postgresdk 0.15.3 → 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 +33 -43
- package/dist/cli.js +7 -10
- package/package.json +1 -1
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
|
|
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
|
|
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.
|
|
492
|
+
1. Pull the SDK from your API:
|
|
502
493
|
|
|
503
494
|
```bash
|
|
504
|
-
|
|
495
|
+
npx postgresdk@latest pull --from=https://api.myapp.com --output=./src/sdk
|
|
505
496
|
# or
|
|
506
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
@@ -694,7 +681,9 @@ See the generated SDK documentation for all available operators: `$eq`, `$ne`, `
|
|
|
694
681
|
### CLI Commands
|
|
695
682
|
|
|
696
683
|
```bash
|
|
697
|
-
postgresdk <command> [options]
|
|
684
|
+
npx postgresdk@latest <command> [options]
|
|
685
|
+
# or: bunx postgresdk@latest
|
|
686
|
+
# or: pnpm dlx postgresdk@latest
|
|
698
687
|
|
|
699
688
|
Commands:
|
|
700
689
|
init Create a postgresdk.config.ts file
|
|
@@ -706,17 +695,18 @@ Commands:
|
|
|
706
695
|
Options:
|
|
707
696
|
-c, --config <path> Path to config file (default: postgresdk.config.ts)
|
|
708
697
|
|
|
709
|
-
Init flags:
|
|
710
|
-
|
|
711
|
-
--
|
|
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)
|
|
712
702
|
|
|
713
703
|
Examples:
|
|
714
|
-
postgresdk init # Interactive prompt
|
|
715
|
-
postgresdk init
|
|
716
|
-
postgresdk init --
|
|
717
|
-
postgresdk generate
|
|
718
|
-
postgresdk generate -c custom.config.ts
|
|
719
|
-
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
|
|
720
710
|
```
|
|
721
711
|
|
|
722
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
|
|
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
|
|
2395
|
+
console.error("❌ Missing API URL");
|
|
2396
2396
|
console.error(`
|
|
2397
|
-
|
|
2398
|
-
console.error(
|
|
2399
|
-
|
|
2400
|
-
|
|
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}`);
|