@api-client/core 0.18.60 → 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/rules/MatchResourceOwner.d.ts +13 -4
- package/build/src/modeling/rules/MatchResourceOwner.d.ts.map +1 -1
- package/build/src/modeling/rules/MatchResourceOwner.js +17 -4
- package/build/src/modeling/rules/MatchResourceOwner.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/rules/MatchResourceOwner.ts +22 -7
- package/tests/unit/modeling/rules/MatchResourceOwner.spec.ts +21 -1
|
@@ -42071,10 +42071,10 @@
|
|
|
42071
42071
|
"@id": "#197"
|
|
42072
42072
|
},
|
|
42073
42073
|
{
|
|
42074
|
-
"@id": "#
|
|
42074
|
+
"@id": "#200"
|
|
42075
42075
|
},
|
|
42076
42076
|
{
|
|
42077
|
-
"@id": "#
|
|
42077
|
+
"@id": "#203"
|
|
42078
42078
|
},
|
|
42079
42079
|
{
|
|
42080
42080
|
"@id": "#206"
|
|
@@ -42810,10 +42810,10 @@
|
|
|
42810
42810
|
"@id": "#219"
|
|
42811
42811
|
},
|
|
42812
42812
|
{
|
|
42813
|
-
"@id": "#
|
|
42813
|
+
"@id": "#219"
|
|
42814
42814
|
},
|
|
42815
42815
|
{
|
|
42816
|
-
"@id": "#
|
|
42816
|
+
"@id": "#210"
|
|
42817
42817
|
},
|
|
42818
42818
|
{
|
|
42819
42819
|
"@id": "#213"
|
|
@@ -43499,7 +43499,7 @@
|
|
|
43499
43499
|
"doc:ExternalDomainElement",
|
|
43500
43500
|
"doc:DomainElement"
|
|
43501
43501
|
],
|
|
43502
|
-
"doc:raw": "
|
|
43502
|
+
"doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
|
|
43503
43503
|
"core:mediaType": "application/yaml",
|
|
43504
43504
|
"sourcemaps:sources": [
|
|
43505
43505
|
{
|
|
@@ -43520,7 +43520,7 @@
|
|
|
43520
43520
|
"doc:ExternalDomainElement",
|
|
43521
43521
|
"doc:DomainElement"
|
|
43522
43522
|
],
|
|
43523
|
-
"doc:raw": "
|
|
43523
|
+
"doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
|
|
43524
43524
|
"core:mediaType": "application/yaml",
|
|
43525
43525
|
"sourcemaps:sources": [
|
|
43526
43526
|
{
|
|
@@ -44232,7 +44232,7 @@
|
|
|
44232
44232
|
"doc:ExternalDomainElement",
|
|
44233
44233
|
"doc:DomainElement"
|
|
44234
44234
|
],
|
|
44235
|
-
"doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '
|
|
44235
|
+
"doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\n",
|
|
44236
44236
|
"core:mediaType": "application/yaml",
|
|
44237
44237
|
"sourcemaps:sources": [
|
|
44238
44238
|
{
|
|
@@ -44295,7 +44295,7 @@
|
|
|
44295
44295
|
"doc:ExternalDomainElement",
|
|
44296
44296
|
"doc:DomainElement"
|
|
44297
44297
|
],
|
|
44298
|
-
"doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '
|
|
44298
|
+
"doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '22'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)22 000000'\n",
|
|
44299
44299
|
"core:mediaType": "application/yaml",
|
|
44300
44300
|
"sourcemaps:sources": [
|
|
44301
44301
|
{
|
|
@@ -44771,12 +44771,12 @@
|
|
|
44771
44771
|
{
|
|
44772
44772
|
"@id": "#202/source-map/lexical/element_0",
|
|
44773
44773
|
"sourcemaps:element": "amf://id#202",
|
|
44774
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44774
|
+
"sourcemaps:value": "[(1,0)-(5,0)]"
|
|
44775
44775
|
},
|
|
44776
44776
|
{
|
|
44777
44777
|
"@id": "#205/source-map/lexical/element_0",
|
|
44778
44778
|
"sourcemaps:element": "amf://id#205",
|
|
44779
|
-
"sourcemaps:value": "[(1,0)-(
|
|
44779
|
+
"sourcemaps:value": "[(1,0)-(3,0)]"
|
|
44780
44780
|
},
|
|
44781
44781
|
{
|
|
44782
44782
|
"@id": "#208/source-map/lexical/element_0",
|
package/package.json
CHANGED
|
@@ -9,13 +9,22 @@ import { observed } from '../../decorators/observed.js'
|
|
|
9
9
|
export interface MatchResourceOwnerAccessRuleSchema extends AccessRuleSchema {
|
|
10
10
|
type: 'matchResourceOwner'
|
|
11
11
|
/**
|
|
12
|
-
* The property on the resource that
|
|
13
|
-
*
|
|
12
|
+
* The property on the resource that references the user's ID (the key in the semantically annotated `User` entity).
|
|
13
|
+
*
|
|
14
|
+
* When the current exposed entity has a property annotated with the "ResourceOwnerIdentifier" semantic,
|
|
15
|
+
* this property should be used. It directly references the user's key.
|
|
14
16
|
*
|
|
15
17
|
* The domain model should annotate this property with the "ResourceOwnerIdentifier" semantic
|
|
16
18
|
* to indicate that it is used for ownership checks.
|
|
17
19
|
*/
|
|
18
|
-
property
|
|
20
|
+
property?: string
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The target for the ownership check.
|
|
24
|
+
* - `property`: The check is performed against a specific property on the resource (default).
|
|
25
|
+
* - `user-entity`: The check is performed against the entity itself (used when the entity represents the user).
|
|
26
|
+
*/
|
|
27
|
+
target?: 'property' | 'user-entity'
|
|
19
28
|
}
|
|
20
29
|
|
|
21
30
|
/**
|
|
@@ -26,18 +35,24 @@ export interface MatchResourceOwnerAccessRuleSchema extends AccessRuleSchema {
|
|
|
26
35
|
export class MatchResourceOwnerAccessRule extends AccessRule implements MatchResourceOwnerAccessRuleSchema {
|
|
27
36
|
override readonly type: 'matchResourceOwner'
|
|
28
37
|
|
|
29
|
-
@observed() accessor property: string
|
|
38
|
+
@observed() accessor property: string | undefined
|
|
39
|
+
@observed() accessor target: 'property' | 'user-entity'
|
|
30
40
|
|
|
31
41
|
constructor(state: Partial<MatchResourceOwnerAccessRuleSchema> = {}) {
|
|
32
42
|
super(state)
|
|
33
43
|
this.type = 'matchResourceOwner'
|
|
34
|
-
this.property = state.property
|
|
44
|
+
this.property = state.property
|
|
45
|
+
this.target = state.target ?? 'property'
|
|
35
46
|
}
|
|
36
47
|
|
|
37
48
|
override toJSON(): MatchResourceOwnerAccessRuleSchema {
|
|
38
|
-
|
|
49
|
+
const json: MatchResourceOwnerAccessRuleSchema = {
|
|
39
50
|
...(super.toJSON() as MatchResourceOwnerAccessRuleSchema),
|
|
40
|
-
|
|
51
|
+
target: this.target,
|
|
52
|
+
}
|
|
53
|
+
if (this.property) {
|
|
54
|
+
json.property = this.property
|
|
41
55
|
}
|
|
56
|
+
return json
|
|
42
57
|
}
|
|
43
58
|
}
|
|
@@ -5,7 +5,8 @@ test.group('MatchResourceOwnerAccessRule', () => {
|
|
|
5
5
|
test('initializes with default values', ({ assert }) => {
|
|
6
6
|
const rule = new MatchResourceOwnerAccessRule()
|
|
7
7
|
assert.equal(rule.type, 'matchResourceOwner')
|
|
8
|
-
assert.
|
|
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 }) => {
|
|
@@ -13,6 +14,15 @@ test.group('MatchResourceOwnerAccessRule', () => {
|
|
|
13
14
|
|
|
14
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 }) => {
|
|
@@ -21,6 +31,16 @@ test.group('MatchResourceOwnerAccessRule', () => {
|
|
|
21
31
|
|
|
22
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 }) => {
|