@cimplify/sdk 0.52.2 → 0.53.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/{ads-BxbWrwqp.d.mts → ads-C2c2Aald.d.mts} +1 -1
- package/dist/{ads-BxbWrwqp.d.ts → ads-C2c2Aald.d.ts} +1 -1
- 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-R3F55BRN.mjs → chunk-3G4QCENX.mjs} +42 -22
- package/dist/{chunk-APHYBBDD.mjs → chunk-6QZQQRBB.mjs} +20 -9
- package/dist/{chunk-GLAVTDDE.mjs → chunk-B3Y4C4A7.mjs} +56 -53
- package/dist/{chunk-ROURLUXG.js → chunk-EJUKGJTZ.js} +4 -4
- package/dist/{chunk-Q5VGDCQF.js → chunk-HCZTBWU4.js} +42 -22
- package/dist/{chunk-EMS6DQIX.js → chunk-IJ32BXKZ.js} +54 -43
- package/dist/{chunk-VZS453ON.mjs → chunk-NEK7CVE2.mjs} +2 -2
- package/dist/{chunk-EQLT46ZR.js → chunk-YJLOOC3L.js} +56 -53
- package/dist/{client-C6J_RGlr.d.mts → client-306peWZ0.d.ts} +47 -29
- package/dist/{client-CX7IFIkL.d.ts → client-Bj2apl_y.d.mts} +47 -29
- package/dist/{client-Lt7uGLmT.d.ts → client-C2bKMy5g.d.ts} +2 -2
- package/dist/{client-DdefKjcs.d.mts → client-D1Gknspz.d.mts} +2 -2
- package/dist/{index-Bo0NjgR6.d.mts → index-D8vnKlOQ.d.mts} +4 -4
- package/dist/{index-BAohYhdg.d.ts → index-DIIlPUOC.d.ts} +4 -4
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +61 -61
- package/dist/index.mjs +2 -2
- package/dist/mock/cli.mjs +42 -22
- package/dist/mock/library.js +42 -22
- package/dist/mock/library.mjs +42 -22
- package/dist/mock/msw.js +42 -22
- package/dist/mock/msw.mjs +42 -22
- package/dist/{payment-_e99nSRj.d.ts → payment-DVS7ZUEp.d.mts} +2 -2
- package/dist/{payment-9L_-GWqQ.d.mts → payment-sn-yGL7v.d.ts} +2 -2
- package/dist/{price-BjehlIhG.d.mts → price-9T1Y47oS.d.ts} +2 -2
- package/dist/{price-CWQ5TQmk.d.ts → price-Cm0tU0V5.d.mts} +2 -2
- package/dist/{product-C-xLzh7Q.d.ts → product-B_kS4Oxa.d.mts} +1 -1
- package/dist/{product-C-xLzh7Q.d.mts → product-B_kS4Oxa.d.ts} +1 -1
- package/dist/react.d.mts +6 -6
- package/dist/react.d.ts +6 -6
- package/dist/react.js +16 -16
- package/dist/react.mjs +2 -2
- package/dist/{server-72rzvJ4Y.d.ts → server-BQzz921M.d.ts} +1 -1
- package/dist/{server-BgccqOLT.d.mts → server-D8rwqZQ6.d.mts} +1 -1
- package/dist/server.d.mts +20 -12
- package/dist/server.d.ts +20 -12
- package/dist/server.js +3 -3
- 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
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var chunkMN4PNKJA_js = require('./chunk-MN4PNKJA.js');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var chunkIJ32BXKZ_js = require('./chunk-IJ32BXKZ.js');
|
|
6
|
+
var chunkYJLOOC3L_js = require('./chunk-YJLOOC3L.js');
|
|
7
7
|
var chunk7Y2O3E4D_js = require('./chunk-7Y2O3E4D.js');
|
|
8
8
|
var chunkXA3ZNR75_js = require('./chunk-XA3ZNR75.js');
|
|
9
9
|
require('./chunk-OWW5GUSB.js');
|
|
@@ -1085,7 +1085,7 @@ var DEFAULT_COUNTRY = "US";
|
|
|
1085
1085
|
function createDefaultClient() {
|
|
1086
1086
|
const processRef = globalThis.process;
|
|
1087
1087
|
const envPublicKey = processRef?.env?.NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY || "";
|
|
1088
|
-
return
|
|
1088
|
+
return chunkIJ32BXKZ_js.createCimplifyClient({ publicKey: envPublicKey });
|
|
1089
1089
|
}
|
|
1090
1090
|
function getStoredLocationId() {
|
|
1091
1091
|
if (typeof window === "undefined" || !window.localStorage) {
|
|
@@ -3520,19 +3520,19 @@ function AuthElement({
|
|
|
3520
3520
|
}, [onReady, onAuthenticated, onRequiresOtp, onError]);
|
|
3521
3521
|
React10.useEffect(() => {
|
|
3522
3522
|
if (!elements || !containerRef.current) return;
|
|
3523
|
-
const element = elements.create(
|
|
3523
|
+
const element = elements.create(chunkYJLOOC3L_js.ELEMENT_TYPES.AUTH, { prefillEmail });
|
|
3524
3524
|
elementRef.current = element;
|
|
3525
|
-
element.on(
|
|
3525
|
+
element.on(chunkYJLOOC3L_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
3526
3526
|
element.on(
|
|
3527
|
-
|
|
3527
|
+
chunkYJLOOC3L_js.EVENT_TYPES.AUTHENTICATED,
|
|
3528
3528
|
(data) => onAuthenticatedRef.current?.(data)
|
|
3529
3529
|
);
|
|
3530
3530
|
element.on(
|
|
3531
|
-
|
|
3531
|
+
chunkYJLOOC3L_js.EVENT_TYPES.REQUIRES_OTP,
|
|
3532
3532
|
(data) => onRequiresOtpRef.current?.(data)
|
|
3533
3533
|
);
|
|
3534
3534
|
element.on(
|
|
3535
|
-
|
|
3535
|
+
chunkYJLOOC3L_js.EVENT_TYPES.ERROR,
|
|
3536
3536
|
(data) => onErrorRef.current?.(data)
|
|
3537
3537
|
);
|
|
3538
3538
|
element.mount(containerRef.current);
|
|
@@ -3561,15 +3561,15 @@ function AddressElement({
|
|
|
3561
3561
|
}, [onReady, onChange, onError]);
|
|
3562
3562
|
React10.useEffect(() => {
|
|
3563
3563
|
if (!elements || !containerRef.current) return;
|
|
3564
|
-
const element = elements.create(
|
|
3564
|
+
const element = elements.create(chunkYJLOOC3L_js.ELEMENT_TYPES.ADDRESS, { mode });
|
|
3565
3565
|
elementRef.current = element;
|
|
3566
|
-
element.on(
|
|
3566
|
+
element.on(chunkYJLOOC3L_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
3567
3567
|
element.on(
|
|
3568
|
-
|
|
3568
|
+
chunkYJLOOC3L_js.EVENT_TYPES.CHANGE,
|
|
3569
3569
|
(data) => onChangeRef.current?.(data)
|
|
3570
3570
|
);
|
|
3571
3571
|
element.on(
|
|
3572
|
-
|
|
3572
|
+
chunkYJLOOC3L_js.EVENT_TYPES.ERROR,
|
|
3573
3573
|
(data) => onErrorRef.current?.(data)
|
|
3574
3574
|
);
|
|
3575
3575
|
element.mount(containerRef.current);
|
|
@@ -3599,15 +3599,15 @@ function PaymentElement({
|
|
|
3599
3599
|
}, [onReady, onChange, onError]);
|
|
3600
3600
|
React10.useEffect(() => {
|
|
3601
3601
|
if (!elements || !containerRef.current) return;
|
|
3602
|
-
const element = elements.create(
|
|
3602
|
+
const element = elements.create(chunkYJLOOC3L_js.ELEMENT_TYPES.PAYMENT, { amount, currency });
|
|
3603
3603
|
elementRef.current = element;
|
|
3604
|
-
element.on(
|
|
3604
|
+
element.on(chunkYJLOOC3L_js.EVENT_TYPES.READY, () => onReadyRef.current?.());
|
|
3605
3605
|
element.on(
|
|
3606
|
-
|
|
3606
|
+
chunkYJLOOC3L_js.EVENT_TYPES.CHANGE,
|
|
3607
3607
|
(data) => onChangeRef.current?.(data)
|
|
3608
3608
|
);
|
|
3609
3609
|
element.on(
|
|
3610
|
-
|
|
3610
|
+
chunkYJLOOC3L_js.EVENT_TYPES.ERROR,
|
|
3611
3611
|
(data) => onErrorRef.current?.(data)
|
|
3612
3612
|
);
|
|
3613
3613
|
element.mount(containerRef.current);
|
package/dist/react.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { DURATION_UNIT, getVariantDisplayName, INPUT_FIELD_TYPE, PRODUCT_TYPE, RENDER_HINT } from './chunk-NRDRVZ62.mjs';
|
|
3
3
|
export { getVariantDisplayName } from './chunk-NRDRVZ62.mjs';
|
|
4
|
-
import { createCimplifyClient } from './chunk-
|
|
5
|
-
import { ELEMENT_TYPES, EVENT_TYPES } from './chunk-
|
|
4
|
+
import { createCimplifyClient } from './chunk-6QZQQRBB.mjs';
|
|
5
|
+
import { ELEMENT_TYPES, EVENT_TYPES } from './chunk-B3Y4C4A7.mjs';
|
|
6
6
|
import { formatPrice, parsePrice, getUnitPriceAtQuantity, isOnSale, getDiscountPercentage, getBasePrice, getPriceRange, formatPriceRange } from './chunk-TD3AY34U.mjs';
|
|
7
7
|
import { isSupportedCurrency } from './chunk-AMZXALF6.mjs';
|
|
8
8
|
import './chunk-3G6RQLXK.mjs';
|
package/dist/server.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
import './payment-
|
|
1
|
+
import { ac as CimplifyClient } from './client-Bj2apl_y.mjs';
|
|
2
|
+
export { J as CacheOptions, c7 as ReadRequestOptions, ct as Result } from './client-Bj2apl_y.mjs';
|
|
3
|
+
export { Q as Category, T as CimplifyError, U as Collection, aX as Product, b9 as ProductWithDetails } from './product-B_kS4Oxa.mjs';
|
|
4
|
+
import './payment-DVS7ZUEp.mjs';
|
|
5
5
|
|
|
6
6
|
interface ServerClientOptions {
|
|
7
7
|
/**
|
|
@@ -27,9 +27,17 @@ interface ServerClientOptions {
|
|
|
27
27
|
*
|
|
28
28
|
* The returned client is the exact same surface the browser uses — every
|
|
29
29
|
* resource (catalogue, cart, checkout, …) and every method works identically.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
30
|
+
*
|
|
31
|
+
* Caching is Next.js's responsibility. Pass `cacheOptions` per read method
|
|
32
|
+
* (`{ revalidate, tags }`); the SDK forwards them as `next: { revalidate, tags }`
|
|
33
|
+
* on the underlying fetch — Next 16's documented ISR API. Invalidate via the
|
|
34
|
+
* `revalidate*` helpers (also exported from this entry) or the bare
|
|
35
|
+
* `revalidateTag` / `revalidatePath` from `next/cache`.
|
|
36
|
+
*
|
|
37
|
+
* If you have `cacheComponents: true` in `next.config.ts` (Next 16 PPR-style
|
|
38
|
+
* caching), the `'use cache'` + `cacheTag` / `cacheLife` directives work too —
|
|
39
|
+
* but they require a Node-compatible runtime and won't function on Cloudflare
|
|
40
|
+
* Workers. For Workers / WfP storefronts, stay on the ISR (`cacheOptions`) path.
|
|
33
41
|
*
|
|
34
42
|
* Errors continue to flow through `Result<T, CimplifyError>`. Use the SDK's
|
|
35
43
|
* `unwrap()` helper, or `if (!result.ok) notFound()` — whichever is
|
|
@@ -37,13 +45,13 @@ interface ServerClientOptions {
|
|
|
37
45
|
*
|
|
38
46
|
* @example
|
|
39
47
|
* import { getServerClient, tags } from "@cimplify/sdk/server";
|
|
40
|
-
*
|
|
48
|
+
*
|
|
49
|
+
* export const revalidate = 3600;
|
|
41
50
|
*
|
|
42
51
|
* async function getProduct(slug: string) {
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* const r = await getServerClient().catalogue.getProductBySlug(slug);
|
|
52
|
+
* const r = await getServerClient().catalogue.getProductBySlug(slug, {
|
|
53
|
+
* cacheOptions: { revalidate: 3600, tags: [tags.product(slug)] },
|
|
54
|
+
* });
|
|
47
55
|
* if (!r.ok) throw new Error(r.error.message);
|
|
48
56
|
* return r.value;
|
|
49
57
|
* }
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
import './payment-
|
|
1
|
+
import { ac as CimplifyClient } from './client-306peWZ0.js';
|
|
2
|
+
export { J as CacheOptions, c7 as ReadRequestOptions, ct as Result } from './client-306peWZ0.js';
|
|
3
|
+
export { Q as Category, T as CimplifyError, U as Collection, aX as Product, b9 as ProductWithDetails } from './product-B_kS4Oxa.js';
|
|
4
|
+
import './payment-sn-yGL7v.js';
|
|
5
5
|
|
|
6
6
|
interface ServerClientOptions {
|
|
7
7
|
/**
|
|
@@ -27,9 +27,17 @@ interface ServerClientOptions {
|
|
|
27
27
|
*
|
|
28
28
|
* The returned client is the exact same surface the browser uses — every
|
|
29
29
|
* resource (catalogue, cart, checkout, …) and every method works identically.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
30
|
+
*
|
|
31
|
+
* Caching is Next.js's responsibility. Pass `cacheOptions` per read method
|
|
32
|
+
* (`{ revalidate, tags }`); the SDK forwards them as `next: { revalidate, tags }`
|
|
33
|
+
* on the underlying fetch — Next 16's documented ISR API. Invalidate via the
|
|
34
|
+
* `revalidate*` helpers (also exported from this entry) or the bare
|
|
35
|
+
* `revalidateTag` / `revalidatePath` from `next/cache`.
|
|
36
|
+
*
|
|
37
|
+
* If you have `cacheComponents: true` in `next.config.ts` (Next 16 PPR-style
|
|
38
|
+
* caching), the `'use cache'` + `cacheTag` / `cacheLife` directives work too —
|
|
39
|
+
* but they require a Node-compatible runtime and won't function on Cloudflare
|
|
40
|
+
* Workers. For Workers / WfP storefronts, stay on the ISR (`cacheOptions`) path.
|
|
33
41
|
*
|
|
34
42
|
* Errors continue to flow through `Result<T, CimplifyError>`. Use the SDK's
|
|
35
43
|
* `unwrap()` helper, or `if (!result.ok) notFound()` — whichever is
|
|
@@ -37,13 +45,13 @@ interface ServerClientOptions {
|
|
|
37
45
|
*
|
|
38
46
|
* @example
|
|
39
47
|
* import { getServerClient, tags } from "@cimplify/sdk/server";
|
|
40
|
-
*
|
|
48
|
+
*
|
|
49
|
+
* export const revalidate = 3600;
|
|
41
50
|
*
|
|
42
51
|
* async function getProduct(slug: string) {
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* const r = await getServerClient().catalogue.getProductBySlug(slug);
|
|
52
|
+
* const r = await getServerClient().catalogue.getProductBySlug(slug, {
|
|
53
|
+
* cacheOptions: { revalidate: 3600, tags: [tags.product(slug)] },
|
|
54
|
+
* });
|
|
47
55
|
* if (!r.ok) throw new Error(r.error.message);
|
|
48
56
|
* return r.value;
|
|
49
57
|
* }
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkIJ32BXKZ_js = require('./chunk-IJ32BXKZ.js');
|
|
4
|
+
require('./chunk-YJLOOC3L.js');
|
|
5
5
|
require('./chunk-7Y2O3E4D.js');
|
|
6
6
|
var chunkXA3ZNR75_js = require('./chunk-XA3ZNR75.js');
|
|
7
7
|
require('./chunk-OWW5GUSB.js');
|
|
@@ -25,7 +25,7 @@ function readEnv(...keys) {
|
|
|
25
25
|
var getServerClient = react.cache((opts = {}) => {
|
|
26
26
|
const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? defaultBaseUrl();
|
|
27
27
|
const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
|
|
28
|
-
const client =
|
|
28
|
+
const client = chunkIJ32BXKZ_js.createCimplifyClient({
|
|
29
29
|
baseUrl,
|
|
30
30
|
publicKey,
|
|
31
31
|
suppressPublicKeyWarning: true
|
package/dist/server.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createCimplifyClient } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
import { createCimplifyClient } from './chunk-6QZQQRBB.mjs';
|
|
2
|
+
import './chunk-B3Y4C4A7.mjs';
|
|
3
3
|
import './chunk-TD3AY34U.mjs';
|
|
4
4
|
export { CimplifyError } from './chunk-AMZXALF6.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-D8rwqZQ6.mjs';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../product-
|
|
3
|
+
import '../product-B_kS4Oxa.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-BQzz921M.js';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../product-
|
|
3
|
+
import '../product-B_kS4Oxa.js';
|
|
4
4
|
|
|
5
5
|
interface MswHandlerSetup {
|
|
6
6
|
handlers: unknown[];
|
package/dist/testing/msw.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkHCZTBWU4_js = require('../chunk-HCZTBWU4.js');
|
|
4
4
|
require('../chunk-XA3ZNR75.js');
|
|
5
5
|
require('../chunk-OWW5GUSB.js');
|
|
6
6
|
|
|
7
7
|
// src/mock/msw.ts
|
|
8
8
|
async function createMswHandlers(options = {}) {
|
|
9
9
|
const baseUrl = options.baseUrl ?? "http://localhost:8787";
|
|
10
|
-
const handle =
|
|
10
|
+
const handle = chunkHCZTBWU4_js.createMockApp(options);
|
|
11
11
|
const msw = await import('msw').catch(() => {
|
|
12
12
|
throw new Error("msw is required to use @cimplify/sdk/mock/msw \u2014 install it as a peer dependency");
|
|
13
13
|
});
|
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-D1Gknspz.mjs';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-D8rwqZQ6.mjs';
|
|
4
|
+
export { S as SeedName } from '../server-D8rwqZQ6.mjs';
|
|
5
|
+
import '../client-Bj2apl_y.mjs';
|
|
6
|
+
import '../product-B_kS4Oxa.mjs';
|
|
7
|
+
import '../payment-DVS7ZUEp.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-C2bKMy5g.js';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-BQzz921M.js';
|
|
4
|
+
export { S as SeedName } from '../server-BQzz921M.js';
|
|
5
|
+
import '../client-306peWZ0.js';
|
|
6
|
+
import '../product-B_kS4Oxa.js';
|
|
7
|
+
import '../payment-sn-yGL7v.js';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|
package/dist/testing/suite.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
6
|
-
require('../chunk-
|
|
3
|
+
var chunkEJUKGJTZ_js = require('../chunk-EJUKGJTZ.js');
|
|
4
|
+
require('../chunk-HCZTBWU4.js');
|
|
5
|
+
require('../chunk-IJ32BXKZ.js');
|
|
6
|
+
require('../chunk-YJLOOC3L.js');
|
|
7
7
|
require('../chunk-7Y2O3E4D.js');
|
|
8
8
|
require('../chunk-XA3ZNR75.js');
|
|
9
9
|
require('../chunk-OWW5GUSB.js');
|
|
@@ -20,11 +20,11 @@ var PLACEHOLDER_PHRASES = [
|
|
|
20
20
|
function createBrandSuite(opts) {
|
|
21
21
|
vitest.describe(opts.label ?? "brand schema", () => {
|
|
22
22
|
vitest.it("conforms to the Cimplify brand contract", () => {
|
|
23
|
-
vitest.expect(() =>
|
|
23
|
+
vitest.expect(() => chunkEJUKGJTZ_js.assertBrand(opts.brand)).not.toThrow();
|
|
24
24
|
});
|
|
25
25
|
vitest.it("declares a known mock seed", () => {
|
|
26
26
|
const b = opts.brand;
|
|
27
|
-
vitest.expect(
|
|
27
|
+
vitest.expect(chunkEJUKGJTZ_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
|
|
28
28
|
});
|
|
29
29
|
vitest.it("has no placeholder copy left in", () => {
|
|
30
30
|
const offenders = [];
|
|
@@ -56,7 +56,7 @@ ${msg}`);
|
|
|
56
56
|
vitest.expect(b.mock?.businessId).toMatch(/^bus_/);
|
|
57
57
|
});
|
|
58
58
|
vitest.it("zod-parses cleanly", () => {
|
|
59
|
-
const result =
|
|
59
|
+
const result = chunkEJUKGJTZ_js.BrandSchema.safeParse(opts.brand);
|
|
60
60
|
if (!result.success) {
|
|
61
61
|
throw new Error(
|
|
62
62
|
"Brand schema violations:\n" + result.error.issues.map((i) => ` \u2022 brand.${i.path.join(".")}: ${i.message}`).join("\n")
|
|
@@ -71,23 +71,23 @@ function createCartFlowSuite(opts = {}) {
|
|
|
71
71
|
vitest.describe(opts.label ?? "cart flow against in-process mock", () => {
|
|
72
72
|
let h;
|
|
73
73
|
vitest.beforeEach(() => {
|
|
74
|
-
h =
|
|
74
|
+
h = chunkEJUKGJTZ_js.createTestClient(opts);
|
|
75
75
|
});
|
|
76
76
|
vitest.afterEach(() => h.dispose());
|
|
77
77
|
vitest.it("starts with an empty cart matching the canonical shape", async () => {
|
|
78
78
|
const res = await h.client.cart.get();
|
|
79
79
|
vitest.expect(res.ok).toBe(true);
|
|
80
80
|
if (!res.ok) return;
|
|
81
|
-
vitest.expect(() =>
|
|
81
|
+
vitest.expect(() => chunkEJUKGJTZ_js.assertCart(res.value)).not.toThrow();
|
|
82
82
|
vitest.expect(res.value.items).toHaveLength(0);
|
|
83
83
|
});
|
|
84
84
|
vitest.it("adds the first product, persists it, and returns a shape-valid cart", async () => {
|
|
85
|
-
const { product, variantId } = await
|
|
85
|
+
const { product, variantId } = await chunkEJUKGJTZ_js.fixtures.addFirstProduct(h.client);
|
|
86
86
|
vitest.expect(product.id).toBeTruthy();
|
|
87
87
|
const get = await h.client.cart.get();
|
|
88
88
|
vitest.expect(get.ok).toBe(true);
|
|
89
89
|
if (!get.ok) return;
|
|
90
|
-
vitest.expect(() =>
|
|
90
|
+
vitest.expect(() => chunkEJUKGJTZ_js.assertCart(get.value)).not.toThrow();
|
|
91
91
|
vitest.expect(get.value.items).toHaveLength(1);
|
|
92
92
|
vitest.expect(get.value.items[0]?.item_id).toBe(product.id);
|
|
93
93
|
if (variantId) {
|
|
@@ -98,8 +98,8 @@ function createCartFlowSuite(opts = {}) {
|
|
|
98
98
|
vitest.expect(parseFloat(String(get.value.pricing.subtotal))).toBeGreaterThan(0);
|
|
99
99
|
});
|
|
100
100
|
vitest.it("dedupes by line_key when adding the same product twice", async () => {
|
|
101
|
-
await
|
|
102
|
-
await
|
|
101
|
+
await chunkEJUKGJTZ_js.fixtures.addFirstProduct(h.client);
|
|
102
|
+
await chunkEJUKGJTZ_js.fixtures.addFirstProduct(h.client);
|
|
103
103
|
const res = await h.client.cart.get();
|
|
104
104
|
vitest.expect(res.ok).toBe(true);
|
|
105
105
|
if (!res.ok) return;
|
|
@@ -107,7 +107,7 @@ function createCartFlowSuite(opts = {}) {
|
|
|
107
107
|
vitest.expect(res.value.items[0]?.quantity).toBe(2);
|
|
108
108
|
});
|
|
109
109
|
vitest.it("removes items and zeroes the subtotal", async () => {
|
|
110
|
-
await
|
|
110
|
+
await chunkEJUKGJTZ_js.fixtures.addFirstProduct(h.client);
|
|
111
111
|
const before = await h.client.cart.get();
|
|
112
112
|
if (!before.ok) throw before.error;
|
|
113
113
|
const itemId = before.value.items[0]?.id;
|
|
@@ -133,28 +133,28 @@ function createContractSuite(opts = {}) {
|
|
|
133
133
|
vitest.describe(opts.label ?? "SDK \u2194 mock contract", () => {
|
|
134
134
|
let h;
|
|
135
135
|
vitest.beforeEach(() => {
|
|
136
|
-
h =
|
|
136
|
+
h = chunkEJUKGJTZ_js.createTestClient(opts);
|
|
137
137
|
});
|
|
138
138
|
vitest.afterEach(() => h.dispose());
|
|
139
139
|
vitest.it("AddItemPayload schema accepts a minimal valid body", () => {
|
|
140
|
-
const result =
|
|
140
|
+
const result = chunkEJUKGJTZ_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
|
|
141
141
|
vitest.expect(result.success).toBe(true);
|
|
142
142
|
});
|
|
143
143
|
vitest.it("AddItemPayload schema rejects negative quantity", () => {
|
|
144
|
-
const result =
|
|
144
|
+
const result = chunkEJUKGJTZ_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
|
|
145
145
|
vitest.expect(result.success).toBe(false);
|
|
146
146
|
});
|
|
147
147
|
vitest.it("AddItemPayload schema rejects empty item_id", () => {
|
|
148
|
-
const result =
|
|
148
|
+
const result = chunkEJUKGJTZ_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
|
|
149
149
|
vitest.expect(result.success).toBe(false);
|
|
150
150
|
});
|
|
151
151
|
vitest.it("Cart line items returned by the mock match CartItemSchema", async () => {
|
|
152
|
-
const { product } = await
|
|
152
|
+
const { product } = await chunkEJUKGJTZ_js.fixtures.addFirstProduct(h.client);
|
|
153
153
|
const get = await h.client.cart.get();
|
|
154
154
|
if (!get.ok) throw get.error;
|
|
155
155
|
vitest.expect(get.value.items.length).toBeGreaterThan(0);
|
|
156
156
|
for (const item of get.value.items) {
|
|
157
|
-
const result =
|
|
157
|
+
const result = chunkEJUKGJTZ_js.CartItemSchema.safeParse(item);
|
|
158
158
|
if (!result.success) {
|
|
159
159
|
const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
160
160
|
throw new Error(`Cart item shape mismatch for ${product.name}:
|
|
@@ -164,19 +164,19 @@ ${issues}`);
|
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
166
|
vitest.it("CheckoutResponse from the mock includes bill_token", async () => {
|
|
167
|
-
await
|
|
167
|
+
await chunkEJUKGJTZ_js.fixtures.addFirstProduct(h.client);
|
|
168
168
|
const cartRes = await h.client.cart.get();
|
|
169
169
|
if (!cartRes.ok) throw cartRes.error;
|
|
170
170
|
const checkout = await h.client.checkout.process({
|
|
171
171
|
cart_id: cartRes.value.id,
|
|
172
|
-
customer:
|
|
172
|
+
customer: chunkEJUKGJTZ_js.fixtures.customer(),
|
|
173
173
|
order_type: "delivery",
|
|
174
174
|
payment_method: "mobile_money",
|
|
175
175
|
mobile_money_details: { phone_number: "+233244000000", provider: "mtn" }
|
|
176
176
|
});
|
|
177
177
|
vitest.expect(checkout.ok).toBe(true);
|
|
178
178
|
if (!checkout.ok) return;
|
|
179
|
-
const result =
|
|
179
|
+
const result = chunkEJUKGJTZ_js.CheckoutResponseSchema.safeParse(checkout.value);
|
|
180
180
|
if (!result.success) {
|
|
181
181
|
const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
182
182
|
throw new Error(`CheckoutResponse shape mismatch:
|
package/dist/testing/suite.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
1
|
+
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-NEK7CVE2.mjs';
|
|
2
|
+
import '../chunk-3G4QCENX.mjs';
|
|
3
|
+
import '../chunk-6QZQQRBB.mjs';
|
|
4
|
+
import '../chunk-B3Y4C4A7.mjs';
|
|
5
5
|
import '../chunk-TD3AY34U.mjs';
|
|
6
6
|
import '../chunk-AMZXALF6.mjs';
|
|
7
7
|
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-D1Gknspz.mjs';
|
|
4
|
+
import './client-Bj2apl_y.mjs';
|
|
5
|
+
import './product-B_kS4Oxa.mjs';
|
|
6
|
+
import './payment-DVS7ZUEp.mjs';
|
|
7
|
+
import './server-D8rwqZQ6.mjs';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|
package/dist/testing.d.ts
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-C2bKMy5g.js';
|
|
4
|
+
import './client-306peWZ0.js';
|
|
5
|
+
import './product-B_kS4Oxa.js';
|
|
6
|
+
import './payment-sn-yGL7v.js';
|
|
7
|
+
import './server-BQzz921M.js';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|