@dsqlbase/core 0.1.6 → 0.2.1

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 (134) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/LICENSE +21 -0
  3. package/README.md +4 -0
  4. package/dist/definition/base.d.ts +50 -3
  5. package/dist/definition/base.d.ts.map +1 -1
  6. package/dist/definition/base.js +34 -1
  7. package/dist/definition/base.js.map +1 -1
  8. package/dist/definition/column.d.ts +87 -14
  9. package/dist/definition/column.d.ts.map +1 -1
  10. package/dist/definition/column.js +99 -5
  11. package/dist/definition/column.js.map +1 -1
  12. package/dist/definition/constraint.d.ts +16 -15
  13. package/dist/definition/constraint.d.ts.map +1 -1
  14. package/dist/definition/constraint.js +4 -1
  15. package/dist/definition/constraint.js.map +1 -1
  16. package/dist/definition/domain.d.ts +12 -8
  17. package/dist/definition/domain.d.ts.map +1 -1
  18. package/dist/definition/domain.js +10 -2
  19. package/dist/definition/domain.js.map +1 -1
  20. package/dist/definition/embedded.d.ts +131 -0
  21. package/dist/definition/embedded.d.ts.map +1 -0
  22. package/dist/definition/embedded.js +133 -0
  23. package/dist/definition/embedded.js.map +1 -0
  24. package/dist/definition/index.d.ts +7 -4
  25. package/dist/definition/index.d.ts.map +1 -1
  26. package/dist/definition/index.js +4 -1
  27. package/dist/definition/index.js.map +1 -1
  28. package/dist/definition/indexes.d.ts +49 -19
  29. package/dist/definition/indexes.d.ts.map +1 -1
  30. package/dist/definition/indexes.js +38 -9
  31. package/dist/definition/indexes.js.map +1 -1
  32. package/dist/definition/namespace.d.ts +2 -2
  33. package/dist/definition/namespace.d.ts.map +1 -1
  34. package/dist/definition/namespace.js.map +1 -1
  35. package/dist/definition/relations.d.ts +47 -15
  36. package/dist/definition/relations.d.ts.map +1 -1
  37. package/dist/definition/relations.js +17 -12
  38. package/dist/definition/relations.js.map +1 -1
  39. package/dist/definition/sequence.d.ts +4 -4
  40. package/dist/definition/sequence.d.ts.map +1 -1
  41. package/dist/definition/sequence.js.map +1 -1
  42. package/dist/definition/table.d.ts +118 -13
  43. package/dist/definition/table.d.ts.map +1 -1
  44. package/dist/definition/table.js +137 -4
  45. package/dist/definition/table.js.map +1 -1
  46. package/dist/definition/tenant.d.ts +50 -0
  47. package/dist/definition/tenant.d.ts.map +1 -0
  48. package/dist/definition/tenant.js +73 -0
  49. package/dist/definition/tenant.js.map +1 -0
  50. package/dist/definition/union.d.ts +84 -0
  51. package/dist/definition/union.d.ts.map +1 -0
  52. package/dist/definition/union.js +89 -0
  53. package/dist/definition/union.js.map +1 -0
  54. package/dist/definition/view.js.map +1 -1
  55. package/dist/index.d.ts +3 -3
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +2 -2
  58. package/dist/index.js.map +1 -1
  59. package/dist/runtime/base.d.ts +22 -4
  60. package/dist/runtime/base.d.ts.map +1 -1
  61. package/dist/runtime/base.js.map +1 -1
  62. package/dist/runtime/column.d.ts +54 -3
  63. package/dist/runtime/column.d.ts.map +1 -1
  64. package/dist/runtime/column.js +75 -7
  65. package/dist/runtime/column.js.map +1 -1
  66. package/dist/runtime/context.d.ts +30 -2
  67. package/dist/runtime/context.d.ts.map +1 -1
  68. package/dist/runtime/context.js +6 -0
  69. package/dist/runtime/context.js.map +1 -1
  70. package/dist/runtime/errors.d.ts +14 -0
  71. package/dist/runtime/errors.d.ts.map +1 -0
  72. package/dist/runtime/errors.js +19 -0
  73. package/dist/runtime/errors.js.map +1 -0
  74. package/dist/runtime/executor.d.ts +29 -1
  75. package/dist/runtime/executor.d.ts.map +1 -1
  76. package/dist/runtime/executor.js +23 -0
  77. package/dist/runtime/executor.js.map +1 -1
  78. package/dist/runtime/group.d.ts +54 -0
  79. package/dist/runtime/group.d.ts.map +1 -0
  80. package/dist/runtime/group.js +96 -0
  81. package/dist/runtime/group.js.map +1 -0
  82. package/dist/runtime/index.d.ts +9 -6
  83. package/dist/runtime/index.d.ts.map +1 -1
  84. package/dist/runtime/index.js +6 -3
  85. package/dist/runtime/index.js.map +1 -1
  86. package/dist/runtime/operation.d.ts +227 -29
  87. package/dist/runtime/operation.d.ts.map +1 -1
  88. package/dist/runtime/operation.js +525 -49
  89. package/dist/runtime/operation.js.map +1 -1
  90. package/dist/runtime/query.d.ts +102 -34
  91. package/dist/runtime/query.d.ts.map +1 -1
  92. package/dist/runtime/query.js +140 -31
  93. package/dist/runtime/query.js.map +1 -1
  94. package/dist/runtime/registry.d.ts +114 -4
  95. package/dist/runtime/registry.d.ts.map +1 -1
  96. package/dist/runtime/registry.js +366 -9
  97. package/dist/runtime/registry.js.map +1 -1
  98. package/dist/runtime/session.d.ts +10 -4
  99. package/dist/runtime/session.d.ts.map +1 -1
  100. package/dist/runtime/session.js.map +1 -1
  101. package/dist/runtime/table.d.ts +87 -8
  102. package/dist/runtime/table.d.ts.map +1 -1
  103. package/dist/runtime/table.js +142 -5
  104. package/dist/runtime/table.js.map +1 -1
  105. package/dist/runtime/union.d.ts +33 -0
  106. package/dist/runtime/union.d.ts.map +1 -0
  107. package/dist/runtime/union.js +69 -0
  108. package/dist/runtime/union.js.map +1 -0
  109. package/dist/sql/index.d.ts +1 -1
  110. package/dist/sql/index.d.ts.map +1 -1
  111. package/dist/sql/index.js.map +1 -1
  112. package/dist/sql/nodes.d.ts +33 -6
  113. package/dist/sql/nodes.d.ts.map +1 -1
  114. package/dist/sql/nodes.js +25 -0
  115. package/dist/sql/nodes.js.map +1 -1
  116. package/dist/sql/tag.d.ts +17 -0
  117. package/dist/sql/tag.d.ts.map +1 -1
  118. package/dist/sql/tag.js +95 -0
  119. package/dist/sql/tag.js.map +1 -1
  120. package/dist/sql/utils.d.ts +2 -2
  121. package/dist/sql/utils.d.ts.map +1 -1
  122. package/dist/sql/utils.js.map +1 -1
  123. package/dist/utils/index.d.ts +1 -1
  124. package/dist/utils/index.d.ts.map +1 -1
  125. package/dist/utils/index.js.map +1 -1
  126. package/dist/utils/thenable.js.map +1 -1
  127. package/dist/utils/types.d.ts +50 -2
  128. package/dist/utils/types.d.ts.map +1 -1
  129. package/dist/utils/types.js.map +1 -1
  130. package/package.json +27 -22
  131. package/dist/sql/expressions.d.ts +0 -25
  132. package/dist/sql/expressions.d.ts.map +0 -1
  133. package/dist/sql/expressions.js +0 -79
  134. package/dist/sql/expressions.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,204 @@
