arky-sdk 0.3.29 → 0.3.31
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.cjs +53 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +53 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -517,6 +517,21 @@ var createAnalyticsApi = (apiConfig) => {
|
|
|
517
517
|
};
|
|
518
518
|
};
|
|
519
519
|
|
|
520
|
+
// src/utils/slug.ts
|
|
521
|
+
var isUuid = (str) => {
|
|
522
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
523
|
+
return uuidRegex.test(str);
|
|
524
|
+
};
|
|
525
|
+
var formatIdOrSlug = (id, apiConfig) => {
|
|
526
|
+
if (isUuid(id)) {
|
|
527
|
+
return id;
|
|
528
|
+
}
|
|
529
|
+
if (id.includes(":")) {
|
|
530
|
+
return id;
|
|
531
|
+
}
|
|
532
|
+
return `${apiConfig.businessId}:${apiConfig.locale}:${id}`;
|
|
533
|
+
};
|
|
534
|
+
|
|
520
535
|
// src/api/cms.ts
|
|
521
536
|
var createCmsApi = (apiConfig) => {
|
|
522
537
|
return {
|
|
@@ -542,8 +557,9 @@ var createCmsApi = (apiConfig) => {
|
|
|
542
557
|
);
|
|
543
558
|
},
|
|
544
559
|
async getCollection(params, options) {
|
|
560
|
+
const formattedId = formatIdOrSlug(params.id, apiConfig);
|
|
545
561
|
return apiConfig.httpClient.get(
|
|
546
|
-
`/v1/businesses/${apiConfig.businessId}/collections/${
|
|
562
|
+
`/v1/businesses/${apiConfig.businessId}/collections/${formattedId}`,
|
|
547
563
|
options
|
|
548
564
|
);
|
|
549
565
|
},
|
|
@@ -607,8 +623,9 @@ var createCmsApi = (apiConfig) => {
|
|
|
607
623
|
);
|
|
608
624
|
},
|
|
609
625
|
async getCollectionEntry(params, options) {
|
|
626
|
+
const formattedId = formatIdOrSlug(params.id, apiConfig);
|
|
610
627
|
return apiConfig.httpClient.get(
|
|
611
|
-
`/v1/businesses/${apiConfig.businessId}/entries/${
|
|
628
|
+
`/v1/businesses/${apiConfig.businessId}/entries/${formattedId}`,
|
|
612
629
|
options
|
|
613
630
|
);
|
|
614
631
|
},
|
|
@@ -633,8 +650,9 @@ var createCmsApi = (apiConfig) => {
|
|
|
633
650
|
},
|
|
634
651
|
// ===== COLLECTION SUBSCRIPTIONS =====
|
|
635
652
|
async getCollectionSubscribers(params, options) {
|
|
653
|
+
const formattedId = formatIdOrSlug(params.id, apiConfig);
|
|
636
654
|
return apiConfig.httpClient.get(
|
|
637
|
-
`/v1/businesses/${apiConfig.businessId}/collections/${
|
|
655
|
+
`/v1/businesses/${apiConfig.businessId}/collections/${formattedId}/subscribers`,
|
|
638
656
|
options
|
|
639
657
|
);
|
|
640
658
|
},
|
|
@@ -650,10 +668,13 @@ var createCmsApi = (apiConfig) => {
|
|
|
650
668
|
);
|
|
651
669
|
},
|
|
652
670
|
async unsubscribeFromCollection(params, options) {
|
|
653
|
-
return apiConfig.httpClient.get(
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
671
|
+
return apiConfig.httpClient.get(
|
|
672
|
+
`/v1/businesses/${apiConfig.businessId}/collections/unsubscribe`,
|
|
673
|
+
{
|
|
674
|
+
...options,
|
|
675
|
+
params
|
|
676
|
+
}
|
|
677
|
+
);
|
|
657
678
|
}
|
|
658
679
|
};
|
|
659
680
|
};
|
|
@@ -683,8 +704,9 @@ var createEshopApi = (apiConfig) => {
|
|
|
683
704
|
);
|
|
684
705
|
},
|
|
685
706
|
async getProduct(params, options) {
|
|
707
|
+
const formattedId = formatIdOrSlug(params.id, apiConfig);
|
|
686
708
|
return apiConfig.httpClient.get(
|
|
687
|
-
`/v1/businesses/${apiConfig.businessId}/products/${
|
|
709
|
+
`/v1/businesses/${apiConfig.businessId}/products/${formattedId}`,
|
|
688
710
|
options
|
|
689
711
|
);
|
|
690
712
|
},
|
|
@@ -755,7 +777,9 @@ var createEshopApi = (apiConfig) => {
|
|
|
755
777
|
currency: params.currency,
|
|
756
778
|
paymentMethod: params.paymentMethod,
|
|
757
779
|
lines,
|
|
758
|
-
...params.shippingMethodId && {
|
|
780
|
+
...params.shippingMethodId && {
|
|
781
|
+
shippingMethodId: params.shippingMethodId
|
|
782
|
+
},
|
|
759
783
|
...params.promoCode && { promoCode: params.promoCode }
|
|
760
784
|
};
|
|
761
785
|
return apiConfig.httpClient.post(`/v1/payments/quote`, payload, options);
|
|
@@ -793,7 +817,11 @@ var createReservationApi = (apiConfig) => {
|
|
|
793
817
|
},
|
|
794
818
|
async updateReservation(params, options) {
|
|
795
819
|
const { id, ...payload } = params;
|
|
796
|
-
return apiConfig.httpClient.put(
|
|
820
|
+
return apiConfig.httpClient.put(
|
|
821
|
+
`/v1/reservations/${id}`,
|
|
822
|
+
payload,
|
|
823
|
+
options
|
|
824
|
+
);
|
|
797
825
|
},
|
|
798
826
|
async checkout(params, options) {
|
|
799
827
|
const payload = {
|
|
@@ -804,7 +832,11 @@ var createReservationApi = (apiConfig) => {
|
|
|
804
832
|
...params.paymentMethod && { paymentMethod: params.paymentMethod },
|
|
805
833
|
...params.promoCode && { promoCode: params.promoCode }
|
|
806
834
|
};
|
|
807
|
-
return apiConfig.httpClient.post(
|
|
835
|
+
return apiConfig.httpClient.post(
|
|
836
|
+
`/v1/reservations/checkout`,
|
|
837
|
+
payload,
|
|
838
|
+
options
|
|
839
|
+
);
|
|
808
840
|
},
|
|
809
841
|
async getReservation(params, options) {
|
|
810
842
|
return apiConfig.httpClient.get(`/v1/reservations/${params.id}`, {
|
|
@@ -872,8 +904,9 @@ var createReservationApi = (apiConfig) => {
|
|
|
872
904
|
);
|
|
873
905
|
},
|
|
874
906
|
async getService(params, options) {
|
|
907
|
+
const formattedId = formatIdOrSlug(params.id, apiConfig);
|
|
875
908
|
return apiConfig.httpClient.get(
|
|
876
|
-
`/v1/businesses/${apiConfig.businessId}/services/${
|
|
909
|
+
`/v1/businesses/${apiConfig.businessId}/services/${formattedId}`,
|
|
877
910
|
options
|
|
878
911
|
);
|
|
879
912
|
},
|
|
@@ -1489,7 +1522,7 @@ async function injectSvgIntoElement(mediaObject, targetElement, className) {
|
|
|
1489
1522
|
}
|
|
1490
1523
|
|
|
1491
1524
|
// src/index.ts
|
|
1492
|
-
var SDK_VERSION = "0.3.
|
|
1525
|
+
var SDK_VERSION = "0.3.30";
|
|
1493
1526
|
var SUPPORTED_FRAMEWORKS = [
|
|
1494
1527
|
"astro",
|
|
1495
1528
|
"react",
|
|
@@ -1498,8 +1531,9 @@ var SUPPORTED_FRAMEWORKS = [
|
|
|
1498
1531
|
"vanilla"
|
|
1499
1532
|
];
|
|
1500
1533
|
function createArkySDK(config) {
|
|
1534
|
+
const locale = config.locale || "en";
|
|
1501
1535
|
console.log(
|
|
1502
|
-
`[Arky SDK v${SDK_VERSION}] Initializing with market: ${config.market}, businessId: ${config.businessId}`
|
|
1536
|
+
`[Arky SDK v${SDK_VERSION}] Initializing with market: ${config.market}, businessId: ${config.businessId}, locale: ${locale}`
|
|
1503
1537
|
);
|
|
1504
1538
|
const httpClient = createHttpClient(config);
|
|
1505
1539
|
const storageUrl = config.storageUrl || "https://storage.arky.io/dev";
|
|
@@ -1509,6 +1543,7 @@ function createArkySDK(config) {
|
|
|
1509
1543
|
storageUrl,
|
|
1510
1544
|
baseUrl: config.baseUrl,
|
|
1511
1545
|
market: config.market,
|
|
1546
|
+
locale,
|
|
1512
1547
|
setToken: config.setToken,
|
|
1513
1548
|
getToken: config.getToken
|
|
1514
1549
|
};
|
|
@@ -1534,6 +1569,10 @@ function createArkySDK(config) {
|
|
|
1534
1569
|
apiConfig.market = market;
|
|
1535
1570
|
},
|
|
1536
1571
|
getMarket: () => apiConfig.market,
|
|
1572
|
+
setLocale: (locale2) => {
|
|
1573
|
+
apiConfig.locale = locale2;
|
|
1574
|
+
},
|
|
1575
|
+
getLocale: () => apiConfig.locale,
|
|
1537
1576
|
isAuthenticated: config.isAuthenticated || (() => false),
|
|
1538
1577
|
logout: config.logout,
|
|
1539
1578
|
setToken: config.setToken,
|