@vibeorm/schema 5.7.0 → 5.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ir.d.ts CHANGED
@@ -131,6 +131,16 @@ export type FieldIR = {
131
131
  * Absent = server/table default (LOWER() kept — conservative).
132
132
  */
133
133
  readonly collation?: string;
134
+ /**
135
+ * How a `BigInt` column reads in JavaScript (`@number`, `dsl.bigint({ mode: "number" })`).
136
+ * `"number"`: a safe `number` instead of a `bigint`, typed `number` in the
137
+ * generated client; a stored value beyond `Number.MAX_SAFE_INTEGER` (or below
138
+ * its negative) fails the read with `VIBE_DATA_INVALID`, and a write of an
139
+ * unsafe number refuses with `VIBE_VALIDATION`, never rounding. Aggregates
140
+ * that carry the field's type (`_sum`, `_min`, `_max`) follow it. Absent =
141
+ * `bigint`. No DDL: the column stays 8-byte.
142
+ */
143
+ readonly bigIntMode?: "number";
134
144
  };
135
145
  export type RelationType = "oneToOne" | "oneToMany" | "manyToOne" | "manyToMany";
136
146
  export type CascadeAction = "Cascade" | "Restrict" | "NoAction" | "SetNull" | "SetDefault";
@@ -154,6 +164,16 @@ export type RelationIR = {
154
164
  readonly fields?: readonly string[];
155
165
  /** Referenced columns on the target model (FK side only). */
156
166
  readonly references?: readonly string[];
167
+ /**
168
+ * Correlation of a to-one without `fields` whose target declares no foreign
169
+ * key back: `fields` on this model pair, member by member, with `references`,
170
+ * a unique key of the target that holds the same values. No constraint backs
171
+ * it, and migrate emits none; only relation loading reads it.
172
+ */
173
+ readonly inverseKey?: {
174
+ readonly fields: readonly string[];
175
+ readonly references: readonly string[];
176
+ };
157
177
  readonly onDelete?: CascadeAction;
158
178
  readonly onUpdate?: CascadeAction;
159
179
  readonly isList: boolean;
@@ -212,6 +232,13 @@ export type IndexIR = {
212
232
  * Unique indexes only; postgres 15+ (pglite included), capability-gated.
213
233
  */
214
234
  readonly nullsNotDistinct?: boolean;
235
+ /**
236
+ * Non-key columns stored in the index (`INCLUDE (…)`, a covering index), by
237
+ * field name, in order. Never a key column of the same index; absent when the
238
+ * index carries none, never empty. PostgreSQL btree, unique, GiST and SP-GiST
239
+ * indexes only (capability `indexIncludeColumns`).
240
+ */
241
+ readonly include?: readonly string[];
215
242
  };
216
243
  /** Identity scalars supported by native RLS; lists, enums, Json and Bytes refuse. */
217
244
  export type RlsContextScalar = "String" | "Boolean" | "Int" | "BigInt" | "Float" | "Decimal" | "DateTime";
@@ -296,9 +323,55 @@ export type ModelIR = {
296
323
  readonly fields: readonly string[];
297
324
  readonly clientName?: string;
298
325
  };
326
+ /**
327
+ * PostgreSQL table storage parameters (`@@storage(…)`), keyed by their
328
+ * PostgreSQL names; absent when the model declares none, never empty.
329
+ * Capability `tableStorageParameters`.
330
+ */
331
+ readonly storage?: TableStorageParameters;
332
+ /**
333
+ * Introspection only: `false` when the live PostgreSQL table has no TOAST
334
+ * table. PostgreSQL accepts and discards `toast.` parameters for such a
335
+ * table, so they cannot be read back or compared.
336
+ */
337
+ readonly catalogToastTable?: false;
299
338
  readonly isView: boolean;
300
339
  readonly documentation?: string;
301
340
  };
