@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/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} queryOptions: (query?: ${typeAccess}['query']) =>`);
308
- lines.push(`${pad} queryOptions({`);
309
- lines.push(`${pad} queryKey: [${flatName}, query],`);
310
- lines.push(`${pad} queryFn: () => fetcher.get<${typeAccess}['response']>(route(${flatName} as never) || ${safePath}, { query }),`);
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 = "1.0.7";
1412
+ var VERSION = "2.0.1";
1416
1413
  export {
1417
1414
  CodegenError,
1418
1415
  ConfigError,