1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "snapshotId": "promo-2026-10-02",
12 "stockPoolId": "warehouse-main",
13 "asOf": "2026-10-02T06:00:00Z",
14 "inventoryCoverage": "complete",
15 "demandCoverage": "complete",
16 "missingInventoryPolicy": "unresolved",
17 "inventory": [
18 {
19 "recordId": "stock-01",
20 "componentSku": "001",
21 "availableUnits": 10
22 },
23 {
24 "recordId": "stock-02",
25 "componentSku": "002",
26 "availableUnits": 8
27 },
28 {
29 "recordId": "stock-03",
30 "componentSku": "003",
31 "availableUnits": 6
32 }
33 ],
34 "inventoryCsv": "",
35 "inventoryColumns": {
36 "recordId": "recordId",
37 "componentSku": "componentSku",
38 "availableUnits": "availableUnits"
39 },
40 "bom": [
41 {
42 "recordId": "bom-01",
43 "bundleSku": "gift-a",
44 "componentSku": "001",
45 "unitsPerBundle": 2
46 },
47 {
48 "recordId": "bom-02",
49 "bundleSku": "gift-a",
50 "componentSku": "002",
51 "unitsPerBundle": 1
52 },
53 {
54 "recordId": "bom-03",
55 "bundleSku": "gift-b",
56 "componentSku": "001",
57 "unitsPerBundle": 1
58 },
59 {
60 "recordId": "bom-04",
61 "bundleSku": "gift-b",
62 "componentSku": "003",
63 "unitsPerBundle": 2
64 }
65 ],
66 "bomCsv": "",
67 "bomColumns": {
68 "recordId": "recordId",
69 "bundleSku": "bundleSku",
70 "componentSku": "componentSku",
71 "unitsPerBundle": "unitsPerBundle"
72 },
73 "demand": [
74 {
75 "recordId": "plan-01",
76 "itemType": "bundle",
77 "sku": "gift-a",
78 "quantity": 4
79 },
80 {
81 "recordId": "plan-02",
82 "itemType": "bundle",
83 "sku": "gift-b",
84 "quantity": 3
85 },
86 {
87 "recordId": "plan-03",
88 "itemType": "component",
89 "sku": "001",
90 "quantity": 2
91 }
92 ],
93 "demandCsv": "",
94 "demandColumns": {
95 "recordId": "recordId",
96 "itemType": "itemType",
97 "sku": "sku",
98 "quantity": "quantity"
99 }
100};
101
102
103const run = await client.actor("h_murdock/bundle-component-demand-audit").call(input);
104
105
106console.log('Results from dataset');
107console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
108const { items } = await client.dataset(run.defaultDatasetId).listItems();
109items.forEach((item) => {
110 console.dir(item);
111});
112
113