@dudousxd/nestjs-inertia-codegen 1.0.7 → 2.0.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/index.js CHANGED
@@ -304,15 +304,17 @@ 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} queryKey: (query?: ${typeAccess}['query']) => query !== undefined ? [${flatName}, query] as const : [${flatName}] as const,`);
307
308
  lines.push(`${pad} queryOptions: (query?: ${typeAccess}['query']) =>`);
308
309
  lines.push(`${pad} queryOptions({`);
309
- lines.push(`${pad} queryKey: [${flatName}, query],`);
310
+ lines.push(`${pad} queryKey: query !== undefined ? [${flatName}, query] : [${flatName}],`);
310
311
  lines.push(`${pad} queryFn: () => fetcher.get<${typeAccess}['response']>(route(${flatName} as never) || ${safePath}, { query }),`);
311
312
  lines.push(`${pad} }),`);
312
313
  lines.push(`${pad}},`);
313
314
  } else {
314
315
  const typeAccess = buildRouterTypeAccess(c.name);
315
316
  lines.push(`${pad}${objKey}: {`);
317
+ lines.push(`${pad} queryKey: () => [${flatName}] as const,`);
316
318
  lines.push(`${pad} mutationOptions: () => ({`);
317
319
  lines.push(`${pad} mutationFn: (body: ${typeAccess}['body']) => fetcher.${fetcherMethod}<${typeAccess}['response']>(route(${flatName} as never) || ${safePath}, { body }),`);
318
320
  lines.push(`${pad} }),`);
@@ -1412,7 +1414,7 @@ async function watch(config, onChange) {
1412
1414
  __name(watch, "watch");
1413
1415
 
1414
1416
  // src/index.ts
1415
- var VERSION = "1.0.7";
1417
+ var VERSION = "2.0.0";
1416
1418
  export {
1417
1419
  CodegenError,
1418
1420
  ConfigError,