postgresdk 0.18.14 → 0.18.15

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
@@ -2915,7 +2915,7 @@ function emitIncludeSpec(graph) {
2915
2915
  out += ` ${relKey}?: boolean | { select?: string[]; exclude?: string[]; include?: ${toPascal(edge.target)}IncludeSpec; limit?: number; offset?: number; orderBy?: string; order?: "asc" | "desc"; };
2916
2916
  `;
2917
2917
  } else {
2918
- out += ` ${relKey}?: boolean | { select?: string[]; exclude?: string[]; } | ${toPascal(edge.target)}IncludeSpec;
2918
+ out += ` ${relKey}?: boolean | { select?: string[]; exclude?: string[]; include?: ${toPascal(edge.target)}IncludeSpec; };
2919
2919
  `;
2920
2920
  }
2921
2921
  }
@@ -3686,9 +3686,13 @@ function emitClient(table, graph, opts, model) {
3686
3686
  } else if (pattern.type === "nested" && pattern.nestedKey) {
3687
3687
  const key = pattern.nestedKey;
3688
3688
  const paramName = includeParamNames[0];
3689
+ const nestedValue = pattern.nestedValue;
3690
+ const requiredIncludes = Object.entries(nestedValue).map(([k, v]) => `${k}: ${JSON.stringify(v)}`).join(", ");
3689
3691
  transformCode = `
3690
3692
  const { ${destructure} } = params ?? {};
3691
- const includeSpec = ${paramName} ? { ${key}: ${paramName} } : ${JSON.stringify(method.includeSpec)};`;
3693
+ const includeSpec = { ${key}: ${paramName}
3694
+ ? { ...${paramName}, include: { ${requiredIncludes}, ...${paramName}.include } }
3695
+ : ${JSON.stringify(nestedValue)} };`;
3692
3696
  }
