@twin.org/rights-management-models 0.0.1-next.10

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 (40) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +21 -0
  3. package/dist/cjs/index.cjs +2 -0
  4. package/dist/esm/index.mjs +1 -0
  5. package/dist/types/index.d.ts +15 -0
  6. package/dist/types/models/IPolicyAdministrationPointComponent.d.ts +49 -0
  7. package/dist/types/models/IPolicyDecisionPointComponent.d.ts +25 -0
  8. package/dist/types/models/IPolicyEnforcementPointComponent.d.ts +19 -0
  9. package/dist/types/models/IPolicyExecutionPointComponent.d.ts +35 -0
  10. package/dist/types/models/IPolicyInformationPointComponent.d.ts +19 -0
  11. package/dist/types/models/IPolicyManagementPointComponent.d.ts +18 -0
  12. package/dist/types/models/IRightsManagementComponent.d.ts +44 -0
  13. package/dist/types/models/api/policyAdministrationPoint/IPapCreateRequest.d.ts +10 -0
  14. package/dist/types/models/api/policyAdministrationPoint/IPapQueryRequest.d.ts +22 -0
  15. package/dist/types/models/api/policyAdministrationPoint/IPapQueryResponse.d.ts +19 -0
  16. package/dist/types/models/api/policyAdministrationPoint/IPapRemoveRequest.d.ts +14 -0
  17. package/dist/types/models/api/policyAdministrationPoint/IPapRetrieveRequest.d.ts +14 -0
  18. package/dist/types/models/api/policyAdministrationPoint/IPapRetrieveResponse.d.ts +10 -0
  19. package/dist/types/models/api/policyAdministrationPoint/IPapUpdateRequest.d.ts +19 -0
  20. package/dist/types/models/policyActionCallback.d.ts +16 -0
  21. package/docs/changelog.md +85 -0
  22. package/docs/examples.md +1 -0
  23. package/docs/reference/index.md +22 -0
  24. package/docs/reference/interfaces/IPapCreateRequest.md +11 -0
  25. package/docs/reference/interfaces/IPapQueryRequest.md +29 -0
  26. package/docs/reference/interfaces/IPapQueryResponse.md +23 -0
  27. package/docs/reference/interfaces/IPapRemoveRequest.md +17 -0
  28. package/docs/reference/interfaces/IPapRetrieveRequest.md +17 -0
  29. package/docs/reference/interfaces/IPapRetrieveResponse.md +11 -0
  30. package/docs/reference/interfaces/IPapUpdateRequest.md +25 -0
  31. package/docs/reference/interfaces/IPolicyAdministrationPointComponent.md +129 -0
  32. package/docs/reference/interfaces/IPolicyDecisionPointComponent.md +67 -0
  33. package/docs/reference/interfaces/IPolicyEnforcementPointComponent.md +62 -0
  34. package/docs/reference/interfaces/IPolicyExecutionPointComponent.md +124 -0
  35. package/docs/reference/interfaces/IPolicyInformationPointComponent.md +61 -0
  36. package/docs/reference/interfaces/IPolicyManagementPointComponent.md +60 -0
  37. package/docs/reference/interfaces/IRightsManagementComponent.md +130 -0
  38. package/docs/reference/type-aliases/PolicyActionCallback.md +59 -0
  39. package/locales/en.json +3 -0
  40. package/package.json +41 -0
