@twin.org/rights-management-service 0.0.3-next.9 → 0.9.0

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.
Files changed (30) hide show
  1. package/README.md +11 -3
  2. package/dist/es/index.js +0 -1
  3. package/dist/es/index.js.map +1 -1
  4. package/dist/es/policyAdministrationPointRoutes.js +254 -32
  5. package/dist/es/policyAdministrationPointRoutes.js.map +1 -1
  6. package/dist/es/policyNegotiationAdminPointRoutes.js +83 -20
  7. package/dist/es/policyNegotiationAdminPointRoutes.js.map +1 -1
  8. package/dist/es/policyNegotiationPointRoutes.js +40 -57
  9. package/dist/es/policyNegotiationPointRoutes.js.map +1 -1
  10. package/dist/es/restEntryPoints.js +0 -7
  11. package/dist/es/restEntryPoints.js.map +1 -1
  12. package/dist/types/index.d.ts +0 -1
  13. package/dist/types/policyAdministrationPointRoutes.d.ts +25 -1
  14. package/dist/types/policyNegotiationAdminPointRoutes.d.ts +10 -2
  15. package/dist/types/policyNegotiationPointRoutes.d.ts +1 -1
  16. package/docs/changelog.md +1594 -118
  17. package/docs/examples.md +47 -1
  18. package/docs/open-api/spec.json +789 -2929
  19. package/docs/reference/functions/{dapRemove.md → papGetAgreement.md} +5 -5
  20. package/docs/reference/functions/{dapQuery.md → papGetOffer.md} +5 -5
  21. package/docs/reference/functions/{dapGet.md → papGetSet.md} +5 -5
  22. package/docs/reference/functions/{dapCreate.md → pnapCreate.md} +4 -4
  23. package/docs/reference/index.md +4 -7
  24. package/package.json +15 -15
  25. package/dist/es/dataAccessPointRoutes.js +0 -353
  26. package/dist/es/dataAccessPointRoutes.js.map +0 -1
  27. package/dist/types/dataAccessPointRoutes.d.ts +0 -53
  28. package/docs/reference/functions/dapUpdate.md +0 -31
  29. package/docs/reference/functions/generateRestRoutesDataAccessPoint.md +0 -25
  30. package/docs/reference/variables/dapTags.md +0 -5
package/README.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # TWIN Rights Management Service
2
2
 
3
- Rights Management service implementation and REST endpoint definitions.
3
+ This package provides a unified rights management service exposing policy and negotiation capabilities. It is designed for deployments that want a consolidated service interface.
4
4
 
5
5
  ## Installation
6
6
 
7
- ```shell
7
+ `shell
8
8
  npm install @twin.org/rights-management-service
9
- ```
9
+ `
10
+
11
+ ## Testing
12
+
13
+ Run the package test suite with:
14
+
15
+ `shell
16
+ npm test
17
+ `
10
18
 
11
19
  ## Examples
12
20
 
package/dist/es/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  // Copyright 2025 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
- export * from "./dataAccessPointRoutes.js";
4
3
  export * from "./policyAdministrationPointRoutes.js";
5
4
  export * from "./policyNegotiationAdminPointRoutes.js";
6
5
  export * from "./policyNegotiationPointRoutes.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./dataAccessPointRoutes.js\";\nexport * from \"./policyAdministrationPointRoutes.js\";\nexport * from \"./policyNegotiationAdminPointRoutes.js\";\nexport * from \"./policyNegotiationPointRoutes.js\";\nexport * from \"./restEntryPoints.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./policyAdministrationPointRoutes.js\";\nexport * from \"./policyNegotiationAdminPointRoutes.js\";\nexport * from \"./policyNegotiationPointRoutes.js\";\nexport * from \"./restEntryPoints.js\";\n"]}
@@ -1,9 +1,11 @@
1
1
  // Copyright 2025 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
- import { HttpParameterHelper } from "@twin.org/api-models";
4
- import { Coerce, ComponentFactory, Guards } from "@twin.org/core";
5
- import { OdrlContexts } from "@twin.org/standards-w3c-odrl";
6
- import { HttpStatusCode } from "@twin.org/web";
3
+ import { HttpContextIdKeys, HttpParameterHelper, HttpUrlHelper } from "@twin.org/api-models";
4
+ import { ContextIdStore } from "@twin.org/context";
5
+ import { Coerce, ComponentFactory, Guards, Is } from "@twin.org/core";
6
+ import { POLICY_METADATA_CONTEXT } from "@twin.org/rights-management-models";
7
+ import { OdrlContexts, OdrlPolicyType } from "@twin.org/standards-w3c-odrl";
8
+ import { HeaderHelper, HeaderTypes, HttpStatusCode } from "@twin.org/web";
7
9
  /**
8
10
  * The source used when communicating about these routes.
9
11
  */