1
1
  # @dsqlbase/core
2
2
 
3
+ ## 0.2.1
4
+
5
+ No changes in this release.
6
+
7
+ ## 0.2.0
8
+
9
+ ### Minor Changes
10
+
11
+ - 2e0b361: Types and the model surface:
12
+ - **Relations split across several `relations()` blocks are typed;** a table with two blocks had no relation names at the type level, though its queries ran.
13
+ - **One model per table, under its schema alias.** A table exported as `members` but named `team_members` also appeared as `dsql.team_members` when the client was indexed dynamically; that duplicate is gone. `Table.alias` holds the alias.
14
+ - **Exported object types are `type` aliases,** so they can no longer be extended by declaration merging (`declare module "dsqlbase" { interface QueryArgs … }`).
15
+
16
+ **Breaking:** the two behaviour changes above.
17
+
18
+ Docs: docs/guide/relations.md, docs/internals/runtime-pipeline.md
19
+
20
+ - 2e0b361: Column writes:
21
+ - **`$onUpdate` runs on every update,** not only when the update also names its column, so `updatedAt.$onUpdate(() => new Date())` works on its own. A value the update sets still wins, and the hook's value is validated and encoded like any written value.
22
+ - **`numeric()` / `decimal()` take `{ precision, scale }`** and default to `numeric(18,6)` — what DSQL makes of a bare `numeric` — so Postgres and PGlite store the same type and DSQL no longer re-plans it. A value the column would round or overflow throws `ColumnValidationError` instead of being rounded silently.
23
+ - `identity(name, { sequenceName })` keeps the sequence name it is given.
24
+
25
+ **Breaking:** an update writes every column with an `$onUpdate` hook; a bare `numeric()` is `numeric(18,6)` on Postgres and PGlite; writes that would round a `numeric` now throw.
26
+
27
+ Docs: docs/guide/schema.md, docs/guide/dsql-notes.md
28
+
29
+ - 2e0b361: Embedded objects: `embedded({ amount, currency })` declares a reusable value object, and `.column("net_value")` places it in a table as a column group — one column per member (`net_value_amount`, …), each with its own type, codec, validator and `.notNull()`. Groups nest and take `.default(obj)`.
30
+ - **Reading:** a group reads as a nested object; `select` takes it as `true` or a map of its members. A group whose members are all nullable reads `null` when every column is `NULL`.
31
+ - **Writing:** `create` writes the members given, `update` only the members given, and `null` clears an all-nullable group.
32
+ - **Filtering and ordering:** a group takes `exists` and a nested `where` over its members; `orderBy` and `paginate` take a nested order per group.
33
+ - Constraint and index callbacks reach members as `c.netValue.amount`. Migrations see plain columns.
34
+
35
+ **Breaking,** for `@dsqlbase/core` callers: `Table.getColumn` returns a `Column` or a `ColumnGroup`, and table column maps accept groups.
36
+
37
+ Docs: docs/guide/embeddable-objects.md, docs/guide/schema.md, docs/guide/querying.md, docs/decisions/0013-embeddable-objects.md
38
+
39
+ - 2e0b361: Filters follow the column's type. Every column carries a runtime type — `string`, `uuid`, `number`, `bigint`, `boolean`, `date`, `interval`, `bytes`, `json`, `jsonb`, `array`, `object` — which decides the `where` operators it takes, whether a bare value means `eq`, and whether it can be an `orderBy` key. The types and the runtime follow the same table, so a refused operator also throws when the query is built, before any SQL runs.
40
+ - Several operators on one field all apply: `{ pages: { gte: 1, lte: 5 } }` used to keep only the first.
41
+ - Filter values go through the column's codec, as inserts and updates do, so a `Date`, a `bigint` or a `Duration` filters the way it is stored.
42
+ - `%` and `_` in `beginsWith`, `endsWith` and a string `contains` match themselves, not any text.
43
+ - `in: []` matches no row and `notIn: []` every row; both used to fail as SQL.
44
+ - An empty `where: {}`, an empty `and` / `or`, and an `or` with a `{}` branch filter nothing. `findOne`, `update` and `delete` refuse an empty `where`.
45
+
46
+ **Breaking:**
47
+ - `bytea` and `json` columns filter by `exists` only, and neither they nor `jsonb` columns can be ordered by; pattern operators are refused on non-string columns, and comparisons on `boolean`. These all built SQL Postgres rejects.
48
+ - An unknown operator throws, including an object naming only unknown ones (`{ assigneeId: { isNull: true } }`), which used to be compared as a value. A direction other than `"asc"` / `"desc"` in `orderBy` throws.
49
+ - A `%` or `_` in a pattern operator's value no longer acts as a wildcard.
50
+ - `@dsqlbase/core`: `ColumnConfig` and `DomainConfig` gain a `runtimeType` parameter. A custom `Session` now receives filter values encoded by the column's codec.
51
+
52
+ Docs: docs/guide/querying.md, docs/internals/codec-boundary.md
53
+
54
+ - 2e0b361: JSON columns: `jsonb()`, `array()` and `record()`, validated by any Standard Schema.
55
+ - **`jsonb(name)`** holds any JSON value; `null` is SQL `NULL`. **`array(name)`** and **`record(name)`** are `jsonb` columns whose value must be an array or a plain object, checked on every write and read.
56
+ - **`.schema(s)`** on `json()`, `jsonb()`, `array()` and `record()` takes any Standard Schema (zod, valibot, arktype — none is a dependency). Writes validate and store the schema's output; reads validate and return it. A failure throws `ColumnValidationError` (`code`, `column`, `phase`, `issues`). `$type<T>()` types a column without validating.
57
+ - **Filters:** `jsonb`, `array` and `record` filter by `eq` / `neq` (whole documents), `contains` (`@>`, a fragment matched recursively; on an array, a list of item fragments) and `exists`; a record also by `hasKey` (`?`). `json` filters by `exists` only, as Postgres's `json` has no equality. `distinct` compares `jsonb`.
58
+ - **Validators** run beside a column's codec: `ColumnConfig.validator { write, read }` runs on every write (`.default()`, `$onCreate`, `$onUpdate` included) and every read; filter values are only encoded.
59
+ - **Fixed:** a JSON string such as `"123"` stored in a JSON column read back as the number `123`.
60
+
61
+ **Breaking:**
62
+ - `array()` is now `jsonb`, not comma-joined `text`, and untyped it reads as `unknown[]`. An existing `array()` column can't change type in place on DSQL; the migration refuses it.
63
+ - A custom `Session` must return `json` / `jsonb` columns parsed, as `pg` and PGlite do.
64
+ - `@dsqlbase/core`: `ColumnConfig` gains an `inputType` parameter; `.default()`, `$onCreate` and `$onUpdate` take the input type.
65
+
66
+ Docs: docs/guide/schema.md, docs/guide/querying.md, docs/internals/codec-boundary.md, docs/decisions/0011-json-columns.md, docs/decisions/0012-json-array-record.md
67
+
68
+ - 2e0b361: Constraints and indexes change on existing tables, within what DSQL allows (verified on a live cluster).
69
+ - **CHECK:** `ADD CONSTRAINT … NOT VALID`, enforced on new writes at once, then validated against existing rows by an async job. If a row violates it, the run stops and the constraint stays, not valid; once the data is fixed, the next plan is just the `VALIDATE`.
70
+ - **Changed indexes are rebuilt without a gap:** the new index is built beside the old one as `<name>_rebuild`, the old one dropped, and the new one renamed into place, so the old index serves reads and enforces uniqueness until then. A changed UNIQUE builds its new index before its old constraint is dropped. An index whose async build failed is repaired the same way, and a run that stops part-way starts over cleanly.
71
+ - **Expression and partial indexes:** ``.columns((c) => [sql`lower(${c.email})`])`` and ``.where((c) => sql`…`)``. Expressions and predicates compare by position and presence, since PostgreSQL prints them back reformatted: to change one, rename the index.
72
+ - **Removed CHECKs, UNIQUEs and indexes are dropped as lossy steps.** An index the definition doesn't declare is dropped too, and the plan notes that it may have been created by hand.
73
+ - **Constraints compare wherever they were declared** (on the column or on the table), and introspection reads back whether a CHECK is validated and an index valid.
74
+
75
+ **Breaking:** `IMMUTABLE_INDEX` is gone, and `IMMUTABLE_CONSTRAINT` now covers primary keys only. `IndexColumnDefinition.sort()` is removed: DSQL refuses `ASC` / `DESC` on index keys. `nullsFirst()` / `nullsLast()` remain.
76
+
77
+ Docs: docs/guide/schema.md, docs/guide/migrations.md, docs/internals/migration-pipeline.md
78
+
79
+ - 2e0b361: Migration fixes, most found against a live DSQL cluster:
80
+ - **An unchanged schema plans nothing on a second run.** Defaults compare by meaning rather than spelling; sequence and identity options by their effective values; composite primary keys and DSQL's implicit primary-key `INCLUDE` no longer re-plan; a `NULLS FIRST` index key is read back correctly.
81
+ - **Objects in a `namespace()` are created, altered and dropped in their own schema.** Statements named them unqualified, so a table landed in `public` and the next plan dropped it. A column typed by a domain in a namespace uses its schema-qualified type.
82
+ - **Derived constraint names stay within PostgreSQL's 63 bytes,** shortened as PostgreSQL shortens its own, so a long `<table>_<column>_not_null` is found again instead of failing every later deploy.
83
+ - **Async DDL no longer hangs on DSQL;** jobs are read and waited for correctly.
84
+ - **`CREATE TABLE` carries identity and generated columns,** which it dropped.
85
+ - **Key-column order is compared** for indexes and keys, and a constraint whose kind changes is replaced.
86
+ - **A change that recreates a column's index and CHECK** no longer stops the planner with a dependency cycle.
87
+
88
+ **Breaking:** a column typed by a namespaced domain serializes its `domain` as `namespace.name` and its type schema-qualified.
89
+
90
+ Docs: docs/guide/migrations.md, docs/internals/migration-pipeline.md, docs/internals/dsql-capabilities.md
91
+
92
+ - 2e0b361: Rename and retire columns and tables without losing data.
93
+ - **`.renamedFrom("previous")`** on a column or a table makes the migration emit `RENAME` instead of a drop and an add. Constraints and indexes named after the old name are renamed with it. When both names exist, the rename is refused (`RENAME_CONFLICT`); once the database has the new name, the hint does nothing.
94
+ - **`.deprecated()`** on a column hides it from the client — results, filters, ordering and inputs, in the types and at runtime — and marks it in the database with the comment `dsqlbase:deprecated`, dropping its `NOT NULL` when it has no default. A table created with a column already deprecated gets the marker in the same run.
95
+ - **In a later release,** removing the column from the definition drops it as a **lossy** step, so it runs without `allow.destructive`.
96
+
97
+ A primary-key column or an embedded-object member can't be deprecated.
98
+
99
+ Docs: docs/guide/schema.md, docs/guide/migrations.md
100
+
101
+ - 2e0b361: Keyset pagination: `paginate()` and `count()` on every model.
102
+ - **`dsql.<model>.paginate({ select, where, orderBy, join, limit, after | before, count })`** reads one page under a total order — your `orderBy`, then every primary-key column you didn't name. It returns `{ items, hasNextPage, hasPreviousPage, startCursor, endCursor }`, each item's cursor at `$$meta.cursor`, and `totalCount` with `count: true`. A page read `before` a cursor comes back in forward order.
103
+ - **Order keys may be nullable.** Nulls sort where Postgres puts them by default — last ascending, first descending — and the `ORDER BY` states it, so pages don't depend on a server setting.
104
+ - **Cursors** carry each key as the database's own text, so microsecond timestamps and big integers page exactly. A cursor is valid only under the order it was taken with; anything else throws `InvalidCursorError` before any SQL runs.
105
+ - **`dsql.<model>.count({ where? })`** resolves to a number. Pages and counts go through the tenant predicate, so a cursor is never a way across tenants.
106
+ - **`createClient({ pagination: { defaultLimit, maxLimit } })`** — `defaultLimit` is 100; `maxLimit`, when set, refuses a larger `limit`. A `findMany` without `limit` still returns every row.
107
+ - **`$transaction([...])` accepts a counted page** (two statements) like any query. In `@dsqlbase/core`: `sql.keyset`, `Executable` and `CompositeQuery`.
108
+
109
+ Docs: docs/guide/pagination.md, docs/guide/querying.md, docs/decisions/0008-client-pagination.md
110
+
111
+ - 2e0b361: Polymorphic relations: `union()` of tables, relations to it, and reading it directly.
112
+ - **`union({ photos, videos })`** (from `dsqlbase/schema`) declares tables that can stand in for one another. `union.columns` holds their shared fields — those every member declares with the same type. A union produces no DDL.
113
+ - **Relations to a union.** `hasMany`, `hasOne` and `belongsTo` accept one. A join to it takes shared-field `select`, `where`, `orderBy`, `limit` and `offset`, applied to every member, plus a per-member `on: { alias: true | false | { select, where, join } }` — GraphQL's fragments. It runs as one `UNION ALL`, ordered and limited across all members in SQL.
114
+ - **`$$key`** on every union row names its member and narrows the result type. In a `where` it filters by member (`{ $$key: { in: types } }`), decided while the query is built, so a member that can't match adds no SQL; `orderBy: { $$key: "asc" }` sorts by it.
115
+ - **`belongsTo(union, { from, to, discriminator })`** joins the member the row's discriminator names. Its `from` column is a keyless `guid()`, which reads, writes and filters global ids keyed by that discriminator.
116
+ - **`dsql.<unionAlias>`** reads a union directly: `findOne`, `findMany`, `paginate` (cursors over `orderBy`, `$$key` and the primary key) and `count`. It is read-only; rows are written through their member's model.
117
+ - Every member passes the tenant predicate in its own branch. A union is on a client only when every member is.
118
+ - Relations to a union are validated when the client is created: members, column pairs, `to` lists, discriminators and global-id agreement.
119
+
120
+ **Breaking,** for `@dsqlbase/core` callers: a relation's `target` may be a union (`SchemaRegistry.getRelationTarget` returns `AnyTable | Union`), and `JoinParams` is `TableJoinParams | UnionJoinParams`. In `dsqlbase`, the `on` map of `$findByGlobalId` and `$listByGlobalId` takes `{ select, where, join }`.
121
+
122
+ Docs: docs/guide/polymorphic-relations.md, docs/guide/relations.md, docs/guide/querying.md, docs/decisions/0009-polymorphic-relations.md
123
+
124
+ - 2e0b361: Query fixes:
125
+ - **Self-relations and same-named tables in different schemas join correctly.** Every level of a select now has its own alias (`FROM "tasks" AS "__t0"`); before, a `tasks.parent → tasks` join matched each row against itself.
126
+ - **`bigint` values stay exact in joined rows and union rows,** which reach the client as JSON: `9007199254740993n` came back as `9007199254740992n`.
127
+ - **`$listByGlobalId` finds an id whose uuid is spelled differently** (upper case, braces, no hyphens), as `$findByGlobalId` does.
128
+ - **`$execute` refuses a `sql` template,** which it ran as nothing; pass one to `$query`, or call `.toQuery()`.
129
+
130
+ **Breaking:** the SQL text of every select changes (results don't), so tests asserting on generated SQL need updating. `@dsqlbase/core/sql/expressions`, an undocumented module duplicating the `sql` helpers, is removed: use `sql.eq`, `sql.and` and the rest.
131
+
132
+ **Known issue:** `update` and `delete` change every row their `where` matches but return only one of them. A fix is planned for the next release; until then, filter them by a unique key. See docs/guide/querying.md.
133
+
134
+ Docs: docs/guide/querying.md, docs/guide/global-ids.md, docs/internals/select-tree-aliasing.md, docs/internals/codec-boundary.md, docs/decisions/0003-select-tree-aliasing.md
135
+
136
+ - 0927824: `$$meta` on every row, and `table().meta()` to put your own data in it.
137
+
138
+ Every result row — from `findOne` / `findMany`, each joined level, and the rows `create` / `update` / `delete` return — carries `$$meta: { key, table, schema? }`: `key` is the schema alias (`members`), `table` the database name (`team_members`). `table("tasks", { … }).meta({ __typename: "Task" })` adds your own fields to it, typed. It is the first key of the row and survives `{ ...row }` and `JSON.stringify`.
139
+
140
+ **Breaking:** rows gain a property, so a whole-row `toEqual` needs `$$meta`. `$$meta` and `$$key` are reserved field names.
141
+
142
+ Docs: docs/guide/querying.md, docs/guide/schema.md, docs/decisions/0004-record-meta.md
143
+
144
+ - 6b80bf1: Relations in `select`: `select: { id: true, author: { name: true } }` reads exactly as `join: { author: { select: { name: true } } }` — same SQL, same result type. A relation takes `true` or a field map over its target, which may name the target's own relations. Filters, order and limits on a relation stay in `join`, and naming one relation in both throws.
145
+
146
+ No `select`, or one naming nothing as `true`, returns every column; naming columns returns those; naming only relations returns only the relations.
147
+
148
+ **Breaking:**
149
+ - The result type of `select: {}` (or an all-`false` select) is the full row, as the runtime already returned. A `join` key set to `false` is no longer in the result type.
150
+ - `@dsqlbase/core`: `SelectOperationArgs.select` is optional, and `[]` now means no column rather than every column.
151
+
152
+ Docs: docs/guide/querying.md, docs/guide/relations.md, docs/decisions/0010-relation-select.md
153
+
154
+ - 2e0b361: A schema that would build wrong queries or DDL now fails when it is declared or when the client is created, naming the problem:
155
+ - More than one primary key on a table (`MULTIPLE_PRIMARY_KEYS` in migration validation). A composite key is one constraint over several columns.
156
+ - Two fields mapped to one database column (`DUPLICATE_COLUMN_NAME`).
157
+ - A relation named like a column of its table: columns and relations share one field namespace.
158
+ - A relation whose column pairs differ in number or type, or name a column of the wrong table.
159
+ - An identity's explicit sequence name already used in its namespace (`DUPLICATE_SEQUENCE_NAME`).
160
+
161
+ `Table.primaryKey` and `Table.isCompositeKey` expose the key at runtime, wherever it was declared.
162
+
163
+ **Fixed:** `PrimaryKeyConstraintDefinition.include()` replaced the key columns with the included ones.
164
+
165
+ **Breaking:** each schema above used to build and failed later, or silently misbehaved.
166
+
167
+ Docs: docs/guide/schema.md, docs/guide/relations.md, docs/internals/migration-pipeline.md
168
+
169
+ - 2e0b361: Tenancy: declare a tenant boundary in the schema, and let the client enforce it. Aurora DSQL has no row-level security, so the client is the last place a multi-tenant application can be stopped from crossing tenants.
170
+ - **Declaring it.** `tenantScope(claims)` (from `dsqlbase/schema`) defines the claim columns every table in a boundary carries: `ws.table(name, columns)` merges them in, and `ws.columns()` spreads into any other table, a namespaced one included. Claim columns must be `notNull`; they are ordinary columns in the DDL.
171
+ - **Scoping a client.** `dsql.$identityClaims(claims)` derives a client for one request. Every read it builds carries the claim predicate ahead of your own `where`, at the root and at every joined level; every update and delete carries it too, and `create` fills the claim columns. A scoped client has no `$query`, `$execute` or `$identityClaims`, since raw SQL would bypass the predicate. `$transaction` inherits the scope.
172
+ - **Enforcing it.** By default a client without claims cannot reach a tenant table: it is absent from the client's type and throws `TenancyError` when a query is built, including through a join. `createClient({ tenancy: { enforce: false } })` lets an internal process run unscoped.
173
+ - **`.readOnly()`** marks a column as managed by something other than the caller. It reads like any column, but it is left out of `create`'s `data` and `update`'s `set`, in the types and at runtime. Claim columns are read-only.
174
+
175
+ **Breaking:**
176
+ - Adopting `tenantScope` takes those tables away from a default client until it is scoped — the point of `enforce: true`.
177
+ - A schema that gives one claim name two data types, or a claim column that is not `notNull`, now throws when the client is created.
178
+ - For direct `@dsqlbase/core` callers: an array `where` passed to `OperationsFactory` means all of its conditions (it used to keep only the first). Client queries never produce one.
179
+
180
+ Docs: docs/guide/tenancy.md, docs/guide/schema.md, docs/guide/querying.md, docs/decisions/0005-tenant-client-visibility.md, docs/decisions/0006-client-tenancy.md
181
+
182
+ ### Patch Changes
183
+
184
+ - 2e0b361: Documentation now lives in [`docs/`](https://github.com/slsdotdev/dsqlbase/tree/main/docs): a guide for using the packages, the internals for contributing, and a record of each design decision. The package READMEs point there, and `QueryArgs.limit` no longer claims a default limit that was never applied.
185
+
186
+ Docs: docs/README.md, docs/guide/README.md, docs/internals/README.md, docs/decisions/README.md
187
+
188
+ - 2e0b361: Packaging fixes for every published package:
189
+ - **The MIT `LICENSE` is now in each tarball.** It was listed as `../../LICENSE`, a path npm ignores, so no release shipped it.
190
+ - **`engines.node` is declared, `>=22`**, and CI runs every suite on Node 22 as well as 24.
191
+ - **In `exports`, `types` comes before `default`**, as TypeScript expects. It resolved before only because the `.d.ts` files sit next to the `.js` files. `publint` and `attw` now check every package in CI.
192
+ - **`homepage` points to the repository.**
193
+ - **Sourcemaps include their sources**, so stack traces and debuggers show the original TypeScript. This makes the packages larger.
194
+ - **The build starts from an empty `dist/`**, so a deleted module can't linger in a tarball.
195
+
196
+ Docs: docs/guide/install.md (Requirements), docs/internals/conventions.md (Packaging), docs/internals/architecture.md.
197
+
198
+ - 2e0b361: The `pg` session returns every transaction's connection to the pool exactly once. A failed `BEGIN`, `COMMIT` or `ROLLBACK` used to keep the connection checked out, so the pool ran dry one failure at a time. A broken connection is now destroyed rather than reused, and `rollback()` doesn't throw. `$transaction` always throws the error that caused the rollback, so a `40001` is still retried when the rollback fails too. The PGlite session waits for `BEGIN`. `TransactionSession` documents this contract for custom sessions.
199
+
200
+ Docs: docs/guide/sessions.md, docs/guide/transactions.md
201
+
3
202
  ## 0.1.6
4
203
 
5
204
  ## 0.1.5
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 sls.dev
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 CHANGED
@@ -13,6 +13,10 @@ npm install @dsqlbase/core
13
13
 
14
14
  For typical application use, `npm install dsqlbase` instead — it re-exports `sql`, `Session`, `SQLStatement`, and `SQLQuery` directly.
15
15
 
16
+ ## Documentation
17
+
18
+ What this package owns and how it fits the others: [Architecture](https://github.com/slsdotdev/dsqlbase/blob/main/docs/internals/architecture.md).
19
+
16
20
  ## License
17
21
 
18
22
  MIT.
@@ -15,18 +15,58 @@ export declare const Kind: Readonly<{
15
15
  readonly CHECK_CONSTRAINT: "CHECK_CONSTRAINT";
16
16
  readonly UNIQUE_CONSTRAINT: "UNIQUE_CONSTRAINT";
17
17
  readonly PRIMARY_KEY_CONSTRAINT: "PRIMARY_KEY_CONSTRAINT";
18
+ readonly TENANT_SCOPE: "TENANT_SCOPE";
19
+ readonly UNION: "UNION";
20
+ readonly UNION_COLUMN: "UNION_COLUMN";
21
+ readonly EMBEDDED_OBJECT: "EMBEDDED_OBJECT";
22
+ readonly COLUMN_GROUP: "COLUMN_GROUP";
18
23
  }>;
19
24
  export declare const Relation: Readonly<{
20
25
  readonly HAS_ONE: "has_one";
21
26
  readonly HAS_MANY: "has_many";
22
27
  readonly BELONGS_TO: "belongs_to";
23
28
  }>;
29
+ /** The field carrying per-row table metadata on every result record. */
30
+ export declare const META_FIELD = "$$meta";
31
+ /**
32
+ * The field naming which member of a union a row came from, on every row of a union result.
33
+ * Top level rather than inside `$$meta`: TypeScript narrows a union on a top-level property
34
+ * only (`docs/decisions/0007-global-ids.md`).
35
+ */
36
+ export declare const KEY_FIELD = "$$key";
37
+ /**
38
+ * Field names a table may use for neither a column nor a relation.
39
+ *
40
+ * The runtime writes them onto result records itself, so a field of the same name would be
41
+ * silently overwritten: `$$meta` on every row, `$$key` on every row of a union result. See
42
+ * `docs/decisions/0004-record-meta.md`.
43
+ */
44
+ export declare const RESERVED_FIELD_NAMES: readonly string[];
24
45
  export type NodeKind = (typeof Kind)[keyof typeof Kind];
25
46
  export type RelationType = (typeof Relation)[keyof typeof Relation];
26
- export interface ColumnCodec<TRaw, TValue> {
47
+ /**
48
+ * Converts a column's values to and from what the driver sends and returns. A codec translates
49
+ * and nothing else: every value bound for the column passes through `encode` — writes, filters,
50
+ * `Column.param` — so a codec that refused values would refuse filters too. Checking a value is
51
+ * {@link ColumnValidator}'s job.
52
+ */
53
+ export type ColumnCodec<TRaw, TValue> = {
27
54
  encode(value: TValue): TRaw;
28
55
  decode(raw: TRaw): TValue;
29
- }
56
+ };
57
+ /**
58
+ * Checks a column's values on their way into and out of the database. Writes run `write` before
59
+ * the codec encodes; reads run `read` after it decodes. Filters run neither: a filter value is a
60
+ * pattern to compare with, not a value to store. Either method throws to refuse a value.
61
+ *
62
+ * `write` takes what a write accepts (`TInput`) and returns what is stored (`TValue`); they
63
+ * differ for a column whose writes accept more than its reads return — a JSON column validated
64
+ * by a schema with defaults, for one.
65
+ */
66
+ export type ColumnValidator<TValue, TInput = TValue> = {
67
+ write(input: TInput): TValue;
68
+ read(value: TValue): TValue;
69
+ };
30
70
  export declare const defaultCodec: ColumnCodec<unknown, unknown>;
31
71
  export type DefinitionSchema = Record<string, DefinitionNode>;
32
72
  export declare abstract class DefinitionNode<TName extends string = string, TConfig extends object = object> implements TypedObject<TConfig> {
@@ -42,7 +82,14 @@ export declare abstract class DefinitionNode<TName extends string = string, TCon
42
82
  export declare class NodeRef<TNode extends DefinitionNode> extends SQLIdentifier implements TypedObject<TNode["__type"]> {
43
83
  readonly kind: "REFERENCE";
44
84
  readonly __type: TNode["__type"];
45
- constructor(target: TNode);
85
+ /** The schema the target lives in, for a target that has one (a domain). */
86
+ readonly namespace?: string;
87
+ constructor(target: TNode, namespace?: string);
88
+ /**
89
+ * How the migration planner keys the target: `namespace.name` outside `public`, the bare name
90
+ * in it. Two objects with one name in different schemas never collide.
91
+ */
92
+ get qualifiedName(): string;
46
93
  toJSON(): TNode["name"];
47
94
  }
48
95
  //# sourceMappingURL=base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/definition/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;EAeN,CAAC;AAEZ,eAAO,MAAM,QAAQ;;;;EAIV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,QAAQ,CAAC;IAEjC,SAAiB,MAAM,EAAE,OAAO,CAAC;IAEjC,SAAgB,IAAI,EAAE,KAAK,CAAC;gBAEhB,IAAI,EAAE,KAAK;IAIhB,MAAM;;;;CAMd;AAED,qBAAa,OAAO,CAAC,KAAK,SAAS,cAAc,CAC/C,SAAQ,aACR,YAAW,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEvC,SAAgB,IAAI,cAAkB;IAEtC,SAAiB,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEzC,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM;IAK7C;;;OAGG;IACH,IAAI,aAAa,IAAI,MAAM,CAI1B;IAED,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;CAGxB"}
@@ -14,12 +14,33 @@ export const Kind = Object.freeze({
14
14
  CHECK_CONSTRAINT: "CHECK_CONSTRAINT",
15
15
  UNIQUE_CONSTRAINT: "UNIQUE_CONSTRAINT",
16
16
  PRIMARY_KEY_CONSTRAINT: "PRIMARY_KEY_CONSTRAINT",
17
+ TENANT_SCOPE: "TENANT_SCOPE",
18
+ UNION: "UNION",
19
+ UNION_COLUMN: "UNION_COLUMN",
20
+ EMBEDDED_OBJECT: "EMBEDDED_OBJECT",
21
+ COLUMN_GROUP: "COLUMN_GROUP",
17
22
  });
18
23
  export const Relation = Object.freeze({
19
24
  HAS_ONE: "has_one",
20
25
  HAS_MANY: "has_many",
21
26
  BELONGS_TO: "belongs_to",
22
27
  });
28
+ /** The field carrying per-row table metadata on every result record. */
29
+ export const META_FIELD = "$$meta";
30
+ /**
31
+ * The field naming which member of a union a row came from, on every row of a union result.
32
+ * Top level rather than inside `$$meta`: TypeScript narrows a union on a top-level property
33
+ * only (`docs/decisions/0007-global-ids.md`).
34
+ */
35
+ export const KEY_FIELD = "$$key";
36
+ /**
37
+ * Field names a table may use for neither a column nor a relation.
38
+ *
39
+ * The runtime writes them onto result records itself, so a field of the same name would be
40
+ * silently overwritten: `$$meta` on every row, `$$key` on every row of a union result. See
41
+ * `docs/decisions/0004-record-meta.md`.
42
+ */
43
+ export const RESERVED_FIELD_NAMES = Object.freeze([META_FIELD, KEY_FIELD]);
23
44
  export const defaultCodec = {
24
45
  encode(value) {
25
46
  return value;
@@ -42,8 +63,20 @@ export class DefinitionNode {
42
63
  }
43
64
  export class NodeRef extends SQLIdentifier {
44
65
  kind = Kind.REFERENCE;
45
- constructor(target) {
66
+ /** The schema the target lives in, for a target that has one (a domain). */
67
+ namespace;
68
+ constructor(target, namespace) {
46
69
  super(target.name);
70
+ this.namespace = namespace;
71
+ }
72
+ /**
73
+ * How the migration planner keys the target: `namespace.name` outside `public`, the bare name
74
+ * in it. Two objects with one name in different schemas never collide.
75
+ */
76
+ get qualifiedName() {
77
+ return this.namespace && this.namespace !== "public"
78
+ ? `${this.namespace}.${this.name}`
79
+ : this.name;
47
80
  }
48
81
  toJSON() {
49
82
  return this.name;
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/definition/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IAChC,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;IAC5B,SAAS,EAAE,WAAW;IACtB,gBAAgB,EAAE,kBAAkB;IACpC,iBAAiB,EAAE,mBAAmB;IACtC,sBAAsB,EAAE,wBAAwB;CACxC,CAAC,CAAC;AAE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AI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,QAAQ;YAClD,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE;YAClC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IAChB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { SQLIdentifier } from \"../sql/nodes.js\";\nimport { TypedObject } from \"../utils/index.js\";\n\nexport const Kind = Object.freeze({\n SCHEMA: \"SCHEMA\",\n TABLE: \"TABLE\",\n COLUMN: \"COLUMN\",\n INDEX: \"INDEX\",\n DOMAIN: \"DOMAIN\",\n SEQUENCE: \"SEQUENCE\",\n VIEW: \"VIEW\",\n FUNCTION: \"FUNCTION\",\n RELATIONS: \"RELATIONS\",\n INDEX_COLUMN: \"INDEX_COLUMN\",\n REFERENCE: \"REFERENCE\",\n CHECK_CONSTRAINT: \"CHECK_CONSTRAINT\",\n UNIQUE_CONSTRAINT: \"UNIQUE_CONSTRAINT\",\n PRIMARY_KEY_CONSTRAINT: \"PRIMARY_KEY_CONSTRAINT\",\n TENANT_SCOPE: \"TENANT_SCOPE\",\n UNION: \"UNION\",\n UNION_COLUMN: \"UNION_COLUMN\",\n EMBEDDED_OBJECT: \"EMBEDDED_OBJECT\",\n COLUMN_GROUP: \"COLUMN_GROUP\",\n} as const);\n\nexport const Relation = Object.freeze({\n HAS_ONE: \"has_one\",\n HAS_MANY: \"has_many\",\n BELONGS_TO: \"belongs_to\",\n} as const);\n\n/** The field carrying per-row table metadata on every result record. */\nexport const META_FIELD = \"$$meta\";\n\n/**\n * The field naming which member of a union a row came from, on every row of a union result.\n * Top level rather than inside `$$meta`: TypeScript narrows a union on a top-level property\n * only (`docs/decisions/0007-global-ids.md`).\n */\nexport const KEY_FIELD = \"$$key\";\n\n/**\n * Field names a table may use for neither a column nor a relation.\n *\n * The runtime writes them onto result records itself, so a field of the same name would be\n * silently overwritten: `$$meta` on every row, `$$key` on every row of a union result. See\n * `docs/decisions/0004-record-meta.md`.\n */\nexport const RESERVED_FIELD_NAMES: readonly string[] = Object.freeze([META_FIELD, KEY_FIELD]);\n\nexport type NodeKind = (typeof Kind)[keyof typeof Kind];\nexport type RelationType = (typeof Relation)[keyof typeof Relation];\n\n/**\n * Converts a column's values to and from what the driver sends and returns. A codec translates\n * and nothing else: every value bound for the column passes through `encode` — writes, filters,\n * `Column.param` — so a codec that refused values would refuse filters too. Checking a value is\n * {@link ColumnValidator}'s job.\n */\nexport type ColumnCodec<TRaw, TValue> = {\n encode(value: TValue): TRaw;\n decode(raw: TRaw): TValue;\n};\n\n/**\n * Checks a column's values on their way into and out of the database. Writes run `write` before\n * the codec encodes; reads run `read` after it decodes. Filters run neither: a filter value is a\n * pattern to compare with, not a value to store. Either method throws to refuse a value.\n *\n * `write` takes what a write accepts (`TInput`) and returns what is stored (`TValue`); they\n * differ for a column whose writes accept more than its reads return — a JSON column validated\n * by a schema with defaults, for one.\n */\nexport type ColumnValidator<TValue, TInput = TValue> = {\n write(input: TInput): TValue;\n read(value: TValue): TValue;\n};\n\nexport const defaultCodec: ColumnCodec<unknown, unknown> = {\n encode(value) {\n return value;\n },\n decode(raw) {\n return raw;\n },\n};\n\nexport type DefinitionSchema = Record<string, DefinitionNode>;\n\nexport abstract class DefinitionNode<\n TName extends string = string,\n TConfig extends object = object,\n> implements TypedObject<TConfig> {\n abstract readonly kind: NodeKind;\n\n declare readonly __type: TConfig;\n\n public readonly name: TName;\n\n constructor(name: TName) {\n this.name = name;\n }\n\n public toJSON() {\n return {\n kind: this.kind,\n name: this.name,\n };\n }\n}\n\nexport class NodeRef<TNode extends DefinitionNode>\n extends SQLIdentifier\n implements TypedObject<TNode[\"__type\"]>\n{\n public readonly kind = Kind.REFERENCE;\n\n declare readonly __type: TNode[\"__type\"];\n\n /** The schema the target lives in, for a target that has one (a domain). */\n readonly namespace?: string;\n\n constructor(target: TNode, namespace?: string) {\n super(target.name);\n this.namespace = namespace;\n }\n\n /**\n * How the migration planner keys the target: `namespace.name` outside `public`, the bare name\n * in it. Two objects with one name in different schemas never collide.\n */\n get qualifiedName(): string {\n return this.namespace && this.namespace !== \"public\"\n ? `${this.namespace}.${this.name}`\n : this.name;\n }\n\n toJSON(): TNode[\"name\"] {\n return this.name;\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { SQLIdentifier, SQLNode } from "../sql/nodes.js";
2
- import { HasDefault, NotNull, PrimaryKey, TypedObject, Unique, ValueType } from "../utils/index.js";
3
- import { ColumnCodec, DefinitionNode, NodeRef } from "./base.js";
2
+ import { HasDefault, NotNull, PrimaryKey, ReadOnly, Deprecated, TypedObject, Unique, ValueType } from "../utils/index.js";
3
+ import { ColumnCodec, ColumnValidator, DefinitionNode, NodeRef } from "./base.js";
4
4
  import { AnyCheckConstraintDefinition } from "./constraint.js";
5
5
  import { AnyDomainDefinition } from "./domain.js";
6
6
  import { SequenceOptions } from "./sequence.js";
@@ -8,44 +8,78 @@ export type UpdateGuard<T extends TypedObject> = T["__type"] extends {
8
8
  primaryKey: true;
9
9
  } ? never : T;
10
10
  export type ColumnGeneratedType = "ALWAYS" | "BY DEFAULT";
11
- export interface ColumnGeneratedConfig {
11
+ /** What `$type<T>()` sets: `T`, or on an `array` column `T` as an array unless it is one. */
12
+ export type TypeArgOf<TColumn extends TypedObject, T> = TColumn["__type"] extends {
13
+ runtimeType: "array";
14
+ } ? T extends readonly unknown[] ? T : T[] : T;
15
+ export type ColumnGeneratedConfig = {
12
16
  type: "ALWAYS";
13
17
  expression: SQLNode;
14
18
  mode: "STORED";
15
- }
16
- export interface ColumnIdentityConfig {
19
+ };
20
+ export type ColumnIdentityConfig = {
17
21
  type: ColumnGeneratedType;
18
22
  options: SequenceOptions;
19
23
  sequenceName?: string;
20
- }
21
- export interface ColumnConfig<TValueType = unknown, TRawType = unknown> {
24
+ };
25
+ /**
26
+ * The kind of value a column holds, for querying: it decides which filter operators apply to
27
+ * the column, whether a bare value stands for `eq`, and whether it can be ordered. It names the
28
+ * database value's kind, not its JavaScript form — a `date()` read as a string is still `date`.
29
+ *
30
+ * `json` and `jsonb` are separate because only `jsonb` has equality and containment. `array`
31
+ * and `object` are `jsonb` columns holding an array or an object at the top level.
32
+ */
33
+ export type ColumnRuntimeType = "string" | "uuid" | "number" | "bigint" | "boolean" | "date" | "interval" | "bytes" | "json" | "jsonb" | "array" | "object";
34
+ export type ColumnConfig<TValueType = unknown, TRawType = unknown, TRuntimeType extends ColumnRuntimeType = ColumnRuntimeType, TInputType = TValueType> = {
22
35
  dataType: string;
36
+ runtimeType: TRuntimeType;
37
+ /** What a read returns. */
23
38
  valueType: TValueType;
39
+ /**
40
+ * What a write — `create`, `update`, a default — accepts: the validator's input. The read type
41
+ * unless set apart. Filters take the read type, since they compare with stored values.
42
+ */
43
+ inputType: TInputType;
24
44
  rawType: TRawType;
25
45
  notNull: boolean;
26
46
  primaryKey: boolean;
27
47
  unique: boolean;
48
+ readOnly: boolean;
49
+ tenantKey: boolean;
28
50
  codec: ColumnCodec<TRawType, TValueType>;
51
+ validator?: ColumnValidator<TValueType, TInputType>;
29
52
  defaultValue?: SQLNode;
30
53
  domain?: NodeRef<AnyDomainDefinition>;
31
54
  generated?: ColumnGeneratedConfig;
32
55
  identity?: ColumnIdentityConfig;
33
- }
56
+ };
34
57
  export type AnyColumnDefinition = ColumnDefinition<string, ColumnConfig>;
35
58
  export declare class ColumnDefinition<TName extends string, TConfig extends ColumnConfig> extends DefinitionNode<TName, TConfig> {
36
59
  readonly kind: "COLUMN";
37
60
  protected _dataType: string;
61
+ protected _runtimeType: ColumnRuntimeType;
38
62
  protected _notNull: boolean;
39
63
  protected _primaryKey: boolean;
40
64
  protected _unique: boolean;
65
+ protected _readOnly: boolean;
66
+ protected _tenantKey: boolean;
41
67
  protected _defaultValue?: SQLNode;
42
68
  protected _domain?: NodeRef<AnyDomainDefinition>;
43
69
  protected _check?: AnyCheckConstraintDefinition;
70
+ /** What `.check()` was called with, so a renamed copy can rebuild the constraint. */
71
+ protected _checkSource?: {
72
+ build: (self: SQLIdentifier) => SQLNode;
73
+ name?: string;
74
+ };
44
75
  protected _generated?: ColumnGeneratedConfig;
45
76
  protected _identity?: ColumnIdentityConfig;
77
+ protected _deprecated: boolean;
78
+ protected _renamedFrom?: string;
46
79
  protected _codec: ColumnCodec<this["__type"]["rawType"], this["__type"]["valueType"]>;
47
- protected _onCreate?: () => this["__type"]["valueType"];
48
- protected _onUpdate?: () => this["__type"]["valueType"];
80
+ protected _validator?: ColumnValidator<this["__type"]["valueType"], this["__type"]["inputType"]>;
81
+ protected _onCreate?: () => this["__type"]["inputType"];
82
+ protected _onUpdate?: () => this["__type"]["inputType"];
49
83
  constructor(name: TName, config?: Partial<TConfig>);
50
84
  /**
51
85
  * Marks the column as `NOT NULL`. This means that the column cannot contain null values.
@@ -53,7 +87,38 @@ export declare class ColumnDefinition<TName extends string, TConfig extends Colu
53
87
  notNull(): NotNull<this>;
54
88
  primaryKey(): PrimaryKey<this>;
55
89
  unique(): Unique<this>;
56
- default(value: this["__type"]["valueType"]): HasDefault<this>;
90
+ /**
91
+ * Marks the column as system-managed: it is dropped from `create` and `update` inputs, both
92
+ * in the types and at runtime, while staying fully readable — selectable, filterable and
93
+ * orderable. Its value comes from whatever owns it, never from the caller.
94
+ */
95
+ readOnly(): ReadOnly<this>;
96
+ /**
97
+ * Marks the column for removal. It stays in the database, but leaves the client: it can't be
98
+ * selected, filtered, ordered by or written — inserts give it its default, or `NULL`. A later
99
+ * release removes it from the definition, and the migration then drops it as a planned,
100
+ * lossy step instead of a destructive one: the database records the deprecation (as a column
101
+ * comment), and a `NOT NULL` without a default is dropped so the column can be left unset.
102
+ */
103
+ deprecated(): Deprecated<this>;
104
+ /**
105
+ * The column's previous name: the migration renames it (`RENAME COLUMN`) instead of dropping
106
+ * one column and adding another, which would lose the data. Once the database has the new
107
+ * name the hint does nothing, so it can stay for a release before it is removed.
108
+ */
109
+ renamedFrom(previous: string): this;
110
+ /**
111
+ * A copy of this definition, of the same class, carrying the same configuration.
112
+ *
113
+ * A `ColumnDefinition` belongs to the table it is declared on: the builders mutate it in
114
+ * place, so one instance shared by two tables would let a later `.check()` on one reach the
115
+ * other. Anything that hands the same declaration to several tables — `tenantScope().columns()`
116
+ * is the first — copies it here instead.
117
+ */
118
+ clone(): this;
119
+ default(value: this["__type"]["inputType"]): HasDefault<this>;
120
+ /** A value a write accepts, as it will be stored: through the validator, if there is one. */
121
+ protected _toValue(input: this["__type"]["inputType"]): this["__type"]["valueType"];
57
122
  /**
58
123
  * Adds a check constraint to the column.
59
124
  *
@@ -69,9 +134,14 @@ export declare class ColumnDefinition<TName extends string, TConfig extends Colu
69
134
  * @returns
70
135
  */
71
136
  check(cb: (self: SQLIdentifier) => SQLNode, name?: string): this;
72
- $type<T>(): ValueType<this, T>;
73
- $onCreate(cb: () => this["__type"]["valueType"]): this;
74
- $onUpdate(cb: () => this["__type"]["valueType"]): UpdateGuard<this>;
137
+ /**
138
+ * Types the column's values. Type-only: nothing checks them. On a column of runtime type
139
+ * `array`, `T` may be the item type or the array type — `$type<string>()` and
140
+ * `$type<string[]>()` both give `string[]`.
141
+ */
142
+ $type<T>(): ValueType<this, TypeArgOf<this, T>>;
143
+ $onCreate(cb: () => this["__type"]["inputType"]): this;
144
+ $onUpdate(cb: () => this["__type"]["inputType"]): UpdateGuard<this>;
75
145
  toJSON(): {
76
146
  readonly kind: "COLUMN";
77
147
  readonly name: TName;
@@ -84,6 +154,7 @@ export declare class ColumnDefinition<TName extends string, TConfig extends Colu
84
154
  readonly kind: "CHECK_CONSTRAINT";
85
155
  readonly name: string;
86
156
  readonly expression: string;
157
+ readonly validated: boolean;
87
158
  } | null;
88
159
  readonly domain: string | null;
89
160
  readonly generated: {
@@ -105,6 +176,8 @@ export declare class ColumnDefinition<TName extends string, TConfig extends Colu
105
176
  ownedBy: string | undefined;
106
177
  } | null;
107
178
  } | null;
179
+ readonly deprecated: boolean;
180
+ readonly renamedFrom: string | null;
108
181
  };
109
182
  }
110
183
  //# sourceMappingURL=column.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"column.d.ts","sourceRoot":"","sources":["../../src/definition/column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAsB,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpG,OAAO,EAAE,WAAW,EAAgB,cAAc,EAAQ,OAAO,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EAAE,4BAA4B,EAA6B,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS;IAAE,UAAU,EAAE,IAAI,CAAA;CAAE,GACrF,KAAK,GACL,CAAC,CAAC;AAEN,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE1D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,eAAe,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY,CAAC,UAAU,GAAG,OAAO,EAAE,QAAQ,GAAG,OAAO;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EA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