@rebasepro/types 0.30.0 → 0.31.0-canary.g902a0ce

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 (57) hide show
  1. package/README.md +16 -18
  2. package/dist/call_context.d.ts +3 -3
  3. package/dist/controllers/client.d.ts +29 -0
  4. package/dist/controllers/data.d.ts +85 -332
  5. package/dist/controllers/data_driver.d.ts +47 -57
  6. package/dist/controllers/index.d.ts +0 -3
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.es.js +2567 -1151
  9. package/dist/index.es.js.map +1 -1
  10. package/dist/schema/column_options.d.ts +336 -0
  11. package/dist/schema/column_type.d.ts +116 -0
  12. package/dist/schema/columns.d.ts +646 -0
  13. package/dist/schema/compiled.d.ts +114 -0
  14. package/dist/schema/descriptor.d.ts +349 -0
  15. package/dist/schema/hooks.d.ts +164 -0
  16. package/dist/schema/index.d.ts +13 -0
  17. package/dist/schema/infer.d.ts +340 -0
  18. package/dist/schema/json.d.ts +237 -0
  19. package/dist/schema/relations.d.ts +205 -0
  20. package/dist/schema/table.d.ts +304 -0
  21. package/dist/schema/table_options.d.ts +103 -0
  22. package/dist/schema/table_patch.d.ts +338 -0
  23. package/dist/types/auth_adapter.d.ts +12 -6
  24. package/dist/types/auth_hooks.d.ts +65 -0
  25. package/dist/types/backend.d.ts +85 -96
  26. package/dist/types/data_source.d.ts +4 -9
  27. package/dist/types/database_adapter.d.ts +30 -31
  28. package/dist/types/entities.d.ts +0 -162
  29. package/dist/types/filter-operators.d.ts +2 -26
  30. package/dist/types/history.d.ts +6 -9
  31. package/dist/types/index.d.ts +3 -9
  32. package/dist/types/mcp_app_modules.d.ts +0 -2
  33. package/dist/types/policy.d.ts +85 -10
  34. package/dist/types/project_manifest.d.ts +113 -46
  35. package/dist/types/read_query.d.ts +98 -0
  36. package/dist/types/register.d.ts +35 -5
  37. package/dist/types/relations.d.ts +0 -430
  38. package/dist/types/schema_editing.d.ts +54 -2
  39. package/dist/types/schema_version.d.ts +24 -4
  40. package/dist/types/security_rules.d.ts +225 -15
  41. package/dist/types/storage_authorize.d.ts +2 -2
  42. package/dist/types/tenancy.d.ts +3 -3
  43. package/dist/types/ui_preferences.d.ts +228 -0
  44. package/package.json +3 -2
  45. package/dist/controllers/auth_state.d.ts +0 -23
  46. package/dist/controllers/collection_registry.d.ts +0 -67
  47. package/dist/controllers/effective_role.d.ts +0 -4
  48. package/dist/types/admin_block.d.ts +0 -96
  49. package/dist/types/chips.d.ts +0 -16
  50. package/dist/types/collection_contract.d.ts +0 -43
  51. package/dist/types/collection_patch.d.ts +0 -74
  52. package/dist/types/collections.d.ts +0 -783
  53. package/dist/types/component_ref.d.ts +0 -81
  54. package/dist/types/conditions-contract.types.d.ts +0 -14
  55. package/dist/types/entity_callbacks.d.ts +0 -393
  56. package/dist/types/indexes.d.ts +0 -179
  57. package/dist/types/properties.d.ts +0 -1640
