@zenstackhq/schema 3.5.6 → 3.6.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/dist/index.cjs +186 -250
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +195 -204
- package/dist/index.d.mts +289 -0
- package/dist/index.mjs +196 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +9 -8
- package/dist/index.d.ts +0 -298
- package/dist/index.js +0 -236
- package/dist/index.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,182 +1,170 @@
|
|
|
1
|
-
import Decimal from
|
|
1
|
+
import Decimal from "decimal.js";
|
|
2
2
|
|
|
3
|
+
//#region src/expression.d.ts
|
|
3
4
|
type Expression = LiteralExpression | ArrayExpression | FieldExpression | MemberExpression | CallExpression | UnaryExpression | BinaryExpression | BindingExpression | ThisExpression | NullExpression;
|
|
4
5
|
type LiteralExpression = {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
kind: 'literal';
|
|
7
|
+
value: string | number | boolean;
|
|
7
8
|
};
|
|
8
9
|
type ArrayExpression = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
kind: 'array';
|
|
11
|
+
type: string;
|
|
12
|
+
items: Expression[];
|
|
12
13
|
};
|
|
13
14
|
type FieldExpression = {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
kind: 'field';
|
|
16
|
+
field: string;
|
|
16
17
|
};
|
|
17
18
|
type MemberExpression = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
kind: 'member';
|
|
20
|
+
receiver: Expression;
|
|
21
|
+
members: string[];
|
|
21
22
|
};
|
|
22
23
|
type BindingExpression = {
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
kind: 'binding';
|
|
25
|
+
name: string;
|
|
25
26
|
};
|
|
26
27
|
type UnaryExpression = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
kind: 'unary';
|
|
29
|
+
op: UnaryOperator;
|
|
30
|
+
operand: Expression;
|
|
30
31
|
};
|
|
31
32
|
type BinaryExpression = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
kind: 'binary';
|
|
34
|
+
op: BinaryOperator;
|
|
35
|
+
left: Expression;
|
|
36
|
+
right: Expression;
|
|
37
|
+
binding?: string;
|
|
37
38
|
};
|
|
38
39
|
type CallExpression = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
kind: 'call';
|
|
41
|
+
function: string;
|
|
42
|
+
args?: Expression[];
|
|
42
43
|
};
|
|
43
44
|
type ThisExpression = {
|
|
44
|
-
|
|
45
|
+
kind: 'this';
|
|
45
46
|
};
|
|
46
47
|
type NullExpression = {
|
|
47
|
-
|
|
48
|
+
kind: 'null';
|
|
48
49
|
};
|
|
49
50
|
type UnaryOperator = '!';
|
|
50
51
|
type BinaryOperator = '&&' | '||' | '==' | '!=' | '<' | '<=' | '>' | '>=' | '?' | '!' | '^' | 'in';
|
|
51
|
-
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/schema.d.ts
|
|
52
54
|
type DataSourceProviderType = 'sqlite' | 'postgresql' | 'mysql';
|
|
53
55
|
type DataSourceProvider = {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
type: DataSourceProviderType;
|
|
57
|
+
defaultSchema?: string;
|
|
56
58
|
};
|
|
57
59
|
type SchemaDef = {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
provider: DataSourceProvider;
|
|
61
|
+
models: Record<string, ModelDef>;
|
|
62
|
+
enums?: Record<string, EnumDef>;
|
|
63
|
+
typeDefs?: Record<string, TypeDefDef>;
|
|
64
|
+
plugins: Record<string, unknown>;
|
|
65
|
+
procedures?: Record<string, ProcedureDef>;
|
|
66
|
+
authType?: GetModels<SchemaDef> | GetTypeDefs<SchemaDef>;
|
|
65
67
|
};
|
|
66
68
|
type UniqueFieldsInfo = Pick<FieldDef, 'type'> | Record<string, Pick<FieldDef, 'type'>>;
|
|
67
69
|
type ModelDef = {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
name: string;
|
|
71
|
+
baseModel?: string;
|
|
72
|
+
fields: Record<string, FieldDef>;
|
|
73
|
+
attributes?: readonly AttributeApplication[];
|
|
74
|
+
uniqueFields: Record<string, UniqueFieldsInfo>;
|
|
75
|
+
idFields: readonly string[];
|
|
76
|
+
computedFields?: Record<string, Function>;
|
|
77
|
+
isDelegate?: boolean;
|
|
78
|
+
subModels?: readonly string[];
|
|
79
|
+
isView?: boolean;
|
|
78
80
|
};
|
|
79
81
|
type AttributeApplication = {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
name: string;
|
|
83
|
+
args?: readonly AttributeArg[];
|
|
82
84
|
};
|
|
83
85
|
type AttributeArg = {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
name?: string;
|
|
87
|
+
value: Expression;
|
|
86
88
|
};
|
|
87
89
|
type CascadeAction = 'SetNull' | 'Cascade' | 'Restrict' | 'NoAction' | 'SetDefault';
|
|
88
90
|
type RelationInfo = {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
name?: string;
|
|
92
|
+
fields?: readonly string[];
|
|
93
|
+
references?: readonly string[];
|
|
94
|
+
hasDefault?: boolean;
|
|
95
|
+
opposite?: string;
|
|
96
|
+
onDelete?: CascadeAction;
|
|
97
|
+
onUpdate?: CascadeAction;
|
|
96
98
|
};
|
|
97
99
|
type UpdatedAtInfo = {
|
|
98
|
-
|
|
100
|
+
ignore?: readonly string[];
|
|
99
101
|
};
|
|
100
102
|
type FieldDefault = MappedBuiltinType | Expression | readonly unknown[];
|
|
101
103
|
type FieldDef = {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
104
|
+
name: string;
|
|
105
|
+
type: string;
|
|
106
|
+
id?: boolean;
|
|
107
|
+
array?: boolean;
|
|
108
|
+
optional?: boolean;
|
|
109
|
+
unique?: boolean;
|
|
110
|
+
updatedAt?: boolean | UpdatedAtInfo;
|
|
111
|
+
attributes?: readonly AttributeApplication[];
|
|
112
|
+
default?: FieldDefault;
|
|
113
|
+
omit?: boolean;
|
|
114
|
+
relation?: RelationInfo;
|
|
115
|
+
foreignKeyFor?: readonly string[];
|
|
116
|
+
computed?: boolean;
|
|
117
|
+
originModel?: string;
|
|
118
|
+
isDiscriminator?: boolean;
|
|
117
119
|
};
|
|
118
120
|
type ProcedureParam = {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
name: string;
|
|
122
|
+
type: string;
|
|
123
|
+
array?: boolean;
|
|
124
|
+
optional?: boolean;
|
|
123
125
|
};
|
|
124
126
|
type ProcedureDef = {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
params: Record<string, ProcedureParam>;
|
|
128
|
+
returnType: string;
|
|
129
|
+
returnArray?: boolean;
|
|
130
|
+
mutation?: boolean;
|
|
129
131
|
};
|
|
130
132
|
type BuiltinType = 'String' | 'Boolean' | 'Int' | 'Float' | 'BigInt' | 'Decimal' | 'DateTime' | 'Bytes' | 'Json' | 'Unsupported';
|
|
131
133
|
type MappedBuiltinType = string | boolean | number | bigint | Decimal | Date;
|
|
132
134
|
type EnumField = {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
name: string;
|
|
136
|
+
attributes?: readonly AttributeApplication[];
|
|
135
137
|
};
|
|
136
138
|
type EnumDef = {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
name: string;
|
|
140
|
+
fields?: Record<string, EnumField>;
|
|
141
|
+
values: Record<string, string>;
|
|
142
|
+
attributes?: readonly AttributeApplication[];
|
|
141
143
|
};
|
|
142
144
|
type TypeDefDef = {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
name: string;
|
|
146
|
+
fields: Record<string, FieldDef>;
|
|
147
|
+
attributes?: readonly AttributeApplication[];
|
|
146
148
|
};
|
|
147
149
|
type GetModels<Schema extends SchemaDef> = Extract<keyof Schema['models'], string>;
|
|
148
|
-
type GetDelegateModels<Schema extends SchemaDef> = keyof {
|
|
149
|
-
[Key in GetModels<Schema> as Schema['models'][Key]['isDelegate'] extends true ? Key : never]: true;
|
|
150
|
-
};
|
|
150
|
+
type GetDelegateModels<Schema extends SchemaDef> = keyof { [Key in GetModels<Schema> as Schema['models'][Key]['isDelegate'] extends true ? Key : never]: true };
|
|
151
151
|
type GetSubModels<Schema extends SchemaDef, Model extends GetModels<Schema>> = GetModel<Schema, Model>['subModels'] extends readonly string[] ? Extract<GetModel<Schema, Model>['subModels'][number], GetModels<Schema>> : never;
|
|
152
152
|
type GetModel<Schema extends SchemaDef, Model extends GetModels<Schema>> = Schema['models'][Model];
|
|
153
153
|
type GetEnums<Schema extends SchemaDef> = Extract<keyof Schema['enums'], string>;
|
|
154
154
|
type GetEnum<Schema extends SchemaDef, Enum extends GetEnums<Schema>> = Schema['enums'][Enum] extends EnumDef ? Schema['enums'][Enum]['values'] : never;
|
|
155
155
|
type GetTypeDefs<Schema extends SchemaDef> = Extract<keyof Schema['typeDefs'], string>;
|
|
156
156
|
type GetTypeDef<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>> = Schema['typeDefs'] extends Record<string, unknown> ? Schema['typeDefs'][TypeDef] : never;
|
|
157
|
-
type GetModelFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
158
|
-
[Key in Extract<keyof GetModel<Schema, Model>['fields'], string> as FieldIsUnsupported<Schema, Model, Key> extends true ? never : Key]: never;
|
|
159
|
-
};
|
|
157
|
+
type GetModelFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof { [Key in Extract<keyof GetModel<Schema, Model>['fields'], string> as FieldIsUnsupported<Schema, Model, Key> extends true ? never : Key]: never };
|
|
160
158
|
type GetModelField<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModel<Schema, Model>['fields'][Field];
|
|
161
|
-
type GetModelDiscriminator<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
162
|
-
[Key in GetModelFields<Schema, Model> as FieldIsDelegateDiscriminator<Schema, Model, Key> extends true ? GetModelField<Schema, Model, Key>['originModel'] extends string ? never : Key : never]: true;
|
|
163
|
-
};
|
|
159
|
+
type GetModelDiscriminator<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof { [Key in GetModelFields<Schema, Model> as FieldIsDelegateDiscriminator<Schema, Model, Key> extends true ? GetModelField<Schema, Model, Key>['originModel'] extends string ? never : Key : never]: true };
|
|
164
160
|
type GetModelFieldType<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = Schema['models'][Model]['fields'][Field]['type'];
|
|
165
161
|
type GetTypeDefFields<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>> = Extract<keyof GetTypeDef<Schema, TypeDef>['fields'], string>;
|
|
166
162
|
type GetTypeDefField<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>, Field extends GetTypeDefFields<Schema, TypeDef>> = GetTypeDef<Schema, TypeDef>['fields'][Field];
|
|
167
163
|
type GetTypeDefFieldType<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>, Field extends GetTypeDefFields<Schema, TypeDef>> = GetTypeDef<Schema, TypeDef>['fields'][Field]['type'];
|
|
168
|
-
type ScalarFields<Schema extends SchemaDef, Model extends GetModels<Schema>, IncludeComputed extends boolean = true> = keyof {
|
|
169
|
-
|
|
170
|
-
};
|
|
171
|
-
type
|
|
172
|
-
[Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['foreignKeyFor'] extends readonly string[] ? Key : never]: Key;
|
|
173
|
-
};
|
|
174
|
-
type NonRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
175
|
-
[Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends object ? never : Key]: Key;
|
|
176
|
-
};
|
|
177
|
-
type RelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
178
|
-
[Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends object ? Key : never]: Key;
|
|
179
|
-
};
|
|
164
|
+
type ScalarFields<Schema extends SchemaDef, Model extends GetModels<Schema>, IncludeComputed extends boolean = true> = keyof { [Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends object ? never : GetModelField<Schema, Model, Key>['foreignKeyFor'] extends readonly string[] ? never : IncludeComputed extends true ? Key : FieldIsComputed<Schema, Model, Key> extends true ? never : Key]: Key };
|
|
165
|
+
type ForeignKeyFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof { [Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['foreignKeyFor'] extends readonly string[] ? Key : never]: Key };
|
|
166
|
+
type NonRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof { [Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends object ? never : Key]: Key };
|
|
167
|
+
type RelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof { [Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends object ? Key : never]: Key };
|
|
180
168
|
type FieldType<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['type'];
|
|
181
169
|
type RelationFieldType<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = GetModelField<Schema, Model, Field>['type'] extends GetModels<Schema> ? GetModelField<Schema, Model, Field>['type'] : never;
|
|
182
170
|
type ModelFieldIsOptional<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['optional'] extends true ? true : false;
|
|
@@ -187,112 +175,115 @@ type FieldIsArray<Schema extends SchemaDef, Model extends GetModels<Schema>, Fie
|
|
|
187
175
|
type FieldIsComputed<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['computed'] extends true ? true : false;
|
|
188
176
|
type FieldIsUnsupported<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends string> = Field extends keyof GetModel<Schema, Model>['fields'] ? GetModel<Schema, Model>['fields'][Field]['type'] extends 'Unsupported' ? true : false : never;
|
|
189
177
|
type FieldHasDefault<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = 'default' extends keyof GetModelField<Schema, Model, Field> ? true : GetModelField<Schema, Model, Field>['updatedAt'] extends true | UpdatedAtInfo ? true : GetModelField<Schema, Model, Field>['relation'] extends {
|
|
190
|
-
|
|
178
|
+
hasDefault: true;
|
|
191
179
|
} ? true : false;
|
|
192
180
|
type FieldIsRelationArray<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = FieldIsRelation<Schema, Model, Field> extends true ? FieldIsArray<Schema, Model, Field> : false;
|
|
193
181
|
type IsDelegateModel<Schema extends SchemaDef, Model extends GetModels<Schema>> = Schema['models'][Model]['isDelegate'] extends true ? true : false;
|
|
194
182
|
type FieldIsDelegateRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = GetModelFieldType<Schema, Model, Field> extends GetModels<Schema> ? IsDelegateModel<Schema, GetModelFieldType<Schema, Model, Field>> : false;
|
|
195
183
|
type FieldIsDelegateDiscriminator<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['isDiscriminator'] extends true ? true : false;
|
|
196
|
-
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/accessor.d.ts
|
|
197
186
|
type Accessors = {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
187
|
+
/**
|
|
188
|
+
* The data source provider type of the schema, e.g. "sqlite", "postgresql", etc.
|
|
189
|
+
*/
|
|
190
|
+
get providerType(): DataSourceProviderType;
|
|
191
|
+
/**
|
|
192
|
+
* Gets a model definition by name. Returns `undefined` if the model is not found.
|
|
193
|
+
*/
|
|
194
|
+
getModel(name: string): ModelDef | undefined;
|
|
195
|
+
/**
|
|
196
|
+
* Gets a model definition by name. Throws an error if the model is not found.
|
|
197
|
+
*/
|
|
198
|
+
requireModel(name: string): ModelDef;
|
|
199
|
+
/**
|
|
200
|
+
* Gets a field definition by model/type and field name. Returns `undefined` if the field is not found.
|
|
201
|
+
*/
|
|
202
|
+
getField(modelOrType: string, field: string): FieldDef | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* Gets a field definition by model/type and field name. Throws an error if the field is not found.
|
|
205
|
+
*/
|
|
206
|
+
requireField(modelOrType: string, field: string): FieldDef;
|
|
207
|
+
/***
|
|
208
|
+
* Gets an enum definition by name. Returns `undefined` if the enum is not found.
|
|
209
|
+
*/
|
|
210
|
+
getEnum(name: string): EnumDef | undefined;
|
|
211
|
+
/**
|
|
212
|
+
* Gets an enum definition by name. Throws an error if the enum is not found.
|
|
213
|
+
*/
|
|
214
|
+
requireEnum(name: string): EnumDef;
|
|
215
|
+
/**
|
|
216
|
+
* Gets a type definition by name. Returns `undefined` if the type definition is not found.
|
|
217
|
+
* @param name
|
|
218
|
+
*/
|
|
219
|
+
getTypeDef(name: string): TypeDefDef | undefined;
|
|
220
|
+
/**
|
|
221
|
+
* Gets a type definition by name. Throws an error if the type definition is not found.
|
|
222
|
+
*/
|
|
223
|
+
requireTypeDef(name: string): TypeDefDef;
|
|
224
|
+
/**
|
|
225
|
+
* Gets a procedure definition by name. Returns `undefined` if the procedure is not found.
|
|
226
|
+
*/
|
|
227
|
+
getProcedure(name: string): ProcedureDef | undefined;
|
|
228
|
+
/**
|
|
229
|
+
* Gets a procedure definition by name. Throws an error if the procedure is not found.
|
|
230
|
+
*/
|
|
231
|
+
requireProcedure(name: string): ProcedureDef;
|
|
232
|
+
/**
|
|
233
|
+
* Gets the unique fields of a model, including both singular and compound unique fields.
|
|
234
|
+
*/
|
|
235
|
+
getUniqueFields(model: string): Array<{
|
|
236
|
+
name: string;
|
|
237
|
+
def: FieldDef;
|
|
238
|
+
} | {
|
|
239
|
+
name: string;
|
|
240
|
+
defs: Record<string, FieldDef>;
|
|
241
|
+
}>;
|
|
242
|
+
/**
|
|
243
|
+
* Gets the delegate discriminator field for a model, if defined via `@@delegate` attribute. Returns `undefined` if not available.
|
|
244
|
+
*/
|
|
245
|
+
getDelegateDiscriminator(model: string): string | undefined;
|
|
257
246
|
};
|
|
258
247
|
declare class InvalidSchemaError extends Error {
|
|
259
|
-
|
|
248
|
+
constructor(message: string);
|
|
260
249
|
}
|
|
250
|
+
type SchemaAccessor<Schema extends SchemaDef> = Schema & Accessors;
|
|
261
251
|
interface SchemaAccessorConstructor {
|
|
262
|
-
|
|
252
|
+
new <Schema extends SchemaDef>(schema: Schema): SchemaAccessor<Schema>;
|
|
263
253
|
}
|
|
264
|
-
type SchemaAccessor<Schema extends SchemaDef> = Schema & Accessors;
|
|
265
254
|
declare const SchemaAccessor: SchemaAccessorConstructor;
|
|
266
|
-
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/expression-utils.d.ts
|
|
267
257
|
/**
|
|
268
258
|
* Utility functions to create and work with Expression objects
|
|
269
259
|
*/
|
|
270
260
|
declare const ExpressionUtils: {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
export {
|
|
261
|
+
literal: (value: string | number | boolean) => LiteralExpression;
|
|
262
|
+
array: (type: string, items: Expression[]) => ArrayExpression;
|
|
263
|
+
call: (functionName: string, args?: Expression[]) => CallExpression;
|
|
264
|
+
binary: (left: Expression, op: BinaryOperator, right: Expression, binding?: string) => BinaryExpression;
|
|
265
|
+
unary: (op: UnaryOperator, operand: Expression) => UnaryExpression;
|
|
266
|
+
field: (field: string) => FieldExpression;
|
|
267
|
+
member: (receiver: Expression, members: string[]) => MemberExpression;
|
|
268
|
+
binding: (name: string) => BindingExpression;
|
|
269
|
+
_this: () => ThisExpression;
|
|
270
|
+
_null: () => NullExpression;
|
|
271
|
+
and: (expr: Expression, ...expressions: Expression[]) => Expression;
|
|
272
|
+
or: (expr: Expression, ...expressions: Expression[]) => Expression;
|
|
273
|
+
not: (expr: Expression) => UnaryExpression;
|
|
274
|
+
is: (value: unknown, kind: Expression["kind"]) => value is Expression;
|
|
275
|
+
isLiteral: (value: unknown) => value is LiteralExpression;
|
|
276
|
+
isArray: (value: unknown) => value is ArrayExpression;
|
|
277
|
+
isCall: (value: unknown) => value is CallExpression;
|
|
278
|
+
isNull: (value: unknown) => value is NullExpression;
|
|
279
|
+
isThis: (value: unknown) => value is ThisExpression;
|
|
280
|
+
isUnary: (value: unknown) => value is UnaryExpression;
|
|
281
|
+
isBinary: (value: unknown) => value is BinaryExpression;
|
|
282
|
+
isField: (value: unknown) => value is FieldExpression;
|
|
283
|
+
isMember: (value: unknown) => value is MemberExpression;
|
|
284
|
+
isBinding: (value: unknown) => value is BindingExpression;
|
|
285
|
+
getLiteralValue: (expr: Expression) => string | number | boolean | undefined;
|
|
286
|
+
};
|
|
287
|
+
//#endregion
|
|
288
|
+
export { ArrayExpression, AttributeApplication, AttributeArg, BinaryExpression, BinaryOperator, BindingExpression, BuiltinType, CallExpression, CascadeAction, DataSourceProvider, DataSourceProviderType, EnumDef, EnumField, Expression, ExpressionUtils, FieldDef, FieldDefault, FieldExpression, FieldHasDefault, FieldIsArray, FieldIsComputed, FieldIsDelegateDiscriminator, FieldIsDelegateRelation, FieldIsRelation, FieldIsRelationArray, FieldIsUnsupported, FieldType, ForeignKeyFields, GetDelegateModels, GetEnum, GetEnums, GetModel, GetModelDiscriminator, GetModelField, GetModelFieldType, GetModelFields, GetModels, GetSubModels, GetTypeDef, GetTypeDefField, GetTypeDefFieldType, GetTypeDefFields, GetTypeDefs, InvalidSchemaError, IsDelegateModel, LiteralExpression, MappedBuiltinType, MemberExpression, ModelDef, ModelFieldIsOptional, NonRelationFields, NullExpression, ProcedureDef, ProcedureParam, RelationFieldType, RelationFields, RelationInfo, ScalarFields, SchemaAccessor, SchemaDef, ThisExpression, TypeDefDef, TypeDefFieldIsArray, TypeDefFieldIsOptional, UnaryExpression, UnaryOperator, UniqueFieldsInfo, UpdatedAtInfo };
|
|
289
|
+
//# sourceMappingURL=index.d.cts.map
|