@apifn/core 0.0.4 → 0.1.2

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.
@@ -0,0 +1,18 @@
1
+ import type { BaseAdapter, TestCase, RunOptions, TestResult } from '@testfn/core' with { 'resolution-mode': 'import' };
2
+
3
+ interface ApifnTestAdapterOptions {
4
+ /** Execute scripts from trusted collections. Defaults to false. */
5
+ allowScripts?: boolean;
6
+ /** Explicit values for collection templates that use {{process.env.NAME}}. */
7
+ processEnv?: NodeJS.ProcessEnv;
8
+ }
9
+ declare class ApifnTestAdapter extends BaseAdapter {
10
+ private readonly collectionOptions;
11
+ name: string;
12
+ constructor(collectionOptions?: ApifnTestAdapterOptions);
13
+ supports(framework: string): boolean;
14
+ discover(patterns: string[]): Promise<TestCase[]>;
15
+ run(tests: TestCase[], options: RunOptions): Promise<TestResult[]>;
16
+ }
17
+
18
+ export { ApifnTestAdapter, type ApifnTestAdapterOptions };
@@ -0,0 +1,18 @@
1
+ import { BaseAdapter, TestCase, RunOptions, TestResult } from '@testfn/core';
2
+
3
+ interface ApifnTestAdapterOptions {
4
+ /** Execute scripts from trusted collections. Defaults to false. */
5
+ allowScripts?: boolean;
6
+ /** Explicit values for collection templates that use {{process.env.NAME}}. */
7
+ processEnv?: NodeJS.ProcessEnv;
8
+ }
9
+ declare class ApifnTestAdapter extends BaseAdapter {
10
+ private readonly collectionOptions;
11
+ name: string;
12
+ constructor(collectionOptions?: ApifnTestAdapterOptions);
13
+ supports(framework: string): boolean;
14
+ discover(patterns: string[]): Promise<TestCase[]>;
15
+ run(tests: TestCase[], options: RunOptions): Promise<TestResult[]>;
16
+ }
17
+
18
+ export { ApifnTestAdapter, type ApifnTestAdapterOptions };
package/dist/testfn.js ADDED
@@ -0,0 +1,229 @@
1
+ import "./chunk-VUNV25KB.js";
2
+
3
+ // src/integrations/testfn.ts
4
+ import * as path from "path";
5
+ import * as fs from "fs";
6
+ import { BaseAdapter } from "@testfn/core";
7
+ var REQUEST_ID_PREFIX = "apifn:";
8
+ function requestId(directory, requestPath) {
9
+ return REQUEST_ID_PREFIX + JSON.stringify([directory, requestPath]);
10
+ }
11
+ function isRequestPathId(id) {
12
+ if (!id.startsWith(REQUEST_ID_PREFIX)) return false;
13
+ try {
14
+ const parts = JSON.parse(id.slice(REQUEST_ID_PREFIX.length));
15
+ return Array.isArray(parts) && parts.length === 2 && parts.every((part) => typeof part === "string");
16
+ } catch {
17
+ return false;
18
+ }
19
+ }
20
+ function visitRequests(collection, visit) {
21
+ function walk(items, suitePath) {
22
+ for (const item of items) {
23
+ if (item.kind === "request") {
24
+ visit(item, suitePath.length ? suitePath.join(" > ") : collection.info.name);
25
+ } else if (item.kind === "folder" && item.children) {
26
+ walk(item.children, [...suitePath, item.name]);
27
+ }
28
+ }
29
+ }
30
+ walk(collection.items, []);
31
+ }
32
+ var ApifnTestAdapter = class extends BaseAdapter {
33
+ constructor(collectionOptions = {}) {
34
+ super();
35
+ this.collectionOptions = collectionOptions;
36
+ }
37
+ collectionOptions;
38
+ name = "apifn";
39
+ supports(framework) {
40
+ return framework.toLowerCase() === "apifn";
41
+ }
42
+ async discover(patterns) {
43
+ let glob;
44
+ try {
45
+ const fg = await import("./out-X7U3YPXW.js");
46
+ glob = fg.default ?? fg;
47
+ } catch {
48
+ console.warn("[apifn/testfn] fast-glob not found, using basic fs discovery");
49
+ }
50
+ const { readCollection } = await import("@apifn/collections");
51
+ const testCases = [];
52
+ const discoveredDirs = /* @__PURE__ */ new Set();
53
+ for (const pattern of patterns) {
54
+ if (glob) {
55
+ const files = await glob(
56
+ pattern.endsWith(".yml") || pattern.endsWith(".yaml") ? pattern : `${pattern}/**/opencollection.yml`,
57
+ { absolute: true }
58
+ );
59
+ for (const f of files) {
60
+ discoveredDirs.add(path.dirname(f));
61
+ }
62
+ } else {
63
+ try {
64
+ if (fs.existsSync(pattern)) {
65
+ const stat = fs.statSync(pattern);
66
+ if (stat.isDirectory()) {
67
+ if (fs.existsSync(path.join(pattern, "opencollection.yml"))) {
68
+ discoveredDirs.add(pattern);
69
+ }
70
+ } else if (pattern.endsWith("opencollection.yml")) {
71
+ discoveredDirs.add(path.dirname(pattern));
72
+ }
73
+ }
74
+ } catch {
75
+ }
76
+ }
77
+ }
78
+ for (const dir of discoveredDirs) {
79
+ try {
80
+ const collection = await readCollection(dir);
81
+ visitRequests(collection, (item, suite) => {
82
+ testCases.push({
83
+ id: requestId(dir, item.path),
84
+ file: dir,
85
+ name: item.name,
86
+ suite,
87
+ tags: ["api"]
88
+ });
89
+ });
90
+ } catch (err) {
91
+ console.warn(`[apifn/testfn] Failed to read collection at ${dir}:`, err);
92
+ }
93
+ }
94
+ return testCases;
95
+ }
96
+ async run(tests, options) {
97
+ const { runCollection, readCollection, COLLECTION_RUNNER_TRUST_OPTIONS } = await import("@apifn/collections");
98
+ if (COLLECTION_RUNNER_TRUST_OPTIONS !== true) {
99
+ throw new Error("The ApiFn TestFn adapter requires @apifn/collections 0.0.5 or later.");
100
+ }
101
+ const results = [];
102
+ const collectionsToRun = /* @__PURE__ */ new Map();
103
+ for (const t of tests) {
104
+ const list = collectionsToRun.get(t.file) || [];
105
+ list.push(t);
106
+ collectionsToRun.set(t.file, list);
107
+ }
108
+ let completedCount = 0;
109
+ const updateProgress = (tc) => {
110
+ completedCount++;
111
+ options.onProgress?.({
112
+ completed: completedCount,
113
+ total: tests.length,
114
+ current: tc
115
+ });
116
+ };
117
+ for (const [dir, testsInCollection] of collectionsToRun.entries()) {
118
+ const completedCases = /* @__PURE__ */ new Set();
119
+ try {
120
+ const collection = await readCollection(dir);
121
+ const requestsByName = /* @__PURE__ */ new Map();
122
+ const pathsById = /* @__PURE__ */ new Map();
123
+ const casesByPath = /* @__PURE__ */ new Map();
124
+ visitRequests(collection, (item, suite) => {
125
+ const matches = requestsByName.get(item.name) ?? [];
126
+ matches.push({ path: item.path, suite });
127
+ requestsByName.set(item.name, matches);
128
+ pathsById.set(requestId(dir, item.path), item.path);
129
+ });
130
+ for (const test of testsInCollection) {
131
+ const matches = isRequestPathId(test.id) ? [] : requestsByName.get(test.name)?.filter((request) => !test.suite || test.suite === request.suite) ?? [];
132
+ const selectedPath = pathsById.get(test.id) ?? (matches.length === 1 ? matches[0].path : void 0);
133
+ if (selectedPath !== void 0) {
134
+ const known = casesByPath.get(selectedPath) ?? [];
135
+ known.push(test);
136
+ casesByPath.set(selectedPath, known);
137
+ } else {
138
+ completedCases.add(test);
139
+ const ambiguous = matches.length > 1;
140
+ results.push({
141
+ id: test.id,
142
+ status: ambiguous ? "failed" : "skipped",
143
+ duration: 0,
144
+ error: {
145
+ message: ambiguous ? "Multiple collection requests match this test. Discover the tests again to select a request by path." : "Test not found in collection"
146
+ }
147
+ });
148
+ updateProgress(test);
149
+ }
150
+ }
151
+ const runOptions = {
152
+ // Default to the first environment or a dummy one if none exists
153
+ environment: Object.keys(collection.environments)[0] ?? "default",
154
+ parallel: options.parallel !== void 0 && options.parallel > 1,
155
+ concurrency: typeof options.parallel === "number" ? options.parallel : void 0,
156
+ timeout: options.timeout,
157
+ retries: options.retries,
158
+ overrides: options.env,
159
+ allowScripts: this.collectionOptions.allowScripts === true,
160
+ processEnv: this.collectionOptions.processEnv,
161
+ includePaths: [...casesByPath.keys()]
162
+ };
163
+ const report = casesByPath.size ? await runCollection(collection, runOptions) : { results: [] };
164
+ for (const reqRes of report.results) {
165
+ for (const tc of casesByPath.get(reqRes.path) ?? []) {
166
+ completedCases.add(tc);
167
+ let status = "passed";
168
+ let testError;
169
+ if (reqRes.status === "failed" || reqRes.status === "error") {
170
+ status = "failed";
171
+ if (reqRes.status === "failed") {
172
+ const failedAsserts = reqRes.assertions.filter((a) => !a.passed);
173
+ const msg = failedAsserts.map((a) => `- ${a.name}`).join("\n");
174
+ testError = {
175
+ message: `Assertions failed:
176
+ ${msg}`
177
+ };
178
+ } else if (reqRes.status === "error") {
179
+ testError = {
180
+ message: reqRes.error || "Unknown Request Error",
181
+ actual: reqRes.statusCode
182
+ };
183
+ }
184
+ } else if (reqRes.status === "skipped") {
185
+ status = "skipped";
186
+ }
187
+ results.push({
188
+ id: tc.id,
189
+ status,
190
+ duration: reqRes.duration,
191
+ error: testError
192
+ });
193
+ updateProgress(tc);
194
+ }
195
+ }
196
+ for (const tc of testsInCollection) {
197
+ if (!completedCases.has(tc)) {
198
+ results.push({
199
+ id: tc.id,
200
+ status: "skipped",
201
+ duration: 0,
202
+ error: { message: "Test not found or excluded in collection run" }
203
+ });
204
+ updateProgress(tc);
205
+ }
206
+ }
207
+ } catch (err) {
208
+ for (const tc of testsInCollection) {
209
+ if (completedCases.has(tc)) continue;
210
+ results.push({
211
+ id: tc.id,
212
+ status: "failed",
213
+ duration: 0,
214
+ error: {
215
+ message: err instanceof Error ? err.message : String(err),
216
+ stack: err instanceof Error ? err.stack : void 0
217
+ }
218
+ });
219
+ updateProgress(tc);
220
+ }
221
+ }
222
+ }
223
+ return results;
224
+ }
225
+ };
226
+ export {
227
+ ApifnTestAdapter
228
+ };
229
+ //# sourceMappingURL=testfn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/integrations/testfn.ts"],"sourcesContent":["import * as path from \"path\";\nimport * as fs from \"fs\";\nimport type {\n TestCase,\n TestResult,\n RunOptions,\n TestStatus,\n TestError,\n TestProgress,\n} from \"@testfn/core\";\nimport { BaseAdapter } from \"@testfn/core\";\n\n// Duck-typing collection types to avoid circular dependency\ninterface CollectionItem { kind: string; name: string; path: string; children?: CollectionItem[];[key: string]: any; }\ninterface CollectionInfo { name: string;[key: string]: any; }\ninterface Collection { info: CollectionInfo; items: CollectionItem[]; environments: Record<string, any>;[key: string]: any; }\ninterface AssertionResult { passed: boolean; name: string;[key: string]: any; }\ninterface RequestResult { path: string; status: \"passed\" | \"failed\" | \"error\" | \"skipped\"; duration: number; assertions: AssertionResult[]; error?: string; statusCode?: number;[key: string]: any; }\ninterface RunReport { results: RequestResult[];[key: string]: any; }\n\nconst REQUEST_ID_PREFIX = \"apifn:\";\n\nfunction requestId(directory: string, requestPath: string): string {\n return REQUEST_ID_PREFIX + JSON.stringify([directory, requestPath]);\n}\n\nfunction isRequestPathId(id: string): boolean {\n if (!id.startsWith(REQUEST_ID_PREFIX)) return false;\n try {\n const parts: unknown = JSON.parse(id.slice(REQUEST_ID_PREFIX.length));\n return Array.isArray(parts) && parts.length === 2 && parts.every((part) => typeof part === \"string\");\n } catch {\n return false;\n }\n}\n\nfunction visitRequests(\n collection: Collection,\n visit: (item: CollectionItem, suite: string) => void,\n): void {\n function walk(items: CollectionItem[], suitePath: string[]): void {\n for (const item of items) {\n if (item.kind === \"request\") {\n visit(item, suitePath.length ? suitePath.join(\" > \") : collection.info.name);\n } else if (item.kind === \"folder\" && item.children) {\n walk(item.children, [...suitePath, item.name]);\n }\n }\n }\n walk(collection.items, []);\n}\n\nexport interface ApifnTestAdapterOptions {\n /** Execute scripts from trusted collections. Defaults to false. */\n allowScripts?: boolean;\n /** Explicit values for collection templates that use {{process.env.NAME}}. */\n processEnv?: NodeJS.ProcessEnv;\n}\n\nexport class ApifnTestAdapter extends BaseAdapter {\n name = \"apifn\";\n\n constructor(private readonly collectionOptions: ApifnTestAdapterOptions = {}) {\n super();\n }\n\n supports(framework: string): boolean {\n return framework.toLowerCase() === \"apifn\";\n }\n\n async discover(patterns: string[]): Promise<TestCase[]> {\n // Dynamic import to avoid circular dependency\n let glob: ((pattern: string | string[], options?: { absolute?: boolean }) => Promise<string[]>) | undefined;\n try {\n // @testfn/core depends on fast-glob, so reuse it when available.\n const fg = await import(\"fast-glob\");\n glob = (fg as any).default ?? (fg as any);\n } catch {\n console.warn(\"[apifn/testfn] fast-glob not found, using basic fs discovery\");\n }\n\n // @ts-ignore\n const { readCollection } = await import(\"@apifn/collections\");\n const testCases: TestCase[] = [];\n const discoveredDirs = new Set<string>();\n\n for (const pattern of patterns) {\n if (glob) {\n // Find opencollection.yml files matching the pattern\n const files: string[] = await glob(\n pattern.endsWith(\".yml\") || pattern.endsWith(\".yaml\")\n ? pattern\n : `${pattern}/**/opencollection.yml`,\n { absolute: true }\n );\n for (const f of files) {\n discoveredDirs.add(path.dirname(f));\n }\n } else {\n // Fallback if no glob (unlikely since testfn has it)\n try {\n if (fs.existsSync(pattern)) {\n const stat = fs.statSync(pattern);\n if (stat.isDirectory()) {\n if (fs.existsSync(path.join(pattern, \"opencollection.yml\"))) {\n discoveredDirs.add(pattern);\n }\n } else if (pattern.endsWith(\"opencollection.yml\")) {\n discoveredDirs.add(path.dirname(pattern));\n }\n }\n } catch {\n // ignore\n }\n }\n }\n\n for (const dir of discoveredDirs) {\n try {\n const collection: Collection = await readCollection(dir);\n\n visitRequests(collection, (item, suite) => {\n testCases.push({\n id: requestId(dir, item.path),\n file: dir,\n name: item.name,\n suite,\n tags: [\"api\"],\n });\n });\n } catch (err) {\n console.warn(`[apifn/testfn] Failed to read collection at ${dir}:`, err);\n }\n }\n\n return testCases;\n }\n\n async run(tests: TestCase[], options: RunOptions): Promise<TestResult[]> {\n // @ts-ignore\n const { runCollection, readCollection, COLLECTION_RUNNER_TRUST_OPTIONS } = await import(\"@apifn/collections\");\n if (COLLECTION_RUNNER_TRUST_OPTIONS !== true) {\n throw new Error(\"The ApiFn TestFn adapter requires @apifn/collections 0.0.5 or later.\");\n }\n const results: TestResult[] = [];\n\n // Group tests by collection file/directory\n const collectionsToRun = new Map<string, TestCase[]>();\n for (const t of tests) {\n const list = collectionsToRun.get(t.file) || [];\n list.push(t);\n collectionsToRun.set(t.file, list);\n }\n\n let completedCount = 0;\n const updateProgress = (tc: TestCase) => {\n completedCount++;\n options.onProgress?.({\n completed: completedCount,\n total: tests.length,\n current: tc,\n });\n };\n\n for (const [dir, testsInCollection] of collectionsToRun.entries()) {\n const completedCases = new Set<TestCase>();\n try {\n const collection = await readCollection(dir);\n const requestsByName = new Map<string, Array<{ path: string; suite: string }>>();\n const pathsById = new Map<string, string>();\n const casesByPath = new Map<string, TestCase[]>();\n visitRequests(collection, (item, suite) => {\n const matches = requestsByName.get(item.name) ?? [];\n matches.push({ path: item.path, suite });\n requestsByName.set(item.name, matches);\n pathsById.set(requestId(dir, item.path), item.path);\n });\n\n for (const test of testsInCollection) {\n const matches = isRequestPathId(test.id)\n ? []\n : requestsByName.get(test.name)?.filter((request) => !test.suite || test.suite === request.suite) ?? [];\n const selectedPath = pathsById.get(test.id) ?? (matches.length === 1 ? matches[0].path : undefined);\n if (selectedPath !== undefined) {\n const known = casesByPath.get(selectedPath) ?? [];\n known.push(test);\n casesByPath.set(selectedPath, known);\n } else {\n completedCases.add(test);\n const ambiguous = matches.length > 1;\n results.push({\n id: test.id,\n status: ambiguous ? \"failed\" : \"skipped\",\n duration: 0,\n error: {\n message: ambiguous\n ? \"Multiple collection requests match this test. Discover the tests again to select a request by path.\"\n : \"Test not found in collection\",\n },\n });\n updateProgress(test);\n }\n }\n\n const runOptions = {\n // Default to the first environment or a dummy one if none exists\n environment: Object.keys(collection.environments)[0] ?? \"default\",\n parallel: options.parallel !== undefined && options.parallel > 1,\n concurrency: typeof options.parallel === \"number\" ? options.parallel : undefined,\n timeout: options.timeout,\n retries: options.retries,\n overrides: options.env,\n allowScripts: this.collectionOptions.allowScripts === true,\n processEnv: this.collectionOptions.processEnv,\n includePaths: [...casesByPath.keys()],\n };\n const report: RunReport = casesByPath.size\n ? await runCollection(collection, runOptions)\n : { results: [] };\n\n // Map collection results to testfn TestResults\n for (const reqRes of report.results) {\n for (const tc of casesByPath.get(reqRes.path) ?? []) {\n completedCases.add(tc);\n let status: TestStatus = \"passed\";\n let testError: TestError | undefined;\n\n if (reqRes.status === \"failed\" || reqRes.status === \"error\") {\n status = \"failed\";\n\n if (reqRes.status === \"failed\") {\n const failedAsserts = reqRes.assertions.filter((a: any) => !a.passed);\n const msg = failedAsserts.map((a: any) => `- ${a.name}`).join(\"\\n\");\n testError = {\n message: `Assertions failed:\\n${msg}`,\n };\n } else if (reqRes.status === \"error\") {\n testError = {\n message: reqRes.error || \"Unknown Request Error\",\n actual: reqRes.statusCode,\n };\n }\n } else if (reqRes.status === \"skipped\") {\n status = \"skipped\";\n }\n\n results.push({\n id: tc.id,\n status,\n duration: reqRes.duration,\n error: testError,\n });\n updateProgress(tc);\n }\n }\n\n // Handle skipped/omitted tests from collection that were requested\n for (const tc of testsInCollection) {\n if (!completedCases.has(tc)) {\n results.push({\n id: tc.id,\n status: \"skipped\",\n duration: 0,\n error: { message: \"Test not found or excluded in collection run\" },\n });\n updateProgress(tc);\n }\n }\n } catch (err) {\n // Collection load or execution failure applies error to all tests in it\n for (const tc of testsInCollection) {\n if (completedCases.has(tc)) continue;\n results.push({\n id: tc.id,\n status: \"failed\",\n duration: 0,\n error: {\n message: err instanceof Error ? err.message : String(err),\n stack: err instanceof Error ? err.stack : undefined,\n },\n });\n updateProgress(tc);\n }\n }\n }\n\n return results;\n }\n}\n"],"mappings":";;;AAAA,YAAY,UAAU;AACtB,YAAY,QAAQ;AASpB,SAAS,mBAAmB;AAU5B,IAAM,oBAAoB;AAE1B,SAAS,UAAU,WAAmB,aAA6B;AAC/D,SAAO,oBAAoB,KAAK,UAAU,CAAC,WAAW,WAAW,CAAC;AACtE;AAEA,SAAS,gBAAgB,IAAqB;AAC1C,MAAI,CAAC,GAAG,WAAW,iBAAiB,EAAG,QAAO;AAC9C,MAAI;AACA,UAAM,QAAiB,KAAK,MAAM,GAAG,MAAM,kBAAkB,MAAM,CAAC;AACpE,WAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,KAAK,MAAM,MAAM,CAAC,SAAS,OAAO,SAAS,QAAQ;AAAA,EACvG,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ;AAEA,SAAS,cACL,YACA,OACI;AACJ,WAAS,KAAK,OAAyB,WAA2B;AAC9D,eAAW,QAAQ,OAAO;AACtB,UAAI,KAAK,SAAS,WAAW;AACzB,cAAM,MAAM,UAAU,SAAS,UAAU,KAAK,KAAK,IAAI,WAAW,KAAK,IAAI;AAAA,MAC/E,WAAW,KAAK,SAAS,YAAY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V,OAAO,EAAE,SAAS,+CAA+C;AAAA,YACrE,CAAC;AACD,2BAAe,EAAE;AAAA,UACrB;AAAA,QACJ;AAAA,MACJ,SAAS,KAAK;AAEV,mBAAW,MAAM,mBAAmB;AAChC,cAAI,eAAe,IAAI,EAAE,EAAG;AAC5B,kBAAQ,KAAK;AAAA,YACT,IAAI,GAAG;AAAA,YACP,QAAQ;AAAA,YACR,UAAU;AAAA,YACV,OAAO;AAAA,cACH,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,cACxD,OAAO,eAAe,QAAQ,IAAI,QAAQ;AAAA,YAC9C;AAAA,UACJ,CAAC;AACD,yBAAe,EAAE;AAAA,QACrB;AAAA,MACJ;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AACJ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apifn/core",
3
- "version": "0.0.4",
3
+ "version": "0.1.2",
4
4
  "description": "Core library for ApiFn — route introspection, schema conversion, OpenAPI generation, and diff",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -16,24 +16,45 @@
