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/index.js CHANGED
@@ -131,6 +131,30 @@ var getImageUrl = (imageBlock, isBlock = true) => {
131
131
  return imageBlock.resolutions?.original?.url || null;
132
132
  };
133
133
 
134
+ // src/utils/orderItems.ts
135
+ function normalizeOrderQuoteItems(items) {
136
+ return items.map((item) => {
137
+ if ("type" in item) {
138
+ return item;
139
+ }
140
+ if ("product_id" in item) {
141
+ return { type: "product", ...item };
142
+ }
143
+ return { type: "booking", ...item };
144
+ });
145
+ }
146
+ function normalizeOrderCheckoutItems(items) {
147
+ return items.map((item) => {
148
+ if ("type" in item) {
149
+ return item;
150
+ }
151
+ if ("product_id" in item) {
152
+ return { type: "product", ...item };
153
+ }
154
+ return { type: "booking", ...item };
155
+ });
156
+ }
157
+
134
158
  // src/api/storefront.ts
135
159
  var COMMON_ACTIVITY_TYPES = [
136
160
  "page_view",
@@ -141,7 +165,7 @@ var COMMON_ACTIVITY_TYPES = [
141
165
  "cart_removed",
142
166
  "checkout_started",
143
167
  "purchase",
144
- "booking_created",
168
+ "order_created",
145
169
  "signin",
146
170
  "signup",
147
171
  "verified_email",
@@ -161,24 +185,8 @@ var createActivityApi = (apiConfig) => ({
161
185
  }
162
186
  }
163
187
  });
