arky-sdk 0.3.4 → 0.3.6
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 +109 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +109 -48
- package/dist/index.js.map +1 -1
- package/dist/types.d.cts +7 -23
- package/dist/types.d.ts +7 -23
- package/dist/utils.cjs +13 -4
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +13 -4
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateCollectionParams, RequestOptions, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, CreateProductParams, UpdateProductParams, GetProductParams, GetProductsParams,
|
|
1
|
+
import { CreateCollectionParams, RequestOptions, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, CreateProductParams, UpdateProductParams, 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, NewsletterFindParams, NewsletterGetParams, CreateNewsletterParams, UpdateNewsletterParams, DeleteNewsletterParams, GetSubscribersParams, NewsletterSubscribeParams, UnsubscribeParams, UpdateUserProfileParams, UpdateProfilePhoneParams, VerifyPhoneCodeParams, GetUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionParams, CreateSubscriptionParams, UpdateSubscriptionParams, CancelSubscriptionParams, ReactivateSubscriptionParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, GetNotificationsParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, GetAnalyticsHealthParams, SetupAnalyticsParams, HandleStripeWebhookParams, GetBusinessMarketsParams, GetBusinessMarketParams } from './types.cjs';
|
|
2
2
|
export { ApiResponse, ApplyPromoCodeParams, Block, Business, BusinessConfig, BusinessPaymentMethod, CreateCollectionEntryParams, DeleteEntryParams, DeleteProductParams, EshopCartItem, EshopItem, EshopStoreState, GenerateBlocksParams, GetAllProductsParams, GetAllServicesParams, GetCollectionEntriesParams, GetEntryParams, GetInvoiceParams, GetPermissionsParams, GetPromoCodeByCodeParams, GetProvidersByServiceParams, GetRoleParentsParams, GetUserLocationParams, Location, LogoutParams, Market, MarketConfigClient, Newsletter, OAuthLoginParams, PaginatedResponse, Payment, PaymentMethod, PaymentProviderConfig, Price, PromoCodeValidation, Quote, QuoteLineItem, ReservationCartPart, ReservationConfirmParams, ReservationStoreState, ScheduleSetParams, SearchAvailableSlotsParams, ShippingMethod, UpdatePromoCodeStatusParams, UpdateUserParams, ValidatePromoCodeParams, Zone } from './types.cjs';
|
|
3
3
|
import { g as getGalleryThumbnail, a as getMarketPrice, b as getPriceAmount, f as formatPayment, c as formatMinor, d as createPaymentForCheckout, e as getCurrencySymbol, v as validatePhoneNumber, h as findTimeZone } from './index-DOEos-hV.cjs';
|
|
4
4
|
export { C as Collection, i as CollectionEntry, E as ERROR_CODES, x as ERROR_CONSTANTS, R as RequestError, S as SYMBOL_AFTER_CURRENCIES, y as ServerError, V as ValidationError, U as ValidationResult, P as categorify, D as convertServerErrorToRequestError, G as convertToMajor, H as convertToMinor, F as errors, l as extractBlockValues, K as fetchSvgContent, k as formatBlockValue, J as formatCurrencyAmount, Q as formatDate, r as getBlockFromArray, j as getBlockLabel, q as getBlockObjectValues, m as getBlockTextValue, n as getBlockValue, o as getBlockValues, I as getCurrencyFromMarket, z as getErrorMessage, s as getImageUrl, L as getSvgContentForAstro, O as humanize, M as injectSvgIntoElement, A as isErrorCode, w as isSymbolAfterCurrency, p as prepareBlocksForSubmission, N as slugify, t as thumbnailUrl, B as transformErrors, u as translateMap, T as tzGroups, W as validateEmail, Y as validateRequired, X as validateVerificationCode } from './index-DOEos-hV.cjs';
|
|
@@ -49,7 +49,6 @@ declare const createEshopApi: (apiConfig: ApiConfig) => {
|
|
|
49
49
|
deleteProduct(id: string, options?: RequestOptions): Promise<any>;
|
|
50
50
|
getProduct(params: GetProductParams, options?: RequestOptions): Promise<any>;
|
|
51
51
|
getProducts(params?: GetProductsParams, options?: RequestOptions): Promise<any>;
|
|
52
|
-
getProductBySlug(params: GetProductBySlugParams, options?: RequestOptions): Promise<any>;
|
|
53
52
|
createOrder(params: CreateOrderParams, options?: RequestOptions): Promise<any>;
|
|
54
53
|
updateOrder(params: UpdateOrderParams, options?: RequestOptions): Promise<any>;
|
|
55
54
|
getOrder(params: GetOrderParams, options?: RequestOptions): Promise<any>;
|
|
@@ -214,7 +213,7 @@ declare function buildQueryString(params: QueryParams): string;
|
|
|
214
213
|
*/
|
|
215
214
|
declare function appendQueryString(url: string, params: QueryParams): string;
|
|
216
215
|
|
|
217
|
-
declare const SDK_VERSION = "0.3.
|
|
216
|
+
declare const SDK_VERSION = "0.3.5";
|
|
218
217
|
declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
|
|
219
218
|
interface ApiConfig {
|
|
220
219
|
httpClient: any;
|
|
@@ -227,7 +226,7 @@ interface ApiConfig {
|
|
|
227
226
|
}
|
|
228
227
|
|
|
229
228
|
declare function createArkySDK(config: HttpClientConfig & {
|
|
230
|
-
market
|
|
229
|
+
market: string;
|
|
231
230
|
}): {
|
|
232
231
|
user: {
|
|
233
232
|
updateUser(params: UpdateUserProfileParams, options?: RequestOptions): Promise<any>;
|
|
@@ -330,7 +329,6 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
330
329
|
deleteProduct(id: string, options?: RequestOptions): Promise<any>;
|
|
331
330
|
getProduct(params: GetProductParams, options?: RequestOptions): Promise<any>;
|
|
332
331
|
getProducts(params?: GetProductsParams, options?: RequestOptions): Promise<any>;
|
|
333
|
-
getProductBySlug(params: GetProductBySlugParams, options?: RequestOptions): Promise<any>;
|
|
334
332
|
createOrder(params: CreateOrderParams, options?: RequestOptions): Promise<any>;
|
|
335
333
|
updateOrder(params: UpdateOrderParams, options?: RequestOptions): Promise<any>;
|
|
336
334
|
getOrder(params: GetOrderParams, options?: RequestOptions): Promise<any>;
|
|
@@ -380,6 +378,8 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
380
378
|
};
|
|
381
379
|
setBusinessId: (businessId: string) => void;
|
|
382
380
|
getBusinessId: () => string;
|
|
381
|
+
setMarket: (market: string) => void;
|
|
382
|
+
getMarket: () => string;
|
|
383
383
|
isAuthenticated: () => boolean;
|
|
384
384
|
logout: () => void;
|
|
385
385
|
setToken: (tokens: AuthTokens) => void;
|
|
@@ -405,4 +405,4 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
405
405
|
};
|
|
406
406
|
};
|
|
407
407
|
|
|
408
|
-
export { type ApiConfig, CancelSubscriptionParams, CheckoutParams, ConfirmUserParams, CreateBusinessParams, CreateCollectionParams, CreateEntryParams, CreateNewsletterParams, CreateOrderParams, CreatePortalSessionParams, CreateProductParams, CreatePromoCodeParams, CreateProviderParams, CreateReservationParams, CreateRoleParams, CreateServiceParams, CreateSubscriptionParams, DeleteBusinessMediaParams, DeleteBusinessParams, DeleteCollectionEntryParams, DeleteCollectionParams, DeleteNewsletterParams, DeletePromoCodeParams, DeleteProviderParams, DeleteRoleParams, DeleteServiceParams, ForgotPasswordParams, GetAnalyticsHealthParams, GetAnalyticsParams, GetAvailableSlotsParams, GetBusinessMarketParams, GetBusinessMarketsParams, GetBusinessMediaParams, GetBusinessParams, GetBusinessParentsParams, GetBusinessServiceWorkingTimeParams, GetCollectionEntryParams, GetCollectionParams, GetCollectionsParams, GetDeliveryStatsParams, GetEntriesParams, GetLoginUrlParams, GetNotificationsParams, GetOrderParams, GetOrdersParams,
|
|
408
|
+
export { type ApiConfig, CancelSubscriptionParams, CheckoutParams, ConfirmUserParams, CreateBusinessParams, CreateCollectionParams, CreateEntryParams, CreateNewsletterParams, CreateOrderParams, CreatePortalSessionParams, CreateProductParams, CreatePromoCodeParams, CreateProviderParams, CreateReservationParams, CreateRoleParams, CreateServiceParams, CreateSubscriptionParams, DeleteBusinessMediaParams, DeleteBusinessParams, DeleteCollectionEntryParams, DeleteCollectionParams, DeleteNewsletterParams, DeletePromoCodeParams, DeleteProviderParams, DeleteRoleParams, DeleteServiceParams, ForgotPasswordParams, GetAnalyticsHealthParams, GetAnalyticsParams, GetAvailableSlotsParams, GetBusinessMarketParams, GetBusinessMarketsParams, GetBusinessMediaParams, GetBusinessParams, GetBusinessParentsParams, GetBusinessServiceWorkingTimeParams, GetCollectionEntryParams, GetCollectionParams, GetCollectionsParams, GetDeliveryStatsParams, GetEntriesParams, GetLoginUrlParams, GetNotificationsParams, GetOrderParams, GetOrdersParams, GetProductParams, GetProductsParams, GetPromoCodeParams, GetPromoCodesParams, GetProviderParams, GetProvidersParams, GetQuoteParams, GetReservationParams, GetReservationPartsParams, GetReservationQuoteParams, GetRoleParams, GetRolesParams, GetServiceParams, GetServicesParams, GetSubscribersParams, GetSubscriptionParams, GetUsersParams, GetVariableMetadataParams, HandleInvitationParams, HandleStripeWebhookParams, type HttpClientConfig, InviteUserParams, LoginUserParams, NewsletterFindParams, NewsletterGetParams, NewsletterSubscribeParams, type QueryParams, ReactivateSubscriptionParams, RegisterUserParams, RequestOptions, ReservationCheckoutParams, ResetForgotPasswordParams, ResetPasswordParams, SDK_VERSION, SUPPORTED_FRAMEWORKS, SearchMyReservationsParams, SearchReservationsParams, SendEntryParams, SetRoleParams, SetupAnalyticsParams, TestWebhookParams, TrackEmailOpenParams, TriggerBuildsParams, UnsubscribeParams, UpdateBusinessParams, UpdateCollectionParams, UpdateEntryParams, UpdateNewsletterParams, UpdateOrderParams, UpdateOrderPaymentStatusParams, UpdateOrderStatusParams, UpdateProductParams, UpdateProfilePhoneParams, UpdatePromoCodeParams, UpdateProviderParams, UpdateReservationParams, UpdateRoleParams, UpdateServiceParams, UpdateSubscriptionParams, UpdateUserProfileParams, UploadBusinessMediaParams, VerifyPhoneCodeParams, appendQueryString, buildQueryString, createAnalyticsApi, createArkySDK, createBusinessApi, createCmsApi, createEshopApi, createMediaApi, createNewsletterApi, createNotificationApi, createPaymentApi, createPaymentForCheckout, createPromoCodeApi, createReservationApi, createRoleApi, createUserApi, findTimeZone, formatMinor, formatPayment, getCurrencySymbol, getGalleryThumbnail, getLocale, getLocaleFromUrl, getLocalizedString, getMarketPrice, getPriceAmount, setDefaultLocale, validatePhoneNumber };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateCollectionParams, RequestOptions, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, CreateProductParams, UpdateProductParams, GetProductParams, GetProductsParams,
|
|
1
|
+
import { CreateCollectionParams, RequestOptions, UpdateCollectionParams, DeleteCollectionParams, GetCollectionParams, GetCollectionsParams, GetEntriesParams, CreateEntryParams, UpdateEntryParams, DeleteCollectionEntryParams, GetCollectionEntryParams, SendEntryParams, GetVariableMetadataParams, CreateProductParams, UpdateProductParams, 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, NewsletterFindParams, NewsletterGetParams, CreateNewsletterParams, UpdateNewsletterParams, DeleteNewsletterParams, GetSubscribersParams, NewsletterSubscribeParams, UnsubscribeParams, UpdateUserProfileParams, UpdateProfilePhoneParams, VerifyPhoneCodeParams, GetUsersParams, SetRoleParams, LoginUserParams, RegisterUserParams, ConfirmUserParams, GetLoginUrlParams, ForgotPasswordParams, ResetForgotPasswordParams, ResetPasswordParams, CreateBusinessParams, UpdateBusinessParams, DeleteBusinessParams, GetBusinessParams, GetBusinessParentsParams, TriggerBuildsParams, GetSubscriptionParams, CreateSubscriptionParams, UpdateSubscriptionParams, CancelSubscriptionParams, ReactivateSubscriptionParams, CreatePortalSessionParams, InviteUserParams, HandleInvitationParams, TestWebhookParams, UploadBusinessMediaParams, DeleteBusinessMediaParams, GetBusinessMediaParams, CreateRoleParams, UpdateRoleParams, DeleteRoleParams, GetRoleParams, GetRolesParams, GetNotificationsParams, TrackEmailOpenParams, GetDeliveryStatsParams, CreatePromoCodeParams, UpdatePromoCodeParams, DeletePromoCodeParams, GetPromoCodeParams, GetPromoCodesParams, GetAnalyticsParams, GetAnalyticsHealthParams, SetupAnalyticsParams, HandleStripeWebhookParams, GetBusinessMarketsParams, GetBusinessMarketParams } from './types.js';
|
|
2
2
|
export { ApiResponse, ApplyPromoCodeParams, Block, Business, BusinessConfig, BusinessPaymentMethod, CreateCollectionEntryParams, DeleteEntryParams, DeleteProductParams, EshopCartItem, EshopItem, EshopStoreState, GenerateBlocksParams, GetAllProductsParams, GetAllServicesParams, GetCollectionEntriesParams, GetEntryParams, GetInvoiceParams, GetPermissionsParams, GetPromoCodeByCodeParams, GetProvidersByServiceParams, GetRoleParentsParams, GetUserLocationParams, Location, LogoutParams, Market, MarketConfigClient, Newsletter, OAuthLoginParams, PaginatedResponse, Payment, PaymentMethod, PaymentProviderConfig, Price, PromoCodeValidation, Quote, QuoteLineItem, ReservationCartPart, ReservationConfirmParams, ReservationStoreState, ScheduleSetParams, SearchAvailableSlotsParams, ShippingMethod, UpdatePromoCodeStatusParams, UpdateUserParams, ValidatePromoCodeParams, Zone } from './types.js';
|
|
3
3
|
import { g as getGalleryThumbnail, a as getMarketPrice, b as getPriceAmount, f as formatPayment, c as formatMinor, d as createPaymentForCheckout, e as getCurrencySymbol, v as validatePhoneNumber, h as findTimeZone } from './index-DEmVFs0E.js';
|
|
4
4
|
export { C as Collection, i as CollectionEntry, E as ERROR_CODES, x as ERROR_CONSTANTS, R as RequestError, S as SYMBOL_AFTER_CURRENCIES, y as ServerError, V as ValidationError, U as ValidationResult, P as categorify, D as convertServerErrorToRequestError, G as convertToMajor, H as convertToMinor, F as errors, l as extractBlockValues, K as fetchSvgContent, k as formatBlockValue, J as formatCurrencyAmount, Q as formatDate, r as getBlockFromArray, j as getBlockLabel, q as getBlockObjectValues, m as getBlockTextValue, n as getBlockValue, o as getBlockValues, I as getCurrencyFromMarket, z as getErrorMessage, s as getImageUrl, L as getSvgContentForAstro, O as humanize, M as injectSvgIntoElement, A as isErrorCode, w as isSymbolAfterCurrency, p as prepareBlocksForSubmission, N as slugify, t as thumbnailUrl, B as transformErrors, u as translateMap, T as tzGroups, W as validateEmail, Y as validateRequired, X as validateVerificationCode } from './index-DEmVFs0E.js';
|
|
@@ -49,7 +49,6 @@ declare const createEshopApi: (apiConfig: ApiConfig) => {
|
|
|
49
49
|
deleteProduct(id: string, options?: RequestOptions): Promise<any>;
|
|
50
50
|
getProduct(params: GetProductParams, options?: RequestOptions): Promise<any>;
|
|
51
51
|
getProducts(params?: GetProductsParams, options?: RequestOptions): Promise<any>;
|
|
52
|
-
getProductBySlug(params: GetProductBySlugParams, options?: RequestOptions): Promise<any>;
|
|
53
52
|
createOrder(params: CreateOrderParams, options?: RequestOptions): Promise<any>;
|
|
54
53
|
updateOrder(params: UpdateOrderParams, options?: RequestOptions): Promise<any>;
|
|
55
54
|
getOrder(params: GetOrderParams, options?: RequestOptions): Promise<any>;
|
|
@@ -214,7 +213,7 @@ declare function buildQueryString(params: QueryParams): string;
|
|
|
214
213
|
*/
|
|
215
214
|
declare function appendQueryString(url: string, params: QueryParams): string;
|
|
216
215
|
|
|
217
|
-
declare const SDK_VERSION = "0.3.
|
|
216
|
+
declare const SDK_VERSION = "0.3.5";
|
|
218
217
|
declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
|
|
219
218
|
interface ApiConfig {
|
|
220
219
|
httpClient: any;
|
|
@@ -227,7 +226,7 @@ interface ApiConfig {
|
|
|
227
226
|
}
|
|
228
227
|
|
|
229
228
|
declare function createArkySDK(config: HttpClientConfig & {
|
|
230
|
-
market
|
|
229
|
+
market: string;
|
|
231
230
|
}): {
|
|
232
231
|
user: {
|
|
233
232
|
updateUser(params: UpdateUserProfileParams, options?: RequestOptions): Promise<any>;
|
|
@@ -330,7 +329,6 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
330
329
|
deleteProduct(id: string, options?: RequestOptions): Promise<any>;
|
|
331
330
|
getProduct(params: GetProductParams, options?: RequestOptions): Promise<any>;
|
|
332
331
|
getProducts(params?: GetProductsParams, options?: RequestOptions): Promise<any>;
|
|
333
|
-
getProductBySlug(params: GetProductBySlugParams, options?: RequestOptions): Promise<any>;
|
|
334
332
|
createOrder(params: CreateOrderParams, options?: RequestOptions): Promise<any>;
|
|
335
333
|
updateOrder(params: UpdateOrderParams, options?: RequestOptions): Promise<any>;
|
|
336
334
|
getOrder(params: GetOrderParams, options?: RequestOptions): Promise<any>;
|
|
@@ -380,6 +378,8 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
380
378
|
};
|
|
381
379
|
setBusinessId: (businessId: string) => void;
|
|
382
380
|
getBusinessId: () => string;
|
|
381
|
+
setMarket: (market: string) => void;
|
|
382
|
+
getMarket: () => string;
|
|
383
383
|
isAuthenticated: () => boolean;
|
|
384
384
|
logout: () => void;
|
|
385
385
|
setToken: (tokens: AuthTokens) => void;
|
|
@@ -405,4 +405,4 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
405
405
|
};
|
|
406
406
|
};
|
|
407
407
|
|
|
408
|
-
export { type ApiConfig, CancelSubscriptionParams, CheckoutParams, ConfirmUserParams, CreateBusinessParams, CreateCollectionParams, CreateEntryParams, CreateNewsletterParams, CreateOrderParams, CreatePortalSessionParams, CreateProductParams, CreatePromoCodeParams, CreateProviderParams, CreateReservationParams, CreateRoleParams, CreateServiceParams, CreateSubscriptionParams, DeleteBusinessMediaParams, DeleteBusinessParams, DeleteCollectionEntryParams, DeleteCollectionParams, DeleteNewsletterParams, DeletePromoCodeParams, DeleteProviderParams, DeleteRoleParams, DeleteServiceParams, ForgotPasswordParams, GetAnalyticsHealthParams, GetAnalyticsParams, GetAvailableSlotsParams, GetBusinessMarketParams, GetBusinessMarketsParams, GetBusinessMediaParams, GetBusinessParams, GetBusinessParentsParams, GetBusinessServiceWorkingTimeParams, GetCollectionEntryParams, GetCollectionParams, GetCollectionsParams, GetDeliveryStatsParams, GetEntriesParams, GetLoginUrlParams, GetNotificationsParams, GetOrderParams, GetOrdersParams,
|
|
408
|
+
export { type ApiConfig, CancelSubscriptionParams, CheckoutParams, ConfirmUserParams, CreateBusinessParams, CreateCollectionParams, CreateEntryParams, CreateNewsletterParams, CreateOrderParams, CreatePortalSessionParams, CreateProductParams, CreatePromoCodeParams, CreateProviderParams, CreateReservationParams, CreateRoleParams, CreateServiceParams, CreateSubscriptionParams, DeleteBusinessMediaParams, DeleteBusinessParams, DeleteCollectionEntryParams, DeleteCollectionParams, DeleteNewsletterParams, DeletePromoCodeParams, DeleteProviderParams, DeleteRoleParams, DeleteServiceParams, ForgotPasswordParams, GetAnalyticsHealthParams, GetAnalyticsParams, GetAvailableSlotsParams, GetBusinessMarketParams, GetBusinessMarketsParams, GetBusinessMediaParams, GetBusinessParams, GetBusinessParentsParams, GetBusinessServiceWorkingTimeParams, GetCollectionEntryParams, GetCollectionParams, GetCollectionsParams, GetDeliveryStatsParams, GetEntriesParams, GetLoginUrlParams, GetNotificationsParams, GetOrderParams, GetOrdersParams, GetProductParams, GetProductsParams, GetPromoCodeParams, GetPromoCodesParams, GetProviderParams, GetProvidersParams, GetQuoteParams, GetReservationParams, GetReservationPartsParams, GetReservationQuoteParams, GetRoleParams, GetRolesParams, GetServiceParams, GetServicesParams, GetSubscribersParams, GetSubscriptionParams, GetUsersParams, GetVariableMetadataParams, HandleInvitationParams, HandleStripeWebhookParams, type HttpClientConfig, InviteUserParams, LoginUserParams, NewsletterFindParams, NewsletterGetParams, NewsletterSubscribeParams, type QueryParams, ReactivateSubscriptionParams, RegisterUserParams, RequestOptions, ReservationCheckoutParams, ResetForgotPasswordParams, ResetPasswordParams, SDK_VERSION, SUPPORTED_FRAMEWORKS, SearchMyReservationsParams, SearchReservationsParams, SendEntryParams, SetRoleParams, SetupAnalyticsParams, TestWebhookParams, TrackEmailOpenParams, TriggerBuildsParams, UnsubscribeParams, UpdateBusinessParams, UpdateCollectionParams, UpdateEntryParams, UpdateNewsletterParams, UpdateOrderParams, UpdateOrderPaymentStatusParams, UpdateOrderStatusParams, UpdateProductParams, UpdateProfilePhoneParams, UpdatePromoCodeParams, UpdateProviderParams, UpdateReservationParams, UpdateRoleParams, UpdateServiceParams, UpdateSubscriptionParams, UpdateUserProfileParams, UploadBusinessMediaParams, VerifyPhoneCodeParams, appendQueryString, buildQueryString, createAnalyticsApi, createArkySDK, createBusinessApi, createCmsApi, createEshopApi, createMediaApi, createNewsletterApi, createNotificationApi, createPaymentApi, createPaymentForCheckout, createPromoCodeApi, createReservationApi, createRoleApi, createUserApi, findTimeZone, formatMinor, formatPayment, getCurrencySymbol, getGalleryThumbnail, getLocale, getLocaleFromUrl, getLocalizedString, getMarketPrice, getPriceAmount, setDefaultLocale, validatePhoneNumber };
|
package/dist/index.js
CHANGED
|
@@ -163,13 +163,6 @@ var createEshopApi = (apiConfig) => {
|
|
|
163
163
|
}
|
|
164
164
|
);
|
|
165
165
|
},
|
|
166
|
-
async getProductBySlug(params, options) {
|
|
167
|
-
const { businessId, slug } = params;
|
|
168
|
-
return apiConfig.httpClient.get(
|
|
169
|
-
`/v1/businesses/${encodeURIComponent(businessId)}/products/slug/${encodeURIComponent(businessId)}/${encodeURIComponent(slug)}`,
|
|
170
|
-
options
|
|
171
|
-
);
|
|
172
|
-
},
|
|
173
166
|
// ===== ORDERS =====
|
|
174
167
|
async createOrder(params, options) {
|
|
175
168
|
return apiConfig.httpClient.post(
|
|
@@ -224,7 +217,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
224
217
|
}));
|
|
225
218
|
const payload = {
|
|
226
219
|
businessId: apiConfig.businessId,
|
|
227
|
-
market:
|
|
220
|
+
market: apiConfig.market,
|
|
228
221
|
currency: params.currency,
|
|
229
222
|
paymentMethod: params.paymentMethod,
|
|
230
223
|
lines,
|
|
@@ -236,7 +229,7 @@ var createEshopApi = (apiConfig) => {
|
|
|
236
229
|
async checkout(params, options) {
|
|
237
230
|
const payload = {
|
|
238
231
|
businessId: apiConfig.businessId,
|
|
239
|
-
market:
|
|
232
|
+
market: apiConfig.market,
|
|
240
233
|
paymentMethod: params.paymentMethod,
|
|
241
234
|
shippingMethodId: params.shippingMethodId,
|
|
242
235
|
items: params.items,
|
|
@@ -274,8 +267,8 @@ var createReservationApi = (apiConfig) => {
|
|
|
274
267
|
async checkout(params, options) {
|
|
275
268
|
const payload = {
|
|
276
269
|
businessId: apiConfig.businessId,
|
|
270
|
+
market: apiConfig.market,
|
|
277
271
|
blocks: params.blocks || [],
|
|
278
|
-
market: params.market || "US",
|
|
279
272
|
parts: params.parts,
|
|
280
273
|
...params.paymentMethod && { paymentMethod: params.paymentMethod },
|
|
281
274
|
...params.promoCode && { promoCode: params.promoCode }
|
|
@@ -319,7 +312,7 @@ var createReservationApi = (apiConfig) => {
|
|
|
319
312
|
}));
|
|
320
313
|
const payload = {
|
|
321
314
|
businessId: apiConfig.businessId,
|
|
322
|
-
market:
|
|
315
|
+
market: apiConfig.market,
|
|
323
316
|
currency: params.currency,
|
|
324
317
|
paymentMethod: params.paymentMethod,
|
|
325
318
|
lines,
|
|
@@ -482,7 +475,7 @@ var createNewsletterApi = (apiConfig) => {
|
|
|
482
475
|
const payload = {
|
|
483
476
|
newsletterId,
|
|
484
477
|
email,
|
|
485
|
-
market:
|
|
478
|
+
market: apiConfig.market,
|
|
486
479
|
...customerId && { customerId },
|
|
487
480
|
...payment && { payment }
|
|
488
481
|
};
|
|
@@ -1366,11 +1359,14 @@ function getMarketPrice(prices, marketId, businessMarkets, options = {}) {
|
|
|
1366
1359
|
showSymbols = true,
|
|
1367
1360
|
decimalPlaces = 2,
|
|
1368
1361
|
showCompareAt = true,
|
|
1369
|
-
fallbackMarket
|
|
1362
|
+
fallbackMarket
|
|
1370
1363
|
} = options;
|
|
1371
1364
|
let price = prices.find((p) => p.market === marketId);
|
|
1365
|
+
if (!price && fallbackMarket) {
|
|
1366
|
+
price = prices.find((p) => p.market === fallbackMarket);
|
|
1367
|
+
}
|
|
1372
1368
|
if (!price) {
|
|
1373
|
-
price = prices
|
|
1369
|
+
price = prices[0];
|
|
1374
1370
|
}
|
|
1375
1371
|
if (!price) return "";
|
|
1376
1372
|
let currency;
|
|
@@ -1403,9 +1399,15 @@ function getMarketPrice(prices, marketId, businessMarkets, options = {}) {
|
|
|
1403
1399
|
}
|
|
1404
1400
|
return formattedPrice;
|
|
1405
1401
|
}
|
|
1406
|
-
function getPriceAmount(prices, marketId, fallbackMarket
|
|
1402
|
+
function getPriceAmount(prices, marketId, fallbackMarket) {
|
|
1407
1403
|
if (!prices || prices.length === 0) return 0;
|
|
1408
|
-
|
|
1404
|
+
let price = prices.find((p) => p.market === marketId);
|
|
1405
|
+
if (!price && fallbackMarket) {
|
|
1406
|
+
price = prices.find((p) => p.market === fallbackMarket);
|
|
1407
|
+
}
|
|
1408
|
+
if (!price) {
|
|
1409
|
+
price = prices[0];
|
|
1410
|
+
}
|
|
1409
1411
|
return price?.amount || 0;
|
|
1410
1412
|
}
|
|
1411
1413
|
function createPaymentForCheckout(subtotalMinor, marketId, currency, paymentMethod, options = {}) {
|
|
@@ -1618,6 +1620,39 @@ function validateRequired(value, fieldName = "This field") {
|
|
|
1618
1620
|
// src/services/createHttpClient.ts
|
|
1619
1621
|
function createHttpClient(cfg) {
|
|
1620
1622
|
const refreshEndpoint = `${cfg.baseUrl}/v1/users/refresh-access-token`;
|
|
1623
|
+
let refreshPromise = null;
|
|
1624
|
+
async function ensureFreshToken() {
|
|
1625
|
+
if (refreshPromise) {
|
|
1626
|
+
return refreshPromise;
|
|
1627
|
+
}
|
|
1628
|
+
refreshPromise = (async () => {
|
|
1629
|
+
const { refreshToken, provider } = await cfg.getToken();
|
|
1630
|
+
if (!refreshToken) {
|
|
1631
|
+
cfg.logout();
|
|
1632
|
+
const err = new Error("No refresh token available");
|
|
1633
|
+
err.name = "ApiError";
|
|
1634
|
+
err.statusCode = 401;
|
|
1635
|
+
throw err;
|
|
1636
|
+
}
|
|
1637
|
+
const refRes = await fetch(refreshEndpoint, {
|
|
1638
|
+
method: "POST",
|
|
1639
|
+
headers: { Accept: "application/json", "Content-Type": "application/json" },
|
|
1640
|
+
body: JSON.stringify({ provider, refreshToken })
|
|
1641
|
+
});
|
|
1642
|
+
if (!refRes.ok) {
|
|
1643
|
+
cfg.logout();
|
|
1644
|
+
const err = new Error("Token refresh failed");
|
|
1645
|
+
err.name = "ApiError";
|
|
1646
|
+
err.statusCode = 401;
|
|
1647
|
+
throw err;
|
|
1648
|
+
}
|
|
1649
|
+
const data = await refRes.json();
|
|
1650
|
+
cfg.setToken(data);
|
|
1651
|
+
})().finally(() => {
|
|
1652
|
+
refreshPromise = null;
|
|
1653
|
+
});
|
|
1654
|
+
return refreshPromise;
|
|
1655
|
+
}
|
|
1621
1656
|
async function request(method, path, body, options) {
|
|
1622
1657
|
if (options?.transformRequest) {
|
|
1623
1658
|
body = options.transformRequest(body);
|
|
@@ -1627,33 +1662,12 @@ function createHttpClient(cfg) {
|
|
|
1627
1662
|
"Content-Type": "application/json",
|
|
1628
1663
|
...options?.headers || {}
|
|
1629
1664
|
};
|
|
1630
|
-
let { accessToken,
|
|
1665
|
+
let { accessToken, expiresAt } = await cfg.getToken();
|
|
1631
1666
|
const nowSec = Date.now() / 1e3;
|
|
1632
1667
|
if (expiresAt && nowSec > expiresAt) {
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
headers: { Accept: "application/json", "Content-Type": "application/json" },
|
|
1637
|
-
body: JSON.stringify({ provider, refreshToken })
|
|
1638
|
-
});
|
|
1639
|
-
if (refRes.ok) {
|
|
1640
|
-
const data2 = await refRes.json();
|
|
1641
|
-
cfg.setToken(data2);
|
|
1642
|
-
accessToken = data2.accessToken;
|
|
1643
|
-
} else {
|
|
1644
|
-
cfg.logout();
|
|
1645
|
-
const err = new Error("Error refreshing token");
|
|
1646
|
-
err.name = "ApiError";
|
|
1647
|
-
err.statusCode = 401;
|
|
1648
|
-
throw err;
|
|
1649
|
-
}
|
|
1650
|
-
} else {
|
|
1651
|
-
cfg.logout();
|
|
1652
|
-
const err = new Error("No refresh token");
|
|
1653
|
-
err.name = "ApiError";
|
|
1654
|
-
err.statusCode = 401;
|
|
1655
|
-
throw err;
|
|
1656
|
-
}
|
|
1668
|
+
await ensureFreshToken();
|
|
1669
|
+
const tokens = await cfg.getToken();
|
|
1670
|
+
accessToken = tokens.accessToken;
|
|
1657
1671
|
}
|
|
1658
1672
|
if (accessToken) {
|
|
1659
1673
|
headers["Authorization"] = `Bearer ${accessToken}`;
|
|
@@ -1663,15 +1677,42 @@ function createHttpClient(cfg) {
|
|
|
1663
1677
|
if (!["GET", "DELETE"].includes(method) && body !== void 0) {
|
|
1664
1678
|
fetchOpts.body = JSON.stringify(body);
|
|
1665
1679
|
}
|
|
1680
|
+
const fullUrl = `${cfg.baseUrl}${finalPath}`;
|
|
1666
1681
|
let res;
|
|
1667
1682
|
let data;
|
|
1668
1683
|
try {
|
|
1669
|
-
const fullUrl = `${cfg.baseUrl}${finalPath}`;
|
|
1670
1684
|
res = await fetch(fullUrl, fetchOpts);
|
|
1671
|
-
data = await res.json();
|
|
1672
1685
|
} catch (error) {
|
|
1673
1686
|
const err = new Error(error instanceof Error ? error.message : "Network request failed");
|
|
1674
1687
|
err.name = "NetworkError";
|
|
1688
|
+
err.method = method;
|
|
1689
|
+
err.url = fullUrl;
|
|
1690
|
+
throw err;
|
|
1691
|
+
}
|
|
1692
|
+
if (res.status === 401 && !options?.["_retried"]) {
|
|
1693
|
+
try {
|
|
1694
|
+
await ensureFreshToken();
|
|
1695
|
+
const tokens = await cfg.getToken();
|
|
1696
|
+
headers["Authorization"] = `Bearer ${tokens.accessToken}`;
|
|
1697
|
+
fetchOpts.headers = headers;
|
|
1698
|
+
return request(method, path, body, { ...options, _retried: true });
|
|
1699
|
+
} catch (refreshError) {
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
try {
|
|
1703
|
+
const contentLength = res.headers.get("content-length");
|
|
1704
|
+
const contentType = res.headers.get("content-type");
|
|
1705
|
+
if (res.status === 204 || contentLength === "0" || !contentType?.includes("application/json")) {
|
|
1706
|
+
data = {};
|
|
1707
|
+
} else {
|
|
1708
|
+
data = await res.json();
|
|
1709
|
+
}
|
|
1710
|
+
} catch (error) {
|
|
1711
|
+
const err = new Error("Failed to parse response");
|
|
1712
|
+
err.name = "ParseError";
|
|
1713
|
+
err.method = method;
|
|
1714
|
+
err.url = fullUrl;
|
|
1715
|
+
err.status = res.status;
|
|
1675
1716
|
throw err;
|
|
1676
1717
|
}
|
|
1677
1718
|
if (!res.ok) {
|
|
@@ -1682,8 +1723,12 @@ function createHttpClient(cfg) {
|
|
|
1682
1723
|
}
|
|
1683
1724
|
const err = new Error(serverErr.message || "Request failed");
|
|
1684
1725
|
err.name = "ApiError";
|
|
1685
|
-
err.statusCode = serverErr.statusCode;
|
|
1726
|
+
err.statusCode = serverErr.statusCode || res.status;
|
|
1686
1727
|
err.validationErrors = reqErr.validationErrors;
|
|
1728
|
+
err.method = method;
|
|
1729
|
+
err.url = fullUrl;
|
|
1730
|
+
const requestId = res.headers.get("x-request-id") || res.headers.get("request-id");
|
|
1731
|
+
if (requestId) err.requestId = requestId;
|
|
1687
1732
|
throw err;
|
|
1688
1733
|
}
|
|
1689
1734
|
if (options?.successMessage && cfg.notify) {
|
|
@@ -1701,9 +1746,18 @@ function createHttpClient(cfg) {
|
|
|
1701
1746
|
}
|
|
1702
1747
|
|
|
1703
1748
|
// src/index.ts
|
|
1704
|
-
var SDK_VERSION = "0.3.
|
|
1705
|
-
var SUPPORTED_FRAMEWORKS = [
|
|
1749
|
+
var SDK_VERSION = "0.3.5";
|
|
1750
|
+
var SUPPORTED_FRAMEWORKS = [
|
|
1751
|
+
"astro",
|
|
1752
|
+
"react",
|
|
1753
|
+
"vue",
|
|
1754
|
+
"svelte",
|
|
1755
|
+
"vanilla"
|
|
1756
|
+
];
|
|
1706
1757
|
function createArkySDK(config) {
|
|
1758
|
+
console.log(
|
|
1759
|
+
`[bruda2 Arky SDK v${SDK_VERSION}] Initializing with market: ${config.market}, businessId: ${config.businessId}`
|
|
1760
|
+
);
|
|
1707
1761
|
const httpClient = createHttpClient(config);
|
|
1708
1762
|
const storageUrl = config.storageUrl || "https://storage.arky.io/dev";
|
|
1709
1763
|
const apiConfig = {
|
|
@@ -1711,7 +1765,7 @@ function createArkySDK(config) {
|
|
|
1711
1765
|
businessId: config.businessId,
|
|
1712
1766
|
storageUrl,
|
|
1713
1767
|
baseUrl: config.baseUrl,
|
|
1714
|
-
market: config.market
|
|
1768
|
+
market: config.market,
|
|
1715
1769
|
setTokens: config.setToken,
|
|
1716
1770
|
getTokens: config.getToken
|
|
1717
1771
|
};
|
|
@@ -1734,6 +1788,10 @@ function createArkySDK(config) {
|
|
|
1734
1788
|
apiConfig.businessId = businessId;
|
|
1735
1789
|
},
|
|
1736
1790
|
getBusinessId: () => apiConfig.businessId,
|
|
1791
|
+
setMarket: (market) => {
|
|
1792
|
+
apiConfig.market = market;
|
|
1793
|
+
},
|
|
1794
|
+
getMarket: () => apiConfig.market,
|
|
1737
1795
|
isAuthenticated: config.isAuthenticated || (() => false),
|
|
1738
1796
|
logout: config.logout,
|
|
1739
1797
|
setToken: config.setToken,
|
|
@@ -1758,7 +1816,10 @@ function createArkySDK(config) {
|
|
|
1758
1816
|
const tokens = await config.getToken();
|
|
1759
1817
|
if (!tokens.accessToken && !tokens.refreshToken) {
|
|
1760
1818
|
const guestToken = await userApi.getGuestToken({});
|
|
1761
|
-
console.log(
|
|
1819
|
+
console.log(
|
|
1820
|
+
"[SDK Init] Created guest token:",
|
|
1821
|
+
guestToken ? "Success" : "Failed"
|
|
1822
|
+
);
|
|
1762
1823
|
} else {
|
|
1763
1824
|
console.log("[SDK Init] Using existing token from storage");
|
|
1764
1825
|
}
|