@codewithagents/openapi-server 1.4.0 → 1.5.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/config.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { validateConfigPath, validateInputPath, validateOutputPath } from '@codewithagents/openapi-gen/config-core';
2
+ export { validateConfigPath, validateInputPath, validateOutputPath };
1
3
  export interface ServerConfig {
2
4
  /** Path to the OpenAPI 3.1 spec file (JSON or YAML) */
3
5
  input_openapi: string;
@@ -8,8 +10,5 @@ export interface ServerConfig {
8
10
  /** Path to user-owned Zod schema file (same file as openapi-gen's input_schema). Optional. */
9
11
  input_schema?: string;
10
12
  }
11
- export declare function validateConfigPath(configPath: string): void;
12
- export declare function validateOutputPath(resolvedOutput: string): void;
13
- export declare function validateInputPath(resolvedInput: string): void;
14
13
  export declare function loadConfig(cwd: string, configPath?: string): Promise<ServerConfig>;
15
14
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,aAAa,EAAE,MAAM,CAAA;IACrB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAA;IACnD,8FAA8F;IAC9F,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAgCD,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAI3D;AAED,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAW/D;AAED,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAW7D;AAGD,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CA4DxF"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAA;AAEpE,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,aAAa,EAAE,MAAM,CAAA;IACrB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAA;IACnD,8FAA8F;IAC9F,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CA8BxF"}
package/dist/config.js CHANGED
@@ -1,108 +1,30 @@
1
- import { readFile } from 'node:fs/promises';
2
- import { join, resolve } from 'node:path';
3
- const FORBIDDEN_OUTPUT_PREFIXES = [
4
- '/etc',
5
- '/usr',
6
- '/bin',
7
- '/sbin',
8
- '/lib',
9
- '/lib64',
10
- '/sys',
11
- '/proc',
12
- '/dev',
13
- '/boot',
14
- '/run',
15
- 'C:\\Windows',
16
- 'C:\\Program Files',
17
- ];
18
- const FORBIDDEN_INPUT_PREFIXES = [
19
- '/etc',
20
- '/usr',
21
- '/bin',
22
- '/sbin',
23
- '/lib',
24
- '/lib64',
25
- '/sys',
26
- '/proc',
27
- '/dev',
28
- 'C:\\Windows',
29
- 'C:\\Program Files',
30
- ];
31
- export function validateConfigPath(configPath) {
32
- if (!configPath.endsWith('.json')) {
33
- throw new Error(`Config file must be a .json file, got: ${configPath}`);
34
- }
35
- }
36
- export function validateOutputPath(resolvedOutput) {
37
- const normalized = resolvedOutput.replace(/\\/g, '/');
38
- for (const forbidden of FORBIDDEN_OUTPUT_PREFIXES) {
39
- const normalizedForbidden = forbidden.replace(/\\/g, '/');
40
- if (normalized === normalizedForbidden || normalized.startsWith(normalizedForbidden + '/')) {
41
- throw new Error(`Output path resolves to a system directory: "${resolvedOutput}". ` +
42
- `This looks like a misconfiguration — please check your config file.`);
43
- }
44
- }
45
- }
46
- export function validateInputPath(resolvedInput) {
47
- const normalized = resolvedInput.replace(/\\/g, '/');
48
- for (const forbidden of FORBIDDEN_INPUT_PREFIXES) {
49
- const normalizedForbidden = forbidden.replace(/\\/g, '/');
50
- if (normalized === normalizedForbidden || normalized.startsWith(normalizedForbidden + '/')) {
51
- throw new Error(`Input spec path resolves to a system directory: "${resolvedInput}". ` +
52
- `This looks like a misconfiguration — please check your config file.`);
53
- }
54
- }
55
- }
56
- // fallow-ignore-next-line complexity
1
+ import { loadConfigFile, validateConfigPath, validateInputPath, validateOutputPath, } from '@codewithagents/openapi-gen/config-core';
2
+ export { validateConfigPath, validateInputPath, validateOutputPath };
57
3
  export async function loadConfig(cwd, configPath) {
58
- const resolvedConfigPath = configPath ?? join(cwd, 'openapi-server.config.json');
59
- if (configPath !== undefined) {
60
- validateConfigPath(configPath);
61
- }
62
- let raw;
63
- try {
64
- raw = await readFile(resolvedConfigPath, 'utf-8');
65
- }
66
- catch {
67
- throw new Error(`Config file not found: ${resolvedConfigPath}`);
68
- }
69
- let parsed;
70
- try {
71
- parsed = JSON.parse(raw);
72
- }
73
- catch {
74
- throw new Error(`Config file is not valid JSON: ${resolvedConfigPath}`);
75
- }
76
- if (typeof parsed !== 'object' || parsed === null) {
77
- throw new Error('Config must be a JSON object');
78
- }
79
- const config = parsed;
80
- if (typeof config['input_openapi'] !== 'string' || !config['input_openapi']) {
81
- throw new Error('Config missing required field: "input_openapi" (path to OpenAPI 3.1 spec)');
82
- }
83
- if (typeof config['output'] !== 'string' || !config['output']) {
84
- throw new Error('Config missing required field: "output" (output directory)');
85
- }
86
- if (config['framework'] !== undefined &&
87
- config['framework'] !== 'hono' &&
88
- config['framework'] !== 'express' &&
89
- config['framework'] !== 'fastify' &&
90
- config['framework'] !== 'none') {
91
- throw new Error('"framework" must be one of: "hono", "express", "fastify", or "none"');
92
- }
93
- if (config['input_schema'] !== undefined &&
94
- (typeof config['input_schema'] !== 'string' || !config['input_schema'])) {
95
- throw new Error('"input_schema" must be a non-empty string path to your Zod schema file');
96
- }
97
- const resolvedInput = resolve(cwd, config['input_openapi']);
98
- const resolvedOutput = resolve(cwd, config['output']);
99
- validateInputPath(resolvedInput);
100
- validateOutputPath(resolvedOutput);
101
- return {
102
- input_openapi: config['input_openapi'],
103
- output: config['output'],
104
- framework: config['framework'],
105
- input_schema: config['input_schema'],
106
- };
4
+ return loadConfigFile({
5
+ cwd,
6
+ configPath,
7
+ defaultFileName: 'openapi-server.config.json',
8
+ parse: (raw) => {
9
+ const framework = raw['framework'];
10
+ if (framework !== undefined &&
11
+ framework !== 'hono' &&
12
+ framework !== 'express' &&
13
+ framework !== 'fastify' &&
14
+ framework !== 'none') {
15
+ throw new Error('"framework" must be one of: "hono", "express", "fastify", or "none"');
16
+ }
17
+ if (raw['input_schema'] !== undefined &&
18
+ (typeof raw['input_schema'] !== 'string' || !raw['input_schema'])) {
19
+ throw new Error('"input_schema" must be a non-empty string path to your Zod schema file');
20
+ }
21
+ return {
22
+ input_openapi: raw['input_openapi'],
23
+ output: raw['output'],
24
+ framework: framework,
25
+ input_schema: raw['input_schema'],
26
+ };
27
+ },
28
+ });
107
29
  }
