arky-sdk 0.7.111 → 0.7.113
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/admin.cjs +112 -127
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.d.cts +1 -1
- package/dist/admin.d.ts +1 -1
- package/dist/admin.js +112 -127
- package/dist/admin.js.map +1 -1
- package/dist/{index-DTg5d847.d.ts → index-C5gikdBg.d.cts} +2 -2
- package/dist/{index-BCAQZOwm.d.cts → index-MFMjlIfS.d.ts} +2 -2
- package/dist/index.cjs +137 -215
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -36
- package/dist/index.d.ts +22 -36
- package/dist/index.js +137 -215
- package/dist/index.js.map +1 -1
- package/dist/storefront.cjs +48 -87
- package/dist/storefront.cjs.map +1 -1
- package/dist/storefront.d.cts +1 -1
- package/dist/storefront.d.ts +1 -1
- package/dist/storefront.js +48 -87
- package/dist/storefront.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +152 -324
- package/dist/types.d.ts +152 -324
- package/dist/types.js.map +1 -1
- 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.map +1 -1
- package/package.json +1 -1
package/dist/storefront.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Activity, AuthStateListener, A as AuthStorage, COMMON_ACTIVITY_TYPES, CommonActivityType, CreateStorefrontConfig, CustomerSession, HttpClientConfig, TrackParams, createStorefront } from './index.cjs';
|
|
2
2
|
import './types.cjs';
|
|
3
|
-
import './index-
|
|
3
|
+
import './index-C5gikdBg.cjs';
|
package/dist/storefront.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Activity, AuthStateListener, A as AuthStorage, COMMON_ACTIVITY_TYPES, CommonActivityType, CreateStorefrontConfig, CustomerSession, HttpClientConfig, TrackParams, createStorefront } from './index.js';
|
|
2
2
|
import './types.js';
|
|
3
|
-
import './index-
|
|
3
|
+
import './index-MFMjlIfS.js';
|
package/dist/storefront.js
CHANGED
|
@@ -124,6 +124,30 @@ var getImageUrl = (imageBlock, isBlock = true) => {
|
|
|
124
124
|
return imageBlock.resolutions?.original?.url || null;
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
+
// src/utils/orderItems.ts
|
|
128
|
+
function normalizeOrderQuoteItems(items) {
|
|
129
|
+
return items.map((item) => {
|
|
130
|
+
if ("type" in item) {
|
|
131
|
+
return item;
|
|
132
|
+
}
|
|
133
|
+
if ("product_id" in item) {
|
|
134
|
+
return { type: "product", ...item };
|
|
135
|
+
}
|
|
136
|
+
return { type: "booking", ...item };
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function normalizeOrderCheckoutItems(items) {
|
|
140
|
+
return items.map((item) => {
|
|
141
|
+
if ("type" in item) {
|
|
142
|
+
return item;
|
|
143
|
+
}
|
|
144
|
+
if ("product_id" in item) {
|
|
145
|
+
return { type: "product", ...item };
|
|
146
|
+
}
|
|
147
|
+
return { type: "booking", ...item };
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
127
151
|
// src/api/storefront.ts
|
|
128
152
|
var COMMON_ACTIVITY_TYPES = [
|
|
129
153
|
"page_view",
|
|
@@ -134,7 +158,7 @@ var COMMON_ACTIVITY_TYPES = [
|
|
|
134
158
|
"cart_removed",
|
|
135
159
|
"checkout_started",
|
|
136
160
|
"purchase",
|
|
137
|
-
"
|
|
161
|
+
"order_created",
|
|
138
162
|
"signin",
|
|
139
163
|
"signup",
|
|
140
164
|
"verified_email",
|
|
@@ -154,24 +178,8 @@ var createActivityApi = (apiConfig) => ({
|
|
|
154
178
|
}
|
|
155
179
|
}
|
|
156
180
|
});
|
|
157
|
-
function groupCartToItems(cart) {
|
|
158
|
-
const groups = /* @__PURE__ */ new Map();
|
|
159
|
-
for (const slot of cart) {
|
|
160
|
-
const key = `${slot.service_id}:${slot.provider_id}`;
|
|
161
|
-
if (!groups.has(key)) {
|
|
162
|
-
groups.set(key, {
|
|
163
|
-
service_id: slot.service_id,
|
|
164
|
-
provider_id: slot.provider_id,
|
|
165
|
-
slots: []
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
groups.get(key).slots.push({ from: slot.from, to: slot.to });
|
|
169
|
-
}
|
|
170
|
-
return [...groups.values()];
|
|
171
|
-
}
|
|
172
181
|
var createStorefrontApi = (apiConfig, updateCustomerSession) => {
|
|
173
182
|
const base = (storeId = apiConfig.storeId) => `/v1/storefront/${storeId}`;
|
|
174
|
-
let cart = [];
|
|
175
183
|
return {
|
|
176
184
|
store: {
|
|
177
185
|
getStore(options) {
|
|
@@ -332,7 +340,7 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
|
|
|
332
340
|
order: {
|
|
333
341
|
getQuote(params, options) {
|
|
334
342
|
const store_id = params.store_id || apiConfig.storeId;
|
|
335
|
-
const { location, store_id: _store_id, ...rest } = params;
|
|
343
|
+
const { location, store_id: _store_id, items, market, ...rest } = params;
|
|
336
344
|
const shipping_address = location ? {
|
|
337
345
|
country: location.country || "",
|
|
338
346
|
state: location.state || "",
|
|
@@ -341,19 +349,29 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
|
|
|
341
349
|
name: "",
|
|
342
350
|
street1: "",
|
|
343
351
|
street2: null
|
|
344
|
-
} :
|
|
352
|
+
} : rest.shipping_address;
|
|
345
353
|
return apiConfig.httpClient.post(
|
|
346
354
|
`${base(store_id)}/orders/quote`,
|
|
347
|
-
{
|
|
355
|
+
{
|
|
356
|
+
...rest,
|
|
357
|
+
items: normalizeOrderQuoteItems(items),
|
|
358
|
+
shipping_address,
|
|
359
|
+
market: market || apiConfig.market
|
|
360
|
+
},
|
|
348
361
|
options
|
|
349
362
|
);
|
|
350
363
|
},
|
|
351
364
|
checkout(params, options) {
|
|
352
|
-
const { store_id, ...rest } = params;
|
|
365
|
+
const { store_id, items, market, ...rest } = params;
|
|
353
366
|
const target = store_id || apiConfig.storeId;
|
|
354
367
|
return apiConfig.httpClient.post(
|
|
355
368
|
`${base(target)}/orders/checkout`,
|
|
356
|
-
{
|
|
369
|
+
{
|
|
370
|
+
...rest,
|
|
371
|
+
items: normalizeOrderCheckoutItems(items),
|
|
372
|
+
store_id: target,
|
|
373
|
+
market: market || apiConfig.market
|
|
374
|
+
},
|
|
357
375
|
options
|
|
358
376
|
);
|
|
359
377
|
},
|
|
@@ -370,71 +388,15 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
|
|
|
370
388
|
...options,
|
|
371
389
|
params: queryParams
|
|
372
390
|
});
|
|
391
|
+
},
|
|
392
|
+
getAvailability(params, options) {
|
|
393
|
+
const { store_id, ...queryParams } = params;
|
|
394
|
+
const target_store_id = store_id || apiConfig.storeId;
|
|
395
|
+
return apiConfig.httpClient.get(
|
|
396
|
+
`${base(target_store_id)}/orders/availability`,
|
|
397
|
+
{ ...options, params: queryParams }
|
|
398
|
+
);
|
|
373
399
|
}
|
|
374
|
-
}
|
|
375
|
-
},
|
|
376
|
-
booking: {
|
|
377
|
-
addToCart(slot) {
|
|
378
|
-
cart.push(slot);
|
|
379
|
-
},
|
|
380
|
-
removeFromCart(slotId) {
|
|
381
|
-
cart = cart.filter((slot) => slot.id !== slotId);
|
|
382
|
-
},
|
|
383
|
-
getCart() {
|
|
384
|
-
return [...cart];
|
|
385
|
-
},
|
|
386
|
-
clearCart() {
|
|
387
|
-
cart = [];
|
|
388
|
-
},
|
|
389
|
-
checkout(params, options) {
|
|
390
|
-
const { store_id, items: paramItems, ...payload } = params || {};
|
|
391
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
392
|
-
const items = paramItems || groupCartToItems(cart);
|
|
393
|
-
return apiConfig.httpClient.post(
|
|
394
|
-
`${base(target_store_id)}/bookings/checkout`,
|
|
395
|
-
{ market: apiConfig.market, ...payload, items },
|
|
396
|
-
options
|
|
397
|
-
);
|
|
398
|
-
},
|
|
399
|
-
get(params, options) {
|
|
400
|
-
const store_id = params.store_id || apiConfig.storeId;
|
|
401
|
-
return apiConfig.httpClient.get(
|
|
402
|
-
`${base(store_id)}/bookings/${params.id}`,
|
|
403
|
-
options
|
|
404
|
-
);
|
|
405
|
-
},
|
|
406
|
-
find(params, options) {
|
|
407
|
-
const { store_id, ...queryParams } = params;
|
|
408
|
-
return apiConfig.httpClient.get(`${base(store_id)}/bookings`, {
|
|
409
|
-
...options,
|
|
410
|
-
params: queryParams
|
|
411
|
-
});
|
|
412
|
-
},
|
|
413
|
-
getQuote(params, options) {
|
|
414
|
-
const { store_id, ...payload } = params;
|
|
415
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
416
|
-
return apiConfig.httpClient.post(
|
|
417
|
-
`${base(target_store_id)}/bookings/quote`,
|
|
418
|
-
{ market: apiConfig.market, ...payload },
|
|
419
|
-
options
|
|
420
|
-
);
|
|
421
|
-
},
|
|
422
|
-
getAvailability(params, options) {
|
|
423
|
-
const { store_id, ...queryParams } = params;
|
|
424
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
425
|
-
return apiConfig.httpClient.get(
|
|
426
|
-
`${base(target_store_id)}/bookings/availability`,
|
|
427
|
-
{ ...options, params: queryParams }
|
|
428
|
-
);
|
|
429
|
-
},
|
|
430
|
-
cancelItem(params, options) {
|
|
431
|
-
const { store_id, booking_id, item_id, ...payload } = params;
|
|
432
|
-
const target_store_id = store_id || apiConfig.storeId;
|
|
433
|
-
return apiConfig.httpClient.post(
|
|
434
|
-
`${base(target_store_id)}/bookings/${booking_id}/items/${item_id}/cancel`,
|
|
435
|
-
payload,
|
|
436
|
-
options
|
|
437
|
-
);
|
|
438
400
|
},
|
|
439
401
|
service: {
|
|
440
402
|
get(params, options) {
|
|
@@ -1314,7 +1276,6 @@ function createStorefront(config) {
|
|
|
1314
1276
|
store: storefrontApi.store,
|
|
1315
1277
|
cms: storefrontApi.cms,
|
|
1316
1278
|
eshop: storefrontApi.eshop,
|
|
1317
|
-
booking: storefrontApi.booking,
|
|
1318
1279
|
crm: storefrontApi.crm,
|
|
1319
1280
|
activity: storefrontApi.activity,
|
|
1320
1281
|
automation: storefrontApi.automation,
|