@mateusseiboth/ember-orm 0.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.
@@ -0,0 +1,145 @@
1
+ /**
2
+ * EmberORM schema AST (DMMF-like).
3
+ *
4
+ * This is the single in-memory source of truth that every other layer
5
+ * (parser, validator, query engine, generator, introspection) depends on.
6
+ * It is intentionally decoupled from Firebird specifics so it can be reused
7
+ * for other dialects in the future.
8
+ */
9
+ type ScalarType = "String" | "Boolean" | "Int" | "BigInt" | "Float" | "Decimal" | "DateTime" | "Bytes" | "Json";
10
+ declare const SCALAR_TYPES: readonly ScalarType[];
11
+ type FieldKind = "scalar" | "enum" | "object";
12
+ /** Value of an attribute argument, e.g. `@default(now())` or `@map("USER_ID")`. */
13
+ type AttributeArgValue = {
14
+ kind: "string";
15
+ value: string;
16
+ } | {
17
+ kind: "number";
18
+ value: number;
19
+ } | {
20
+ kind: "boolean";
21
+ value: boolean;
22
+ } | {
23
+ kind: "ref";
24
+ value: string;
25
+ } | {
26
+ kind: "function";
27
+ name: string;
28
+ args: AttributeArgValue[];
29
+ } | {
30
+ kind: "array";
31
+ items: AttributeArgValue[];
32
+ };
33
+ interface DefaultValue {
34
+ /** A scalar literal default. */
35
+ literal?: string | number | boolean;
36
+ /** A function default such as now(), uuid(), cuid(), autoincrement(). */
37
+ function?: {
38
+ name: string;
39
+ args: AttributeArgValue[];
40
+ };
41
+ }
42
+ interface RelationInfo {
43
+ /** Relation name (@relation("name")). */
44
+ name?: string;
45
+ /** Local fields participating in the FK (`fields: [...]`). */
46
+ fields?: string[];
47
+ /** Referenced fields on the other model (`references: [...]`). */
48
+ references?: string[];
49
+ onDelete?: ReferentialAction;
50
+ onUpdate?: ReferentialAction;
51
+ }
52
+ type ReferentialAction = "Cascade" | "Restrict" | "NoAction" | "SetNull" | "SetDefault";
53
+ interface NativeType {
54
+ /** e.g. "VarChar", "Decimal". */
55
+ name: string;
56
+ /** e.g. [255] or [18, 4]. */
57
+ args: number[];
58
+ }
59
+ interface FieldNode {
60
+ name: string;
61
+ /** Resolved type name: a ScalarType, an enum name, or a model name. */
62
+ type: string;
63
+ kind: FieldKind;
64
+ isList: boolean;
65
+ isRequired: boolean;
66
+ isId: boolean;
67
+ isUnique: boolean;
68
+ isUpdatedAt: boolean;
69
+ /** Column name in the database (@map). Defaults to `name`. */
70
+ dbName?: string;
71
+ default?: DefaultValue;
72
+ relation?: RelationInfo;
73
+ nativeType?: NativeType;
74
+ /** documentation/comment attached above the field (///). */
75
+ documentation?: string;
76
+ }
77
+ interface UniqueIndex {
78
+ name?: string;
79
+ fields: string[];
80
+ }
81
+ interface IndexNode {
82
+ name?: string;
83
+ fields: string[];
84
+ unique: boolean;
85
+ }
86
+ interface ModelNode {
87
+ name: string;
88
+ /** Table name in the database (@@map). Defaults to `name`. */
89
+ dbName?: string;
90
+ fields: FieldNode[];
91
+ /** Names of fields forming the primary key (composite supported via @@id). */
92
+ primaryKey: string[];
93
+ uniqueIndexes: UniqueIndex[];
94
+ indexes: IndexNode[];
95
+ documentation?: string;
96
+ }
97
+ interface EnumNode {
98
+ name: string;
99
+ dbName?: string;
100
+ values: {
101
+ name: string;
102
+ dbName?: string;
103
+ }[];
104
+ documentation?: string;
105
+ }
106
+ interface DatasourceNode {
107
+ name: string;
108
+ provider: string;
109
+ /** Raw url expression; env("X") resolved at runtime. */
110
+ url: {
111
+ kind: "literal" | "env";
112
+ value: string;
113
+ };
114
+ }
115
+ interface GeneratorNode {
116
+ name: string;
117
+ provider: string;
118
+ output?: string;
119
+ config: Record<string, string>;
120
+ }
121
+ interface SchemaDocument {
122
+ datasource?: DatasourceNode;
123
+ generators: GeneratorNode[];
124
+ models: ModelNode[];
125
+ enums: EnumNode[];
126
+ }
127
+ declare function emptySchema(): SchemaDocument;
128
+ declare function findModel(schema: SchemaDocument, name: string): ModelNode | undefined;
129
+ declare function findEnum(schema: SchemaDocument, name: string): EnumNode | undefined;
130
+ /**
131
+ * Physical column name. Firebird folds unquoted identifiers to UPPER CASE, and
132
+ * EmberORM always quotes identifiers, so a field without an explicit `@map`
133
+ * resolves to its UPPER-CASED name to match the stored column. Use `@map` to
134
+ * target a column created with case-sensitive (quoted) lower/mixed case.
135
+ */
136
+ declare function fieldColumn(field: FieldNode): string;
137
+ /** Physical table name; same UPPER-CASE folding rule as {@link fieldColumn}. */
138
+ declare function modelTable(model: ModelNode): string;
139
+ /** Returns scalar fields only (excludes relation/object fields). */
140
+ declare function scalarFields(model: ModelNode): FieldNode[];
141
+ /** Returns relation (object) fields only. */
142
+ declare function relationFields(model: ModelNode): FieldNode[];
143
+ declare function idFields(model: ModelNode): FieldNode[];
144
+
145
+ export { type AttributeArgValue as A, type DatasourceNode as D, type EnumNode as E, type FieldNode as F, type GeneratorNode as G, type IndexNode as I, type ModelNode as M, type NativeType as N, type ReferentialAction as R, type SchemaDocument as S, type UniqueIndex as U, SCALAR_TYPES as a, type ScalarType as b, type DefaultValue as c, type FieldKind as d, type RelationInfo as e, emptySchema as f, fieldColumn as g, findEnum as h, findModel as i, idFields as j, modelTable as m, relationFields as r, scalarFields as s };