@cossackframework/database 0.8.2 → 0.9.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/README.md +6 -7
- package/agent-docs.json +90 -0
- package/dist/adapter/types.d.ts +14 -1
- package/dist/adapter/types.d.ts.map +1 -1
- package/dist/config.d.ts +10 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/cossack/cache-policy.d.ts +18 -0
- package/dist/cossack/cache-policy.d.ts.map +1 -0
- package/dist/cossack/cache-policy.js +64 -0
- package/dist/cossack/cache-policy.js.map +1 -0
- package/dist/cossack/index.d.ts +21 -3
- package/dist/cossack/index.d.ts.map +1 -1
- package/dist/cossack/index.js +115 -61
- package/dist/cossack/index.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/metadata/finalize.d.ts.map +1 -1
- package/dist/metadata/finalize.js +22 -5
- package/dist/metadata/finalize.js.map +1 -1
- package/dist/metadata/inspection.d.ts +51 -0
- package/dist/metadata/inspection.d.ts.map +1 -0
- package/dist/metadata/inspection.js +19 -0
- package/dist/metadata/inspection.js.map +1 -0
- package/dist/migration/plan.d.ts +13 -0
- package/dist/migration/plan.d.ts.map +1 -0
- package/dist/migration/plan.js +73 -0
- package/dist/migration/plan.js.map +1 -0
- package/dist/migration/runner.d.ts +14 -3
- package/dist/migration/runner.d.ts.map +1 -1
- package/dist/migration/runner.js +157 -23
- package/dist/migration/runner.js.map +1 -1
- package/dist/migration/types.d.ts +42 -2
- package/dist/migration/types.d.ts.map +1 -1
- package/dist/orm.d.ts +51 -0
- package/dist/orm.d.ts.map +1 -1
- package/dist/orm.js +44 -11
- package/dist/orm.js.map +1 -1
- package/dist/query/builder.d.ts +3 -2
- package/dist/query/builder.d.ts.map +1 -1
- package/dist/query/builder.js +63 -12
- package/dist/query/builder.js.map +1 -1
- package/dist/query/diagnostics.d.ts +3 -0
- package/dist/query/diagnostics.d.ts.map +1 -0
- package/dist/query/diagnostics.js +75 -0
- package/dist/query/diagnostics.js.map +1 -0
- package/dist/runtime/cloudflare-turso.d.ts +29 -0
- package/dist/runtime/cloudflare-turso.d.ts.map +1 -0
- package/dist/runtime/cloudflare-turso.js +47 -0
- package/dist/runtime/cloudflare-turso.js.map +1 -0
- package/dist/runtime/cloudflare.d.ts +1 -26
- package/dist/runtime/cloudflare.d.ts.map +1 -1
- package/dist/runtime/cloudflare.js +4 -45
- package/dist/runtime/cloudflare.js.map +1 -1
- package/dist/runtime/node.d.ts +2 -0
- package/dist/runtime/node.d.ts.map +1 -1
- package/dist/runtime/node.js +6 -1
- package/dist/runtime/node.js.map +1 -1
- package/dist/runtime/turso.d.ts +5 -1
- package/dist/runtime/turso.d.ts.map +1 -1
- package/dist/runtime/turso.js +19 -5
- package/dist/runtime/turso.js.map +1 -1
- package/dist/runtime-capabilities.d.ts +25 -0
- package/dist/runtime-capabilities.d.ts.map +1 -0
- package/dist/runtime-capabilities.js +17 -0
- package/dist/runtime-capabilities.js.map +1 -0
- package/dist/schema/builder.d.ts.map +1 -1
- package/dist/schema/builder.js +6 -10
- package/dist/schema/builder.js.map +1 -1
- package/dist/schema/ddl.d.ts.map +1 -1
- package/dist/schema/ddl.js +29 -5
- package/dist/schema/ddl.js.map +1 -1
- package/dist/schema/introspection.d.ts +3 -1
- package/dist/schema/introspection.d.ts.map +1 -1
- package/dist/schema/introspection.js +9 -7
- package/dist/schema/introspection.js.map +1 -1
- package/dist/seeding/runner.d.ts +5 -1
- package/dist/seeding/runner.d.ts.map +1 -1
- package/dist/seeding/runner.js +66 -1
- package/dist/seeding/runner.js.map +1 -1
- package/dist/seeding/types.d.ts +15 -1
- package/dist/seeding/types.d.ts.map +1 -1
- package/dist/seeding/types.js.map +1 -1
- package/dist/sql/client.d.ts +1 -1
- package/dist/sql/client.d.ts.map +1 -1
- package/dist/sql/client.js +10 -51
- package/dist/sql/client.js.map +1 -1
- package/dist/sql/node-client.d.ts +7 -0
- package/dist/sql/node-client.d.ts.map +1 -0
- package/dist/sql/node-client.js +61 -0
- package/dist/sql/node-client.js.map +1 -0
- package/dist/tooling/cloudflare.d.ts +61 -0
- package/dist/tooling/cloudflare.d.ts.map +1 -0
- package/dist/tooling/cloudflare.js +130 -0
- package/dist/tooling/cloudflare.js.map +1 -0
- package/dist/tooling/format-error.d.ts +3 -0
- package/dist/tooling/format-error.d.ts.map +1 -0
- package/dist/tooling/format-error.js +22 -0
- package/dist/tooling/format-error.js.map +1 -0
- package/dist/tooling/generate.d.ts.map +1 -1
- package/dist/tooling/generate.js +5 -15
- package/dist/tooling/generate.js.map +1 -1
- package/dist/tooling/index.d.ts +6 -2
- package/dist/tooling/index.d.ts.map +1 -1
- package/dist/tooling/index.js +232 -64
- package/dist/tooling/index.js.map +1 -1
- package/dist/tooling/inspection.d.ts +40 -0
- package/dist/tooling/inspection.d.ts.map +1 -0
- package/dist/tooling/inspection.js +63 -0
- package/dist/tooling/inspection.js.map +1 -0
- package/dist/tooling/process-json.d.ts +4 -0
- package/dist/tooling/process-json.d.ts.map +1 -0
- package/dist/tooling/process-json.js +79 -0
- package/dist/tooling/process-json.js.map +1 -0
- package/docs/comparison.md +22 -22
- package/docs/inspection.md +50 -0
- package/docs/installation.md +0 -2
- package/docs/introduction.md +2 -2
- package/docs/migrations.md +91 -2
- package/docs/queries.md +19 -1
- package/docs/raw-queries.md +19 -4
- package/docs/relationships.md +11 -0
- package/docs/runtimes.md +77 -36
- package/docs/seeders.md +38 -0
- package/package.json +8 -7
- package/dist/runtime/deno.d.ts +0 -38
- package/dist/runtime/deno.d.ts.map +0 -1
- package/dist/runtime/deno.js +0 -57
- package/dist/runtime/deno.js.map +0 -1
package/docs/runtimes.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Runtimes
|
|
3
|
-
description: Configure runtime adapters, custom drivers, and multiple database connections across Node.js, Bun,
|
|
3
|
+
description: Configure runtime adapters, custom drivers, and multiple database connections across Node.js, Bun, and Workers.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Runtimes
|
|
@@ -10,11 +10,10 @@ eagerly include Node built-ins, native SQLite packages, or unused drivers.
|
|
|
10
10
|
|
|
11
11
|
| Runtime entry | Adapters |
|
|
12
12
|
| --- | --- |
|
|
13
|
-
| `@cossackframework/database/node` | Node SQLite, better-sqlite3, PostgreSQL, MySQL, Turso |
|
|
14
|
-
| `@cossackframework/database/deno` | Turso embedded SQLite, PostgreSQL, MySQL, remote Turso, or an injected driver |
|
|
13
|
+
| `@cossackframework/database/node` | Node SQLite, better-sqlite3, PostgreSQL, MySQL, Turso, automatic `SQL` client |
|
|
15
14
|
| `@cossackframework/database/bun` | Native Bun SQL for SQLite, PostgreSQL, MySQL |
|
|
16
15
|
| `@cossackframework/database/cloudflare` | D1 and Hyperdrive PostgreSQL/MySQL |
|
|
17
|
-
| `@cossackframework/database/
|
|
16
|
+
| `@cossackframework/database/cloudflare-turso` | Remote Turso for Workers |
|
|
18
17
|
| `@cossackframework/database/adapter` | Public contracts for custom adapters |
|
|
19
18
|
|
|
20
19
|
## Node.js
|
|
@@ -83,7 +82,7 @@ Turso (choose the client matching the connection):
|
|
|
83
82
|
|
|
84
83
|
```sh
|
|
85
84
|
pnpm add @tursodatabase/database # embedded SQLite / Desktop
|
|
86
|
-
pnpm add @tursodatabase/serverless # remote Turso
|
|
85
|
+
pnpm add @tursodatabase/serverless # remote Turso
|
|
87
86
|
```
|
|
88
87
|
|
|
89
88
|
```ts
|
|
@@ -97,6 +96,10 @@ const adapter = await turso({
|
|
|
97
96
|
});
|
|
98
97
|
```
|
|
99
98
|
|
|
99
|
+
Workers that use remote Turso should import `turso` from
|
|
100
|
+
`@cossackframework/database/cloudflare-turso`. Keeping that optional provider in
|
|
101
|
+
its own entry lets a D1-only Worker bundle without the Turso client installed.
|
|
102
|
+
|
|
100
103
|
Node adapters install `AsyncLocalStorage` request scopes automatically.
|
|
101
104
|
|
|
102
105
|
## Bun
|
|
@@ -135,16 +138,19 @@ by that client.
|
|
|
135
138
|
Create the adapter from a D1 binding:
|
|
136
139
|
|
|
137
140
|
```ts
|
|
141
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
138
142
|
import { createORM } from "@cossackframework/database";
|
|
139
143
|
import { d1 } from "@cossackframework/database/cloudflare";
|
|
144
|
+
import { createAsyncLocalScope } from "@cossackframework/database/adapter";
|
|
140
145
|
|
|
141
146
|
interface Env {
|
|
142
147
|
DB: D1Database;
|
|
143
148
|
}
|
|
144
149
|
|
|
145
150
|
export async function createRequestORM(env: Env) {
|
|
151
|
+
const adapter = await d1(env.DB);
|
|
146
152
|
return createORM({
|
|
147
|
-
adapter:
|
|
153
|
+
adapter: { ...adapter, scope: createAsyncLocalScope(new AsyncLocalStorage()) },
|
|
148
154
|
entities,
|
|
149
155
|
});
|
|
150
156
|
}
|
|
@@ -158,11 +164,46 @@ does not emulate them unsafely.
|
|
|
158
164
|
Migration schema operations and migration bookkeeping are submitted in one D1
|
|
159
165
|
batch. General callback-based transactions remain unsupported.
|
|
160
166
|
|
|
161
|
-
The
|
|
167
|
+
The application factory adds async-local request scoping through `node:async_hooks`.
|
|
168
|
+
Generated Cloudflare applications include this scope. Enable
|
|
162
169
|
the Workers compatibility support required by the deployment's compatibility
|
|
163
170
|
date, such as
|
|
164
171
|
[`nodejs_als`](https://developers.cloudflare.com/workers/runtime-apis/nodejs/asynclocalstorage/).
|
|
165
172
|
|
|
173
|
+
`ormMiddleware()` owns databases created by its request factory. Component RPC
|
|
174
|
+
streams retain these databases until completion, failure, or cancellation. The
|
|
175
|
+
framework captures the SQL scope when it creates the response, so Active Record
|
|
176
|
+
and global `sql` calls can run between yielded values. Ordinary responses close
|
|
177
|
+
their owned ORM when middleware finishes. Caller-owned ORM instances remain
|
|
178
|
+
the caller's responsibility.
|
|
179
|
+
|
|
180
|
+
### D1 tooling
|
|
181
|
+
|
|
182
|
+
Keep tooling separate from the request adapter. Generated D1 applications use:
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
import type { ORMToolingContext } from "@cossackframework/database";
|
|
186
|
+
import { createD1ToolingAdapter } from "@cossackframework/database/tooling";
|
|
187
|
+
|
|
188
|
+
export function createToolingAdapter(context: ORMToolingContext) {
|
|
189
|
+
return createD1ToolingAdapter(context, { binding: "DB" });
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The helper resolves Wrangler from the application and uses its configuration
|
|
194
|
+
parser. Local tooling disables remote bindings and shares the application's
|
|
195
|
+
`.wrangler/state/v3` storage used by Wrangler and the Cloudflare Vite plugin.
|
|
196
|
+
Remote tooling forces the selected D1 binding to use the remote resource,
|
|
197
|
+
requires a real `database_id`, and closes the proxy when the ORM closes. The
|
|
198
|
+
helper does not provision a remote database. JSON results include the selected
|
|
199
|
+
account ID, environment, binding and D1 identity when Wrangler provides them;
|
|
200
|
+
they never include credential values.
|
|
201
|
+
|
|
202
|
+
Named environments use their own binding declarations. Missing environments
|
|
203
|
+
fail instead of falling back to production. CLI and Studio share this binding
|
|
204
|
+
discovery through `readD1ToolingBindings()`. These exports are Node tooling;
|
|
205
|
+
Worker request code continues to import `d1()` from the Cloudflare entry.
|
|
206
|
+
|
|
166
207
|
## Cloudflare Hyperdrive
|
|
167
208
|
|
|
168
209
|
PostgreSQL through Hyperdrive:
|
|
@@ -198,35 +239,6 @@ clients and release them deterministically. Enable `nodejs_compat` for the
|
|
|
198
239
|
official `pg` and `mysql2` drivers. See Cloudflare's
|
|
199
240
|
[Hyperdrive driver guidance](https://developers.cloudflare.com/hyperdrive/).
|
|
200
241
|
|
|
201
|
-
## Deno
|
|
202
|
-
|
|
203
|
-
Deno accepts an injected driver rather than importing a specific database
|
|
204
|
-
library into the neutral package:
|
|
205
|
-
|
|
206
|
-
```ts
|
|
207
|
-
import { createORM } from "@cossackframework/database";
|
|
208
|
-
import {
|
|
209
|
-
deno,
|
|
210
|
-
type InjectedDenoDriver,
|
|
211
|
-
} from "@cossackframework/database/deno";
|
|
212
|
-
|
|
213
|
-
declare const driver: InjectedDenoDriver;
|
|
214
|
-
|
|
215
|
-
const orm = createORM({
|
|
216
|
-
adapter: deno(driver),
|
|
217
|
-
entities,
|
|
218
|
-
});
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
The injected driver declares its dialect, executes parameterized statements,
|
|
222
|
-
normalizes rows affected and insert IDs, and optionally supplies transactions.
|
|
223
|
-
An application can also inject a runtime-appropriate `ScopeStorage`.
|
|
224
|
-
|
|
225
|
-
Deno can connect through npm-compatible PostgreSQL/MySQL clients or an
|
|
226
|
-
application-provided SQLite driver. See Deno's
|
|
227
|
-
[database connection guide](https://docs.deno.com/examples/connecting_to_databases_tutorial/)
|
|
228
|
-
for runtime permissions and driver choices.
|
|
229
|
-
|
|
230
242
|
## Custom Runtime
|
|
231
243
|
|
|
232
244
|
Cossack ORM does not require runtime support to live in this package. A custom
|
|
@@ -424,3 +436,32 @@ if (orm.driver.capabilities.transactions) {
|
|
|
424
436
|
|
|
425
437
|
Capabilities include transactions, savepoints, returning clauses, batches,
|
|
426
438
|
connection reservation, cancellation, parameter limits, and batch limits.
|
|
439
|
+
|
|
440
|
+
## Provider capabilities
|
|
441
|
+
|
|
442
|
+
`orm.inspectCapabilities()` returns frozen driver declarations, including provider,
|
|
443
|
+
dialect, transaction modes, schema operations, generated values, returning support,
|
|
444
|
+
connection reservation, cancellation, and parameter/batch limits. These facts do
|
|
445
|
+
not establish remote connectivity or a server version. Custom drivers must declare
|
|
446
|
+
accurate limits and implement the advertised methods.
|
|
447
|
+
|
|
448
|
+
| Operation | SQLite / embedded Turso | PostgreSQL | MySQL | D1 |
|
|
449
|
+
| --- | --- | --- | --- | --- |
|
|
450
|
+
| Interactive transactions | Yes | Yes | Yes | No |
|
|
451
|
+
| Nested savepoints | Yes | Yes | Yes | No |
|
|
452
|
+
| Transactional DDL rollback | Yes | Yes | No | No |
|
|
453
|
+
| Generated increment key | Integer primary key | Identity column | AUTO_INCREMENT | Integer primary key |
|
|
454
|
+
| Explicit generated identity | No | Yes | No | No |
|
|
455
|
+
| Direct column type alteration | No | Yes | Yes | No |
|
|
456
|
+
|
|
457
|
+
UUID generation happens in the client. PostgreSQL and MySQL column alterations
|
|
458
|
+
support type changes only; changes to defaults or constraints need explicit SQL.
|
|
459
|
+
SQLite type changes need a table-rebuild migration. Schema queues compile every
|
|
460
|
+
operation before execution, so unsupported later operations cannot publish earlier
|
|
461
|
+
DDL. MySQL DDL can implicitly commit and must not be described as rollback-safe.
|
|
462
|
+
|
|
463
|
+
D1 supports its driver's atomic batch facility, not interactive callbacks or
|
|
464
|
+
nested transactions. Remote Turso and injected drivers use their own declared
|
|
465
|
+
capabilities. Unsupported interactive/nested operations reject before entering the
|
|
466
|
+
callback. Queries over the declared parameter limit reject before driver execution.
|
|
467
|
+
Unsupported generated identity and native array metadata reject during ORM setup.
|
package/docs/seeders.md
CHANGED
|
@@ -182,6 +182,44 @@ Avoid random identifiers for records that must not be duplicated. Keep
|
|
|
182
182
|
production-only or destructive data policies in the application/framework CLI,
|
|
183
183
|
where environment and confirmation information is available.
|
|
184
184
|
|
|
185
|
+
## Preview seeders
|
|
186
|
+
|
|
187
|
+
Preview selected seeders without executing their callbacks:
|
|
188
|
+
|
|
189
|
+
```sh
|
|
190
|
+
pnpm exec cossack seeder run --only users --env staging --target remote --dry-run --json
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The result reports selected seeders, ordered statements, affected objects,
|
|
194
|
+
parameter counts, risk, target identity and transaction limitations. Callbacks are
|
|
195
|
+
never invoked during planning. A callback seeder reports `complete: false`; an
|
|
196
|
+
empty SQL list does not imply that its eventual callback makes no changes.
|
|
197
|
+
|
|
198
|
+
For a complete plan, declare SQL fragments instead of a callback:
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
import { defineSeeder, sql } from "@cossackframework/database";
|
|
202
|
+
|
|
203
|
+
export const settings = defineSeeder({
|
|
204
|
+
name: "settings",
|
|
205
|
+
transaction: "required",
|
|
206
|
+
operations: [sql.fragment`INSERT INTO settings (key, value) VALUES (${"theme"}, ${"system"})`],
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Declared `operations` are authoritative for execution as well as planning; a
|
|
211
|
+
`run` callback on the same definition is not executed. A required transaction on
|
|
212
|
+
an unsupported provider produces an incomplete plan. Statements without an
|
|
213
|
+
interactive transaction run individually and can leave partial changes on failure.
|
|
214
|
+
Parameter values stay private; raw SQL object discovery remains incomplete.
|
|
215
|
+
|
|
216
|
+
`await runner.applyPlan(await runner.plan())` applies a plan returned by that
|
|
217
|
+
live runner after rechecking its target and definitions. Plans use detached
|
|
218
|
+
statement/parameter snapshots. A copied or deserialized JSON report is not an
|
|
219
|
+
executable plan. Seeders have no applied-history ledger and remain rerunnable;
|
|
220
|
+
planning does not prove that data-dependent SQL is safe or idempotent.
|
|
221
|
+
`seed list` reads registration metadata without constructing an adapter.
|
|
222
|
+
|
|
185
223
|
## Framework integration
|
|
186
224
|
|
|
187
225
|
A framework should:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cossackframework/database",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Serverless-first Active Record ORM for Cossack",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"files": [
|
|
24
24
|
"dist",
|
|
25
25
|
"docs",
|
|
26
|
+
"agent-docs.json",
|
|
26
27
|
"README.md",
|
|
27
28
|
"LICENSE"
|
|
28
29
|
],
|
|
@@ -47,9 +48,9 @@
|
|
|
47
48
|
"types": "./dist/runtime/cloudflare.d.ts",
|
|
48
49
|
"import": "./dist/runtime/cloudflare.js"
|
|
49
50
|
},
|
|
50
|
-
"./
|
|
51
|
-
"types": "./dist/runtime/
|
|
52
|
-
"import": "./dist/runtime/
|
|
51
|
+
"./cloudflare-turso": {
|
|
52
|
+
"types": "./dist/runtime/cloudflare-turso.d.ts",
|
|
53
|
+
"import": "./dist/runtime/cloudflare-turso.js"
|
|
53
54
|
},
|
|
54
55
|
"./cossack": {
|
|
55
56
|
"types": "./dist/cossack/index.d.ts",
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
"@tursodatabase/database": "^0.7.2",
|
|
73
74
|
"@tursodatabase/serverless": "^1.4.0",
|
|
74
75
|
"better-sqlite3": ">=11",
|
|
75
|
-
"hono": "^4.
|
|
76
|
+
"hono": "^4.13.7",
|
|
76
77
|
"mysql2": ">=3.11",
|
|
77
78
|
"pg": ">=8.13",
|
|
78
79
|
"reflect-metadata": ">=0.2"
|
|
@@ -99,10 +100,10 @@
|
|
|
99
100
|
},
|
|
100
101
|
"devDependencies": {
|
|
101
102
|
"@types/node": "^22.19.0",
|
|
102
|
-
"hono": "^4.
|
|
103
|
+
"hono": "^4.13.7",
|
|
103
104
|
"reflect-metadata": "^0.2.2",
|
|
104
105
|
"typescript": "^7.0.2",
|
|
105
|
-
"vitest": "^4.1.
|
|
106
|
+
"vitest": "^4.1.11"
|
|
106
107
|
},
|
|
107
108
|
"scripts": {
|
|
108
109
|
"build": "tsc -p tsconfig.build.json",
|
package/dist/runtime/deno.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { Adapter, Driver, QueryOperation, QueryResult, ScopeStorage } from "../adapter/types.js";
|
|
2
|
-
import type { CompiledQuery } from "../sql/fragment.js";
|
|
3
|
-
import { type TursoEmbeddedOptions } from "./turso.js";
|
|
4
|
-
export { turso, type TursoOptions, type TursoEmbeddedOptions, type TursoRemoteOptions } from "./turso.js";
|
|
5
|
-
export interface InjectedDenoDriver {
|
|
6
|
-
readonly dialect: "sqlite" | "postgres" | "mysql";
|
|
7
|
-
execute<Row = Record<string, unknown>>(text: string, parameters: readonly unknown[]): Promise<{
|
|
8
|
-
readonly rows: readonly Row[];
|
|
9
|
-
readonly rowsAffected?: number;
|
|
10
|
-
readonly lastInsertId?: string | number | bigint;
|
|
11
|
-
}>;
|
|
12
|
-
transaction?<T>(callback: (driver: InjectedDenoDriver) => Promise<T>): Promise<T>;
|
|
13
|
-
close(): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
declare class DenoDriver implements Driver {
|
|
16
|
-
private readonly injected;
|
|
17
|
-
readonly dialect: "mysql" | "postgres" | "sqlite";
|
|
18
|
-
readonly capabilities: import("../adapter/types.js").DriverCapabilities;
|
|
19
|
-
constructor(injected: InjectedDenoDriver);
|
|
20
|
-
execute<Row = Record<string, unknown>>(query: CompiledQuery, operation?: QueryOperation): Promise<QueryResult<Row>>;
|
|
21
|
-
transaction<T>(callback: (driver: Driver) => Promise<T>): Promise<T>;
|
|
22
|
-
close(): Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
export declare function deno(driver: InjectedDenoDriver, options?: {
|
|
25
|
-
readonly scope?: ScopeStorage<unknown>;
|
|
26
|
-
}): Adapter;
|
|
27
|
-
/** Local SQLite-compatible Turso Database engine for Deno and desktop. */
|
|
28
|
-
export interface DenoSQLiteOptions {
|
|
29
|
-
readonly filename?: string;
|
|
30
|
-
readonly encryption?: TursoEmbeddedOptions["encryption"];
|
|
31
|
-
}
|
|
32
|
-
export declare function denoSQLite(options?: DenoSQLiteOptions): Promise<Adapter>;
|
|
33
|
-
/** PostgreSQL adapter with per-request AsyncLocalStorage scoping. */
|
|
34
|
-
export declare function postgres(options: string | Readonly<Record<string, unknown>>): Promise<Adapter>;
|
|
35
|
-
/** MySQL adapter with per-request AsyncLocalStorage scoping. */
|
|
36
|
-
export declare function mysql(options: string | Readonly<Record<string, unknown>>): Promise<Adapter>;
|
|
37
|
-
export { DenoDriver };
|
|
38
|
-
//# sourceMappingURL=deno.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deno.d.ts","sourceRoot":"","sources":["../../src/runtime/deno.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AE,aAAa,EACpB,SAAS,GAAE,cAAsB,GAChC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAU3B;IAED,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAGnE;IAED,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAErB;CACF;AAED,wBAAgB,IAAI,CAClB,MAAM,EAAE,kBAAkB,EAC1B,OAAO,GAAE;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAA;CAAO,GACvD,OAAO,CAKT;AAED,0EAA0E;AAC1E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAC;CAC1D;AACD,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAK5E;AAED,qEAAqE;AACrE,wBAAgB,QAAQ,CACtB,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAClD,OAAO,CAAC,OAAO,CAAC,CAElB;AAED,gEAAgE;AAChE,wBAAgB,KAAK,CACnB,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAClD,OAAO,CAAC,OAAO,CAAC,CAElB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/runtime/deno.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { capabilities, meta } from "./helpers.js";
|
|
2
|
-
import { postgres as nodePostgres, mysql as nodeMySQL, } from "./node.js";
|
|
3
|
-
import { turso } from "./turso.js";
|
|
4
|
-
export { turso } from "./turso.js";
|
|
5
|
-
class DenoDriver {
|
|
6
|
-
constructor(injected) {
|
|
7
|
-
this.injected = injected;
|
|
8
|
-
this.dialect = injected.dialect;
|
|
9
|
-
this.capabilities = capabilities({
|
|
10
|
-
transactions: Boolean(injected.transaction),
|
|
11
|
-
returning: injected.dialect !== "mysql",
|
|
12
|
-
reserveConnection: false,
|
|
13
|
-
parameterLimit: injected.dialect === "sqlite" ? 999 : 65_535,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
async execute(query, operation = "raw") {
|
|
17
|
-
const start = performance.now();
|
|
18
|
-
const result = await this.injected.execute(query.text, query.parameters);
|
|
19
|
-
return {
|
|
20
|
-
rows: result.rows,
|
|
21
|
-
meta: meta(this.dialect, operation, start, {
|
|
22
|
-
rowsAffected: result.rowsAffected ?? 0,
|
|
23
|
-
...(result.lastInsertId === undefined ? {} : { lastInsertId: result.lastInsertId }),
|
|
24
|
-
}),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
transaction(callback) {
|
|
28
|
-
if (!this.injected.transaction)
|
|
29
|
-
throw new Error("The injected Deno driver does not support transactions.");
|
|
30
|
-
return this.injected.transaction((transaction) => callback(new DenoDriver(transaction)));
|
|
31
|
-
}
|
|
32
|
-
close() {
|
|
33
|
-
return this.injected.close();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export function deno(driver, options = {}) {
|
|
37
|
-
return {
|
|
38
|
-
driver: new DenoDriver(driver),
|
|
39
|
-
...(options.scope === undefined ? {} : { scope: options.scope }),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export function denoSQLite(options = {}) {
|
|
43
|
-
return turso({
|
|
44
|
-
path: options.filename ?? ":memory:",
|
|
45
|
-
...(options.encryption ? { encryption: options.encryption } : {}),
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/** PostgreSQL adapter with per-request AsyncLocalStorage scoping. */
|
|
49
|
-
export function postgres(options) {
|
|
50
|
-
return nodePostgres(options);
|
|
51
|
-
}
|
|
52
|
-
/** MySQL adapter with per-request AsyncLocalStorage scoping. */
|
|
53
|
-
export function mysql(options) {
|
|
54
|
-
return nodeMySQL(options);
|
|
55
|
-
}
|
|
56
|
-
export { DenoDriver };
|
|
57
|
-
//# sourceMappingURL=deno.js.map
|
package/dist/runtime/deno.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deno.js","sourceRoot":"","sources":["../../src/runtime/deno.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EACL,QAAQ,IAAI,YAAY,EACxB,KAAK,IAAI,SAAS,GACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,KAAK,EAA6B,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAyE,MAAM,YAAY,CAAC;AAgB1G,MAAM,UAAU;IAId,YAA6B,QAA4B;wBAA5B,QAAQ;QACnC,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;YAC/B,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;YAC3C,SAAS,EAAE,QAAQ,CAAC,OAAO,KAAK,OAAO;YACvC,iBAAiB,EAAE,KAAK;YACxB,cAAc,EAAE,QAAQ,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM;SAC7D,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CACX,KAAoB,EACpB,SAAS,GAAmB,KAAK;QAEjC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAM,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9E,OAAO;YACL,IAAI,EAAE,MAAM,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