@cimplify/sdk 0.85.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-DU4IX2I2.mjs → chunk-A2GXDCSI.mjs} +2 -2
- package/dist/{chunk-XA3ZNR75.js → chunk-AETVRBKI.js} +1 -1
- package/dist/{chunk-GIFVSWYJ.mjs → chunk-D6JWYYTG.mjs} +2 -2
- package/dist/{chunk-A6J7W6DH.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-NWTCBGJ2.js → chunk-X4UNISYG.js} +4 -4
- package/dist/{client-WKKxIiF1.d.ts → client-BQSRj4iK.d.mts} +528 -539
- package/dist/{client-DLtwQ-jI.d.mts → client-BdI24jUT.d.ts} +528 -539
- package/dist/{client-BT5gaiGR.d.ts → client-CMJO_8zo.d.ts} +2 -2
- package/dist/{client-BEhIE0Dm.d.mts → client-DowGNrTh.d.mts} +2 -2
- package/dist/{index-BrC1x2kK.d.ts → index-BRwHpMY-.d.ts} +3 -3
- package/dist/{index-DZz6hdrT.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 +2 -2
- package/dist/mock/library.js +2 -2
- package/dist/mock/library.mjs +2 -2
- package/dist/mock/msw.js +2 -2
- package/dist/mock/msw.mjs +2 -2
- package/dist/{payment-D1f3ZQPC.d.ts → payment-BA7KNBxg.d.ts} +3 -3
- package/dist/{payment-Dh-6cRcV.d.mts → payment-CFev-fOE.d.mts} +3 -3
- package/dist/{price-CQdOJoX-.d.ts → price-BNhGVB5q.d.ts} +1 -1
- package/dist/{price-4T7dlhxM.d.mts → price-nRxqVNGq.d.mts} +1 -1
- package/dist/product-BGxIfTqJ.d.mts +5400 -0
- package/dist/product-BGxIfTqJ.d.ts +5400 -0
- package/dist/react.d.mts +6 -6
- package/dist/react.d.ts +6 -6
- package/dist/react.js +139 -139
- package/dist/react.mjs +19 -19
- package/dist/{server-DjK98UW-.d.mts → server-9u0LiG5U.d.mts} +1 -1
- package/dist/{server-DvThXldo.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/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/dist/product-RJMIdCAf.d.mts +0 -1582
- package/dist/product-RJMIdCAf.d.ts +0 -1582
|
@@ -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: {
|
|
@@ -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) {
|
|
@@ -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") + '">' +
|