@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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog — @dudousxd/nestjs-inertia-codegen
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - fix(codegen): remove @tanstack/query-core dependency — generated api.ts uses plain object literals
8
+
9
+ - Updated dependencies []:
10
+ - @dudousxd/nestjs-inertia@2.0.1
11
+
12
+ ## 2.0.0
13
+
14
+ ### Minor Changes
15
+
16
+ - feat(codegen): add queryKey() helper for typed cache invalidation — api.crew.getCrew.queryKey()
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies []:
21
+ - @dudousxd/nestjs-inertia@2.0.0
22
+
3
23
  ## 1.0.7
4
24
 
5
25
  ### Patch Changes
package/dist/cli/main.cjs CHANGED
@@ -324,15 +324,16 @@ function emitApiObjectBlock(tree, indent) {
324
324
  if (method === "GET") {
325
325
  const typeAccess = buildRouterTypeAccess(c.name);
326
326
  lines.push(`${pad}${objKey}: {`);
327
- lines.push(`${pad} queryOptions: (query?: ${typeAccess}['query']) =>`);
328
- lines.push(`${pad} queryOptions({`);
329
- lines.push(`${pad} queryKey: [${flatName}, query],`);
330
- lines.push(`${pad} queryFn: () => fetcher.get<${typeAccess}['response']>(route(${flatName} as never) || ${safePath}, { query }),`);
331
- lines.push(`${pad} }),`);
327
+ lines.push(`${pad} queryKey: (query?: ${typeAccess}['query']) => query !== undefined ? [${flatName}, query] as const : [${flatName}] as const,`);
328
+ lines.push(`${pad} queryOptions: (query?: ${typeAccess}['query']) => ({`);
329
+ lines.push(`${pad} queryKey: query !== undefined ? [${flatName}, query] as const : [${flatName}] as const,`);
330
+ lines.push(`${pad} queryFn: () => fetcher.get<${typeAccess}['response']>(route(${flatName} as never) || ${safePath}, { query }),`);
331
+ lines.push(`${pad} }),`);
332
332
  lines.push(`${pad}},`);
333
333
  } else {
334
334
  const typeAccess = buildRouterTypeAccess(c.name);
335
335
  lines.push(`${pad}${objKey}: {`);
336
+ lines.push(`${pad} queryKey: () => [${flatName}] as const,`);
336
337
  lines.push(`${pad} mutationOptions: () => ({`);
337
338
  lines.push(`${pad} mutationFn: (body: ${typeAccess}['body']) => fetcher.${fetcherMethod}<${typeAccess}['response']>(route(${flatName} as never) || ${safePath}, { body }),`);
338
339
  lines.push(`${pad} }),`);
@@ -354,14 +355,10 @@ function buildRouterTypeAccess(name) {
354
355
  __name(buildRouterTypeAccess, "buildRouterTypeAccess");
355
356
  function buildApiFile(routes) {
356
357
  const contracted = routes.filter((r) => r.contract);
357
- const hasGetRoutes = contracted.some((r) => r.method === "GET");
358
358
  const lines = [
359
359
  "// Generated by @dudousxd/nestjs-inertia-codegen. Do not edit.",
360
360
  ""
361
361
  ];
362
- if (hasGetRoutes) {
363
- lines.push("import { queryOptions } from '@tanstack/query-core';");
364
- }
365
362
  lines.push("import { route } from './routes.js';");
366
363
  lines.push("import { createFetcher } from '@dudousxd/nestjs-inertia-client';");
367
364
  lines.push("");
@@ -1432,7 +1429,7 @@ async function watch(config, onChange) {
1432
1429
  __name(watch, "watch");
1433
1430
 
1434
1431
  // src/index.ts
1435
- var VERSION = "1.0.7";
1432
+ var VERSION = "2.0.1";
1436
1433
 
1437
1434
  // src/cli/codegen.ts
1438
1435
  async function runCodegen(opts = {}) {