3693
3697
  } else {
3694
3698
  transformCode = `
@@ -3735,9 +3739,13 @@ function emitClient(table, graph, opts, model) {
3735
3739
  } else if (pattern.type === "nested" && pattern.nestedKey) {
3736
3740
  const key = pattern.nestedKey;
3737
3741
  const paramName = includeParamNames[0];
3742
+ const nestedValue = pattern.nestedValue;
3743
+ const requiredIncludes = Object.entries(nestedValue).map(([k, v]) => `${k}: ${JSON.stringify(v)}`).join(", ");
3738
3744
  transformCode = `
3739
3745
  const { ${destructure}, ...baseParams } = params ?? {};
3740
- const includeSpec = ${paramName} ? { ${key}: ${paramName} } : ${JSON.stringify(method.includeSpec)};
3746
+ const includeSpec = { ${key}: ${paramName}
3747
+ ? { ...${paramName}, include: { ${requiredIncludes}, ...${paramName}.include } }
3748
+ : ${JSON.stringify(nestedValue)} };
3741
3749
  return this.post<${method.returnType}>(\`\${this.resource}/list\`, { ...baseParams, include: includeSpec });`;
3742
3750
  }
3743
3751
  } else {
@@ -4762,9 +4770,15 @@ export async function loadIncludes(
4762
4770
  // Could be belongs-to (current has FK to target) OR has-one (target unique-FK to current)
4763
4771
  const specValue = s[key];
4764
4772
  const options: RelationOptions = {};
4773
+ let childSpec: any = undefined;
4774
+
4765
4775
  if (specValue && typeof specValue === "object" && specValue !== true) {
4766
4776
  if (specValue.select !== undefined) options.select = specValue.select;
4767
4777
  if (specValue.exclude !== undefined) options.exclude = specValue.exclude;
4778
+ // Support { include: TargetIncludeSpec } — mirrors the many/via handler
4779
+ if (specValue.include !== undefined) {
4780
+ childSpec = specValue.include;
4781
+ }
4768
4782
  }
4769
4783
 
4770
4784
  const currFks = (FK_INDEX as any)[table] as Array<{from:string[];toTable:string;to:string[]}>;
@@ -4784,7 +4798,7 @@ export async function loadIncludes(
4784
4798
  for (const r of rows) r[key] = null;
4785
4799
  }
4786
4800
  }
4787
- const childSpec = s[key] && typeof s[key] === "object" ? s[key] : undefined;
4801
+
4788
4802
  if (childSpec) {
4789
4803
  const children = rows.map(r => r[key]).filter(Boolean);
4790
4804
  try {
package/dist/index.js CHANGED
@@ -1954,7 +1954,7 @@ function emitIncludeSpec(graph) {
1954
1954
  out += ` ${relKey}?: boolean | { select?: string[]; exclude?: string[]; include?: ${toPascal(edge.target)}IncludeSpec; limit?: number; offset?: number; orderBy?: string; order?: "asc" | "desc"; };
1955
1955
  `;
1956
1956
  } else {
1957
- out += ` ${relKey}?: boolean | { select?: string[]; exclude?: string[]; } | ${toPascal(edge.target)}IncludeSpec;
1957
+ out += ` ${relKey}?: boolean | { select?: string[]; exclude?: string[]; include?: ${toPascal(edge.target)}IncludeSpec; };
1958
1958
  `;
1959
1959
  }
1960
1960
  }
@@ -2725,9 +2725,13 @@ function emitClient(table, graph, opts, model) {
2725
2725
  } else if (pattern.type === "nested" && pattern.nestedKey) {
2726
2726
  const key = pattern.nestedKey;
2727
2727
  const paramName = includeParamNames[0];
2728
+ const nestedValue = pattern.nestedValue;
2729
+ const requiredIncludes = Object.entries(nestedValue).map(([k, v]) => `${k}: ${JSON.stringify(v)}`).join(", ");
2728
2730
  transformCode = `
2729
2731
  const { ${destructure} } = params ?? {};
2730
- const includeSpec = ${paramName} ? { ${key}: ${paramName} } : ${JSON.stringify(method.includeSpec)};`;
2732
+ const includeSpec = { ${key}: ${paramName}
2733
+ ? { ...${paramName}, include: { ${requiredIncludes}, ...${paramName}.include } }
2734
+ : ${JSON.stringify(nestedValue)} };`;
2731
2735
  }
2732
2736
  } else {
2733
2737
  transformCode = `
@@ -2774,9 +2778,13 @@ function emitClient(table, graph, opts, model) {
2774
2778
  } else if (pattern.type === "nested" && pattern.nestedKey) {
2775
2779
  const key = pattern.nestedKey;
2776
2780
  const paramName = includeParamNames[0];
2781
+ const nestedValue = pattern.nestedValue;
2782
+ const requiredIncludes = Object.entries(nestedValue).map(([k, v]) => `${k}: ${JSON.stringify(v)}`).join(", ");
2777
2783
  transformCode = `
2778
2784
  const { ${destructure}, ...baseParams } = params ?? {};
2779
- const includeSpec = ${paramName} ? { ${key}: ${paramName} } : ${JSON.stringify(method.includeSpec)};
2785
+ const includeSpec = { ${key}: ${paramName}
2786
+ ? { ...${paramName}, include: { ${requiredIncludes}, ...${paramName}.include } }
2787
+ : ${JSON.stringify(nestedValue)} };
2780
2788
  return this.post<${method.returnType}>(\`\${this.resource}/list\`, { ...baseParams, include: includeSpec });`;
2781
2789
  }
2782
2790
  } else {
@@ -3801,9 +3809,15 @@ export async function loadIncludes(
3801
3809
  // Could be belongs-to (current has FK to target) OR has-one (target unique-FK to current)
3802
3810
  const specValue = s[key];
3803
3811
  const options: RelationOptions = {};
3812
+ let childSpec: any = undefined;
3813
+
3804
3814
  if (specValue && typeof specValue === "object" && specValue !== true) {
3805
3815
  if (specValue.select !== undefined) options.select = specValue.select;
3806
3816
  if (specValue.exclude !== undefined) options.exclude = specValue.exclude;
3817
+ // Support { include: TargetIncludeSpec } — mirrors the many/via handler
3818
+ if (specValue.include !== undefined) {
3819
+ childSpec = specValue.include;
3820
+ }
3807
3821
  }
3808
3822
 
3809
3823
  const currFks = (FK_INDEX as any)[table] as Array<{from:string[];toTable:string;to:string[]}>;
@@ -3823,7 +3837,7 @@ export async function loadIncludes(
3823
3837
  for (const r of rows) r[key] = null;
3824
3838
  }
3825
3839
  }
3826
- const childSpec = s[key] && typeof s[key] === "object" ? s[key] : undefined;
3840
+
3827
3841
  if (childSpec) {
3828
3842
  const children = rows.map(r => r[key]).filter(Boolean);
3829
3843
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresdk",
3
- "version": "0.18.14",
3
+ "version": "0.18.15",
4
4
  "description": "Generate a typed server/client SDK from a Postgres schema (includes, Zod, Hono).",
5
5
  "type": "module",
6
6
  "bin": {