@@ -0,0 +1,646 @@
1
+ import type { ColumnKind, ColumnType, NumericColumnKind, TemporalColumnKind, TextColumnKind } from "./column_type.js";
2
+ import type { ArrayValidation, BaseValidation, ColumnAccess, ColumnDefault, ColumnStamp, ColumnStorage, ColumnValidation, DateValidation, NumberValidation, StorageOptions, StringValidation, VectorIndexOptions } from "./column_options.js";
3
+ import type { ColumnTransform } from "./hooks.js";
4
+ import type { JsonField, JsonGeoPoint, JsonKind, JsonShapeDef } from "./json.js";
5
+ /**
6
+ * Every Drizzle spelling Rebase refuses, with the instruction it shows.
7
+ *
8
+ * Each text is used twice: as a string-literal *type* placed where the
9
+ * developer wrote the refused thing (a `this` parameter, a config key, an
10
+ * argument), so TypeScript prints the instruction verbatim; and as the message
11
+ * thrown at run time, for a JavaScript caller the types do not reach. See
12
+ * `drizzle-alignment.md` for the table of Drizzle spellings.
13
+ *
14
+ * @group Schema
15
+ */
16
+ export declare const DRIZZLE_REFUSALS: {
17
+ /** `col.timestamp()` without `withTimezone: true`: Drizzle's timestamp WITHOUT time zone. */
18
+ readonly timestamp: "Rebase stores instants as timestamptz: write `col.timestamp({ withTimezone: true })`. For a timestamp without time zone write `col.custom({ dataType: \"timestamp\" })`.";
19
+ /** `col.timestamp({ mode: "date" })`: Drizzle's Date-typed mode. */
20
+ readonly timestampMode: "Rebase serves a timestamp as an ISO string: leave `mode` out or write `mode: \"string\"`.";
21
+ /** `col.timestamp({ precision })`. */
22
+ readonly timestampPrecision: "Rebase does not state a timestamp's precision: leave `precision` out, or write `col.custom({ dataType: \"timestamp(3) with time zone\" })`.";
23
+ /** `col.date({ mode: "date" })`: Drizzle's Date-typed mode. */
24
+ readonly dateMode: "Rebase serves a date as a `YYYY-MM-DD` string: leave `mode` out or write `mode: \"string\"`.";
25
+ /** `col.time({ withTimezone: true })`: a `timetz`. */
26
+ readonly timeZone: "`col.time()` is a time without time zone: leave `withTimezone` out, or write `col.custom({ dataType: \"timetz\" })`.";
27
+ /** `col.time({ precision })`. */
28
+ readonly timePrecision: "Rebase does not state a time's precision: leave `precision` out, or write `col.custom({ dataType: \"time(3)\" })`.";
29
+ /** `col.numeric({ mode: "string" | "bigint" })`: our value is a JSON number. */
30
+ readonly numericMode: "Rebase reads and writes numeric as a JSON number: leave `mode` out or write `mode: \"number\"`. For exact decimals kept as text write `col.text()`.";
31
+ /** `col.bigint({ mode: "bigint" })`: our value is a JSON number. */
32
+ readonly bigintMode: "Rebase serves bigint as a JSON number: write `{ mode: \"number\" }`. For exact 64-bit values write `col.numeric()` or `col.text()`.";
33
+ /** `col.varchar("name")` / `col.varchar({ enum })` without a length. */
34
+ readonly varcharLength: "`col.varchar()` needs a length (a bare varchar is unbounded in Postgres and Drizzle): write `col.varchar({ length: 255 })`, or `col.text()` for text of any length.";
35
+ /** `col.char("name")` / `col.char({ enum })` without a length. */
36
+ readonly charLength: "`col.char()` needs a length (a bare char is char(1) in Postgres and Drizzle): write `col.char({ length: 2 })`.";
37
+ /** `.generatedAlwaysAsIdentity()`: the planner creates BY DEFAULT identities only. */
38
+ readonly identityAlways: "Rebase creates identity columns GENERATED BY DEFAULT: write `.generatedByDefaultAsIdentity()`.";
39
+ /** `.generatedByDefaultAsIdentity({ … })`: sequence options. */
40
+ readonly identityOptions: "Rebase does not take sequence options: write `.generatedByDefaultAsIdentity()` with no argument.";
41
+ /** `.references(() => …)`: a foreign key is a `rel.belongsTo`. */
42
+ readonly references: "A foreign key is a relation in Rebase: write `relations: { author: rel.belongsTo(() => users, { localKey: \"author_id\", onDelete: \"cascade\" }) }`. The relation's key is what `include` names.";
43
+ /** `.$defaultFn()` / `.$default()`: a run-time default function. */
44
+ readonly defaultFn: "Rebase's schema is data, not code: a default is `.default(value)` or `.default(sql`…`)`; the time is `.defaultNow()` or `.onCreateNow()`, the caller `.onCreateUser()`; anything else belongs in `hooks.beforeSave`.";
45
+ /** `.$onUpdate()` / `.$onUpdateFn()`: a run-time update function. */
46
+ readonly onUpdateFn: "Rebase's schema is data, not code: write `.onUpdateNow()` for the time, `.onUpdateUser()` for the caller; anything else belongs in `hooks.beforeSave`.";
47
+ /** `.unique(name, { nulls })`: a named or NULLS NOT DISTINCT constraint. */
48
+ readonly uniqueName: "Rebase derives constraint names and keeps NULLs distinct: write `.unique()`, or a unique index under `indexes`.";
49
+ /** `.generatedAlwaysAs(value)` with something other than a `sql` expression. */
50
+ readonly generatedValue: "`.generatedAlwaysAs()` takes a SQL expression: write `.generatedAlwaysAs(sql`…`)`.";
51
+ /** `.array(size)`. */
52
+ readonly arraySize: "Postgres ignores array sizes: write `.array()`.";
53
+ /** `.notNull()` & co. before `.array()`. */
54
+ readonly arrayOrder: "`.notNull()`, a default, `.primaryKey()`, `.readOnly()` and `.private()` before `.array()` would describe each item: write them after it, as in `col.text().array().notNull()`.";
55
+ /** `.array().array()`. */
56
+ readonly arrayOfArray: "An array of arrays is not supported: use `col.jsonb()` for nested lists.";
57
+ /** `sql` with an interpolation. */
58
+ readonly sqlInterpolation: "`sql` writes its text into the DDL verbatim: write the expression inline, without `${…}`.";
59
+ /** `col.bigint()` / `col.bigserial()` without `{ mode }`. */
60
+ readonly bigintModeMissing: "`col.bigint()` and `col.bigserial()` take Drizzle's `{ mode: \"number\" }`: write `col.bigint({ mode: \"number\" })`.";
61
+ /** `col.numeric(10, 2)`: positional precision and scale. */
62
+ readonly numericPositional: "`col.numeric()` takes a config object: write `col.numeric({ precision: 10, scale: 2 })`.";
63
+ /** `col.vector(1536)`: positional dimensions. */
64
+ readonly vectorPositional: "`col.vector()` takes a config object: write `col.vector({ dimensions: 1536 })`.";
65
+ /** `col.enum(values, { name })`: a named enum type. */
66
+ readonly enumName: "A named Postgres enum type is declared once with `pgEnum`: write `const postStatus = pgEnum(\"post_status\", [...])`, then `postStatus()` in the column.";
67
+ /** `col.custom("inet")`: a lone string is the SQL column name. */
68
+ readonly customDataType: "`col.custom()` names its Postgres type in a config object: write `col.custom({ dataType: \"inet\" })`, or `col.custom(\"ip\", { dataType: \"inet\" })` with a SQL column name.";
69
+ /** `pgEnum(name, { A: "a" })`: Drizzle's object form. */
70
+ readonly pgEnumObject: "`pgEnum(name, values)` takes the list of labels: write `pgEnum(\"post_status\", [\"draft\", \"published\"])`.";
71
+ };
72
+ type Refusal = typeof DRIZZLE_REFUSALS;
73
+ /** The brand of a {@link sql} expression. */
74
+ export declare const SQL_BRAND = "rebase.sql";
75
+ /**
76
+ * A SQL expression written with the {@link sql} tag: `sql\`now()\``.
77
+ *
78
+ * @group Schema
79
+ */
80
+ export interface SqlTemplate {
81
+ /** Marks a value as written with the {@link sql} tag. */
82
+ readonly brand: typeof SQL_BRAND;
83
+ /** The expression, exactly as written between the backticks. */
84
+ readonly text: string;
85
+ }
86
+ /**
87
+ * A SQL expression for a default or a generated column, as Drizzle writes it:
88
+ * `.default(sql\`gen_short_id()\`)`, `.generatedAlwaysAs(sql\`lower(email)\`)`.
89
+ *
90
+ * The text goes into the DDL verbatim, so it takes no interpolation: write the
91
+ * expression inline.
92
+ *
93
+ * @group Schema
94
+ */
95
+ export declare function sql(strings: TemplateStringsArray, ...values: Refusal["sqlInterpolation"][]): SqlTemplate;
96
+ /**
97
+ * Whether a value is a {@link sql} expression, from this copy of the package or another.
98
+ *
99
+ * @group Schema
100
+ */
101
+ export declare function isSqlTemplate(value: unknown): value is SqlTemplate;
102
+ /**
103
+ * Everything a column builder has been told, as data.
104
+ *
105
+ * Wire-safe except for `transform` and the hooks inside `json`, which stay on
106
+ * the server.
107
+ *
108
+ * @group Schema
109
+ */
110
+ export interface ColumnDef {
111
+ /** The Postgres type. */
112
+ type: ColumnType;
113
+ /** The SQL column name, when it is not the snake_case of the key. */
114
+ column?: string;
115
+ notNull: boolean;
116
+ primaryKey: boolean;
117
+ unique: boolean;
118
+ default?: ColumnDefault;
119
+ /** `GENERATED ALWAYS AS (<expression>) STORED`. */
120
+ generatedAs?: string;
121
+ readOnly: boolean;
122
+ private: boolean;
123
+ access?: ColumnAccess;
124
+ stamp?: ColumnStamp;
125
+ validate?: ColumnValidation;
126
+ oneOf?: readonly (string | number)[];
127
+ description?: string;
128
+ storage?: ColumnStorage;
129
+ /**
130
+ * A meaning the Postgres type does not state: `"geopoint"` (`col.geopoint()`,
131
+ * a `jsonb` point) or `"user"` (`.userId()`, a text or uuid column holding a
132
+ * user's id).
133
+ */
134
+ semantic?: "geopoint" | "user";
135
+ vectorIndex?: VectorIndexOptions | false;
136
+ /** The shape of a `json`/`jsonb` document. */
137
+ json?: JsonShapeDef;
138
+ /** For an array column: the definition of each item. */
139
+ element?: ColumnDef;
140
+ /** Field-level hooks. Server only. */
141
+ transform?: ColumnTransform;
142
+ }
143
+ /**
144
+ * The type-level tag of a builder. A {@link ColumnKind}, or one of the two
145
+ * builders whose meaning the Postgres type alone does not state.
146
+ */
147
+ export type BuilderKind = ColumnKind | "storage" | "geopoint";
148
+ /**
149
+ * What the type system tracks about a column besides its data type.
150
+ *
151
+ * @group Schema
152
+ */
153
+ export interface ColumnFlags {
154
+ /** `NOT NULL`: never `null` on a row, required on create unless it has a default. */
155
+ notNull: boolean;
156
+ /** A create may omit it. */
157
+ hasDefault: boolean;
158
+ /** Clients may write it. */
159
+ writable: boolean;
160
+ /** It is served on the wire. */
161
+ exposed: boolean;
162
+ /** Part of the primary key. */
163
+ primaryKey: boolean;
164
+ }
165
+ /** The flags of a column no modifier has touched: nullable, required-by-nobody, writable, served. */
166
+ export interface InitialColumnFlags extends ColumnFlags {
167
+ notNull: false;
168
+ hasDefault: false;
169
+ writable: true;
170
+ exposed: true;
171
+ primaryKey: false;
172
+ }
173
+ /**
174
+ * The value a column's `.transform()` hooks receive and return: the column's
175
+ * type, plus `null` while the column is nullable.
176
+ *
177
+ * Read from the flags at the point `.transform()` is called, so the order of
178
+ * the chain matters: `.notNull().transform(…)` (or `.primaryKey()` first)
179
+ * receives `TData`; `.transform(…).notNull()` was typed before the column
180
+ * became `NOT NULL` and keeps receiving `TData | null`. Write `.notNull()`
181
+ * first.
182
+ *
183
+ * @group Schema
184
+ */
185
+ export type ColumnTransformValue<TData, F extends ColumnFlags> = F["notNull"] extends true ? TData : TData | null;
186
+ type SetFlag<F extends ColumnFlags, K extends keyof ColumnFlags, V extends boolean> = {
187
+ [P in keyof ColumnFlags]: P extends K ? V : F[P];
188
+ };
189
+ type WithDefault<F extends ColumnFlags> = SetFlag<F, "hasDefault", true>;
190
+ /** The rules `.validate()` accepts for a kind of column. */
191
+ export type ValidationFor<K extends BuilderKind> = K extends TextColumnKind | "storage" ? StringValidation : K extends NumericColumnKind ? NumberValidation : K extends TemporalColumnKind ? DateValidation : K extends "array" ? ArrayValidation : BaseValidation;
192
+ /** The value `.default()` accepts: what the column holds; a `Date` too, for a temporal column. */
193
+ export type DefaultValueFor<TData, K extends BuilderKind> = K extends TemporalColumnKind ? TData | Date : TData;
194
+ /** The brand every column builder carries, so one built by another copy of this package is still recognised. */
195
+ export declare const COLUMN_BRAND = "rebase.column";
196
+ /**
197
+ * One column of a table: `col.text()`, `col.uuid().primaryKey()`, ….
198
+ *
199
+ * Immutable — every modifier returns a new builder — so a column can be shared
200
+ * between tables. Columns are nullable until `.notNull()` or `.primaryKey()`
201
+ * says otherwise, as in SQL.
202
+ *
203
+ * @typeParam TData The TypeScript type of a value on the wire.
204
+ * @typeParam TKind Which builder made it; decides which modifiers apply.
205
+ * @typeParam F What has been said about it so far.
206
+ *
207
+ * @group Schema
208
+ */
209
+ export declare class ColumnBuilder<TData, TKind extends BuilderKind = BuilderKind, F extends ColumnFlags = InitialColumnFlags> {
210
+ /** Everything this column has been told. */
211
+ readonly def: ColumnDef;
212
+ /** Type-level only: the TypeScript type of a value. */
213
+ readonly $data: TData;
214
+ /** Type-level only: the builder kind. */
215
+ readonly $kind: TKind;
216
+ /** Type-level only: the flags. */
217
+ readonly $flags: F;
218
+ readonly brand = "rebase.column";
219
+ constructor(
220
+ /** Everything this column has been told. */
221
+ def: ColumnDef);
222
+ private with;
223
+ /**
224
+ * The patch that sets a stamp, refusing a second, different one: a column
225
+ * holds one stamp, so `.onCreateNow().onUpdateNow()` would otherwise keep
226
+ * whichever came last without a word.
227
+ */
228
+ private stamped;
229
+ /**
230
+ * Types the value without changing the column, as Drizzle's `$type`:
231
+ * `col.jsonb().$type<{ seoTitle?: string }>()`, `col.integer().$type<UserId>()`.
232
+ * Nothing is checked at run time; use `col.jsonb(json.object({...}))` for
233
+ * a shape the server enforces.
234
+ */
235
+ $type<T>(): ColumnBuilder<T, TKind, F>;
236
+ /** `NOT NULL`. The API requires the column on create unless it has a default. */
237
+ notNull(): ColumnBuilder<TData, TKind, SetFlag<F, "notNull", true>>;
238
+ /**
239
+ * Part of the primary key. Several columns marked this way form a composite
240
+ * key, in declaration order.
241
+ */
242
+ primaryKey(): ColumnBuilder<TData, TKind, SetFlag<SetFlag<F, "notNull", true>, "primaryKey", true>>;
243
+ /**
244
+ * A single-column `UNIQUE` constraint. Its name is derived; Drizzle's
245
+ * `.unique(name, { nulls })` arguments are refused.
246
+ */
247
+ unique(name?: Refusal["uniqueName"], config?: Refusal["uniqueName"]): ColumnBuilder<TData, TKind, F>;
248
+ /**
249
+ * A default: a value, written as the column's DDL default and applied by
250
+ * the driver on create, so a row comes out the same whoever inserts it — or
251
+ * an expression Postgres evaluates, `.default(sql\`gen_short_id()\`)`.
252
+ */
253
+ default(value: DefaultValueFor<TData, TKind> | SqlTemplate): ColumnBuilder<TData, TKind, WithDefault<F>>;
254
+ /** Refused: Drizzle's run-time default function. See {@link DRIZZLE_REFUSALS}. */
255
+ $defaultFn(this: Refusal["defaultFn"], ..._args: unknown[]): never;
256
+ /** Refused: Drizzle's alias of `$defaultFn`. See {@link DRIZZLE_REFUSALS}. */
257
+ $default(this: Refusal["defaultFn"], ..._args: unknown[]): never;
258
+ /** Refused: Drizzle's run-time update function. See {@link DRIZZLE_REFUSALS}. */
259
+ $onUpdate(this: Refusal["onUpdateFn"], ..._args: unknown[]): never;
260
+ /** Refused: Drizzle's run-time update function. See {@link DRIZZLE_REFUSALS}. */
261
+ $onUpdateFn(this: Refusal["onUpdateFn"], ..._args: unknown[]): never;
262
+ /**
263
+ * Refused: a foreign key is a relation, `rel.belongsTo(() => users, {...})`
264
+ * under `relations`, whose key is what `include` names.
265
+ */
266
+ references(this: Refusal["references"], ..._args: unknown[]): never;
267
+ /**
268
+ * The database already holds a default for this column that Rebase does not
269
+ * state. A create may omit the column, and a schema push leaves the default
270
+ * alone.
271
+ */
272
+ dbDefault(): ColumnBuilder<TData, TKind, WithDefault<F>>;
273
+ /**
274
+ * `GENERATED ALWAYS AS (<expression>) STORED`, as Drizzle writes it:
275
+ * `.generatedAlwaysAs(sql\`lower(email)\`)`. Nobody writes the column.
276
+ */
277
+ generatedAlwaysAs(as: SqlTemplate | (() => SqlTemplate)): ColumnBuilder<TData, TKind, SetFlag<WithDefault<F>, "writable", false>>;
278
+ /**
279
+ * Client writes are refused on create and update. The database (a default,
280
+ * a trigger) and the server's own code still fill it.
281
+ */
282
+ readOnly(): ColumnBuilder<TData, TKind, SetFlag<F, "writable", false>>;
283
+ /**
284
+ * Never leaves the server: absent from every row on the wire, from the SDK
285
+ * and from OpenAPI, and refused in filters and sorts. Hooks and server code
286
+ * still see it.
287
+ */
288
+ private(): ColumnBuilder<TData, TKind, SetFlag<SetFlag<F, "exposed", false>, "writable", false>>;
289
+ /**
290
+ * Who may read and who may write the column, by role. Enforced on every
291
+ * door into the table, not only in the panel. `read` and `write` are lists
292
+ * of role names; anything else throws.
293
+ */
294
+ access(access: ColumnAccess): ColumnBuilder<TData, TKind, F>;
295
+ /** What the column holds, for OpenAPI and MCP tool descriptions. */
296
+ describe(description: string): ColumnBuilder<TData, TKind, F>;
297
+ /** Rules the API checks before a write. */
298
+ validate(rules: ValidationFor<TKind>): ColumnBuilder<TData, TKind, F>;
299
+ /**
300
+ * Field-level hooks: `beforeSave` returns the value to store, `afterRead`
301
+ * the value to serve. They run on the server, for every caller.
302
+ *
303
+ * The value is `TData | null` on a column not (yet) marked `.notNull()` /
304
+ * `.primaryKey()` — a nullable column hands the hook `null` — and `TData`
305
+ * on one that is; see {@link ColumnTransformValue}. Chain `.notNull()`
306
+ * before `.transform()` to get the narrower type.
307
+ */
308
+ transform(transform: ColumnTransform<ColumnTransformValue<TData, F>>): ColumnBuilder<TData, TKind, F>;
309
+ /**
310
+ * A closed set of accepted values that is *not* a Postgres enum type: the
311
+ * API refuses anything else and the SDK types the column as their union.
312
+ * Use `col.enum()` when the database should enforce it too.
313
+ *
314
+ * On a number column. On a text column write Drizzle's spelling,
315
+ * `col.text({ enum: [...] })`.
316
+ */
317
+ oneOf<const V extends readonly TData[], K extends TextColumnKind | NumericColumnKind>(this: ColumnBuilder<TData, K, F>, values: V): ColumnBuilder<V[number], K, F>;
318
+ /** `DEFAULT gen_random_uuid()`. */
319
+ defaultRandom(this: ColumnBuilder<string, "uuid", F>): ColumnBuilder<string, "uuid", WithDefault<F>>;
320
+ /** `GENERATED BY DEFAULT AS IDENTITY`. Sequence options are refused. */
321
+ generatedByDefaultAsIdentity<K extends "smallint" | "integer" | "bigint">(this: ColumnBuilder<number, K, F>, sequence?: Refusal["identityOptions"]): ColumnBuilder<number, K, WithDefault<F>>;
322
+ /** Refused: Rebase creates identity columns `GENERATED BY DEFAULT`. See {@link DRIZZLE_REFUSALS}. */
323
+ generatedAlwaysAsIdentity(this: Refusal["identityAlways"], ..._args: unknown[]): never;
324
+ /**
325
+ * A Postgres array of this column's type, as Drizzle writes it:
326
+ * `col.text().array()` is `TEXT[]`. What is chained before `.array()`
327
+ * describes each item (`col.text({ enum: [...] }).array()`,
328
+ * `col.integer().validate({ min: 0 }).array()`); column modifiers come
329
+ * after it (`.array().notNull().default([])`). A leading SQL name
330
+ * (`col.text("tag_list").array()`) names the array column.
331
+ */
332
+ array(this: F extends InitialColumnFlags ? TKind extends "array" ? Refusal["arrayOfArray"] : ColumnBuilder<TData, TKind, F> : Refusal["arrayOrder"], size?: Refusal["arraySize"]): ColumnBuilder<TData[], "array">;
333
+ /**
334
+ * `DEFAULT now()`, as Drizzle's `defaultNow()`: a DDL default a client may
335
+ * still override. `.onCreateNow()` is the server stamp the client cannot.
336
+ */
337
+ defaultNow<K extends TemporalColumnKind>(this: ColumnBuilder<string, K, F>): ColumnBuilder<string, K, WithDefault<F>>;
338
+ /** The server stamps the current time when the row is created (`DEFAULT now()`). */
339
+ onCreateNow<K extends TemporalColumnKind>(this: ColumnBuilder<string, K, F>): ColumnBuilder<string, K, WithDefault<F>>;
340
+ /**
341
+ * The server stamps the current time on every write: `DEFAULT now()`, a
342
+ * `BEFORE UPDATE` trigger, and the driver's own stamp.
343
+ */
344
+ onUpdateNow<K extends TemporalColumnKind>(this: ColumnBuilder<string, K, F>): ColumnBuilder<string, K, WithDefault<F>>;
345
+ /** The server writes the caller's id when the row is created. */
346
+ onCreateUser<K extends TextColumnKind | "uuid">(this: ColumnBuilder<string, K, F>): ColumnBuilder<string, K, WithDefault<F>>;
347
+ /** The server writes the caller's id on every write. */
348
+ onUpdateUser<K extends TextColumnKind | "uuid">(this: ColumnBuilder<string, K, F>): ColumnBuilder<string, K, WithDefault<F>>;
349
+ /**
350
+ * The column holds the id of a user. The panel offers a user picker for it,
351
+ * and callers who may write the table may look users up to fill it (the
352
+ * user picker's read answers them even though row-level security hides
353
+ * other users' rows).
354
+ *
355
+ * Only on `col.text()`, `col.varchar()`, `col.char()` and `col.uuid()`;
356
+ * anything else throws. It declares no foreign key: use
357
+ * `rel.belongsTo(() => users)` when the database should enforce one.
358
+ */
359
+ userId<K extends TextColumnKind | "uuid">(this: ColumnBuilder<string, K, F>): ColumnBuilder<string, K, F>;
360
+ /** The column holds several files: `TEXT[]` of paths. */
361
+ multiple(this: ColumnBuilder<string, "storage", F>): ColumnBuilder<string[], "array", F>;
362
+ }
363
+ /** Any column, whatever it holds. */
364
+ export type AnyColumn = ColumnBuilder<unknown, BuilderKind, ColumnFlags>;
365
+ /**
366
+ * The `columns` of a table: builders by key, in physical order.
367
+ *
368
+ * @group Schema
369
+ */
370
+ export type ColumnsShape = Record<string, AnyColumn>;
371
+ /** A non-empty list of string labels, as a type. */
372
+ type Labels = readonly [string, ...string[]];
373
+ /** What `col.text()` takes besides the name: Drizzle's `{ enum }`, a closed set of values. */
374
+ export interface TextConfig<E extends Labels = Labels> {
375
+ /** The values the API accepts; the SDK types the column as their union. A Postgres enum type is `pgEnum`. */
376
+ enum: E;
377
+ }
378
+ /** What `col.varchar()` / `col.char()` take besides the name. */
379
+ export interface StringConfig<E extends Labels = Labels> {
380
+ /** The length in characters. Required: a bare varchar is unbounded and a bare char is char(1). */
381
+ length: number;
382
+ /** The values the API accepts, as `col.text({ enum })`. */
383
+ enum?: E;
384
+ }
385
+ /** What `col.numeric()` takes besides the name. */
386
+ export interface NumericConfig {
387
+ /** Total number of digits. */
388
+ precision?: number;
389
+ /** Digits after the decimal point. Needs a precision. */
390
+ scale?: number;
391
+ /** The value is a JSON number. Drizzle's `"string"` and `"bigint"` modes are refused. */
392
+ mode?: "number" | Refusal["numericMode"];
393
+ }
394
+ /** What `col.bigint()` / `col.bigserial()` take besides the name. */
395
+ export interface BigintConfig {
396
+ /** `"number"`: the value is a JSON number. Drizzle's `"bigint"` mode is refused. */
397
+ mode: "number" | Refusal["bigintMode"];
398
+ }
399
+ /** What `col.timestamp()` takes besides the name. */
400
+ export interface TimestampConfig {
401
+ /** `true`: the column is `TIMESTAMPTZ`, the only timestamp Rebase creates. */
402
+ withTimezone: true;
403
+ /** `"string"`: an ISO string on the wire, which it always is. */
404
+ mode?: "string" | Refusal["timestampMode"];
405
+ /** Refused: Rebase does not state a timestamp's precision. */
406
+ precision?: Refusal["timestampPrecision"];
407
+ }
408
+ /** What `col.date()` takes besides the name. */
409
+ export interface DateConfig {
410
+ /** `"string"`: `YYYY-MM-DD` on the wire, which it always is. */
411
+ mode?: "string" | Refusal["dateMode"];
412
+ }
413
+ /** What `col.time()` takes besides the name. */
414
+ export interface TimeConfig {
415
+ /** `false` or omitted: `col.time()` is a time without time zone. */
416
+ withTimezone?: false | Refusal["timeZone"];
417
+ /** Refused: Rebase does not state a time's precision. */
418
+ precision?: Refusal["timePrecision"];
419
+ }
420
+ /** What `col.vector()` takes besides the name. */
421
+ export interface VectorConfig {
422
+ /** The number of dimensions. */
423
+ dimensions: number;
424
+ /** The approximate-nearest-neighbour index: HNSW cosine when omitted, none with `false`. */
425
+ index?: VectorIndexOptions | false;
426
+ }
427
+ /** What `col.custom()` takes besides the name. */
428
+ export interface CustomConfig {
429
+ /** The Postgres type, verbatim: `"inet"`, `"citext"`, `"geometry(Point, 4326)"`. */
430
+ dataType: string;
431
+ }
432
+ declare function jsonb(name?: string): ColumnBuilder<unknown, "jsonb">;
433
+ declare function jsonb<T>(shape: JsonField<T, JsonKind, boolean>): ColumnBuilder<T, "jsonb">;
434
+ declare function jsonb<T>(name: string, shape: JsonField<T, JsonKind, boolean>): ColumnBuilder<T, "jsonb">;
435
+ declare function json(name?: string): ColumnBuilder<unknown, "json">;
436
+ declare function json<T>(shape: JsonField<T, JsonKind, boolean>): ColumnBuilder<T, "json">;
437
+ declare function json<T>(name: string, shape: JsonField<T, JsonKind, boolean>): ColumnBuilder<T, "json">;
438
+ declare function text(name?: string): ColumnBuilder<string, "text">;
439
+ declare function text<const E extends Labels>(config: TextConfig<E>): ColumnBuilder<E[number], "text">;
440
+ declare function text<const E extends Labels>(name: string, config: TextConfig<E>): ColumnBuilder<E[number], "text">;
441
+ declare function varchar(config: StringConfig<Labels> & {
442
+ enum?: undefined;
443
+ } & object): ColumnBuilder<string, "varchar">;
444
+ declare function varchar<const E extends Labels>(config: StringConfig<E> & object): ColumnBuilder<E[number], "varchar">;
445
+ declare function varchar(name: string, config: StringConfig<Labels> & {
446
+ enum?: undefined;
447
+ } & object): ColumnBuilder<string, "varchar">;
448
+ declare function varchar<const E extends Labels>(name: string, config: StringConfig<E> & object): ColumnBuilder<E[number], "varchar">;
449
+ declare function varchar(this: Refusal["varcharLength"], ...rest: unknown[]): never;
450
+ declare function char(config: StringConfig<Labels> & {
451
+ enum?: undefined;
452
+ } & object): ColumnBuilder<string, "char">;
453
+ declare function char<const E extends Labels>(config: StringConfig<E> & object): ColumnBuilder<E[number], "char">;
454
+ declare function char(name: string, config: StringConfig<Labels> & {
455
+ enum?: undefined;
456
+ } & object): ColumnBuilder<string, "char">;
457
+ declare function char<const E extends Labels>(name: string, config: StringConfig<E> & object): ColumnBuilder<E[number], "char">;
458
+ declare function char(this: Refusal["charLength"], ...rest: unknown[]): never;
459
+ declare function enumColumn<const V extends Labels>(values: V): ColumnBuilder<V[number], "enum">;
460
+ declare function enumColumn<const V extends Labels>(name: string, values: V): ColumnBuilder<V[number], "enum">;
461
+ declare function enumColumn(this: Refusal["enumName"], values: Labels, options: Readonly<Record<string, unknown>>): never;
462
+ declare function numeric(name?: string, config?: NumericConfig): ColumnBuilder<number, "numeric">;
463
+ declare function numeric(config: NumericConfig): ColumnBuilder<number, "numeric">;
464
+ declare function numeric(this: Refusal["numericPositional"], precision: number, scale?: number): never;
465
+ declare function decimal(name?: string, config?: NumericConfig): ColumnBuilder<number, "numeric">;
466
+ declare function decimal(config: NumericConfig): ColumnBuilder<number, "numeric">;
467
+ declare function bigint(config: BigintConfig): ColumnBuilder<number, "bigint">;
468
+ declare function bigint(name: string, config: BigintConfig): ColumnBuilder<number, "bigint">;
469
+ declare function bigint(this: Refusal["bigintModeMissing"], ...rest: unknown[]): never;
470
+ declare function bigserial(config: BigintConfig): ColumnBuilder<number, "bigserial", WithDefault<InitialColumnFlags>>;
471
+ declare function bigserial(name: string, config: BigintConfig): ColumnBuilder<number, "bigserial", WithDefault<InitialColumnFlags>>;
472
+ declare function bigserial(this: Refusal["bigintModeMissing"], ...rest: unknown[]): never;
473
+ declare function timestamp(config: TimestampConfig): ColumnBuilder<string, "timestamptz">;
474
+ declare function timestamp(name: string, config: TimestampConfig): ColumnBuilder<string, "timestamptz">;
475
+ declare function timestamp(this: Refusal["timestamp"], ...rest: unknown[]): never;
476
+ declare function date(name?: string, config?: DateConfig): ColumnBuilder<string, "date">;
477
+ declare function date(config: DateConfig): ColumnBuilder<string, "date">;
478
+ declare function time(name?: string, config?: TimeConfig): ColumnBuilder<string, "time">;
479
+ declare function time(config: TimeConfig): ColumnBuilder<string, "time">;
480
+ declare function vector(config: VectorConfig): ColumnBuilder<number[], "vector">;
481
+ declare function vector(name: string, config: VectorConfig): ColumnBuilder<number[], "vector">;
482
+ declare function vector(this: Refusal["vectorPositional"], dimensions: number, ...rest: unknown[]): never;
483
+ declare function storage(options: StorageOptions): ColumnBuilder<string, "storage">;
484
+ declare function storage(name: string, options: StorageOptions): ColumnBuilder<string, "storage">;
485
+ declare function custom<T = string>(config: CustomConfig): ColumnBuilder<T, "other">;
486
+ declare function custom<T = string>(name: string, config: CustomConfig): ColumnBuilder<T, "other">;
487
+ declare function custom(this: Refusal["customDataType"], name: string): never;
488
+ /**
489
+ * The column builders, spelled as Drizzle's `pg-core` spells them: the
490
+ * optional SQL column name first, then Drizzle's config object, then the
491
+ * chain.
492
+ *
493
+ * ```ts
494
+ * columns: {
495
+ * id: col.uuid().primaryKey().defaultRandom(),
496
+ * title: col.text().notNull().validate({ min: 3, max: 200 }),
497
+ * slug: col.varchar({ length: 160 }).notNull().unique(),
498
+ * status: postStatus().notNull().default("draft"), // const postStatus = pgEnum("post_status", [...])
499
+ * tags: col.text().array().notNull().default([]),
500
+ * heroImage: col.storage({ path: "posts/heroes/", accept: ["image/*"], maxBytes: "10MB" }),
501
+ * createdAt: col.timestamp({ withTimezone: true }).notNull().defaultNow(),
502
+ * }
503
+ * ```
504
+ *
505
+ * @group Schema
506
+ */
507
+ export declare const col: {
508
+ /** `UUID`. */
509
+ uuid: (name?: string) => ColumnBuilder<string, "uuid", InitialColumnFlags>;
510
+ /** `TEXT`. `col.text({ enum: [...] })` accepts only those values. */
511
+ text: typeof text;
512
+ /** `VARCHAR(n)`: `col.varchar({ length: n })`. */
513
+ varchar: typeof varchar;
514
+ /** `CHAR(n)`: `col.char({ length: n })`. */
515
+ char: typeof char;
516
+ /**
517
+ * A Postgres enum type of its own, created as `<table>_<column>`. A type
518
+ * with a stated name, shared by several columns, is `pgEnum(name, values)`.
519
+ */
520
+ enum: typeof enumColumn;
521
+ /** `SMALLINT`. */
522
+ smallint: (name?: string) => ColumnBuilder<number, "smallint", InitialColumnFlags>;
523
+ /** `INTEGER`. */
524
+ integer: (name?: string) => ColumnBuilder<number, "integer", InitialColumnFlags>;
525
+ /** `BIGINT`, read and written as a JavaScript number: `col.bigint({ mode: "number" })`. */
526
+ bigint: typeof bigint;
527
+ /** `SMALLSERIAL`. Prefer `col.smallint().generatedByDefaultAsIdentity()` in a new schema. */
528
+ smallserial(name?: string): ColumnBuilder<number, "smallserial", WithDefault<InitialColumnFlags>>;
529
+ /** `SERIAL`. Prefer `col.integer().generatedByDefaultAsIdentity()` in a new schema. */
530
+ serial(name?: string): ColumnBuilder<number, "serial", WithDefault<InitialColumnFlags>>;
531
+ /** `BIGSERIAL`: `col.bigserial({ mode: "number" })`. Prefer an identity column in a new schema. */
532
+ bigserial: typeof bigserial;
533
+ /** `REAL`. */
534
+ real: (name?: string) => ColumnBuilder<number, "real", InitialColumnFlags>;
535
+ /** `DOUBLE PRECISION`. */
536
+ doublePrecision: (name?: string) => ColumnBuilder<number, "doublePrecision", InitialColumnFlags>;
537
+ /** `NUMERIC`, `NUMERIC(p)` or `NUMERIC(p, s)`: `col.numeric({ precision, scale })`. A JSON number. */
538
+ numeric: typeof numeric;
539
+ /** Drizzle's alias of `col.numeric()`. */
540
+ decimal: typeof decimal;
541
+ /** `BOOLEAN`. */
542
+ boolean: (name?: string) => ColumnBuilder<boolean, "boolean", InitialColumnFlags>;
543
+ /** `TIMESTAMPTZ`: `col.timestamp({ withTimezone: true })`. An ISO string on the wire. */
544
+ timestamp: typeof timestamp;
545
+ /** `DATE`. `YYYY-MM-DD` on the wire. */
546
+ date: typeof date;
547
+ /** `TIME`. `HH:MM:SS` on the wire. */
548
+ time: typeof time;
549
+ /**
550
+ * `JSONB`. `col.jsonb().$type<T>()` types the document;
551
+ * `col.jsonb(json.object({...}))` also tells the server its shape, so
552
+ * nested fields are validated, stamped and searchable.
553
+ */
554
+ jsonb: typeof jsonb;
555
+ /** `JSON`. As `col.jsonb`, for a column that must keep the text it was given. */
556
+ json: typeof json;
557
+ /**
558
+ * `vector(dimensions)` (pgvector): `col.vector({ dimensions: 1536 })`. An
559
+ * HNSW cosine index is created unless `index` says otherwise; `index: false`
560
+ * creates none.
561
+ */
562
+ vector: typeof vector;
563
+ /** `BYTEA`. Base64 on the wire. */
564
+ bytea: (name?: string) => ColumnBuilder<string, "bytea", InitialColumnFlags>;
565
+ /** A point on Earth, stored as `JSONB` `{ latitude, longitude }`. */
566
+ geopoint(name?: string): ColumnBuilder<JsonGeoPoint, "geopoint">;
567
+ /**
568
+ * The path of a stored file, as `TEXT` — or several with `.multiple()`. The
569
+ * upload route enforces `accept` and `maxBytes`, and the orphan sweep counts
570
+ * the file as referenced.
571
+ */
572
+ storage: typeof storage;
573
+ /**
574
+ * A column of a Postgres type no other builder names —
575
+ * `col.custom({ dataType: "inet" })`, `col.custom({ dataType: "citext" })`,
576
+ * `col.custom({ dataType: "geometry(Point, 4326)" })`. What
577
+ * `rebase schema introspect` writes for a column of such a type, so a
578
+ * project generated from an existing database keeps it.
579
+ *
580
+ * Rebase names the type in DDL, verbatim, and does nothing else with it: it
581
+ * does not create, alter or drop the type's definition (an extension or a
582
+ * `CREATE TYPE` the database already holds provides it), it does not
583
+ * validate values, and it passes every value through exactly as the
584
+ * driver returns it — a string for most types. `.$type<T>()` types it for
585
+ * the SDK when the driver returns something else.
586
+ */
587
+ custom: typeof custom;
588
+ /** Refused: write `col.custom({ dataType: "interval" })`. */
589
+ interval: (this: "Rebase has no `col.interval()`: write `col.custom({ dataType: \"interval\" })`. The value passes through as the driver returns it (a string).", ..._args: unknown[]) => never;
590
+ /** Refused: write `col.custom({ dataType: "inet" })`. */
591
+ inet: (this: "Rebase has no `col.inet()`: write `col.custom({ dataType: \"inet\" })`. The value passes through as the driver returns it (a string).", ..._args: unknown[]) => never;
592
+ /** Refused: write `col.custom({ dataType: "cidr" })`. */
593
+ cidr: (this: "Rebase has no `col.cidr()`: write `col.custom({ dataType: \"cidr\" })`. The value passes through as the driver returns it (a string).", ..._args: unknown[]) => never;
594
+ /** Refused: write `col.custom({ dataType: "macaddr" })`. */
595
+ macaddr: (this: "Rebase has no `col.macaddr()`: write `col.custom({ dataType: \"macaddr\" })`. The value passes through as the driver returns it (a string).", ..._args: unknown[]) => never;
596
+ /** Refused: write `col.custom({ dataType: "macaddr8" })`. */
597
+ macaddr8: (this: "Rebase has no `col.macaddr8()`: write `col.custom({ dataType: \"macaddr8\" })`. The value passes through as the driver returns it (a string).", ..._args: unknown[]) => never;
598
+ /** Refused: write `col.custom({ dataType: "point" })`. */
599
+ point: (this: "Rebase has no `col.point()`: write `col.custom({ dataType: \"point\" })`. The value passes through as the driver returns it (a string).", ..._args: unknown[]) => never;
600
+ /** Refused: write `col.custom({ dataType: "line" })`. */
601
+ line: (this: "Rebase has no `col.line()`: write `col.custom({ dataType: \"line\" })`. The value passes through as the driver returns it (a string).", ..._args: unknown[]) => never;
602
+ /** Refused: write `col.custom({ dataType: "halfvec" })`. */
603
+ halfvec: (this: "Rebase has no `col.halfvec()`: write `col.custom({ dataType: \"halfvec\" })`. The value passes through as the driver returns it (a string).", ..._args: unknown[]) => never;
604
+ /** Refused: write `col.custom({ dataType: "sparsevec" })`. */
605
+ sparsevec: (this: "Rebase has no `col.sparsevec()`: write `col.custom({ dataType: \"sparsevec\" })`. The value passes through as the driver returns it (a string).", ..._args: unknown[]) => never;
606
+ /** Refused: write `col.custom({ dataType: "bit" })`. */
607
+ bit: (this: "Rebase has no `col.bit()`: write `col.custom({ dataType: \"bit\" })`. The value passes through as the driver returns it (a string).", ..._args: unknown[]) => never;
608
+ };
609
+ /**
610
+ * A Postgres enum type with a stated name, as Drizzle declares one: call it in
611
+ * a column, `status: postStatus().notNull()`, or with the SQL column name,
612
+ * `postStatus("state")`.
613
+ *
614
+ * @group Schema
615
+ */
616
+ export interface PgEnum<V extends Labels> {
617
+ /** A column of this enum type; the optional argument is the SQL column name. */
618
+ (name?: string): ColumnBuilder<V[number], "enum">;
619
+ /** The type's name in Postgres. */
620
+ readonly enumName: string;
621
+ /** Its labels, in order. */
622
+ readonly enumValues: V;
623
+ }
624
+ /**
625
+ * Declare a Postgres enum type by name, as Drizzle does:
626
+ *
627
+ * ```ts
628
+ * export const postStatus = pgEnum("post_status", ["draft", "published"]);
629
+ * // columns: { status: postStatus().notNull().default("draft") }
630
+ * ```
631
+ *
632
+ * Every column of it shares the one type. Two declarations of the same name
633
+ * must list the same labels.
634
+ *
635
+ * @group Schema
636
+ */
637
+ export declare function pgEnum<const V extends Labels>(enumName: string, values: V): PgEnum<V>;
638
+ export declare function pgEnum(this: Refusal["pgEnumObject"], enumName: string, values: Readonly<Record<string, string>>): never;
639
+ /**
640
+ * Whether a value is a column builder, from this copy of the package or
641
+ * another.
642
+ *
643
+ * @group Schema
644
+ */
645
+ export declare function isColumnBuilder(value: unknown): value is AnyColumn;
646
+ export {};