postgresdk 0.18.7 → 0.18.9

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.js CHANGED
@@ -605,7 +605,7 @@ function generateIncludeMethods(table, graph, opts, allTables) {
605
605
  });
606
606
  explore(edge.target, newPath, newIsMany, newTargets, new Set([...visited, edge.target]), depth + 1);
607
607
  }
608
- if (depth === 1 && Object.keys(currentEdges).length > 1 && Object.keys(currentEdges).length <= 3) {
608
+ if (depth === 1 && Object.keys(currentEdges).length > 1 && Object.keys(currentEdges).length <= 6) {
609
609
  const edgeEntries = Object.entries(currentEdges);
610
610
  if (edgeEntries.length >= 2) {
611
611
  for (let i = 0;i < edgeEntries.length - 1; i++) {
@@ -3460,7 +3460,8 @@ function emitClient(table, graph, opts, model) {
3460
3460
  }
3461
3461
  }
3462
3462
  const typeImports = `import type { Insert${Type}, Update${Type}, Select${Type} } from "./types/${table.name}${ext}";`;
3463
- const includeSpecImport = `import type { ${Type}IncludeSpec } from "./include-spec${ext}";`;
3463
+ const includeSpecTypes = [table.name, ...Array.from(importedTypes).filter((t) => t !== table.name)];
3464
+ const includeSpecImport = `import type { ${includeSpecTypes.map((t) => `${pascal(t)}IncludeSpec`).join(", ")} } from "./include-spec${ext}";`;
3464
3465
  const otherTableImports = [];
3465
3466
  for (const target of Array.from(importedTypes)) {
3466
3467
  if (target !== table.name) {
@@ -3528,6 +3529,8 @@ function emitClient(table, graph, opts, model) {
3528
3529
  } else if (pattern.type === "nested" && pattern.nestedKey) {
3529
3530
  const paramName = toIncludeParamName(pattern.nestedKey);
3530
3531
  includeParamNames.push(paramName);
3532
+ const targetTable = method.targets[0];
3533
+ const targetType = targetTable ? pascal(targetTable) : Type;
3531
3534
  paramsType = `{
3532
3535
  select?: string[];
3533
3536
  exclude?: string[];
@@ -3543,7 +3546,7 @@ function emitClient(table, graph, opts, model) {
3543
3546
  order?: "asc" | "desc";
3544
3547
  limit?: number;
3545
3548
  offset?: number;
3546
- include?: ${Type}IncludeSpec;
3549
+ include?: ${targetType}IncludeSpec;
3547
3550
  };
3548
3551
  }`;
3549
3552
  }
package/dist/index.js CHANGED
@@ -604,7 +604,7 @@ function generateIncludeMethods(table, graph, opts, allTables) {
604
604
  });
605
605
  explore(edge.target, newPath, newIsMany, newTargets, new Set([...visited, edge.target]), depth + 1);
606
606
  }
607
- if (depth === 1 && Object.keys(currentEdges).length > 1 && Object.keys(currentEdges).length <= 3) {
607
+ if (depth === 1 && Object.keys(currentEdges).length > 1 && Object.keys(currentEdges).length <= 6) {
608
608
  const edgeEntries = Object.entries(currentEdges);
609
609
  if (edgeEntries.length >= 2) {
610
610
  for (let i = 0;i < edgeEntries.length - 1; i++) {
@@ -2499,7 +2499,8 @@ function emitClient(table, graph, opts, model) {
2499
2499
  }
2500
2500
  }
2501
2501
  const typeImports = `import type { Insert${Type}, Update${Type}, Select${Type} } from "./types/${table.name}${ext}";`;
2502
- const includeSpecImport = `import type { ${Type}IncludeSpec } from "./include-spec${ext}";`;
2502
+ const includeSpecTypes = [table.name, ...Array.from(importedTypes).filter((t) => t !== table.name)];
2503
+ const includeSpecImport = `import type { ${includeSpecTypes.map((t) => `${pascal(t)}IncludeSpec`).join(", ")} } from "./include-spec${ext}";`;
2503
2504
  const otherTableImports = [];
2504
2505
  for (const target of Array.from(importedTypes)) {
2505
2506
  if (target !== table.name) {
@@ -2567,6 +2568,8 @@ function emitClient(table, graph, opts, model) {
2567
2568
  } else if (pattern.type === "nested" && pattern.nestedKey) {
2568
2569
  const paramName = toIncludeParamName(pattern.nestedKey);
2569
2570
  includeParamNames.push(paramName);
2571
+ const targetTable = method.targets[0];
2572
+ const targetType = targetTable ? pascal(targetTable) : Type;
2570
2573
  paramsType = `{
2571
2574
  select?: string[];
2572
2575
  exclude?: string[];
@@ -2582,7 +2585,7 @@ function emitClient(table, graph, opts, model) {
2582
2585
  order?: "asc" | "desc";
2583
2586
  limit?: number;
2584
2587
  offset?: number;
2585
- include?: ${Type}IncludeSpec;
2588
+ include?: ${targetType}IncludeSpec;
2586
2589
  };
2587
2590
  }`;
2588
2591
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresdk",
3
- "version": "0.18.7",
3
+ "version": "0.18.9",
4
4
  "description": "Generate a typed server/client SDK from a Postgres schema (includes, Zod, Hono).",
5
5
  "type": "module",
6
6
  "bin": {