arky-sdk 0.5.0 → 0.5.2

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.
@@ -1,4 +1,4 @@
1
- import { Payment, InventoryLevel } from './types.cjs';
1
+ import { Payment, InventoryLevel, BusinessConfig } from './types.js';
2
2
 
3
3
  declare function convertToMajor(minorAmount: number, currency: string): number;
4
4
  declare function convertToMinor(majorAmount: number, currency: string): number;
@@ -40,4 +40,12 @@ declare function getInventoryAt(variant: VariantWithInventory, locationId: strin
40
40
  */
41
41
  declare function getFirstAvailableFCId(variant: VariantWithInventory, quantity?: number): string | undefined;
42
42
 
43
- export { formatMinor as a, getCurrencyName as b, getAvailableStock as c, getReservedStock as d, getInventoryAt as e, formatPayment as f, getCurrencySymbol as g, hasStock as h, isValidKey as i, getFirstAvailableFCId as j, convertToMajor as k, convertToMinor as l, nameToKey as n, toKey as t, validateKey as v };
43
+ declare function getPaymentConfig(configs: BusinessConfig): {
44
+ publishableKey: string;
45
+ currency: string;
46
+ } | null;
47
+ declare function getAnalyticsConfigs(configs: BusinessConfig): {
48
+ measurementId: string;
49
+ }[];
50
+
51
+ export { formatMinor as a, getCurrencyName as b, getAvailableStock as c, getReservedStock as d, getInventoryAt as e, formatPayment as f, getCurrencySymbol as g, hasStock as h, isValidKey as i, getFirstAvailableFCId as j, getPaymentConfig as k, getAnalyticsConfigs as l, convertToMajor as m, nameToKey as n, convertToMinor as o, toKey as t, validateKey as v };
@@ -1,4 +1,4 @@
1
- import { Payment, InventoryLevel } from './types.js';
1
+ import { Payment, InventoryLevel, BusinessConfig } from './types.cjs';
2
2
 
3
3
  declare function convertToMajor(minorAmount: number, currency: string): number;
4
4
  declare function convertToMinor(majorAmount: number, currency: string): number;
@@ -40,4 +40,12 @@ declare function getInventoryAt(variant: VariantWithInventory, locationId: strin
40
40
  */
41
41
  declare function getFirstAvailableFCId(variant: VariantWithInventory, quantity?: number): string | undefined;
42
42
 
43
- export { formatMinor as a, getCurrencyName as b, getAvailableStock as c, getReservedStock as d, getInventoryAt as e, formatPayment as f, getCurrencySymbol as g, hasStock as h, isValidKey as i, getFirstAvailableFCId as j, convertToMajor as k, convertToMinor as l, nameToKey as n, toKey as t, validateKey as v };
43
+ declare function getPaymentConfig(configs: BusinessConfig): {
44
+ publishableKey: string;
45
+ currency: string;
46
+ } | null;
47
+ declare function getAnalyticsConfigs(configs: BusinessConfig): {
48
+ measurementId: string;
49
+ }[];
50
+
51
+ export { formatMinor as a, getCurrencyName as b, getAvailableStock as c, getReservedStock as d, getInventoryAt as e, formatPayment as f, getCurrencySymbol as g, hasStock as h, isValidKey as i, getFirstAvailableFCId as j, getPaymentConfig as k, getAnalyticsConfigs as l, convertToMajor as m, nameToKey as n, convertToMinor as o, toKey as t, validateKey as v };
package/dist/index.cjs CHANGED
@@ -1121,11 +1121,11 @@ var createDatabaseApi = (apiConfig) => {
1121
1121
  var createLocationApi = (apiConfig) => {
1122
1122
  return {
1123
1123
  async getCountries(options) {
1124
- return apiConfig.httpClient.get(`/v1/platform/location/countries`, options);
1124
+ return apiConfig.httpClient.get(`/v1/platform/countries`, options);
1125
1125
  },
1126
- async getCountryStates(countryCode, options) {
1126
+ async getCountry(countryCode, options) {
1127
1127
  return apiConfig.httpClient.get(
1128
- `/v1/platform/location/countries/${countryCode}/states`,
1128
+ `/v1/platform/countries/${countryCode}`,
1129
1129
  options
1130
1130
  );
1131
1131
  }
@@ -1356,8 +1356,8 @@ var createPlatformApi = (apiConfig) => {
1356
1356
  async getCurrencies(options) {
1357
1357
  return apiConfig.httpClient.get("/v1/platform/currencies", options);
1358
1358
  },
1359
- async getWorkflowIntegrations(options) {
1360
- return apiConfig.httpClient.get("/v1/platform/workflow/integrations", options);
1359
+ async getIntegrationCatalogue(options) {
1360
+ return apiConfig.httpClient.get("/v1/platform/integration-catalogue", options);
1361
1361
  }
1362
1362
  };
1363
1363
  };
@@ -1414,7 +1414,7 @@ function createEventsApi(apiConfig) {
1414
1414
  );
1415
1415
  },
1416
1416
  async getWebhookEvents(options) {
1417
- return apiConfig.httpClient.get(`/v1/platform/events/metadata`, options);
1417
+ return apiConfig.httpClient.get(`/v1/platform/events`, options);
1418
1418
  }
1419
1419
  };
1420
1420
  }
@@ -1688,6 +1688,22 @@ function getFirstAvailableFCId(variant, quantity = 1) {
1688
1688
  return inv?.locationId;
1689
1689
  }
1690
1690
 
1691
+ // src/utils/integrations.ts
1692
+ function getPaymentConfig(configs) {
1693
+ if (!configs.paymentId) return null;
1694
+ const i = configs.integrations?.find((i2) => i2.id === configs.paymentId);
1695
+ if (!i || i.provider?.type !== "stripe") return null;
1696
+ return { publishableKey: i.provider.publishableKey, currency: i.provider.currency };
1697
+ }
1698
+ function getAnalyticsConfigs(configs) {
1699
+ return (configs.analyticsIds || []).map((id) => configs.integrations?.find((i) => i.id === id)).filter((i) => !!i && i.provider?.type === "google_analytics4").map((i) => {
1700
+ if (i.provider.type === "google_analytics4") {
1701
+ return { measurementId: i.provider.measurementId };
1702
+ }
1703
+ return null;
1704
+ }).filter(Boolean);
1705
+ }
1706
+
1691
1707
  // src/index.ts
1692
1708
  var SDK_VERSION = "0.4.74";
1693
1709
  var SUPPORTED_FRAMEWORKS = [
@@ -1715,9 +1731,12 @@ async function createArkySDK(config) {
1715
1731
  const platformApi = createPlatformApi(apiConfig);
1716
1732
  if (typeof window !== "undefined") {
1717
1733
  businessApi.getBusiness({}).then(({ data: business }) => {
1718
- for (const a of business?.config?.analytics || []) {
1719
- if (a.provider === "google_analytics4") {
1720
- injectGA4Script(a.measurementId);
1734
+ const configs = business?.configs || business?.config;
1735
+ if (configs?.integrations) {
1736
+ for (const i of configs.integrations) {
1737
+ if (i.provider?.type === "google_analytics4") {
1738
+ injectGA4Script(i.provider.measurementId);
1739
+ }
1721
1740
  }
1722
1741
  }
1723
1742
  }).catch(() => {
@@ -1796,7 +1815,9 @@ async function createArkySDK(config) {
1796
1815
  getReservedStock,
1797
1816
  hasStock,
1798
1817
  getInventoryAt,
1799
- getFirstAvailableFCId
1818
+ getFirstAvailableFCId,
1819
+ getPaymentConfig,
1820
+ getAnalyticsConfigs
1800
1821
  }
1801
1822
  };
1802
1823
  return sdk;