@cimplify/sdk 0.46.1 → 0.46.3
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 +22 -22
- package/dist/advanced.mjs +3 -3
- package/dist/{chunk-5LZNTG4V.mjs → chunk-632JEJUS.mjs} +1 -1
- package/dist/{chunk-AUS4B7PA.mjs → chunk-6HYKWYUF.mjs} +2 -2
- package/dist/{chunk-Z3CHDA24.js → chunk-6RP6OPYO.js} +3 -3
- package/dist/{chunk-6V67MAWO.js → chunk-7ZACMER7.js} +22 -22
- package/dist/{chunk-UJ5BBLKL.mjs → chunk-CKRMA5F7.mjs} +2 -2
- package/dist/{chunk-4KNCSWE4.js → chunk-GEWFWQYK.js} +234 -234
- package/dist/{chunk-DETRNWHF.js → chunk-TKOTACKZ.js} +22 -0
- package/dist/{chunk-NKZ5YN5D.js → chunk-TW4OFRWV.js} +4 -4
- package/dist/{chunk-7H2DYO4T.mjs → chunk-WUIERJ6J.mjs} +2 -2
- package/dist/{chunk-7RRVM2X2.mjs → chunk-XY2DFX5K.mjs} +1 -1
- package/dist/{chunk-3HXYEK5K.mjs → chunk-Z2AYLZDF.mjs} +21 -1
- package/dist/{chunk-HNPVZGTO.js → chunk-Z2MLAIID.js} +60 -60
- package/dist/{client-D7nI2XmP.d.ts → client-B76ZNW5r.d.ts} +2 -2
- package/dist/{client-BScRT1Rz.d.mts → client-CT9NwIDX.d.mts} +2 -2
- package/dist/{client-DyrpQRza.d.mts → client-G2WCoxv2.d.mts} +2 -2
- package/dist/{client-B9r5rH3O.d.ts → client-QVINYu1X.d.ts} +2 -2
- package/dist/{index-DC_ZcSgO.d.ts → index-BAohYhdg.d.ts} +3 -3
- package/dist/{index-3C9J8Wb-.d.mts → index-Bo0NjgR6.d.mts} +3 -3
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +115 -107
- package/dist/index.mjs +4 -4
- package/dist/mock/cli.mjs +2 -0
- package/dist/mock/library.js +2 -0
- package/dist/mock/library.mjs +2 -0
- package/dist/mock/msw.js +2 -0
- package/dist/mock/msw.mjs +2 -0
- package/dist/{payment-Bse2XJ-c.d.mts → payment-9L_-GWqQ.d.mts} +1 -1
- package/dist/{payment-JcNqOf_T.d.ts → payment-_e99nSRj.d.ts} +1 -1
- package/dist/{price-YBGk5seG.d.mts → price-BjehlIhG.d.mts} +1 -1
- package/dist/{price-mHkRncgW.d.ts → price-CWQ5TQmk.d.ts} +1 -1
- package/dist/{product-DiX-HGkT.d.ts → product-C-xLzh7Q.d.mts} +16 -1
- package/dist/{product-DiX-HGkT.d.mts → product-C-xLzh7Q.d.ts} +16 -1
- package/dist/react.d.mts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +93 -85
- package/dist/react.mjs +12 -4
- package/dist/{server-Bg3VtA1D.d.ts → server-72rzvJ4Y.d.ts} +1 -1
- package/dist/{server-kakjHRgj.d.mts → server-BgccqOLT.d.mts} +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +6 -6
- package/dist/server.mjs +4 -4
- package/dist/styles.css +1 -1
- package/dist/testing/msw.d.mts +2 -2
- package/dist/testing/msw.d.ts +2 -2
- package/dist/testing/msw.js +3 -3
- package/dist/testing/msw.mjs +2 -2
- package/dist/testing/suite.d.mts +6 -6
- package/dist/testing/suite.d.ts +6 -6
- package/dist/testing/suite.js +25 -25
- package/dist/testing/suite.mjs +6 -6
- package/dist/testing.d.mts +5 -5
- package/dist/testing.d.ts +5 -5
- package/dist/testing.js +81 -81
- package/dist/testing.mjs +7 -7
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +29 -29
- package/dist/utils.mjs +2 -2
- package/package.json +1 -1
|
@@ -115,6 +115,8 @@ var ErrorCode = {
|
|
|
115
115
|
QUOTE_EXPIRED: "QUOTE_EXPIRED",
|
|
116
116
|
QUOTE_CONSUMED: "QUOTE_CONSUMED",
|
|
117
117
|
QUOTE_STORAGE_UNAVAILABLE: "QUOTE_STORAGE_UNAVAILABLE",
|
|
118
|
+
QUOTE_VALIDATION_FAILED: "QUOTE_VALIDATION_FAILED",
|
|
119
|
+
PRICE_CHANGED: "PRICE_CHANGED",
|
|
118
120
|
PAYMENT_FAILED: "PAYMENT_FAILED",
|
|
119
121
|
PAYMENT_CANCELLED: "PAYMENT_CANCELLED",
|
|
120
122
|
INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS",
|
|
@@ -156,6 +158,8 @@ var ERROR_SUGGESTIONS = {
|
|
|
156
158
|
QUOTE_EXPIRED: "Quote has expired. Re-fetch pricing to generate a new quote with a valid expiry window.",
|
|
157
159
|
QUOTE_CONSUMED: "Quote has already been used. Request a fresh quote to prevent duplicate checkout attempts.",
|
|
158
160
|
QUOTE_STORAGE_UNAVAILABLE: "Quote storage is temporarily unavailable. Retry shortly and avoid charging until quote fetch succeeds.",
|
|
161
|
+
QUOTE_VALIDATION_FAILED: "Cart contents diverged from the locked quote (different items, options, or quantity). Refresh quotes for the affected lines and resubmit.",
|
|
162
|
+
PRICE_CHANGED: "Prices changed since the quote was created. Refresh pricing, show the new total to the shopper, and require explicit confirmation before re-submitting.",
|
|
159
163
|
PAYMENT_FAILED: "Payment provider rejected or failed processing. Show retry/change-method options to the shopper.",
|
|
160
164
|
PAYMENT_CANCELLED: "Payment was cancelled by the shopper or provider flow. Allow a safe retry path.",
|
|
161
165
|
INSUFFICIENT_FUNDS: "Payment method has insufficient funds. Prompt shopper to use another method.",
|
|
@@ -215,6 +219,22 @@ var IdempotencyMismatchError = class extends CimplifyError {
|
|
|
215
219
|
function isCimplifyError(error) {
|
|
216
220
|
return error instanceof CimplifyError;
|
|
217
221
|
}
|
|
222
|
+
var QUOTE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
223
|
+
ErrorCode.QUOTE_NOT_FOUND,
|
|
224
|
+
ErrorCode.QUOTE_EXPIRED,
|
|
225
|
+
ErrorCode.QUOTE_CONSUMED,
|
|
226
|
+
ErrorCode.QUOTE_STORAGE_UNAVAILABLE,
|
|
227
|
+
ErrorCode.QUOTE_VALIDATION_FAILED,
|
|
228
|
+
ErrorCode.PRICE_CHANGED
|
|
229
|
+
]);
|
|
230
|
+
function isQuoteError(error) {
|
|
231
|
+
if (!isCimplifyError(error)) return false;
|
|
232
|
+
return QUOTE_ERROR_CODES.has(error.code);
|
|
233
|
+
}
|
|
234
|
+
function isQuoteConflictRequiringConsent(error) {
|
|
235
|
+
if (!isCimplifyError(error)) return false;
|
|
236
|
+
return error.code === ErrorCode.PRICE_CHANGED || error.code === ErrorCode.QUOTE_VALIDATION_FAILED;
|
|
237
|
+
}
|
|
218
238
|
function isIdempotencyMismatchError(error) {
|
|
219
239
|
return error instanceof IdempotencyMismatchError;
|
|
220
240
|
}
|
|
@@ -265,6 +285,8 @@ exports.enrichError = enrichError;
|
|
|
265
285
|
exports.getErrorHint = getErrorHint;
|
|
266
286
|
exports.isCimplifyError = isCimplifyError;
|
|
267
287
|
exports.isIdempotencyMismatchError = isIdempotencyMismatchError;
|
|
288
|
+
exports.isQuoteConflictRequiringConsent = isQuoteConflictRequiringConsent;
|
|
289
|
+
exports.isQuoteError = isQuoteError;
|
|
268
290
|
exports.isRetryableError = isRetryableError;
|
|
269
291
|
exports.isSupportedCurrency = isSupportedCurrency;
|
|
270
292
|
exports.money = money;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkZ2MLAIID_js = require('./chunk-Z2MLAIID.js');
|
|
4
|
+
var chunkGEWFWQYK_js = require('./chunk-GEWFWQYK.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 = chunkGEWFWQYK_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 = chunkZ2MLAIID_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,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-CKRMA5F7.mjs';
|
|
2
|
+
import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-Z2AYLZDF.mjs';
|
|
3
3
|
|
|
4
4
|
// src/activity.ts
|
|
5
5
|
var ActivityService = class {
|
|
@@ -113,6 +113,8 @@ var ErrorCode = {
|
|
|
113
113
|
QUOTE_EXPIRED: "QUOTE_EXPIRED",
|
|
114
114
|
QUOTE_CONSUMED: "QUOTE_CONSUMED",
|
|
115
115
|
QUOTE_STORAGE_UNAVAILABLE: "QUOTE_STORAGE_UNAVAILABLE",
|
|
116
|
+
QUOTE_VALIDATION_FAILED: "QUOTE_VALIDATION_FAILED",
|
|
117
|
+
PRICE_CHANGED: "PRICE_CHANGED",
|
|
116
118
|
PAYMENT_FAILED: "PAYMENT_FAILED",
|
|
117
119
|
PAYMENT_CANCELLED: "PAYMENT_CANCELLED",
|
|
118
120
|
INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS",
|
|
@@ -154,6 +156,8 @@ var ERROR_SUGGESTIONS = {
|
|
|
154
156
|
QUOTE_EXPIRED: "Quote has expired. Re-fetch pricing to generate a new quote with a valid expiry window.",
|
|
155
157
|
QUOTE_CONSUMED: "Quote has already been used. Request a fresh quote to prevent duplicate checkout attempts.",
|
|
156
158
|
QUOTE_STORAGE_UNAVAILABLE: "Quote storage is temporarily unavailable. Retry shortly and avoid charging until quote fetch succeeds.",
|
|
159
|
+
QUOTE_VALIDATION_FAILED: "Cart contents diverged from the locked quote (different items, options, or quantity). Refresh quotes for the affected lines and resubmit.",
|
|
160
|
+
PRICE_CHANGED: "Prices changed since the quote was created. Refresh pricing, show the new total to the shopper, and require explicit confirmation before re-submitting.",
|
|
157
161
|
PAYMENT_FAILED: "Payment provider rejected or failed processing. Show retry/change-method options to the shopper.",
|
|
158
162
|
PAYMENT_CANCELLED: "Payment was cancelled by the shopper or provider flow. Allow a safe retry path.",
|
|
159
163
|
INSUFFICIENT_FUNDS: "Payment method has insufficient funds. Prompt shopper to use another method.",
|
|
@@ -213,6 +217,22 @@ var IdempotencyMismatchError = class extends CimplifyError {
|
|
|
213
217
|
function isCimplifyError(error) {
|
|
214
218
|
return error instanceof CimplifyError;
|
|
215
219
|
}
|
|
220
|
+
var QUOTE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
221
|
+
ErrorCode.QUOTE_NOT_FOUND,
|
|
222
|
+
ErrorCode.QUOTE_EXPIRED,
|
|
223
|
+
ErrorCode.QUOTE_CONSUMED,
|
|
224
|
+
ErrorCode.QUOTE_STORAGE_UNAVAILABLE,
|
|
225
|
+
ErrorCode.QUOTE_VALIDATION_FAILED,
|
|
226
|
+
ErrorCode.PRICE_CHANGED
|
|
227
|
+
]);
|
|
228
|
+
function isQuoteError(error) {
|
|
229
|
+
if (!isCimplifyError(error)) return false;
|
|
230
|
+
return QUOTE_ERROR_CODES.has(error.code);
|
|
231
|
+
}
|
|
232
|
+
function isQuoteConflictRequiringConsent(error) {
|
|
233
|
+
if (!isCimplifyError(error)) return false;
|
|
234
|
+
return error.code === ErrorCode.PRICE_CHANGED || error.code === ErrorCode.QUOTE_VALIDATION_FAILED;
|
|
235
|
+
}
|
|
216
236
|
function isIdempotencyMismatchError(error) {
|
|
217
237
|
return error instanceof IdempotencyMismatchError;
|
|
218
238
|
}
|
|
@@ -247,4 +267,4 @@ function isRetryableError(error) {
|
|
|
247
267
|
return false;
|
|
248
268
|
}
|
|
249
269
|
|
|
250
|
-
export { CimplifyError, ERROR_HINTS, ErrorCode, IdempotencyMismatchError, ZERO, __privateAdd, __privateGet, __privateMethod, __privateSet, __privateWrapper, __publicField, currencyCode, enrichError, getErrorHint, isCimplifyError, isIdempotencyMismatchError, isRetryableError, isSupportedCurrency, money, moneyFromNumber };
|
|
270
|
+
export { CimplifyError, ERROR_HINTS, ErrorCode, IdempotencyMismatchError, ZERO, __privateAdd, __privateGet, __privateMethod, __privateSet, __privateWrapper, __publicField, 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 chunk7ZACMER7_js = require('./chunk-7ZACMER7.js');
|
|
4
|
+
var chunkTKOTACKZ_js = require('./chunk-TKOTACKZ.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 chunk7ZACMER7_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 chunk7ZACMER7_js.safe(this.client.get(path));
|
|
41
41
|
}
|
|
42
42
|
async dismissMessage(code) {
|
|
43
|
-
return
|
|
43
|
+
return chunk7ZACMER7_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 chunk7ZACMER7_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 chunk7ZACMER7_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 ?? chunk7ZACMER7_js.generateIdempotencyKey();
|
|
74
|
+
return chunk7ZACMER7_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 chunk7ZACMER7_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 chunk7ZACMER7_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 ?? chunk7ZACMER7_js.generateIdempotencyKey();
|
|
97
|
+
return chunk7ZACMER7_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 ?? chunk7ZACMER7_js.generateIdempotencyKey();
|
|
114
|
+
return chunk7ZACMER7_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 chunk7ZACMER7_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 chunkTKOTACKZ_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 chunkTKOTACKZ_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 chunk7ZACMER7_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 chunk7ZACMER7_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 chunk7ZACMER7_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 ?? chunk7ZACMER7_js.generateIdempotencyKey();
|
|
214
|
+
return chunk7ZACMER7_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 ?? chunk7ZACMER7_js.generateIdempotencyKey();
|
|
223
|
+
return chunk7ZACMER7_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 chunk7ZACMER7_js.safe(this.client.get(path));
|
|
239
239
|
}
|
|
240
240
|
};
|
|
241
241
|
|
|
@@ -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 chunkTKOTACKZ_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 chunkTKOTACKZ_js.enrichError(
|
|
315
|
+
new chunkTKOTACKZ_js.CimplifyError(
|
|
316
|
+
chunkTKOTACKZ_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 chunkTKOTACKZ_js.enrichError(
|
|
325
|
+
new chunkTKOTACKZ_js.CimplifyError(
|
|
326
|
+
chunkTKOTACKZ_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 chunkTKOTACKZ_js.CimplifyError) {
|
|
334
|
+
return chunkTKOTACKZ_js.enrichError(error, { isTestMode });
|
|
335
335
|
}
|
|
336
|
-
return
|
|
337
|
-
new
|
|
338
|
-
|
|
336
|
+
return chunkTKOTACKZ_js.enrichError(
|
|
337
|
+
new chunkTKOTACKZ_js.CimplifyError(
|
|
338
|
+
chunkTKOTACKZ_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 chunkTKOTACKZ_js.CimplifyError(
|
|
514
|
+
chunkTKOTACKZ_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 chunkTKOTACKZ_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 chunkTKOTACKZ_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 chunkTKOTACKZ_js.IdempotencyMismatchError(errorMessage, originalCreatedAt);
|
|
791
791
|
}
|
|
792
|
-
const error =
|
|
793
|
-
new
|
|
792
|
+
const error = chunkTKOTACKZ_js.enrichError(
|
|
793
|
+
new chunkTKOTACKZ_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 === chunkTKOTACKZ_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 = chunkTKOTACKZ_js.enrichError(
|
|
809
|
+
new chunkTKOTACKZ_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 chunk7ZACMER7_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 chunk7ZACMER7_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 chunk7ZACMER7_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 chunk7ZACMER7_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 chunk7ZACMER7_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 chunk7ZACMER7_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 chunk7ZACMER7_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 chunk7ZACMER7_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 chunk7ZACMER7_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 chunk7ZACMER7_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 chunk7ZACMER7_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 chunk7ZACMER7_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
|
|
939
939
|
}
|
|
940
940
|
};
|
|
941
941
|
function createCimplifyClient(config = {}) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CimplifyClient } from './client-
|
|
2
|
-
import { C as CreateAppOptions, A as AppHandle } from './server-
|
|
1
|
+
import { C as CimplifyClient } from './client-QVINYu1X.js';
|
|
2
|
+
import { C as CreateAppOptions, A as AppHandle } from './server-72rzvJ4Y.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Test client + fixtures.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CimplifyClient } from './client-
|
|
2
|
-
import { C as CreateAppOptions, A as AppHandle } from './server-
|
|
1
|
+
import { C as CimplifyClient } from './client-G2WCoxv2.mjs';
|
|
2
|
+
import { C as CreateAppOptions, A as AppHandle } from './server-BgccqOLT.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Test client + fixtures.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as CimplifyError,
|
|
2
|
-
import { c as AuthorizationType, e as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, h as PaymentStatusResponse } from './payment-
|
|
1
|
+
import { h as CimplifyError, ap as Category, X as Product, al as AddOnWithOptions, d as Pagination, aa as ProductWithDetails, ac as ProductVariant, ae as VariantAxis, aj as VariantAxisSelection, ak as AddOn, ar as Collection, aw as BundleSummary, av as Bundle, aI as Composite, aP as ComponentSelectionInput, aQ as CompositePriceResult, C as ChosenPrice, aX as ProductTaxonomy, aY as TaxonomyWithChildren, bR as EligiblePlansQuery, bQ as ProductBillingPlan, aW as ProductTimeProfile, aZ as ProductAvailabilityNow, a$ as Deal, b0 as ProductDealInfo, b1 as DiscountValidation, b3 as TagsResponse, K as CustomAttributeDefinition, L as CustomAttributeValue, Q as PropertyFacet, U as TaxonomyAttributeTemplate, W as KnowledgeArticle, bH as UICart, bt as CartItem, bM as CartSummary, bK as AddToCartInput, bJ as CartMutationResult, bL as UpdateCartItemInput, bf as DiscountDetails, M as Money, a as CurrencyCode, br as LineConfiguration, S as SchedulingMode, x as DurationUnit, bU as Subscription, bX as SubscriptionWithDetails } from './product-C-xLzh7Q.mjs';
|
|
2
|
+
import { c as AuthorizationType, e as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, h as PaymentStatusResponse } from './payment-9L_-GWqQ.mjs';
|
|
3
3
|
|
|
4
4
|
interface RequestContext {
|
|
5
5
|
method: "GET" | "POST" | "PATCH" | "DELETE";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as CimplifyError,
|
|
2
|
-
import { c as AuthorizationType, e as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, h as PaymentStatusResponse } from './payment-
|
|
1
|
+
import { h as CimplifyError, ap as Category, X as Product, al as AddOnWithOptions, d as Pagination, aa as ProductWithDetails, ac as ProductVariant, ae as VariantAxis, aj as VariantAxisSelection, ak as AddOn, ar as Collection, aw as BundleSummary, av as Bundle, aI as Composite, aP as ComponentSelectionInput, aQ as CompositePriceResult, C as ChosenPrice, aX as ProductTaxonomy, aY as TaxonomyWithChildren, bR as EligiblePlansQuery, bQ as ProductBillingPlan, aW as ProductTimeProfile, aZ as ProductAvailabilityNow, a$ as Deal, b0 as ProductDealInfo, b1 as DiscountValidation, b3 as TagsResponse, K as CustomAttributeDefinition, L as CustomAttributeValue, Q as PropertyFacet, U as TaxonomyAttributeTemplate, W as KnowledgeArticle, bH as UICart, bt as CartItem, bM as CartSummary, bK as AddToCartInput, bJ as CartMutationResult, bL as UpdateCartItemInput, bf as DiscountDetails, M as Money, a as CurrencyCode, br as LineConfiguration, S as SchedulingMode, x as DurationUnit, bU as Subscription, bX as SubscriptionWithDetails } from './product-C-xLzh7Q.js';
|
|
2
|
+
import { c as AuthorizationType, e as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, h as PaymentStatusResponse } from './payment-_e99nSRj.js';
|
|
3
3
|
|
|
4
4
|
interface RequestContext {
|
|
5
5
|
method: "GET" | "POST" | "PATCH" | "DELETE";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { M as Money, a as CurrencyCode,
|
|
2
|
-
import { P as ProductWithPrice } from './price-
|
|
3
|
-
import { i as PaymentErrorDetails, g as PaymentResponse, h as PaymentStatusResponse } from './payment-
|
|
1
|
+
import { M as Money, a as CurrencyCode, ba as PricePathTaxInfo, a8 as QuantityPricingTier, X as Product, aa as ProductWithDetails } from './product-C-xLzh7Q.js';
|
|
2
|
+
import { P as ProductWithPrice } from './price-CWQ5TQmk.js';
|
|
3
|
+
import { i as PaymentErrorDetails, g as PaymentResponse, h as PaymentStatusResponse } from './payment-_e99nSRj.js';
|
|
4
4
|
import { CountryCode } from 'libphonenumber-js';
|
|
5
5
|
|
|
6
6
|
declare const CURRENCY_SYMBOLS: Record<string, string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { M as Money, a as CurrencyCode,
|
|
2
|
-
import { P as ProductWithPrice } from './price-
|
|
3
|
-
import { i as PaymentErrorDetails, g as PaymentResponse, h as PaymentStatusResponse } from './payment-
|
|
1
|
+
import { M as Money, a as CurrencyCode, ba as PricePathTaxInfo, a8 as QuantityPricingTier, X as Product, aa as ProductWithDetails } from './product-C-xLzh7Q.mjs';
|
|
2
|
+
import { P as ProductWithPrice } from './price-BjehlIhG.mjs';
|
|
3
|
+
import { i as PaymentErrorDetails, g as PaymentResponse, h as PaymentStatusResponse } from './payment-9L_-GWqQ.mjs';
|
|
4
4
|
import { CountryCode } from 'libphonenumber-js';
|
|
5
5
|
|
|
6
6
|
declare const CURRENCY_SYMBOLS: Record<string, string>;
|