@lambdaorm/lib 3.5.5 → 3.5.6
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/CHANGELOG.md +10 -0
- package/README.md +61 -99
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.5.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 67cd58c: READMEs: the one of `@lambdaorm/lib` is about the library (installation, getting started, queries across databases,
|
|
8
|
+
dialects, stages), with the CLI, the Data Gateway, the client and the UI as related projects at the end; no emojis,
|
|
9
|
+
and only the npm and license badges.
|
|
10
|
+
- Updated dependencies [67cd58c]
|
|
11
|
+
- @lambdaorm/base@3.3.4
|
|
12
|
+
|
|
3
13
|
## 3.5.5
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
# λORM
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
**Write a query once. Run it on any database — from your code, a terminal, an API or an AI agent.**
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/@lambdaorm/lib)
|
|
8
|
-
[](https://hub.docker.com/r/flaviorita/data-gateway)
|
|
3
|
+
[](https://www.npmjs.com/package/@lambdaorm/lib)
|
|
9
4
|
[](https://opensource.org/licenses/MIT)
|
|
10
|
-
[](https://github.com/lambda-orm/wiki/discussions)
|
|
11
|
-
[](https://discord.com/invite/yXT6XBX2)
|
|
12
|
-
|
|
13
|
-
📖 **Documentation:** [lambda-orm.github.io/wiki](https://lambda-orm.github.io/wiki) (English, Deutsch, Español, Português)
|
|
14
5
|
|
|
15
|
-
|
|
6
|
+
**Documentation:** [lambda-orm.github.io/wiki](https://lambda-orm.github.io/wiki)
|
|
16
7
|
|
|
17
|
-
λORM is
|
|
18
|
-
|
|
8
|
+
λORM is an ORM for Node.js and TypeScript. You describe your **domain** once (entities, relations, rules) in a schema
|
|
9
|
+
and write queries as **lambda expressions** over it:
|
|
19
10
|
|
|
20
11
|
```typescript
|
|
21
12
|
Orders
|
|
@@ -24,32 +15,17 @@ Orders
|
|
|
24
15
|
```
|
|
25
16
|
|
|
26
17
|
λORM turns that query into SQL for **MySQL, MariaDB, PostgreSQL, SQL Server, Oracle and SQLite**, or into an
|
|
27
|
-
aggregation pipeline for **MongoDB
|
|
28
|
-
same query runs **from a Node library, the command line, a REST or WebSocket API, or an AI agent through MCP**.
|
|
18
|
+
aggregation pipeline for **MongoDB**, even when the entities of one query live in **different databases**.
|
|
29
19
|
|
|
30
|
-
##
|
|
31
|
-
|
|
32
|
-
- 🧩 **One domain, any database.** Your queries talk about `Orders` and `Customers`, not about tables, dialects or
|
|
33
|
-
where each entity is stored.
|
|
34
|
-
- 🌐 **One query across several databases.** Orders in MongoDB, customers in PostgreSQL, products in MySQL: one
|
|
35
|
-
query, one result. λORM splits it per source and joins the results.
|
|
36
|
-
- 🎭 **Stages.** The same domain on one SQLite in development and distributed over three engines in production —
|
|
37
|
-
or a write side and a read side ([CQRS](https://microservices.io/patterns/data/cqrs.html)) — by configuration, not
|
|
38
|
-
code.
|
|
39
|
-
- 🔌 **Every channel.** TypeScript (typed), a string, the CLI, REST, WebSocket, MCP: the same language everywhere.
|
|
40
|
-
- 🔐 **Governed access.** The [Data Gateway](https://lambda-orm.github.io/wiki/data-gateway/) publishes your schemas
|
|
41
|
-
with credentials, permissions (`read`, `write`, …) and an audit of every change — for applications, people and AI
|
|
42
|
-
agents alike.
|
|
43
|
-
- 🛠️ **Schema-first, both ways.** From a YAML to the tables (`push`), from the databases to the YAML (`pull`), or
|
|
44
|
-
from a JSON file of data to a schema, tables and rows (`incorporate`).
|
|
45
|
-
|
|
46
|
-
## Use it as a library
|
|
20
|
+
## Installation
|
|
47
21
|
|
|
48
22
|
```sh
|
|
49
23
|
npm install @lambdaorm/lib
|
|
50
24
|
npm install mysql2 # the driver of your database: mysql2, pg, tedious, oracledb, mongodb or sql.js
|
|
51
25
|
```
|
|
52
26
|
|
|
27
|
+
## Getting started
|
|
28
|
+
|
|
53
29
|
```typescript
|
|
54
30
|
import { orm } from '@lambdaorm/lib'
|
|
55
31
|
import { Orders } from './northwind/domain/model' // generated by `lambdaorm build`, or written by hand
|
|
@@ -61,12 +37,12 @@ try {
|
|
|
61
37
|
(customerId: string) => Orders.filter(p => p.customerId == customerId).include(p => p.details),
|
|
62
38
|
{ customerId: 'ALFKI' })
|
|
63
39
|
|
|
64
|
-
// …or the same query as a string (from a file, a request,
|
|
40
|
+
// …or the same query as a string (from a file, a request, a configuration)
|
|
65
41
|
const count = await orm.execute('Orders.filter(p => p.customerId == customerId).map(p => count(1))', { customerId: 'ALFKI' })
|
|
66
42
|
|
|
67
43
|
// several writes in one transaction
|
|
68
44
|
await orm.transaction({}, async tr => {
|
|
69
|
-
|
|
45
|
+
await tr.execute('Orders.insert().include(p => p.details)', newOrder)
|
|
70
46
|
await tr.execute('Products.update(p => ({ inStock: p.inStock - quantity })).filter(p => p.id == productId)', { productId: 11, quantity: 2 })
|
|
71
47
|
})
|
|
72
48
|
} finally {
|
|
@@ -79,10 +55,25 @@ needs. See [Usage](https://lambda-orm.github.io/wiki/usage/Usage/),
|
|
|
79
55
|
[Repository](https://lambda-orm.github.io/wiki/usage/Repository/) and
|
|
80
56
|
[Transaction](https://lambda-orm.github.io/wiki/usage/Transaction/).
|
|
81
57
|
|
|
58
|
+
## Why λORM
|
|
59
|
+
|
|
60
|
+
- **One domain, any database.** Your queries talk about `Orders` and `Customers`, not about tables, dialects or
|
|
61
|
+
where each entity is stored.
|
|
62
|
+
- **One query across several databases.** Orders in MongoDB, customers in PostgreSQL, products in MySQL: one query,
|
|
63
|
+
one result. λORM splits it per source and joins the results.
|
|
64
|
+
- **Stages.** The same domain on one SQLite in development and distributed over three engines in production, or a
|
|
65
|
+
write side and a read side ([CQRS](https://microservices.io/patterns/data/cqrs.html)), by configuration, not code.
|
|
66
|
+
- **Typed or as text.** A query is a TypeScript lambda checked by the compiler, or the same expression as a string.
|
|
67
|
+
- **Schema-first, both ways.** From a YAML to the tables (`push`), from the databases to the YAML (`pull`), or from a
|
|
68
|
+
JSON file of data to a schema, tables and rows (`incorporate`).
|
|
69
|
+
|
|
82
70
|
## The same query, from everywhere
|
|
83
71
|
|
|
72
|
+
The query language is the same beyond the library. Each project has its README, and the
|
|
73
|
+
[wiki](https://lambda-orm.github.io/wiki) covers the whole ecosystem.
|
|
74
|
+
|
|
84
75
|
<table>
|
|
85
|
-
<tr><td><b>Node.js / TypeScript</b
|
|
76
|
+
<tr><td><b>Node.js / TypeScript</b>: this library (<a href="https://lambda-orm.github.io/wiki/usage/Usage/">wiki</a>)</td></tr>
|
|
86
77
|
<tr><td>
|
|
87
78
|
|
|
88
79
|
```typescript
|
|
@@ -95,7 +86,7 @@ const products = await orm.execute(
|
|
|
95
86
|
```
|
|
96
87
|
|
|
97
88
|
</td></tr>
|
|
98
|
-
<tr><td><b>Command line</b
|
|
89
|
+
<tr><td><b>Command line</b>: <a href="https://github.com/lambda-orm/core/tree/main/packages/cli#readme"><code>@lambdaorm/cli</code></a> (<a href="https://lambda-orm.github.io/wiki/cli/">wiki</a>)</td></tr>
|
|
99
90
|
<tr><td>
|
|
100
91
|
|
|
101
92
|
```sh
|
|
@@ -103,7 +94,7 @@ lambdaorm execute -q "Products.filter(p => p.price > minPrice).map(p => [p.name,
|
|
|
103
94
|
```
|
|
104
95
|
|
|
105
96
|
</td></tr>
|
|
106
|
-
<tr><td><b>REST API</b
|
|
97
|
+
<tr><td><b>REST API</b>, from any language: the <a href="https://github.com/lambda-orm/core/tree/main/packages/data-gateway#readme">Data Gateway</a> (<a href="https://lambda-orm.github.io/wiki/data-gateway/Rest/">wiki</a>)</td></tr>
|
|
107
98
|
<tr><td>
|
|
108
99
|
|
|
109
100
|
```sh
|
|
@@ -121,7 +112,7 @@ products = requests.post("http://gateway:8080/northwind/execute", headers={"X-Ap
|
|
|
121
112
|
```
|
|
122
113
|
|
|
123
114
|
</td></tr>
|
|
124
|
-
<tr><td><b>Node client</b
|
|
115
|
+
<tr><td><b>Node client</b>, over REST or WebSocket: <a href="https://github.com/lambda-orm/core/tree/main/packages/client#readme"><code>@lambdaorm/client</code></a> (<a href="https://lambda-orm.github.io/wiki/data-gateway/Clients/">wiki</a>)</td></tr>
|
|
125
116
|
<tr><td>
|
|
126
117
|
|
|
127
118
|
```typescript
|
|
@@ -133,19 +124,19 @@ orm.on('schema.statusChanged', ({ status }) => console.log(status))
|
|
|
133
124
|
```
|
|
134
125
|
|
|
135
126
|
</td></tr>
|
|
136
|
-
<tr><td><b>AI agents</b>
|
|
127
|
+
<tr><td><b>AI agents</b>, through MCP: the <a href="https://github.com/lambda-orm/core/tree/main/packages/data-gateway#readme">Data Gateway</a> (<a href="https://lambda-orm.github.io/wiki/data-gateway/Mcp/">wiki</a>)</td></tr>
|
|
137
128
|
<tr><td>
|
|
138
129
|
|
|
139
130
|
```sh
|
|
140
131
|
claude mcp add --transport http northwind http://gateway:8081/northwind/mcp --header "X-Api-Key: $KEY"
|
|
141
132
|
```
|
|
142
133
|
|
|
143
|
-
> *"Which products cost more than 50?"
|
|
134
|
+
> *"Which products cost more than 50?"*: the agent reads the domain of the schema from the tools and calls
|
|
144
135
|
> `orm_execute` with `Products.filter(p => p.price > 50).map(p => [p.name, p.price])`. With a `read` credential, it
|
|
145
136
|
> can't change anything.
|
|
146
137
|
|
|
147
138
|
</td></tr>
|
|
148
|
-
<tr><td><b>The browser</b
|
|
139
|
+
<tr><td><b>The browser</b>: the UI of the Data Gateway, built with <a href="https://github.com/lambda-orm/core/tree/main/packages/ui#readme"><code>@lambdaorm/ui</code></a> (<a href="https://lambda-orm.github.io/wiki/data-gateway/Ui/">wiki</a>)</td></tr>
|
|
149
140
|
<tr><td>
|
|
150
141
|
|
|
151
142
|

|
|
@@ -195,7 +186,7 @@ Orders MongoDB Ordering aggregate [{ $match: { CustomerID: …
|
|
|
195
186
|
```
|
|
196
187
|
|
|
197
188
|
**One query per relation, never one per row:** each level reads the keys of the level above with an `IN`. When there
|
|
198
|
-
are many, the keys are split into chunks
|
|
189
|
+
are many, the keys are split into chunks (at most 999 on Oracle, 7000 on the others) that run in parallel. The
|
|
199
190
|
result is one JSON tree, as if everything were in one database.
|
|
200
191
|
|
|
201
192
|
## One query, each engine's dialect
|
|
@@ -228,8 +219,8 @@ WHERE (p.UnitPrice > :minPrice AND c.CategoryName = :category) ORDER BY p.UnitPr
|
|
|
228
219
|
|
|
229
220
|
The join is implicit (`p.category.name`), the parameters are always bound, and the property names are the domain's
|
|
230
221
|
(`price`), not the columns' (`UnitPrice`): the [mapping](https://lambda-orm.github.io/wiki/schema/SchemaDefinition/)
|
|
231
|
-
lives in the schema. The [engines lab](https://github.com/lambda-orm/core/tree/main/packages/lib/src/dev/labs/engines)
|
|
232
|
-
MariaDB, SQL Server, Oracle and MongoDB.
|
|
222
|
+
lives in the schema. The [engines lab](https://github.com/lambda-orm/core/tree/main/packages/lib/src/dev/labs/engines)
|
|
223
|
+
runs the same tests on PostgreSQL, MySQL, MariaDB, SQL Server, Oracle and MongoDB.
|
|
233
224
|
|
|
234
225
|
## Stages: the same code, another infrastructure
|
|
235
226
|
|
|
@@ -251,35 +242,10 @@ await orm.execute(query, data, { stage: 'prod' })
|
|
|
251
242
|
|
|
252
243
|
A write stage and a read stage over different databases is [CQRS by configuration](https://lambda-orm.github.io/wiki/schema/SchemaExample-MultiplesStages/).
|
|
253
244
|
|
|
254
|
-
## Governed access: the Data Gateway
|
|
255
|
-
|
|
256
|
-
The [Data Gateway](https://lambda-orm.github.io/wiki/data-gateway/) (Docker
|
|
257
|
-
[`flaviorita/data-gateway`](https://hub.docker.com/r/flaviorita/data-gateway)) publishes one or several schemas over
|
|
258
|
-
REST, WebSocket and MCP, with a web UI — no backend to write:
|
|
259
|
-
|
|
260
|
-
```yaml
|
|
261
|
-
authentication:
|
|
262
|
-
adapter: local
|
|
263
|
-
type: apikey
|
|
264
|
-
keys:
|
|
265
|
-
- { name: agent, value: $AGENT_KEY, permissions: [ read ] }
|
|
266
|
-
- { name: backend, value: $BACKEND_KEY, permissions: [ read, write, script ] }
|
|
267
|
-
transports:
|
|
268
|
-
http: { port: 8080, ui: { enabled: true } } # REST, OpenAPI, the UI
|
|
269
|
-
mcpHttp: { port: 8081 } # AI agents
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
- The same permissions on every transport: an agent with `read` can query, never write.
|
|
273
|
-
- Every write leaves an audit line: who, what, which entities, how many rows.
|
|
274
|
-
- Each schema in its own worker; Prometheus metrics, health probes for Kubernetes, rate and size limits.
|
|
275
|
-
|
|
276
|
-
**Try it in ten minutes:** [Getting started](https://lambda-orm.github.io/wiki/data-gateway/GettingStarted/), from
|
|
277
|
-
an empty folder to the REST API, the UI, MCP and WebSocket.
|
|
278
|
-
|
|
279
245
|
## And more
|
|
280
246
|
|
|
281
|
-
- **[Scripts](https://lambda-orm.github.io/wiki/usage/Script/):** a whole use case
|
|
282
|
-
several queries
|
|
247
|
+
- **[Scripts](https://lambda-orm.github.io/wiki/usage/Script/):** a whole use case (variables, conditions, loops and
|
|
248
|
+
several queries) in one transaction and one call.
|
|
283
249
|
- **[Transactions](https://lambda-orm.github.io/wiki/usage/Transaction/)** across sources and stages.
|
|
284
250
|
- **Writes with their children:** `Orders.insert().include(p => p.details)`, `bulkInsert`, `upsert`, and updates of
|
|
285
251
|
composite relations.
|
|
@@ -290,33 +256,29 @@ an empty folder to the REST API, the UI, MCP and WebSocket.
|
|
|
290
256
|
- **[Listeners](https://lambda-orm.github.io/wiki/schema/SchemaExample-Listener/), constraints, default values and
|
|
291
257
|
computed properties**, written in the same expression language.
|
|
292
258
|
|
|
293
|
-
##
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
Questions, ideas and feedback are welcome in [GitHub Discussions](https://github.com/lambda-orm/wiki/discussions);
|
|
317
|
-
issues and pull requests in [github.com/lambda-orm/core](https://github.com/lambda-orm/core) (against `develop`). Read the
|
|
318
|
-
[contribution guidelines](https://github.com/lambda-orm/wiki/blob/main/CONTRIBUTING.md). Commits follow
|
|
319
|
-
[Conventional Commits](https://www.conventionalcommits.org/).
|
|
259
|
+
## Documentation
|
|
260
|
+
|
|
261
|
+
- [Usage](https://lambda-orm.github.io/wiki/usage/Usage/)
|
|
262
|
+
- [Query language](https://lambda-orm.github.io/wiki/queries/Query-Language/)
|
|
263
|
+
- [Schema](https://lambda-orm.github.io/wiki/schema/Schema/)
|
|
264
|
+
- [Labs](https://github.com/lambda-orm/lambdaorm-labs): complete examples
|
|
265
|
+
- [Change log](CHANGELOG.md)
|
|
266
|
+
|
|
267
|
+
## Related projects
|
|
268
|
+
|
|
269
|
+
The same queries, beyond the library:
|
|
270
|
+
|
|
271
|
+
- [`@lambdaorm/cli`](https://www.npmjs.com/package/@lambdaorm/cli): the `lambdaorm` command: projects,
|
|
272
|
+
synchronization, import / export, queries and scripts from a terminal.
|
|
273
|
+
- [Data Gateway](https://lambda-orm.github.io/wiki/data-gateway/) (Docker
|
|
274
|
+
[`flaviorita/data-gateway`](https://hub.docker.com/r/flaviorita/data-gateway)): your schemas over REST, WebSocket and
|
|
275
|
+
MCP for AI agents, with a web UI, credentials, permissions and audit, for applications in any language.
|
|
276
|
+
- [`@lambdaorm/client`](https://www.npmjs.com/package/@lambdaorm/client): the interface of this library, run on a
|
|
277
|
+
Data Gateway.
|
|
278
|
+
- [`@lambdaorm/ui`](https://www.npmjs.com/package/@lambdaorm/ui): React components: the query editor, results,
|
|
279
|
+
explorer and diagrams.
|
|
280
|
+
|
|
281
|
+
Source and contributions: [github.com/lambda-orm/core](https://github.com/lambda-orm/core).
|
|
320
282
|
|
|
321
283
|
## License
|
|
322
284
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lambdaorm/lib",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.6",
|
|
4
4
|
"description": "LambdaORM core library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"3xpr": "^5.3.1",
|
|
22
|
-
"@lambdaorm/base": "^3.3.
|
|
22
|
+
"@lambdaorm/base": "^3.3.4",
|
|
23
23
|
"crypto-js": "^4.2.0",
|
|
24
24
|
"dotenv": "^16.5.0",
|
|
25
25
|
"h3lp": "^5.0.0",
|