@twin.org/dataspace-control-plane-service 0.0.3-next.18 → 0.0.3-next.20

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/docs/examples.md CHANGED
@@ -1 +1,144 @@
1
- # @twin.org/data-exchange-service - Examples
1
+ # Control Plane Service Examples
2
+
3
+ Use these snippets to negotiate agreements, manage transfer lifecycle, and resolve process identifiers in service components.
4
+
5
+ ## DataspaceControlPlaneService
6
+
7
+ ```typescript
8
+ import { DataspaceControlPlaneService } from '@twin.org/dataspace-control-plane-service';
9
+
10
+ const service = new DataspaceControlPlaneService({
11
+ loggingComponentType: 'logging',
12
+ trustComponentType: 'trust',
13
+ config: {
14
+ dataPlanePath: 'dataspace-data-plane'
15
+ }
16
+ });
17
+
18
+ console.log(service.className()); // DataspaceControlPlaneService
19
+ ```
20
+
21
+ ```typescript
22
+ import { DataspaceControlPlaneService } from '@twin.org/dataspace-control-plane-service';
23
+
24
+ const service = new DataspaceControlPlaneService();
25
+
26
+ service.registerNegotiationCallback('supply-chain', {
27
+ onStateChanged: async (negotiationId, state) => {
28
+ console.log(negotiationId); // urn:negotiation:001
29
+ console.log(state); // OFFERED
30
+ },
31
+ onCompleted: async (negotiationId, agreementId) => {
32
+ console.log(negotiationId); // urn:negotiation:001
33
+ console.log(agreementId); // urn:agreement:001
34
+ },
35
+ onFailed: async (negotiationId, reason) => {
36
+ console.log(negotiationId); // urn:negotiation:001
37
+ console.log(reason); // negotiationTerminatedByProvider
38
+ }
39
+ });
40
+
41
+ await service.start();
42
+ await service.stop();
43
+ service.unregisterNegotiationCallback('supply-chain');
44
+ ```
45
+
46
+ ```typescript
47
+ import { DataspaceControlPlaneService } from '@twin.org/dataspace-control-plane-service';
48
+ import type {
49
+ IDataspaceProtocolAgreement,
50
+ IDataspaceProtocolTransferRequestMessage,
51
+ IDataspaceProtocolTransferStartMessage,
52
+ IDataspaceProtocolTransferCompletionMessage,
53
+ IDataspaceProtocolTransferSuspensionMessage,
54
+ IDataspaceProtocolTransferTerminationMessage
55
+ } from '@twin.org/standards-dataspace-protocol';
56
+
57
+ const service = new DataspaceControlPlaneService();
58
+ const trustPayload = 'eyJhbGciOi...';
59
+
60
+ declare const agreement: IDataspaceProtocolAgreement;
61
+ declare const requestMessage: IDataspaceProtocolTransferRequestMessage;
62
+ declare const startMessage: IDataspaceProtocolTransferStartMessage;
63
+ declare const completionMessage: IDataspaceProtocolTransferCompletionMessage;
64
+ declare const suspensionMessage: IDataspaceProtocolTransferSuspensionMessage;
65
+ declare const terminationMessage: IDataspaceProtocolTransferTerminationMessage;
66
+
67
+ const requested = await service.requestTransfer(requestMessage, trustPayload);
68
+ const started = await service.startTransfer(startMessage, trustPayload);
69
+ const completed = await service.completeTransfer(completionMessage, trustPayload);
70
+ const suspended = await service.suspendTransfer(suspensionMessage, trustPayload);
71
+ const terminated = await service.terminateTransfer(terminationMessage, trustPayload);
72
+
73
+ const negotiationId = await service.negotiateAgreement(
74
+ agreement,
75
+ 'https://provider.example',
76
+ trustPayload
77
+ );
78
+ const negotiation = await service.getNegotiation(negotiationId, trustPayload);
79
+ const history = await service.getNegotiationHistory(negotiationId, trustPayload);
80
+
81
+ console.log(requested['@type']); // TransferProcess
82
+ console.log(started['@type']); // TransferStartMessage
83
+ console.log(completed['@type']); // TransferProcess
84
+ console.log(suspended['@type']); // TransferProcess
85
+ console.log(terminated['@type']); // TransferProcess
86
+ console.log(negotiation['@id']); // urn:negotiation:001
87
+ console.log(history.length); // 3
88
+ ```
89
+
90
+ ```typescript
91
+ import { DataspaceControlPlaneService } from '@twin.org/dataspace-control-plane-service';
92
+
93
+ const service = new DataspaceControlPlaneService();
94
+
95
+ const transfer = await service.getTransferProcess('consumer-process-id', 'eyJhbGciOi...');
96
+ const consumerPid = await service.resolveConsumerPid('provider-process-id');
97
+ const providerPid = await service.resolveProviderPid('consumer-process-id');
98
+
99
+ console.log(transfer['@type']); // TransferProcess
100
+ console.log(consumerPid); // consumer-process-id
101
+ console.log(providerPid); // provider-process-id
102
+ ```
103
+
104
+ ## DataspaceControlPlanePolicyRequester
105
+
106
+ ```typescript
107
+ import { DataspaceControlPlanePolicyRequester } from '@twin.org/dataspace-control-plane-service';
108
+ import type {
109
+ IDataspaceProtocolAgreement,
110
+ IDataspaceProtocolOffer
111
+ } from '@twin.org/standards-dataspace-protocol';
112
+
113
+ const requester = new DataspaceControlPlanePolicyRequester('logging', {
114
+ onStateChanged: async (negotiationId, state) => {
115
+ console.log(negotiationId); // urn:negotiation:001
116
+ console.log(state); // OFFERED
117
+ },
118
+ onCompleted: async (negotiationId, agreementId) => {
119
+ console.log(negotiationId); // urn:negotiation:001
120
+ console.log(agreementId); // urn:agreement:001
121
+ },
122
+ onFailed: async (negotiationId, reason) => {
123
+ console.log(negotiationId); // urn:negotiation:001
124
+ console.log(reason); // negotiationTerminatedByProvider
125
+ }
126
+ });
127
+
128
+ console.log(requester.className()); // DataspaceControlPlanePolicyRequester
129
+
130
+ requester.trackNegotiation('urn:negotiation:001');
131
+ const active = requester.getActiveNegotiations();
132
+ console.log(active.size); // 1
133
+
134
+ declare const offer: IDataspaceProtocolOffer;
135
+ declare const agreement: IDataspaceProtocolAgreement;
136
+
137
+ await requester.offer('urn:negotiation:001', offer);
138
+ await requester.agreement('urn:negotiation:001', agreement);
139
+ await requester.finalised('urn:negotiation:001');
140
+
141
+ requester.trackNegotiation('urn:negotiation:002');
142
+ await requester.terminated('urn:negotiation:002');
143
+ requester.removeNegotiation('urn:negotiation:002');
144
+ ```
@@ -44,7 +44,7 @@ Optional callback interface for state change notifications.
44
44
 
