@vibeorm/schema 2.0.0-alpha.1
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 +53 -0
- package/dist/capabilities.d.ts +36 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/errors.d.ts +41 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/extension.d.ts +334 -0
- package/dist/extension.d.ts.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +428 -0
- package/dist/index.js.map +15 -0
- package/dist/ir.d.ts +153 -0
- package/dist/ir.d.ts.map +1 -0
- package/dist/m2m.d.ts +36 -0
- package/dist/m2m.d.ts.map +1 -0
- package/dist/reserved.d.ts +28 -0
- package/dist/reserved.d.ts.map +1 -0
- package/dist/validate.d.ts +24 -0
- package/dist/validate.d.ts.map +1 -0
- package/package.json +45 -0
package/dist/ir.d.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Schema IR for VibeORM v2.
|
|
3
|
+
*
|
|
4
|
+
* Both schema sources (.prisma via @vibeorm/parser, TS DSL via @vibeorm/dsl)
|
|
5
|
+
* compile to this IR. Everything downstream (generator, runtime, migrate,
|
|
6
|
+
* extensions) consumes ONLY this — nothing else ever parses schema text.
|
|
7
|
+
*/
|
|
8
|
+
/** Datasource providers a schema may declare. */
|
|
9
|
+
export type Provider = "postgresql" | "pglite" | "sqlite" | "mysql";
|
|
10
|
+
/**
|
|
11
|
+
* SQL dialects. PGlite speaks the postgres dialect — it differs only at the
|
|
12
|
+
* adapter level (single connection, bundled extension set).
|
|
13
|
+
*/
|
|
14
|
+
export type Dialect = "postgres" | "sqlite" | "mysql";
|
|
15
|
+
/** All dialects, for matrix-style iteration in tests and tooling. */
|
|
16
|
+
export declare const DIALECTS: readonly Dialect[];
|
|
17
|
+
/** Map a datasource provider to the SQL dialect it speaks. */
|
|
18
|
+
export declare function providerToDialect(params: {
|
|
19
|
+
provider: Provider;
|
|
20
|
+
}): Dialect;
|
|
21
|
+
/** Prisma-aligned scalar types. */
|
|
22
|
+
export type ScalarType = "String" | "Boolean" | "Int" | "BigInt" | "Float" | "Decimal" | "DateTime" | "Json" | "Bytes";
|
|
23
|
+
/** A field's type: a scalar, or a reference to a schema enum by name. */
|
|
24
|
+
export type FieldType = ScalarType | {
|
|
25
|
+
readonly enum: string;
|
|
26
|
+
};
|
|
27
|
+
/** Narrow a FieldType to an enum reference. */
|
|
28
|
+
export declare function isEnumType(fieldType: FieldType): fieldType is {
|
|
29
|
+
readonly enum: string;
|
|
30
|
+
};
|
|
31
|
+
/** Default value declarations, normalized across schema sources. */
|
|
32
|
+
export type DefaultValueIR = {
|
|
33
|
+
readonly kind: "autoincrement";
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "now";
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "uuid";
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: "cuid";
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: "nanoid";
|
|
42
|
+
} | {
|
|
43
|
+
readonly kind: "ulid";
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: "literal";
|
|
46
|
+
readonly value: string | number | boolean;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: "enumValue";
|
|
49
|
+
readonly value: string;
|
|
50
|
+
} | {
|
|
51
|
+
readonly kind: "dbgenerated";
|
|
52
|
+
readonly sql: string;
|
|
53
|
+
};
|
|
54
|
+
/** A scalar/enum column on a model. */
|
|
55
|
+
export type FieldIR = {
|
|
56
|
+
readonly name: string;
|
|
57
|
+
/** Column name in the database when it differs from `name` (@map). */
|
|
58
|
+
readonly dbName?: string;
|
|
59
|
+
readonly type: FieldType;
|
|
60
|
+
readonly isList: boolean;
|
|
61
|
+
readonly isOptional: boolean;
|
|
62
|
+
readonly isId: boolean;
|
|
63
|
+
readonly isUnique: boolean;
|
|
64
|
+
readonly isUpdatedAt: boolean;
|
|
65
|
+
readonly default?: DefaultValueIR;
|
|
66
|
+
/** Dialect-native type override (@db.*), verbatim (e.g. "VarChar(191)"). */
|
|
67
|
+
readonly nativeType?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Column declared as Prisma `Unsupported("...")` / `dsl.unsupported("...")`.
|
|
70
|
+
* Kept in the IR for schema fidelity (convert, migrate DDL) but excluded from
|
|
71
|
+
* the queryable surface: never projected, never writable, no generated types.
|
|
72
|
+
* `nativeType` carries the raw database type; `type` is a nominal "String".
|
|
73
|
+
*/
|
|
74
|
+
readonly isUnsupported?: true;
|
|
75
|
+
readonly documentation?: string;
|
|
76
|
+
};
|
|
77
|
+
export type RelationType = "oneToOne" | "oneToMany" | "manyToOne" | "manyToMany";
|
|
78
|
+
export type CascadeAction = "Cascade" | "Restrict" | "NoAction" | "SetNull" | "SetDefault";
|
|
79
|
+
/**
|
|
80
|
+
* A relation field on a model. Implicit many-to-many pairing follows the v1
|
|
81
|
+
* rule (LEARNINGS.md): both sides are lists AND relation names match
|
|
82
|
+
* symmetrically (both unnamed, or same name), with self-exclusion.
|
|
83
|
+
*/
|
|
84
|
+
export type RelationIR = {
|
|
85
|
+
/** Field name on the owning model (e.g. "posts"). */
|
|
86
|
+
readonly name: string;
|
|
87
|
+
/** Owning model name. */
|
|
88
|
+
readonly model: string;
|
|
89
|
+
readonly targetModel: string;
|
|
90
|
+
readonly type: RelationType;
|
|
91
|
+
/** Explicit @relation name — disambiguates multiple relations between the same pair. */
|
|
92
|
+
readonly relationName?: string;
|
|
93
|
+
/** FK columns on the owning model (FK side only). */
|
|
94
|
+
readonly fields?: readonly string[];
|
|
95
|
+
/** Referenced columns on the target model (FK side only). */
|
|
96
|
+
readonly references?: readonly string[];
|
|
97
|
+
readonly onDelete?: CascadeAction;
|
|
98
|
+
readonly onUpdate?: CascadeAction;
|
|
99
|
+
readonly isList: boolean;
|
|
100
|
+
readonly isOptional: boolean;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Index kind. Core kinds are closed; extensions register additional kinds
|
|
104
|
+
* (e.g. "bm25", "hnsw", "fts5") through the extension registry.
|
|
105
|
+
*/
|
|
106
|
+
export type IndexKind = "btree" | "unique" | "gin" | "gist" | "hash" | (string & {});
|
|
107
|
+
export type IndexFieldIR = {
|
|
108
|
+
readonly name: string;
|
|
109
|
+
readonly sort?: "asc" | "desc";
|
|
110
|
+
};
|
|
111
|
+
export type IndexIR = {
|
|
112
|
+
readonly name?: string;
|
|
113
|
+
readonly kind: IndexKind;
|
|
114
|
+
readonly fields: readonly IndexFieldIR[];
|
|
115
|
+
/** Partial index predicate (raw SQL), postgres/sqlite only (capability-gated). */
|
|
116
|
+
readonly where?: string;
|
|
117
|
+
};
|
|
118
|
+
export type ModelIR = {
|
|
119
|
+
readonly name: string;
|
|
120
|
+
/** Table name in the database when it differs from `name` (@@map). */
|
|
121
|
+
readonly dbName?: string;
|
|
122
|
+
readonly fields: readonly FieldIR[];
|
|
123
|
+
readonly relations: readonly RelationIR[];
|
|
124
|
+
readonly indexes: readonly IndexIR[];
|
|
125
|
+
/** Composite primary key (@@id). Single-field PKs use FieldIR.isId. */
|
|
126
|
+
readonly primaryKey?: {
|
|
127
|
+
readonly fields: readonly string[];
|
|
128
|
+
};
|
|
129
|
+
readonly isView: boolean;
|
|
130
|
+
readonly documentation?: string;
|
|
131
|
+
};
|
|
132
|
+
export type EnumIR = {
|
|
133
|
+
readonly name: string;
|
|
134
|
+
readonly dbName?: string;
|
|
135
|
+
readonly values: readonly string[];
|
|
136
|
+
};
|
|
137
|
+
/** An extension declared for this schema (config and/or schema attributes). */
|
|
138
|
+
export type ExtensionDeclIR = {
|
|
139
|
+
readonly name: string;
|
|
140
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
141
|
+
};
|
|
142
|
+
export type DatasourceIR = {
|
|
143
|
+
readonly provider: Provider;
|
|
144
|
+
/** Connection URL if the schema declares one (env-resolved at runtime, not here). */
|
|
145
|
+
readonly url?: string;
|
|
146
|
+
};
|
|
147
|
+
export type SchemaIR = {
|
|
148
|
+
readonly datasource: DatasourceIR;
|
|
149
|
+
readonly models: readonly ModelIR[];
|
|
150
|
+
readonly enums: readonly EnumIR[];
|
|
151
|
+
readonly extensions: readonly ExtensionDeclIR[];
|
|
152
|
+
};
|
|
153
|
+
//# sourceMappingURL=ir.d.ts.map
|
package/dist/ir.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir.d.ts","sourceRoot":"","sources":["../src/ir.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,iDAAiD;AACjD,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEtD,qEAAqE;AACrE,eAAO,MAAM,QAAQ,EAAE,SAAS,OAAO,EAAoC,CAAC;AAE5E,8DAA8D;AAC9D,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAAG,OAAO,CAWzE;AAID,mCAAmC;AACnC,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,SAAS,GACT,KAAK,GACL,QAAQ,GACR,OAAO,GACP,SAAS,GACT,UAAU,GACV,MAAM,GACN,OAAO,CAAC;AAEZ,yEAAyE;AACzE,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/D,+CAA+C;AAC/C,wBAAgB,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,IAAI;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAEvF;AAED,oEAAoE;AACpE,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;CAAE,GAClC;IAAE,QAAQ,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EF,MAAM,MAAM,QAAQ,GAAG;IACrB,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
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implicit many-to-many join-table convention (Prisma-compatible).
|
|
3
|
+
*
|
|
4
|
+
* ONE shared rule for every consumer — runtime query building, migrate DDL,
|
|
5
|
+
* introspection round-trip — per LEARNINGS: implicit-M2M conventions must never
|
|
6
|
+
* be re-implemented per consumer.
|
|
7
|
+
*
|
|
8
|
+
* Convention (matches Prisma and v1):
|
|
9
|
+
* - Relation key: the explicit relation name when both sides declare one,
|
|
10
|
+
* else `${A}To${B}` with A, B the two model names sorted lexicographically.
|
|
11
|
+
* - Table name: `_` + relation key (`_PostToTag`, `_tags`).
|
|
12
|
+
* - Columns: `"A"` references the lexicographically-first model's primary key,
|
|
13
|
+
* `"B"` the other. Self-relations use the same model on both sides (`_XToX`).
|
|
14
|
+
*/
|
|
15
|
+
export type ImplicitJoinTable = {
|
|
16
|
+
/** Join table name, including the leading underscore. */
|
|
17
|
+
readonly tableName: string;
|
|
18
|
+
/** Model whose primary key column `"A"` references (sorts first). */
|
|
19
|
+
readonly modelA: string;
|
|
20
|
+
/** Model whose primary key column `"B"` references. */
|
|
21
|
+
readonly modelB: string;
|
|
22
|
+
/** Column names, fixed by the convention. */
|
|
23
|
+
readonly columnA: "A";
|
|
24
|
+
readonly columnB: "B";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the join table for an implicit many-to-many relation between two
|
|
28
|
+
* models. Argument order does not matter; the convention sorts internally.
|
|
29
|
+
*/
|
|
30
|
+
export declare function implicitJoinTable(params: {
|
|
31
|
+
modelA: string;
|
|
32
|
+
modelB: string;
|
|
33
|
+
/** Explicit @relation name shared by both sides, when present. */
|
|
34
|
+
relationName?: string;
|
|
35
|
+
}): ImplicitJoinTable;
|
|
36
|
+
//# sourceMappingURL=m2m.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"m2m.d.ts","sourceRoot":"","sources":["../src/m2m.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;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,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reserved names on the generated client surface.
|
|
3
|
+
*
|
|
4
|
+
* Extensions claim exactly one identifier per scope (plan D9): a method or
|
|
5
|
+
* namespace on opted-in model delegates, and/or a root `$name` namespace.
|
|
6
|
+
* The generator rejects any extension whose name collides with these lists.
|
|
7
|
+
* Snapshot-tested so the core can never silently grow into an extension's name.
|
|
8
|
+
*/
|
|
9
|
+
export declare const RESERVED_DELEGATE_NAMES: readonly string[];
|
|
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
|
+
export declare function isReservedDelegateName(params: {
|
|
22
|
+
name: string;
|
|
23
|
+
}): boolean;
|
|
24
|
+
/** Checks the `$`-prefixed form an extension's root namespace would occupy. */
|
|
25
|
+
export declare function isReservedClientName(params: {
|
|
26
|
+
name: string;
|
|
27
|
+
}): boolean;
|
|
28
|
+
//# sourceMappingURL=reserved.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../src/reserved.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAkBpD,CAAC;AAIF,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAUlD,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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural validation of a SchemaIR.
|
|
3
|
+
*
|
|
4
|
+
* Shared by both schema sources (parser + dsl), so a schema that validates here
|
|
5
|
+
* validates everywhere. Source-specific rules (e.g. Prisma AMBIGUOUS_RELATION
|
|
6
|
+
* candidate detection) live in the source packages and land in P1.
|
|
7
|
+
*/
|
|
8
|
+
import type { SchemaIR } from "./ir.ts";
|
|
9
|
+
export type ValidationIssue = {
|
|
10
|
+
/** Stable rule id, e.g. "duplicate-model", "unknown-relation-target". */
|
|
11
|
+
readonly rule: string;
|
|
12
|
+
readonly message: string;
|
|
13
|
+
readonly model?: string;
|
|
14
|
+
readonly field?: string;
|
|
15
|
+
};
|
|
16
|
+
/** Validate a SchemaIR structurally; returns all issues found (empty = valid). */
|
|
17
|
+
export declare function validateSchemaIR(params: {
|
|
18
|
+
schema: SchemaIR;
|
|
19
|
+
}): ValidationIssue[];
|
|
20
|
+
/** Throw VIBE_SCHEMA_INVALID (with all issues in meta) if the schema is invalid. */
|
|
21
|
+
export declare function assertValidSchemaIR(params: {
|
|
22
|
+
schema: SchemaIR;
|
|
23
|
+
}): void;
|
|
24
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAW,QAAQ,EAAE,MAAM,SAAS,CAAC;AAMjD,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;AAIF,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GAAG,eAAe,EAAE,CAwChF;AA8JD,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GAAG,IAAI,CAWtE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vibeorm/schema",
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
|
+
"description": "Canonical schema IR, validation, dialect/capability types, and error codes for VibeORM v2",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"orm",
|
|
7
|
+
"typescript",
|
|
8
|
+
"sql",
|
|
9
|
+
"database",
|
|
10
|
+
"bun",
|
|
11
|
+
"type-safe",
|
|
12
|
+
"schema",
|
|
13
|
+
"prisma",
|
|
14
|
+
"schema-ir",
|
|
15
|
+
"validation"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://github.com/vibeorm/vibeorm/tree/master/packages/schema#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/vibeorm/vibeorm/issues"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/vibeorm/vibeorm.git",
|
|
24
|
+
"directory": "packages/schema"
|
|
25
|
+
},
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"author": "VibeORM contributors",
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"engines": {
|
|
40
|
+
"bun": ">=1.2.0"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
}
|
|
45
|
+
}
|