@cimplify/sdk 0.44.14 → 0.44.18
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 +1 -1
- package/dist/advanced.d.ts +1 -1
- package/dist/advanced.js +22 -21
- package/dist/advanced.mjs +3 -2
- package/dist/{chunk-OMAP327U.js → chunk-3FS3ZDKX.js} +62 -61
- package/dist/chunk-53J2WE4S.js +657 -0
- package/dist/{chunk-3WD6U5RD.mjs → chunk-5OK3YDZC.mjs} +4 -3
- package/dist/{chunk-V2O5AO7I.js → chunk-BN2CXGMO.js} +5 -246
- package/dist/chunk-CCSONJCO.js +8824 -0
- package/dist/{chunk-BAWKQRIB.js → chunk-HBRCVJL4.js} +22 -21
- package/dist/chunk-MJBSVUHO.mjs +8822 -0
- package/dist/{chunk-6TVQQYQ5.mjs → chunk-NRT6PVW5.mjs} +4 -231
- package/dist/chunk-QBQCMQ4F.js +271 -0
- package/dist/chunk-VDH3O7UB.mjs +604 -0
- package/dist/chunk-XPXAZXF2.mjs +250 -0
- package/dist/{chunk-EZK2FXTM.mjs → chunk-XZPO5GEM.mjs} +2 -1
- package/dist/cli/commands/deploy.mjs +9 -1
- package/dist/client-B_Ei3ENB.d.mts +86 -0
- package/dist/client-Bep2FooI.d.ts +86 -0
- package/dist/{client-lvLvB1_K.d.ts → client-D6ZisKco.d.ts} +7 -0
- package/dist/{client-CkGlXZRd.d.mts → client-Dh-bHyhU.d.mts} +7 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +145 -144
- package/dist/index.mjs +4 -3
- package/dist/mock/cli.mjs +2 -1
- package/dist/mock/library.js +2 -1
- package/dist/mock/library.mjs +2 -1
- package/dist/mock/msw.js +2 -1
- package/dist/mock/msw.mjs +2 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +81 -80
- package/dist/react.mjs +4 -3
- package/dist/server-CWpUlLOQ.d.mts +1003 -0
- package/dist/server-CWpUlLOQ.d.ts +1003 -0
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +6 -5
- package/dist/server.mjs +4 -3
- package/dist/testing/msw.d.mts +17 -0
- package/dist/testing/msw.d.ts +17 -0
- package/dist/testing/msw.js +42 -0
- package/dist/testing/msw.mjs +40 -0
- package/dist/testing/suite.d.mts +85 -0
- package/dist/testing/suite.d.ts +85 -0
- package/dist/testing/suite.js +174 -0
- package/dist/testing/suite.mjs +170 -0
- package/dist/testing.d.mts +1885 -0
- package/dist/testing.d.ts +1885 -0
- package/dist/testing.js +261 -0
- package/dist/testing.mjs +51 -0
- package/dist/utils.js +29 -28
- package/dist/utils.mjs +2 -1
- package/package.json +28 -4
- package/templates/storefront-bakery/__tests__/brand.test.ts +4 -0
- package/templates/storefront-bakery/__tests__/cart-flow.test.ts +4 -0
- package/templates/storefront-bakery/__tests__/contract.test.ts +4 -0
- package/templates/storefront-bakery/package.json +11 -3
- package/templates/storefront-bakery/vitest.config.ts +9 -0
- package/templates/storefront-fashion/__tests__/brand.test.ts +4 -0
- package/templates/storefront-fashion/__tests__/cart-flow.test.ts +4 -0
- package/templates/storefront-fashion/__tests__/contract.test.ts +4 -0
- package/templates/storefront-fashion/package.json +11 -3
- package/templates/storefront-fashion/vitest.config.ts +9 -0
- package/templates/storefront-grocery/__tests__/brand.test.ts +4 -0
- package/templates/storefront-grocery/__tests__/cart-flow.test.ts +4 -0
- package/templates/storefront-grocery/__tests__/contract.test.ts +4 -0
- package/templates/storefront-grocery/package.json +11 -3
- package/templates/storefront-grocery/vitest.config.ts +9 -0
- package/templates/storefront-restaurant/__tests__/brand.test.ts +4 -0
- package/templates/storefront-restaurant/__tests__/cart-flow.test.ts +4 -0
- package/templates/storefront-restaurant/__tests__/contract.test.ts +4 -0
- package/templates/storefront-restaurant/package.json +11 -3
- package/templates/storefront-restaurant/vitest.config.ts +9 -0
- package/templates/storefront-retail/__tests__/brand.test.ts +4 -0
- package/templates/storefront-retail/__tests__/cart-flow.test.ts +4 -0
- package/templates/storefront-retail/__tests__/contract.test.ts +4 -0
- package/templates/storefront-retail/package.json +11 -3
- package/templates/storefront-retail/vitest.config.ts +9 -0
- package/templates/storefront-services/__tests__/brand.test.ts +4 -0
- package/templates/storefront-services/__tests__/cart-flow.test.ts +4 -0
- package/templates/storefront-services/__tests__/contract.test.ts +4 -0
- package/templates/storefront-services/package.json +11 -3
- package/templates/storefront-services/vitest.config.ts +9 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkBN2CXGMO_js = require('./chunk-BN2CXGMO.js');
|
|
4
|
+
var chunkQBQCMQ4F_js = require('./chunk-QBQCMQ4F.js');
|
|
4
5
|
|
|
5
6
|
// src/types/result.ts
|
|
6
7
|
function ok(value) {
|
|
@@ -84,11 +85,11 @@ function generateIdempotencyKey(prefix = "idem") {
|
|
|
84
85
|
|
|
85
86
|
// src/internal/safe.ts
|
|
86
87
|
function toCimplifyError(error) {
|
|
87
|
-
if (error instanceof
|
|
88
|
+
if (error instanceof chunkQBQCMQ4F_js.CimplifyError) return chunkQBQCMQ4F_js.enrichError(error);
|
|
88
89
|
if (error instanceof Error) {
|
|
89
|
-
return
|
|
90
|
+
return chunkQBQCMQ4F_js.enrichError(new chunkQBQCMQ4F_js.CimplifyError(chunkQBQCMQ4F_js.ErrorCode.UNKNOWN_ERROR, error.message, false));
|
|
90
91
|
}
|
|
91
|
-
return
|
|
92
|
+
return chunkQBQCMQ4F_js.enrichError(new chunkQBQCMQ4F_js.CimplifyError(chunkQBQCMQ4F_js.ErrorCode.UNKNOWN_ERROR, String(error), false));
|
|
92
93
|
}
|
|
93
94
|
async function safe(promise) {
|
|
94
95
|
try {
|
|
@@ -647,7 +648,7 @@ var CartOperations = class {
|
|
|
647
648
|
if (typeof updates.quantity !== "number") {
|
|
648
649
|
return {
|
|
649
650
|
ok: false,
|
|
650
|
-
error: new
|
|
651
|
+
error: new chunkQBQCMQ4F_js.CimplifyError(
|
|
651
652
|
"VALIDATION_ERROR",
|
|
652
653
|
"updateItem requires a quantity; richer mid-cart edits are not supported"
|
|
653
654
|
)
|
|
@@ -1089,7 +1090,7 @@ var CheckoutResolver = class {
|
|
|
1089
1090
|
}
|
|
1090
1091
|
}
|
|
1091
1092
|
}
|
|
1092
|
-
if (checkoutResult.requires_authorization ||
|
|
1093
|
+
if (checkoutResult.requires_authorization || chunkBN2CXGMO_js.isPaymentStatusRequiresAction(checkoutResult.payment_status)) {
|
|
1093
1094
|
const authorization = await this.handleAuthorization({
|
|
1094
1095
|
authorizationType,
|
|
1095
1096
|
paymentReference,
|
|
@@ -1263,18 +1264,18 @@ var CheckoutResolver = class {
|
|
|
1263
1264
|
if (statusResult.value.reference) {
|
|
1264
1265
|
paymentReference = statusResult.value.reference;
|
|
1265
1266
|
}
|
|
1266
|
-
const normalized =
|
|
1267
|
-
if (normalized.paid ||
|
|
1267
|
+
const normalized = chunkBN2CXGMO_js.normalizeStatusResponse(statusResult.value);
|
|
1268
|
+
if (normalized.paid || chunkBN2CXGMO_js.isPaymentStatusSuccess(normalized.status)) {
|
|
1268
1269
|
return this.finalizeSuccess(latestCheckoutResult);
|
|
1269
1270
|
}
|
|
1270
|
-
if (
|
|
1271
|
+
if (chunkBN2CXGMO_js.isPaymentStatusFailure(normalized.status)) {
|
|
1271
1272
|
return this.fail(
|
|
1272
1273
|
normalized.status ? normalized.status.toUpperCase() : "PAYMENT_FAILED",
|
|
1273
1274
|
normalized.message || "Payment failed during confirmation.",
|
|
1274
1275
|
false
|
|
1275
1276
|
);
|
|
1276
1277
|
}
|
|
1277
|
-
if (
|
|
1278
|
+
if (chunkBN2CXGMO_js.isPaymentStatusRequiresAction(normalized.status)) {
|
|
1278
1279
|
const authorization = await this.handleAuthorization({
|
|
1279
1280
|
authorizationType,
|
|
1280
1281
|
paymentReference,
|
|
@@ -1305,8 +1306,8 @@ var CheckoutResolver = class {
|
|
|
1305
1306
|
try {
|
|
1306
1307
|
const finalResult = await this.client.checkout.pollPaymentStatus(input.orderId);
|
|
1307
1308
|
if (finalResult.ok) {
|
|
1308
|
-
const normalized =
|
|
1309
|
-
if (normalized.paid ||
|
|
1309
|
+
const normalized = chunkBN2CXGMO_js.normalizeStatusResponse(finalResult.value);
|
|
1310
|
+
if (normalized.paid || chunkBN2CXGMO_js.isPaymentStatusSuccess(normalized.status)) {
|
|
1310
1311
|
return this.finalizeSuccess(latestCheckoutResult);
|
|
1311
1312
|
}
|
|
1312
1313
|
}
|
|
@@ -1502,12 +1503,12 @@ var CheckoutResolver = class {
|
|
|
1502
1503
|
};
|
|
1503
1504
|
}
|
|
1504
1505
|
isSuccessfulStatus(status) {
|
|
1505
|
-
const normalized =
|
|
1506
|
-
return normalized.paid ||
|
|
1506
|
+
const normalized = chunkBN2CXGMO_js.normalizeStatusResponse({ status, paid: false });
|
|
1507
|
+
return normalized.paid || chunkBN2CXGMO_js.isPaymentStatusSuccess(normalized.status);
|
|
1507
1508
|
}
|
|
1508
1509
|
isFailureStatus(status) {
|
|
1509
|
-
const normalized =
|
|
1510
|
-
return
|
|
1510
|
+
const normalized = chunkBN2CXGMO_js.normalizeStatusResponse({ status, paid: false });
|
|
1511
|
+
return chunkBN2CXGMO_js.isPaymentStatusFailure(normalized.status);
|
|
1511
1512
|
}
|
|
1512
1513
|
ensureNotAborted() {
|
|
1513
1514
|
if (this.signal?.aborted) {
|
|
@@ -1570,7 +1571,7 @@ var CheckoutService = class {
|
|
|
1570
1571
|
}
|
|
1571
1572
|
async initializePayment(_orderId, _method) {
|
|
1572
1573
|
return err(
|
|
1573
|
-
new
|
|
1574
|
+
new chunkQBQCMQ4F_js.CimplifyError(
|
|
1574
1575
|
"NOT_IMPLEMENTED",
|
|
1575
1576
|
"initializePayment is not available in REST mode.",
|
|
1576
1577
|
false
|
|
@@ -1642,11 +1643,11 @@ var CheckoutService = class {
|
|
|
1642
1643
|
pay_currency: data.pay_currency,
|
|
1643
1644
|
fx_quote_id: data.fx_quote_id
|
|
1644
1645
|
};
|
|
1645
|
-
const baseCurrency =
|
|
1646
|
+
const baseCurrency = chunkQBQCMQ4F_js.currencyCode(
|
|
1646
1647
|
(cart.pricing.currency || checkoutData.pay_currency || "GHS").toUpperCase()
|
|
1647
1648
|
);
|
|
1648
1649
|
const payCurrency = data.pay_currency?.trim().toUpperCase();
|
|
1649
|
-
const payCurrencyCode = payCurrency ?
|
|
1650
|
+
const payCurrencyCode = payCurrency ? chunkQBQCMQ4F_js.currencyCode(payCurrency) : void 0;
|
|
1650
1651
|
const cartTotalAmount = typeof cart.pricing.total_price === "number" ? cart.pricing.total_price : Number.parseFloat(cart.pricing.total_price || "0");
|
|
1651
1652
|
if (payCurrencyCode && payCurrencyCode !== baseCurrency && !checkoutData.fx_quote_id && Number.isFinite(cartTotalAmount) && cartTotalAmount > 0) {
|
|
1652
1653
|
const fxQuoteResult = await this.client.fx.lockQuote({
|
|
@@ -2004,7 +2005,7 @@ var BusinessService = class {
|
|
|
2004
2005
|
if (!result.ok) return err(result.error);
|
|
2005
2006
|
const location = result.value.find((item) => item.id === locationId);
|
|
2006
2007
|
if (!location) {
|
|
2007
|
-
return err(new
|
|
2008
|
+
return err(new chunkQBQCMQ4F_js.CimplifyError(chunkQBQCMQ4F_js.ErrorCode.NOT_FOUND, `Location not found: ${locationId}`, false));
|
|
2008
2009
|
}
|
|
2009
2010
|
return ok(location);
|
|
2010
2011
|
}
|
|
@@ -2290,7 +2291,7 @@ var EVENT_TYPES = {
|
|
|
2290
2291
|
|
|
2291
2292
|
// src/elements.ts
|
|
2292
2293
|
function toCheckoutError(code, message, recoverable) {
|
|
2293
|
-
const hint =
|
|
2294
|
+
const hint = chunkQBQCMQ4F_js.getErrorHint(code);
|
|
2294
2295
|
return {
|
|
2295
2296
|
success: false,
|
|
2296
2297
|
error: {
|