45
45
  ## Properties
46
46
 
47
- ### CLASS\_NAME
47
+ ### CLASS\_NAME {#class_name}
48
48
 
49
49
  > `readonly` `static` **CLASS\_NAME**: `string`
50
50
 
@@ -52,7 +52,7 @@ Runtime name for the class.
52
52
 
53
53
  ## Methods
54
54
 
55
- ### className()
55
+ ### className() {#classname}
56
56
 
57
57
  > **className**(): `string`
58
58
 
@@ -70,7 +70,7 @@ The class name of the component.
70
70
 
71
71
  ***
72
72
 
73
- ### trackNegotiation()
73
+ ### trackNegotiation() {#tracknegotiation}
74
74
 
75
75
  > **trackNegotiation**(`negotiationId`): `void`
76
76
 
@@ -91,7 +91,7 @@ The negotiation ID returned by PNP.sendRequestToProvider().
91
91
 
92
92
  ***
93
93
 
94
- ### getActiveNegotiations()
94
+ ### getActiveNegotiations() {#getactivenegotiations}
95
95
 
96
96
  > **getActiveNegotiations**(): `Map`\<`string`, [`INegotiationState`](../interfaces/INegotiationState.md)\>
97
97
 
@@ -105,7 +105,7 @@ Map of negotiationId to negotiation state.
105
105
 
