-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathrun.liquid
More file actions
57 lines (50 loc) · 1.52 KB
/
run.liquid
File metadata and controls
57 lines (50 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{%- if flavor contains "vanilla-js" -%}
// @ts-check
/**
* @typedef {import("../generated/api").RunInput} RunInput
* @typedef {import("../generated/api").CartFulfillmentGroupsLocationRankingsGenerateRunResult} CartFulfillmentGroupsLocationRankingsGenerateRunResult
*/
/**
* @param {RunInput} input
* @returns {CartFulfillmentGroupsLocationRankingsGenerateRunResult}
*/
export function run(input) {
const operations = input.fulfillmentGroups.map((group) => {
const rankings = group.inventoryLocationHandles?.map((inventoryLocationHandle) => ({
locationHandle: inventoryLocationHandle,
rank: 0,
})) || [];
return {
fulfillment_group_location_ranking_add {
fulfillmentGroupHandle: group.handle,
rankings,
},
};
});
return {operations};
};
{%- elsif flavor contains "typescript" -%}
import type {
RunInput,
CartFulfillmentGroupsLocationRankingsGenerateRunResult,
Operation,
RankedLocation,
} from "../generated/api";
export function run(input: RunInput): CartFulfillmentGroupsLocationRankingsGenerateRunResult {
const operations: Operation[] = input.fulfillmentGroups.map((group) => {
const rankings: RankedLocation[] = group.inventoryLocationHandles?.map(
(inventoryLocationHandle) => ({
locationHandle: inventoryLocationHandle,
rank: 0,
}),
) || [];
return {
fulfillment_group_location_ranking_add {
fulfillmentGroupHandle: group.handle,
rankings,
},
};
});
return {operations};
};
{%- endif -%}