@cimplify/sdk 0.19.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.
- package/dist/advanced.d.mts +2 -2
- package/dist/advanced.d.ts +2 -2
- package/dist/advanced.js +21 -21
- package/dist/advanced.mjs +2 -2
- package/dist/{chunk-RYQ5IPWX.js → chunk-2BSYTQAY.js} +18 -28
- package/dist/{chunk-AFEE43MQ.mjs → chunk-676BJ3EU.mjs} +43 -8
- package/dist/{chunk-7ACYNCNM.mjs → chunk-7KH2XJIW.mjs} +55 -12
- package/dist/{chunk-B2RTVYJR.js → chunk-AVVLN353.js} +76 -40
- package/dist/{chunk-FTL2SXCG.mjs → chunk-HG7GG3TT.mjs} +18 -28
- package/dist/{chunk-6SRY4DPY.js → chunk-KSN3RJFL.js} +74 -30
- package/dist/{client-FNZzXO_v.d.ts → client-D4E9aJy7.d.mts} +139 -7
- package/dist/{client-B3payjUV.d.mts → client-VyO6Bqz2.d.ts} +139 -7
- package/dist/index.d.mts +38 -5
- package/dist/index.d.ts +38 -5
- package/dist/index.js +101 -97
- package/dist/index.mjs +3 -3
- package/dist/{payment-CO2tRThu.d.mts → payment-CKqMU4xT.d.mts} +1051 -943
- package/dist/{payment-CO2tRThu.d.ts → payment-CKqMU4xT.d.ts} +1051 -943
- package/dist/{price-Bp6JlVzW.d.ts → price-BqV_DjjQ.d.mts} +1 -1
- package/dist/{price-Dg7MJEsL.d.mts → price-e4beObLZ.d.ts} +1 -1
- package/dist/react.d.mts +463 -11
- package/dist/react.d.ts +463 -11
- package/dist/react.js +1630 -113
- package/dist/react.mjs +1566 -65
- package/dist/styles.css +1 -1
- package/dist/utils.d.mts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +28 -28
- package/dist/utils.mjs +1 -1
- package/package.json +2 -2
- package/registry/availability-badge.json +1 -1
- package/registry/booking-page.json +1 -1
- package/registry/bundle-selector.json +1 -1
- package/registry/cart-summary.json +1 -1
- package/registry/composite-selector.json +1 -1
- package/registry/order-summary.json +1 -1
- package/registry/product-customizer.json +1 -1
- package/registry/search-input.json +1 -1
- package/registry/service-card.json +1 -1
- package/registry/variant-selector.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
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
|
-
|
|
33
|
-
|
|
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
|
|
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
|
|
73
|
-
new
|
|
74
|
-
|
|
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
|
|
83
|
-
new
|
|
84
|
-
|
|
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
|
|
92
|
-
return
|
|
120
|
+
if (error instanceof chunk2BSYTQAY_js.CimplifyError) {
|
|
121
|
+
return chunk2BSYTQAY_js.enrichError(error, { isTestMode });
|
|
93
122
|
}
|
|
94
|
-
return
|
|
95
|
-
new
|
|
96
|
-
|
|
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
|
|
264
|
-
|
|
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
|
|
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
|
|
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 =
|
|
539
|
-
new
|
|
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 ===
|
|
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 =
|
|
555
|
-
new
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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: "
|
|
554
|
-
done: "
|
|
555
|
-
paid: "
|
|
556
|
-
paid_in_full: "
|
|
557
|
-
paid_successfully: "
|
|
558
|
-
succeeded: "
|
|
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: "
|
|
561
|
-
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: "
|
|
565
|
-
requires_capture: "
|
|
566
|
-
partially_paid: "
|
|
567
|
-
partially_refunded: "
|
|
568
|
-
card_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
|
|
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
|
|
77
|
+
if (error instanceof chunk2BSYTQAY_js.CimplifyError) return chunk2BSYTQAY_js.enrichError(error);
|
|
78
78
|
if (error instanceof Error) {
|
|
79
|
-
return
|
|
79
|
+
return chunk2BSYTQAY_js.enrichError(new chunk2BSYTQAY_js.CimplifyError(chunk2BSYTQAY_js.ErrorCode.UNKNOWN_ERROR, error.message, false));
|
|
80
80
|
}
|
|
81
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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", {
|
|
@@ -973,7 +1016,7 @@ var CheckoutResolver = class {
|
|
|
973
1016
|
}
|
|
974
1017
|
}
|
|
975
1018
|
}
|
|
976
|
-
if (checkoutResult.requires_authorization ||
|
|
1019
|
+
if (checkoutResult.requires_authorization || chunk2BSYTQAY_js.isPaymentStatusRequiresAction(checkoutResult.payment_status)) {
|
|
977
1020
|
const authorization = await this.handleAuthorization({
|
|
978
1021
|
authorizationType,
|
|
979
1022
|
paymentReference,
|
|
@@ -1147,18 +1190,18 @@ var CheckoutResolver = class {
|
|
|
1147
1190
|
if (statusResult.value.reference) {
|
|
1148
1191
|
paymentReference = statusResult.value.reference;
|
|
1149
1192
|
}
|
|
1150
|
-
const normalized =
|
|
1151
|
-
if (normalized.paid ||
|
|
1193
|
+
const normalized = chunk2BSYTQAY_js.normalizeStatusResponse(statusResult.value);
|
|
1194
|
+
if (normalized.paid || chunk2BSYTQAY_js.isPaymentStatusSuccess(normalized.status)) {
|
|
1152
1195
|
return this.finalizeSuccess(latestCheckoutResult);
|
|
1153
1196
|
}
|
|
1154
|
-
if (
|
|
1197
|
+
if (chunk2BSYTQAY_js.isPaymentStatusFailure(normalized.status)) {
|
|
1155
1198
|
return this.fail(
|
|
1156
1199
|
normalized.status ? normalized.status.toUpperCase() : "PAYMENT_FAILED",
|
|
1157
1200
|
normalized.message || "Payment failed during confirmation.",
|
|
1158
1201
|
false
|
|
1159
1202
|
);
|
|
1160
1203
|
}
|
|
1161
|
-
if (
|
|
1204
|
+
if (chunk2BSYTQAY_js.isPaymentStatusRequiresAction(normalized.status)) {
|
|
1162
1205
|
const authorization = await this.handleAuthorization({
|
|
1163
1206
|
authorizationType,
|
|
1164
1207
|
paymentReference,
|
|
@@ -1189,8 +1232,8 @@ var CheckoutResolver = class {
|
|
|
1189
1232
|
try {
|
|
1190
1233
|
const finalResult = await this.client.checkout.pollPaymentStatus(input.orderId);
|
|
1191
1234
|
if (finalResult.ok) {
|
|
1192
|
-
const normalized =
|
|
1193
|
-
if (normalized.paid ||
|
|
1235
|
+
const normalized = chunk2BSYTQAY_js.normalizeStatusResponse(finalResult.value);
|
|
1236
|
+
if (normalized.paid || chunk2BSYTQAY_js.isPaymentStatusSuccess(normalized.status)) {
|
|
1194
1237
|
return this.finalizeSuccess(latestCheckoutResult);
|
|
1195
1238
|
}
|
|
1196
1239
|
}
|
|
@@ -1386,12 +1429,12 @@ var CheckoutResolver = class {
|
|
|
1386
1429
|
};
|
|
1387
1430
|
}
|
|
1388
1431
|
isSuccessfulStatus(status) {
|
|
1389
|
-
const normalized =
|
|
1390
|
-
return normalized.paid ||
|
|
1432
|
+
const normalized = chunk2BSYTQAY_js.normalizeStatusResponse({ status, paid: false });
|
|
1433
|
+
return normalized.paid || chunk2BSYTQAY_js.isPaymentStatusSuccess(normalized.status);
|
|
1391
1434
|
}
|
|
1392
1435
|
isFailureStatus(status) {
|
|
1393
|
-
const normalized =
|
|
1394
|
-
return
|
|
1436
|
+
const normalized = chunk2BSYTQAY_js.normalizeStatusResponse({ status, paid: false });
|
|
1437
|
+
return chunk2BSYTQAY_js.isPaymentStatusFailure(normalized.status);
|
|
1395
1438
|
}
|
|
1396
1439
|
ensureNotAborted() {
|
|
1397
1440
|
if (this.signal?.aborted) {
|
|
@@ -1462,7 +1505,7 @@ var CheckoutService = class {
|
|
|
1462
1505
|
}
|
|
1463
1506
|
async initializePayment(_orderId, _method) {
|
|
1464
1507
|
return err(
|
|
1465
|
-
new
|
|
1508
|
+
new chunk2BSYTQAY_js.CimplifyError(
|
|
1466
1509
|
"NOT_IMPLEMENTED",
|
|
1467
1510
|
"initializePayment is not available in REST mode.",
|
|
1468
1511
|
false
|
|
@@ -1534,11 +1577,11 @@ var CheckoutService = class {
|
|
|
1534
1577
|
pay_currency: data.pay_currency,
|
|
1535
1578
|
fx_quote_id: data.fx_quote_id
|
|
1536
1579
|
};
|
|
1537
|
-
const baseCurrency =
|
|
1580
|
+
const baseCurrency = chunk2BSYTQAY_js.currencyCode(
|
|
1538
1581
|
(cart.pricing.currency || checkoutData.pay_currency || "GHS").toUpperCase()
|
|
1539
1582
|
);
|
|
1540
1583
|
const payCurrency = data.pay_currency?.trim().toUpperCase();
|
|
1541
|
-
const payCurrencyCode = payCurrency ?
|
|
1584
|
+
const payCurrencyCode = payCurrency ? chunk2BSYTQAY_js.currencyCode(payCurrency) : void 0;
|
|
1542
1585
|
const cartTotalAmount = typeof cart.pricing.total_price === "number" ? cart.pricing.total_price : Number.parseFloat(cart.pricing.total_price || "0");
|
|
1543
1586
|
if (payCurrencyCode && payCurrencyCode !== baseCurrency && !checkoutData.fx_quote_id && Number.isFinite(cartTotalAmount) && cartTotalAmount > 0) {
|
|
1544
1587
|
const fxQuoteResult = await this.client.fx.lockQuote({
|
|
@@ -1861,7 +1904,7 @@ var BusinessService = class {
|
|
|
1861
1904
|
if (!result.ok) return err(result.error);
|
|
1862
1905
|
const location = result.value.find((item) => item.id === locationId);
|
|
1863
1906
|
if (!location) {
|
|
1864
|
-
return err(new
|
|
1907
|
+
return err(new chunk2BSYTQAY_js.CimplifyError(chunk2BSYTQAY_js.ErrorCode.NOT_FOUND, `Location not found: ${locationId}`, false));
|
|
1865
1908
|
}
|
|
1866
1909
|
return ok(location);
|
|
1867
1910
|
}
|
|
@@ -2135,7 +2178,7 @@ var EVENT_TYPES = {
|
|
|
2135
2178
|
|
|
2136
2179
|
// src/elements.ts
|
|
2137
2180
|
function toCheckoutError(code, message, recoverable) {
|
|
2138
|
-
const hint =
|
|
2181
|
+
const hint = chunk2BSYTQAY_js.getErrorHint(code);
|
|
2139
2182
|
return {
|
|
2140
2183
|
success: false,
|
|
2141
2184
|
error: {
|
|
@@ -2844,6 +2887,7 @@ exports.isOk = isOk;
|
|
|
2844
2887
|
exports.mapError = mapError;
|
|
2845
2888
|
exports.mapResult = mapResult;
|
|
2846
2889
|
exports.ok = ok;
|
|
2890
|
+
exports.safe = safe;
|
|
2847
2891
|
exports.toNullable = toNullable;
|
|
2848
2892
|
exports.tryCatch = tryCatch;
|
|
2849
2893
|
exports.unwrap = unwrap;
|