106
106
  ***
107
107
 
108
- ### removeNegotiation()
108
+ ### removeNegotiation() {#removenegotiation}
109
109
 
110
110
  > **removeNegotiation**(`negotiationId`): `void`
111
111
 
@@ -125,7 +125,7 @@ The negotiation ID to remove.
125
125
 
126
126
  ***
127
127
 
128
- ### offer()
128
+ ### offer() {#offer}
129
129
 
130
130
  > **offer**(`negotiationId`, `offer`): `Promise`\<`boolean`\>
131
131
 
@@ -158,7 +158,7 @@ True if the offer was accepted, false otherwise.
158
158
 
159
159
  ***
160
160
 
161
- ### agreement()
161
+ ### agreement() {#agreement}
162
162
 
163
163
  > **agreement**(`negotiationId`, `agreement`): `Promise`\<`boolean`\>
164
164
 
@@ -191,7 +191,7 @@ True if the agreement was accepted, false otherwise.
191
191
 
192
192
  ***
193
193
 
194
- ### finalised()
194
+ ### finalised() {#finalised}
195
195
 
196
196
  > **finalised**(`negotiationId`): `Promise`\<`void`\>
197
197
 
@@ -218,7 +218,7 @@ Nothing.
218
218
 
219
219
  ***
220
220
 
221
- ### terminated()
221
+ ### terminated() {#terminated}
222
222
 
223
223
  > **terminated**(`negotiationId`): `Promise`\<`void`\>
224
224
 
@@ -33,7 +33,7 @@ The options for the service.
33
33
 
34
34
  ## Properties
35
35
 
36
- ### CLASS\_NAME
36
+ ### CLASS\_NAME {#class_name}
37
37
 
38
38
  > `readonly` `static` **CLASS\_NAME**: `string`
39
39
 
@@ -41,7 +41,7 @@ Runtime name for the class.
41
41
 
42
42
  ## Methods
43
43
 
44
- ### className()
44
+ ### className() {#classname}
45
45
 
46
46
  > **className**(): `string`
47
47
 
@@ -59,7 +59,7 @@ The class name of the component.
59
59
 
60
60
  ***
61
61
 
62
- ### registerNegotiationCallback()
62
+ ### registerNegotiationCallback() {#registernegotiationcallback}
63
63
 
64
64
  > **registerNegotiationCallback**(`key`, `callback`): `void`
65
65
 
@@ -90,7 +90,7 @@ The callback interface to register.
90
90
 
91
91
  ***
92
92
 
93
- ### unregisterNegotiationCallback()
93
+ ### unregisterNegotiationCallback() {#unregisternegotiationcallback}
94
94
 
95
95
  > **unregisterNegotiationCallback**(`key`): `void`
96
96
 
@@ -114,7 +114,7 @@ The key used when registering the callback.
114
114
 
115
115
  ***
116
116
 
117
- ### start()
117
+ ### start() {#start}
118
118
 
119
119
  > **start**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
120
120
 
@@ -140,7 +140,7 @@ The node logging component type.
140
140
 
141
141
  ***
142
142
 
143
- ### stop()
143
+ ### stop() {#stop}
144
144
 
145
145
  > **stop**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
146
146
 
@@ -165,7 +165,7 @@ The node logging component type.
165
165
 
166
166
  ***
167
167
 
168
- ### requestTransfer()
168
+ ### requestTransfer() {#requesttransfer}
169
169
 
170
170
  > **requestTransfer**(`request`, `trustPayload`): `Promise`\<`IDataspaceProtocolTransferError` \| `IDataspaceProtocolTransferProcess`\>
171
171
 
@@ -201,7 +201,7 @@ Called by: Consumer when it wants to request a new Transfer Process
201
201
 
202
202
  ***
203
203
 
204
- ### startTransfer()
204
+ ### startTransfer() {#starttransfer}
205
205
 
206
206
  > **startTransfer**(`message`, `publicOrigin`, `trustPayload`): `Promise`\<`IDataspaceProtocolTransferError` \| `IDataspaceProtocolTransferStartMessage`\>
