arky-sdk 0.3.27 → 0.3.28
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/README.md +126 -25
- package/dist/index.cjs +41 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -10
- package/dist/index.d.ts +2 -10
- package/dist/index.js +41 -24
- package/dist/index.js.map +1 -1
- package/dist/types.d.cts +51 -40
- package/dist/types.d.ts +51 -40
- package/package.json +1 -1
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,
|
|
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
3
|
import { g as getGalleryThumbnail, a as getBlockLabel, b as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission, e as extractBlockValues, c as getMarketPrice, d as getPriceAmount, h as formatPayment, i as formatMinor, j as createPaymentForCheckout, k as getCurrencySymbol, v as validatePhoneNumber, l as findTimeZone, s as slugify, m as humanize, n as categorify, o as formatDate, q as getSvgContentForAstro, r as fetchSvgContent, t as injectSvgIntoElement } from './svg-CFjyTGXu.cjs';
|
|
4
4
|
|
|
@@ -19,14 +19,10 @@ interface HttpClientConfig {
|
|
|
19
19
|
logout: () => void;
|
|
20
20
|
navigate?: (path: string) => void;
|
|
21
21
|
loginFallbackPath?: string;
|
|
22
|
-
notify?: (opts: {
|
|
23
|
-
message: string;
|
|
24
|
-
type: 'error' | 'success';
|
|
25
|
-
}) => void;
|
|
26
22
|
isAuthenticated?: () => boolean;
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
declare const SDK_VERSION = "0.3.
|
|
25
|
+
declare const SDK_VERSION = "0.3.28";
|
|
30
26
|
declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
|
|
31
27
|
interface ApiConfig {
|
|
32
28
|
httpClient: any;
|
|
@@ -90,8 +86,6 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
90
86
|
getRoles(params: GetRolesParams, options?: RequestOptions): Promise<any>;
|
|
91
87
|
};
|
|
92
88
|
notification: {
|
|
93
|
-
getNotifications(params: GetNotificationsParams, options?: RequestOptions): Promise<any>;
|
|
94
|
-
updateNotifications(params: UpdateNotificationsParams, options?: RequestOptions): Promise<any>;
|
|
95
89
|
trackEmailOpen(params: TrackEmailOpenParams, options?: RequestOptions): Promise<any>;
|
|
96
90
|
getDeliveryStats(params: GetDeliveryStatsParams, options?: RequestOptions): Promise<any>;
|
|
97
91
|
};
|
|
@@ -104,8 +98,6 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
104
98
|
};
|
|
105
99
|
analytics: {
|
|
106
100
|
getAnalytics(params: GetAnalyticsParams, options?: RequestOptions): Promise<any>;
|
|
107
|
-
getAnalyticsHealth(params: GetAnalyticsHealthParams, options?: RequestOptions): Promise<any>;
|
|
108
|
-
setupAnalytics(params: SetupAnalyticsParams, options?: RequestOptions): Promise<any>;
|
|
109
101
|
};
|
|
110
102
|
cms: {
|
|
111
103
|
createCollection(params: CreateCollectionParams, options?: RequestOptions): Promise<any>;
|
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,
|
|
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
3
|
import { g as getGalleryThumbnail, a as getBlockLabel, b as getBlockTextValue, f as formatBlockValue, p as prepareBlocksForSubmission, e as extractBlockValues, c as getMarketPrice, d as getPriceAmount, h as formatPayment, i as formatMinor, j as createPaymentForCheckout, k as getCurrencySymbol, v as validatePhoneNumber, l as findTimeZone, s as slugify, m as humanize, n as categorify, o as formatDate, q as getSvgContentForAstro, r as fetchSvgContent, t as injectSvgIntoElement } from './svg-BhIM4HZW.js';
|
|
4
4
|
|
|
@@ -19,14 +19,10 @@ interface HttpClientConfig {
|
|
|
19
19
|
logout: () => void;
|
|
20
20
|
navigate?: (path: string) => void;
|
|
21
21
|
loginFallbackPath?: string;
|
|
22
|
-
notify?: (opts: {
|
|
23
|
-
message: string;
|
|
24
|
-
type: 'error' | 'success';
|
|
25
|
-
}) => void;
|
|
26
22
|
isAuthenticated?: () => boolean;
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
declare const SDK_VERSION = "0.3.
|
|
25
|
+
declare const SDK_VERSION = "0.3.28";
|
|
30
26
|
declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
|
|
31
27
|
interface ApiConfig {
|
|
32
28
|
httpClient: any;
|
|
@@ -90,8 +86,6 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
90
86
|
getRoles(params: GetRolesParams, options?: RequestOptions): Promise<any>;
|
|
91
87
|
};
|
|
92
88
|
notification: {
|
|
93
|
-
getNotifications(params: GetNotificationsParams, options?: RequestOptions): Promise<any>;
|
|
94
|
-
updateNotifications(params: UpdateNotificationsParams, options?: RequestOptions): Promise<any>;
|
|
95
89
|
trackEmailOpen(params: TrackEmailOpenParams, options?: RequestOptions): Promise<any>;
|
|
96
90
|
getDeliveryStats(params: GetDeliveryStatsParams, options?: RequestOptions): Promise<any>;
|
|
97
91
|
};
|
|
@@ -104,8 +98,6 @@ declare function createArkySDK(config: HttpClientConfig & {
|
|
|
104
98
|
};
|
|
105
99
|
analytics: {
|
|
106
100
|
getAnalytics(params: GetAnalyticsParams, options?: RequestOptions): Promise<any>;
|
|
107
|
-
getAnalyticsHealth(params: GetAnalyticsHealthParams, options?: RequestOptions): Promise<any>;
|
|
108
|
-
setupAnalytics(params: SetupAnalyticsParams, options?: RequestOptions): Promise<any>;
|
|
109
101
|
};
|
|
110
102
|
cms: {
|
|
111
103
|
createCollection(params: CreateCollectionParams, options?: RequestOptions): Promise<any>;
|
package/dist/index.js
CHANGED
|
@@ -102,6 +102,7 @@ function createHttpClient(cfg) {
|
|
|
102
102
|
const fullUrl = `${cfg.baseUrl}${finalPath}`;
|
|
103
103
|
let res;
|
|
104
104
|
let data;
|
|
105
|
+
const startedAt = Date.now();
|
|
105
106
|
try {
|
|
106
107
|
res = await fetch(fullUrl, fetchOpts);
|
|
107
108
|
} catch (error) {
|
|
@@ -109,6 +110,12 @@ function createHttpClient(cfg) {
|
|
|
109
110
|
err.name = "NetworkError";
|
|
110
111
|
err.method = method;
|
|
111
112
|
err.url = fullUrl;
|
|
113
|
+
if (options?.onError && method !== "GET") {
|
|
114
|
+
Promise.resolve(
|
|
115
|
+
options.onError({ error: err, method, url: fullUrl, aborted: false })
|
|
116
|
+
).catch(() => {
|
|
117
|
+
});
|
|
118
|
+
}
|
|
112
119
|
throw err;
|
|
113
120
|
}
|
|
114
121
|
if (res.status === 401 && !options?.["_retried"]) {
|
|
@@ -135,14 +142,17 @@ function createHttpClient(cfg) {
|
|
|
135
142
|
err.method = method;
|
|
136
143
|
err.url = fullUrl;
|
|
137
144
|
err.status = res.status;
|
|
145
|
+
if (options?.onError && method !== "GET") {
|
|
146
|
+
Promise.resolve(
|
|
147
|
+
options.onError({ error: err, method, url: fullUrl, status: res.status })
|
|
148
|
+
).catch(() => {
|
|
149
|
+
});
|
|
150
|
+
}
|
|
138
151
|
throw err;
|
|
139
152
|
}
|
|
140
153
|
if (!res.ok) {
|
|
141
154
|
const serverErr = data;
|
|
142
155
|
const reqErr = convertServerErrorToRequestError(serverErr);
|
|
143
|
-
if (options?.errorMessage && cfg.notify) {
|
|
144
|
-
cfg.notify({ message: options.errorMessage, type: "error" });
|
|
145
|
-
}
|
|
146
156
|
const err = new Error(serverErr.message || "Request failed");
|
|
147
157
|
err.name = "ApiError";
|
|
148
158
|
err.statusCode = serverErr.statusCode || res.status;
|
|
@@ -151,10 +161,35 @@ function createHttpClient(cfg) {
|
|
|
151
161
|
err.url = fullUrl;
|
|
152
162
|
const requestId = res.headers.get("x-request-id") || res.headers.get("request-id");
|
|
153
163
|
if (requestId) err.requestId = requestId;
|
|
164
|
+
if (options?.onError && method !== "GET") {
|
|
165
|
+
Promise.resolve(
|
|
166
|
+
options.onError({
|
|
167
|
+
error: err,
|
|
168
|
+
method,
|
|
169
|
+
url: fullUrl,
|
|
170
|
+
status: res.status,
|
|
171
|
+
response: serverErr,
|
|
172
|
+
requestId: requestId || null,
|
|
173
|
+
durationMs: Date.now() - startedAt
|
|
174
|
+
})
|
|
175
|
+
).catch(() => {
|
|
176
|
+
});
|
|
177
|
+
}
|
|
154
178
|
throw err;
|
|
155
179
|
}
|
|
156
|
-
if (options?.
|
|
157
|
-
|
|
180
|
+
if (options?.onSuccess && method !== "GET") {
|
|
181
|
+
const requestId = res.headers.get("x-request-id") || res.headers.get("request-id");
|
|
182
|
+
Promise.resolve(
|
|
183
|
+
options.onSuccess({
|
|
184
|
+
data,
|
|
185
|
+
method,
|
|
186
|
+
url: fullUrl,
|
|
187
|
+
status: res.status,
|
|
188
|
+
requestId: requestId || null,
|
|
189
|
+
durationMs: Date.now() - startedAt
|
|
190
|
+
})
|
|
191
|
+
).catch(() => {
|
|
192
|
+
});
|
|
158
193
|
}
|
|
159
194
|
return data;
|
|
160
195
|
}
|
|
@@ -415,18 +450,6 @@ var createRoleApi = (apiConfig) => {
|
|
|
415
450
|
// src/api/notification.ts
|
|
416
451
|
var createNotificationApi = (apiConfig) => {
|
|
417
452
|
return {
|
|
418
|
-
async getNotifications(params, options) {
|
|
419
|
-
return apiConfig.httpClient.get(`/v1/notifications`, {
|
|
420
|
-
...options,
|
|
421
|
-
params: {
|
|
422
|
-
limit: params.limit,
|
|
423
|
-
previous_id: params.previous_id
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
},
|
|
427
|
-
async updateNotifications(params, options) {
|
|
428
|
-
return apiConfig.httpClient.put(`/v1/notifications`, { seen: true }, options);
|
|
429
|
-
},
|
|
430
453
|
async trackEmailOpen(params, options) {
|
|
431
454
|
return apiConfig.httpClient.get(
|
|
432
455
|
`/v1/notifications/track/email/${params.trackingPixelId}`,
|
|
@@ -488,12 +511,6 @@ var createAnalyticsApi = (apiConfig) => {
|
|
|
488
511
|
...options,
|
|
489
512
|
params
|
|
490
513
|
});
|
|
491
|
-
},
|
|
492
|
-
async getAnalyticsHealth(params, options) {
|
|
493
|
-
return apiConfig.httpClient.get(`/v1/analytics/${apiConfig.businessId}/health`, options);
|
|
494
|
-
},
|
|
495
|
-
async setupAnalytics(params, options) {
|
|
496
|
-
return apiConfig.httpClient.post(`/v1/analytics/admin/setup`, params, options);
|
|
497
514
|
}
|
|
498
515
|
};
|
|
499
516
|
};
|
|
@@ -1480,7 +1497,7 @@ async function injectSvgIntoElement(mediaObject, targetElement, className) {
|
|
|
1480
1497
|
}
|
|
1481
1498
|
|
|
1482
1499
|
// src/index.ts
|
|
1483
|
-
var SDK_VERSION = "0.3.
|
|
1500
|
+
var SDK_VERSION = "0.3.28";
|
|
1484
1501
|
var SUPPORTED_FRAMEWORKS = [
|
|
1485
1502
|
"astro",
|
|
1486
1503
|
"react",
|