@zenstackhq/schema 3.3.0-beta.2 → 3.3.0-beta.4
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 +12 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -33,9 +33,10 @@ var ExpressionUtils = {
|
|
|
33
33
|
value
|
|
34
34
|
};
|
|
35
35
|
}, "literal"),
|
|
36
|
-
array: /* @__PURE__ */ __name((items) => {
|
|
36
|
+
array: /* @__PURE__ */ __name((type, items) => {
|
|
37
37
|
return {
|
|
38
38
|
kind: "array",
|
|
39
|
+
type,
|
|
39
40
|
items
|
|
40
41
|
};
|
|
41
42
|
}, "array"),
|
|
@@ -46,12 +47,13 @@ var ExpressionUtils = {
|
|
|
46
47
|
args
|
|
47
48
|
};
|
|
48
49
|
}, "call"),
|
|
49
|
-
binary: /* @__PURE__ */ __name((left, op, right) => {
|
|
50
|
+
binary: /* @__PURE__ */ __name((left, op, right, binding) => {
|
|
50
51
|
return {
|
|
51
52
|
kind: "binary",
|
|
52
53
|
op,
|
|
53
54
|
left,
|
|
54
|
-
right
|
|
55
|
+
right,
|
|
56
|
+
binding
|
|
55
57
|
};
|
|
56
58
|
}, "binary"),
|
|
57
59
|
unary: /* @__PURE__ */ __name((op, operand) => {
|
|
@@ -74,6 +76,12 @@ var ExpressionUtils = {
|
|
|
74
76
|
members
|
|
75
77
|
};
|
|
76
78
|
}, "member"),
|
|
79
|
+
binding: /* @__PURE__ */ __name((name) => {
|
|
80
|
+
return {
|
|
81
|
+
kind: "binding",
|
|
82
|
+
name
|
|
83
|
+
};
|
|
84
|
+
}, "binding"),
|
|
77
85
|
_this: /* @__PURE__ */ __name(() => {
|
|
78
86
|
return {
|
|
79
87
|
kind: "this"
|
|
@@ -105,6 +113,7 @@ var ExpressionUtils = {
|
|
|
105
113
|
isBinary: /* @__PURE__ */ __name((value) => ExpressionUtils.is(value, "binary"), "isBinary"),
|
|
106
114
|
isField: /* @__PURE__ */ __name((value) => ExpressionUtils.is(value, "field"), "isField"),
|
|
107
115
|
isMember: /* @__PURE__ */ __name((value) => ExpressionUtils.is(value, "member"), "isMember"),
|
|
116
|
+
isBinding: /* @__PURE__ */ __name((value) => ExpressionUtils.is(value, "binding"), "isBinding"),
|
|
108
117
|
getLiteralValue: /* @__PURE__ */ __name((expr) => {
|
|
109
118
|
return ExpressionUtils.isLiteral(expr) ? expr.value : void 0;
|
|
110
119
|
}, "getLiteralValue")
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/expression-utils.ts"],"sourcesContent":["export type * from './expression';\nexport * from './expression-utils';\nexport type * from './schema';\n","import type {\n ArrayExpression,\n BinaryExpression,\n BinaryOperator,\n CallExpression,\n Expression,\n FieldExpression,\n LiteralExpression,\n MemberExpression,\n NullExpression,\n ThisExpression,\n UnaryExpression,\n UnaryOperator,\n} from './expression';\n\n/**\n * Utility functions to create and work with Expression objects\n */\nexport const ExpressionUtils = {\n literal: (value: string | number | boolean): LiteralExpression => {\n return {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/expression-utils.ts"],"sourcesContent":["export type * from './expression';\nexport * from './expression-utils';\nexport type * from './schema';\n","import type {\n ArrayExpression,\n BinaryExpression,\n BinaryOperator,\n BindingExpression,\n CallExpression,\n Expression,\n FieldExpression,\n LiteralExpression,\n MemberExpression,\n NullExpression,\n ThisExpression,\n UnaryExpression,\n UnaryOperator,\n} from './expression';\n\n/**\n * Utility functions to create and work with Expression objects\n */\nexport const ExpressionUtils = {\n literal: (value: string | number | boolean): LiteralExpression => {\n return { kind: 'literal', value };\n },\n\n array: (type: string, items: Expression[]): ArrayExpression => {\n return { kind: 'array', type, items };\n },\n\n call: (functionName: string, args?: Expression[]): CallExpression => {\n return { kind: 'call', function: functionName, args };\n },\n\n binary: (left: Expression, op: BinaryOperator, right: Expression, binding?: string): BinaryExpression => {\n return { kind: 'binary', op, left, right, binding };\n },\n\n unary: (op: UnaryOperator, operand: Expression): UnaryExpression => {\n return { kind: 'unary', op, operand };\n },\n\n field: (field: string): FieldExpression => {\n return { kind: 'field', field };\n },\n\n member: (receiver: Expression, members: string[]): MemberExpression => {\n return { kind: 'member', receiver: receiver, members };\n },\n\n binding: (name: string): BindingExpression => {\n return { kind: 'binding', name };\n },\n\n _this: (): ThisExpression => {\n return { kind: 'this' };\n },\n\n _null: (): NullExpression => {\n return { kind: 'null' };\n },\n\n and: (expr: Expression, ...expressions: Expression[]) => {\n return expressions.reduce((acc, exp) => ExpressionUtils.binary(acc, '&&', exp), expr);\n },\n\n or: (expr: Expression, ...expressions: Expression[]) => {\n return expressions.reduce((acc, exp) => ExpressionUtils.binary(acc, '||', exp), expr);\n },\n\n not: (expr: Expression) => {\n return ExpressionUtils.unary('!', expr);\n },\n\n is: (value: unknown, kind: Expression['kind']): value is Expression => {\n return !!value && typeof value === 'object' && 'kind' in value && value.kind === kind;\n },\n\n isLiteral: (value: unknown): value is LiteralExpression => ExpressionUtils.is(value, 'literal'),\n\n isArray: (value: unknown): value is ArrayExpression => ExpressionUtils.is(value, 'array'),\n\n isCall: (value: unknown): value is CallExpression => ExpressionUtils.is(value, 'call'),\n\n isNull: (value: unknown): value is NullExpression => ExpressionUtils.is(value, 'null'),\n\n isThis: (value: unknown): value is ThisExpression => ExpressionUtils.is(value, 'this'),\n\n isUnary: (value: unknown): value is UnaryExpression => ExpressionUtils.is(value, 'unary'),\n\n isBinary: (value: unknown): value is BinaryExpression => ExpressionUtils.is(value, 'binary'),\n\n isField: (value: unknown): value is FieldExpression => ExpressionUtils.is(value, 'field'),\n\n isMember: (value: unknown): value is MemberExpression => ExpressionUtils.is(value, 'member'),\n\n isBinding: (value: unknown): value is BindingExpression => ExpressionUtils.is(value, 'binding'),\n\n getLiteralValue: (expr: Expression): string | number | boolean | undefined => {\n return ExpressionUtils.isLiteral(expr) ? expr.value : undefined;\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;;;;;;ACkBO,IAAMA,kBAAkB;EAC3BC,SAAS,wBAACC,UAAAA;AACN,WAAO;MAAEC,MAAM;MAAWD;IAAM;EACpC,GAFS;EAITE,OAAO,wBAACC,MAAcC,UAAAA;AAClB,WAAO;MAAEH,MAAM;MAASE;MAAMC;IAAM;EACxC,GAFO;EAIPC,MAAM,wBAACC,cAAsBC,SAAAA;AACzB,WAAO;MAAEN,MAAM;MAAQO,UAAUF;MAAcC;IAAK;EACxD,GAFM;EAINE,QAAQ,wBAACC,MAAkBC,IAAoBC,OAAmBC,YAAAA;AAC9D,WAAO;MAAEZ,MAAM;MAAUU;MAAID;MAAME;MAAOC;IAAQ;EACtD,GAFQ;EAIRC,OAAO,wBAACH,IAAmBI,YAAAA;AACvB,WAAO;MAAEd,MAAM;MAASU;MAAII;IAAQ;EACxC,GAFO;EAIPC,OAAO,wBAACA,UAAAA;AACJ,WAAO;MAAEf,MAAM;MAASe;IAAM;EAClC,GAFO;EAIPC,QAAQ,wBAACC,UAAsBC,YAAAA;AAC3B,WAAO;MAAElB,MAAM;MAAUiB;MAAoBC;IAAQ;EACzD,GAFQ;EAIRN,SAAS,wBAACO,SAAAA;AACN,WAAO;MAAEnB,MAAM;MAAWmB;IAAK;EACnC,GAFS;EAITC,OAAO,6BAAA;AACH,WAAO;MAAEpB,MAAM;IAAO;EAC1B,GAFO;EAIPqB,OAAO,6BAAA;AACH,WAAO;MAAErB,MAAM;IAAO;EAC1B,GAFO;EAIPsB,KAAK,wBAACC,SAAqBC,gBAAAA;AACvB,WAAOA,YAAYC,OAAO,CAACC,KAAKC,QAAQ9B,gBAAgBW,OAAOkB,KAAK,MAAMC,GAAAA,GAAMJ,IAAAA;EACpF,GAFK;EAILK,IAAI,wBAACL,SAAqBC,gBAAAA;AACtB,WAAOA,YAAYC,OAAO,CAACC,KAAKC,QAAQ9B,gBAAgBW,OAAOkB,KAAK,MAAMC,GAAAA,GAAMJ,IAAAA;EACpF,GAFI;EAIJM,KAAK,wBAACN,SAAAA;AACF,WAAO1B,gBAAgBgB,MAAM,KAAKU,IAAAA;EACtC,GAFK;EAILO,IAAI,wBAAC/B,OAAgBC,SAAAA;AACjB,WAAO,CAAC,CAACD,SAAS,OAAOA,UAAU,YAAY,UAAUA,SAASA,MAAMC,SAASA;EACrF,GAFI;EAIJ+B,WAAW,wBAAChC,UAA+CF,gBAAgBiC,GAAG/B,OAAO,SAAA,GAA1E;EAEXiC,SAAS,wBAACjC,UAA6CF,gBAAgBiC,GAAG/B,OAAO,OAAA,GAAxE;EAETkC,QAAQ,wBAAClC,UAA4CF,gBAAgBiC,GAAG/B,OAAO,MAAA,GAAvE;EAERmC,QAAQ,wBAACnC,UAA4CF,gBAAgBiC,GAAG/B,OAAO,MAAA,GAAvE;EAERoC,QAAQ,wBAACpC,UAA4CF,gBAAgBiC,GAAG/B,OAAO,MAAA,GAAvE;EAERqC,SAAS,wBAACrC,UAA6CF,gBAAgBiC,GAAG/B,OAAO,OAAA,GAAxE;EAETsC,UAAU,wBAACtC,UAA8CF,gBAAgBiC,GAAG/B,OAAO,QAAA,GAAzE;EAEVuC,SAAS,wBAACvC,UAA6CF,gBAAgBiC,GAAG/B,OAAO,OAAA,GAAxE;EAETwC,UAAU,wBAACxC,UAA8CF,gBAAgBiC,GAAG/B,OAAO,QAAA,GAAzE;EAEVyC,WAAW,wBAACzC,UAA+CF,gBAAgBiC,GAAG/B,OAAO,SAAA,GAA1E;EAEX0C,iBAAiB,wBAAClB,SAAAA;AACd,WAAO1B,gBAAgBkC,UAAUR,IAAAA,IAAQA,KAAKxB,QAAQ2C;EAC1D,GAFiB;AAGrB;","names":["ExpressionUtils","literal","value","kind","array","type","items","call","functionName","args","function","binary","left","op","right","binding","unary","operand","field","member","receiver","members","name","_this","_null","and","expr","expressions","reduce","acc","exp","or","not","is","isLiteral","isArray","isCall","isNull","isThis","isUnary","isBinary","isField","isMember","isBinding","getLiteralValue","undefined"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import Decimal from 'decimal.js';
|
|
2
2
|
|
|
3
|
-
type Expression = LiteralExpression | ArrayExpression | FieldExpression | MemberExpression | CallExpression | UnaryExpression | BinaryExpression | ThisExpression | NullExpression;
|
|
3
|
+
type Expression = LiteralExpression | ArrayExpression | FieldExpression | MemberExpression | CallExpression | UnaryExpression | BinaryExpression | BindingExpression | ThisExpression | NullExpression;
|
|
4
4
|
type LiteralExpression = {
|
|
5
5
|
kind: 'literal';
|
|
6
6
|
value: string | number | boolean;
|
|
7
7
|
};
|
|
8
8
|
type ArrayExpression = {
|
|
9
9
|
kind: 'array';
|
|
10
|
+
type: string;
|
|
10
11
|
items: Expression[];
|
|
11
12
|
};
|
|
12
13
|
type FieldExpression = {
|
|
@@ -18,6 +19,10 @@ type MemberExpression = {
|
|
|
18
19
|
receiver: Expression;
|
|
19
20
|
members: string[];
|
|
20
21
|
};
|
|
22
|
+
type BindingExpression = {
|
|
23
|
+
kind: 'binding';
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
21
26
|
type UnaryExpression = {
|
|
22
27
|
kind: 'unary';
|
|
23
28
|
op: UnaryOperator;
|
|
@@ -28,6 +33,7 @@ type BinaryExpression = {
|
|
|
28
33
|
op: BinaryOperator;
|
|
29
34
|
left: Expression;
|
|
30
35
|
right: Expression;
|
|
36
|
+
binding?: string;
|
|
31
37
|
};
|
|
32
38
|
type CallExpression = {
|
|
33
39
|
kind: 'call';
|
|
@@ -48,12 +54,13 @@ type BinaryOperator = '&&' | '||' | '==' | '!=' | '<' | '<=' | '>' | '>=' | '?'
|
|
|
48
54
|
*/
|
|
49
55
|
declare const ExpressionUtils: {
|
|
50
56
|
literal: (value: string | number | boolean) => LiteralExpression;
|
|
51
|
-
array: (items: Expression[]) => ArrayExpression;
|
|
57
|
+
array: (type: string, items: Expression[]) => ArrayExpression;
|
|
52
58
|
call: (functionName: string, args?: Expression[]) => CallExpression;
|
|
53
|
-
binary: (left: Expression, op: BinaryOperator, right: Expression) => BinaryExpression;
|
|
59
|
+
binary: (left: Expression, op: BinaryOperator, right: Expression, binding?: string) => BinaryExpression;
|
|
54
60
|
unary: (op: UnaryOperator, operand: Expression) => UnaryExpression;
|
|
55
61
|
field: (field: string) => FieldExpression;
|
|
56
62
|
member: (receiver: Expression, members: string[]) => MemberExpression;
|
|
63
|
+
binding: (name: string) => BindingExpression;
|
|
57
64
|
_this: () => ThisExpression;
|
|
58
65
|
_null: () => NullExpression;
|
|
59
66
|
and: (expr: Expression, ...expressions: Expression[]) => Expression;
|
|
@@ -69,10 +76,11 @@ declare const ExpressionUtils: {
|
|
|
69
76
|
isBinary: (value: unknown) => value is BinaryExpression;
|
|
70
77
|
isField: (value: unknown) => value is FieldExpression;
|
|
71
78
|
isMember: (value: unknown) => value is MemberExpression;
|
|
79
|
+
isBinding: (value: unknown) => value is BindingExpression;
|
|
72
80
|
getLiteralValue: (expr: Expression) => string | number | boolean | undefined;
|
|
73
81
|
};
|
|
74
82
|
|
|
75
|
-
type DataSourceProviderType = 'sqlite' | 'postgresql';
|
|
83
|
+
type DataSourceProviderType = 'sqlite' | 'postgresql' | 'mysql';
|
|
76
84
|
type DataSourceProvider = {
|
|
77
85
|
type: DataSourceProviderType;
|
|
78
86
|
defaultSchema?: string;
|
|
@@ -152,6 +160,7 @@ type EnumField = {
|
|
|
152
160
|
attributes?: readonly AttributeApplication[];
|
|
153
161
|
};
|
|
154
162
|
type EnumDef = {
|
|
163
|
+
name: string;
|
|
155
164
|
fields?: Record<string, EnumField>;
|
|
156
165
|
values: Record<string, string>;
|
|
157
166
|
attributes?: readonly AttributeApplication[];
|
|
@@ -208,4 +217,4 @@ type IsDelegateModel<Schema extends SchemaDef, Model extends GetModels<Schema>>
|
|
|
208
217
|
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;
|
|
209
218
|
type FieldIsDelegateDiscriminator<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['isDiscriminator'] extends true ? true : false;
|
|
210
219
|
|
|
211
|
-
export { type ArrayExpression, type AttributeApplication, type AttributeArg, type BinaryExpression, type BinaryOperator, type BuiltinType, type CallExpression, type CascadeAction, type DataSourceProvider, type DataSourceProviderType, type EnumDef, type EnumField, type Expression, ExpressionUtils, type FieldDef, type FieldExpression, type FieldHasDefault, type FieldIsArray, type FieldIsComputed, type FieldIsDelegateDiscriminator, type FieldIsDelegateRelation, type FieldIsRelation, type FieldIsRelationArray, type FieldType, type ForeignKeyFields, type GetDelegateModels, type GetEnum, type GetEnums, type GetModel, type GetModelDiscriminator, type GetModelField, type GetModelFieldType, type GetModelFields, type GetModels, type GetSubModels, type GetTypeDef, type GetTypeDefField, type GetTypeDefFieldType, type GetTypeDefFields, type GetTypeDefs, type IsDelegateModel, type LiteralExpression, type MappedBuiltinType, type MemberExpression, type ModelDef, type ModelFieldIsOptional, type NonRelationFields, type NullExpression, type ProcedureDef, type ProcedureParam, type RelationFieldType, type RelationFields, type RelationInfo, type ScalarFields, type SchemaDef, type ThisExpression, type TypeDefDef, type TypeDefFieldIsArray, type TypeDefFieldIsOptional, type UnaryExpression, type UnaryOperator };
|
|
220
|
+
export { type ArrayExpression, type AttributeApplication, type AttributeArg, type BinaryExpression, type BinaryOperator, type BindingExpression, type BuiltinType, type CallExpression, type CascadeAction, type DataSourceProvider, type DataSourceProviderType, type EnumDef, type EnumField, type Expression, ExpressionUtils, type FieldDef, type FieldExpression, type FieldHasDefault, type FieldIsArray, type FieldIsComputed, type FieldIsDelegateDiscriminator, type FieldIsDelegateRelation, type FieldIsRelation, type FieldIsRelationArray, type FieldType, type ForeignKeyFields, type GetDelegateModels, type GetEnum, type GetEnums, type GetModel, type GetModelDiscriminator, type GetModelField, type GetModelFieldType, type GetModelFields, type GetModels, type GetSubModels, type GetTypeDef, type GetTypeDefField, type GetTypeDefFieldType, type GetTypeDefFields, type GetTypeDefs, type IsDelegateModel, type LiteralExpression, type MappedBuiltinType, type MemberExpression, type ModelDef, type ModelFieldIsOptional, type NonRelationFields, type NullExpression, type ProcedureDef, type ProcedureParam, type RelationFieldType, type RelationFields, type RelationInfo, type ScalarFields, type SchemaDef, type ThisExpression, type TypeDefDef, type TypeDefFieldIsArray, type TypeDefFieldIsOptional, type UnaryExpression, type UnaryOperator };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import Decimal from 'decimal.js';
|
|
2
2
|
|
|
3
|
-
type Expression = LiteralExpression | ArrayExpression | FieldExpression | MemberExpression | CallExpression | UnaryExpression | BinaryExpression | ThisExpression | NullExpression;
|
|
3
|
+
type Expression = LiteralExpression | ArrayExpression | FieldExpression | MemberExpression | CallExpression | UnaryExpression | BinaryExpression | BindingExpression | ThisExpression | NullExpression;
|
|
4
4
|
type LiteralExpression = {
|
|
5
5
|
kind: 'literal';
|
|
6
6
|
value: string | number | boolean;
|
|
7
7
|
};
|
|
8
8
|
type ArrayExpression = {
|
|
9
9
|
kind: 'array';
|
|
10
|
+
type: string;
|
|
10
11
|
items: Expression[];
|
|
11
12
|
};
|
|
12
13
|
type FieldExpression = {
|
|
@@ -18,6 +19,10 @@ type MemberExpression = {
|
|
|
18
19
|
receiver: Expression;
|
|
19
20
|
members: string[];
|
|
20
21
|
};
|
|
22
|
+
type BindingExpression = {
|
|
23
|
+
kind: 'binding';
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
21
26
|
type UnaryExpression = {
|
|
22
27
|
kind: 'unary';
|
|
23
28
|
op: UnaryOperator;
|
|
@@ -28,6 +33,7 @@ type BinaryExpression = {
|
|
|
28
33
|
op: BinaryOperator;
|
|
29
34
|
left: Expression;
|
|
30
35
|
right: Expression;
|
|
36
|
+
binding?: string;
|
|
31
37
|
};
|
|
32
38
|
type CallExpression = {
|
|
33
39
|
kind: 'call';
|
|
@@ -48,12 +54,13 @@ type BinaryOperator = '&&' | '||' | '==' | '!=' | '<' | '<=' | '>' | '>=' | '?'
|
|
|
48
54
|
*/
|
|
49
55
|
declare const ExpressionUtils: {
|
|
50
56
|
literal: (value: string | number | boolean) => LiteralExpression;
|
|
51
|
-
array: (items: Expression[]) => ArrayExpression;
|
|
57
|
+
array: (type: string, items: Expression[]) => ArrayExpression;
|
|
52
58
|
call: (functionName: string, args?: Expression[]) => CallExpression;
|
|
53
|
-
binary: (left: Expression, op: BinaryOperator, right: Expression) => BinaryExpression;
|
|
59
|
+
binary: (left: Expression, op: BinaryOperator, right: Expression, binding?: string) => BinaryExpression;
|
|
54
60
|
unary: (op: UnaryOperator, operand: Expression) => UnaryExpression;
|
|
55
61
|
field: (field: string) => FieldExpression;
|
|
56
62
|
member: (receiver: Expression, members: string[]) => MemberExpression;
|
|
63
|
+
binding: (name: string) => BindingExpression;
|
|
57
64
|
_this: () => ThisExpression;
|
|
58
65
|
_null: () => NullExpression;
|
|
59
66
|
and: (expr: Expression, ...expressions: Expression[]) => Expression;
|
|
@@ -69,10 +76,11 @@ declare const ExpressionUtils: {
|
|
|
69
76
|
isBinary: (value: unknown) => value is BinaryExpression;
|
|
70
77
|
isField: (value: unknown) => value is FieldExpression;
|
|
71
78
|
isMember: (value: unknown) => value is MemberExpression;
|
|
79
|
+
isBinding: (value: unknown) => value is BindingExpression;
|
|
72
80
|
getLiteralValue: (expr: Expression) => string | number | boolean | undefined;
|
|
73
81
|
};
|
|
74
82
|
|
|
75
|
-
type DataSourceProviderType = 'sqlite' | 'postgresql';
|
|
83
|
+
type DataSourceProviderType = 'sqlite' | 'postgresql' | 'mysql';
|
|
76
84
|
type DataSourceProvider = {
|
|
77
85
|
type: DataSourceProviderType;
|
|
78
86
|
defaultSchema?: string;
|
|
@@ -152,6 +160,7 @@ type EnumField = {
|
|
|
152
160
|
attributes?: readonly AttributeApplication[];
|
|
153
161
|
};
|
|
154
162
|
type EnumDef = {
|
|
163
|
+
name: string;
|
|
155
164
|
fields?: Record<string, EnumField>;
|
|
156
165
|
values: Record<string, string>;
|
|
157
166
|
attributes?: readonly AttributeApplication[];
|
|
@@ -208,4 +217,4 @@ type IsDelegateModel<Schema extends SchemaDef, Model extends GetModels<Schema>>
|
|
|
208
217
|
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;
|
|
209
218
|
type FieldIsDelegateDiscriminator<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['isDiscriminator'] extends true ? true : false;
|
|
210
219
|
|
|
211
|
-
export { type ArrayExpression, type AttributeApplication, type AttributeArg, type BinaryExpression, type BinaryOperator, type BuiltinType, type CallExpression, type CascadeAction, type DataSourceProvider, type DataSourceProviderType, type EnumDef, type EnumField, type Expression, ExpressionUtils, type FieldDef, type FieldExpression, type FieldHasDefault, type FieldIsArray, type FieldIsComputed, type FieldIsDelegateDiscriminator, type FieldIsDelegateRelation, type FieldIsRelation, type FieldIsRelationArray, type FieldType, type ForeignKeyFields, type GetDelegateModels, type GetEnum, type GetEnums, type GetModel, type GetModelDiscriminator, type GetModelField, type GetModelFieldType, type GetModelFields, type GetModels, type GetSubModels, type GetTypeDef, type GetTypeDefField, type GetTypeDefFieldType, type GetTypeDefFields, type GetTypeDefs, type IsDelegateModel, type LiteralExpression, type MappedBuiltinType, type MemberExpression, type ModelDef, type ModelFieldIsOptional, type NonRelationFields, type NullExpression, type ProcedureDef, type ProcedureParam, type RelationFieldType, type RelationFields, type RelationInfo, type ScalarFields, type SchemaDef, type ThisExpression, type TypeDefDef, type TypeDefFieldIsArray, type TypeDefFieldIsOptional, type UnaryExpression, type UnaryOperator };
|
|
220
|
+
export { type ArrayExpression, type AttributeApplication, type AttributeArg, type BinaryExpression, type BinaryOperator, type BindingExpression, type BuiltinType, type CallExpression, type CascadeAction, type DataSourceProvider, type DataSourceProviderType, type EnumDef, type EnumField, type Expression, ExpressionUtils, type FieldDef, type FieldExpression, type FieldHasDefault, type FieldIsArray, type FieldIsComputed, type FieldIsDelegateDiscriminator, type FieldIsDelegateRelation, type FieldIsRelation, type FieldIsRelationArray, type FieldType, type ForeignKeyFields, type GetDelegateModels, type GetEnum, type GetEnums, type GetModel, type GetModelDiscriminator, type GetModelField, type GetModelFieldType, type GetModelFields, type GetModels, type GetSubModels, type GetTypeDef, type GetTypeDefField, type GetTypeDefFieldType, type GetTypeDefFields, type GetTypeDefs, type IsDelegateModel, type LiteralExpression, type MappedBuiltinType, type MemberExpression, type ModelDef, type ModelFieldIsOptional, type NonRelationFields, type NullExpression, type ProcedureDef, type ProcedureParam, type RelationFieldType, type RelationFields, type RelationInfo, type ScalarFields, type SchemaDef, type ThisExpression, type TypeDefDef, type TypeDefFieldIsArray, type TypeDefFieldIsOptional, type UnaryExpression, type UnaryOperator };
|
package/dist/index.js
CHANGED
|
@@ -9,9 +9,10 @@ var ExpressionUtils = {
|
|
|
9
9
|
value
|
|
10
10
|
};
|
|
11
11
|
}, "literal"),
|
|
12
|
-
array: /* @__PURE__ */ __name((items) => {
|
|
12
|
+
array: /* @__PURE__ */ __name((type, items) => {
|
|
13
13
|
return {
|
|
14
14
|
kind: "array",
|
|
15
|
+
type,
|
|
15
16
|
items
|
|
16
17
|
};
|
|
17
18
|
}, "array"),
|
|
@@ -22,12 +23,13 @@ var ExpressionUtils = {
|
|
|
22
23
|
args
|
|
23
24
|
};
|
|
24
25
|
}, "call"),
|
|
25
|
-
binary: /* @__PURE__ */ __name((left, op, right) => {
|
|
26
|
+
binary: /* @__PURE__ */ __name((left, op, right, binding) => {
|
|
26
27
|
return {
|
|
27
28
|
kind: "binary",
|
|
28
29
|
op,
|
|
29
30
|
left,
|
|
30
|
-
right
|
|
31
|
+
right,
|
|
32
|
+
binding
|
|
31
33
|
};
|
|
32
34
|
}, "binary"),
|
|
33
35
|
unary: /* @__PURE__ */ __name((op, operand) => {
|
|
@@ -50,6 +52,12 @@ var ExpressionUtils = {
|
|
|
50
52
|
members
|
|
51
53
|
};
|
|
52
54
|
}, "member"),
|
|
55
|
+
binding: /* @__PURE__ */ __name((name) => {
|
|
56
|
+
return {
|
|
57
|
+
kind: "binding",
|
|
58
|
+
name
|
|
59
|
+
};
|
|
60
|
+
}, "binding"),
|
|
53
61
|
_this: /* @__PURE__ */ __name(() => {
|
|
54
62
|
return {
|
|
55
63
|
kind: "this"
|
|
@@ -81,6 +89,7 @@ var ExpressionUtils = {
|
|
|
81
89
|
isBinary: /* @__PURE__ */ __name((value) => ExpressionUtils.is(value, "binary"), "isBinary"),
|
|
82
90
|
isField: /* @__PURE__ */ __name((value) => ExpressionUtils.is(value, "field"), "isField"),
|
|
83
91
|
isMember: /* @__PURE__ */ __name((value) => ExpressionUtils.is(value, "member"), "isMember"),
|
|
92
|
+
isBinding: /* @__PURE__ */ __name((value) => ExpressionUtils.is(value, "binding"), "isBinding"),
|
|
84
93
|
getLiteralValue: /* @__PURE__ */ __name((expr) => {
|
|
85
94
|
return ExpressionUtils.isLiteral(expr) ? expr.value : void 0;
|
|
86
95
|
}, "getLiteralValue")
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/expression-utils.ts"],"sourcesContent":["import type {\n ArrayExpression,\n BinaryExpression,\n BinaryOperator,\n CallExpression,\n Expression,\n FieldExpression,\n LiteralExpression,\n MemberExpression,\n NullExpression,\n ThisExpression,\n UnaryExpression,\n UnaryOperator,\n} from './expression';\n\n/**\n * Utility functions to create and work with Expression objects\n */\nexport const ExpressionUtils = {\n literal: (value: string | number | boolean): LiteralExpression => {\n return {
|
|
1
|
+
{"version":3,"sources":["../src/expression-utils.ts"],"sourcesContent":["import type {\n ArrayExpression,\n BinaryExpression,\n BinaryOperator,\n BindingExpression,\n CallExpression,\n Expression,\n FieldExpression,\n LiteralExpression,\n MemberExpression,\n NullExpression,\n ThisExpression,\n UnaryExpression,\n UnaryOperator,\n} from './expression';\n\n/**\n * Utility functions to create and work with Expression objects\n */\nexport const ExpressionUtils = {\n literal: (value: string | number | boolean): LiteralExpression => {\n return { kind: 'literal', value };\n },\n\n array: (type: string, items: Expression[]): ArrayExpression => {\n return { kind: 'array', type, items };\n },\n\n call: (functionName: string, args?: Expression[]): CallExpression => {\n return { kind: 'call', function: functionName, args };\n },\n\n binary: (left: Expression, op: BinaryOperator, right: Expression, binding?: string): BinaryExpression => {\n return { kind: 'binary', op, left, right, binding };\n },\n\n unary: (op: UnaryOperator, operand: Expression): UnaryExpression => {\n return { kind: 'unary', op, operand };\n },\n\n field: (field: string): FieldExpression => {\n return { kind: 'field', field };\n },\n\n member: (receiver: Expression, members: string[]): MemberExpression => {\n return { kind: 'member', receiver: receiver, members };\n },\n\n binding: (name: string): BindingExpression => {\n return { kind: 'binding', name };\n },\n\n _this: (): ThisExpression => {\n return { kind: 'this' };\n },\n\n _null: (): NullExpression => {\n return { kind: 'null' };\n },\n\n and: (expr: Expression, ...expressions: Expression[]) => {\n return expressions.reduce((acc, exp) => ExpressionUtils.binary(acc, '&&', exp), expr);\n },\n\n or: (expr: Expression, ...expressions: Expression[]) => {\n return expressions.reduce((acc, exp) => ExpressionUtils.binary(acc, '||', exp), expr);\n },\n\n not: (expr: Expression) => {\n return ExpressionUtils.unary('!', expr);\n },\n\n is: (value: unknown, kind: Expression['kind']): value is Expression => {\n return !!value && typeof value === 'object' && 'kind' in value && value.kind === kind;\n },\n\n isLiteral: (value: unknown): value is LiteralExpression => ExpressionUtils.is(value, 'literal'),\n\n isArray: (value: unknown): value is ArrayExpression => ExpressionUtils.is(value, 'array'),\n\n isCall: (value: unknown): value is CallExpression => ExpressionUtils.is(value, 'call'),\n\n isNull: (value: unknown): value is NullExpression => ExpressionUtils.is(value, 'null'),\n\n isThis: (value: unknown): value is ThisExpression => ExpressionUtils.is(value, 'this'),\n\n isUnary: (value: unknown): value is UnaryExpression => ExpressionUtils.is(value, 'unary'),\n\n isBinary: (value: unknown): value is BinaryExpression => ExpressionUtils.is(value, 'binary'),\n\n isField: (value: unknown): value is FieldExpression => ExpressionUtils.is(value, 'field'),\n\n isMember: (value: unknown): value is MemberExpression => ExpressionUtils.is(value, 'member'),\n\n isBinding: (value: unknown): value is BindingExpression => ExpressionUtils.is(value, 'binding'),\n\n getLiteralValue: (expr: Expression): string | number | boolean | undefined => {\n return ExpressionUtils.isLiteral(expr) ? expr.value : undefined;\n },\n};\n"],"mappings":";;;;AAmBO,IAAMA,kBAAkB;EAC3BC,SAAS,wBAACC,UAAAA;AACN,WAAO;MAAEC,MAAM;MAAWD;IAAM;EACpC,GAFS;EAITE,OAAO,wBAACC,MAAcC,UAAAA;AAClB,WAAO;MAAEH,MAAM;MAASE;MAAMC;IAAM;EACxC,GAFO;EAIPC,MAAM,wBAACC,cAAsBC,SAAAA;AACzB,WAAO;MAAEN,MAAM;MAAQO,UAAUF;MAAcC;IAAK;EACxD,GAFM;EAINE,QAAQ,wBAACC,MAAkBC,IAAoBC,OAAmBC,YAAAA;AAC9D,WAAO;MAAEZ,MAAM;MAAUU;MAAID;MAAME;MAAOC;IAAQ;EACtD,GAFQ;EAIRC,OAAO,wBAACH,IAAmBI,YAAAA;AACvB,WAAO;MAAEd,MAAM;MAASU;MAAII;IAAQ;EACxC,GAFO;EAIPC,OAAO,wBAACA,UAAAA;AACJ,WAAO;MAAEf,MAAM;MAASe;IAAM;EAClC,GAFO;EAIPC,QAAQ,wBAACC,UAAsBC,YAAAA;AAC3B,WAAO;MAAElB,MAAM;MAAUiB;MAAoBC;IAAQ;EACzD,GAFQ;EAIRN,SAAS,wBAACO,SAAAA;AACN,WAAO;MAAEnB,MAAM;MAAWmB;IAAK;EACnC,GAFS;EAITC,OAAO,6BAAA;AACH,WAAO;MAAEpB,MAAM;IAAO;EAC1B,GAFO;EAIPqB,OAAO,6BAAA;AACH,WAAO;MAAErB,MAAM;IAAO;EAC1B,GAFO;EAIPsB,KAAK,wBAACC,SAAqBC,gBAAAA;AACvB,WAAOA,YAAYC,OAAO,CAACC,KAAKC,QAAQ9B,gBAAgBW,OAAOkB,KAAK,MAAMC,GAAAA,GAAMJ,IAAAA;EACpF,GAFK;EAILK,IAAI,wBAACL,SAAqBC,gBAAAA;AACtB,WAAOA,YAAYC,OAAO,CAACC,KAAKC,QAAQ9B,gBAAgBW,OAAOkB,KAAK,MAAMC,GAAAA,GAAMJ,IAAAA;EACpF,GAFI;EAIJM,KAAK,wBAACN,SAAAA;AACF,WAAO1B,gBAAgBgB,MAAM,KAAKU,IAAAA;EACtC,GAFK;EAILO,IAAI,wBAAC/B,OAAgBC,SAAAA;AACjB,WAAO,CAAC,CAACD,SAAS,OAAOA,UAAU,YAAY,UAAUA,SAASA,MAAMC,SAASA;EACrF,GAFI;EAIJ+B,WAAW,wBAAChC,UAA+CF,gBAAgBiC,GAAG/B,OAAO,SAAA,GAA1E;EAEXiC,SAAS,wBAACjC,UAA6CF,gBAAgBiC,GAAG/B,OAAO,OAAA,GAAxE;EAETkC,QAAQ,wBAAClC,UAA4CF,gBAAgBiC,GAAG/B,OAAO,MAAA,GAAvE;EAERmC,QAAQ,wBAACnC,UAA4CF,gBAAgBiC,GAAG/B,OAAO,MAAA,GAAvE;EAERoC,QAAQ,wBAACpC,UAA4CF,gBAAgBiC,GAAG/B,OAAO,MAAA,GAAvE;EAERqC,SAAS,wBAACrC,UAA6CF,gBAAgBiC,GAAG/B,OAAO,OAAA,GAAxE;EAETsC,UAAU,wBAACtC,UAA8CF,gBAAgBiC,GAAG/B,OAAO,QAAA,GAAzE;EAEVuC,SAAS,wBAACvC,UAA6CF,gBAAgBiC,GAAG/B,OAAO,OAAA,GAAxE;EAETwC,UAAU,wBAACxC,UAA8CF,gBAAgBiC,GAAG/B,OAAO,QAAA,GAAzE;EAEVyC,WAAW,wBAACzC,UAA+CF,gBAAgBiC,GAAG/B,OAAO,SAAA,GAA1E;EAEX0C,iBAAiB,wBAAClB,SAAAA;AACd,WAAO1B,gBAAgBkC,UAAUR,IAAAA,IAAQA,KAAKxB,QAAQ2C;EAC1D,GAFiB;AAGrB;","names":["ExpressionUtils","literal","value","kind","array","type","items","call","functionName","args","function","binary","left","op","right","binding","unary","operand","field","member","receiver","members","name","_this","_null","and","expr","expressions","reduce","acc","exp","or","not","is","isLiteral","isArray","isCall","isNull","isThis","isUnary","isBinary","isField","isMember","isBinding","getLiteralValue","undefined"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenstackhq/schema",
|
|
3
|
-
"version": "3.3.0-beta.
|
|
3
|
+
"version": "3.3.0-beta.4",
|
|
4
4
|
"description": "ZenStack Runtime Schema",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [],
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"decimal.js": "^10.4.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@zenstackhq/eslint-config": "3.3.0-beta.
|
|
29
|
-
"@zenstackhq/typescript-config": "3.3.0-beta.
|
|
28
|
+
"@zenstackhq/eslint-config": "3.3.0-beta.4",
|
|
29
|
+
"@zenstackhq/typescript-config": "3.3.0-beta.4"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsc --noEmit && tsup-node",
|