postgresdk 0.5.1-alpha.0 → 0.5.1-alpha.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/dist/cli.js CHANGED
@@ -579,11 +579,17 @@ export default {
579
579
  // serverFramework: "hono",
580
580
 
581
581
  /**
582
- * Use .js extensions in imports (for Vercel Edge, Deno, etc.)
582
+ * Use .js extensions in server imports (for Vercel Edge, Deno, etc.)
583
583
  * @default false
584
584
  */
585
585
  // useJsExtensions: false,
586
586
 
587
+ /**
588
+ * Use .js extensions in client SDK imports (rarely needed)
589
+ * @default false
590
+ */
591
+ // useJsExtensionsClient: false,
592
+
587
593
  // ========== AUTHENTICATION ==========
588
594
 
589
595
  /**
@@ -1185,17 +1191,18 @@ ${hasAuth ? `
1185
1191
  }
1186
1192
 
1187
1193
  // src/emit-client.ts
1188
- function emitClient(table) {
1194
+ function emitClient(table, useJsExtensions) {
1189
1195
  const Type = pascal(table.name);
1196
+ const ext = useJsExtensions ? ".js" : "";
1190
1197
  const pkCols = Array.isArray(table.pk) ? table.pk : table.pk ? [table.pk] : [];
1191
1198
  const safePk = pkCols.length ? pkCols : ["id"];
1192
1199
  const hasCompositePk = safePk.length > 1;
1193
1200
  const pkType = hasCompositePk ? `{ ${safePk.map((c) => `${c}: string`).join("; ")} }` : `string`;
1194
1201
  const pkPathExpr = hasCompositePk ? safePk.map((c) => `pk.${c}`).join(` + "/" + `) : `pk`;
1195
1202
  return `/* Generated. Do not edit. */
1196
- import { BaseClient } from "./base-client";
1197
- import type { ${Type}IncludeSpec } from "./include-spec";
1198
- import type { Insert${Type}, Update${Type}, Select${Type} } from "./types/${table.name}";
1203
+ import { BaseClient } from "./base-client${ext}";
1204
+ import type { ${Type}IncludeSpec } from "./include-spec${ext}";
1205
+ import type { Insert${Type}, Update${Type}, Select${Type} } from "./types/${table.name}${ext}";
1199
1206
 
1200
1207
  /**
1201
1208
  * Client for ${table.name} table operations
@@ -1235,19 +1242,20 @@ export class ${Type}Client extends BaseClient {
1235
1242
  }
1236
1243
  `;
1237
1244
  }
1238
- function emitClientIndex(tables) {
1245
+ function emitClientIndex(tables, useJsExtensions) {
1246
+ const ext = useJsExtensions ? ".js" : "";
1239
1247
  let out = `/* Generated. Do not edit. */
1240
1248
  `;
1241
- out += `import { BaseClient, type AuthConfig } from "./base-client";
1249
+ out += `import { BaseClient, type AuthConfig } from "./base-client${ext}";
1242
1250
  `;
1243
1251
  for (const t of tables) {
1244
- out += `import { ${pascal(t.name)}Client } from "./${t.name}";
1252
+ out += `import { ${pascal(t.name)}Client } from "./${t.name}${ext}";
1245
1253
  `;
1246
1254
  }
1247
1255
  out += `
1248
1256
  // Re-export auth types for convenience
1249
1257
  `;
1250
- out += `export type { AuthConfig as SDKAuth, AuthConfig, HeaderMap, AuthHeadersProvider } from "./base-client";
1258
+ out += `export type { AuthConfig as SDKAuth, AuthConfig, HeaderMap, AuthHeadersProvider } from "./base-client${ext}";
1251
1259
 
1252
1260
  `;
1253
1261
  out += `/**
@@ -1279,18 +1287,18 @@ function emitClientIndex(tables) {
1279
1287
  out += `// Export individual table clients
1280
1288
  `;
1281
1289
  for (const t of tables) {
1282
- out += `export { ${pascal(t.name)}Client } from "./${t.name}";
1290
+ out += `export { ${pascal(t.name)}Client } from "./${t.name}${ext}";
1283
1291
  `;
1284
1292
  }
1285
1293
  out += `
1286
1294
  // Export base client for custom extensions
1287
1295
  `;
1288
- out += `export { BaseClient } from "./base-client";
1296
+ out += `export { BaseClient } from "./base-client${ext}";
1289
1297
  `;
1290
1298
  out += `
1291
1299
  // Export include specifications
1292
1300
  `;
1293
- out += `export * from "./include-spec";
1301
+ out += `export * from "./include-spec${ext}";
1294
1302
  `;
1295
1303
  return out;
1296
1304
  }
