postgresdk 0.15.2 → 0.15.4

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/README.md CHANGED
@@ -62,19 +62,6 @@ const filtered = await sdk.users.list({
62
62
 
63
63
  ## Getting Started
64
64
 
65
- ### Installation
66
-
67
- ```bash
68
- npm install -g postgresdk
69
- # or
70
- npx postgresdk generate
71
-
72
- # With Bun
73
- bun install -g postgresdk
74
- # or
75
- bunx postgresdk generate
76
- ```
77
-
78
65
  > **Note:** Currently only generates **Hono** server code. See [Supported Frameworks](#supported-frameworks) for details.
79
66
 
80
67
  ### Quick Start
@@ -82,9 +69,11 @@ bunx postgresdk generate
82
69
  1. Initialize your project:
83
70
 
84
71
  ```bash
85
- npx postgresdk init
86
- # or with Bun
87
- bunx postgresdk init
72
+ npx postgresdk@latest init
73
+ # or
74
+ bunx postgresdk@latest init
75
+ # or
76
+ pnpm dlx postgresdk@latest init
88
77
  ```
89
78
 
90
79
  This creates a `postgresdk.config.ts` file with all available options documented.
@@ -101,9 +90,11 @@ export default {
101
90
  3. Run the generator:
102
91
 
103
92
  ```bash
104
- postgresdk generate
105
- # or with Bun
106
- bunx postgresdk generate
93
+ npx postgresdk@latest generate
94
+ # or
95
+ bunx postgresdk@latest generate
96
+ # or
97
+ pnpm dlx postgresdk@latest generate
107
98
  ```
108
99
 
109
100
  4. Set up your server:
@@ -498,23 +489,17 @@ When you run `postgresdk generate`, the client SDK is automatically bundled into
498
489
 
499
490
  **On client applications:**
500
491
 
501
- 1. Install postgresdk in your client project:
492
+ 1. Pull the SDK from your API:
502
493
 
503
494
  ```bash
504
- npm install -D postgresdk
495
+ npx postgresdk@latest pull --from=https://api.myapp.com --output=./src/sdk
505
496
  # or
506
- bun install -D postgresdk
507
- ```
508
-
509
- 2. Pull the SDK from your API:
510
-
511
- ```bash
512
- npx postgresdk pull --from=https://api.myapp.com --output=./src/sdk
513
- # or with Bun
514
- bunx postgresdk pull --from=https://api.myapp.com --output=./src/sdk
497
+ bunx postgresdk@latest pull --from=https://api.myapp.com --output=./src/sdk
498
+ # or
499
+ pnpm dlx postgresdk@latest pull --from=https://api.myapp.com --output=./src/sdk
515
500
  ```
516
501
 
517
- 3. Use the generated SDK with full TypeScript types:
502
+ 2. Use the generated SDK with full TypeScript types:
518
503
 
519
504
  ```typescript
520
505
  import { SDK } from "./src/sdk";
@@ -538,9 +523,11 @@ export default {
538
523
 
539
524
  Then run:
540
525
  ```bash
541
- npx postgresdk pull
526
+ npx postgresdk@latest pull
527
+ # or
528
+ bunx postgresdk@latest pull
542
529
  # or
543
- bunx postgresdk pull
530
+ pnpm dlx postgresdk@latest pull
544
531
  ```
545
532
 
546
533
  The SDK files are written directly to your client project, giving you full TypeScript autocomplete and type safety.
@@ -588,9 +575,7 @@ const books = booksResult.data;
588
575
  const nestedResult = await sdk.authors.list({
589
576
  include: {
590
577
  books: {
591
- include: {
592
- tags: true
593
- }
578
+ tags: true
594
579
  }
595
580
  }
596
581
  });
@@ -696,7 +681,9 @@ See the generated SDK documentation for all available operators: `$eq`, `$ne`, `
696
681
  ### CLI Commands
697
682
 
698
683
  ```bash
699
- postgresdk <command> [options]
684
+ npx postgresdk@latest <command> [options]
685
+ # or: bunx postgresdk@latest
686
+ # or: pnpm dlx postgresdk@latest
700
687
 
701
688
  Commands:
702
689
  init Create a postgresdk.config.ts file
@@ -708,17 +695,18 @@ Commands:
708
695
  Options:
709
696
  -c, --config <path> Path to config file (default: postgresdk.config.ts)
710
697
 
711
- Init flags:
712
- --api Generate API-side config (for database introspection)
713
- --sdk Generate SDK-side config (for consuming remote SDK)
698
+ Init subcommands/flags:
699
+ init pull Generate pull-only config (alias for --sdk)
700
+ init --api Generate API-side config (for database introspection)
701
+ init --sdk Generate SDK-side config (for consuming remote SDK)
714
702
 
715
703
  Examples:
716
- postgresdk init # Interactive prompt
717
- postgresdk init --api # API-side config
718
- postgresdk init --sdk # SDK-side config
719
- postgresdk generate
720
- postgresdk generate -c custom.config.ts
721
- postgresdk pull --from=https://api.com --output=./src/sdk
704
+ npx postgresdk@latest init # Interactive prompt
705
+ npx postgresdk@latest init pull # Pull-only config
706
+ npx postgresdk@latest init --api # API-side config
707
+ npx postgresdk@latest generate
708
+ npx postgresdk@latest generate -c custom.config.ts
709
+ npx postgresdk@latest pull --from=https://api.com --output=./src/sdk
722
710
  ```
723
711
 
724
712
  ### Generated Tests
package/dist/cli.js CHANGED
@@ -1994,7 +1994,7 @@ async function initCommand(args) {
1994
1994
  `);
1995
1995
  const forceError = args.includes("--force-error");
1996
1996
  const isApiSide = args.includes("--api");
1997
- const isSdkSide = args.includes("--sdk");
1997
+ const isSdkSide = args.includes("--sdk") || args[0] === "pull";
1998
1998
  const configPath = resolve(process.cwd(), "postgresdk.config.ts");
1999
1999
  if (existsSync2(configPath)) {
2000
2000
  if (forceError) {
@@ -2116,7 +2116,7 @@ async function initCommand(args) {
2116
2116
  }
2117
2117
  let projectType;
2118
2118
  if (isApiSide && isSdkSide) {
2119
- console.error("❌ Error: Cannot use both --api and --sdk flags");
2119
+ console.error("❌ Error: Cannot use both --api and --sdk/pull options");
2120
2120
  process.exit(1);
2121
2121
  } else if (isApiSide) {
2122
2122
  projectType = "api";
@@ -2392,15 +2392,12 @@ async function pullCommand(args) {
2392
2392
  ...Object.fromEntries(Object.entries(cliConfig).filter(([_, v]) => v !== undefined))
2393
2393
  };
2394
2394
  if (!config.from) {
2395
- console.error("❌ Missing API URL. Specify via --from or in postgresdk.config.ts");
2395
+ console.error("❌ Missing API URL");
2396
2396
  console.error(`
2397
- Example config file:`);
2398
- console.error(`export default {
2399
- pull: {
2400
- from: "https://api.company.com",
2401
- output: "./src/sdk"
2402
- }
2403
- }`);
2397
+ Options:`);
2398
+ console.error(" 1. Use CLI args: npx postgresdk@latest pull --from=https://api.company.com --output=./src/sdk");
2399
+ console.error(" 2. Create config: npx postgresdk@latest init pull");
2400
+ console.error(" (then edit postgresdk.config.ts and run 'postgresdk pull')");
2404
2401
  process.exit(1);
2405
2402
  }
2406
2403
  console.log(`\uD83D\uDD04 Pulling SDK from ${config.from}`);
@@ -2688,7 +2685,7 @@ export function buildWith(root: TableName, spec: any, maxDepth = ${maxDepth}) {
2688
2685
  const v = s[key];
2689
2686
  if (v === true) out[key] = true;
2690
2687
  else if (v && typeof v === "object") {
2691
- const child = "include" in v ? walk(rel.target, v.include, depth + 1) : undefined;
2688
+ const child = walk(rel.target, v, depth + 1);
2692
2689
  out[key] = child ? { with: child } : true;
2693
2690
  }
2694
2691
  }
@@ -3581,7 +3578,7 @@ export async function loadIncludes(
3581
3578
  for (const r of rows) r[key] = [];
3582
3579
  }
3583
3580
  // Recurse if nested include specified
3584
- const childSpec = s[key] && typeof s[key] === "object" ? (s[key] as any).include : undefined;
3581
+ const childSpec = s[key] && typeof s[key] === "object" ? s[key] : undefined;
3585
3582
  if (childSpec) {
3586
3583
  const children = rows.flatMap(r => (r[key] ?? []));
3587
3584
  try {
@@ -3601,7 +3598,7 @@ export async function loadIncludes(
3601
3598
  log.error("loadOneToMany failed", { table, key, target }, e?.message ?? e);
3602
3599
  for (const r of rows) r[key] = [];
3603
3600
  }
3604
- const childSpec = s[key] && typeof s[key] === "object" ? (s[key] as any).include : undefined;
3601
+ const childSpec = s[key] && typeof s[key] === "object" ? s[key] : undefined;
3605
3602
  if (childSpec) {
3606
3603
  const children = rows.flatMap(r => (r[key] ?? []));
3607
3604
  try {
@@ -3630,7 +3627,7 @@ export async function loadIncludes(
3630
3627
  for (const r of rows) r[key] = null;
3631
3628
  }
3632
3629
  }
3633
- const childSpec = s[key] && typeof s[key] === "object" ? (s[key] as any).include : undefined;
3630
+ const childSpec = s[key] && typeof s[key] === "object" ? s[key] : undefined;
3634
3631
  if (childSpec) {
3635
3632
  const children = rows.map(r => r[key]).filter(Boolean);
3636
3633
  try {
package/dist/index.js CHANGED
@@ -1862,7 +1862,7 @@ export function buildWith(root: TableName, spec: any, maxDepth = ${maxDepth}) {
1862
1862
  const v = s[key];
1863
1863
  if (v === true) out[key] = true;
1864
1864
  else if (v && typeof v === "object") {
1865
- const child = "include" in v ? walk(rel.target, v.include, depth + 1) : undefined;
1865
+ const child = walk(rel.target, v, depth + 1);
1866
1866
  out[key] = child ? { with: child } : true;
1867
1867
  }
1868
1868
  }
@@ -2755,7 +2755,7 @@ export async function loadIncludes(
2755
2755
  for (const r of rows) r[key] = [];
2756
2756
  }
2757
2757
  // Recurse if nested include specified
2758
- const childSpec = s[key] && typeof s[key] === "object" ? (s[key] as any).include : undefined;
2758
+ const childSpec = s[key] && typeof s[key] === "object" ? s[key] : undefined;
2759
2759
  if (childSpec) {
2760
2760
  const children = rows.flatMap(r => (r[key] ?? []));
2761
2761
  try {
@@ -2775,7 +2775,7 @@ export async function loadIncludes(
2775
2775
  log.error("loadOneToMany failed", { table, key, target }, e?.message ?? e);
2776
2776
  for (const r of rows) r[key] = [];
2777
2777
  }
2778
- const childSpec = s[key] && typeof s[key] === "object" ? (s[key] as any).include : undefined;
2778
+ const childSpec = s[key] && typeof s[key] === "object" ? s[key] : undefined;
2779
2779
  if (childSpec) {
2780
2780
  const children = rows.flatMap(r => (r[key] ?? []));
2781
2781
  try {
@@ -2804,7 +2804,7 @@ export async function loadIncludes(
2804
2804
  for (const r of rows) r[key] = null;
2805
2805
  }
2806
2806
  }
2807
- const childSpec = s[key] && typeof s[key] === "object" ? (s[key] as any).include : undefined;
2807
+ const childSpec = s[key] && typeof s[key] === "object" ? s[key] : undefined;
2808
2808
  if (childSpec) {
2809
2809
  const children = rows.map(r => r[key]).filter(Boolean);
2810
2810
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresdk",
3
- "version": "0.15.2",
3
+ "version": "0.15.4",
4
4
  "description": "Generate a typed server/client SDK from a Postgres schema (includes, Zod, Hono).",
5
5
  "type": "module",
6
6
  "bin": {