arky-sdk 0.3.29 → 0.3.32

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.d.cts CHANGED
@@ -22,7 +22,7 @@ interface HttpClientConfig {
22
22
  isAuthenticated?: () => boolean;
23
23
  }
24
24
 
25
- declare const SDK_VERSION = "0.3.28";
25
+ declare const SDK_VERSION = "0.3.30";
26
26
  declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
27
27
  interface ApiConfig {
28
28
  httpClient: any;
@@ -30,12 +30,14 @@ interface ApiConfig {
30
30
  storageUrl: string;
31
31
  baseUrl: string;
32
32
  market: string;
33
+ locale: string;
33
34
  setToken: (tokens: any) => void;
34
35
  getToken: () => Promise<any> | any;
35
36
  }
36
37
 
37
38
  declare function createArkySDK(config: HttpClientConfig & {
38
39
  market: string;
40
+ locale?: string;
39
41
  }): {
40
42
  user: {
41
43
  updateUser(params: UpdateUserProfileParams, options?: RequestOptions): Promise<any>;
@@ -163,6 +165,8 @@ declare function createArkySDK(config: HttpClientConfig & {
163
165
  getBusinessId: () => string;
164
166
  setMarket: (market: string) => void;
165
167
  getMarket: () => string;
168
+ setLocale: (locale: string) => void;
169
+ getLocale: () => string;
166
170
  isAuthenticated: () => boolean;
167
171
  logout: () => void;
168
172
  setToken: (tokens: AuthTokens) => void;
package/dist/index.d.ts CHANGED
@@ -22,7 +22,7 @@ interface HttpClientConfig {
22
22
  isAuthenticated?: () => boolean;
23
23
  }
24
24
 
25
- declare const SDK_VERSION = "0.3.28";
25
+ declare const SDK_VERSION = "0.3.30";
26
26
  declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
27
27
  interface ApiConfig {
28
28
  httpClient: any;
@@ -30,12 +30,14 @@ interface ApiConfig {
30
30
  storageUrl: string;
31
31
  baseUrl: string;
32
32
  market: string;
33
+ locale: string;
33
34
  setToken: (tokens: any) => void;
34
35
  getToken: () => Promise<any> | any;
35
36
  }
36
37
 
37
38
  declare function createArkySDK(config: HttpClientConfig & {
38
39
  market: string;
40
+ locale?: string;
39
41
  }): {
40
42
  user: {
41
43
  updateUser(params: UpdateUserProfileParams, options?: RequestOptions): Promise<any>;
@@ -163,6 +165,8 @@ declare function createArkySDK(config: HttpClientConfig & {
163
165
  getBusinessId: () => string;
164
166
  setMarket: (market: string) => void;
165
167
  getMarket: () => string;
168
+ setLocale: (locale: string) => void;
169
+ getLocale: () => string;
166
170
  isAuthenticated: () => boolean;
167
171
  logout: () => void;
168
172
  setToken: (tokens: AuthTokens) => void;
package/dist/index.js CHANGED
@@ -515,6 +515,193 @@ var createAnalyticsApi = (apiConfig) => {
515
515
  };
516
516
  };
517
517
 
518
+ // src/utils/slug.ts
519
+ var isUuid = (str) => {
520
+ const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
521
+ return uuidRegex.test(str);
522
+ };
523
+ var formatIdOrSlug = (id, apiConfig) => {
524
+ if (isUuid(id)) {
525
+ return id;
526
+ }
527
+ if (id.includes(":")) {
528
+ return id;
529
+ }
530
+ return `${apiConfig.businessId}:${apiConfig.locale}:${id}`;
531
+ };
532
+
533
+ // src/utils/blocks.ts
534
+ function getBlockLabel(block, locale = "en") {
535
+ if (!block) return "";
536
+ if (block.properties?.label) {
537
+ if (typeof block.properties.label === "object") {
538
+ return block.properties.label[locale] || block.properties.label.en || Object.values(block.properties.label)[0] || "";
539
+ }
540
+ if (typeof block.properties.label === "string") {
541
+ return block.properties.label;
542
+ }
543
+ }
544
+ return block.key?.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()) || "";
545
+ }
546
+ function formatBlockValue(block) {
547
+ if (!block || block.value === null || block.value === void 0) {
548
+ return "";
549
+ }
550
+ switch (block.type) {
551
+ case "BOOLEAN":
552
+ return block.value ? "Yes" : "No";
553
+ case "NUMBER":
554
+ if (block.properties?.variant === "DATE" || block.properties?.variant === "DATE_TIME") {
555
+ try {
556
+ return new Date(block.value).toLocaleDateString();
557
+ } catch (e) {
558
+ return String(block.value);
559
+ }
560
+ }
561
+ return String(block.value);
562
+ case "RELATIONSHIP":
563
+ if (Array.isArray(block.value) && block.value.length > 0) {
564
+ const firstValue = block.value[0];
565
+ if (firstValue && firstValue.mimeType) {
566
+ return firstValue.name || firstValue.id || "Media";
567
+ }
568
+ return firstValue.title || firstValue.name || firstValue.id || "Entry";
569
+ }
570
+ return String(block.value);
571
+ default:
572
+ return String(block.value);
573
+ }
574
+ }
575
+ function prepareBlocksForSubmission(formData) {
576
+ const preparedBlocks = [];
577
+ Object.keys(formData).forEach((key) => {
578
+ if (formData[key] !== null && formData[key] !== void 0) {
579
+ preparedBlocks.push({
580
+ key,
581
+ value: [formData[key]]
582
+ });
583
+ }
584
+ });
585
+ return preparedBlocks;
586
+ }
587
+ function extractBlockValues(blocks) {
588
+ const values = {};
589
+ blocks.forEach((block) => {
590
+ if (block.value && block.value.length > 0) {
591
+ values[block.key] = block.value[0];
592
+ } else {
593
+ values[block.key] = null;
594
+ }
595
+ });
596
+ return values;
597
+ }
598
+ function getBlockTextValue(block, locale = "en") {
599
+ if (!block || !block.value || block.value.length === 0) return "";
600
+ const firstValue = block.value[0];
601
+ if (typeof firstValue === "object" && firstValue !== null) {
602
+ if (firstValue[locale]) return firstValue[locale];
603
+ if (firstValue.en) return firstValue.en;
604
+ const values = Object.values(firstValue);
605
+ return String(values[0] || "");
606
+ }
607
+ return String(firstValue);
608
+ }
609
+ var getBlockValue = (entry, blockKey) => {
610
+ if (!entry || !entry.blocks) return null;
611
+ const block = entry.blocks.find((f) => f.key === blockKey);
612
+ if (!block || !block.value || block.value.length === 0) return null;
613
+ return block.value[0];
614
+ };
615
+ var getBlockValues = (entry, blockKey) => {
616
+ if (!entry || !entry.blocks) return null;
617
+ const block = entry.blocks.find((f) => f.key === blockKey);
618
+ if (!block || !block.value || block.value.length === 0) return null;
619
+ return block.value;
620
+ };
621
+ function unwrapBlock(block, locale) {
622
+ if (!block?.type || block.value === void 0) return block;
623
+ if (block.type === "BLOCK") {
624
+ return block.value.map((obj) => {
625
+ const parsed = {};
626
+ for (const [k, v] of Object.entries(obj)) {
627
+ parsed[k] = unwrapBlock(v, locale);
628
+ }
629
+ return parsed;
630
+ });
631
+ }
632
+ const isLocalized = block.type === "TEXT";
633
+ const isList = block.properties?.ui === "list" || (block.properties?.maxValues ?? 1) > 1 || block.value.length > 1;
634
+ if (isList) {
635
+ return isLocalized ? block.value.map((v) => v[locale] || v["en"]) : [...block.value];
636
+ }
637
+ return isLocalized ? block.value[0][locale] || block.value[0]["en"] : block.value[0];
638
+ }
639
+ var getBlockObjectValues = (entry, blockKey, locale = "en") => {
640
+ if (!entry) {
641
+ return [];
642
+ }
643
+ const values = getBlockValues(entry, blockKey);
644
+ const parsed = values.map((obj) => {
645
+ const res = obj.value.reduce((acc, current) => {
646
+ acc[current.key] = unwrapBlock(current, locale);
647
+ return acc;
648
+ }, {});
649
+ return res;
650
+ });
651
+ return parsed;
652
+ };
653
+ var getBlockFromArray = (entry, blockKey, locale = "en") => {
654
+ if (!entry) {
655
+ return [];
656
+ }
657
+ const values = getBlockValues(entry, blockKey);
658
+ return values.reduce((acc, current) => {
659
+ acc[current.key] = unwrapBlock(current, locale);
660
+ return acc;
661
+ });
662
+ };
663
+ var getImageUrl = (imageBlock, isBlock = true, storageUrl = "https://storage.arky.io/dev") => {
664
+ if (!imageBlock) return null;
665
+ const isExternalUrl = (url) => {
666
+ return url.startsWith("http://") || url.startsWith("https://");
667
+ };
668
+ if (imageBlock.type === "RELATIONSHIP" && Array.isArray(imageBlock.value)) {
669
+ const mediaValue = imageBlock.value[0];
670
+ if (mediaValue && mediaValue.mimeType) {
671
+ if (mediaValue.resolutions && mediaValue.resolutions.original && mediaValue.resolutions.original.url) {
672
+ const url = mediaValue.resolutions.original.url;
673
+ return isExternalUrl(url) ? url : `${storageUrl}/${url}`;
674
+ }
675
+ if (mediaValue.url) {
676
+ return isExternalUrl(mediaValue.url) ? mediaValue.url : `${storageUrl}/${mediaValue.url}`;
677
+ }
678
+ }
679
+ return null;
680
+ }
681
+ if (isBlock) {
682
+ if (typeof imageBlock === "string") {
683
+ if (isExternalUrl(imageBlock)) {
684
+ return imageBlock;
685
+ }
686
+ return `${storageUrl}/${imageBlock}`;
687
+ }
688
+ if (imageBlock.url) {
689
+ if (isExternalUrl(imageBlock.url)) {
690
+ return imageBlock.url;
691
+ }
692
+ return `${storageUrl}/${imageBlock.url}`;
693
+ }
694
+ }
695
+ if (imageBlock.resolutions && imageBlock.resolutions.original && imageBlock.resolutions.original.url) {
696
+ const url = imageBlock.resolutions.original.url;
697
+ if (isExternalUrl(url)) {
698
+ return url;
699
+ }
700
+ return `${storageUrl}/${url}`;
701
+ }
702
+ return null;
703
+ };
704
+
518
705
  // src/api/cms.ts
519
706
  var createCmsApi = (apiConfig) => {
520
707
  return {
@@ -540,10 +727,24 @@ var createCmsApi = (apiConfig) => {
540
727
  );
541
728
  },
542
729
  async getCollection(params, options) {
543
- return apiConfig.httpClient.get(
544
- `/v1/businesses/${apiConfig.businessId}/collections/${params.id}`,
730
+ const formattedId = formatIdOrSlug(params.id, apiConfig);
731
+ const response = await apiConfig.httpClient.get(
732
+ `/v1/businesses/${apiConfig.businessId}/collections/${formattedId}`,
545
733
  options
546
734
  );
735
+ return {
736
+ ...response,
737
+ getBlock(key) {
738
+ return getBlockFromArray(response, key, apiConfig.locale);
739
+ },
740
+ getBlockValues(key) {
741
+ return getBlockObjectValues(response, key, apiConfig.locale);
742
+ },
743
+ getImage(key) {
744
+ const block = getBlockFromArray(response, key, apiConfig.locale);
745
+ return getImageUrl(block, true, apiConfig.storageUrl);
746
+ }
747
+ };
547
748
  },
548
749
  async getCollections(params, options) {
549
750
  return apiConfig.httpClient.get(
@@ -605,8 +806,9 @@ var createCmsApi = (apiConfig) => {
605
806
  );
606
807
  },
607
808
  async getCollectionEntry(params, options) {
809
+ const formattedId = formatIdOrSlug(params.id, apiConfig);
608
810
  return apiConfig.httpClient.get(
609
- `/v1/businesses/${apiConfig.businessId}/entries/${params.id}`,
811
+ `/v1/businesses/${apiConfig.businessId}/entries/${formattedId}`,
610
812
  options
611
813
  );
612
814
  },
@@ -631,8 +833,9 @@ var createCmsApi = (apiConfig) => {
631
833
  },
632
834
  // ===== COLLECTION SUBSCRIPTIONS =====
633
835
  async getCollectionSubscribers(params, options) {
836
+ const formattedId = formatIdOrSlug(params.id, apiConfig);
634
837
  return apiConfig.httpClient.get(
635
- `/v1/businesses/${apiConfig.businessId}/collections/${params.id}/subscribers`,
838
+ `/v1/businesses/${apiConfig.businessId}/collections/${formattedId}/subscribers`,
636
839
  options
637
840
  );
638
841
  },
@@ -648,10 +851,13 @@ var createCmsApi = (apiConfig) => {
648
851
  );
649
852
  },
650
853
  async unsubscribeFromCollection(params, options) {
651
- return apiConfig.httpClient.get(`/v1/businesses/${apiConfig.businessId}/collections/unsubscribe`, {
652
- ...options,
653
- params
654
- });
854
+ return apiConfig.httpClient.get(
855
+ `/v1/businesses/${apiConfig.businessId}/collections/unsubscribe`,
856
+ {
857
+ ...options,
858
+ params
859
+ }
860
+ );
655
861
  }
656
862
  };
657
863
  };
@@ -681,10 +887,22 @@ var createEshopApi = (apiConfig) => {
681
887
  );
682
888
  },
683
889
  async getProduct(params, options) {
684
- return apiConfig.httpClient.get(
685
- `/v1/businesses/${apiConfig.businessId}/products/${params.id}`,
890
+ const formattedId = formatIdOrSlug(params.id, apiConfig);
891
+ const response = await apiConfig.httpClient.get(
892
+ `/v1/businesses/${apiConfig.businessId}/products/${formattedId}`,
686
893
  options
687
894
  );
895
+ return {
896
+ ...response,
897
+ getName() {
898
+ const locale = apiConfig.locale;
899
+ return response.name?.[locale] || response.name?.en || response.name || "";
900
+ },
901
+ getDescription() {
902
+ const locale = apiConfig.locale;
903
+ return response.description?.[locale] || response.description?.en || response.description || "";
904
+ }
905
+ };
688
906
  },
689
907
  async getProducts(params, options) {
690
908
  return apiConfig.httpClient.get(
@@ -753,7 +971,9 @@ var createEshopApi = (apiConfig) => {
753
971
  currency: params.currency,
754
972
  paymentMethod: params.paymentMethod,
755
973
  lines,
756
- ...params.shippingMethodId && { shippingMethodId: params.shippingMethodId },
974
+ ...params.shippingMethodId && {
975
+ shippingMethodId: params.shippingMethodId
976
+ },
757
977
  ...params.promoCode && { promoCode: params.promoCode }
758
978
  };
759
979
  return apiConfig.httpClient.post(`/v1/payments/quote`, payload, options);
@@ -791,7 +1011,11 @@ var createReservationApi = (apiConfig) => {
791
1011
  },
792
1012
  async updateReservation(params, options) {
793
1013
  const { id, ...payload } = params;
794
- return apiConfig.httpClient.put(`/v1/reservations/${id}`, payload, options);
1014
+ return apiConfig.httpClient.put(
1015
+ `/v1/reservations/${id}`,
1016
+ payload,
1017
+ options
1018
+ );
795
1019
  },
796
1020
  async checkout(params, options) {
797
1021
  const payload = {
@@ -802,7 +1026,11 @@ var createReservationApi = (apiConfig) => {
802
1026
  ...params.paymentMethod && { paymentMethod: params.paymentMethod },
803
1027
  ...params.promoCode && { promoCode: params.promoCode }
804
1028
  };
805
- return apiConfig.httpClient.post(`/v1/reservations/checkout`, payload, options);
1029
+ return apiConfig.httpClient.post(
1030
+ `/v1/reservations/checkout`,
1031
+ payload,
1032
+ options
1033
+ );
806
1034
  },
807
1035
  async getReservation(params, options) {
808
1036
  return apiConfig.httpClient.get(`/v1/reservations/${params.id}`, {
@@ -870,10 +1098,22 @@ var createReservationApi = (apiConfig) => {
870
1098
  );
871
1099
  },
872
1100
  async getService(params, options) {
873
- return apiConfig.httpClient.get(
874
- `/v1/businesses/${apiConfig.businessId}/services/${params.id}`,
1101
+ const formattedId = formatIdOrSlug(params.id, apiConfig);
1102
+ const response = await apiConfig.httpClient.get(
1103
+ `/v1/businesses/${apiConfig.businessId}/services/${formattedId}`,
875
1104
  options
876
1105
  );
1106
+ return {
1107
+ ...response,
1108
+ getName() {
1109
+ const locale = apiConfig.locale;
1110
+ return response.name?.[locale] || response.name?.en || response.name || "";
1111
+ },
1112
+ getDescription() {
1113
+ const locale = apiConfig.locale;
1114
+ return response.description?.[locale] || response.description?.en || response.description || "";
1115
+ }
1116
+ };
877
1117
  },
878
1118
  async getServices(params, options) {
879
1119
  return apiConfig.httpClient.get(
@@ -967,178 +1207,6 @@ var createPaymentApi = (apiConfig) => {
967
1207
  };
968
1208
  };
969
1209
 
970
- // src/utils/blocks.ts
971
- function getBlockLabel(block, locale = "en") {
972
- if (!block) return "";
973
- if (block.properties?.label) {
974
- if (typeof block.properties.label === "object") {
975
- return block.properties.label[locale] || block.properties.label.en || Object.values(block.properties.label)[0] || "";
976
- }
977
- if (typeof block.properties.label === "string") {
978
- return block.properties.label;
979
- }
980
- }
981
- return block.key?.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()) || "";
982
- }
983
- function formatBlockValue(block) {
984
- if (!block || block.value === null || block.value === void 0) {
985
- return "";
986
- }
987
- switch (block.type) {
988
- case "BOOLEAN":
989
- return block.value ? "Yes" : "No";
990
- case "NUMBER":
991
- if (block.properties?.variant === "DATE" || block.properties?.variant === "DATE_TIME") {
992
- try {
993
- return new Date(block.value).toLocaleDateString();
994
- } catch (e) {
995
- return String(block.value);
996
- }
997
- }
998
- return String(block.value);
999
- case "RELATIONSHIP":
1000
- if (Array.isArray(block.value) && block.value.length > 0) {
1001
- const firstValue = block.value[0];
1002
- if (firstValue && firstValue.mimeType) {
1003
- return firstValue.name || firstValue.id || "Media";
1004
- }
1005
- return firstValue.title || firstValue.name || firstValue.id || "Entry";
1006
- }
1007
- return String(block.value);
1008
- default:
1009
- return String(block.value);
1010
- }
1011
- }
1012
- function prepareBlocksForSubmission(formData) {
1013
- const preparedBlocks = [];
1014
- Object.keys(formData).forEach((key) => {
1015
- if (formData[key] !== null && formData[key] !== void 0) {
1016
- preparedBlocks.push({
1017
- key,
1018
- value: [formData[key]]
1019
- });
1020
- }
1021
- });
1022
- return preparedBlocks;
1023
- }
1024
- function extractBlockValues(blocks) {
1025
- const values = {};
1026
- blocks.forEach((block) => {
1027
- if (block.value && block.value.length > 0) {
1028
- values[block.key] = block.value[0];
1029
- } else {
1030
- values[block.key] = null;
1031
- }
1032
- });
1033
- return values;
1034
- }
1035
- function getBlockTextValue(block, locale = "en") {
1036
- if (!block || !block.value || block.value.length === 0) return "";
1037
- const firstValue = block.value[0];
1038
- if (typeof firstValue === "object" && firstValue !== null) {
1039
- if (firstValue[locale]) return firstValue[locale];
1040
- if (firstValue.en) return firstValue.en;
1041
- const values = Object.values(firstValue);
1042
- return String(values[0] || "");
1043
- }
1044
- return String(firstValue);
1045
- }
1046
- var getBlockValue = (entry, blockKey) => {
1047
- if (!entry || !entry.blocks) return null;
1048
- const block = entry.blocks.find((f) => f.key === blockKey);
1049
- if (!block || !block.value || block.value.length === 0) return null;
1050
- return block.value[0];
1051
- };
1052
- var getBlockValues = (entry, blockKey) => {
1053
- if (!entry || !entry.blocks) return null;
1054
- const block = entry.blocks.find((f) => f.key === blockKey);
1055
- if (!block || !block.value || block.value.length === 0) return null;
1056
- return block.value;
1057
- };
1058
- function unwrapBlock(block, locale) {
1059
- if (!block?.type || block.value === void 0) return block;
1060
- if (block.type === "BLOCK") {
1061
- return block.value.map((obj) => {
1062
- const parsed = {};
1063
- for (const [k, v] of Object.entries(obj)) {
1064
- parsed[k] = unwrapBlock(v, locale);
1065
- }
1066
- return parsed;
1067
- });
1068
- }
1069
- const isLocalized = block.type === "TEXT";
1070
- const isList = block.properties?.ui === "list" || (block.properties?.maxValues ?? 1) > 1 || block.value.length > 1;
1071
- if (isList) {
1072
- return isLocalized ? block.value.map((v) => v[locale] || v["en"]) : [...block.value];
1073
- }
1074
- return isLocalized ? block.value[0][locale] || block.value[0]["en"] : block.value[0];
1075
- }
1076
- var getBlockObjectValues = (entry, blockKey, locale = "en") => {
1077
- if (!entry) {
1078
- return [];
1079
- }
1080
- const values = getBlockValues(entry, blockKey);
1081
- const parsed = values.map((obj) => {
1082
- const res = obj.value.reduce((acc, current) => {
1083
- acc[current.key] = unwrapBlock(current, locale);
1084
- return acc;
1085
- }, {});
1086
- return res;
1087
- });
1088
- return parsed;
1089
- };
1090
- var getBlockFromArray = (entry, blockKey, locale = "en") => {
1091
- if (!entry) {
1092
- return [];
1093
- }
1094
- const values = getBlockValues(entry, blockKey);
1095
- return values.reduce((acc, current) => {
1096
- acc[current.key] = unwrapBlock(current, locale);
1097
- return acc;
1098
- });
1099
- };
1100
- var getImageUrl = (imageBlock, isBlock = true, storageUrl = "https://storage.arky.io/dev") => {
1101
- if (!imageBlock) return null;
1102
- const isExternalUrl = (url) => {
1103
- return url.startsWith("http://") || url.startsWith("https://");
1104
- };
1105
- if (imageBlock.type === "RELATIONSHIP" && Array.isArray(imageBlock.value)) {
1106
- const mediaValue = imageBlock.value[0];
1107
- if (mediaValue && mediaValue.mimeType) {
1108
- if (mediaValue.resolutions && mediaValue.resolutions.original && mediaValue.resolutions.original.url) {
1109
- const url = mediaValue.resolutions.original.url;
1110
- return isExternalUrl(url) ? url : `${storageUrl}/${url}`;
1111
- }
1112
- if (mediaValue.url) {
1113
- return isExternalUrl(mediaValue.url) ? mediaValue.url : `${storageUrl}/${mediaValue.url}`;
1114
- }
1115
- }
1116
- return null;
1117
- }
1118
- if (isBlock) {
1119
- if (typeof imageBlock === "string") {
1120
- if (isExternalUrl(imageBlock)) {
1121
- return imageBlock;
1122
- }
1123
- return `${storageUrl}/${imageBlock}`;
1124
- }
1125
- if (imageBlock.url) {
1126
- if (isExternalUrl(imageBlock.url)) {
1127
- return imageBlock.url;
1128
- }
1129
- return `${storageUrl}/${imageBlock.url}`;
1130
- }
1131
- }
1132
- if (imageBlock.resolutions && imageBlock.resolutions.original && imageBlock.resolutions.original.url) {
1133
- const url = imageBlock.resolutions.original.url;
1134
- if (isExternalUrl(url)) {
1135
- return url;
1136
- }
1137
- return `${storageUrl}/${url}`;
1138
- }
1139
- return null;
1140
- };
1141
-
1142
1210
  // src/utils/currency.ts
1143
1211
  function getCurrencySymbol(currency) {
1144
1212
  const currencySymbols = {
@@ -1487,7 +1555,7 @@ async function injectSvgIntoElement(mediaObject, targetElement, className) {
1487
1555
  }
1488
1556
 
1489
1557
  // src/index.ts
1490
- var SDK_VERSION = "0.3.28";
1558
+ var SDK_VERSION = "0.3.30";
1491
1559
  var SUPPORTED_FRAMEWORKS = [
1492
1560
  "astro",
1493
1561
  "react",
@@ -1496,8 +1564,9 @@ var SUPPORTED_FRAMEWORKS = [
1496
1564
  "vanilla"
1497
1565
  ];
1498
1566
  function createArkySDK(config) {
1567
+ const locale = config.locale || "en";
1499
1568
  console.log(
1500
- `[Arky SDK v${SDK_VERSION}] Initializing with market: ${config.market}, businessId: ${config.businessId}`
1569
+ `[Arky SDK v${SDK_VERSION}] Initializing with market: ${config.market}, businessId: ${config.businessId}, locale: ${locale}`
1501
1570
  );
1502
1571
  const httpClient = createHttpClient(config);
1503
1572
  const storageUrl = config.storageUrl || "https://storage.arky.io/dev";
@@ -1507,6 +1576,7 @@ function createArkySDK(config) {
1507
1576
  storageUrl,
1508
1577
  baseUrl: config.baseUrl,
1509
1578
  market: config.market,
1579
+ locale,
1510
1580
  setToken: config.setToken,
1511
1581
  getToken: config.getToken
1512
1582
  };
@@ -1532,6 +1602,10 @@ function createArkySDK(config) {
1532
1602
  apiConfig.market = market;
1533
1603
  },
1534
1604
  getMarket: () => apiConfig.market,
1605
+ setLocale: (locale2) => {
1606
+ apiConfig.locale = locale2;
1607
+ },
1608
+ getLocale: () => apiConfig.locale,
1535
1609
  isAuthenticated: config.isAuthenticated || (() => false),
1536
1610
  logout: config.logout,
1537
1611
  setToken: config.setToken,