@@ -2076,7 +2084,7 @@ ${registrations.replace(/router/g, "app")}
2076
2084
  ${reExports}
2077
2085
 
2078
2086
  // Re-export types and schemas for convenience
2079
- export * from "./include-spec";
2087
+ export * from "./include-spec${ext}";
2080
2088
  `;
2081
2089
  }
2082
2090
 
@@ -2431,12 +2439,12 @@ async function generate(configPath) {
2431
2439
  });
2432
2440
  files.push({
2433
2441
  path: join(clientDir, `${table.name}.ts`),
2434
- content: emitClient(table)
2442
+ content: emitClient(table, cfg.useJsExtensionsClient)
2435
2443
  });
2436
2444
  }
2437
2445
  files.push({
2438
2446
  path: join(clientDir, "index.ts"),
2439
- content: emitClientIndex(Object.values(model.tables))
2447
+ content: emitClientIndex(Object.values(model.tables), cfg.useJsExtensionsClient)
2440
2448
  });
2441
2449
  if (serverFramework === "hono") {
2442
2450
  files.push({
@@ -1,3 +1,3 @@
1
1
  import type { Table } from "./introspect";
2
- export declare function emitClient(table: Table): string;
3
- export declare function emitClientIndex(tables: Table[]): string;
2
+ export declare function emitClient(table: Table, useJsExtensions?: boolean): string;
3
+ export declare function emitClientIndex(tables: Table[], useJsExtensions?: boolean): string;
package/dist/index.js CHANGED
@@ -933,17 +933,18 @@ ${hasAuth ? `
933
933
  }
934
934
 
935
935
  // src/emit-client.ts
