@cimplify/sdk 0.51.0 → 0.52.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 +1 -1
- package/dist/advanced.d.ts +1 -1
- package/dist/advanced.js +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-QCS6D4XW.mjs → chunk-24FK7VFL.mjs} +1 -1
- package/dist/{chunk-FJQC4VSN.js → chunk-CYGLTD7D.js} +43 -54
- package/dist/{chunk-CAG3TEXO.js → chunk-D22UVSFN.js} +2 -2
- package/dist/{chunk-VOWMB2KR.js → chunk-DR4UPU6P.js} +53 -56
- package/dist/{chunk-GUZXQSGI.mjs → chunk-MBR2DBEN.mjs} +9 -20
- package/dist/{chunk-FXACV333.mjs → chunk-OFNVLUH4.mjs} +53 -56
- package/dist/{client-CF2pmEE9.d.mts → client-C6J_RGlr.d.mts} +27 -45
- package/dist/{client-B6x53-Al.d.ts → client-CX7IFIkL.d.ts} +27 -45
- package/dist/{client-BbrCopIS.d.mts → client-DdefKjcs.d.mts} +1 -1
- package/dist/{client-BvEjhvwq.d.ts → client-Lt7uGLmT.d.ts} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +61 -61
- package/dist/index.mjs +2 -2
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +16 -16
- package/dist/react.mjs +2 -2
- package/dist/server.d.mts +10 -18
- package/dist/server.d.ts +10 -18
- package/dist/server.js +9 -103
- package/dist/server.mjs +4 -98
- package/dist/testing/suite.d.mts +2 -2
- package/dist/testing/suite.d.ts +2 -2
- package/dist/testing/suite.js +22 -22
- package/dist/testing/suite.mjs +3 -3
- package/dist/testing.d.mts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +78 -78
- package/dist/testing.mjs +4 -4
- package/package.json +1 -1
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CimplifyClient } from './client-
|
|
2
|
-
export {
|
|
1
|
+
import { C as CimplifyClient } from './client-CX7IFIkL.js';
|
|
2
|
+
export { aO as Result } from './client-CX7IFIkL.js';
|
|
3
3
|
import { IncrementalCache } from '@opennextjs/aws/types/overrides';
|
|
4
4
|
export { ap as Category, h as CimplifyError, ar as Collection, X as Product, aa as ProductWithDetails } from './product-C-xLzh7Q.js';
|
|
5
5
|
import './payment-_e99nSRj.js';
|
|
@@ -28,17 +28,9 @@ interface ServerClientOptions {
|
|
|
28
28
|
*
|
|
29
29
|
* The returned client is the exact same surface the browser uses — every
|
|
30
30
|
* resource (catalogue, cart, checkout, …) and every method works identically.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* on the underlying fetch — Next 16's documented ISR API. Invalidate via the
|
|
35
|
-
* `revalidate*` helpers (also exported from this entry) or the bare
|
|
36
|
-
* `revalidateTag` / `revalidatePath` from `next/cache`.
|
|
37
|
-
*
|
|
38
|
-
* If you have `cacheComponents: true` in `next.config.ts` (Next 16 PPR-style
|
|
39
|
-
* caching), the `'use cache'` + `cacheTag` / `cacheLife` directives work too —
|
|
40
|
-
* but they require a Node-compatible runtime and won't function on Cloudflare
|
|
41
|
-
* Workers. For Workers / WfP storefronts, stay on the ISR (`cacheOptions`) path.
|
|
31
|
+
* Caching is Next.js's responsibility: wrap your composed reads with
|
|
32
|
+
* `'use cache'` + `cacheTag` (using the tag builders from `@cimplify/sdk/server`),
|
|
33
|
+
* or set `next: { revalidate, tags }` on individual fetches.
|
|
42
34
|
*
|
|
43
35
|
* Errors continue to flow through `Result<T, CimplifyError>`. Use the SDK's
|
|
44
36
|
* `unwrap()` helper, or `if (!result.ok) notFound()` — whichever is
|
|
@@ -46,13 +38,13 @@ interface ServerClientOptions {
|
|
|
46
38
|
*
|
|
47
39
|
* @example
|
|
48
40
|
* import { getServerClient, tags } from "@cimplify/sdk/server";
|
|
49
|
-
*
|
|
50
|
-
* export const revalidate = 3600;
|
|
41
|
+
* import { cacheTag, cacheLife } from "next/cache";
|
|
51
42
|
*
|
|
52
43
|
* async function getProduct(slug: string) {
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
44
|
+
* "use cache";
|
|
45
|
+
* cacheTag(tags.product(slug));
|
|
46
|
+
* cacheLife("hours");
|
|
47
|
+
* const r = await getServerClient().catalogue.getProductBySlug(slug);
|
|
56
48
|
* if (!r.ok) throw new Error(r.error.message);
|
|
57
49
|
* return r.value;
|
|
58
50
|
* }
|
package/dist/server.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkCYGLTD7D_js = require('./chunk-CYGLTD7D.js');
|
|
4
|
+
require('./chunk-DR4UPU6P.js');
|
|
5
5
|
require('./chunk-6RP6OPYO.js');
|
|
6
6
|
var chunkTKOTACKZ_js = require('./chunk-TKOTACKZ.js');
|
|
7
7
|
var react = require('react');
|
|
8
|
-
var
|
|
8
|
+
var internal = require('@opennextjs/cloudflare/overrides/internal');
|
|
9
|
+
var cloudflareContext = require('@opennextjs/cloudflare/cloudflare-context');
|
|
9
10
|
|
|
10
11
|
var DEFAULT_PROD_URL = "https://storefronts.cimplify.io";
|
|
11
12
|
var DEFAULT_DEV_URL = "http://127.0.0.1:8787";
|
|
@@ -25,7 +26,7 @@ function readEnv(...keys) {
|
|
|
25
26
|
var getServerClient = react.cache((opts = {}) => {
|
|
26
27
|
const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? defaultBaseUrl();
|
|
27
28
|
const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
|
|
28
|
-
const client =
|
|
29
|
+
const client = chunkCYGLTD7D_js.createCimplifyClient({
|
|
29
30
|
baseUrl,
|
|
30
31
|
publicKey,
|
|
31
32
|
suppressPublicKeyWarning: true
|
|
@@ -67,107 +68,12 @@ var tags = {
|
|
|
67
68
|
// src/server/cache-life.ts
|
|
68
69
|
var CACHE_LIFE_DEFAULT = "max";
|
|
69
70
|
var CACHE_LIFE_PROBE = "seconds";
|
|
70
|
-
|
|
71
|
-
// ../node_modules/.bun/@opennextjs+cloudflare@1.19.11+2f5a8389dca7b522/node_modules/@opennextjs/cloudflare/dist/api/cloudflare-context.js
|
|
72
|
-
var cloudflareContextSymbol = /* @__PURE__ */ Symbol.for("__cloudflare-context__");
|
|
73
|
-
function getCloudflareContext(options = { async: false }) {
|
|
74
|
-
return options.async ? getCloudflareContextAsync() : getCloudflareContextSync();
|
|
75
|
-
}
|
|
76
|
-
function getCloudflareContextFromGlobalScope() {
|
|
77
|
-
const global = globalThis;
|
|
78
|
-
return global[cloudflareContextSymbol];
|
|
79
|
-
}
|
|
80
|
-
function inSSG() {
|
|
81
|
-
const global = globalThis;
|
|
82
|
-
return global.__NEXT_DATA__?.nextExport === true;
|
|
83
|
-
}
|
|
84
|
-
function getCloudflareContextSync() {
|
|
85
|
-
const cloudflareContext = getCloudflareContextFromGlobalScope();
|
|
86
|
-
if (cloudflareContext) {
|
|
87
|
-
return cloudflareContext;
|
|
88
|
-
}
|
|
89
|
-
if (inSSG()) {
|
|
90
|
-
throw new Error(`
|
|
91
|
-
|
|
92
|
-
ERROR: \`getCloudflareContext\` has been called in sync mode in either a static route or at the top level of a non-static one, both cases are not allowed but can be solved by either:
|
|
93
|
-
- make sure that the call is not at the top level and that the route is not static
|
|
94
|
-
- call \`getCloudflareContext({async: true})\` to use the \`async\` mode
|
|
95
|
-
- avoid calling \`getCloudflareContext\` in the route
|
|
96
|
-
`);
|
|
97
|
-
}
|
|
98
|
-
throw new Error(initOpenNextCloudflareForDevErrorMsg);
|
|
99
|
-
}
|
|
100
|
-
async function getCloudflareContextAsync() {
|
|
101
|
-
const cloudflareContext = getCloudflareContextFromGlobalScope();
|
|
102
|
-
if (cloudflareContext) {
|
|
103
|
-
return cloudflareContext;
|
|
104
|
-
}
|
|
105
|
-
const inNodejsRuntime = process.env.NEXT_RUNTIME === "nodejs";
|
|
106
|
-
if (inNodejsRuntime || inSSG()) {
|
|
107
|
-
const cloudflareContext2 = await getCloudflareContextFromWrangler();
|
|
108
|
-
addCloudflareContextToNodejsGlobal(cloudflareContext2);
|
|
109
|
-
return cloudflareContext2;
|
|
110
|
-
}
|
|
111
|
-
throw new Error(initOpenNextCloudflareForDevErrorMsg);
|
|
112
|
-
}
|
|
113
|
-
function addCloudflareContextToNodejsGlobal(cloudflareContext) {
|
|
114
|
-
const global = globalThis;
|
|
115
|
-
global[cloudflareContextSymbol] = cloudflareContext;
|
|
116
|
-
}
|
|
117
|
-
async function getCloudflareContextFromWrangler(options) {
|
|
118
|
-
const { getPlatformProxy } = await import(
|
|
119
|
-
/* webpackIgnore: true */
|
|
120
|
-
`${"__wrangler".replaceAll("_", "")}`
|
|
121
|
-
);
|
|
122
|
-
const environment = process.env.NEXT_DEV_WRANGLER_ENV;
|
|
123
|
-
const { env, cf, ctx } = await getPlatformProxy({
|
|
124
|
-
...options,
|
|
125
|
-
// The `env` passed to the fetch handler does not contain variables from `.env*` files.
|
|
126
|
-
// because we invoke wrangler with `CLOUDFLARE_LOAD_DEV_VARS_FROM_DOT_ENV`=`"false"`.
|
|
127
|
-
// Initializing `envFiles` with an empty list is the equivalent for this API call.
|
|
128
|
-
envFiles: [],
|
|
129
|
-
environment
|
|
130
|
-
});
|
|
131
|
-
return {
|
|
132
|
-
env,
|
|
133
|
-
cf,
|
|
134
|
-
ctx
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
var initOpenNextCloudflareForDevErrorMsg = `
|
|
138
|
-
|
|
139
|
-
ERROR: \`getCloudflareContext\` has been called without having called \`initOpenNextCloudflareForDev\` from the Next.js config file.
|
|
140
|
-
You should update your Next.js config file as shown below:
|
|
141
|
-
|
|
142
|
-
\`\`\`
|
|
143
|
-
// next.config.mjs
|
|
144
|
-
|
|
145
|
-
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
|
|
146
|
-
|
|
147
|
-
initOpenNextCloudflareForDev();
|
|
148
|
-
|
|
149
|
-
const nextConfig = { ... };
|
|
150
|
-
export default nextConfig;
|
|
151
|
-
\`\`\`
|
|
152
|
-
|
|
153
|
-
`;
|
|
154
|
-
|
|
155
|
-
// ../node_modules/.bun/@opennextjs+cloudflare@1.19.11+2f5a8389dca7b522/node_modules/@opennextjs/cloudflare/dist/api/overrides/internal.js
|
|
156
|
-
var FALLBACK_BUILD_ID = "no-build-id";
|
|
157
|
-
var DEFAULT_PREFIX = "incremental-cache";
|
|
158
|
-
function computeCacheKey(key, options) {
|
|
159
|
-
const { cacheType = "cache", prefix = DEFAULT_PREFIX, buildId = FALLBACK_BUILD_ID } = options;
|
|
160
|
-
const hash = crypto$1.createHash("sha256").update(key).digest("hex");
|
|
161
|
-
return `${prefix}/${buildId}/${hash}.${cacheType}`.replace(/\/+/g, "/");
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// src/server/overrides/evict-incremental-cache.ts
|
|
165
71
|
var R2_BUCKET_BINDING = "NEXT_INC_CACHE_R2_BUCKET";
|
|
166
72
|
var R2_PREFIX_ENV = "NEXT_INC_CACHE_R2_PREFIX";
|
|
167
73
|
var PATH_INDEX_BINDING = "CIMPLIFY_PATH_INDEX";
|
|
168
74
|
var CIMPLIFY_TAG_PREFIX = "cimplify:";
|
|
169
75
|
function r2Key(env, key, cacheType) {
|
|
170
|
-
return computeCacheKey(key, {
|
|
76
|
+
return internal.computeCacheKey(key, {
|
|
171
77
|
prefix: env[R2_PREFIX_ENV],
|
|
172
78
|
buildId: globalThis.process?.env?.OPEN_NEXT_BUILD_ID,
|
|
173
79
|
cacheType
|
|
@@ -185,7 +91,7 @@ function pathIndexFor(env) {
|
|
|
185
91
|
var evictIncrementalCache = {
|
|
186
92
|
name: "cimplify-evict-r2-cache",
|
|
187
93
|
async get(key, cacheType) {
|
|
188
|
-
const env = getCloudflareContext().env;
|
|
94
|
+
const env = cloudflareContext.getCloudflareContext().env;
|
|
189
95
|
const r2 = env[R2_BUCKET_BINDING];
|
|
190
96
|
if (!r2) return null;
|
|
191
97
|
try {
|
|
@@ -200,7 +106,7 @@ var evictIncrementalCache = {
|
|
|
200
106
|
}
|
|
201
107
|
},
|
|
202
108
|
async set(key, value, cacheType) {
|
|
203
|
-
const env = getCloudflareContext().env;
|
|
109
|
+
const env = cloudflareContext.getCloudflareContext().env;
|
|
204
110
|
const r2 = env[R2_BUCKET_BINDING];
|
|
205
111
|
if (!r2) return;
|
|
206
112
|
const k = r2Key(env, key, cacheType);
|
|
@@ -219,7 +125,7 @@ var evictIncrementalCache = {
|
|
|
219
125
|
}
|
|
220
126
|
},
|
|
221
127
|
async delete(key) {
|
|
222
|
-
const env = getCloudflareContext().env;
|
|
128
|
+
const env = cloudflareContext.getCloudflareContext().env;
|
|
223
129
|
const r2 = env[R2_BUCKET_BINDING];
|
|
224
130
|
if (!r2) return;
|
|
225
131
|
try {
|
package/dist/server.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { createCimplifyClient } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
import { createCimplifyClient } from './chunk-MBR2DBEN.mjs';
|
|
2
|
+
import './chunk-OFNVLUH4.mjs';
|
|
3
3
|
import './chunk-XY2DFX5K.mjs';
|
|
4
4
|
export { CimplifyError } from './chunk-Z2AYLZDF.mjs';
|
|
5
5
|
import { cache } from 'react';
|
|
6
|
-
import {
|
|
6
|
+
import { computeCacheKey } from '@opennextjs/cloudflare/overrides/internal';
|
|
7
|
+
import { getCloudflareContext } from '@opennextjs/cloudflare/cloudflare-context';
|
|
7
8
|
|
|
8
9
|
var DEFAULT_PROD_URL = "https://storefronts.cimplify.io";
|
|
9
10
|
var DEFAULT_DEV_URL = "http://127.0.0.1:8787";
|
|
@@ -65,101 +66,6 @@ var tags = {
|
|
|
65
66
|
// src/server/cache-life.ts
|
|
66
67
|
var CACHE_LIFE_DEFAULT = "max";
|
|
67
68
|
var CACHE_LIFE_PROBE = "seconds";
|
|
68
|
-
|
|
69
|
-
// ../node_modules/.bun/@opennextjs+cloudflare@1.19.11+2f5a8389dca7b522/node_modules/@opennextjs/cloudflare/dist/api/cloudflare-context.js
|
|
70
|
-
var cloudflareContextSymbol = /* @__PURE__ */ Symbol.for("__cloudflare-context__");
|
|
71
|
-
function getCloudflareContext(options = { async: false }) {
|
|
72
|
-
return options.async ? getCloudflareContextAsync() : getCloudflareContextSync();
|
|
73
|
-
}
|
|
74
|
-
function getCloudflareContextFromGlobalScope() {
|
|
75
|
-
const global = globalThis;
|
|
76
|
-
return global[cloudflareContextSymbol];
|
|
77
|
-
}
|
|
78
|
-
function inSSG() {
|
|
79
|
-
const global = globalThis;
|
|
80
|
-
return global.__NEXT_DATA__?.nextExport === true;
|
|
81
|
-
}
|
|
82
|
-
function getCloudflareContextSync() {
|
|
83
|
-
const cloudflareContext = getCloudflareContextFromGlobalScope();
|
|
84
|
-
if (cloudflareContext) {
|
|
85
|
-
return cloudflareContext;
|
|
86
|
-
}
|
|
87
|
-
if (inSSG()) {
|
|
88
|
-
throw new Error(`
|
|
89
|
-
|
|
90
|
-
ERROR: \`getCloudflareContext\` has been called in sync mode in either a static route or at the top level of a non-static one, both cases are not allowed but can be solved by either:
|
|
91
|
-
- make sure that the call is not at the top level and that the route is not static
|
|
92
|
-
- call \`getCloudflareContext({async: true})\` to use the \`async\` mode
|
|
93
|
-
- avoid calling \`getCloudflareContext\` in the route
|
|
94
|
-
`);
|
|
95
|
-
}
|
|
96
|
-
throw new Error(initOpenNextCloudflareForDevErrorMsg);
|
|
97
|
-
}
|
|
98
|
-
async function getCloudflareContextAsync() {
|
|
99
|
-
const cloudflareContext = getCloudflareContextFromGlobalScope();
|
|
100
|
-
if (cloudflareContext) {
|
|
101
|
-
return cloudflareContext;
|
|
102
|
-
}
|
|
103
|
-
const inNodejsRuntime = process.env.NEXT_RUNTIME === "nodejs";
|
|
104
|
-
if (inNodejsRuntime || inSSG()) {
|
|
105
|
-
const cloudflareContext2 = await getCloudflareContextFromWrangler();
|
|
106
|
-
addCloudflareContextToNodejsGlobal(cloudflareContext2);
|
|
107
|
-
return cloudflareContext2;
|
|
108
|
-
}
|
|
109
|
-
throw new Error(initOpenNextCloudflareForDevErrorMsg);
|
|
110
|
-
}
|
|
111
|
-
function addCloudflareContextToNodejsGlobal(cloudflareContext) {
|
|
112
|
-
const global = globalThis;
|
|
113
|
-
global[cloudflareContextSymbol] = cloudflareContext;
|
|
114
|
-
}
|
|
115
|
-
async function getCloudflareContextFromWrangler(options) {
|
|
116
|
-
const { getPlatformProxy } = await import(
|
|
117
|
-
/* webpackIgnore: true */
|
|
118
|
-
`${"__wrangler".replaceAll("_", "")}`
|
|
119
|
-
);
|
|
120
|
-
const environment = process.env.NEXT_DEV_WRANGLER_ENV;
|
|
121
|
-
const { env, cf, ctx } = await getPlatformProxy({
|
|
122
|
-
...options,
|
|
123
|
-
// The `env` passed to the fetch handler does not contain variables from `.env*` files.
|
|
124
|
-
// because we invoke wrangler with `CLOUDFLARE_LOAD_DEV_VARS_FROM_DOT_ENV`=`"false"`.
|
|
125
|
-
// Initializing `envFiles` with an empty list is the equivalent for this API call.
|
|
126
|
-
envFiles: [],
|
|
127
|
-
environment
|
|
128
|
-
});
|
|
129
|
-
return {
|
|
130
|
-
env,
|
|
131
|
-
cf,
|
|
132
|
-
ctx
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
var initOpenNextCloudflareForDevErrorMsg = `
|
|
136
|
-
|
|
137
|
-
ERROR: \`getCloudflareContext\` has been called without having called \`initOpenNextCloudflareForDev\` from the Next.js config file.
|
|
138
|
-
You should update your Next.js config file as shown below:
|
|
139
|
-
|
|
140
|
-
\`\`\`
|
|
141
|
-
// next.config.mjs
|
|
142
|
-
|
|
143
|
-
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
|
|
144
|
-
|
|
145
|
-
initOpenNextCloudflareForDev();
|
|
146
|
-
|
|
147
|
-
const nextConfig = { ... };
|
|
148
|
-
export default nextConfig;
|
|
149
|
-
\`\`\`
|
|
150
|
-
|
|
151
|
-
`;
|
|
152
|
-
|
|
153
|
-
// ../node_modules/.bun/@opennextjs+cloudflare@1.19.11+2f5a8389dca7b522/node_modules/@opennextjs/cloudflare/dist/api/overrides/internal.js
|
|
154
|
-
var FALLBACK_BUILD_ID = "no-build-id";
|
|
155
|
-
var DEFAULT_PREFIX = "incremental-cache";
|
|
156
|
-
function computeCacheKey(key, options) {
|
|
157
|
-
const { cacheType = "cache", prefix = DEFAULT_PREFIX, buildId = FALLBACK_BUILD_ID } = options;
|
|
158
|
-
const hash = createHash("sha256").update(key).digest("hex");
|
|
159
|
-
return `${prefix}/${buildId}/${hash}.${cacheType}`.replace(/\/+/g, "/");
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// src/server/overrides/evict-incremental-cache.ts
|
|
163
69
|
var R2_BUCKET_BINDING = "NEXT_INC_CACHE_R2_BUCKET";
|
|
164
70
|
var R2_PREFIX_ENV = "NEXT_INC_CACHE_R2_PREFIX";
|
|
165
71
|
var PATH_INDEX_BINDING = "CIMPLIFY_PATH_INDEX";
|
package/dist/testing/suite.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TestAPI } from 'vitest';
|
|
2
|
-
import { T as TestClientHandle } from '../client-
|
|
2
|
+
import { T as TestClientHandle } from '../client-DdefKjcs.mjs';
|
|
3
3
|
import { C as CreateAppOptions } from '../server-BgccqOLT.mjs';
|
|
4
4
|
export { S as SeedName } from '../server-BgccqOLT.mjs';
|
|
5
|
-
import '../client-
|
|
5
|
+
import '../client-C6J_RGlr.mjs';
|
|
6
6
|
import '../product-C-xLzh7Q.mjs';
|
|
7
7
|
import '../payment-9L_-GWqQ.mjs';
|
|
8
8
|
import 'hono';
|
package/dist/testing/suite.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TestAPI } from 'vitest';
|
|
2
|
-
import { T as TestClientHandle } from '../client-
|
|
2
|
+
import { T as TestClientHandle } from '../client-Lt7uGLmT.js';
|
|
3
3
|
import { C as CreateAppOptions } from '../server-72rzvJ4Y.js';
|
|
4
4
|
export { S as SeedName } from '../server-72rzvJ4Y.js';
|
|
5
|
-
import '../client-
|
|
5
|
+
import '../client-CX7IFIkL.js';
|
|
6
6
|
import '../product-C-xLzh7Q.js';
|
|
7
7
|
import '../payment-_e99nSRj.js';
|
|
8
8
|
import 'hono';
|
package/dist/testing/suite.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
3
|
+
var chunkD22UVSFN_js = require('../chunk-D22UVSFN.js');
|
|
4
|
+
require('../chunk-CYGLTD7D.js');
|
|
5
|
+
require('../chunk-DR4UPU6P.js');
|
|
6
6
|
require('../chunk-6RP6OPYO.js');
|
|
7
7
|
require('../chunk-GEWFWQYK.js');
|
|
8
8
|
require('../chunk-TKOTACKZ.js');
|
|
@@ -19,11 +19,11 @@ var PLACEHOLDER_PHRASES = [
|
|
|
19
19
|
function createBrandSuite(opts) {
|
|
20
20
|
vitest.describe(opts.label ?? "brand schema", () => {
|
|
21
21
|
vitest.it("conforms to the Cimplify brand contract", () => {
|
|
22
|
-
vitest.expect(() =>
|
|
22
|
+
vitest.expect(() => chunkD22UVSFN_js.assertBrand(opts.brand)).not.toThrow();
|
|
23
23
|
});
|
|
24
24
|
vitest.it("declares a known mock seed", () => {
|
|
25
25
|
const b = opts.brand;
|
|
26
|
-
vitest.expect(
|
|
26
|
+
vitest.expect(chunkD22UVSFN_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
|
|
27
27
|
});
|
|
28
28
|
vitest.it("has no placeholder copy left in", () => {
|
|
29
29
|
const offenders = [];
|
|
@@ -55,7 +55,7 @@ ${msg}`);
|
|
|
55
55
|
vitest.expect(b.mock?.businessId).toMatch(/^bus_/);
|
|
56
56
|
});
|
|
57
57
|
vitest.it("zod-parses cleanly", () => {
|
|
58
|
-
const result =
|
|
58
|
+
const result = chunkD22UVSFN_js.BrandSchema.safeParse(opts.brand);
|
|
59
59
|
if (!result.success) {
|
|
60
60
|
throw new Error(
|
|
61
61
|
"Brand schema violations:\n" + result.error.issues.map((i) => ` \u2022 brand.${i.path.join(".")}: ${i.message}`).join("\n")
|
|
@@ -70,23 +70,23 @@ function createCartFlowSuite(opts = {}) {
|
|
|
70
70
|
vitest.describe(opts.label ?? "cart flow against in-process mock", () => {
|
|
71
71
|
let h;
|
|
72
72
|
vitest.beforeEach(() => {
|
|
73
|
-
h =
|
|
73
|
+
h = chunkD22UVSFN_js.createTestClient(opts);
|
|
74
74
|
});
|
|
75
75
|
vitest.afterEach(() => h.dispose());
|
|
76
76
|
vitest.it("starts with an empty cart matching the canonical shape", async () => {
|
|
77
77
|
const res = await h.client.cart.get();
|
|
78
78
|
vitest.expect(res.ok).toBe(true);
|
|
79
79
|
if (!res.ok) return;
|
|
80
|
-
vitest.expect(() =>
|
|
80
|
+
vitest.expect(() => chunkD22UVSFN_js.assertCart(res.value)).not.toThrow();
|
|
81
81
|
vitest.expect(res.value.items).toHaveLength(0);
|
|
82
82
|
});
|
|
83
83
|
vitest.it("adds the first product, persists it, and returns a shape-valid cart", async () => {
|
|
84
|
-
const { product, variantId } = await
|
|
84
|
+
const { product, variantId } = await chunkD22UVSFN_js.fixtures.addFirstProduct(h.client);
|
|
85
85
|
vitest.expect(product.id).toBeTruthy();
|
|
86
86
|
const get = await h.client.cart.get();
|
|
87
87
|
vitest.expect(get.ok).toBe(true);
|
|
88
88
|
if (!get.ok) return;
|
|
89
|
-
vitest.expect(() =>
|
|
89
|
+
vitest.expect(() => chunkD22UVSFN_js.assertCart(get.value)).not.toThrow();
|
|
90
90
|
vitest.expect(get.value.items).toHaveLength(1);
|
|
91
91
|
vitest.expect(get.value.items[0]?.item_id).toBe(product.id);
|
|
92
92
|
if (variantId) {
|
|
@@ -97,8 +97,8 @@ function createCartFlowSuite(opts = {}) {
|
|
|
97
97
|
vitest.expect(parseFloat(String(get.value.pricing.subtotal))).toBeGreaterThan(0);
|
|
98
98
|
});
|
|
99
99
|
vitest.it("dedupes by line_key when adding the same product twice", async () => {
|
|
100
|
-
await
|
|
101
|
-
await
|
|
100
|
+
await chunkD22UVSFN_js.fixtures.addFirstProduct(h.client);
|
|
101
|
+
await chunkD22UVSFN_js.fixtures.addFirstProduct(h.client);
|
|
102
102
|
const res = await h.client.cart.get();
|
|
103
103
|
vitest.expect(res.ok).toBe(true);
|
|
104
104
|
if (!res.ok) return;
|
|
@@ -106,7 +106,7 @@ function createCartFlowSuite(opts = {}) {
|
|
|
106
106
|
vitest.expect(res.value.items[0]?.quantity).toBe(2);
|
|
107
107
|
});
|
|
108
108
|
vitest.it("removes items and zeroes the subtotal", async () => {
|
|
109
|
-
await
|
|
109
|
+
await chunkD22UVSFN_js.fixtures.addFirstProduct(h.client);
|
|
110
110
|
const before = await h.client.cart.get();
|
|
111
111
|
if (!before.ok) throw before.error;
|
|
112
112
|
const itemId = before.value.items[0]?.id;
|
|
@@ -132,28 +132,28 @@ function createContractSuite(opts = {}) {
|
|
|
132
132
|
vitest.describe(opts.label ?? "SDK \u2194 mock contract", () => {
|
|
133
133
|
let h;
|
|
134
134
|
vitest.beforeEach(() => {
|
|
135
|
-
h =
|
|
135
|
+
h = chunkD22UVSFN_js.createTestClient(opts);
|
|
136
136
|
});
|
|
137
137
|
vitest.afterEach(() => h.dispose());
|
|
138
138
|
vitest.it("AddItemPayload schema accepts a minimal valid body", () => {
|
|
139
|
-
const result =
|
|
139
|
+
const result = chunkD22UVSFN_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
|
|
140
140
|
vitest.expect(result.success).toBe(true);
|
|
141
141
|
});
|
|
142
142
|
vitest.it("AddItemPayload schema rejects negative quantity", () => {
|
|
143
|
-
const result =
|
|
143
|
+
const result = chunkD22UVSFN_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
|
|
144
144
|
vitest.expect(result.success).toBe(false);
|
|
145
145
|
});
|
|
146
146
|
vitest.it("AddItemPayload schema rejects empty item_id", () => {
|
|
147
|
-
const result =
|
|
147
|
+
const result = chunkD22UVSFN_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
|
|
148
148
|
vitest.expect(result.success).toBe(false);
|
|
149
149
|
});
|
|
150
150
|
vitest.it("Cart line items returned by the mock match CartItemSchema", async () => {
|
|
151
|
-
const { product } = await
|
|
151
|
+
const { product } = await chunkD22UVSFN_js.fixtures.addFirstProduct(h.client);
|
|
152
152
|
const get = await h.client.cart.get();
|
|
153
153
|
if (!get.ok) throw get.error;
|
|
154
154
|
vitest.expect(get.value.items.length).toBeGreaterThan(0);
|
|
155
155
|
for (const item of get.value.items) {
|
|
156
|
-
const result =
|
|
156
|
+
const result = chunkD22UVSFN_js.CartItemSchema.safeParse(item);
|
|
157
157
|
if (!result.success) {
|
|
158
158
|
const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
159
159
|
throw new Error(`Cart item shape mismatch for ${product.name}:
|
|
@@ -163,19 +163,19 @@ ${issues}`);
|
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
165
|
vitest.it("CheckoutResponse from the mock includes bill_token", async () => {
|
|
166
|
-
await
|
|
166
|
+
await chunkD22UVSFN_js.fixtures.addFirstProduct(h.client);
|
|
167
167
|
const cartRes = await h.client.cart.get();
|
|
168
168
|
if (!cartRes.ok) throw cartRes.error;
|
|
169
169
|
const checkout = await h.client.checkout.process({
|
|
170
170
|
cart_id: cartRes.value.id,
|
|
171
|
-
customer:
|
|
171
|
+
customer: chunkD22UVSFN_js.fixtures.customer(),
|
|
172
172
|
order_type: "delivery",
|
|
173
173
|
payment_method: "mobile_money",
|
|
174
174
|
mobile_money_details: { phone_number: "+233244000000", provider: "mtn" }
|
|
175
175
|
});
|
|
176
176
|
vitest.expect(checkout.ok).toBe(true);
|
|
177
177
|
if (!checkout.ok) return;
|
|
178
|
-
const result =
|
|
178
|
+
const result = chunkD22UVSFN_js.CheckoutResponseSchema.safeParse(checkout.value);
|
|
179
179
|
if (!result.success) {
|
|
180
180
|
const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
181
181
|
throw new Error(`CheckoutResponse shape mismatch:
|
package/dist/testing/suite.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-24FK7VFL.mjs';
|
|
2
|
+
import '../chunk-MBR2DBEN.mjs';
|
|
3
|
+
import '../chunk-OFNVLUH4.mjs';
|
|
4
4
|
import '../chunk-XY2DFX5K.mjs';
|
|
5
5
|
import '../chunk-632JEJUS.mjs';
|
|
6
6
|
import '../chunk-Z2AYLZDF.mjs';
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
3
|
+
export { A as AddFirstProductOptions, a as AddFirstProductResult, P as ProductSummary, T as TestClientHandle, c as createTestClient, f as fixtures } from './client-DdefKjcs.mjs';
|
|
4
|
+
import './client-C6J_RGlr.mjs';
|
|
5
5
|
import './product-C-xLzh7Q.mjs';
|
|
6
6
|
import './payment-9L_-GWqQ.mjs';
|
|
7
7
|
import './server-BgccqOLT.mjs';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
3
|
+
export { A as AddFirstProductOptions, a as AddFirstProductResult, P as ProductSummary, T as TestClientHandle, c as createTestClient, f as fixtures } from './client-Lt7uGLmT.js';
|
|
4
|
+
import './client-CX7IFIkL.js';
|
|
5
5
|
import './product-C-xLzh7Q.js';
|
|
6
6
|
import './payment-_e99nSRj.js';
|
|
7
7
|
import './server-72rzvJ4Y.js';
|