@cimplify/sdk 0.85.0 → 0.87.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-XA3ZNR75.js → chunk-AETVRBKI.js} +1 -1
- package/dist/{chunk-GIFVSWYJ.mjs → chunk-APBLFZ2I.mjs} +5 -5
- package/dist/{chunk-HPN5R3K2.js → chunk-FWEF2DHR.js} +80 -28
- package/dist/{chunk-DU4IX2I2.mjs → chunk-J7JDCPNW.mjs} +2 -2
- package/dist/{chunk-AMZXALF6.mjs → chunk-K5EN2W2Q.mjs} +1 -1
- package/dist/{chunk-TD3AY34U.mjs → chunk-KFLGQGMC.mjs} +3 -3
- package/dist/{chunk-E6T5VJMG.mjs → chunk-OZDDHSIB.mjs} +9 -1
- package/dist/{chunk-GFM5JW45.js → chunk-P3352VXA.js} +62 -62
- package/dist/{chunk-7Y2O3E4D.js → chunk-PTPOQVXS.js} +5 -5
- package/dist/{chunk-A6J7W6DH.js → chunk-PWDX5N2M.js} +4 -4
- package/dist/{chunk-NWUEWUX2.mjs → chunk-RCGSHS2Q.mjs} +2 -2
- package/dist/{chunk-NWTCBGJ2.js → chunk-ROBTTS3Q.js} +7 -7
- package/dist/{chunk-IQLJJW2H.js → chunk-T7Z25EY4.js} +9 -0
- package/dist/{chunk-7BM56JET.mjs → chunk-U57TYZLD.mjs} +60 -8
- package/dist/{client-WKKxIiF1.d.ts → client-BIt37FjS.d.mts} +541 -542
- package/dist/{client-BEhIE0Dm.d.mts → client-BMOdyC1F.d.mts} +2 -2
- package/dist/{client-BT5gaiGR.d.ts → client-BvWtk822.d.ts} +2 -2
- package/dist/{client-DLtwQ-jI.d.mts → client-Dfl6WY2F.d.ts} +541 -542
- package/dist/{index-DZz6hdrT.d.mts → index-BxOJ3BLn.d.mts} +3 -3
- package/dist/{index-BrC1x2kK.d.ts → index-DW6JifS1.d.ts} +3 -3
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +133 -129
- package/dist/index.mjs +6 -6
- package/dist/mock/cli.mjs +5 -5
- package/dist/mock/library.js +5 -5
- package/dist/mock/library.mjs +5 -5
- package/dist/mock/msw.js +5 -5
- package/dist/mock/msw.mjs +5 -5
- package/dist/{payment-D1f3ZQPC.d.ts → payment-CLp__KpE.d.mts} +3 -3
- package/dist/{payment-Dh-6cRcV.d.mts → payment-DJrvivO_.d.ts} +3 -3
- package/dist/{price-CQdOJoX-.d.ts → price-B7_UzClY.d.ts} +1 -1
- package/dist/{price-4T7dlhxM.d.mts → price-Ddk8Vr8z.d.mts} +1 -1
- package/dist/product-C0Lr81ze.d.mts +5439 -0
- package/dist/product-C0Lr81ze.d.ts +5439 -0
- package/dist/react.d.mts +24 -7
- package/dist/react.d.ts +24 -7
- package/dist/react.js +224 -186
- package/dist/react.mjs +57 -22
- package/dist/{server-DjK98UW-.d.mts → server-0TnEJt8U.d.mts} +2 -2
- package/dist/{server-DvThXldo.d.ts → server-P2G43ENi.d.ts} +2 -2
- 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 +5 -2
- package/registry/currency-selector.json +1 -1
- package/registry/digital-product-card.json +1 -1
- package/registry/digital-product-layout.json +1 -1
- package/registry/product-card.json +1 -1
- package/dist/product-RJMIdCAf.d.mts +0 -1582
- package/dist/product-RJMIdCAf.d.ts +0 -1582
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkFWEF2DHR_js = require('./chunk-FWEF2DHR.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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_js.safe(this.client.get(path));
|
|
107
107
|
}
|
|
108
108
|
async dismissMessage(code) {
|
|
109
|
-
return
|
|
109
|
+
return chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 ?? chunkFWEF2DHR_js.generateIdempotencyKey();
|
|
154
|
+
return chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 ?? chunkFWEF2DHR_js.generateIdempotencyKey();
|
|
177
|
+
return chunkFWEF2DHR_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 ?? chunkFWEF2DHR_js.generateIdempotencyKey();
|
|
194
|
+
return chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 ?? chunkFWEF2DHR_js.generateIdempotencyKey();
|
|
306
|
+
return chunkFWEF2DHR_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 ?? chunkFWEF2DHR_js.generateIdempotencyKey();
|
|
315
|
+
return chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_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 chunkFWEF2DHR_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
|
|
1045
1045
|
}
|
|
1046
1046
|
};
|
|
1047
1047
|
function createCimplifyClient(config = {}) {
|
|
@@ -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 chunkROBTTS3Q_js = require('./chunk-ROBTTS3Q.js');
|
|
4
|
+
var chunkP3352VXA_js = require('./chunk-P3352VXA.js');
|
|
5
5
|
var zod = require('zod');
|
|
6
6
|
|
|
7
7
|
var cimplifyRegistry = zod.z.registry();
|
|
@@ -600,7 +600,7 @@ async function toForwardedRequest(input, init) {
|
|
|
600
600
|
};
|
|
601
601
|
}
|
|
602
602
|
function createTestClient(options = {}) {
|
|
603
|
-
const mock =
|
|
603
|
+
const mock = chunkROBTTS3Q_js.createMockApp(options);
|
|
604
604
|
let sessionToken;
|
|
605
605
|
const fetchImpl = async (input, init) => {
|
|
606
606
|
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
@@ -619,7 +619,7 @@ function createTestClient(options = {}) {
|
|
|
619
619
|
if (echoed) sessionToken = echoed;
|
|
620
620
|
return res;
|
|
621
621
|
};
|
|
622
|
-
const client =
|
|
622
|
+
const client = chunkP3352VXA_js.createCimplifyClient({
|
|
623
623
|
baseUrl: TEST_BASE_URL,
|
|
624
624
|
// Link mock lives at /v1/link on the same Hono app, so point the SDK's
|
|
625
625
|
// 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-U57TYZLD.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,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAETVRBKI_js = require('./chunk-AETVRBKI.js');
|
|
4
4
|
var chunkOWW5GUSB_js = require('./chunk-OWW5GUSB.js');
|
|
5
5
|
|
|
6
6
|
// ../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/compose.js
|
|
@@ -2076,8 +2076,8 @@ var MockError = class extends Error {
|
|
|
2076
2076
|
};
|
|
2077
2077
|
}
|
|
2078
2078
|
};
|
|
2079
|
-
var notFound = (msg) => new MockError(
|
|
2080
|
-
var validation = (msg, ctx) => new MockError(
|
|
2079
|
+
var notFound = (msg) => new MockError(chunkAETVRBKI_js.ErrorCode.NOT_FOUND, msg, 404);
|
|
2080
|
+
var validation = (msg, ctx) => new MockError(chunkAETVRBKI_js.ErrorCode.VALIDATION_ERROR, msg, 400, ctx);
|
|
2081
2081
|
|
|
2082
2082
|
// src/mock/routes/_helpers.ts
|
|
2083
2083
|
function authMiddleware(deps) {
|
|
@@ -2443,7 +2443,7 @@ function buildV1(deps) {
|
|
|
2443
2443
|
return tryRoute(c, () => deps.scheduling.cancelBooking(c.req.param("booking_id"), body.reason));
|
|
2444
2444
|
});
|
|
2445
2445
|
app.get("/lite/bootstrap", (c) => tryRoute(c, () => deps.lite.bootstrap(deps.defaultBusinessId)));
|
|
2446
|
-
app.get("/lite/
|
|
2446
|
+
app.get("/lite/resources/:resource_id", (c) => tryRoute(c, () => deps.lite.getResource(c.req.param("resource_id"))));
|
|
2447
2447
|
app.get("/lite/menu", (c) => tryRoute(c, () => deps.lite.getMenu(deps.defaultBusinessId)));
|
|
2448
2448
|
app.get("/lite/menu/categories/:category_id", (c) => tryRoute(c, () => deps.lite.getMenuCategory(c.req.param("category_id"))));
|
|
2449
2449
|
app.get("/fx/rate", (c) => tryRoute(c, () => deps.fx.getRate(c.req.query("from") ?? "USD", c.req.query("to") ?? "GHS")));
|
|
@@ -2824,7 +2824,7 @@ var ELEMENT_HANDLER_JS = `/* eslint-disable */
|
|
|
2824
2824
|
'<select id="order-type">' +
|
|
2825
2825
|
' <option value="delivery">Delivery</option>' +
|
|
2826
2826
|
' <option value="pickup">Pickup</option>' +
|
|
2827
|
-
' <option value="
|
|
2827
|
+
' <option value="dine-in">Dine-in</option>' +
|
|
2828
2828
|
'</select>' +
|
|
2829
2829
|
'<label>Customer name</label>' +
|
|
2830
2830
|
'<input id="cust-name" value="' + (qs.get("name") || "Test Customer") + '">' +
|
|
@@ -5546,8 +5546,8 @@ function createLiteService(opts) {
|
|
|
5546
5546
|
tables: []
|
|
5547
5547
|
};
|
|
5548
5548
|
},
|
|
5549
|
-
|
|
5550
|
-
return { id:
|
|
5549
|
+
getResource(resourceId) {
|
|
5550
|
+
return { id: resourceId, table_number: resourceId.slice(-2), capacity: 4, occupied: false };
|
|
5551
5551
|
},
|
|
5552
5552
|
getMenu(businessId) {
|
|
5553
5553
|
const products = registry.products.list((p) => p.business_id === businessId);
|
|
@@ -96,6 +96,14 @@ var DURATION_UNIT = {
|
|
|
96
96
|
Months: "months",
|
|
97
97
|
Years: "years"
|
|
98
98
|
};
|
|
99
|
+
var BOUNDARY_KIND = {
|
|
100
|
+
CheckInOut: "check_in_out",
|
|
101
|
+
PickupReturn: "pickup_return",
|
|
102
|
+
DeliveryCollection: "delivery_collection",
|
|
103
|
+
AccessVacate: "access_vacate",
|
|
104
|
+
MoveInOut: "move_in_out",
|
|
105
|
+
Custom: "custom"
|
|
106
|
+
};
|
|
99
107
|
var INPUT_FIELD_TYPE = {
|
|
100
108
|
Text: "text",
|
|
101
109
|
Textarea: "textarea",
|
|
@@ -155,6 +163,7 @@ function appendTransform(url, t) {
|
|
|
155
163
|
return `${url}${url.includes("?") ? "&" : "?"}${query}`;
|
|
156
164
|
}
|
|
157
165
|
|
|
166
|
+
exports.BOUNDARY_KIND = BOUNDARY_KIND;
|
|
158
167
|
exports.CIMPLIFY_CDN_HOSTS = CIMPLIFY_CDN_HOSTS;
|
|
159
168
|
exports.DEFAULT_CDN_BASE_URL = DEFAULT_CDN_BASE_URL;
|
|
160
169
|
exports.DURATION_UNIT = DURATION_UNIT;
|
|
@@ -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) {
|
|
@@ -1551,15 +1551,43 @@ function toTerminalFailure(code, message, recoverable) {
|
|
|
1551
1551
|
}
|
|
1552
1552
|
};
|
|
1553
1553
|
}
|
|
1554
|
+
function isValidCustomerName(name) {
|
|
1555
|
+
const trimmed = (name ?? "").trim();
|
|
1556
|
+
return trimmed.length >= 2 && /\p{L}/u.test(trimmed);
|
|
1557
|
+
}
|
|
1558
|
+
function isOfflinePaymentMethod(method) {
|
|
1559
|
+
return method === "cash" || method === "offline";
|
|
1560
|
+
}
|
|
1554
1561
|
var CheckoutService = class {
|
|
1555
1562
|
constructor(client) {
|
|
1556
1563
|
this.client = client;
|
|
1557
1564
|
}
|
|
1565
|
+
validateCheckoutData(data) {
|
|
1566
|
+
if (isOfflinePaymentMethod(data.payment_method)) {
|
|
1567
|
+
return new CimplifyError(
|
|
1568
|
+
"INVALID_PAYMENT_METHOD",
|
|
1569
|
+
"Offline payment isn't available for online checkout. Please pay by card or mobile money.",
|
|
1570
|
+
false
|
|
1571
|
+
);
|
|
1572
|
+
}
|
|
1573
|
+
if (!isValidCustomerName(data.customer?.name)) {
|
|
1574
|
+
return new CimplifyError(
|
|
1575
|
+
"INVALID_CUSTOMER_NAME",
|
|
1576
|
+
"Enter your name, not a phone number.",
|
|
1577
|
+
false
|
|
1578
|
+
);
|
|
1579
|
+
}
|
|
1580
|
+
return null;
|
|
1581
|
+
}
|
|
1558
1582
|
orderTokenParam(orderId) {
|
|
1559
1583
|
const token = this.client.getOrderToken(orderId);
|
|
1560
1584
|
return token ? `?token=${encodeURIComponent(token)}` : "";
|
|
1561
1585
|
}
|
|
1562
1586
|
async process(data) {
|
|
1587
|
+
const invalid = this.validateCheckoutData(data);
|
|
1588
|
+
if (invalid) {
|
|
1589
|
+
return err(invalid);
|
|
1590
|
+
}
|
|
1563
1591
|
const checkoutData = {
|
|
1564
1592
|
...data,
|
|
1565
1593
|
idempotency_key: data.idempotency_key || generateIdempotencyKey()
|
|
@@ -2090,7 +2118,7 @@ var InventoryService = class {
|
|
|
2090
2118
|
async getAvailableQuantity(productId, locationId) {
|
|
2091
2119
|
const result = await this.getProductStock(productId, locationId);
|
|
2092
2120
|
if (!result.ok) return result;
|
|
2093
|
-
return ok(result.value.available_quantity);
|
|
2121
|
+
return ok(result.value.available_quantity ?? void 0);
|
|
2094
2122
|
}
|
|
2095
2123
|
};
|
|
2096
2124
|
|
|
@@ -2220,9 +2248,9 @@ var LiteService = class {
|
|
|
2220
2248
|
async getBootstrap() {
|
|
2221
2249
|
return safe(this.client.get("/api/v1/lite/bootstrap"));
|
|
2222
2250
|
}
|
|
2223
|
-
async
|
|
2224
|
-
const encodedId = encodeURIComponent(
|
|
2225
|
-
return safe(this.client.get(`/api/v1/lite/
|
|
2251
|
+
async getResource(resourceId) {
|
|
2252
|
+
const encodedId = encodeURIComponent(resourceId);
|
|
2253
|
+
return safe(this.client.get(`/api/v1/lite/resources/${encodedId}`));
|
|
2226
2254
|
}
|
|
2227
2255
|
async getMenu() {
|
|
2228
2256
|
return safe(this.client.get("/api/v1/lite/menu"));
|
|
@@ -3199,6 +3227,7 @@ var CimplifyElement = class {
|
|
|
3199
3227
|
this.pendingInit = null;
|
|
3200
3228
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
3201
3229
|
this.resolvers = /* @__PURE__ */ new Map();
|
|
3230
|
+
this.lastReportedHeight = 0;
|
|
3202
3231
|
this.listening = false;
|
|
3203
3232
|
this.type = type;
|
|
3204
3233
|
this.businessId = businessId;
|
|
@@ -3207,11 +3236,33 @@ var CimplifyElement = class {
|
|
|
3207
3236
|
this.parent = parent;
|
|
3208
3237
|
this.nonce = generateNonce();
|
|
3209
3238
|
this.boundHandleMessage = this.handleMessage.bind(this);
|
|
3239
|
+
this.boundHandleResize = () => this.applyHeight();
|
|
3210
3240
|
if (typeof window !== "undefined") {
|
|
3211
3241
|
window.addEventListener("message", this.boundHandleMessage);
|
|
3242
|
+
window.addEventListener("resize", this.boundHandleResize);
|
|
3212
3243
|
this.listening = true;
|
|
3213
3244
|
}
|
|
3214
3245
|
}
|
|
3246
|
+
/**
|
|
3247
|
+
* Size the iframe to the element's reported content height. The checkout can
|
|
3248
|
+
* exceed the viewport, so cap it at the viewport height — the checkout then
|
|
3249
|
+
* scrolls internally instead of growing (and scrolling) the host page. Other
|
|
3250
|
+
* element types size to content as before.
|
|
3251
|
+
*/
|
|
3252
|
+
applyHeight(reportedHeight) {
|
|
3253
|
+
if (!this.iframe) return;
|
|
3254
|
+
if (typeof reportedHeight === "number" && reportedHeight > 0) {
|
|
3255
|
+
this.lastReportedHeight = reportedHeight;
|
|
3256
|
+
}
|
|
3257
|
+
const content = this.lastReportedHeight;
|
|
3258
|
+
if (!content) return;
|
|
3259
|
+
if (this.type !== "checkout" || typeof window === "undefined") {
|
|
3260
|
+
this.iframe.style.height = `${content}px`;
|
|
3261
|
+
return;
|
|
3262
|
+
}
|
|
3263
|
+
const capped = Math.max(320, Math.min(content, window.innerHeight));
|
|
3264
|
+
this.iframe.style.height = `${capped}px`;
|
|
3265
|
+
}
|
|
3215
3266
|
mount(container) {
|
|
3216
3267
|
if (this.mounted) {
|
|
3217
3268
|
console.warn(`Element ${this.type} is already mounted`);
|
|
@@ -3244,6 +3295,7 @@ var CimplifyElement = class {
|
|
|
3244
3295
|
this.resolvers.clear();
|
|
3245
3296
|
if (this.listening && typeof window !== "undefined") {
|
|
3246
3297
|
window.removeEventListener("message", this.boundHandleMessage);
|
|
3298
|
+
window.removeEventListener("resize", this.boundHandleResize);
|
|
3247
3299
|
this.listening = false;
|
|
3248
3300
|
}
|
|
3249
3301
|
this.parent._removeElement(this.type, this);
|
|
@@ -3369,7 +3421,7 @@ var CimplifyElement = class {
|
|
|
3369
3421
|
switch (message.type) {
|
|
3370
3422
|
case MESSAGE_TYPES.READY:
|
|
3371
3423
|
this.ready = true;
|
|
3372
|
-
if (
|
|
3424
|
+
if (message.height) this.applyHeight(message.height);
|
|
3373
3425
|
if (this.pendingInit) {
|
|
3374
3426
|
const { publicKey } = this.pendingInit;
|
|
3375
3427
|
this.sendMessage({
|
|
@@ -3393,7 +3445,7 @@ var CimplifyElement = class {
|
|
|
3393
3445
|
this.emit(EVENT_TYPES.READY, { height: message.height });
|
|
3394
3446
|
break;
|
|
3395
3447
|
case MESSAGE_TYPES.HEIGHT_CHANGE:
|
|
3396
|
-
|
|
3448
|
+
this.applyHeight(message.height);
|
|
3397
3449
|
break;
|
|
3398
3450
|
case MESSAGE_TYPES.ERROR:
|
|
3399
3451
|
this.emit(EVENT_TYPES.ERROR, { code: message.code, message: message.message });
|