@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
package/dist/advanced.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { k as AuthService, C as BusinessService,
|
|
2
|
-
import './product-
|
|
3
|
-
import './payment-
|
|
1
|
+
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements, aG as ELEMENT_TYPES, aH as EVENT_TYPES, aK as ElementEventType, aL as ElementOptions, aM as ElementType, aU as ElementsOptions, b0 as FetchQuoteInput, b9 as FxService, bd as GetProductsOptions, bg as InventoryService, bo as LinkService, bs as LiteService, bz as MESSAGE_TYPES, b$ as OrderQueries, cl as PriceQuote, cr as QuoteBundleSelectionInput, cs as QuoteCompositeSelectionInput, ct as QuoteDynamicBuckets, cu as QuoteStatus, cv as QuoteUiMessage, cx as RefreshQuoteInput, cy as RefreshQuoteResult, c_ as SchedulingService, dE as createElements } from './client-BIt37FjS.mjs';
|
|
2
|
+
import './product-C0Lr81ze.mjs';
|
|
3
|
+
import './payment-CLp__KpE.mjs';
|
|
4
4
|
|
|
5
5
|
declare function generateIdempotencyKey(prefix?: string): string;
|
|
6
6
|
|
package/dist/advanced.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { k as AuthService, C as BusinessService,
|
|
2
|
-
import './product-
|
|
3
|
-
import './payment-
|
|
1
|
+
export { k as AuthService, C as BusinessService, O as CartOperations, P as CatalogueQueries, a8 as CheckoutOperations, a8 as CheckoutService, ae as CimplifyElement, af as CimplifyElements, aG as ELEMENT_TYPES, aH as EVENT_TYPES, aK as ElementEventType, aL as ElementOptions, aM as ElementType, aU as ElementsOptions, b0 as FetchQuoteInput, b9 as FxService, bd as GetProductsOptions, bg as InventoryService, bo as LinkService, bs as LiteService, bz as MESSAGE_TYPES, b$ as OrderQueries, cl as PriceQuote, cr as QuoteBundleSelectionInput, cs as QuoteCompositeSelectionInput, ct as QuoteDynamicBuckets, cu as QuoteStatus, cv as QuoteUiMessage, cx as RefreshQuoteInput, cy as RefreshQuoteResult, c_ as SchedulingService, dE as createElements } from './client-Dfl6WY2F.js';
|
|
2
|
+
import './product-C0Lr81ze.js';
|
|
3
|
+
import './payment-DJrvivO_.js';
|
|
4
4
|
|
|
5
5
|
declare function generateIdempotencyKey(prefix?: string): string;
|
|
6
6
|
|
package/dist/advanced.js
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var chunkFWEF2DHR_js = require('./chunk-FWEF2DHR.js');
|
|
4
|
+
require('./chunk-PTPOQVXS.js');
|
|
5
|
+
require('./chunk-AETVRBKI.js');
|
|
6
6
|
require('./chunk-OWW5GUSB.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "AuthService", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkFWEF2DHR_js.AuthService; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "BusinessService", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkFWEF2DHR_js.BusinessService; }
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "CartOperations", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunkFWEF2DHR_js.CartOperations; }
|
|
21
21
|
});
|
|
22
22
|
Object.defineProperty(exports, "CatalogueQueries", {
|
|
23
23
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunkFWEF2DHR_js.CatalogueQueries; }
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "CheckoutOperations", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkFWEF2DHR_js.CheckoutService; }
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "CheckoutService", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkFWEF2DHR_js.CheckoutService; }
|
|
33
33
|
});
|
|
34
34
|
Object.defineProperty(exports, "CimplifyElement", {
|
|
35
35
|
enumerable: true,
|
|
36
|
-
get: function () { return
|
|
36
|
+
get: function () { return chunkFWEF2DHR_js.CimplifyElement; }
|
|
37
37
|
});
|
|
38
38
|
Object.defineProperty(exports, "CimplifyElements", {
|
|
39
39
|
enumerable: true,
|
|
40
|
-
get: function () { return
|
|
40
|
+
get: function () { return chunkFWEF2DHR_js.CimplifyElements; }
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "ELEMENT_TYPES", {
|
|
43
43
|
enumerable: true,
|
|
44
|
-
get: function () { return
|
|
44
|
+
get: function () { return chunkFWEF2DHR_js.ELEMENT_TYPES; }
|
|
45
45
|
});
|
|
46
46
|
Object.defineProperty(exports, "EVENT_TYPES", {
|
|
47
47
|
enumerable: true,
|
|
48
|
-
get: function () { return
|
|
48
|
+
get: function () { return chunkFWEF2DHR_js.EVENT_TYPES; }
|
|
49
49
|
});
|
|
50
50
|
Object.defineProperty(exports, "FxService", {
|
|
51
51
|
enumerable: true,
|
|
52
|
-
get: function () { return
|
|
52
|
+
get: function () { return chunkFWEF2DHR_js.FxService; }
|
|
53
53
|
});
|
|
54
54
|
Object.defineProperty(exports, "InventoryService", {
|
|
55
55
|
enumerable: true,
|
|
56
|
-
get: function () { return
|
|
56
|
+
get: function () { return chunkFWEF2DHR_js.InventoryService; }
|
|
57
57
|
});
|
|
58
58
|
Object.defineProperty(exports, "LinkService", {
|
|
59
59
|
enumerable: true,
|
|
60
|
-
get: function () { return
|
|
60
|
+
get: function () { return chunkFWEF2DHR_js.LinkService; }
|
|
61
61
|
});
|
|
62
62
|
Object.defineProperty(exports, "LiteService", {
|
|
63
63
|
enumerable: true,
|
|
64
|
-
get: function () { return
|
|
64
|
+
get: function () { return chunkFWEF2DHR_js.LiteService; }
|
|
65
65
|
});
|
|
66
66
|
Object.defineProperty(exports, "MESSAGE_TYPES", {
|
|
67
67
|
enumerable: true,
|
|
68
|
-
get: function () { return
|
|
68
|
+
get: function () { return chunkFWEF2DHR_js.MESSAGE_TYPES; }
|
|
69
69
|
});
|
|
70
70
|
Object.defineProperty(exports, "OrderQueries", {
|
|
71
71
|
enumerable: true,
|
|
72
|
-
get: function () { return
|
|
72
|
+
get: function () { return chunkFWEF2DHR_js.OrderQueries; }
|
|
73
73
|
});
|
|
74
74
|
Object.defineProperty(exports, "SchedulingService", {
|
|
75
75
|
enumerable: true,
|
|
76
|
-
get: function () { return
|
|
76
|
+
get: function () { return chunkFWEF2DHR_js.SchedulingService; }
|
|
77
77
|
});
|
|
78
78
|
Object.defineProperty(exports, "createElements", {
|
|
79
79
|
enumerable: true,
|
|
80
|
-
get: function () { return
|
|
80
|
+
get: function () { return chunkFWEF2DHR_js.createElements; }
|
|
81
81
|
});
|
|
82
82
|
Object.defineProperty(exports, "generateIdempotencyKey", {
|
|
83
83
|
enumerable: true,
|
|
84
|
-
get: function () { return
|
|
84
|
+
get: function () { return chunkFWEF2DHR_js.generateIdempotencyKey; }
|
|
85
85
|
});
|
package/dist/advanced.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AuthService, BusinessService, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LinkService, LiteService, MESSAGE_TYPES, OrderQueries, SchedulingService, createElements, generateIdempotencyKey } from './chunk-
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { AuthService, BusinessService, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyElement, CimplifyElements, ELEMENT_TYPES, EVENT_TYPES, FxService, InventoryService, LinkService, LiteService, MESSAGE_TYPES, OrderQueries, SchedulingService, createElements, generateIdempotencyKey } from './chunk-U57TYZLD.mjs';
|
|
2
|
+
import './chunk-KFLGQGMC.mjs';
|
|
3
|
+
import './chunk-K5EN2W2Q.mjs';
|
|
4
4
|
import './chunk-3G6RQLXK.mjs';
|
|
@@ -155,7 +155,7 @@ var ERROR_SUGGESTIONS = {
|
|
|
155
155
|
INSUFFICIENT_QUANTITY: "Requested quantity exceeds available inventory. Reduce quantity and retry.",
|
|
156
156
|
BUSINESS_ID_REQUIRED: "Business context could not be resolved. Verify the public key and business bootstrap call.",
|
|
157
157
|
INVALID_CART: "Cart is invalid for checkout. Sync cart state, ensure items exist, then retry.",
|
|
158
|
-
ORDER_TYPE_REQUIRED: "Order type is required. Provide one of delivery, pickup, or
|
|
158
|
+
ORDER_TYPE_REQUIRED: "Order type is required. Provide one of delivery, pickup, or dine-in before checkout.",
|
|
159
159
|
NO_PAYMENT_ELEMENT: "PaymentElement is required for processCheckout(). Mount it before triggering checkout.",
|
|
160
160
|
PAYMENT_NOT_MOUNTED: "PaymentElement iframe is not mounted. Mount it in the DOM before processCheckout().",
|
|
161
161
|
AUTH_INCOMPLETE: "AuthElement has not completed authentication. Wait for AUTHENTICATED before checkout.",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorCode } from './chunk-
|
|
1
|
+
import { ErrorCode } from './chunk-K5EN2W2Q.mjs';
|
|
2
2
|
import { __publicField, __privateAdd, __privateSet, __privateGet, __privateMethod, __privateWrapper } from './chunk-3G6RQLXK.mjs';
|
|
3
3
|
|
|
4
4
|
// ../node_modules/.bun/hono@4.12.25/node_modules/hono/dist/compose.js
|
|
@@ -2441,7 +2441,7 @@ function buildV1(deps) {
|
|
|
2441
2441
|
return tryRoute(c, () => deps.scheduling.cancelBooking(c.req.param("booking_id"), body.reason));
|
|
2442
2442
|
});
|
|
2443
2443
|
app.get("/lite/bootstrap", (c) => tryRoute(c, () => deps.lite.bootstrap(deps.defaultBusinessId)));
|
|
2444
|
-
app.get("/lite/
|
|
2444
|
+
app.get("/lite/resources/:resource_id", (c) => tryRoute(c, () => deps.lite.getResource(c.req.param("resource_id"))));
|
|
2445
2445
|
app.get("/lite/menu", (c) => tryRoute(c, () => deps.lite.getMenu(deps.defaultBusinessId)));
|
|
2446
2446
|
app.get("/lite/menu/categories/:category_id", (c) => tryRoute(c, () => deps.lite.getMenuCategory(c.req.param("category_id"))));
|
|
2447
2447
|
app.get("/fx/rate", (c) => tryRoute(c, () => deps.fx.getRate(c.req.query("from") ?? "USD", c.req.query("to") ?? "GHS")));
|
|
@@ -2822,7 +2822,7 @@ var ELEMENT_HANDLER_JS = `/* eslint-disable */
|
|
|
2822
2822
|
'<select id="order-type">' +
|
|
2823
2823
|
' <option value="delivery">Delivery</option>' +
|
|
2824
2824
|
' <option value="pickup">Pickup</option>' +
|
|
2825
|
-
' <option value="
|
|
2825
|
+
' <option value="dine-in">Dine-in</option>' +
|
|
2826
2826
|
'</select>' +
|
|
2827
2827
|
'<label>Customer name</label>' +
|
|
2828
2828
|
'<input id="cust-name" value="' + (qs.get("name") || "Test Customer") + '">' +
|
|
@@ -5544,8 +5544,8 @@ function createLiteService(opts) {
|
|
|
5544
5544
|
tables: []
|
|
5545
5545
|
};
|
|
5546
5546
|
},
|
|
5547
|
-
|
|
5548
|
-
return { id:
|
|
5547
|
+
getResource(resourceId) {
|
|
5548
|
+
return { id: resourceId, table_number: resourceId.slice(-2), capacity: 4, occupied: false };
|
|
5549
5549
|
},
|
|
5550
5550
|
getMenu(businessId) {
|
|
5551
5551
|
const products = registry.products.list((p) => p.business_id === businessId);
|
|
@@ -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) {
|
|
@@ -1553,15 +1553,43 @@ function toTerminalFailure(code, message, recoverable) {
|
|
|
1553
1553
|
}
|
|
1554
1554
|
};
|
|
1555
1555
|
}
|
|
1556
|
+
function isValidCustomerName(name) {
|
|
1557
|
+
const trimmed = (name ?? "").trim();
|
|
1558
|
+
return trimmed.length >= 2 && /\p{L}/u.test(trimmed);
|
|
1559
|
+
}
|
|
1560
|
+
function isOfflinePaymentMethod(method) {
|
|
1561
|
+
return method === "cash" || method === "offline";
|
|
1562
|
+
}
|
|
1556
1563
|
var CheckoutService = class {
|
|
1557
1564
|
constructor(client) {
|
|
1558
1565
|
this.client = client;
|
|
1559
1566
|
}
|
|
1567
|
+
validateCheckoutData(data) {
|
|
1568
|
+
if (isOfflinePaymentMethod(data.payment_method)) {
|
|
1569
|
+
return new chunkAETVRBKI_js.CimplifyError(
|
|
1570
|
+
"INVALID_PAYMENT_METHOD",
|
|
1571
|
+
"Offline payment isn't available for online checkout. Please pay by card or mobile money.",
|
|
1572
|
+
false
|
|
1573
|
+
);
|
|
1574
|
+
}
|
|
1575
|
+
if (!isValidCustomerName(data.customer?.name)) {
|
|
1576
|
+
return new chunkAETVRBKI_js.CimplifyError(
|
|
1577
|
+
"INVALID_CUSTOMER_NAME",
|
|
1578
|
+
"Enter your name, not a phone number.",
|
|
1579
|
+
false
|
|
1580
|
+
);
|
|
1581
|
+
}
|
|
1582
|
+
return null;
|
|
1583
|
+
}
|
|
1560
1584
|
orderTokenParam(orderId) {
|
|
1561
1585
|
const token = this.client.getOrderToken(orderId);
|
|
1562
1586
|
return token ? `?token=${encodeURIComponent(token)}` : "";
|
|
1563
1587
|
}
|
|
1564
1588
|
async process(data) {
|
|
1589
|
+
const invalid = this.validateCheckoutData(data);
|
|
1590
|
+
if (invalid) {
|
|
1591
|
+
return err(invalid);
|
|
1592
|
+
}
|
|
1565
1593
|
const checkoutData = {
|
|
1566
1594
|
...data,
|
|
1567
1595
|
idempotency_key: data.idempotency_key || generateIdempotencyKey()
|
|
@@ -1574,7 +1602,7 @@ var CheckoutService = class {
|
|
|
1574
1602
|
}
|
|
1575
1603
|
async initializePayment(_orderId, _method) {
|
|
1576
1604
|
return err(
|
|
1577
|
-
new
|
|
1605
|
+
new chunkAETVRBKI_js.CimplifyError(
|
|
1578
1606
|
"NOT_IMPLEMENTED",
|
|
1579
1607
|
"initializePayment is not available in REST mode.",
|
|
1580
1608
|
false
|
|
@@ -1647,11 +1675,11 @@ var CheckoutService = class {
|
|
|
1647
1675
|
pay_currency: data.pay_currency,
|
|
1648
1676
|
fx_quote_id: data.fx_quote_id
|
|
1649
1677
|
};
|
|
1650
|
-
const baseCurrency =
|
|
1678
|
+
const baseCurrency = chunkAETVRBKI_js.currencyCode(
|
|
1651
1679
|
(cart.pricing.currency || checkoutData.pay_currency || "GHS").toUpperCase()
|
|
1652
1680
|
);
|
|
1653
1681
|
const payCurrency = data.pay_currency?.trim().toUpperCase();
|
|
1654
|
-
const payCurrencyCode = payCurrency ?
|
|
1682
|
+
const payCurrencyCode = payCurrency ? chunkAETVRBKI_js.currencyCode(payCurrency) : void 0;
|
|
1655
1683
|
const cartTotalAmount = typeof cart.pricing.total_price === "number" ? cart.pricing.total_price : Number.parseFloat(cart.pricing.total_price || "0");
|
|
1656
1684
|
if (payCurrencyCode && payCurrencyCode !== baseCurrency && !checkoutData.fx_quote_id && Number.isFinite(cartTotalAmount) && cartTotalAmount > 0) {
|
|
1657
1685
|
const fxQuoteResult = await this.client.fx.lockQuote({
|
|
@@ -2012,7 +2040,7 @@ var BusinessService = class {
|
|
|
2012
2040
|
if (!result.ok) return err(result.error);
|
|
2013
2041
|
const location = result.value.find((item) => item.id === locationId);
|
|
2014
2042
|
if (!location) {
|
|
2015
|
-
return err(new
|
|
2043
|
+
return err(new chunkAETVRBKI_js.CimplifyError(chunkAETVRBKI_js.ErrorCode.NOT_FOUND, `Location not found: ${locationId}`, false));
|
|
2016
2044
|
}
|
|
2017
2045
|
return ok(location);
|
|
2018
2046
|
}
|
|
@@ -2092,7 +2120,7 @@ var InventoryService = class {
|
|
|
2092
2120
|
async getAvailableQuantity(productId, locationId) {
|
|
2093
2121
|
const result = await this.getProductStock(productId, locationId);
|
|
2094
2122
|
if (!result.ok) return result;
|
|
2095
|
-
return ok(result.value.available_quantity);
|
|
2123
|
+
return ok(result.value.available_quantity ?? void 0);
|
|
2096
2124
|
}
|
|
2097
2125
|
};
|
|
2098
2126
|
|
|
@@ -2222,9 +2250,9 @@ var LiteService = class {
|
|
|
2222
2250
|
async getBootstrap() {
|
|
2223
2251
|
return safe(this.client.get("/api/v1/lite/bootstrap"));
|
|
2224
2252
|
}
|
|
2225
|
-
async
|
|
2226
|
-
const encodedId = encodeURIComponent(
|
|
2227
|
-
return safe(this.client.get(`/api/v1/lite/
|
|
2253
|
+
async getResource(resourceId) {
|
|
2254
|
+
const encodedId = encodeURIComponent(resourceId);
|
|
2255
|
+
return safe(this.client.get(`/api/v1/lite/resources/${encodedId}`));
|
|
2228
2256
|
}
|
|
2229
2257
|
async getMenu() {
|
|
2230
2258
|
return safe(this.client.get("/api/v1/lite/menu"));
|
|
@@ -2628,7 +2656,7 @@ function startRedirectSignIn(opts, authorizeEndpoint, pkce, state) {
|
|
|
2628
2656
|
|
|
2629
2657
|
// src/elements.ts
|
|
2630
2658
|
function toCheckoutError(code, message, recoverable) {
|
|
2631
|
-
const hint =
|
|
2659
|
+
const hint = chunkAETVRBKI_js.getErrorHint(code);
|
|
2632
2660
|
return {
|
|
2633
2661
|
success: false,
|
|
2634
2662
|
error: {
|
|
@@ -3201,6 +3229,7 @@ var CimplifyElement = class {
|
|
|
3201
3229
|
this.pendingInit = null;
|
|
3202
3230
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
3203
3231
|
this.resolvers = /* @__PURE__ */ new Map();
|
|
3232
|
+
this.lastReportedHeight = 0;
|
|
3204
3233
|
this.listening = false;
|
|
3205
3234
|
this.type = type;
|
|
3206
3235
|
this.businessId = businessId;
|
|
@@ -3209,11 +3238,33 @@ var CimplifyElement = class {
|
|
|
3209
3238
|
this.parent = parent;
|
|
3210
3239
|
this.nonce = generateNonce();
|
|
3211
3240
|
this.boundHandleMessage = this.handleMessage.bind(this);
|
|
3241
|
+
this.boundHandleResize = () => this.applyHeight();
|
|
3212
3242
|
if (typeof window !== "undefined") {
|
|
3213
3243
|
window.addEventListener("message", this.boundHandleMessage);
|
|
3244
|
+
window.addEventListener("resize", this.boundHandleResize);
|
|
3214
3245
|
this.listening = true;
|
|
3215
3246
|
}
|
|
3216
3247
|
}
|
|
3248
|
+
/**
|
|
3249
|
+
* Size the iframe to the element's reported content height. The checkout can
|
|
3250
|
+
* exceed the viewport, so cap it at the viewport height — the checkout then
|
|
3251
|
+
* scrolls internally instead of growing (and scrolling) the host page. Other
|
|
3252
|
+
* element types size to content as before.
|
|
3253
|
+
*/
|
|
3254
|
+
applyHeight(reportedHeight) {
|
|
3255
|
+
if (!this.iframe) return;
|
|
3256
|
+
if (typeof reportedHeight === "number" && reportedHeight > 0) {
|
|
3257
|
+
this.lastReportedHeight = reportedHeight;
|
|
3258
|
+
}
|
|
3259
|
+
const content = this.lastReportedHeight;
|
|
3260
|
+
if (!content) return;
|
|
3261
|
+
if (this.type !== "checkout" || typeof window === "undefined") {
|
|
3262
|
+
this.iframe.style.height = `${content}px`;
|
|
3263
|
+
return;
|
|
3264
|
+
}
|
|
3265
|
+
const capped = Math.max(320, Math.min(content, window.innerHeight));
|
|
3266
|
+
this.iframe.style.height = `${capped}px`;
|
|
3267
|
+
}
|
|
3217
3268
|
mount(container) {
|
|
3218
3269
|
if (this.mounted) {
|
|
3219
3270
|
console.warn(`Element ${this.type} is already mounted`);
|
|
@@ -3246,6 +3297,7 @@ var CimplifyElement = class {
|
|
|
3246
3297
|
this.resolvers.clear();
|
|
3247
3298
|
if (this.listening && typeof window !== "undefined") {
|
|
3248
3299
|
window.removeEventListener("message", this.boundHandleMessage);
|
|
3300
|
+
window.removeEventListener("resize", this.boundHandleResize);
|
|
3249
3301
|
this.listening = false;
|
|
3250
3302
|
}
|
|
3251
3303
|
this.parent._removeElement(this.type, this);
|
|
@@ -3371,7 +3423,7 @@ var CimplifyElement = class {
|
|
|
3371
3423
|
switch (message.type) {
|
|
3372
3424
|
case MESSAGE_TYPES.READY:
|
|
3373
3425
|
this.ready = true;
|
|
3374
|
-
if (
|
|
3426
|
+
if (message.height) this.applyHeight(message.height);
|
|
3375
3427
|
if (this.pendingInit) {
|
|
3376
3428
|
const { publicKey } = this.pendingInit;
|
|
3377
3429
|
this.sendMessage({
|
|
@@ -3395,7 +3447,7 @@ var CimplifyElement = class {
|
|
|
3395
3447
|
this.emit(EVENT_TYPES.READY, { height: message.height });
|
|
3396
3448
|
break;
|
|
3397
3449
|
case MESSAGE_TYPES.HEIGHT_CHANGE:
|
|
3398
|
-
|
|
3450
|
+
this.applyHeight(message.height);
|
|
3399
3451
|
break;
|
|
3400
3452
|
case MESSAGE_TYPES.ERROR:
|
|
3401
3453
|
this.emit(EVENT_TYPES.ERROR, { code: message.code, message: message.message });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createMockApp } from './chunk-
|
|
2
|
-
import { createCimplifyClient } from './chunk-
|
|
1
|
+
import { createMockApp } from './chunk-APBLFZ2I.mjs';
|
|
2
|
+
import { createCimplifyClient } from './chunk-RCGSHS2Q.mjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
var cimplifyRegistry = z.registry();
|
|
@@ -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",
|
|
@@ -94,6 +94,14 @@ var DURATION_UNIT = {
|
|
|
94
94
|
Months: "months",
|
|
95
95
|
Years: "years"
|
|
96
96
|
};
|
|
97
|
+
var BOUNDARY_KIND = {
|
|
98
|
+
CheckInOut: "check_in_out",
|
|
99
|
+
PickupReturn: "pickup_return",
|
|
100
|
+
DeliveryCollection: "delivery_collection",
|
|
101
|
+
AccessVacate: "access_vacate",
|
|
102
|
+
MoveInOut: "move_in_out",
|
|
103
|
+
Custom: "custom"
|
|
104
|
+
};
|
|
97
105
|
var INPUT_FIELD_TYPE = {
|
|
98
106
|
Text: "text",
|
|
99
107
|
Textarea: "textarea",
|
|
@@ -153,4 +161,4 @@ function appendTransform(url, t) {
|
|
|
153
161
|
return `${url}${url.includes("?") ? "&" : "?"}${query}`;
|
|
154
162
|
}
|
|
155
163
|
|
|
156
|
-
export { CIMPLIFY_CDN_HOSTS, DEFAULT_CDN_BASE_URL, DURATION_UNIT, INPUT_FIELD_TYPE, PRODUCT_TYPE, RENDER_HINT, allGalleryImages, assetUrl, getVariantDisplayName, isCimplifyAsset, resolveGallery };
|
|
164
|
+
export { BOUNDARY_KIND, CIMPLIFY_CDN_HOSTS, DEFAULT_CDN_BASE_URL, DURATION_UNIT, INPUT_FIELD_TYPE, PRODUCT_TYPE, RENDER_HINT, allGalleryImages, assetUrl, getVariantDisplayName, isCimplifyAsset, resolveGallery };
|