108
30
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAazC,MAAM,yBAAyB,GAAG;IAChC,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP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,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAA;AAapE,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW,EAAE,UAAmB;IAC/D,OAAO,cAAc,CAAe;QAClC,GAAG;QACH,UAAU;QACV,eAAe,EAAE,4BAA4B;QAC7C,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;YACb,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,CAAC,CAAA;YAClC,IACE,SAAS,KAAK,SAAS;gBACvB,SAAS,KAAK,MAAM;gBACpB,SAAS,KAAK,SAAS;gBACvB,SAAS,KAAK,SAAS;gBACvB,SAAS,KAAK,MAAM,EACpB,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAA;YACxF,CAAC;YACD,IACE,GAAG,CAAC,cAAc,CAAC,KAAK,SAAS;gBACjC,CAAC,OAAO,GAAG,CAAC,cAAc,CAAC,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,EACjE,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAA;YAC3F,CAAC;YACD,OAAO;gBACL,aAAa,EAAE,GAAG,CAAC,eAAe,CAAW;gBAC7C,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAW;gBAC/B,SAAS,EAAE,SAAgE;gBAC3E,YAAY,EAAE,GAAG,CAAC,cAAc,CAAuB;aACxD,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codewithagents/openapi-server",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Generate typed server-side service interfaces and framework routers from OpenAPI 3.1",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,12 +18,14 @@
18
18
  "dependencies": {
19
19
  "openapi-types": "^12.1.3",
20
20
  "prettier": "^3.5.3",
21
- "@codewithagents/openapi-gen": "4.4.0"
21
+ "@codewithagents/openapi-gen": "4.8.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@types/node": "^22.0.0",
24
+ "@stryker-mutator/core": "^9.6.1",
25
+ "@stryker-mutator/vitest-runner": "^9.6.1",
26
+ "@types/node": "^25.0.0",
25
27
  "@vitest/coverage-v8": "^4.1.7",
26
- "esbuild": "^0.25.0",
28
+ "esbuild": "^0.28.0",
27
29
  "fast-check": "^4.8.0",
28
30
  "typescript": "^6.0.0",
29
31
  "vitest": "^4.1.7"
@@ -58,6 +60,7 @@
58
60
  "lint": "tsc -p tsconfig.build.json --noEmit",
59
61
  "test": "vitest run",
60
62
  "test:coverage": "vitest run --coverage",
63
+ "test:mutation": "stryker run",
61
64
  "dev": "tsc -p tsconfig.build.json --watch"
62
65
  }
63
66
  }