@dbsp/adapter-pgsql 1.0.0
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/LICENSE +21 -0
- package/README.md +68 -0
- package/dist/index.d.ts +2154 -0
- package/dist/index.js +16240 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Olivier Orabona
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @dbsp/adapter-pgsql
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@dbsp/adapter-pgsql)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
PostgreSQL adapter for `@dbsp/core` — compiles semantic plan reports to parameterized SQL and executes against a `pg.Pool`.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add @dbsp/adapter-pgsql pg
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { createOrm } from '@dbsp/core';
|
|
18
|
+
import { createPgsqlAdapter } from '@dbsp/adapter-pgsql';
|
|
19
|
+
import { Pool } from 'pg';
|
|
20
|
+
|
|
21
|
+
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
|
22
|
+
|
|
23
|
+
const orm = createOrm({
|
|
24
|
+
schema: db,
|
|
25
|
+
adapter: createPgsqlAdapter(pool),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const rows = await orm.select('users').where(eq('active', true)).all();
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Compile-only mode
|
|
32
|
+
|
|
33
|
+
Compile SQL without a database connection — useful for CLI tooling, CI plan inspection, and testing:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { createOrm, eq } from '@dbsp/core';
|
|
37
|
+
import { createPgsqlCompileOnlyAdapter } from '@dbsp/adapter-pgsql';
|
|
38
|
+
|
|
39
|
+
const adapter = createPgsqlCompileOnlyAdapter();
|
|
40
|
+
const orm = createOrm({ schema: db, adapter });
|
|
41
|
+
const { sql, params } = orm.select('users').where(eq('active', true)).dump();
|
|
42
|
+
// sql, params — no Pool needed
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Key features
|
|
46
|
+
|
|
47
|
+
- **Parameterized queries** — All user values use `$N` positional parameters; no SQL injection surface
|
|
48
|
+
- **Identifier quoting** — All table/column/schema names are double-quoted automatically
|
|
49
|
+
- **AST-based compiler** — SQL is built from the plan AST, never from string templates
|
|
50
|
+
- **DDL provisioning** — `compareSchemata()` + `generateDDL()` with 12-phase topological sort
|
|
51
|
+
- **Schema migrations** — `generateMigrationSQL()` with UP/DOWN sections and destructive-change safety gate
|
|
52
|
+
- **Schema introspection** — Reflect live database structure back into `ModelIR`
|
|
53
|
+
- **Row-Level Security** — `rlsEnabled` + `policies[]` on `TableIR`, compiled to `CREATE POLICY` DDL
|
|
54
|
+
- **Streaming & cursors** — `orm.select(...).stream()` and server-side cursor support
|
|
55
|
+
- **Indexes** — Create/drop/list indexes including GIN, HNSW, BM25 via `orm.tables.<name>.indexes`
|
|
56
|
+
- **Runtime DDL helpers** — `truncate()`, `vacuum()`, `storageSize()`, `alterColumn()`
|
|
57
|
+
- **Multi-tenant** — Respects `orm.withSchema(schemaName)` for all operations
|
|
58
|
+
|
|
59
|
+
## Documentation
|
|
60
|
+
|
|
61
|
+
- [Guides](https://oorabona.github.io/db-semantic-planner/guide/)
|
|
62
|
+
- [DDL helpers guide](https://oorabona.github.io/db-semantic-planner/guide/ddl-helpers)
|
|
63
|
+
- [RLS policies guide](https://oorabona.github.io/db-semantic-planner/guide/rls-policies)
|
|
64
|
+
- [Schema versioning guide](https://oorabona.github.io/db-semantic-planner/guide/schema-versioning)
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT
|