arky-sdk 0.7.93 → 0.7.102

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 CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var nanostores = require('nanostores');
4
-
5
3
  // src/types/index.ts
6
4
  var PaymentMethodType = /* @__PURE__ */ ((PaymentMethodType2) => {
7
5
  PaymentMethodType2["Cash"] = "cash";
@@ -158,7 +156,7 @@ var createActivityApi = (apiConfig) => ({
158
156
  async track(params) {
159
157
  try {
160
158
  await apiConfig.httpClient.post(
161
- `/v1/storefront/${apiConfig.businessId}/activities/track`,
159
+ `/v1/storefront/${apiConfig.storeId}/activities/track`,
162
160
  { type: params.type, payload: params.payload }
163
161
  );
164
162
  } catch {
@@ -181,11 +179,11 @@ function groupCartToItems(cart) {
181
179
  return [...groups.values()];
182
180
  }
183
181
  var createStorefrontApi = (apiConfig) => {
184
- const base = (businessId = apiConfig.businessId) => `/v1/storefront/${businessId}`;
182
+ const base = (storeId = apiConfig.storeId) => `/v1/storefront/${storeId}`;
185
183
  let cart = [];
186
184
  return {
187
- business: {
188
- getBusiness(options) {
185
+ store: {
186
+ getStore(options) {
189
187
  return apiConfig.httpClient.get(base(), options);
190
188
  },
191
189
  location: {
@@ -217,19 +215,19 @@ var createStorefrontApi = (apiConfig) => {
217
215
  cms: {
218
216
  node: {
219
217
  async get(params, options) {
220
- const business_id = params.business_id || apiConfig.businessId;
218
+ const store_id = params.store_id || apiConfig.storeId;
221
219
  let identifier;
222
220
  if (params.id) {
223
221
  identifier = params.id;
224
222
  } else if (params.slug) {
225
- identifier = `${business_id}:${apiConfig.locale}:${params.slug}`;
223
+ identifier = `${store_id}:${apiConfig.locale}:${params.slug}`;
226
224
  } else if (params.key) {
227
- identifier = `${business_id}:${params.key}`;
225
+ identifier = `${store_id}:${params.key}`;
228
226
  } else {
229
227
  throw new Error("GetNodeParams requires id, slug, or key");
230
228
  }
231
229
  const response = await apiConfig.httpClient.get(
232
- `${base(business_id)}/nodes/${identifier}`,
230
+ `${base(store_id)}/nodes/${identifier}`,
233
231
  options
234
232
  );
235
233
  return {
@@ -247,15 +245,15 @@ var createStorefrontApi = (apiConfig) => {
247
245
  };
248
246
  },
249
247
  find(params, options) {
250
- const { business_id, ...queryParams } = params;
251
- return apiConfig.httpClient.get(`${base(business_id)}/nodes`, {
248
+ const { store_id, ...queryParams } = params;
249
+ return apiConfig.httpClient.get(`${base(store_id)}/nodes`, {
252
250
  ...options,
253
251
  params: queryParams
254
252
  });
255
253
  },
256
254
  getChildren(params, options) {
257
- const { id, business_id, ...queryParams } = params;
258
- return apiConfig.httpClient.get(`${base(business_id)}/nodes/${id}/children`, {
255
+ const { id, store_id, ...queryParams } = params;
256
+ return apiConfig.httpClient.get(`${base(store_id)}/nodes/${id}/children`, {
259
257
  ...options,
260
258
  params: queryParams
261
259
  });
@@ -263,53 +261,53 @@ var createStorefrontApi = (apiConfig) => {
263
261
  },
264
262
  form: {
265
263
  get(params, options) {
266
- const business_id = params.business_id || apiConfig.businessId;
264
+ const store_id = params.store_id || apiConfig.storeId;
267
265
  let identifier;
268
266
  if (params.id) {
269
267
  identifier = params.id;
270
268
  } else if (params.key) {
271
- identifier = `${business_id}:${params.key}`;
269
+ identifier = `${store_id}:${params.key}`;
272
270
  } else {
273
271
  throw new Error("GetFormParams requires id or key");
274
272
  }
275
273
  return apiConfig.httpClient.get(
276
- `${base(business_id)}/forms/${identifier}`,
274
+ `${base(store_id)}/forms/${identifier}`,
277
275
  options
278
276
  );
279
277
  },
280
278
  submit(params, options) {
281
- const { business_id, form_id, ...payload } = params;
282
- const target_business_id = business_id || apiConfig.businessId;
279
+ const { store_id, form_id, ...payload } = params;
280
+ const target_store_id = store_id || apiConfig.storeId;
283
281
  if (!form_id) {
284
282
  throw new Error("SubmitFormParams requires form_id");
285
283
  }
286
284
  return apiConfig.httpClient.post(
287
- `${base(target_business_id)}/forms/${form_id}/submissions`,
288
- { ...payload, form_id, business_id: target_business_id },
285
+ `${base(target_store_id)}/forms/${form_id}/submissions`,
286
+ { ...payload, form_id, store_id: target_store_id },
289
287
  options
290
288
  );
291
289
  }
292
290
  },
293
291
  taxonomy: {
294
292
  get(params, options) {
295
- const business_id = params.business_id || apiConfig.businessId;
293
+ const store_id = params.store_id || apiConfig.storeId;
296
294
  let identifier;
297
295
  if (params.id) {
298
296
  identifier = params.id;
299
297
  } else if (params.key) {
300
- identifier = `${business_id}:${params.key}`;
298
+ identifier = `${store_id}:${params.key}`;
301
299
  } else {
302
300
  throw new Error("GetTaxonomyParams requires id or key");
303
301
  }
304
302
  return apiConfig.httpClient.get(
305
- `${base(business_id)}/taxonomies/${identifier}`,
303
+ `${base(store_id)}/taxonomies/${identifier}`,
306
304
  options
307
305
  );
308
306
  },
309
307
  getChildren(params, options) {
310
- const business_id = params.business_id || apiConfig.businessId;
308
+ const store_id = params.store_id || apiConfig.storeId;
311
309
  return apiConfig.httpClient.get(
312
- `${base(business_id)}/taxonomies/${params.id}/children`,
310
+ `${base(store_id)}/taxonomies/${params.id}/children`,
313
311
  options
314
312
  );
315
313
  }
@@ -318,23 +316,23 @@ var createStorefrontApi = (apiConfig) => {
318
316
  eshop: {
319
317
  product: {
320
318
  get(params, options) {
321
- const business_id = params.business_id || apiConfig.businessId;
319
+ const store_id = params.store_id || apiConfig.storeId;
322
320
  let identifier;
323
321
  if (params.id) {
324
322
  identifier = params.id;
325
323
  } else if (params.slug) {
326
- identifier = `${business_id}:${apiConfig.locale}:${params.slug}`;
324
+ identifier = `${store_id}:${apiConfig.locale}:${params.slug}`;
327
325
  } else {
328
326
  throw new Error("GetProductParams requires id or slug");
329
327
  }
330
328
  return apiConfig.httpClient.get(
331
- `${base(business_id)}/products/${identifier}`,
329
+ `${base(store_id)}/products/${identifier}`,
332
330
  options
333
331
  );
334
332
  },
335
333
  find(params, options) {
336
- const { business_id, ...queryParams } = params;
337
- return apiConfig.httpClient.get(`${base(business_id)}/products`, {
334
+ const { store_id, ...queryParams } = params;
335
+ return apiConfig.httpClient.get(`${base(store_id)}/products`, {
338
336
  ...options,
339
337
  params: queryParams
340
338
  });
@@ -342,8 +340,8 @@ var createStorefrontApi = (apiConfig) => {
342
340
  },
343
341
  order: {
344
342
  getQuote(params, options) {
345
- const business_id = params.business_id || apiConfig.businessId;
346
- const { location, business_id: _business_id, ...rest } = params;
343
+ const store_id = params.store_id || apiConfig.storeId;
344
+ const { location, store_id: _store_id, ...rest } = params;
347
345
  const shipping_address = location ? {
348
346
  country: location.country || "",
349
347
  state: location.state || "",
@@ -354,30 +352,30 @@ var createStorefrontApi = (apiConfig) => {
354
352
  street2: null
355
353
  } : void 0;
356
354
  return apiConfig.httpClient.post(
357
- `${base(business_id)}/orders/quote`,
355
+ `${base(store_id)}/orders/quote`,
358
356
  { ...rest, shipping_address, market: apiConfig.market },
359
357
  options
360
358
  );
361
359
  },
362
360
  checkout(params, options) {
363
- const { business_id, ...rest } = params;
364
- const target = business_id || apiConfig.businessId;
361
+ const { store_id, ...rest } = params;
362
+ const target = store_id || apiConfig.storeId;
365
363
  return apiConfig.httpClient.post(
366
364
  `${base(target)}/orders/checkout`,
367
- { ...rest, business_id: target, market: apiConfig.market },
365
+ { ...rest, store_id: target, market: apiConfig.market },
368
366
  options
369
367
  );
370
368
  },
371
369
  get(params, options) {
372
- const business_id = params.business_id || apiConfig.businessId;
370
+ const store_id = params.store_id || apiConfig.storeId;
373
371
  return apiConfig.httpClient.get(
374
- `${base(business_id)}/orders/${params.id}`,
372
+ `${base(store_id)}/orders/${params.id}`,
375
373
  options
376
374
  );
377
375
  },
378
376
  find(params, options) {
379
- const { business_id, ...queryParams } = params;
380
- return apiConfig.httpClient.get(`${base(business_id)}/orders`, {
377
+ const { store_id, ...queryParams } = params;
378
+ return apiConfig.httpClient.get(`${base(store_id)}/orders`, {
381
379
  ...options,
382
380
  params: queryParams
383
381
  });
@@ -398,81 +396,81 @@ var createStorefrontApi = (apiConfig) => {
398
396
  cart = [];
399
397
  },
400
398
  checkout(params, options) {
401
- const { business_id, items: paramItems, ...payload } = params || {};
402
- const target_business_id = business_id || apiConfig.businessId;
399
+ const { store_id, items: paramItems, ...payload } = params || {};
400
+ const target_store_id = store_id || apiConfig.storeId;
403
401
  const items = paramItems || groupCartToItems(cart);
404
402
  return apiConfig.httpClient.post(
405
- `${base(target_business_id)}/bookings/checkout`,
406
- { market: "booking", ...payload, items },
403
+ `${base(target_store_id)}/bookings/checkout`,
404
+ { market: apiConfig.market, ...payload, items },
407
405
  options
408
406
  );
409
407
  },
410
408
  get(params, options) {
411
- const business_id = params.business_id || apiConfig.businessId;
409
+ const store_id = params.store_id || apiConfig.storeId;
412
410
  return apiConfig.httpClient.get(
413
- `${base(business_id)}/bookings/${params.id}`,
411
+ `${base(store_id)}/bookings/${params.id}`,
414
412
  options
415
413
  );
416
414
  },
417
415
  find(params, options) {
418
- const { business_id, ...queryParams } = params;
419
- return apiConfig.httpClient.get(`${base(business_id)}/bookings`, {
416
+ const { store_id, ...queryParams } = params;
417
+ return apiConfig.httpClient.get(`${base(store_id)}/bookings`, {
420
418
  ...options,
421
419
  params: queryParams
422
420
  });
423
421
  },
424
422
  getQuote(params, options) {
425
- const { business_id, ...payload } = params;
426
- const target_business_id = business_id || apiConfig.businessId;
423
+ const { store_id, ...payload } = params;
424
+ const target_store_id = store_id || apiConfig.storeId;
427
425
  return apiConfig.httpClient.post(
428
- `${base(target_business_id)}/bookings/quote`,
429
- { market: "booking", ...payload },
426
+ `${base(target_store_id)}/bookings/quote`,
427
+ { market: apiConfig.market, ...payload },
430
428
  options
431
429
  );
432
430
  },
433
431
  getAvailability(params, options) {
434
- const { business_id, ...queryParams } = params;
435
- const target_business_id = business_id || apiConfig.businessId;
432
+ const { store_id, ...queryParams } = params;
433
+ const target_store_id = store_id || apiConfig.storeId;
436
434
  return apiConfig.httpClient.get(
437
- `${base(target_business_id)}/bookings/availability`,
435
+ `${base(target_store_id)}/bookings/availability`,
438
436
  { ...options, params: queryParams }
439
437
  );
440
438
  },
441
439
  cancelItem(params, options) {
442
- const { business_id, booking_id, item_id, ...payload } = params;
443
- const target_business_id = business_id || apiConfig.businessId;
440
+ const { store_id, booking_id, item_id, ...payload } = params;
441
+ const target_store_id = store_id || apiConfig.storeId;
444
442
  return apiConfig.httpClient.post(
445
- `${base(target_business_id)}/bookings/${booking_id}/items/${item_id}/cancel`,
443
+ `${base(target_store_id)}/bookings/${booking_id}/items/${item_id}/cancel`,
446
444
  payload,
447
445
  options
448
446
  );
449
447
  },
450
448
  service: {
451
449
  get(params, options) {
452
- const business_id = params.business_id || apiConfig.businessId;
450
+ const store_id = params.store_id || apiConfig.storeId;
453
451
  let identifier;
454
452
  if (params.id) {
455
453
  identifier = params.id;
456
454
  } else if (params.slug) {
457
- identifier = `${business_id}:${apiConfig.locale}:${params.slug}`;
455
+ identifier = `${store_id}:${apiConfig.locale}:${params.slug}`;
458
456
  } else {
459
457
  throw new Error("GetServiceParams requires id or slug");
460
458
  }
461
459
  return apiConfig.httpClient.get(
462
- `${base(business_id)}/services/${identifier}`,
460
+ `${base(store_id)}/services/${identifier}`,
463
461
  options
464
462
  );
465
463
  },
466
464
  find(params, options) {
467
- const { business_id, ...queryParams } = params;
468
- return apiConfig.httpClient.get(`${base(business_id)}/services`, {
465
+ const { store_id, ...queryParams } = params;
466
+ return apiConfig.httpClient.get(`${base(store_id)}/services`, {
469
467
  ...options,
470
468
  params: queryParams
471
469
  });
472
470
  },
473
471
  findProviders(params, options) {
474
- const { business_id, ...queryParams } = params;
475
- return apiConfig.httpClient.get(`${base(business_id)}/service-providers`, {
472
+ const { store_id, ...queryParams } = params;
473
+ return apiConfig.httpClient.get(`${base(store_id)}/service-providers`, {
476
474
  ...options,
477
475
  params: queryParams
478
476
  });
@@ -480,23 +478,23 @@ var createStorefrontApi = (apiConfig) => {
480
478
  },
481
479
  provider: {
482
480
  get(params, options) {
483
- const business_id = params.business_id || apiConfig.businessId;
481
+ const store_id = params.store_id || apiConfig.storeId;
484
482
  let identifier;
485
483
  if (params.id) {
486
484
  identifier = params.id;
487
485
  } else if (params.slug) {
488
- identifier = `${business_id}:${apiConfig.locale}:${params.slug}`;
486
+ identifier = `${store_id}:${apiConfig.locale}:${params.slug}`;
489
487
  } else {
490
488
  throw new Error("GetProviderParams requires id or slug");
491
489
  }
492
490
  return apiConfig.httpClient.get(
493
- `${base(business_id)}/providers/${identifier}`,
491
+ `${base(store_id)}/providers/${identifier}`,
494
492
  options
495
493
  );
496
494
  },
497
495
  find(params, options) {
498
- const { business_id, ...queryParams } = params;
499
- return apiConfig.httpClient.get(`${base(business_id)}/providers`, {
496
+ const { store_id, ...queryParams } = params;
497
+ return apiConfig.httpClient.get(`${base(store_id)}/providers`, {
500
498
  ...options,
501
499
  params: queryParams
502
500
  });
@@ -505,61 +503,46 @@ var createStorefrontApi = (apiConfig) => {
505
503
  },
506
504
  crm: {
507
505
  customer: {
508
- async session(params, options) {
509
- const business_id = params?.business_id || apiConfig.businessId;
506
+ async identify(params, options) {
507
+ const store_id = apiConfig.storeId;
510
508
  const result = await apiConfig.httpClient.post(
511
- `${base(business_id)}/customers/session`,
512
- { business_id, market: params?.market || apiConfig.market || null },
513
- options
514
- );
515
- if (result?.token?.access_token) {
516
- apiConfig.setToken(result.token);
517
- }
518
- return result;
519
- },
520
- async connect(params, options) {
521
- const business_id = params.business_id || apiConfig.businessId;
522
- const result = await apiConfig.httpClient.post(
523
- `${base(business_id)}/customers/connect`,
524
- { email: params.email, business_id },
509
+ `${base(store_id)}/customers/identify`,
510
+ {
511
+ store_id,
512
+ market: params?.market || apiConfig.market || null,
513
+ email: params?.email,
514
+ verify: params?.verify ?? false
515
+ },
525
516
  options
526
517
  );
527
- if (result?.access_token) {
528
- apiConfig.setToken(result);
518
+ if (result?.token?.token) {
519
+ apiConfig.setToken({ access_token: result.token.token });
529
520
  }
530
521
  return result;
531
522
  },
532
- requestCode(params, options) {
533
- const business_id = params.business_id || apiConfig.businessId;
534
- return apiConfig.httpClient.post(
535
- `${base(business_id)}/customers/auth/code`,
536
- { email: params.email, business_id },
537
- options
538
- );
539
- },
540
523
  async verify(params, options) {
541
- const business_id = params.business_id || apiConfig.businessId;
524
+ const store_id = apiConfig.storeId;
542
525
  const result = await apiConfig.httpClient.post(
543
- `${base(business_id)}/customers/auth/verify`,
544
- { email: params.email, code: params.code, business_id },
526
+ `${base(store_id)}/customers/verify`,
527
+ { store_id, code: params.code },
545
528
  options
546
529
  );
547
- if (result?.access_token) {
548
- apiConfig.setToken(result);
530
+ if (result?.token) {
531
+ apiConfig.setToken({ access_token: result.token });
549
532
  }
550
533
  return result;
551
534
  },
552
- async refreshToken(params, options) {
553
- const business_id = params.business_id || apiConfig.businessId;
554
- const result = await apiConfig.httpClient.post(
555
- `${base(business_id)}/customers/auth/refresh`,
556
- { refresh_token: params.refresh_token },
557
- options
558
- );
559
- if (result?.access_token) {
560
- apiConfig.setToken(result);
535
+ async logout(options) {
536
+ const store_id = apiConfig.storeId;
537
+ try {
538
+ await apiConfig.httpClient.post(
539
+ `${base(store_id)}/customers/logout`,
540
+ {},
541
+ options
542
+ );
543
+ } finally {
544
+ apiConfig.setToken({ access_token: "" });
561
545
  }
562
- return result;
563
546
  },
564
547
  getMe(options) {
565
548
  return apiConfig.httpClient.get(`${base()}/customers/me`, options);
@@ -571,12 +554,12 @@ var createStorefrontApi = (apiConfig) => {
571
554
  if (params.id) {
572
555
  identifier = params.id;
573
556
  } else if (params.key) {
574
- identifier = `${apiConfig.businessId}:${params.key}`;
557
+ identifier = `${apiConfig.storeId}:${params.key}`;
575
558
  } else {
576
559
  throw new Error("GetAudienceParams requires id or key");
577
560
  }
578
561
  return apiConfig.httpClient.get(
579
- `${base(apiConfig.businessId)}/audiences/${identifier}`,
562
+ `${base(apiConfig.storeId)}/audiences/${identifier}`,
580
563
  options
581
564
  );
582
565
  },
@@ -623,44 +606,44 @@ var createStorefrontApi = (apiConfig) => {
623
606
  automation: {
624
607
  agent: {
625
608
  getAgents(params, options) {
626
- const business_id = params?.business_id || apiConfig.businessId;
609
+ const store_id = params?.store_id || apiConfig.storeId;
627
610
  const queryParams = { ...params || {} };
628
- delete queryParams.business_id;
629
- return apiConfig.httpClient.get(`${base(business_id)}/agents`, {
611
+ delete queryParams.store_id;
612
+ return apiConfig.httpClient.get(`${base(store_id)}/agents`, {
630
613
  ...options,
631
614
  params: Object.keys(queryParams).length > 0 ? queryParams : void 0
632
615
  });
633
616
  },
634
617
  getAgent(params, options) {
635
- const business_id = params.business_id || apiConfig.businessId;
618
+ const store_id = params.store_id || apiConfig.storeId;
636
619
  return apiConfig.httpClient.get(
637
- `${base(business_id)}/agents/${params.id}`,
620
+ `${base(store_id)}/agents/${params.id}`,
638
621
  options
639
622
  );
640
623
  },
641
624
  sendMessage(params, options) {
642
- const business_id = params.business_id || apiConfig.businessId;
625
+ const store_id = params.store_id || apiConfig.storeId;
643
626
  const body = { message: params.message };
644
627
  if (params.chat_id) body.chat_id = params.chat_id;
645
628
  return apiConfig.httpClient.post(
646
- `${base(business_id)}/agents/${params.id}/chats/messages`,
629
+ `${base(store_id)}/agents/${params.id}/chats/messages`,
647
630
  body,
648
631
  options
649
632
  );
650
633
  },
651
634
  getChat(params, options) {
652
- const business_id = params.business_id || apiConfig.businessId;
635
+ const store_id = params.store_id || apiConfig.storeId;
653
636
  return apiConfig.httpClient.get(
654
- `${base(business_id)}/agents/${params.id}/chats/${params.chat_id}`,
637
+ `${base(store_id)}/agents/${params.id}/chats/${params.chat_id}`,
655
638
  options
656
639
  );
657
640
  },
658
641
  getChatMessages(params, options) {
659
- const business_id = params.business_id || apiConfig.businessId;
642
+ const store_id = params.store_id || apiConfig.storeId;
660
643
  const queryParams = {};
661
644
  if (params.limit) queryParams.limit = String(params.limit);
662
645
  return apiConfig.httpClient.get(
663
- `${base(business_id)}/agents/${params.id}/chats/${params.chat_id}/messages`,
646
+ `${base(store_id)}/agents/${params.id}/chats/${params.chat_id}/messages`,
664
647
  {
665
648
  ...options,
666
649
  params: Object.keys(queryParams).length > 0 ? queryParams : void 0
@@ -668,11 +651,11 @@ var createStorefrontApi = (apiConfig) => {
668
651
  );
669
652
  },
670
653
  rateChat(params, options) {
671
- const business_id = params.business_id || apiConfig.businessId;
654
+ const store_id = params.store_id || apiConfig.storeId;
672
655
  const body = { rating: params.rating };
673
656
  if (params.comment) body.comment = params.comment;
674
657
  return apiConfig.httpClient.post(
675
- `${base(business_id)}/agents/${params.id}/chats/${params.chat_id}/rate`,
658
+ `${base(store_id)}/agents/${params.id}/chats/${params.chat_id}/rate`,
676
659
  body,
677
660
  options
678
661
  );
@@ -720,36 +703,31 @@ function buildQueryString(params) {
720
703
  }
721
704
 
722
705
  // src/services/createHttpClient.ts
723
- var STORAGE_KEYS = {
724
- access_token: "arky_token",
725
- refresh_token: "arky_refresh",
726
- access_expires_at: "arky_expires_at"
727
- };
706
+ var TOKEN_KEY = "arky_token";
707
+ var LEGACY_KEYS = ["arky_refresh", "arky_expires_at"];
728
708
  function defaultGetToken() {
729
709
  if (typeof window === "undefined") return { access_token: "" };
730
710
  return {
731
- access_token: localStorage.getItem(STORAGE_KEYS.access_token) || "",
732
- refresh_token: localStorage.getItem(STORAGE_KEYS.refresh_token) || "",
733
- access_expires_at: parseInt(localStorage.getItem(STORAGE_KEYS.access_expires_at) || "0", 10)
711
+ access_token: localStorage.getItem(TOKEN_KEY) || ""
734
712
  };
735
713
  }
736
714
  function defaultSetToken(tokens) {
737
715
  if (typeof window === "undefined") return;
738
716
  if (tokens.access_token) {
739
- localStorage.setItem(STORAGE_KEYS.access_token, tokens.access_token);
740
- localStorage.setItem(STORAGE_KEYS.refresh_token, tokens.refresh_token || "");
741
- localStorage.setItem(STORAGE_KEYS.access_expires_at, (tokens.access_expires_at || 0).toString());
717
+ localStorage.setItem(TOKEN_KEY, tokens.access_token);
742
718
  } else {
743
- Object.values(STORAGE_KEYS).forEach((key) => localStorage.removeItem(key));
719
+ localStorage.removeItem(TOKEN_KEY);
744
720
  }
721
+ LEGACY_KEYS.forEach((key) => localStorage.removeItem(key));
745
722
  }
746
723
  function defaultLogout() {
747
724
  if (typeof window === "undefined") return;
748
- Object.values(STORAGE_KEYS).forEach((key) => localStorage.removeItem(key));
725
+ localStorage.removeItem(TOKEN_KEY);
726
+ LEGACY_KEYS.forEach((key) => localStorage.removeItem(key));
749
727
  }
750
728
  function defaultIsAuthenticated() {
751
729
  if (typeof window === "undefined") return false;
752
- const token = localStorage.getItem(STORAGE_KEYS.access_token) || "";
730
+ const token = localStorage.getItem(TOKEN_KEY) || "";
753
731
  return token.startsWith("customer_") || token.startsWith("account_");
754
732
  }
755
733
  function createHttpClient(cfg) {
@@ -931,10 +909,10 @@ var createAccountApi = (apiConfig) => {
931
909
  if (params.api_tokens !== void 0) payload.api_tokens = params.api_tokens;
932
910
  return apiConfig.httpClient.put("/v1/accounts", payload, options);
933
911
  },
934
- async deleteAccount(params, options) {
912
+ async deleteAccount(_params, options) {
935
913
  return apiConfig.httpClient.delete("/v1/accounts", options);
936
914
  },
937
- async getMe(params, options) {
915
+ async getMe(_params, options) {
938
916
  return apiConfig.httpClient.get("/v1/accounts/me", options);
939
917
  },
940
918
  async searchAccounts(params, options) {
@@ -942,7 +920,7 @@ var createAccountApi = (apiConfig) => {
942
920
  ...options,
943
921
  params: {
944
922
  ...params,
945
- business_id: apiConfig.businessId
923
+ store_id: apiConfig.storeId
946
924
  }
947
925
  });
948
926
  }
@@ -956,22 +934,30 @@ var createAuthApi = (apiConfig) => {
956
934
  return apiConfig.httpClient.post("/v1/auth/code", params, options);
957
935
  },
958
936
  async verify(params, options) {
959
- const result = await apiConfig.httpClient.post("/v1/auth/verify", params, options);
937
+ const result = await apiConfig.httpClient.post(
938
+ "/v1/auth/verify",
939
+ params,
940
+ options
941
+ );
960
942
  if (result?.access_token) {
961
- apiConfig.setToken({ ...result, email: params.email, is_verified: true });
943
+ apiConfig.setToken({ access_token: result.access_token, refresh_token: result.refresh_token });
962
944
  }
963
945
  return result;
964
946
  },
965
947
  async refresh(params, options) {
966
948
  return apiConfig.httpClient.post("/v1/auth/refresh", params, options);
967
949
  },
968
- async businessCode(businessId, params, options) {
969
- return apiConfig.httpClient.post(`/v1/businesses/${businessId}/auth/code`, params, options);
950
+ async storeCode(storeId, params, options) {
951
+ return apiConfig.httpClient.post(`/v1/stores/${storeId}/auth/code`, params, options);
970
952
  },
971
- async businessVerify(businessId, params, options) {
972
- const result = await apiConfig.httpClient.post(`/v1/businesses/${businessId}/auth/verify`, params, options);
953
+ async storeVerify(storeId, params, options) {
954
+ const result = await apiConfig.httpClient.post(
955
+ `/v1/stores/${storeId}/auth/verify`,
956
+ params,
957
+ options
958
+ );
973
959
  if (result?.access_token) {
974
- apiConfig.setToken({ ...result, email: params.email, is_verified: true });
960
+ apiConfig.setToken({ access_token: result.access_token, refresh_token: result.refresh_token });
975
961
  }
976
962
  return result;
977
963
  },
@@ -981,86 +967,86 @@ var createAuthApi = (apiConfig) => {
981
967
  };
982
968
  };
983
969
 
984
- // src/api/business.ts
985
- var createBusinessApi = (apiConfig) => {
970
+ // src/api/store.ts
971
+ var createStoreApi = (apiConfig) => {
986
972
  return {
987
- async createBusiness(params, options) {
988
- return apiConfig.httpClient.post(`/v1/businesses`, params, options);
973
+ async createStore(params, options) {
974
+ return apiConfig.httpClient.post(`/v1/stores`, params, options);
989
975
  },
990
- async updateBusiness(params, options) {
976
+ async updateStore(params, options) {
991
977
  return apiConfig.httpClient.put(
992
- `/v1/businesses/${params.id}`,
978
+ `/v1/stores/${params.id}`,
993
979
  params,
994
980
  options
995
981
  );
996
982
  },
997
- async deleteBusiness(params, options) {
983
+ async deleteStore(params, options) {
998
984
  return apiConfig.httpClient.delete(
999
- `/v1/businesses/${params.id}`,
985
+ `/v1/stores/${params.id}`,
1000
986
  options
1001
987
  );
1002
988
  },
1003
- async getBusiness(params, options) {
989
+ async getStore(_params, options) {
1004
990
  return apiConfig.httpClient.get(
1005
- `/v1/businesses/${apiConfig.businessId}`,
991
+ `/v1/stores/${apiConfig.storeId}`,
1006
992
  options
1007
993
  );
1008
994
  },
1009
- async getBusinesses(params, options) {
1010
- return apiConfig.httpClient.get(`/v1/businesses`, {
995
+ async getStores(params, options) {
996
+ return apiConfig.httpClient.get(`/v1/stores`, {
1011
997
  ...options,
1012
998
  params
1013
999
  });
1014
1000
  },
1015
- async getSubscriptionPlans(params, options) {
1016
- return apiConfig.httpClient.get("/v1/businesses/plans", options);
1001
+ async getSubscriptionPlans(_params, options) {
1002
+ return apiConfig.httpClient.get("/v1/stores/plans", options);
1017
1003
  },
1018
1004
  async subscribe(params, options) {
1019
- const { business_id, plan_id, success_url, cancel_url } = params;
1020
- const target_business_id = business_id || apiConfig.businessId;
1005
+ const { store_id, plan_id, success_url, cancel_url } = params;
1006
+ const target_store_id = store_id || apiConfig.storeId;
1021
1007
  return apiConfig.httpClient.put(
1022
- `/v1/businesses/${target_business_id}/subscribe`,
1008
+ `/v1/stores/${target_store_id}/subscribe`,
1023
1009
  { plan_id, success_url, cancel_url },
1024
1010
  options
1025
1011
  );
1026
1012
  },
1027
1013
  async createPortalSession(params, options) {
1028
- const business_id = params.business_id || apiConfig.businessId;
1014
+ const store_id = params.store_id || apiConfig.storeId;
1029
1015
  return apiConfig.httpClient.post(
1030
- `/v1/businesses/${business_id}/subscription/portal`,
1016
+ `/v1/stores/${store_id}/subscription/portal`,
1031
1017
  { return_url: params.return_url },
1032
1018
  options
1033
1019
  );
1034
1020
  },
1035
1021
  async inviteUser(params, options) {
1036
1022
  return apiConfig.httpClient.post(
1037
- `/v1/businesses/${apiConfig.businessId}/invitation`,
1023
+ `/v1/stores/${apiConfig.storeId}/invitation`,
1038
1024
  params,
1039
1025
  options
1040
1026
  );
1041
1027
  },
1042
1028
  async removeMember(params, options) {
1043
1029
  return apiConfig.httpClient.delete(
1044
- `/v1/businesses/${apiConfig.businessId}/members/${params.account_id}`,
1030
+ `/v1/stores/${apiConfig.storeId}/members/${params.account_id}`,
1045
1031
  options
1046
1032
  );
1047
1033
  },
1048
1034
  async handleInvitation(params, options) {
1049
- const { business_id, ...payload } = params;
1035
+ const { store_id, ...payload } = params;
1050
1036
  return apiConfig.httpClient.put(
1051
- `/v1/businesses/${business_id || apiConfig.businessId}/invitation`,
1037
+ `/v1/stores/${store_id || apiConfig.storeId}/invitation`,
1052
1038
  payload,
1053
1039
  options
1054
1040
  );
1055
1041
  },
1056
1042
  async testWebhook(params, options) {
1057
1043
  return apiConfig.httpClient.post(
1058
- `/v1/businesses/${apiConfig.businessId}/webhooks/test`,
1044
+ `/v1/stores/${apiConfig.storeId}/webhooks/test`,
1059
1045
  params.webhook,
1060
1046
  options
1061
1047
  );
1062
1048
  },
1063
- async getBusinessMedia(params, options) {
1049
+ async getStoreMedia(params, options) {
1064
1050
  const queryParams = {
1065
1051
  limit: params.limit
1066
1052
  };
@@ -1070,84 +1056,84 @@ var createBusinessApi = (apiConfig) => {
1070
1056
  if (params.mime_type) queryParams.mime_type = params.mime_type;
1071
1057
  if (params.sort_field) queryParams.sort_field = params.sort_field;
1072
1058
  if (params.sort_direction) queryParams.sort_direction = params.sort_direction;
1073
- return apiConfig.httpClient.get(`/v1/businesses/${params.id}/media`, {
1059
+ return apiConfig.httpClient.get(`/v1/stores/${params.id}/media`, {
1074
1060
  ...options,
1075
1061
  params: queryParams
1076
1062
  });
1077
1063
  },
1078
1064
  async oauthConnect(params, options) {
1079
1065
  return apiConfig.httpClient.post(
1080
- `/v1/businesses/${params.business_id}/oauth/connect`,
1066
+ `/v1/stores/${params.store_id}/oauth/connect`,
1081
1067
  { provider: params.provider, code: params.code, redirect_uri: params.redirect_uri },
1082
1068
  options
1083
1069
  );
1084
1070
  },
1085
1071
  async oauthDisconnect(params, options) {
1086
1072
  return apiConfig.httpClient.post(
1087
- `/v1/businesses/${params.business_id}/oauth/disconnect`,
1073
+ `/v1/stores/${params.store_id}/oauth/disconnect`,
1088
1074
  { provider: params.provider },
1089
1075
  options
1090
1076
  );
1091
1077
  },
1092
1078
  async listIntegrations(params, options) {
1093
1079
  return apiConfig.httpClient.get(
1094
- `/v1/businesses/${params.business_id}/integrations`,
1080
+ `/v1/stores/${params.store_id}/integrations`,
1095
1081
  options
1096
1082
  );
1097
1083
  },
1098
1084
  async createIntegration(params, options) {
1099
- const { business_id, ...payload } = params;
1085
+ const { store_id, ...payload } = params;
1100
1086
  return apiConfig.httpClient.post(
1101
- `/v1/businesses/${business_id}/integrations`,
1087
+ `/v1/stores/${store_id}/integrations`,
1102
1088
  payload,
1103
1089
  options
1104
1090
  );
1105
1091
  },
1106
1092
  async updateIntegration(params, options) {
1107
- const { business_id, id, ...payload } = params;
1093
+ const { store_id, id, ...payload } = params;
1108
1094
  return apiConfig.httpClient.put(
1109
- `/v1/businesses/${business_id}/integrations/${id}`,
1095
+ `/v1/stores/${store_id}/integrations/${id}`,
1110
1096
  payload,
1111
1097
  options
1112
1098
  );
1113
1099
  },
1114
1100
  async deleteIntegration(params, options) {
1115
1101
  return apiConfig.httpClient.delete(
1116
- `/v1/businesses/${params.business_id}/integrations/${params.id}`,
1102
+ `/v1/stores/${params.store_id}/integrations/${params.id}`,
1117
1103
  options
1118
1104
  );
1119
1105
  },
1120
1106
  async getIntegrationConfig(params, options) {
1121
1107
  return apiConfig.httpClient.get(
1122
- `/v1/businesses/${params.business_id}/integrations/config/${params.type}`,
1108
+ `/v1/stores/${params.store_id}/integrations/config/${params.type}`,
1123
1109
  options
1124
1110
  );
1125
1111
  },
1126
1112
  async listWebhooks(params, options) {
1127
1113
  return apiConfig.httpClient.get(
1128
- `/v1/businesses/${params.business_id}/webhooks`,
1114
+ `/v1/stores/${params.store_id}/webhooks`,
1129
1115
  options
1130
1116
  );
1131
1117
  },
1132
1118
  async createWebhook(params, options) {
1133
- const { business_id, ...payload } = params;
1119
+ const { store_id, ...payload } = params;
1134
1120
  return apiConfig.httpClient.post(
1135
- `/v1/businesses/${business_id}/webhooks`,
1121
+ `/v1/stores/${store_id}/webhooks`,
1136
1122
  payload,
1137
1123
  options
1138
1124
  );
1139
1125
  },
1140
1126
  async updateWebhook(params, options) {
1141
- const { business_id, id, ...payload } = params;
1127
+ const { store_id, id, ...payload } = params;
1142
1128
  return apiConfig.httpClient.put(
1143
- `/v1/businesses/${business_id}/webhooks/${id}`,
1129
+ `/v1/stores/${store_id}/webhooks/${id}`,
1144
1130
  payload,
1145
1131
  options
1146
1132
  );
1147
1133
  },
1148
1134
  async deleteWebhook(params, options) {
1149
1135
  return apiConfig.httpClient.delete(
1150
- `/v1/businesses/${params.business_id}/webhooks/${params.id}`,
1136
+ `/v1/stores/${params.store_id}/webhooks/${params.id}`,
1151
1137
  options
1152
1138
  );
1153
1139
  }
@@ -1158,16 +1144,16 @@ var createBusinessApi = (apiConfig) => {
1158
1144
  var createMediaApi = (apiConfig) => {
1159
1145
  return {
1160
1146
  async getMedia(params, options) {
1161
- const target_business_id = params.business_id || apiConfig.businessId;
1147
+ const target_store_id = params.store_id || apiConfig.storeId;
1162
1148
  return apiConfig.httpClient.get(
1163
- `/v1/businesses/${target_business_id}/media/${params.media_id}`,
1149
+ `/v1/stores/${target_store_id}/media/${params.media_id}`,
1164
1150
  options
1165
1151
  );
1166
1152
  },
1167
- async uploadBusinessMedia(params, options) {
1168
- const { business_id, files = [], urls = [] } = params;
1169
- const target_business_id = business_id || apiConfig.businessId;
1170
- const url = `${apiConfig.baseUrl}/v1/businesses/${target_business_id}/media`;
1153
+ async uploadStoreMedia(params, _options) {
1154
+ const { store_id, files = [], urls = [] } = params;
1155
+ const target_store_id = store_id || apiConfig.storeId;
1156
+ const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
1171
1157
  const formData = new FormData();
1172
1158
  files.forEach((file) => formData.append("files", file));
1173
1159
  urls.forEach((url2) => formData.append("urls", url2));
@@ -1184,17 +1170,17 @@ var createMediaApi = (apiConfig) => {
1184
1170
  }
1185
1171
  return await response.json();
1186
1172
  },
1187
- async deleteBusinessMedia(params, options) {
1173
+ async deleteStoreMedia(params, options) {
1188
1174
  const { id, media_id } = params;
1189
1175
  return apiConfig.httpClient.delete(
1190
- `/v1/businesses/${id}/media/${media_id}`,
1176
+ `/v1/stores/${id}/media/${media_id}`,
1191
1177
  options
1192
1178
  );
1193
1179
  },
1194
- async getBusinessMedia(params, options) {
1195
- const { business_id, cursor, limit, ids, query, mime_type, sort_field, sort_direction } = params;
1196
- const target_business_id = business_id || apiConfig.businessId;
1197
- const url = `${apiConfig.baseUrl}/v1/businesses/${target_business_id}/media`;
1180
+ async getStoreMedia(params, _options) {
1181
+ const { store_id, cursor, limit, ids, query, mime_type, sort_field, sort_direction } = params;
1182
+ const target_store_id = store_id || apiConfig.storeId;
1183
+ const url = `${apiConfig.baseUrl}/v1/stores/${target_store_id}/media`;
1198
1184
  const queryParams = { limit: String(limit) };
1199
1185
  if (cursor) queryParams.cursor = cursor;
1200
1186
  if (ids && ids.length > 0) queryParams.ids = ids.join(",");
@@ -1216,10 +1202,10 @@ var createMediaApi = (apiConfig) => {
1216
1202
  return await response.json();
1217
1203
  },
1218
1204
  async updateMedia(params, options) {
1219
- const { media_id, business_id, ...payload } = params;
1220
- const target_business_id = business_id || apiConfig.businessId;
1205
+ const { media_id, store_id, ...payload } = params;
1206
+ const target_store_id = store_id || apiConfig.storeId;
1221
1207
  return apiConfig.httpClient.put(
1222
- `/v1/businesses/${target_business_id}/media/${media_id}`,
1208
+ `/v1/stores/${target_store_id}/media/${media_id}`,
1223
1209
  payload,
1224
1210
  options
1225
1211
  );
@@ -1250,41 +1236,41 @@ var createNotificationApi = (apiConfig) => {
1250
1236
  var createPromoCodeApi = (apiConfig) => {
1251
1237
  return {
1252
1238
  async createPromoCode(params, options) {
1253
- const { business_id, ...payload } = params;
1254
- const target_business_id = business_id || apiConfig.businessId;
1239
+ const { store_id, ...payload } = params;
1240
+ const target_store_id = store_id || apiConfig.storeId;
1255
1241
  return apiConfig.httpClient.post(
1256
- `/v1/businesses/${target_business_id}/promo-codes`,
1242
+ `/v1/stores/${target_store_id}/promo-codes`,
1257
1243
  payload,
1258
1244
  options
1259
1245
  );
1260
1246
  },
1261
1247
  async updatePromoCode(params, options) {
1262
- const { business_id, ...payload } = params;
1263
- const target_business_id = business_id || apiConfig.businessId;
1248
+ const { store_id, ...payload } = params;
1249
+ const target_store_id = store_id || apiConfig.storeId;
1264
1250
  return apiConfig.httpClient.put(
1265
- `/v1/businesses/${target_business_id}/promo-codes/${params.id}`,
1251
+ `/v1/stores/${target_store_id}/promo-codes/${params.id}`,
1266
1252
  payload,
1267
1253
  options
1268
1254
  );
1269
1255
  },
1270
1256
  async deletePromoCode(params, options) {
1271
- const target_business_id = params.business_id || apiConfig.businessId;
1257
+ const target_store_id = params.store_id || apiConfig.storeId;
1272
1258
  return apiConfig.httpClient.delete(
1273
- `/v1/businesses/${target_business_id}/promo-codes/${params.id}`,
1259
+ `/v1/stores/${target_store_id}/promo-codes/${params.id}`,
1274
1260
  options
1275
1261
  );
1276
1262
  },
1277
1263
  async getPromoCode(params, options) {
1278
- const target_business_id = params.business_id || apiConfig.businessId;
1264
+ const target_store_id = params.store_id || apiConfig.storeId;
1279
1265
  return apiConfig.httpClient.get(
1280
- `/v1/businesses/${target_business_id}/promo-codes/${params.id}`,
1266
+ `/v1/stores/${target_store_id}/promo-codes/${params.id}`,
1281
1267
  options
1282
1268
  );
1283
1269
  },
1284
1270
  async getPromoCodes(params, options) {
1285
- const { business_id, ...queryParams } = params;
1286
- const target_business_id = business_id || apiConfig.businessId;
1287
- return apiConfig.httpClient.get(`/v1/businesses/${target_business_id}/promo-codes`, {
1271
+ const { store_id, ...queryParams } = params;
1272
+ const target_store_id = store_id || apiConfig.storeId;
1273
+ return apiConfig.httpClient.get(`/v1/stores/${target_store_id}/promo-codes`, {
1288
1274
  ...options,
1289
1275
  params: queryParams
1290
1276
  });
@@ -1296,44 +1282,44 @@ var createPromoCodeApi = (apiConfig) => {
1296
1282
  var createCmsApi = (apiConfig) => {
1297
1283
  return {
1298
1284
  async createNode(params, options) {
1299
- const { business_id, ...payload } = params;
1300
- const target_business_id = business_id || apiConfig.businessId;
1285
+ const { store_id, ...payload } = params;
1286
+ const target_store_id = store_id || apiConfig.storeId;
1301
1287
  return apiConfig.httpClient.post(
1302
- `/v1/businesses/${target_business_id}/nodes`,
1288
+ `/v1/stores/${target_store_id}/nodes`,
1303
1289
  payload,
1304
1290
  options
1305
1291
  );
1306
1292
  },
1307
1293
  async updateNode(params, options) {
1308
- const { business_id, ...payload } = params;
1309
- const target_business_id = business_id || apiConfig.businessId;
1294
+ const { store_id, ...payload } = params;
1295
+ const target_store_id = store_id || apiConfig.storeId;
1310
1296
  return apiConfig.httpClient.put(
1311
- `/v1/businesses/${target_business_id}/nodes/${params.id}`,
1297
+ `/v1/stores/${target_store_id}/nodes/${params.id}`,
1312
1298
  payload,
1313
1299
  options
1314
1300
  );
1315
1301
  },
1316
1302
  async deleteNode(params, options) {
1317
- const target_business_id = params.business_id || apiConfig.businessId;
1303
+ const target_store_id = params.store_id || apiConfig.storeId;
1318
1304
  return apiConfig.httpClient.delete(
1319
- `/v1/businesses/${target_business_id}/nodes/${params.id}`,
1305
+ `/v1/stores/${target_store_id}/nodes/${params.id}`,
1320
1306
  options
1321
1307
  );
1322
1308
  },
1323
1309
  async getNode(params, options) {
1324
- const target_business_id = params.business_id || apiConfig.businessId;
1310
+ const target_store_id = params.store_id || apiConfig.storeId;
1325
1311
  let identifier;
1326
1312
  if (params.id) {
1327
1313
  identifier = params.id;
1328
1314
  } else if (params.slug) {
1329
- identifier = `${target_business_id}:${apiConfig.locale}:${params.slug}`;
1315
+ identifier = `${target_store_id}:${apiConfig.locale}:${params.slug}`;
1330
1316
  } else if (params.key) {
1331
- identifier = `${target_business_id}:${params.key}`;
1317
+ identifier = `${target_store_id}:${params.key}`;
1332
1318
  } else {
1333
1319
  throw new Error("GetNodeParams requires id, slug, or key");
1334
1320
  }
1335
1321
  const response = await apiConfig.httpClient.get(
1336
- `/v1/businesses/${target_business_id}/nodes/${identifier}`,
1322
+ `/v1/stores/${target_store_id}/nodes/${identifier}`,
1337
1323
  options
1338
1324
  );
1339
1325
  return {
@@ -1351,10 +1337,10 @@ var createCmsApi = (apiConfig) => {
1351
1337
  };
1352
1338
  },
1353
1339
  async getNodes(params, options) {
1354
- const { business_id, ...queryParams } = params;
1355
- const target_business_id = business_id || apiConfig.businessId;
1340
+ const { store_id, ...queryParams } = params;
1341
+ const target_store_id = store_id || apiConfig.storeId;
1356
1342
  return apiConfig.httpClient.get(
1357
- `/v1/businesses/${target_business_id}/nodes`,
1343
+ `/v1/stores/${target_store_id}/nodes`,
1358
1344
  {
1359
1345
  ...options,
1360
1346
  params: queryParams
@@ -1362,10 +1348,10 @@ var createCmsApi = (apiConfig) => {
1362
1348
  );
1363
1349
  },
1364
1350
  async getNodeChildren(params, options) {
1365
- const { id, business_id, ...queryParams } = params;
1366
- const target_business_id = business_id || apiConfig.businessId;
1351
+ const { id, store_id, ...queryParams } = params;
1352
+ const target_store_id = store_id || apiConfig.storeId;
1367
1353
  return apiConfig.httpClient.get(
1368
- `/v1/businesses/${target_business_id}/nodes/${id}/children`,
1354
+ `/v1/stores/${target_store_id}/nodes/${id}/children`,
1369
1355
  {
1370
1356
  ...options,
1371
1357
  params: queryParams
@@ -1379,50 +1365,50 @@ var createCmsApi = (apiConfig) => {
1379
1365
  var createEshopApi = (apiConfig) => {
1380
1366
  return {
1381
1367
  async createProduct(params, options) {
1382
- const { business_id, ...payload } = params;
1383
- const target_business_id = business_id || apiConfig.businessId;
1368
+ const { store_id, ...payload } = params;
1369
+ const target_store_id = store_id || apiConfig.storeId;
1384
1370
  return apiConfig.httpClient.post(
1385
- `/v1/businesses/${target_business_id}/products`,
1371
+ `/v1/stores/${target_store_id}/products`,
1386
1372
  payload,
1387
1373
  options
1388
1374
  );
1389
1375
  },
1390
1376
  async updateProduct(params, options) {
1391
- const { business_id, ...payload } = params;
1392
- const target_business_id = business_id || apiConfig.businessId;
1377
+ const { store_id, ...payload } = params;
1378
+ const target_store_id = store_id || apiConfig.storeId;
1393
1379
  return apiConfig.httpClient.put(
1394
- `/v1/businesses/${target_business_id}/products/${params.id}`,
1380
+ `/v1/stores/${target_store_id}/products/${params.id}`,
1395
1381
  payload,
1396
1382
  options
1397
1383
  );
1398
1384
  },
1399
1385
  async deleteProduct(params, options) {
1400
- const target_business_id = params.business_id || apiConfig.businessId;
1386
+ const target_store_id = params.store_id || apiConfig.storeId;
1401
1387
  return apiConfig.httpClient.delete(
1402
- `/v1/businesses/${target_business_id}/products/${params.id}`,
1388
+ `/v1/stores/${target_store_id}/products/${params.id}`,
1403
1389
  options
1404
1390
  );
1405
1391
  },
1406
1392
  async getProduct(params, options) {
1407
- const target_business_id = params.business_id || apiConfig.businessId;
1393
+ const target_store_id = params.store_id || apiConfig.storeId;
1408
1394
  let identifier;
1409
1395
  if (params.id) {
1410
1396
  identifier = params.id;
1411
1397
  } else if (params.slug) {
1412
- identifier = `${target_business_id}:${apiConfig.locale}:${params.slug}`;
1398
+ identifier = `${target_store_id}:${apiConfig.locale}:${params.slug}`;
1413
1399
  } else {
1414
1400
  throw new Error("GetProductParams requires id or slug");
1415
1401
  }
1416
1402
  return apiConfig.httpClient.get(
1417
- `/v1/businesses/${target_business_id}/products/${identifier}`,
1403
+ `/v1/stores/${target_store_id}/products/${identifier}`,
1418
1404
  options
1419
1405
  );
1420
1406
  },
1421
1407
  async getProducts(params, options) {
1422
- const { business_id, ...queryParams } = params;
1423
- const target_business_id = business_id || apiConfig.businessId;
1408
+ const { store_id, ...queryParams } = params;
1409
+ const target_store_id = store_id || apiConfig.storeId;
1424
1410
  return apiConfig.httpClient.get(
1425
- `/v1/businesses/${encodeURIComponent(target_business_id)}/products`,
1411
+ `/v1/stores/${encodeURIComponent(target_store_id)}/products`,
1426
1412
  {
1427
1413
  ...options,
1428
1414
  params: queryParams
@@ -1430,35 +1416,35 @@ var createEshopApi = (apiConfig) => {
1430
1416
  );
1431
1417
  },
1432
1418
  async createOrder(params, options) {
1433
- const { business_id, ...payload } = params;
1434
- const target_business_id = business_id || apiConfig.businessId;
1419
+ const { store_id, ...payload } = params;
1420
+ const target_store_id = store_id || apiConfig.storeId;
1435
1421
  return apiConfig.httpClient.post(
1436
- `/v1/businesses/${target_business_id}/orders`,
1422
+ `/v1/stores/${target_store_id}/orders`,
1437
1423
  payload,
1438
1424
  options
1439
1425
  );
1440
1426
  },
1441
1427
  async updateOrder(params, options) {
1442
- const { business_id, ...payload } = params;
1443
- const target_business_id = business_id || apiConfig.businessId;
1428
+ const { store_id, ...payload } = params;
1429
+ const target_store_id = store_id || apiConfig.storeId;
1444
1430
  return apiConfig.httpClient.put(
1445
- `/v1/businesses/${target_business_id}/orders/${params.id}`,
1431
+ `/v1/stores/${target_store_id}/orders/${params.id}`,
1446
1432
  payload,
1447
1433
  options
1448
1434
  );
1449
1435
  },
1450
1436
  async getOrder(params, options) {
1451
- const target_business_id = params.business_id || apiConfig.businessId;
1437
+ const target_store_id = params.store_id || apiConfig.storeId;
1452
1438
  return apiConfig.httpClient.get(
1453
- `/v1/businesses/${target_business_id}/orders/${params.id}`,
1439
+ `/v1/stores/${target_store_id}/orders/${params.id}`,
1454
1440
  options
1455
1441
  );
1456
1442
  },
1457
1443
  async getOrders(params, options) {
1458
- const { business_id, ...queryParams } = params;
1459
- const target_business_id = business_id || apiConfig.businessId;
1444
+ const { store_id, ...queryParams } = params;
1445
+ const target_store_id = store_id || apiConfig.storeId;
1460
1446
  return apiConfig.httpClient.get(
1461
- `/v1/businesses/${target_business_id}/orders`,
1447
+ `/v1/stores/${target_store_id}/orders`,
1462
1448
  {
1463
1449
  ...options,
1464
1450
  params: queryParams
@@ -1477,14 +1463,14 @@ var createEshopApi = (apiConfig) => {
1477
1463
  street2: null
1478
1464
  } : void 0;
1479
1465
  return apiConfig.httpClient.post(
1480
- `/v1/businesses/${apiConfig.businessId}/orders/quote`,
1466
+ `/v1/stores/${apiConfig.storeId}/orders/quote`,
1481
1467
  { ...rest, shipping_address, market: apiConfig.market },
1482
1468
  options
1483
1469
  );
1484
1470
  },
1485
1471
  async processRefund(params, options) {
1486
1472
  return apiConfig.httpClient.post(
1487
- `/v1/businesses/${apiConfig.businessId}/orders/${params.id}/refund`,
1473
+ `/v1/stores/${apiConfig.storeId}/orders/${params.id}/refund`,
1488
1474
  { amount: params.amount },
1489
1475
  options
1490
1476
  );
@@ -1509,34 +1495,34 @@ var createBookingApi = (apiConfig) => {
1509
1495
  cart = [];
1510
1496
  },
1511
1497
  async createBooking(params, options) {
1512
- const { business_id, ...payload } = params;
1513
- const target_business_id = business_id || apiConfig.businessId;
1498
+ const { store_id, ...payload } = params;
1499
+ const target_store_id = store_id || apiConfig.storeId;
1514
1500
  return apiConfig.httpClient.post(
1515
- `/v1/businesses/${target_business_id}/bookings`,
1516
- { market: "booking", ...payload },
1501
+ `/v1/stores/${target_store_id}/bookings`,
1502
+ { market: apiConfig.market, ...payload },
1517
1503
  options
1518
1504
  );
1519
1505
  },
1520
1506
  async updateBooking(params, options) {
1521
1507
  const { id, ...payload } = params;
1522
1508
  return apiConfig.httpClient.put(
1523
- `/v1/businesses/${apiConfig.businessId}/bookings/${id}`,
1509
+ `/v1/stores/${apiConfig.storeId}/bookings/${id}`,
1524
1510
  payload,
1525
1511
  options
1526
1512
  );
1527
1513
  },
1528
1514
  async getBooking(params, options) {
1529
- const target_business_id = params.business_id || apiConfig.businessId;
1515
+ const target_store_id = params.store_id || apiConfig.storeId;
1530
1516
  return apiConfig.httpClient.get(
1531
- `/v1/businesses/${target_business_id}/bookings/${params.id}`,
1517
+ `/v1/stores/${target_store_id}/bookings/${params.id}`,
1532
1518
  options
1533
1519
  );
1534
1520
  },
1535
1521
  async searchBookings(params, options) {
1536
- const { business_id, ...queryParams } = params;
1537
- const target_business_id = business_id || apiConfig.businessId;
1522
+ const { store_id, ...queryParams } = params;
1523
+ const target_store_id = store_id || apiConfig.storeId;
1538
1524
  return apiConfig.httpClient.get(
1539
- `/v1/businesses/${target_business_id}/bookings`,
1525
+ `/v1/stores/${target_store_id}/bookings`,
1540
1526
  {
1541
1527
  ...options,
1542
1528
  params: queryParams
@@ -1544,74 +1530,74 @@ var createBookingApi = (apiConfig) => {
1544
1530
  );
1545
1531
  },
1546
1532
  async getQuote(params, options) {
1547
- const { business_id, ...payload } = params;
1548
- const target_business_id = business_id || apiConfig.businessId;
1533
+ const { store_id, ...payload } = params;
1534
+ const target_store_id = store_id || apiConfig.storeId;
1549
1535
  return apiConfig.httpClient.post(
1550
- `/v1/businesses/${target_business_id}/bookings/quote`,
1551
- { market: "booking", ...payload },
1536
+ `/v1/stores/${target_store_id}/bookings/quote`,
1537
+ { market: apiConfig.market, ...payload },
1552
1538
  options
1553
1539
  );
1554
1540
  },
1555
1541
  async processRefund(params, options) {
1556
1542
  return apiConfig.httpClient.post(
1557
- `/v1/businesses/${apiConfig.businessId}/bookings/${params.id}/refund`,
1543
+ `/v1/stores/${apiConfig.storeId}/bookings/${params.id}/refund`,
1558
1544
  { amount: params.amount },
1559
1545
  options
1560
1546
  );
1561
1547
  },
1562
1548
  async getAvailability(params, options) {
1563
- const { business_id, ...query } = params;
1564
- const target_business_id = business_id || apiConfig.businessId;
1549
+ const { store_id, ...query } = params;
1550
+ const target_store_id = store_id || apiConfig.storeId;
1565
1551
  return apiConfig.httpClient.get(
1566
- `/v1/businesses/${target_business_id}/bookings/availability`,
1552
+ `/v1/stores/${target_store_id}/bookings/availability`,
1567
1553
  { ...options, params: query }
1568
1554
  );
1569
1555
  },
1570
1556
  async createService(params, options) {
1571
- const { business_id, ...payload } = params;
1572
- const target_business_id = business_id || apiConfig.businessId;
1557
+ const { store_id, ...payload } = params;
1558
+ const target_store_id = store_id || apiConfig.storeId;
1573
1559
  return apiConfig.httpClient.post(
1574
- `/v1/businesses/${target_business_id}/services`,
1560
+ `/v1/stores/${target_store_id}/services`,
1575
1561
  payload,
1576
1562
  options
1577
1563
  );
1578
1564
  },
1579
1565
  async updateService(params, options) {
1580
- const { business_id, ...payload } = params;
1581
- const target_business_id = business_id || apiConfig.businessId;
1566
+ const { store_id, ...payload } = params;
1567
+ const target_store_id = store_id || apiConfig.storeId;
1582
1568
  return apiConfig.httpClient.put(
1583
- `/v1/businesses/${target_business_id}/services/${params.id}`,
1569
+ `/v1/stores/${target_store_id}/services/${params.id}`,
1584
1570
  payload,
1585
1571
  options
1586
1572
  );
1587
1573
  },
1588
1574
  async deleteService(params, options) {
1589
- const target_business_id = params.business_id || apiConfig.businessId;
1575
+ const target_store_id = params.store_id || apiConfig.storeId;
1590
1576
  return apiConfig.httpClient.delete(
1591
- `/v1/businesses/${target_business_id}/services/${params.id}`,
1577
+ `/v1/stores/${target_store_id}/services/${params.id}`,
1592
1578
  options
1593
1579
  );
1594
1580
  },
1595
1581
  async getService(params, options) {
1596
- const business_id = params.business_id || apiConfig.businessId;
1582
+ const store_id = params.store_id || apiConfig.storeId;
1597
1583
  let identifier;
1598
1584
  if (params.id) {
1599
1585
  identifier = params.id;
1600
1586
  } else if (params.slug) {
1601
- identifier = `${business_id}:${apiConfig.locale}:${params.slug}`;
1587
+ identifier = `${store_id}:${apiConfig.locale}:${params.slug}`;
1602
1588
  } else {
1603
1589
  throw new Error("GetServiceParams requires id or slug");
1604
1590
  }
1605
1591
  return apiConfig.httpClient.get(
1606
- `/v1/businesses/${business_id}/services/${identifier}`,
1592
+ `/v1/stores/${store_id}/services/${identifier}`,
1607
1593
  options
1608
1594
  );
1609
1595
  },
1610
1596
  async getServices(params, options) {
1611
- const { business_id, ...queryParams } = params;
1612
- const target_business_id = business_id || apiConfig.businessId;
1597
+ const { store_id, ...queryParams } = params;
1598
+ const target_store_id = store_id || apiConfig.storeId;
1613
1599
  return apiConfig.httpClient.get(
1614
- `/v1/businesses/${target_business_id}/services`,
1600
+ `/v1/stores/${target_store_id}/services`,
1615
1601
  {
1616
1602
  ...options,
1617
1603
  params: queryParams
@@ -1619,50 +1605,50 @@ var createBookingApi = (apiConfig) => {
1619
1605
  );
1620
1606
  },
1621
1607
  async createProvider(params, options) {
1622
- const { business_id, ...payload } = params;
1623
- const target_business_id = business_id || apiConfig.businessId;
1608
+ const { store_id, ...payload } = params;
1609
+ const target_store_id = store_id || apiConfig.storeId;
1624
1610
  return apiConfig.httpClient.post(
1625
- `/v1/businesses/${target_business_id}/providers`,
1611
+ `/v1/stores/${target_store_id}/providers`,
1626
1612
  payload,
1627
1613
  options
1628
1614
  );
1629
1615
  },
1630
1616
  async updateProvider(params, options) {
1631
- const { business_id, ...payload } = params;
1632
- const target_business_id = business_id || apiConfig.businessId;
1617
+ const { store_id, ...payload } = params;
1618
+ const target_store_id = store_id || apiConfig.storeId;
1633
1619
  return apiConfig.httpClient.put(
1634
- `/v1/businesses/${target_business_id}/providers/${params.id}`,
1620
+ `/v1/stores/${target_store_id}/providers/${params.id}`,
1635
1621
  payload,
1636
1622
  options
1637
1623
  );
1638
1624
  },
1639
1625
  async deleteProvider(params, options) {
1640
- const target_business_id = params.business_id || apiConfig.businessId;
1626
+ const target_store_id = params.store_id || apiConfig.storeId;
1641
1627
  return apiConfig.httpClient.delete(
1642
- `/v1/businesses/${target_business_id}/providers/${params.id}`,
1628
+ `/v1/stores/${target_store_id}/providers/${params.id}`,
1643
1629
  options
1644
1630
  );
1645
1631
  },
1646
1632
  async getProvider(params, options) {
1647
- const business_id = params.business_id || apiConfig.businessId;
1633
+ const store_id = params.store_id || apiConfig.storeId;
1648
1634
  let identifier;
1649
1635
  if (params.id) {
1650
1636
  identifier = params.id;
1651
1637
  } else if (params.slug) {
1652
- identifier = `${business_id}:${apiConfig.locale}:${params.slug}`;
1638
+ identifier = `${store_id}:${apiConfig.locale}:${params.slug}`;
1653
1639
  } else {
1654
1640
  throw new Error("GetProviderParams requires id or slug");
1655
1641
  }
1656
1642
  return apiConfig.httpClient.get(
1657
- `/v1/businesses/${business_id}/providers/${identifier}`,
1643
+ `/v1/stores/${store_id}/providers/${identifier}`,
1658
1644
  options
1659
1645
  );
1660
1646
  },
1661
1647
  async getProviders(params, options) {
1662
- const { business_id, ...queryParams } = params;
1663
- const target_business_id = business_id || apiConfig.businessId;
1648
+ const { store_id, ...queryParams } = params;
1649
+ const target_store_id = store_id || apiConfig.storeId;
1664
1650
  return apiConfig.httpClient.get(
1665
- `/v1/businesses/${target_business_id}/providers`,
1651
+ `/v1/stores/${target_store_id}/providers`,
1666
1652
  {
1667
1653
  ...options,
1668
1654
  params: queryParams
@@ -1670,44 +1656,44 @@ var createBookingApi = (apiConfig) => {
1670
1656
  );
1671
1657
  },
1672
1658
  async cancelBookingItem(params, options) {
1673
- const { business_id, booking_id, item_id, ...payload } = params;
1674
- const target_business_id = business_id || apiConfig.businessId;
1659
+ const { store_id, booking_id, item_id, ...payload } = params;
1660
+ const target_store_id = store_id || apiConfig.storeId;
1675
1661
  return apiConfig.httpClient.post(
1676
- `/v1/businesses/${target_business_id}/bookings/${booking_id}/items/${item_id}/cancel`,
1662
+ `/v1/stores/${target_store_id}/bookings/${booking_id}/items/${item_id}/cancel`,
1677
1663
  payload,
1678
1664
  options
1679
1665
  );
1680
1666
  },
1681
1667
  async findServiceProviders(params, options) {
1682
- const { business_id, ...queryParams } = params;
1683
- const target_business_id = business_id || apiConfig.businessId;
1668
+ const { store_id, ...queryParams } = params;
1669
+ const target_store_id = store_id || apiConfig.storeId;
1684
1670
  return apiConfig.httpClient.get(
1685
- `/v1/businesses/${target_business_id}/service-providers`,
1671
+ `/v1/stores/${target_store_id}/service-providers`,
1686
1672
  { ...options, params: queryParams }
1687
1673
  );
1688
1674
  },
1689
1675
  async createServiceProvider(params, options) {
1690
- const { business_id, ...payload } = params;
1691
- const target_business_id = business_id || apiConfig.businessId;
1676
+ const { store_id, ...payload } = params;
1677
+ const target_store_id = store_id || apiConfig.storeId;
1692
1678
  return apiConfig.httpClient.post(
1693
- `/v1/businesses/${target_business_id}/service-providers`,
1679
+ `/v1/stores/${target_store_id}/service-providers`,
1694
1680
  payload,
1695
1681
  options
1696
1682
  );
1697
1683
  },
1698
1684
  async updateServiceProvider(params, options) {
1699
- const { business_id, id, ...payload } = params;
1700
- const target_business_id = business_id || apiConfig.businessId;
1685
+ const { store_id, id, ...payload } = params;
1686
+ const target_store_id = store_id || apiConfig.storeId;
1701
1687
  return apiConfig.httpClient.put(
1702
- `/v1/businesses/${target_business_id}/service-providers/${id}`,
1688
+ `/v1/stores/${target_store_id}/service-providers/${id}`,
1703
1689
  payload,
1704
1690
  options
1705
1691
  );
1706
1692
  },
1707
1693
  async deleteServiceProvider(params, options) {
1708
- const target_business_id = params.business_id || apiConfig.businessId;
1694
+ const target_store_id = params.store_id || apiConfig.storeId;
1709
1695
  return apiConfig.httpClient.delete(
1710
- `/v1/businesses/${target_business_id}/service-providers/${params.id}`,
1696
+ `/v1/stores/${target_store_id}/service-providers/${params.id}`,
1711
1697
  options
1712
1698
  );
1713
1699
  }
@@ -1728,33 +1714,33 @@ var createLocationApi = (apiConfig) => {
1728
1714
  },
1729
1715
  async list(options) {
1730
1716
  return apiConfig.httpClient.get(
1731
- `/v1/businesses/${apiConfig.businessId}/locations`,
1717
+ `/v1/stores/${apiConfig.storeId}/locations`,
1732
1718
  options
1733
1719
  );
1734
1720
  },
1735
1721
  async get(id, options) {
1736
1722
  return apiConfig.httpClient.get(
1737
- `/v1/businesses/${apiConfig.businessId}/locations/${id}`,
1723
+ `/v1/stores/${apiConfig.storeId}/locations/${id}`,
1738
1724
  options
1739
1725
  );
1740
1726
  },
1741
1727
  async create(params, options) {
1742
1728
  return apiConfig.httpClient.post(
1743
- `/v1/businesses/${apiConfig.businessId}/locations`,
1744
- { ...params, business_id: apiConfig.businessId },
1729
+ `/v1/stores/${apiConfig.storeId}/locations`,
1730
+ { ...params, store_id: apiConfig.storeId },
1745
1731
  options
1746
1732
  );
1747
1733
  },
1748
1734
  async update(params, options) {
1749
1735
  return apiConfig.httpClient.put(
1750
- `/v1/businesses/${apiConfig.businessId}/locations/${params.id}`,
1751
- { ...params, business_id: apiConfig.businessId },
1736
+ `/v1/stores/${apiConfig.storeId}/locations/${params.id}`,
1737
+ { ...params, store_id: apiConfig.storeId },
1752
1738
  options
1753
1739
  );
1754
1740
  },
1755
1741
  async delete(params, options) {
1756
1742
  return apiConfig.httpClient.delete(
1757
- `/v1/businesses/${apiConfig.businessId}/locations/${params.id}`,
1743
+ `/v1/stores/${apiConfig.storeId}/locations/${params.id}`,
1758
1744
  options
1759
1745
  );
1760
1746
  }
@@ -1766,33 +1752,33 @@ var createMarketApi = (apiConfig) => {
1766
1752
  return {
1767
1753
  async list(options) {
1768
1754
  return apiConfig.httpClient.get(
1769
- `/v1/businesses/${apiConfig.businessId}/markets`,
1755
+ `/v1/stores/${apiConfig.storeId}/markets`,
1770
1756
  options
1771
1757
  );
1772
1758
  },
1773
1759
  async get(id, options) {
1774
1760
  return apiConfig.httpClient.get(
1775
- `/v1/businesses/${apiConfig.businessId}/markets/${id}`,
1761
+ `/v1/stores/${apiConfig.storeId}/markets/${id}`,
1776
1762
  options
1777
1763
  );
1778
1764
  },
1779
1765
  async create(params, options) {
1780
1766
  return apiConfig.httpClient.post(
1781
- `/v1/businesses/${apiConfig.businessId}/markets`,
1782
- { ...params, business_id: apiConfig.businessId },
1767
+ `/v1/stores/${apiConfig.storeId}/markets`,
1768
+ { ...params, store_id: apiConfig.storeId },
1783
1769
  options
1784
1770
  );
1785
1771
  },
1786
1772
  async update(params, options) {
1787
1773
  return apiConfig.httpClient.put(
1788
- `/v1/businesses/${apiConfig.businessId}/markets/${params.id}`,
1789
- { ...params, business_id: apiConfig.businessId },
1774
+ `/v1/stores/${apiConfig.storeId}/markets/${params.id}`,
1775
+ { ...params, store_id: apiConfig.storeId },
1790
1776
  options
1791
1777
  );
1792
1778
  },
1793
1779
  async delete(params, options) {
1794
1780
  return apiConfig.httpClient.delete(
1795
- `/v1/businesses/${apiConfig.businessId}/markets/${params.id}`,
1781
+ `/v1/stores/${apiConfig.storeId}/markets/${params.id}`,
1796
1782
  options
1797
1783
  );
1798
1784
  }
@@ -1802,12 +1788,12 @@ var createMarketApi = (apiConfig) => {
1802
1788
  // src/api/crm.ts
1803
1789
  var createActivityAdminApi = (apiConfig) => ({
1804
1790
  async timeline(params, options) {
1805
- const business_id = params.business_id || apiConfig.businessId;
1791
+ const store_id = params.store_id || apiConfig.storeId;
1806
1792
  const queryParams = { customer_id: params.customer_id };
1807
1793
  if (params.limit !== void 0) queryParams.limit = params.limit;
1808
1794
  if (params.cursor) queryParams.cursor = params.cursor;
1809
1795
  return apiConfig.httpClient.get(
1810
- `/v1/businesses/${business_id}/activities/timeline`,
1796
+ `/v1/stores/${store_id}/activities/timeline`,
1811
1797
  { ...options, params: queryParams }
1812
1798
  );
1813
1799
  }
@@ -1815,21 +1801,21 @@ var createActivityAdminApi = (apiConfig) => ({
1815
1801
  var createCustomerApi = (apiConfig) => {
1816
1802
  return {
1817
1803
  async create(params, options) {
1818
- const { business_id, ...payload } = params;
1804
+ const { store_id, ...payload } = params;
1819
1805
  return apiConfig.httpClient.post(
1820
- `/v1/businesses/${business_id || apiConfig.businessId}/customers`,
1806
+ `/v1/stores/${store_id || apiConfig.storeId}/customers`,
1821
1807
  payload,
1822
1808
  options
1823
1809
  );
1824
1810
  },
1825
1811
  async get(params, options) {
1826
1812
  return apiConfig.httpClient.get(
1827
- `/v1/businesses/${params.business_id || apiConfig.businessId}/customers/${params.id}`,
1813
+ `/v1/stores/${params.store_id || apiConfig.storeId}/customers/${params.id}`,
1828
1814
  options
1829
1815
  );
1830
1816
  },
1831
1817
  async find(params, options) {
1832
- const business_id = params?.business_id || apiConfig.businessId;
1818
+ const store_id = params?.store_id || apiConfig.storeId;
1833
1819
  const queryParams = {};
1834
1820
  if (params?.limit !== void 0) queryParams.limit = params.limit;
1835
1821
  if (params?.cursor) queryParams.cursor = params.cursor;
@@ -1837,7 +1823,7 @@ var createCustomerApi = (apiConfig) => {
1837
1823
  if (params?.sort_field) queryParams.sort_field = params.sort_field;
1838
1824
  if (params?.sort_direction) queryParams.sort_direction = params.sort_direction;
1839
1825
  return apiConfig.httpClient.get(
1840
- `/v1/businesses/${business_id}/customers`,
1826
+ `/v1/stores/${store_id}/customers`,
1841
1827
  {
1842
1828
  ...options,
1843
1829
  params: queryParams
@@ -1845,46 +1831,46 @@ var createCustomerApi = (apiConfig) => {
1845
1831
  );
1846
1832
  },
1847
1833
  async update(params, options) {
1848
- const { id, business_id, ...body } = params;
1834
+ const { id, store_id, ...body } = params;
1849
1835
  return apiConfig.httpClient.put(
1850
- `/v1/businesses/${business_id || apiConfig.businessId}/customers/${id}`,
1836
+ `/v1/stores/${store_id || apiConfig.storeId}/customers/${id}`,
1851
1837
  body,
1852
1838
  options
1853
1839
  );
1854
1840
  },
1855
1841
  async merge(params, options) {
1856
- const business_id = params.business_id || apiConfig.businessId;
1842
+ const store_id = params.store_id || apiConfig.storeId;
1857
1843
  return apiConfig.httpClient.post(
1858
- `/v1/businesses/${business_id}/customers/${params.target_id}/merge`,
1859
- { source_id: params.source_id, business_id },
1844
+ `/v1/stores/${store_id}/customers/${params.target_id}/merge`,
1845
+ { source_id: params.source_id, store_id },
1860
1846
  options
1861
1847
  );
1862
1848
  },
1863
1849
  async revokeToken(params, options) {
1864
- const business_id = params.business_id || apiConfig.businessId;
1850
+ const store_id = params.store_id || apiConfig.storeId;
1865
1851
  return apiConfig.httpClient.delete(
1866
- `/v1/businesses/${business_id}/customers/${params.id}/sessions/${params.token_id}`,
1852
+ `/v1/stores/${store_id}/customers/${params.id}/sessions/${params.token_id}`,
1867
1853
  options
1868
1854
  );
1869
1855
  },
1870
1856
  async revokeAllTokens(params, options) {
1871
- const business_id = params.business_id || apiConfig.businessId;
1857
+ const store_id = params.store_id || apiConfig.storeId;
1872
1858
  return apiConfig.httpClient.delete(
1873
- `/v1/businesses/${business_id}/customers/${params.id}/sessions`,
1859
+ `/v1/stores/${store_id}/customers/${params.id}/sessions`,
1874
1860
  options
1875
1861
  );
1876
1862
  },
1877
1863
  audiences: {
1878
1864
  async create(params, options) {
1879
1865
  return apiConfig.httpClient.post(
1880
- `/v1/businesses/${apiConfig.businessId}/audiences`,
1866
+ `/v1/stores/${apiConfig.storeId}/audiences`,
1881
1867
  params,
1882
1868
  options
1883
1869
  );
1884
1870
  },
1885
1871
  async update(params, options) {
1886
1872
  return apiConfig.httpClient.put(
1887
- `/v1/businesses/${apiConfig.businessId}/audiences/${params.id}`,
1873
+ `/v1/stores/${apiConfig.storeId}/audiences/${params.id}`,
1888
1874
  params,
1889
1875
  options
1890
1876
  );
@@ -1894,24 +1880,24 @@ var createCustomerApi = (apiConfig) => {
1894
1880
  if (params.id) {
1895
1881
  identifier = params.id;
1896
1882
  } else if (params.key) {
1897
- identifier = `${apiConfig.businessId}:${params.key}`;
1883
+ identifier = `${apiConfig.storeId}:${params.key}`;
1898
1884
  } else {
1899
1885
  throw new Error("GetAudienceParams requires id or key");
1900
1886
  }
1901
1887
  return apiConfig.httpClient.get(
1902
- `/v1/businesses/${apiConfig.businessId}/audiences/${identifier}`,
1888
+ `/v1/stores/${apiConfig.storeId}/audiences/${identifier}`,
1903
1889
  options
1904
1890
  );
1905
1891
  },
1906
1892
  async find(params, options) {
1907
1893
  return apiConfig.httpClient.get(
1908
- `/v1/businesses/${apiConfig.businessId}/audiences`,
1894
+ `/v1/stores/${apiConfig.storeId}/audiences`,
1909
1895
  { ...options, params }
1910
1896
  );
1911
1897
  },
1912
1898
  async getSubscribers(params, options) {
1913
1899
  return apiConfig.httpClient.get(
1914
- `/v1/businesses/${apiConfig.businessId}/audiences/${params.id}/subscribers`,
1900
+ `/v1/stores/${apiConfig.storeId}/audiences/${params.id}/subscribers`,
1915
1901
  {
1916
1902
  ...options,
1917
1903
  params: { limit: params.limit, cursor: params.cursor }
@@ -1920,14 +1906,14 @@ var createCustomerApi = (apiConfig) => {
1920
1906
  },
1921
1907
  async addSubscriber(params, options) {
1922
1908
  return apiConfig.httpClient.post(
1923
- `/v1/businesses/${apiConfig.businessId}/audiences/${params.id}/subscribers`,
1909
+ `/v1/stores/${apiConfig.storeId}/audiences/${params.id}/subscribers`,
1924
1910
  { customer_id: params.customer_id },
1925
1911
  options
1926
1912
  );
1927
1913
  },
1928
1914
  async removeSubscriber(params, options) {
1929
1915
  return apiConfig.httpClient.delete(
1930
- `/v1/businesses/${apiConfig.businessId}/audiences/${params.id}/subscribers/${params.customer_id}`,
1916
+ `/v1/stores/${apiConfig.storeId}/audiences/${params.id}/subscribers/${params.customer_id}`,
1931
1917
  options
1932
1918
  );
1933
1919
  }
@@ -1940,41 +1926,41 @@ var createCustomerApi = (apiConfig) => {
1940
1926
  var createWorkflowApi = (apiConfig) => {
1941
1927
  return {
1942
1928
  async createWorkflow(params, options) {
1943
- const { business_id, ...payload } = params;
1944
- const target_business_id = business_id || apiConfig.businessId;
1929
+ const { store_id, ...payload } = params;
1930
+ const target_store_id = store_id || apiConfig.storeId;
1945
1931
  return apiConfig.httpClient.post(
1946
- `/v1/businesses/${target_business_id}/workflows`,
1947
- { ...payload, business_id: target_business_id },
1932
+ `/v1/stores/${target_store_id}/workflows`,
1933
+ { ...payload, store_id: target_store_id },
1948
1934
  options
1949
1935
  );
1950
1936
  },
1951
1937
  async updateWorkflow(params, options) {
1952
- const { business_id, id, ...payload } = params;
1953
- const target_business_id = business_id || apiConfig.businessId;
1938
+ const { store_id, id, ...payload } = params;
1939
+ const target_store_id = store_id || apiConfig.storeId;
1954
1940
  return apiConfig.httpClient.put(
1955
- `/v1/businesses/${target_business_id}/workflows/${id}`,
1941
+ `/v1/stores/${target_store_id}/workflows/${id}`,
1956
1942
  payload,
1957
1943
  options
1958
1944
  );
1959
1945
  },
1960
1946
  async deleteWorkflow(params, options) {
1961
- const business_id = params.business_id || apiConfig.businessId;
1947
+ const store_id = params.store_id || apiConfig.storeId;
1962
1948
  return apiConfig.httpClient.delete(
1963
- `/v1/businesses/${business_id}/workflows/${params.id}`,
1949
+ `/v1/stores/${store_id}/workflows/${params.id}`,
1964
1950
  options
1965
1951
  );
1966
1952
  },
1967
1953
  async getWorkflow(params, options) {
1968
- const business_id = params.business_id || apiConfig.businessId;
1954
+ const store_id = params.store_id || apiConfig.storeId;
1969
1955
  return apiConfig.httpClient.get(
1970
- `/v1/businesses/${business_id}/workflows/${params.id}`,
1956
+ `/v1/stores/${store_id}/workflows/${params.id}`,
1971
1957
  options
1972
1958
  );
1973
1959
  },
1974
1960
  async getWorkflows(params, options) {
1975
- const business_id = params?.business_id || apiConfig.businessId;
1976
- const { business_id: _, ...queryParams } = params || {};
1977
- return apiConfig.httpClient.get(`/v1/businesses/${business_id}/workflows`, {
1961
+ const store_id = params?.store_id || apiConfig.storeId;
1962
+ const { store_id: _, ...queryParams } = params || {};
1963
+ return apiConfig.httpClient.get(`/v1/stores/${store_id}/workflows`, {
1978
1964
  ...options,
1979
1965
  params: Object.keys(queryParams).length > 0 ? queryParams : void 0
1980
1966
  });
@@ -1984,10 +1970,10 @@ var createWorkflowApi = (apiConfig) => {
1984
1970
  return apiConfig.httpClient.post(`/v1/workflows/trigger/${secret}`, payload, options);
1985
1971
  },
1986
1972
  async getWorkflowExecutions(params, options) {
1987
- const business_id = params.business_id || apiConfig.businessId;
1988
- const { business_id: _, workflow_id, ...queryParams } = params;
1973
+ const store_id = params.store_id || apiConfig.storeId;
1974
+ const { store_id: _, workflow_id, ...queryParams } = params;
1989
1975
  return apiConfig.httpClient.get(
1990
- `/v1/businesses/${business_id}/workflows/${workflow_id}/executions`,
1976
+ `/v1/stores/${store_id}/workflows/${workflow_id}/executions`,
1991
1977
  {
1992
1978
  ...options,
1993
1979
  params: Object.keys(queryParams).length > 0 ? queryParams : void 0
@@ -1995,9 +1981,9 @@ var createWorkflowApi = (apiConfig) => {
1995
1981
  );
1996
1982
  },
1997
1983
  async getWorkflowExecution(params, options) {
1998
- const business_id = params.business_id || apiConfig.businessId;
1984
+ const store_id = params.store_id || apiConfig.storeId;
1999
1985
  return apiConfig.httpClient.get(
2000
- `/v1/businesses/${business_id}/workflows/${params.workflow_id}/executions/${params.execution_id}`,
1986
+ `/v1/stores/${store_id}/workflows/${params.workflow_id}/executions/${params.execution_id}`,
2001
1987
  options
2002
1988
  );
2003
1989
  }
@@ -2025,7 +2011,7 @@ var createShippingApi = (apiConfig) => {
2025
2011
  async getRates(params, options) {
2026
2012
  const { order_id, ...payload } = params;
2027
2013
  return apiConfig.httpClient.post(
2028
- `/v1/businesses/${apiConfig.businessId}/orders/${order_id}/shipping/rates`,
2014
+ `/v1/stores/${apiConfig.storeId}/orders/${order_id}/shipping/rates`,
2029
2015
  payload,
2030
2016
  options
2031
2017
  );
@@ -2033,7 +2019,7 @@ var createShippingApi = (apiConfig) => {
2033
2019
  async ship(params, options) {
2034
2020
  const { order_id, ...payload } = params;
2035
2021
  return apiConfig.httpClient.post(
2036
- `/v1/businesses/${apiConfig.businessId}/orders/${order_id}/ship`,
2022
+ `/v1/stores/${apiConfig.storeId}/orders/${order_id}/ship`,
2037
2023
  payload,
2038
2024
  options
2039
2025
  );
@@ -2045,63 +2031,63 @@ var createShippingApi = (apiConfig) => {
2045
2031
  var createAgentApi = (apiConfig) => {
2046
2032
  return {
2047
2033
  async createAgent(params, options) {
2048
- const { business_id, ...payload } = params;
2049
- const target_business_id = business_id || apiConfig.businessId;
2034
+ const { store_id, ...payload } = params;
2035
+ const target_store_id = store_id || apiConfig.storeId;
2050
2036
  return apiConfig.httpClient.post(
2051
- `/v1/businesses/${target_business_id}/agents`,
2052
- { ...payload, business_id: target_business_id },
2037
+ `/v1/stores/${target_store_id}/agents`,
2038
+ { ...payload, store_id: target_store_id },
2053
2039
  options
2054
2040
  );
2055
2041
  },
2056
2042
  async updateAgent(params, options) {
2057
- const { business_id, id, ...payload } = params;
2058
- const target_business_id = business_id || apiConfig.businessId;
2043
+ const { store_id, id, ...payload } = params;
2044
+ const target_store_id = store_id || apiConfig.storeId;
2059
2045
  return apiConfig.httpClient.put(
2060
- `/v1/businesses/${target_business_id}/agents/${id}`,
2046
+ `/v1/stores/${target_store_id}/agents/${id}`,
2061
2047
  payload,
2062
2048
  options
2063
2049
  );
2064
2050
  },
2065
2051
  async deleteAgent(params, options) {
2066
- const business_id = params.business_id || apiConfig.businessId;
2052
+ const store_id = params.store_id || apiConfig.storeId;
2067
2053
  return apiConfig.httpClient.delete(
2068
- `/v1/businesses/${business_id}/agents/${params.id}`,
2054
+ `/v1/stores/${store_id}/agents/${params.id}`,
2069
2055
  options
2070
2056
  );
2071
2057
  },
2072
2058
  async getAgent(params, options) {
2073
- const business_id = params.business_id || apiConfig.businessId;
2059
+ const store_id = params.store_id || apiConfig.storeId;
2074
2060
  return apiConfig.httpClient.get(
2075
- `/v1/businesses/${business_id}/agents/${params.id}`,
2061
+ `/v1/stores/${store_id}/agents/${params.id}`,
2076
2062
  options
2077
2063
  );
2078
2064
  },
2079
2065
  async getAgents(params, options) {
2080
- const business_id = params?.business_id || apiConfig.businessId;
2081
- const { business_id: _, ...queryParams } = params || {};
2082
- return apiConfig.httpClient.get(`/v1/businesses/${business_id}/agents`, {
2066
+ const store_id = params?.store_id || apiConfig.storeId;
2067
+ const { store_id: _, ...queryParams } = params || {};
2068
+ return apiConfig.httpClient.get(`/v1/stores/${store_id}/agents`, {
2083
2069
  ...options,
2084
2070
  params: Object.keys(queryParams).length > 0 ? queryParams : void 0
2085
2071
  });
2086
2072
  },
2087
2073
  async sendMessage(params, options) {
2088
- const business_id = params.business_id || apiConfig.businessId;
2074
+ const store_id = params.store_id || apiConfig.storeId;
2089
2075
  const body = { message: params.message };
2090
2076
  if (params.chat_id) body.chat_id = params.chat_id;
2091
2077
  if (params.direct) body.direct = params.direct;
2092
2078
  return apiConfig.httpClient.post(
2093
- `/v1/businesses/${business_id}/agents/${params.id}/chats/messages`,
2079
+ `/v1/stores/${store_id}/agents/${params.id}/chats/messages`,
2094
2080
  body,
2095
2081
  options
2096
2082
  );
2097
2083
  },
2098
2084
  async getChats(params, options) {
2099
- const business_id = params.business_id || apiConfig.businessId;
2085
+ const store_id = params.store_id || apiConfig.storeId;
2100
2086
  const queryParams = {};
2101
2087
  if (params.limit) queryParams.limit = String(params.limit);
2102
2088
  if (params.cursor) queryParams.cursor = params.cursor;
2103
2089
  return apiConfig.httpClient.get(
2104
- `/v1/businesses/${business_id}/agents/${params.id}/chats`,
2090
+ `/v1/stores/${store_id}/agents/${params.id}/chats`,
2105
2091
  {
2106
2092
  ...options,
2107
2093
  params: Object.keys(queryParams).length > 0 ? queryParams : void 0
@@ -2109,44 +2095,44 @@ var createAgentApi = (apiConfig) => {
2109
2095
  );
2110
2096
  },
2111
2097
  async getChat(params, options) {
2112
- const business_id = params.business_id || apiConfig.businessId;
2098
+ const store_id = params.store_id || apiConfig.storeId;
2113
2099
  return apiConfig.httpClient.get(
2114
- `/v1/businesses/${business_id}/agents/${params.id}/chats/${params.chat_id}`,
2100
+ `/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}`,
2115
2101
  options
2116
2102
  );
2117
2103
  },
2118
2104
  async updateChat(params, options) {
2119
- const business_id = params.business_id || apiConfig.businessId;
2105
+ const store_id = params.store_id || apiConfig.storeId;
2120
2106
  return apiConfig.httpClient.put(
2121
- `/v1/businesses/${business_id}/agents/${params.id}/chats/${params.chat_id}`,
2107
+ `/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}`,
2122
2108
  { status: params.status },
2123
2109
  options
2124
2110
  );
2125
2111
  },
2126
2112
  async rateChat(params, options) {
2127
- const business_id = params.business_id || apiConfig.businessId;
2113
+ const store_id = params.store_id || apiConfig.storeId;
2128
2114
  const body = { rating: params.rating };
2129
2115
  if (params.comment) body.comment = params.comment;
2130
2116
  return apiConfig.httpClient.post(
2131
- `/v1/businesses/${business_id}/agents/${params.id}/chats/${params.chat_id}/rate`,
2117
+ `/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}/rate`,
2132
2118
  body,
2133
2119
  options
2134
2120
  );
2135
2121
  },
2136
- async getBusinessChats(params, options) {
2137
- const business_id = params.business_id || apiConfig.businessId;
2138
- const { business_id: _, ...queryParams } = params;
2139
- return apiConfig.httpClient.get(`/v1/businesses/${business_id}/chats`, {
2122
+ async getStoreChats(params, options) {
2123
+ const store_id = params.store_id || apiConfig.storeId;
2124
+ const { store_id: _, ...queryParams } = params;
2125
+ return apiConfig.httpClient.get(`/v1/stores/${store_id}/chats`, {
2140
2126
  ...options,
2141
2127
  params: Object.keys(queryParams).length > 0 ? queryParams : void 0
2142
2128
  });
2143
2129
  },
2144
2130
  async getChatMessages(params, options) {
2145
- const business_id = params.business_id || apiConfig.businessId;
2131
+ const store_id = params.store_id || apiConfig.storeId;
2146
2132
  const queryParams = {};
2147
2133
  if (params.limit) queryParams.limit = String(params.limit);
2148
2134
  return apiConfig.httpClient.get(
2149
- `/v1/businesses/${business_id}/agents/${params.id}/chats/${params.chat_id}/messages`,
2135
+ `/v1/stores/${store_id}/agents/${params.id}/chats/${params.chat_id}/messages`,
2150
2136
  {
2151
2137
  ...options,
2152
2138
  params: Object.keys(queryParams).length > 0 ? queryParams : void 0
@@ -2160,50 +2146,50 @@ var createAgentApi = (apiConfig) => {
2160
2146
  var createEmailTemplateApi = (apiConfig) => {
2161
2147
  return {
2162
2148
  async createEmailTemplate(params, options) {
2163
- const { business_id, ...payload } = params;
2164
- const target_business_id = business_id || apiConfig.businessId;
2149
+ const { store_id, ...payload } = params;
2150
+ const target_store_id = store_id || apiConfig.storeId;
2165
2151
  return apiConfig.httpClient.post(
2166
- `/v1/businesses/${target_business_id}/email-templates`,
2152
+ `/v1/stores/${target_store_id}/email-templates`,
2167
2153
  payload,
2168
2154
  options
2169
2155
  );
2170
2156
  },
2171
2157
  async updateEmailTemplate(params, options) {
2172
- const { business_id, ...payload } = params;
2173
- const target_business_id = business_id || apiConfig.businessId;
2158
+ const { store_id, ...payload } = params;
2159
+ const target_store_id = store_id || apiConfig.storeId;
2174
2160
  return apiConfig.httpClient.put(
2175
- `/v1/businesses/${target_business_id}/email-templates/${params.id}`,
2161
+ `/v1/stores/${target_store_id}/email-templates/${params.id}`,
2176
2162
  payload,
2177
2163
  options
2178
2164
  );
2179
2165
  },
2180
2166
  async deleteEmailTemplate(params, options) {
2181
- const target_business_id = params.business_id || apiConfig.businessId;
2167
+ const target_store_id = params.store_id || apiConfig.storeId;
2182
2168
  return apiConfig.httpClient.delete(
2183
- `/v1/businesses/${target_business_id}/email-templates/${params.id}`,
2169
+ `/v1/stores/${target_store_id}/email-templates/${params.id}`,
2184
2170
  options
2185
2171
  );
2186
2172
  },
2187
2173
  async getEmailTemplate(params, options) {
2188
- const target_business_id = params.business_id || apiConfig.businessId;
2174
+ const target_store_id = params.store_id || apiConfig.storeId;
2189
2175
  let identifier;
2190
2176
  if (params.id) {
2191
2177
  identifier = params.id;
2192
2178
  } else if (params.key) {
2193
- identifier = `${target_business_id}:${params.key}`;
2179
+ identifier = `${target_store_id}:${params.key}`;
2194
2180
  } else {
2195
2181
  throw new Error("GetEmailTemplateParams requires id or key");
2196
2182
  }
2197
2183
  return apiConfig.httpClient.get(
2198
- `/v1/businesses/${target_business_id}/email-templates/${identifier}`,
2184
+ `/v1/stores/${target_store_id}/email-templates/${identifier}`,
2199
2185
  options
2200
2186
  );
2201
2187
  },
2202
2188
  async getEmailTemplates(params, options) {
2203
- const { business_id, ...queryParams } = params;
2204
- const target_business_id = business_id || apiConfig.businessId;
2189
+ const { store_id, ...queryParams } = params;
2190
+ const target_store_id = store_id || apiConfig.storeId;
2205
2191
  return apiConfig.httpClient.get(
2206
- `/v1/businesses/${target_business_id}/email-templates`,
2192
+ `/v1/stores/${target_store_id}/email-templates`,
2207
2193
  {
2208
2194
  ...options,
2209
2195
  params: queryParams
@@ -2217,50 +2203,50 @@ var createEmailTemplateApi = (apiConfig) => {
2217
2203
  var createFormApi = (apiConfig) => {
2218
2204
  return {
2219
2205
  async createForm(params, options) {
2220
- const { business_id, ...payload } = params;
2221
- const target_business_id = business_id || apiConfig.businessId;
2206
+ const { store_id, ...payload } = params;
2207
+ const target_store_id = store_id || apiConfig.storeId;
2222
2208
  return apiConfig.httpClient.post(
2223
- `/v1/businesses/${target_business_id}/forms`,
2209
+ `/v1/stores/${target_store_id}/forms`,
2224
2210
  payload,
2225
2211
  options
2226
2212
  );
2227
2213
  },
2228
2214
  async updateForm(params, options) {
2229
- const { business_id, ...payload } = params;
2230
- const target_business_id = business_id || apiConfig.businessId;
2215
+ const { store_id, ...payload } = params;
2216
+ const target_store_id = store_id || apiConfig.storeId;
2231
2217
  return apiConfig.httpClient.put(
2232
- `/v1/businesses/${target_business_id}/forms/${params.id}`,
2218
+ `/v1/stores/${target_store_id}/forms/${params.id}`,
2233
2219
  payload,
2234
2220
  options
2235
2221
  );
2236
2222
  },
2237
2223
  async deleteForm(params, options) {
2238
- const target_business_id = params.business_id || apiConfig.businessId;
2224
+ const target_store_id = params.store_id || apiConfig.storeId;
2239
2225
  return apiConfig.httpClient.delete(
2240
- `/v1/businesses/${target_business_id}/forms/${params.id}`,
2226
+ `/v1/stores/${target_store_id}/forms/${params.id}`,
2241
2227
  options
2242
2228
  );
2243
2229
  },
2244
2230
  async getForm(params, options) {
2245
- const target_business_id = params.business_id || apiConfig.businessId;
2231
+ const target_store_id = params.store_id || apiConfig.storeId;
2246
2232
  let identifier;
2247
2233
  if (params.id) {
2248
2234
  identifier = params.id;
2249
2235
  } else if (params.key) {
2250
- identifier = `${target_business_id}:${params.key}`;
2236
+ identifier = `${target_store_id}:${params.key}`;
2251
2237
  } else {
2252
2238
  throw new Error("GetFormParams requires id or key");
2253
2239
  }
2254
2240
  return apiConfig.httpClient.get(
2255
- `/v1/businesses/${target_business_id}/forms/${identifier}`,
2241
+ `/v1/stores/${target_store_id}/forms/${identifier}`,
2256
2242
  options
2257
2243
  );
2258
2244
  },
2259
2245
  async getForms(params, options) {
2260
- const { business_id, ...queryParams } = params;
2261
- const target_business_id = business_id || apiConfig.businessId;
2246
+ const { store_id, ...queryParams } = params;
2247
+ const target_store_id = store_id || apiConfig.storeId;
2262
2248
  return apiConfig.httpClient.get(
2263
- `/v1/businesses/${target_business_id}/forms`,
2249
+ `/v1/stores/${target_store_id}/forms`,
2264
2250
  {
2265
2251
  ...options,
2266
2252
  params: queryParams
@@ -2268,38 +2254,38 @@ var createFormApi = (apiConfig) => {
2268
2254
  );
2269
2255
  },
2270
2256
  async submit(params, options) {
2271
- const { business_id, form_id, ...payload } = params;
2272
- const target_business_id = business_id || apiConfig.businessId;
2257
+ const { store_id, form_id, ...payload } = params;
2258
+ const target_store_id = store_id || apiConfig.storeId;
2273
2259
  return apiConfig.httpClient.post(
2274
- `/v1/businesses/${target_business_id}/forms/${form_id}/submissions`,
2275
- { ...payload, form_id, business_id: target_business_id },
2260
+ `/v1/stores/${target_store_id}/forms/${form_id}/submissions`,
2261
+ { ...payload, form_id, store_id: target_store_id },
2276
2262
  options
2277
2263
  );
2278
2264
  },
2279
2265
  async getSubmissions(params, options) {
2280
- const { business_id, form_id, ...queryParams } = params;
2281
- const target_business_id = business_id || apiConfig.businessId;
2266
+ const { store_id, form_id, ...queryParams } = params;
2267
+ const target_store_id = store_id || apiConfig.storeId;
2282
2268
  return apiConfig.httpClient.get(
2283
- `/v1/businesses/${target_business_id}/forms/${form_id}/submissions`,
2269
+ `/v1/stores/${target_store_id}/forms/${form_id}/submissions`,
2284
2270
  {
2285
2271
  ...options,
2286
- params: { ...queryParams, form_id, business_id: target_business_id }
2272
+ params: { ...queryParams, form_id, store_id: target_store_id }
2287
2273
  }
2288
2274
  );
2289
2275
  },
2290
2276
  async getSubmission(params, options) {
2291
- const target_business_id = params.business_id || apiConfig.businessId;
2277
+ const target_store_id = params.store_id || apiConfig.storeId;
2292
2278
  return apiConfig.httpClient.get(
2293
- `/v1/businesses/${target_business_id}/forms/${params.form_id}/submissions/${params.id}`,
2279
+ `/v1/stores/${target_store_id}/forms/${params.form_id}/submissions/${params.id}`,
2294
2280
  options
2295
2281
  );
2296
2282
  },
2297
2283
  async updateSubmission(params, options) {
2298
- const { business_id, form_id, id, ...payload } = params;
2299
- const target_business_id = business_id || apiConfig.businessId;
2284
+ const { store_id, form_id, id, ...payload } = params;
2285
+ const target_store_id = store_id || apiConfig.storeId;
2300
2286
  return apiConfig.httpClient.put(
2301
- `/v1/businesses/${target_business_id}/forms/${form_id}/submissions/${id}`,
2302
- { ...payload, form_id, business_id: target_business_id, id },
2287
+ `/v1/stores/${target_store_id}/forms/${form_id}/submissions/${id}`,
2288
+ { ...payload, form_id, store_id: target_store_id, id },
2303
2289
  options
2304
2290
  );
2305
2291
  }
@@ -2310,50 +2296,50 @@ var createFormApi = (apiConfig) => {
2310
2296
  var createTaxonomyApi = (apiConfig) => {
2311
2297
  return {
2312
2298
  async createTaxonomy(params, options) {
2313
- const { business_id, ...payload } = params;
2314
- const target_business_id = business_id || apiConfig.businessId;
2299
+ const { store_id, ...payload } = params;
2300
+ const target_store_id = store_id || apiConfig.storeId;
2315
2301
  return apiConfig.httpClient.post(
2316
- `/v1/businesses/${target_business_id}/taxonomies`,
2302
+ `/v1/stores/${target_store_id}/taxonomies`,
2317
2303
  payload,
2318
2304
  options
2319
2305
  );
2320
2306
  },
2321
2307
  async updateTaxonomy(params, options) {
2322
- const { business_id, ...payload } = params;
2323
- const target_business_id = business_id || apiConfig.businessId;
2308
+ const { store_id, ...payload } = params;
2309
+ const target_store_id = store_id || apiConfig.storeId;
2324
2310
  return apiConfig.httpClient.put(
2325
- `/v1/businesses/${target_business_id}/taxonomies/${params.id}`,
2311
+ `/v1/stores/${target_store_id}/taxonomies/${params.id}`,
2326
2312
  payload,
2327
2313
  options
2328
2314
  );
2329
2315
  },
2330
2316
  async deleteTaxonomy(params, options) {
2331
- const target_business_id = params.business_id || apiConfig.businessId;
2317
+ const target_store_id = params.store_id || apiConfig.storeId;
2332
2318
  return apiConfig.httpClient.delete(
2333
- `/v1/businesses/${target_business_id}/taxonomies/${params.id}`,
2319
+ `/v1/stores/${target_store_id}/taxonomies/${params.id}`,
2334
2320
  options
2335
2321
  );
2336
2322
  },
2337
2323
  async getTaxonomy(params, options) {
2338
- const target_business_id = params.business_id || apiConfig.businessId;
2324
+ const target_store_id = params.store_id || apiConfig.storeId;
2339
2325
  let identifier;
2340
2326
  if (params.id) {
2341
2327
  identifier = params.id;
2342
2328
  } else if (params.key) {
2343
- identifier = `${target_business_id}:${params.key}`;
2329
+ identifier = `${target_store_id}:${params.key}`;
2344
2330
  } else {
2345
2331
  throw new Error("GetTaxonomyParams requires id or key");
2346
2332
  }
2347
2333
  return apiConfig.httpClient.get(
2348
- `/v1/businesses/${target_business_id}/taxonomies/${identifier}`,
2334
+ `/v1/stores/${target_store_id}/taxonomies/${identifier}`,
2349
2335
  options
2350
2336
  );
2351
2337
  },
2352
2338
  async getTaxonomies(params, options) {
2353
- const { business_id, ...queryParams } = params;
2354
- const target_business_id = business_id || apiConfig.businessId;
2339
+ const { store_id, ...queryParams } = params;
2340
+ const target_store_id = store_id || apiConfig.storeId;
2355
2341
  return apiConfig.httpClient.get(
2356
- `/v1/businesses/${target_business_id}/taxonomies`,
2342
+ `/v1/stores/${target_store_id}/taxonomies`,
2357
2343
  {
2358
2344
  ...options,
2359
2345
  params: queryParams
@@ -2361,10 +2347,10 @@ var createTaxonomyApi = (apiConfig) => {
2361
2347
  );
2362
2348
  },
2363
2349
  async getTaxonomyChildren(params, options) {
2364
- const { id, business_id } = params;
2365
- const target_business_id = business_id || apiConfig.businessId;
2350
+ const { id, store_id } = params;
2351
+ const target_store_id = store_id || apiConfig.storeId;
2366
2352
  return apiConfig.httpClient.get(
2367
- `/v1/businesses/${target_business_id}/taxonomies/${id}/children`,
2353
+ `/v1/stores/${target_store_id}/taxonomies/${id}/children`,
2368
2354
  options
2369
2355
  );
2370
2356
  }
@@ -2375,9 +2361,9 @@ var createTaxonomyApi = (apiConfig) => {
2375
2361
  var createAnalyticsApi = (apiConfig) => {
2376
2362
  return {
2377
2363
  async query(spec, options) {
2378
- const business_id = options?.business_id || apiConfig.businessId;
2364
+ const store_id = options?.store_id || apiConfig.storeId;
2379
2365
  return apiConfig.httpClient.post(
2380
- `/v1/businesses/${business_id}/analytics/query`,
2366
+ `/v1/stores/${store_id}/analytics/query`,
2381
2367
  spec,
2382
2368
  options
2383
2369
  );
@@ -2461,51 +2447,6 @@ function validatePhoneNumber(phone) {
2461
2447
  }
2462
2448
  return { isValid: true };
2463
2449
  }
2464
- function createStores() {
2465
- const $customer = nanostores.atom(null);
2466
- const $business = nanostores.atom(null);
2467
- const $market = nanostores.atom(null);
2468
- const $loading = nanostores.atom(false);
2469
- const $error = nanostores.atom(null);
2470
- const $isLoggedIn = nanostores.computed($customer, (c) => !!c?.emails?.length);
2471
- const $currency = nanostores.computed($market, (m) => m?.currency);
2472
- const $currencySymbol = nanostores.computed($market, (m) => {
2473
- if (!m?.currency) return void 0;
2474
- return new Intl.NumberFormat("en", {
2475
- style: "currency",
2476
- currency: m.currency.toUpperCase(),
2477
- currencyDisplay: "narrowSymbol"
2478
- }).formatToParts(0).find((p) => p.type === "currency")?.value || m.currency.toUpperCase();
2479
- });
2480
- const $paymentMethods = nanostores.computed($market, (m) => m?.payment_methods || []);
2481
- const $paymentConfig = nanostores.computed([$business, $paymentMethods], (biz, methods) => {
2482
- const payment = biz?.payment || null;
2483
- const hasCreditCard = methods.some((m) => m.id === "credit_card");
2484
- return {
2485
- provider: payment,
2486
- enabled: hasCreditCard && !!payment
2487
- };
2488
- });
2489
- const $zones = nanostores.computed($market, (m) => m?.zones || []);
2490
- return {
2491
- customer: $customer,
2492
- business: $business,
2493
- market: $market,
2494
- loading: $loading,
2495
- error: $error,
2496
- isLoggedIn: $isLoggedIn,
2497
- currency: $currency,
2498
- currencySymbol: $currencySymbol,
2499
- paymentMethods: $paymentMethods,
2500
- paymentConfig: $paymentConfig,
2501
- zones: $zones
2502
- };
2503
- }
2504
- function populateStores(stores, data) {
2505
- stores.customer.set(data.customer);
2506
- stores.business.set(data.business);
2507
- stores.market.set(data.market);
2508
- }
2509
2450
 
2510
2451
  // src/utils/timezone.ts
2511
2452
  var tzGroups = [
@@ -2680,7 +2621,7 @@ function getFirstAvailableFCId(variant, quantity = 1) {
2680
2621
  }
2681
2622
 
2682
2623
  // src/index.ts
2683
- var SDK_VERSION = "0.7.93";
2624
+ var SDK_VERSION = "0.7.102";
2684
2625
  var SUPPORTED_FRAMEWORKS = [
2685
2626
  "astro",
2686
2627
  "react",
@@ -2727,7 +2668,7 @@ function createUtilitySurface(apiConfig) {
2727
2668
  getFirstAvailableFCId
2728
2669
  };
2729
2670
  }
2730
- async function createAdmin(config) {
2671
+ function createAdmin(config) {
2731
2672
  const locale = config.locale || "en";
2732
2673
  const getToken = config.getToken || defaultGetToken;
2733
2674
  const setToken = config.setToken || defaultSetToken;
@@ -2736,7 +2677,7 @@ async function createAdmin(config) {
2736
2677
  const httpClient = createHttpClient({ ...config, getToken, setToken, logout });
2737
2678
  const apiConfig = {
2738
2679
  httpClient,
2739
- businessId: config.businessId,
2680
+ storeId: config.storeId,
2740
2681
  baseUrl: config.baseUrl,
2741
2682
  market: config.market,
2742
2683
  locale,
@@ -2745,7 +2686,7 @@ async function createAdmin(config) {
2745
2686
  };
2746
2687
  const accountApi = createAccountApi(apiConfig);
2747
2688
  const authApi = createAuthApi(apiConfig);
2748
- const businessApi = createBusinessApi(apiConfig);
2689
+ const storeApi = createStoreApi(apiConfig);
2749
2690
  const platformApi = createPlatformApi(apiConfig);
2750
2691
  const cmsApi = createCmsApi(apiConfig);
2751
2692
  const eshopApi = createEshopApi(apiConfig);
@@ -2762,8 +2703,8 @@ async function createAdmin(config) {
2762
2703
  const sdk = {
2763
2704
  auth: authApi,
2764
2705
  account: accountApi,
2765
- business: {
2766
- ...businessApi,
2706
+ store: {
2707
+ ...storeApi,
2767
2708
  location: locationApi,
2768
2709
  market: marketApi
2769
2710
  },
@@ -2890,7 +2831,7 @@ async function createAdmin(config) {
2890
2831
  getChat: agentApi.getChat,
2891
2832
  updateChat: agentApi.updateChat,
2892
2833
  rateChat: agentApi.rateChat,
2893
- getBusinessChats: agentApi.getBusinessChats,
2834
+ getStoreChats: agentApi.getStoreChats,
2894
2835
  getChatMessages: agentApi.getChatMessages
2895
2836
  },
2896
2837
  workflow: {
@@ -2907,10 +2848,10 @@ async function createAdmin(config) {
2907
2848
  analytics: {
2908
2849
  query: analyticsApi.query
2909
2850
  },
2910
- setBusinessId: (businessId) => {
2911
- apiConfig.businessId = businessId;
2851
+ setStoreId: (storeId) => {
2852
+ apiConfig.storeId = storeId;
2912
2853
  },
2913
- getBusinessId: () => apiConfig.businessId,
2854
+ getStoreId: () => apiConfig.storeId,
2914
2855
  setMarket: (market) => {
2915
2856
  apiConfig.market = market;
2916
2857
  },
@@ -2934,17 +2875,15 @@ function createStorefront(config) {
2934
2875
  const setToken = config.setToken || defaultSetToken;
2935
2876
  const logout = config.logout || defaultLogout;
2936
2877
  const isAuthenticated = config.isAuthenticated || defaultIsAuthenticated;
2937
- let refresh_business_id = config.businessId;
2938
2878
  const httpClient = createHttpClient({
2939
2879
  ...config,
2940
2880
  getToken,
2941
2881
  setToken,
2942
- logout,
2943
- refreshPath: () => `/v1/storefront/${refresh_business_id}/customers/auth/refresh`
2882
+ logout
2944
2883
  });
2945
2884
  const apiConfig = {
2946
2885
  httpClient,
2947
- businessId: config.businessId,
2886
+ storeId: config.storeId,
2948
2887
  baseUrl: config.baseUrl,
2949
2888
  market,
2950
2889
  locale,
@@ -2952,77 +2891,135 @@ function createStorefront(config) {
2952
2891
  getToken
2953
2892
  };
2954
2893
  const storefrontApi = createStorefrontApi(apiConfig);
2955
- const stores = createStores();
2956
2894
  let sessionPromise = null;
2957
- let resolveReady;
2958
- const ready = new Promise((r) => {
2959
- resolveReady = r;
2960
- });
2961
- function session(market2) {
2962
- if (market2 !== void 0) apiConfig.market = market2;
2963
- if (sessionPromise) return sessionPromise;
2964
- sessionPromise = (async () => {
2965
- stores.loading.set(true);
2966
- stores.error.set(null);
2895
+ let currentSession = null;
2896
+ const sessionListeners = /* @__PURE__ */ new Set();
2897
+ const customerApi = storefrontApi.crm.customer;
2898
+ function emitSessionChange(session) {
2899
+ for (const listener of sessionListeners) {
2900
+ Promise.resolve().then(() => listener(session)).catch(() => {
2901
+ });
2902
+ }
2903
+ }
2904
+ function setCurrentSessionFromResult(result) {
2905
+ const s = {
2906
+ customer: result.customer,
2907
+ store: result.store,
2908
+ market: result.market || null
2909
+ };
2910
+ currentSession = s;
2911
+ emitSessionChange(s);
2912
+ return s;
2913
+ }
2914
+ function clearSession() {
2915
+ sessionPromise = null;
2916
+ currentSession = null;
2917
+ emitSessionChange(null);
2918
+ }
2919
+ async function invalidateAfterAuth(promise) {
2920
+ const result = await promise;
2921
+ clearSession();
2922
+ return result;
2923
+ }
2924
+ function identify(params) {
2925
+ if (params?.market !== void 0) apiConfig.market = params.market;
2926
+ const isBareCall = !params?.email && !params?.verify;
2927
+ if (isBareCall && sessionPromise) return sessionPromise;
2928
+ const promise = (async () => {
2967
2929
  try {
2968
- const result = await storefrontApi.crm.customer.session({
2969
- market: apiConfig.market
2930
+ const result = await customerApi.identify({
2931
+ market: apiConfig.market,
2932
+ email: params?.email,
2933
+ verify: params?.verify
2970
2934
  });
2971
- const s = {
2972
- customer: result.customer,
2973
- business: result.business,
2974
- market: result.market || null
2975
- };
2976
- populateStores(stores, s);
2977
- resolveReady();
2978
- return s;
2935
+ return setCurrentSessionFromResult(result);
2979
2936
  } catch (err) {
2980
- const status = err?.status || err?.response?.status;
2981
- if (status === 401) {
2982
- await setToken({ access_token: "", refresh_token: "", access_expires_at: 0 });
2983
- const result = await storefrontApi.crm.customer.session({
2937
+ const e = err;
2938
+ const status = e?.statusCode || e?.status || e?.response?.status;
2939
+ if (isBareCall && status === 401) {
2940
+ currentSession = null;
2941
+ emitSessionChange(null);
2942
+ await setToken({ access_token: "" });
2943
+ const result = await customerApi.identify({
2984
2944
  market: apiConfig.market
2985
2945
  });
2986
- const s = {
2987
- customer: result.customer,
2988
- business: result.business,
2989
- market: result.market || null
2990
- };
2991
- populateStores(stores, s);
2992
- resolveReady();
2993
- return s;
2946
+ return setCurrentSessionFromResult(result);
2994
2947
  }
2995
2948
  throw err;
2996
- } finally {
2997
- stores.loading.set(false);
2998
2949
  }
2999
2950
  })().catch((err) => {
3000
- stores.error.set(err.message || "Session failed");
3001
- sessionPromise = null;
2951
+ if (isBareCall) sessionPromise = null;
3002
2952
  throw err;
3003
2953
  });
3004
- return sessionPromise;
2954
+ if (isBareCall) sessionPromise = promise;
2955
+ return promise;
3005
2956
  }
3006
2957
  function setMarket(key) {
3007
- sessionPromise = null;
3008
- return session(key);
2958
+ apiConfig.market = key;
2959
+ clearSession();
2960
+ }
2961
+ function onSessionChange(listener) {
2962
+ sessionListeners.add(listener);
2963
+ if (currentSession) {
2964
+ Promise.resolve().then(() => listener(currentSession)).catch(() => {
2965
+ });
2966
+ }
2967
+ return () => {
2968
+ sessionListeners.delete(listener);
2969
+ };
2970
+ }
2971
+ function getSession() {
2972
+ return currentSession;
2973
+ }
2974
+ function setTokenAndClearSession(tokens) {
2975
+ setToken(tokens);
2976
+ clearSession();
2977
+ }
2978
+ const crm = {
2979
+ ...storefrontApi.crm,
2980
+ customer: {
2981
+ ...customerApi,
2982
+ async identify(params, options) {
2983
+ const result = await customerApi.identify(params, options);
2984
+ setCurrentSessionFromResult(result);
2985
+ return result;
2986
+ },
2987
+ verify: (params, options) => invalidateAfterAuth(customerApi.verify(params, options))
2988
+ }
2989
+ };
2990
+ async function verify(params) {
2991
+ const result = await invalidateAfterAuth(customerApi.verify(params));
2992
+ return result;
2993
+ }
2994
+ async function me() {
2995
+ return customerApi.getMe();
2996
+ }
2997
+ async function logoutCustomer() {
2998
+ try {
2999
+ await customerApi.logout();
3000
+ } finally {
3001
+ clearSession();
3002
+ }
3009
3003
  }
3010
3004
  return {
3011
- session,
3012
- stores,
3013
- business: storefrontApi.business,
3005
+ identify,
3006
+ verify,
3007
+ me,
3008
+ logout: logoutCustomer,
3009
+ getSession,
3010
+ onSessionChange,
3011
+ store: storefrontApi.store,
3014
3012
  cms: storefrontApi.cms,
3015
3013
  eshop: storefrontApi.eshop,
3016
3014
  booking: storefrontApi.booking,
3017
- crm: storefrontApi.crm,
3015
+ crm,
3018
3016
  activity: storefrontApi.activity,
3019
- ready,
3020
3017
  automation: storefrontApi.automation,
3021
- setBusinessId: (businessId) => {
3022
- refresh_business_id = businessId;
3023
- apiConfig.businessId = businessId;
3018
+ setStoreId: (storeId) => {
3019
+ apiConfig.storeId = storeId;
3020
+ clearSession();
3024
3021
  },
3025
- getBusinessId: () => apiConfig.businessId,
3022
+ getStoreId: () => apiConfig.storeId,
3026
3023
  setMarket,
3027
3024
  getMarket: () => apiConfig.market,
3028
3025
  setLocale: (locale2) => {
@@ -3030,8 +3027,7 @@ function createStorefront(config) {
3030
3027
  },
3031
3028
  getLocale: () => apiConfig.locale,
3032
3029
  isAuthenticated,
3033
- logout,
3034
- setToken,
3030
+ setToken: setTokenAndClearSession,
3035
3031
  extractBlockValues,
3036
3032
  utils: createUtilitySurface(apiConfig)
3037
3033
  };