@cimplify/sdk 0.100.1 → 0.100.2
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 +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-QGFKIAEM.js → chunk-6JEKKL3M.js} +5 -0
- package/dist/{chunk-NKZIXLKW.mjs → chunk-B2YOCOLH.mjs} +1 -1
- package/dist/{chunk-NH3HYUC3.js → chunk-IFAQLFAJ.js} +1 -1
- package/dist/{chunk-BHQCSHIG.js → chunk-IJI7KMTG.js} +58 -57
- package/dist/{chunk-T2B656RS.mjs → chunk-PJUXAUM2.mjs} +13 -12
- package/dist/{chunk-NR4Z2SFY.js → chunk-QRBBSIAY.js} +4 -4
- package/dist/{chunk-PTKAN4SI.mjs → chunk-TIQLOH2B.mjs} +5 -0
- package/dist/{chunk-KEC2CX4R.mjs → chunk-YWNJJO2U.mjs} +2 -2
- package/dist/{client-T5c-Nxq-.d.mts → client-C6wb92AD.d.mts} +2 -2
- package/dist/{client-DRgEa78P.d.ts → client-CgXkRu2o.d.ts} +2 -2
- package/dist/{client-B0Lku_lc.d.mts → client-D8XcrONA.d.mts} +23 -12
- package/dist/{client-DxgC_lXU.d.ts → client-LPg_AUUr.d.ts} +23 -12
- package/dist/{index-CzKN1hjf.d.ts → index-B_RYmvlF.d.ts} +3 -3
- package/dist/{index-DzuLT5wi.d.mts → index-D-LUYk1Y.d.mts} +3 -3
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +69 -69
- package/dist/index.mjs +3 -3
- package/dist/mock/cli.mjs +1 -1
- package/dist/mock/library.js +1 -1
- package/dist/mock/library.mjs +1 -1
- package/dist/mock/msw.js +1 -1
- package/dist/mock/msw.mjs +1 -1
- package/dist/{payment-D8NEwCna.d.mts → payment-BSzy7sly.d.mts} +1 -1
- package/dist/{payment-lZBP7h5M.d.ts → payment-jK8ztICx.d.ts} +1 -1
- package/dist/{price-ncQb-TC8.d.ts → price-CJLfcYKd.d.ts} +1 -1
- package/dist/{price-DepWAmcL.d.mts → price-D96h6c6L.d.mts} +1 -1
- package/dist/{product-B384_Qm2.d.mts → product-CeV8euw4.d.mts} +11 -10
- package/dist/{product-B384_Qm2.d.ts → product-CeV8euw4.d.ts} +11 -10
- package/dist/react.d.mts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +51 -29
- package/dist/react.mjs +28 -6
- package/dist/{server-oCGNIO_K.d.mts → server--RyVAfPN.d.mts} +1 -1
- package/dist/{server-B7O4ttpv.d.ts → server-CNyy47HL.d.ts} +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +7 -7
- package/dist/server.mjs +2 -2
- package/dist/testing/msw.d.mts +2 -2
- package/dist/testing/msw.d.ts +2 -2
- package/dist/testing/msw.js +2 -2
- package/dist/testing/msw.mjs +1 -1
- package/dist/testing/suite.d.mts +6 -6
- package/dist/testing/suite.d.ts +6 -6
- package/dist/testing/suite.js +23 -23
- package/dist/testing/suite.mjs +4 -4
- package/dist/testing.d.mts +5 -5
- package/dist/testing.d.ts +5 -5
- package/dist/testing.js +79 -79
- package/dist/testing.mjs +5 -5
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
var chunkQPRI2NII_js = require('./chunk-QPRI2NII.js');
|
|
5
5
|
var chunkXREIZ56K_js = require('./chunk-XREIZ56K.js');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var chunkIJI7KMTG_js = require('./chunk-IJI7KMTG.js');
|
|
7
|
+
var chunk6JEKKL3M_js = require('./chunk-6JEKKL3M.js');
|
|
8
8
|
var chunkWMEC5JWN_js = require('./chunk-WMEC5JWN.js');
|
|
9
9
|
var chunkNIOUSKQQ_js = require('./chunk-NIOUSKQQ.js');
|
|
10
10
|
require('./chunk-OWW5GUSB.js');
|
|
@@ -379,6 +379,26 @@ function Ad({
|
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
// src/utils/cart-transform.ts
|
|
382
|
+
var DECIMAL_AMOUNT_PATTERN = /^([+-]?)(\d+)(?:\.(\d+))?$/;
|
|
383
|
+
function multiplyDecimalByInteger(value, multiplier) {
|
|
384
|
+
if (!Number.isSafeInteger(multiplier) || multiplier < 0) {
|
|
385
|
+
throw new RangeError("Cart item quantity must be a non-negative safe integer");
|
|
386
|
+
}
|
|
387
|
+
const source = String(value).trim();
|
|
388
|
+
const match = DECIMAL_AMOUNT_PATTERN.exec(source);
|
|
389
|
+
if (!match) {
|
|
390
|
+
throw new TypeError("Cart item price must be a decimal amount");
|
|
391
|
+
}
|
|
392
|
+
const [, sign, whole, fraction = ""] = match;
|
|
393
|
+
const scaledAmount = BigInt(`${sign}${whole}${fraction}`);
|
|
394
|
+
const scaledTotal = scaledAmount * BigInt(multiplier);
|
|
395
|
+
if (fraction.length === 0) return scaledTotal.toString();
|
|
396
|
+
const negative = scaledTotal < 0n;
|
|
397
|
+
const digits = (negative ? -scaledTotal : scaledTotal).toString().padStart(fraction.length + 1, "0");
|
|
398
|
+
const splitAt = digits.length - fraction.length;
|
|
399
|
+
const formatted = `${digits.slice(0, splitAt)}.${digits.slice(splitAt)}`;
|
|
400
|
+
return negative ? `-${formatted}` : formatted;
|
|
401
|
+
}
|
|
382
402
|
function getSelections(item) {
|
|
383
403
|
if (item.bundle_resolved?.selections?.length) {
|
|
384
404
|
return item.bundle_resolved.selections.map((s) => ({
|
|
@@ -397,11 +417,12 @@ function getSelections(item) {
|
|
|
397
417
|
}
|
|
398
418
|
function mapItem(item, fx) {
|
|
399
419
|
const amt = (value) => fx ? String(fx.convertPrice(value)) : String(value);
|
|
420
|
+
const currentUnitPrice = item.total_price;
|
|
400
421
|
const result = {
|
|
401
422
|
name: item.name,
|
|
402
423
|
quantity: item.quantity,
|
|
403
|
-
unit_price: amt(
|
|
404
|
-
total_price: amt(item.
|
|
424
|
+
unit_price: amt(currentUnitPrice),
|
|
425
|
+
total_price: amt(multiplyDecimalByInteger(currentUnitPrice, item.quantity)),
|
|
405
426
|
line_type: item.line_type
|
|
406
427
|
};
|
|
407
428
|
if (item.image_url) result.image_url = item.image_url;
|
|
@@ -422,9 +443,9 @@ function mapItem(item, fx) {
|
|
|
422
443
|
}
|
|
423
444
|
return result;
|
|
424
445
|
}
|
|
425
|
-
function transformToCheckoutCart(cart, fx) {
|
|
446
|
+
function transformToCheckoutCart(cart, fx, checkout) {
|
|
426
447
|
const amt = (value) => fx ? String(fx.convertPrice(value)) : String(value);
|
|
427
|
-
|
|
448
|
+
const checkoutCart = {
|
|
428
449
|
items: cart.items.map((item) => mapItem(item, fx)),
|
|
429
450
|
subtotal: amt(cart.pricing.subtotal),
|
|
430
451
|
tax_amount: amt(cart.pricing.tax_amount),
|
|
@@ -437,6 +458,7 @@ function transformToCheckoutCart(cart, fx) {
|
|
|
437
458
|
deposit_amount: cart.pricing.deposit_amount != null ? amt(cart.pricing.deposit_amount) : void 0,
|
|
438
459
|
requires_delivery: cart.requires_delivery
|
|
439
460
|
};
|
|
461
|
+
return checkoutCart;
|
|
440
462
|
}
|
|
441
463
|
|
|
442
464
|
// src/internal/collection.ts
|
|
@@ -823,7 +845,7 @@ async function syncFromServer(entry) {
|
|
|
823
845
|
return next;
|
|
824
846
|
}
|
|
825
847
|
function emitMutationError(entry, operation, opId, idempotencyKey, error) {
|
|
826
|
-
entry.client.events.emit(
|
|
848
|
+
entry.client.events.emit(chunkIJI7KMTG_js.MUTATION_ERROR, {
|
|
827
849
|
service: "cart",
|
|
828
850
|
operation,
|
|
829
851
|
opId,
|
|
@@ -863,10 +885,10 @@ function getOrCreateStore(params) {
|
|
|
863
885
|
syncTail: Promise.resolve(),
|
|
864
886
|
failedOpRemovers: /* @__PURE__ */ new Set()
|
|
865
887
|
};
|
|
866
|
-
client.events.on(
|
|
888
|
+
client.events.on(chunkIJI7KMTG_js.SESSION_CLAIMED, () => {
|
|
867
889
|
if (entry.initialized) void syncFromServer(entry);
|
|
868
890
|
});
|
|
869
|
-
client.events.on(
|
|
891
|
+
client.events.on(chunkIJI7KMTG_js.SESSION_CLEARED, () => {
|
|
870
892
|
if (entry.initialized) void syncFromServer(entry);
|
|
871
893
|
});
|
|
872
894
|
cartStores.set(storeKey, entry);
|
|
@@ -1170,7 +1192,7 @@ var DEFAULT_COUNTRY = "US";
|
|
|
1170
1192
|
function createDefaultClient() {
|
|
1171
1193
|
const processRef = globalThis.process;
|
|
1172
1194
|
const envPublicKey = processRef?.env?.NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY || "";
|
|
1173
|
-
return
|
|
1195
|
+
return chunkIJI7KMTG_js.createCimplifyClient({ publicKey: envPublicKey });
|
|
1174
1196
|
}
|
|
1175
1197
|
function getStoredLocationId() {
|
|
1176
1198
|
if (typeof window === "undefined" || !window.localStorage) {
|
|
@@ -3482,7 +3504,7 @@ function CimplifySignInButton({
|
|
|
3482
3504
|
const onClick = async () => {
|
|
3483
3505
|
if (busy || disabled || !signInOpts.clientId) return;
|
|
3484
3506
|
setBusy(true);
|
|
3485
|
-
await
|
|
3507
|
+
await chunk6JEKKL3M_js.startSignIn({
|
|
3486
3508
|
...signInOpts,
|
|
3487
3509
|
onSuccess: () => {
|
|
3488
3510
|
setBusy(false);
|
|
@@ -4950,9 +4972,9 @@ function useClientSessionEpoch(client) {
|
|
|
4950
4972
|
const subscribe = React14.useCallback(
|
|
4951
4973
|
(notify) => {
|
|
4952
4974
|
const unsubscribe = [
|
|
4953
|
-
client.events.on(
|
|
4954
|
-
client.events.on(
|
|
4955
|
-
client.events.on(
|
|
4975
|
+
client.events.on(chunkIJI7KMTG_js.AUTH_TOKEN_CHANGED, notify),
|
|
4976
|
+
client.events.on(chunkIJI7KMTG_js.SESSION_CLAIMED, notify),
|
|
4977
|
+
client.events.on(chunkIJI7KMTG_js.SESSION_CLEARED, notify)
|
|
4956
4978
|
];
|
|
4957
4979
|
return () => {
|
|
4958
4980
|
for (const stopListening of unsubscribe) {
|
|
@@ -6282,7 +6304,7 @@ function useChat(options = {}) {
|
|
|
6282
6304
|
const watchSessionClaims = React14.useCallback(() => {
|
|
6283
6305
|
const c = clientRef.current;
|
|
6284
6306
|
if (!c || claimUnsubRef.current) return;
|
|
6285
|
-
const unsubClaimed = c.events.on(
|
|
6307
|
+
const unsubClaimed = c.events.on(chunkIJI7KMTG_js.SESSION_CLAIMED, (event) => {
|
|
6286
6308
|
setClaimedAs(event.customerName || c.support.claimedCustomerName || null);
|
|
6287
6309
|
if (!openedRef.current) {
|
|
6288
6310
|
void openIfExisting();
|
|
@@ -6291,7 +6313,7 @@ function useChat(options = {}) {
|
|
|
6291
6313
|
connectWebSocket();
|
|
6292
6314
|
void resyncConversation();
|
|
6293
6315
|
});
|
|
6294
|
-
const unsubCleared = c.events.on(
|
|
6316
|
+
const unsubCleared = c.events.on(chunkIJI7KMTG_js.SESSION_CLEARED, resetConversation);
|
|
6295
6317
|
claimUnsubRef.current = () => {
|
|
6296
6318
|
unsubClaimed();
|
|
6297
6319
|
unsubCleared();
|
|
@@ -6343,7 +6365,7 @@ function useChat(options = {}) {
|
|
|
6343
6365
|
if (!openedRef.current) return false;
|
|
6344
6366
|
}
|
|
6345
6367
|
const replyTo = opts?.replyTo;
|
|
6346
|
-
const clientId =
|
|
6368
|
+
const clientId = chunk6JEKKL3M_js.generateIdempotencyKey();
|
|
6347
6369
|
const localId = optimisticId(clientId);
|
|
6348
6370
|
const optimistic = {
|
|
6349
6371
|
id: localId,
|
|
@@ -6532,15 +6554,15 @@ function AuthElement({
|
|
|
6532
6554
|
}, [onReady, onAuthenticated, onError]);
|
|
6533
6555
|
React14.useEffect(() => {
|
|
6534
6556
|
if (!elements || !containerRef.current) return;
|
|
6535
|
-
const element = elements.create(
|
|
6557
|
+
const element = elements.create(chunk6JEKKL3M_js.ELEMENT_TYPES.AUTH, { prefillEmail });
|
|
6536
6558
|
elementRef.current = element;
|
|
6537
|
-
element.on(
|
|
6559
|
+
element.on(chunk6JEKKL3M_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
6538
6560
|
element.on(
|
|
6539
|
-
|
|
6561
|
+
chunk6JEKKL3M_js.EVENT_TYPES.AUTHENTICATED,
|
|
6540
6562
|
(data) => onAuthenticatedRef.current?.(data)
|
|
6541
6563
|
);
|
|
6542
6564
|
element.on(
|
|
6543
|
-
|
|
6565
|
+
chunk6JEKKL3M_js.EVENT_TYPES.ERROR,
|
|
6544
6566
|
(data) => onErrorRef.current?.(data)
|
|
6545
6567
|
);
|
|
6546
6568
|
element.mount(containerRef.current);
|
|
@@ -6569,15 +6591,15 @@ function AddressElement({
|
|
|
6569
6591
|
}, [onReady, onChange, onError]);
|
|
6570
6592
|
React14.useEffect(() => {
|
|
6571
6593
|
if (!elements || !containerRef.current) return;
|
|
6572
|
-
const element = elements.create(
|
|
6594
|
+
const element = elements.create(chunk6JEKKL3M_js.ELEMENT_TYPES.ADDRESS, { mode });
|
|
6573
6595
|
elementRef.current = element;
|
|
6574
|
-
element.on(
|
|
6596
|
+
element.on(chunk6JEKKL3M_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
6575
6597
|
element.on(
|
|
6576
|
-
|
|
6598
|
+
chunk6JEKKL3M_js.EVENT_TYPES.CHANGE,
|
|
6577
6599
|
(data) => onChangeRef.current?.(data)
|
|
6578
6600
|
);
|
|
6579
6601
|
element.on(
|
|
6580
|
-
|
|
6602
|
+
chunk6JEKKL3M_js.EVENT_TYPES.ERROR,
|
|
6581
6603
|
(data) => onErrorRef.current?.(data)
|
|
6582
6604
|
);
|
|
6583
6605
|
element.mount(containerRef.current);
|
|
@@ -6607,15 +6629,15 @@ function PaymentElement({
|
|
|
6607
6629
|
}, [onReady, onChange, onError]);
|
|
6608
6630
|
React14.useEffect(() => {
|
|
6609
6631
|
if (!elements || !containerRef.current) return;
|
|
6610
|
-
const element = elements.create(
|
|
6632
|
+
const element = elements.create(chunk6JEKKL3M_js.ELEMENT_TYPES.PAYMENT, { amount, currency });
|
|
6611
6633
|
elementRef.current = element;
|
|
6612
|
-
element.on(
|
|
6634
|
+
element.on(chunk6JEKKL3M_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
6613
6635
|
element.on(
|
|
6614
|
-
|
|
6636
|
+
chunk6JEKKL3M_js.EVENT_TYPES.CHANGE,
|
|
6615
6637
|
(data) => onChangeRef.current?.(data)
|
|
6616
6638
|
);
|
|
6617
6639
|
element.on(
|
|
6618
|
-
|
|
6640
|
+
chunk6JEKKL3M_js.EVENT_TYPES.ERROR,
|
|
6619
6641
|
(data) => onErrorRef.current?.(data)
|
|
6620
6642
|
);
|
|
6621
6643
|
element.mount(containerRef.current);
|
package/dist/react.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, isMultiDayServi
|
|
|
3
3
|
export { getVariantDisplayName } from './chunk-4G5UWFC3.mjs';
|
|
4
4
|
import { splitGenUIContent, messagePreview } from './chunk-U4MW6PYU.mjs';
|
|
5
5
|
export { messagePreview, splitGenUIContent } from './chunk-U4MW6PYU.mjs';
|
|
6
|
-
import { SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, AUTH_TOKEN_CHANGED, MUTATION_ERROR } from './chunk-
|
|
7
|
-
import { generateIdempotencyKey, ELEMENT_TYPES, EVENT_TYPES, startSignIn } from './chunk-
|
|
6
|
+
import { SESSION_CLAIMED, SESSION_CLEARED, createCimplifyClient, AUTH_TOKEN_CHANGED, MUTATION_ERROR } from './chunk-PJUXAUM2.mjs';
|
|
7
|
+
import { generateIdempotencyKey, ELEMENT_TYPES, EVENT_TYPES, startSignIn } from './chunk-TIQLOH2B.mjs';
|
|
8
8
|
import { parsePrice, formatMoney, formatPrice, getVariantUnitPrice, getProductCurrency, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-DLW3RWRK.mjs';
|
|
9
9
|
import { isSupportedCurrency, currencyCode, CimplifyError } from './chunk-O3YUHLZL.mjs';
|
|
10
10
|
import './chunk-3G6RQLXK.mjs';
|
|
@@ -355,6 +355,26 @@ function Ad({
|
|
|
355
355
|
}
|
|
356
356
|
|
|
357
357
|
// src/utils/cart-transform.ts
|
|
358
|
+
var DECIMAL_AMOUNT_PATTERN = /^([+-]?)(\d+)(?:\.(\d+))?$/;
|
|
359
|
+
function multiplyDecimalByInteger(value, multiplier) {
|
|
360
|
+
if (!Number.isSafeInteger(multiplier) || multiplier < 0) {
|
|
361
|
+
throw new RangeError("Cart item quantity must be a non-negative safe integer");
|
|
362
|
+
}
|
|
363
|
+
const source = String(value).trim();
|
|
364
|
+
const match = DECIMAL_AMOUNT_PATTERN.exec(source);
|
|
365
|
+
if (!match) {
|
|
366
|
+
throw new TypeError("Cart item price must be a decimal amount");
|
|
367
|
+
}
|
|
368
|
+
const [, sign, whole, fraction = ""] = match;
|
|
369
|
+
const scaledAmount = BigInt(`${sign}${whole}${fraction}`);
|
|
370
|
+
const scaledTotal = scaledAmount * BigInt(multiplier);
|
|
371
|
+
if (fraction.length === 0) return scaledTotal.toString();
|
|
372
|
+
const negative = scaledTotal < 0n;
|
|
373
|
+
const digits = (negative ? -scaledTotal : scaledTotal).toString().padStart(fraction.length + 1, "0");
|
|
374
|
+
const splitAt = digits.length - fraction.length;
|
|
375
|
+
const formatted = `${digits.slice(0, splitAt)}.${digits.slice(splitAt)}`;
|
|
376
|
+
return negative ? `-${formatted}` : formatted;
|
|
377
|
+
}
|
|
358
378
|
function getSelections(item) {
|
|
359
379
|
if (item.bundle_resolved?.selections?.length) {
|
|
360
380
|
return item.bundle_resolved.selections.map((s) => ({
|
|
@@ -373,11 +393,12 @@ function getSelections(item) {
|
|
|
373
393
|
}
|
|
374
394
|
function mapItem(item, fx) {
|
|
375
395
|
const amt = (value) => fx ? String(fx.convertPrice(value)) : String(value);
|
|
396
|
+
const currentUnitPrice = item.total_price;
|
|
376
397
|
const result = {
|
|
377
398
|
name: item.name,
|
|
378
399
|
quantity: item.quantity,
|
|
379
|
-
unit_price: amt(
|
|
380
|
-
total_price: amt(item.
|
|
400
|
+
unit_price: amt(currentUnitPrice),
|
|
401
|
+
total_price: amt(multiplyDecimalByInteger(currentUnitPrice, item.quantity)),
|
|
381
402
|
line_type: item.line_type
|
|
382
403
|
};
|
|
383
404
|
if (item.image_url) result.image_url = item.image_url;
|
|
@@ -398,9 +419,9 @@ function mapItem(item, fx) {
|
|
|
398
419
|
}
|
|
399
420
|
return result;
|
|
400
421
|
}
|
|
401
|
-
function transformToCheckoutCart(cart, fx) {
|
|
422
|
+
function transformToCheckoutCart(cart, fx, checkout) {
|
|
402
423
|
const amt = (value) => fx ? String(fx.convertPrice(value)) : String(value);
|
|
403
|
-
|
|
424
|
+
const checkoutCart = {
|
|
404
425
|
items: cart.items.map((item) => mapItem(item, fx)),
|
|
405
426
|
subtotal: amt(cart.pricing.subtotal),
|
|
406
427
|
tax_amount: amt(cart.pricing.tax_amount),
|
|
@@ -413,6 +434,7 @@ function transformToCheckoutCart(cart, fx) {
|
|
|
413
434
|
deposit_amount: cart.pricing.deposit_amount != null ? amt(cart.pricing.deposit_amount) : void 0,
|
|
414
435
|
requires_delivery: cart.requires_delivery
|
|
415
436
|
};
|
|
437
|
+
return checkoutCart;
|
|
416
438
|
}
|
|
417
439
|
|
|
418
440
|
// src/internal/collection.ts
|
package/dist/server.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { af as CimplifyClient } from './client-
|
|
2
|
-
export { J as CacheOptions,
|
|
3
|
-
export { S as Category, V as CimplifyError, W as Collection, aZ as Product, bb as ProductWithDetails } from './product-
|
|
1
|
+
import { af as CimplifyClient } from './client-D8XcrONA.mjs';
|
|
2
|
+
export { J as CacheOptions, cD as ReadRequestOptions, c_ as Result } from './client-D8XcrONA.mjs';
|
|
3
|
+
export { S as Category, V as CimplifyError, W as Collection, aZ as Product, bb as ProductWithDetails } from './product-CeV8euw4.mjs';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
|
-
import './payment-
|
|
5
|
+
import './payment-BSzy7sly.mjs';
|
|
6
6
|
|
|
7
7
|
interface ServerClientOptions {
|
|
8
8
|
/**
|
package/dist/server.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { af as CimplifyClient } from './client-
|
|
2
|
-
export { J as CacheOptions,
|
|
3
|
-
export { S as Category, V as CimplifyError, W as Collection, aZ as Product, bb as ProductWithDetails } from './product-
|
|
1
|
+
import { af as CimplifyClient } from './client-LPg_AUUr.js';
|
|
2
|
+
export { J as CacheOptions, cD as ReadRequestOptions, c_ as Result } from './client-LPg_AUUr.js';
|
|
3
|
+
export { S as Category, V as CimplifyError, W as Collection, aZ as Product, bb as ProductWithDetails } from './product-CeV8euw4.js';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
|
-
import './payment-
|
|
5
|
+
import './payment-jK8ztICx.js';
|
|
6
6
|
|
|
7
7
|
interface ServerClientOptions {
|
|
8
8
|
/**
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkIJI7KMTG_js = require('./chunk-IJI7KMTG.js');
|
|
4
|
+
var chunk6JEKKL3M_js = require('./chunk-6JEKKL3M.js');
|
|
5
5
|
require('./chunk-WMEC5JWN.js');
|
|
6
6
|
var chunkNIOUSKQQ_js = require('./chunk-NIOUSKQQ.js');
|
|
7
7
|
require('./chunk-OWW5GUSB.js');
|
|
@@ -26,7 +26,7 @@ function readEnv(...keys) {
|
|
|
26
26
|
var getServerClient = react.cache((opts = {}) => {
|
|
27
27
|
const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? defaultBaseUrl();
|
|
28
28
|
const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
|
|
29
|
-
const client =
|
|
29
|
+
const client = chunkIJI7KMTG_js.createCimplifyClient({
|
|
30
30
|
baseUrl,
|
|
31
31
|
publicKey,
|
|
32
32
|
suppressPublicKeyWarning: true
|
|
@@ -250,7 +250,7 @@ var QUERY_AUTH_ERROR = "cimplify_auth_error";
|
|
|
250
250
|
var discoveryCache = /* @__PURE__ */ new Map();
|
|
251
251
|
var jwksCache = /* @__PURE__ */ new Map();
|
|
252
252
|
function issuerBase(cfg) {
|
|
253
|
-
return (cfg.issuer ?? cfg.authUrl ??
|
|
253
|
+
return (cfg.issuer ?? cfg.authUrl ?? chunk6JEKKL3M_js.DEFAULT_ISSUER).replace(/\/$/, "");
|
|
254
254
|
}
|
|
255
255
|
function cookieName(cfg) {
|
|
256
256
|
return cfg.cookieName ?? SESSION_COOKIE;
|
|
@@ -465,12 +465,12 @@ async function handleOidcCallback(req, opts) {
|
|
|
465
465
|
}
|
|
466
466
|
function readPkceCookie(cookieHeader) {
|
|
467
467
|
if (!cookieHeader) return null;
|
|
468
|
-
const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${
|
|
468
|
+
const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunk6JEKKL3M_js.PKCE_COOKIE}=`));
|
|
469
469
|
if (!match) return null;
|
|
470
|
-
return
|
|
470
|
+
return chunk6JEKKL3M_js.decodePkceState(match.slice(chunk6JEKKL3M_js.PKCE_COOKIE.length + 1));
|
|
471
471
|
}
|
|
472
472
|
function buildPkceClearCookie() {
|
|
473
|
-
return `${
|
|
473
|
+
return `${chunk6JEKKL3M_js.PKCE_COOKIE}=; Path=${chunk6JEKKL3M_js.PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
|
|
474
474
|
}
|
|
475
475
|
function safeReturnPath(returnTo, fallback) {
|
|
476
476
|
if (returnTo && returnTo.startsWith("/") && !returnTo.startsWith("//")) return returnTo;
|
package/dist/server.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createCimplifyClient } from './chunk-
|
|
2
|
-
import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-
|
|
1
|
+
import { createCimplifyClient } from './chunk-PJUXAUM2.mjs';
|
|
2
|
+
import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-TIQLOH2B.mjs';
|
|
3
3
|
import './chunk-DLW3RWRK.mjs';
|
|
4
4
|
export { CimplifyError } from './chunk-O3YUHLZL.mjs';
|
|
5
5
|
import './chunk-3G6RQLXK.mjs';
|
package/dist/testing/msw.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as AppHandle, C as CreateAppOptions } from '../server
|
|
1
|
+
import { A as AppHandle, C as CreateAppOptions } from '../server--RyVAfPN.mjs';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../product-
|
|
3
|
+
import '../product-CeV8euw4.mjs';
|
|
4
4
|
|
|
5
5
|
interface MswHandlerSetup {
|
|
6
6
|
handlers: unknown[];
|
package/dist/testing/msw.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as AppHandle, C as CreateAppOptions } from '../server-
|
|
1
|
+
import { A as AppHandle, C as CreateAppOptions } from '../server-CNyy47HL.js';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../product-
|
|
3
|
+
import '../product-CeV8euw4.js';
|
|
4
4
|
|
|
5
5
|
interface MswHandlerSetup {
|
|
6
6
|
handlers: unknown[];
|
package/dist/testing/msw.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkIFAQLFAJ_js = require('../chunk-IFAQLFAJ.js');
|
|
4
4
|
require('../chunk-XREIZ56K.js');
|
|
5
5
|
require('../chunk-NIOUSKQQ.js');
|
|
6
6
|
require('../chunk-OWW5GUSB.js');
|
|
@@ -8,7 +8,7 @@ require('../chunk-OWW5GUSB.js');
|
|
|
8
8
|
// src/mock/msw.ts
|
|
9
9
|
async function createMswHandlers(options = {}) {
|
|
10
10
|
const baseUrl = options.baseUrl ?? "http://localhost:8787";
|
|
11
|
-
const handle =
|
|
11
|
+
const handle = chunkIFAQLFAJ_js.createMockApp(options);
|
|
12
12
|
const msw = await import('msw').catch(() => {
|
|
13
13
|
throw new Error("msw is required to use @cimplify/sdk/mock/msw \u2014 install it as a peer dependency");
|
|
14
14
|
});
|
package/dist/testing/msw.mjs
CHANGED
package/dist/testing/suite.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TestAPI } from 'vitest';
|
|
2
|
-
import { T as TestClientHandle } from '../client-
|
|
3
|
-
import { C as CreateAppOptions } from '../server
|
|
4
|
-
export { S as SeedName } from '../server
|
|
5
|
-
import '../client-
|
|
6
|
-
import '../product-
|
|
7
|
-
import '../payment-
|
|
2
|
+
import { T as TestClientHandle } from '../client-C6wb92AD.mjs';
|
|
3
|
+
import { C as CreateAppOptions } from '../server--RyVAfPN.mjs';
|
|
4
|
+
export { S as SeedName } from '../server--RyVAfPN.mjs';
|
|
5
|
+
import '../client-D8XcrONA.mjs';
|
|
6
|
+
import '../product-CeV8euw4.mjs';
|
|
7
|
+
import '../payment-BSzy7sly.mjs';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|
package/dist/testing/suite.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TestAPI } from 'vitest';
|
|
2
|
-
import { T as TestClientHandle } from '../client-
|
|
3
|
-
import { C as CreateAppOptions } from '../server-
|
|
4
|
-
export { S as SeedName } from '../server-
|
|
5
|
-
import '../client-
|
|
6
|
-
import '../product-
|
|
7
|
-
import '../payment-
|
|
2
|
+
import { T as TestClientHandle } from '../client-CgXkRu2o.js';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-CNyy47HL.js';
|
|
4
|
+
export { S as SeedName } from '../server-CNyy47HL.js';
|
|
5
|
+
import '../client-LPg_AUUr.js';
|
|
6
|
+
import '../product-CeV8euw4.js';
|
|
7
|
+
import '../payment-jK8ztICx.js';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|
package/dist/testing/suite.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkQRBBSIAY_js = require('../chunk-QRBBSIAY.js');
|
|
4
|
+
require('../chunk-IFAQLFAJ.js');
|
|
5
5
|
require('../chunk-XREIZ56K.js');
|
|
6
|
-
require('../chunk-
|
|
7
|
-
require('../chunk-
|
|
6
|
+
require('../chunk-IJI7KMTG.js');
|
|
7
|
+
require('../chunk-6JEKKL3M.js');
|
|
8
8
|
require('../chunk-WMEC5JWN.js');
|
|
9
9
|
require('../chunk-NIOUSKQQ.js');
|
|
10
10
|
require('../chunk-OWW5GUSB.js');
|
|
@@ -21,11 +21,11 @@ var PLACEHOLDER_PHRASES = [
|
|
|
21
21
|
function createBrandSuite(opts) {
|
|
22
22
|
vitest.describe(opts.label ?? "brand schema", () => {
|
|
23
23
|
vitest.it("conforms to the Cimplify brand contract", () => {
|
|
24
|
-
vitest.expect(() =>
|
|
24
|
+
vitest.expect(() => chunkQRBBSIAY_js.assertBrand(opts.brand)).not.toThrow();
|
|
25
25
|
});
|
|
26
26
|
vitest.it("declares a known mock seed", () => {
|
|
27
27
|
const b = opts.brand;
|
|
28
|
-
vitest.expect(
|
|
28
|
+
vitest.expect(chunkQRBBSIAY_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
|
|
29
29
|
});
|
|
30
30
|
vitest.it("has no placeholder copy left in", () => {
|
|
31
31
|
const offenders = [];
|
|
@@ -57,7 +57,7 @@ ${msg}`);
|
|
|
57
57
|
vitest.expect(b.mock?.businessId).toMatch(/^bus_/);
|
|
58
58
|
});
|
|
59
59
|
vitest.it("zod-parses cleanly", () => {
|
|
60
|
-
const result =
|
|
60
|
+
const result = chunkQRBBSIAY_js.BrandSchema.safeParse(opts.brand);
|
|
61
61
|
if (!result.success) {
|
|
62
62
|
throw new Error(
|
|
63
63
|
"Brand schema violations:\n" + result.error.issues.map((i) => ` \u2022 brand.${i.path.join(".")}: ${i.message}`).join("\n")
|
|
@@ -72,23 +72,23 @@ function createCartFlowSuite(opts = {}) {
|
|
|
72
72
|
vitest.describe(opts.label ?? "cart flow against in-process mock", () => {
|
|
73
73
|
let h;
|
|
74
74
|
vitest.beforeEach(() => {
|
|
75
|
-
h =
|
|
75
|
+
h = chunkQRBBSIAY_js.createTestClient(opts);
|
|
76
76
|
});
|
|
77
77
|
vitest.afterEach(() => h.dispose());
|
|
78
78
|
vitest.it("starts with an empty cart matching the canonical shape", async () => {
|
|
79
79
|
const res = await h.client.cart.get();
|
|
80
80
|
vitest.expect(res.ok).toBe(true);
|
|
81
81
|
if (!res.ok) return;
|
|
82
|
-
vitest.expect(() =>
|
|
82
|
+
vitest.expect(() => chunkQRBBSIAY_js.assertCart(res.value)).not.toThrow();
|
|
83
83
|
vitest.expect(res.value.items).toHaveLength(0);
|
|
84
84
|
});
|
|
85
85
|
vitest.it("adds the first product, persists it, and returns a shape-valid cart", async () => {
|
|
86
|
-
const { product, variantId } = await
|
|
86
|
+
const { product, variantId } = await chunkQRBBSIAY_js.fixtures.addFirstProduct(h.client);
|
|
87
87
|
vitest.expect(product.id).toBeTruthy();
|
|
88
88
|
const get = await h.client.cart.get();
|
|
89
89
|
vitest.expect(get.ok).toBe(true);
|
|
90
90
|
if (!get.ok) return;
|
|
91
|
-
vitest.expect(() =>
|
|
91
|
+
vitest.expect(() => chunkQRBBSIAY_js.assertCart(get.value)).not.toThrow();
|
|
92
92
|
vitest.expect(get.value.items).toHaveLength(1);
|
|
93
93
|
vitest.expect(get.value.items[0]?.item_id).toBe(product.id);
|
|
94
94
|
if (variantId) {
|
|
@@ -99,8 +99,8 @@ function createCartFlowSuite(opts = {}) {
|
|
|
99
99
|
vitest.expect(parseFloat(String(get.value.pricing.subtotal))).toBeGreaterThan(0);
|
|
100
100
|
});
|
|
101
101
|
vitest.it("dedupes by line_key when adding the same product twice", async () => {
|
|
102
|
-
await
|
|
103
|
-
await
|
|
102
|
+
await chunkQRBBSIAY_js.fixtures.addFirstProduct(h.client);
|
|
103
|
+
await chunkQRBBSIAY_js.fixtures.addFirstProduct(h.client);
|
|
104
104
|
const res = await h.client.cart.get();
|
|
105
105
|
vitest.expect(res.ok).toBe(true);
|
|
106
106
|
if (!res.ok) return;
|
|
@@ -108,7 +108,7 @@ function createCartFlowSuite(opts = {}) {
|
|
|
108
108
|
vitest.expect(res.value.items[0]?.quantity).toBe(2);
|
|
109
109
|
});
|
|
110
110
|
vitest.it("removes items and zeroes the subtotal", async () => {
|
|
111
|
-
await
|
|
111
|
+
await chunkQRBBSIAY_js.fixtures.addFirstProduct(h.client);
|
|
112
112
|
const before = await h.client.cart.get();
|
|
113
113
|
if (!before.ok) throw before.error;
|
|
114
114
|
const itemId = before.value.items[0]?.id;
|
|
@@ -134,28 +134,28 @@ function createContractSuite(opts = {}) {
|
|
|
134
134
|
vitest.describe(opts.label ?? "SDK \u2194 mock contract", () => {
|
|
135
135
|
let h;
|
|
136
136
|
vitest.beforeEach(() => {
|
|
137
|
-
h =
|
|
137
|
+
h = chunkQRBBSIAY_js.createTestClient(opts);
|
|
138
138
|
});
|
|
139
139
|
vitest.afterEach(() => h.dispose());
|
|
140
140
|
vitest.it("AddItemPayload schema accepts a minimal valid body", () => {
|
|
141
|
-
const result =
|
|
141
|
+
const result = chunkQRBBSIAY_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
|
|
142
142
|
vitest.expect(result.success).toBe(true);
|
|
143
143
|
});
|
|
144
144
|
vitest.it("AddItemPayload schema rejects negative quantity", () => {
|
|
145
|
-
const result =
|
|
145
|
+
const result = chunkQRBBSIAY_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
|
|
146
146
|
vitest.expect(result.success).toBe(false);
|
|
147
147
|
});
|
|
148
148
|
vitest.it("AddItemPayload schema rejects empty item_id", () => {
|
|
149
|
-
const result =
|
|
149
|
+
const result = chunkQRBBSIAY_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
|
|
150
150
|
vitest.expect(result.success).toBe(false);
|
|
151
151
|
});
|
|
152
152
|
vitest.it("Cart line items returned by the mock match CartItemSchema", async () => {
|
|
153
|
-
const { product } = await
|
|
153
|
+
const { product } = await chunkQRBBSIAY_js.fixtures.addFirstProduct(h.client);
|
|
154
154
|
const get = await h.client.cart.get();
|
|
155
155
|
if (!get.ok) throw get.error;
|
|
156
156
|
vitest.expect(get.value.items.length).toBeGreaterThan(0);
|
|
157
157
|
for (const item of get.value.items) {
|
|
158
|
-
const result =
|
|
158
|
+
const result = chunkQRBBSIAY_js.CartItemSchema.safeParse(item);
|
|
159
159
|
if (!result.success) {
|
|
160
160
|
const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
161
161
|
throw new Error(`Cart item shape mismatch for ${product.name}:
|
|
@@ -165,19 +165,19 @@ ${issues}`);
|
|
|
165
165
|
}
|
|
166
166
|
});
|
|
167
167
|
vitest.it("CheckoutResponse from the mock includes bill_token", async () => {
|
|
168
|
-
await
|
|
168
|
+
await chunkQRBBSIAY_js.fixtures.addFirstProduct(h.client);
|
|
169
169
|
const cartRes = await h.client.cart.get();
|
|
170
170
|
if (!cartRes.ok) throw cartRes.error;
|
|
171
171
|
const checkout = await h.client.checkout.process({
|
|
172
172
|
cart_id: cartRes.value.id,
|
|
173
|
-
customer:
|
|
173
|
+
customer: chunkQRBBSIAY_js.fixtures.customer(),
|
|
174
174
|
order_type: "delivery",
|
|
175
175
|
payment_method: "mobile_money",
|
|
176
176
|
mobile_money_details: { phone_number: "+233244000000", provider: "mtn" }
|
|
177
177
|
});
|
|
178
178
|
vitest.expect(checkout.ok).toBe(true);
|
|
179
179
|
if (!checkout.ok) return;
|
|
180
|
-
const result =
|
|
180
|
+
const result = chunkQRBBSIAY_js.CheckoutResponseSchema.safeParse(checkout.value);
|
|
181
181
|
if (!result.success) {
|
|
182
182
|
const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
183
183
|
throw new Error(`CheckoutResponse shape mismatch:
|
package/dist/testing/suite.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-YWNJJO2U.mjs';
|
|
2
|
+
import '../chunk-B2YOCOLH.mjs';
|
|
3
3
|
import '../chunk-U4MW6PYU.mjs';
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-PJUXAUM2.mjs';
|
|
5
|
+
import '../chunk-TIQLOH2B.mjs';
|
|
6
6
|
import '../chunk-DLW3RWRK.mjs';
|
|
7
7
|
import '../chunk-O3YUHLZL.mjs';
|
|
8
8
|
import '../chunk-3G6RQLXK.mjs';
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { $ZodType } from 'zod/v4/core';
|
|
3
|
-
export { A as AddFirstProductOptions, a as AddFirstProductResult, P as ProductSummary, T as TestClientHandle, c as createTestClient, f as fixtures } from './client-
|
|
4
|
-
import './client-
|
|
5
|
-
import './product-
|
|
6
|
-
import './payment-
|
|
7
|
-
import './server
|
|
3
|
+
export { A as AddFirstProductOptions, a as AddFirstProductResult, P as ProductSummary, T as TestClientHandle, c as createTestClient, f as fixtures } from './client-C6wb92AD.mjs';
|
|
4
|
+
import './client-D8XcrONA.mjs';
|
|
5
|
+
import './product-CeV8euw4.mjs';
|
|
6
|
+
import './payment-BSzy7sly.mjs';
|
|
7
|
+
import './server--RyVAfPN.mjs';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|