16
16
  "types": "./dist/types.d.ts",
17
17
  "import": "./dist/types.js",
18
18
  "require": "./dist/types.cjs"
19
+ },
20
+ "./internal/openapi-reference-context": {
21
+ "import": {
22
+ "types": "./dist/openapi-reference-context.d.ts",
23
+ "default": "./dist/openapi-reference-context.js"
24
+ },
25
+ "require": {
26
+ "types": "./dist/openapi-reference-context.d.cts",
27
+ "default": "./dist/openapi-reference-context.cjs"
28
+ }
29
+ },
30
+ "./testfn": {
31
+ "import": {
32
+ "types": "./dist/testfn.d.ts",
33
+ "default": "./dist/testfn.js"
34
+ },
35
+ "require": {
36
+ "types": "./dist/testfn.d.cts",
37
+ "default": "./dist/testfn.cjs"
38
+ }
19
39
  }
20
40
  },
21
41
  "scripts": {
22
- "build": "tsup",
42
+ "build": "tsup && node scripts/fix-testfn-cjs-types.mjs",
23
43
  "dev": "tsup --watch",
24
- "test": "vitest run",
25
- "lint": "tsc --noEmit"
44
+ "test": "vitest run && node scripts/verify-packed-consumer.mjs",
45
+ "lint": "tsc --noEmit",
46
+ "verify:packed": "node scripts/verify-packed-consumer.mjs"
26
47
  },
