@cimplify/sdk 0.99.1 → 0.100.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 +3 -3
- package/dist/advanced.d.ts +3 -3
- package/dist/advanced.js +21 -21
- package/dist/advanced.mjs +2 -2
- package/dist/{chunk-PTPOQVXS.js → chunk-64EDCDBR.js} +5 -9
- package/dist/{chunk-XMDLF5Y6.mjs → chunk-GWKIDFN6.mjs} +1 -1
- package/dist/{chunk-BUPCMMRR.mjs → chunk-I7L4VRHI.mjs} +1 -1
- package/dist/{chunk-W5PH7SPK.js → chunk-J3UYIBKH.js} +47 -47
- package/dist/{chunk-VUSHG3HA.mjs → chunk-OX5L6XE7.mjs} +50 -6
- package/dist/{chunk-KFLGQGMC.mjs → chunk-V5TU5JKA.mjs} +5 -9
- package/dist/{chunk-VEOAMBEX.js → chunk-X6G6QERR.js} +60 -16
- package/dist/{chunk-WEEGNH7K.js → chunk-ZA5VKVUB.js} +2 -2
- package/dist/{client-BNfVL2IL.d.mts → client-B5MeD8da.d.mts} +2 -2
- package/dist/{client-CX59ew7C.d.ts → client-C1vS5pf0.d.ts} +2 -2
- package/dist/{client-BeMhSkRT.d.mts → client-DQpvwf-p.d.mts} +2 -2
- package/dist/{client-CCCOOaI3.d.ts → client-DmR3Z6pQ.d.ts} +2 -2
- package/dist/{index-D-w5h82t.d.ts → index-Br-vFygC.d.ts} +3 -3
- package/dist/{index-BuNjyfaV.d.mts → index-DUOCn1Cs.d.mts} +3 -3
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +100 -100
- package/dist/index.mjs +4 -4
- package/dist/{payment-pKPpaORI.d.mts → payment-BIpS9oPG.d.mts} +2 -2
- package/dist/{payment-By0JidTe.d.ts → payment-CsuBKHqg.d.ts} +2 -2
- package/dist/{price-BvRtp6ak.d.mts → price-IOOoVYS-.d.mts} +1 -1
- package/dist/{price-23RNXftz.d.ts → price-Ml_uPoiY.d.ts} +1 -1
- package/dist/{product-O8-wcHSe.d.mts → product-BKV6TBj_.d.mts} +26 -48
- package/dist/{product-O8-wcHSe.d.ts → product-BKV6TBj_.d.ts} +26 -48
- package/dist/react.d.mts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +130 -130
- package/dist/react.mjs +3 -3
- package/dist/{server-HVDbbqR9.d.mts → server-C0iEk55_.d.mts} +1 -1
- package/dist/{server-JBuTPY-j.d.ts → server-CfpYhSV_.d.ts} +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +8 -8
- package/dist/server.mjs +3 -3
- package/dist/testing/msw.d.mts +2 -2
- package/dist/testing/msw.d.ts +2 -2
- package/dist/testing/suite.d.mts +6 -6
- package/dist/testing/suite.d.ts +6 -6
- package/dist/testing/suite.js +23 -23
- package/dist/testing/suite.mjs +4 -4
- package/dist/testing.d.mts +5 -5
- package/dist/testing.d.ts +5 -5
- package/dist/testing.js +79 -79
- package/dist/testing.mjs +5 -5
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +28 -28
- package/dist/utils.mjs +1 -1
- package/package.json +1 -1
package/dist/advanced.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, ab as CheckoutOperations, ab as CheckoutService, ah as CimplifyElement, ai as CimplifyElements, aK as ELEMENT_TYPES, aL as EVENT_TYPES, aO as ElementEventType, aP as ElementOptions, aQ as ElementType, aY as ElementsOptions, b4 as FetchQuoteInput, bd as FxService, bh as GetProductsOptions, bk as InventoryService, bs as LinkService, by as LiteService, bF as MESSAGE_TYPES, c5 as OrderQueries, cr as PriceQuote, cx as QuoteBundleSelectionInput, cy as QuoteCompositeSelectionInput, cz as QuoteDynamicBuckets, cA as QuoteStatus, cB as QuoteUiMessage, cD as RefreshQuoteInput, cE as RefreshQuoteResult, d4 as SchedulingService, dK as createElements } from './client-
|
|
2
|
-
import './product-
|
|
3
|
-
import './payment-
|
|
1
|
+
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, ab as CheckoutOperations, ab as CheckoutService, ah as CimplifyElement, ai as CimplifyElements, aK as ELEMENT_TYPES, aL as EVENT_TYPES, aO as ElementEventType, aP as ElementOptions, aQ as ElementType, aY as ElementsOptions, b4 as FetchQuoteInput, bd as FxService, bh as GetProductsOptions, bk as InventoryService, bs as LinkService, by as LiteService, bF as MESSAGE_TYPES, c5 as OrderQueries, cr as PriceQuote, cx as QuoteBundleSelectionInput, cy as QuoteCompositeSelectionInput, cz as QuoteDynamicBuckets, cA as QuoteStatus, cB as QuoteUiMessage, cD as RefreshQuoteInput, cE as RefreshQuoteResult, d4 as SchedulingService, dK as createElements } from './client-B5MeD8da.mjs';
|
|
2
|
+
import './product-BKV6TBj_.mjs';
|
|
3
|
+
import './payment-BIpS9oPG.mjs';
|
|
4
4
|
|
|
5
5
|
declare function generateIdempotencyKey(prefix?: string): string;
|
|
6
6
|
|
package/dist/advanced.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, ab as CheckoutOperations, ab as CheckoutService, ah as CimplifyElement, ai as CimplifyElements, aK as ELEMENT_TYPES, aL as EVENT_TYPES, aO as ElementEventType, aP as ElementOptions, aQ as ElementType, aY as ElementsOptions, b4 as FetchQuoteInput, bd as FxService, bh as GetProductsOptions, bk as InventoryService, bs as LinkService, by as LiteService, bF as MESSAGE_TYPES, c5 as OrderQueries, cr as PriceQuote, cx as QuoteBundleSelectionInput, cy as QuoteCompositeSelectionInput, cz as QuoteDynamicBuckets, cA as QuoteStatus, cB as QuoteUiMessage, cD as RefreshQuoteInput, cE as RefreshQuoteResult, d4 as SchedulingService, dK as createElements } from './client-
|
|
2
|
-
import './product-
|
|
3
|
-
import './payment-
|
|
1
|
+
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, ab as CheckoutOperations, ab as CheckoutService, ah as CimplifyElement, ai as CimplifyElements, aK as ELEMENT_TYPES, aL as EVENT_TYPES, aO as ElementEventType, aP as ElementOptions, aQ as ElementType, aY as ElementsOptions, b4 as FetchQuoteInput, bd as FxService, bh as GetProductsOptions, bk as InventoryService, bs as LinkService, by as LiteService, bF as MESSAGE_TYPES, c5 as OrderQueries, cr as PriceQuote, cx as QuoteBundleSelectionInput, cy as QuoteCompositeSelectionInput, cz as QuoteDynamicBuckets, cA as QuoteStatus, cB as QuoteUiMessage, cD as RefreshQuoteInput, cE as RefreshQuoteResult, d4 as SchedulingService, dK as createElements } from './client-C1vS5pf0.js';
|
|
2
|
+
import './product-BKV6TBj_.js';
|
|
3
|
+
import './payment-CsuBKHqg.js';
|
|
4
4
|
|
|
5
5
|
declare function generateIdempotencyKey(prefix?: string): string;
|
|
6
6
|
|
package/dist/advanced.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkX6G6QERR_js = require('./chunk-X6G6QERR.js');
|
|
4
|
+
require('./chunk-64EDCDBR.js');
|
|
5
5
|
require('./chunk-AETVRBKI.js');
|
|
6
6
|
require('./chunk-OWW5GUSB.js');
|
|
7
7
|
|
|
@@ -9,77 +9,77 @@ require('./chunk-OWW5GUSB.js');
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "AuthService", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkX6G6QERR_js.AuthService; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "BusinessService", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkX6G6QERR_js.BusinessService; }
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "CartOperations", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunkX6G6QERR_js.CartOperations; }
|
|
21
21
|
});
|
|
22
22
|
Object.defineProperty(exports, "CatalogueQueries", {
|
|
23
23
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunkX6G6QERR_js.CatalogueQueries; }
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "CheckoutOperations", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkX6G6QERR_js.CheckoutService; }
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "CheckoutService", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkX6G6QERR_js.CheckoutService; }
|
|
33
33
|
});
|
|
34
34
|
Object.defineProperty(exports, "CimplifyElement", {
|
|
35
35
|
enumerable: true,
|
|
36
|
-
get: function () { return
|
|
36
|
+
get: function () { return chunkX6G6QERR_js.CimplifyElement; }
|
|
37
37
|
});
|
|
38
38
|
Object.defineProperty(exports, "CimplifyElements", {
|
|
39
39
|
enumerable: true,
|
|
40
|
-
get: function () { return
|
|
40
|
+
get: function () { return chunkX6G6QERR_js.CimplifyElements; }
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "ELEMENT_TYPES", {
|
|
43
43
|
enumerable: true,
|
|
44
|
-
get: function () { return
|
|
44
|
+
get: function () { return chunkX6G6QERR_js.ELEMENT_TYPES; }
|
|
45
45
|
});
|
|
46
46
|
Object.defineProperty(exports, "EVENT_TYPES", {
|
|
47
47
|
enumerable: true,
|
|
48
|
-
get: function () { return
|
|
48
|
+
get: function () { return chunkX6G6QERR_js.EVENT_TYPES; }
|
|
49
49
|
});
|
|
50
50
|
Object.defineProperty(exports, "FxService", {
|
|
51
51
|
enumerable: true,
|
|
52
|
-
get: function () { return
|
|
52
|
+
get: function () { return chunkX6G6QERR_js.FxService; }
|
|
53
53
|
});
|
|
54
54
|
Object.defineProperty(exports, "InventoryService", {
|
|
55
55
|
enumerable: true,
|
|
56
|
-
get: function () { return
|
|
56
|
+
get: function () { return chunkX6G6QERR_js.InventoryService; }
|
|
57
57
|
});
|
|
58
58
|
Object.defineProperty(exports, "LinkService", {
|
|
59
59
|
enumerable: true,
|
|
60
|
-
get: function () { return
|
|
60
|
+
get: function () { return chunkX6G6QERR_js.LinkService; }
|
|
61
61
|
});
|
|
62
62
|
Object.defineProperty(exports, "LiteService", {
|
|
63
63
|
enumerable: true,
|
|
64
|
-
get: function () { return
|
|
64
|
+
get: function () { return chunkX6G6QERR_js.LiteService; }
|
|
65
65
|
});
|
|
66
66
|
Object.defineProperty(exports, "MESSAGE_TYPES", {
|
|
67
67
|
enumerable: true,
|
|
68
|
-
get: function () { return
|
|
68
|
+
get: function () { return chunkX6G6QERR_js.MESSAGE_TYPES; }
|
|
69
69
|
});
|
|
70
70
|
Object.defineProperty(exports, "OrderQueries", {
|
|
71
71
|
enumerable: true,
|
|
72
|
-
get: function () { return
|
|
72
|
+
get: function () { return chunkX6G6QERR_js.OrderQueries; }
|
|
73
73
|
});
|
|
74
74
|
Object.defineProperty(exports, "SchedulingService", {
|
|
75
75
|
enumerable: true,
|
|
76
|
-
get: function () { return
|
|
76
|
+
get: function () { return chunkX6G6QERR_js.SchedulingService; }
|
|
77
77
|
});
|
|
78
78
|
Object.defineProperty(exports, "createElements", {
|
|
79
79
|
enumerable: true,
|
|
80
|
-
get: function () { return
|
|
80
|
+
get: function () { return chunkX6G6QERR_js.createElements; }
|
|
81
81
|
});
|
|
82
82
|
Object.defineProperty(exports, "generateIdempotencyKey", {
|
|
83
83
|
enumerable: true,
|
|
84
|
-
get: function () { return
|
|
84
|
+
get: function () { return chunkX6G6QERR_js.generateIdempotencyKey; }
|
|
85
85
|
});
|
package/dist/advanced.mjs
CHANGED
|
@@ -1,4 +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-
|
|
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-OX5L6XE7.mjs';
|
|
2
|
+
import './chunk-V5TU5JKA.mjs';
|
|
3
3
|
import './chunk-K5EN2W2Q.mjs';
|
|
4
4
|
import './chunk-3G6RQLXK.mjs';
|
|
@@ -356,7 +356,8 @@ var PAYMENT_SUCCESS_STATUSES = /* @__PURE__ */ new Set([
|
|
|
356
356
|
"paid",
|
|
357
357
|
"captured",
|
|
358
358
|
"completed",
|
|
359
|
-
"authorized"
|
|
359
|
+
"authorized",
|
|
360
|
+
"not_required"
|
|
360
361
|
]);
|
|
361
362
|
var PAYMENT_FAILURE_STATUSES = /* @__PURE__ */ new Set([
|
|
362
363
|
"failed",
|
|
@@ -381,6 +382,7 @@ var PAYMENT_STATUS_ALIAS_MAP = {
|
|
|
381
382
|
success: "captured",
|
|
382
383
|
captured: "captured",
|
|
383
384
|
completed: "captured",
|
|
385
|
+
not_required: "not_required",
|
|
384
386
|
pending_confirmation: "pending",
|
|
385
387
|
requires_authorization: "requires_action",
|
|
386
388
|
requires_action: "requires_action",
|
|
@@ -402,6 +404,7 @@ var KNOWN_PAYMENT_STATUSES = /* @__PURE__ */ new Set([
|
|
|
402
404
|
"processing",
|
|
403
405
|
"authorized",
|
|
404
406
|
"captured",
|
|
407
|
+
"not_required",
|
|
405
408
|
"failed",
|
|
406
409
|
"cancelled",
|
|
407
410
|
"refunded",
|
|
@@ -450,14 +453,7 @@ function normalizeStatusResponse(response) {
|
|
|
450
453
|
const normalizedAmount = typeof res.amount === "string" ? chunkAETVRBKI_js.money(res.amount) : typeof res.amount === "number" && Number.isFinite(res.amount) ? chunkAETVRBKI_js.moneyFromNumber(res.amount) : chunkAETVRBKI_js.moneyFromNumber(0);
|
|
451
454
|
const normalizedCurrency = typeof res.currency === "string" && res.currency.trim().length > 0 ? res.currency : "";
|
|
452
455
|
const paidValue = res.paid === true;
|
|
453
|
-
const derivedPaid = paidValue ||
|
|
454
|
-
"success",
|
|
455
|
-
"succeeded",
|
|
456
|
-
"paid",
|
|
457
|
-
"captured",
|
|
458
|
-
"authorized",
|
|
459
|
-
"completed"
|
|
460
|
-
].includes(normalizedStatus);
|
|
456
|
+
const derivedPaid = paidValue || PAYMENT_SUCCESS_STATUSES.has(normalizedStatus);
|
|
461
457
|
return {
|
|
462
458
|
status: normalizedStatus,
|
|
463
459
|
paid: derivedPaid,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { safe, generateIdempotencyKey, err, ok, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-
|
|
1
|
+
import { safe, generateIdempotencyKey, err, ok, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-OX5L6XE7.mjs';
|
|
2
2
|
import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-K5EN2W2Q.mjs';
|
|
3
3
|
|
|
4
4
|
// src/store-credit.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkX6G6QERR_js = require('./chunk-X6G6QERR.js');
|
|
4
4
|
var chunkAETVRBKI_js = require('./chunk-AETVRBKI.js');
|
|
5
5
|
|
|
6
6
|
// src/store-credit.ts
|
|
@@ -13,7 +13,7 @@ var StoreCreditQueries = class {
|
|
|
13
13
|
* currency. Requires a signed-in customer; returns an error otherwise.
|
|
14
14
|
*/
|
|
15
15
|
async balance() {
|
|
16
|
-
return
|
|
16
|
+
return chunkX6G6QERR_js.safe(this.client.get("/api/v1/store-credit/balance"));
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -105,7 +105,7 @@ var ActivityService = class {
|
|
|
105
105
|
this.sendEvents([event]);
|
|
106
106
|
}
|
|
107
107
|
async getState() {
|
|
108
|
-
return
|
|
108
|
+
return chunkX6G6QERR_js.safe(this.client.get("/api/v1/activity/state"));
|
|
109
109
|
}
|
|
110
110
|
async getRecommendations(options) {
|
|
111
111
|
const params = new URLSearchParams();
|
|
@@ -113,10 +113,10 @@ var ActivityService = class {
|
|
|
113
113
|
if (options?.limit) params.set("limit", String(options.limit));
|
|
114
114
|
const query = params.toString();
|
|
115
115
|
const path = query ? `/api/v1/activity/recommendations?${query}` : "/api/v1/activity/recommendations";
|
|
116
|
-
return
|
|
116
|
+
return chunkX6G6QERR_js.safe(this.client.get(path));
|
|
117
117
|
}
|
|
118
118
|
async dismissMessage(code) {
|
|
119
|
-
return
|
|
119
|
+
return chunkX6G6QERR_js.safe(
|
|
120
120
|
this.client.post("/api/v1/activity/messages/dismiss", { code })
|
|
121
121
|
);
|
|
122
122
|
}
|
|
@@ -189,16 +189,16 @@ var SubscriptionService = class {
|
|
|
189
189
|
this.client = client;
|
|
190
190
|
}
|
|
191
191
|
async list() {
|
|
192
|
-
return
|
|
192
|
+
return chunkX6G6QERR_js.safe(this.client.get("/api/v1/subscriptions"));
|
|
193
193
|
}
|
|
194
194
|
async get(id) {
|
|
195
195
|
const encodedId = encodeURIComponent(id);
|
|
196
|
-
return
|
|
196
|
+
return chunkX6G6QERR_js.safe(this.client.get(`/api/v1/subscriptions/${encodedId}`));
|
|
197
197
|
}
|
|
198
198
|
async cancel(id, reason, opts) {
|
|
199
199
|
const encodedId = encodeURIComponent(id);
|
|
200
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
201
|
-
return
|
|
200
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkX6G6QERR_js.generateIdempotencyKey();
|
|
201
|
+
return chunkX6G6QERR_js.safe(
|
|
202
202
|
this.client.post(
|
|
203
203
|
`/api/v1/subscriptions/${encodedId}/cancel`,
|
|
204
204
|
{ reason },
|
|
@@ -208,20 +208,20 @@ var SubscriptionService = class {
|
|
|
208
208
|
}
|
|
209
209
|
async pause(id) {
|
|
210
210
|
const encodedId = encodeURIComponent(id);
|
|
211
|
-
return
|
|
211
|
+
return chunkX6G6QERR_js.safe(
|
|
212
212
|
this.client.post(`/api/v1/subscriptions/${encodedId}/pause`)
|
|
213
213
|
);
|
|
214
214
|
}
|
|
215
215
|
async resume(id) {
|
|
216
216
|
const encodedId = encodeURIComponent(id);
|
|
217
|
-
return
|
|
217
|
+
return chunkX6G6QERR_js.safe(
|
|
218
218
|
this.client.post(`/api/v1/subscriptions/${encodedId}/resume`)
|
|
219
219
|
);
|
|
220
220
|
}
|
|
221
221
|
async skipNextRenewal(id, opts) {
|
|
222
222
|
const encodedId = encodeURIComponent(id);
|
|
223
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
224
|
-
return
|
|
223
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkX6G6QERR_js.generateIdempotencyKey();
|
|
224
|
+
return chunkX6G6QERR_js.safe(
|
|
225
225
|
this.client.post(
|
|
226
226
|
`/api/v1/subscriptions/${encodedId}/skip`,
|
|
227
227
|
void 0,
|
|
@@ -237,8 +237,8 @@ var UploadService = class {
|
|
|
237
237
|
this.client = client;
|
|
238
238
|
}
|
|
239
239
|
async init(filename, contentType, sizeBytes, opts) {
|
|
240
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
241
|
-
return
|
|
240
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkX6G6QERR_js.generateIdempotencyKey();
|
|
241
|
+
return chunkX6G6QERR_js.safe(
|
|
242
242
|
this.client.post(
|
|
243
243
|
"/api/v1/uploads/init",
|
|
244
244
|
{
|
|
@@ -251,7 +251,7 @@ var UploadService = class {
|
|
|
251
251
|
);
|
|
252
252
|
}
|
|
253
253
|
async confirm(uploadId) {
|
|
254
|
-
return
|
|
254
|
+
return chunkX6G6QERR_js.safe(
|
|
255
255
|
this.client.post("/api/v1/uploads/confirm", {
|
|
256
256
|
upload_id: uploadId
|
|
257
257
|
})
|
|
@@ -297,7 +297,7 @@ var PlacesService = class {
|
|
|
297
297
|
this.client = client;
|
|
298
298
|
}
|
|
299
299
|
async autocomplete(input, sessionToken) {
|
|
300
|
-
return
|
|
300
|
+
return chunkX6G6QERR_js.safe(
|
|
301
301
|
this.client.post("/api/v1/places/autocomplete", {
|
|
302
302
|
input,
|
|
303
303
|
sessionToken
|
|
@@ -305,7 +305,7 @@ var PlacesService = class {
|
|
|
305
305
|
);
|
|
306
306
|
}
|
|
307
307
|
async details(placeId, sessionToken) {
|
|
308
|
-
return
|
|
308
|
+
return chunkX6G6QERR_js.safe(
|
|
309
309
|
this.client.post("/api/v1/places/details", {
|
|
310
310
|
place_id: placeId,
|
|
311
311
|
sessionToken
|
|
@@ -324,7 +324,7 @@ var DeliveryService = class {
|
|
|
324
324
|
params.set("dropoff_lat", String(dropoffLat));
|
|
325
325
|
params.set("dropoff_lng", String(dropoffLng));
|
|
326
326
|
if (country) params.set("country", country);
|
|
327
|
-
return
|
|
327
|
+
return chunkX6G6QERR_js.safe(
|
|
328
328
|
this.client.get(`/api/v1/delivery/fee?${params.toString()}`)
|
|
329
329
|
);
|
|
330
330
|
}
|
|
@@ -336,7 +336,7 @@ var DeliveryService = class {
|
|
|
336
336
|
params.set("dropoff_lng", String(dropoffLng));
|
|
337
337
|
if (opts?.country) params.set("country", opts.country);
|
|
338
338
|
if (opts?.orderValue != null) params.set("order_value", String(opts.orderValue));
|
|
339
|
-
return
|
|
339
|
+
return chunkX6G6QERR_js.safe(
|
|
340
340
|
this.client.get(`/api/v1/delivery/options?${params.toString()}`)
|
|
341
341
|
);
|
|
342
342
|
}
|
|
@@ -413,7 +413,7 @@ var SupportService = class {
|
|
|
413
413
|
async claimConversation() {
|
|
414
414
|
const accessToken = this.client.getAccessToken();
|
|
415
415
|
if (!accessToken) {
|
|
416
|
-
return
|
|
416
|
+
return chunkX6G6QERR_js.err(new chunkAETVRBKI_js.CimplifyError("not_authenticated", "No access token to claim with"));
|
|
417
417
|
}
|
|
418
418
|
if (this.claimInFlight) {
|
|
419
419
|
if (this.claimInFlightToken === accessToken) return this.claimInFlight;
|
|
@@ -421,12 +421,12 @@ var SupportService = class {
|
|
|
421
421
|
return this.claimConversation();
|
|
422
422
|
}
|
|
423
423
|
if (this.lastClaimedAccessToken === accessToken) {
|
|
424
|
-
return
|
|
424
|
+
return chunkX6G6QERR_js.err(new chunkAETVRBKI_js.CimplifyError("already_claimed", "Session already claimed for this token"));
|
|
425
425
|
}
|
|
426
426
|
const epoch = this.client.getSessionEpoch();
|
|
427
427
|
this.claimInFlightToken = accessToken;
|
|
428
428
|
this.claimInFlight = (async () => {
|
|
429
|
-
const result = await
|
|
429
|
+
const result = await chunkX6G6QERR_js.safe(
|
|
430
430
|
this.client.post(
|
|
431
431
|
"/api/v1/support/conversation/claim",
|
|
432
432
|
{ access_token: accessToken },
|
|
@@ -435,7 +435,7 @@ var SupportService = class {
|
|
|
435
435
|
);
|
|
436
436
|
if (result.ok) {
|
|
437
437
|
if (this.client.getSessionEpoch() !== epoch) {
|
|
438
|
-
return
|
|
438
|
+
return chunkX6G6QERR_js.err(
|
|
439
439
|
new chunkAETVRBKI_js.CimplifyError("session_cleared", "Session was cleared during the claim")
|
|
440
440
|
);
|
|
441
441
|
}
|
|
@@ -464,20 +464,20 @@ var SupportService = class {
|
|
|
464
464
|
* the inbox with empty threads.
|
|
465
465
|
*/
|
|
466
466
|
async peekConversation() {
|
|
467
|
-
const result = await
|
|
467
|
+
const result = await chunkX6G6QERR_js.safe(
|
|
468
468
|
this.client.get("/api/v1/support/conversation")
|
|
469
469
|
);
|
|
470
470
|
if (!result.ok) return result;
|
|
471
|
-
if (!result.value.conversation) return
|
|
472
|
-
return
|
|
471
|
+
if (!result.value.conversation) return chunkX6G6QERR_js.ok(null);
|
|
472
|
+
return chunkX6G6QERR_js.ok({
|
|
473
473
|
conversation: result.value.conversation,
|
|
474
474
|
messages: result.value.messages
|
|
475
475
|
});
|
|
476
476
|
}
|
|
477
477
|
/** Open (or resume) the customer's widget conversation. */
|
|
478
478
|
async openConversation(opts) {
|
|
479
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
480
|
-
return
|
|
479
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkX6G6QERR_js.generateIdempotencyKey();
|
|
480
|
+
return chunkX6G6QERR_js.safe(
|
|
481
481
|
this.client.post("/api/v1/support/conversation", void 0, {
|
|
482
482
|
idempotencyKey
|
|
483
483
|
})
|
|
@@ -492,8 +492,8 @@ var SupportService = class {
|
|
|
492
492
|
* server resolves it thread-scoped and echoes the quote as `reply_to`.
|
|
493
493
|
*/
|
|
494
494
|
async sendMessage(content, opts) {
|
|
495
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
496
|
-
return
|
|
495
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkX6G6QERR_js.generateIdempotencyKey();
|
|
496
|
+
return chunkX6G6QERR_js.safe(
|
|
497
497
|
this.client.post(
|
|
498
498
|
"/api/v1/support/conversation/messages",
|
|
499
499
|
{
|
|
@@ -517,11 +517,11 @@ var SupportService = class {
|
|
|
517
517
|
if (options.limit) params.set("limit", String(options.limit));
|
|
518
518
|
const query = params.toString();
|
|
519
519
|
const path = query ? `/api/v1/support/conversation/messages?${query}` : "/api/v1/support/conversation/messages";
|
|
520
|
-
return
|
|
520
|
+
return chunkX6G6QERR_js.safe(this.client.get(path));
|
|
521
521
|
}
|
|
522
522
|
/** React to a message in the active conversation by its `ChatMessage.id`. */
|
|
523
523
|
async reactToMessage(messageId, emoji) {
|
|
524
|
-
return
|
|
524
|
+
return chunkX6G6QERR_js.safe(
|
|
525
525
|
this.client.post(
|
|
526
526
|
`/api/v1/support/conversation/messages/${messageId}/reactions`,
|
|
527
527
|
{ emoji }
|
|
@@ -530,8 +530,8 @@ var SupportService = class {
|
|
|
530
530
|
}
|
|
531
531
|
/** Ask for a person: flags the thread for the merchant's inbox. */
|
|
532
532
|
async requestHuman(opts) {
|
|
533
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
534
|
-
return
|
|
533
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkX6G6QERR_js.generateIdempotencyKey();
|
|
534
|
+
return chunkX6G6QERR_js.safe(
|
|
535
535
|
this.client.post(
|
|
536
536
|
"/api/v1/support/conversation/handoff",
|
|
537
537
|
void 0,
|
|
@@ -1250,25 +1250,25 @@ var CimplifyClient = class {
|
|
|
1250
1250
|
}
|
|
1251
1251
|
get catalogue() {
|
|
1252
1252
|
if (!this._catalogue) {
|
|
1253
|
-
this._catalogue = new
|
|
1253
|
+
this._catalogue = new chunkX6G6QERR_js.CatalogueQueries(this);
|
|
1254
1254
|
}
|
|
1255
1255
|
return this._catalogue;
|
|
1256
1256
|
}
|
|
1257
1257
|
get cart() {
|
|
1258
1258
|
if (!this._cart) {
|
|
1259
|
-
this._cart = new
|
|
1259
|
+
this._cart = new chunkX6G6QERR_js.CartOperations(this);
|
|
1260
1260
|
}
|
|
1261
1261
|
return this._cart;
|
|
1262
1262
|
}
|
|
1263
1263
|
get checkout() {
|
|
1264
1264
|
if (!this._checkout) {
|
|
1265
|
-
this._checkout = new
|
|
1265
|
+
this._checkout = new chunkX6G6QERR_js.CheckoutService(this);
|
|
1266
1266
|
}
|
|
1267
1267
|
return this._checkout;
|
|
1268
1268
|
}
|
|
1269
1269
|
get orders() {
|
|
1270
1270
|
if (!this._orders) {
|
|
1271
|
-
this._orders = new
|
|
1271
|
+
this._orders = new chunkX6G6QERR_js.OrderQueries(this);
|
|
1272
1272
|
}
|
|
1273
1273
|
return this._orders;
|
|
1274
1274
|
}
|
|
@@ -1298,43 +1298,43 @@ var CimplifyClient = class {
|
|
|
1298
1298
|
}
|
|
1299
1299
|
get link() {
|
|
1300
1300
|
if (!this._link) {
|
|
1301
|
-
this._link = new
|
|
1301
|
+
this._link = new chunkX6G6QERR_js.LinkService(this);
|
|
1302
1302
|
}
|
|
1303
1303
|
return this._link;
|
|
1304
1304
|
}
|
|
1305
1305
|
get auth() {
|
|
1306
1306
|
if (!this._auth) {
|
|
1307
|
-
this._auth = new
|
|
1307
|
+
this._auth = new chunkX6G6QERR_js.AuthService(this);
|
|
1308
1308
|
}
|
|
1309
1309
|
return this._auth;
|
|
1310
1310
|
}
|
|
1311
1311
|
get business() {
|
|
1312
1312
|
if (!this._business) {
|
|
1313
|
-
this._business = new
|
|
1313
|
+
this._business = new chunkX6G6QERR_js.BusinessService(this);
|
|
1314
1314
|
}
|
|
1315
1315
|
return this._business;
|
|
1316
1316
|
}
|
|
1317
1317
|
get inventory() {
|
|
1318
1318
|
if (!this._inventory) {
|
|
1319
|
-
this._inventory = new
|
|
1319
|
+
this._inventory = new chunkX6G6QERR_js.InventoryService(this);
|
|
1320
1320
|
}
|
|
1321
1321
|
return this._inventory;
|
|
1322
1322
|
}
|
|
1323
1323
|
get scheduling() {
|
|
1324
1324
|
if (!this._scheduling) {
|
|
1325
|
-
this._scheduling = new
|
|
1325
|
+
this._scheduling = new chunkX6G6QERR_js.SchedulingService(this);
|
|
1326
1326
|
}
|
|
1327
1327
|
return this._scheduling;
|
|
1328
1328
|
}
|
|
1329
1329
|
get lite() {
|
|
1330
1330
|
if (!this._lite) {
|
|
1331
|
-
this._lite = new
|
|
1331
|
+
this._lite = new chunkX6G6QERR_js.LiteService(this);
|
|
1332
1332
|
}
|
|
1333
1333
|
return this._lite;
|
|
1334
1334
|
}
|
|
1335
1335
|
get fx() {
|
|
1336
1336
|
if (!this._fx) {
|
|
1337
|
-
this._fx = new
|
|
1337
|
+
this._fx = new chunkX6G6QERR_js.FxService(this);
|
|
1338
1338
|
}
|
|
1339
1339
|
return this._fx;
|
|
1340
1340
|
}
|
|
@@ -1369,7 +1369,7 @@ var CimplifyClient = class {
|
|
|
1369
1369
|
if (businessId) {
|
|
1370
1370
|
this.setBusinessId(businessId);
|
|
1371
1371
|
}
|
|
1372
|
-
return
|
|
1372
|
+
return chunkX6G6QERR_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
|
|
1373
1373
|
}
|
|
1374
1374
|
};
|
|
1375
1375
|
function createCimplifyClient(config = {}) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isPaymentStatusRequiresAction, normalizeStatusResponse, isPaymentStatusSuccess, isPaymentStatusFailure } from './chunk-
|
|
2
|
-
import { CimplifyError,
|
|
1
|
+
import { isPaymentStatusRequiresAction, normalizeStatusResponse, isPaymentStatusSuccess, isPaymentStatusFailure } from './chunk-V5TU5JKA.mjs';
|
|
2
|
+
import { CimplifyError, ErrorCode, currencyCode, enrichError, getErrorHint } from './chunk-K5EN2W2Q.mjs';
|
|
3
3
|
|
|
4
4
|
// src/types/result.ts
|
|
5
5
|
function ok(value) {
|
|
@@ -80,6 +80,37 @@ function generateIdempotencyKey(prefix = "idem") {
|
|
|
80
80
|
const random = Math.random().toString(36).substring(2, 15);
|
|
81
81
|
return `${prefix}_${timestamp}_${random}`;
|
|
82
82
|
}
|
|
83
|
+
var INTENT_PREFIX = "cimplify-intent:";
|
|
84
|
+
function sessionStorageOrNull() {
|
|
85
|
+
try {
|
|
86
|
+
return typeof window !== "undefined" ? window.sessionStorage : null;
|
|
87
|
+
} catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function intentIdempotencyKey(scope, fingerprint, storage = sessionStorageOrNull()) {
|
|
92
|
+
const slot = INTENT_PREFIX + scope;
|
|
93
|
+
try {
|
|
94
|
+
const raw = storage?.getItem(slot);
|
|
95
|
+
if (raw) {
|
|
96
|
+
const stored = JSON.parse(raw);
|
|
97
|
+
if (stored.fingerprint === fingerprint && typeof stored.key === "string") return stored.key;
|
|
98
|
+
}
|
|
99
|
+
} catch {
|
|
100
|
+
}
|
|
101
|
+
const key = generateIdempotencyKey();
|
|
102
|
+
try {
|
|
103
|
+
storage?.setItem(slot, JSON.stringify({ key, fingerprint }));
|
|
104
|
+
} catch {
|
|
105
|
+
}
|
|
106
|
+
return key;
|
|
107
|
+
}
|
|
108
|
+
function clearIntentIdempotencyKey(scope, storage = sessionStorageOrNull()) {
|
|
109
|
+
try {
|
|
110
|
+
storage?.removeItem(INTENT_PREFIX + scope);
|
|
111
|
+
} catch {
|
|
112
|
+
}
|
|
113
|
+
}
|
|
83
114
|
|
|
84
115
|
// src/internal/safe.ts
|
|
85
116
|
function toCimplifyError(error) {
|
|
@@ -1588,13 +1619,26 @@ var CheckoutService = class {
|
|
|
1588
1619
|
if (invalid) {
|
|
1589
1620
|
return err(invalid);
|
|
1590
1621
|
}
|
|
1622
|
+
const intentScope = `checkout:${data.cart_id}`;
|
|
1623
|
+
const intentFingerprint = JSON.stringify([
|
|
1624
|
+
data.payment_method,
|
|
1625
|
+
data.mobile_money_details,
|
|
1626
|
+
data.pay_currency,
|
|
1627
|
+
data.voucher_code,
|
|
1628
|
+
data.pay_deposit
|
|
1629
|
+
]);
|
|
1591
1630
|
const checkoutData = {
|
|
1592
1631
|
...data,
|
|
1593
|
-
idempotency_key: data.idempotency_key ||
|
|
1632
|
+
idempotency_key: data.idempotency_key || intentIdempotencyKey(intentScope, intentFingerprint)
|
|
1594
1633
|
};
|
|
1595
1634
|
const result = await safe(this.client.post("/api/v1/checkout", checkoutData));
|
|
1596
|
-
if (result.ok
|
|
1597
|
-
|
|
1635
|
+
if (result.ok) {
|
|
1636
|
+
clearIntentIdempotencyKey(intentScope);
|
|
1637
|
+
if (result.value.bill_token) {
|
|
1638
|
+
this.client.setOrderToken(result.value.order_id, result.value.bill_token);
|
|
1639
|
+
}
|
|
1640
|
+
} else if (result.error.code !== ErrorCode.NETWORK_ERROR && result.error.code !== ErrorCode.TIMEOUT) {
|
|
1641
|
+
clearIntentIdempotencyKey(intentScope);
|
|
1598
1642
|
}
|
|
1599
1643
|
return result;
|
|
1600
1644
|
}
|
|
@@ -1668,7 +1712,7 @@ var CheckoutService = class {
|
|
|
1668
1712
|
special_instructions: data.special_instructions,
|
|
1669
1713
|
link_address_id: data.link_address_id,
|
|
1670
1714
|
link_payment_method_id: data.link_payment_method_id,
|
|
1671
|
-
idempotency_key: data.idempotency_key
|
|
1715
|
+
idempotency_key: data.idempotency_key,
|
|
1672
1716
|
metadata: data.metadata,
|
|
1673
1717
|
pay_currency: data.pay_currency,
|
|
1674
1718
|
fx_quote_id: data.fx_quote_id,
|
|
@@ -354,7 +354,8 @@ var PAYMENT_SUCCESS_STATUSES = /* @__PURE__ */ new Set([
|
|
|
354
354
|
"paid",
|
|
355
355
|
"captured",
|
|
356
356
|
"completed",
|
|
357
|
-
"authorized"
|
|
357
|
+
"authorized",
|
|
358
|
+
"not_required"
|
|
358
359
|
]);
|
|
359
360
|
var PAYMENT_FAILURE_STATUSES = /* @__PURE__ */ new Set([
|
|
360
361
|
"failed",
|
|
@@ -379,6 +380,7 @@ var PAYMENT_STATUS_ALIAS_MAP = {
|
|
|
379
380
|
success: "captured",
|
|
380
381
|
captured: "captured",
|
|
381
382
|
completed: "captured",
|
|
383
|
+
not_required: "not_required",
|
|
382
384
|
pending_confirmation: "pending",
|
|
383
385
|
requires_authorization: "requires_action",
|
|
384
386
|
requires_action: "requires_action",
|
|
@@ -400,6 +402,7 @@ var KNOWN_PAYMENT_STATUSES = /* @__PURE__ */ new Set([
|
|
|
400
402
|
"processing",
|
|
401
403
|
"authorized",
|
|
402
404
|
"captured",
|
|
405
|
+
"not_required",
|
|
403
406
|
"failed",
|
|
404
407
|
"cancelled",
|
|
405
408
|
"refunded",
|
|
@@ -448,14 +451,7 @@ function normalizeStatusResponse(response) {
|
|
|
448
451
|
const normalizedAmount = typeof res.amount === "string" ? money(res.amount) : typeof res.amount === "number" && Number.isFinite(res.amount) ? moneyFromNumber(res.amount) : moneyFromNumber(0);
|
|
449
452
|
const normalizedCurrency = typeof res.currency === "string" && res.currency.trim().length > 0 ? res.currency : "";
|
|
450
453
|
const paidValue = res.paid === true;
|
|
451
|
-
const derivedPaid = paidValue ||
|
|
452
|
-
"success",
|
|
453
|
-
"succeeded",
|
|
454
|
-
"paid",
|
|
455
|
-
"captured",
|
|
456
|
-
"authorized",
|
|
457
|
-
"completed"
|
|
458
|
-
].includes(normalizedStatus);
|
|
454
|
+
const derivedPaid = paidValue || PAYMENT_SUCCESS_STATUSES.has(normalizedStatus);
|
|
459
455
|
return {
|
|
460
456
|
status: normalizedStatus,
|
|
461
457
|
paid: derivedPaid,
|