207
207
 
@@ -242,7 +242,7 @@ Role Performed: Provider / Consumer
242
242
 
243
243
  ***
244
244
 
245
- ### completeTransfer()
245
+ ### completeTransfer() {#completetransfer}
246
246
 
247
247
  > **completeTransfer**(`message`, `trustPayload`): `Promise`\<`IDataspaceProtocolTransferError` \| `IDataspaceProtocolTransferProcess`\>
248
248
 
@@ -274,7 +274,7 @@ Transfer Process (DSP compliant) with state COMPLETED, or TransferError if the o
274
274
 
275
275
  ***
276
276
 
277
- ### suspendTransfer()
277
+ ### suspendTransfer() {#suspendtransfer}
278
278
 
279
279
  > **suspendTransfer**(`message`, `trustPayload`): `Promise`\<`IDataspaceProtocolTransferError` \| `IDataspaceProtocolTransferProcess`\>
280
280
 
@@ -306,7 +306,7 @@ Transfer Process (DSP compliant) with state SUSPENDED, or TransferError if the o
306
306
 
307
307
  ***
308
308
 
309
- ### terminateTransfer()
309
+ ### terminateTransfer() {#terminatetransfer}
310
310
 
311
311
  > **terminateTransfer**(`message`, `trustPayload`): `Promise`\<`IDataspaceProtocolTransferError` \| `IDataspaceProtocolTransferProcess`\>
312
312
 
@@ -338,7 +338,7 @@ Transfer Process (DSP compliant) with state TERMINATED, or TransferError if the
338
338
 
339
339
  ***
340
340
 
341
- ### getTransferProcess()
341
+ ### getTransferProcess() {#gettransferprocess}
342
342
 
343
343
  > **getTransferProcess**(`pid`, `trustPayload`): `Promise`\<`IDataspaceProtocolTransferError` \| `IDataspaceProtocolTransferProcess`\>
344
344
 
@@ -370,7 +370,7 @@ Transfer Process (DSP compliant) with current state, or TransferError if the ope
370
370
 
371
371
  ***
372
372
 
373
- ### negotiateAgreement()
373
+ ### negotiateAgreement() {#negotiateagreement}
374
374
 
375
375
  > **negotiateAgreement**(`datasetId`, `offerId`, `providerEndpoint`, `publicOrigin`, `trustPayload`): `Promise`\<\{ `negotiationId`: `string`; \}\>
376
376
 
@@ -422,7 +422,7 @@ The negotiation ID. Use the registered callback for completion notification.
422
422
 
423
423
  ***
424
424
 
425
- ### getNegotiation()
425
+ ### getNegotiation() {#getnegotiation}
426
426
 
427
427
  > **getNegotiation**(`negotiationId`, `trustPayload`): `Promise`\<`IDataspaceProtocolContractNegotiation` \| `IDataspaceProtocolContractNegotiationError`\>
428
428
 
@@ -454,7 +454,7 @@ Current state of the negotiation.
454
454
 
455
455
  ***
456
456
 
457
- ### getNegotiationHistory()
457
+ ### getNegotiationHistory() {#getnegotiationhistory}
458
458
 
459
459
  > **getNegotiationHistory**(`state`, `cursor`, `trustPayload`): `Promise`\<\{ `negotiations`: `object`[]; `cursor?`: `string`; `count`: `number`; \}\>
460
460
 
@@ -492,7 +492,7 @@ List of negotiation history entries with pagination.
492
492
 
493
493
  ***
494
494
 
495
- ### resolveConsumerPid()
495
+ ### resolveConsumerPid() {#resolveconsumerpid}
496
496
 
497
497
  > **resolveConsumerPid**(`consumerPid`, `trustPayload`): `Promise`\<`ITransferContext`\>
498
498
 
@@ -524,7 +524,7 @@ Transfer Context with Agreement, datasetId, and Transfer Process metadata.
524
524
 
525
525
  ***
526
526
 
527
- ### resolveProviderPid()
527
+ ### resolveProviderPid() {#resolveproviderpid}
528
528
 
