@twin.org/rights-management-service 0.0.1-next.7 → 0.0.1
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/cjs/index.cjs +105 -37
- package/dist/esm/index.mjs +105 -38
- package/dist/types/rightsManagementRoutes.d.ts +11 -3
- package/dist/types/rightsManagementService.d.ts +9 -3
- package/docs/changelog.md +100 -0
- package/docs/open-api/spec.json +171 -3466
- package/docs/reference/classes/RightsManagementService.md +33 -7
- package/docs/reference/functions/{papStore.md → papCreate.md} +4 -4
- package/docs/reference/functions/papUpdate.md +31 -0
- package/docs/reference/index.md +2 -1
- package/locales/en.json +6 -4
- package/package.json +9 -9
package/dist/cjs/index.cjs
CHANGED
|
@@ -27,31 +27,28 @@ const tags = [
|
|
|
27
27
|
* @returns The generated routes.
|
|
28
28
|
*/
|
|
29
29
|
function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
30
|
-
const
|
|
31
|
-
operationId: "
|
|
32
|
-
summary: "
|
|
30
|
+
const createRoute = {
|
|
31
|
+
operationId: "papCreate",
|
|
32
|
+
summary: "Create a policy",
|
|
33
33
|
tag: tags[0].name,
|
|
34
34
|
method: "POST",
|
|
35
35
|
path: `${baseRouteName}/pap/`,
|
|
36
|
-
handler: async (httpRequestContext, request) =>
|
|
36
|
+
handler: async (httpRequestContext, request) => papCreate(httpRequestContext, componentName, request),
|
|
37
37
|
requestType: {
|
|
38
|
-
type: "
|
|
38
|
+
type: "IPapCreateRequest",
|
|
39
39
|
examples: [
|
|
40
40
|
{
|
|
41
|
-
id: "
|
|
41
|
+
id: "papCreateExample",
|
|
42
42
|
request: {
|
|
43
43
|
body: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
}
|
|
44
|
+
"@context": standardsW3cOdrl.OdrlContexts.ContextRoot,
|
|
45
|
+
"@type": "Set",
|
|
46
|
+
permission: [
|
|
47
|
+
{
|
|
48
|
+
target: "http://example.com/asset/1",
|
|
49
|
+
action: "use"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
}
|
|
@@ -62,11 +59,11 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
62
59
|
type: "ICreatedResponse",
|
|
63
60
|
examples: [
|
|
64
61
|
{
|
|
65
|
-
id: "
|
|
62
|
+
id: "papCreateResponseExample",
|
|
66
63
|
response: {
|
|
67
|
-
statusCode:
|
|
64
|
+
statusCode: 201,
|
|
68
65
|
headers: {
|
|
69
|
-
|
|
66
|
+
location: "urn:rights-management:abc123def456"
|
|
70
67
|
}
|
|
71
68
|
}
|
|
72
69
|
}
|
|
@@ -74,6 +71,43 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
74
71
|
}
|
|
75
72
|
]
|
|
76
73
|
};
|
|
74
|
+
const updateRoute = {
|
|
75
|
+
operationId: "papUpdate",
|
|
76
|
+
summary: "Update a policy",
|
|
77
|
+
tag: tags[0].name,
|
|
78
|
+
method: "PUT",
|
|
79
|
+
path: `${baseRouteName}/pap/:id`,
|
|
80
|
+
handler: async (httpRequestContext, request) => papUpdate(httpRequestContext, componentName, request),
|
|
81
|
+
requestType: {
|
|
82
|
+
type: "IPapUpdateRequest",
|
|
83
|
+
examples: [
|
|
84
|
+
{
|
|
85
|
+
id: "papUpdateExample",
|
|
86
|
+
request: {
|
|
87
|
+
pathParams: {
|
|
88
|
+
id: "urn:rights-management:abc123def456"
|
|
89
|
+
},
|
|
90
|
+
body: {
|
|
91
|
+
"@context": standardsW3cOdrl.OdrlContexts.ContextRoot,
|
|
92
|
+
"@type": "Set",
|
|
93
|
+
uid: "urn:rights-management:abc123def456",
|
|
94
|
+
permission: [
|
|
95
|
+
{
|
|
96
|
+
target: "http://example.com/asset/2",
|
|
97
|
+
action: "read"
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
responseType: [
|
|
106
|
+
{
|
|
107
|
+
type: "INoContentResponse"
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
};
|
|
77
111
|
const retrieveRoute = {
|
|
78
112
|
operationId: "papRetrieve",
|
|
79
113
|
summary: "Retrieve a policy",
|
|
@@ -88,7 +122,7 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
88
122
|
id: "papRetrieveExample",
|
|
89
123
|
request: {
|
|
90
124
|
pathParams: {
|
|
91
|
-
id: "
|
|
125
|
+
id: "urn:rights-management:abc123def456"
|
|
92
126
|
}
|
|
93
127
|
}
|
|
94
128
|
}
|
|
@@ -104,7 +138,7 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
104
138
|
body: {
|
|
105
139
|
"@context": standardsW3cOdrl.OdrlContexts.ContextRoot,
|
|
106
140
|
"@type": "Set",
|
|
107
|
-
uid: "
|
|
141
|
+
uid: "urn:rights-management:abc123def456",
|
|
108
142
|
permission: [
|
|
109
143
|
{
|
|
110
144
|
target: "http://example.com/asset/1",
|
|
@@ -132,7 +166,7 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
132
166
|
id: "papRemoveExample",
|
|
133
167
|
request: {
|
|
134
168
|
pathParams: {
|
|
135
|
-
id: "
|
|
169
|
+
id: "urn:rights-management:abc123def456"
|
|
136
170
|
}
|
|
137
171
|
}
|
|
138
172
|
}
|
|
@@ -177,7 +211,7 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
177
211
|
{
|
|
178
212
|
"@context": standardsW3cOdrl.OdrlContexts.ContextRoot,
|
|
179
213
|
"@type": "Set",
|
|
180
|
-
uid: "
|
|
214
|
+
uid: "urn:rights-management:abc123def456",
|
|
181
215
|
permission: [
|
|
182
216
|
{
|
|
183
217
|
target: "http://example.com/asset/1",
|
|
@@ -193,30 +227,48 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
193
227
|
}
|
|
194
228
|
]
|
|
195
229
|
};
|
|
196
|
-
return [
|
|
230
|
+
return [createRoute, updateRoute, retrieveRoute, removeRoute, queryRoute];
|
|
197
231
|
}
|
|
198
232
|
/**
|
|
199
|
-
* PAP:
|
|
233
|
+
* PAP: Create a policy.
|
|
200
234
|
* @param httpRequestContext The request context for the API.
|
|
201
235
|
* @param componentName The name of the component to use in the routes.
|
|
202
236
|
* @param request The request.
|
|
203
237
|
* @returns The response object with additional http response properties.
|
|
204
238
|
*/
|
|
205
|
-
async function
|
|
239
|
+
async function papCreate(httpRequestContext, componentName, request) {
|
|
206
240
|
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
207
241
|
core.Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
208
|
-
core.Guards.object(ROUTES_SOURCE, "request.body.policy", request.body.policy);
|
|
209
242
|
core.Guards.stringValue(ROUTES_SOURCE, "httpRequestContext.nodeIdentity", httpRequestContext.nodeIdentity);
|
|
210
243
|
const component = core.ComponentFactory.get(componentName);
|
|
211
|
-
const policy = request.body
|
|
212
|
-
await component.
|
|
244
|
+
const policy = request.body;
|
|
245
|
+
const uid = await component.papCreate(policy);
|
|
213
246
|
return {
|
|
214
247
|
statusCode: web.HttpStatusCode.created,
|
|
215
248
|
headers: {
|
|
216
|
-
|
|
249
|
+
location: uid
|
|
217
250
|
}
|
|
218
251
|
};
|
|
219
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* PAP: Update a policy.
|
|
255
|
+
* @param httpRequestContext The request context for the API.
|
|
256
|
+
* @param componentName The name of the component to use in the routes.
|
|
257
|
+
* @param request The request.
|
|
258
|
+
* @returns The response object with additional http response properties.
|
|
259
|
+
*/
|
|
260
|
+
async function papUpdate(httpRequestContext, componentName, request) {
|
|
261
|
+
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
262
|
+
core.Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
263
|
+
core.Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
264
|
+
core.Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
265
|
+
core.Guards.stringValue(ROUTES_SOURCE, "httpRequestContext.nodeIdentity", httpRequestContext.nodeIdentity);
|
|
266
|
+
const component = core.ComponentFactory.get(componentName);
|
|
267
|
+
await component.papUpdate(request.body);
|
|
268
|
+
return {
|
|
269
|
+
statusCode: web.HttpStatusCode.noContent
|
|
270
|
+
};
|
|
271
|
+
}
|
|
220
272
|
/**
|
|
221
273
|
* PAP: Retrieve a policy.
|
|
222
274
|
* @param httpRequestContext The request context for the API.
|
|
@@ -299,17 +351,32 @@ class RightsManagementService {
|
|
|
299
351
|
this._papComponent = core.ComponentFactory.get(options?.papComponentType ?? "pap");
|
|
300
352
|
}
|
|
301
353
|
/**
|
|
302
|
-
* PAP:
|
|
303
|
-
* @param policy The policy to
|
|
354
|
+
* PAP: Create a new policy with auto-generated UID.
|
|
355
|
+
* @param policy The policy to create (uid will be auto-generated).
|
|
356
|
+
* @returns The UID of the created policy.
|
|
357
|
+
*/
|
|
358
|
+
async papCreate(policy) {
|
|
359
|
+
try {
|
|
360
|
+
core.Guards.object(this.CLASS_NAME, "policy", policy);
|
|
361
|
+
const result = await this._papComponent.create(policy);
|
|
362
|
+
return result;
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
throw new core.GeneralError(this.CLASS_NAME, "papCreateFailed", undefined, error);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* PAP: Update an existing policy.
|
|
370
|
+
* @param policy The policy to update (must include uid).
|
|
304
371
|
* @returns Nothing.
|
|
305
372
|
*/
|
|
306
|
-
async
|
|
373
|
+
async papUpdate(policy) {
|
|
307
374
|
try {
|
|
308
375
|
core.Guards.object(this.CLASS_NAME, "policy", policy);
|
|
309
|
-
await this._papComponent.
|
|
376
|
+
await this._papComponent.update(policy);
|
|
310
377
|
}
|
|
311
378
|
catch (error) {
|
|
312
|
-
throw new core.GeneralError(this.CLASS_NAME, "
|
|
379
|
+
throw new core.GeneralError(this.CLASS_NAME, "papUpdateFailed", undefined, error);
|
|
313
380
|
}
|
|
314
381
|
}
|
|
315
382
|
/**
|
|
@@ -382,9 +449,10 @@ const restEntryPoints = [
|
|
|
382
449
|
|
|
383
450
|
exports.RightsManagementService = RightsManagementService;
|
|
384
451
|
exports.generateRestRoutesRightsManagement = generateRestRoutesRightsManagement;
|
|
452
|
+
exports.papCreate = papCreate;
|
|
385
453
|
exports.papQuery = papQuery;
|
|
386
454
|
exports.papRemove = papRemove;
|
|
387
455
|
exports.papRetrieve = papRetrieve;
|
|
388
|
-
exports.
|
|
456
|
+
exports.papUpdate = papUpdate;
|
|
389
457
|
exports.restEntryPoints = restEntryPoints;
|
|
390
458
|
exports.tags = tags;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HttpParameterHelper } from '@twin.org/api-models';
|
|
2
2
|
import { Guards, ComponentFactory, Coerce, GeneralError, Is } from '@twin.org/core';
|
|
3
3
|
import { OdrlContexts } from '@twin.org/standards-w3c-odrl';
|
|
4
|
-
import { HttpStatusCode
|
|
4
|
+
import { HttpStatusCode } from '@twin.org/web';
|
|
5
5
|
|
|
6
6
|
// Copyright 2024 IOTA Stiftung.
|
|
7
7
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -25,31 +25,28 @@ const tags = [
|
|
|
25
25
|
* @returns The generated routes.
|
|
26
26
|
*/
|
|
27
27
|
function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
28
|
-
const
|
|
29
|
-
operationId: "
|
|
30
|
-
summary: "
|
|
28
|
+
const createRoute = {
|
|
29
|
+
operationId: "papCreate",
|
|
30
|
+
summary: "Create a policy",
|
|
31
31
|
tag: tags[0].name,
|
|
32
32
|
method: "POST",
|
|
33
33
|
path: `${baseRouteName}/pap/`,
|
|
34
|
-
handler: async (httpRequestContext, request) =>
|
|
34
|
+
handler: async (httpRequestContext, request) => papCreate(httpRequestContext, componentName, request),
|
|
35
35
|
requestType: {
|
|
36
|
-
type: "
|
|
36
|
+
type: "IPapCreateRequest",
|
|
37
37
|
examples: [
|
|
38
38
|
{
|
|
39
|
-
id: "
|
|
39
|
+
id: "papCreateExample",
|
|
40
40
|
request: {
|
|
41
41
|
body: {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
}
|
|
42
|
+
"@context": OdrlContexts.ContextRoot,
|
|
43
|
+
"@type": "Set",
|
|
44
|
+
permission: [
|
|
45
|
+
{
|
|
46
|
+
target: "http://example.com/asset/1",
|
|
47
|
+
action: "use"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
52
|
}
|
|
@@ -60,11 +57,11 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
60
57
|
type: "ICreatedResponse",
|
|
61
58
|
examples: [
|
|
62
59
|
{
|
|
63
|
-
id: "
|
|
60
|
+
id: "papCreateResponseExample",
|
|
64
61
|
response: {
|
|
65
|
-
statusCode:
|
|
62
|
+
statusCode: 201,
|
|
66
63
|
headers: {
|
|
67
|
-
|
|
64
|
+
location: "urn:rights-management:abc123def456"
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
67
|
}
|
|
@@ -72,6 +69,43 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
72
69
|
}
|
|
73
70
|
]
|
|
74
71
|
};
|
|
72
|
+
const updateRoute = {
|
|
73
|
+
operationId: "papUpdate",
|
|
74
|
+
summary: "Update a policy",
|
|
75
|
+
tag: tags[0].name,
|
|
76
|
+
method: "PUT",
|
|
77
|
+
path: `${baseRouteName}/pap/:id`,
|
|
78
|
+
handler: async (httpRequestContext, request) => papUpdate(httpRequestContext, componentName, request),
|
|
79
|
+
requestType: {
|
|
80
|
+
type: "IPapUpdateRequest",
|
|
81
|
+
examples: [
|
|
82
|
+
{
|
|
83
|
+
id: "papUpdateExample",
|
|
84
|
+
request: {
|
|
85
|
+
pathParams: {
|
|
86
|
+
id: "urn:rights-management:abc123def456"
|
|
87
|
+
},
|
|
88
|
+
body: {
|
|
89
|
+
"@context": OdrlContexts.ContextRoot,
|
|
90
|
+
"@type": "Set",
|
|
91
|
+
uid: "urn:rights-management:abc123def456",
|
|
92
|
+
permission: [
|
|
93
|
+
{
|
|
94
|
+
target: "http://example.com/asset/2",
|
|
95
|
+
action: "read"
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
responseType: [
|
|
104
|
+
{
|
|
105
|
+
type: "INoContentResponse"
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
};
|
|
75
109
|
const retrieveRoute = {
|
|
76
110
|
operationId: "papRetrieve",
|
|
77
111
|
summary: "Retrieve a policy",
|
|
@@ -86,7 +120,7 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
86
120
|
id: "papRetrieveExample",
|
|
87
121
|
request: {
|
|
88
122
|
pathParams: {
|
|
89
|
-
id: "
|
|
123
|
+
id: "urn:rights-management:abc123def456"
|
|
90
124
|
}
|
|
91
125
|
}
|
|
92
126
|
}
|
|
@@ -102,7 +136,7 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
102
136
|
body: {
|
|
103
137
|
"@context": OdrlContexts.ContextRoot,
|
|
104
138
|
"@type": "Set",
|
|
105
|
-
uid: "
|
|
139
|
+
uid: "urn:rights-management:abc123def456",
|
|
106
140
|
permission: [
|
|
107
141
|
{
|
|
108
142
|
target: "http://example.com/asset/1",
|
|
@@ -130,7 +164,7 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
130
164
|
id: "papRemoveExample",
|
|
131
165
|
request: {
|
|
132
166
|
pathParams: {
|
|
133
|
-
id: "
|
|
167
|
+
id: "urn:rights-management:abc123def456"
|
|
134
168
|
}
|
|
135
169
|
}
|
|
136
170
|
}
|
|
@@ -175,7 +209,7 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
175
209
|
{
|
|
176
210
|
"@context": OdrlContexts.ContextRoot,
|
|
177
211
|
"@type": "Set",
|
|
178
|
-
uid: "
|
|
212
|
+
uid: "urn:rights-management:abc123def456",
|
|
179
213
|
permission: [
|
|
180
214
|
{
|
|
181
215
|
target: "http://example.com/asset/1",
|
|
@@ -191,30 +225,48 @@ function generateRestRoutesRightsManagement(baseRouteName, componentName) {
|
|
|
191
225
|
}
|
|
192
226
|
]
|
|
193
227
|
};
|
|
194
|
-
return [
|
|
228
|
+
return [createRoute, updateRoute, retrieveRoute, removeRoute, queryRoute];
|
|
195
229
|
}
|
|
196
230
|
/**
|
|
197
|
-
* PAP:
|
|
231
|
+
* PAP: Create a policy.
|
|
198
232
|
* @param httpRequestContext The request context for the API.
|
|
199
233
|
* @param componentName The name of the component to use in the routes.
|
|
200
234
|
* @param request The request.
|
|
201
235
|
* @returns The response object with additional http response properties.
|
|
202
236
|
*/
|
|
203
|
-
async function
|
|
237
|
+
async function papCreate(httpRequestContext, componentName, request) {
|
|
204
238
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
205
239
|
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
206
|
-
Guards.object(ROUTES_SOURCE, "request.body.policy", request.body.policy);
|
|
207
240
|
Guards.stringValue(ROUTES_SOURCE, "httpRequestContext.nodeIdentity", httpRequestContext.nodeIdentity);
|
|
208
241
|
const component = ComponentFactory.get(componentName);
|
|
209
|
-
const policy = request.body
|
|
210
|
-
await component.
|
|
242
|
+
const policy = request.body;
|
|
243
|
+
const uid = await component.papCreate(policy);
|
|
211
244
|
return {
|
|
212
245
|
statusCode: HttpStatusCode.created,
|
|
213
246
|
headers: {
|
|
214
|
-
|
|
247
|
+
location: uid
|
|
215
248
|
}
|
|
216
249
|
};
|
|
217
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* PAP: Update a policy.
|
|
253
|
+
* @param httpRequestContext The request context for the API.
|
|
254
|
+
* @param componentName The name of the component to use in the routes.
|
|
255
|
+
* @param request The request.
|
|
256
|
+
* @returns The response object with additional http response properties.
|
|
257
|
+
*/
|
|
258
|
+
async function papUpdate(httpRequestContext, componentName, request) {
|
|
259
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
260
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
261
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
262
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
263
|
+
Guards.stringValue(ROUTES_SOURCE, "httpRequestContext.nodeIdentity", httpRequestContext.nodeIdentity);
|
|
264
|
+
const component = ComponentFactory.get(componentName);
|
|
265
|
+
await component.papUpdate(request.body);
|
|
266
|
+
return {
|
|
267
|
+
statusCode: HttpStatusCode.noContent
|
|
268
|
+
};
|
|
269
|
+
}
|
|
218
270
|
/**
|
|
219
271
|
* PAP: Retrieve a policy.
|
|
220
272
|
* @param httpRequestContext The request context for the API.
|
|
@@ -297,17 +349,32 @@ class RightsManagementService {
|
|
|
297
349
|
this._papComponent = ComponentFactory.get(options?.papComponentType ?? "pap");
|
|
298
350
|
}
|
|
299
351
|
/**
|
|
300
|
-
* PAP:
|
|
301
|
-
* @param policy The policy to
|
|
352
|
+
* PAP: Create a new policy with auto-generated UID.
|
|
353
|
+
* @param policy The policy to create (uid will be auto-generated).
|
|
354
|
+
* @returns The UID of the created policy.
|
|
355
|
+
*/
|
|
356
|
+
async papCreate(policy) {
|
|
357
|
+
try {
|
|
358
|
+
Guards.object(this.CLASS_NAME, "policy", policy);
|
|
359
|
+
const result = await this._papComponent.create(policy);
|
|
360
|
+
return result;
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
throw new GeneralError(this.CLASS_NAME, "papCreateFailed", undefined, error);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* PAP: Update an existing policy.
|
|
368
|
+
* @param policy The policy to update (must include uid).
|
|
302
369
|
* @returns Nothing.
|
|
303
370
|
*/
|
|
304
|
-
async
|
|
371
|
+
async papUpdate(policy) {
|
|
305
372
|
try {
|
|
306
373
|
Guards.object(this.CLASS_NAME, "policy", policy);
|
|
307
|
-
await this._papComponent.
|
|
374
|
+
await this._papComponent.update(policy);
|
|
308
375
|
}
|
|
309
376
|
catch (error) {
|
|
310
|
-
throw new GeneralError(this.CLASS_NAME, "
|
|
377
|
+
throw new GeneralError(this.CLASS_NAME, "papUpdateFailed", undefined, error);
|
|
311
378
|
}
|
|
312
379
|
}
|
|
313
380
|
/**
|
|
@@ -378,4 +445,4 @@ const restEntryPoints = [
|
|
|
378
445
|
}
|
|
379
446
|
];
|
|
380
447
|
|
|
381
|
-
export { RightsManagementService, generateRestRoutesRightsManagement, papQuery, papRemove, papRetrieve,
|
|
448
|
+
export { RightsManagementService, generateRestRoutesRightsManagement, papCreate, papQuery, papRemove, papRetrieve, papUpdate, restEntryPoints, tags };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ICreatedResponse, type IHttpRequestContext, type INoContentResponse, type IRestRoute, type ITag } from "@twin.org/api-models";
|
|
2
|
-
import type { IPapQueryRequest, IPapQueryResponse, IPapRemoveRequest, IPapRetrieveRequest, IPapRetrieveResponse,
|
|
2
|
+
import type { IPapCreateRequest, IPapQueryRequest, IPapQueryResponse, IPapRemoveRequest, IPapRetrieveRequest, IPapRetrieveResponse, IPapUpdateRequest } from "@twin.org/rights-management-models";
|
|
3
3
|
/**
|
|
4
4
|
* The tag to associate with the routes.
|
|
5
5
|
*/
|
|
@@ -12,13 +12,21 @@ export declare const tags: ITag[];
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function generateRestRoutesRightsManagement(baseRouteName: string, componentName: string): IRestRoute[];
|
|
14
14
|
/**
|
|
15
|
-
* PAP:
|
|
15
|
+
* PAP: Create a policy.
|
|
16
16
|
* @param httpRequestContext The request context for the API.
|
|
17
17
|
* @param componentName The name of the component to use in the routes.
|
|
18
18
|
* @param request The request.
|
|
19
19
|
* @returns The response object with additional http response properties.
|
|
20
20
|
*/
|
|
21
|
-
export declare function
|
|
21
|
+
export declare function papCreate(httpRequestContext: IHttpRequestContext, componentName: string, request: IPapCreateRequest): Promise<ICreatedResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* PAP: Update a policy.
|
|
24
|
+
* @param httpRequestContext The request context for the API.
|
|
25
|
+
* @param componentName The name of the component to use in the routes.
|
|
26
|
+
* @param request The request.
|
|
27
|
+
* @returns The response object with additional http response properties.
|
|
28
|
+
*/
|
|
29
|
+
export declare function papUpdate(httpRequestContext: IHttpRequestContext, componentName: string, request: IPapUpdateRequest): Promise<INoContentResponse>;
|
|
22
30
|
/**
|
|
23
31
|
* PAP: Retrieve a policy.
|
|
24
32
|
* @param httpRequestContext The request context for the API.
|
|
@@ -21,11 +21,17 @@ export declare class RightsManagementService implements IRightsManagementCompone
|
|
|
21
21
|
*/
|
|
22
22
|
constructor(options?: IRightsManagementServiceConstructorOptions);
|
|
23
23
|
/**
|
|
24
|
-
* PAP:
|
|
25
|
-
* @param policy The policy to
|
|
24
|
+
* PAP: Create a new policy with auto-generated UID.
|
|
25
|
+
* @param policy The policy to create (uid will be auto-generated).
|
|
26
|
+
* @returns The UID of the created policy.
|
|
27
|
+
*/
|
|
28
|
+
papCreate(policy: Omit<IOdrlPolicy, "uid">): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* PAP: Update an existing policy.
|
|
31
|
+
* @param policy The policy to update (must include uid).
|
|
26
32
|
* @returns Nothing.
|
|
27
33
|
*/
|
|
28
|
-
|
|
34
|
+
papUpdate(policy: IOdrlPolicy): Promise<void>;
|
|
29
35
|
/**
|
|
30
36
|
* PAP: Retrieve a policy.
|
|
31
37
|
* @param policyId The id of the policy to retrieve.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,105 @@
|
|
|
1
1
|
# @twin.org/rights-management-pap-service - Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.1 (2025-07-08)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* release to production ([947f85a](https://github.com/twinfoundation/rights-management/commit/947f85ab9e23c117135dba7008a75c2d85435259))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/rights-management-models bumped from ^0.0.0 to ^0.0.1
|
|
16
|
+
* @twin.org/rights-management-pap-service bumped from ^0.0.0 to ^0.0.1
|
|
17
|
+
|
|
18
|
+
## [0.0.1-next.12](https://github.com/twinfoundation/rights-management/compare/rights-management-service-v0.0.1-next.11...rights-management-service-v0.0.1-next.12) (2025-06-26)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Miscellaneous Chores
|
|
22
|
+
|
|
23
|
+
* **rights-management-service:** Synchronize repo versions
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Dependencies
|
|
27
|
+
|
|
28
|
+
* The following workspace dependencies were updated
|
|
29
|
+
* dependencies
|
|
30
|
+
* @twin.org/rights-management-models bumped from 0.0.1-next.11 to 0.0.1-next.12
|
|
31
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.1-next.11 to 0.0.1-next.12
|
|
32
|
+
|
|
33
|
+
## [0.0.1-next.11](https://github.com/twinfoundation/rights-management/compare/rights-management-service-v0.0.1-next.10...rights-management-service-v0.0.1-next.11) (2025-06-20)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* query params force coercion ([8590a0d](https://github.com/twinfoundation/rights-management/commit/8590a0da92584c04b67e73c448319f96f70c34a5))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Dependencies
|
|
42
|
+
|
|
43
|
+
* The following workspace dependencies were updated
|
|
44
|
+
* dependencies
|
|
45
|
+
* @twin.org/rights-management-models bumped from 0.0.1-next.10 to 0.0.1-next.11
|
|
46
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.1-next.10 to 0.0.1-next.11
|
|
47
|
+
|
|
48
|
+
## [0.0.1-next.10](https://github.com/twinfoundation/rights-management/compare/rights-management-service-v0.0.1-next.9...rights-management-service-v0.0.1-next.10) (2025-06-12)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Features
|
|
52
|
+
|
|
53
|
+
* update dependencies ([dd0a553](https://github.com/twinfoundation/rights-management/commit/dd0a553020b0dc5c41fb6865a2e36bd26045b0b9))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Dependencies
|
|
57
|
+
|
|
58
|
+
* The following workspace dependencies were updated
|
|
59
|
+
* dependencies
|
|
60
|
+
* @twin.org/rights-management-models bumped from 0.0.1-next.9 to 0.0.1-next.10
|
|
61
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.1-next.9 to 0.0.1-next.10
|
|
62
|
+
|
|
63
|
+
## [0.0.1-next.9](https://github.com/twinfoundation/rights-management/compare/rights-management-service-v0.0.1-next.8...rights-management-service-v0.0.1-next.9) (2025-06-06)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### Features
|
|
67
|
+
|
|
68
|
+
* pap create, update methods ([#13](https://github.com/twinfoundation/rights-management/issues/13)) ([edb6c9e](https://github.com/twinfoundation/rights-management/commit/edb6c9efcfda55ac96f7594253bf831b4f0e5993))
|
|
69
|
+
* remove unnecessary config options from service ([31ef3a2](https://github.com/twinfoundation/rights-management/commit/31ef3a2eb2293efdad7e6b8b55f105cc62bba3ed))
|
|
70
|
+
* rename pap entity storage to pap service ([38a2c14](https://github.com/twinfoundation/rights-management/commit/38a2c14d8f63a86e398820166c83437be5aca1b8))
|
|
71
|
+
* rights management pap ([#4](https://github.com/twinfoundation/rights-management/issues/4)) ([d1165a9](https://github.com/twinfoundation/rights-management/commit/d1165a92f57128731cfb308d977832e28cf33493))
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
### Bug Fixes
|
|
75
|
+
|
|
76
|
+
* adding missing dependency ([#15](https://github.com/twinfoundation/rights-management/issues/15)) ([c7e6267](https://github.com/twinfoundation/rights-management/commit/c7e62678b296ef8d28c31921cb78aeabe674cd84))
|
|
77
|
+
* modifying the function name for the rest routes ([#6](https://github.com/twinfoundation/rights-management/issues/6)) ([7915111](https://github.com/twinfoundation/rights-management/commit/7915111ac608c9d69bcaa819c85b553fc9bace6a))
|
|
78
|
+
* slimline openapi spec ([aacb9d5](https://github.com/twinfoundation/rights-management/commit/aacb9d50f80d3652ef7419ca3777f53e542773f1))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### Dependencies
|
|
82
|
+
|
|
83
|
+
* The following workspace dependencies were updated
|
|
84
|
+
* dependencies
|
|
85
|
+
* @twin.org/rights-management-models bumped from 0.0.1-next.8 to 0.0.1-next.9
|
|
86
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.1-next.8 to 0.0.1-next.9
|
|
87
|
+
|
|
88
|
+
## [0.0.1-next.8](https://github.com/twinfoundation/rights-management/compare/rights-management-service-v0.0.1-next.7...rights-management-service-v0.0.1-next.8) (2025-06-05)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
### Features
|
|
92
|
+
|
|
93
|
+
* pap create, update methods ([#13](https://github.com/twinfoundation/rights-management/issues/13)) ([edb6c9e](https://github.com/twinfoundation/rights-management/commit/edb6c9efcfda55ac96f7594253bf831b4f0e5993))
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
### Dependencies
|
|
97
|
+
|
|
98
|
+
* The following workspace dependencies were updated
|
|
99
|
+
* dependencies
|
|
100
|
+
* @twin.org/rights-management-models bumped from 0.0.1-next.7 to 0.0.1-next.8
|
|
101
|
+
* @twin.org/rights-management-pap-service bumped from 0.0.1-next.7 to 0.0.1-next.8
|
|
102
|
+
|
|
3
103
|
## [0.0.1-next.7](https://github.com/twinfoundation/rights-management/compare/rights-management-service-v0.0.1-next.6...rights-management-service-v0.0.1-next.7) (2025-06-02)
|
|
4
104
|
|
|
5
105
|
|