@cimplify/sdk 0.82.0 → 0.84.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/{chunk-SRJEMEVZ.js → chunk-FKBXZ2A6.js} +212 -6
- package/dist/{chunk-7PAQR3VC.mjs → chunk-I6RE4BKH.mjs} +4 -2
- package/dist/{chunk-IZDJEDR4.js → chunk-ODEPW244.js} +5 -3
- package/dist/{chunk-BRVIXGUW.mjs → chunk-PLTP6HWW.mjs} +212 -6
- package/dist/{client-DnHP_2Jw.d.mts → client-Ba4Hng9i.d.mts} +2 -2
- package/dist/{client-BSpVgule.d.mts → client-BjUJapti.d.mts} +2 -2
- package/dist/{client-xc2aQSB4.d.ts → client-CINi3Dw3.d.ts} +2 -2
- package/dist/{client-Dh-KIIX8.d.ts → client-D8AjO8jb.d.ts} +2 -2
- package/dist/{index-Dy8D3r9b.d.mts → index-9Bl-zBAI.d.mts} +3 -3
- package/dist/{index-C4xE31-D.d.ts → index-DCPxHjbj.d.ts} +3 -3
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/mock/cli.mjs +309 -19
- package/dist/mock/library.js +223 -6
- package/dist/mock/library.mjs +216 -7
- package/dist/mock/msw.js +212 -6
- package/dist/mock/msw.mjs +212 -6
- package/dist/{payment-nH9OCUg2.d.ts → payment-BVv9leS_.d.ts} +1 -1
- package/dist/{payment-T_0MUE9o.d.mts → payment-D61iGd0o.d.mts} +1 -1
- package/dist/{price-B8WMoldA.d.ts → price-BYWCHYO5.d.ts} +3 -1
- package/dist/{price-Bg7hujK_.d.mts → price-Cthq6nPb.d.mts} +3 -1
- package/dist/{product-DXhjLQ_w.d.mts → product-2MAoE0kZ.d.mts} +26 -1
- package/dist/{product-DXhjLQ_w.d.ts → product-2MAoE0kZ.d.ts} +26 -1
- package/dist/react.d.mts +36 -5
- package/dist/react.d.ts +36 -5
- package/dist/react.js +99 -11
- package/dist/react.mjs +99 -12
- package/dist/{server-tr993CPj.d.mts → server-BjQ0xWmc.d.mts} +87 -3
- package/dist/{server-wAB-qfyZ.d.ts → server-DDaQIYLa.d.ts} +87 -3
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- 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 +21 -21
- package/dist/testing/suite.mjs +2 -2
- package/dist/testing.d.mts +11 -5
- package/dist/testing.d.ts +11 -5
- package/dist/testing.js +77 -77
- package/dist/testing.mjs +3 -3
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/package.json +1 -1
- package/registry/default-product-layout.json +1 -1
- package/registry/retail-product-card.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-2MAoE0kZ.mjs';
|
|
3
3
|
|
|
4
4
|
interface Clock {
|
|
5
5
|
now(): Date;
|
|
@@ -1096,10 +1096,94 @@ interface LinkService {
|
|
|
1096
1096
|
revokeAllSessions(customerId: string): number;
|
|
1097
1097
|
}
|
|
1098
1098
|
|
|
1099
|
+
/** A whole-registry JSON snapshot: `storeName -> id -> row`. */
|
|
1100
|
+
type RegistrySnapshot = Record<string, Record<string, unknown>>;
|
|
1101
|
+
|
|
1099
1102
|
type SeedName = "default" | "empty" | "reesa-storefront" | "restaurant" | "retail" | "services" | "grocery" | "fashion" | "pharmacy" | "auto";
|
|
1100
1103
|
|
|
1104
|
+
interface SeedBusinessInput extends Partial<Omit<MockBusiness, "id" | "name">> {
|
|
1105
|
+
name: string;
|
|
1106
|
+
}
|
|
1107
|
+
interface SeedCategoryInput {
|
|
1108
|
+
name: string;
|
|
1109
|
+
slug?: string;
|
|
1110
|
+
description?: string;
|
|
1111
|
+
image?: string;
|
|
1112
|
+
displayOrder?: number;
|
|
1113
|
+
}
|
|
1114
|
+
interface SeedCollectionInput {
|
|
1115
|
+
name: string;
|
|
1116
|
+
slug?: string;
|
|
1117
|
+
description?: string;
|
|
1118
|
+
}
|
|
1119
|
+
interface SeedProductInput {
|
|
1120
|
+
name: string;
|
|
1121
|
+
price: string;
|
|
1122
|
+
slug?: string;
|
|
1123
|
+
description?: string;
|
|
1124
|
+
productType?: string;
|
|
1125
|
+
currency?: string;
|
|
1126
|
+
image?: string;
|
|
1127
|
+
images?: string[];
|
|
1128
|
+
category?: MockCategory | string;
|
|
1129
|
+
collection?: MockCollection | string;
|
|
1130
|
+
tags?: string[];
|
|
1131
|
+
isSignature?: boolean;
|
|
1132
|
+
isNew?: boolean;
|
|
1133
|
+
ingredients?: string[];
|
|
1134
|
+
allergies?: string[];
|
|
1135
|
+
calories?: number;
|
|
1136
|
+
durationMinutes?: number;
|
|
1137
|
+
metadata?: Record<string, unknown>;
|
|
1138
|
+
}
|
|
1139
|
+
interface SeedServiceInput {
|
|
1140
|
+
name: string;
|
|
1141
|
+
price: string;
|
|
1142
|
+
durationMinutes: number;
|
|
1143
|
+
description?: string;
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Ergonomic builder over the mock state registry. Hands seed authors the same
|
|
1147
|
+
* id-minting, defaulting, and back-reference wiring the built-in seeds do by
|
|
1148
|
+
* hand, while keeping a stable surface even if the underlying store shapes
|
|
1149
|
+
* change. `registry` is the escape hatch for anything not modeled here.
|
|
1150
|
+
*/
|
|
1151
|
+
interface SeedContext {
|
|
1152
|
+
readonly registry: StateRegistry;
|
|
1153
|
+
business(input: SeedBusinessInput): MockBusiness;
|
|
1154
|
+
category(input: SeedCategoryInput): MockCategory;
|
|
1155
|
+
collection(input: SeedCollectionInput): MockCollection;
|
|
1156
|
+
product(input: SeedProductInput): MockProduct;
|
|
1157
|
+
service(input: SeedServiceInput): MockService;
|
|
1158
|
+
image(industry: string, slug: string): string;
|
|
1159
|
+
/** Apply a built-in seed first, then keep mutating from there. */
|
|
1160
|
+
extend(name: SeedName): {
|
|
1161
|
+
businessId: string;
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
type SeedFn = (ctx: SeedContext) => {
|
|
1165
|
+
businessId: string;
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Where the mock's initial state comes from. A bare string is a built-in seed
|
|
1170
|
+
* name (back-compat); the object forms open the door to user-supplied data
|
|
1171
|
+
* (`json`) and logic (`fn`).
|
|
1172
|
+
*/
|
|
1173
|
+
type SeedSource = SeedName | {
|
|
1174
|
+
kind: "builtin";
|
|
1175
|
+
name: SeedName;
|
|
1176
|
+
} | {
|
|
1177
|
+
kind: "json";
|
|
1178
|
+
data: RegistrySnapshot;
|
|
1179
|
+
businessId?: string;
|
|
1180
|
+
} | {
|
|
1181
|
+
kind: "fn";
|
|
1182
|
+
seed: SeedFn;
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1101
1185
|
interface MockOptions {
|
|
1102
|
-
seed?:
|
|
1186
|
+
seed?: SeedSource;
|
|
1103
1187
|
authMode?: "permissive" | "strict";
|
|
1104
1188
|
defaultOtp?: string;
|
|
1105
1189
|
rngSeed?: number;
|
|
@@ -1143,7 +1227,7 @@ interface Deps {
|
|
|
1143
1227
|
link: LinkService;
|
|
1144
1228
|
defaultBusinessId: string;
|
|
1145
1229
|
chaos: ChaosState;
|
|
1146
|
-
resetAll: (seed?:
|
|
1230
|
+
resetAll: (seed?: SeedSource) => string;
|
|
1147
1231
|
}
|
|
1148
1232
|
|
|
1149
1233
|
interface CreateAppOptions extends MockOptions {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
import { b1 as ProductInputField } from './product-
|
|
2
|
+
import { b1 as ProductInputField } from './product-2MAoE0kZ.js';
|
|
3
3
|
|
|
4
4
|
interface Clock {
|
|
5
5
|
now(): Date;
|
|
@@ -1096,10 +1096,94 @@ interface LinkService {
|
|
|
1096
1096
|
revokeAllSessions(customerId: string): number;
|
|
1097
1097
|
}
|
|
1098
1098
|
|
|
1099
|
+
/** A whole-registry JSON snapshot: `storeName -> id -> row`. */
|
|
1100
|
+
type RegistrySnapshot = Record<string, Record<string, unknown>>;
|
|
1101
|
+
|
|
1099
1102
|
type SeedName = "default" | "empty" | "reesa-storefront" | "restaurant" | "retail" | "services" | "grocery" | "fashion" | "pharmacy" | "auto";
|
|
1100
1103
|
|
|
1104
|
+
interface SeedBusinessInput extends Partial<Omit<MockBusiness, "id" | "name">> {
|
|
1105
|
+
name: string;
|
|
1106
|
+
}
|
|
1107
|
+
interface SeedCategoryInput {
|
|
1108
|
+
name: string;
|
|
1109
|
+
slug?: string;
|
|
1110
|
+
description?: string;
|
|
1111
|
+
image?: string;
|
|
1112
|
+
displayOrder?: number;
|
|
1113
|
+
}
|
|
1114
|
+
interface SeedCollectionInput {
|
|
1115
|
+
name: string;
|
|
1116
|
+
slug?: string;
|
|
1117
|
+
description?: string;
|
|
1118
|
+
}
|
|
1119
|
+
interface SeedProductInput {
|
|
1120
|
+
name: string;
|
|
1121
|
+
price: string;
|
|
1122
|
+
slug?: string;
|
|
1123
|
+
description?: string;
|
|
1124
|
+
productType?: string;
|
|
1125
|
+
currency?: string;
|
|
1126
|
+
image?: string;
|
|
1127
|
+
images?: string[];
|
|
1128
|
+
category?: MockCategory | string;
|
|
1129
|
+
collection?: MockCollection | string;
|
|
1130
|
+
tags?: string[];
|
|
1131
|
+
isSignature?: boolean;
|
|
1132
|
+
isNew?: boolean;
|
|
1133
|
+
ingredients?: string[];
|
|
1134
|
+
allergies?: string[];
|
|
1135
|
+
calories?: number;
|
|
1136
|
+
durationMinutes?: number;
|
|
1137
|
+
metadata?: Record<string, unknown>;
|
|
1138
|
+
}
|
|
1139
|
+
interface SeedServiceInput {
|
|
1140
|
+
name: string;
|
|
1141
|
+
price: string;
|
|
1142
|
+
durationMinutes: number;
|
|
1143
|
+
description?: string;
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Ergonomic builder over the mock state registry. Hands seed authors the same
|
|
1147
|
+
* id-minting, defaulting, and back-reference wiring the built-in seeds do by
|
|
1148
|
+
* hand, while keeping a stable surface even if the underlying store shapes
|
|
1149
|
+
* change. `registry` is the escape hatch for anything not modeled here.
|
|
1150
|
+
*/
|
|
1151
|
+
interface SeedContext {
|
|
1152
|
+
readonly registry: StateRegistry;
|
|
1153
|
+
business(input: SeedBusinessInput): MockBusiness;
|
|
1154
|
+
category(input: SeedCategoryInput): MockCategory;
|
|
1155
|
+
collection(input: SeedCollectionInput): MockCollection;
|
|
1156
|
+
product(input: SeedProductInput): MockProduct;
|
|
1157
|
+
service(input: SeedServiceInput): MockService;
|
|
1158
|
+
image(industry: string, slug: string): string;
|
|
1159
|
+
/** Apply a built-in seed first, then keep mutating from there. */
|
|
1160
|
+
extend(name: SeedName): {
|
|
1161
|
+
businessId: string;
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
type SeedFn = (ctx: SeedContext) => {
|
|
1165
|
+
businessId: string;
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Where the mock's initial state comes from. A bare string is a built-in seed
|
|
1170
|
+
* name (back-compat); the object forms open the door to user-supplied data
|
|
1171
|
+
* (`json`) and logic (`fn`).
|
|
1172
|
+
*/
|
|
1173
|
+
type SeedSource = SeedName | {
|
|
1174
|
+
kind: "builtin";
|
|
1175
|
+
name: SeedName;
|
|
1176
|
+
} | {
|
|
1177
|
+
kind: "json";
|
|
1178
|
+
data: RegistrySnapshot;
|
|
1179
|
+
businessId?: string;
|
|
1180
|
+
} | {
|
|
1181
|
+
kind: "fn";
|
|
1182
|
+
seed: SeedFn;
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1101
1185
|
interface MockOptions {
|
|
1102
|
-
seed?:
|
|
1186
|
+
seed?: SeedSource;
|
|
1103
1187
|
authMode?: "permissive" | "strict";
|
|
1104
1188
|
defaultOtp?: string;
|
|
1105
1189
|
rngSeed?: number;
|
|
@@ -1143,7 +1227,7 @@ interface Deps {
|
|
|
1143
1227
|
link: LinkService;
|
|
1144
1228
|
defaultBusinessId: string;
|
|
1145
1229
|
chaos: ChaosState;
|
|
1146
|
-
resetAll: (seed?:
|
|
1230
|
+
resetAll: (seed?: SeedSource) => string;
|
|
1147
1231
|
}
|
|
1148
1232
|
|
|
1149
1233
|
interface CreateAppOptions extends MockOptions {
|
package/dist/server.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ad as CimplifyClient } from './client-
|
|
2
|
-
export { K as CacheOptions, ct as ReadRequestOptions, cP as Result } from './client-
|
|
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-Ba4Hng9i.mjs';
|
|
2
|
+
export { K as CacheOptions, ct as ReadRequestOptions, cP as Result } from './client-Ba4Hng9i.mjs';
|
|
3
|
+
export { Q as Category, T as CimplifyError, U as Collection, aX as Product, b9 as ProductWithDetails } from './product-2MAoE0kZ.mjs';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
|
-
import './payment-
|
|
5
|
+
import './payment-D61iGd0o.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, ct as ReadRequestOptions, cP as Result } from './client-
|
|
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-CINi3Dw3.js';
|
|
2
|
+
export { K as CacheOptions, ct as ReadRequestOptions, cP as Result } from './client-CINi3Dw3.js';
|
|
3
|
+
export { Q as Category, T as CimplifyError, U as Collection, aX as Product, b9 as ProductWithDetails } from './product-2MAoE0kZ.js';
|
|
4
4
|
import { JWTVerifyResult } from 'jose';
|
|
5
|
-
import './payment-
|
|
5
|
+
import './payment-BVv9leS_.js';
|
|
6
6
|
|
|
7
7
|
interface ServerClientOptions {
|
|
8
8
|
/**
|
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-BjQ0xWmc.mjs';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../product-
|
|
3
|
+
import '../product-2MAoE0kZ.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-DDaQIYLa.js';
|
|
2
2
|
import 'hono';
|
|
3
|
-
import '../product-
|
|
3
|
+
import '../product-2MAoE0kZ.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 chunkFKBXZ2A6_js = require('../chunk-FKBXZ2A6.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 = chunkFKBXZ2A6_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-BjUJapti.mjs';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-BjQ0xWmc.mjs';
|
|
4
|
+
export { S as SeedName } from '../server-BjQ0xWmc.mjs';
|
|
5
|
+
import '../client-Ba4Hng9i.mjs';
|
|
6
|
+
import '../product-2MAoE0kZ.mjs';
|
|
7
|
+
import '../payment-D61iGd0o.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-D8AjO8jb.js';
|
|
3
|
+
import { C as CreateAppOptions } from '../server-DDaQIYLa.js';
|
|
4
|
+
export { S as SeedName } from '../server-DDaQIYLa.js';
|
|
5
|
+
import '../client-CINi3Dw3.js';
|
|
6
|
+
import '../product-2MAoE0kZ.js';
|
|
7
|
+
import '../payment-BVv9leS_.js';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|
package/dist/testing/suite.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkODEPW244_js = require('../chunk-ODEPW244.js');
|
|
4
|
+
require('../chunk-FKBXZ2A6.js');
|
|
5
5
|
require('../chunk-GFM5JW45.js');
|
|
6
6
|
require('../chunk-HPN5R3K2.js');
|
|
7
7
|
require('../chunk-7Y2O3E4D.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(() => chunkODEPW244_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(chunkODEPW244_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 = chunkODEPW244_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 = chunkODEPW244_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(() => chunkODEPW244_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 chunkODEPW244_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(() => chunkODEPW244_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 chunkODEPW244_js.fixtures.addFirstProduct(h.client);
|
|
102
|
+
await chunkODEPW244_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 chunkODEPW244_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 = chunkODEPW244_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 = chunkODEPW244_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 = chunkODEPW244_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 = chunkODEPW244_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 chunkODEPW244_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 = chunkODEPW244_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 chunkODEPW244_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: chunkODEPW244_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 = chunkODEPW244_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,5 +1,5 @@
|
|
|
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-I6RE4BKH.mjs';
|
|
2
|
+
import '../chunk-PLTP6HWW.mjs';
|
|
3
3
|
import '../chunk-NWUEWUX2.mjs';
|
|
4
4
|
import '../chunk-7BM56JET.mjs';
|
|
5
5
|
import '../chunk-TD3AY34U.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-BjUJapti.mjs';
|
|
4
|
+
import './client-Ba4Hng9i.mjs';
|
|
5
|
+
import './product-2MAoE0kZ.mjs';
|
|
6
|
+
import './payment-D61iGd0o.mjs';
|
|
7
|
+
import './server-BjQ0xWmc.mjs';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1242,6 +1242,7 @@ declare const CartSchema: z.ZodObject<{
|
|
|
1242
1242
|
status: z.ZodString;
|
|
1243
1243
|
source: z.ZodString;
|
|
1244
1244
|
channel: z.ZodString;
|
|
1245
|
+
requires_delivery: z.ZodOptional<z.ZodBoolean>;
|
|
1245
1246
|
}, z.core.$loose>;
|
|
1246
1247
|
type Cart = z.infer<typeof CartSchema>;
|
|
1247
1248
|
declare const assertCart: (value: unknown) => asserts value is {
|
|
@@ -1410,6 +1411,7 @@ declare const assertCart: (value: unknown) => asserts value is {
|
|
|
1410
1411
|
status: string;
|
|
1411
1412
|
source: string;
|
|
1412
1413
|
channel: string;
|
|
1414
|
+
requires_delivery?: boolean | undefined;
|
|
1413
1415
|
};
|
|
1414
1416
|
|
|
1415
1417
|
/**
|
|
@@ -1436,6 +1438,7 @@ declare const CheckoutBodySchema: z.ZodObject<{
|
|
|
1436
1438
|
}, z.core.$strip>;
|
|
1437
1439
|
order_type: z.ZodString;
|
|
1438
1440
|
address_info: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1441
|
+
delivery_rate_id: z.ZodOptional<z.ZodString>;
|
|
1439
1442
|
payment_method: z.ZodString;
|
|
1440
1443
|
mobile_money_details: z.ZodOptional<z.ZodObject<{
|
|
1441
1444
|
phone_number: z.ZodString;
|
|
@@ -1460,6 +1463,7 @@ declare const assertCheckoutBody: (value: unknown) => asserts value is {
|
|
|
1460
1463
|
payment_method: string;
|
|
1461
1464
|
location_id?: string | undefined;
|
|
1462
1465
|
address_info?: Record<string, unknown> | undefined;
|
|
1466
|
+
delivery_rate_id?: string | undefined;
|
|
1463
1467
|
mobile_money_details?: {
|
|
1464
1468
|
phone_number: string;
|
|
1465
1469
|
provider: string;
|
|
@@ -1957,6 +1961,7 @@ declare const PUBLIC_SCHEMAS: {
|
|
|
1957
1961
|
status: z.ZodString;
|
|
1958
1962
|
source: z.ZodString;
|
|
1959
1963
|
channel: z.ZodString;
|
|
1964
|
+
requires_delivery: z.ZodOptional<z.ZodBoolean>;
|
|
1960
1965
|
}, z.core.$loose>;
|
|
1961
1966
|
readonly CartItem: z.ZodObject<{
|
|
1962
1967
|
id: z.ZodString;
|
|
@@ -2128,6 +2133,7 @@ declare const PUBLIC_SCHEMAS: {
|
|
|
2128
2133
|
}, z.core.$strip>;
|
|
2129
2134
|
order_type: z.ZodString;
|
|
2130
2135
|
address_info: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2136
|
+
delivery_rate_id: z.ZodOptional<z.ZodString>;
|
|
2131
2137
|
payment_method: z.ZodString;
|
|
2132
2138
|
mobile_money_details: z.ZodOptional<z.ZodObject<{
|
|
2133
2139
|
phone_number: z.ZodString;
|
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-D8AjO8jb.js';
|
|
4
|
+
import './client-CINi3Dw3.js';
|
|
5
|
+
import './product-2MAoE0kZ.js';
|
|
6
|
+
import './payment-BVv9leS_.js';
|
|
7
|
+
import './server-DDaQIYLa.js';
|
|
8
8
|
import 'hono';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1242,6 +1242,7 @@ declare const CartSchema: z.ZodObject<{
|
|
|
1242
1242
|
status: z.ZodString;
|
|
1243
1243
|
source: z.ZodString;
|
|
1244
1244
|
channel: z.ZodString;
|
|
1245
|
+
requires_delivery: z.ZodOptional<z.ZodBoolean>;
|
|
1245
1246
|
}, z.core.$loose>;
|
|
1246
1247
|
type Cart = z.infer<typeof CartSchema>;
|
|
1247
1248
|
declare const assertCart: (value: unknown) => asserts value is {
|
|
@@ -1410,6 +1411,7 @@ declare const assertCart: (value: unknown) => asserts value is {
|
|
|
1410
1411
|
status: string;
|
|
1411
1412
|
source: string;
|
|
1412
1413
|
channel: string;
|
|
1414
|
+
requires_delivery?: boolean | undefined;
|
|
1413
1415
|
};
|
|
1414
1416
|
|
|
1415
1417
|
/**
|
|
@@ -1436,6 +1438,7 @@ declare const CheckoutBodySchema: z.ZodObject<{
|
|
|
1436
1438
|
}, z.core.$strip>;
|
|
1437
1439
|
order_type: z.ZodString;
|
|
1438
1440
|
address_info: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1441
|
+
delivery_rate_id: z.ZodOptional<z.ZodString>;
|
|
1439
1442
|
payment_method: z.ZodString;
|
|
1440
1443
|
mobile_money_details: z.ZodOptional<z.ZodObject<{
|
|
1441
1444
|
phone_number: z.ZodString;
|
|
@@ -1460,6 +1463,7 @@ declare const assertCheckoutBody: (value: unknown) => asserts value is {
|
|
|
1460
1463
|
payment_method: string;
|
|
1461
1464
|
location_id?: string | undefined;
|
|
1462
1465
|
address_info?: Record<string, unknown> | undefined;
|
|
1466
|
+
delivery_rate_id?: string | undefined;
|
|
1463
1467
|
mobile_money_details?: {
|
|
1464
1468
|
phone_number: string;
|
|
1465
1469
|
provider: string;
|
|
@@ -1957,6 +1961,7 @@ declare const PUBLIC_SCHEMAS: {
|
|
|
1957
1961
|
status: z.ZodString;
|
|
1958
1962
|
source: z.ZodString;
|
|
1959
1963
|
channel: z.ZodString;
|
|
1964
|
+
requires_delivery: z.ZodOptional<z.ZodBoolean>;
|
|
1960
1965
|
}, z.core.$loose>;
|
|
1961
1966
|
readonly CartItem: z.ZodObject<{
|
|
1962
1967
|
id: z.ZodString;
|
|
@@ -2128,6 +2133,7 @@ declare const PUBLIC_SCHEMAS: {
|
|
|
2128
2133
|
}, z.core.$strip>;
|
|
2129
2134
|
order_type: z.ZodString;
|
|
2130
2135
|
address_info: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2136
|
+
delivery_rate_id: z.ZodOptional<z.ZodString>;
|
|
2131
2137
|
payment_method: z.ZodString;
|
|
2132
2138
|
mobile_money_details: z.ZodOptional<z.ZodObject<{
|
|
2133
2139
|
phone_number: z.ZodString;
|