@contember/schema-utils 1.4.0-beta.2 → 1.4.0-rc.2
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/dist/src/definition-generator/AclDefinitionCodeGenerator.js +4 -4
- package/dist/src/definition-generator/AclDefinitionCodeGenerator.js.map +1 -1
- package/dist/src/definition-generator/DefinitionCodeGenerator.js +6 -6
- package/dist/src/definition-generator/DefinitionCodeGenerator.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/cases/unit/schemas/acl.d.ts +7 -8
- package/dist/tests/cases/unit/schemas/acl.d.ts.map +1 -1
- package/dist/tests/cases/unit/schemas/acl.js +11 -11
- package/dist/tests/cases/unit/schemas/acl.js.map +1 -1
- package/dist/tests/cases/unit/schemas/basic.d.ts +1 -2
- package/dist/tests/cases/unit/schemas/basic.d.ts.map +1 -1
- package/dist/tests/cases/unit/schemas/basic.js +1 -1
- package/dist/tests/cases/unit/schemas/basic.js.map +1 -1
- package/dist/tests/cases/unit/schemas/enum.d.ts +3 -4
- package/dist/tests/cases/unit/schemas/enum.d.ts.map +1 -1
- package/dist/tests/cases/unit/schemas/enum.js +3 -3
- package/dist/tests/cases/unit/schemas/enum.js.map +1 -1
- package/dist/tests/cases/unit/schemas/relations.d.ts +7 -8
- package/dist/tests/cases/unit/schemas/relations.d.ts.map +1 -1
- package/dist/tests/cases/unit/schemas/relations.js +7 -7
- package/dist/tests/cases/unit/schemas/relations.js.map +1 -1
- package/dist/tests/cases/unit/schemas/unique.d.ts +1 -2
- package/dist/tests/cases/unit/schemas/unique.d.ts.map +1 -1
- package/dist/tests/cases/unit/schemas/unique.js +2 -2
- package/dist/tests/cases/unit/schemas/unique.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/definition-generator/AclDefinitionCodeGenerator.ts +4 -4
- package/src/definition-generator/DefinitionCodeGenerator.ts +6 -6
- package/tests/cases/unit/__snapshots__/laxSchemaConverter.test.ts.snap +1 -1
- package/tests/cases/unit/schemas/acl.ts +12 -12
- package/tests/cases/unit/schemas/basic.ts +2 -2
- package/tests/cases/unit/schemas/enum.ts +4 -4
- package/tests/cases/unit/schemas/relations.ts +8 -8
- package/tests/cases/unit/schemas/unique.ts +3 -3
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c } from '@contember/schema-definition'
|
|
2
2
|
|
|
3
|
-
export const readerRole =
|
|
3
|
+
export const readerRole = c.createRole('reader', { stages: '*' })
|
|
4
4
|
|
|
5
|
-
export const editorRole =
|
|
5
|
+
export const editorRole = c.createRole('editor', { stages: '*' })
|
|
6
6
|
|
|
7
|
-
export const categoryEditorVariable =
|
|
7
|
+
export const categoryEditorVariable = c.createEntityVariable('category', 'Category', editorRole)
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
@
|
|
10
|
+
@c.Allow(readerRole, {
|
|
11
11
|
read: true,
|
|
12
12
|
})
|
|
13
|
-
@
|
|
13
|
+
@c.Allow(editorRole, {
|
|
14
14
|
when: { category: { id: categoryEditorVariable } },
|
|
15
15
|
read: true,
|
|
16
16
|
create: ['title', 'category'],
|
|
17
17
|
update: ['title', 'category'],
|
|
18
18
|
})
|
|
19
19
|
export class Article {
|
|
20
|
-
title =
|
|
21
|
-
deletedAt =
|
|
22
|
-
category =
|
|
20
|
+
title = c.stringColumn()
|
|
21
|
+
deletedAt = c.dateTimeColumn()
|
|
22
|
+
category = c.manyHasOne(Category)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
@
|
|
26
|
+
@c.Allow(readerRole, {
|
|
27
27
|
read: true,
|
|
28
28
|
})
|
|
29
|
-
@
|
|
29
|
+
@c.Allow(editorRole, {
|
|
30
30
|
read: true,
|
|
31
31
|
})
|
|
32
32
|
export class Category {
|
|
33
|
-
name =
|
|
33
|
+
name = c.stringColumn()
|
|
34
34
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c } from '@contember/schema-definition'
|
|
2
2
|
|
|
3
|
-
export const articleState =
|
|
3
|
+
export const articleState = c.createEnum('draft', 'published')
|
|
4
4
|
|
|
5
5
|
export class Article {
|
|
6
|
-
title =
|
|
7
|
-
state =
|
|
6
|
+
title = c.stringColumn()
|
|
7
|
+
state = c.enumColumn(articleState).notNull().default('draft')
|
|
8
8
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c } from '@contember/schema-definition'
|
|
2
2
|
|
|
3
3
|
export class Article {
|
|
4
|
-
title =
|
|
5
|
-
category =
|
|
6
|
-
tags =
|
|
4
|
+
title = c.stringColumn()
|
|
5
|
+
category = c.manyHasOne(Category, 'articles')
|
|
6
|
+
tags = c.manyHasMany(Tag, 'articles')
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export class Category {
|
|
10
|
-
name =
|
|
11
|
-
articles =
|
|
10
|
+
name = c.stringColumn()
|
|
11
|
+
articles = c.oneHasMany(Article, 'category')
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export class Tag {
|
|
15
|
-
name =
|
|
16
|
-
tags =
|
|
15
|
+
name = c.stringColumn()
|
|
16
|
+
tags = c.manyHasManyInverse(Article, 'tags')
|
|
17
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c } from '@contember/schema-definition'
|
|
2
2
|
|
|
3
|
-
@
|
|
3
|
+
@c.Unique('title')
|
|
4
4
|
export class Article {
|
|
5
|
-
title =
|
|
5
|
+
title = c.stringColumn()
|
|
6
6
|
}
|