@cimplify/sdk 0.80.0 → 0.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advanced.d.mts +3 -3
- package/dist/advanced.d.ts +3 -3
- package/dist/advanced.js +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-3BKMNVTR.mjs → chunk-7BM56JET.mjs} +1 -0
- package/dist/{chunk-FIC5S3KD.mjs → chunk-7PAQR3VC.mjs} +2 -2
- package/dist/{chunk-BNA4GW4D.mjs → chunk-BRVIXGUW.mjs} +60 -0
- package/dist/{chunk-NV445GMS.js → chunk-GFM5JW45.js} +48 -36
- package/dist/{chunk-CV5QMDQS.js → chunk-HPN5R3K2.js} +1 -0
- package/dist/{chunk-KMP4HVA2.js → chunk-IZDJEDR4.js} +4 -4
- package/dist/{chunk-NJGJCQWF.mjs → chunk-NWUEWUX2.mjs} +13 -1
- package/dist/{chunk-OSTOGR4F.js → chunk-SRJEMEVZ.js} +60 -0
- package/dist/{client-6BNd11sq.d.mts → client-BSpVgule.d.mts} +2 -2
- package/dist/{client-CuoWlAfH.d.ts → client-Dh-KIIX8.d.ts} +2 -2
- package/dist/{client-D22iSqke.d.ts → client-DnHP_2Jw.d.mts} +44 -4
- package/dist/{client-Czbt-mej.d.mts → client-xc2aQSB4.d.ts} +44 -4
- package/dist/{index-Moe4cGMB.d.ts → index-C4xE31-D.d.ts} +3 -3
- package/dist/{index-Bu76UyFz.d.mts → index-Dy8D3r9b.d.mts} +3 -3
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +69 -69
- package/dist/index.mjs +3 -3
- package/dist/mock/cli.mjs +60 -0
- package/dist/mock/library.js +60 -0
- package/dist/mock/library.mjs +60 -0
- package/dist/mock/msw.js +60 -0
- package/dist/mock/msw.mjs +60 -0
- package/dist/{payment-B7qzWdaJ.d.mts → payment-T_0MUE9o.d.mts} +1 -1
- package/dist/{payment-mVIJIJcq.d.ts → payment-nH9OCUg2.d.ts} +1 -1
- package/dist/{price-CS1IsORZ.d.ts → price-B8WMoldA.d.ts} +1 -1
- package/dist/{price-BfOaGqjx.d.mts → price-Bg7hujK_.d.mts} +1 -1
- package/dist/{product-BgFOFmQw.d.ts → product-DXhjLQ_w.d.mts} +1 -0
- package/dist/{product-BgFOFmQw.d.mts → product-DXhjLQ_w.d.ts} +1 -0
- package/dist/react.d.mts +23 -5
- package/dist/react.d.ts +23 -5
- package/dist/react.js +43 -17
- package/dist/react.mjs +29 -4
- package/dist/{server-CGO4zneR.d.mts → server-tr993CPj.d.mts} +22 -1
- package/dist/{server-Daq42vK7.d.ts → server-wAB-qfyZ.d.ts} +22 -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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import { b1 as ProductInputField } from './product-
|
|
2
|
+
import { b1 as ProductInputField } from './product-DXhjLQ_w.mjs';
|
|
3
3
|
|
|
4
4
|
interface Clock {
|
|
5
5
|
now(): Date;
|
|
@@ -894,6 +894,19 @@ interface PlacesService {
|
|
|
894
894
|
}): unknown;
|
|
895
895
|
}
|
|
896
896
|
|
|
897
|
+
interface MockDeliveryOption {
|
|
898
|
+
rate_id: string | null;
|
|
899
|
+
name: string;
|
|
900
|
+
description?: string;
|
|
901
|
+
fee: string;
|
|
902
|
+
currency: string;
|
|
903
|
+
free_delivery_applied: boolean;
|
|
904
|
+
free_over_amount?: string;
|
|
905
|
+
eta_min_minutes?: number;
|
|
906
|
+
eta_max_minutes?: number;
|
|
907
|
+
is_default: boolean;
|
|
908
|
+
details: Record<string, unknown>;
|
|
909
|
+
}
|
|
897
910
|
interface DeliveryService {
|
|
898
911
|
getFee(opts: {
|
|
899
912
|
lat?: number;
|
|
@@ -907,6 +920,14 @@ interface DeliveryService {
|
|
|
907
920
|
provider: string;
|
|
908
921
|
quotes: unknown[];
|
|
909
922
|
};
|
|
923
|
+
getOptions(opts: {
|
|
924
|
+
lat?: number;
|
|
925
|
+
lng?: number;
|
|
926
|
+
order_value?: string;
|
|
927
|
+
}): {
|
|
928
|
+
serviceable: boolean;
|
|
929
|
+
options: MockDeliveryOption[];
|
|
930
|
+
};
|
|
910
931
|
}
|
|
911
932
|
|
|
912
933
|
interface ActivityService {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import { b1 as ProductInputField } from './product-
|
|
2
|
+
import { b1 as ProductInputField } from './product-DXhjLQ_w.js';
|
|
3
3
|
|
|
4
4
|
interface Clock {
|
|
5
5
|
now(): Date;
|
|
@@ -894,6 +894,19 @@ interface PlacesService {
|
|
|
894
894
|
}): unknown;
|
|
895
895
|
}
|
|
896
896
|
|
|
897
|
+
interface MockDeliveryOption {
|
|
898
|
+
rate_id: string | null;
|
|
899
|
+
name: string;
|
|
900
|
+
description?: string;
|
|
901
|
+
fee: string;
|
|
902
|
+
currency: string;
|
|
903
|
+
free_delivery_applied: boolean;
|
|
904
|
+
free_over_amount?: string;
|
|
905
|
+
eta_min_minutes?: number;
|
|
906
|
+
eta_max_minutes?: number;
|
|
907
|
+
is_default: boolean;
|
|
908
|
+
details: Record<string, unknown>;
|
|
909
|
+
}
|
|
897
910
|
interface DeliveryService {
|
|
898
911
|
getFee(opts: {
|
|
899
912
|
lat?: number;
|
|
@@ -907,6 +920,14 @@ interface DeliveryService {
|
|
|
907
920
|
provider: string;
|
|
908
921
|
quotes: unknown[];
|
|
909
922
|
};
|
|
923
|
+
getOptions(opts: {
|
|
924
|
+
lat?: number;
|
|
925
|
+
lng?: number;
|
|
926
|
+
order_value?: string;
|
|
927
|
+
}): {
|
|
928
|
+
serviceable: boolean;
|
|
929
|
+
options: MockDeliveryOption[];
|
|
930
|
+
};
|
|
910
931
|
}
|
|
911
932
|
|
|
912
933
|
interface ActivityService {
|
package/dist/server.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ad as CimplifyClient } from './client-
|
|
2
|
-
export { K as CacheOptions,
|
|
3
|
-
export { Q as Category, T as CimplifyError, U as Collection, aX as Product, b9 as ProductWithDetails } from './product-
|
|
1
|
+
import { ad as CimplifyClient } from './client-DnHP_2Jw.mjs';
|
|
2
|
+
export { K as CacheOptions, ct as ReadRequestOptions, cP as Result } from './client-DnHP_2Jw.mjs';
|
|
3
|
+
export { Q as Category, T as CimplifyError, U as Collection, aX as Product, b9 as ProductWithDetails } from './product-DXhjLQ_w.mjs';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
|
-
import './payment-
|
|
5
|
+
import './payment-T_0MUE9o.mjs';
|
|
6
6
|
|
|
7
7
|
interface ServerClientOptions {
|
|
8
8
|
/**
|
package/dist/server.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ad as CimplifyClient } from './client-
|
|
2
|
-
export { K as CacheOptions,
|
|
3
|
-
export { Q as Category, T as CimplifyError, U as Collection, aX as Product, b9 as ProductWithDetails } from './product-
|
|
1
|
+
import { ad as CimplifyClient } from './client-xc2aQSB4.js';
|
|
2
|
+
export { K as CacheOptions, ct as ReadRequestOptions, cP as Result } from './client-xc2aQSB4.js';
|
|
3
|
+
export { Q as Category, T as CimplifyError, U as Collection, aX as Product, b9 as ProductWithDetails } from './product-DXhjLQ_w.js';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
|
-
import './payment-
|
|
5
|
+
import './payment-nH9OCUg2.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 chunkGFM5JW45_js = require('./chunk-GFM5JW45.js');
|
|
4
|
+
var chunkHPN5R3K2_js = require('./chunk-HPN5R3K2.js');
|
|
5
5
|
require('./chunk-7Y2O3E4D.js');
|
|
6
6
|
var chunkXA3ZNR75_js = require('./chunk-XA3ZNR75.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 = chunkGFM5JW45_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 ?? chunkHPN5R3K2_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(`${chunkHPN5R3K2_js.PKCE_COOKIE}=`));
|
|
469
469
|
if (!match) return null;
|
|
470
|
-
return
|
|
470
|
+
return chunkHPN5R3K2_js.decodePkceState(match.slice(chunkHPN5R3K2_js.PKCE_COOKIE.length + 1));
|
|
471
471
|
}
|
|
472
472
|
function buildPkceClearCookie() {
|
|
473
|
-
return `${
|
|
473
|
+
return `${chunkHPN5R3K2_js.PKCE_COOKIE}=; Path=${chunkHPN5R3K2_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-NWUEWUX2.mjs';
|
|
2
|
+
import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-7BM56JET.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-tr993CPj.mjs';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../product-
|
|
3
|
+
import '../product-DXhjLQ_w.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-wAB-qfyZ.js';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../product-
|
|
3
|
+
import '../product-DXhjLQ_w.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 chunkSRJEMEVZ_js = require('../chunk-SRJEMEVZ.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 = chunkSRJEMEVZ_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-BSpVgule.mjs';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-tr993CPj.mjs';
|
|
4
|
+
export { S as SeedName } from '../server-tr993CPj.mjs';
|
|
5
|
+
import '../client-DnHP_2Jw.mjs';
|
|
6
|
+
import '../product-DXhjLQ_w.mjs';
|
|
7
|
+
import '../payment-T_0MUE9o.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-Dh-KIIX8.js';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-wAB-qfyZ.js';
|
|
4
|
+
export { S as SeedName } from '../server-wAB-qfyZ.js';
|
|
5
|
+
import '../client-xc2aQSB4.js';
|
|
6
|
+
import '../product-DXhjLQ_w.js';
|
|
7
|
+
import '../payment-nH9OCUg2.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 chunkIZDJEDR4_js = require('../chunk-IZDJEDR4.js');
|
|
4
|
+
require('../chunk-SRJEMEVZ.js');
|
|
5
|
+
require('../chunk-GFM5JW45.js');
|
|
6
|
+
require('../chunk-HPN5R3K2.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(() => chunkIZDJEDR4_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(chunkIZDJEDR4_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 = chunkIZDJEDR4_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 = chunkIZDJEDR4_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(() => chunkIZDJEDR4_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 chunkIZDJEDR4_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(() => chunkIZDJEDR4_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 chunkIZDJEDR4_js.fixtures.addFirstProduct(h.client);
|
|
102
|
+
await chunkIZDJEDR4_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 chunkIZDJEDR4_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 = chunkIZDJEDR4_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 = chunkIZDJEDR4_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 = chunkIZDJEDR4_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 = chunkIZDJEDR4_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 chunkIZDJEDR4_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 = chunkIZDJEDR4_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 chunkIZDJEDR4_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: chunkIZDJEDR4_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 = chunkIZDJEDR4_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-7PAQR3VC.mjs';
|
|
2
|
+
import '../chunk-BRVIXGUW.mjs';
|
|
3
|
+
import '../chunk-NWUEWUX2.mjs';
|
|
4
|
+
import '../chunk-7BM56JET.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-BSpVgule.mjs';
|
|
4
|
+
import './client-DnHP_2Jw.mjs';
|
|
5
|
+
import './product-DXhjLQ_w.mjs';
|
|
6
|
+
import './payment-T_0MUE9o.mjs';
|
|
7
|
+
import './server-tr993CPj.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-Dh-KIIX8.js';
|
|
4
|
+
import './client-xc2aQSB4.js';
|
|
5
|
+
import './product-DXhjLQ_w.js';
|
|
6
|
+
import './payment-nH9OCUg2.js';
|
|
7
|
+
import './server-wAB-qfyZ.js';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|