27
48
  "dependencies": {
28
49
  "@apidevtools/swagger-parser": "^12.1.0",
29
- "@testfn/core": "0.0.2",
30
50
  "yaml": "^2.8.1",
31
51
  "zod": "^3.25.28",
32
52
  "zod-to-json-schema": "^3.24.6"
33
53
  },
34
54
  "peerDependencies": {
35
55
  "@sinclair/typebox": "*",
36
- "@superfunctions/http": "0.2.0"
56
+ "@superfunctions/http": ">=0.2.0 <0.4.0",
57
+ "@testfn/core": ">=0.0.2 <0.1.0"
37
58
  },
38
59
  "peerDependenciesMeta": {
39
60
  "@sinclair/typebox": {
@@ -41,11 +62,15 @@
41
62
  },
42
63
  "@superfunctions/http": {
43
64
  "optional": false
65
+ },
66
+ "@testfn/core": {
67
+ "optional": true
44
68
  }
45
69
  },
46
70
  "devDependencies": {
47
71
  "@sinclair/typebox": "^0.34.41",
48
- "@superfunctions/http": "0.2.0",
72
+ "@superfunctions/http": "0.3.1",
73
+ "@testfn/core": "0.0.4",
49
74
  "@types/node": "^20.0.0",
50
75
  "tsup": "^8.0.0",
51
76
  "typescript": "^5.3.0",
@@ -67,5 +92,5 @@
67
92
  "files": [
68
93
  "dist"
69
94
  ],
70
- "gitHead": "699d9d09932199d660333c57fe7bc646492ea3bf"
95
+ "gitHead": "38c7ebd67502fee64a79128bda819d250b23d49b"
71
96
  }