arky-sdk 0.5.26 → 0.5.27

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, Integration } from './types.js';
1
+ import { Payment, InventoryLevel } 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,12 +40,4 @@ declare function getInventoryAt(variant: VariantWithInventory, locationId: strin
40
40
  */
41
41
  declare function getFirstAvailableFCId(variant: VariantWithInventory, quantity?: number): string | undefined;
42
42
 
43
- declare function getPaymentConfig(integrations: Integration[]): {
44
- publishableKey: string;
45
- currency: string;
46
- } | null;
47
- declare function getAnalyticsConfigs(integrations: Integration[]): {
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 };
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 };
@@ -1,4 +1,4 @@
1
- import { Payment, InventoryLevel, Integration } from './types.cjs';
1
+ import { Payment, InventoryLevel } 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,12 +40,4 @@ declare function getInventoryAt(variant: VariantWithInventory, locationId: strin
40
40
  */
41
41
  declare function getFirstAvailableFCId(variant: VariantWithInventory, quantity?: number): string | undefined;
42
42
 
43
- declare function getPaymentConfig(integrations: Integration[]): {
44
- publishableKey: string;
45
- currency: string;
46
- } | null;
47
- declare function getAnalyticsConfigs(integrations: Integration[]): {
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 };
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 };
package/dist/index.cjs CHANGED
@@ -441,15 +441,9 @@ var createBusinessApi = (apiConfig) => {
441
441
  options
442
442
  );
443
443
  },
444
- async getPaymentConfig(params, options) {
444
+ async getIntegrationConfig(params, options) {
445
445
  return apiConfig.httpClient.get(
446
- `/v1/businesses/${params.businessId}/integrations/payment`,
447
- options
448
- );
449
- },
450
- async getShippingConfig(params, options) {
451
- return apiConfig.httpClient.get(
452
- `/v1/businesses/${params.businessId}/integrations/shipping`,
446
+ `/v1/businesses/${params.businessId}/integrations/config/${params.type}`,
453
447
  options
454
448
  );
455
449
  }
@@ -1723,23 +1717,8 @@ function getFirstAvailableFCId(variant, quantity = 1) {
1723
1717
  return inv?.locationId;
1724
1718
  }
1725
1719
 
1726
- // src/utils/integrations.ts
1727
- function getPaymentConfig(integrations) {
1728
- const i = integrations?.find((i2) => i2.provider?.type === "stripe" && i2.provider.activeForCardPayments);
1729
- if (!i || i.provider?.type !== "stripe") return null;
1730
- return { publishableKey: i.provider.publishableKey, currency: i.provider.currency };
1731
- }
1732
- function getAnalyticsConfigs(integrations) {
1733
- return (integrations || []).filter((i) => i.provider?.type === "google_analytics4" && i.provider.activeForTracking).map((i) => {
1734
- if (i.provider.type === "google_analytics4") {
1735
- return { measurementId: i.provider.measurementId };
1736
- }
1737
- return null;
1738
- }).filter(Boolean);
1739
- }
1740
-
1741
1720
  // src/index.ts
1742
- var SDK_VERSION = "0.5.25";
1721
+ var SDK_VERSION = "0.5.27";
1743
1722
  var SUPPORTED_FRAMEWORKS = [
1744
1723
  "astro",
1745
1724
  "react",
@@ -1764,13 +1743,11 @@ async function createArkySDK(config) {
1764
1743
  const businessApi = createBusinessApi(apiConfig);
1765
1744
  const platformApi = createPlatformApi(apiConfig);
1766
1745
  if (typeof window !== "undefined") {
1767
- businessApi.getBusiness({}).then(({ data: business }) => {
1768
- const configs = business?.configs || business?.config;
1769
- if (configs?.integrations) {
1770
- for (const i of configs.integrations) {
1771
- if (i.provider?.type === "google_analytics4") {
1772
- injectGA4Script(i.provider.measurementId);
1773
- }
1746
+ businessApi.getIntegrationConfig({ businessId: apiConfig.businessId, type: "analytics" }).then((configs) => {
1747
+ if (!configs) return;
1748
+ for (const c of Array.isArray(configs) ? configs : [configs]) {
1749
+ if (c.measurementId) {
1750
+ injectGA4Script(c.measurementId);
1774
1751
  }
1775
1752
  }
1776
1753
  }).catch(() => {
@@ -1848,9 +1825,7 @@ async function createArkySDK(config) {
1848
1825
  getReservedStock,
1849
1826
  hasStock,
1850
1827
  getInventoryAt,
1851
- getFirstAvailableFCId,
1852
- getPaymentConfig,
1853
- getAnalyticsConfigs
1828
+ getFirstAvailableFCId
1854
1829
  }
1855
1830
  };
1856
1831
  return sdk;