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.
Files changed (53) hide show
  1. package/README.md +156 -24
  2. package/dist/adapters/cockroachdb.js +4 -9
  3. package/dist/cjs/adapters/cockroachdb.js +4 -9
  4. package/dist/cjs/cli/index.js +23 -12
  5. package/dist/cjs/cli/observe-ui.js +12 -2
  6. package/dist/cjs/cli/observe.js +6 -7
  7. package/dist/cjs/cli/studio-ui.generated.js +1 -1
  8. package/dist/cjs/cli/studio.js +6 -37
  9. package/dist/cjs/client.js +45 -33
  10. package/dist/cjs/dialect.js +116 -0
  11. package/dist/cjs/errors.js +19 -1
  12. package/dist/cjs/generate.js +4 -0
  13. package/dist/cjs/index.js +3 -2
  14. package/dist/cjs/introspect.js +20 -0
  15. package/dist/cjs/mssql.js +1338 -0
  16. package/dist/cjs/mysql.js +1052 -0
  17. package/dist/cjs/query/builder.js +408 -122
  18. package/dist/cjs/query/utils.js +1 -0
  19. package/dist/cjs/sqlite.js +849 -0
  20. package/dist/cjs/typed-sql.js +9 -7
  21. package/dist/cli/index.js +23 -12
  22. package/dist/cli/migrate.d.ts +2 -2
  23. package/dist/cli/observe-ui.d.ts +1 -1
  24. package/dist/cli/observe-ui.js +12 -2
  25. package/dist/cli/observe.js +7 -8
  26. package/dist/cli/studio-ui.generated.js +1 -1
  27. package/dist/cli/studio.d.ts +0 -10
  28. package/dist/cli/studio.js +7 -37
  29. package/dist/client.d.ts +35 -14
  30. package/dist/client.js +46 -34
  31. package/dist/dialect.d.ts +258 -1
  32. package/dist/dialect.js +83 -0
  33. package/dist/errors.d.ts +12 -0
  34. package/dist/errors.js +17 -0
  35. package/dist/generate.js +4 -0
  36. package/dist/index.d.ts +4 -4
  37. package/dist/index.js +1 -1
  38. package/dist/introspect.d.ts +18 -0
  39. package/dist/introspect.js +19 -0
  40. package/dist/mssql.d.ts +233 -0
  41. package/dist/mssql.js +1298 -0
  42. package/dist/mysql.d.ts +174 -0
  43. package/dist/mysql.js +1012 -0
  44. package/dist/query/builder.d.ts +105 -6
  45. package/dist/query/builder.js +409 -123
  46. package/dist/query/index.d.ts +2 -2
  47. package/dist/query/types.d.ts +62 -12
  48. package/dist/query/utils.js +1 -0
  49. package/dist/sqlite.d.ts +144 -0
  50. package/dist/sqlite.js +842 -0
  51. package/dist/typed-sql.d.ts +7 -5
  52. package/dist/typed-sql.js +9 -7
  53. package/package.json +32 -3
@@ -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 `$N` placeholder and
55
- * pushed to the params array in order. The static string segments are the only
56
- * thing concatenated into the SQL text. This is the single point that
57
- * guarantees parameterization for the entire typed-SQL surface.
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 `$N` placeholder and
55
- * pushed to the params array in order. The static string segments are the only
56
- * thing concatenated into the SQL text. This is the single point that
57
- * guarantees parameterization for the entire typed-SQL surface.
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 `$N` placeholders from params (pg would reject it, but fail
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 += `$${i + 1}`;
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.19.1",
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/schema-builder.test.ts src/test/errors.test.ts src/test/stress.test.ts src/test/migrate.test.ts src/test/update-operators.test.ts src/test/empty-where-guard.test.ts src/test/cli.test.ts src/test/serverless.test.ts src/test/pipeline.test.ts src/test/pipeline-submittable.test.ts src/test/with-inference.test.ts src/test/operator-validation.test.ts src/test/unlimited-warning.test.ts src/test/generate-relations.test.ts src/test/stream-and-parse.test.ts src/test/sql-cache.test.ts src/test/dialect.test.ts src/test/studio.test.ts src/test/sql-injection.test.ts src/test/cli-flags.test.ts src/test/cockroachdb-adapter.test.ts src/test/yugabytedb-adapter.test.ts src/test/pg-compat.test.ts src/test/relation-filter-validation.test.ts src/test/client-coverage.test.ts src/test/schema-diff.test.ts src/test/composite-fk.test.ts src/test/retry.test.ts src/test/text-search.test.ts src/test/optimistic-lock.test.ts src/test/sql-safety-property.test.ts src/test/nested-write.test.ts src/test/nested-write-update-upsert.test.ts src/test/cursor-pagination.test.ts src/test/client-branches.test.ts src/test/is-isNot-filter.test.ts src/test/event-emitter.test.ts src/test/observe.test.ts src/test/relation-limit-param.test.ts src/test/where-guard-cache-and-relation-where.test.ts",
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/schema-builder.test.ts src/test/errors.test.ts src/test/stress.test.ts",
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",