@zenstackhq/schema 3.0.0-beta.26 → 3.0.0-beta.28

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 CHANGED
@@ -90,17 +90,17 @@ type ModelDef = {
90
90
  name: string;
91
91
  baseModel?: string;
92
92
  fields: Record<string, FieldDef>;
93
- attributes?: AttributeApplication[];
93
+ attributes?: readonly AttributeApplication[];
94
94
  uniqueFields: Record<string, Pick<FieldDef, 'type'> | Record<string, Pick<FieldDef, 'type'>>>;
95
- idFields: string[];
95
+ idFields: readonly string[];
96
96
  computedFields?: Record<string, Function>;
97
97
  isDelegate?: boolean;
98
- subModels?: string[];
98
+ subModels?: readonly string[];
99
99
  isView?: boolean;
100
100
  };
101
101
  type AttributeApplication = {
102
102
  name: string;
103
- args?: AttributeArg[];
103
+ args?: readonly AttributeArg[];
104
104
  };
105
105
  type AttributeArg = {
106
106
  name?: string;
@@ -109,8 +109,8 @@ type AttributeArg = {
109
109
  type CascadeAction = 'SetNull' | 'Cascade' | 'Restrict' | 'NoAction' | 'SetDefault';
110
110
  type RelationInfo = {
111
111
  name?: string;
112
- fields?: string[];
113
- references?: string[];
112
+ fields?: readonly string[];
113
+ references?: readonly string[];
114
114
  hasDefault?: boolean;
115
115
  opposite?: string;
116
116
  onDelete?: CascadeAction;
@@ -124,11 +124,11 @@ type FieldDef = {
124
124
  optional?: boolean;
125
125
  unique?: boolean;
126
126
  updatedAt?: boolean;
127
- attributes?: AttributeApplication[];
128
- default?: MappedBuiltinType | Expression | unknown[];
127
+ attributes?: readonly AttributeApplication[];
128
+ default?: MappedBuiltinType | Expression | readonly unknown[];
129
129
  omit?: boolean;
130
130
  relation?: RelationInfo;
131
- foreignKeyFor?: string[];
131
+ foreignKeyFor?: readonly string[];
132
132
  computed?: boolean;
133
133
  originModel?: string;
134
134
  isDiscriminator?: boolean;
@@ -147,23 +147,23 @@ type BuiltinType = 'String' | 'Boolean' | 'Int' | 'Float' | 'BigInt' | 'Decimal'
147
147
  type MappedBuiltinType = string | boolean | number | bigint | Decimal | Date;
148
148
  type EnumField = {
149
149
  name: string;
150
- attributes?: AttributeApplication[];
150
+ attributes?: readonly AttributeApplication[];
151
151
  };
152
152
  type EnumDef = {
153
153
  fields?: Record<string, EnumField>;
154
154
  values: Record<string, string>;
155
- attributes?: AttributeApplication[];
155
+ attributes?: readonly AttributeApplication[];
156
156
  };
157
157
  type TypeDefDef = {
158
158
  name: string;
159
159
  fields: Record<string, FieldDef>;
160
- attributes?: AttributeApplication[];
160
+ attributes?: readonly AttributeApplication[];
161
161
  };
162
162
  type GetModels<Schema extends SchemaDef> = Extract<keyof Schema['models'], string>;
163
163
  type GetDelegateModels<Schema extends SchemaDef> = keyof {
164
164
  [Key in GetModels<Schema> as Schema['models'][Key]['isDelegate'] extends true ? Key : never]: true;
165
165
  };
166
- type GetSubModels<Schema extends SchemaDef, Model extends GetModels<Schema>> = GetModel<Schema, Model>['subModels'] extends string[] ? Extract<GetModel<Schema, Model>['subModels'][number], GetModels<Schema>> : never;
166
+ 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;
167
167
  type GetModel<Schema extends SchemaDef, Model extends GetModels<Schema>> = Schema['models'][Model];
168
168
  type GetEnums<Schema extends SchemaDef> = keyof Schema['enums'];
169
169
  type GetEnum<Schema extends SchemaDef, Enum extends GetEnums<Schema>> = Schema['enums'][Enum] extends EnumDef ? Schema['enums'][Enum]['values'] : never;
@@ -177,11 +177,12 @@ type GetModelDiscriminator<Schema extends SchemaDef, Model extends GetModels<Sch
177
177
  type GetModelFieldType<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = Schema['models'][Model]['fields'][Field]['type'];
178
178
  type GetTypeDefFields<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>> = Extract<keyof GetTypeDef<Schema, TypeDef>['fields'], string>;
179
179
  type GetTypeDefField<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>, Field extends GetTypeDefFields<Schema, TypeDef>> = GetTypeDef<Schema, TypeDef>['fields'][Field];
180
+ type GetTypeDefFieldType<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>, Field extends GetTypeDefFields<Schema, TypeDef>> = GetTypeDef<Schema, TypeDef>['fields'][Field]['type'];
180
181
  type ScalarFields<Schema extends SchemaDef, Model extends GetModels<Schema>, IncludeComputed extends boolean = true> = keyof {
181
- [Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends object ? never : GetModelField<Schema, Model, Key>['foreignKeyFor'] extends string[] ? never : IncludeComputed extends true ? Key : FieldIsComputed<Schema, Model, Key> extends true ? never : Key]: Key;
182
+ [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;
182
183
  };
183
184
  type ForeignKeyFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
184
- [Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['foreignKeyFor'] extends string[] ? Key : never]: Key;
185
+ [Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['foreignKeyFor'] extends readonly string[] ? Key : never]: Key;
185
186
  };
186
187
  type NonRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
187
188
  [Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends object ? never : Key]: Key;
@@ -205,4 +206,4 @@ type IsDelegateModel<Schema extends SchemaDef, Model extends GetModels<Schema>>
205
206
  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;
206
207
  type FieldIsDelegateDiscriminator<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['isDiscriminator'] extends true ? true : false;
207
208
 
208
- 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 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 };
209
+ 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 };
package/dist/index.d.ts CHANGED
@@ -90,17 +90,17 @@ type ModelDef = {
90
90
  name: string;
91
91
  baseModel?: string;
92
92
  fields: Record<string, FieldDef>;
93
- attributes?: AttributeApplication[];
93
+ attributes?: readonly AttributeApplication[];
94
94
  uniqueFields: Record<string, Pick<FieldDef, 'type'> | Record<string, Pick<FieldDef, 'type'>>>;
95
- idFields: string[];
95
+ idFields: readonly string[];
96
96
  computedFields?: Record<string, Function>;
97
97
  isDelegate?: boolean;
98
- subModels?: string[];
98
+ subModels?: readonly string[];
99
99
  isView?: boolean;
100
100
  };
101
101
  type AttributeApplication = {
102
102
  name: string;
103
- args?: AttributeArg[];
103
+ args?: readonly AttributeArg[];
104
104
  };
105
105
  type AttributeArg = {
106
106
  name?: string;
@@ -109,8 +109,8 @@ type AttributeArg = {
109
109
  type CascadeAction = 'SetNull' | 'Cascade' | 'Restrict' | 'NoAction' | 'SetDefault';
110
110
  type RelationInfo = {
111
111
  name?: string;
112
- fields?: string[];
113
- references?: string[];
112
+ fields?: readonly string[];
113
+ references?: readonly string[];
114
114
  hasDefault?: boolean;
115
115
  opposite?: string;
116
116
  onDelete?: CascadeAction;
@@ -124,11 +124,11 @@ type FieldDef = {
124
124
  optional?: boolean;
125
125
  unique?: boolean;
126
126
  updatedAt?: boolean;
127
- attributes?: AttributeApplication[];
128
- default?: MappedBuiltinType | Expression | unknown[];
127
+ attributes?: readonly AttributeApplication[];
128
+ default?: MappedBuiltinType | Expression | readonly unknown[];
129
129
  omit?: boolean;
130
130
  relation?: RelationInfo;
131
- foreignKeyFor?: string[];
131
+ foreignKeyFor?: readonly string[];
132
132
  computed?: boolean;
133
133
  originModel?: string;
134
134
  isDiscriminator?: boolean;
@@ -147,23 +147,23 @@ type BuiltinType = 'String' | 'Boolean' | 'Int' | 'Float' | 'BigInt' | 'Decimal'
147
147
  type MappedBuiltinType = string | boolean | number | bigint | Decimal | Date;
148
148
  type EnumField = {
149
149
  name: string;
150
- attributes?: AttributeApplication[];
150
+ attributes?: readonly AttributeApplication[];
151
151
  };
152
152
  type EnumDef = {
153
153
  fields?: Record<string, EnumField>;
154
154
  values: Record<string, string>;
155
- attributes?: AttributeApplication[];
155
+ attributes?: readonly AttributeApplication[];
156
156
  };
157
157
  type TypeDefDef = {
158
158
  name: string;
159
159
  fields: Record<string, FieldDef>;
160
- attributes?: AttributeApplication[];
160
+ attributes?: readonly AttributeApplication[];
161
161
  };
162
162
  type GetModels<Schema extends SchemaDef> = Extract<keyof Schema['models'], string>;
163
163
  type GetDelegateModels<Schema extends SchemaDef> = keyof {
164
164
  [Key in GetModels<Schema> as Schema['models'][Key]['isDelegate'] extends true ? Key : never]: true;
165
165
  };
166
- type GetSubModels<Schema extends SchemaDef, Model extends GetModels<Schema>> = GetModel<Schema, Model>['subModels'] extends string[] ? Extract<GetModel<Schema, Model>['subModels'][number], GetModels<Schema>> : never;
166
+ 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;
167
167
  type GetModel<Schema extends SchemaDef, Model extends GetModels<Schema>> = Schema['models'][Model];
168
168
  type GetEnums<Schema extends SchemaDef> = keyof Schema['enums'];
169
169
  type GetEnum<Schema extends SchemaDef, Enum extends GetEnums<Schema>> = Schema['enums'][Enum] extends EnumDef ? Schema['enums'][Enum]['values'] : never;
@@ -177,11 +177,12 @@ type GetModelDiscriminator<Schema extends SchemaDef, Model extends GetModels<Sch
177
177
  type GetModelFieldType<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = Schema['models'][Model]['fields'][Field]['type'];
178
178
  type GetTypeDefFields<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>> = Extract<keyof GetTypeDef<Schema, TypeDef>['fields'], string>;
179
179
  type GetTypeDefField<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>, Field extends GetTypeDefFields<Schema, TypeDef>> = GetTypeDef<Schema, TypeDef>['fields'][Field];
180
+ type GetTypeDefFieldType<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>, Field extends GetTypeDefFields<Schema, TypeDef>> = GetTypeDef<Schema, TypeDef>['fields'][Field]['type'];
180
181
  type ScalarFields<Schema extends SchemaDef, Model extends GetModels<Schema>, IncludeComputed extends boolean = true> = keyof {
181
- [Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends object ? never : GetModelField<Schema, Model, Key>['foreignKeyFor'] extends string[] ? never : IncludeComputed extends true ? Key : FieldIsComputed<Schema, Model, Key> extends true ? never : Key]: Key;
182
+ [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;
182
183
  };
183
184
  type ForeignKeyFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
184
- [Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['foreignKeyFor'] extends string[] ? Key : never]: Key;
185
+ [Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['foreignKeyFor'] extends readonly string[] ? Key : never]: Key;
185
186
  };
186
187
  type NonRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
187
188
  [Key in GetModelFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends object ? never : Key]: Key;
@@ -205,4 +206,4 @@ type IsDelegateModel<Schema extends SchemaDef, Model extends GetModels<Schema>>
205
206
  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;
206
207
  type FieldIsDelegateDiscriminator<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['isDiscriminator'] extends true ? true : false;
207
208
 
208
- 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 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 };
209
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenstackhq/schema",
3
- "version": "3.0.0-beta.26",
3
+ "version": "3.0.0-beta.28",
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.0.0-beta.26",
29
- "@zenstackhq/typescript-config": "3.0.0-beta.26"
28
+ "@zenstackhq/eslint-config": "3.0.0-beta.28",
29
+ "@zenstackhq/typescript-config": "3.0.0-beta.28"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "tsc --noEmit && tsup-node",