529
529
  > **resolveProviderPid**(`providerPid`, `trustPayload`): `Promise`\<`ITransferContext`\>
530
530
 
@@ -4,7 +4,7 @@ Dataspace Control Plane service configuration.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### overrideTrustGeneratorType?
7
+ ### overrideTrustGeneratorType? {#overridetrustgeneratortype}
8
8
 
9
9
  > `optional` **overrideTrustGeneratorType**: `string`
10
10
 
@@ -13,7 +13,7 @@ If not specified, the default trust generator configured in the trust component
13
13
 
14
14
  ***
15
15
 
16
- ### dataPlanePath?
16
+ ### dataPlanePath? {#dataplanepath}
17
17
 
18
18
  > `optional` **dataPlanePath**: `string`
19
19
 
@@ -4,37 +4,25 @@ Dataspace Control Plane service constructor options.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### policyAdministrationPointComponentType?
7
+ ### policyAdministrationPointComponentType? {#policyadministrationpointcomponenttype}
8
8
 
9
9
  > `optional` **policyAdministrationPointComponentType**: `string`
10
10
 
11
11
  Policy Administration Point component type.
12
12
  Used for Agreement lookup and validation during Transfer Process initiation.
13
13
 
14
- #### Default
15
-
16
- ```ts
17
- policy-administration-point
18
- ```
19
-
20
14
  ***
21
15
 
22
- ### policyNegotiationPointComponentType?
16
+ ### policyNegotiationPointComponentType? {#policynegotiationpointcomponenttype}
23
17
 
24
18
  > `optional` **policyNegotiationPointComponentType**: `string`
25
19
 
26
20
  Policy Negotiation Point component type.
27
21
  Used for contract negotiation to create agreements before transfer processes.
28
22
 
29
- #### Default
30
-
31
- ```ts
32
- policy-negotiation-point
33
- ```
34
-
35
23
  ***
36
24
 
37
- ### policyNegotiationAdminPointComponentType?
25
+ ### policyNegotiationAdminPointComponentType? {#policynegotiationadminpointcomponenttype}
38
26
 
39
27
  > `optional` **policyNegotiationAdminPointComponentType**: `string`
40
28
 
@@ -42,15 +30,9 @@ Policy Negotiation Admin Point component type.
42
30
  Used for querying negotiation history.
43
31
  Optional - if not provided, negotiation history will not be available.
44
32
 
45
- #### Default
46
-
47
- ```ts
48
- policy-negotiation-admin-point
49
- ```
50
-
51
33
  ***
52
34
 
53
- ### federatedCatalogueComponentType?
35
+ ### federatedCatalogueComponentType? {#federatedcataloguecomponenttype}
54
36
 
55
37
  > `optional` **federatedCatalogueComponentType**: `string`
56
38
 
@@ -58,72 +40,42 @@ Federated Catalogue component type.
58
40
  Used for dataset validation during Transfer Process initiation.
59
41
  Validates that Agreements reference valid catalog datasets.
60
42
 
61
- #### Default
62
-
63
- ```ts
64
- federated-catalogue
65
- ```
66
-
67
43
  ***
68
44
 
69
- ### loggingComponentType?
45
+ ### loggingComponentType? {#loggingcomponenttype}
70
46
 
71
47
  > `optional` **loggingComponentType**: `string`
72
48
 
73
49
  Logging component type.
74
50
 
75
- #### Default
76
-
77
- ```ts
78
- logging
79
- ```
80
-
81
51
  ***
82
52
 
83
- ### identityComponentType?
53
+ ### identityComponentType? {#identitycomponenttype}
84
54
 
85
55
  > `optional` **identityComponentType**: `string`
86
56
 
87
57
  Identity component type (for token signing/verification).
88
58
 
89
- #### Default
90
-
91
- ```ts
92
- identity
93
- ```
94
-
95
59
  ***
96
60
 
97
- ### identityAuthenticationComponentType?
61
+ ### identityAuthenticationComponentType? {#identityauthenticationcomponenttype}
98
62
 
99
63
  > `optional` **identityAuthenticationComponentType**: `string`
100
64
 
101
65
  Identity Authentication component type (for token validation).
102
66
 
