@dbsp/core 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 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,69 @@
1
+ # @dbsp/core
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@dbsp/core.svg)](https://www.npmjs.com/package/@dbsp/core)
4
+ [![license](https://img.shields.io/npm/l/@dbsp/core.svg)](LICENSE)
5
+
6
+ Intent-first semantic query planner for databases. Declare what you want, let the planner decide how — with full type safety and observability.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ pnpm add @dbsp/core @dbsp/adapter-pgsql
12
+ ```
13
+
14
+ ## Quick Start
15
+
16
+ ```typescript
17
+ import { schema, ref, createOrm, eq } from '@dbsp/core';
18
+ import { createPgsqlAdapter } from '@dbsp/adapter-pgsql';
19
+ import { Pool } from 'pg';
20
+
21
+ // 1. Define schema
22
+ const db = schema({
23
+ users: { id: 'uuid', name: 'string', email: 'string', active: 'boolean' },
24
+ posts: { id: 'uuid', title: 'string', authorId: ref('users') },
25
+ });
26
+
27
+ // 2. Create ORM
28
+ const orm = createOrm({
29
+ schema: db,
30
+ adapter: createPgsqlAdapter(new Pool({ connectionString: process.env.DATABASE_URL })),
31
+ });
32
+
33
+ // 3. Query
34
+ const users = await orm.select('users').where(eq('active', true)).all();
35
+
36
+ // 4. Inspect the plan
37
+ const dump = await orm.select('users').where(eq('active', true)).dump();
38
+ console.log(dump.sql); // SELECT "id", "name", "email", "active" FROM "users" WHERE "active" = $1
39
+ console.log(dump.params); // [true]
40
+ console.log(dump.plan); // PlanReport with decisions + reasoning
41
+ ```
42
+
43
+ ## Key features
44
+
45
+ - **Intent-first** — Declare what to fetch; the planner decides JOIN vs EXISTS, aliasing, CTE extraction
46
+ - **Type-safe** — Full TypeScript inference from schema definition to query result types
47
+ - **Observable** — Every query exposes `dump()` returning plan decisions, SQL, and bound parameters
48
+ - **Deterministic** — Same inputs always produce the same SQL and plan (stable aliasing)
49
+ - **Multi-tenant** — `orm.withSchema('tenant_123')` for schema-per-tenant isolation
50
+ - **Expression primitives** — `op()`, `fn()`, `ref()`, `cast()`, `caseWhen()`, vector distances, ParadeDB full-text
51
+ - **Set operations** — `union()`, `unionAll()`, `intersect()`, `except()`
52
+ - **Subqueries** — Scalar subqueries, `inSubquery()`, correlated EXISTS
53
+ - **Joins** — Relation-based includes, manual `join()` with custom `ON` clauses
54
+ - **Mutations** — Insert, update, upsert, delete with type-safe builders
55
+
56
+ ## Adapter interface
57
+
58
+ `@dbsp/core` defines the `Adapter` port; concrete implementations live in separate packages (e.g. `@dbsp/adapter-pgsql`). The core is fully database-agnostic.
59
+
60
+ ## Documentation
61
+
62
+ - [Guides](https://oorabona.github.io/db-semantic-planner/guide/)
63
+ - [Expression primitives guide](https://oorabona.github.io/db-semantic-planner/guide/expression-primitives)
64
+ - [Joins guide](https://oorabona.github.io/db-semantic-planner/guide/joins)
65
+ - [DDL helpers guide](https://oorabona.github.io/db-semantic-planner/guide/ddl-helpers)
66
+
67
+ ## License
68
+
69
+ MIT