Skip to content

Commit e415370

Browse files
authored
merge dev to main (#197)
1 parent 5cf490a commit e415370

File tree

17 files changed

+460
-50
lines changed

17 files changed

+460
-50
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.28",
3+
"version": "1.0.0-alpha.31",
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.28",
3+
"version": "1.0.0-alpha.31",
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: 118 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
104104
"definition": {
105105
"$type": "Group",
106106
"elements": [
107+
{
108+
"$type": "RuleCall",
109+
"rule": {
110+
"$ref": "#/rules@56"
111+
},
112+
"arguments": [],
113+
"cardinality": "*"
114+
},
107115
{
108116
"$type": "Keyword",
109117
"value": "datasource"
@@ -156,6 +164,14 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
156164
"definition": {
157165
"$type": "Group",
158166
"elements": [
167+
{
168+
"$type": "RuleCall",
169+
"rule": {
170+
"$ref": "#/rules@56"
171+
},
172+
"arguments": [],
173+
"cardinality": "*"
174+
},
159175
{
160176
"$type": "Assignment",
161177
"feature": "name",
@@ -211,6 +227,14 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
211227
"definition": {
212228
"$type": "Group",
213229
"elements": [
230+
{
231+
"$type": "RuleCall",
232+
"rule": {
233+
"$ref": "#/rules@56"
234+
},
235+
"arguments": [],
236+
"cardinality": "*"
237+
},
214238
{
215239
"$type": "Keyword",
216240
"value": "generator"
@@ -263,6 +287,14 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
263287
"definition": {
264288
"$type": "Group",
265289
"elements": [
290+
{
291+
"$type": "RuleCall",
292+
"rule": {
293+
"$ref": "#/rules@56"
294+
},
295+
"arguments": [],
296+
"cardinality": "*"
297+
},
266298
{
267299
"$type": "Assignment",
268300
"feature": "name",
@@ -318,6 +350,14 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
318350
"definition": {
319351
"$type": "Group",
320352
"elements": [
353+
{
354+
"$type": "RuleCall",
355+
"rule": {
356+
"$ref": "#/rules@56"
357+
},
358+
"arguments": [],
359+
"cardinality": "*"
360+
},
321361
{
322362
"$type": "Keyword",
323363
"value": "plugin"
@@ -370,6 +410,14 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
370410
"definition": {
371411
"$type": "Group",
372412
"elements": [
413+
{
414+
"$type": "RuleCall",
415+
"rule": {
416+
"$ref": "#/rules@56"
417+
},
418+
"arguments": [],
419+
"cardinality": "*"
420+
},
373421
{
374422
"$type": "Assignment",
375423
"feature": "name",
@@ -1589,6 +1637,14 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
15891637
"definition": {
15901638
"$type": "Group",
15911639
"elements": [
1640+
{
1641+
"$type": "RuleCall",
1642+
"rule": {
1643+
"$ref": "#/rules@56"
1644+
},
1645+
"arguments": [],
1646+
"cardinality": "*"
1647+
},
15921648
{
15931649
"$type": "Keyword",
15941650
"value": "enum"
@@ -1639,16 +1695,29 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
16391695
"$type": "ParserRule",
16401696
"name": "EnumField",
16411697
"definition": {
1642-
"$type": "Assignment",
1643-
"feature": "name",
1644-
"operator": "=",
1645-
"terminal": {
1646-
"$type": "RuleCall",
1647-
"rule": {
1648-
"$ref": "#/rules@53"
1698+
"$type": "Group",
1699+
"elements": [
1700+
{
1701+
"$type": "RuleCall",
1702+
"rule": {
1703+
"$ref": "#/rules@56"
1704+
},
1705+
"arguments": [],
1706+
"cardinality": "*"
16491707
},
1650-
"arguments": []
1651-
}
1708+
{
1709+
"$type": "Assignment",
1710+
"feature": "name",
1711+
"operator": "=",
1712+
"terminal": {
1713+
"$type": "RuleCall",
1714+
"rule": {
1715+
"$ref": "#/rules@53"
1716+
},
1717+
"arguments": []
1718+
}
1719+
}
1720+
]
16521721
},
16531722
"definesHiddenTokens": false,
16541723
"entry": false,
@@ -1663,6 +1732,14 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
16631732
"definition": {
16641733
"$type": "Group",
16651734
"elements": [
1735+
{
1736+
"$type": "RuleCall",
1737+
"rule": {
1738+
"$ref": "#/rules@56"
1739+
},
1740+
"arguments": [],
1741+
"cardinality": "*"
1742+
},
16661743
{
16671744
"$type": "Keyword",
16681745
"value": "function"
@@ -1779,6 +1856,14 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
17791856
"definition": {
17801857
"$type": "Group",
17811858
"elements": [
1859+
{
1860+
"$type": "RuleCall",
1861+
"rule": {
1862+
"$ref": "#/rules@56"
1863+
},
1864+
"arguments": [],
1865+
"cardinality": "*"
1866+
},
17821867
{
17831868
"$type": "Assignment",
17841869
"feature": "name",
@@ -2034,6 +2119,14 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
20342119
"definition": {
20352120
"$type": "Group",
20362121
"elements": [
2122+
{
2123+
"$type": "RuleCall",
2124+
"rule": {
2125+
"$ref": "#/rules@56"
2126+
},
2127+
"arguments": [],
2128+
"cardinality": "*"
2129+
},
20372130
{
20382131
"$type": "Keyword",
20392132
"value": "attribute"
@@ -2126,6 +2219,14 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
21262219
"definition": {
21272220
"$type": "Group",
21282221
"elements": [
2222+
{
2223+
"$type": "RuleCall",
2224+
"rule": {
2225+
"$ref": "#/rules@56"
2226+
},
2227+
"arguments": [],
2228+
"cardinality": "*"
2229+
},
21292230
{
21302231
"$type": "Assignment",
21312232
"feature": "default",
@@ -2323,6 +2424,14 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel
23232424
"definition": {
23242425
"$type": "Group",
23252426
"elements": [
2427+
{
2428+
"$type": "RuleCall",
2429+
"rule": {
2430+
"$ref": "#/rules@56"
2431+
},
2432+
"arguments": [],
2433+
"cardinality": "*"
2434+
},
23262435
{
23272436
"$type": "Assignment",
23282437
"feature": "decl",

packages/language/src/zmodel.langium

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ AbstractDeclaration:
1010

1111
// datasource
1212
DataSource:
13-
'datasource' name=ID '{' (fields+=DataSourceField)* '}';
13+
TRIPLE_SLASH_COMMENT* 'datasource' name=ID '{' (fields+=DataSourceField)* '}';
1414

1515
DataSourceField:
16-
name=ID '=' value=(LiteralExpr|InvocationExpr);
16+
TRIPLE_SLASH_COMMENT* name=ID '=' value=(LiteralExpr|InvocationExpr);
1717

1818
// generator
1919
GeneratorDecl:
20-
'generator' name=ID '{' (fields+=GeneratorField)* '}';
20+
TRIPLE_SLASH_COMMENT* 'generator' name=ID '{' (fields+=GeneratorField)* '}';
2121

2222
GeneratorField:
23-
name=ID '=' value=(LiteralExpr | ArrayExpr);
23+
TRIPLE_SLASH_COMMENT* name=ID '=' value=(LiteralExpr | ArrayExpr);
2424

2525
// plugin
2626
Plugin:
27-
'plugin' name=ID '{' (fields+=PluginField)* '}';
27+
TRIPLE_SLASH_COMMENT* 'plugin' name=ID '{' (fields+=PluginField)* '}';
2828

2929
PluginField:
30-
name=ID '=' value=(LiteralExpr | ArrayExpr);
30+
TRIPLE_SLASH_COMMENT* name=ID '=' value=(LiteralExpr | ArrayExpr);
3131

3232
// expression
3333
Expression:
@@ -149,17 +149,17 @@ DataModelFieldType:
149149

150150
// enum
151151
Enum:
152-
'enum' name=ID '{' (fields+=EnumField)+ '}';
152+
TRIPLE_SLASH_COMMENT* 'enum' name=ID '{' (fields+=EnumField)+ '}';
153153

154154
EnumField:
155-
name=ID;
155+
TRIPLE_SLASH_COMMENT* name=ID;
156156

157157
// function
158158
FunctionDecl:
159-
'function' name=ID '(' (params+=FunctionParam (',' params+=FunctionParam)*)? ')' ':' returnType=FunctionParamType '{' (expression=Expression)? '}';
159+
TRIPLE_SLASH_COMMENT* 'function' name=ID '(' (params+=FunctionParam (',' params+=FunctionParam)*)? ')' ':' returnType=FunctionParamType '{' (expression=Expression)? '}';
160160

161161
FunctionParam:
162-
name=ID ':' type=FunctionParamType;
162+
TRIPLE_SLASH_COMMENT* name=ID ':' type=FunctionParamType;
163163

164164
FunctionParamType:
165165
(type=ExpressionType | reference=[TypeDeclaration]) (array?='[]')?;
@@ -184,10 +184,10 @@ AttributeName returns string:
184184

185185
// attribute
186186
Attribute:
187-
'attribute' name=AttributeName '(' (params+=AttributeParam (',' params+=AttributeParam)*)? ')' (attributes+=AttributeAttribute)*;
187+
TRIPLE_SLASH_COMMENT* 'attribute' name=AttributeName '(' (params+=AttributeParam (',' params+=AttributeParam)*)? ')' (attributes+=AttributeAttribute)*;
188188

189189
AttributeParam:
190-
(default?='_')? name=ID ':' type=AttributeParamType;
190+
TRIPLE_SLASH_COMMENT* (default?='_')? name=ID ':' type=AttributeParamType;
191191

192192
// FieldReference refers to fields declared in the current model
193193
// TransitiveFieldReference refers to fields declared in the model type of the current field
@@ -200,7 +200,7 @@ DataModelFieldAttribute:
200200
decl=[Attribute:DataModelFieldAttributeName] ('(' AttributeArgList? ')')?;
201201

202202
DataModelAttribute:
203-
decl=[Attribute:DataModelAttributeName] ('(' AttributeArgList? ')')?;
203+
TRIPLE_SLASH_COMMENT* decl=[Attribute:DataModelAttributeName] ('(' AttributeArgList? ')')?;
204204

205205
AttributeAttribute:
206206
decl=[Attribute:AttributeAttributeName] ('(' AttributeArgList? ')')?;

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.28",
3+
"version": "1.0.0-alpha.31",
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.28",
4+
"version": "1.0.0-alpha.31",
55
"description": "ZenStack plugin and runtime for ReactJS",
66
"main": "index.js",
77
"repository": {

packages/plugins/react/src/react-hooks-generator.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@ import * as path from 'path';
66
import { Project } from 'ts-morph';
77

88
export async function generate(model: Model, options: PluginOptions, dmmf: DMMF.Document) {
9-
const project = new Project();
10-
const models: DataModel[] = [];
11-
const warnings: string[] = [];
12-
13-
for (const dm of model.declarations.filter((d): d is DataModel => isDataModel(d))) {
14-
const hasAllowRule = dm.attributes.find((attr) => attr.decl.ref?.name === '@@allow');
15-
if (hasAllowRule) {
16-
models.push(dm);
17-
}
18-
}
19-
209
let outDir = options.output as string;
2110
if (!outDir) {
2211
throw new PluginError('"output" option is required');
@@ -27,6 +16,10 @@ export async function generate(model: Model, options: PluginOptions, dmmf: DMMF.
2716
outDir = path.join(path.dirname(options.schemaPath), outDir);
2817
}
2918

19+
const project = new Project();
20+
const warnings: string[] = [];
21+
const models = model.declarations.filter((d): d is DataModel => isDataModel(d));
22+
3023
generateIndex(project, outDir, models);
3124

3225
models.forEach((model) => {
@@ -42,7 +35,7 @@ function wrapReadbackErrorCheck(code: string) {
4235
return `try {
4336
${code}
4437
} catch (err: any) {
45-
if (err.prisma && err.code === 'P2004') {
38+
if (err.info?.prisma && err.info?.code === 'P2004') {
4639
// unable to readback data
4740
return undefined;
4841
} else {

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.28",
4+
"version": "1.0.0-alpha.31",
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.28",
4+
"version": "1.0.0-alpha.31",
55
"description": "Runtime of ZenStack for both client-side and server-side environments.",
66
"repository": {
77
"type": "git",

0 commit comments

Comments
 (0)