turbine-orm 0.19.1 → 0.21.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 +156 -24
- package/dist/adapters/cockroachdb.js +4 -9
- package/dist/cjs/adapters/cockroachdb.js +4 -9
- package/dist/cjs/cli/index.js +23 -12
- package/dist/cjs/cli/observe-ui.js +12 -2
- package/dist/cjs/cli/observe.js +6 -7
- package/dist/cjs/cli/studio-ui.generated.js +1 -1
- package/dist/cjs/cli/studio.js +6 -37
- package/dist/cjs/client.js +45 -33
- package/dist/cjs/dialect.js +116 -0
- package/dist/cjs/errors.js +19 -1
- package/dist/cjs/generate.js +4 -0
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/introspect.js +20 -0
- package/dist/cjs/mssql.js +1338 -0
- package/dist/cjs/mysql.js +1052 -0
- package/dist/cjs/query/builder.js +408 -122
- package/dist/cjs/query/utils.js +1 -0
- package/dist/cjs/sqlite.js +849 -0
- package/dist/cjs/typed-sql.js +9 -7
- package/dist/cli/index.js +23 -12
- package/dist/cli/migrate.d.ts +2 -2
- package/dist/cli/observe-ui.d.ts +1 -1
- package/dist/cli/observe-ui.js +12 -2
- package/dist/cli/observe.js +7 -8
- package/dist/cli/studio-ui.generated.js +1 -1
- package/dist/cli/studio.d.ts +0 -10
- package/dist/cli/studio.js +7 -37
- package/dist/client.d.ts +35 -14
- package/dist/client.js +46 -34
- package/dist/dialect.d.ts +258 -1
- package/dist/dialect.js +83 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.js +17 -0
- package/dist/generate.js +4 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/introspect.d.ts +18 -0
- package/dist/introspect.js +19 -0
- package/dist/mssql.d.ts +233 -0
- package/dist/mssql.js +1298 -0
- package/dist/mysql.d.ts +174 -0
- package/dist/mysql.js +1012 -0
- package/dist/query/builder.d.ts +105 -6
- package/dist/query/builder.js +409 -123
- package/dist/query/index.d.ts +2 -2
- package/dist/query/types.d.ts +62 -12
- package/dist/query/utils.js +1 -0
- package/dist/sqlite.d.ts +144 -0
- package/dist/sqlite.js +842 -0
- package/dist/typed-sql.d.ts +7 -5
- package/dist/typed-sql.js +9 -7
- package/package.json +32 -3
package/dist/typed-sql.d.ts
CHANGED
|
@@ -48,17 +48,19 @@
|
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
50
|
import type { PgCompatPool } from './client.js';
|
|
51
|
+
import { type Dialect } from './dialect.js';
|
|
51
52
|
/**
|
|
52
53
|
* Build a `(sql, params)` pair from a tagged-template invocation.
|
|
53
54
|
*
|
|
54
|
-
* Each interpolated value is replaced by a positional
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
55
|
+
* Each interpolated value is replaced by a positional placeholder (the active
|
|
56
|
+
* dialect's `paramPlaceholder`, `$N` for PostgreSQL) and pushed to the params
|
|
57
|
+
* array in order. The static string segments are the only thing concatenated
|
|
58
|
+
* into the SQL text. This is the single point that guarantees parameterization
|
|
59
|
+
* for the entire typed-SQL surface.
|
|
58
60
|
*
|
|
59
61
|
* Exported for unit testing the parameterization invariant without a database.
|
|
60
62
|
*/
|
|
61
|
-
export declare function buildTypedSql(strings: TemplateStringsArray, values: readonly unknown[]): {
|
|
63
|
+
export declare function buildTypedSql(strings: TemplateStringsArray, values: readonly unknown[], dialect?: Pick<Dialect, 'paramPlaceholder'>): {
|
|
62
64
|
sql: string;
|
|
63
65
|
params: unknown[];
|
|
64
66
|
};
|
package/dist/typed-sql.js
CHANGED
|
@@ -47,21 +47,23 @@
|
|
|
47
47
|
* // ^? number | null
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
+
import { postgresDialect } from './dialect.js';
|
|
50
51
|
import { ValidationError, wrapPgError } from './errors.js';
|
|
51
52
|
/**
|
|
52
53
|
* Build a `(sql, params)` pair from a tagged-template invocation.
|
|
53
54
|
*
|
|
54
|
-
* Each interpolated value is replaced by a positional
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
55
|
+
* Each interpolated value is replaced by a positional placeholder (the active
|
|
56
|
+
* dialect's `paramPlaceholder`, `$N` for PostgreSQL) and pushed to the params
|
|
57
|
+
* array in order. The static string segments are the only thing concatenated
|
|
58
|
+
* into the SQL text. This is the single point that guarantees parameterization
|
|
59
|
+
* for the entire typed-SQL surface.
|
|
58
60
|
*
|
|
59
61
|
* Exported for unit testing the parameterization invariant without a database.
|
|
60
62
|
*/
|
|
61
|
-
export function buildTypedSql(strings, values) {
|
|
63
|
+
export function buildTypedSql(strings, values, dialect = postgresDialect) {
|
|
62
64
|
// The tagged-template API guarantees `strings.length === values.length + 1`.
|
|
63
65
|
// Guard the directly-callable (exported) surface so a mismatched call can't
|
|
64
|
-
// silently desync
|
|
66
|
+
// silently desync placeholders from params (pg would reject it, but fail
|
|
65
67
|
// loudly here instead).
|
|
66
68
|
if (strings.length !== values.length + 1) {
|
|
67
69
|
throw new ValidationError(`[turbine] sql template segment/value count mismatch: ${strings.length} segments, ${values.length} values.`);
|
|
@@ -70,7 +72,7 @@ export function buildTypedSql(strings, values) {
|
|
|
70
72
|
for (let i = 0; i < strings.length; i++) {
|
|
71
73
|
sql += strings[i];
|
|
72
74
|
if (i < values.length) {
|
|
73
|
-
sql +=
|
|
75
|
+
sql += dialect.paramPlaceholder(i + 1);
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
return { sql, params: values.slice() };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turbine-orm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Postgres-native TypeScript ORM — runs on Neon, Vercel Postgres, Cloudflare, Supabase. Streaming cursors, typed errors, single-query nested relations. One dependency, no WASM engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -14,6 +14,21 @@
|
|
|
14
14
|
"import": "./dist/serverless.js",
|
|
15
15
|
"require": "./dist/cjs/serverless.js"
|
|
16
16
|
},
|
|
17
|
+
"./sqlite": {
|
|
18
|
+
"types": "./dist/sqlite.d.ts",
|
|
19
|
+
"import": "./dist/sqlite.js",
|
|
20
|
+
"require": "./dist/cjs/sqlite.js"
|
|
21
|
+
},
|
|
22
|
+
"./mysql": {
|
|
23
|
+
"types": "./dist/mysql.d.ts",
|
|
24
|
+
"import": "./dist/mysql.js",
|
|
25
|
+
"require": "./dist/cjs/mysql.js"
|
|
26
|
+
},
|
|
27
|
+
"./mssql": {
|
|
28
|
+
"types": "./dist/mssql.d.ts",
|
|
29
|
+
"import": "./dist/mssql.js",
|
|
30
|
+
"require": "./dist/cjs/mssql.js"
|
|
31
|
+
},
|
|
17
32
|
"./cli": {
|
|
18
33
|
"types": "./dist/cli/config.d.ts",
|
|
19
34
|
"import": "./dist/cli/config.js",
|
|
@@ -50,7 +65,7 @@
|
|
|
50
65
|
"examples": "tsx examples/examples.ts",
|
|
51
66
|
"dogfood": "tsx examples/dogfood.ts",
|
|
52
67
|
"test": "tsx --test --test-concurrency=1 src/test/*.test.ts",
|
|
53
|
-
"test:unit": "tsx --test src/test
|
|
68
|
+
"test:unit": "DATABASE_URL= tsx --test src/test/*.test.ts",
|
|
54
69
|
"test:coverage": "c8 tsx --test --test-concurrency=1 src/test/*.test.ts",
|
|
55
70
|
"lint": "biome check src/",
|
|
56
71
|
"lint:fix": "biome check --write src/",
|
|
@@ -59,7 +74,7 @@
|
|
|
59
74
|
"prepare": "husky",
|
|
60
75
|
"size": "size-limit",
|
|
61
76
|
"size:check": "size-limit",
|
|
62
|
-
"test:watch": "tsx --watch --test src/test
|
|
77
|
+
"test:watch": "tsx --watch --test src/test/*.test.ts",
|
|
63
78
|
"db:seed": "psql $DATABASE_URL -v ON_ERROR_STOP=1 -f src/test/fixtures/seed.sql",
|
|
64
79
|
"db:reset": "psql $DATABASE_URL -c 'DROP SCHEMA public CASCADE; CREATE SCHEMA public;' && npm run db:seed",
|
|
65
80
|
"site:dev": "cd site && npm run dev",
|
|
@@ -86,10 +101,24 @@
|
|
|
86
101
|
"c8": "^11.0.0",
|
|
87
102
|
"husky": "^9.1.7",
|
|
88
103
|
"lint-staged": "^16.4.0",
|
|
104
|
+
"mssql": "^11.0.1",
|
|
105
|
+
"mysql2": "^3.22.5",
|
|
89
106
|
"size-limit": "^12.1.0",
|
|
90
107
|
"tsx": "^4.19.0",
|
|
91
108
|
"typescript": "^5.7.0"
|
|
92
109
|
},
|
|
110
|
+
"peerDependencies": {
|
|
111
|
+
"mssql": "^10.0.0 || ^11.0.0",
|
|
112
|
+
"mysql2": "^3.0.0"
|
|
113
|
+
},
|
|
114
|
+
"peerDependenciesMeta": {
|
|
115
|
+
"mssql": {
|
|
116
|
+
"optional": true
|
|
117
|
+
},
|
|
118
|
+
"mysql2": {
|
|
119
|
+
"optional": true
|
|
120
|
+
}
|
|
121
|
+
},
|
|
93
122
|
"keywords": [
|
|
94
123
|
"orm",
|
|
95
124
|
"postgres",
|