@cimplify/sdk 0.52.0 → 0.52.2
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.js +23 -22
- package/dist/advanced.mjs +4 -3
- package/dist/chunk-3G6RQLXK.mjs +21 -0
- package/dist/{chunk-6RP6OPYO.js → chunk-7Y2O3E4D.js} +3 -3
- package/dist/{chunk-Z2AYLZDF.mjs → chunk-AMZXALF6.mjs} +1 -21
- package/dist/{chunk-MBR2DBEN.mjs → chunk-APHYBBDD.mjs} +3 -3
- package/dist/{chunk-CYGLTD7D.js → chunk-EMS6DQIX.js} +61 -61
- package/dist/{chunk-DR4UPU6P.js → chunk-EQLT46ZR.js} +22 -22
- package/dist/{chunk-OFNVLUH4.mjs → chunk-GLAVTDDE.mjs} +2 -2
- 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-D22UVSFN.js → chunk-ROURLUXG.js} +4 -4
- package/dist/{chunk-XY2DFX5K.mjs → chunk-TD3AY34U.mjs} +1 -1
- package/dist/{chunk-24FK7VFL.mjs → chunk-VZS453ON.mjs} +2 -2
- package/dist/{chunk-TKOTACKZ.js → chunk-XA3ZNR75.js} +0 -26
- package/dist/index.js +110 -109
- package/dist/index.mjs +5 -4
- 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 +1 -30
- package/dist/server.d.ts +1 -30
- 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.js +26 -25
- package/dist/testing/suite.mjs +7 -6
- 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.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,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,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 {
|
|
@@ -276,7 +276,7 @@ var SESSION_TOKEN_STORAGE_KEY = "cimplify_session_token";
|
|
|
276
276
|
var ORDER_TOKEN_PREFIX = "cimplify_ot_";
|
|
277
277
|
var SESSION_TOKEN_HEADER = "x-session-token";
|
|
278
278
|
var ORDER_TOKEN_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
279
|
-
var DEFAULT_TIMEOUT_MS =
|
|
279
|
+
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
280
280
|
var DEFAULT_MAX_RETRIES = 3;
|
|
281
281
|
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
282
282
|
function sleep(ms) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkEQLT46ZR_js = require('./chunk-EQLT46ZR.js');
|
|
4
|
+
var chunkXA3ZNR75_js = require('./chunk-XA3ZNR75.js');
|
|
5
5
|
|
|
6
6
|
// src/activity.ts
|
|
7
7
|
var ActivityService = class {
|
|
@@ -29,7 +29,7 @@ var ActivityService = class {
|
|
|
29
29
|
this.sendEvents([event]);
|
|
30
30
|
}
|
|
31
31
|
async getState() {
|
|
32
|
-
return
|
|
32
|
+
return chunkEQLT46ZR_js.safe(this.client.get("/api/v1/activity/state"));
|
|
33
33
|
}
|
|
34
34
|
async getRecommendations(options) {
|
|
35
35
|
const params = new URLSearchParams();
|
|
@@ -37,10 +37,10 @@ var ActivityService = class {
|
|
|
37
37
|
if (options?.limit) params.set("limit", String(options.limit));
|
|
38
38
|
const query = params.toString();
|
|
39
39
|
const path = query ? `/api/v1/activity/recommendations?${query}` : "/api/v1/activity/recommendations";
|
|
40
|
-
return
|
|
40
|
+
return chunkEQLT46ZR_js.safe(this.client.get(path));
|
|
41
41
|
}
|
|
42
42
|
async dismissMessage(code) {
|
|
43
|
-
return
|
|
43
|
+
return chunkEQLT46ZR_js.safe(
|
|
44
44
|
this.client.post("/api/v1/activity/messages/dismiss", { code })
|
|
45
45
|
);
|
|
46
46
|
}
|
|
@@ -62,16 +62,16 @@ var SubscriptionService = class {
|
|
|
62
62
|
this.client = client;
|
|
63
63
|
}
|
|
64
64
|
async list() {
|
|
65
|
-
return
|
|
65
|
+
return chunkEQLT46ZR_js.safe(this.client.get("/api/v1/subscriptions"));
|
|
66
66
|
}
|
|
67
67
|
async get(id) {
|
|
68
68
|
const encodedId = encodeURIComponent(id);
|
|
69
|
-
return
|
|
69
|
+
return chunkEQLT46ZR_js.safe(this.client.get(`/api/v1/subscriptions/${encodedId}`));
|
|
70
70
|
}
|
|
71
71
|
async cancel(id, reason, opts) {
|
|
72
72
|
const encodedId = encodeURIComponent(id);
|
|
73
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
74
|
-
return
|
|
73
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkEQLT46ZR_js.generateIdempotencyKey();
|
|
74
|
+
return chunkEQLT46ZR_js.safe(
|
|
75
75
|
this.client.post(
|
|
76
76
|
`/api/v1/subscriptions/${encodedId}/cancel`,
|
|
77
77
|
{ reason },
|
|
@@ -81,20 +81,20 @@ var SubscriptionService = class {
|
|
|
81
81
|
}
|
|
82
82
|
async pause(id) {
|
|
83
83
|
const encodedId = encodeURIComponent(id);
|
|
84
|
-
return
|
|
84
|
+
return chunkEQLT46ZR_js.safe(
|
|
85
85
|
this.client.post(`/api/v1/subscriptions/${encodedId}/pause`)
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
async resume(id) {
|
|
89
89
|
const encodedId = encodeURIComponent(id);
|
|
90
|
-
return
|
|
90
|
+
return chunkEQLT46ZR_js.safe(
|
|
91
91
|
this.client.post(`/api/v1/subscriptions/${encodedId}/resume`)
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
94
|
async skipNextRenewal(id, opts) {
|
|
95
95
|
const encodedId = encodeURIComponent(id);
|
|
96
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
97
|
-
return
|
|
96
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkEQLT46ZR_js.generateIdempotencyKey();
|
|
97
|
+
return chunkEQLT46ZR_js.safe(
|
|
98
98
|
this.client.post(
|
|
99
99
|
`/api/v1/subscriptions/${encodedId}/skip`,
|
|
100
100
|
void 0,
|
|
@@ -110,8 +110,8 @@ var UploadService = class {
|
|
|
110
110
|
this.client = client;
|
|
111
111
|
}
|
|
112
112
|
async init(filename, contentType, sizeBytes, opts) {
|
|
113
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
114
|
-
return
|
|
113
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkEQLT46ZR_js.generateIdempotencyKey();
|
|
114
|
+
return chunkEQLT46ZR_js.safe(
|
|
115
115
|
this.client.post(
|
|
116
116
|
"/api/v1/uploads/init",
|
|
117
117
|
{
|
|
@@ -124,7 +124,7 @@ var UploadService = class {
|
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
async confirm(uploadId) {
|
|
127
|
-
return
|
|
127
|
+
return chunkEQLT46ZR_js.safe(
|
|
128
128
|
this.client.post("/api/v1/uploads/confirm", {
|
|
129
129
|
upload_id: uploadId
|
|
130
130
|
})
|
|
@@ -143,7 +143,7 @@ var UploadService = class {
|
|
|
143
143
|
if (!uploadResponse.ok) {
|
|
144
144
|
return {
|
|
145
145
|
ok: false,
|
|
146
|
-
error: new
|
|
146
|
+
error: new chunkXA3ZNR75_js.CimplifyError(
|
|
147
147
|
"UPLOAD_FAILED",
|
|
148
148
|
`Upload failed with status ${uploadResponse.status}`,
|
|
149
149
|
true
|
|
@@ -153,7 +153,7 @@ var UploadService = class {
|
|
|
153
153
|
} catch (error) {
|
|
154
154
|
return {
|
|
155
155
|
ok: false,
|
|
156
|
-
error: new
|
|
156
|
+
error: new chunkXA3ZNR75_js.CimplifyError(
|
|
157
157
|
"UPLOAD_FAILED",
|
|
158
158
|
error instanceof Error ? error.message : "Upload failed",
|
|
159
159
|
true
|
|
@@ -170,7 +170,7 @@ var PlacesService = class {
|
|
|
170
170
|
this.client = client;
|
|
171
171
|
}
|
|
172
172
|
async autocomplete(input, sessionToken) {
|
|
173
|
-
return
|
|
173
|
+
return chunkEQLT46ZR_js.safe(
|
|
174
174
|
this.client.post("/api/v1/places/autocomplete", {
|
|
175
175
|
input,
|
|
176
176
|
sessionToken
|
|
@@ -178,7 +178,7 @@ var PlacesService = class {
|
|
|
178
178
|
);
|
|
179
179
|
}
|
|
180
180
|
async details(placeId, sessionToken) {
|
|
181
|
-
return
|
|
181
|
+
return chunkEQLT46ZR_js.safe(
|
|
182
182
|
this.client.post("/api/v1/places/details", {
|
|
183
183
|
place_id: placeId,
|
|
184
184
|
sessionToken
|
|
@@ -197,7 +197,7 @@ var DeliveryService = class {
|
|
|
197
197
|
params.set("dropoff_lat", String(dropoffLat));
|
|
198
198
|
params.set("dropoff_lng", String(dropoffLng));
|
|
199
199
|
if (country) params.set("country", country);
|
|
200
|
-
return
|
|
200
|
+
return chunkEQLT46ZR_js.safe(
|
|
201
201
|
this.client.get(`/api/v1/delivery/fee?${params.toString()}`)
|
|
202
202
|
);
|
|
203
203
|
}
|
|
@@ -210,8 +210,8 @@ var SupportService = class {
|
|
|
210
210
|
}
|
|
211
211
|
/** Open (or resume) the customer's widget conversation. */
|
|
212
212
|
async openConversation(opts) {
|
|
213
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
214
|
-
return
|
|
213
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkEQLT46ZR_js.generateIdempotencyKey();
|
|
214
|
+
return chunkEQLT46ZR_js.safe(
|
|
215
215
|
this.client.post("/api/v1/support/conversation", void 0, {
|
|
216
216
|
idempotencyKey
|
|
217
217
|
})
|
|
@@ -219,8 +219,8 @@ var SupportService = class {
|
|
|
219
219
|
}
|
|
220
220
|
/** Send a message in the active conversation. */
|
|
221
221
|
async sendMessage(content, opts) {
|
|
222
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
223
|
-
return
|
|
222
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkEQLT46ZR_js.generateIdempotencyKey();
|
|
223
|
+
return chunkEQLT46ZR_js.safe(
|
|
224
224
|
this.client.post(
|
|
225
225
|
"/api/v1/support/conversation/messages",
|
|
226
226
|
{ content },
|
|
@@ -235,7 +235,7 @@ var SupportService = class {
|
|
|
235
235
|
if (options.limit) params.set("limit", String(options.limit));
|
|
236
236
|
const query = params.toString();
|
|
237
237
|
const path = query ? `/api/v1/support/conversation/messages?${query}` : "/api/v1/support/conversation/messages";
|
|
238
|
-
return
|
|
238
|
+
return chunkEQLT46ZR_js.safe(this.client.get(path));
|
|
239
239
|
}
|
|
240
240
|
};
|
|
241
241
|
|
|
@@ -278,7 +278,7 @@ var SESSION_TOKEN_STORAGE_KEY = "cimplify_session_token";
|
|
|
278
278
|
var ORDER_TOKEN_PREFIX = "cimplify_ot_";
|
|
279
279
|
var SESSION_TOKEN_HEADER = "x-session-token";
|
|
280
280
|
var ORDER_TOKEN_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
281
|
-
var DEFAULT_TIMEOUT_MS =
|
|
281
|
+
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
282
282
|
var DEFAULT_MAX_RETRIES = 3;
|
|
283
283
|
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
284
284
|
function sleep(ms) {
|
|
@@ -304,16 +304,16 @@ function isRetryable(error) {
|
|
|
304
304
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
305
305
|
return true;
|
|
306
306
|
}
|
|
307
|
-
if (error instanceof
|
|
307
|
+
if (error instanceof chunkXA3ZNR75_js.CimplifyError) {
|
|
308
308
|
return error.retryable;
|
|
309
309
|
}
|
|
310
310
|
return false;
|
|
311
311
|
}
|
|
312
312
|
function toNetworkError(error, isTestMode) {
|
|
313
313
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
314
|
-
return
|
|
315
|
-
new
|
|
316
|
-
|
|
314
|
+
return chunkXA3ZNR75_js.enrichError(
|
|
315
|
+
new chunkXA3ZNR75_js.CimplifyError(
|
|
316
|
+
chunkXA3ZNR75_js.ErrorCode.TIMEOUT,
|
|
317
317
|
"Request timed out. Please check your connection and try again.",
|
|
318
318
|
true
|
|
319
319
|
),
|
|
@@ -321,21 +321,21 @@ function toNetworkError(error, isTestMode) {
|
|
|
321
321
|
);
|
|
322
322
|
}
|
|
323
323
|
if (error instanceof TypeError && error.message.includes("fetch")) {
|
|
324
|
-
return
|
|
325
|
-
new
|
|
326
|
-
|
|
324
|
+
return chunkXA3ZNR75_js.enrichError(
|
|
325
|
+
new chunkXA3ZNR75_js.CimplifyError(
|
|
326
|
+
chunkXA3ZNR75_js.ErrorCode.NETWORK_ERROR,
|
|
327
327
|
"Network error. Please check your internet connection.",
|
|
328
328
|
true
|
|
329
329
|
),
|
|
330
330
|
{ isTestMode }
|
|
331
331
|
);
|
|
332
332
|
}
|
|
333
|
-
if (error instanceof
|
|
334
|
-
return
|
|
333
|
+
if (error instanceof chunkXA3ZNR75_js.CimplifyError) {
|
|
334
|
+
return chunkXA3ZNR75_js.enrichError(error, { isTestMode });
|
|
335
335
|
}
|
|
336
|
-
return
|
|
337
|
-
new
|
|
338
|
-
|
|
336
|
+
return chunkXA3ZNR75_js.enrichError(
|
|
337
|
+
new chunkXA3ZNR75_js.CimplifyError(
|
|
338
|
+
chunkXA3ZNR75_js.ErrorCode.UNKNOWN_ERROR,
|
|
339
339
|
error instanceof Error ? error.message : "An unknown error occurred",
|
|
340
340
|
false
|
|
341
341
|
),
|
|
@@ -510,8 +510,8 @@ var CimplifyClient = class {
|
|
|
510
510
|
this.businessIdResolvePromise = (async () => {
|
|
511
511
|
const result = await this.business.getInfo();
|
|
512
512
|
if (!result.ok || !result.value?.id) {
|
|
513
|
-
throw new
|
|
514
|
-
|
|
513
|
+
throw new chunkXA3ZNR75_js.CimplifyError(
|
|
514
|
+
chunkXA3ZNR75_js.ErrorCode.NOT_FOUND,
|
|
515
515
|
"Unable to resolve business ID from the current public key.",
|
|
516
516
|
true
|
|
517
517
|
);
|
|
@@ -628,7 +628,7 @@ var CimplifyClient = class {
|
|
|
628
628
|
if (response.status >= 400 && response.status < 500) {
|
|
629
629
|
this.hooks.onRequestError?.({
|
|
630
630
|
...context,
|
|
631
|
-
error: new
|
|
631
|
+
error: new chunkXA3ZNR75_js.CimplifyError(
|
|
632
632
|
`HTTP_${response.status}`,
|
|
633
633
|
`Request failed with status ${response.status}`,
|
|
634
634
|
false
|
|
@@ -654,7 +654,7 @@ var CimplifyClient = class {
|
|
|
654
654
|
}
|
|
655
655
|
this.hooks.onRequestError?.({
|
|
656
656
|
...context,
|
|
657
|
-
error: new
|
|
657
|
+
error: new chunkXA3ZNR75_js.CimplifyError(
|
|
658
658
|
"SERVER_ERROR",
|
|
659
659
|
`Server error ${response.status} after ${retryCount} retries`,
|
|
660
660
|
false
|
|
@@ -787,17 +787,17 @@ var CimplifyClient = class {
|
|
|
787
787
|
const retryable = typeof json.error === "object" && typeof json.error?.retryable === "boolean" ? json.error.retryable : false;
|
|
788
788
|
if (errorCode === "IDEMPOTENCY_MISMATCH") {
|
|
789
789
|
const originalCreatedAt = typeof json.error === "object" && json.error?.original_created_at || "";
|
|
790
|
-
throw new
|
|
790
|
+
throw new chunkXA3ZNR75_js.IdempotencyMismatchError(errorMessage, originalCreatedAt);
|
|
791
791
|
}
|
|
792
|
-
const error =
|
|
793
|
-
new
|
|
792
|
+
const error = chunkXA3ZNR75_js.enrichError(
|
|
793
|
+
new chunkXA3ZNR75_js.CimplifyError(
|
|
794
794
|
errorCode,
|
|
795
795
|
errorMessage,
|
|
796
796
|
retryable
|
|
797
797
|
),
|
|
798
798
|
{ isTestMode: this.isTestMode() }
|
|
799
799
|
);
|
|
800
|
-
if ((response.status === 401 || error.code ===
|
|
800
|
+
if ((response.status === 401 || error.code === chunkXA3ZNR75_js.ErrorCode.UNAUTHORIZED) && this.accessToken) {
|
|
801
801
|
console.warn(
|
|
802
802
|
"[Cimplify] Received 401 Unauthorized. Access token may be missing/expired. Refresh authentication and retry the request."
|
|
803
803
|
);
|
|
@@ -805,8 +805,8 @@ var CimplifyClient = class {
|
|
|
805
805
|
throw error;
|
|
806
806
|
}
|
|
807
807
|
if (json?.success === false || json?.error?.code || json?.error?.message) {
|
|
808
|
-
const error =
|
|
809
|
-
new
|
|
808
|
+
const error = chunkXA3ZNR75_js.enrichError(
|
|
809
|
+
new chunkXA3ZNR75_js.CimplifyError(
|
|
810
810
|
json.error?.code || "API_ERROR",
|
|
811
811
|
json.error?.message || "An error occurred",
|
|
812
812
|
json.error?.retryable || false
|
|
@@ -822,25 +822,25 @@ var CimplifyClient = class {
|
|
|
822
822
|
}
|
|
823
823
|
get catalogue() {
|
|
824
824
|
if (!this._catalogue) {
|
|
825
|
-
this._catalogue = new
|
|
825
|
+
this._catalogue = new chunkEQLT46ZR_js.CatalogueQueries(this);
|
|
826
826
|
}
|
|
827
827
|
return this._catalogue;
|
|
828
828
|
}
|
|
829
829
|
get cart() {
|
|
830
830
|
if (!this._cart) {
|
|
831
|
-
this._cart = new
|
|
831
|
+
this._cart = new chunkEQLT46ZR_js.CartOperations(this);
|
|
832
832
|
}
|
|
833
833
|
return this._cart;
|
|
834
834
|
}
|
|
835
835
|
get checkout() {
|
|
836
836
|
if (!this._checkout) {
|
|
837
|
-
this._checkout = new
|
|
837
|
+
this._checkout = new chunkEQLT46ZR_js.CheckoutService(this);
|
|
838
838
|
}
|
|
839
839
|
return this._checkout;
|
|
840
840
|
}
|
|
841
841
|
get orders() {
|
|
842
842
|
if (!this._orders) {
|
|
843
|
-
this._orders = new
|
|
843
|
+
this._orders = new chunkEQLT46ZR_js.OrderQueries(this);
|
|
844
844
|
}
|
|
845
845
|
return this._orders;
|
|
846
846
|
}
|
|
@@ -864,43 +864,43 @@ var CimplifyClient = class {
|
|
|
864
864
|
}
|
|
865
865
|
get link() {
|
|
866
866
|
if (!this._link) {
|
|
867
|
-
this._link = new
|
|
867
|
+
this._link = new chunkEQLT46ZR_js.LinkService(this);
|
|
868
868
|
}
|
|
869
869
|
return this._link;
|
|
870
870
|
}
|
|
871
871
|
get auth() {
|
|
872
872
|
if (!this._auth) {
|
|
873
|
-
this._auth = new
|
|
873
|
+
this._auth = new chunkEQLT46ZR_js.AuthService(this);
|
|
874
874
|
}
|
|
875
875
|
return this._auth;
|
|
876
876
|
}
|
|
877
877
|
get business() {
|
|
878
878
|
if (!this._business) {
|
|
879
|
-
this._business = new
|
|
879
|
+
this._business = new chunkEQLT46ZR_js.BusinessService(this);
|
|
880
880
|
}
|
|
881
881
|
return this._business;
|
|
882
882
|
}
|
|
883
883
|
get inventory() {
|
|
884
884
|
if (!this._inventory) {
|
|
885
|
-
this._inventory = new
|
|
885
|
+
this._inventory = new chunkEQLT46ZR_js.InventoryService(this);
|
|
886
886
|
}
|
|
887
887
|
return this._inventory;
|
|
888
888
|
}
|
|
889
889
|
get scheduling() {
|
|
890
890
|
if (!this._scheduling) {
|
|
891
|
-
this._scheduling = new
|
|
891
|
+
this._scheduling = new chunkEQLT46ZR_js.SchedulingService(this);
|
|
892
892
|
}
|
|
893
893
|
return this._scheduling;
|
|
894
894
|
}
|
|
895
895
|
get lite() {
|
|
896
896
|
if (!this._lite) {
|
|
897
|
-
this._lite = new
|
|
897
|
+
this._lite = new chunkEQLT46ZR_js.LiteService(this);
|
|
898
898
|
}
|
|
899
899
|
return this._lite;
|
|
900
900
|
}
|
|
901
901
|
get fx() {
|
|
902
902
|
if (!this._fx) {
|
|
903
|
-
this._fx = new
|
|
903
|
+
this._fx = new chunkEQLT46ZR_js.FxService(this);
|
|
904
904
|
}
|
|
905
905
|
return this._fx;
|
|
906
906
|
}
|
|
@@ -935,7 +935,7 @@ var CimplifyClient = class {
|
|
|
935
935
|
if (businessId) {
|
|
936
936
|
this.setBusinessId(businessId);
|
|
937
937
|
}
|
|
938
|
-
return
|
|
938
|
+
return chunkEQLT46ZR_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
|
|
939
939
|
}
|
|
940
940
|
};
|
|
941
941
|
function createCimplifyClient(config = {}) {
|