@cimplify/sdk 0.51.1 → 0.52.1
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 +1 -1
- package/dist/advanced.d.ts +1 -1
- package/dist/advanced.js +23 -22
- package/dist/advanced.mjs +4 -3
- package/dist/chunk-3G6RQLXK.mjs +21 -0
- package/dist/{chunk-GUZXQSGI.mjs → chunk-4QDCMYYB.mjs} +10 -21
- package/dist/{chunk-CAG3TEXO.js → chunk-7A3D3LFI.js} +4 -4
- package/dist/{chunk-6RP6OPYO.js → chunk-7Y2O3E4D.js} +3 -3
- package/dist/{chunk-Z2AYLZDF.mjs → chunk-AMZXALF6.mjs} +1 -21
- package/dist/{chunk-VOWMB2KR.js → chunk-EQLT46ZR.js} +75 -78
- package/dist/{chunk-FXACV333.mjs → chunk-GLAVTDDE.mjs} +55 -58
- package/dist/chunk-OWW5GUSB.js +28 -0
- package/dist/{chunk-GEWFWQYK.js → chunk-Q5VGDCQF.js} +235 -234
- package/dist/{chunk-632JEJUS.mjs → chunk-R3F55BRN.mjs} +2 -1
- package/dist/{chunk-QCS6D4XW.mjs → chunk-RDORJT7Y.mjs} +2 -2
- package/dist/{chunk-XY2DFX5K.mjs → chunk-TD3AY34U.mjs} +1 -1
- package/dist/{chunk-FJQC4VSN.js → chunk-W6CCBNGL.js} +68 -79
- package/dist/{chunk-TKOTACKZ.js → chunk-XA3ZNR75.js} +0 -26
- package/dist/{client-CF2pmEE9.d.mts → client-C6J_RGlr.d.mts} +27 -45
- package/dist/{client-B6x53-Al.d.ts → client-CX7IFIkL.d.ts} +27 -45
- package/dist/{client-BbrCopIS.d.mts → client-DdefKjcs.d.mts} +1 -1
- package/dist/{client-BvEjhvwq.d.ts → client-Lt7uGLmT.d.ts} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +110 -109
- package/dist/index.mjs +5 -4
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +86 -85
- package/dist/react.mjs +5 -4
- package/dist/server/evict.d.mts +31 -0
- package/dist/server/evict.d.ts +31 -0
- package/dist/server/evict.js +75 -0
- package/dist/server/evict.mjs +73 -0
- package/dist/server.d.mts +11 -48
- package/dist/server.d.ts +11 -48
- package/dist/server.js +7 -76
- package/dist/server.mjs +6 -74
- package/dist/testing/msw.js +4 -3
- package/dist/testing/msw.mjs +3 -2
- package/dist/testing/suite.d.mts +2 -2
- package/dist/testing/suite.d.ts +2 -2
- package/dist/testing/suite.js +26 -25
- package/dist/testing/suite.mjs +7 -6
- package/dist/testing.d.mts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +82 -81
- package/dist/testing.mjs +8 -7
- package/dist/utils.js +30 -29
- package/dist/utils.mjs +3 -2
- package/package.json +7 -1
package/dist/advanced.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AuthService, B as BusinessService,
|
|
1
|
+
export { A as AuthService, B as BusinessService, k as CartOperations, b as CatalogueQueries, m as CheckoutOperations, m as CheckoutService, a7 as CimplifyElement, a6 as CimplifyElements, ab as ELEMENT_TYPES, aa as EVENT_TYPES, af as ElementEventType, ad as ElementOptions, ae as ElementType, ac as ElementsOptions, F as FetchQuoteInput, s as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, r as LiteService, a9 as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, g as QuoteDynamicBuckets, f as QuoteStatus, h as QuoteUiMessage, e as RefreshQuoteInput, j as RefreshQuoteResult, q as SchedulingService, a8 as createElements } from './client-C6J_RGlr.mjs';
|
|
2
2
|
import './product-C-xLzh7Q.mjs';
|
|
3
3
|
import './payment-9L_-GWqQ.mjs';
|
|
4
4
|
|
package/dist/advanced.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AuthService, B as BusinessService,
|
|
1
|
+
export { A as AuthService, B as BusinessService, k as CartOperations, b as CatalogueQueries, m as CheckoutOperations, m as CheckoutService, a7 as CimplifyElement, a6 as CimplifyElements, ab as ELEMENT_TYPES, aa as EVENT_TYPES, af as ElementEventType, ad as ElementOptions, ae as ElementType, ac as ElementsOptions, F as FetchQuoteInput, s as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, r as LiteService, a9 as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, g as QuoteDynamicBuckets, f as QuoteStatus, h as QuoteUiMessage, e as RefreshQuoteInput, j as RefreshQuoteResult, q as SchedulingService, a8 as createElements } from './client-CX7IFIkL.js';
|
|
2
2
|
import './product-C-xLzh7Q.js';
|
|
3
3
|
import './payment-_e99nSRj.js';
|
|
4
4
|
|
package/dist/advanced.js
CHANGED
|
@@ -1,84 +1,85 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var chunkEQLT46ZR_js = require('./chunk-EQLT46ZR.js');
|
|
4
|
+
require('./chunk-7Y2O3E4D.js');
|
|
5
|
+
require('./chunk-XA3ZNR75.js');
|
|
6
|
+
require('./chunk-OWW5GUSB.js');
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
Object.defineProperty(exports, "AuthService", {
|
|
10
11
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkEQLT46ZR_js.AuthService; }
|
|
12
13
|
});
|
|
13
14
|
Object.defineProperty(exports, "BusinessService", {
|
|
14
15
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkEQLT46ZR_js.BusinessService; }
|
|
16
17
|
});
|
|
17
18
|
Object.defineProperty(exports, "CartOperations", {
|
|
18
19
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunkEQLT46ZR_js.CartOperations; }
|
|
20
21
|
});
|
|
21
22
|
Object.defineProperty(exports, "CatalogueQueries", {
|
|
22
23
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunkEQLT46ZR_js.CatalogueQueries; }
|
|
24
25
|
});
|
|
25
26
|
Object.defineProperty(exports, "CheckoutOperations", {
|
|
26
27
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkEQLT46ZR_js.CheckoutService; }
|
|
28
29
|
});
|
|
29
30
|
Object.defineProperty(exports, "CheckoutService", {
|
|
30
31
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkEQLT46ZR_js.CheckoutService; }
|
|
32
33
|
});
|
|
33
34
|
Object.defineProperty(exports, "CimplifyElement", {
|
|
34
35
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
36
|
+
get: function () { return chunkEQLT46ZR_js.CimplifyElement; }
|
|
36
37
|
});
|
|
37
38
|
Object.defineProperty(exports, "CimplifyElements", {
|
|
38
39
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
40
|
+
get: function () { return chunkEQLT46ZR_js.CimplifyElements; }
|
|
40
41
|
});
|
|
41
42
|
Object.defineProperty(exports, "ELEMENT_TYPES", {
|
|
42
43
|
enumerable: true,
|
|
43
|
-
get: function () { return
|
|
44
|
+
get: function () { return chunkEQLT46ZR_js.ELEMENT_TYPES; }
|
|
44
45
|
});
|
|
45
46
|
Object.defineProperty(exports, "EVENT_TYPES", {
|
|
46
47
|
enumerable: true,
|
|
47
|
-
get: function () { return
|
|
48
|
+
get: function () { return chunkEQLT46ZR_js.EVENT_TYPES; }
|
|
48
49
|
});
|
|
49
50
|
Object.defineProperty(exports, "FxService", {
|
|
50
51
|
enumerable: true,
|
|
51
|
-
get: function () { return
|
|
52
|
+
get: function () { return chunkEQLT46ZR_js.FxService; }
|
|
52
53
|
});
|
|
53
54
|
Object.defineProperty(exports, "InventoryService", {
|
|
54
55
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
56
|
+
get: function () { return chunkEQLT46ZR_js.InventoryService; }
|
|
56
57
|
});
|
|
57
58
|
Object.defineProperty(exports, "LinkService", {
|
|
58
59
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
60
|
+
get: function () { return chunkEQLT46ZR_js.LinkService; }
|
|
60
61
|
});
|
|
61
62
|
Object.defineProperty(exports, "LiteService", {
|
|
62
63
|
enumerable: true,
|
|
63
|
-
get: function () { return
|
|
64
|
+
get: function () { return chunkEQLT46ZR_js.LiteService; }
|
|
64
65
|
});
|
|
65
66
|
Object.defineProperty(exports, "MESSAGE_TYPES", {
|
|
66
67
|
enumerable: true,
|
|
67
|
-
get: function () { return
|
|
68
|
+
get: function () { return chunkEQLT46ZR_js.MESSAGE_TYPES; }
|
|
68
69
|
});
|
|
69
70
|
Object.defineProperty(exports, "OrderQueries", {
|
|
70
71
|
enumerable: true,
|
|
71
|
-
get: function () { return
|
|
72
|
+
get: function () { return chunkEQLT46ZR_js.OrderQueries; }
|
|
72
73
|
});
|
|
73
74
|
Object.defineProperty(exports, "SchedulingService", {
|
|
74
75
|
enumerable: true,
|
|
75
|
-
get: function () { return
|
|
76
|
+
get: function () { return chunkEQLT46ZR_js.SchedulingService; }
|
|
76
77
|
});
|
|
77
78
|
Object.defineProperty(exports, "createElements", {
|
|
78
79
|
enumerable: true,
|
|
79
|
-
get: function () { return
|
|
80
|
+
get: function () { return chunkEQLT46ZR_js.createElements; }
|
|
80
81
|
});
|
|
81
82
|
Object.defineProperty(exports, "generateIdempotencyKey", {
|
|
82
83
|
enumerable: true,
|
|
83
|
-
get: function () { return
|
|
84
|
+
get: function () { return chunkEQLT46ZR_js.generateIdempotencyKey; }
|
|
84
85
|
});
|
package/dist/advanced.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { AuthService, BusinessService, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LinkService, LiteService, MESSAGE_TYPES, OrderQueries, SchedulingService, createElements, generateIdempotencyKey } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { AuthService, BusinessService, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LinkService, LiteService, MESSAGE_TYPES, OrderQueries, SchedulingService, createElements, generateIdempotencyKey } from './chunk-GLAVTDDE.mjs';
|
|
2
|
+
import './chunk-TD3AY34U.mjs';
|
|
3
|
+
import './chunk-AMZXALF6.mjs';
|
|
4
|
+
import './chunk-3G6RQLXK.mjs';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
13
|
+
set _(value) {
|
|
14
|
+
__privateSet(obj, member, value, setter);
|
|
15
|
+
},
|
|
16
|
+
get _() {
|
|
17
|
+
return __privateGet(obj, member, getter);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export { __privateAdd, __privateGet, __privateMethod, __privateSet, __privateWrapper, __publicField };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { safe, generateIdempotencyKey, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-
|
|
2
|
-
import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-
|
|
1
|
+
import { safe, generateIdempotencyKey, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-GLAVTDDE.mjs';
|
|
2
|
+
import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-AMZXALF6.mjs';
|
|
3
3
|
|
|
4
4
|
// src/activity.ts
|
|
5
5
|
var ActivityService = class {
|
|
@@ -282,14 +282,6 @@ var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
|
282
282
|
function sleep(ms) {
|
|
283
283
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
284
284
|
}
|
|
285
|
-
function nextInit(cacheOptions) {
|
|
286
|
-
if (!cacheOptions) return {};
|
|
287
|
-
const next = {};
|
|
288
|
-
if (cacheOptions.revalidate !== void 0) next.revalidate = cacheOptions.revalidate;
|
|
289
|
-
if (cacheOptions.tags && cacheOptions.tags.length > 0) next.tags = [...cacheOptions.tags];
|
|
290
|
-
if (next.revalidate === void 0 && !next.tags) return {};
|
|
291
|
-
return { next };
|
|
292
|
-
}
|
|
293
285
|
function mergeOptionHeaders(base, opts) {
|
|
294
286
|
if (!opts) return base;
|
|
295
287
|
const merged = { ...base };
|
|
@@ -706,9 +698,8 @@ var CimplifyClient = class {
|
|
|
706
698
|
});
|
|
707
699
|
throw finalError;
|
|
708
700
|
}
|
|
709
|
-
getDedupeKey(type, payload
|
|
710
|
-
|
|
711
|
-
return `${type}:${JSON.stringify(payload)}${cacheKey}`;
|
|
701
|
+
getDedupeKey(type, payload) {
|
|
702
|
+
return `${type}:${JSON.stringify(payload)}`;
|
|
712
703
|
}
|
|
713
704
|
async deduplicatedRequest(key, requestFn) {
|
|
714
705
|
const existing = this.inflightRequests.get(key);
|
|
@@ -721,14 +712,13 @@ var CimplifyClient = class {
|
|
|
721
712
|
this.inflightRequests.set(key, request);
|
|
722
713
|
return request;
|
|
723
714
|
}
|
|
724
|
-
async get(path
|
|
725
|
-
const key = this.getDedupeKey("get", path
|
|
715
|
+
async get(path) {
|
|
716
|
+
const key = this.getDedupeKey("get", path);
|
|
726
717
|
return this.deduplicatedRequest(key, async () => {
|
|
727
718
|
const response = await this.resilientFetch(this.buildUrl(this.baseUrl, path), {
|
|
728
719
|
method: "GET",
|
|
729
720
|
credentials: this.credentials,
|
|
730
|
-
headers: this.getHeaders()
|
|
731
|
-
...nextInit(opts?.cacheOptions)
|
|
721
|
+
headers: this.getHeaders()
|
|
732
722
|
});
|
|
733
723
|
return this.handleRestResponse(response);
|
|
734
724
|
});
|
|
@@ -759,14 +749,13 @@ var CimplifyClient = class {
|
|
|
759
749
|
});
|
|
760
750
|
return this.handleRestResponse(response);
|
|
761
751
|
}
|
|
762
|
-
async linkGet(path
|
|
763
|
-
const key = this.getDedupeKey("linkGet", path
|
|
752
|
+
async linkGet(path) {
|
|
753
|
+
const key = this.getDedupeKey("linkGet", path);
|
|
764
754
|
return this.deduplicatedRequest(key, async () => {
|
|
765
755
|
const response = await this.resilientFetch(`${this.linkApiUrl}${path}`, {
|
|
766
756
|
method: "GET",
|
|
767
757
|
credentials: this.credentials,
|
|
768
|
-
headers: this.getHeaders()
|
|
769
|
-
...nextInit(opts?.cacheOptions)
|
|
758
|
+
headers: this.getHeaders()
|
|
770
759
|
});
|
|
771
760
|
return this.handleRestResponse(response);
|
|
772
761
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkQ5VGDCQF_js = require('./chunk-Q5VGDCQF.js');
|
|
4
|
+
var chunkW6CCBNGL_js = require('./chunk-W6CCBNGL.js');
|
|
5
5
|
var zod = require('zod');
|
|
6
6
|
|
|
7
7
|
var cimplifyRegistry = zod.z.registry();
|
|
@@ -595,7 +595,7 @@ async function toForwardedRequest(input, init) {
|
|
|
595
595
|
};
|
|
596
596
|
}
|
|
597
597
|
function createTestClient(options = {}) {
|
|
598
|
-
const mock =
|
|
598
|
+
const mock = chunkQ5VGDCQF_js.createMockApp(options);
|
|
599
599
|
let sessionToken;
|
|
600
600
|
const fetchImpl = async (input, init) => {
|
|
601
601
|
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
@@ -614,7 +614,7 @@ function createTestClient(options = {}) {
|
|
|
614
614
|
if (echoed) sessionToken = echoed;
|
|
615
615
|
return res;
|
|
616
616
|
};
|
|
617
|
-
const client =
|
|
617
|
+
const client = chunkW6CCBNGL_js.createCimplifyClient({
|
|
618
618
|
baseUrl: TEST_BASE_URL,
|
|
619
619
|
// Link mock lives at /v1/link on the same Hono app, so point the SDK's
|
|
620
620
|
// separate Link transport at the same TEST_BASE_URL.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkXA3ZNR75_js = require('./chunk-XA3ZNR75.js');
|
|
4
4
|
|
|
5
5
|
// src/utils/price.ts
|
|
6
6
|
var CURRENCY_SYMBOLS = {
|
|
@@ -440,14 +440,14 @@ function normalizeStatusResponse(response) {
|
|
|
440
440
|
return {
|
|
441
441
|
status: "pending",
|
|
442
442
|
paid: false,
|
|
443
|
-
amount:
|
|
443
|
+
amount: chunkXA3ZNR75_js.moneyFromNumber(0),
|
|
444
444
|
currency: "",
|
|
445
445
|
message: "No status available"
|
|
446
446
|
};
|
|
447
447
|
}
|
|
448
448
|
const res = response;
|
|
449
449
|
const normalizedStatus = normalizePaymentStatusValue(res.status ?? void 0);
|
|
450
|
-
const normalizedAmount = typeof res.amount === "string" ?
|
|
450
|
+
const normalizedAmount = typeof res.amount === "string" ? chunkXA3ZNR75_js.money(res.amount) : typeof res.amount === "number" && Number.isFinite(res.amount) ? chunkXA3ZNR75_js.moneyFromNumber(res.amount) : chunkXA3ZNR75_js.moneyFromNumber(0);
|
|
451
451
|
const normalizedCurrency = typeof res.currency === "string" && res.currency.trim().length > 0 ? res.currency : "";
|
|
452
452
|
const paidValue = res.paid === true;
|
|
453
453
|
const derivedPaid = paidValue || [
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __typeError = (msg) => {
|
|
3
|
-
throw TypeError(msg);
|
|
4
|
-
};
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
|
-
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
13
|
-
set _(value) {
|
|
14
|
-
__privateSet(obj, member, value, setter);
|
|
15
|
-
},
|
|
16
|
-
get _() {
|
|
17
|
-
return __privateGet(obj, member, getter);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
1
|
// src/types/common.ts
|
|
22
2
|
function money(value) {
|
|
23
3
|
return typeof value === "string" ? parseFloat(value) || 0 : value;
|
|
@@ -267,4 +247,4 @@ function isRetryableError(error) {
|
|
|
267
247
|
return false;
|
|
268
248
|
}
|
|
269
249
|
|
|
270
|
-
export { CimplifyError, ERROR_HINTS, ErrorCode, IdempotencyMismatchError, ZERO,
|
|
250
|
+
export { CimplifyError, ERROR_HINTS, ErrorCode, IdempotencyMismatchError, ZERO, currencyCode, enrichError, getErrorHint, isCimplifyError, isIdempotencyMismatchError, isQuoteConflictRequiringConsent, isQuoteError, isRetryableError, isSupportedCurrency, money, moneyFromNumber };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk7Y2O3E4D_js = require('./chunk-7Y2O3E4D.js');
|
|
4
|
+
var chunkXA3ZNR75_js = require('./chunk-XA3ZNR75.js');
|
|
5
5
|
|
|
6
6
|
// src/types/result.ts
|
|
7
7
|
function ok(value) {
|
|
@@ -85,11 +85,11 @@ function generateIdempotencyKey(prefix = "idem") {
|
|
|
85
85
|
|
|
86
86
|
// src/internal/safe.ts
|
|
87
87
|
function toCimplifyError(error) {
|
|
88
|
-
if (error instanceof
|
|
88
|
+
if (error instanceof chunkXA3ZNR75_js.CimplifyError) return chunkXA3ZNR75_js.enrichError(error);
|
|
89
89
|
if (error instanceof Error) {
|
|
90
|
-
return
|
|
90
|
+
return chunkXA3ZNR75_js.enrichError(new chunkXA3ZNR75_js.CimplifyError(chunkXA3ZNR75_js.ErrorCode.UNKNOWN_ERROR, error.message, false));
|
|
91
91
|
}
|
|
92
|
-
return
|
|
92
|
+
return chunkXA3ZNR75_js.enrichError(new chunkXA3ZNR75_js.CimplifyError(chunkXA3ZNR75_js.ErrorCode.UNKNOWN_ERROR, String(error), false));
|
|
93
93
|
}
|
|
94
94
|
async function safe(promise) {
|
|
95
95
|
try {
|
|
@@ -254,12 +254,12 @@ var CatalogueQueries = class {
|
|
|
254
254
|
constructor(client) {
|
|
255
255
|
this.client = client;
|
|
256
256
|
}
|
|
257
|
-
async getCatalogue(
|
|
258
|
-
const result = await safe(this.client.get("/api/v1/catalogue"
|
|
257
|
+
async getCatalogue() {
|
|
258
|
+
const result = await safe(this.client.get("/api/v1/catalogue"));
|
|
259
259
|
if (!result.ok) return result;
|
|
260
260
|
return ok(normalizeCatalogueSnapshot(result.value));
|
|
261
261
|
}
|
|
262
|
-
async getProducts(options
|
|
262
|
+
async getProducts(options) {
|
|
263
263
|
const path = withQuery("/api/v1/catalogue/products", {
|
|
264
264
|
category_id: options?.category,
|
|
265
265
|
taxonomy_id: options?.taxonomy,
|
|
@@ -277,13 +277,13 @@ var CatalogueQueries = class {
|
|
|
277
277
|
cursor: options?.cursor,
|
|
278
278
|
properties: options?.properties ? JSON.stringify(options.properties) : void 0
|
|
279
279
|
});
|
|
280
|
-
const result = await safe(this.client.get(path
|
|
280
|
+
const result = await safe(this.client.get(path));
|
|
281
281
|
if (!result.ok) return result;
|
|
282
282
|
return ok(normalizeCatalogueResult(result.value));
|
|
283
283
|
}
|
|
284
|
-
async getProduct(id
|
|
284
|
+
async getProduct(id) {
|
|
285
285
|
const encodedId = encodeURIComponent(id);
|
|
286
|
-
const result = await safe(this.client.get(`/api/v1/catalogue/products/${encodedId}
|
|
286
|
+
const result = await safe(this.client.get(`/api/v1/catalogue/products/${encodedId}`));
|
|
287
287
|
if (!result.ok) return result;
|
|
288
288
|
const payload = result.value;
|
|
289
289
|
const rawProduct = isRecord(payload.item) ? payload.item : payload;
|
|
@@ -293,15 +293,15 @@ var CatalogueQueries = class {
|
|
|
293
293
|
}
|
|
294
294
|
const addOnIds = rawProduct.add_on_ids;
|
|
295
295
|
if (Array.isArray(addOnIds) && addOnIds.length > 0) {
|
|
296
|
-
const addOnsResult = await this.getAddOns(product.id
|
|
296
|
+
const addOnsResult = await this.getAddOns(product.id);
|
|
297
297
|
if (addOnsResult.ok) {
|
|
298
298
|
product.add_ons = addOnsResult.value;
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
return ok(product);
|
|
302
302
|
}
|
|
303
|
-
async getProductBySlug(slug
|
|
304
|
-
return this.getProduct(slug
|
|
303
|
+
async getProductBySlug(slug) {
|
|
304
|
+
return this.getProduct(slug);
|
|
305
305
|
}
|
|
306
306
|
async getVariants(productId) {
|
|
307
307
|
const encodedId = encodeURIComponent(productId);
|
|
@@ -329,45 +329,45 @@ var CatalogueQueries = class {
|
|
|
329
329
|
)
|
|
330
330
|
);
|
|
331
331
|
}
|
|
332
|
-
async getAddOns(productId
|
|
332
|
+
async getAddOns(productId) {
|
|
333
333
|
const encodedId = encodeURIComponent(productId);
|
|
334
|
-
return safe(this.client.get(`/api/v1/catalogue/products/${encodedId}/add-ons
|
|
334
|
+
return safe(this.client.get(`/api/v1/catalogue/products/${encodedId}/add-ons`));
|
|
335
335
|
}
|
|
336
|
-
async getCategories(
|
|
337
|
-
return safe(this.client.get("/api/v1/catalogue/categories"
|
|
336
|
+
async getCategories() {
|
|
337
|
+
return safe(this.client.get("/api/v1/catalogue/categories"));
|
|
338
338
|
}
|
|
339
|
-
async getCategory(id
|
|
339
|
+
async getCategory(id) {
|
|
340
340
|
const encodedId = encodeURIComponent(id);
|
|
341
|
-
return safe(this.client.get(`/api/v1/catalogue/categories/${encodedId}
|
|
341
|
+
return safe(this.client.get(`/api/v1/catalogue/categories/${encodedId}`));
|
|
342
342
|
}
|
|
343
|
-
async getCategoryBySlug(slug
|
|
344
|
-
return this.getCategory(slug
|
|
343
|
+
async getCategoryBySlug(slug) {
|
|
344
|
+
return this.getCategory(slug);
|
|
345
345
|
}
|
|
346
|
-
async getCategoryProducts(categoryId, options
|
|
346
|
+
async getCategoryProducts(categoryId, options) {
|
|
347
347
|
const encodedId = encodeURIComponent(categoryId);
|
|
348
348
|
const path = withQuery(`/api/v1/catalogue/categories/${encodedId}/products`, {
|
|
349
349
|
limit: options?.limit,
|
|
350
350
|
offset: options?.offset
|
|
351
351
|
});
|
|
352
|
-
return safe(this.client.get(path
|
|
352
|
+
return safe(this.client.get(path));
|
|
353
353
|
}
|
|
354
|
-
async getCollections(
|
|
355
|
-
return safe(this.client.get("/api/v1/catalogue/collections"
|
|
354
|
+
async getCollections() {
|
|
355
|
+
return safe(this.client.get("/api/v1/catalogue/collections"));
|
|
356
356
|
}
|
|
357
|
-
async getCollection(id
|
|
357
|
+
async getCollection(id) {
|
|
358
358
|
const encodedId = encodeURIComponent(id);
|
|
359
|
-
return safe(this.client.get(`/api/v1/catalogue/collections/${encodedId}
|
|
359
|
+
return safe(this.client.get(`/api/v1/catalogue/collections/${encodedId}`));
|
|
360
360
|
}
|
|
361
|
-
async getCollectionBySlug(slug
|
|
362
|
-
return this.getCollection(slug
|
|
361
|
+
async getCollectionBySlug(slug) {
|
|
362
|
+
return this.getCollection(slug);
|
|
363
363
|
}
|
|
364
|
-
async getCollectionProducts(collectionId, options
|
|
364
|
+
async getCollectionProducts(collectionId, options) {
|
|
365
365
|
const encodedId = encodeURIComponent(collectionId);
|
|
366
366
|
const path = withQuery(`/api/v1/catalogue/collections/${encodedId}/products`, {
|
|
367
367
|
limit: options?.limit,
|
|
368
368
|
offset: options?.offset
|
|
369
369
|
});
|
|
370
|
-
return safe(this.client.get(path
|
|
370
|
+
return safe(this.client.get(path));
|
|
371
371
|
}
|
|
372
372
|
async searchCollections(query, limit = 20) {
|
|
373
373
|
const path = withQuery("/api/v1/catalogue/collections", { search: query, limit });
|
|
@@ -492,20 +492,17 @@ var CatalogueQueries = class {
|
|
|
492
492
|
})
|
|
493
493
|
);
|
|
494
494
|
}
|
|
495
|
-
async search(query, options
|
|
496
|
-
const result = await this.getProducts(
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
},
|
|
502
|
-
opts
|
|
503
|
-
);
|
|
495
|
+
async search(query, options) {
|
|
496
|
+
const result = await this.getProducts({
|
|
497
|
+
...options,
|
|
498
|
+
search: query,
|
|
499
|
+
limit: options?.limit ?? 20
|
|
500
|
+
});
|
|
504
501
|
if (!result.ok) return result;
|
|
505
502
|
return ok(result.value.items);
|
|
506
503
|
}
|
|
507
|
-
async searchProducts(query, options
|
|
508
|
-
return this.search(query, options
|
|
504
|
+
async searchProducts(query, options) {
|
|
505
|
+
return this.search(query, options);
|
|
509
506
|
}
|
|
510
507
|
async getMenu(options) {
|
|
511
508
|
const path = withQuery("/api/v1/catalogue/menu", {
|
|
@@ -651,7 +648,7 @@ var CartOperations = class {
|
|
|
651
648
|
if (typeof updates.quantity !== "number") {
|
|
652
649
|
return {
|
|
653
650
|
ok: false,
|
|
654
|
-
error: new
|
|
651
|
+
error: new chunkXA3ZNR75_js.CimplifyError(
|
|
655
652
|
"VALIDATION_ERROR",
|
|
656
653
|
"updateItem requires a quantity; richer mid-cart edits are not supported"
|
|
657
654
|
)
|
|
@@ -1096,7 +1093,7 @@ var CheckoutResolver = class {
|
|
|
1096
1093
|
}
|
|
1097
1094
|
}
|
|
1098
1095
|
}
|
|
1099
|
-
if (checkoutResult.requires_authorization ||
|
|
1096
|
+
if (checkoutResult.requires_authorization || chunk7Y2O3E4D_js.isPaymentStatusRequiresAction(checkoutResult.payment_status)) {
|
|
1100
1097
|
const authorization = await this.handleAuthorization({
|
|
1101
1098
|
authorizationType,
|
|
1102
1099
|
paymentReference,
|
|
@@ -1270,18 +1267,18 @@ var CheckoutResolver = class {
|
|
|
1270
1267
|
if (statusResult.value.reference) {
|
|
1271
1268
|
paymentReference = statusResult.value.reference;
|
|
1272
1269
|
}
|
|
1273
|
-
const normalized =
|
|
1274
|
-
if (normalized.paid ||
|
|
1270
|
+
const normalized = chunk7Y2O3E4D_js.normalizeStatusResponse(statusResult.value);
|
|
1271
|
+
if (normalized.paid || chunk7Y2O3E4D_js.isPaymentStatusSuccess(normalized.status)) {
|
|
1275
1272
|
return this.finalizeSuccess(latestCheckoutResult);
|
|
1276
1273
|
}
|
|
1277
|
-
if (
|
|
1274
|
+
if (chunk7Y2O3E4D_js.isPaymentStatusFailure(normalized.status)) {
|
|
1278
1275
|
return this.fail(
|
|
1279
1276
|
normalized.status ? normalized.status.toUpperCase() : "PAYMENT_FAILED",
|
|
1280
1277
|
normalized.message || "Payment failed during confirmation.",
|
|
1281
1278
|
false
|
|
1282
1279
|
);
|
|
1283
1280
|
}
|
|
1284
|
-
if (
|
|
1281
|
+
if (chunk7Y2O3E4D_js.isPaymentStatusRequiresAction(normalized.status)) {
|
|
1285
1282
|
const authorization = await this.handleAuthorization({
|
|
1286
1283
|
authorizationType,
|
|
1287
1284
|
paymentReference,
|
|
@@ -1312,8 +1309,8 @@ var CheckoutResolver = class {
|
|
|
1312
1309
|
try {
|
|
1313
1310
|
const finalResult = await this.client.checkout.pollPaymentStatus(input.orderId);
|
|
1314
1311
|
if (finalResult.ok) {
|
|
1315
|
-
const normalized =
|
|
1316
|
-
if (normalized.paid ||
|
|
1312
|
+
const normalized = chunk7Y2O3E4D_js.normalizeStatusResponse(finalResult.value);
|
|
1313
|
+
if (normalized.paid || chunk7Y2O3E4D_js.isPaymentStatusSuccess(normalized.status)) {
|
|
1317
1314
|
return this.finalizeSuccess(latestCheckoutResult);
|
|
1318
1315
|
}
|
|
1319
1316
|
}
|
|
@@ -1509,12 +1506,12 @@ var CheckoutResolver = class {
|
|
|
1509
1506
|
};
|
|
1510
1507
|
}
|
|
1511
1508
|
isSuccessfulStatus(status) {
|
|
1512
|
-
const normalized =
|
|
1513
|
-
return normalized.paid ||
|
|
1509
|
+
const normalized = chunk7Y2O3E4D_js.normalizeStatusResponse({ status, paid: false });
|
|
1510
|
+
return normalized.paid || chunk7Y2O3E4D_js.isPaymentStatusSuccess(normalized.status);
|
|
1514
1511
|
}
|
|
1515
1512
|
isFailureStatus(status) {
|
|
1516
|
-
const normalized =
|
|
1517
|
-
return
|
|
1513
|
+
const normalized = chunk7Y2O3E4D_js.normalizeStatusResponse({ status, paid: false });
|
|
1514
|
+
return chunk7Y2O3E4D_js.isPaymentStatusFailure(normalized.status);
|
|
1518
1515
|
}
|
|
1519
1516
|
ensureNotAborted() {
|
|
1520
1517
|
if (this.signal?.aborted) {
|
|
@@ -1573,7 +1570,7 @@ var CheckoutService = class {
|
|
|
1573
1570
|
}
|
|
1574
1571
|
async initializePayment(_orderId, _method) {
|
|
1575
1572
|
return err(
|
|
1576
|
-
new
|
|
1573
|
+
new chunkXA3ZNR75_js.CimplifyError(
|
|
1577
1574
|
"NOT_IMPLEMENTED",
|
|
1578
1575
|
"initializePayment is not available in REST mode.",
|
|
1579
1576
|
false
|
|
@@ -1645,11 +1642,11 @@ var CheckoutService = class {
|
|
|
1645
1642
|
pay_currency: data.pay_currency,
|
|
1646
1643
|
fx_quote_id: data.fx_quote_id
|
|
1647
1644
|
};
|
|
1648
|
-
const baseCurrency =
|
|
1645
|
+
const baseCurrency = chunkXA3ZNR75_js.currencyCode(
|
|
1649
1646
|
(cart.pricing.currency || checkoutData.pay_currency || "GHS").toUpperCase()
|
|
1650
1647
|
);
|
|
1651
1648
|
const payCurrency = data.pay_currency?.trim().toUpperCase();
|
|
1652
|
-
const payCurrencyCode = payCurrency ?
|
|
1649
|
+
const payCurrencyCode = payCurrency ? chunkXA3ZNR75_js.currencyCode(payCurrency) : void 0;
|
|
1653
1650
|
const cartTotalAmount = typeof cart.pricing.total_price === "number" ? cart.pricing.total_price : Number.parseFloat(cart.pricing.total_price || "0");
|
|
1654
1651
|
if (payCurrencyCode && payCurrencyCode !== baseCurrency && !checkoutData.fx_quote_id && Number.isFinite(cartTotalAmount) && cartTotalAmount > 0) {
|
|
1655
1652
|
const fxQuoteResult = await this.client.fx.lockQuote({
|
|
@@ -1960,42 +1957,42 @@ var BusinessService = class {
|
|
|
1960
1957
|
constructor(client) {
|
|
1961
1958
|
this.client = client;
|
|
1962
1959
|
}
|
|
1963
|
-
async getInfo(
|
|
1964
|
-
return safe(this.client.get("/api/v1/business"
|
|
1960
|
+
async getInfo() {
|
|
1961
|
+
return safe(this.client.get("/api/v1/business"));
|
|
1965
1962
|
}
|
|
1966
|
-
async getByHandle(handle
|
|
1963
|
+
async getByHandle(handle) {
|
|
1967
1964
|
const encodedHandle = encodeURIComponent(handle);
|
|
1968
|
-
return safe(this.client.get(`/api/v1/business/by-handle/${encodedHandle}
|
|
1965
|
+
return safe(this.client.get(`/api/v1/business/by-handle/${encodedHandle}`));
|
|
1969
1966
|
}
|
|
1970
|
-
async getByDomain(domain
|
|
1967
|
+
async getByDomain(domain) {
|
|
1971
1968
|
const encodedDomain = encodeURIComponent(domain);
|
|
1972
|
-
return safe(this.client.get(`/api/v1/business/by-domain?domain=${encodedDomain}
|
|
1969
|
+
return safe(this.client.get(`/api/v1/business/by-domain?domain=${encodedDomain}`));
|
|
1973
1970
|
}
|
|
1974
|
-
async getSettings(
|
|
1975
|
-
return safe(this.client.get("/api/v1/business/settings"
|
|
1971
|
+
async getSettings() {
|
|
1972
|
+
return safe(this.client.get("/api/v1/business/settings"));
|
|
1976
1973
|
}
|
|
1977
|
-
async getLocations(
|
|
1978
|
-
return safe(this.client.get("/api/v1/business/locations"
|
|
1974
|
+
async getLocations() {
|
|
1975
|
+
return safe(this.client.get("/api/v1/business/locations"));
|
|
1979
1976
|
}
|
|
1980
|
-
async getLocation(locationId
|
|
1981
|
-
const result = await this.getLocations(
|
|
1977
|
+
async getLocation(locationId) {
|
|
1978
|
+
const result = await this.getLocations();
|
|
1982
1979
|
if (!result.ok) return err(result.error);
|
|
1983
1980
|
const location = result.value.find((item) => item.id === locationId);
|
|
1984
1981
|
if (!location) {
|
|
1985
|
-
return err(new
|
|
1982
|
+
return err(new chunkXA3ZNR75_js.CimplifyError(chunkXA3ZNR75_js.ErrorCode.NOT_FOUND, `Location not found: ${locationId}`, false));
|
|
1986
1983
|
}
|
|
1987
1984
|
return ok(location);
|
|
1988
1985
|
}
|
|
1989
|
-
async getHours(
|
|
1990
|
-
return safe(this.client.get("/api/v1/business/hours"
|
|
1986
|
+
async getHours() {
|
|
1987
|
+
return safe(this.client.get("/api/v1/business/hours"));
|
|
1991
1988
|
}
|
|
1992
|
-
async getLocationHours(locationId
|
|
1993
|
-
const result = await this.getHours(
|
|
1989
|
+
async getLocationHours(locationId) {
|
|
1990
|
+
const result = await this.getHours();
|
|
1994
1991
|
if (!result.ok) return result;
|
|
1995
1992
|
return ok(result.value.filter((hour) => hour.location_id === locationId));
|
|
1996
1993
|
}
|
|
1997
|
-
async getBootstrap(
|
|
1998
|
-
return safe(this.client.get("/api/v1/bootstrap"
|
|
1994
|
+
async getBootstrap() {
|
|
1995
|
+
return safe(this.client.get("/api/v1/bootstrap"));
|
|
1999
1996
|
}
|
|
2000
1997
|
};
|
|
2001
1998
|
|
|
@@ -2269,7 +2266,7 @@ var EVENT_TYPES = {
|
|
|
2269
2266
|
|
|
2270
2267
|
// src/elements.ts
|
|
2271
2268
|
function toCheckoutError(code, message, recoverable) {
|
|
2272
|
-
const hint =
|
|
2269
|
+
const hint = chunkXA3ZNR75_js.getErrorHint(code);
|
|
2273
2270
|
return {
|
|
2274
2271
|
success: false,
|
|
2275
2272
|
error: {
|