@@ -17,6 +19,14 @@ export const papTags = [
17
19
  description: "Endpoints for managing ODRL policies in the Policy Administration Point"
18
20
  }
19
21
  ];
22
+ /**
23
+ * Example JSON-LD context returned by PAP read endpoints for policies with metadata timestamps.
24
+ * Uses `POLICY_METADATA_CONTEXT` from rights-management-models merged with ODRL context.
25
+ */
26
+ const PAP_POLICY_RESPONSE_CONTEXT = [
27
+ OdrlContexts.Context,
28
+ POLICY_METADATA_CONTEXT
29
+ ];
20
30
  /**
21
31
  * The REST routes for the Policy Administration Point.
22
32
  * @param baseRouteName Prefix to prepend to the paths.
@@ -24,6 +34,10 @@ export const papTags = [
24
34
  * @returns The generated routes.
25
35
  */
26
36
  export function generateRestRoutesPolicyAdministrationPoint(baseRouteName, componentName) {
37
+ const papPolicyExampleLifecycle = {
38
+ dateCreated: "2025-09-03T00:00:00.000Z",
39
+ dateModified: "2025-09-03T00:00:00.000Z"
40
+ };
27
41
  const papCreateRoute = {
28
42
  operationId: "papCreate",
29
43
  summary: "Create a policy",
@@ -39,7 +53,7 @@ export function generateRestRoutesPolicyAdministrationPoint(baseRouteName, compo
39
53
  request: {
40
54
  body: {
41
55
  "@context": OdrlContexts.Context,
42
- "@type": "Set",
56
+ "@type": OdrlPolicyType.Set,
43
57
  permission: [
44
58
  {
45
59
  target: "http://example.com/asset/1",
@@ -86,8 +100,8 @@ export function generateRestRoutesPolicyAdministrationPoint(baseRouteName, compo
86
100
  },
87
101
  body: {
88
102
  "@context": OdrlContexts.Context,
89
- "@type": "Set",
90
- uid: "urn:rights-management:abc123def456",
103
+ "@type": OdrlPolicyType.Set,
104
+ "@id": "urn:rights-management:abc123def456",
91
105
  permission: [
92
106
  {
93
107
  target: "http://example.com/asset/2",
@@ -133,9 +147,10 @@ export function generateRestRoutesPolicyAdministrationPoint(baseRouteName, compo
133
147
  id: "papGetResponseExample",
134
148
  response: {
135
149
  body: {
136
- "@context": OdrlContexts.Context,
137
- "@type": "Set",
138
- uid: "urn:rights-management:abc123def456",
150
+ "@context": PAP_POLICY_RESPONSE_CONTEXT,
151
+ "@type": OdrlPolicyType.Set,
152
+ "@id": "urn:rights-management:abc123def456",
153
+ ...papPolicyExampleLifecycle,
139
154
  permission: [
140
155
  {
141
156
  target: "http://example.com/asset/1",
@@ -149,6 +164,147 @@ export function generateRestRoutesPolicyAdministrationPoint(baseRouteName, compo
149
164
  }
150
165
  ]
151
166
  };
167
+ const papGetAgreementRoute = {
168
+ operationId: "papGetAgreement",
169
+ summary: "Get a policy agreement",
170
+ tag: papTags[0].name,
171
+ method: "GET",
172
+ path: `${baseRouteName}/policy/admin/agreement/:id`,
173
+ handler: async (httpRequestContext, request) => papGetAgreement(httpRequestContext, componentName, request),
174
+ requestType: {
175
+ type: "IPapGetAgreementRequest",
176
+ examples: [
177
+ {
178
+ id: "papGetAgreementRequestExample",
179
+ request: {
180
+ pathParams: {
181
+ id: "urn:rights-management:abc123def456"
182
+ }
183
+ }
184
+ }
185
+ ]
186
+ },
187
+ responseType: [
188
+ {
189
+ type: "IPapGetAgreementResponse",
190
+ examples: [
191
+ {
192
+ id: "papGetResponseExample",
193
+ response: {
194
+ body: {
195
+ "@context": PAP_POLICY_RESPONSE_CONTEXT,
196
+ "@type": OdrlPolicyType.Agreement,
197
+ "@id": "urn:rights-management:abc123def456",
198
+ ...papPolicyExampleLifecycle,
199
+ permission: [
200
+ {
201
+ target: "http://example.com/asset/1",
202
+ action: "use"
203
+ }
204
+ ],
205
+ assignee: "did:example:receiver",
206
+ assigner: "did:example:sender"
207
+ }
208
+ }
209
+ }
210
+ ]
211
+ }
212
+ ]
213
+ };
214
+ const papGetOfferRoute = {
215
+ operationId: "papGetOffer",
216
+ summary: "Get a policy offer",
217
+ tag: papTags[0].name,
218
+ method: "GET",
219
+ path: `${baseRouteName}/policy/admin/offer/:id`,
220
+ handler: async (httpRequestContext, request) => papGetOffer(httpRequestContext, componentName, request),
221
+ requestType: {
222
+ type: "IPapGetOfferRequest",
223
+ examples: [
224
+ {
225
+ id: "papGetOfferRequestExample",
226
+ request: {
227
+ pathParams: {
228
+ id: "urn:rights-management:abc123def456"
229
+ }
230
+ }
231
+ }
232
+ ]
233
+ },
234
+ responseType: [
235
+ {
236
+ type: "IPapGetOfferResponse",
237
+ examples: [
238
+ {
239
+ id: "papGetResponseExample",
240
+ response: {
241
+ body: {
242
+ "@context": PAP_POLICY_RESPONSE_CONTEXT,
243
+ "@type": OdrlPolicyType.Offer,
244
+ "@id": "urn:rights-management:abc123def456",
245
+ ...papPolicyExampleLifecycle,
246
+ permission: [
247
+ {
248
+ target: "http://example.com/asset/1",
249
+ action: "use"
250
+ }
251
+ ],
252
+ assignee: "did:example:receiver",
253
+ assigner: "did:example:sender"
254
+ }
255
+ }
256
+ }
257
+ ]
258
+ }
259
+ ]
260
+ };
261
+ const papGetSetRoute = {
262
+ operationId: "papGetSet",
263
+ summary: "Get a policy set",
264
+ tag: papTags[0].name,
265
+ method: "GET",
266
+ path: `${baseRouteName}/policy/admin/set/:id`,
267
+ handler: async (httpRequestContext, request) => papGetSet(httpRequestContext, componentName, request),
268
+ requestType: {
269
+ type: "IPapGetSetRequest",
270
+ examples: [
271
+ {
272
+ id: "papGetSetRequestExample",
273
+ request: {
274
+ pathParams: {
275
+ id: "urn:rights-management:abc123def456"
276
+ }
277
+ }
278
+ }
279
+ ]
280
+ },
281
+ responseType: [
282
+ {
283
+ type: "IPapGetSetResponse",
284
+ examples: [
285
+ {
286
+ id: "papGetResponseExample",
287
+ response: {
288
+ body: {
289
+ "@context": PAP_POLICY_RESPONSE_CONTEXT,
290
+ "@type": OdrlPolicyType.Set,
291
+ "@id": "urn:rights-management:abc123def456",
292
+ ...papPolicyExampleLifecycle,
293
+ permission: [
294
+ {
295
+ target: "http://example.com/asset/1",
296
+ action: "use"
297
+ }
298
+ ],
299
+ assignee: "did:example:receiver",
300
+ assigner: "did:example:sender"
301
+ }
302
+ }
303
+ }
304
+ ]
305
+ }
306
+ ]
307
+ };
152
308
  const papRemoveRoute = {
153
309
  operationId: "papRemove",
154
310
  summary: "Remove a policy",
@@ -202,29 +358,36 @@ export function generateRestRoutesPolicyAdministrationPoint(baseRouteName, compo
202
358
  {
203
359
  id: "papQueryResponseExample",
204
360
  response: {
205
- body: {
206
- cursor: "next-page-cursor",
207
- policies: [
208
- {
209
- "@context": OdrlContexts.Context,
210
- "@type": "Set",
211
- uid: "urn:rights-management:abc123def456",
212
- permission: [
213
- {
214
- target: "http://example.com/asset/1",
215
- action: "use"
216
- }
217
- ]
218
- }
219
- ]
220
- }
361
+ body: [
362
+ {
363
+ "@context": PAP_POLICY_RESPONSE_CONTEXT,
364
+ "@type": OdrlPolicyType.Set,
365
+ "@id": "urn:rights-management:abc123def456",
366
+ ...papPolicyExampleLifecycle,
367
+ permission: [
368
+ {
369
+ target: "http://example.com/asset/1",
370
+ action: "use"
371
+ }
372
+ ]
373
+ }
374
+ ]
221
375
  }
222
376
  }
223
377
  ]
224
378
  }
225
379
  ]
226
380
  };
227
- return [papCreateRoute, papUpdateRoute, papGetRoute, papRemoveRoute, papQueryRoute];
381
+ return [
382
+ papCreateRoute,
383
+ papUpdateRoute,
384
+ papGetRoute,
385
+ papGetAgreementRoute,
386
+ papGetOfferRoute,
387
+ papGetSetRoute,
388
+ papRemoveRoute,
389
+ papQueryRoute
390
+ ];
228
391
  }
229
392
  /**
230
393
  * PAP: Create a policy.
@@ -281,6 +444,57 @@ export async function papGet(httpRequestContext, componentName, request) {
281
444
  body: policy
282
445
  };
283
446
  }
447
+ /**
448
+ * PAP: Get a agreement.
449
+ * @param httpRequestContext The request context for the API.
450
+ * @param componentName The name of the component to use in the routes.
451
+ * @param request The request.
452
+ * @returns The response object with additional http response properties.
453
+ */
454
+ export async function papGetAgreement(httpRequestContext, componentName, request) {
455
+ Guards.object(ROUTES_SOURCE, "request", request);
456
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
457
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
458
+ const component = ComponentFactory.get(componentName);
459
+ const policy = await component.getAgreement(request.pathParams.id);
460
+ return {
461
+ body: policy
462
+ };
463
+ }
464
+ /**
465
+ * PAP: Get an offer.
466
+ * @param httpRequestContext The request context for the API.
467
+ * @param componentName The name of the component to use in the routes.
468
+ * @param request The request.
469
+ * @returns The response object with additional http response properties.
470
+ */
471
+ export async function papGetOffer(httpRequestContext, componentName, request) {
472
+ Guards.object(ROUTES_SOURCE, "request", request);
473
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
474
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
475
+ const component = ComponentFactory.get(componentName);
476
+ const policy = await component.getOffer(request.pathParams.id);
477
+ return {
478
+ body: policy
479
+ };
480
+ }
481
+ /**
482
+ * PAP: Get a set.
483
+ * @param httpRequestContext The request context for the API.
484
+ * @param componentName The name of the component to use in the routes.
485
+ * @param request The request.
486
+ * @returns The response object with additional http response properties.
487
+ */
488
+ export async function papGetSet(httpRequestContext, componentName, request) {
489
+ Guards.object(ROUTES_SOURCE, "request", request);
490
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
491
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
492
+ const component = ComponentFactory.get(componentName);
493
+ const policy = await component.getSet(request.pathParams.id);
494
+ return {
495
+ body: policy
496
+ };
497
+ }
284
498
  /**
285
499
  * PAP: Remove a policy.
286
500
  * @param httpRequestContext The request context for the API.
@@ -308,12 +522,20 @@ export async function papRemove(httpRequestContext, componentName, request) {
308
522
  export async function papQuery(httpRequestContext, componentName, request) {
309
523
  Guards.object(ROUTES_SOURCE, "request", request);
310
524
  const component = ComponentFactory.get(componentName);
311
- const result = await component.query(HttpParameterHelper.objectFromString(request.query?.conditions), request.query?.cursor, Coerce.integer(request.query?.limit));
525
+ const result = await component.query({
526
+ assigner: request.query?.assigner,
527
+ assignee: request.query?.assignee,
528
+ target: request.query?.target,
529
+ action: request.query?.action
530
+ }, HttpParameterHelper.objectFromString(request.query?.conditions), request.query?.cursor, Coerce.integer(request.query?.limit));
531
+ const headers = {};
532
+ if (Is.stringValue(result.cursor)) {
533
+ const contextIds = await ContextIdStore.getContextIds();
534
+ headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(HttpUrlHelper.replaceOrigin(httpRequestContext.serverRequest.url, contextIds?.[HttpContextIdKeys.PublicOrigin]), { cursor: result.cursor }, "next");
535
+ }
312
536
  return {
313
- body: {
314
- cursor: result.cursor,
315
- policies: result.policies
316
- }
537
+ headers,
538
+ body: result.policies
317
539
  };
318
540
  }
319
541
  //# sourceMappingURL=policyAdministrationPointRoutes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"policyAdministrationPointRoutes.js","sourceRoot":"","sources":["../../src/policyAdministrationPointRoutes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,mBAAmB,EAMnB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\n\ttype ICreatedResponse,\n\ttype IHttpRequestContext,\n\ttype INoContentResponse,\n\ttype IRestRoute,\n\ttype ITag\n} from \"@twin.org/api-models\";\nimport { Coerce, ComponentFactory, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type {\n\tIPapCreateRequest,\n\tIPapGetRequest,\n\tIPapGetResponse,\n\tIPapQueryRequest,\n\tIPapQueryResponse,\n\tIPapRemoveRequest,\n\tIPapUpdateRequest,\n\tIPolicyAdministrationPointComponent\n} from \"@twin.org/rights-management-models\";\nimport { OdrlContexts } from \"@twin.org/standards-w3c-odrl\";\nimport { HttpStatusCode } from \"@twin.org/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"policyAdministrationPointRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const papTags: ITag[] = [\n\t{\n\t\tname: \"Policy Administration Point\",\n\t\tdescription: \"Endpoints for managing ODRL policies in the Policy Administration Point\"\n\t}\n];\n\n/**\n * The REST routes for the Policy Administration Point.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesPolicyAdministrationPoint(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst papCreateRoute: IRestRoute<IPapCreateRequest, ICreatedResponse> = {\n\t\toperationId: \"papCreate\",\n\t\tsummary: \"Create a policy\",\n\t\ttag: papTags[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/policy/admin`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tpapCreate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IPapCreateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"papCreateRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": OdrlContexts.Context,\n\t\t\t\t\t\t\t\"@type\": \"Set\",\n\t\t\t\t\t\t\tpermission: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttarget: \"http://example.com/asset/1\",\n\t\t\t\t\t\t\t\t\taction: \"use\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ICreatedResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"papCreateResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: 201,\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\tlocation: \"urn:rights-management:abc123def456\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst papUpdateRoute: IRestRoute<IPapUpdateRequest, INoContentResponse> = {\n\t\toperationId: \"papUpdate\",\n\t\tsummary: \"Update a policy\",\n\t\ttag: papTags[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/policy/admin/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tpapUpdate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IPapUpdateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"papUpdateRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"urn:rights-management:abc123def456\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": OdrlContexts.Context,\n\t\t\t\t\t\t\t\"@type\": \"Set\",\n\t\t\t\t\t\t\tuid: \"urn:rights-management:abc123def456\",\n\t\t\t\t\t\t\tpermission: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttarget: \"http://example.com/asset/2\",\n\t\t\t\t\t\t\t\t\taction: \"read\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst papGetRoute: IRestRoute<IPapGetRequest, IPapGetResponse> = {\n\t\toperationId: \"papGet\",\n\t\tsummary: \"Get a policy\",\n\t\ttag: papTags[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/policy/admin/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tpapGet(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IPapGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"papGetRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"urn:rights-management:abc123def456\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IPapGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"papGetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": OdrlContexts.Context,\n\t\t\t\t\t\t\t\t\"@type\": \"Set\",\n\t\t\t\t\t\t\t\tuid: \"urn:rights-management:abc123def456\",\n\t\t\t\t\t\t\t\tpermission: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttarget: \"http://example.com/asset/1\",\n\t\t\t\t\t\t\t\t\t\taction: \"use\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst papRemoveRoute: IRestRoute<IPapRemoveRequest, INoContentResponse> = {\n\t\toperationId: \"papRemove\",\n\t\tsummary: \"Remove a policy\",\n\t\ttag: papTags[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/policy/admin/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tpapRemove(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IPapRemoveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"papRemoveRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"urn:rights-management:abc123def456\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst papQueryRoute: IRestRoute<IPapQueryRequest, IPapQueryResponse> = {\n\t\toperationId: \"papQuery\",\n\t\tsummary: \"Query policies\",\n\t\ttag: papTags[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/policy/admin`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tpapQuery(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IPapQueryRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"papQueryRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tcursor: \"optional-pagination-cursor\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IPapQueryResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"papQueryResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tcursor: \"next-page-cursor\",\n\t\t\t\t\t\t\t\tpolicies: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"@context\": OdrlContexts.Context,\n\t\t\t\t\t\t\t\t\t\t\"@type\": \"Set\",\n\t\t\t\t\t\t\t\t\t\tuid: \"urn:rights-management:abc123def456\",\n\t\t\t\t\t\t\t\t\t\tpermission: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\ttarget: \"http://example.com/asset/1\",\n\t\t\t\t\t\t\t\t\t\t\t\taction: \"use\"\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [papCreateRoute, papUpdateRoute, papGetRoute, papRemoveRoute, papQueryRoute];\n}\n\n/**\n * PAP: Create a policy.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function papCreate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IPapCreateRequest\n): Promise<ICreatedResponse> {\n\tGuards.object<IPapCreateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IPapCreateRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst component = ComponentFactory.get<IPolicyAdministrationPointComponent>(componentName);\n\n\tconst policy = request.body;\n\tconst uid = await component.create(policy);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.created,\n\t\theaders: {\n\t\t\tlocation: uid\n\t\t}\n\t};\n}\n\n/**\n * PAP: Update a policy.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function papUpdate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IPapUpdateRequest\n): Promise<INoContentResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.pathParams), request.pathParams);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst component = ComponentFactory.get<IPolicyAdministrationPointComponent>(componentName);\n\tawait component.update(request.body);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * PAP: Get a policy.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function papGet(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IPapGetRequest\n): Promise<IPapGetResponse> {\n\tGuards.object<IPapGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IPapGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IPolicyAdministrationPointComponent>(componentName);\n\tconst policy = await component.get(request.pathParams.id);\n\n\treturn {\n\t\tbody: policy\n\t};\n}\n\n/**\n * PAP: Remove a policy.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function papRemove(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IPapRemoveRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IPapRemoveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IPapRemoveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IPolicyAdministrationPointComponent>(componentName);\n\tawait component.remove(request.pathParams.id);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * PAP: Query policies.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function papQuery(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IPapQueryRequest\n): Promise<IPapQueryResponse> {\n\tGuards.object<IPapQueryRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tconst component = ComponentFactory.get<IPolicyAdministrationPointComponent>(componentName);\n\tconst result = await component.query(\n\t\tHttpParameterHelper.objectFromString(request.query?.conditions),\n\t\trequest.query?.cursor,\n\t\tCoerce.integer(request.query?.limit)\n\t);\n\n\treturn {\n\t\tbody: {\n\t\t\tcursor: result.cursor,\n\t\t\tpolicies: result.policies\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"file":"policyAdministrationPointRoutes.js","sourceRoot":"","sources":["../../src/policyAdministrationPointRoutes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EAMb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEtE,OAAO,EACN,uBAAuB,EAevB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,cAAc,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CAAC,iBAAiB,CAAC,YAAY,CAAC,CAC5C,EACD,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,EACzB,MAAM,CACN,CAAC;IACH,CAAC;IAED,OAAO;QACN,OAAO;QACP,IAAI,EAAE,MAAM,CAAC,QAAQ;KACrB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tHttpContextIdKeys,\n\tHttpParameterHelper,\n\tHttpUrlHelper,\n\ttype ICreatedResponse,\n\ttype IHttpRequestContext,\n\ttype INoContentResponse,\n\ttype IRestRoute,\n\ttype ITag\n} from \"@twin.org/api-models\";\nimport { ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, ComponentFactory, Guards, Is } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tPOLICY_METADATA_CONTEXT,\n\ttype IPapCreateRequest,\n\ttype IPapGetAgreementRequest,\n\ttype IPapGetAgreementResponse,\n\ttype IPapGetOfferRequest,\n\ttype IPapGetOfferResponse,\n\ttype IPapGetRequest,\n\ttype IPapGetResponse,\n\ttype IPapGetSetRequest,\n\ttype IPapGetSetResponse,\n\ttype IPapQueryRequest,\n\ttype IPapQueryResponse,\n\ttype IPapRemoveRequest,\n\ttype IPapUpdateRequest,\n\ttype IPolicyAdministrationPointComponent\n} from \"@twin.org/rights-management-models\";\nimport { OdrlContexts, OdrlPolicyType, type OdrlContextType } from \"@twin.org/standards-w3c-odrl\";\nimport { HeaderHelper, HeaderTypes, HttpStatusCode } from \"@twin.org/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"policyAdministrationPointRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const papTags: ITag[] = [\n\t{\n\t\tname: \"Policy Administration Point\",\n\t\tdescription: \"Endpoints for managing ODRL policies in the Policy Administration Point\"\n\t}\n];\n\n/**\n * Example JSON-LD context returned by PAP read endpoints for policies with metadata timestamps.\n * Uses `POLICY_METADATA_CONTEXT` from rights-management-models merged with ODRL context.\n */\nconst PAP_POLICY_RESPONSE_CONTEXT: OdrlContextType = [\n\tOdrlContexts.Context,\n\tPOLICY_METADATA_CONTEXT\n];\n\n/**\n * The REST routes for the Policy Administration Point.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesPolicyAdministrationPoint(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst papPolicyExampleLifecycle = {\n\t\tdateCreated: \"2025-09-03T00:00:00.000Z\",\n\t\tdateModified: \"2025-09-03T00:00:00.000Z\"\n\t};\n\n\tconst papCreateRoute: IRestRoute<IPapCreateRequest, ICreatedResponse> = {\n\t\toperationId: \"papCreate\",\n\t\tsummary: \"Create a policy\",\n\t\ttag: papTags[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/policy/admin`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tpapCreate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IPapCreateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"papCreateRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": OdrlContexts.Context,\n\t\t\t\t\t\t\t\"@type\": OdrlPolicyType.Set,\n\t\t\t\t\t\t\tpermission: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttarget: \"http://example.com/asset/1\",\n\t\t\t\t\t\t\t\t\taction: \"use\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ICreatedResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"papCreateResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: 201,\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\tlocation: \"urn:rights-management:abc123def456\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst papUpdateRoute: IRestRoute<IPapUpdateRequest, INoContentResponse> = {\n\t\toperationId: \"papUpdate\",\n\t\tsummary: \"Update a policy\",\n\t\ttag: papTags[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/policy/admin/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tpapUpdate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IPapUpdateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"papUpdateRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"urn:rights-management:abc123def456\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": OdrlContexts.Context,\n\t\t\t\t\t\t\t\"@type\": OdrlPolicyType.Set,\n\t\t\t\t\t\t\t\"@id\": \"urn:rights-management:abc123def456\",\n\t\t\t\t\t\t\tpermission: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttarget: \"http://example.com/asset/2\",\n\t\t\t\t\t\t\t\t\taction: \"read\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst papGetRoute: IRestRoute<IPapGetRequest, IPapGetResponse> = {\n\t\toperationId: \"papGet\",\n\t\tsummary: \"Get a policy\",\n\t\ttag: papTags[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/policy/admin/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tpapGet(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IPapGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"papGetRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"urn:rights-management:abc123def456\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IPapGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"papGetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": PAP_POLICY_RESPONSE_CONTEXT,\n\t\t\t\t\t\t\t\t\"@type\": OdrlPolicyType.Set,\n\t\t\t\t\t\t\t\t\"@id\": \"urn:rights-management:abc123def456\",\n\t\t\t\t\t\t\t\t...papPolicyExampleLifecycle,\n\t\t\t\t\t\t\t\tpermission: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttarget: \"http://example.com/asset/1\",\n\t\t\t\t\t\t\t\t\t\taction: \"use\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst papGetAgreementRoute: IRestRoute<IPapGetAgreementRequest, IPapGetAgreementResponse> = {\n\t\toperationId: \"papGetAgreement\",\n\t\tsummary: \"Get a policy agreement\",\n\t\ttag: papTags[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/policy/admin/agreement/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tpapGetAgreement(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IPapGetAgreementRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"papGetAgreementRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"urn:rights-management:abc123def456\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IPapGetAgreementResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"papGetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": PAP_POLICY_RESPONSE_CONTEXT,\n\t\t\t\t\t\t\t\t\"@type\": OdrlPolicyType.Agreement,\n\t\t\t\t\t\t\t\t\"@id\": \"urn:rights-management:abc123def456\",\n\t\t\t\t\t\t\t\t...papPolicyExampleLifecycle,\n\t\t\t\t\t\t\t\tpermission: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttarget: \"http://example.com/asset/1\",\n\t\t\t\t\t\t\t\t\t\taction: \"use\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tassignee: \"did:example:receiver\",\n\t\t\t\t\t\t\t\tassigner: \"did:example:sender\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst papGetOfferRoute: IRestRoute<IPapGetOfferRequest, IPapGetOfferResponse> = {\n\t\toperationId: \"papGetOffer\",\n\t\tsummary: \"Get a policy offer\",\n\t\ttag: papTags[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/policy/admin/offer/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tpapGetOffer(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IPapGetOfferRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"papGetOfferRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"urn:rights-management:abc123def456\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IPapGetOfferResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"papGetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": PAP_POLICY_RESPONSE_CONTEXT,\n\t\t\t\t\t\t\t\t\"@type\": OdrlPolicyType.Offer,\n\t\t\t\t\t\t\t\t\"@id\": \"urn:rights-management:abc123def456\",\n\t\t\t\t\t\t\t\t...papPolicyExampleLifecycle,\n\t\t\t\t\t\t\t\tpermission: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttarget: \"http://example.com/asset/1\",\n\t\t\t\t\t\t\t\t\t\taction: \"use\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tassignee: \"did:example:receiver\",\n\t\t\t\t\t\t\t\tassigner: \"did:example:sender\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst papGetSetRoute: IRestRoute<IPapGetSetRequest, IPapGetSetResponse> = {\n\t\toperationId: \"papGetSet\",\n\t\tsummary: \"Get a policy set\",\n\t\ttag: papTags[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/policy/admin/set/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tpapGetSet(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IPapGetSetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"papGetSetRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"urn:rights-management:abc123def456\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IPapGetSetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"papGetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": PAP_POLICY_RESPONSE_CONTEXT,\n\t\t\t\t\t\t\t\t\"@type\": OdrlPolicyType.Set,\n\t\t\t\t\t\t\t\t\"@id\": \"urn:rights-management:abc123def456\",\n\t\t\t\t\t\t\t\t...papPolicyExampleLifecycle,\n\t\t\t\t\t\t\t\tpermission: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttarget: \"http://example.com/asset/1\",\n\t\t\t\t\t\t\t\t\t\taction: \"use\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tassignee: \"did:example:receiver\",\n\t\t\t\t\t\t\t\tassigner: \"did:example:sender\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst papRemoveRoute: IRestRoute<IPapRemoveRequest, INoContentResponse> = {\n\t\toperationId: \"papRemove\",\n\t\tsummary: \"Remove a policy\",\n\t\ttag: papTags[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/policy/admin/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tpapRemove(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IPapRemoveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"papRemoveRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"urn:rights-management:abc123def456\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst papQueryRoute: IRestRoute<IPapQueryRequest, IPapQueryResponse> = {\n\t\toperationId: \"papQuery\",\n\t\tsummary: \"Query policies\",\n\t\ttag: papTags[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/policy/admin`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tpapQuery(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IPapQueryRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"papQueryRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tcursor: \"optional-pagination-cursor\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IPapQueryResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"papQueryResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"@context\": PAP_POLICY_RESPONSE_CONTEXT,\n\t\t\t\t\t\t\t\t\t\"@type\": OdrlPolicyType.Set,\n\t\t\t\t\t\t\t\t\t\"@id\": \"urn:rights-management:abc123def456\",\n\t\t\t\t\t\t\t\t\t...papPolicyExampleLifecycle,\n\t\t\t\t\t\t\t\t\tpermission: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\ttarget: \"http://example.com/asset/1\",\n\t\t\t\t\t\t\t\t\t\t\taction: \"use\"\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [\n\t\tpapCreateRoute,\n\t\tpapUpdateRoute,\n\t\tpapGetRoute,\n\t\tpapGetAgreementRoute,\n\t\tpapGetOfferRoute,\n\t\tpapGetSetRoute,\n\t\tpapRemoveRoute,\n\t\tpapQueryRoute\n\t];\n}\n\n/**\n * PAP: Create a policy.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function papCreate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IPapCreateRequest\n): Promise<ICreatedResponse> {\n\tGuards.object<IPapCreateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IPapCreateRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst component = ComponentFactory.get<IPolicyAdministrationPointComponent>(componentName);\n\n\tconst policy = request.body;\n\tconst uid = await component.create(policy);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.created,\n\t\theaders: {\n\t\t\tlocation: uid\n\t\t}\n\t};\n}\n\n/**\n * PAP: Update a policy.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function papUpdate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IPapUpdateRequest\n): Promise<INoContentResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.pathParams), request.pathParams);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst component = ComponentFactory.get<IPolicyAdministrationPointComponent>(componentName);\n\tawait component.update(request.body);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * PAP: Get a policy.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function papGet(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IPapGetRequest\n): Promise<IPapGetResponse> {\n\tGuards.object<IPapGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IPapGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IPolicyAdministrationPointComponent>(componentName);\n\tconst policy = await component.get(request.pathParams.id);\n\n\treturn {\n\t\tbody: policy\n\t};\n}\n\n/**\n * PAP: Get a agreement.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function papGetAgreement(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IPapGetAgreementRequest\n): Promise<IPapGetAgreementResponse> {\n\tGuards.object<IPapGetAgreementRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IPapGetAgreementRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IPolicyAdministrationPointComponent>(componentName);\n\tconst policy = await component.getAgreement(request.pathParams.id);\n\n\treturn {\n\t\tbody: policy\n\t};\n}\n\n/**\n * PAP: Get an offer.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function papGetOffer(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IPapGetOfferRequest\n): Promise<IPapGetOfferResponse> {\n\tGuards.object<IPapGetOfferRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IPapGetOfferRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IPolicyAdministrationPointComponent>(componentName);\n\tconst policy = await component.getOffer(request.pathParams.id);\n\n\treturn {\n\t\tbody: policy\n\t};\n}\n\n/**\n * PAP: Get a set.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function papGetSet(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IPapGetSetRequest\n): Promise<IPapGetSetResponse> {\n\tGuards.object<IPapGetSetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IPapGetSetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IPolicyAdministrationPointComponent>(componentName);\n\tconst policy = await component.getSet(request.pathParams.id);\n\n\treturn {\n\t\tbody: policy\n\t};\n}\n\n/**\n * PAP: Remove a policy.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function papRemove(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IPapRemoveRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IPapRemoveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IPapRemoveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IPolicyAdministrationPointComponent>(componentName);\n\tawait component.remove(request.pathParams.id);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * PAP: Query policies.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function papQuery(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IPapQueryRequest\n): Promise<IPapQueryResponse> {\n\tGuards.object<IPapQueryRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tconst component = ComponentFactory.get<IPolicyAdministrationPointComponent>(componentName);\n\tconst result = await component.query(\n\t\t{\n\t\t\tassigner: request.query?.assigner,\n\t\t\tassignee: request.query?.assignee,\n\t\t\ttarget: request.query?.target,\n\t\t\taction: request.query?.action\n\t\t},\n\t\tHttpParameterHelper.objectFromString(request.query?.conditions),\n\t\trequest.query?.cursor,\n\t\tCoerce.integer(request.query?.limit)\n\t);\n\n\tconst headers: IPapQueryResponse[\"headers\"] = {};\n\n\tif (Is.stringValue(result.cursor)) {\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\n\t\theaders[HeaderTypes.Link] = HeaderHelper.createLinkHeader(\n\t\t\tHttpUrlHelper.replaceOrigin(\n\t\t\t\thttpRequestContext.serverRequest.url,\n\t\t\t\tcontextIds?.[HttpContextIdKeys.PublicOrigin]\n\t\t\t),\n\t\t\t{ cursor: result.cursor },\n\t\t\t\"next\"\n\t\t);\n\t}\n\n\treturn {\n\t\theaders,\n\t\tbody: result.policies\n\t};\n}\n"]}