164
- function groupCartToItems(cart) {
165
- const groups = /* @__PURE__ */ new Map();
166
- for (const slot of cart) {
167
- const key = `${slot.service_id}:${slot.provider_id}`;
168
- if (!groups.has(key)) {
169
- groups.set(key, {
170
- service_id: slot.service_id,
171
- provider_id: slot.provider_id,
172
- slots: []
173
- });
174
- }
175
- groups.get(key).slots.push({ from: slot.from, to: slot.to });
176
- }
177
- return [...groups.values()];
178
- }
179
188
  var createStorefrontApi = (apiConfig, updateCustomerSession) => {
180
189
  const base = (storeId = apiConfig.storeId) => `/v1/storefront/${storeId}`;
181
- let cart = [];
182
190
  return {
183
191
  store: {
184
192
  getStore(options) {
@@ -339,7 +347,7 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
339
347
  order: {
340
348
  getQuote(params, options) {
341
349
  const store_id = params.store_id || apiConfig.storeId;
342
- const { location, store_id: _store_id, ...rest } = params;
350
+ const { location, store_id: _store_id, items, market, ...rest } = params;
343
351
  const shipping_address = location ? {
344
352
  country: location.country || "",
345
353
  state: location.state || "",
@@ -348,19 +356,29 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
348
356
  name: "",
349
357
  street1: "",
350
358
  street2: null
351
- } : void 0;
359
+ } : rest.shipping_address;
352
360
  return apiConfig.httpClient.post(
353
361
  `${base(store_id)}/orders/quote`,
354
- { ...rest, shipping_address, market: apiConfig.market },
362
+ {
363
+ ...rest,
364
+ items: normalizeOrderQuoteItems(items),
365
+ shipping_address,
366
+ market: market || apiConfig.market
367
+ },
355
368
  options
356
369
  );
357
370
  },
358
371
  checkout(params, options) {
359
- const { store_id, ...rest } = params;
372
+ const { store_id, items, market, ...rest } = params;
360
373
  const target = store_id || apiConfig.storeId;
361
374
  return apiConfig.httpClient.post(
362
375
  `${base(target)}/orders/checkout`,
363
- { ...rest, store_id: target, market: apiConfig.market },
376
+ {
377
+ ...rest,
378
+ items: normalizeOrderCheckoutItems(items),
379
+ store_id: target,
380
+ market: market || apiConfig.market
381
+ },
364
382
  options
365
383
  );
366
384
  },
@@ -377,71 +395,15 @@ var createStorefrontApi = (apiConfig, updateCustomerSession) => {
377
395
  ...options,
378
396
  params: queryParams
379
397
  });
398
+ },
399
+ getAvailability(params, options) {
400
+ const { store_id, ...queryParams } = params;
401
+ const target_store_id = store_id || apiConfig.storeId;
402
+ return apiConfig.httpClient.get(
403
+ `${base(target_store_id)}/orders/availability`,
404
+ { ...options, params: queryParams }
405
+ );
380
406
  }
381
- }
382
- },
383
- booking: {
384
- addToCart(slot) {
385
- cart.push(slot);
386
- },
387
- removeFromCart(slotId) {
388
- cart = cart.filter((slot) => slot.id !== slotId);
389
- },
390
- getCart() {
391
- return [...cart];
392
- },
393
- clearCart() {
394
- cart = [];
395
- },
396
- checkout(params, options) {
397
- const { store_id, items: paramItems, ...payload } = params || {};
398
- const target_store_id = store_id || apiConfig.storeId;
399
- const items = paramItems || groupCartToItems(cart);
400
- return apiConfig.httpClient.post(
401
- `${base(target_store_id)}/bookings/checkout`,
402
- { market: apiConfig.market, ...payload, items },
403
- options
404
- );
405
- },
406
- get(params, options) {
407
- const store_id = params.store_id || apiConfig.storeId;
408
- return apiConfig.httpClient.get(
409
- `${base(store_id)}/bookings/${params.id}`,
410
- options
411
- );
412
- },
413
- find(params, options) {
414
- const { store_id, ...queryParams } = params;
415
- return apiConfig.httpClient.get(`${base(store_id)}/bookings`, {
416
- ...options,
417
- params: queryParams
418
- });
419
- },
420
- getQuote(params, options) {
421
- const { store_id, ...payload } = params;
422
- const target_store_id = store_id || apiConfig.storeId;
423
- return apiConfig.httpClient.post(
424
- `${base(target_store_id)}/bookings/quote`,
425
- { market: apiConfig.market, ...payload },
426
- options
427
- );
428
- },
429
- getAvailability(params, options) {
430
- const { store_id, ...queryParams } = params;
431
- const target_store_id = store_id || apiConfig.storeId;
432
- return apiConfig.httpClient.get(
433
- `${base(target_store_id)}/bookings/availability`,
434
- { ...options, params: queryParams }
435
- );
436
- },
437
- cancelItem(params, options) {
438
- const { store_id, booking_id, item_id, ...payload } = params;
439
- const target_store_id = store_id || apiConfig.storeId;
440
- return apiConfig.httpClient.post(
441
- `${base(target_store_id)}/bookings/${booking_id}/items/${item_id}/cancel`,
442
- payload,
443
- options
444
- );
445
407
  },
446
408
  service: {
447
409
  get(params, options) {
@@ -1357,6 +1319,13 @@ var createCmsApi = (apiConfig) => {
1357
1319
  };
1358
1320
 
1359
1321
  // src/api/eshop.ts
1322
+ var normalizeTaxonomyAliases = (payload) => {
1323
+ const { filters, ...rest } = payload;
1324
+ return {
1325
+ ...rest,
1326
+ ...!rest.taxonomies && filters ? { taxonomies: filters } : {}
1327
+ };
1328
+ };
1360
1329
  var createEshopApi = (apiConfig) => {
1361
1330
  return {
1362
1331
  async createProduct(params, options) {
@@ -1364,7 +1333,7 @@ var createEshopApi = (apiConfig) => {
1364
1333
  const target_store_id = store_id || apiConfig.storeId;
1365
1334
  return apiConfig.httpClient.post(
1366
1335
  `/v1/stores/${target_store_id}/products`,
1367
- payload,
1336
+ normalizeTaxonomyAliases(payload),
1368
1337
  options
1369
1338
  );
1370
1339
  },
@@ -1373,7 +1342,7 @@ var createEshopApi = (apiConfig) => {
1373
1342
  const target_store_id = store_id || apiConfig.storeId;
1374
1343
  return apiConfig.httpClient.put(
1375
1344
  `/v1/stores/${target_store_id}/products/${params.id}`,
1376
- payload,
1345
+ normalizeTaxonomyAliases(payload),
1377
1346
  options
1378
1347
  );
1379
1348
  },
@@ -1411,17 +1380,41 @@ var createEshopApi = (apiConfig) => {
1411
1380
  );
1412
1381
  },
1413
1382
  async createOrder(params, options) {
1414
- const { store_id, ...payload } = params;
1383
+ const { store_id, items, ...rest } = params;
1415
1384
  const target_store_id = store_id || apiConfig.storeId;
1385
+ const payload = {
1386
+ ...rest,
1387
+ market: rest.market || apiConfig.market,
1388
+ items: normalizeOrderCheckoutItems(items)
1389
+ };
1416
1390
  return apiConfig.httpClient.post(
1417
1391
  `/v1/stores/${target_store_id}/orders`,
1418
1392
  payload,
1419
1393
  options
1420
1394
  );
1421
1395
  },
1396
+ async checkoutOrder(params, options) {
1397
+ const { store_id, items, ...rest } = params;
1398
+ const target_store_id = store_id || apiConfig.storeId;
1399
+ const payload = {
1400
+ ...rest,
1401
+ store_id: target_store_id,
1402
+ market: rest.market || apiConfig.market,
1403
+ items: normalizeOrderCheckoutItems(items)
1404
+ };
1405
+ return apiConfig.httpClient.post(
1406
+ `/v1/stores/${target_store_id}/orders/checkout`,
1407
+ payload,
1408
+ options
1409
+ );
1410
+ },
1422
1411
  async updateOrder(params, options) {
1423
- const { store_id, ...payload } = params;
1412
+ const { store_id, items, ...rest } = params;
1424
1413
  const target_store_id = store_id || apiConfig.storeId;
1414
+ const payload = {
1415
+ ...rest,
1416
+ ...items ? { items: normalizeOrderCheckoutItems(items) } : {}
1417
+ };
1425
1418
  return apiConfig.httpClient.put(
1426
1419
  `/v1/stores/${target_store_id}/orders/${params.id}`,
1427
1420
  payload,
@@ -1447,7 +1440,8 @@ var createEshopApi = (apiConfig) => {
1447
1440
  );
1448
1441
  },
1449
1442
  async getQuote(params, options) {
1450
- const { location, ...rest } = params;
1443
+ const { location, store_id, items, ...rest } = params;
1444
+ const target_store_id = store_id || apiConfig.storeId;
1451
1445
  const shipping_address = location ? {
1452
1446
  country: location.country || "",
1453
1447
  state: location.state || "",
@@ -1456,13 +1450,26 @@ var createEshopApi = (apiConfig) => {
1456
1450
  name: "",
1457
1451
  street1: "",
1458
1452
  street2: null
1459
- } : void 0;
1453
+ } : rest.shipping_address;
1460
1454
  return apiConfig.httpClient.post(
1461
- `/v1/stores/${apiConfig.storeId}/orders/quote`,
1462
- { ...rest, shipping_address, market: apiConfig.market },
1455
+ `/v1/stores/${target_store_id}/orders/quote`,
1456
+ {
1457
+ ...rest,
1458
+ items: normalizeOrderQuoteItems(items),
1459
+ shipping_address,
1460
+ market: rest.market || apiConfig.market
1461
+ },
1463
1462
  options
1464
1463
  );
1465
1464
  },
1465
+ async getOrderAvailability(params, options) {
1466
+ const { store_id, ...queryParams } = params;
1467
+ const target_store_id = store_id || apiConfig.storeId;
1468
+ return apiConfig.httpClient.get(
1469
+ `/v1/stores/${target_store_id}/orders/availability`,
1470
+ { ...options, params: queryParams }
1471
+ );
1472
+ },
1466
1473
  async processRefund(params, options) {
1467
1474
  return apiConfig.httpClient.post(
1468
1475
  `/v1/stores/${apiConfig.storeId}/orders/${params.id}/refund`,
@@ -1473,87 +1480,22 @@ var createEshopApi = (apiConfig) => {
1473
1480
  };
1474
1481
  };
1475
1482
 
1476
- // src/api/booking.ts
1477
- var createBookingApi = (apiConfig) => {
1478
- let cart = [];
1483
+ // src/api/scheduling.ts
1484
+ var normalizeTaxonomyAliases2 = (payload) => {
1485
+ const { filters, ...rest } = payload;
1486
+ return {
1487
+ ...rest,
1488
+ ...!rest.taxonomies && filters ? { taxonomies: filters } : {}
1489
+ };
1490
+ };
1491
+ var createSchedulingApi = (apiConfig) => {
1479
1492
  return {
1480
- addToCart(slot) {
1481
- cart.push(slot);
1482
- },
1483
- removeFromCart(slotId) {
1484
- cart = cart.filter((s) => s.id !== slotId);
1485
- },
1486
- getCart() {
1487
- return [...cart];
1488
- },
1489
- clearCart() {
1490
- cart = [];
1491
- },
1492
- async createBooking(params, options) {
1493
- const { store_id, ...payload } = params;
1494
- const target_store_id = store_id || apiConfig.storeId;
1495
- return apiConfig.httpClient.post(
1496
- `/v1/stores/${target_store_id}/bookings`,
1497
- { market: apiConfig.market, ...payload },
1498
- options
1499
- );
1500
- },
1501
- async updateBooking(params, options) {
1502
- const { id, ...payload } = params;
1503
- return apiConfig.httpClient.put(
1504
- `/v1/stores/${apiConfig.storeId}/bookings/${id}`,
1505
- payload,
1506
- options
1507
- );
1508
- },
1509
- async getBooking(params, options) {
1510
- const target_store_id = params.store_id || apiConfig.storeId;
1511
- return apiConfig.httpClient.get(
1512
- `/v1/stores/${target_store_id}/bookings/${params.id}`,
1513
- options
1514
- );
1515
- },
1516
- async searchBookings(params, options) {
1517
- const { store_id, ...queryParams } = params;
1518
- const target_store_id = store_id || apiConfig.storeId;
1519
- return apiConfig.httpClient.get(
1520
- `/v1/stores/${target_store_id}/bookings`,
1521
- {
1522
- ...options,
1523
- params: queryParams
1524
- }
1525
- );
1526
- },
1527
- async getQuote(params, options) {
1528
- const { store_id, ...payload } = params;
1529
- const target_store_id = store_id || apiConfig.storeId;
1530
- return apiConfig.httpClient.post(
1531
- `/v1/stores/${target_store_id}/bookings/quote`,
1532
- { market: apiConfig.market, ...payload },
1533
- options
1534
- );
1535
- },
1536
- async processRefund(params, options) {
1537
- return apiConfig.httpClient.post(
1538
- `/v1/stores/${apiConfig.storeId}/bookings/${params.id}/refund`,
1539
- { amount: params.amount },
1540
- options
1541
- );
1542
- },
1543
- async getAvailability(params, options) {
1544
- const { store_id, ...query } = params;
1545
- const target_store_id = store_id || apiConfig.storeId;
1546
- return apiConfig.httpClient.get(
1547
- `/v1/stores/${target_store_id}/bookings/availability`,
1548
- { ...options, params: query }
1549
- );
1550
- },
1551
1493
  async createService(params, options) {
1552
1494
  const { store_id, ...payload } = params;
1553
1495
  const target_store_id = store_id || apiConfig.storeId;
1554
1496
  return apiConfig.httpClient.post(
1555
1497
  `/v1/stores/${target_store_id}/services`,
1556
- payload,
1498
+ normalizeTaxonomyAliases2(payload),
1557
1499
  options
1558
1500
  );
1559
1501
  },
@@ -1562,7 +1504,7 @@ var createBookingApi = (apiConfig) => {
1562
1504
  const target_store_id = store_id || apiConfig.storeId;
1563
1505
  return apiConfig.httpClient.put(
1564
1506
  `/v1/stores/${target_store_id}/services/${params.id}`,
1565
- payload,
1507
+ normalizeTaxonomyAliases2(payload),
1566
1508
  options
1567
1509
  );
1568
1510
  },
@@ -1604,7 +1546,7 @@ var createBookingApi = (apiConfig) => {
1604
1546
  const target_store_id = store_id || apiConfig.storeId;
1605
1547
  return apiConfig.httpClient.post(
1606
1548
  `/v1/stores/${target_store_id}/providers`,
1607
- payload,
1549
+ normalizeTaxonomyAliases2(payload),
1608
1550
  options
1609
1551
  );
1610
1552
  },
@@ -1613,7 +1555,7 @@ var createBookingApi = (apiConfig) => {
1613
1555
  const target_store_id = store_id || apiConfig.storeId;
1614
1556
  return apiConfig.httpClient.put(
1615
1557
  `/v1/stores/${target_store_id}/providers/${params.id}`,
1616
- payload,
1558
+ normalizeTaxonomyAliases2(payload),
1617
1559
  options
1618
1560
  );
1619
1561
  },
@@ -1650,15 +1592,6 @@ var createBookingApi = (apiConfig) => {
1650
1592
  }
1651
1593
  );
1652
1594
  },
1653
- async cancelBookingItem(params, options) {
1654
- const { store_id, booking_id, item_id, ...payload } = params;
1655
- const target_store_id = store_id || apiConfig.storeId;
1656
- return apiConfig.httpClient.post(
1657
- `/v1/stores/${target_store_id}/bookings/${booking_id}/items/${item_id}/cancel`,
1658
- payload,
1659
- options
1660
- );
1661
- },
1662
1595
  async findServiceProviders(params, options) {
1663
1596
  const { store_id, ...queryParams } = params;
1664
1597
  const target_store_id = store_id || apiConfig.storeId;
@@ -2647,7 +2580,7 @@ function getFirstAvailableFCId(variant, quantity = 1) {
2647
2580
  }
2648
2581
 
2649
2582
  // src/index.ts
2650
- var SDK_VERSION = "0.7.110";
2583
+ var SDK_VERSION = "0.7.112";
2651
2584
  var SUPPORTED_FRAMEWORKS = [
2652
2585
  "astro",
2653
2586
  "react",
@@ -2784,7 +2717,8 @@ function createAdmin(config) {
2784
2717
  const platformApi = createPlatformApi(apiConfig);
2785
2718
  const cmsApi = createCmsApi(apiConfig);
2786
2719
  const eshopApi = createEshopApi(apiConfig);
2787
- const bookingApi = createBookingApi(apiConfig);
2720
+ const schedulingApi = createSchedulingApi(apiConfig);
2721
+ const promoCodeApi = createPromoCodeApi(apiConfig);
2788
2722
  const crmApi = createCustomerApi(apiConfig);
2789
2723
  const locationApi = createLocationApi(apiConfig);
2790
2724
  const marketApi = createMarketApi(apiConfig);
@@ -2804,7 +2738,7 @@ function createAdmin(config) {
2804
2738
  },
2805
2739
  media: createMediaApi(apiConfig),
2806
2740
  notification: createNotificationApi(apiConfig),
2807
- promoCode: createPromoCodeApi(apiConfig),
2741
+ promoCode: promoCodeApi,
2808
2742
  platform: platformApi,
2809
2743
  shipping: createShippingApi(apiConfig),
2810
2744
  cms: {
@@ -2857,40 +2791,29 @@ function createAdmin(config) {
2857
2791
  get: eshopApi.getOrder,
2858
2792
  find: eshopApi.getOrders,
2859
2793
  getQuote: eshopApi.getQuote,
2794
+ checkout: eshopApi.checkoutOrder,
2795
+ getAvailability: eshopApi.getOrderAvailability,
2860
2796
  processRefund: eshopApi.processRefund
2861
- }
2862
- },
2863
- booking: {
2864
- addToCart: bookingApi.addToCart,
2865
- removeFromCart: bookingApi.removeFromCart,
2866
- getCart: bookingApi.getCart,
2867
- clearCart: bookingApi.clearCart,
2868
- create: bookingApi.createBooking,
2869
- update: bookingApi.updateBooking,
2870
- get: bookingApi.getBooking,
2871
- find: bookingApi.searchBookings,
2872
- getQuote: bookingApi.getQuote,
2873
- processRefund: bookingApi.processRefund,
2874
- getAvailability: bookingApi.getAvailability,
2875
- cancelItem: bookingApi.cancelBookingItem,
2797
+ },
2876
2798
  service: {
2877
- create: bookingApi.createService,
2878
- update: bookingApi.updateService,
2879
- delete: bookingApi.deleteService,
2880
- get: bookingApi.getService,
2881
- find: bookingApi.getServices,
2882
- findProviders: bookingApi.findServiceProviders,
2883
- createProvider: bookingApi.createServiceProvider,
2884
- updateProvider: bookingApi.updateServiceProvider,
2885
- deleteProvider: bookingApi.deleteServiceProvider
2799
+ create: schedulingApi.createService,
2800
+ update: schedulingApi.updateService,
2801
+ delete: schedulingApi.deleteService,
2802
+ get: schedulingApi.getService,
2803
+ find: schedulingApi.getServices,
2804
+ findProviders: schedulingApi.findServiceProviders,
2805
+ createProvider: schedulingApi.createServiceProvider,
2806
+ updateProvider: schedulingApi.updateServiceProvider,
2807
+ deleteProvider: schedulingApi.deleteServiceProvider
2886
2808
  },
2887
2809
  provider: {
2888
- create: bookingApi.createProvider,
2889
- update: bookingApi.updateProvider,
2890
- delete: bookingApi.deleteProvider,
2891
- get: bookingApi.getProvider,
2892
- find: bookingApi.getProviders
2893
- }
2810
+ create: schedulingApi.createProvider,
2811
+ update: schedulingApi.updateProvider,
2812
+ delete: schedulingApi.deleteProvider,
2813
+ get: schedulingApi.getProvider,
2814
+ find: schedulingApi.getProviders
2815
+ },
2816
+ promoCode: promoCodeApi
2894
2817
  },
2895
2818
  crm: {
2896
2819
  customer: {
@@ -3137,7 +3060,6 @@ function createStorefront(config) {
3137
3060
  store: storefrontApi.store,
3138
3061
  cms: storefrontApi.cms,
3139
3062
  eshop: storefrontApi.eshop,
3140
- booking: storefrontApi.booking,
3141
3063
  crm: storefrontApi.crm,
3142
3064
  activity: storefrontApi.activity,
3143
3065
  automation: storefrontApi.automation,