zenstack 1.0.0-alpha.116 → 1.0.0-alpha.119
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/cli/cli-util.js +1 -1
- package/cli/cli-util.js.map +1 -1
- package/cli/plugin-runner.js +19 -17
- package/cli/plugin-runner.js.map +1 -1
- package/language-server/utils.d.ts +1 -5
- package/language-server/utils.js +2 -19
- package/language-server/utils.js.map +1 -1
- package/language-server/validator/datamodel-validator.js +1 -1
- package/language-server/validator/datamodel-validator.js.map +1 -1
- package/package.json +5 -5
- package/plugins/access-policy/expression-writer.js +11 -10
- package/plugins/access-policy/expression-writer.js.map +1 -1
- package/plugins/access-policy/policy-guard-generator.js +6 -6
- package/plugins/access-policy/policy-guard-generator.js.map +1 -1
- package/plugins/access-policy/typescript-expression-transformer.js +9 -8
- package/plugins/access-policy/typescript-expression-transformer.js.map +1 -1
- package/plugins/model-meta/index.js +4 -21
- package/plugins/model-meta/index.js.map +1 -1
- package/plugins/plugin-utils.d.ts +0 -4
- package/plugins/plugin-utils.js +1 -16
- package/plugins/plugin-utils.js.map +1 -1
- package/plugins/prisma/prisma-builder.d.ts +3 -2
- package/plugins/prisma/prisma-builder.js +5 -3
- package/plugins/prisma/prisma-builder.js.map +1 -1
- package/plugins/prisma/schema-generator.js +36 -25
- package/plugins/prisma/schema-generator.js.map +1 -1
- package/plugins/zod/generator.js +1 -0
- package/plugins/zod/generator.js.map +1 -1
- package/res/starter.zmodel +3 -3
- package/res/stdlib.zmodel +53 -53
package/res/stdlib.zmodel
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
2
|
* Enum representing referential integrity related actions
|
|
3
3
|
*/
|
|
4
4
|
enum ReferentialAction {
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
6
|
* Used with "onDelete": deleting a referenced record will trigger the deletion of referencing record.
|
|
7
7
|
* Used with "onUpdate": updates the relation scalar fields if the referenced scalar fields of the dependent record are updated.
|
|
8
8
|
*/
|
|
9
9
|
Cascade
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
12
|
* Used with "onDelete": prevents the deletion if any referencing records exist.
|
|
13
13
|
* Used with "onUpdate": prevents the identifier of a referenced record from being changed.
|
|
14
14
|
*/
|
|
15
15
|
Restrict
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
18
|
* Similar to 'Restrict', the difference between the two is dependent on the database being used.
|
|
19
19
|
* See details: https://www.prisma.io/docs/concepts/components/prisma-schema/relations/referential-actions#noaction
|
|
20
20
|
*/
|
|
21
21
|
NoAction
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
24
|
* Used with "onDelete": the scalar field of the referencing object will be set to NULL.
|
|
25
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
26
|
*/
|
|
27
27
|
SetNull
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
30
|
* Used with "onDelete": the scalar field of the referencing object will be set to the fields default value.
|
|
31
31
|
* Used with "onUpdate": the scalar field of the referencing object will be set to the fields default value.
|
|
32
32
|
*/
|
|
33
33
|
SetDefault
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
37
|
* Enum representing all possible field types
|
|
38
38
|
*/
|
|
39
39
|
enum AttributeTargetField {
|
|
@@ -49,44 +49,44 @@ enum AttributeTargetField {
|
|
|
49
49
|
ModelField
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
/**
|
|
53
53
|
* Reads value from an environment variable.
|
|
54
54
|
*/
|
|
55
55
|
function env(name: String): String {
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
/**
|
|
59
59
|
* Gets the current login user.
|
|
60
60
|
*/
|
|
61
61
|
function auth(): Any {
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
/**
|
|
65
65
|
* Gets current date-time (as DateTime type).
|
|
66
66
|
*/
|
|
67
67
|
function now(): DateTime {
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
/**
|
|
71
71
|
* Generates a globally unique identifier based on the UUID specs.
|
|
72
72
|
*/
|
|
73
73
|
function uuid(): String {
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
/**
|
|
77
77
|
* Generates a globally unique identifier based on the CUID spec.
|
|
78
78
|
*/
|
|
79
79
|
function cuid(): String {
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
/**
|
|
83
83
|
* Creates a sequence of integers in the underlying database and assign the incremented
|
|
84
84
|
* values to the ID values of the created records based on the sequence.
|
|
85
85
|
*/
|
|
86
86
|
function autoincrement(): Int {
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
/**
|
|
90
90
|
* Represents default values that cannot be expressed in the Prisma schema (such as random()).
|
|
91
91
|
*/
|
|
92
92
|
function dbgenerated(expr: String): Any {
|
|
@@ -98,50 +98,50 @@ function dbgenerated(expr: String): Any {
|
|
|
98
98
|
function future(): Any {
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
/**
|
|
102
102
|
* If the field value contains the search string. By default, the search is case-sensitive,
|
|
103
103
|
* but you can override the behavior with the "caseInSensitive" argument.
|
|
104
104
|
*/
|
|
105
105
|
function contains(field: String, search: String, caseInSensitive: Boolean?): Boolean {
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
/**
|
|
109
109
|
* If the field value matches the search condition with [full-text-search](https://www.prisma.io/docs/concepts/components/prisma-client/full-text-search). Need to enable "fullTextSearch" preview feature to use.
|
|
110
110
|
*/
|
|
111
111
|
function search(field: String, search: String): Boolean {
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
/**
|
|
115
115
|
* If the field value starts with the search string
|
|
116
116
|
*/
|
|
117
117
|
function startsWith(field: String, search: String): Boolean {
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
/**
|
|
121
121
|
* If the field value ends with the search string
|
|
122
122
|
*/
|
|
123
123
|
function endsWith(field: String, search: String): Boolean {
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
/**
|
|
127
127
|
* If the field value (a list) has the given search value
|
|
128
128
|
*/
|
|
129
129
|
function has(field: Any[], search: Any): Boolean {
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
/**
|
|
133
133
|
* If the field value (a list) has every element of the search list
|
|
134
134
|
*/
|
|
135
135
|
function hasEvery(field: Any[], search: Any[]): Boolean {
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
/**
|
|
139
139
|
* If the field value (a list) has at least one element of the search list
|
|
140
140
|
*/
|
|
141
141
|
function hasSome(field: Any[], search: Any[]): Boolean {
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
/**
|
|
145
145
|
* If the field value (a list) is empty
|
|
146
146
|
*/
|
|
147
147
|
function isEmpty(field: Any[]): Boolean {
|
|
@@ -157,32 +157,32 @@ attribute @@@targetField(targetField: AttributeTargetField[])
|
|
|
157
157
|
*/
|
|
158
158
|
attribute @@@prisma()
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
/**
|
|
161
161
|
* Defines an ID on the model.
|
|
162
162
|
*/
|
|
163
163
|
attribute @id(map: String?, length: Int?, sort: String?, clustered: Boolean?) @@@prisma
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
/**
|
|
166
166
|
* Defines a default value for a field.
|
|
167
167
|
*/
|
|
168
168
|
attribute @default(_ value: ContextType) @@@prisma
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
/**
|
|
171
171
|
* Defines a unique constraint for this field.
|
|
172
172
|
*/
|
|
173
173
|
attribute @unique(map: String?, length: Int?, sort: String?, clustered: Boolean?) @@@prisma
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
/**
|
|
176
176
|
* Defines a multi-field ID (composite ID) on the model.
|
|
177
177
|
*/
|
|
178
178
|
attribute @@id(_ fields: FieldReference[], name: String?, map: String?, length: Int?, sort: String?, clustered: Boolean?) @@@prisma
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
/**
|
|
181
181
|
* Defines a compound unique constraint for the specified fields.
|
|
182
182
|
*/
|
|
183
183
|
attribute @@unique(_ fields: FieldReference[], name: String?, map: String?, length: Int?, sort: String?, clustered: Boolean?) @@@prisma
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
/**
|
|
186
186
|
* Index types
|
|
187
187
|
*/
|
|
188
188
|
enum IndexType {
|
|
@@ -194,37 +194,37 @@ enum IndexType {
|
|
|
194
194
|
Brin
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
/**
|
|
198
198
|
* Defines an index in the database.
|
|
199
199
|
*/
|
|
200
200
|
attribute @@index(_ fields: FieldReference[], name: String?, map: String?, length: Int?, sort: String?, clustered: Boolean?, type: IndexType?) @@@prisma
|
|
201
201
|
|
|
202
|
-
|
|
202
|
+
/**
|
|
203
203
|
* Defines meta information about the relation.
|
|
204
204
|
*/
|
|
205
205
|
attribute @relation(_ name: String?, fields: FieldReference[]?, references: TransitiveFieldReference[]?, onDelete: ReferentialAction?, onUpdate: ReferentialAction?, map: String?) @@@prisma
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
/**
|
|
208
208
|
* Maps a field name or enum value from the schema to a column with a different name in the database.
|
|
209
209
|
*/
|
|
210
210
|
attribute @map(_ name: String) @@@prisma
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
/**
|
|
213
213
|
* Maps the schema model name to a table with a different name, or an enum name to a different underlying enum in the database.
|
|
214
214
|
*/
|
|
215
215
|
attribute @@map(_ name: String) @@@prisma
|
|
216
216
|
|
|
217
|
-
|
|
217
|
+
/**
|
|
218
218
|
* Exclude a field from the Prisma Client (for example, a field that you do not want Prisma users to update).
|
|
219
219
|
*/
|
|
220
220
|
attribute @ignore() @@@prisma
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
/**
|
|
223
223
|
* Exclude a model from the Prisma Client (for example, a model that you do not want Prisma users to update).
|
|
224
224
|
*/
|
|
225
225
|
attribute @@ignore() @@@prisma
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
/**
|
|
228
228
|
* Automatically stores the time when a record was last updated.
|
|
229
229
|
*/
|
|
230
230
|
attribute @updatedAt() @@@targetField([DateTimeField]) @@@prisma
|
|
@@ -317,22 +317,22 @@ attribute @db.Blob() @@@targetField([BytesField]) @@@prisma
|
|
|
317
317
|
attribute @db.MediumBlob() @@@targetField([BytesField]) @@@prisma
|
|
318
318
|
attribute @db.Image() @@@targetField([BytesField]) @@@prisma
|
|
319
319
|
|
|
320
|
-
|
|
320
|
+
/**
|
|
321
321
|
* Specifies the schema to use in a multi-schema database. https://www.prisma.io/docs/guides/database/multi-schema.
|
|
322
322
|
*/
|
|
323
323
|
attribute @@schema(_ name: String) @@@prisma
|
|
324
324
|
|
|
325
|
-
|
|
325
|
+
/**
|
|
326
326
|
* Defines an access policy that allows a set of operations when the given condition is true.
|
|
327
327
|
*/
|
|
328
328
|
attribute @@allow(_ operation: String, _ condition: Boolean)
|
|
329
329
|
|
|
330
|
-
|
|
330
|
+
/**
|
|
331
331
|
* Defines an access policy that denies a set of operations when the given condition is true.
|
|
332
332
|
*/
|
|
333
333
|
attribute @@deny(_ operation: String, _ condition: Boolean)
|
|
334
334
|
|
|
335
|
-
|
|
335
|
+
/**
|
|
336
336
|
* Indicates that the field is a password field and needs to be hashed before persistence.
|
|
337
337
|
*
|
|
338
338
|
* ZenStack uses `bcryptjs` library to hash password. You can use the `saltLength` parameter
|
|
@@ -346,72 +346,72 @@ attribute @@deny(_ operation: String, _ condition: Boolean)
|
|
|
346
346
|
*/
|
|
347
347
|
attribute @password(saltLength: Int?, salt: String?) @@@targetField([StringField])
|
|
348
348
|
|
|
349
|
-
|
|
349
|
+
/**
|
|
350
350
|
* Indicates that the field should be omitted when read from the generated services.
|
|
351
351
|
*/
|
|
352
352
|
attribute @omit()
|
|
353
353
|
|
|
354
|
-
|
|
354
|
+
/**
|
|
355
355
|
* Validates length of a string field.
|
|
356
356
|
*/
|
|
357
357
|
attribute @length(_ min: Int?, _ max: Int?) @@@targetField([StringField])
|
|
358
358
|
|
|
359
|
-
|
|
359
|
+
/**
|
|
360
360
|
* Validates a string field value matches a regex.
|
|
361
361
|
*/
|
|
362
362
|
attribute @regex(_ regex: String) @@@targetField([StringField])
|
|
363
363
|
|
|
364
|
-
|
|
364
|
+
/**
|
|
365
365
|
* Validates a string field value starts with the given text.
|
|
366
366
|
*/
|
|
367
367
|
attribute @startsWith(_ text: String) @@@targetField([StringField])
|
|
368
368
|
|
|
369
|
-
|
|
369
|
+
/**
|
|
370
370
|
* Validates a string field value ends with the given text.
|
|
371
371
|
*/
|
|
372
372
|
attribute @endsWith(_ text: String) @@@targetField([StringField])
|
|
373
373
|
|
|
374
|
-
|
|
374
|
+
/**
|
|
375
375
|
* Validates a string field value is a valid email address.
|
|
376
376
|
*/
|
|
377
377
|
attribute @email() @@@targetField([StringField])
|
|
378
378
|
|
|
379
|
-
|
|
379
|
+
/**
|
|
380
380
|
* Validates a string field value is a valid ISO datetime.
|
|
381
381
|
*/
|
|
382
382
|
attribute @datetime() @@@targetField([StringField])
|
|
383
383
|
|
|
384
|
-
|
|
384
|
+
/**
|
|
385
385
|
* Validates a string field value is a valid url.
|
|
386
386
|
*/
|
|
387
387
|
attribute @url() @@@targetField([StringField])
|
|
388
388
|
|
|
389
|
-
|
|
389
|
+
/**
|
|
390
390
|
* Validates a number field is greater than the given value.
|
|
391
391
|
*/
|
|
392
392
|
attribute @gt(_ value: Int) @@@targetField([IntField, FloatField, DecimalField])
|
|
393
393
|
|
|
394
|
-
|
|
394
|
+
/**
|
|
395
395
|
* Validates a number field is greater than or equal to the given value.
|
|
396
396
|
*/
|
|
397
397
|
attribute @gte(_ value: Int) @@@targetField([IntField, FloatField, DecimalField])
|
|
398
398
|
|
|
399
|
-
|
|
399
|
+
/**
|
|
400
400
|
* Validates a number field is less than the given value.
|
|
401
401
|
*/
|
|
402
402
|
attribute @lt(_ value: Int) @@@targetField([IntField, FloatField, DecimalField])
|
|
403
403
|
|
|
404
|
-
|
|
404
|
+
/**
|
|
405
405
|
* Validates a number field is less than or equal to the given value.
|
|
406
406
|
*/
|
|
407
407
|
attribute @lte(_ value: Int) @@@targetField([IntField, FloatField, DecimalField])
|
|
408
408
|
|
|
409
|
-
|
|
409
|
+
/**
|
|
410
410
|
* A utility attribute to allow passthrough of arbitrary attribute text to the generated Prisma schema.
|
|
411
411
|
*/
|
|
412
412
|
attribute @prisma.passthrough(_ text: String)
|
|
413
413
|
|
|
414
|
-
|
|
414
|
+
/**
|
|
415
415
|
* A utility attribute to allow passthrough of arbitrary attribute text to the generated Prisma schema.
|
|
416
416
|
*/
|
|
417
417
|
attribute @@prisma.passthrough(_ text: String)
|