postgresdk 0.9.1 → 0.9.3

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.
Files changed (3) hide show
  1. package/dist/cli.js +22 -14
  2. package/dist/index.js +22 -14
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -602,8 +602,12 @@ function generateIncludeMethods(table, graph, opts, allTables) {
602
602
  continue;
603
603
  const [key1, edge1] = entry1;
604
604
  const [key2, edge2] = entry2;
605
- if (opts.skipJunctionTables && (edge1.target.includes("_") || edge2.target.includes("_"))) {
606
- continue;
605
+ if (opts.skipJunctionTables && allTables) {
606
+ const table1 = allTables.find((t) => t.name === edge1.target);
607
+ const table2 = allTables.find((t) => t.name === edge2.target);
608
+ if (table1 && isJunctionTable(table1) || table2 && isJunctionTable(table2)) {
609
+ continue;
610
+ }
607
611
  }
608
612
  const combinedPath = [key1, key2];
609
613
  const combinedSuffix = `With${pascal(key1)}And${pascal(key2)}`;
@@ -4159,18 +4163,6 @@ async function generate(configPath) {
4159
4163
  content: emitHonoRouter(Object.values(model.tables), !!normalizedAuth?.strategy && normalizedAuth.strategy !== "none", cfg.useJsExtensions)
4160
4164
  });
4161
4165
  }
4162
- const clientFiles = files.filter((f) => {
4163
- return f.path.includes(clientDir);
4164
- });
4165
- files.push({
4166
- path: join(serverDir, "sdk-bundle.ts"),
4167
- content: emitSdkBundle(clientFiles, clientDir)
4168
- });
4169
- const contractCode = emitUnifiedContract(model, cfg);
4170
- files.push({
4171
- path: join(serverDir, "contract.ts"),
4172
- content: contractCode
4173
- });
4174
4166
  const { generateUnifiedContract: generateUnifiedContract2, generateUnifiedContractMarkdown: generateUnifiedContractMarkdown2 } = await Promise.resolve().then(() => (init_emit_sdk_contract(), exports_emit_sdk_contract));
4175
4167
  if (process.env.SDK_DEBUG) {
4176
4168
  console.log(`[Index] Model has ${Object.keys(model.tables || {}).length} tables before contract generation`);
@@ -4180,6 +4172,22 @@ async function generate(configPath) {
4180
4172
  path: join(serverDir, "CONTRACT.md"),
4181
4173
  content: generateUnifiedContractMarkdown2(contract)
4182
4174
  });
4175
+ files.push({
4176
+ path: join(clientDir, "CONTRACT.md"),
4177
+ content: generateUnifiedContractMarkdown2(contract)
4178
+ });
4179
+ const contractCode = emitUnifiedContract(model, cfg, graph);
4180
+ files.push({
4181
+ path: join(serverDir, "contract.ts"),
4182
+ content: contractCode
4183
+ });
4184
+ const clientFiles = files.filter((f) => {
4185
+ return f.path.includes(clientDir);
4186
+ });
4187
+ files.push({
4188
+ path: join(serverDir, "sdk-bundle.ts"),
4189
+ content: emitSdkBundle(clientFiles, clientDir)
4190
+ });
4183
4191
  if (generateTests) {
4184
4192
  console.log("\uD83E\uDDEA Generating tests...");
4185
4193
  const relativeClientPath = relative(testDir, clientDir);
package/dist/index.js CHANGED
@@ -601,8 +601,12 @@ function generateIncludeMethods(table, graph, opts, allTables) {
601
601
  continue;
602
602
  const [key1, edge1] = entry1;
603
603
  const [key2, edge2] = entry2;
604
- if (opts.skipJunctionTables && (edge1.target.includes("_") || edge2.target.includes("_"))) {
605
- continue;
604
+ if (opts.skipJunctionTables && allTables) {
605
+ const table1 = allTables.find((t) => t.name === edge1.target);
606
+ const table2 = allTables.find((t) => t.name === edge2.target);
607
+ if (table1 && isJunctionTable(table1) || table2 && isJunctionTable(table2)) {
608
+ continue;
609
+ }
606
610
  }
607
611
  const combinedPath = [key1, key2];
608
612
  const combinedSuffix = `With${pascal(key1)}And${pascal(key2)}`;
@@ -3896,18 +3900,6 @@ async function generate(configPath) {
3896
3900
  content: emitHonoRouter(Object.values(model.tables), !!normalizedAuth?.strategy && normalizedAuth.strategy !== "none", cfg.useJsExtensions)
3897
3901
  });
3898
3902
  }
3899
- const clientFiles = files.filter((f) => {
3900
- return f.path.includes(clientDir);
3901
- });
3902
- files.push({
3903
- path: join(serverDir, "sdk-bundle.ts"),
3904
- content: emitSdkBundle(clientFiles, clientDir)
3905
- });
3906
- const contractCode = emitUnifiedContract(model, cfg);
3907
- files.push({
3908
- path: join(serverDir, "contract.ts"),
3909
- content: contractCode
3910
- });
3911
3903
  const { generateUnifiedContract: generateUnifiedContract2, generateUnifiedContractMarkdown: generateUnifiedContractMarkdown2 } = await Promise.resolve().then(() => (init_emit_sdk_contract(), exports_emit_sdk_contract));
3912
3904
  if (process.env.SDK_DEBUG) {
3913
3905
  console.log(`[Index] Model has ${Object.keys(model.tables || {}).length} tables before contract generation`);
@@ -3917,6 +3909,22 @@ async function generate(configPath) {
3917
3909
  path: join(serverDir, "CONTRACT.md"),
3918
3910
  content: generateUnifiedContractMarkdown2(contract)
3919
3911
  });
3912
+ files.push({
3913
+ path: join(clientDir, "CONTRACT.md"),
3914
+ content: generateUnifiedContractMarkdown2(contract)
3915
+ });
3916
+ const contractCode = emitUnifiedContract(model, cfg, graph);
3917
+ files.push({
3918
+ path: join(serverDir, "contract.ts"),
3919
+ content: contractCode
3920
+ });
3921
+ const clientFiles = files.filter((f) => {
3922
+ return f.path.includes(clientDir);
3923
+ });
3924
+ files.push({
3925
+ path: join(serverDir, "sdk-bundle.ts"),
3926
+ content: emitSdkBundle(clientFiles, clientDir)
3927
+ });
3920
3928
  if (generateTests) {
3921
3929
  console.log("\uD83E\uDDEA Generating tests...");
3922
3930
  const relativeClientPath = relative(testDir, clientDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresdk",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "Generate a typed server/client SDK from a Postgres schema (includes, Zod, Hono).",
5
5
  "type": "module",
6
6
  "bin": {