@codewithagents/openapi-react-query 3.5.2 → 3.6.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.
@@ -0,0 +1,23 @@
1
+ /** The parsed result of CLI arguments. */
2
+ export type CliAction = {
3
+ action: 'help';
4
+ } | {
5
+ action: 'version';
6
+ } | {
7
+ action: 'run';
8
+ configFile?: string;
9
+ cwd: string;
10
+ } | {
11
+ action: 'error';
12
+ message: string;
13
+ };
14
+ /**
15
+ * Parse raw process.argv into a structured action.
16
+ *
17
+ * Pure function: no I/O, no process.exit. Testable in isolation.
18
+ *
19
+ * @param argv process.argv (first two entries are node + script path)
20
+ * @param cwd the working directory to resolve paths against
21
+ */
22
+ export declare function parseCliArgs(argv: string[], cwd: string): CliAction;
23
+ //# sourceMappingURL=cli-args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAEA,0CAA0C;AAC1C,MAAM,MAAM,SAAS,GACjB;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAExC;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CA8BnE"}
@@ -0,0 +1,37 @@
1
+ import { resolve, dirname } from 'node:path';
2
+ /**
3
+ * Parse raw process.argv into a structured action.
4
+ *
5
+ * Pure function: no I/O, no process.exit. Testable in isolation.
6
+ *
7
+ * @param argv process.argv (first two entries are node + script path)
8
+ * @param cwd the working directory to resolve paths against
9
+ */
10
+ export function parseCliArgs(argv, cwd) {
11
+ const args = argv.slice(2);
12
+ if (args.includes('--help') || args.includes('-h')) {
13
+ return { action: 'help' };
14
+ }
15
+ if (args.includes('--version') || args.includes('-v')) {
16
+ return { action: 'version' };
17
+ }
18
+ const configIdx = args.indexOf('--config');
19
+ if (configIdx !== -1) {
20
+ const next = args[configIdx + 1];
21
+ if (next === undefined || next.startsWith('--')) {
22
+ return {
23
+ action: 'error',
24
+ message: [
25
+ 'Error: --config requires a file path argument',
26
+ 'Usage: openapi-react-query [--config <path-to-config.json>]',
27
+ ].join('\n'),
28
+ };
29
+ }
30
+ const configFile = resolve(cwd, next);
31
+ // Relative paths inside the config resolve from the config file's directory,
32
+ // not from the shell's CWD. This matches how most tooling works.
33
+ return { action: 'run', configFile, cwd: dirname(configFile) };
34
+ }
35
+ return { action: 'run', cwd };
36
+ }
37
+ //# sourceMappingURL=cli-args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAS5C;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,IAAc,EAAE,GAAW;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAE1B,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACnD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;IAC3B,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACtD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;IAC9B,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAC1C,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAA;QAChC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAChD,OAAO;gBACL,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE;oBACP,+CAA+C;oBAC/C,6DAA6D;iBAC9D,CAAC,IAAI,CAAC,IAAI,CAAC;aACb,CAAA;QACH,CAAC;QACD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QACrC,6EAA6E;QAC7E,iEAAiE;QACjE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAA;IAChE,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;AAC/B,CAAC"}
package/dist/cli.js CHANGED
@@ -1,23 +1,31 @@
1
1
  #!/usr/bin/env node
2
- import { resolve, dirname } from 'node:path';
2
+ import { readFileSync } from 'node:fs';
3
3
  import { generate } from './generator.js';
4
- const args = process.argv.slice(2);
5
- const configIdx = args.indexOf('--config');
6
- let cwd = process.cwd();
7
- let configFile;
8
- if (configIdx !== -1) {
9
- const next = args[configIdx + 1];
10
- if (next === undefined || next.startsWith('--')) {
11
- console.error('Error: --config requires a file path argument');
12
- console.error('Usage: openapi-react-query [--config <path-to-config.json>]');
13
- process.exit(1);
14
- }
15
- configFile = resolve(cwd, next);
16
- // Relative paths inside the config resolve from the config file's directory,
17
- // not from the shell's CWD. This matches how most tooling works.
18
- cwd = dirname(configFile);
4
+ import { parseCliArgs } from './cli-args.js';
5
+ const parsed = parseCliArgs(process.argv, process.cwd());
6
+ if (parsed.action === 'help') {
7
+ console.log([
8
+ 'Usage: openapi-react-query [--config <path>]',
9
+ '',
10
+ 'Generate typed React Query v5 hooks from an OpenAPI 3.1 spec.',
11
+ '',
12
+ 'Options:',
13
+ ' --config <path> Path to config file (default: openapi-react-query.config.json in cwd)',
14
+ ' --help, -h Show this help message',
15
+ ' --version, -v Show version number',
16
+ ].join('\n'));
17
+ process.exit(0);
19
18
  }
20
- generate(cwd, configFile).catch((err) => {
19
+ if (parsed.action === 'version') {
20
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));
21
+ console.log(pkg.version);
22
+ process.exit(0);
23
+ }
24
+ if (parsed.action === 'error') {
25
+ console.error(parsed.message);
26
+ process.exit(1);
27
+ }
28
+ generate(parsed.cwd, parsed.configFile).catch((err) => {
21
29
  console.error(`Error: ${err.message}`);
22
30
  process.exit(1);
23
31
  });
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAClC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1C,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;AACvB,IAAI,UAA8B,CAAA;AAElC,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;IACrB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAA;IAChC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAA;QAC9D,OAAO,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAA;QAC5E,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,OAAO,CAAC,CAC5C,CAAA;IACxB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAED,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;IAC9B,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAED,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;IAC3D,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;IACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ export { generate } from './generator.js';
2
+ export { loadConfig } from './config.js';
3
+ export type { ReactQueryConfig } from './config.js';
4
+ export { generateHooks } from './plugins/hooks.js';
5
+ export type { HookGenOptions } from './plugins/hooks.js';
6
+ export { generateTestUtils } from './plugins/test-utils.js';
7
+ export type { GeneratedFile } from './plugins/test-utils.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { generate } from './generator.js';
2
+ export { loadConfig } from './config.js';
3
+ export { generateHooks } from './plugins/hooks.js';
4
+ export { generateTestUtils } from './plugins/test-utils.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codewithagents/openapi-react-query",
3
- "version": "3.5.2",
3
+ "version": "3.6.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.3.2"
19
+ "@codewithagents/openapi-gen": "4.4.0"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "@tanstack/react-query": "^5.0.0"