@cimplify/sdk 0.100.0 → 0.100.1
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-J3UYIBKH.js → chunk-BHQCSHIG.js} +78 -72
- package/dist/{chunk-V5TU5JKA.mjs → chunk-DLW3RWRK.mjs} +30 -6
- package/dist/{chunk-I7L4VRHI.mjs → chunk-KEC2CX4R.mjs} +2 -2
- package/dist/{chunk-FECGCIVV.js → chunk-NH3HYUC3.js} +3 -3
- package/dist/{chunk-AETVRBKI.js → chunk-NIOUSKQQ.js} +1 -0
- package/dist/{chunk-7TEMLVDT.mjs → chunk-NKZIXLKW.mjs} +1 -1
- package/dist/{chunk-ZA5VKVUB.js → chunk-NR4Z2SFY.js} +4 -4
- package/dist/{chunk-K5EN2W2Q.mjs → chunk-O3YUHLZL.mjs} +1 -0
- package/dist/{chunk-OX5L6XE7.mjs → chunk-PTKAN4SI.mjs} +25 -15
- package/dist/{chunk-X6G6QERR.js → chunk-QGFKIAEM.js} +48 -38
- package/dist/{chunk-GWKIDFN6.mjs → chunk-T2B656RS.mjs} +8 -3
- package/dist/{chunk-64EDCDBR.js → chunk-WMEC5JWN.js} +32 -7
- package/dist/{client-C1vS5pf0.d.ts → client-B0Lku_lc.d.mts} +17 -16
- package/dist/{client-DmR3Z6pQ.d.ts → client-DRgEa78P.d.ts} +2 -2
- package/dist/{client-B5MeD8da.d.mts → client-DxgC_lXU.d.ts} +17 -16
- package/dist/{client-DQpvwf-p.d.mts → client-T5c-Nxq-.d.mts} +2 -2
- package/dist/{index-Br-vFygC.d.ts → index-CzKN1hjf.d.ts} +3 -3
- package/dist/{index-DUOCn1Cs.d.mts → index-DzuLT5wi.d.mts} +3 -3
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +117 -117
- package/dist/index.mjs +5 -5
- package/dist/{payment-BIpS9oPG.d.mts → payment-D8NEwCna.d.mts} +1 -1
- package/dist/{payment-CsuBKHqg.d.ts → payment-lZBP7h5M.d.ts} +1 -1
- package/dist/{price-IOOoVYS-.d.mts → price-DepWAmcL.d.mts} +1 -1
- package/dist/{price-Ml_uPoiY.d.ts → price-ncQb-TC8.d.ts} +1 -1
- package/dist/{product-BKV6TBj_.d.ts → product-B384_Qm2.d.mts} +12 -1
- package/dist/{product-BKV6TBj_.d.mts → product-B384_Qm2.d.ts} +12 -1
- package/dist/react.d.mts +10 -5
- package/dist/react.d.ts +10 -5
- package/dist/react.js +830 -446
- package/dist/react.mjs +711 -327
- package/dist/{server-CfpYhSV_.d.ts → server-B7O4ttpv.d.ts} +1 -1
- package/dist/{server-C0iEk55_.d.mts → server-oCGNIO_K.d.mts} +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 +1 -1
- package/registry/cart-summary.json +1 -1
- package/registry/product-customizer.json +1 -1
- package/registry/sale-badge.json +1 -1
package/dist/server.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { af as CimplifyClient } from './client-
|
|
2
|
-
export { J as CacheOptions, cC as ReadRequestOptions, cZ as Result } from './client-
|
|
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-B0Lku_lc.mjs';
|
|
2
|
+
export { J as CacheOptions, cC as ReadRequestOptions, cZ as Result } from './client-B0Lku_lc.mjs';
|
|
3
|
+
export { S as Category, V as CimplifyError, W as Collection, aZ as Product, bb as ProductWithDetails } from './product-B384_Qm2.mjs';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
|
-
import './payment-
|
|
5
|
+
import './payment-D8NEwCna.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, cC as ReadRequestOptions, cZ as Result } from './client-
|
|
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-DxgC_lXU.js';
|
|
2
|
+
export { J as CacheOptions, cC as ReadRequestOptions, cZ as Result } from './client-DxgC_lXU.js';
|
|
3
|
+
export { S as Category, V as CimplifyError, W as Collection, aZ as Product, bb as ProductWithDetails } from './product-B384_Qm2.js';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
|
-
import './payment-
|
|
5
|
+
import './payment-lZBP7h5M.js';
|
|
6
6
|
|
|
7
7
|
interface ServerClientOptions {
|
|
8
8
|
/**
|
package/dist/server.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
require('./chunk-
|
|
6
|
-
var
|
|
3
|
+
var chunkBHQCSHIG_js = require('./chunk-BHQCSHIG.js');
|
|
4
|
+
var chunkQGFKIAEM_js = require('./chunk-QGFKIAEM.js');
|
|
5
|
+
require('./chunk-WMEC5JWN.js');
|
|
6
|
+
var chunkNIOUSKQQ_js = require('./chunk-NIOUSKQQ.js');
|
|
7
7
|
require('./chunk-OWW5GUSB.js');
|
|
8
8
|
var react = require('react');
|
|
9
9
|
var jose = require('jose');
|
|
@@ -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 = chunkBHQCSHIG_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 ?? chunkQGFKIAEM_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(`${chunkQGFKIAEM_js.PKCE_COOKIE}=`));
|
|
469
469
|
if (!match) return null;
|
|
470
|
-
return
|
|
470
|
+
return chunkQGFKIAEM_js.decodePkceState(match.slice(chunkQGFKIAEM_js.PKCE_COOKIE.length + 1));
|
|
471
471
|
}
|
|
472
472
|
function buildPkceClearCookie() {
|
|
473
|
-
return `${
|
|
473
|
+
return `${chunkQGFKIAEM_js.PKCE_COOKIE}=; Path=${chunkQGFKIAEM_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;
|
|
@@ -642,7 +642,7 @@ async function handleTokenRefresh(req, cfg) {
|
|
|
642
642
|
|
|
643
643
|
Object.defineProperty(exports, "CimplifyError", {
|
|
644
644
|
enumerable: true,
|
|
645
|
-
get: function () { return
|
|
645
|
+
get: function () { return chunkNIOUSKQQ_js.CimplifyError; }
|
|
646
646
|
});
|
|
647
647
|
exports.CACHE_LIFE_DEFAULT = CACHE_LIFE_DEFAULT;
|
|
648
648
|
exports.CACHE_LIFE_PROBE = CACHE_LIFE_PROBE;
|
package/dist/server.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createCimplifyClient } from './chunk-
|
|
2
|
-
import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
export { CimplifyError } from './chunk-
|
|
1
|
+
import { createCimplifyClient } from './chunk-T2B656RS.mjs';
|
|
2
|
+
import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-PTKAN4SI.mjs';
|
|
3
|
+
import './chunk-DLW3RWRK.mjs';
|
|
4
|
+
export { CimplifyError } from './chunk-O3YUHLZL.mjs';
|
|
5
5
|
import './chunk-3G6RQLXK.mjs';
|
|
6
6
|
import { cache } from 'react';
|
|
7
7
|
import { jwtVerify, createRemoteJWKSet } from 'jose';
|
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-oCGNIO_K.mjs';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../product-
|
|
3
|
+
import '../product-B384_Qm2.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-B7O4ttpv.js';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../product-
|
|
3
|
+
import '../product-B384_Qm2.js';
|
|
4
4
|
|
|
5
5
|
interface MswHandlerSetup {
|
|
6
6
|
handlers: unknown[];
|
package/dist/testing/msw.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkNH3HYUC3_js = require('../chunk-NH3HYUC3.js');
|
|
4
4
|
require('../chunk-XREIZ56K.js');
|
|
5
|
-
require('../chunk-
|
|
5
|
+
require('../chunk-NIOUSKQQ.js');
|
|
6
6
|
require('../chunk-OWW5GUSB.js');
|
|
7
7
|
|
|
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 = chunkNH3HYUC3_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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createMockApp } from '../chunk-
|
|
1
|
+
import { createMockApp } from '../chunk-NKZIXLKW.mjs';
|
|
2
2
|
import '../chunk-U4MW6PYU.mjs';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-O3YUHLZL.mjs';
|
|
4
4
|
import '../chunk-3G6RQLXK.mjs';
|
|
5
5
|
|
|
6
6
|
// src/mock/msw.ts
|
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-T5c-Nxq-.mjs';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-oCGNIO_K.mjs';
|
|
4
|
+
export { S as SeedName } from '../server-oCGNIO_K.mjs';
|
|
5
|
+
import '../client-B0Lku_lc.mjs';
|
|
6
|
+
import '../product-B384_Qm2.mjs';
|
|
7
|
+
import '../payment-D8NEwCna.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-DRgEa78P.js';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-B7O4ttpv.js';
|
|
4
|
+
export { S as SeedName } from '../server-B7O4ttpv.js';
|
|
5
|
+
import '../client-DxgC_lXU.js';
|
|
6
|
+
import '../product-B384_Qm2.js';
|
|
7
|
+
import '../payment-lZBP7h5M.js';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|
package/dist/testing/suite.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkNR4Z2SFY_js = require('../chunk-NR4Z2SFY.js');
|
|
4
|
+
require('../chunk-NH3HYUC3.js');
|
|
5
5
|
require('../chunk-XREIZ56K.js');
|
|
6
|
-
require('../chunk-
|
|
7
|
-
require('../chunk-
|
|
8
|
-
require('../chunk-
|
|
9
|
-
require('../chunk-
|
|
6
|
+
require('../chunk-BHQCSHIG.js');
|
|
7
|
+
require('../chunk-QGFKIAEM.js');
|
|
8
|
+
require('../chunk-WMEC5JWN.js');
|
|
9
|
+
require('../chunk-NIOUSKQQ.js');
|
|
10
10
|
require('../chunk-OWW5GUSB.js');
|
|
11
11
|
var vitest = require('vitest');
|
|
12
12
|
|
|
@@ -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(() => chunkNR4Z2SFY_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(chunkNR4Z2SFY_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 = chunkNR4Z2SFY_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 = chunkNR4Z2SFY_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(() => chunkNR4Z2SFY_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 chunkNR4Z2SFY_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(() => chunkNR4Z2SFY_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 chunkNR4Z2SFY_js.fixtures.addFirstProduct(h.client);
|
|
103
|
+
await chunkNR4Z2SFY_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 chunkNR4Z2SFY_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 = chunkNR4Z2SFY_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 = chunkNR4Z2SFY_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 = chunkNR4Z2SFY_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 = chunkNR4Z2SFY_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 chunkNR4Z2SFY_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 = chunkNR4Z2SFY_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 chunkNR4Z2SFY_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: chunkNR4Z2SFY_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 = chunkNR4Z2SFY_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,10 +1,10 @@
|
|
|
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-KEC2CX4R.mjs';
|
|
2
|
+
import '../chunk-NKZIXLKW.mjs';
|
|
3
3
|
import '../chunk-U4MW6PYU.mjs';
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-T2B656RS.mjs';
|
|
5
|
+
import '../chunk-PTKAN4SI.mjs';
|
|
6
|
+
import '../chunk-DLW3RWRK.mjs';
|
|
7
|
+
import '../chunk-O3YUHLZL.mjs';
|
|
8
8
|
import '../chunk-3G6RQLXK.mjs';
|
|
9
9
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
10
10
|
|
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-T5c-Nxq-.mjs';
|
|
4
|
+
import './client-B0Lku_lc.mjs';
|
|
5
|
+
import './product-B384_Qm2.mjs';
|
|
6
|
+
import './payment-D8NEwCna.mjs';
|
|
7
|
+
import './server-oCGNIO_K.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-DRgEa78P.js';
|
|
4
|
+
import './client-DxgC_lXU.js';
|
|
5
|
+
import './product-B384_Qm2.js';
|
|
6
|
+
import './payment-lZBP7h5M.js';
|
|
7
|
+
import './server-B7O4ttpv.js';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|