diff --git a/package.json b/package.json index 80689267f..9b0b3d158 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@typescript-eslint/parser": "^7.6.0", "concurrently": "^7.4.0", "copyfiles": "^2.4.1", - "eslint": "^8.56.0", + "eslint": "^8.57.0", "eslint-plugin-jest": "^28.2.0", "jest": "^29.7.0", "replace-in-file": "^7.0.1", diff --git a/packages/language/src/generated/ast.ts b/packages/language/src/generated/ast.ts index a95a748d9..77e3dc4f1 100644 --- a/packages/language/src/generated/ast.ts +++ b/packages/language/src/generated/ast.ts @@ -78,10 +78,10 @@ export function isReferenceTarget(item: unknown): item is ReferenceTarget { return reflection.isInstance(item, ReferenceTarget); } -export type RegularID = 'abstract' | 'attribute' | 'datasource' | 'enum' | 'import' | 'in' | 'model' | 'plugin' | 'view' | string; +export type RegularID = 'Any' | 'BigInt' | 'Boolean' | 'Bytes' | 'DateTime' | 'Decimal' | 'Float' | 'Int' | 'Json' | 'Null' | 'Object' | 'String' | 'Unsupported' | 'abstract' | 'attribute' | 'datasource' | 'enum' | 'import' | 'in' | 'model' | 'plugin' | 'view' | string; export function isRegularID(item: unknown): item is RegularID { - return item === 'model' || item === 'enum' || item === 'attribute' || item === 'datasource' || item === 'plugin' || item === 'abstract' || item === 'in' || item === 'view' || item === 'import' || (typeof item === 'string' && (/[_a-zA-Z][\w_]*/.test(item))); + return item === 'model' || item === 'enum' || item === 'attribute' || item === 'datasource' || item === 'plugin' || item === 'abstract' || item === 'in' || item === 'view' || item === 'import' || item === 'String' || item === 'Boolean' || item === 'Int' || item === 'BigInt' || item === 'Float' || item === 'Decimal' || item === 'DateTime' || item === 'Json' || item === 'Bytes' || item === 'Null' || item === 'Object' || item === 'Any' || item === 'Unsupported' || (typeof item === 'string' && (/[_a-zA-Z][\w_]*/.test(item))); } export type TypeDeclaration = DataModel | Enum; diff --git a/packages/language/src/generated/grammar.ts b/packages/language/src/generated/grammar.ts index 45aa3ff97..acf9ba13e 100644 --- a/packages/language/src/generated/grammar.ts +++ b/packages/language/src/generated/grammar.ts @@ -2701,6 +2701,58 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel { "$type": "Keyword", "value": "import" + }, + { + "$type": "Keyword", + "value": "String" + }, + { + "$type": "Keyword", + "value": "Boolean" + }, + { + "$type": "Keyword", + "value": "Int" + }, + { + "$type": "Keyword", + "value": "BigInt" + }, + { + "$type": "Keyword", + "value": "Float" + }, + { + "$type": "Keyword", + "value": "Decimal" + }, + { + "$type": "Keyword", + "value": "DateTime" + }, + { + "$type": "Keyword", + "value": "Json" + }, + { + "$type": "Keyword", + "value": "Bytes" + }, + { + "$type": "Keyword", + "value": "Null" + }, + { + "$type": "Keyword", + "value": "Object" + }, + { + "$type": "Keyword", + "value": "Any" + }, + { + "$type": "Keyword", + "value": "Unsupported" } ] }, diff --git a/packages/language/src/zmodel.langium b/packages/language/src/zmodel.langium index 8fcc72c34..8606010bf 100644 --- a/packages/language/src/zmodel.langium +++ b/packages/language/src/zmodel.langium @@ -224,7 +224,7 @@ FunctionParamType: // https://github.com/langium/langium/discussions/1012 RegularID returns string: // include keywords that we'd like to work as ID in most places - ID | 'model' | 'enum' | 'attribute' | 'datasource' | 'plugin' | 'abstract' | 'in' | 'view' | 'import'; + ID | 'model' | 'enum' | 'attribute' | 'datasource' | 'plugin' | 'abstract' | 'in' | 'view' | 'import' | 'String' | 'Boolean' | 'Int' | 'BigInt' | 'Float' | 'Decimal' | 'DateTime' | 'Json' | 'Bytes' | 'Null' | 'Object' | 'Any' | 'Unsupported'; // attribute Attribute: diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c744e5770..645c1c6d6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,7 +30,7 @@ importers: specifier: ^2.4.1 version: 2.4.1 eslint: - specifier: ^8.56.0 + specifier: ^8.57.0 version: 8.57.0 eslint-plugin-jest: specifier: ^28.2.0 diff --git a/tests/integration/tests/e2e/type-coverage.test.ts b/tests/integration/tests/e2e/type-coverage.test.ts index c8c88211c..2a41b3ffd 100644 --- a/tests/integration/tests/e2e/type-coverage.test.ts +++ b/tests/integration/tests/e2e/type-coverage.test.ts @@ -13,14 +13,14 @@ describe('Type Coverage Tests', () => { model Foo { id String @id @default(cuid()) - string String - int Int - bigInt BigInt - date DateTime - float Float - decimal Decimal - boolean Boolean - bytes Bytes + String String + Int Int + BigInt BigInt + DateTime DateTime + Float Float + Decimal Decimal + Boolean Boolean + Bytes Bytes @@allow('all', true) } @@ -41,14 +41,14 @@ describe('Type Coverage Tests', () => { const date = new Date(); const data = { id: '1', - string: 'string', - int: 100, - bigInt: BigInt(9007199254740991), - date, - float: 1.23, - decimal: new Decimal(1.2345), - boolean: true, - bytes: Buffer.from('hello'), + String: 'string', + Int: 100, + BigInt: BigInt(9007199254740991), + DateTime: date, + Float: 1.23, + Decimal: new Decimal(1.2345), + Boolean: true, + Bytes: Buffer.from('hello'), }; await db.foo.create({