@cimplify/sdk 0.84.0 → 0.86.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 +22 -22
- package/dist/advanced.mjs +3 -3
- package/dist/{chunk-I6RE4BKH.mjs → chunk-A2GXDCSI.mjs} +2 -2
- package/dist/{chunk-XA3ZNR75.js → chunk-AETVRBKI.js} +1 -1
- package/dist/{chunk-PLTP6HWW.mjs → chunk-D6JWYYTG.mjs} +20 -20
- package/dist/{chunk-ODEPW244.js → chunk-ESGKWRQS.js} +4 -4
- package/dist/{chunk-GFM5JW45.js → chunk-HJEKXCG2.js} +62 -62
- package/dist/{chunk-AMZXALF6.mjs → chunk-K5EN2W2Q.mjs} +1 -1
- package/dist/{chunk-TD3AY34U.mjs → chunk-KFLGQGMC.mjs} +3 -3
- package/dist/{chunk-NWUEWUX2.mjs → chunk-MRL53WP6.mjs} +2 -2
- package/dist/{chunk-7BM56JET.mjs → chunk-NN3WC7XZ.mjs} +3 -3
- package/dist/{chunk-7Y2O3E4D.js → chunk-PTPOQVXS.js} +5 -5
- package/dist/{chunk-HPN5R3K2.js → chunk-VUG4HTUM.js} +23 -23
- package/dist/{chunk-FKBXZ2A6.js → chunk-X4UNISYG.js} +22 -22
- package/dist/{client-CINi3Dw3.d.ts → client-BQSRj4iK.d.mts} +528 -539
- package/dist/{client-Ba4Hng9i.d.mts → client-BdI24jUT.d.ts} +528 -539
- package/dist/{client-D8AjO8jb.d.ts → client-CMJO_8zo.d.ts} +2 -2
- package/dist/{client-BjUJapti.d.mts → client-DowGNrTh.d.mts} +2 -2
- package/dist/{index-DCPxHjbj.d.ts → index-BRwHpMY-.d.ts} +3 -3
- package/dist/{index-9Bl-zBAI.d.mts → index-DLb_Ldl6.d.mts} +3 -3
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +117 -117
- package/dist/index.mjs +5 -5
- package/dist/mock/cli.mjs +659 -355
- package/dist/mock/library.js +20 -20
- package/dist/mock/library.mjs +20 -20
- package/dist/mock/msw.js +20 -20
- package/dist/mock/msw.mjs +20 -20
- package/dist/{payment-BVv9leS_.d.ts → payment-BA7KNBxg.d.ts} +3 -3
- package/dist/{payment-D61iGd0o.d.mts → payment-CFev-fOE.d.mts} +3 -3
- package/dist/{price-BYWCHYO5.d.ts → price-BNhGVB5q.d.ts} +3 -1
- package/dist/{price-Cthq6nPb.d.mts → price-nRxqVNGq.d.mts} +3 -1
- package/dist/product-BGxIfTqJ.d.mts +5400 -0
- package/dist/product-BGxIfTqJ.d.ts +5400 -0
- package/dist/react.d.mts +22 -7
- package/dist/react.d.ts +22 -7
- package/dist/react.js +177 -155
- package/dist/react.mjs +57 -36
- package/dist/{server-BjQ0xWmc.d.mts → server-9u0LiG5U.d.mts} +1 -1
- package/dist/{server-DDaQIYLa.d.ts → server-BH7DTaaz.d.ts} +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +10 -10
- 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 +25 -22
- package/registry/currency-selector.json +1 -1
- package/registry/digital-product-card.json +1 -1
- package/registry/digital-product-layout.json +1 -1
- package/dist/product-2MAoE0kZ.d.mts +0 -1570
- package/dist/product-2MAoE0kZ.d.ts +0 -1570
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkVUG4HTUM_js = require('./chunk-VUG4HTUM.js');
|
|
4
|
+
var chunkAETVRBKI_js = require('./chunk-AETVRBKI.js');
|
|
5
5
|
|
|
6
6
|
// src/store-credit.ts
|
|
7
7
|
var StoreCreditQueries = class {
|
|
@@ -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 chunkVUG4HTUM_js.safe(this.client.get("/api/v1/store-credit/balance"));
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -95,7 +95,7 @@ var ActivityService = class {
|
|
|
95
95
|
this.sendEvents([event]);
|
|
96
96
|
}
|
|
97
97
|
async getState() {
|
|
98
|
-
return
|
|
98
|
+
return chunkVUG4HTUM_js.safe(this.client.get("/api/v1/activity/state"));
|
|
99
99
|
}
|
|
100
100
|
async getRecommendations(options) {
|
|
101
101
|
const params = new URLSearchParams();
|
|
@@ -103,10 +103,10 @@ var ActivityService = class {
|
|
|
103
103
|
if (options?.limit) params.set("limit", String(options.limit));
|
|
104
104
|
const query = params.toString();
|
|
105
105
|
const path = query ? `/api/v1/activity/recommendations?${query}` : "/api/v1/activity/recommendations";
|
|
106
|
-
return
|
|
106
|
+
return chunkVUG4HTUM_js.safe(this.client.get(path));
|
|
107
107
|
}
|
|
108
108
|
async dismissMessage(code) {
|
|
109
|
-
return
|
|
109
|
+
return chunkVUG4HTUM_js.safe(
|
|
110
110
|
this.client.post("/api/v1/activity/messages/dismiss", { code })
|
|
111
111
|
);
|
|
112
112
|
}
|
|
@@ -142,16 +142,16 @@ var SubscriptionService = class {
|
|
|
142
142
|
this.client = client;
|
|
143
143
|
}
|
|
144
144
|
async list() {
|
|
145
|
-
return
|
|
145
|
+
return chunkVUG4HTUM_js.safe(this.client.get("/api/v1/subscriptions"));
|
|
146
146
|
}
|
|
147
147
|
async get(id) {
|
|
148
148
|
const encodedId = encodeURIComponent(id);
|
|
149
|
-
return
|
|
149
|
+
return chunkVUG4HTUM_js.safe(this.client.get(`/api/v1/subscriptions/${encodedId}`));
|
|
150
150
|
}
|
|
151
151
|
async cancel(id, reason, opts) {
|
|
152
152
|
const encodedId = encodeURIComponent(id);
|
|
153
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
154
|
-
return
|
|
153
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkVUG4HTUM_js.generateIdempotencyKey();
|
|
154
|
+
return chunkVUG4HTUM_js.safe(
|
|
155
155
|
this.client.post(
|
|
156
156
|
`/api/v1/subscriptions/${encodedId}/cancel`,
|
|
157
157
|
{ reason },
|
|
@@ -161,20 +161,20 @@ var SubscriptionService = class {
|
|
|
161
161
|
}
|
|
162
162
|
async pause(id) {
|
|
163
163
|
const encodedId = encodeURIComponent(id);
|
|
164
|
-
return
|
|
164
|
+
return chunkVUG4HTUM_js.safe(
|
|
165
165
|
this.client.post(`/api/v1/subscriptions/${encodedId}/pause`)
|
|
166
166
|
);
|
|
167
167
|
}
|
|
168
168
|
async resume(id) {
|
|
169
169
|
const encodedId = encodeURIComponent(id);
|
|
170
|
-
return
|
|
170
|
+
return chunkVUG4HTUM_js.safe(
|
|
171
171
|
this.client.post(`/api/v1/subscriptions/${encodedId}/resume`)
|
|
172
172
|
);
|
|
173
173
|
}
|
|
174
174
|
async skipNextRenewal(id, opts) {
|
|
175
175
|
const encodedId = encodeURIComponent(id);
|
|
176
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
177
|
-
return
|
|
176
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkVUG4HTUM_js.generateIdempotencyKey();
|
|
177
|
+
return chunkVUG4HTUM_js.safe(
|
|
178
178
|
this.client.post(
|
|
179
179
|
`/api/v1/subscriptions/${encodedId}/skip`,
|
|
180
180
|
void 0,
|
|
@@ -190,8 +190,8 @@ var UploadService = class {
|
|
|
190
190
|
this.client = client;
|
|
191
191
|
}
|
|
192
192
|
async init(filename, contentType, sizeBytes, opts) {
|
|
193
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
194
|
-
return
|
|
193
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkVUG4HTUM_js.generateIdempotencyKey();
|
|
194
|
+
return chunkVUG4HTUM_js.safe(
|
|
195
195
|
this.client.post(
|
|
196
196
|
"/api/v1/uploads/init",
|
|
197
197
|
{
|
|
@@ -204,7 +204,7 @@ var UploadService = class {
|
|
|
204
204
|
);
|
|
205
205
|
}
|
|
206
206
|
async confirm(uploadId) {
|
|
207
|
-
return
|
|
207
|
+
return chunkVUG4HTUM_js.safe(
|
|
208
208
|
this.client.post("/api/v1/uploads/confirm", {
|
|
209
209
|
upload_id: uploadId
|
|
210
210
|
})
|
|
@@ -223,7 +223,7 @@ var UploadService = class {
|
|
|
223
223
|
if (!uploadResponse.ok) {
|
|
224
224
|
return {
|
|
225
225
|
ok: false,
|
|
226
|
-
error: new
|
|
226
|
+
error: new chunkAETVRBKI_js.CimplifyError(
|
|
227
227
|
"UPLOAD_FAILED",
|
|
228
228
|
`Upload failed with status ${uploadResponse.status}`,
|
|
229
229
|
true
|
|
@@ -233,7 +233,7 @@ var UploadService = class {
|
|
|
233
233
|
} catch (error) {
|
|
234
234
|
return {
|
|
235
235
|
ok: false,
|
|
236
|
-
error: new
|
|
236
|
+
error: new chunkAETVRBKI_js.CimplifyError(
|
|
237
237
|
"UPLOAD_FAILED",
|
|
238
238
|
error instanceof Error ? error.message : "Upload failed",
|
|
239
239
|
true
|
|
@@ -250,7 +250,7 @@ var PlacesService = class {
|
|
|
250
250
|
this.client = client;
|
|
251
251
|
}
|
|
252
252
|
async autocomplete(input, sessionToken) {
|
|
253
|
-
return
|
|
253
|
+
return chunkVUG4HTUM_js.safe(
|
|
254
254
|
this.client.post("/api/v1/places/autocomplete", {
|
|
255
255
|
input,
|
|
256
256
|
sessionToken
|
|
@@ -258,7 +258,7 @@ var PlacesService = class {
|
|
|
258
258
|
);
|
|
259
259
|
}
|
|
260
260
|
async details(placeId, sessionToken) {
|
|
261
|
-
return
|
|
261
|
+
return chunkVUG4HTUM_js.safe(
|
|
262
262
|
this.client.post("/api/v1/places/details", {
|
|
263
263
|
place_id: placeId,
|
|
264
264
|
sessionToken
|
|
@@ -277,7 +277,7 @@ var DeliveryService = class {
|
|
|
277
277
|
params.set("dropoff_lat", String(dropoffLat));
|
|
278
278
|
params.set("dropoff_lng", String(dropoffLng));
|
|
279
279
|
if (country) params.set("country", country);
|
|
280
|
-
return
|
|
280
|
+
return chunkVUG4HTUM_js.safe(
|
|
281
281
|
this.client.get(`/api/v1/delivery/fee?${params.toString()}`)
|
|
282
282
|
);
|
|
283
283
|
}
|
|
@@ -289,7 +289,7 @@ var DeliveryService = class {
|
|
|
289
289
|
params.set("dropoff_lng", String(dropoffLng));
|
|
290
290
|
if (opts?.country) params.set("country", opts.country);
|
|
291
291
|
if (opts?.orderValue != null) params.set("order_value", String(opts.orderValue));
|
|
292
|
-
return
|
|
292
|
+
return chunkVUG4HTUM_js.safe(
|
|
293
293
|
this.client.get(`/api/v1/delivery/options?${params.toString()}`)
|
|
294
294
|
);
|
|
295
295
|
}
|
|
@@ -302,8 +302,8 @@ var SupportService = class {
|
|
|
302
302
|
}
|
|
303
303
|
/** Open (or resume) the customer's widget conversation. */
|
|
304
304
|
async openConversation(opts) {
|
|
305
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
306
|
-
return
|
|
305
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkVUG4HTUM_js.generateIdempotencyKey();
|
|
306
|
+
return chunkVUG4HTUM_js.safe(
|
|
307
307
|
this.client.post("/api/v1/support/conversation", void 0, {
|
|
308
308
|
idempotencyKey
|
|
309
309
|
})
|
|
@@ -311,8 +311,8 @@ var SupportService = class {
|
|
|
311
311
|
}
|
|
312
312
|
/** Send a message in the active conversation. */
|
|
313
313
|
async sendMessage(content, opts) {
|
|
314
|
-
const idempotencyKey = opts?.idempotencyKey ??
|
|
315
|
-
return
|
|
314
|
+
const idempotencyKey = opts?.idempotencyKey ?? chunkVUG4HTUM_js.generateIdempotencyKey();
|
|
315
|
+
return chunkVUG4HTUM_js.safe(
|
|
316
316
|
this.client.post(
|
|
317
317
|
"/api/v1/support/conversation/messages",
|
|
318
318
|
{ content },
|
|
@@ -327,7 +327,7 @@ var SupportService = class {
|
|
|
327
327
|
if (options.limit) params.set("limit", String(options.limit));
|
|
328
328
|
const query = params.toString();
|
|
329
329
|
const path = query ? `/api/v1/support/conversation/messages?${query}` : "/api/v1/support/conversation/messages";
|
|
330
|
-
return
|
|
330
|
+
return chunkVUG4HTUM_js.safe(this.client.get(path));
|
|
331
331
|
}
|
|
332
332
|
};
|
|
333
333
|
|
|
@@ -403,16 +403,16 @@ function isRetryable(error) {
|
|
|
403
403
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
404
404
|
return true;
|
|
405
405
|
}
|
|
406
|
-
if (error instanceof
|
|
406
|
+
if (error instanceof chunkAETVRBKI_js.CimplifyError) {
|
|
407
407
|
return error.retryable;
|
|
408
408
|
}
|
|
409
409
|
return false;
|
|
410
410
|
}
|
|
411
411
|
function toNetworkError(error, isTestMode) {
|
|
412
412
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
413
|
-
return
|
|
414
|
-
new
|
|
415
|
-
|
|
413
|
+
return chunkAETVRBKI_js.enrichError(
|
|
414
|
+
new chunkAETVRBKI_js.CimplifyError(
|
|
415
|
+
chunkAETVRBKI_js.ErrorCode.TIMEOUT,
|
|
416
416
|
"Request timed out. Please check your connection and try again.",
|
|
417
417
|
true
|
|
418
418
|
),
|
|
@@ -420,21 +420,21 @@ function toNetworkError(error, isTestMode) {
|
|
|
420
420
|
);
|
|
421
421
|
}
|
|
422
422
|
if (error instanceof TypeError && error.message.includes("fetch")) {
|
|
423
|
-
return
|
|
424
|
-
new
|
|
425
|
-
|
|
423
|
+
return chunkAETVRBKI_js.enrichError(
|
|
424
|
+
new chunkAETVRBKI_js.CimplifyError(
|
|
425
|
+
chunkAETVRBKI_js.ErrorCode.NETWORK_ERROR,
|
|
426
426
|
"Network error. Please check your internet connection.",
|
|
427
427
|
true
|
|
428
428
|
),
|
|
429
429
|
{ isTestMode }
|
|
430
430
|
);
|
|
431
431
|
}
|
|
432
|
-
if (error instanceof
|
|
433
|
-
return
|
|
432
|
+
if (error instanceof chunkAETVRBKI_js.CimplifyError) {
|
|
433
|
+
return chunkAETVRBKI_js.enrichError(error, { isTestMode });
|
|
434
434
|
}
|
|
435
|
-
return
|
|
436
|
-
new
|
|
437
|
-
|
|
435
|
+
return chunkAETVRBKI_js.enrichError(
|
|
436
|
+
new chunkAETVRBKI_js.CimplifyError(
|
|
437
|
+
chunkAETVRBKI_js.ErrorCode.UNKNOWN_ERROR,
|
|
438
438
|
error instanceof Error ? error.message : "An unknown error occurred",
|
|
439
439
|
false
|
|
440
440
|
),
|
|
@@ -615,8 +615,8 @@ var CimplifyClient = class {
|
|
|
615
615
|
this.businessIdResolvePromise = (async () => {
|
|
616
616
|
const result = await this.business.getInfo();
|
|
617
617
|
if (!result.ok || !result.value?.id) {
|
|
618
|
-
throw new
|
|
619
|
-
|
|
618
|
+
throw new chunkAETVRBKI_js.CimplifyError(
|
|
619
|
+
chunkAETVRBKI_js.ErrorCode.NOT_FOUND,
|
|
620
620
|
"Unable to resolve business ID from the current public key.",
|
|
621
621
|
true
|
|
622
622
|
);
|
|
@@ -725,7 +725,7 @@ var CimplifyClient = class {
|
|
|
725
725
|
if (response.status >= 400 && response.status < 500) {
|
|
726
726
|
this.hooks.onRequestError?.({
|
|
727
727
|
...context,
|
|
728
|
-
error: new
|
|
728
|
+
error: new chunkAETVRBKI_js.CimplifyError(
|
|
729
729
|
`HTTP_${response.status}`,
|
|
730
730
|
`Request failed with status ${response.status}`,
|
|
731
731
|
false
|
|
@@ -751,7 +751,7 @@ var CimplifyClient = class {
|
|
|
751
751
|
}
|
|
752
752
|
this.hooks.onRequestError?.({
|
|
753
753
|
...context,
|
|
754
|
-
error: new
|
|
754
|
+
error: new chunkAETVRBKI_js.CimplifyError(
|
|
755
755
|
"SERVER_ERROR",
|
|
756
756
|
`Server error ${response.status} after ${retryCount} retries`,
|
|
757
757
|
false
|
|
@@ -887,17 +887,17 @@ var CimplifyClient = class {
|
|
|
887
887
|
const retryable = typeof json.error === "object" && typeof json.error?.retryable === "boolean" ? json.error.retryable : false;
|
|
888
888
|
if (errorCode === "IDEMPOTENCY_MISMATCH") {
|
|
889
889
|
const originalCreatedAt = typeof json.error === "object" && json.error?.original_created_at || "";
|
|
890
|
-
throw new
|
|
890
|
+
throw new chunkAETVRBKI_js.IdempotencyMismatchError(errorMessage, originalCreatedAt);
|
|
891
891
|
}
|
|
892
|
-
const error =
|
|
893
|
-
new
|
|
892
|
+
const error = chunkAETVRBKI_js.enrichError(
|
|
893
|
+
new chunkAETVRBKI_js.CimplifyError(
|
|
894
894
|
errorCode,
|
|
895
895
|
errorMessage,
|
|
896
896
|
retryable
|
|
897
897
|
),
|
|
898
898
|
{ isTestMode: this.isTestMode() }
|
|
899
899
|
);
|
|
900
|
-
if ((response.status === 401 || error.code ===
|
|
900
|
+
if ((response.status === 401 || error.code === chunkAETVRBKI_js.ErrorCode.UNAUTHORIZED) && this.accessToken) {
|
|
901
901
|
console.warn(
|
|
902
902
|
"[Cimplify] Received 401 Unauthorized. Access token may be missing/expired. Refresh authentication and retry the request."
|
|
903
903
|
);
|
|
@@ -905,8 +905,8 @@ var CimplifyClient = class {
|
|
|
905
905
|
throw error;
|
|
906
906
|
}
|
|
907
907
|
if (json?.success === false || json?.error?.code || json?.error?.message) {
|
|
908
|
-
const error =
|
|
909
|
-
new
|
|
908
|
+
const error = chunkAETVRBKI_js.enrichError(
|
|
909
|
+
new chunkAETVRBKI_js.CimplifyError(
|
|
910
910
|
json.error?.code || "API_ERROR",
|
|
911
911
|
json.error?.message || "An error occurred",
|
|
912
912
|
json.error?.retryable || false
|
|
@@ -922,25 +922,25 @@ var CimplifyClient = class {
|
|
|
922
922
|
}
|
|
923
923
|
get catalogue() {
|
|
924
924
|
if (!this._catalogue) {
|
|
925
|
-
this._catalogue = new
|
|
925
|
+
this._catalogue = new chunkVUG4HTUM_js.CatalogueQueries(this);
|
|
926
926
|
}
|
|
927
927
|
return this._catalogue;
|
|
928
928
|
}
|
|
929
929
|
get cart() {
|
|
930
930
|
if (!this._cart) {
|
|
931
|
-
this._cart = new
|
|
931
|
+
this._cart = new chunkVUG4HTUM_js.CartOperations(this);
|
|
932
932
|
}
|
|
933
933
|
return this._cart;
|
|
934
934
|
}
|
|
935
935
|
get checkout() {
|
|
936
936
|
if (!this._checkout) {
|
|
937
|
-
this._checkout = new
|
|
937
|
+
this._checkout = new chunkVUG4HTUM_js.CheckoutService(this);
|
|
938
938
|
}
|
|
939
939
|
return this._checkout;
|
|
940
940
|
}
|
|
941
941
|
get orders() {
|
|
942
942
|
if (!this._orders) {
|
|
943
|
-
this._orders = new
|
|
943
|
+
this._orders = new chunkVUG4HTUM_js.OrderQueries(this);
|
|
944
944
|
}
|
|
945
945
|
return this._orders;
|
|
946
946
|
}
|
|
@@ -970,43 +970,43 @@ var CimplifyClient = class {
|
|
|
970
970
|
}
|
|
971
971
|
get link() {
|
|
972
972
|
if (!this._link) {
|
|
973
|
-
this._link = new
|
|
973
|
+
this._link = new chunkVUG4HTUM_js.LinkService(this);
|
|
974
974
|
}
|
|
975
975
|
return this._link;
|
|
976
976
|
}
|
|
977
977
|
get auth() {
|
|
978
978
|
if (!this._auth) {
|
|
979
|
-
this._auth = new
|
|
979
|
+
this._auth = new chunkVUG4HTUM_js.AuthService(this);
|
|
980
980
|
}
|
|
981
981
|
return this._auth;
|
|
982
982
|
}
|
|
983
983
|
get business() {
|
|
984
984
|
if (!this._business) {
|
|
985
|
-
this._business = new
|
|
985
|
+
this._business = new chunkVUG4HTUM_js.BusinessService(this);
|
|
986
986
|
}
|
|
987
987
|
return this._business;
|
|
988
988
|
}
|
|
989
989
|
get inventory() {
|
|
990
990
|
if (!this._inventory) {
|
|
991
|
-
this._inventory = new
|
|
991
|
+
this._inventory = new chunkVUG4HTUM_js.InventoryService(this);
|
|
992
992
|
}
|
|
993
993
|
return this._inventory;
|
|
994
994
|
}
|
|
995
995
|
get scheduling() {
|
|
996
996
|
if (!this._scheduling) {
|
|
997
|
-
this._scheduling = new
|
|
997
|
+
this._scheduling = new chunkVUG4HTUM_js.SchedulingService(this);
|
|
998
998
|
}
|
|
999
999
|
return this._scheduling;
|
|
1000
1000
|
}
|
|
1001
1001
|
get lite() {
|
|
1002
1002
|
if (!this._lite) {
|
|
1003
|
-
this._lite = new
|
|
1003
|
+
this._lite = new chunkVUG4HTUM_js.LiteService(this);
|
|
1004
1004
|
}
|
|
1005
1005
|
return this._lite;
|
|
1006
1006
|
}
|
|
1007
1007
|
get fx() {
|
|
1008
1008
|
if (!this._fx) {
|
|
1009
|
-
this._fx = new
|
|
1009
|
+
this._fx = new chunkVUG4HTUM_js.FxService(this);
|
|
1010
1010
|
}
|
|
1011
1011
|
return this._fx;
|
|
1012
1012
|
}
|
|
@@ -1041,7 +1041,7 @@ var CimplifyClient = class {
|
|
|
1041
1041
|
if (businessId) {
|
|
1042
1042
|
this.setBusinessId(businessId);
|
|
1043
1043
|
}
|
|
1044
|
-
return
|
|
1044
|
+
return chunkVUG4HTUM_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
|
|
1045
1045
|
}
|
|
1046
1046
|
};
|
|
1047
1047
|
function createCimplifyClient(config = {}) {
|
|
@@ -153,7 +153,7 @@ var ERROR_SUGGESTIONS = {
|
|
|
153
153
|
INSUFFICIENT_QUANTITY: "Requested quantity exceeds available inventory. Reduce quantity and retry.",
|
|
154
154
|
BUSINESS_ID_REQUIRED: "Business context could not be resolved. Verify the public key and business bootstrap call.",
|
|
155
155
|
INVALID_CART: "Cart is invalid for checkout. Sync cart state, ensure items exist, then retry.",
|
|
156
|
-
ORDER_TYPE_REQUIRED: "Order type is required. Provide one of delivery, pickup, or
|
|
156
|
+
ORDER_TYPE_REQUIRED: "Order type is required. Provide one of delivery, pickup, or dine-in before checkout.",
|
|
157
157
|
NO_PAYMENT_ELEMENT: "PaymentElement is required for processCheckout(). Mount it before triggering checkout.",
|
|
158
158
|
PAYMENT_NOT_MOUNTED: "PaymentElement iframe is not mounted. Mount it in the DOM before processCheckout().",
|
|
159
159
|
AUTH_INCOMPLETE: "AuthElement has not completed authentication. Wait for AUTHENTICATED before checkout.",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { moneyFromNumber, money } from './chunk-
|
|
1
|
+
import { moneyFromNumber, money } from './chunk-K5EN2W2Q.mjs';
|
|
2
2
|
|
|
3
3
|
// src/utils/price.ts
|
|
4
4
|
var CURRENCY_SYMBOLS = {
|
|
@@ -319,9 +319,9 @@ function normalizePaymentResponse(response) {
|
|
|
319
319
|
};
|
|
320
320
|
}
|
|
321
321
|
if (isWebPaymentResponse(response)) {
|
|
322
|
-
const objectAuthType = response.authorization_type && typeof response.authorization_type === "object" && "address" in response.authorization_type ?
|
|
322
|
+
const objectAuthType = response.authorization_type && typeof response.authorization_type === "object" && "address" in response.authorization_type ? { address: response.authorization_type.address } : void 0;
|
|
323
323
|
const authType = typeof response.authorization_type === "string" ? response.authorization_type.trim().toLowerCase().replace(/[\s-]+/g, "_") : void 0;
|
|
324
|
-
const validStringAuthTypes = ["otp", "pin", "phone", "birthday"
|
|
324
|
+
const validStringAuthTypes = ["otp", "pin", "phone", "birthday"];
|
|
325
325
|
const safeAuthType = objectAuthType || (authType && validStringAuthTypes.includes(authType) ? authType : void 0);
|
|
326
326
|
return {
|
|
327
327
|
provider: response.transaction.provider_type?.toLowerCase() || "unknown",
|
|
@@ -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-NN3WC7XZ.mjs';
|
|
2
|
+
import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-K5EN2W2Q.mjs';
|
|
3
3
|
|
|
4
4
|
// src/store-credit.ts
|
|
5
5
|
var StoreCreditQueries = class {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isPaymentStatusRequiresAction, normalizeStatusResponse, isPaymentStatusSuccess, isPaymentStatusFailure } from './chunk-
|
|
2
|
-
import { CimplifyError, currencyCode, ErrorCode, enrichError, getErrorHint } from './chunk-
|
|
1
|
+
import { isPaymentStatusRequiresAction, normalizeStatusResponse, isPaymentStatusSuccess, isPaymentStatusFailure } from './chunk-KFLGQGMC.mjs';
|
|
2
|
+
import { CimplifyError, currencyCode, ErrorCode, enrichError, getErrorHint } from './chunk-K5EN2W2Q.mjs';
|
|
3
3
|
|
|
4
4
|
// src/types/result.ts
|
|
5
5
|
function ok(value) {
|
|
@@ -2090,7 +2090,7 @@ var InventoryService = class {
|
|
|
2090
2090
|
async getAvailableQuantity(productId, locationId) {
|
|
2091
2091
|
const result = await this.getProductStock(productId, locationId);
|
|
2092
2092
|
if (!result.ok) return result;
|
|
2093
|
-
return ok(result.value.available_quantity);
|
|
2093
|
+
return ok(result.value.available_quantity ?? void 0);
|
|
2094
2094
|
}
|
|
2095
2095
|
};
|
|
2096
2096
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAETVRBKI_js = require('./chunk-AETVRBKI.js');
|
|
4
4
|
|
|
5
5
|
// src/utils/price.ts
|
|
6
6
|
var CURRENCY_SYMBOLS = {
|
|
@@ -321,9 +321,9 @@ function normalizePaymentResponse(response) {
|
|
|
321
321
|
};
|
|
322
322
|
}
|
|
323
323
|
if (isWebPaymentResponse(response)) {
|
|
324
|
-
const objectAuthType = response.authorization_type && typeof response.authorization_type === "object" && "address" in response.authorization_type ?
|
|
324
|
+
const objectAuthType = response.authorization_type && typeof response.authorization_type === "object" && "address" in response.authorization_type ? { address: response.authorization_type.address } : void 0;
|
|
325
325
|
const authType = typeof response.authorization_type === "string" ? response.authorization_type.trim().toLowerCase().replace(/[\s-]+/g, "_") : void 0;
|
|
326
|
-
const validStringAuthTypes = ["otp", "pin", "phone", "birthday"
|
|
326
|
+
const validStringAuthTypes = ["otp", "pin", "phone", "birthday"];
|
|
327
327
|
const safeAuthType = objectAuthType || (authType && validStringAuthTypes.includes(authType) ? authType : void 0);
|
|
328
328
|
return {
|
|
329
329
|
provider: response.transaction.provider_type?.toLowerCase() || "unknown",
|
|
@@ -440,14 +440,14 @@ function normalizeStatusResponse(response) {
|
|
|
440
440
|
return {
|
|
441
441
|
status: "pending",
|
|
442
442
|
paid: false,
|
|
443
|
-
amount:
|
|
443
|
+
amount: chunkAETVRBKI_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" ? chunkAETVRBKI_js.money(res.amount) : typeof res.amount === "number" && Number.isFinite(res.amount) ? chunkAETVRBKI_js.moneyFromNumber(res.amount) : chunkAETVRBKI_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,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkPTPOQVXS_js = require('./chunk-PTPOQVXS.js');
|
|
4
|
+
var chunkAETVRBKI_js = require('./chunk-AETVRBKI.js');
|
|
5
5
|
|
|
6
6
|
// src/types/result.ts
|
|
7
7
|
function ok(value) {
|
|
@@ -85,11 +85,11 @@ function generateIdempotencyKey(prefix = "idem") {
|
|
|
85
85
|
|
|
86
86
|
// src/internal/safe.ts
|
|
87
87
|
function toCimplifyError(error) {
|
|
88
|
-
if (error instanceof
|
|
88
|
+
if (error instanceof chunkAETVRBKI_js.CimplifyError) return chunkAETVRBKI_js.enrichError(error);
|
|
89
89
|
if (error instanceof Error) {
|
|
90
|
-
return
|
|
90
|
+
return chunkAETVRBKI_js.enrichError(new chunkAETVRBKI_js.CimplifyError(chunkAETVRBKI_js.ErrorCode.UNKNOWN_ERROR, error.message, false));
|
|
91
91
|
}
|
|
92
|
-
return
|
|
92
|
+
return chunkAETVRBKI_js.enrichError(new chunkAETVRBKI_js.CimplifyError(chunkAETVRBKI_js.ErrorCode.UNKNOWN_ERROR, String(error), false));
|
|
93
93
|
}
|
|
94
94
|
async function safe(promise) {
|
|
95
95
|
try {
|
|
@@ -651,7 +651,7 @@ var CartOperations = class {
|
|
|
651
651
|
if (typeof updates.quantity !== "number") {
|
|
652
652
|
return {
|
|
653
653
|
ok: false,
|
|
654
|
-
error: new
|
|
654
|
+
error: new chunkAETVRBKI_js.CimplifyError(
|
|
655
655
|
"VALIDATION_ERROR",
|
|
656
656
|
"updateItem requires a quantity; richer mid-cart edits are not supported"
|
|
657
657
|
)
|
|
@@ -1097,7 +1097,7 @@ var CheckoutResolver = class {
|
|
|
1097
1097
|
}
|
|
1098
1098
|
}
|
|
1099
1099
|
}
|
|
1100
|
-
if (checkoutResult.requires_authorization ||
|
|
1100
|
+
if (checkoutResult.requires_authorization || chunkPTPOQVXS_js.isPaymentStatusRequiresAction(checkoutResult.payment_status)) {
|
|
1101
1101
|
const authorization = await this.handleAuthorization({
|
|
1102
1102
|
authorizationType,
|
|
1103
1103
|
paymentReference,
|
|
@@ -1271,18 +1271,18 @@ var CheckoutResolver = class {
|
|
|
1271
1271
|
if (statusResult.value.reference) {
|
|
1272
1272
|
paymentReference = statusResult.value.reference;
|
|
1273
1273
|
}
|
|
1274
|
-
const normalized =
|
|
1275
|
-
if (normalized.paid ||
|
|
1274
|
+
const normalized = chunkPTPOQVXS_js.normalizeStatusResponse(statusResult.value);
|
|
1275
|
+
if (normalized.paid || chunkPTPOQVXS_js.isPaymentStatusSuccess(normalized.status)) {
|
|
1276
1276
|
return this.finalizeSuccess(latestCheckoutResult);
|
|
1277
1277
|
}
|
|
1278
|
-
if (
|
|
1278
|
+
if (chunkPTPOQVXS_js.isPaymentStatusFailure(normalized.status)) {
|
|
1279
1279
|
return this.fail(
|
|
1280
1280
|
normalized.status ? normalized.status.toUpperCase() : "PAYMENT_FAILED",
|
|
1281
1281
|
normalized.message || "Payment failed during confirmation.",
|
|
1282
1282
|
false
|
|
1283
1283
|
);
|
|
1284
1284
|
}
|
|
1285
|
-
if (
|
|
1285
|
+
if (chunkPTPOQVXS_js.isPaymentStatusRequiresAction(normalized.status)) {
|
|
1286
1286
|
const authorization = await this.handleAuthorization({
|
|
1287
1287
|
authorizationType,
|
|
1288
1288
|
paymentReference,
|
|
@@ -1313,8 +1313,8 @@ var CheckoutResolver = class {
|
|
|
1313
1313
|
try {
|
|
1314
1314
|
const finalResult = await this.client.checkout.pollPaymentStatus(input.orderId);
|
|
1315
1315
|
if (finalResult.ok) {
|
|
1316
|
-
const normalized =
|
|
1317
|
-
if (normalized.paid ||
|
|
1316
|
+
const normalized = chunkPTPOQVXS_js.normalizeStatusResponse(finalResult.value);
|
|
1317
|
+
if (normalized.paid || chunkPTPOQVXS_js.isPaymentStatusSuccess(normalized.status)) {
|
|
1318
1318
|
return this.finalizeSuccess(latestCheckoutResult);
|
|
1319
1319
|
}
|
|
1320
1320
|
}
|
|
@@ -1510,12 +1510,12 @@ var CheckoutResolver = class {
|
|
|
1510
1510
|
};
|
|
1511
1511
|
}
|
|
1512
1512
|
isSuccessfulStatus(status) {
|
|
1513
|
-
const normalized =
|
|
1514
|
-
return normalized.paid ||
|
|
1513
|
+
const normalized = chunkPTPOQVXS_js.normalizeStatusResponse({ status, paid: false });
|
|
1514
|
+
return normalized.paid || chunkPTPOQVXS_js.isPaymentStatusSuccess(normalized.status);
|
|
1515
1515
|
}
|
|
1516
1516
|
isFailureStatus(status) {
|
|
1517
|
-
const normalized =
|
|
1518
|
-
return
|
|
1517
|
+
const normalized = chunkPTPOQVXS_js.normalizeStatusResponse({ status, paid: false });
|
|
1518
|
+
return chunkPTPOQVXS_js.isPaymentStatusFailure(normalized.status);
|
|
1519
1519
|
}
|
|
1520
1520
|
ensureNotAborted() {
|
|
1521
1521
|
if (this.signal?.aborted) {
|
|
@@ -1574,7 +1574,7 @@ var CheckoutService = class {
|
|
|
1574
1574
|
}
|
|
1575
1575
|
async initializePayment(_orderId, _method) {
|
|
1576
1576
|
return err(
|
|
1577
|
-
new
|
|
1577
|
+
new chunkAETVRBKI_js.CimplifyError(
|
|
1578
1578
|
"NOT_IMPLEMENTED",
|
|
1579
1579
|
"initializePayment is not available in REST mode.",
|
|
1580
1580
|
false
|
|
@@ -1647,11 +1647,11 @@ var CheckoutService = class {
|
|
|
1647
1647
|
pay_currency: data.pay_currency,
|
|
1648
1648
|
fx_quote_id: data.fx_quote_id
|
|
1649
1649
|
};
|
|
1650
|
-
const baseCurrency =
|
|
1650
|
+
const baseCurrency = chunkAETVRBKI_js.currencyCode(
|
|
1651
1651
|
(cart.pricing.currency || checkoutData.pay_currency || "GHS").toUpperCase()
|
|
1652
1652
|
);
|
|
1653
1653
|
const payCurrency = data.pay_currency?.trim().toUpperCase();
|
|
1654
|
-
const payCurrencyCode = payCurrency ?
|
|
1654
|
+
const payCurrencyCode = payCurrency ? chunkAETVRBKI_js.currencyCode(payCurrency) : void 0;
|
|
1655
1655
|
const cartTotalAmount = typeof cart.pricing.total_price === "number" ? cart.pricing.total_price : Number.parseFloat(cart.pricing.total_price || "0");
|
|
1656
1656
|
if (payCurrencyCode && payCurrencyCode !== baseCurrency && !checkoutData.fx_quote_id && Number.isFinite(cartTotalAmount) && cartTotalAmount > 0) {
|
|
1657
1657
|
const fxQuoteResult = await this.client.fx.lockQuote({
|
|
@@ -2012,7 +2012,7 @@ var BusinessService = class {
|
|
|
2012
2012
|
if (!result.ok) return err(result.error);
|
|
2013
2013
|
const location = result.value.find((item) => item.id === locationId);
|
|
2014
2014
|
if (!location) {
|
|
2015
|
-
return err(new
|
|
2015
|
+
return err(new chunkAETVRBKI_js.CimplifyError(chunkAETVRBKI_js.ErrorCode.NOT_FOUND, `Location not found: ${locationId}`, false));
|
|
2016
2016
|
}
|
|
2017
2017
|
return ok(location);
|
|
2018
2018
|
}
|
|
@@ -2092,7 +2092,7 @@ var InventoryService = class {
|
|
|
2092
2092
|
async getAvailableQuantity(productId, locationId) {
|
|
2093
2093
|
const result = await this.getProductStock(productId, locationId);
|
|
2094
2094
|
if (!result.ok) return result;
|
|
2095
|
-
return ok(result.value.available_quantity);
|
|
2095
|
+
return ok(result.value.available_quantity ?? void 0);
|
|
2096
2096
|
}
|
|
2097
2097
|
};
|
|
2098
2098
|
|
|
@@ -2628,7 +2628,7 @@ function startRedirectSignIn(opts, authorizeEndpoint, pkce, state) {
|
|
|
2628
2628
|
|
|
2629
2629
|
// src/elements.ts
|
|
2630
2630
|
function toCheckoutError(code, message, recoverable) {
|
|
2631
|
-
const hint =
|
|
2631
|
+
const hint = chunkAETVRBKI_js.getErrorHint(code);
|
|
2632
2632
|
return {
|
|
2633
2633
|
success: false,
|
|
2634
2634
|
error: {
|