@vibeorm/schema 4.2.0 → 5.0.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/capabilities.d.ts +22 -1
- package/dist/check-rules.d.ts +92 -0
- package/dist/errors.d.ts +7 -2
- package/dist/generated-columns.d.ts +39 -0
- package/dist/index-expressions.d.ts +73 -0
- package/dist/index.d.ts +15 -4
- package/dist/index.js +2274 -601
- package/dist/index.js.map +20 -13
- package/dist/ir.d.ts +31 -1
- package/dist/local-date.d.ts +21 -0
- package/dist/physical-names.d.ts +8 -1
- package/dist/predicate.d.ts +65 -13
- package/dist/referential-actions.d.ts +35 -0
- package/dist/row-rules.d.ts +198 -0
- package/dist/validator-ref.d.ts +22 -0
- package/package.json +1 -1
package/dist/ir.d.ts
CHANGED
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
* extensions) consumes ONLY this — nothing else ever parses schema text.
|
|
7
7
|
*/
|
|
8
8
|
import type { ExclusionIR } from "./exclusion.ts";
|
|
9
|
+
import type { GeneratedColumnIR } from "./generated-columns.ts";
|
|
9
10
|
import type { MigrationObjectIR, QualifiedSqlName } from "./migration-objects.ts";
|
|
10
|
-
import type { PredicateIR } from "./predicate.ts";
|
|
11
|
+
import type { PredicateExpression, PredicateIR } from "./predicate.ts";
|
|
12
|
+
import type { RowRuleIR } from "./row-rules.ts";
|
|
11
13
|
/** Datasource providers a schema may declare. */
|
|
12
14
|
export type Provider = "postgresql" | "pglite" | "sqlite" | "mysql";
|
|
13
15
|
/**
|
|
@@ -43,6 +45,8 @@ export declare function isEnumType(fieldType: FieldType): fieldType is {
|
|
|
43
45
|
*/
|
|
44
46
|
export declare function fieldTypeIdentity(params: {
|
|
45
47
|
type: FieldType;
|
|
48
|
+
nativeType?: string;
|
|
49
|
+
isUnsupported?: boolean;
|
|
46
50
|
}): string;
|
|
47
51
|
/** Default value declarations, normalized across schema sources. */
|
|
48
52
|
export type DefaultValueIR = {
|
|
@@ -75,6 +79,11 @@ export type JsonSchemaRefIR = {
|
|
|
75
79
|
readonly name: string;
|
|
76
80
|
readonly from: string;
|
|
77
81
|
};
|
|
82
|
+
/** A consumer-owned runtime scalar validator export; executable values never enter SchemaIR. */
|
|
83
|
+
export type ValidatorRefIR = {
|
|
84
|
+
readonly name: string;
|
|
85
|
+
readonly from: string;
|
|
86
|
+
};
|
|
78
87
|
/** A scalar/enum column on a model. */
|
|
79
88
|
export type FieldIR = {
|
|
80
89
|
readonly name: string;
|
|
@@ -87,6 +96,8 @@ export type FieldIR = {
|
|
|
87
96
|
readonly isUnique: boolean;
|
|
88
97
|
readonly isUpdatedAt: boolean;
|
|
89
98
|
readonly default?: DefaultValueIR;
|
|
99
|
+
/** Stored database expression, distinct from a DEFAULT and never client-writable. */
|
|
100
|
+
readonly generated?: GeneratedColumnIR;
|
|
90
101
|
/** Dialect-native type override (@db.*), verbatim (e.g. "VarChar(191)"). */
|
|
91
102
|
readonly nativeType?: string;
|
|
92
103
|
/** Migration-only namespace evidence, bound to the exact unsupported declaration it resolved. */
|
|
@@ -108,6 +119,8 @@ export type FieldIR = {
|
|
|
108
119
|
readonly documentation?: string;
|
|
109
120
|
/** Runtime JSON schema reference, resolved relative to each emitted entry. */
|
|
110
121
|
readonly jsonSchema?: JsonSchemaRefIR;
|
|
122
|
+
/** Write-only non-JSON scalar validator, resolved relative to each emitted entry. */
|
|
123
|
+
readonly validator?: ValidatorRefIR;
|
|
111
124
|
/**
|
|
112
125
|
* Explicit column collation (`@collation("...")`) — String fields. Rendered
|
|
113
126
|
* as `COLLATE` on mysql and silently INERT on postgres/sqlite (the `@db.*`
|
|
@@ -156,6 +169,19 @@ export type IndexFieldIR = {
|
|
|
156
169
|
/** Qualified PostgreSQL class; omitted preserves ordinary index semantics. */
|
|
157
170
|
readonly operatorClass?: QualifiedSqlName;
|
|
158
171
|
};
|
|
172
|
+
/** Complete ordered keys for an expression-bearing index; never client selectors. */
|
|
173
|
+
export type IndexKeyTermIR = {
|
|
174
|
+
readonly kind: "field";
|
|
175
|
+
readonly field: IndexFieldIR;
|
|
176
|
+
} | {
|
|
177
|
+
readonly kind: "expression";
|
|
178
|
+
readonly expression: PredicateExpression;
|
|
179
|
+
readonly sort?: "asc" | "desc";
|
|
180
|
+
} | {
|
|
181
|
+
readonly kind: "raw";
|
|
182
|
+
readonly sql: string;
|
|
183
|
+
readonly sort?: "asc" | "desc";
|
|
184
|
+
};
|
|
159
185
|
export type IndexIR = {
|
|
160
186
|
readonly name?: string;
|
|
161
187
|
/** Physical unique constraint owning this index, when catalog-backed. */
|
|
@@ -170,6 +196,8 @@ export type IndexIR = {
|
|
|
170
196
|
readonly clientName?: string;
|
|
171
197
|
readonly kind: IndexKind;
|
|
172
198
|
readonly fields: readonly IndexFieldIR[];
|
|
199
|
+
/** Complete ordered key list, with at least one expression/raw term; fields must be empty. */
|
|
200
|
+
readonly expressions?: readonly IndexKeyTermIR[];
|
|
173
201
|
/** Partial index predicate (raw SQL), postgres/sqlite only (capability-gated). */
|
|
174
202
|
readonly where?: string;
|
|
175
203
|
/**
|
|
@@ -244,6 +272,8 @@ export type ModelIR = {
|
|
|
244
272
|
/** Named CHECK constraints (@@check), including authored expression changes. */
|
|
245
273
|
readonly exclusions?: readonly ExclusionIR[];
|
|
246
274
|
readonly checks?: readonly CheckIR[];
|
|
275
|
+
/** Declared database row invariants, separate from CHECKs and user migration SQL. */
|
|
276
|
+
readonly rowRules?: readonly RowRuleIR[];
|
|
247
277
|
/**
|
|
248
278
|
* Row-scoping policy (`@@policy([field], context: "key")`): the runtime
|
|
249
279
|
* fails closed on policied models until a context is bound ($withPolicy).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { FieldType } from "./ir.ts";
|
|
2
|
+
/** Recognize the supported string-backed calendar-day representation, including invalid lists. */
|
|
3
|
+
export declare function isLocalDateField(params: {
|
|
4
|
+
readonly field: {
|
|
5
|
+
readonly type: FieldType;
|
|
6
|
+
readonly nativeType?: string;
|
|
7
|
+
readonly isUnsupported?: boolean;
|
|
8
|
+
};
|
|
9
|
+
}): boolean;
|
|
10
|
+
/** Validate canonical Gregorian calendar days in years 0001–9999 without parsing an instant. */
|
|
11
|
+
export declare function isCanonicalLocalDate(params: {
|
|
12
|
+
readonly value: unknown;
|
|
13
|
+
}): params is {
|
|
14
|
+
readonly value: string;
|
|
15
|
+
};
|
|
16
|
+
/** Mint the physical name of SQLite's owned local-date CHECK; admission validates its length and collisions. */
|
|
17
|
+
export declare function localDateCheckName(params: {
|
|
18
|
+
readonly table: string;
|
|
19
|
+
readonly column: string;
|
|
20
|
+
}): string;
|
|
21
|
+
//# sourceMappingURL=local-date.d.ts.map
|
package/dist/physical-names.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* names are refused when over the limit (validate.ts) — the author chose them
|
|
16
16
|
* and can shorten them, whereas PostgreSQL would silently truncate.
|
|
17
17
|
*/
|
|
18
|
-
import type { Dialect } from "./ir.ts";
|
|
18
|
+
import type { Dialect, IndexIR, ModelIR } from "./ir.ts";
|
|
19
19
|
/** How a dialect measures an identifier and where it stops honouring it. */
|
|
20
20
|
export type IdentifierLimit = {
|
|
21
21
|
/** Longest identifier the server keeps intact. */
|
|
@@ -67,6 +67,13 @@ export declare function defaultIndexName(params: {
|
|
|
67
67
|
unique: boolean;
|
|
68
68
|
dialect: Dialect;
|
|
69
69
|
}): string;
|
|
70
|
+
/** Default mapped functional-key name; only its prefix may be shortened. */
|
|
71
|
+
export declare function defaultExpressionIndexName(params: {
|
|
72
|
+
readonly table: string;
|
|
73
|
+
readonly model: Pick<ModelIR, "name" | "fields">;
|
|
74
|
+
readonly index: IndexIR;
|
|
75
|
+
readonly dialect: Dialect;
|
|
76
|
+
}): string;
|
|
70
77
|
/**
|
|
71
78
|
* Default foreign-key constraint name: `Table_col1_col2_fkey`, shortened to the
|
|
72
79
|
* dialect's limit. `columns` are the PHYSICAL FK column names on the owning
|
package/dist/predicate.d.ts
CHANGED
|
@@ -22,11 +22,17 @@
|
|
|
22
22
|
* A raw SQL string stays the documented escape hatch for anything this cannot
|
|
23
23
|
* express; raw text is carried verbatim and never parsed back into a predicate.
|
|
24
24
|
*/
|
|
25
|
-
import type { Dialect } from "./ir.ts";
|
|
25
|
+
import type { Dialect, FieldType, ModelIR } from "./ir.ts";
|
|
26
26
|
/** Comparison operators a schema predicate may use. Deliberately closed. */
|
|
27
27
|
export type PredicateComparisonOp = "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
|
|
28
28
|
/** All comparison operators, for matrix-style iteration in tests and tooling. */
|
|
29
29
|
export declare const PREDICATE_COMPARISON_OPS: readonly PredicateComparisonOp[];
|
|
30
|
+
/** Numeric expression families; arithmetic never implicitly promotes a family. */
|
|
31
|
+
export type PredicateNumericType = "Int" | "BigInt" | "Float" | "Decimal";
|
|
32
|
+
/** Schema expression sites; node admission is separate from host availability. */
|
|
33
|
+
export type PredicateUsage = "check" | "indexPredicate" | "exclusionPredicate" | "indexExpression";
|
|
34
|
+
/** Sites whose root must be a Boolean predicate. */
|
|
35
|
+
export type PredicateBooleanUsage = Exclude<PredicateUsage, "indexExpression">;
|
|
30
36
|
/**
|
|
31
37
|
* A reference to one of the model's own fields, by LOGICAL name. The mapped
|
|
32
38
|
* physical column is resolved when the predicate is rendered.
|
|
@@ -43,7 +49,7 @@ export type PredicateValue = {
|
|
|
43
49
|
readonly kind: "value";
|
|
44
50
|
readonly value: string | number | boolean;
|
|
45
51
|
};
|
|
46
|
-
/** Scalar expressions
|
|
52
|
+
/** Scalar expressions; each node has independent per-usage admission. */
|
|
47
53
|
export type PredicateExpression = PredicateFieldRef | {
|
|
48
54
|
readonly kind: "jsonText";
|
|
49
55
|
readonly field: PredicateFieldRef;
|
|
@@ -51,8 +57,15 @@ export type PredicateExpression = PredicateFieldRef | {
|
|
|
51
57
|
} | {
|
|
52
58
|
readonly kind: "length";
|
|
53
59
|
readonly expression: PredicateExpression;
|
|
60
|
+
} | {
|
|
61
|
+
readonly kind: "add" | "sub" | "mul";
|
|
62
|
+
readonly left: PredicateExpression;
|
|
63
|
+
readonly right: PredicateOperand;
|
|
64
|
+
} | {
|
|
65
|
+
readonly kind: "lower" | "upper";
|
|
66
|
+
readonly expression: PredicateExpression;
|
|
54
67
|
};
|
|
55
|
-
/**
|
|
68
|
+
/** An expression or a literal; comparison and arithmetic left sides are expressions. */
|
|
56
69
|
export type PredicateOperand = PredicateExpression | PredicateValue;
|
|
57
70
|
/**
|
|
58
71
|
* A boolean expression over one model's fields.
|
|
@@ -89,6 +102,35 @@ export type PredicateIR = {
|
|
|
89
102
|
readonly kind: "isTrue";
|
|
90
103
|
readonly operand: PredicateIR;
|
|
91
104
|
};
|
|
105
|
+
/** Every scalar, Boolean and literal node in the closed predicate vocabulary. */
|
|
106
|
+
export type PredicateNodeKind = PredicateExpression["kind"] | PredicateIR["kind"] | PredicateValue["kind"];
|
|
107
|
+
/** Allowed usages for every node; dialect objects freeze the table and its rows. */
|
|
108
|
+
export type PredicateCapabilityTable = Readonly<Record<PredicateNodeKind, readonly PredicateUsage[]>>;
|
|
109
|
+
/** Pre-order scalar expressions and distinct node kinds in first-seen order. */
|
|
110
|
+
export type PredicateInspection = {
|
|
111
|
+
readonly expressions: readonly PredicateExpression[];
|
|
112
|
+
readonly nodeKinds: readonly PredicateNodeKind[];
|
|
113
|
+
};
|
|
114
|
+
/** Produced value type, independent of a source column's storage metadata. */
|
|
115
|
+
export type PredicateResultType = {
|
|
116
|
+
readonly type: FieldType;
|
|
117
|
+
readonly refinement?: "localDate" | "nativeUuid";
|
|
118
|
+
};
|
|
119
|
+
/** Exactly one Boolean predicate or scalar expression is admitted at a time. */
|
|
120
|
+
export type PredicateCapabilityInput = {
|
|
121
|
+
readonly predicate: PredicateIR;
|
|
122
|
+
readonly expression?: never;
|
|
123
|
+
} | {
|
|
124
|
+
readonly expression: PredicateExpression;
|
|
125
|
+
readonly predicate?: never;
|
|
126
|
+
};
|
|
127
|
+
/** The first denied node, operand native type or arithmetic family, suitable for issue reporting. */
|
|
128
|
+
export type PredicateCapabilityIssue = {
|
|
129
|
+
readonly feature: string;
|
|
130
|
+
readonly node: PredicateNodeKind;
|
|
131
|
+
/** Names the field and its native type when an operand's storage type is the reason. */
|
|
132
|
+
readonly hint?: string;
|
|
133
|
+
};
|
|
92
134
|
/** Narrow a predicate operand to a field reference. */
|
|
93
135
|
export declare function isPredicateFieldRef(operand: PredicateOperand): operand is PredicateFieldRef;
|
|
94
136
|
/**
|
|
@@ -100,18 +142,25 @@ export declare function isPredicateFieldRef(operand: PredicateOperand): operand
|
|
|
100
142
|
export declare function predicateFieldNames(params: {
|
|
101
143
|
predicate: PredicateIR;
|
|
102
144
|
}): readonly string[];
|
|
103
|
-
/**
|
|
145
|
+
/** Inspect every nested node, refusing malformed untrusted IR with a typed error. */
|
|
104
146
|
export declare function inspectPredicate(params: {
|
|
105
147
|
predicate: PredicateIR;
|
|
106
|
-
}):
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
dialect: Dialect;
|
|
114
|
-
usage:
|
|
148
|
+
}): PredicateInspection;
|
|
149
|
+
/** Inspect scalar children independently of a Boolean predicate or SQL renderer. */
|
|
150
|
+
export declare function inspectPredicateExpression(params: {
|
|
151
|
+
readonly expression: PredicateExpression;
|
|
152
|
+
}): PredicateInspection;
|
|
153
|
+
/** Report node/usage denial, and operand native-type and arithmetic-family denial when model facts are supplied. */
|
|
154
|
+
export declare function predicateCapabilityIssue(params: PredicateCapabilityInput & {
|
|
155
|
+
readonly dialect: Dialect;
|
|
156
|
+
readonly usage: PredicateUsage;
|
|
157
|
+
readonly model?: Pick<ModelIR, "name" | "fields">;
|
|
158
|
+
}): PredicateCapabilityIssue | undefined;
|
|
159
|
+
/** Refuse denied nodes, operand native types or numeric families before schema SQL is emitted. */
|
|
160
|
+
export declare function assertPredicateCapabilities(params: PredicateCapabilityInput & {
|
|
161
|
+
readonly dialect: Dialect;
|
|
162
|
+
readonly usage: PredicateUsage;
|
|
163
|
+
readonly model?: Pick<ModelIR, "name" | "fields">;
|
|
115
164
|
}): void;
|
|
116
165
|
/**
|
|
117
166
|
* A stable, DIALECT-FREE key for a predicate.
|
|
@@ -124,6 +173,9 @@ export declare function assertPredicateCapabilities(params: {
|
|
|
124
173
|
* It is NOT a semantic equivalence test: `a AND b` and `b AND a` get different
|
|
125
174
|
* keys, deliberately. Guessing SQL equivalence is what constitution rule 4
|
|
126
175
|
* forbids and what EPIC 1's live normalization exists for.
|
|
176
|
+
*
|
|
177
|
+
* Pre-arithmetic trees retain their exact legacy bytes; format selection never
|
|
178
|
+
* depends on capability admission.
|
|
127
179
|
*/
|
|
128
180
|
export declare function predicateKey(params: {
|
|
129
181
|
predicate: PredicateIR;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effective foreign-key referential actions — Prisma's defaults, resolved ONCE.
|
|
3
|
+
*
|
|
4
|
+
* Migrate renders these into DDL and compares them; schema validation reads
|
|
5
|
+
* them to refuse a MySQL CHECK on a column an action writes. One rule, so the
|
|
6
|
+
* two can never disagree about what a relation does.
|
|
7
|
+
*/
|
|
8
|
+
import type { CascadeAction, FieldIR, RelationIR } from "./ir.ts";
|
|
9
|
+
/**
|
|
10
|
+
* Effective onDelete — Prisma's default: a required foreign key (every column
|
|
11
|
+
* non-nullable) restricts, an optional one sets NULL.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveOnDelete(params: {
|
|
14
|
+
explicit: CascadeAction | undefined;
|
|
15
|
+
required: boolean;
|
|
16
|
+
}): CascadeAction;
|
|
17
|
+
/** Effective onUpdate — Prisma's default is Cascade. */
|
|
18
|
+
export declare function resolveOnUpdate(params: {
|
|
19
|
+
explicit: CascadeAction | undefined;
|
|
20
|
+
}): CascadeAction;
|
|
21
|
+
/**
|
|
22
|
+
* A relation's effective actions. Its foreign key is required when every
|
|
23
|
+
* foreign-key column is non-nullable — the fact the database sees, and the one
|
|
24
|
+
* Prisma's defaults key off. A column `field` cannot resolve counts as
|
|
25
|
+
* required; schema validation reports the unknown column separately.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveReferentialActions(params: {
|
|
28
|
+
relation: Pick<RelationIR, "fields" | "onDelete" | "onUpdate">;
|
|
29
|
+
/** The relation model's field by LOGICAL name. */
|
|
30
|
+
field: (name: string) => FieldIR | undefined;
|
|
31
|
+
}): {
|
|
32
|
+
readonly onDelete: CascadeAction;
|
|
33
|
+
readonly onUpdate: CascadeAction;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=referential-actions.d.ts.map
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import type { Dialect, FieldIR, ModelIR, SchemaIR } from "./ir.ts";
|
|
2
|
+
import type { MigrationObjectIR, SqlObjectIdentity } from "./migration-objects.ts";
|
|
3
|
+
/** A fixed group is protected from insertion, or after OLD's nullable gate is set. */
|
|
4
|
+
export type RowRuleWhenIR = {
|
|
5
|
+
readonly fromCreation: true;
|
|
6
|
+
} | {
|
|
7
|
+
readonly onceSet: string;
|
|
8
|
+
};
|
|
9
|
+
/** Structured row invariant; names are resolved physical stems and fields are logical names. */
|
|
10
|
+
export type RowRuleIR = {
|
|
11
|
+
readonly kind: "appendOnly";
|
|
12
|
+
readonly name: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "fixed";
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly columns: readonly string[];
|
|
17
|
+
readonly when: RowRuleWhenIR;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: "rowFixed";
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly except: readonly string[];
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: "frozen";
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly from: {
|
|
26
|
+
readonly create: true;
|
|
27
|
+
} | {
|
|
28
|
+
readonly field: string;
|
|
29
|
+
};
|
|
30
|
+
readonly mutable: readonly string[];
|
|
31
|
+
};
|
|
32
|
+
/** Authoring data before the shared normalizer resolves the optional physical stem. */
|
|
33
|
+
export type RowRuleSpec = {
|
|
34
|
+
readonly kind: "appendOnly";
|
|
35
|
+
readonly name?: string;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "fixed";
|
|
38
|
+
readonly name?: string;
|
|
39
|
+
readonly columns: readonly string[];
|
|
40
|
+
readonly when: RowRuleWhenIR;
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: "rowFixed";
|
|
43
|
+
readonly name?: string;
|
|
44
|
+
readonly except: readonly string[];
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: "frozen";
|
|
47
|
+
readonly name?: string;
|
|
48
|
+
readonly from: {
|
|
49
|
+
readonly create: true;
|
|
50
|
+
} | {
|
|
51
|
+
readonly field: string;
|
|
52
|
+
};
|
|
53
|
+
readonly mutable: readonly string[];
|
|
54
|
+
};
|
|
55
|
+
/** Shared admission keys; later dialects can enable each rule independently. */
|
|
56
|
+
export type RowRuleCapability = "rowRuleAppendOnly" | "rowRuleFixed" | "rowRuleRowFixed" | "rowRuleFrozen";
|
|
57
|
+
/** A structural or semantic error, usable by the schema's aggregate validator. */
|
|
58
|
+
export type RowRuleValidationIssue = {
|
|
59
|
+
readonly rule: string;
|
|
60
|
+
readonly message: string;
|
|
61
|
+
readonly model?: string;
|
|
62
|
+
readonly field?: string;
|
|
63
|
+
};
|
|
64
|
+
/** One physical object owned by a declaration, tagged with the part it plays. */
|
|
65
|
+
export type RowRuleObject = {
|
|
66
|
+
readonly role: "function" | "trigger";
|
|
67
|
+
readonly identity: SqlObjectIdentity;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Every physical object one declaration owns, in creation order. PostgreSQL emits
|
|
71
|
+
* one function then one trigger; a later dialect may emit several triggers and no
|
|
72
|
+
* function, so consumers select by role instead of assuming a fixed pair.
|
|
73
|
+
*/
|
|
74
|
+
export type RowRuleIdentities = readonly RowRuleObject[];
|
|
75
|
+
/** The row events owned by portable rule triggers. */
|
|
76
|
+
export type RowRuleEvent = "update" | "delete";
|
|
77
|
+
/** Reserved SQLite error payload; it is not evidence of object ownership. */
|
|
78
|
+
export declare const SQLITE_ROW_RULE_ERROR_PREFIX: "VIBEORM_ROW_RULE:";
|
|
79
|
+
/** Conservative UTF-8 bound on MySQL SIGNAL's completed MESSAGE_TEXT value. */
|
|
80
|
+
export declare const MYSQL_ROW_RULE_MESSAGE_MAX_BYTES: 128;
|
|
81
|
+
/** Count the decoded diagnostic value, never the SQL literal or its escaping. */
|
|
82
|
+
export declare function mysqlRowRuleMessageByteLength(params: {
|
|
83
|
+
readonly triggerName: string;
|
|
84
|
+
}): number;
|
|
85
|
+
/** Decode only a nonempty reserved payload at the beginning of the message. */
|
|
86
|
+
export declare function sqliteRowRuleConstraint(params: {
|
|
87
|
+
readonly message: string;
|
|
88
|
+
}): string | undefined;
|
|
89
|
+
/** Inspect canonical JSON shape, including nested unknown-key refusal, before catalog access. */
|
|
90
|
+
export declare function rowRuleShapeIssue(params: {
|
|
91
|
+
value: unknown;
|
|
92
|
+
}): string | undefined;
|
|
93
|
+
/** Select the shared dialect capability for one declared rule. */
|
|
94
|
+
export declare function rowRuleCapability(params: {
|
|
95
|
+
kind: RowRuleIR["kind"];
|
|
96
|
+
}): RowRuleCapability;
|
|
97
|
+
/** Refuse an unsupported rule with its exact feature key and authoring context. */
|
|
98
|
+
export declare function assertRowRuleCapability(params: {
|
|
99
|
+
dialect: Dialect;
|
|
100
|
+
model: string;
|
|
101
|
+
rule: RowRuleIR | RowRuleSpec;
|
|
102
|
+
}): void;
|
|
103
|
+
/** Default stem from physical table/column names, without truncation or hashing. */
|
|
104
|
+
export declare function defaultRowRuleName(params: {
|
|
105
|
+
model: Pick<ModelIR, "name" | "dbName" | "fields">;
|
|
106
|
+
rule: RowRuleSpec;
|
|
107
|
+
}): string;
|
|
108
|
+
/** Finished pair names; the stem never includes either suffix. */
|
|
109
|
+
export declare function rowRuleObjectNames(params: {
|
|
110
|
+
rule: Pick<RowRuleIR, "name">;
|
|
111
|
+
}): {
|
|
112
|
+
readonly functionName: string;
|
|
113
|
+
readonly triggerName: string;
|
|
114
|
+
};
|
|
115
|
+
/** Finished SQLite/MySQL event name, independent of the PostgreSQL pair helper. */
|
|
116
|
+
export declare function rowRuleTriggerName(params: {
|
|
117
|
+
readonly rule: Pick<RowRuleIR, "name">;
|
|
118
|
+
readonly event: RowRuleEvent;
|
|
119
|
+
}): string;
|
|
120
|
+
/** OLD-value activation field, absent for creation-fixed and append-only rules. */
|
|
121
|
+
export declare function rowRuleGateField(params: {
|
|
122
|
+
rule: RowRuleIR | RowRuleSpec;
|
|
123
|
+
}): string | undefined;
|
|
124
|
+
type RowRuleOwnedObject = Pick<MigrationObjectIR, "id" | "identity">;
|
|
125
|
+
/** Internal, invocation-local preparation shared by schema validation passes. */
|
|
126
|
+
export type RowRuleValidationContext = {
|
|
127
|
+
readonly objects: () => readonly RowRuleOwnedObject[];
|
|
128
|
+
readonly generatedFields: (params: {
|
|
129
|
+
model: ModelIR;
|
|
130
|
+
}) => ReadonlySet<string>;
|
|
131
|
+
readonly validate: (params: {
|
|
132
|
+
model: ModelIR;
|
|
133
|
+
}) => readonly RowRuleValidationIssue[];
|
|
134
|
+
readonly assertEquality: (params: {
|
|
135
|
+
model: ModelIR;
|
|
136
|
+
rule: RowRuleIR;
|
|
137
|
+
}) => void;
|
|
138
|
+
};
|
|
139
|
+
/** Prepare registered ownership lazily; no row rules means no migration-object reads. */
|
|
140
|
+
export declare function createRowRuleValidationContext(params: {
|
|
141
|
+
schema: SchemaIR;
|
|
142
|
+
dialect?: Dialect;
|
|
143
|
+
}): RowRuleValidationContext;
|
|
144
|
+
/** Authored generated-column ownership identities mapped to logical keys. */
|
|
145
|
+
export declare function rowRuleGeneratedFields(params: {
|
|
146
|
+
schema: SchemaIR;
|
|
147
|
+
model: ModelIR;
|
|
148
|
+
}): readonly string[];
|
|
149
|
+
/** Effective protected fields: explicit fixed order then gate; complements follow model order. */
|
|
150
|
+
export declare function rowRuleProtectedFields(params: {
|
|
151
|
+
schema: SchemaIR;
|
|
152
|
+
model: ModelIR;
|
|
153
|
+
rule: RowRuleIR;
|
|
154
|
+
}): readonly FieldIR[];
|
|
155
|
+
/** Exact physical objects in creation order; only PostgreSQL owns a function. */
|
|
156
|
+
export declare function rowRuleIdentities(params: {
|
|
157
|
+
schema: SchemaIR;
|
|
158
|
+
model: ModelIR;
|
|
159
|
+
rule: RowRuleIR;
|
|
160
|
+
dialect?: Dialect;
|
|
161
|
+
namespace?: string;
|
|
162
|
+
}): RowRuleIdentities;
|
|
163
|
+
/** Collect only exact declared core identities; a name prefix never implies ownership. */
|
|
164
|
+
export declare function schemaRowRuleIdentities(params: {
|
|
165
|
+
schema: SchemaIR;
|
|
166
|
+
dialect?: Dialect;
|
|
167
|
+
namespace?: string;
|
|
168
|
+
}): readonly SqlObjectIdentity[];
|
|
169
|
+
/** Validate canonical declarations on a complete model, without throwing for structural failures. */
|
|
170
|
+
export declare function validateRowRules(params: {
|
|
171
|
+
schema: SchemaIR;
|
|
172
|
+
model: ModelIR;
|
|
173
|
+
}): readonly RowRuleValidationIssue[];
|
|
174
|
+
/** Normalize source declarations, copy retained arrays and stabilize exception sets in model order. */
|
|
175
|
+
export declare function normalizeRowRules(params: {
|
|
176
|
+
model: ModelIR;
|
|
177
|
+
rules: unknown;
|
|
178
|
+
dialect: Dialect;
|
|
179
|
+
schema?: SchemaIR;
|
|
180
|
+
}): readonly RowRuleIR[];
|
|
181
|
+
/** Refuse protected/gate types whose database equality is not part of the admitted contract. */
|
|
182
|
+
export declare function assertRowRuleEquality(params: {
|
|
183
|
+
schema: SchemaIR;
|
|
184
|
+
model: ModelIR;
|
|
185
|
+
rule: RowRuleIR;
|
|
186
|
+
dialect?: Dialect;
|
|
187
|
+
}): void;
|
|
188
|
+
/** MySQL FK actions bypass child triggers; refuse declarations whose protection they evade. */
|
|
189
|
+
export declare function assertRowRuleReferentialActions(params: {
|
|
190
|
+
readonly schema: SchemaIR;
|
|
191
|
+
readonly dialect?: Dialect;
|
|
192
|
+
}): void;
|
|
193
|
+
/** Lossless VibeORM .prisma attribute spelling, including resolved stems and tagged gates. */
|
|
194
|
+
export declare function rowRulePrismaAttribute(params: {
|
|
195
|
+
rule: RowRuleIR;
|
|
196
|
+
}): string;
|
|
197
|
+
export {};
|
|
198
|
+
//# sourceMappingURL=row-rules.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ValidatorRefIR } from "./ir.ts";
|
|
2
|
+
/** A validator reference contains only serializable named-export and import-specifier data. */
|
|
3
|
+
export declare function validatorRefIssue(params: {
|
|
4
|
+
readonly value: unknown;
|
|
5
|
+
}): string | undefined;
|
|
6
|
+
/** Validate, copy and freeze a reference without retaining its mutable authoring object. */
|
|
7
|
+
export declare function assertValidatorRef(params: {
|
|
8
|
+
readonly value: unknown;
|
|
9
|
+
}): ValidatorRefIR;
|
|
10
|
+
/** Whether documentation contains a validator annotation requiring normalization. */
|
|
11
|
+
export declare function hasValidatorAnnotation(params: {
|
|
12
|
+
readonly documentation: string | undefined;
|
|
13
|
+
}): boolean;
|
|
14
|
+
/** Move the validator annotation into dedicated metadata while preserving other documentation. */
|
|
15
|
+
export declare function normalizeValidatorRef(params: {
|
|
16
|
+
readonly documentation?: string | undefined;
|
|
17
|
+
readonly reference?: unknown;
|
|
18
|
+
}): {
|
|
19
|
+
readonly documentation?: string;
|
|
20
|
+
readonly validator?: ValidatorRefIR;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=validator-ref.d.ts.map
|