arky-sdk 0.4.76 → 0.4.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,11 +19,11 @@ interface VariantWithInventory {
19
19
  inventory: InventoryLevel[];
20
20
  }
21
21
  /**
22
- * Get total available stock across all fulfillment centers for a variant
22
+ * Get total available stock across all locations for a variant
23
23
  */
24
24
  declare function getAvailableStock(variant: VariantWithInventory): number;
25
25
  /**
26
- * Get total reserved stock across all fulfillment centers for a variant
26
+ * Get total reserved stock across all locations for a variant
27
27
  */
28
28
  declare function getReservedStock(variant: VariantWithInventory): number;
29
29
  /**
@@ -31,12 +31,12 @@ declare function getReservedStock(variant: VariantWithInventory): number;
31
31
  */
32
32
  declare function hasStock(variant: VariantWithInventory, quantity?: number): boolean;
33
33
  /**
34
- * Get inventory level at a specific fulfillment center
34
+ * Get inventory level at a specific location
35
35
  */
36
- declare function getInventoryAt(variant: VariantWithInventory, fulfillmentCenterId: string): InventoryLevel | undefined;
36
+ declare function getInventoryAt(variant: VariantWithInventory, locationId: string): InventoryLevel | undefined;
37
37
  /**
38
- * Get the first fulfillment center with available stock
39
- * Returns the fulfillmentCenterId of the first center that has stock
38
+ * Get the first location with available stock
39
+ * Returns the locationId of the first location that has stock
40
40
  */
41
41
  declare function getFirstAvailableFCId(variant: VariantWithInventory, quantity?: number): string | undefined;
42
42
 
@@ -19,11 +19,11 @@ interface VariantWithInventory {
19
19
  inventory: InventoryLevel[];
20
20
  }
21
21
  /**
22
- * Get total available stock across all fulfillment centers for a variant
22
+ * Get total available stock across all locations for a variant
23
23
  */
24
24
  declare function getAvailableStock(variant: VariantWithInventory): number;
25
25
  /**
26
- * Get total reserved stock across all fulfillment centers for a variant
26
+ * Get total reserved stock across all locations for a variant
27
27
  */
28
28
  declare function getReservedStock(variant: VariantWithInventory): number;
29
29
  /**
@@ -31,12 +31,12 @@ declare function getReservedStock(variant: VariantWithInventory): number;
31
31
  */
32
32
  declare function hasStock(variant: VariantWithInventory, quantity?: number): boolean;
33
33
  /**
34
- * Get inventory level at a specific fulfillment center
34
+ * Get inventory level at a specific location
35
35
  */
36
- declare function getInventoryAt(variant: VariantWithInventory, fulfillmentCenterId: string): InventoryLevel | undefined;
36
+ declare function getInventoryAt(variant: VariantWithInventory, locationId: string): InventoryLevel | undefined;
37
37
  /**
38
- * Get the first fulfillment center with available stock
39
- * Returns the fulfillmentCenterId of the first center that has stock
38
+ * Get the first location with available stock
39
+ * Returns the locationId of the first location that has stock
40
40
  */
41
41
  declare function getFirstAvailableFCId(variant: VariantWithInventory, quantity?: number): string | undefined;
42
42
 
