@cimplify/sdk 0.18.0 → 0.20.0

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.
Files changed (40) hide show
  1. package/dist/advanced.d.mts +2 -2
  2. package/dist/advanced.d.ts +2 -2
  3. package/dist/advanced.js +21 -21
  4. package/dist/advanced.mjs +2 -2
  5. package/dist/{chunk-RYQ5IPWX.js → chunk-2BSYTQAY.js} +18 -28
  6. package/dist/{chunk-KTTQC5HG.mjs → chunk-676BJ3EU.mjs} +43 -8
  7. package/dist/{chunk-2JI47EYJ.mjs → chunk-7KH2XJIW.mjs} +67 -12
  8. package/dist/{chunk-MJECWMOY.js → chunk-AVVLN353.js} +76 -40
  9. package/dist/{chunk-FTL2SXCG.mjs → chunk-HG7GG3TT.mjs} +18 -28
  10. package/dist/{chunk-DYKFSV77.js → chunk-KSN3RJFL.js} +86 -30
  11. package/dist/{client-BFFfuzJr.d.mts → client-D4E9aJy7.d.mts} +141 -7
  12. package/dist/{client-B1UtuyOg.d.ts → client-VyO6Bqz2.d.ts} +141 -7
  13. package/dist/index.d.mts +38 -5
  14. package/dist/index.d.ts +38 -5
  15. package/dist/index.js +101 -97
  16. package/dist/index.mjs +3 -3
  17. package/dist/{payment-D9FTaOse.d.mts → payment-CKqMU4xT.d.mts} +1052 -934
  18. package/dist/{payment-D9FTaOse.d.ts → payment-CKqMU4xT.d.ts} +1052 -934
  19. package/dist/{price-BD1iioLh.d.ts → price-BqV_DjjQ.d.mts} +1 -1
  20. package/dist/{price-9JsPuknm.d.mts → price-e4beObLZ.d.ts} +1 -1
  21. package/dist/react.d.mts +463 -11
  22. package/dist/react.d.ts +463 -11
  23. package/dist/react.js +1630 -113
  24. package/dist/react.mjs +1566 -65
  25. package/dist/styles.css +1 -1
  26. package/dist/utils.d.mts +2 -2
  27. package/dist/utils.d.ts +2 -2
  28. package/dist/utils.js +28 -28
  29. package/dist/utils.mjs +1 -1
  30. package/package.json +2 -2
  31. package/registry/availability-badge.json +1 -1
  32. package/registry/booking-page.json +1 -1
  33. package/registry/bundle-selector.json +1 -1
  34. package/registry/cart-summary.json +1 -1
  35. package/registry/composite-selector.json +1 -1
  36. package/registry/order-summary.json +1 -1
  37. package/registry/product-customizer.json +1 -1
  38. package/registry/search-input.json +1 -1
  39. package/registry/service-card.json +1 -1
  40. package/registry/variant-selector.json +1 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkDYKFSV77_js = require('./chunk-DYKFSV77.js');
4
- var chunkRYQ5IPWX_js = require('./chunk-RYQ5IPWX.js');
3
+ var chunkKSN3RJFL_js = require('./chunk-KSN3RJFL.js');
4
+ var chunk2BSYTQAY_js = require('./chunk-2BSYTQAY.js');
5
5
 
6
6
  // src/activity.ts
7
7
  var ActivityService = class {
@@ -28,12 +28,25 @@ var ActivityService = class {
28
28
  };
29
29
  this.sendEvents([event]);
30
30
  }
31
+ async getState() {
32
+ return chunkKSN3RJFL_js.safe(this.client.get("/api/v1/activity/state"));
33
+ }
34
+ async getRecommendations(options) {
35
+ const params = new URLSearchParams();
36
+ if (options?.location_id) params.set("location_id", options.location_id);
37
+ if (options?.limit) params.set("limit", String(options.limit));
38
+ const query = params.toString();
39
+ const path = query ? `/api/v1/activity/recommendations?${query}` : "/api/v1/activity/recommendations";
40
+ return chunkKSN3RJFL_js.safe(this.client.get(path));
41
+ }
42
+ async dismissMessage(code) {
43
+ return chunkKSN3RJFL_js.safe(
44
+ this.client.post("/api/v1/activity/messages/dismiss", { code })
45
+ );
46
+ }
31
47
  sendEvents(events) {
32
- try {
33
- this.client.post("/api/v1/activity/events", { events }).catch(() => {
34
- });
35
- } catch {
36
- }
48
+ this.client.post("/api/v1/activity/events", { events }).catch(() => {
49
+ });
37
50
  }
