@zenstackhq/schema 3.5.0-beta.2 → 3.5.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.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -154,7 +154,9 @@ 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>> =
|
|
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
|
+
};
|
|
158
160
|
type GetModelField<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModel<Schema, Model>['fields'][Field];
|
|
159
161
|
type GetModelDiscriminator<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
160
162
|
[Key in GetModelFields<Schema, Model> as FieldIsDelegateDiscriminator<Schema, Model, Key> extends true ? GetModelField<Schema, Model, Key>['originModel'] extends string ? never : Key : never]: true;
|
|
@@ -183,6 +185,7 @@ type TypeDefFieldIsArray<Schema extends SchemaDef, TypeDef extends GetTypeDefs<S
|
|
|
183
185
|
type FieldIsRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['relation'] extends object ? true : false;
|
|
184
186
|
type FieldIsArray<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['array'] extends true ? true : false;
|
|
185
187
|
type FieldIsComputed<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['computed'] extends true ? true : false;
|
|
188
|
+
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;
|
|
186
189
|
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 {
|
|
187
190
|
hasDefault: true;
|
|
188
191
|
} ? true : false;
|
|
@@ -292,4 +295,4 @@ declare const ExpressionUtils: {
|
|
|
292
295
|
getLiteralValue: (expr: Expression) => string | number | boolean | undefined;
|
|
293
296
|
};
|
|
294
297
|
|
|
295
|
-
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 FieldDefault, 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, InvalidSchemaError, 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, SchemaAccessor, type SchemaDef, type ThisExpression, type TypeDefDef, type TypeDefFieldIsArray, type TypeDefFieldIsOptional, type UnaryExpression, type UnaryOperator, type UniqueFieldsInfo, type UpdatedAtInfo };
|
|
298
|
+
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 FieldDefault, type FieldExpression, type FieldHasDefault, type FieldIsArray, type FieldIsComputed, type FieldIsDelegateDiscriminator, type FieldIsDelegateRelation, type FieldIsRelation, type FieldIsRelationArray, type FieldIsUnsupported, 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, InvalidSchemaError, 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, SchemaAccessor, type SchemaDef, type ThisExpression, type TypeDefDef, type TypeDefFieldIsArray, type TypeDefFieldIsOptional, type UnaryExpression, type UnaryOperator, type UniqueFieldsInfo, type UpdatedAtInfo };
|
package/dist/index.d.ts
CHANGED
|
@@ -154,7 +154,9 @@ 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>> =
|
|
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
|
+
};
|
|
158
160
|
type GetModelField<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModel<Schema, Model>['fields'][Field];
|
|
159
161
|
type GetModelDiscriminator<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
160
162
|
[Key in GetModelFields<Schema, Model> as FieldIsDelegateDiscriminator<Schema, Model, Key> extends true ? GetModelField<Schema, Model, Key>['originModel'] extends string ? never : Key : never]: true;
|
|
@@ -183,6 +185,7 @@ type TypeDefFieldIsArray<Schema extends SchemaDef, TypeDef extends GetTypeDefs<S
|
|
|
183
185
|
type FieldIsRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['relation'] extends object ? true : false;
|
|
184
186
|
type FieldIsArray<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['array'] extends true ? true : false;
|
|
185
187
|
type FieldIsComputed<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['computed'] extends true ? true : false;
|
|
188
|
+
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;
|
|
186
189
|
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 {
|
|
187
190
|
hasDefault: true;
|
|
188
191
|
} ? true : false;
|
|
@@ -292,4 +295,4 @@ declare const ExpressionUtils: {
|
|
|
292
295
|
getLiteralValue: (expr: Expression) => string | number | boolean | undefined;
|
|
293
296
|
};
|
|
294
297
|
|
|
295
|
-
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 FieldDefault, 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, InvalidSchemaError, 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, SchemaAccessor, type SchemaDef, type ThisExpression, type TypeDefDef, type TypeDefFieldIsArray, type TypeDefFieldIsOptional, type UnaryExpression, type UnaryOperator, type UniqueFieldsInfo, type UpdatedAtInfo };
|
|
298
|
+
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 FieldDefault, type FieldExpression, type FieldHasDefault, type FieldIsArray, type FieldIsComputed, type FieldIsDelegateDiscriminator, type FieldIsDelegateRelation, type FieldIsRelation, type FieldIsRelationArray, type FieldIsUnsupported, 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, InvalidSchemaError, 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, SchemaAccessor, type SchemaDef, type ThisExpression, type TypeDefDef, type TypeDefFieldIsArray, type TypeDefFieldIsOptional, type UnaryExpression, type UnaryOperator, type UniqueFieldsInfo, type UpdatedAtInfo };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenstackhq/schema",
|
|
3
|
-
"version": "3.5.0-beta.
|
|
3
|
+
"version": "3.5.0-beta.4",
|
|
4
4
|
"description": "ZenStack Runtime Schema",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [],
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"decimal.js": "^10.4.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@zenstackhq/typescript-config": "3.5.0-beta.
|
|
33
|
-
"@zenstackhq/
|
|
34
|
-
"@zenstackhq/
|
|
32
|
+
"@zenstackhq/typescript-config": "3.5.0-beta.4",
|
|
33
|
+
"@zenstackhq/vitest-config": "3.5.0-beta.4",
|
|
34
|
+
"@zenstackhq/eslint-config": "3.5.0-beta.4"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc --noEmit && tsup-node",
|