package/dist/index.cjs CHANGED
@@ -578,7 +578,7 @@ function formatBlockValue(block) {
578
578
  function prepareBlocksForSubmission(formData, blockTypes) {
579
579
  return Object.keys(formData).filter((key) => formData[key] !== null && formData[key] !== void 0).map((key) => ({
580
580
  key,
581
- value: blockTypes?.[key] === "block" && !Array.isArray(formData[key]) ? [formData[key]] : formData[key]
581
+ value: blockTypes?.[key] === "list" && !Array.isArray(formData[key]) ? [formData[key]] : formData[key]
582
582
  }));
583
583
  }
584
584
  function extractBlockValues(blocks) {
@@ -605,14 +605,14 @@ var getBlockTextValue = (block, locale = "en") => {
605
605
  var getBlockValues = (entry, blockKey) => {
606
606
  const block = entry?.blocks?.find((f) => f.key === blockKey);
607
607
  if (!block) return [];
608
- if (block.type === "block" && Array.isArray(block.value)) {
608
+ if (block.type === "list" && Array.isArray(block.value)) {
609
609
  return block.value;
610
610
  }
611
611
  return [];
612
612
  };
613
613
  function unwrapBlock(block, locale) {
614
614
  if (!block?.type || block.value === void 0) return block;
615
- if (block.type === "block") {
615
+ if (block.type === "list") {
616
616
  return block.value.map((obj) => {
617
617
  const parsed = {};
618
618
  for (const [k, v] of Object.entries(obj)) {
@@ -621,6 +621,13 @@ function unwrapBlock(block, locale) {
621
621
  return parsed;
622
622
  });
623
623
  }
624
+ if (block.type === "map") {
625
+ const parsed = {};
626
+ for (const [k, v] of Object.entries(block.value || {})) {
627
+ parsed[k] = unwrapBlock(v, locale);
628
+ }
629
+ return parsed;
630
+ }
624
631
  if (block.type === "text_filter" || block.type === "number_filter") {
625
632
  return block.value;
626
633
  }
@@ -631,7 +638,7 @@ function unwrapBlock(block, locale) {
631
638
  }
632
639
  var getBlockObjectValues = (entry, blockKey, locale = "en") => {
633
640
  const block = entry?.blocks?.find((f) => f.key === blockKey);
634
- if (!block || block.type !== "block" || !Array.isArray(block.value)) return [];
641
+ if (!block || block.type !== "list" || !Array.isArray(block.value)) return [];
635
642
  return block.value.map((obj) => {
636
643
  if (!obj?.value || !Array.isArray(obj.value)) return {};
637
644
  return obj.value.reduce((acc, current) => {
@@ -643,12 +650,19 @@ var getBlockObjectValues = (entry, blockKey, locale = "en") => {
643
650
  var getBlockFromArray = (entry, blockKey, locale = "en") => {
644
651
  const block = entry?.blocks?.find((f) => f.key === blockKey);
645
652
  if (!block) return {};
646
- if (block.type === "block" && Array.isArray(block.value)) {
653
+ if (block.type === "list" && Array.isArray(block.value)) {
647
654
  return block.value.reduce((acc, current) => {
648
655
  acc[current.key] = unwrapBlock(current, locale);
649
656
  return acc;
650
657
  }, {});
651
658
  }
659
+ if (block.type === "map" && block.value && typeof block.value === "object") {
660
+ const result = {};
661
+ for (const [k, v] of Object.entries(block.value)) {
662
+ result[k] = unwrapBlock(v, locale);
663
+ }
664
+ return result;
665
+ }
652
666
  return { [block.key]: unwrapBlock(block, locale) };
653
667
  };
654
668
  var getImageUrl = (imageBlock, isBlock = true) => {
@@ -750,12 +764,6 @@ var createCmsApi = (apiConfig) => {
750
764
  params,
751
765
  options
752
766
  );
753
- },
754
- async getVariableMetadata(params, options) {
755
- return apiConfig.httpClient.get(
756
- `/v1/businesses/${apiConfig.businessId}/nodes/types/${params.nodeType}/variables`,
757
- options
758
- );
759
767
  }
760
768
  };
761
769
  };
@@ -1247,6 +1255,24 @@ var createWorkflowApi = (apiConfig) => {
1247
1255
  async triggerWorkflow(params, options) {
1248
1256
  const { secret, ...payload } = params;
1249
1257
  return apiConfig.httpClient.post(`/v1/workflows/trigger/${secret}`, payload, options);
1258
+ },
1259
+ async getWorkflowExecutions(params, options) {
1260
+ const businessId = params.businessId || apiConfig.businessId;
1261
+ const { businessId: _, workflowId, ...queryParams } = params;
1262
+ return apiConfig.httpClient.get(
1263
+ `/v1/businesses/${businessId}/workflows/${workflowId}/executions`,
1264
+ {
1265
+ ...options,
1266
+ params: Object.keys(queryParams).length > 0 ? queryParams : void 0
1267
+ }
1268
+ );
1269
+ },
1270
+ async getWorkflowExecution(params, options) {
1271
+ const businessId = params.businessId || apiConfig.businessId;
1272
+ return apiConfig.httpClient.get(
1273
+ `/v1/businesses/${businessId}/workflows/${params.workflowId}/executions/${params.executionId}`,
1274
+ options
1275
+ );
1250
1276
  }
1251
1277
  };
1252
1278
  };
@@ -1661,12 +1687,12 @@ function getReservedStock(variant) {
1661
1687
  function hasStock(variant, quantity = 1) {
1662
1688
  return getAvailableStock(variant) >= quantity;
1663
1689
  }
1664
- function getInventoryAt(variant, fulfillmentCenterId) {
1665
- return variant?.inventory?.find((inv) => inv.fulfillmentCenterId === fulfillmentCenterId);
1690
+ function getInventoryAt(variant, locationId) {
1691
+ return variant?.inventory?.find((inv) => inv.locationId === locationId);
1666
1692
  }
1667
1693
  function getFirstAvailableFCId(variant, quantity = 1) {
1668
1694
  const inv = variant?.inventory?.find((i) => i.available >= quantity);
1669
- return inv?.fulfillmentCenterId;
1695
+ return inv?.locationId;
1670
1696
  }
1671
1697
 
1672
1698
  // src/index.ts