936
- function emitClient(table) {
936
+ function emitClient(table, useJsExtensions) {
937
937
  const Type = pascal(table.name);
938
+ const ext = useJsExtensions ? ".js" : "";
938
939
  const pkCols = Array.isArray(table.pk) ? table.pk : table.pk ? [table.pk] : [];
939
940
  const safePk = pkCols.length ? pkCols : ["id"];
940
941
  const hasCompositePk = safePk.length > 1;
941
942
  const pkType = hasCompositePk ? `{ ${safePk.map((c) => `${c}: string`).join("; ")} }` : `string`;
942
943
  const pkPathExpr = hasCompositePk ? safePk.map((c) => `pk.${c}`).join(` + "/" + `) : `pk`;
943
944
  return `/* Generated. Do not edit. */
944
- import { BaseClient } from "./base-client";
945
- import type { ${Type}IncludeSpec } from "./include-spec";
946
- import type { Insert${Type}, Update${Type}, Select${Type} } from "./types/${table.name}";
945
+ import { BaseClient } from "./base-client${ext}";
946
+ import type { ${Type}IncludeSpec } from "./include-spec${ext}";
947
+ import type { Insert${Type}, Update${Type}, Select${Type} } from "./types/${table.name}${ext}";
947
948
 
948
949
  /**
949
950
  * Client for ${table.name} table operations
@@ -983,19 +984,20 @@ export class ${Type}Client extends BaseClient {
983
984
  }
984
985
  `;
985
986
  }
986
- function emitClientIndex(tables) {
987
+ function emitClientIndex(tables, useJsExtensions) {
988
+ const ext = useJsExtensions ? ".js" : "";
987
989
  let out = `/* Generated. Do not edit. */
988
990
  `;
989
- out += `import { BaseClient, type AuthConfig } from "./base-client";
991
+ out += `import { BaseClient, type AuthConfig } from "./base-client${ext}";
990
992
  `;
991
993
  for (const t of tables) {
992
- out += `import { ${pascal(t.name)}Client } from "./${t.name}";
994
+ out += `import { ${pascal(t.name)}Client } from "./${t.name}${ext}";
993
995
  `;
994
996
  }
995
997
  out += `
996
998
  // Re-export auth types for convenience
997
999
  `;
998
- out += `export type { AuthConfig as SDKAuth, AuthConfig, HeaderMap, AuthHeadersProvider } from "./base-client";
1000
+ out += `export type { AuthConfig as SDKAuth, AuthConfig, HeaderMap, AuthHeadersProvider } from "./base-client${ext}";
999
1001
 
1000
1002
  `;
1001
1003
  out += `/**
@@ -1027,18 +1029,18 @@ function emitClientIndex(tables) {
1027
1029
  out += `// Export individual table clients
1028
1030
  `;
1029
1031
  for (const t of tables) {
1030
- out += `export { ${pascal(t.name)}Client } from "./${t.name}";
1032
+ out += `export { ${pascal(t.name)}Client } from "./${t.name}${ext}";
1031
1033
  `;
1032
1034
  }
1033
1035
  out += `
1034
1036
  // Export base client for custom extensions
1035
1037
  `;
1036
- out += `export { BaseClient } from "./base-client";
1038
+ out += `export { BaseClient } from "./base-client${ext}";
1037
1039
  `;
1038
1040
  out += `
1039
1041
  // Export include specifications
1040
1042
  `;
1041
- out += `export * from "./include-spec";
1043
+ out += `export * from "./include-spec${ext}";
1042
1044
  `;
1043
1045
  return out;
1044
1046
  }
@@ -1824,7 +1826,7 @@ ${registrations.replace(/router/g, "app")}
1824
1826
  ${reExports}
1825
1827
 
1826
1828
  // Re-export types and schemas for convenience
1827
- export * from "./include-spec";
1829
+ export * from "./include-spec${ext}";
1828
1830
  `;
1829
1831
  }
1830
1832
 
@@ -2179,12 +2181,12 @@ async function generate(configPath) {
2179
2181
  });
2180
2182
  files.push({
2181
2183
  path: join(clientDir, `${table.name}.ts`),
2182
- content: emitClient(table)
2184
+ content: emitClient(table, cfg.useJsExtensionsClient)
2183
2185
  });
2184
2186
  }
2185
2187
  files.push({
2186
2188
  path: join(clientDir, "index.ts"),
2187
- content: emitClientIndex(Object.values(model.tables))
2189
+ content: emitClientIndex(Object.values(model.tables), cfg.useJsExtensionsClient)
2188
2190
  });
2189
2191
  if (serverFramework === "hono") {
2190
2192
  files.push({
package/dist/types.d.ts CHANGED
@@ -30,6 +30,7 @@ export interface Config {
30
30
  auth?: AuthConfigInput;
31
31
  pull?: PullConfig;
32
32
  useJsExtensions?: boolean;
33
+ useJsExtensionsClient?: boolean;
33
34
  }
34
35
  export interface PullConfig {
35
36
  from: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresdk",
3
- "version": "0.5.1-alpha.0",
3
+ "version": "0.5.1-alpha.1",
4
4
  "description": "Generate a typed server/client SDK from a Postgres schema (includes, Zod, Hono).",
5
5
  "type": "module",
6
6
  "bin": {