38
51
  };
39
52
  function currentPath() {
@@ -43,6 +56,22 @@ function currentPath() {
43
56
  return void 0;
44
57
  }
45
58
 
59
+ // src/delivery.ts
60
+ var DeliveryService = class {
61
+ constructor(client) {
62
+ this.client = client;
63
+ }
64
+ async getFee(dropoffLat, dropoffLng, country) {
65
+ const params = new URLSearchParams();
66
+ params.set("dropoff_lat", String(dropoffLat));
67
+ params.set("dropoff_lng", String(dropoffLng));
68
+ if (country) params.set("country", country);
69
+ return chunkKSN3RJFL_js.safe(
70
+ this.client.get(`/api/v1/delivery/fee?${params.toString()}`)
71
+ );
72
+ }
73
+ };
74
+
46
75
  // src/client.ts
47
76
  var ACCESS_TOKEN_STORAGE_KEY = "cimplify_access_token";
48
77
  var SESSION_TOKEN_STORAGE_KEY = "cimplify_session_token";
@@ -62,16 +91,16 @@ function isRetryable(error) {
62
91
  if (error instanceof DOMException && error.name === "AbortError") {
63
92
  return true;
64
93
  }
65
- if (error instanceof chunkRYQ5IPWX_js.CimplifyError) {
94
+ if (error instanceof chunk2BSYTQAY_js.CimplifyError) {
66
95
  return error.retryable;
67
96
  }
68
97
  return false;
69
98
  }
70
99
  function toNetworkError(error, isTestMode) {
71
100
  if (error instanceof DOMException && error.name === "AbortError") {
72
- return chunkRYQ5IPWX_js.enrichError(
73
- new chunkRYQ5IPWX_js.CimplifyError(
74
- chunkRYQ5IPWX_js.ErrorCode.TIMEOUT,
101
+ return chunk2BSYTQAY_js.enrichError(
102
+ new chunk2BSYTQAY_js.CimplifyError(
103
+ chunk2BSYTQAY_js.ErrorCode.TIMEOUT,
75
104
  "Request timed out. Please check your connection and try again.",
76
105
  true
77
106
  ),
@@ -79,21 +108,21 @@ function toNetworkError(error, isTestMode) {
79
108
  );
80
109
  }
81
110
  if (error instanceof TypeError && error.message.includes("fetch")) {
82
- return chunkRYQ5IPWX_js.enrichError(
83
- new chunkRYQ5IPWX_js.CimplifyError(
84
- chunkRYQ5IPWX_js.ErrorCode.NETWORK_ERROR,
111
+ return chunk2BSYTQAY_js.enrichError(
112
+ new chunk2BSYTQAY_js.CimplifyError(
113
+ chunk2BSYTQAY_js.ErrorCode.NETWORK_ERROR,
85
114
  "Network error. Please check your internet connection.",
86
115
  true
87
116
  ),
88
117
  { isTestMode }
89
118
  );
90
119
  }
91
- if (error instanceof chunkRYQ5IPWX_js.CimplifyError) {
92
- return chunkRYQ5IPWX_js.enrichError(error, { isTestMode });
120
+ if (error instanceof chunk2BSYTQAY_js.CimplifyError) {
121
+ return chunk2BSYTQAY_js.enrichError(error, { isTestMode });
93
122
  }
94
- return chunkRYQ5IPWX_js.enrichError(
95
- new chunkRYQ5IPWX_js.CimplifyError(
96
- chunkRYQ5IPWX_js.ErrorCode.UNKNOWN_ERROR,
123
+ return chunk2BSYTQAY_js.enrichError(
124
+ new chunk2BSYTQAY_js.CimplifyError(
125
+ chunk2BSYTQAY_js.ErrorCode.UNKNOWN_ERROR,
97
126
  error instanceof Error ? error.message : "An unknown error occurred",
98
127
  false
99
128
  ),
@@ -260,8 +289,8 @@ var CimplifyClient = class {
260
289
  this.businessIdResolvePromise = (async () => {
261
290
  const result = await this.business.getInfo();
262
291
  if (!result.ok || !result.value?.id) {
263
- throw new chunkRYQ5IPWX_js.CimplifyError(
264
- chunkRYQ5IPWX_js.ErrorCode.NOT_FOUND,
292
+ throw new chunk2BSYTQAY_js.CimplifyError(
293
+ chunk2BSYTQAY_js.ErrorCode.NOT_FOUND,
265
294
  "Unable to resolve business ID from the current public key.",
266
295
  true
267
296
  );
@@ -378,7 +407,7 @@ var CimplifyClient = class {
378
407
  if (response.status >= 400 && response.status < 500) {
379
408
  this.hooks.onRequestError?.({
380
409
  ...context,
381
- error: new chunkRYQ5IPWX_js.CimplifyError(
410
+ error: new chunk2BSYTQAY_js.CimplifyError(
382
411
  `HTTP_${response.status}`,
383
412
  `Request failed with status ${response.status}`,
384
413
  false
@@ -404,7 +433,7 @@ var CimplifyClient = class {
404
433
  }
405
434
  this.hooks.onRequestError?.({
406
435
  ...context,
407
- error: new chunkRYQ5IPWX_js.CimplifyError(
436
+ error: new chunk2BSYTQAY_js.CimplifyError(
408
437
  "SERVER_ERROR",
409
438
  `Server error ${response.status} after ${retryCount} retries`,
410
439
  false
@@ -535,15 +564,15 @@ var CimplifyClient = class {
535
564
  const errorCode = typeof json.error === "object" && json.error?.error_code || typeof json.error === "object" && json.error?.code || "API_ERROR";
536
565
  const errorMessage = typeof json.error === "object" && json.error?.error_message || typeof json.error === "object" && json.error?.message || typeof json.error === "string" && json.error || typeof json.message === "string" && json.message || "An error occurred";
537
566
  const retryable = typeof json.error === "object" && typeof json.error?.retryable === "boolean" ? json.error.retryable : false;
538
- const error = chunkRYQ5IPWX_js.enrichError(
539
- new chunkRYQ5IPWX_js.CimplifyError(
567
+ const error = chunk2BSYTQAY_js.enrichError(
568
+ new chunk2BSYTQAY_js.CimplifyError(
540
569
  errorCode,
541
570
  errorMessage,
542
571
  retryable
543
572
  ),
544
573
  { isTestMode: this.isTestMode() }
545
574
  );
546
- if (response.status === 401 || error.code === chunkRYQ5IPWX_js.ErrorCode.UNAUTHORIZED) {
575
+ if (response.status === 401 || error.code === chunk2BSYTQAY_js.ErrorCode.UNAUTHORIZED) {
547
576
  console.warn(
548
577
  "[Cimplify] Received 401 Unauthorized. Access token may be missing/expired. Refresh authentication and retry the request."
549
578
  );
@@ -551,8 +580,8 @@ var CimplifyClient = class {
551
580
  throw error;
552
581
  }
553
582
  if (json?.success === false || json?.error?.code || json?.error?.message) {
554
- const error = chunkRYQ5IPWX_js.enrichError(
555
- new chunkRYQ5IPWX_js.CimplifyError(
583
+ const error = chunk2BSYTQAY_js.enrichError(
584
+ new chunk2BSYTQAY_js.CimplifyError(
556
585
  json.error?.code || "API_ERROR",
557
586
  json.error?.message || "An error occurred",
558
587
  json.error?.retryable || false
@@ -568,67 +597,67 @@ var CimplifyClient = class {
568
597
  }
569
598
  get catalogue() {
570
599
  if (!this._catalogue) {
571
- this._catalogue = new chunkDYKFSV77_js.CatalogueQueries(this);
600
+ this._catalogue = new chunkKSN3RJFL_js.CatalogueQueries(this);
572
601
  }
573
602
  return this._catalogue;
574
603
  }
575
604
  get cart() {
576
605
  if (!this._cart) {
577
- this._cart = new chunkDYKFSV77_js.CartOperations(this);
606
+ this._cart = new chunkKSN3RJFL_js.CartOperations(this);
578
607
  }
579
608
  return this._cart;
580
609
  }
581
610
  get checkout() {
582
611
  if (!this._checkout) {
583
- this._checkout = new chunkDYKFSV77_js.CheckoutService(this);
612
+ this._checkout = new chunkKSN3RJFL_js.CheckoutService(this);
584
613
  }
585
614
  return this._checkout;
586
615
  }
587
616
  get orders() {
588
617
  if (!this._orders) {
589
- this._orders = new chunkDYKFSV77_js.OrderQueries(this);
618
+ this._orders = new chunkKSN3RJFL_js.OrderQueries(this);
590
619
  }
591
620
  return this._orders;
592
621
  }
593
622
  get link() {
594
623
  if (!this._link) {
595
- this._link = new chunkDYKFSV77_js.LinkService(this);
624
+ this._link = new chunkKSN3RJFL_js.LinkService(this);
596
625
  }
597
626
  return this._link;
598
627
  }
599
628
  get auth() {
600
629
  if (!this._auth) {
601
- this._auth = new chunkDYKFSV77_js.AuthService(this);
630
+ this._auth = new chunkKSN3RJFL_js.AuthService(this);
602
631
  }
603
632
  return this._auth;
604
633
  }
605
634
  get business() {
606
635
  if (!this._business) {
607
- this._business = new chunkDYKFSV77_js.BusinessService(this);
636
+ this._business = new chunkKSN3RJFL_js.BusinessService(this);
608
637
  }
609
638
  return this._business;
610
639
  }
611
640
  get inventory() {
612
641
  if (!this._inventory) {
613
- this._inventory = new chunkDYKFSV77_js.InventoryService(this);
642
+ this._inventory = new chunkKSN3RJFL_js.InventoryService(this);
614
643
  }
615
644
  return this._inventory;
616
645
  }
617
646
  get scheduling() {
618
647
  if (!this._scheduling) {
619
- this._scheduling = new chunkDYKFSV77_js.SchedulingService(this);
648
+ this._scheduling = new chunkKSN3RJFL_js.SchedulingService(this);
620
649
  }
621
650
  return this._scheduling;
622
651
  }
623
652
  get lite() {
624
653
  if (!this._lite) {
625
- this._lite = new chunkDYKFSV77_js.LiteService(this);
654
+ this._lite = new chunkKSN3RJFL_js.LiteService(this);
626
655
  }
627
656
  return this._lite;
628
657
  }
629
658
  get fx() {
630
659
  if (!this._fx) {
631
- this._fx = new chunkDYKFSV77_js.FxService(this);
660
+ this._fx = new chunkKSN3RJFL_js.FxService(this);
632
661
  }
633
662
  return this._fx;
634
663
  }
@@ -638,11 +667,17 @@ var CimplifyClient = class {
638
667
  }
639
668
  return this._activity;
640
669
  }
670
+ get delivery() {
671
+ if (!this._delivery) {
672
+ this._delivery = new DeliveryService(this);
673
+ }
674
+ return this._delivery;
675
+ }
641
676
  elements(businessId, options) {
642
677
  if (businessId) {
643
678
  this.setBusinessId(businessId);
644
679
  }
645
- return chunkDYKFSV77_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
680
+ return chunkKSN3RJFL_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
646
681
  }
647
682
  };
648
683
  function createCimplifyClient(config = {}) {
@@ -688,5 +723,6 @@ function getVariantDisplayName(variant, productName) {
688
723
 
689
724
  exports.ActivityService = ActivityService;
690
725
  exports.CimplifyClient = CimplifyClient;
726
+ exports.DeliveryService = DeliveryService;
691
727
  exports.createCimplifyClient = createCimplifyClient;
692
728
  exports.getVariantDisplayName = getVariantDisplayName;
@@ -550,26 +550,29 @@ var PAYMENT_REQUIRES_ACTION_STATUSES = /* @__PURE__ */ new Set([
550
550
  "requires_capture"
551
551
  ]);
552
552
  var PAYMENT_STATUS_ALIAS_MAP = {
553
- ok: "success",
554
- done: "success",
555
- paid: "paid",
556
- paid_in_full: "paid",
557
- paid_successfully: "paid",
558
- succeeded: "success",
553
+ ok: "captured",
554
+ done: "captured",
555
+ paid: "captured",
556
+ paid_in_full: "captured",
557
+ paid_successfully: "captured",
558
+ succeeded: "captured",
559
+ success: "captured",
559
560
  captured: "captured",
560
- completed: "completed",
561
- pending_confirmation: "pending_confirmation",
561
+ completed: "captured",
562
+ pending_confirmation: "pending",
562
563
  requires_authorization: "requires_action",
563
564
  requires_action: "requires_action",
564
- requires_payment_method: "requires_payment_method",
565
- requires_capture: "requires_capture",
566
- partially_paid: "partially_paid",
567
- partially_refunded: "partially_refunded",
568
- card_declined: "declined",
565
+ requires_payment_method: "requires_action",
566
+ requires_capture: "authorized",
567
+ partially_paid: "pending",
568
+ partially_refunded: "refunded",
569
+ card_declined: "failed",
570
+ declined: "failed",
569
571
  canceled: "cancelled",
570
572
  authorized: "authorized",
571
573
  cancelled: "cancelled",
572
- unresolved: "pending"
574
+ unresolved: "pending",
575
+ error: "failed"
573
576
  };
574
577
  var KNOWN_PAYMENT_STATUSES = /* @__PURE__ */ new Set([
575
578
  "initialized",
@@ -586,20 +589,7 @@ var KNOWN_PAYMENT_STATUSES = /* @__PURE__ */ new Set([
586
589
  "abandoned",
587
590
  "reversed",
588
591
  "disputed",
589
- "refund_pending",
590
- "created",
591
- "pending_confirmation",
592
- "success",
593
- "succeeded",
594
- "declined",
595
- "partially_refunded",
596
- "partially_paid",
597
- "paid",
598
- "unpaid",
599
- "requires_payment_method",
600
- "requires_capture",
601
- "completed",
602
- "error"
592
+ "refund_pending"
603
593
  ]);
604
594
  function normalizeStatusToken(status) {
605
595
  return status?.trim().toLowerCase().replace(/[\s-]+/g, "_") ?? "";
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkRYQ5IPWX_js = require('./chunk-RYQ5IPWX.js');
3
+ var chunk2BSYTQAY_js = require('./chunk-2BSYTQAY.js');
4
4
 
5
5
  // src/types/result.ts
6
6
  function ok(value) {
@@ -74,11 +74,11 @@ function combineObject(results) {
74
74
 
75
75
  // src/internal/safe.ts
76
76
  function toCimplifyError(error) {
77
- if (error instanceof chunkRYQ5IPWX_js.CimplifyError) return chunkRYQ5IPWX_js.enrichError(error);
77
+ if (error instanceof chunk2BSYTQAY_js.CimplifyError) return chunk2BSYTQAY_js.enrichError(error);
78
78
  if (error instanceof Error) {
79
- return chunkRYQ5IPWX_js.enrichError(new chunkRYQ5IPWX_js.CimplifyError(chunkRYQ5IPWX_js.ErrorCode.UNKNOWN_ERROR, error.message, false));
79
+ return chunk2BSYTQAY_js.enrichError(new chunk2BSYTQAY_js.CimplifyError(chunk2BSYTQAY_js.ErrorCode.UNKNOWN_ERROR, error.message, false));
80
80
  }
81
- return chunkRYQ5IPWX_js.enrichError(new chunkRYQ5IPWX_js.CimplifyError(chunkRYQ5IPWX_js.ErrorCode.UNKNOWN_ERROR, String(error), false));
81
+ return chunk2BSYTQAY_js.enrichError(new chunk2BSYTQAY_js.CimplifyError(chunk2BSYTQAY_js.ErrorCode.UNKNOWN_ERROR, String(error), false));
82
82
  }
83
83
  async function safe(promise) {
84
84
  try {
@@ -277,10 +277,7 @@ var CatalogueQueries = class {
277
277
  return ok(normalizeCatalogueProductPayload(result.value));
278
278
  }
279
279
  async getProductBySlug(slug) {
280
- const encodedSlug = encodeURIComponent(slug);
281
- const result = await safe(this.client.get(`/api/v1/catalogue/products/slug/${encodedSlug}`));
282
- if (!result.ok) return result;
283
- return ok(normalizeCatalogueProductPayload(result.value));
280
+ return this.getProduct(slug);
284
281
  }
285
282
  async getVariants(productId) {
286
283
  const encodedId = encodeURIComponent(productId);
@@ -320,8 +317,7 @@ var CatalogueQueries = class {
320
317
  return safe(this.client.get(`/api/v1/catalogue/categories/${encodedId}`));
321
318
  }
322
319
  async getCategoryBySlug(slug) {
323
- const encodedSlug = encodeURIComponent(slug);
324
- return safe(this.client.get(`/api/v1/catalogue/categories/slug/${encodedSlug}`));
320
+ return this.getCategory(slug);
325
321
  }
326
322
  async getCategoryProducts(categoryId, options) {
327
323
  const encodedId = encodeURIComponent(categoryId);
@@ -339,8 +335,7 @@ var CatalogueQueries = class {
339
335
  return safe(this.client.get(`/api/v1/catalogue/collections/${encodedId}`));
340
336
  }
341
337
  async getCollectionBySlug(slug) {
342
- const encodedSlug = encodeURIComponent(slug);
343
- return safe(this.client.get(`/api/v1/catalogue/collections/slug/${encodedSlug}`));
338
+ return this.getCollection(slug);
344
339
  }
345
340
  async getCollectionProducts(collectionId, options) {
346
341
  const encodedId = encodeURIComponent(collectionId);
@@ -357,6 +352,13 @@ var CatalogueQueries = class {
357
352
  async getBundles() {
358
353
  return safe(this.client.get("/api/v1/catalogue/bundles"));
359
354
  }
355
+ async getBundle(id) {
356
+ const encodedId = encodeURIComponent(id);
357
+ return safe(this.client.get(`/api/v1/catalogue/bundles/${encodedId}`));
358
+ }
359
+ async getBundleBySlug(slug) {
360
+ return this.getBundle(slug);
361
+ }
360
362
  async searchBundles(query, limit = 20) {
361
363
  const path = withQuery("/api/v1/catalogue/bundles", { search: query, limit });
362
364
  return safe(this.client.get(path));
@@ -365,6 +367,14 @@ var CatalogueQueries = class {
365
367
  const path = withQuery("/api/v1/catalogue/composites", { limit: options?.limit });
366
368
  return safe(this.client.get(path));
367
369
  }
370
+ async getComposite(id) {
371
+ const encodedId = encodeURIComponent(id);
372
+ return safe(this.client.get(`/api/v1/catalogue/composites/${encodedId}`));
373
+ }
374
+ async getCompositeByProduct(productId) {
375
+ const encodedId = encodeURIComponent(productId);
376
+ return safe(this.client.get(`/api/v1/catalogue/composites/by-product/${encodedId}`));
377
+ }
368
378
  async calculateCompositePrice(compositeId, selections, locationId) {
369
379
  const encodedId = encodeURIComponent(compositeId);
370
380
  return safe(
@@ -409,6 +419,15 @@ var CatalogueQueries = class {
409
419
  const path = withQuery("/api/v1/catalogue/taxonomies/search", { q: query, limit });
410
420
  return safe(this.client.get(path));
411
421
  }
422
+ async getEligibleBillingPlans(productId, query) {
423
+ const encodedId = encodeURIComponent(productId);
424
+ const path = withQuery(`/api/v1/catalogue/products/${encodedId}/billing-plans/eligible`, {
425
+ customer_id: query?.customer_id,
426
+ quantity: query?.quantity,
427
+ order_value: query?.order_value
428
+ });
429
+ return safe(this.client.get(path));
430
+ }
412
431
  async getProductSchedules(productId) {
413
432
  const encodedId = encodeURIComponent(productId);
414
433
  return safe(this.client.get(`/api/v1/catalogue/products/${encodedId}/schedules`));
@@ -483,8 +502,32 @@ var CatalogueQueries = class {
483
502
  });
484
503
  return safe(this.client.get(path));
485
504
  }
486
- async getAttributeDefinitions() {
487
- return safe(this.client.get("/api/v1/catalogue/attributes"));
505
+ async getAttributeDefinitions(namespace) {
506
+ const params = namespace ? `?namespace=${encodeURIComponent(namespace)}` : "";
507
+ return safe(
508
+ this.client.get(`/api/v1/catalogue/attributes${params}`)
509
+ );
510
+ }
511
+ async getProductAttributes(productId) {
512
+ return safe(
513
+ this.client.get(
514
+ `/api/v1/catalogue/products/${productId}/attributes`
515
+ )
516
+ );
517
+ }
518
+ async getCategoryAttributes(categoryId) {
519
+ return safe(
520
+ this.client.get(
521
+ `/api/v1/catalogue/categories/${categoryId}/attributes`
522
+ )
523
+ );
524
+ }
525
+ async getCollectionAttributes(collectionId) {
526
+ return safe(
527
+ this.client.get(
528
+ `/api/v1/catalogue/collections/${collectionId}/attributes`
529
+ )
530
+ );
488
531
  }
489
532
  async getPropertyFacets(options) {
490
533
  const path = withQuery("/api/v1/catalogue/properties/facets", {
@@ -501,6 +544,18 @@ var CatalogueQueries = class {
501
544
  )
502
545
  );
503
546
  }
547
+ async searchKnowledge(query, limit) {
548
+ const path = withQuery("/api/v1/catalogue/knowledge-base/search", {
549
+ q: query,
550
+ limit: limit ?? 5
551
+ });
552
+ return safe(this.client.get(path));
553
+ }
554
+ async getKnowledgeArticles() {
555
+ return safe(
556
+ this.client.get("/api/v1/catalogue/knowledge-base/articles")
557
+ );
558
+ }
504
559
  };
505
560
 
506
561
  // src/cart.ts
@@ -961,7 +1016,7 @@ var CheckoutResolver = class {
961
1016
  }
962
1017
  }
963
1018
  }
964
- if (checkoutResult.requires_authorization || chunkRYQ5IPWX_js.isPaymentStatusRequiresAction(checkoutResult.payment_status)) {
1019
+ if (checkoutResult.requires_authorization || chunk2BSYTQAY_js.isPaymentStatusRequiresAction(checkoutResult.payment_status)) {
965
1020
  const authorization = await this.handleAuthorization({
966
1021
  authorizationType,
967
1022
  paymentReference,
@@ -1135,18 +1190,18 @@ var CheckoutResolver = class {
1135
1190
  if (statusResult.value.reference) {
1136
1191
  paymentReference = statusResult.value.reference;
1137
1192
  }
1138
- const normalized = chunkRYQ5IPWX_js.normalizeStatusResponse(statusResult.value);
1139
- if (normalized.paid || chunkRYQ5IPWX_js.isPaymentStatusSuccess(normalized.status)) {
1193
+ const normalized = chunk2BSYTQAY_js.normalizeStatusResponse(statusResult.value);
1194
+ if (normalized.paid || chunk2BSYTQAY_js.isPaymentStatusSuccess(normalized.status)) {
1140
1195
  return this.finalizeSuccess(latestCheckoutResult);
1141
1196
  }
1142
- if (chunkRYQ5IPWX_js.isPaymentStatusFailure(normalized.status)) {
1197
+ if (chunk2BSYTQAY_js.isPaymentStatusFailure(normalized.status)) {
1143
1198
  return this.fail(
1144
1199
  normalized.status ? normalized.status.toUpperCase() : "PAYMENT_FAILED",
1145
1200
  normalized.message || "Payment failed during confirmation.",
1146
1201
  false
1147
1202
  );
1148
1203
  }
1149
- if (chunkRYQ5IPWX_js.isPaymentStatusRequiresAction(normalized.status)) {
1204
+ if (chunk2BSYTQAY_js.isPaymentStatusRequiresAction(normalized.status)) {
1150
1205
  const authorization = await this.handleAuthorization({
1151
1206
  authorizationType,
1152
1207
  paymentReference,
@@ -1177,8 +1232,8 @@ var CheckoutResolver = class {
1177
1232
  try {
1178
1233
  const finalResult = await this.client.checkout.pollPaymentStatus(input.orderId);
1179
1234
  if (finalResult.ok) {
1180
- const normalized = chunkRYQ5IPWX_js.normalizeStatusResponse(finalResult.value);
1181
- if (normalized.paid || chunkRYQ5IPWX_js.isPaymentStatusSuccess(normalized.status)) {
1235
+ const normalized = chunk2BSYTQAY_js.normalizeStatusResponse(finalResult.value);
1236
+ if (normalized.paid || chunk2BSYTQAY_js.isPaymentStatusSuccess(normalized.status)) {
1182
1237
  return this.finalizeSuccess(latestCheckoutResult);
1183
1238
  }
1184
1239
  }
@@ -1374,12 +1429,12 @@ var CheckoutResolver = class {
1374
1429
  };
1375
1430
  }
1376
1431
  isSuccessfulStatus(status) {
1377
- const normalized = chunkRYQ5IPWX_js.normalizeStatusResponse({ status, paid: false });
1378
- return normalized.paid || chunkRYQ5IPWX_js.isPaymentStatusSuccess(normalized.status);
1432
+ const normalized = chunk2BSYTQAY_js.normalizeStatusResponse({ status, paid: false });
1433
+ return normalized.paid || chunk2BSYTQAY_js.isPaymentStatusSuccess(normalized.status);
1379
1434
  }
1380
1435
  isFailureStatus(status) {
1381
- const normalized = chunkRYQ5IPWX_js.normalizeStatusResponse({ status, paid: false });
1382
- return chunkRYQ5IPWX_js.isPaymentStatusFailure(normalized.status);
1436
+ const normalized = chunk2BSYTQAY_js.normalizeStatusResponse({ status, paid: false });
1437
+ return chunk2BSYTQAY_js.isPaymentStatusFailure(normalized.status);
1383
1438
  }
1384
1439
  ensureNotAborted() {
1385
1440
  if (this.signal?.aborted) {
@@ -1450,7 +1505,7 @@ var CheckoutService = class {
1450
1505
  }
1451
1506
  async initializePayment(_orderId, _method) {
1452
1507
  return err(
1453
- new chunkRYQ5IPWX_js.CimplifyError(
1508
+ new chunk2BSYTQAY_js.CimplifyError(
1454
1509
  "NOT_IMPLEMENTED",
1455
1510
  "initializePayment is not available in REST mode.",
1456
1511
  false
@@ -1522,11 +1577,11 @@ var CheckoutService = class {
1522
1577
  pay_currency: data.pay_currency,
1523
1578
  fx_quote_id: data.fx_quote_id
1524
1579
  };
1525
- const baseCurrency = chunkRYQ5IPWX_js.currencyCode(
1580
+ const baseCurrency = chunk2BSYTQAY_js.currencyCode(
1526
1581
  (cart.pricing.currency || checkoutData.pay_currency || "GHS").toUpperCase()
1527
1582
  );
1528
1583
  const payCurrency = data.pay_currency?.trim().toUpperCase();
1529
- const payCurrencyCode = payCurrency ? chunkRYQ5IPWX_js.currencyCode(payCurrency) : void 0;
1584
+ const payCurrencyCode = payCurrency ? chunk2BSYTQAY_js.currencyCode(payCurrency) : void 0;
1530
1585
  const cartTotalAmount = typeof cart.pricing.total_price === "number" ? cart.pricing.total_price : Number.parseFloat(cart.pricing.total_price || "0");
1531
1586
  if (payCurrencyCode && payCurrencyCode !== baseCurrency && !checkoutData.fx_quote_id && Number.isFinite(cartTotalAmount) && cartTotalAmount > 0) {
1532
1587
  const fxQuoteResult = await this.client.fx.lockQuote({
@@ -1849,7 +1904,7 @@ var BusinessService = class {
1849
1904
  if (!result.ok) return err(result.error);
1850
1905
  const location = result.value.find((item) => item.id === locationId);
1851
1906
  if (!location) {
1852
- return err(new chunkRYQ5IPWX_js.CimplifyError(chunkRYQ5IPWX_js.ErrorCode.NOT_FOUND, `Location not found: ${locationId}`, false));
1907
+ return err(new chunk2BSYTQAY_js.CimplifyError(chunk2BSYTQAY_js.ErrorCode.NOT_FOUND, `Location not found: ${locationId}`, false));
1853
1908
  }
1854
1909
  return ok(location);
1855
1910
  }
@@ -2123,7 +2178,7 @@ var EVENT_TYPES = {
2123
2178
 
2124
2179
  // src/elements.ts
2125
2180
  function toCheckoutError(code, message, recoverable) {
2126
- const hint = chunkRYQ5IPWX_js.getErrorHint(code);
2181
+ const hint = chunk2BSYTQAY_js.getErrorHint(code);
2127
2182
  return {
2128
2183
  success: false,
2129
2184
  error: {
@@ -2832,6 +2887,7 @@ exports.isOk = isOk;
2832
2887
  exports.mapError = mapError;
2833
2888
  exports.mapResult = mapResult;
2834
2889
  exports.ok = ok;
2890
+ exports.safe = safe;
2835
2891
  exports.toNullable = toNullable;
2836
2892
  exports.tryCatch = tryCatch;
2837
2893
  exports.unwrap = unwrap;