@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/cli/main.js CHANGED
@@ -292,15 +292,17 @@ function emitApiObjectBlock(tree, indent) {
292
292
  if (method === "GET") {
293
293
  const typeAccess = buildRouterTypeAccess(c.name);
294
294
  lines.push(`${pad}${objKey}: {`);
295
+ lines.push(`${pad} queryKey: (query?: ${typeAccess}['query']) => query !== undefined ? [${flatName}, query] as const : [${flatName}] as const,`);
295
296
  lines.push(`${pad} queryOptions: (query?: ${typeAccess}['query']) =>`);
296
297
  lines.push(`${pad} queryOptions({`);
297
- lines.push(`${pad} queryKey: [${flatName}, query],`);
298
+ lines.push(`${pad} queryKey: query !== undefined ? [${flatName}, query] : [${flatName}],`);
298
299
  lines.push(`${pad} queryFn: () => fetcher.get<${typeAccess}['response']>(route(${flatName} as never) || ${safePath}, { query }),`);
299
300
  lines.push(`${pad} }),`);
300
301
  lines.push(`${pad}},`);
301
302
  } else {
302
303
  const typeAccess = buildRouterTypeAccess(c.name);
303
304
  lines.push(`${pad}${objKey}: {`);
305
+ lines.push(`${pad} queryKey: () => [${flatName}] as const,`);
304
306
  lines.push(`${pad} mutationOptions: () => ({`);
305
307
  lines.push(`${pad} mutationFn: (body: ${typeAccess}['body']) => fetcher.${fetcherMethod}<${typeAccess}['response']>(route(${flatName} as never) || ${safePath}, { body }),`);
306
308
  lines.push(`${pad} }),`);
@@ -1400,7 +1402,7 @@ async function watch(config, onChange) {
1400
1402
  __name(watch, "watch");
1401
1403
 
1402
1404
  // src/index.ts
1403
- var VERSION = "1.0.7";
1405
+ var VERSION = "2.0.0";
1404
1406
 
1405
1407
  // src/cli/codegen.ts
1406
1408
  async function runCodegen(opts = {}) {