@@ -0,0 +1,60 @@
1
+ # Interface: IPolicyManagementPointComponent
2
+
3
+ Interface describing a Policy Management Point (PMP) contract.
4
+ Provide the policies to the Policy Decision Point (PDP) based on the data and identities.
5
+
6
+ ## Extends
7
+
8
+ - `IComponent`
9
+
10
+ ## Methods
11
+
12
+ ### retrieve()
13
+
14
+ > **retrieve**\<`T`\>(`assetType`, `action`, `data`, `userIdentity`, `nodeIdentity`): `Promise`\<`IOdrlPolicy`[]\>
15
+
16
+ Get the policies from a PAP based on the data and identities.
17
+
18
+ #### Type Parameters
19
+
20
+ ##### T
21
+
22
+ `T` = `unknown`
23
+
24
+ #### Parameters
25
+
26
+ ##### assetType
27
+
28
+ `string`
29
+
30
+ The type of asset being processed.
31
+
32
+ ##### action
33
+
34
+ `string`
35
+
36
+ The action being performed on the asset.
37
+
38
+ ##### data
39
+
40
+ The data to retrieve the policies for.
41
+
42
+ `undefined` | `T`
43
+
44
+ ##### userIdentity
45
+
46
+ `string`
47
+
48
+ The user identity to retrieve the policies for.
49
+
50
+ ##### nodeIdentity
51
+
52
+ `string`
53
+
54
+ The node identity to retrieve the policies for.
55
+
56
+ #### Returns
57
+
58
+ `Promise`\<`IOdrlPolicy`[]\>
59
+
60
+ Returns the policies which apply to the data and identities so that the PDP can make a decision.
@@ -0,0 +1,130 @@
1
+ # Interface: IRightsManagementComponent
2
+
3
+ Interface describing a unified Rights Management Component.
4
+ This serves as a single point of entry for all rights management operations.
5
+
6
+ ## Extends
7
+
8
+ - `IComponent`
9
+
10
+ ## Methods
11
+
12
+ ### papCreate()
13
+
14
+ > **papCreate**(`policy`): `Promise`\<`string`\>
15
+
16
+ Create a new policy with auto-generated UID.
17
+
18
+ #### Parameters
19
+
20
+ ##### policy
21
+
22
+ `Omit`\<`IOdrlPolicy`, `"uid"`\>
23
+
24
+ The policy to create (uid will be auto-generated).
25
+
26
+ #### Returns
27
+
28
+ `Promise`\<`string`\>
29
+
30
+ The UID of the created policy.
31
+
32
+ ***
33
+
34
+ ### papUpdate()
35
+
36
+ > **papUpdate**(`policy`): `Promise`\<`void`\>
37
+
38
+ PAP: Update an existing policy.
39
+
40
+ #### Parameters
41
+
42
+ ##### policy
43
+
44
+ `IOdrlPolicy`
45
+
46
+ The policy to update (must include uid).
47
+
48
+ #### Returns
49
+
50
+ `Promise`\<`void`\>
51
+
52
+ Nothing.
53
+
54
+ ***
55
+
56
+ ### papRetrieve()
57
+
58
+ > **papRetrieve**(`policyId`): `Promise`\<`IOdrlPolicy`\>
59
+
60
+ PAP: Retrieve a policy.
61
+
62
+ #### Parameters
63
+
64
+ ##### policyId
65
+
66
+ `string`
67
+
68
+ The id of the policy to retrieve.
69
+
70
+ #### Returns
71
+
72
+ `Promise`\<`IOdrlPolicy`\>
73
+
74
+ The policy.
75
+
76
+ ***
77
+
78
+ ### papRemove()
79
+
80
+ > **papRemove**(`policyId`): `Promise`\<`void`\>
81
+
82
+ PAP: Remove a policy.
83
+
84
+ #### Parameters
85
+
86
+ ##### policyId
87
+
88
+ `string`
89
+
90
+ The id of the policy to remove.
91
+
92
+ #### Returns
93
+
94
+ `Promise`\<`void`\>
95
+
96
+ Nothing.
97
+
98
+ ***
99
+
100
+ ### papQuery()
101
+
102
+ > **papQuery**(`conditions?`, `cursor?`, `pageSize?`): `Promise`\<\{ `cursor?`: `string`; `policies`: `IOdrlPolicy`[]; \}\>
103
+
104
+ PAP: Query the policies using the specified conditions.
105
+
106
+ #### Parameters
107
+
108
+ ##### conditions?
109
+
110
+ `EntityCondition`\<`IOdrlPolicy`\>
111
+
112
+ The conditions to use for the query.
113
+
114
+ ##### cursor?
115
+
116
+ `string`
117
+
118
+ The cursor to use for pagination.
119
+
120
+ ##### pageSize?
121
+
122
+ `number`
123
+
124
+ The number of results to return per page.
125
+
126
+ #### Returns
127
+
128
+ `Promise`\<\{ `cursor?`: `string`; `policies`: `IOdrlPolicy`[]; \}\>
129
+
130
+ Cursor for next page of results and the policies matching the query.
@@ -0,0 +1,59 @@
1
+ # Type Alias: PolicyActionCallback()\<T\>
2
+
3
+ > **PolicyActionCallback**\<`T`\> = (`assetType`, `action`, `data`, `userIdentity`, `nodeIdentity`, `policies`) => `Promise`\<`void`\>
4
+
5
+ Callback function type for policy actions.
6
+ This function is called when a policy action is executed.
7
+ It receives the asset type, action, data, user identity,
8
+ node identity, and the policies that apply to the data.
9
+ The function should return a promise that resolves when the action is complete.
10
+
11
+ ## Type Parameters
12
+
13
+ ### T
14
+
15
+ `T` = `unknown`
16
+
17
+ ## Parameters
18
+
19
+ ### assetType
20
+
21
+ `string`
22
+
23
+ The type of asset being processed.
24
+
25
+ ### action
26
+
27
+ `string`
28
+
29
+ The action being performed on the asset.
30
+
31
+ ### data
32
+
33
+ The data to process.
34
+
35
+ `T` | `undefined`
36
+
37
+ ### userIdentity
38
+
39
+ `string`
40
+
41
+ The user identity to use in the decision making.
42
+
43
+ ### nodeIdentity
44
+
45
+ `string`
46
+
47
+ The node identity to use in the decision making.
48
+
49
+ ### policies
50
+
51
+ `IOdrlPolicy`[]
52
+
53
+ The policies that apply to the data.
54
+
55
+ ## Returns
56
+
57
+ `Promise`\<`void`\>
58
+
59
+ A promise that resolves when the action is complete.
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": {}
3
+ }
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@twin.org/rights-management-models",
3
+ "version": "0.0.1-next.10",
4
+ "description": "Models which define the structure of the rights management connectors and services",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/rights-management.git",
8
+ "directory": "packages/rights-management-models"
9
+ },
10
+ "author": "martyn.janes@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=20.0.0"
15
+ },
16
+ "dependencies": {
17
+ "@twin.org/core": "next",
18
+ "@twin.org/data-json-ld": "next",
19
+ "@twin.org/entity": "next",
20
+ "@twin.org/nameof": "next",
21
+ "@twin.org/standards-w3c-odrl": "next"
22
+ },
23
+ "main": "./dist/cjs/index.cjs",
24
+ "module": "./dist/esm/index.mjs",
25
+ "types": "./dist/types/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/types/index.d.ts",
29
+ "require": "./dist/cjs/index.cjs",
30
+ "import": "./dist/esm/index.mjs"
31
+ },
32
+ "./locales/*.json": "./locales/*.json"
33
+ },
34
+ "files": [
35
+ "dist/cjs",
36
+ "dist/esm",
37
+ "dist/types",
38
+ "locales",
39
+ "docs"
40
+ ]
41
+ }