@api-client/core 0.18.59 → 0.18.61
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/build/src/modeling/ApiModel.d.ts.map +1 -1
- package/build/src/modeling/ApiModel.js +2 -2
- package/build/src/modeling/ApiModel.js.map +1 -1
- package/build/src/modeling/ExposedEntity.d.ts.map +1 -1
- package/build/src/modeling/ExposedEntity.js +4 -4
- package/build/src/modeling/ExposedEntity.js.map +1 -1
- package/build/src/modeling/actions/Action.d.ts.map +1 -1
- package/build/src/modeling/actions/Action.js +2 -2
- package/build/src/modeling/actions/Action.js.map +1 -1
- package/build/src/modeling/actions/index.d.ts +10 -0
- package/build/src/modeling/actions/index.d.ts.map +1 -1
- package/build/src/modeling/actions/index.js +30 -0
- package/build/src/modeling/actions/index.js.map +1 -1
- package/build/src/modeling/rules/AllowAuthenticated.d.ts +2 -2
- package/build/src/modeling/rules/AllowAuthenticated.d.ts.map +1 -1
- package/build/src/modeling/rules/AllowAuthenticated.js +1 -1
- package/build/src/modeling/rules/AllowAuthenticated.js.map +1 -1
- package/build/src/modeling/rules/AllowPublic.d.ts +2 -2
- package/build/src/modeling/rules/AllowPublic.d.ts.map +1 -1
- package/build/src/modeling/rules/AllowPublic.js +1 -1
- package/build/src/modeling/rules/AllowPublic.js.map +1 -1
- package/build/src/modeling/rules/MatchResourceOwner.d.ts +15 -6
- package/build/src/modeling/rules/MatchResourceOwner.d.ts.map +1 -1
- package/build/src/modeling/rules/MatchResourceOwner.js +18 -5
- package/build/src/modeling/rules/MatchResourceOwner.js.map +1 -1
- package/build/src/modeling/rules/index.d.ts +11 -0
- package/build/src/modeling/rules/index.d.ts.map +1 -1
- package/build/src/modeling/rules/index.js +30 -0
- package/build/src/modeling/rules/index.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +10 -10
- package/package.json +1 -1
- package/src/modeling/ApiModel.ts +2 -1
- package/src/modeling/ExposedEntity.ts +4 -2
- package/src/modeling/actions/Action.ts +2 -1
- package/src/modeling/rules/AllowAuthenticated.ts +3 -3
- package/src/modeling/rules/AllowPublic.ts +3 -3
- package/src/modeling/rules/MatchResourceOwner.ts +25 -10
- package/tests/unit/modeling/actions/Action.spec.ts +10 -10
- package/tests/unit/modeling/actions/CreateAction.spec.ts +8 -8
- package/tests/unit/modeling/actions/DeleteAction.spec.ts +5 -5
- package/tests/unit/modeling/actions/ReadAction.spec.ts +9 -9
- package/tests/unit/modeling/api_model.spec.ts +3 -3
- package/tests/unit/modeling/exposed_entity.spec.ts +8 -8
- package/tests/unit/modeling/exposed_entity_actions.spec.ts +182 -0
- package/tests/unit/modeling/rules/AllowAuthenticated.spec.ts +2 -2
- package/tests/unit/modeling/rules/AllowPublic.spec.ts +2 -2
- package/tests/unit/modeling/rules/MatchResourceOwner.spec.ts +24 -4
- package/tests/unit/modeling/rules/restoring_rules.spec.ts +121 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { test } from '@japa/runner'
|
|
2
|
+
import {
|
|
3
|
+
ApiModel,
|
|
4
|
+
CreateAction,
|
|
5
|
+
DataDomain,
|
|
6
|
+
DeleteAction,
|
|
7
|
+
DomainEntity,
|
|
8
|
+
ListAction,
|
|
9
|
+
ReadAction,
|
|
10
|
+
SearchAction,
|
|
11
|
+
UpdateAction,
|
|
12
|
+
} from '../../../src/modeling/index.js'
|
|
13
|
+
import { ExposedEntityKind } from '../../../src/models/kinds.js'
|
|
14
|
+
import { nanoid } from '../../../src/nanoid.js'
|
|
15
|
+
|
|
16
|
+
test.group('ExposedEntity::actions', (group) => {
|
|
17
|
+
let domain: DataDomain
|
|
18
|
+
let entity: DomainEntity
|
|
19
|
+
|
|
20
|
+
group.each.setup(() => {
|
|
21
|
+
domain = new DataDomain()
|
|
22
|
+
const m1 = domain.addModel()
|
|
23
|
+
entity = m1.addEntity()
|
|
24
|
+
domain.info.version = '1.0.0'
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('restores a list acton', ({ assert }) => {
|
|
28
|
+
const action = new ListAction()
|
|
29
|
+
const model = new ApiModel(
|
|
30
|
+
{
|
|
31
|
+
exposes: [
|
|
32
|
+
{
|
|
33
|
+
kind: ExposedEntityKind,
|
|
34
|
+
key: nanoid(),
|
|
35
|
+
entity: { key: entity.key },
|
|
36
|
+
hasCollection: true,
|
|
37
|
+
collectionPath: '/things',
|
|
38
|
+
resourcePath: '/things/{id}',
|
|
39
|
+
isRoot: true,
|
|
40
|
+
actions: [action.toJSON()],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
domain
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
const restoredAction = model.exposes[0].actions[0]
|
|
48
|
+
assert.ok(restoredAction, 'Action should be restored')
|
|
49
|
+
assert.equal(restoredAction.kind, 'list', 'Action kind should be list')
|
|
50
|
+
assert.instanceOf(restoredAction, ListAction, 'Action should be an instance of ListAction')
|
|
51
|
+
}).tags(['@modeling', '@action', '@restoring'])
|
|
52
|
+
|
|
53
|
+
test('restores a create acton', ({ assert }) => {
|
|
54
|
+
const action = new CreateAction()
|
|
55
|
+
const model = new ApiModel(
|
|
56
|
+
{
|
|
57
|
+
exposes: [
|
|
58
|
+
{
|
|
59
|
+
kind: ExposedEntityKind,
|
|
60
|
+
key: nanoid(),
|
|
61
|
+
entity: { key: entity.key },
|
|
62
|
+
hasCollection: true,
|
|
63
|
+
collectionPath: '/things',
|
|
64
|
+
resourcePath: '/things/{id}',
|
|
65
|
+
isRoot: true,
|
|
66
|
+
actions: [action.toJSON()],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
domain
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
const restoredAction = model.exposes[0].actions[0]
|
|
74
|
+
assert.ok(restoredAction, 'Action should be restored')
|
|
75
|
+
assert.equal(restoredAction.kind, 'create', 'Action kind should be create')
|
|
76
|
+
assert.instanceOf(restoredAction, CreateAction, 'Action should be an instance of CreateAction')
|
|
77
|
+
}).tags(['@modeling', '@action', '@restoring'])
|
|
78
|
+
|
|
79
|
+
test('restores a read acton', ({ assert }) => {
|
|
80
|
+
const action = new ReadAction()
|
|
81
|
+
const model = new ApiModel(
|
|
82
|
+
{
|
|
83
|
+
exposes: [
|
|
84
|
+
{
|
|
85
|
+
kind: ExposedEntityKind,
|
|
86
|
+
key: nanoid(),
|
|
87
|
+
entity: { key: entity.key },
|
|
88
|
+
hasCollection: true,
|
|
89
|
+
collectionPath: '/things',
|
|
90
|
+
resourcePath: '/things/{id}',
|
|
91
|
+
isRoot: true,
|
|
92
|
+
actions: [action.toJSON()],
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
domain
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
const restoredAction = model.exposes[0].actions[0]
|
|
100
|
+
assert.ok(restoredAction, 'Action should be restored')
|
|
101
|
+
assert.equal(restoredAction.kind, 'read', 'Action kind should be read')
|
|
102
|
+
assert.instanceOf(restoredAction, ReadAction, 'Action should be an instance of ReadAction')
|
|
103
|
+
}).tags(['@modeling', '@action', '@restoring'])
|
|
104
|
+
|
|
105
|
+
test('restores a update acton', ({ assert }) => {
|
|
106
|
+
const action = new UpdateAction()
|
|
107
|
+
const model = new ApiModel(
|
|
108
|
+
{
|
|
109
|
+
exposes: [
|
|
110
|
+
{
|
|
111
|
+
kind: ExposedEntityKind,
|
|
112
|
+
key: nanoid(),
|
|
113
|
+
entity: { key: entity.key },
|
|
114
|
+
hasCollection: true,
|
|
115
|
+
collectionPath: '/things',
|
|
116
|
+
resourcePath: '/things/{id}',
|
|
117
|
+
isRoot: true,
|
|
118
|
+
actions: [action.toJSON()],
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
domain
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
const restoredAction = model.exposes[0].actions[0]
|
|
126
|
+
assert.ok(restoredAction, 'Action should be restored')
|
|
127
|
+
assert.equal(restoredAction.kind, 'update', 'Action kind should be update')
|
|
128
|
+
assert.instanceOf(restoredAction, UpdateAction, 'Action should be an instance of UpdateAction')
|
|
129
|
+
}).tags(['@modeling', '@action', '@restoring'])
|
|
130
|
+
|
|
131
|
+
test('restores a delete acton', ({ assert }) => {
|
|
132
|
+
const action = new DeleteAction()
|
|
133
|
+
const model = new ApiModel(
|
|
134
|
+
{
|
|
135
|
+
exposes: [
|
|
136
|
+
{
|
|
137
|
+
kind: ExposedEntityKind,
|
|
138
|
+
key: nanoid(),
|
|
139
|
+
entity: { key: entity.key },
|
|
140
|
+
hasCollection: true,
|
|
141
|
+
collectionPath: '/things',
|
|
142
|
+
resourcePath: '/things/{id}',
|
|
143
|
+
isRoot: true,
|
|
144
|
+
actions: [action.toJSON()],
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
domain
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
const restoredAction = model.exposes[0].actions[0]
|
|
152
|
+
assert.ok(restoredAction, 'Action should be restored')
|
|
153
|
+
assert.equal(restoredAction.kind, 'delete', 'Action kind should be delete')
|
|
154
|
+
assert.instanceOf(restoredAction, DeleteAction, 'Action should be an instance of DeleteAction')
|
|
155
|
+
}).tags(['@modeling', '@action', '@restoring'])
|
|
156
|
+
|
|
157
|
+
test('restores a search acton', ({ assert }) => {
|
|
158
|
+
const action = new SearchAction()
|
|
159
|
+
const model = new ApiModel(
|
|
160
|
+
{
|
|
161
|
+
exposes: [
|
|
162
|
+
{
|
|
163
|
+
kind: ExposedEntityKind,
|
|
164
|
+
key: nanoid(),
|
|
165
|
+
entity: { key: entity.key },
|
|
166
|
+
hasCollection: true,
|
|
167
|
+
collectionPath: '/things',
|
|
168
|
+
resourcePath: '/things/{id}',
|
|
169
|
+
isRoot: true,
|
|
170
|
+
actions: [action.toJSON()],
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
domain
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
const restoredAction = model.exposes[0].actions[0]
|
|
178
|
+
assert.ok(restoredAction, 'Action should be restored')
|
|
179
|
+
assert.equal(restoredAction.kind, 'search', 'Action kind should be search')
|
|
180
|
+
assert.instanceOf(restoredAction, SearchAction, 'Action should be an instance of SearchAction')
|
|
181
|
+
}).tags(['@modeling', '@action', '@restoring'])
|
|
182
|
+
})
|
|
@@ -4,14 +4,14 @@ import { AllowAuthenticatedAccessRule } from '../../../../src/modeling/rules/All
|
|
|
4
4
|
test.group('AllowAuthenticatedAccessRule', () => {
|
|
5
5
|
test('initializes with correct type', ({ assert }) => {
|
|
6
6
|
const rule = new AllowAuthenticatedAccessRule()
|
|
7
|
-
assert.equal(rule.type, '
|
|
7
|
+
assert.equal(rule.type, 'allowAuthenticated')
|
|
8
8
|
}).tags(['@modeling', '@rule', '@allow-authenticated'])
|
|
9
9
|
|
|
10
10
|
test('toJSON returns valid schema', ({ assert }) => {
|
|
11
11
|
const rule = new AllowAuthenticatedAccessRule()
|
|
12
12
|
const json = rule.toJSON()
|
|
13
13
|
|
|
14
|
-
assert.equal(json.type, '
|
|
14
|
+
assert.equal(json.type, 'allowAuthenticated')
|
|
15
15
|
}).tags(['@modeling', '@rule', '@allow-authenticated', '@serialization'])
|
|
16
16
|
|
|
17
17
|
test('notifies change', async ({ assert }) => {
|
|
@@ -4,14 +4,14 @@ import { AllowPublicAccessRule } from '../../../../src/modeling/rules/AllowPubli
|
|
|
4
4
|
test.group('AllowPublicAccessRule', () => {
|
|
5
5
|
test('initializes with correct type', ({ assert }) => {
|
|
6
6
|
const rule = new AllowPublicAccessRule()
|
|
7
|
-
assert.equal(rule.type, '
|
|
7
|
+
assert.equal(rule.type, 'allowPublic')
|
|
8
8
|
}).tags(['@modeling', '@rule', '@allow-public'])
|
|
9
9
|
|
|
10
10
|
test('toJSON returns valid schema', ({ assert }) => {
|
|
11
11
|
const rule = new AllowPublicAccessRule()
|
|
12
12
|
const json = rule.toJSON()
|
|
13
13
|
|
|
14
|
-
assert.equal(json.type, '
|
|
14
|
+
assert.equal(json.type, 'allowPublic')
|
|
15
15
|
}).tags(['@modeling', '@rule', '@allow-public', '@serialization'])
|
|
16
16
|
|
|
17
17
|
test('notifies change', async ({ assert }) => {
|
|
@@ -4,23 +4,43 @@ import { MatchResourceOwnerAccessRule } from '../../../../src/modeling/rules/Mat
|
|
|
4
4
|
test.group('MatchResourceOwnerAccessRule', () => {
|
|
5
5
|
test('initializes with default values', ({ assert }) => {
|
|
6
6
|
const rule = new MatchResourceOwnerAccessRule()
|
|
7
|
-
assert.equal(rule.type, '
|
|
8
|
-
assert.
|
|
7
|
+
assert.equal(rule.type, 'matchResourceOwner')
|
|
8
|
+
assert.isUndefined(rule.property)
|
|
9
|
+
assert.equal(rule.target, 'property')
|
|
9
10
|
}).tags(['@modeling', '@rule', '@match-resource-owner'])
|
|
10
11
|
|
|
11
12
|
test('initializes with provided values', ({ assert }) => {
|
|
12
13
|
const rule = new MatchResourceOwnerAccessRule({ property: 'creatorId' })
|
|
13
14
|
|
|
14
|
-
assert.equal(rule.type, '
|
|
15
|
+
assert.equal(rule.type, 'matchResourceOwner')
|
|
15
16
|
assert.equal(rule.property, 'creatorId')
|
|
17
|
+
assert.equal(rule.target, 'property')
|
|
18
|
+
}).tags(['@modeling', '@rule', '@match-resource-owner'])
|
|
19
|
+
|
|
20
|
+
test('initializes with target user-entity', ({ assert }) => {
|
|
21
|
+
const rule = new MatchResourceOwnerAccessRule({ target: 'user-entity' })
|
|
22
|
+
|
|
23
|
+
assert.equal(rule.type, 'matchResourceOwner')
|
|
24
|
+
assert.isUndefined(rule.property)
|
|
25
|
+
assert.equal(rule.target, 'user-entity')
|
|
16
26
|
}).tags(['@modeling', '@rule', '@match-resource-owner'])
|
|
17
27
|
|
|
18
28
|
test('toJSON returns valid schema', ({ assert }) => {
|
|
19
29
|
const rule = new MatchResourceOwnerAccessRule({ property: 'creatorId' })
|
|
20
30
|
const json = rule.toJSON()
|
|
21
31
|
|
|
22
|
-
assert.equal(json.type, '
|
|
32
|
+
assert.equal(json.type, 'matchResourceOwner')
|
|
23
33
|
assert.equal(json.property, 'creatorId')
|
|
34
|
+
assert.equal(json.target, 'property')
|
|
35
|
+
}).tags(['@modeling', '@rule', '@match-resource-owner', '@serialization'])
|
|
36
|
+
|
|
37
|
+
test('toJSON omits property when undefined', ({ assert }) => {
|
|
38
|
+
const rule = new MatchResourceOwnerAccessRule({ target: 'user-entity' })
|
|
39
|
+
const json = rule.toJSON()
|
|
40
|
+
|
|
41
|
+
assert.equal(json.type, 'matchResourceOwner')
|
|
42
|
+
assert.isUndefined(json.property)
|
|
43
|
+
assert.equal(json.target, 'user-entity')
|
|
24
44
|
}).tags(['@modeling', '@rule', '@match-resource-owner', '@serialization'])
|
|
25
45
|
|
|
26
46
|
test('notifies change when property changes', async ({ assert }) => {
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { test } from '@japa/runner'
|
|
2
|
+
import { ApiModel, DataDomain, DomainEntity, ListAction } from '../../../../src/modeling/index.js'
|
|
3
|
+
import {
|
|
4
|
+
AllowAuthenticatedAccessRule,
|
|
5
|
+
AllowPublicAccessRule,
|
|
6
|
+
MatchEmailDomainAccessRule,
|
|
7
|
+
MatchResourceOwnerAccessRule,
|
|
8
|
+
MatchUserPropertyAccessRule,
|
|
9
|
+
MatchUserRoleAccessRule,
|
|
10
|
+
} from '../../../../src/modeling/index.js'
|
|
11
|
+
import { nanoid } from '../../../../src/nanoid.js'
|
|
12
|
+
import { ExposedEntityKind } from '../../../../src/models/kinds.js'
|
|
13
|
+
|
|
14
|
+
test.group('restoring actions', (group) => {
|
|
15
|
+
let domain: DataDomain
|
|
16
|
+
let entity: DomainEntity
|
|
17
|
+
|
|
18
|
+
group.each.setup(() => {
|
|
19
|
+
domain = new DataDomain()
|
|
20
|
+
const m1 = domain.addModel()
|
|
21
|
+
entity = m1.addEntity()
|
|
22
|
+
domain.info.version = '1.0.0'
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test('restores rules on the API model', ({ assert }) => {
|
|
26
|
+
const r1 = new AllowAuthenticatedAccessRule()
|
|
27
|
+
const r2 = new AllowPublicAccessRule()
|
|
28
|
+
const r3 = new MatchEmailDomainAccessRule()
|
|
29
|
+
const r4 = new MatchResourceOwnerAccessRule()
|
|
30
|
+
const r5 = new MatchUserPropertyAccessRule()
|
|
31
|
+
const r6 = new MatchUserRoleAccessRule()
|
|
32
|
+
const model = new ApiModel(
|
|
33
|
+
{
|
|
34
|
+
accessRule: [r1.toJSON(), r2.toJSON(), r3.toJSON(), r4.toJSON(), r5.toJSON(), r6.toJSON()],
|
|
35
|
+
},
|
|
36
|
+
domain
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
assert.lengthOf(model.accessRule, 6)
|
|
40
|
+
assert.instanceOf(model.accessRule[0], AllowAuthenticatedAccessRule)
|
|
41
|
+
assert.instanceOf(model.accessRule[1], AllowPublicAccessRule)
|
|
42
|
+
assert.instanceOf(model.accessRule[2], MatchEmailDomainAccessRule)
|
|
43
|
+
assert.instanceOf(model.accessRule[3], MatchResourceOwnerAccessRule)
|
|
44
|
+
assert.instanceOf(model.accessRule[4], MatchUserPropertyAccessRule)
|
|
45
|
+
assert.instanceOf(model.accessRule[5], MatchUserRoleAccessRule)
|
|
46
|
+
}).tags(['@modeling', '@rule', '@restoring'])
|
|
47
|
+
|
|
48
|
+
test('restores rules on the exposed entity', ({ assert }) => {
|
|
49
|
+
const r1 = new AllowAuthenticatedAccessRule()
|
|
50
|
+
const r2 = new AllowPublicAccessRule()
|
|
51
|
+
const r3 = new MatchEmailDomainAccessRule()
|
|
52
|
+
const r4 = new MatchResourceOwnerAccessRule()
|
|
53
|
+
const r5 = new MatchUserPropertyAccessRule()
|
|
54
|
+
const r6 = new MatchUserRoleAccessRule()
|
|
55
|
+
const model = new ApiModel(
|
|
56
|
+
{
|
|
57
|
+
exposes: [
|
|
58
|
+
{
|
|
59
|
+
kind: ExposedEntityKind,
|
|
60
|
+
key: nanoid(),
|
|
61
|
+
entity: { key: entity.key },
|
|
62
|
+
hasCollection: true,
|
|
63
|
+
collectionPath: '/things',
|
|
64
|
+
resourcePath: '/things/{id}',
|
|
65
|
+
isRoot: true,
|
|
66
|
+
actions: [],
|
|
67
|
+
accessRule: [r1.toJSON(), r2.toJSON(), r3.toJSON(), r4.toJSON(), r5.toJSON(), r6.toJSON()],
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
domain
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
const ex = model.exposes[0]!
|
|
75
|
+
assert.lengthOf(ex.accessRule!, 6)
|
|
76
|
+
assert.instanceOf(ex.accessRule![0], AllowAuthenticatedAccessRule)
|
|
77
|
+
assert.instanceOf(ex.accessRule![1], AllowPublicAccessRule)
|
|
78
|
+
assert.instanceOf(ex.accessRule![2], MatchEmailDomainAccessRule)
|
|
79
|
+
assert.instanceOf(ex.accessRule![3], MatchResourceOwnerAccessRule)
|
|
80
|
+
assert.instanceOf(ex.accessRule![4], MatchUserPropertyAccessRule)
|
|
81
|
+
assert.instanceOf(ex.accessRule![5], MatchUserRoleAccessRule)
|
|
82
|
+
}).tags(['@modeling', '@rule', '@restoring'])
|
|
83
|
+
|
|
84
|
+
test('restores rules on the action', ({ assert }) => {
|
|
85
|
+
const r1 = new AllowAuthenticatedAccessRule()
|
|
86
|
+
const r2 = new AllowPublicAccessRule()
|
|
87
|
+
const r3 = new MatchEmailDomainAccessRule()
|
|
88
|
+
const r4 = new MatchResourceOwnerAccessRule()
|
|
89
|
+
const r5 = new MatchUserPropertyAccessRule()
|
|
90
|
+
const r6 = new MatchUserRoleAccessRule()
|
|
91
|
+
const action = new ListAction({
|
|
92
|
+
accessRule: [r1.toJSON(), r2.toJSON(), r3.toJSON(), r4.toJSON(), r5.toJSON(), r6.toJSON()],
|
|
93
|
+
}).toJSON()
|
|
94
|
+
const model = new ApiModel(
|
|
95
|
+
{
|
|
96
|
+
exposes: [
|
|
97
|
+
{
|
|
98
|
+
kind: ExposedEntityKind,
|
|
99
|
+
key: nanoid(),
|
|
100
|
+
entity: { key: entity.key },
|
|
101
|
+
hasCollection: true,
|
|
102
|
+
collectionPath: '/things',
|
|
103
|
+
resourcePath: '/things/{id}',
|
|
104
|
+
isRoot: true,
|
|
105
|
+
actions: [action],
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
domain
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
const ex = model.exposes[0]!.actions[0]!
|
|
113
|
+
assert.lengthOf(ex.accessRule!, 6)
|
|
114
|
+
assert.instanceOf(ex.accessRule![0], AllowAuthenticatedAccessRule)
|
|
115
|
+
assert.instanceOf(ex.accessRule![1], AllowPublicAccessRule)
|
|
116
|
+
assert.instanceOf(ex.accessRule![2], MatchEmailDomainAccessRule)
|
|
117
|
+
assert.instanceOf(ex.accessRule![3], MatchResourceOwnerAccessRule)
|
|
118
|
+
assert.instanceOf(ex.accessRule![4], MatchUserPropertyAccessRule)
|
|
119
|
+
assert.instanceOf(ex.accessRule![5], MatchUserRoleAccessRule)
|
|
120
|
+
}).tags(['@modeling', '@rule', '@restoring'])
|
|
121
|
+
})
|