341
+ /** A table storage parameter value: a number, a boolean, or an enum word (`vacuum_index_cleanup`). */
342
+ export type TableStorageValue = number | boolean | string;
343
+ /** Parameters PostgreSQL accepts for a table and, with a `toast.` prefix, for its TOAST table. */
344
+ export type VacuumStorageParameters = {
345
+ readonly autovacuum_enabled?: boolean;
346
+ readonly vacuum_index_cleanup?: "auto" | "on" | "off";
347
+ readonly vacuum_truncate?: boolean;
348
+ readonly autovacuum_vacuum_threshold?: number;
349
+ readonly autovacuum_vacuum_scale_factor?: number;
350
+ readonly autovacuum_vacuum_insert_threshold?: number;
351
+ readonly autovacuum_vacuum_insert_scale_factor?: number;
352
+ readonly autovacuum_vacuum_cost_delay?: number;
353
+ readonly autovacuum_vacuum_cost_limit?: number;
354
+ readonly autovacuum_freeze_min_age?: number;
355
+ readonly autovacuum_freeze_max_age?: number;
356
+ readonly autovacuum_freeze_table_age?: number;
357
+ readonly autovacuum_multixact_freeze_min_age?: number;
358
+ readonly autovacuum_multixact_freeze_max_age?: number;
359
+ readonly autovacuum_multixact_freeze_table_age?: number;
360
+ readonly log_autovacuum_min_duration?: number;
361
+ };
362
+ /**
363
+ * PostgreSQL table storage parameters (CREATE TABLE "Storage Parameters"), by
364
+ * their PostgreSQL names. `toast.`-prefixed keys set the TOAST table's value.
365
+ */
366
+ export type TableStorageParameters = VacuumStorageParameters & {
367
+ readonly fillfactor?: number;
368
+ readonly toast_tuple_target?: number;
369
+ readonly parallel_workers?: number;
370
+ readonly autovacuum_analyze_threshold?: number;
371
+ readonly autovacuum_analyze_scale_factor?: number;
372
+ } & {
373
+ readonly [K in keyof VacuumStorageParameters as `toast.${K}`]?: VacuumStorageParameters[K];
374
+ };
302
375
  /**
303
376
  * How an enum is physically stored.
304
377
  *
@@ -0,0 +1,66 @@
1
+ import type { Dialect, ModelIR, SchemaIR, TableStorageValue } from "./ir.ts";
2
+ /** How one storage parameter is typed and bounded (PostgreSQL `reloptions.c`). */
3
+ export type TableStorageParameterSpec = {
4
+ readonly type: "integer" | "real" | "boolean" | "enum";
5
+ readonly min?: number;
6
+ readonly max?: number;
7
+ readonly values?: readonly string[];
8
+ };
9
+ /**
10
+ * Every table storage parameter a schema may declare, keyed by its PostgreSQL
11
+ * name (`toast.`-prefixed for the TOAST table), in the order DDL renders them.
12
+ * Parameters newer than PostgreSQL 13 (`autovacuum_vacuum_max_threshold`,
13
+ * `vacuum_max_eager_freeze_failure_rate`) and `user_catalog_table` are left out.
14
+ */
15
+ export declare const TABLE_STORAGE_PARAMETERS: Readonly<Record<string, TableStorageParameterSpec>>;
16
+ /** The declarable keys, in rendering order. */
17
+ export declare const TABLE_STORAGE_KEYS: readonly string[];
18
+ /** Whether a key sets the TOAST table's parameter rather than the table's own. */
19
+ export declare function isToastStorageKey(params: {
20
+ key: string;
21
+ }): boolean;
22
+ /**
23
+ * The `.prisma` spelling of a key: an attribute argument name cannot hold a
24
+ * dot, so `toast.autovacuum_enabled` is written `toast_autovacuum_enabled`.
25
+ */
26
+ export declare function tableStoragePrismaKey(params: {
27
+ key: string;
28
+ }): string;
29
+ /** The PostgreSQL key a `.prisma` argument name stands for; undefined when it names none. */
30
+ export declare function tableStorageKeyFromPrisma(params: {
31
+ name: string;
32
+ }): string | undefined;
33
+ /**
34
+ * Read a parameter value written as text (a `.prisma` argument, a
35
+ * `pg_class.reloptions` entry) into its IR value: undefined when the key is
36
+ * unknown or the text is not a value of its type. Bounds are not checked here.
37
+ */
38
+ export declare function parseTableStorageValue(params: {
39
+ key: string;
40
+ text: string;
41
+ }): TableStorageValue | undefined;
42
+ /** The SQL text of a value inside `WITH (…)` / `SET (…)`. */
43
+ export declare function renderTableStorageValue(params: {
44
+ value: TableStorageValue;
45
+ }): string;
46
+ /** Whether any model of the schema declares storage parameters. */
47
+ export declare function hasTableStorage(params: {
48
+ schema: SchemaIR;
49
+ }): boolean;
50
+ /**
51
+ * Refuse storage parameters that cannot be created: a malformed or empty
52
+ * record, a view, a dialect without them (`tableStorageParameters`), an
53
+ * unknown key, or a value of the wrong type or outside PostgreSQL's range.
54
+ */
55
+ export declare function assertTableStorage(params: {
56
+ schema: SchemaIR;
57
+ dialect: Dialect;
58
+ }): void;
59
+ /**
60
+ * A model's parameters as `[key, value]` pairs in rendering order, unknown keys
61
+ * last so a printer never drops one silently; empty when it declares none.
62
+ */
63
+ export declare function tableStorageEntries(params: {
64
+ model: Pick<ModelIR, "storage">;
65
+ }): readonly (readonly [string, TableStorageValue])[];
66
+ //# sourceMappingURL=table-storage.d.ts.map
@@ -23,6 +23,29 @@ export type ValidationIssue = {
23
23
  * this list cannot silently fall behind the emitters.
24
24
  */
25
25
  export declare const RESERVED_ENUM_NAMES: readonly string[];
26
+ /**
27
+ * A model type-name family the generator renames when another owner generates
28
+ * the same name (`Call`'s to-many `CallListRelationFilter` and `CallList`'s
29
+ * to-one `CallListRelationFilter`). Every emission site of these families reads
30
+ * its name from {@link generatedTypeNames}.
31
+ */
32
+ export type DisambiguatedTypeSuffix = "ListRelationFilter" | "RelationFilter" | "RelationOrderByInput" | "RelationFindManyArgs" | "CreateArgs" | "UpdateArgs" | "UpdateWhereInput" | "UpsertArgs" | "DeleteArgs" | "CountArgs" | "CountSelect" | "AggregateArgs" | "ViewSelect" | "ViewInclude" | "ViewFindManyArgs" | "ViewFindUniqueArgs" | "ViewDelegate";
33
+ /** The declared names of one schema's generated client, shared by validation and the generator. */
34
+ export type GeneratedTypeNames = {
35
+ /** `<Model><Suffix>`, or `<Model>_<Suffix>` when an owner with a longer name keeps `<Model><Suffix>`. */
36
+ readonly model: (params: {
37
+ model: string;
38
+ suffix: DisambiguatedTypeSuffix;
39
+ }) => string;
40
+ };
41
+ /**
42
+ * The type names a valid schema's generated client declares. Validation
43
+ * reports the clashes this resolution cannot settle, so the generator only
44
+ * ever reads names that are unique.
45
+ */
46
+ export declare function generatedTypeNames(params: {
47
+ schema: SchemaIR;
48
+ }): GeneratedTypeNames;
26
49
  /** Validate a SchemaIR structurally; returns all issues found (empty = valid). */
27
50
  export declare function validateSchemaIR(params: {
28
51
  schema: SchemaIR;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibeorm/schema",
3
- "version": "5.7.0",
3
+ "version": "5.9.0",
4
4
  "description": "Canonical schema IR, validation, dialect/capability types, and error codes for VibeORM v2",
5
5
  "keywords": [
6
6
  "orm",