@zenstackhq/schema 3.3.0-beta.3 → 3.3.0-beta.5
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 +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
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 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 {
|
|
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":";;;;;;;;;;;;;;;;;;;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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
|
@@ -7,6 +7,7 @@ type LiteralExpression = {
|
|
|
7
7
|
};
|
|
8
8
|
type ArrayExpression = {
|
|
9
9
|
kind: 'array';
|
|
10
|
+
type: string;
|
|
10
11
|
items: Expression[];
|
|
11
12
|
};
|
|
12
13
|
type FieldExpression = {
|
|
@@ -53,7 +54,7 @@ type BinaryOperator = '&&' | '||' | '==' | '!=' | '<' | '<=' | '>' | '>=' | '?'
|
|
|
53
54
|
*/
|
|
54
55
|
declare const ExpressionUtils: {
|
|
55
56
|
literal: (value: string | number | boolean) => LiteralExpression;
|
|
56
|
-
array: (items: Expression[]) => ArrayExpression;
|
|
57
|
+
array: (type: string, items: Expression[]) => ArrayExpression;
|
|
57
58
|
call: (functionName: string, args?: Expression[]) => CallExpression;
|
|
58
59
|
binary: (left: Expression, op: BinaryOperator, right: Expression, binding?: string) => BinaryExpression;
|
|
59
60
|
unary: (op: UnaryOperator, operand: Expression) => UnaryExpression;
|
|
@@ -123,6 +124,9 @@ type RelationInfo = {
|
|
|
123
124
|
onDelete?: CascadeAction;
|
|
124
125
|
onUpdate?: CascadeAction;
|
|
125
126
|
};
|
|
127
|
+
type UpdatedAtInfo = {
|
|
128
|
+
ignore?: readonly string[];
|
|
129
|
+
};
|
|
126
130
|
type FieldDef = {
|
|
127
131
|
name: string;
|
|
128
132
|
type: string;
|
|
@@ -130,7 +134,7 @@ type FieldDef = {
|
|
|
130
134
|
array?: boolean;
|
|
131
135
|
optional?: boolean;
|
|
132
136
|
unique?: boolean;
|
|
133
|
-
updatedAt?: boolean;
|
|
137
|
+
updatedAt?: boolean | UpdatedAtInfo;
|
|
134
138
|
attributes?: readonly AttributeApplication[];
|
|
135
139
|
default?: MappedBuiltinType | Expression | readonly unknown[];
|
|
136
140
|
omit?: boolean;
|
|
@@ -208,7 +212,7 @@ type TypeDefFieldIsArray<Schema extends SchemaDef, TypeDef extends GetTypeDefs<S
|
|
|
208
212
|
type FieldIsRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['relation'] extends object ? true : false;
|
|
209
213
|
type FieldIsArray<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['array'] extends true ? true : false;
|
|
210
214
|
type FieldIsComputed<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['computed'] extends true ? true : false;
|
|
211
|
-
type FieldHasDefault<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['default'] extends object | number | string | boolean ? true : GetModelField<Schema, Model, Field>['updatedAt'] extends true ? true : GetModelField<Schema, Model, Field>['relation'] extends {
|
|
215
|
+
type FieldHasDefault<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['default'] extends object | number | string | boolean ? true : GetModelField<Schema, Model, Field>['updatedAt'] extends (true | UpdatedAtInfo) ? true : GetModelField<Schema, Model, Field>['relation'] extends {
|
|
212
216
|
hasDefault: true;
|
|
213
217
|
} ? true : false;
|
|
214
218
|
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;
|
|
@@ -216,4 +220,4 @@ type IsDelegateModel<Schema extends SchemaDef, Model extends GetModels<Schema>>
|
|
|
216
220
|
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;
|
|
217
221
|
type FieldIsDelegateDiscriminator<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['isDiscriminator'] extends true ? true : false;
|
|
218
222
|
|
|
219
|
-
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 };
|
|
223
|
+
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, type UpdatedAtInfo };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ type LiteralExpression = {
|
|
|
7
7
|
};
|
|
8
8
|
type ArrayExpression = {
|
|
9
9
|
kind: 'array';
|
|
10
|
+
type: string;
|
|
10
11
|
items: Expression[];
|
|
11
12
|
};
|
|
12
13
|
type FieldExpression = {
|
|
@@ -53,7 +54,7 @@ type BinaryOperator = '&&' | '||' | '==' | '!=' | '<' | '<=' | '>' | '>=' | '?'
|
|
|
53
54
|
*/
|
|
54
55
|
declare const ExpressionUtils: {
|
|
55
56
|
literal: (value: string | number | boolean) => LiteralExpression;
|
|
56
|
-
array: (items: Expression[]) => ArrayExpression;
|
|
57
|
+
array: (type: string, items: Expression[]) => ArrayExpression;
|
|
57
58
|
call: (functionName: string, args?: Expression[]) => CallExpression;
|
|
58
59
|
binary: (left: Expression, op: BinaryOperator, right: Expression, binding?: string) => BinaryExpression;
|
|
59
60
|
unary: (op: UnaryOperator, operand: Expression) => UnaryExpression;
|
|
@@ -123,6 +124,9 @@ type RelationInfo = {
|
|
|
123
124
|
onDelete?: CascadeAction;
|
|
124
125
|
onUpdate?: CascadeAction;
|
|
125
126
|
};
|
|
127
|
+
type UpdatedAtInfo = {
|
|
128
|
+
ignore?: readonly string[];
|
|
129
|
+
};
|
|
126
130
|
type FieldDef = {
|
|
127
131
|
name: string;
|
|
128
132
|
type: string;
|
|
@@ -130,7 +134,7 @@ type FieldDef = {
|
|
|
130
134
|
array?: boolean;
|
|
131
135
|
optional?: boolean;
|
|
132
136
|
unique?: boolean;
|
|
133
|
-
updatedAt?: boolean;
|
|
137
|
+
updatedAt?: boolean | UpdatedAtInfo;
|
|
134
138
|
attributes?: readonly AttributeApplication[];
|
|
135
139
|
default?: MappedBuiltinType | Expression | readonly unknown[];
|
|
136
140
|
omit?: boolean;
|
|
@@ -208,7 +212,7 @@ type TypeDefFieldIsArray<Schema extends SchemaDef, TypeDef extends GetTypeDefs<S
|
|
|
208
212
|
type FieldIsRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['relation'] extends object ? true : false;
|
|
209
213
|
type FieldIsArray<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['array'] extends true ? true : false;
|
|
210
214
|
type FieldIsComputed<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['computed'] extends true ? true : false;
|
|
211
|
-
type FieldHasDefault<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['default'] extends object | number | string | boolean ? true : GetModelField<Schema, Model, Field>['updatedAt'] extends true ? true : GetModelField<Schema, Model, Field>['relation'] extends {
|
|
215
|
+
type FieldHasDefault<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['default'] extends object | number | string | boolean ? true : GetModelField<Schema, Model, Field>['updatedAt'] extends (true | UpdatedAtInfo) ? true : GetModelField<Schema, Model, Field>['relation'] extends {
|
|
212
216
|
hasDefault: true;
|
|
213
217
|
} ? true : false;
|
|
214
218
|
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;
|
|
@@ -216,4 +220,4 @@ type IsDelegateModel<Schema extends SchemaDef, Model extends GetModels<Schema>>
|
|
|
216
220
|
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;
|
|
217
221
|
type FieldIsDelegateDiscriminator<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['isDiscriminator'] extends true ? true : false;
|
|
218
222
|
|
|
219
|
-
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 };
|
|
223
|
+
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, type UpdatedAtInfo };
|
package/dist/index.js
CHANGED
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 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 {
|
|
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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AAAA;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.5",
|
|
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.5",
|
|
29
|
+
"@zenstackhq/typescript-config": "3.3.0-beta.5"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsc --noEmit && tsup-node",
|