103
- #### Default
104
-
105
- ```ts
106
- identity-authentication
107
- ```
108
-
109
67
  ***
110
68
 
111
- ### trustComponentType?
69
+ ### trustComponentType? {#trustcomponenttype}
112
70
 
113
71
  > `optional` **trustComponentType**: `string`
114
72
 
115
73
  Trust component type for trust verification.
116
74
  Used to verify JWT/VC tokens and extract identity information.
117
75
 
118
- #### Default
119
-
120
- ```ts
121
- trust
122
- ```
123
-
124
76
  ***
125
77
 
126
- ### transferProcessEntityStorageType?
78
+ ### transferProcessEntityStorageType? {#transferprocessentitystoragetype}
127
79
 
128
80
  > `optional` **transferProcessEntityStorageType**: `string`
129
81
 
@@ -131,29 +83,17 @@ Entity storage type for Transfer Process entities.
131
83
  Used to persist transfer state for the consumerPid flow.
132
84
  Must match the Data Plane's transferProcessEntityStorageType for shared storage.
133
85
 
134
- #### Default
135
-
136
- ```ts
137
- transfer-process
138
- ```
139
-
140
86
  ***
141
87
 
142
- ### taskSchedulerComponentType?
88
+ ### taskSchedulerComponentType? {#taskschedulercomponenttype}
143
89
 
144
90
  > `optional` **taskSchedulerComponentType**: `string`
145
91
 
146
92
  Task scheduler component type for periodic cleanup of stalled negotiations.
147
93
 
148
- #### Default
149
-
150
- ```ts
151
- task-scheduler
152
- ```
153
-
154
94
  ***
155
95
 
156
- ### config?
96
+ ### config? {#config}
157
97
 
158
98
  > `optional` **config**: [`IDataspaceControlPlaneServiceConfig`](IDataspaceControlPlaneServiceConfig.md)
159
99
 
@@ -4,7 +4,7 @@ Negotiation state tracked internally for callback routing.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### negotiationId
7
+ ### negotiationId {#negotiationid}
8
8
 
9
9
  > **negotiationId**: `string`
10
10
 
@@ -12,7 +12,7 @@ The negotiation ID (self-reference for lookup).
12
12
 
13
13
  ***
14
14
 
15
- ### state
15
+ ### state {#state}
16
16
 
17
17
  > **state**: `DataspaceProtocolContractNegotiationStateType`
18
18
 
@@ -20,7 +20,7 @@ Current negotiation state.
20
20
 
21
21
  ***
22
22
 
23
- ### agreement?
23
+ ### agreement? {#agreement}
24
24
 
25
25
  > `optional` **agreement**: `IDataspaceProtocolAgreement`
26
26
 
@@ -28,7 +28,7 @@ Agreement received from provider (stored until finalized).
28
28
 
29
29
  ***
30
30
 
31
- ### startedAt
31
+ ### startedAt {#startedat}
32
32
 
33
33
  > **startedAt**: `number`
34
34
 
@@ -36,7 +36,7 @@ Timestamp when negotiation started.
36
36
 
37
37
  ***
38
38
 
39
- ### updatedAt
39
+ ### updatedAt {#updatedat}
40
40
 
41
41
  > **updatedAt**: `number`
42
42
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@twin.org/dataspace-control-plane-service",
3
- "version": "0.0.3-next.18",
4
- "description": "Dataspace Control Plane service implementation for Eclipse Dataspace Protocol Transfer Process Protocol",
3
+ "version": "0.0.3-next.20",
4
+ "description": "Implements agreement negotiation and transfer process lifecycle management for control plane operations.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/twinfoundation/dataspace.git",
@@ -17,7 +17,7 @@
17
17
  "@twin.org/api-models": "next",
18
18
  "@twin.org/context": "next",
19
19
  "@twin.org/core": "next",
20
- "@twin.org/dataspace-models": "0.0.3-next.18",
20
+ "@twin.org/dataspace-models": "0.0.3-next.20",
21
21
  "@twin.org/entity": "next",
22
22
  "@twin.org/entity-storage-models": "next",
23
23
  "@twin.org/federated-catalogue-models": "next",