@codewithagents/openapi-react-query 3.7.0 → 3.8.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 +2 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +49 -125
- package/dist/config.js.map +1 -1
- package/package.json +2 -2
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 ReactQueryConfig {
|
|
2
4
|
/** Path to OpenAPI 3.1 spec file (JSON or YAML) */
|
|
3
5
|
input_openapi: string;
|
|
@@ -17,8 +19,5 @@ export interface ReactQueryConfig {
|
|
|
17
19
|
/** When true, mutation hooks auto-invalidate related resource queries on success (default: false) */
|
|
18
20
|
auto_invalidate?: boolean;
|
|
19
21
|
}
|
|
20
|
-
export declare function validateConfigPath(configPath: string): void;
|
|
21
|
-
export declare function validateOutputPath(resolvedOutput: string): void;
|
|
22
|
-
export declare function validateInputPath(resolvedInput: string): void;
|
|
23
22
|
export declare function loadConfig(cwd: string, configPath?: string): Promise<ReactQueryConfig>;
|
|
24
23
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
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,gBAAgB;IAC/B,mDAAmD;IACnD,aAAa,EAAE,MAAM,CAAA;IACrB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,iGAAiG;IACjG,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACrE,qGAAqG;IACrG,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAwCD,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAmB5F"}
|
package/dist/config.js
CHANGED
|
@@ -1,133 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
'
|
|
5
|
-
|
|
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
|
-
// Must end in .json — prevents accidentally loading non-config files
|
|
33
|
-
if (!configPath.endsWith('.json')) {
|
|
34
|
-
throw new Error(`Config file must be a .json file, got: ${configPath}`);
|
|
1
|
+
import { loadConfigFile, validateConfigPath, validateInputPath, validateOutputPath, } from '@codewithagents/openapi-gen/config-core';
|
|
2
|
+
export { validateConfigPath, validateInputPath, validateOutputPath };
|
|
3
|
+
function validateTiming(resource, timing) {
|
|
4
|
+
if (typeof timing !== 'object' || timing === null) {
|
|
5
|
+
throw new Error(`"overrides.${resource}" must be an object`);
|
|
35
6
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for (const forbidden of FORBIDDEN_OUTPUT_PREFIXES) {
|
|
40
|
-
const normalizedForbidden = forbidden.replace(/\\/g, '/');
|
|
41
|
-
if (normalized === normalizedForbidden || normalized.startsWith(normalizedForbidden + '/')) {
|
|
42
|
-
throw new Error(`Output path resolves to a system directory: "${resolvedOutput}". ` +
|
|
43
|
-
`This looks like a misconfiguration — please check your config file.`);
|
|
44
|
-
}
|
|
7
|
+
const t = timing;
|
|
8
|
+
if (t['stale_time'] !== undefined && typeof t['stale_time'] !== 'number') {
|
|
9
|
+
throw new Error(`"overrides.${resource}.stale_time" must be a number`);
|
|
45
10
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const normalized = resolvedInput.replace(/\\/g, '/');
|
|
49
|
-
for (const forbidden of FORBIDDEN_INPUT_PREFIXES) {
|
|
50
|
-
const normalizedForbidden = forbidden.replace(/\\/g, '/');
|
|
51
|
-
if (normalized === normalizedForbidden || normalized.startsWith(normalizedForbidden + '/')) {
|
|
52
|
-
throw new Error(`Input spec path resolves to a system directory: "${resolvedInput}". ` +
|
|
53
|
-
`This looks like a misconfiguration — please check your config file.`);
|
|
54
|
-
}
|
|
11
|
+
if (t['gc_time'] !== undefined && typeof t['gc_time'] !== 'number') {
|
|
12
|
+
throw new Error(`"overrides.${resource}.gc_time" must be a number`);
|
|
55
13
|
}
|
|
56
14
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (configPath !== undefined) {
|
|
61
|
-
validateConfigPath(configPath);
|
|
62
|
-
}
|
|
63
|
-
let raw;
|
|
64
|
-
try {
|
|
65
|
-
raw = await readFile(resolvedConfigPath, 'utf-8');
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
throw new Error(`Config file not found: ${resolvedConfigPath}`);
|
|
69
|
-
}
|
|
70
|
-
let parsed;
|
|
71
|
-
try {
|
|
72
|
-
parsed = JSON.parse(raw);
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
throw new Error(`Config file is not valid JSON: ${resolvedConfigPath}`);
|
|
76
|
-
}
|
|
77
|
-
if (typeof parsed !== 'object' || parsed === null) {
|
|
78
|
-
throw new Error('Config must be a JSON object');
|
|
79
|
-
}
|
|
80
|
-
const config = parsed;
|
|
81
|
-
if (typeof config['input_openapi'] !== 'string' || !config['input_openapi']) {
|
|
82
|
-
throw new Error('Config missing required field: "input_openapi" (path to OpenAPI 3.1 spec)');
|
|
83
|
-
}
|
|
84
|
-
if (typeof config['output'] !== 'string' || !config['output']) {
|
|
85
|
-
throw new Error('Config missing required field: "output" (output directory)');
|
|
15
|
+
function validateOverrides(value) {
|
|
16
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
17
|
+
throw new Error('"overrides" must be an object');
|
|
86
18
|
}
|
|
87
|
-
|
|
88
|
-
|
|
19
|
+
for (const [resource, timing] of Object.entries(value)) {
|
|
20
|
+
validateTiming(resource, timing);
|
|
89
21
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
throw new Error(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
input_openapi: config['input_openapi'],
|
|
125
|
-
output: config['output'],
|
|
126
|
-
stale_time: config['stale_time'],
|
|
127
|
-
gc_time: config['gc_time'],
|
|
128
|
-
suspense: config['suspense'],
|
|
129
|
-
overrides: config['overrides'],
|
|
130
|
-
auto_invalidate: config['auto_invalidate'],
|
|
131
|
-
};
|
|
22
|
+
}
|
|
23
|
+
function expectNumber(raw, key, message) {
|
|
24
|
+
if (raw[key] !== undefined && typeof raw[key] !== 'number')
|
|
25
|
+
throw new Error(message);
|
|
26
|
+
}
|
|
27
|
+
function expectBoolean(raw, key, message) {
|
|
28
|
+
if (raw[key] !== undefined && typeof raw[key] !== 'boolean')
|
|
29
|
+
throw new Error(message);
|
|
30
|
+
}
|
|
31
|
+
function validateReactQueryFields(raw) {
|
|
32
|
+
expectNumber(raw, 'stale_time', '"stale_time" must be a number (milliseconds)');
|
|
33
|
+
expectNumber(raw, 'gc_time', '"gc_time" must be a number (milliseconds)');
|
|
34
|
+
expectBoolean(raw, 'suspense', '"suspense" must be a boolean');
|
|
35
|
+
expectBoolean(raw, 'auto_invalidate', '"auto_invalidate" must be a boolean');
|
|
36
|
+
if (raw['overrides'] !== undefined)
|
|
37
|
+
validateOverrides(raw['overrides']);
|
|
38
|
+
}
|
|
39
|
+
export async function loadConfig(cwd, configPath) {
|
|
40
|
+
return loadConfigFile({
|
|
41
|
+
cwd,
|
|
42
|
+
configPath,
|
|
43
|
+
defaultFileName: 'openapi-react-query.config.json',
|
|
44
|
+
parse: (raw, base) => {
|
|
45
|
+
validateReactQueryFields(raw);
|
|
46
|
+
return {
|
|
47
|
+
...base,
|
|
48
|
+
stale_time: raw['stale_time'],
|
|
49
|
+
gc_time: raw['gc_time'],
|
|
50
|
+
suspense: raw['suspense'],
|
|
51
|
+
overrides: raw['overrides'],
|
|
52
|
+
auto_invalidate: raw['auto_invalidate'],
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
});
|
|
132
56
|
}
|
|
133
57
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAA;AAmBpE,SAAS,cAAc,CAAC,QAAgB,EAAE,MAAe;IACvD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,cAAc,QAAQ,qBAAqB,CAAC,CAAA;IAC9D,CAAC;IACD,MAAM,CAAC,GAAG,MAAiC,CAAA;IAC3C,IAAI,CAAC,CAAC,YAAY,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,CAAC,YAAY,CAAC,KAAK,QAAQ,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,cAAc,QAAQ,+BAA+B,CAAC,CAAA;IACxE,CAAC;IACD,IAAI,CAAC,CAAC,SAAS,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,QAAQ,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CAAC,cAAc,QAAQ,4BAA4B,CAAC,CAAA;IACrE,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,I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QACV,eAAe,EAAE,iCAAiC;QAClD,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACnB,wBAAwB,CAAC,GAAG,CAAC,CAAA;YAC7B,OAAO;gBACL,GAAG,IAAI;gBACP,UAAU,EAAE,GAAG,CAAC,YAAY,CAAuB;gBACnD,OAAO,EAAE,GAAG,CAAC,SAAS,CAAuB;gBAC7C,QAAQ,EAAE,GAAG,CAAC,UAAU,CAAwB;gBAChD,SAAS,EAAE,GAAG,CAAC,WAAW,CAEb;gBACb,eAAe,EAAE,GAAG,CAAC,iBAAiB,CAAwB;aAC/D,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codewithagents/openapi-react-query",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Generate typed React Query v5 hooks from OpenAPI 3.1 specs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"openapi-types": "^12.1.3",
|
|
18
18
|
"prettier": "^3.5.3",
|
|
19
|
-
"@codewithagents/openapi-gen": "4.
|
|
19
|
+
"@codewithagents/openapi-gen": "4.8.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@tanstack/react-query": "^5.0.0"
|