zenstack 0.6.0-pre.3 → 0.6.0-pre.5
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/asset/logo-256-bg.png +0 -0
- package/asset/logo-dark-256.png +0 -0
- package/asset/logo-light-256.png +0 -0
- package/bin/post-install.js +24 -0
- package/cli/index.js +6532 -0
- package/extension.js +39 -0
- package/language-server/main.js +6436 -0
- package/package.json +4 -7
- package/plugins/policy-guard/index.js +4289 -0
- package/plugins/prisma/index.js +3740 -0
- package/plugins/react-hooks/index.js +4318 -0
- package/plugins/trpc/index.js +5386 -0
- package/plugins/zod/index.js +4808 -0
- package/res/package.template.json +9 -0
- package/res/prism-zmodel.js +22 -0
- package/res/stdlib.zmodel +218 -0
- package/res/tsconfig.template.json +17 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// based on: https://github.com/prisma/docs/blob/c72eb087fcf57f3c00d153f86c549ef28b3d0f44/src/components/customMdx/prism/prism-prisma.js
|
|
2
|
+
|
|
3
|
+
(function (Prism) {
|
|
4
|
+
Prism.languages.zmodel = Prism.languages.extend('clike', {
|
|
5
|
+
keyword:
|
|
6
|
+
/\b(?:datasource|enum|generator|model|attribute|function|null|this)\b/,
|
|
7
|
+
'type-class-name': /(\b()\s+)[\w.\\]+/,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
Prism.languages.javascript['class-name'][0].pattern =
|
|
11
|
+
/(\b(?:model|datasource|enum|generator)\s+)[\w.\\]+/;
|
|
12
|
+
|
|
13
|
+
Prism.languages.insertBefore('zmodel', 'function', {
|
|
14
|
+
annotation: {
|
|
15
|
+
pattern: /(^|[^.])@+\w+/,
|
|
16
|
+
lookbehind: true,
|
|
17
|
+
alias: 'punctuation',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
Prism.languages.json5 = Prism.languages.js;
|
|
22
|
+
})(Prism);
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Enum representing referential integrity related actions
|
|
3
|
+
*/
|
|
4
|
+
enum ReferentialAction {
|
|
5
|
+
/*
|
|
6
|
+
* Used with "onDelete": deleting a referenced record will trigger the deletion of referencing record.
|
|
7
|
+
* Used with "onUpdate": updates the relation scalar fields if the referenced scalar fields of the dependent record are updated.
|
|
8
|
+
*/
|
|
9
|
+
Cascade
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* Used with "onDelete": prevents the deletion if any referencing records exist.
|
|
13
|
+
* Used with "onUpdate": prevents the identifier of a referenced record from being changed.
|
|
14
|
+
*/
|
|
15
|
+
Restrict
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* Similar to 'Restrict', the difference between the two is dependent on the database being used.
|
|
19
|
+
* See details: https://www.prisma.io/docs/concepts/components/prisma-schema/relations/referential-actions#noaction
|
|
20
|
+
*/
|
|
21
|
+
NoAction
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* Used with "onDelete": the scalar field of the referencing object will be set to NULL.
|
|
25
|
+
* Used with "onUpdate": when updating the identifier of a referenced object, the scalar fields of the referencing objects will be set to NULL.
|
|
26
|
+
*/
|
|
27
|
+
SetNull
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* Used with "onDelete": the scalar field of the referencing object will be set to the fields default value.
|
|
31
|
+
* Used with "onUpdate": the scalar field of the referencing object will be set to the fields default value.
|
|
32
|
+
*/
|
|
33
|
+
SetDefault
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* Enum representing all possible field types
|
|
38
|
+
*/
|
|
39
|
+
enum AttributeTargetField {
|
|
40
|
+
StringField
|
|
41
|
+
IntField
|
|
42
|
+
FloatField
|
|
43
|
+
DecimalField
|
|
44
|
+
BooleanField
|
|
45
|
+
DateTimeField
|
|
46
|
+
JsonField
|
|
47
|
+
BytesField
|
|
48
|
+
ModelField
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
* Reads value from an environment variable.
|
|
53
|
+
*/
|
|
54
|
+
function env(name: String): String {}
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
* Gets the current login user.
|
|
58
|
+
*/
|
|
59
|
+
function auth(): Any {}
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
* Gets current date-time (as DateTime type).
|
|
63
|
+
*/
|
|
64
|
+
function now(): DateTime {}
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
* Generates a globally unique identifier based on the UUID specs.
|
|
68
|
+
*/
|
|
69
|
+
function uuid(): String {}
|
|
70
|
+
|
|
71
|
+
/*
|
|
72
|
+
* Generates a globally unique identifier based on the CUID spec.
|
|
73
|
+
*/
|
|
74
|
+
function cuid(): String {}
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
* Creates a sequence of integers in the underlying database and assign the incremented
|
|
78
|
+
* values to the ID values of the created records based on the sequence.
|
|
79
|
+
*/
|
|
80
|
+
function autoincrement(): Int {}
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
* Represents default values that cannot be expressed in the Prisma schema (such as random()).
|
|
84
|
+
*/
|
|
85
|
+
function dbgenerated(expr: String): Any {}
|
|
86
|
+
|
|
87
|
+
attribute @@@targetField(targetField: AttributeTargetField[])
|
|
88
|
+
|
|
89
|
+
attribute @@@prisma()
|
|
90
|
+
|
|
91
|
+
/*
|
|
92
|
+
* Defines an ID on the model.
|
|
93
|
+
*/
|
|
94
|
+
attribute @id(map: String?) @@@prisma
|
|
95
|
+
|
|
96
|
+
/*
|
|
97
|
+
* Defines a default value for a field.
|
|
98
|
+
*/
|
|
99
|
+
attribute @default(_ value: ContextType) @@@prisma
|
|
100
|
+
|
|
101
|
+
/*
|
|
102
|
+
* Defines a unique constraint for this field.
|
|
103
|
+
*/
|
|
104
|
+
attribute @unique(map: String?) @@@prisma
|
|
105
|
+
|
|
106
|
+
/*
|
|
107
|
+
* Defines a compound unique constraint for the specified fields.
|
|
108
|
+
*/
|
|
109
|
+
attribute @@unique(_ fields: FieldReference[], name: String?, map: String?) @@@prisma
|
|
110
|
+
|
|
111
|
+
/*
|
|
112
|
+
* Defines an index in the database.
|
|
113
|
+
*/
|
|
114
|
+
attribute @@index(_ fields: FieldReference[], map: String?) @@@prisma
|
|
115
|
+
|
|
116
|
+
/*
|
|
117
|
+
* Defines meta information about the relation.
|
|
118
|
+
*/
|
|
119
|
+
attribute @relation(_ name: String?, fields: FieldReference[]?, references: FieldReference[]?, onDelete: ReferentialAction?, onUpdate: ReferentialAction?, map: String?) @@@prisma
|
|
120
|
+
|
|
121
|
+
/*
|
|
122
|
+
* Maps a field name or enum value from the schema to a column with a different name in the database.
|
|
123
|
+
*/
|
|
124
|
+
attribute @map(_ name: String) @@@prisma
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
* Maps the schema model name to a table with a different name, or an enum name to a different underlying enum in the database.
|
|
128
|
+
*/
|
|
129
|
+
attribute @@map(_ name: String) @@@prisma
|
|
130
|
+
|
|
131
|
+
/*
|
|
132
|
+
* Automatically stores the time when a record was last updated.
|
|
133
|
+
*/
|
|
134
|
+
attribute @updatedAt() @@@targetField([DateTimeField]) @@@prisma
|
|
135
|
+
|
|
136
|
+
/*
|
|
137
|
+
* Defines an access policy that allows a set of operations when the given condition is true.
|
|
138
|
+
*/
|
|
139
|
+
attribute @@allow(_ operation: String, _ condition: Boolean)
|
|
140
|
+
|
|
141
|
+
/*
|
|
142
|
+
* Defines an access policy that denies a set of operations when the given condition is true.
|
|
143
|
+
*/
|
|
144
|
+
attribute @@deny(_ operation: String, _ condition: Boolean)
|
|
145
|
+
|
|
146
|
+
/*
|
|
147
|
+
* Indicates that the field is a password field and needs to be hashed before persistence.
|
|
148
|
+
*
|
|
149
|
+
* ZenStack uses `bcryptjs` library to hash password. You can use the `saltLength` parameter
|
|
150
|
+
* to configure the cost of hashing, or use `salt` parameter to provide an explicit salt.
|
|
151
|
+
* By default, salt length of 12 is used.
|
|
152
|
+
*
|
|
153
|
+
* @see https://www.npmjs.com/package/bcryptjs for details
|
|
154
|
+
*
|
|
155
|
+
* @saltLength: length of salt to use (cost factor for the hash function)
|
|
156
|
+
* @salt: salt to use (a pregenerated valid salt)
|
|
157
|
+
*/
|
|
158
|
+
attribute @password(saltLength: Int?, salt: String?) @@@targetField([StringField])
|
|
159
|
+
|
|
160
|
+
/*
|
|
161
|
+
* Indicates that the field should be omitted when read from the generated services.
|
|
162
|
+
*/
|
|
163
|
+
attribute @omit()
|
|
164
|
+
|
|
165
|
+
/*
|
|
166
|
+
* Validates length of a string field.
|
|
167
|
+
*/
|
|
168
|
+
attribute @length(_ min: Int?, _ max: Int?) @@@targetField([StringField])
|
|
169
|
+
|
|
170
|
+
/*
|
|
171
|
+
* Validates a string field value matches a regex.
|
|
172
|
+
*/
|
|
173
|
+
attribute @regex(_ regex: String) @@@targetField([StringField])
|
|
174
|
+
|
|
175
|
+
/*
|
|
176
|
+
* Validates a string field value starts with the given text.
|
|
177
|
+
*/
|
|
178
|
+
attribute @startsWith(_ text: String) @@@targetField([StringField])
|
|
179
|
+
|
|
180
|
+
/*
|
|
181
|
+
* Validates a string field value ends with the given text.
|
|
182
|
+
*/
|
|
183
|
+
attribute @endsWith(_ text: String) @@@targetField([StringField])
|
|
184
|
+
|
|
185
|
+
/*
|
|
186
|
+
* Validates a string field value is a valid email address.
|
|
187
|
+
*/
|
|
188
|
+
attribute @email() @@@targetField([StringField])
|
|
189
|
+
|
|
190
|
+
/*
|
|
191
|
+
* Validates a string field value is a valid ISO datetime.
|
|
192
|
+
*/
|
|
193
|
+
attribute @datetime() @@@targetField([StringField])
|
|
194
|
+
|
|
195
|
+
/*
|
|
196
|
+
* Validates a string field value is a valid url.
|
|
197
|
+
*/
|
|
198
|
+
attribute @url() @@@targetField([StringField])
|
|
199
|
+
|
|
200
|
+
/*
|
|
201
|
+
* Validates a number field is greater than the given value.
|
|
202
|
+
*/
|
|
203
|
+
attribute @gt(_ value: Int) @@@targetField([IntField, FloatField, DecimalField])
|
|
204
|
+
|
|
205
|
+
/*
|
|
206
|
+
* Validates a number field is greater than or equal to the given value.
|
|
207
|
+
*/
|
|
208
|
+
attribute @gte(_ value: Int) @@@targetField([IntField, FloatField, DecimalField])
|
|
209
|
+
|
|
210
|
+
/*
|
|
211
|
+
* Validates a number field is less than the given value.
|
|
212
|
+
*/
|
|
213
|
+
attribute @lt(_ value: Int) @@@targetField([IntField, FloatField, DecimalField])
|
|
214
|
+
|
|
215
|
+
/*
|
|
216
|
+
* Validates a number field is less than or equal to the given value.
|
|
217
|
+
*/
|
|
218
|
+
attribute @lte(_ value: Int) @@@targetField([IntField, FloatField, DecimalField])
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES6",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"lib": ["ESNext", "DOM"],
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"outDir": "lib",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"resolveJsonModule": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["**/*.ts"],
|
|
16
|
+
"exclude": ["node_modules", ".prisma", "**/*.d.ts"]
|
|
17
|
+
}
|