@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.cjs
CHANGED
|
@@ -345,15 +345,16 @@ function emitApiObjectBlock(tree, indent) {
|
|
|
345
345
|
if (method === "GET") {
|
|
346
346
|
const typeAccess = buildRouterTypeAccess(c.name);
|
|
347
347
|
lines.push(`${pad}${objKey}: {`);
|
|
348
|
-
lines.push(`${pad}
|
|
349
|
-
lines.push(`${pad}
|
|
350
|
-
lines.push(`${pad}
|
|
351
|
-
lines.push(`${pad}
|
|
352
|
-
lines.push(`${pad}
|
|
348
|
+
lines.push(`${pad} queryKey: (query?: ${typeAccess}['query']) => query !== undefined ? [${flatName}, query] as const : [${flatName}] as const,`);
|
|
349
|
+
lines.push(`${pad} queryOptions: (query?: ${typeAccess}['query']) => ({`);
|
|
350
|
+
lines.push(`${pad} queryKey: query !== undefined ? [${flatName}, query] as const : [${flatName}] as const,`);
|
|
351
|
+
lines.push(`${pad} queryFn: () => fetcher.get<${typeAccess}['response']>(route(${flatName} as never) || ${safePath}, { query }),`);
|
|
352
|
+
lines.push(`${pad} }),`);
|
|
353
353
|
lines.push(`${pad}},`);
|
|
354
354
|
} else {
|
|
355
355
|
const typeAccess = buildRouterTypeAccess(c.name);
|
|
356
356
|
lines.push(`${pad}${objKey}: {`);
|
|
357
|
+
lines.push(`${pad} queryKey: () => [${flatName}] as const,`);
|
|
357
358
|
lines.push(`${pad} mutationOptions: () => ({`);
|
|
358
359
|
lines.push(`${pad} mutationFn: (body: ${typeAccess}['body']) => fetcher.${fetcherMethod}<${typeAccess}['response']>(route(${flatName} as never) || ${safePath}, { body }),`);
|
|
359
360
|
lines.push(`${pad} }),`);
|
|
@@ -375,14 +376,10 @@ function buildRouterTypeAccess(name) {
|
|
|
375
376
|
__name(buildRouterTypeAccess, "buildRouterTypeAccess");
|
|
376
377
|
function buildApiFile(routes) {
|
|
377
378
|
const contracted = routes.filter((r) => r.contract);
|
|
378
|
-
const hasGetRoutes = contracted.some((r) => r.method === "GET");
|
|
379
379
|
const lines = [
|
|
380
380
|
"// Generated by @dudousxd/nestjs-inertia-codegen. Do not edit.",
|
|
381
381
|
""
|
|
382
382
|
];
|
|
383
|
-
if (hasGetRoutes) {
|
|
384
|
-
lines.push("import { queryOptions } from '@tanstack/query-core';");
|
|
385
|
-
}
|
|
386
383
|
lines.push("import { route } from './routes.js';");
|
|
387
384
|
lines.push("import { createFetcher } from '@dudousxd/nestjs-inertia-client';");
|
|
388
385
|
lines.push("");
|
|
@@ -1453,7 +1450,7 @@ async function watch(config, onChange) {
|
|
|
1453
1450
|
__name(watch, "watch");
|
|
1454
1451
|
|
|
1455
1452
|
// src/index.ts
|
|
1456
|
-
var VERSION = "
|
|
1453
|
+
var VERSION = "2.0.1";
|
|
1457
1454
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1458
1455
|
0 && (module.exports = {
|
|
1459
1456
|
CodegenError,
|