Skip to content

Commit 4f11835

Browse files
committed
chore: remove unused spaces
1 parent 088c41a commit 4f11835

File tree

16 files changed

+59
-66
lines changed

16 files changed

+59
-66
lines changed

packages/cli/src/actions/generate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { isPlugin, LiteralExpr, type Model } from '@zenstackhq/language/ast';
22
import type { CliGenerator } from '@zenstackhq/runtime/client';
33
import { PrismaSchemaGenerator, TsSchemaGenerator } from '@zenstackhq/sdk';
4+
import { invariant } from '@zenstackhq/sdk/local-helpers';
45
import colors from 'colors';
56
import fs from 'node:fs';
67
import path from 'node:path';
7-
import invariant from 'tiny-invariant';
88
import { getSchemaFile, loadSchemaDocument } from './action-utils';
99

1010
type Options = {
@@ -41,7 +41,7 @@ import { ZenStackClient } from '@zenstackhq/runtime';
4141
import { schema } from '${outputPath}/schema';
4242
4343
const client = new ZenStackClient(schema, {
44-
dialectConfig: { ... }
44+
dialectConfig: { ... }
4545
});
4646
\`\`\`
4747
`);

packages/language/res/stdlib.zmodel

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ enum ReferentialAction {
2525
* Used with "onUpdate": when updating the identifier of a referenced object, the scalar fields of the referencing objects will be set to NULL.
2626
*/
2727
SetNull
28-
28+
2929
/**
3030
* Used with "onDelete": the scalar field of the referencing object will be set to the fields default value.
3131
* Used with "onUpdate": the scalar field of the referencing object will be set to the fields default value.
@@ -104,7 +104,7 @@ function ulid(): String {
104104
} @@@expressionContext([DefaultValue])
105105

106106
/**
107-
* Creates a sequence of integers in the underlying database and assign the incremented
107+
* Creates a sequence of integers in the underlying database and assign the incremented
108108
* values to the ID values of the created records based on the sequence.
109109
*/
110110
function autoincrement(): Int {
@@ -174,9 +174,9 @@ function isEmpty(field: Any[]): Boolean {
174174
/**
175175
* The name of the model for which the policy rule is defined. If the rule is
176176
* inherited to a sub model, this function returns the name of the sub model.
177-
*
177+
*
178178
* @param optional parameter to control the casing of the returned value. Valid
179-
* values are "original", "upper", "lower", "capitalize", "uncapitalize". Defaults
179+
* values are "original", "upper", "lower", "capitalize", "uncapitalize". Defaults
180180
* to "original".
181181
*/
182182
function currentModel(casing: String?): String {
@@ -186,7 +186,7 @@ function currentModel(casing: String?): String {
186186
* The operation for which the policy rule is defined for. Note that a rule with
187187
* "all" operation is expanded to "create", "read", "update", and "delete" rules,
188188
* and the function returns corresponding value for each expanded version.
189-
*
189+
*
190190
* @param optional parameter to control the casing of the returned value. Valid
191191
* values are "original", "upper", "lower", "capitalize", "uncapitalize". Defaults
192192
* to "original".
@@ -523,13 +523,13 @@ attribute @@schema(_ name: String) @@@prisma
523523

524524
/**
525525
* Indicates that the field is a password field and needs to be hashed before persistence.
526-
*
526+
*
527527
* ZenStack uses `bcryptjs` library to hash password. You can use the `saltLength` parameter
528528
* to configure the cost of hashing, or use `salt` parameter to provide an explicit salt.
529529
* By default, salt length of 12 is used.
530530
*
531531
* @see https://www.npmjs.com/package/bcryptjs for details
532-
*
532+
*
533533
* @param saltLength: length of salt to use (cost factor for the hash function)
534534
* @param salt: salt to use (a pregenerated valid salt)
535535
*/
@@ -538,8 +538,8 @@ attribute @password(saltLength: Int?, salt: String?) @@@targetField([StringField
538538

539539
/**
540540
* Indicates that the field is encrypted when storing in the DB and should be decrypted when read
541-
*
542-
* ZenStack uses the Web Crypto API to encrypt and decrypt the field.
541+
*
542+
* ZenStack uses the Web Crypto API to encrypt and decrypt the field.
543543
*/
544544
attribute @encrypted() @@@targetField([StringField])
545545

@@ -665,9 +665,9 @@ function url(field: String): Boolean {
665665

666666
/**
667667
* Checks if the current user can perform the given operation on the given field.
668-
*
668+
*
669669
* @param field: The field to check access for
670-
* @param operation: The operation to check access for. Can be "read", "create", "update", or "delete". If the operation is not provided,
670+
* @param operation: The operation to check access for. Can be "read", "create", "update", or "delete". If the operation is not provided,
671671
* it defaults the operation of the containing policy rule.
672672
*/
673673
function check(field: Any, operation: String?): Boolean {

packages/language/src/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ export function getObjectLiteral<T>(expr: Expression | ConfigExpr | undefined):
332332
}
333333

334334
export function getLiteralArray<
335-
336335
T extends string | number | boolean | any = any,
337336
>(expr: Expression | ConfigExpr | undefined): T[] | undefined {
338337
const arr = getArray(expr);

packages/language/src/validators/datamodel-validator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ export default class DataModelValidator implements AstValidator<DataModel> {
259259
return;
260260
}
261261

262-
263262
const oppositeModel = field.type.reference!.ref! as DataModel;
264263

265264
// Use name because the current document might be updated

packages/language/src/zmodel.langium

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Argument:
164164
DataModel:
165165
(comments+=TRIPLE_SLASH_COMMENT)*
166166
(
167-
((isAbstract?='abstract')? 'model' name=RegularID
167+
((isAbstract?='abstract')? 'model' name=RegularID
168168
('extends' superTypes+=[DataModel] (',' superTypes+=[DataModel])*)?) |
169169
((isView?='view') name=RegularID)
170170
)
@@ -193,7 +193,7 @@ TypeDef:
193193
type TypeDefFieldTypes = TypeDef | Enum;
194194

195195
TypeDefField:
196-
(comments+=TRIPLE_SLASH_COMMENT)*
196+
(comments+=TRIPLE_SLASH_COMMENT)*
197197
name=RegularIDWithTypeNames type=TypeDefFieldType (attributes+=DataModelFieldAttribute)*;
198198

199199
TypeDefFieldType:
@@ -208,7 +208,7 @@ Enum:
208208
'enum' name=RegularID '{' (
209209
fields+=EnumField
210210
| attributes+=DataModelAttribute
211-
)+
211+
)+
212212
'}';
213213

214214
EnumField:

packages/runtime/src/plugins/policy/plugin.zmodel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/**
22
* Defines an access policy that allows a set of operations when the given condition is true.
3-
*
3+
*
44
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
55
* @param condition: a boolean expression that controls if the operation should be allowed.
66
*/
77
attribute @@allow(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'delete'", "'all'"]), _ condition: Boolean)
88

99
/**
1010
* Defines an access policy that allows the annotated field to be read or updated.
11-
* You can pass a third argument as `true` to make it override the model-level policies.
12-
*
11+
* You can pass a third argument as `true` to make it override the model-level policies.
12+
*
1313
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
1414
* @param condition: a boolean expression that controls if the operation should be allowed.
1515
* @param override: a boolean value that controls if the field-level policy should override the model-level policy.
@@ -18,7 +18,7 @@ attribute @allow(_ operation: String @@@completionHint(["'create'", "'read'", "'
1818

1919
/**
2020
* Defines an access policy that denies a set of operations when the given condition is true.
21-
*
21+
*
2222
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
2323
* @param condition: a boolean expression that controls if the operation should be denied.
2424
*/

packages/runtime/src/utils/clone.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// @ts-expect-error
2-
import { isPlainObject } from 'is-plain-object';
1+
import { isPlainObject } from '@zenstackhq/sdk/local-helpers';
32

43
/**
54
* Clones the given object. Only arrays and plain objects are cloned. Other values are returned as is.
@@ -14,7 +13,6 @@ export function clone<T>(value: T): T {
1413
return value;
1514
}
1615

17-
1816
const result: any = {};
1917
for (const key of Object.keys(value)) {
2018
result[key] = clone(value[key as keyof T]);

packages/runtime/test/client-api/type-coverage.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('zmodel type coverage tests', () => {
88
`
99
model Foo {
1010
id String @id @default(cuid())
11-
11+
1212
String String
1313
Int Int
1414
BigInt BigInt
@@ -17,7 +17,7 @@ describe('zmodel type coverage tests', () => {
1717
Decimal Decimal
1818
Boolean Boolean
1919
Bytes Bytes
20-
20+
2121
@@allow('all', true)
2222
}
2323
`,

packages/runtime/test/policy/connect-disconnect.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ describe('connect and disconnect tests', () => {
77
id String @id @default(uuid())
88
m2 M2[]
99
value Int @default(0)
10-
10+
1111
@@deny('read', value < 0)
1212
@@allow('all', true)
1313
}
14-
14+
1515
model M2 {
1616
id String @id @default(uuid())
1717
value Int
1818
deleted Boolean @default(false)
1919
m1 M1? @relation(fields: [m1Id], references:[id])
2020
m1Id String?
2121
m3 M3[]
22-
22+
2323
@@allow('read,create', true)
2424
@@allow('update', !deleted)
2525
}
@@ -183,17 +183,17 @@ describe('connect and disconnect tests', () => {
183183
model M1 {
184184
id String @id @default(uuid())
185185
m2 M2?
186-
186+
187187
@@allow('all', true)
188188
}
189-
189+
190190
model M2 {
191191
id String @id @default(uuid())
192192
value Int
193193
deleted Boolean @default(false)
194194
m1 M1? @relation(fields: [m1Id], references:[id])
195195
m1Id String? @unique
196-
196+
197197
@@allow('read,create', true)
198198
@@allow('update', !deleted)
199199
}
@@ -285,17 +285,17 @@ describe('connect and disconnect tests', () => {
285285
id String @id @default(uuid())
286286
value Int @default(0)
287287
m2 M2[]
288-
288+
289289
@@deny('read', value < 0)
290290
@@allow('all', true)
291291
}
292-
292+
293293
model M2 {
294294
id String @id @default(uuid())
295295
value Int
296296
deleted Boolean @default(false)
297297
m1 M1[]
298-
298+
299299
@@deny('read', value < 0)
300300
@@allow('read,create', true)
301301
@@allow('update', !deleted)
@@ -325,16 +325,16 @@ describe('connect and disconnect tests', () => {
325325
id String @id @default(uuid())
326326
value Int @default(0)
327327
m2 M1OnM2[]
328-
328+
329329
@@allow('all', true)
330330
}
331-
331+
332332
model M2 {
333333
id String @id @default(uuid())
334334
value Int
335335
deleted Boolean @default(false)
336336
m1 M1OnM2[]
337-
337+
338338
@@allow('read,create', true)
339339
}
340340

packages/runtime/test/policy/cross-model-field-comparison.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ describe('cross-model field comparison tests', () => {
1010
profile Profile @relation(fields: [profileId], references: [id])
1111
profileId Int @unique
1212
age Int
13-
13+
1414
@@allow('all', age == profile.age)
1515
@@deny('update', age > 100)
1616
}
17-
17+
1818
model Profile {
1919
id Int @id
2020
age Int
2121
user User?
22-
22+
2323
@@allow('all', true)
2424
}
2525
`,

0 commit comments

Comments
 (0)