@vibeorm/schema 3.0.0 → 4.1.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
@@ -70,6 +70,11 @@ export type DefaultValueIR = {
70
70
  readonly kind: "dbgenerated";
71
71
  readonly sql: string;
72
72
  };
73
+ /** A consumer-owned runtime JSON validator export. Validator objects never enter SchemaIR. */
74
+ export type JsonSchemaRefIR = {
75
+ readonly name: string;
76
+ readonly from: string;
77
+ };
73
78
  /** A scalar/enum column on a model. */
74
79
  export type FieldIR = {
75
80
  readonly name: string;
@@ -101,6 +106,8 @@ export type FieldIR = {
101
106
  * (`@type(Name from "./x")`) the generator reads on Json fields.
102
107
  */
103
108
  readonly documentation?: string;
109
+ /** Runtime JSON schema reference, resolved relative to each emitted entry. */
110
+ readonly jsonSchema?: JsonSchemaRefIR;
104
111
  /**
105
112
  * Explicit column collation (`@collation("...")`) — String fields. Rendered
106
113
  * as `COLLATE` on mysql and silently INERT on postgres/sqlite (the `@db.*`
@@ -0,0 +1,30 @@
1
+ import type { JsonSchemaRefIR } from "./ir.ts";
2
+ /** Whether documentation still contains a schema annotation requiring normalization. */
3
+ export declare function hasJsonSchemaAnnotation(params: {
4
+ documentation: string | undefined;
5
+ }): boolean;
6
+ /** Structural issue for a legacy assertion-only annotation; it remains documentation in IR. */
7
+ export declare function jsonTypeAnnotationIssue(params: {
8
+ documentation: string | undefined;
9
+ }): string | undefined;
10
+ /** Resolve the assertion annotation without turning it into a runtime binding. */
11
+ export declare function jsonTypeAnnotationRef(params: {
12
+ documentation: string | undefined;
13
+ }): JsonSchemaRefIR | undefined;
14
+ /** A reference must contain only serializable named-export and import-specifier data. */
15
+ export declare function jsonSchemaRefIssue(params: {
16
+ value: unknown;
17
+ }): string | undefined;
18
+ /** Validate and copy a reference; never retain a mutable authoring object or validator. */
19
+ export declare function assertJsonSchemaRef(params: {
20
+ value: unknown;
21
+ }): JsonSchemaRefIR;
22
+ /** Normalize Prisma/DSL annotations into dedicated IR metadata, retaining other documentation. */
23
+ export declare function normalizeJsonSchemaRef(params: {
24
+ documentation?: string | undefined;
25
+ reference?: unknown;
26
+ }): {
27
+ readonly documentation?: string;
28
+ readonly jsonSchema?: JsonSchemaRefIR;
29
+ };
30
+ //# sourceMappingURL=json-schema-ref.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { Dialect, ModelIR, SchemaIR } from "./ir.ts";
2
+ /** Resolve declared public-only ownership without changing unrelated unqualified models. */
3
+ export declare function modelSqlNamespace(params: {
4
+ schema: SchemaIR;
5
+ model: ModelIR;
6
+ dialect?: Dialect;
7
+ }): string | undefined;
8
+ //# sourceMappingURL=model-sql-namespace.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { Dialect, SchemaIR } from "./ir.ts";
2
+ /** Admit only the public-table native RLS contract shared by every consumer. */
3
+ export declare function assertNativeRlsAdmission(params: {
4
+ schema: SchemaIR;
5
+ dialect?: Dialect;
6
+ }): void;
7
+ //# sourceMappingURL=native-rls-admission.d.ts.map
@@ -22,6 +22,7 @@
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
26
  /** Comparison operators a schema predicate may use. Deliberately closed. */
26
27
  export type PredicateComparisonOp = "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
27
28
  /** All comparison operators, for matrix-style iteration in tests and tooling. */
@@ -42,8 +43,17 @@ export type PredicateValue = {
42
43
  readonly kind: "value";
43
44
  readonly value: string | number | boolean;
44
45
  };
45
- /** Either side of a comparison: another field, or a literal. */
46
- export type PredicateOperand = PredicateFieldRef | PredicateValue;
46
+ /** Scalar expressions. Computed expressions are qualified for PostgreSQL CHECKs only. */
47
+ export type PredicateExpression = PredicateFieldRef | {
48
+ readonly kind: "jsonText";
49
+ readonly field: PredicateFieldRef;
50
+ readonly path: readonly string[];
51
+ } | {
52
+ readonly kind: "length";
53
+ readonly expression: PredicateExpression;
54
+ };
55
+ /** Either side of a comparison: an expression, or a literal. */
56
+ export type PredicateOperand = PredicateExpression | PredicateValue;
47
57
  /**
48
58
  * A boolean expression over one model's fields.
49
59
  *
@@ -55,7 +65,7 @@ export type PredicateOperand = PredicateFieldRef | PredicateValue;
55
65
  export type PredicateIR = {
56
66
  readonly kind: "compare";
57
67
  readonly op: PredicateComparisonOp;
58
- readonly left: PredicateFieldRef;
68
+ readonly left: PredicateExpression;
59
69
  readonly right: PredicateOperand;
60
70
  } | {
61
71
  readonly kind: "inList";
@@ -75,6 +85,9 @@ export type PredicateIR = {
75
85
  } | {
76
86
  readonly kind: "not";
77
87
  readonly operand: PredicateIR;
88
+ } | {
89
+ readonly kind: "isTrue";
90
+ readonly operand: PredicateIR;
78
91
  };
79
92
  /** Narrow a predicate operand to a field reference. */
80
93
  export declare function isPredicateFieldRef(operand: PredicateOperand): operand is PredicateFieldRef;
@@ -87,6 +100,19 @@ export declare function isPredicateFieldRef(operand: PredicateOperand): operand
87
100
  export declare function predicateFieldNames(params: {
88
101
  predicate: PredicateIR;
89
102
  }): readonly string[];
103
+ /** Walk every nested scalar expression and record whether CHECK-only nodes occur. */
104
+ export declare function inspectPredicate(params: {
105
+ predicate: PredicateIR;
106
+ }): {
107
+ readonly expressions: readonly PredicateExpression[];
108
+ readonly checkOnly: boolean;
109
+ };
110
+ /** Refuse CHECK-only expressions in index/exclusion predicates and unqualified dialects. */
111
+ export declare function assertPredicateCapabilities(params: {
112
+ predicate: PredicateIR;
113
+ dialect: Dialect;
114
+ usage: "check" | "indexPredicate" | "exclusionPredicate";
115
+ }): void;
90
116
  /**
91
117
  * A stable, DIALECT-FREE key for a predicate.
92
118
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibeorm/schema",
3
- "version": "3.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Canonical schema IR, validation, dialect/capability types, and error codes for VibeORM v2",
5
5
  "keywords": [
6
6
  "orm",