@dudousxd/nestjs-inertia-codegen 1.0.7 → 2.0.1
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/CHANGELOG.md +20 -0
- package/dist/cli/main.cjs +7 -10
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +7 -10
- package/dist/cli/main.js.map +1 -1
- package/dist/index.cjs +7 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -10
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -304,15 +304,16 @@ function emitApiObjectBlock(tree, indent) {
|
|
|
304
304
|
if (method === "GET") {
|
|
305
305
|
const typeAccess = buildRouterTypeAccess(c.name);
|
|
306
306
|
lines.push(`${pad}${objKey}: {`);
|
|
307
|
-
lines.push(`${pad}
|
|
308
|
-
lines.push(`${pad}
|
|
309
|
-
lines.push(`${pad}
|
|
310
|
-
lines.push(`${pad}
|
|
311
|
-
lines.push(`${pad}
|
|
307
|
+
lines.push(`${pad} queryKey: (query?: ${typeAccess}['query']) => query !== undefined ? [${flatName}, query] as const : [${flatName}] as const,`);
|
|
308
|
+
lines.push(`${pad} queryOptions: (query?: ${typeAccess}['query']) => ({`);
|
|
309
|
+
lines.push(`${pad} queryKey: query !== undefined ? [${flatName}, query] as const : [${flatName}] as const,`);
|
|
310
|
+
lines.push(`${pad} queryFn: () => fetcher.get<${typeAccess}['response']>(route(${flatName} as never) || ${safePath}, { query }),`);
|
|
311
|
+
lines.push(`${pad} }),`);
|
|
312
312
|
lines.push(`${pad}},`);
|
|
313
313
|
} else {
|
|
314
314
|
const typeAccess = buildRouterTypeAccess(c.name);
|
|
315
315
|
lines.push(`${pad}${objKey}: {`);
|
|
316
|
+
lines.push(`${pad} queryKey: () => [${flatName}] as const,`);
|
|
316
317
|
lines.push(`${pad} mutationOptions: () => ({`);
|
|
317
318
|
lines.push(`${pad} mutationFn: (body: ${typeAccess}['body']) => fetcher.${fetcherMethod}<${typeAccess}['response']>(route(${flatName} as never) || ${safePath}, { body }),`);
|
|
318
319
|
lines.push(`${pad} }),`);
|
|
@@ -334,14 +335,10 @@ function buildRouterTypeAccess(name) {
|
|
|
334
335
|
__name(buildRouterTypeAccess, "buildRouterTypeAccess");
|
|
335
336
|
function buildApiFile(routes) {
|
|
336
337
|
const contracted = routes.filter((r) => r.contract);
|
|
337
|
-
const hasGetRoutes = contracted.some((r) => r.method === "GET");
|
|
338
338
|
const lines = [
|
|
339
339
|
"// Generated by @dudousxd/nestjs-inertia-codegen. Do not edit.",
|
|
340
340
|
""
|
|
341
341
|
];
|
|
342
|
-
if (hasGetRoutes) {
|
|
343
|
-
lines.push("import { queryOptions } from '@tanstack/query-core';");
|
|
344
|
-
}
|
|
345
342
|
lines.push("import { route } from './routes.js';");
|
|
346
343
|
lines.push("import { createFetcher } from '@dudousxd/nestjs-inertia-client';");
|
|
347
344
|
lines.push("");
|
|
@@ -1412,7 +1409,7 @@ async function watch(config, onChange) {
|
|
|
1412
1409
|
__name(watch, "watch");
|
|
1413
1410
|
|
|
1414
1411
|
// src/index.ts
|
|
1415
|
-
var VERSION = "
|
|
1412
|
+
var VERSION = "2.0.1";
|
|
1416
1413
|
export {
|
|
1417
1414
|
CodegenError,
|
|
1418
1415
|
ConfigError,
|