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.
- package/dist/{index-Cjdv3omy.d.cts → index-BfZKq1T6.d.ts} +10 -2
- package/dist/{index-UQfW3UpN.d.ts → index-Bz8k50In.d.cts} +10 -2
- package/dist/index.cjs +31 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +31 -10
- package/dist/index.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +47 -32
- package/dist/types.d.ts +47 -32
- package/dist/types.js.map +1 -1
- package/dist/utils.cjs +18 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +17 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Payment, InventoryLevel } from './types.
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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/
|
|
1124
|
+
return apiConfig.httpClient.get(`/v1/platform/countries`, options);
|
|
1125
1125
|
},
|
|
1126
|
-
async
|
|
1126
|
+
async getCountry(countryCode, options) {
|
|
1127
1127
|
return apiConfig.httpClient.get(
|
|
1128
|
-
`/v1/platform/
|
|
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
|
|
1360
|
-
return apiConfig.httpClient.get("/v1/platform/
|
|
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
|
|
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
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
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;
|