@vibeorm/schema 2.0.0-alpha.7 → 2.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/README.md +3 -3
- package/dist/capabilities.d.ts +10 -3
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/default-values.d.ts +11 -0
- package/dist/default-values.d.ts.map +1 -0
- package/dist/errors.d.ts +37 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +763 -13
- package/dist/index.js.map +11 -8
- package/dist/ir.d.ts +57 -0
- package/dist/ir.d.ts.map +1 -1
- package/dist/m2m.d.ts +10 -1
- package/dist/m2m.d.ts.map +1 -1
- package/dist/prisma-literal.d.ts +59 -0
- package/dist/prisma-literal.d.ts.map +1 -0
- package/dist/reserved.d.ts.map +1 -1
- package/dist/validate.d.ts +26 -1
- package/dist/validate.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/ir.d.ts
CHANGED
|
@@ -41,6 +41,9 @@ export type DefaultValueIR = {
|
|
|
41
41
|
readonly kind: "nanoid";
|
|
42
42
|
} | {
|
|
43
43
|
readonly kind: "ulid";
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: "list";
|
|
46
|
+
readonly values: readonly (string | number | boolean)[];
|
|
44
47
|
} | {
|
|
45
48
|
readonly kind: "literal";
|
|
46
49
|
readonly value: string | number | boolean;
|
|
@@ -141,6 +144,29 @@ export type IndexIR = {
|
|
|
141
144
|
*/
|
|
142
145
|
readonly nullsNotDistinct?: boolean;
|
|
143
146
|
};
|
|
147
|
+
/** Identity scalars supported by native RLS; lists, enums, Json and Bytes refuse. */
|
|
148
|
+
export type RlsContextScalar = "String" | "Boolean" | "Int" | "BigInt" | "Float" | "Decimal" | "DateTime";
|
|
149
|
+
/** Every declared context key is required at binding, including nullable slots. */
|
|
150
|
+
export type RlsContextFieldIR = {
|
|
151
|
+
readonly type: RlsContextScalar;
|
|
152
|
+
readonly nullable: boolean;
|
|
153
|
+
};
|
|
154
|
+
/** Declaration order controls deterministic setting and predicate order. */
|
|
155
|
+
export type RlsContextIR = Readonly<Record<string, RlsContextFieldIR>>;
|
|
156
|
+
/** Declarative reference, never an evaluated callback or raw SQL expression. */
|
|
157
|
+
export type RlsContextRefIR = {
|
|
158
|
+
readonly context: string;
|
|
159
|
+
};
|
|
160
|
+
/** Native PostgreSQL policy, separate from ModelIR.policy's query rewriting. */
|
|
161
|
+
export type RlsPolicyIR = {
|
|
162
|
+
readonly where: Readonly<Record<string, RlsContextRefIR>>;
|
|
163
|
+
} | {
|
|
164
|
+
readonly through: string;
|
|
165
|
+
} | "unprotected" | "deny";
|
|
166
|
+
/** Enables native RLS and requires an explicit classification on every model. */
|
|
167
|
+
export type NativeRlsIR = {
|
|
168
|
+
readonly context: RlsContextIR;
|
|
169
|
+
};
|
|
144
170
|
/**
|
|
145
171
|
* A named CHECK constraint on a model. The expression is RAW SQL, rendered
|
|
146
172
|
* verbatim into DDL; the NAME keys the migration diff — engines re-serialize
|
|
@@ -169,6 +195,8 @@ export type ModelIR = {
|
|
|
169
195
|
readonly field: string;
|
|
170
196
|
readonly context: string;
|
|
171
197
|
};
|
|
198
|
+
/** Database-enforced row policy; cannot combine with application-level policy. */
|
|
199
|
+
readonly rls?: RlsPolicyIR;
|
|
172
200
|
/**
|
|
173
201
|
* Composite primary key (@@id). Single-field PKs use FieldIR.isId.
|
|
174
202
|
* `clientName` (`@@id(..., name:)`) names the client selector — the
|
|
@@ -182,11 +210,38 @@ export type ModelIR = {
|
|
|
182
210
|
readonly isView: boolean;
|
|
183
211
|
readonly documentation?: string;
|
|
184
212
|
};
|
|
213
|
+
/**
|
|
214
|
+
* How an enum is physically stored.
|
|
215
|
+
*
|
|
216
|
+
* - `"database"` — the native projection: a PostgreSQL enum type, a MySQL
|
|
217
|
+
* inline `ENUM(...)`, a SQLite TEXT column with an enum CHECK.
|
|
218
|
+
* - `"string"` — an ordinary String column (postgres `text`, sqlite `TEXT`,
|
|
219
|
+
* mysql's varchar mapping) with membership enforced by VibeORM in the codec
|
|
220
|
+
* path on both input and output. Adding a member changes generated code,
|
|
221
|
+
* never DDL. Sorting/equality follow string collation, not declaration order.
|
|
222
|
+
*
|
|
223
|
+
* The logical enum (name, members, generated constant + literal union) is the
|
|
224
|
+
* same either way; only the physical projection differs.
|
|
225
|
+
*/
|
|
226
|
+
export type EnumStorage = "database" | "string";
|
|
227
|
+
/** All enum storage strategies, for validation and matrix-style tests. */
|
|
228
|
+
export declare const ENUM_STORAGES: readonly EnumStorage[];
|
|
185
229
|
export type EnumIR = {
|
|
186
230
|
readonly name: string;
|
|
187
231
|
readonly dbName?: string;
|
|
188
232
|
readonly values: readonly string[];
|
|
233
|
+
/**
|
|
234
|
+
* Physical storage. ABSENT means `"database"` — the backwards-compatible
|
|
235
|
+
* default, so IR from older schemas (and every `.prisma` enum) keeps its
|
|
236
|
+
* native projection untouched. Read it through `enumStorageOf`, never
|
|
237
|
+
* directly, so the default lives in one place.
|
|
238
|
+
*/
|
|
239
|
+
readonly storage?: EnumStorage;
|
|
189
240
|
};
|
|
241
|
+
/** The effective storage of an enum (`"database"` when the IR omits it). */
|
|
242
|
+
export declare function enumStorageOf(params: {
|
|
243
|
+
enumDef: Pick<EnumIR, "storage">;
|
|
244
|
+
}): EnumStorage;
|
|
190
245
|
/** An extension declared for this schema (config and/or schema attributes). */
|
|
191
246
|
export type ExtensionDeclIR = {
|
|
192
247
|
readonly name: string;
|
|
@@ -198,6 +253,8 @@ export type DatasourceIR = {
|
|
|
198
253
|
readonly url?: string;
|
|
199
254
|
};
|
|
200
255
|
export type SchemaIR = {
|
|
256
|
+
/** Native RLS context declaration; absent preserves existing client behavior. */
|
|
257
|
+
readonly rls?: NativeRlsIR;
|
|
201
258
|
readonly datasource: DatasourceIR;
|
|
202
259
|
readonly models: readonly ModelIR[];
|
|
203
260
|
readonly enums: readonly EnumIR[];
|
package/dist/ir.d.ts.map
CHAN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IACnC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;CAChC,CAAC;AAEF,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CAAE,GAAG,WAAW,CAEvF;AAED,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,qFAAqF;IACrF,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,iFAAiF;IACjF,QAAQ,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,SAAS,eAAe,EAAE,CAAC;CACjD,CAAC"}
|
package/dist/m2m.d.ts
CHANGED
|
@@ -10,7 +10,16 @@
|
|
|
10
10
|
* else `${A}To${B}` with A, B the two model names sorted lexicographically.
|
|
11
11
|
* - Table name: `_` + relation key (`_PostToTag`, `_tags`).
|
|
12
12
|
* - Columns: `"A"` references the lexicographically-first model's primary key,
|
|
13
|
-
* `"B"` the other.
|
|
13
|
+
* `"B"` the other.
|
|
14
|
+
*
|
|
15
|
+
* SELF relations are a degenerate case of that last rule and are REFUSED, not
|
|
16
|
+
* supported: both sides carry the same model name, so the sort decides nothing
|
|
17
|
+
* and both relation fields would own column `"A"` and read the join table in
|
|
18
|
+
* the same direction. `validateSchemaIR` rejects the shape with
|
|
19
|
+
* `implicit-self-many-to-many`, and the runtime relation planner carries a
|
|
20
|
+
* backstop for IRs that never passed validation. This function still DERIVES a
|
|
21
|
+
* self join table's name (`_XToX`) because introspection and the migration
|
|
22
|
+
* differ have to recognise one that already exists in a database.
|
|
14
23
|
*/
|
|
15
24
|
export type ImplicitJoinTable = {
|
|
16
25
|
/** Join table name, including the leading underscore. */
|
package/dist/m2m.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m2m.d.ts","sourceRoot":"","sources":["../src/m2m.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"m2m.d.ts","sourceRoot":"","sources":["../src/m2m.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yDAAyD;IACzD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,iBAAiB,CAYpB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Prisma literal grammar, in ONE place.
|
|
3
|
+
*
|
|
4
|
+
* Two defects the review found were the same defect seen from both sides:
|
|
5
|
+
* reading a `.prisma` string token by stripping its quotes keeps the escape
|
|
6
|
+
* BYTES (`\n` stayed a backslash and an `n`), and writing one by interpolating
|
|
7
|
+
* a value between two quotes emits text that cannot be read back (an embedded
|
|
8
|
+
* `"` ends the token early). Both directions therefore live here, so the
|
|
9
|
+
* decoder and the encoder can never drift apart:
|
|
10
|
+
*
|
|
11
|
+
* - {@link decodePrismaString} — token text (quotes included) → the bytes it denotes.
|
|
12
|
+
* - {@link encodePrismaString} — a value → a token that decodes back to it.
|
|
13
|
+
* - {@link exactIntegerLiteral} — an integer literal's digits, never rounded
|
|
14
|
+
* through a JavaScript number.
|
|
15
|
+
*
|
|
16
|
+
* ROUND-TRIP CONTRACT (unit-tested):
|
|
17
|
+
* `decodePrismaString({ raw: encodePrismaString({ value }) }) === value` for
|
|
18
|
+
* every string, and the parser reads back what the printers write.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Decode a `.prisma` string token into the bytes it denotes.
|
|
22
|
+
*
|
|
23
|
+
* The surrounding double quotes are optional: a token that is not quoted (a
|
|
24
|
+
* bare identifier the CST handed over as a string) is returned unchanged, which
|
|
25
|
+
* is what every call site relied on before escapes were decoded at all.
|
|
26
|
+
*
|
|
27
|
+
* @throws VibeError `VIBE_SCHEMA_INVALID` on an unknown escape, a malformed
|
|
28
|
+
* `\uXXXX`, or a trailing backslash — never a silently mangled value.
|
|
29
|
+
*/
|
|
30
|
+
export declare function decodePrismaString(params: {
|
|
31
|
+
raw: string;
|
|
32
|
+
}): string;
|
|
33
|
+
/**
|
|
34
|
+
* Encode a value as a complete `.prisma` string token, quotes included.
|
|
35
|
+
*
|
|
36
|
+
* Every printer that writes a string into schema text goes through this, so
|
|
37
|
+
* embedded quotes, backslashes, newlines and control characters survive a
|
|
38
|
+
* re-parse instead of truncating the token or changing its bytes.
|
|
39
|
+
*/
|
|
40
|
+
export declare function encodePrismaString(params: {
|
|
41
|
+
value: string;
|
|
42
|
+
}): string;
|
|
43
|
+
/**
|
|
44
|
+
* The IR value for an integer literal default, exactly as written.
|
|
45
|
+
*
|
|
46
|
+
* A JavaScript `number` holds integers exactly only up to 2^53 − 1, so
|
|
47
|
+
* `@default(9007199254740993)` used to become `9007199254740992` before any
|
|
48
|
+
* SQL was rendered. Digits that do not survive that conversion are carried in
|
|
49
|
+
* the `literal` variant's EXISTING string slot instead — the same shape a
|
|
50
|
+
* numeric string default (`Decimal @default("0")`) already has, which every
|
|
51
|
+
* consumer already compiles against and renders. Safe integers keep their
|
|
52
|
+
* `number` form, so nothing that works today changes shape.
|
|
53
|
+
*
|
|
54
|
+
* @throws VibeError `VIBE_SCHEMA_INVALID` when the text is not an integer literal.
|
|
55
|
+
*/
|
|
56
|
+
export declare function exactIntegerLiteral(params: {
|
|
57
|
+
text: string;
|
|
58
|
+
}): number | string;
|
|
59
|
+
//# sourceMappingURL=prisma-literal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-literal.d.ts","sourceRoot":"","sources":["../src/prisma-literal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AA+BH;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CA8BlE;AAOD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAapE;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,MAAM,CAY7E"}
|
package/dist/reserved.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../src/reserved.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../src/reserved.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAmBpD,CAAC;AAIF,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAclD,CAAC;AAIF;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAkB,CAAC;AAIxD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAExE;AAED,+EAA+E;AAC/E,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAGtE"}
|
package/dist/validate.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* validates everywhere. Source-specific rules (e.g. Prisma AMBIGUOUS_RELATION
|
|
6
6
|
* candidate detection) live in the source packages and land in P1.
|
|
7
7
|
*/
|
|
8
|
-
import type { SchemaIR } from "./ir.ts";
|
|
8
|
+
import type { ModelIR, RelationIR, SchemaIR } from "./ir.ts";
|
|
9
9
|
export type ValidationIssue = {
|
|
10
10
|
/** Stable rule id, e.g. "duplicate-model", "unknown-relation-target". */
|
|
11
11
|
readonly rule: string;
|
|
@@ -13,6 +13,16 @@ export type ValidationIssue = {
|
|
|
13
13
|
readonly model?: string;
|
|
14
14
|
readonly field?: string;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Enum names that would collide with a name the generated client already
|
|
18
|
+
* exports, imports or uses internally (`index.js` / `index.d.ts` / `enums.js` / `enums.d.ts`).
|
|
19
|
+
* An enum `X` emits `X` (constant + literal union), `XFilter`,
|
|
20
|
+
* `XNullableFilter`, `XListFilter` and `XValidator`, so the shared scalar
|
|
21
|
+
* filter prefixes are reserved too: an enum named `String` would redefine
|
|
22
|
+
* `StringFilter`. Mirrored by a generator test against the emitted output so
|
|
23
|
+
* this list cannot silently fall behind the emitters.
|
|
24
|
+
*/
|
|
25
|
+
export declare const RESERVED_ENUM_NAMES: readonly string[];
|
|
16
26
|
/** Validate a SchemaIR structurally; returns all issues found (empty = valid). */
|
|
17
27
|
export declare function validateSchemaIR(params: {
|
|
18
28
|
schema: SchemaIR;
|
|
@@ -21,4 +31,19 @@ export declare function validateSchemaIR(params: {
|
|
|
21
31
|
export declare function assertValidSchemaIR(params: {
|
|
22
32
|
schema: SchemaIR;
|
|
23
33
|
}): void;
|
|
34
|
+
/** Validate context declarations independently (also used by settings rendering). */
|
|
35
|
+
export declare function validateRlsContextIR(params: {
|
|
36
|
+
context: unknown;
|
|
37
|
+
}): ValidationIssue[];
|
|
38
|
+
/**
|
|
39
|
+
* Shared structural implicit-M2M rule, including introspection's unnamed lists.
|
|
40
|
+
* Each fieldless list must be the other's sole counterpart under the same
|
|
41
|
+
* relation-name key, counting FK-owning candidates too. Never trust `type`:
|
|
42
|
+
* ordinary mutual FKs also synthesize unnamed lists during introspection.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isImplicitManyToManyRelation(params: {
|
|
45
|
+
model: ModelIR;
|
|
46
|
+
relation: RelationIR;
|
|
47
|
+
models: readonly ModelIR[];
|
|
48
|
+
}): boolean;
|
|
24
49
|
//# sourceMappingURL=validate.d.ts.map
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAU,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAOrE,MAAM,MAAM,eAAe,GAAG;IAC5B,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAMF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EA0EhD,CAAC;AA+DF,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GAAG,eAAe,EAAE,CAsOhF;AAiPD,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GAAG,IAAI,CAoCtE;AAkBD,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,eAAe,EAAE,CAepF;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE;IACnD,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,UAAU,CAAC;IACrB,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;CAC5B,GAAG,OAAO,CAQV"}
|