arky-sdk 0.3.31 → 0.3.33

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
@@ -1,4 +1,4 @@
1
- import { UpdateUserProfileParams, RequestOptions, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, LogoutParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, UpdateSubscriptionParams, CancelSubscriptionParams, ReactivateSubscriptionParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, SetProviderScheduleParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GenerateBlocksParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, GetCollectionSubscribersParams, SubscribeToCollectionParams, UnsubscribeFromCollectionParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, GetReservationPartsParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetAvailableSlotsParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, HandleStripeWebhookParams, GetBusinessMarketsParams, GetBusinessMarketParams } from './types.cjs';
1
+ import { UpdateUserProfileParams, RequestOptions, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, LogoutParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, UpdateSubscriptionParams, CancelSubscriptionParams, ReactivateSubscriptionParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, SetProviderScheduleParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, UpdateMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GenerateBlocksParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, GetCollectionSubscribersParams, SubscribeToCollectionParams, UnsubscribeFromCollectionParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, GetReservationPartsParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetAvailableSlotsParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, HandleStripeWebhookParams, GetBusinessMarketsParams, GetBusinessMarketParams } from './types.cjs';
2
2
  export { ApiResponse, Block, Business, EshopCartItem, EshopStoreState, Price, ReservationCartPart, ReservationStoreState } from './types.cjs';
3
3
  import { g as getBlockLabel, a as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission, e as extractBlockValues, b as getMarketPrice, c as getPriceAmount, d as formatPayment, h as formatMinor, i as createPaymentForCheckout, j as getCurrencySymbol, v as validatePhoneNumber, k as findTimeZone, s as slugify, l as humanize, m as categorify, n as formatDate, o as getSvgContentForAstro, q as fetchSvgContent, r as injectSvgIntoElement } from './svg-DKAX97qt.cjs';
4
4
 
