arky-sdk 0.3.28 → 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 -26
- 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 +53 -26
- package/dist/index.js.map +1 -1
- package/dist/{svg-BhIM4HZW.d.ts → svg-CR0zPGOt.d.ts} +1 -3
- package/dist/{svg-CFjyTGXu.d.cts → svg-DKAX97qt.d.cts} +1 -3
- package/dist/types.d.cts +32 -0
- package/dist/types.d.ts +32 -0
- package/dist/utils.cjs +0 -12
- 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 +1 -11
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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';
|
|
2
2
|
export { ApiResponse, Block, Business, EshopCartItem, EshopStoreState, Price, ReservationCartPart, ReservationStoreState } from './types.cjs';
|
|
3
|
-
import { g as
|
|
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
|
|
|
5
5
|
interface AuthTokens {
|
|
6
6
|
accessToken: string;
|
|
@@ -22,7 +22,7 @@ interface HttpClientConfig {
|
|
|
22
22
|
isAuthenticated?: () => boolean;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
declare const SDK_VERSION = "0.3.
|
|
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,13 +165,13 @@ 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;
|
|
169
173
|
utils: {
|
|
170
174
|
getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
|
|
171
|
-
thumbnailUrl: (service: any) => string;
|
|
172
|
-
getGalleryThumbnail: typeof getGalleryThumbnail;
|
|
173
175
|
getBlockValue: (entry: any, blockKey: string) => any;
|
|
174
176
|
getBlockValues: (entry: any, blockKey: string) => any;
|
|
175
177
|
getBlockLabel: typeof getBlockLabel;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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';
|
|
2
2
|
export { ApiResponse, Block, Business, EshopCartItem, EshopStoreState, Price, ReservationCartPart, ReservationStoreState } from './types.js';
|
|
3
|
-
import { g as
|
|
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
|
|
|
5
5
|
interface AuthTokens {
|
|
6
6
|
accessToken: string;
|
|
@@ -22,7 +22,7 @@ interface HttpClientConfig {
|
|
|
22
22
|
isAuthenticated?: () => boolean;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
declare const SDK_VERSION = "0.3.
|
|
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,13 +165,13 @@ 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;
|
|
169
173
|
utils: {
|
|
170
174
|
getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
|
|
171
|
-
thumbnailUrl: (service: any) => string;
|
|
172
|
-
getGalleryThumbnail: typeof getGalleryThumbnail;
|
|
173
175
|
getBlockValue: (entry: any, blockKey: string) => any;
|
|
174
176
|
getBlockValues: (entry: any, blockKey: string) => any;
|
|
175
177
|
getBlockLabel: typeof getBlockLabel;
|
package/dist/index.js
CHANGED
|
@@ -515,6 +515,21 @@ 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
|
+
|
|
518
533
|
// src/api/cms.ts
|
|
519
534
|
var createCmsApi = (apiConfig) => {
|
|
520
535
|
return {
|
|
@@ -540,8 +555,9 @@ var createCmsApi = (apiConfig) => {
|
|
|
540
555
|
);
|
|
541
556
|
},
|
|
542
557
|
async getCollection(params, options) {
|
|
558
|
+
const formattedId = formatIdOrSlug(params.id, apiConfig);
|
|
543
559
|
return apiConfig.httpClient.get(
|
|
544
|
-
`/v1/businesses/${apiConfig.businessId}/collections/${
|
|
560
|
+
`/v1/businesses/${apiConfig.businessId}/collections/${formattedId}`,
|
|
545
561
|
options
|
|
546
562
|
);
|
|
547
563
|
},
|
|
@@ -605,8 +621,9 @@ var createCmsApi = (apiConfig) => {
|
|
|
605
621
|
);
|
|
606
622
|
},
|
|
607
623
|
async getCollectionEntry(params, options) {
|
|
624
|
+
const formattedId = formatIdOrSlug(params.id, apiConfig);
|
|
608
625
|
return apiConfig.httpClient.get(
|
|
609
|
-
`/v1/businesses/${apiConfig.businessId}/entries/${
|
|
626
|
+
`/v1/businesses/${apiConfig.businessId}/entries/${formattedId}`,
|
|
610
627
|
options
|
|
611
628
|
);
|
|
612
629
|
},
|
|
@@ -631,8 +648,9 @@ var createCmsApi = (apiConfig) => {
|
|
|
631
648
|
},
|
|
632
649
|
// ===== COLLECTION SUBSCRIPTIONS =====
|
|
633
650
|
async getCollectionSubscribers(params, options) {
|
|
651
|
+
const formattedId = formatIdOrSlug(params.id, apiConfig);
|
|
634
652
|
return apiConfig.httpClient.get(
|
|
635
|
-
`/v1/businesses/${apiConfig.businessId}/collections/${
|
|
653
|
+
`/v1/businesses/${apiConfig.businessId}/collections/${formattedId}/subscribers`,
|
|
636
654
|
options
|
|
637
655
|
);
|
|
638
656
|
},
|
|
@@ -648,10 +666,13 @@ var createCmsApi = (apiConfig) => {
|
|
|
648
666
|
);
|
|
649
667
|
},
|
|
650
668
|
async unsubscribeFromCollection(params, options) {
|
|
651
|
-
return apiConfig.httpClient.get(
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
669
|
+
return apiConfig.httpClient.get(
|
|
670
|
+
`/v1/businesses/${apiConfig.businessId}/collections/unsubscribe`,
|
|
671
|
+
{
|
|
672
|
+
...options,
|
|
673
|
+
params
|
|
674
|
+
}
|
|
675
|
+
);
|
|
655
676
|
}
|
|
656
677
|
};
|
|
657
678
|
};
|
|
@@ -681,8 +702,9 @@ var createEshopApi = (apiConfig) => {
|
|
|
681
702
|
);
|
|
682
703
|
},
|
|
683
704
|
async getProduct(params, options) {
|
|
705
|
+
const formattedId = formatIdOrSlug(params.id, apiConfig);
|
|
684
706
|
return apiConfig.httpClient.get(
|
|
685
|
-
`/v1/businesses/${apiConfig.businessId}/products/${
|
|
707
|
+
`/v1/businesses/${apiConfig.businessId}/products/${formattedId}`,
|
|
686
708
|
options
|
|
687
709
|
);
|
|
688
710
|
},
|
|
@@ -753,7 +775,9 @@ var createEshopApi = (apiConfig) => {
|
|
|
753
775
|
currency: params.currency,
|
|
754
776
|
paymentMethod: params.paymentMethod,
|
|
755
777
|
lines,
|
|
756
|
-
...params.shippingMethodId && {
|
|
778
|
+
...params.shippingMethodId && {
|
|
779
|
+
shippingMethodId: params.shippingMethodId
|
|
780
|
+
},
|
|
757
781
|
...params.promoCode && { promoCode: params.promoCode }
|
|
758
782
|
};
|
|
759
783
|
return apiConfig.httpClient.post(`/v1/payments/quote`, payload, options);
|
|
@@ -791,7 +815,11 @@ var createReservationApi = (apiConfig) => {
|
|
|
791
815
|
},
|
|
792
816
|
async updateReservation(params, options) {
|
|
793
817
|
const { id, ...payload } = params;
|
|
794
|
-
return apiConfig.httpClient.put(
|
|
818
|
+
return apiConfig.httpClient.put(
|
|
819
|
+
`/v1/reservations/${id}`,
|
|
820
|
+
payload,
|
|
821
|
+
options
|
|
822
|
+
);
|
|
795
823
|
},
|
|
796
824
|
async checkout(params, options) {
|
|
797
825
|
const payload = {
|
|
@@ -802,7 +830,11 @@ var createReservationApi = (apiConfig) => {
|
|
|
802
830
|
...params.paymentMethod && { paymentMethod: params.paymentMethod },
|
|
803
831
|
...params.promoCode && { promoCode: params.promoCode }
|
|
804
832
|
};
|
|
805
|
-
return apiConfig.httpClient.post(
|
|
833
|
+
return apiConfig.httpClient.post(
|
|
834
|
+
`/v1/reservations/checkout`,
|
|
835
|
+
payload,
|
|
836
|
+
options
|
|
837
|
+
);
|
|
806
838
|
},
|
|
807
839
|
async getReservation(params, options) {
|
|
808
840
|
return apiConfig.httpClient.get(`/v1/reservations/${params.id}`, {
|
|
@@ -870,8 +902,9 @@ var createReservationApi = (apiConfig) => {
|
|
|
870
902
|
);
|
|
871
903
|
},
|
|
872
904
|
async getService(params, options) {
|
|
905
|
+
const formattedId = formatIdOrSlug(params.id, apiConfig);
|
|
873
906
|
return apiConfig.httpClient.get(
|
|
874
|
-
`/v1/businesses/${apiConfig.businessId}/services/${
|
|
907
|
+
`/v1/businesses/${apiConfig.businessId}/services/${formattedId}`,
|
|
875
908
|
options
|
|
876
909
|
);
|
|
877
910
|
},
|
|
@@ -1138,16 +1171,6 @@ var getImageUrl = (imageBlock, isBlock = true, storageUrl = "https://storage.ark
|
|
|
1138
1171
|
}
|
|
1139
1172
|
return null;
|
|
1140
1173
|
};
|
|
1141
|
-
function getGalleryThumbnail(gallery) {
|
|
1142
|
-
if (!gallery?.length) return null;
|
|
1143
|
-
const item = gallery.find((g) => g.settings.isThumbnail) || gallery[0];
|
|
1144
|
-
const res = item.media.resolutions.thumbnail || item.media.resolutions.original;
|
|
1145
|
-
return res?.url || null;
|
|
1146
|
-
}
|
|
1147
|
-
function thumbnailUrl(service, storageUrl = "") {
|
|
1148
|
-
const path = getGalleryThumbnail(service.gallery);
|
|
1149
|
-
return path ? `${storageUrl}/${path}` : null;
|
|
1150
|
-
}
|
|
1151
1174
|
|
|
1152
1175
|
// src/utils/currency.ts
|
|
1153
1176
|
function getCurrencySymbol(currency) {
|
|
@@ -1497,7 +1520,7 @@ async function injectSvgIntoElement(mediaObject, targetElement, className) {
|
|
|
1497
1520
|
}
|
|
1498
1521
|
|
|
1499
1522
|
// src/index.ts
|
|
1500
|
-
var SDK_VERSION = "0.3.
|
|
1523
|
+
var SDK_VERSION = "0.3.30";
|
|
1501
1524
|
var SUPPORTED_FRAMEWORKS = [
|
|
1502
1525
|
"astro",
|
|
1503
1526
|
"react",
|
|
@@ -1506,8 +1529,9 @@ var SUPPORTED_FRAMEWORKS = [
|
|
|
1506
1529
|
"vanilla"
|
|
1507
1530
|
];
|
|
1508
1531
|
function createArkySDK(config) {
|
|
1532
|
+
const locale = config.locale || "en";
|
|
1509
1533
|
console.log(
|
|
1510
|
-
`[Arky SDK v${SDK_VERSION}] Initializing with market: ${config.market}, businessId: ${config.businessId}`
|
|
1534
|
+
`[Arky SDK v${SDK_VERSION}] Initializing with market: ${config.market}, businessId: ${config.businessId}, locale: ${locale}`
|
|
1511
1535
|
);
|
|
1512
1536
|
const httpClient = createHttpClient(config);
|
|
1513
1537
|
const storageUrl = config.storageUrl || "https://storage.arky.io/dev";
|
|
@@ -1517,6 +1541,7 @@ function createArkySDK(config) {
|
|
|
1517
1541
|
storageUrl,
|
|
1518
1542
|
baseUrl: config.baseUrl,
|
|
1519
1543
|
market: config.market,
|
|
1544
|
+
locale,
|
|
1520
1545
|
setToken: config.setToken,
|
|
1521
1546
|
getToken: config.getToken
|
|
1522
1547
|
};
|
|
@@ -1542,14 +1567,16 @@ function createArkySDK(config) {
|
|
|
1542
1567
|
apiConfig.market = market;
|
|
1543
1568
|
},
|
|
1544
1569
|
getMarket: () => apiConfig.market,
|
|
1570
|
+
setLocale: (locale2) => {
|
|
1571
|
+
apiConfig.locale = locale2;
|
|
1572
|
+
},
|
|
1573
|
+
getLocale: () => apiConfig.locale,
|
|
1545
1574
|
isAuthenticated: config.isAuthenticated || (() => false),
|
|
1546
1575
|
logout: config.logout,
|
|
1547
1576
|
setToken: config.setToken,
|
|
1548
1577
|
utils: {
|
|
1549
1578
|
// Block utilities
|
|
1550
1579
|
getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock, storageUrl),
|
|
1551
|
-
thumbnailUrl: (service) => thumbnailUrl(service, storageUrl),
|
|
1552
|
-
getGalleryThumbnail,
|
|
1553
1580
|
getBlockValue,
|
|
1554
1581
|
getBlockValues,
|
|
1555
1582
|
getBlockLabel,
|