@vibeorm/schema 5.9.0 → 5.11.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 +33 -0
- package/dist/errors.d.ts +11 -0
- package/dist/exclusion.d.ts +8 -0
- package/dist/extension.d.ts +0 -5
- package/dist/failure-kind.d.ts +72 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +523 -7
- package/dist/index.js.map +17 -11
- package/dist/native-rls-admission.d.ts +1 -1
- package/dist/partial-predicate.d.ts +18 -0
- package/dist/reserved.d.ts +0 -10
- package/dist/row-rules.d.ts +1 -22
- package/dist/sealed.d.ts +16 -0
- package/dist/suggest.d.ts +53 -0
- package/dist/unique-keys.d.ts +48 -0
- package/dist/validate.d.ts +4 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dialect, SchemaIR } from "./ir.ts";
|
|
2
|
-
/** Admit only the public-table native RLS contract shared by every consumer. */
|
|
2
|
+
/** Admit only the public-table native RLS contract shared by every consumer (once per dialect for a sealed schema). */
|
|
3
3
|
export declare function assertNativeRlsAdmission(params: {
|
|
4
4
|
schema: SchemaIR;
|
|
5
5
|
dialect?: Dialect;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The comparison key of a partial index's predicate (`where:`): two spellings
|
|
3
|
+
* of one predicate are one database object. Migrate compares indexes by it and
|
|
4
|
+
* the unique-key enumeration dedupes by it, so both agree on which partial
|
|
5
|
+
* uniques are the same key.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Comparison key for a partial-index predicate.
|
|
9
|
+
*
|
|
10
|
+
* Literal bytes, quoted identifier case and casts are semantic. Only the
|
|
11
|
+
* supported boolean structure is reparenthesized. Quoted and unquoted names
|
|
12
|
+
* may conservatively compare unequal; equivalence requires catalog evidence.
|
|
13
|
+
* Complex lexical forms remain opaque rather than claiming false convergence.
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeWhere(params: {
|
|
16
|
+
where: string | undefined;
|
|
17
|
+
}): string;
|
|
18
|
+
//# sourceMappingURL=partial-predicate.d.ts.map
|
package/dist/reserved.d.ts
CHANGED
|
@@ -8,16 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const RESERVED_DELEGATE_NAMES: readonly string[];
|
|
10
10
|
export declare const RESERVED_CLIENT_NAMES: readonly string[];
|
|
11
|
-
/**
|
|
12
|
-
* Column-name prefix reserved for VibeORM's own result projections — the M2M
|
|
13
|
-
* join loader's `__vibe_parent` stitch key today, hidden order/stitch fields
|
|
14
|
-
* generally. A user column with this prefix would collide with a projection
|
|
15
|
-
* alias and be silently misgrouped or stripped, so schema validation refuses
|
|
16
|
-
* it (`reserved-column-prefix`). Unreachable from `.prisma` field-name
|
|
17
|
-
* grammar, reachable via `@map` or hand-built IR. Wave-C sqlite review,
|
|
18
|
-
* finding 3.
|
|
19
|
-
*/
|
|
20
|
-
export declare const RESERVED_COLUMN_PREFIX: string;
|
|
21
11
|
export declare function isReservedDelegateName(params: {
|
|
22
12
|
name: string;
|
|
23
13
|
}): boolean;
|
package/dist/row-rules.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dialect, FieldIR, ModelIR, SchemaIR } from "./ir.ts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SqlObjectIdentity } from "./migration-objects.ts";
|
|
3
3
|
/** A fixed group is protected from insertion, or after OLD's nullable gate is set. */
|
|
4
4
|
export type RowRuleWhenIR = {
|
|
5
5
|
readonly fromCreation: true;
|
|
@@ -121,26 +121,6 @@ export declare function rowRuleTriggerName(params: {
|
|
|
121
121
|
export declare function rowRuleGateField(params: {
|
|
122
122
|
rule: RowRuleIR | RowRuleSpec;
|
|
123
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
124
|
/** Authored generated-column ownership identities mapped to logical keys. */
|
|
145
125
|
export declare function rowRuleGeneratedFields(params: {
|
|
146
126
|
schema: SchemaIR;
|
|
@@ -194,5 +174,4 @@ export declare function assertRowRuleReferentialActions(params: {
|
|
|
194
174
|
export declare function rowRulePrismaAttribute(params: {
|
|
195
175
|
rule: RowRuleIR;
|
|
196
176
|
}): string;
|
|
197
|
-
export {};
|
|
198
177
|
//# sourceMappingURL=row-rules.d.ts.map
|
package/dist/sealed.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SchemaIR } from "./ir.ts";
|
|
2
|
+
/**
|
|
3
|
+
* A deep-frozen copy of a schema. Nothing can change a sealed schema, so
|
|
4
|
+
* `assertValidSchemaIR` validates it once and answers from memory afterwards —
|
|
5
|
+
* a consumer that checks a schema per operation (native RLS readiness, policy
|
|
6
|
+
* rendering) pays the validation once. The caller's schema stays as it was and
|
|
7
|
+
* keeps being validated on every call.
|
|
8
|
+
*
|
|
9
|
+
* A schema that holds anything but plain objects, arrays and primitives (a
|
|
10
|
+
* function, a class instance, a symbol) cannot be copied faithfully and is
|
|
11
|
+
* returned as it is.
|
|
12
|
+
*/
|
|
13
|
+
export declare function sealSchemaIR(params: {
|
|
14
|
+
schema: SchemaIR;
|
|
15
|
+
}): SchemaIR;
|
|
16
|
+
//# sourceMappingURL=sealed.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Did you mean …?" for a misspelled name: a field, relation, model, operator
|
|
3
|
+
* or argument keyword. Meant for refusal paths only — the caller computes it
|
|
4
|
+
* after a lookup already failed, never on a successful one.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Edit distance with adjacent transpositions (optimal string alignment):
|
|
8
|
+
* `stauts` → `status` is one edit, not two.
|
|
9
|
+
*/
|
|
10
|
+
export declare function editDistance(params: {
|
|
11
|
+
from: string;
|
|
12
|
+
to: string;
|
|
13
|
+
}): number;
|
|
14
|
+
/**
|
|
15
|
+
* The one known name close to `name`, or `undefined`. Close means an edit
|
|
16
|
+
* distance (a transposition counts as one edit) of at most 2, or at most a
|
|
17
|
+
* third of the longer name's length, and less than `name`'s own length, so a
|
|
18
|
+
* one-letter typo never "suggests" an unrelated short name. When several names
|
|
19
|
+
* are equally close none is suggested: a wrong guess costs more than none.
|
|
20
|
+
*
|
|
21
|
+
* @example suggestName({ name: "stauts", candidates: ["id", "status", "total"] }) // "status"
|
|
22
|
+
*/
|
|
23
|
+
export declare function suggestName(params: {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly candidates: Iterable<string>;
|
|
26
|
+
}): string | undefined;
|
|
27
|
+
/** The message suffix for a {@link suggestName} result: ` — did you mean "status"?`, or `""` without one. */
|
|
28
|
+
export declare function didYouMean(params: {
|
|
29
|
+
readonly suggestion: string | undefined;
|
|
30
|
+
}): string;
|
|
31
|
+
/**
|
|
32
|
+
* A refusal's message and meta with the {@link suggestName} result for `name`
|
|
33
|
+
* appended (`… — did you mean "status"?`, `meta.suggestion`), or unchanged
|
|
34
|
+
* when no single known name is close. The returned meta is marked as an
|
|
35
|
+
* unknown-name refusal's ({@link isUnknownNameRefusal}).
|
|
36
|
+
*/
|
|
37
|
+
export declare function withSuggestion(params: {
|
|
38
|
+
readonly message: string;
|
|
39
|
+
readonly meta: Record<string, unknown>;
|
|
40
|
+
readonly name: string;
|
|
41
|
+
readonly candidates: Iterable<string>;
|
|
42
|
+
}): {
|
|
43
|
+
message: string;
|
|
44
|
+
meta: Record<string, unknown>;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Whether an error's `meta` is an unknown-name refusal's from
|
|
48
|
+
* {@link withSuggestion} — the errors a delegate call names its method on.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isUnknownNameRefusal(params: {
|
|
51
|
+
readonly meta: object;
|
|
52
|
+
}): boolean;
|
|
53
|
+
//# sourceMappingURL=suggest.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every unique key of a model — its primary key and each unique index migrate
|
|
3
|
+
* creates — with a stable LOGICAL key and the PHYSICAL name the dialect gives
|
|
4
|
+
* it. One enumeration for every consumer: the runtime's violation lookup and
|
|
5
|
+
* `db.<model>.uniques`, `describeSchema`, and the generator's declarations.
|
|
6
|
+
*
|
|
7
|
+
* Physical names come from the shared naming rule (`physical-names.ts`), and
|
|
8
|
+
* the set of objects follows migrate's own: declared unique indexes first, a
|
|
9
|
+
* duplicate definition collapses into the first, and a field `@unique` folds
|
|
10
|
+
* into a declared index over the same column (`@unique(map: "x")` is one
|
|
11
|
+
* index named `x`).
|
|
12
|
+
*/
|
|
13
|
+
import type { Dialect, ModelIR } from "./ir.ts";
|
|
14
|
+
/** One unique key of a model. */
|
|
15
|
+
export type UniqueKeyIR = {
|
|
16
|
+
/**
|
|
17
|
+
* Stable logical key: the declared selector name (`name:` on `@@id` /
|
|
18
|
+
* `@@unique`), else the field names joined with `_` — the key compound
|
|
19
|
+
* selectors use, and a field `@unique`'s field name. A key whose natural
|
|
20
|
+
* name an earlier key already holds is keyed by its physical name (the
|
|
21
|
+
* declared one, else the default unshortened): the same key on every dialect.
|
|
22
|
+
*/
|
|
23
|
+
readonly key: string;
|
|
24
|
+
/**
|
|
25
|
+
* The physical name a violation of this key reports on the dialect: a
|
|
26
|
+
* catalog-backed constraint's name, else the index name. MySQL's primary
|
|
27
|
+
* key is `PRIMARY`; `null` for SQLite's primary key, which has no name.
|
|
28
|
+
*/
|
|
29
|
+
readonly name: string | null;
|
|
30
|
+
/** Every physical name the database may report for this key (index and constraint), `name` first. */
|
|
31
|
+
readonly names: readonly string[];
|
|
32
|
+
/** Field names in key order; absent for an expression key. */
|
|
33
|
+
readonly fields?: readonly string[];
|
|
34
|
+
/** Fields an expression key reads, when they are known (never for raw SQL). */
|
|
35
|
+
readonly sourceFields?: readonly string[];
|
|
36
|
+
readonly primaryKey: boolean;
|
|
37
|
+
/** A partial unique (`where:`): it guards only the rows its predicate covers. */
|
|
38
|
+
readonly partial: boolean;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Every unique key of `model` on `dialect`, primary key first. A view has
|
|
42
|
+
* none. Implicit many-to-many join tables are not models and are not listed.
|
|
43
|
+
*/
|
|
44
|
+
export declare function modelUniqueKeys(params: {
|
|
45
|
+
readonly model: ModelIR;
|
|
46
|
+
readonly dialect: Dialect;
|
|
47
|
+
}): readonly UniqueKeyIR[];
|
|
48
|
+
//# sourceMappingURL=unique-keys.d.ts.map
|
package/dist/validate.d.ts
CHANGED
|
@@ -50,7 +50,10 @@ export declare function generatedTypeNames(params: {
|
|
|
50
50
|
export declare function validateSchemaIR(params: {
|
|
51
51
|
schema: SchemaIR;
|
|
52
52
|
}): ValidationIssue[];
|
|
53
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Throw VIBE_SCHEMA_INVALID (with all issues in meta) if the schema is invalid.
|
|
55
|
+
* A schema sealed by `sealSchemaIR` is validated once; later calls return at once.
|
|
56
|
+
*/
|
|
54
57
|
export declare function assertValidSchemaIR(params: {
|
|
55
58
|
schema: SchemaIR;
|
|
56
59
|
}): void;
|