Skip to content

Commit a05d320

Browse files
authored
feat: add support for type modifier attributes (#240)
1 parent 88828e3 commit a05d320

File tree

16 files changed

+259
-25
lines changed

16 files changed

+259
-25
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zenstack-monorepo",
3-
"version": "1.0.0-alpha.55",
3+
"version": "1.0.0-alpha.56",
44
"description": "",
55
"scripts": {
66
"build": "pnpm -r build",

packages/language/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/language",
3-
"version": "1.0.0-alpha.55",
3+
"version": "1.0.0-alpha.56",
44
"displayName": "ZenStack modeling language compiler",
55
"description": "ZenStack modeling language compiler",
66
"homepage": "https://zenstack.dev",

packages/language/src/generated/grammar.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,11 +2035,23 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
20352035
"value": "."
20362036
},
20372037
{
2038-
"$type": "RuleCall",
2039-
"rule": {
2040-
"$ref": "#/rules@53"
2041-
},
2042-
"arguments": []
2038+
"$type": "Alternatives",
2039+
"elements": [
2040+
{
2041+
"$type": "RuleCall",
2042+
"rule": {
2043+
"$ref": "#/rules@53"
2044+
},
2045+
"arguments": []
2046+
},
2047+
{
2048+
"$type": "RuleCall",
2049+
"rule": {
2050+
"$ref": "#/rules@48"
2051+
},
2052+
"arguments": []
2053+
}
2054+
]
20432055
}
20442056
],
20452057
"cardinality": "*"

packages/language/src/zmodel.langium

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ FunctionParamType:
171171
(type=ExpressionType | reference=[TypeDeclaration]) (array?='[' ']')?;
172172

173173
QualifiedName returns string:
174-
ID ('.' ID)*;
174+
// TODO: is this the right way to deal with token precedence?
175+
ID ('.' (ID|BuiltinType))*;
175176

176177
// attribute-level attribute
177178
AttributeAttributeName returns string:
@@ -221,7 +222,7 @@ ExpressionType returns string:
221222
'String' | 'Int' | 'Float' | 'Boolean' | 'DateTime' | 'Null' | 'Any';
222223

223224
BuiltinType returns string:
224-
'String'|'Boolean'|'Int'|'BigInt'|'Float'|'Decimal'|'DateTime'|'Json'|'Bytes';
225+
'String' | 'Boolean' | 'Int' | 'BigInt' | 'Float' | 'Decimal' | 'DateTime' | 'Json' | 'Bytes';
225226

226227
hidden terminal WS: /\s+/;
227228
terminal BOOLEAN returns boolean: /true|false/;

packages/next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/next",
3-
"version": "1.0.0-alpha.55",
3+
"version": "1.0.0-alpha.56",
44
"displayName": "ZenStack Next.js integration",
55
"description": "ZenStack Next.js integration",
66
"homepage": "https://zenstack.dev",

packages/plugins/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/react",
33
"displayName": "ZenStack plugin and runtime for ReactJS",
4-
"version": "1.0.0-alpha.55",
4+
"version": "1.0.0-alpha.56",
55
"description": "ZenStack plugin and runtime for ReactJS",
66
"main": "index.js",
77
"repository": {

packages/plugins/trpc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/trpc",
33
"displayName": "ZenStack plugin for tRPC",
4-
"version": "1.0.0-alpha.55",
4+
"version": "1.0.0-alpha.56",
55
"description": "ZenStack plugin for tRPC",
66
"main": "index.js",
77
"repository": {

packages/runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/runtime",
33
"displayName": "ZenStack Runtime Library",
4-
"version": "1.0.0-alpha.55",
4+
"version": "1.0.0-alpha.56",
55
"description": "Runtime of ZenStack for both client-side and server-side environments.",
66
"repository": {
77
"type": "git",

packages/schema/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publisher": "zenstack",
44
"displayName": "ZenStack Language Tools",
55
"description": "A toolkit for building secure CRUD apps with Next.js + Typescript",
6-
"version": "1.0.0-alpha.55",
6+
"version": "1.0.0-alpha.56",
77
"author": {
88
"name": "ZenStack Team"
99
},

packages/schema/src/language-server/validator/datamodel-validator.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export default class DataModelValidator implements AstValidator<DataModel> {
2323
}
2424

2525
private validateFields(dm: DataModel, accept: ValidationAcceptor) {
26+
// TODO: check conflict of @id and @@id
27+
2628
const idFields = dm.fields.filter((f) => f.attributes.find((attr) => attr.decl.ref?.name === '@id'));
2729
if (idFields.length === 0) {
2830
const { allows, denies, hasFieldValidation } = analyzePolicies(dm);

0 commit comments

Comments
 (0)