@@ -79,6 +79,7 @@ declare function createArkySDK(config: HttpClientConfig & {
79
79
  uploadBusinessMedia(params: UploadBusinessMediaParams, options?: RequestOptions): Promise<any>;
80
80
  deleteBusinessMedia(params: DeleteBusinessMediaParams, options?: RequestOptions): Promise<any>;
81
81
  getBusinessMedia(params: GetBusinessMediaParams, options?: RequestOptions): Promise<any>;
82
+ updateMedia(params: UpdateMediaParams, options?: RequestOptions): Promise<any>;
82
83
  };
83
84
  role: {
84
85
  createRole(params: CreateRoleParams, options?: RequestOptions): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UpdateUserProfileParams, RequestOptions, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, LogoutParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, UpdateSubscriptionParams, CancelSubscriptionParams, ReactivateSubscriptionParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, SetProviderScheduleParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GenerateBlocksParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, GetCollectionSubscribersParams, SubscribeToCollectionParams, UnsubscribeFromCollectionParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, GetReservationPartsParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetAvailableSlotsParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, HandleStripeWebhookParams, GetBusinessMarketsParams, GetBusinessMarketParams } from './types.js';
1
+ import { UpdateUserProfileParams, RequestOptions, AddPhoneNumberParams, PhoneNumberConfirmParams, GetMeParams, SearchUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, LogoutParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessesParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionPlansParams, GetSubscriptionParams, UpdateSubscriptionParams, CancelSubscriptionParams, ReactivateSubscriptionParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, GetBusinessMediaParams2, SetProviderScheduleParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, UpdateMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, CreateCollectionParams, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GenerateBlocksParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, GetCollectionSubscribersParams, SubscribeToCollectionParams, UnsubscribeFromCollectionParams, CreateProductParams, UpdateProductParams, DeleteProductParams, GetProductParams, GetProductsParams, CreateOrderParams, UpdateOrderParams, GetOrderParams, GetOrdersParams, UpdateOrderStatusParams, UpdateOrderPaymentStatusParams, GetQuoteParams, CheckoutParams, CreateReservationParams, UpdateReservationParams, ReservationCheckoutParams, GetReservationParams, GetReservationPartsParams, SearchReservationsParams, SearchMyReservationsParams, GetReservationQuoteParams, CreateServiceParams, UpdateServiceParams, DeleteServiceParams, GetServiceParams, GetServicesParams, GetAvailableSlotsParams, CreateProviderParams, UpdateProviderParams, DeleteProviderParams, GetProviderParams, GetProvidersParams, GetBusinessServiceWorkingTimeParams, HandleStripeWebhookParams, GetBusinessMarketsParams, GetBusinessMarketParams } from './types.js';
2
2
  export { ApiResponse, Block, Business, EshopCartItem, EshopStoreState, Price, ReservationCartPart, ReservationStoreState } from './types.js';
3
3
  import { g as getBlockLabel, a as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission, e as extractBlockValues, b as getMarketPrice, c as getPriceAmount, d as formatPayment, h as formatMinor, i as createPaymentForCheckout, j as getCurrencySymbol, v as validatePhoneNumber, k as findTimeZone, s as slugify, l as humanize, m as categorify, n as formatDate, o as getSvgContentForAstro, q as fetchSvgContent, r as injectSvgIntoElement } from './svg-CR0zPGOt.js';
4
4
 
@@ -79,6 +79,7 @@ declare function createArkySDK(config: HttpClientConfig & {
79
79
  uploadBusinessMedia(params: UploadBusinessMediaParams, options?: RequestOptions): Promise<any>;
80
80
  deleteBusinessMedia(params: DeleteBusinessMediaParams, options?: RequestOptions): Promise<any>;
81
81
  getBusinessMedia(params: GetBusinessMediaParams, options?: RequestOptions): Promise<any>;
82
+ updateMedia(params: UpdateMediaParams, options?: RequestOptions): Promise<any>;
82
83
  };
83
84
  role: {
84
85
  createRole(params: CreateRoleParams, options?: RequestOptions): Promise<void>;
package/dist/index.js CHANGED
@@ -373,7 +373,7 @@ var createMediaApi = (apiConfig) => {
373
373
  return {
374
374
  async uploadBusinessMedia(params, options) {
375
375
  const { files = [], urls = [] } = params;
376
- const url = `${apiConfig.baseUrl}/v1/businesses/${apiConfig.businessId}/upload`;
376
+ const url = `${apiConfig.baseUrl}/v1/businesses/${apiConfig.businessId}/media`;
377
377
  const formData = new FormData();
378
378
  files.forEach((file) => formData.append("files", file));
379
379
  urls.forEach((url2) => formData.append("files", url2));
@@ -393,11 +393,8 @@ var createMediaApi = (apiConfig) => {
393
393
  async deleteBusinessMedia(params, options) {
394
394
  const { id, mediaId } = params;
395
395
  return apiConfig.httpClient.delete(
396
- `/v1/businesses/${id}/upload`,
397
- {
398
- ...options,
399
- params: { mediaId }
400
- }
396
+ `/v1/businesses/${id}/media/${mediaId}`,
397
+ options
401
398
  );
402
399
  },
403
400
  async getBusinessMedia(params, options) {
@@ -412,6 +409,14 @@ var createMediaApi = (apiConfig) => {
412
409
  throw new Error(errorData?.message || "Failed to fetch media");
413
410
  }
414
411
  return await response.json();
412
+ },
413
+ async updateMedia(params, options) {
414
+ const { mediaId, ...updateData } = params;
415
+ return apiConfig.httpClient.put(
416
+ `/v1/businesses/${apiConfig.businessId}/media/${mediaId}`,
417
+ updateData,
418
+ options
419
+ );
415
420
  }
416
421
  };
417
422
  };
@@ -530,6 +535,178 @@ var formatIdOrSlug = (id, apiConfig) => {
530
535
  return `${apiConfig.businessId}:${apiConfig.locale}:${id}`;
531
536
  };
532
537
 
538
+ // src/utils/blocks.ts
539
+ function getBlockLabel(block, locale = "en") {
540
+ if (!block) return "";
541
+ if (block.properties?.label) {
542
+ if (typeof block.properties.label === "object") {
543
+ return block.properties.label[locale] || block.properties.label.en || Object.values(block.properties.label)[0] || "";
544
+ }
545
+ if (typeof block.properties.label === "string") {
546
+ return block.properties.label;
547
+ }
548
+ }
549
+ return block.key?.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()) || "";
550
+ }
551
+ function formatBlockValue(block) {
552
+ if (!block || block.value === null || block.value === void 0) {
553
+ return "";
554
+ }
555
+ switch (block.type) {
556
+ case "BOOLEAN":
557
+ return block.value ? "Yes" : "No";
558
+ case "NUMBER":
559
+ if (block.properties?.variant === "DATE" || block.properties?.variant === "DATE_TIME") {
560
+ try {
561
+ return new Date(block.value).toLocaleDateString();
562
+ } catch (e) {
563
+ return String(block.value);
564
+ }
565
+ }
566
+ return String(block.value);
567
+ case "RELATIONSHIP":
568
+ if (Array.isArray(block.value) && block.value.length > 0) {
569
+ const firstValue = block.value[0];
570
+ if (firstValue && firstValue.mimeType) {
571
+ return firstValue.name || firstValue.id || "Media";
572
+ }
573
+ return firstValue.title || firstValue.name || firstValue.id || "Entry";
574
+ }
575
+ return String(block.value);
576
+ default:
577
+ return String(block.value);
578
+ }
579
+ }
580
+ function prepareBlocksForSubmission(formData) {
581
+ const preparedBlocks = [];
582
+ Object.keys(formData).forEach((key) => {
583
+ if (formData[key] !== null && formData[key] !== void 0) {
584
+ preparedBlocks.push({
585
+ key,
586
+ value: [formData[key]]
587
+ });
588
+ }
589
+ });
590
+ return preparedBlocks;
591
+ }
592
+ function extractBlockValues(blocks) {
593
+ const values = {};
594
+ blocks.forEach((block) => {
595
+ if (block.value && block.value.length > 0) {
596
+ values[block.key] = block.value[0];
597
+ } else {
598
+ values[block.key] = null;
599
+ }
600
+ });
601
+ return values;
602
+ }
603
+ function getBlockTextValue(block, locale = "en") {
604
+ if (!block || !block.value || block.value.length === 0) return "";
605
+ const firstValue = block.value[0];
606
+ if (typeof firstValue === "object" && firstValue !== null) {
607
+ if (firstValue[locale]) return firstValue[locale];
608
+ if (firstValue.en) return firstValue.en;
609
+ const values = Object.values(firstValue);
610
+ return String(values[0] || "");
611
+ }
612
+ return String(firstValue);
613
+ }
614
+ var getBlockValue = (entry, blockKey) => {
615
+ if (!entry || !entry.blocks) return null;
616
+ const block = entry.blocks.find((f) => f.key === blockKey);
617
+ if (!block || !block.value || block.value.length === 0) return null;
618
+ return block.value[0];
619
+ };
620
+ var getBlockValues = (entry, blockKey) => {
621
+ if (!entry || !entry.blocks) return null;
622
+ const block = entry.blocks.find((f) => f.key === blockKey);
623
+ if (!block || !block.value || block.value.length === 0) return null;
624
+ return block.value;
625
+ };
626
+ function unwrapBlock(block, locale) {
627
+ if (!block?.type || block.value === void 0) return block;
628
+ if (block.type === "BLOCK") {
629
+ return block.value.map((obj) => {
630
+ const parsed = {};
631
+ for (const [k, v] of Object.entries(obj)) {
632
+ parsed[k] = unwrapBlock(v, locale);
633
+ }
634
+ return parsed;
635
+ });
636
+ }
637
+ const isLocalized = block.type === "TEXT";
638
+ const isList = block.properties?.ui === "list" || (block.properties?.maxValues ?? 1) > 1 || block.value.length > 1;
639
+ if (isList) {
640
+ return isLocalized ? block.value.map((v) => v[locale] || v["en"]) : [...block.value];
641
+ }
642
+ return isLocalized ? block.value[0][locale] || block.value[0]["en"] : block.value[0];
643
+ }
644
+ var getBlockObjectValues = (entry, blockKey, locale = "en") => {
645
+ if (!entry) {
646
+ return [];
647
+ }
648
+ const values = getBlockValues(entry, blockKey);
649
+ const parsed = values.map((obj) => {
650
+ const res = obj.value.reduce((acc, current) => {
651
+ acc[current.key] = unwrapBlock(current, locale);
652
+ return acc;
653
+ }, {});
654
+ return res;
655
+ });
656
+ return parsed;
657
+ };
658
+ var getBlockFromArray = (entry, blockKey, locale = "en") => {
659
+ if (!entry) {
660
+ return [];
661
+ }
662
+ const values = getBlockValues(entry, blockKey);
663
+ return values.reduce((acc, current) => {
664
+ acc[current.key] = unwrapBlock(current, locale);
665
+ return acc;
666
+ });
667
+ };
668
+ var getImageUrl = (imageBlock, isBlock = true, storageUrl = "https://storage.arky.io/dev") => {
669
+ if (!imageBlock) return null;
670
+ const isExternalUrl = (url) => {
671
+ return url.startsWith("http://") || url.startsWith("https://");
672
+ };
673
+ if (imageBlock.type === "RELATIONSHIP" && Array.isArray(imageBlock.value)) {
674
+ const mediaValue = imageBlock.value[0];
675
+ if (mediaValue && mediaValue.mimeType) {
676
+ if (mediaValue.resolutions && mediaValue.resolutions.original && mediaValue.resolutions.original.url) {
677
+ const url = mediaValue.resolutions.original.url;
678
+ return isExternalUrl(url) ? url : `${storageUrl}/${url}`;
679
+ }
680
+ if (mediaValue.url) {
681
+ return isExternalUrl(mediaValue.url) ? mediaValue.url : `${storageUrl}/${mediaValue.url}`;
682
+ }
683
+ }
684
+ return null;
685
+ }
686
+ if (isBlock) {
687
+ if (typeof imageBlock === "string") {
688
+ if (isExternalUrl(imageBlock)) {
689
+ return imageBlock;
690
+ }
691
+ return `${storageUrl}/${imageBlock}`;
692
+ }
693
+ if (imageBlock.url) {
694
+ if (isExternalUrl(imageBlock.url)) {
695
+ return imageBlock.url;
696
+ }
697
+ return `${storageUrl}/${imageBlock.url}`;
698
+ }
699
+ }
700
+ if (imageBlock.resolutions && imageBlock.resolutions.original && imageBlock.resolutions.original.url) {
701
+ const url = imageBlock.resolutions.original.url;
702
+ if (isExternalUrl(url)) {
703
+ return url;
704
+ }
705
+ return `${storageUrl}/${url}`;
706
+ }
707
+ return null;
708
+ };
709
+
533
710
  // src/api/cms.ts
534
711
  var createCmsApi = (apiConfig) => {
535
712
  return {
@@ -556,10 +733,23 @@ var createCmsApi = (apiConfig) => {
556
733
  },
557
734
  async getCollection(params, options) {
558
735
  const formattedId = formatIdOrSlug(params.id, apiConfig);
559
- return apiConfig.httpClient.get(
736
+ const response = await apiConfig.httpClient.get(
560
737
  `/v1/businesses/${apiConfig.businessId}/collections/${formattedId}`,
561
738
  options
562
739
  );
740
+ return {
741
+ ...response,
742
+ getBlock(key) {
743
+ return getBlockFromArray(response, key, apiConfig.locale);
744
+ },
745
+ getBlockValues(key) {
746
+ return getBlockObjectValues(response, key, apiConfig.locale);
747
+ },
748
+ getImage(key) {
749
+ const block = getBlockFromArray(response, key, apiConfig.locale);
750
+ return getImageUrl(block, true, apiConfig.storageUrl);
751
+ }
752
+ };
563
753
  },
564
754
  async getCollections(params, options) {
565
755
  return apiConfig.httpClient.get(
@@ -703,10 +893,21 @@ var createEshopApi = (apiConfig) => {
703
893
  },
704
894
  async getProduct(params, options) {
705
895
  const formattedId = formatIdOrSlug(params.id, apiConfig);
706
- return apiConfig.httpClient.get(
896
+ const response = await apiConfig.httpClient.get(
707
897
  `/v1/businesses/${apiConfig.businessId}/products/${formattedId}`,
708
898
  options
709
899
  );
900
+ return {
901
+ ...response,
902
+ getName() {
903
+ const locale = apiConfig.locale;
904
+ return response.name?.[locale] || response.name?.en || response.name || "";
905
+ },
906
+ getDescription() {
907
+ const locale = apiConfig.locale;
908
+ return response.description?.[locale] || response.description?.en || response.description || "";
909
+ }
910
+ };
710
911
  },
711
912
  async getProducts(params, options) {
712
913
  return apiConfig.httpClient.get(
@@ -903,10 +1104,21 @@ var createReservationApi = (apiConfig) => {
903
1104
  },
904
1105
  async getService(params, options) {
905
1106
  const formattedId = formatIdOrSlug(params.id, apiConfig);
906
- return apiConfig.httpClient.get(
1107
+ const response = await apiConfig.httpClient.get(
907
1108
  `/v1/businesses/${apiConfig.businessId}/services/${formattedId}`,
908
1109
  options
909
1110
  );
1111
+ return {
1112
+ ...response,
1113
+ getName() {
1114
+ const locale = apiConfig.locale;
1115
+ return response.name?.[locale] || response.name?.en || response.name || "";
1116
+ },
1117
+ getDescription() {
1118
+ const locale = apiConfig.locale;
1119
+ return response.description?.[locale] || response.description?.en || response.description || "";
1120
+ }
1121
+ };
910
1122
  },
911
1123
  async getServices(params, options) {
912
1124
  return apiConfig.httpClient.get(
@@ -1000,178 +1212,6 @@ var createPaymentApi = (apiConfig) => {
1000
1212
  };
1001
1213
  };
1002
1214
 
1003
- // src/utils/blocks.ts
1004
- function getBlockLabel(block, locale = "en") {
1005
- if (!block) return "";
1006
- if (block.properties?.label) {
1007
- if (typeof block.properties.label === "object") {
1008
- return block.properties.label[locale] || block.properties.label.en || Object.values(block.properties.label)[0] || "";
1009
- }
1010
- if (typeof block.properties.label === "string") {
1011
- return block.properties.label;
1012
- }
1013
- }
1014
- return block.key?.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase()) || "";
1015
- }
1016
- function formatBlockValue(block) {
1017
- if (!block || block.value === null || block.value === void 0) {
1018
- return "";
1019
- }
1020
- switch (block.type) {
1021
- case "BOOLEAN":
1022
- return block.value ? "Yes" : "No";
1023
- case "NUMBER":
1024
- if (block.properties?.variant === "DATE" || block.properties?.variant === "DATE_TIME") {
1025
- try {
1026
- return new Date(block.value).toLocaleDateString();
1027
- } catch (e) {
1028
- return String(block.value);
1029
- }
1030
- }
1031
- return String(block.value);
1032
- case "RELATIONSHIP":
1033
- if (Array.isArray(block.value) && block.value.length > 0) {
1034
- const firstValue = block.value[0];
1035
- if (firstValue && firstValue.mimeType) {
1036
- return firstValue.name || firstValue.id || "Media";
1037
- }
1038
- return firstValue.title || firstValue.name || firstValue.id || "Entry";
1039
- }
1040
- return String(block.value);
1041
- default:
1042
- return String(block.value);
1043
- }
1044
- }
1045
- function prepareBlocksForSubmission(formData) {
1046
- const preparedBlocks = [];
1047
- Object.keys(formData).forEach((key) => {
1048
- if (formData[key] !== null && formData[key] !== void 0) {
1049
- preparedBlocks.push({
1050
- key,
1051
- value: [formData[key]]
1052
- });
1053
- }
1054
- });
1055
- return preparedBlocks;
1056
- }
1057
- function extractBlockValues(blocks) {
1058
- const values = {};
1059
- blocks.forEach((block) => {
1060
- if (block.value && block.value.length > 0) {
1061
- values[block.key] = block.value[0];
1062
- } else {
1063
- values[block.key] = null;
1064
- }
1065
- });
1066
- return values;
1067
- }
1068
- function getBlockTextValue(block, locale = "en") {
1069
- if (!block || !block.value || block.value.length === 0) return "";
1070
- const firstValue = block.value[0];
1071
- if (typeof firstValue === "object" && firstValue !== null) {
1072
- if (firstValue[locale]) return firstValue[locale];
1073
- if (firstValue.en) return firstValue.en;
1074
- const values = Object.values(firstValue);
1075
- return String(values[0] || "");
1076
- }
1077
- return String(firstValue);
1078
- }
1079
- var getBlockValue = (entry, blockKey) => {
1080
- if (!entry || !entry.blocks) return null;
1081
- const block = entry.blocks.find((f) => f.key === blockKey);
1082
- if (!block || !block.value || block.value.length === 0) return null;
1083
- return block.value[0];
1084
- };
1085
- var getBlockValues = (entry, blockKey) => {
1086
- if (!entry || !entry.blocks) return null;
1087
- const block = entry.blocks.find((f) => f.key === blockKey);
1088
- if (!block || !block.value || block.value.length === 0) return null;
1089
- return block.value;
1090
- };
1091
- function unwrapBlock(block, locale) {
1092
- if (!block?.type || block.value === void 0) return block;
1093
- if (block.type === "BLOCK") {
1094
- return block.value.map((obj) => {
1095
- const parsed = {};
1096
- for (const [k, v] of Object.entries(obj)) {
1097
- parsed[k] = unwrapBlock(v, locale);
1098
- }
1099
- return parsed;
1100
- });
1101
- }
1102
- const isLocalized = block.type === "TEXT";
1103
- const isList = block.properties?.ui === "list" || (block.properties?.maxValues ?? 1) > 1 || block.value.length > 1;
1104
- if (isList) {
1105
- return isLocalized ? block.value.map((v) => v[locale] || v["en"]) : [...block.value];
1106
- }
1107
- return isLocalized ? block.value[0][locale] || block.value[0]["en"] : block.value[0];
1108
- }
1109
- var getBlockObjectValues = (entry, blockKey, locale = "en") => {
1110
- if (!entry) {
1111
- return [];
1112
- }
1113
- const values = getBlockValues(entry, blockKey);
1114
- const parsed = values.map((obj) => {
1115
- const res = obj.value.reduce((acc, current) => {
1116
- acc[current.key] = unwrapBlock(current, locale);
1117
- return acc;
1118
- }, {});
1119
- return res;
1120
- });
1121
- return parsed;
1122
- };
1123
- var getBlockFromArray = (entry, blockKey, locale = "en") => {
1124
- if (!entry) {
1125
- return [];
1126
- }
1127
- const values = getBlockValues(entry, blockKey);
1128
- return values.reduce((acc, current) => {
1129
- acc[current.key] = unwrapBlock(current, locale);
1130
- return acc;
1131
- });
1132
- };
1133
- var getImageUrl = (imageBlock, isBlock = true, storageUrl = "https://storage.arky.io/dev") => {
1134
- if (!imageBlock) return null;
1135
- const isExternalUrl = (url) => {
1136
- return url.startsWith("http://") || url.startsWith("https://");
1137
- };
1138
- if (imageBlock.type === "RELATIONSHIP" && Array.isArray(imageBlock.value)) {
1139
- const mediaValue = imageBlock.value[0];
1140
- if (mediaValue && mediaValue.mimeType) {
1141
- if (mediaValue.resolutions && mediaValue.resolutions.original && mediaValue.resolutions.original.url) {
1142
- const url = mediaValue.resolutions.original.url;
1143
- return isExternalUrl(url) ? url : `${storageUrl}/${url}`;
1144
- }
1145
- if (mediaValue.url) {
1146
- return isExternalUrl(mediaValue.url) ? mediaValue.url : `${storageUrl}/${mediaValue.url}`;
1147
- }
1148
- }
1149
- return null;
1150
- }
1151
- if (isBlock) {
1152
- if (typeof imageBlock === "string") {
1153
- if (isExternalUrl(imageBlock)) {
1154
- return imageBlock;
1155
- }
1156
- return `${storageUrl}/${imageBlock}`;
1157
- }
1158
- if (imageBlock.url) {
1159
- if (isExternalUrl(imageBlock.url)) {
1160
- return imageBlock.url;
1161
- }
1162
- return `${storageUrl}/${imageBlock.url}`;
1163
- }
1164
- }
1165
- if (imageBlock.resolutions && imageBlock.resolutions.original && imageBlock.resolutions.original.url) {
1166
- const url = imageBlock.resolutions.original.url;
1167
- if (isExternalUrl(url)) {
1168
- return url;
1169
- }
1170
- return `${storageUrl}/${url}`;
1171
- }
1172
- return null;
1173
- };
1174
-
1175
1215
  // src/utils/currency.ts
1176
1216
  function getCurrencySymbol(currency) {
1177
1217
  const currencySymbols = {