@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/README.md +4 -100
- package/dist/es/dataspaceControlPlaneRoutes.js +274 -21
- package/dist/es/dataspaceControlPlaneRoutes.js.map +1 -1
- package/dist/es/dataspaceControlPlaneService.js +44 -25
- package/dist/es/dataspaceControlPlaneService.js.map +1 -1
- package/docs/changelog.md +29 -1
- package/docs/examples.md +144 -1
- package/docs/reference/classes/DataspaceControlPlanePolicyRequester.md +9 -9
- package/docs/reference/classes/DataspaceControlPlaneService.md +17 -17
- package/docs/reference/interfaces/IDataspaceControlPlaneServiceConfig.md +2 -2
- package/docs/reference/interfaces/IDataspaceControlPlaneServiceConstructorOptions.md +11 -71
- package/docs/reference/interfaces/INegotiationState.md +5 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Dataspace Control Plane Service
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package implements agreement negotiation and transfer process lifecycle management for control plane operations. It coordinates protocol-compliant state transitions and persists transfer state that can be consumed by downstream data plane components.
|
|
4
|
+
|
|
5
|
+
Its behaviour follows the [Eclipse Dataspace Protocol](https://eclipse-dataspace-protocol-base.github.io/DataspaceProtocol/) and is designed for policy-aware transfer orchestration.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -8,104 +10,6 @@ Dataspace Control Plane contract implementation and REST endpoint definitions, i
|
|
|
8
10
|
npm install @twin.org/dataspace-control-plane-service
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
## Overview
|
|
12
|
-
|
|
13
|
-
The Control Plane manages DSP protocol operations including contract negotiation and transfer process management.
|
|
14
|
-
|
|
15
|
-
### Key Features
|
|
16
|
-
|
|
17
|
-
- **Transfer Process Management**: Create, start, complete, suspend, and terminate transfers
|
|
18
|
-
- **Contract Negotiation**: Negotiate agreements with providers via Policy Negotiation Point (PNP)
|
|
19
|
-
- **Agreement Validation**: Validate agreements via Policy Administration Point (PAP)
|
|
20
|
-
- **Dataset Validation**: Validate datasets via Federated Catalogue
|
|
21
|
-
- **Entity Storage**: Persists `TransferProcessEntity` to shared storage (accessible by Data Plane)
|
|
22
|
-
- **Token Generation**: Creates transfer tokens with configurable expiration
|
|
23
|
-
- **State Machine**: Enforces valid state transitions per DSP specification
|
|
24
|
-
|
|
25
|
-
### Constructor Options
|
|
26
|
-
|
|
27
|
-
- `loggingComponentType` (default: `logging`) - Logging component type
|
|
28
|
-
- `identityComponentType` (default: `identity`) - Identity component for token signing
|
|
29
|
-
- `identityAuthenticationComponentType` (default: `identity-authentication`) - Token validation component
|
|
30
|
-
- `transferProcessEntityStorageType` (default: `transfer-process-entity`) - Entity storage for transfer processes
|
|
31
|
-
- `policyAdministrationPointComponentType` (default: `policy-administration-point`) - Agreement lookup component
|
|
32
|
-
- `policyNegotiationPointComponentType` (default: `policy-negotiation-point`) - Contract negotiation component
|
|
33
|
-
- `federatedCatalogueComponentType` (default: `federated-catalogue`) - Dataset validation component
|
|
34
|
-
- `trustComponentType` (default: `trust`) - Trust verification component
|
|
35
|
-
|
|
36
|
-
### DSP Protocols
|
|
37
|
-
|
|
38
|
-
The Control Plane implements two separate DSP protocols, following the Eclipse Dataspace Protocol specification:
|
|
39
|
-
|
|
40
|
-
#### 1. Contract Negotiation Protocol
|
|
41
|
-
|
|
42
|
-
Negotiate agreements with providers before initiating transfers. Integrates with the Rights Management Policy Negotiation Point (PNP).
|
|
43
|
-
|
|
44
|
-
**REST API Endpoints:**
|
|
45
|
-
|
|
46
|
-
- `POST /control-plane/negotiations` - Initiate contract negotiation
|
|
47
|
-
- `GET /control-plane/negotiations/:negotiationId` - Get negotiation status
|
|
48
|
-
|
|
49
|
-
**Example Flow:**
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
# Step 1: Initiate negotiation
|
|
53
|
-
curl -X POST https://consumer.example.com/control-plane/negotiations \
|
|
54
|
-
-H "Authorization: Bearer ${TOKEN}" \
|
|
55
|
-
-H "Content-Type: application/json" \
|
|
56
|
-
-d '{
|
|
57
|
-
"offerId": "offer-from-catalog",
|
|
58
|
-
"providerEndpoint": "https://provider.example.com/negotiations"
|
|
59
|
-
}'
|
|
60
|
-
# Response: { agreement: {...}, agreementId: "...", negotiationId: "..." }
|
|
61
|
-
|
|
62
|
-
# Step 2: Check negotiation status (optional)
|
|
63
|
-
curl -X GET https://consumer.example.com/control-plane/negotiations/${NEGOTIATION_ID} \
|
|
64
|
-
-H "Authorization: Bearer ${TOKEN}"
|
|
65
|
-
# Response: { negotiationId: "...", state: "FINALIZED", ... }
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
**Service Methods:**
|
|
69
|
-
|
|
70
|
-
- `negotiateAgreement()` - Initiate contract negotiation (returns agreement)
|
|
71
|
-
- `getNegotiation()` - Retrieve negotiation state
|
|
72
|
-
|
|
73
|
-
**Flow**: Catalog → Negotiation → Agreement → Transfer
|
|
74
|
-
|
|
75
|
-
#### 2. Transfer Process Protocol
|
|
76
|
-
|
|
77
|
-
Manage the lifecycle of data transfers using negotiated agreements.
|
|
78
|
-
|
|
79
|
-
**REST API Endpoints:**
|
|
80
|
-
|
|
81
|
-
- `POST /control-plane/transfers/request` - Request a transfer
|
|
82
|
-
- `GET /control-plane/transfers/:pid` - Get transfer process state
|
|
83
|
-
- `POST /control-plane/transfers/:pid/start` - Start a transfer
|
|
84
|
-
- `POST /control-plane/transfers/:pid/complete` - Complete a transfer
|
|
85
|
-
- `POST /control-plane/transfers/:pid/suspend` - Suspend a transfer
|
|
86
|
-
- `POST /control-plane/transfers/:pid/terminate` - Terminate a transfer
|
|
87
|
-
|
|
88
|
-
**Service Methods:**
|
|
89
|
-
|
|
90
|
-
- `requestTransfer()` - Initiate a transfer request (requires existing agreement)
|
|
91
|
-
- `getTransferProcess()` - Retrieve transfer process state
|
|
92
|
-
- `startTransfer()` - Start an approved transfer
|
|
93
|
-
- `completeTransfer()` - Mark transfer as complete
|
|
94
|
-
- `suspendTransfer()` - Temporarily suspend a transfer
|
|
95
|
-
- `terminateTransfer()` - Terminate a transfer
|
|
96
|
-
|
|
97
|
-
### Shared Storage Architecture
|
|
98
|
-
|
|
99
|
-
The Control Plane writes `TransferProcessEntity` to entity storage, which is read by the Data Plane for `consumerPid` resolution:
|
|
100
|
-
|
|
101
|
-
```text
|
|
102
|
-
Control Plane Data Plane
|
|
103
|
-
│ │
|
|
104
|
-
│ set(TransferProcessEntity) │ get(consumerPid)
|
|
105
|
-
│ │
|
|
106
|
-
└───── Entity Storage ──────────┘
|
|
107
|
-
```
|
|
108
|
-
|
|
109
13
|
## Examples
|
|
110
14
|
|
|
111
15
|
Usage of the APIs is shown in the examples [docs/examples.md](docs/examples.md)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentFactory, Guards } from "@twin.org/core";
|
|
2
|
-
import {
|
|
2
|
+
import { DataspaceProtocolContexts, DataspaceProtocolTransferProcessStateType, DataspaceProtocolTransferProcessTypes } from "@twin.org/standards-dataspace-protocol";
|
|
3
|
+
import { HeaderHelper, HeaderTypes, MimeTypes } from "@twin.org/web";
|
|
3
4
|
import { transformErrorToStatusCode } from "./utils/transferErrorUtils.js";
|
|
4
5
|
/**
|
|
5
6
|
* The source used when communicating about these routes.
|
|
@@ -14,6 +15,37 @@ export const tagsDataspaceControlPlane = [
|
|
|
14
15
|
description: "DSP Transfer Process Protocol endpoints for initiating and managing data transfers."
|
|
15
16
|
}
|
|
16
17
|
];
|
|
18
|
+
// Example objects for API documentation
|
|
19
|
+
const requestTransferExample = {
|
|
20
|
+
"@context": DataspaceProtocolContexts.Context,
|
|
21
|
+
"@type": DataspaceProtocolTransferProcessTypes.TransferRequestMessage,
|
|
22
|
+
processId: "urn:uuid:consumer-process-12345",
|
|
23
|
+
consumerPid: "urn:uuid:consumer-process-12345",
|
|
24
|
+
providerPid: "urn:uuid:provider-process-12345",
|
|
25
|
+
agreementId: "urn:uuid:agreement-12345",
|
|
26
|
+
dataAddress: {
|
|
27
|
+
"@type": DataspaceProtocolTransferProcessTypes.DataAddress,
|
|
28
|
+
"@id": "https://provider.example.com/data",
|
|
29
|
+
endpointType: "https://w3id.org/dspace/v1/HttpDataAddress",
|
|
30
|
+
baseUrl: "https://provider.example.com/data"
|
|
31
|
+
},
|
|
32
|
+
callbackAddress: "https://consumer.example.com/transfer/webhook",
|
|
33
|
+
format: "urn:example:format"
|
|
34
|
+
};
|
|
35
|
+
const transferProcessExample = {
|
|
36
|
+
"@context": DataspaceProtocolContexts.Context,
|
|
37
|
+
"@type": DataspaceProtocolTransferProcessTypes.TransferProcess,
|
|
38
|
+
processId: "urn:uuid:provider-process-12345",
|
|
39
|
+
consumerPid: "urn:uuid:consumer-process-12345",
|
|
40
|
+
providerPid: "urn:uuid:provider-process-12345",
|
|
41
|
+
state: DataspaceProtocolTransferProcessStateType.STARTED,
|
|
42
|
+
dataAddress: {
|
|
43
|
+
"@type": DataspaceProtocolTransferProcessTypes.DataAddress,
|
|
44
|
+
"@id": "https://provider.example.com/data/transfer-12345",
|
|
45
|
+
endpointType: "https://w3id.org/dspace/v1/HttpDataAddress",
|
|
46
|
+
baseUrl: "https://provider.example.com/data/transfer-12345"
|
|
47
|
+
}
|
|
48
|
+
};
|
|
17
49
|
/**
|
|
18
50
|
* The REST routes for dataspace control plane (DSP Protocol only).
|
|
19
51
|
* These routes implement the Eclipse Dataspace Protocol Transfer Process Protocol.
|
|
@@ -26,71 +58,292 @@ export const tagsDataspaceControlPlane = [
|
|
|
26
58
|
* @returns The generated DSP protocol routes.
|
|
27
59
|
*/
|
|
28
60
|
export function generateRestRoutesDataspaceControlPlane(baseRouteName, componentName) {
|
|
29
|
-
const routes = [];
|
|
30
61
|
// ============================================================================
|
|
31
62
|
// TRANSFER PROCESS PROTOCOL (DSP)
|
|
32
63
|
// ============================================================================
|
|
33
64
|
// POST /transfers/request - Request Transfer Process (DSP)
|
|
34
|
-
|
|
65
|
+
const requestTransferRoute = {
|
|
35
66
|
operationId: "requestTransfer",
|
|
36
67
|
summary: "Request Transfer Process (DSP)",
|
|
37
68
|
tag: tagsDataspaceControlPlane[0].name,
|
|
38
69
|
method: "POST",
|
|
39
70
|
path: `${baseRouteName}/transfers/request`,
|
|
40
71
|
skipAuth: true,
|
|
41
|
-
handler: async (httpRequestContext, request) => requestTransferHandler(httpRequestContext, componentName, request)
|
|
42
|
-
|
|
72
|
+
handler: async (httpRequestContext, request) => requestTransferHandler(httpRequestContext, componentName, request),
|
|
73
|
+
requestType: {
|
|
74
|
+
mimeType: MimeTypes.JsonLd,
|
|
75
|
+
type: "IRequestTransferRequest",
|
|
76
|
+
examples: [
|
|
77
|
+
{
|
|
78
|
+
id: "requestTransferRequestExample",
|
|
79
|
+
request: {
|
|
80
|
+
headers: {
|
|
81
|
+
[HeaderTypes.Authorization]: "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
82
|
+
},
|
|
83
|
+
body: requestTransferExample
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
responseType: [
|
|
89
|
+
{
|
|
90
|
+
type: "IRequestTransferResponse",
|
|
91
|
+
examples: [
|
|
92
|
+
{
|
|
93
|
+
id: "requestTransferResponseExample",
|
|
94
|
+
response: {
|
|
95
|
+
body: transferProcessExample
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
};
|
|
43
102
|
// GET /transfers/:pid - Get Transfer Process state (DSP)
|
|
44
|
-
|
|
103
|
+
const getTransferProcessRoute = {
|
|
45
104
|
operationId: "getTransferProcess",
|
|
46
105
|
summary: "Get Transfer Process state (DSP)",
|
|
47
106
|
tag: tagsDataspaceControlPlane[0].name,
|
|
48
107
|
method: "GET",
|
|
49
108
|
path: `${baseRouteName}/transfers/:pid`,
|
|
50
109
|
skipAuth: true,
|
|
51
|
-
handler: async (httpRequestContext, request) => getTransferProcessHandler(httpRequestContext, componentName, request)
|
|
52
|
-
|
|
110
|
+
handler: async (httpRequestContext, request) => getTransferProcessHandler(httpRequestContext, componentName, request),
|
|
111
|
+
requestType: {
|
|
112
|
+
type: "IGetTransferProcessRequest",
|
|
113
|
+
examples: [
|
|
114
|
+
{
|
|
115
|
+
id: "getTransferProcessRequestExample",
|
|
116
|
+
request: {
|
|
117
|
+
headers: {
|
|
118
|
+
authorization: "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
119
|
+
},
|
|
120
|
+
pathParams: {
|
|
121
|
+
pid: "urn:uuid:provider-process-12345"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
responseType: [
|
|
128
|
+
{
|
|
129
|
+
type: "IGetTransferProcessResponse",
|
|
130
|
+
examples: [
|
|
131
|
+
{
|
|
132
|
+
id: "getTransferProcessResponseExample",
|
|
133
|
+
response: {
|
|
134
|
+
body: transferProcessExample
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
};
|
|
53
141
|
// POST /transfers/:pid/start - Start Transfer Process (DSP)
|
|
54
|
-
|
|
142
|
+
const startTransferRoute = {
|
|
55
143
|
operationId: "startTransfer",
|
|
56
144
|
summary: "Start Transfer Process (DSP)",
|
|
57
145
|
tag: tagsDataspaceControlPlane[0].name,
|
|
58
146
|
method: "POST",
|
|
59
147
|
path: `${baseRouteName}/transfers/:pid/start`,
|
|
60
148
|
skipAuth: true,
|
|
61
|
-
handler: async (httpRequestContext, request) => startTransferHandler(httpRequestContext, componentName, request)
|
|
62
|
-
|
|
149
|
+
handler: async (httpRequestContext, request) => startTransferHandler(httpRequestContext, componentName, request),
|
|
150
|
+
requestType: {
|
|
151
|
+
mimeType: MimeTypes.JsonLd,
|
|
152
|
+
type: "IStartTransferRequest",
|
|
153
|
+
examples: [
|
|
154
|
+
{
|
|
155
|
+
id: "startTransferRequestExample",
|
|
156
|
+
request: {
|
|
157
|
+
headers: {
|
|
158
|
+
[HeaderTypes.Authorization]: "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
159
|
+
},
|
|
160
|
+
pathParams: {
|
|
161
|
+
pid: "urn:uuid:consumer-process-12345"
|
|
162
|
+
},
|
|
163
|
+
body: {
|
|
164
|
+
"@context": DataspaceProtocolContexts.Context,
|
|
165
|
+
"@type": "TransferStartMessage",
|
|
166
|
+
consumerPid: "urn:uuid:consumer-process-12345",
|
|
167
|
+
providerPid: "urn:uuid:provider-process-12345"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
responseType: [
|
|
174
|
+
{
|
|
175
|
+
type: "IStartTransferResponse",
|
|
176
|
+
examples: [
|
|
177
|
+
{
|
|
178
|
+
id: "startTransferResponseExample",
|
|
179
|
+
response: {
|
|
180
|
+
body: {
|
|
181
|
+
"@context": DataspaceProtocolContexts.Context,
|
|
182
|
+
"@type": DataspaceProtocolTransferProcessTypes.TransferStartMessage,
|
|
183
|
+
consumerPid: "urn:uuid:consumer-process-12345",
|
|
184
|
+
providerPid: "urn:uuid:provider-process-12345"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
};
|
|
63
192
|
// POST /transfers/:pid/complete - Complete Transfer Process (DSP)
|
|
64
|
-
|
|
193
|
+
const completeTransferRoute = {
|
|
65
194
|
operationId: "completeTransfer",
|
|
66
195
|
summary: "Complete Transfer Process (DSP)",
|
|
67
196
|
tag: tagsDataspaceControlPlane[0].name,
|
|
68
197
|
method: "POST",
|
|
69
198
|
path: `${baseRouteName}/transfers/:pid/complete`,
|
|
70
199
|
skipAuth: true,
|
|
71
|
-
handler: async (httpRequestContext, request) => completeTransferHandler(httpRequestContext, componentName, request)
|
|
72
|
-
|
|
200
|
+
handler: async (httpRequestContext, request) => completeTransferHandler(httpRequestContext, componentName, request),
|
|
201
|
+
requestType: {
|
|
202
|
+
mimeType: MimeTypes.JsonLd,
|
|
203
|
+
type: "ICompleteTransferRequest",
|
|
204
|
+
examples: [
|
|
205
|
+
{
|
|
206
|
+
id: "completeTransferRequestExample",
|
|
207
|
+
request: {
|
|
208
|
+
headers: {
|
|
209
|
+
[HeaderTypes.Authorization]: "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
210
|
+
},
|
|
211
|
+
pathParams: {
|
|
212
|
+
pid: "urn:uuid:consumer-process-12345"
|
|
213
|
+
},
|
|
214
|
+
body: {
|
|
215
|
+
"@context": DataspaceProtocolContexts.Context,
|
|
216
|
+
"@type": "TransferCompletionMessage",
|
|
217
|
+
consumerPid: "urn:uuid:consumer-process-12345",
|
|
218
|
+
providerPid: "urn:uuid:provider-process-12345"
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
]
|
|
223
|
+
},
|
|
224
|
+
responseType: [
|
|
225
|
+
{
|
|
226
|
+
type: "ICompleteTransferResponse",
|
|
227
|
+
examples: [
|
|
228
|
+
{
|
|
229
|
+
id: "completeTransferResponseExample",
|
|
230
|
+
response: {
|
|
231
|
+
body: {
|
|
232
|
+
...transferProcessExample,
|
|
233
|
+
state: DataspaceProtocolTransferProcessStateType.COMPLETED
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
};
|
|
73
241
|
// POST /transfers/:pid/suspend - Suspend Transfer Process (DSP)
|
|
74
|
-
|
|
242
|
+
const suspendTransferRoute = {
|
|
75
243
|
operationId: "suspendTransfer",
|
|
76
244
|
summary: "Suspend Transfer Process (DSP)",
|
|
77
245
|
tag: tagsDataspaceControlPlane[0].name,
|
|
78
246
|
method: "POST",
|
|
79
247
|
path: `${baseRouteName}/transfers/:pid/suspend`,
|
|
80
248
|
skipAuth: true,
|
|
81
|
-
handler: async (httpRequestContext, request) => suspendTransferHandler(httpRequestContext, componentName, request)
|
|
82
|
-
|
|
249
|
+
handler: async (httpRequestContext, request) => suspendTransferHandler(httpRequestContext, componentName, request),
|
|
250
|
+
requestType: {
|
|
251
|
+
mimeType: MimeTypes.JsonLd,
|
|
252
|
+
type: "ISuspendTransferRequest",
|
|
253
|
+
examples: [
|
|
254
|
+
{
|
|
255
|
+
id: "suspendTransferRequestExample",
|
|
256
|
+
request: {
|
|
257
|
+
headers: {
|
|
258
|
+
[HeaderTypes.Authorization]: "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
259
|
+
},
|
|
260
|
+
pathParams: {
|
|
261
|
+
pid: "urn:uuid:consumer-process-12345"
|
|
262
|
+
},
|
|
263
|
+
body: {
|
|
264
|
+
"@context": DataspaceProtocolContexts.Context,
|
|
265
|
+
"@type": "TransferSuspensionMessage",
|
|
266
|
+
consumerPid: "urn:uuid:consumer-process-12345",
|
|
267
|
+
providerPid: "urn:uuid:provider-process-12345"
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
},
|
|
273
|
+
responseType: [
|
|
274
|
+
{
|
|
275
|
+
type: "ISuspendTransferResponse",
|
|
276
|
+
examples: [
|
|
277
|
+
{
|
|
278
|
+
id: "suspendTransferResponseExample",
|
|
279
|
+
response: {
|
|
280
|
+
body: {
|
|
281
|
+
...transferProcessExample,
|
|
282
|
+
state: DataspaceProtocolTransferProcessStateType.SUSPENDED
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
]
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
};
|
|
83
290
|
// POST /transfers/:pid/terminate - Terminate Transfer Process (DSP)
|
|
84
|
-
|
|
291
|
+
const terminateTransferRoute = {
|
|
85
292
|
operationId: "terminateTransfer",
|
|
86
293
|
summary: "Terminate Transfer Process (DSP)",
|
|
87
294
|
tag: tagsDataspaceControlPlane[0].name,
|
|
88
295
|
method: "POST",
|
|
89
296
|
path: `${baseRouteName}/transfers/:pid/terminate`,
|
|
90
297
|
skipAuth: true,
|
|
91
|
-
handler: async (httpRequestContext, request) => terminateTransferHandler(httpRequestContext, componentName, request)
|
|
92
|
-
|
|
93
|
-
|
|
298
|
+
handler: async (httpRequestContext, request) => terminateTransferHandler(httpRequestContext, componentName, request),
|
|
299
|
+
requestType: {
|
|
300
|
+
mimeType: MimeTypes.JsonLd,
|
|
301
|
+
type: "ITerminateTransferRequest",
|
|
302
|
+
examples: [
|
|
303
|
+
{
|
|
304
|
+
id: "terminateTransferRequestExample",
|
|
305
|
+
request: {
|
|
306
|
+
headers: {
|
|
307
|
+
[HeaderTypes.Authorization]: "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
308
|
+
},
|
|
309
|
+
pathParams: {
|
|
310
|
+
pid: "urn:uuid:consumer-process-12345"
|
|
311
|
+
},
|
|
312
|
+
body: {
|
|
313
|
+
"@context": DataspaceProtocolContexts.Context,
|
|
314
|
+
"@type": "TransferTerminationMessage",
|
|
315
|
+
consumerPid: "urn:uuid:consumer-process-12345",
|
|
316
|
+
providerPid: "urn:uuid:provider-process-12345"
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
]
|
|
321
|
+
},
|
|
322
|
+
responseType: [
|
|
323
|
+
{
|
|
324
|
+
type: "ITerminateTransferResponse",
|
|
325
|
+
examples: [
|
|
326
|
+
{
|
|
327
|
+
id: "terminateTransferResponseExample",
|
|
328
|
+
response: {
|
|
329
|
+
body: {
|
|
330
|
+
...transferProcessExample,
|
|
331
|
+
state: DataspaceProtocolTransferProcessStateType.TERMINATED
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
]
|
|
336
|
+
}
|
|
337
|
+
]
|
|
338
|
+
};
|
|
339
|
+
return [
|
|
340
|
+
requestTransferRoute,
|
|
341
|
+
getTransferProcessRoute,
|
|
342
|
+
startTransferRoute,
|
|
343
|
+
completeTransferRoute,
|
|
344
|
+
suspendTransferRoute,
|
|
345
|
+
terminateTransferRoute
|
|
346
|
+
];
|
|
94
347
|
}
|
|
95
348
|
// ============================================================================
|
|
96
349
|
// TRANSFER PROCESS PROTOCOL HANDLERS
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataspaceControlPlaneRoutes.js","sourceRoot":"","sources":["../../src/dataspaceControlPlaneRoutes.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAiB1D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E;;GAEG;AACH,MAAM,aAAa,GAAG,6BAA6B,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAW;IAChD;QACC,IAAI,EAAE,kBAAkB;QACxB,WAAW,EACV,qFAAqF;KACtF;CACD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uCAAuC,CACtD,aAAqB,EACrB,aAAqB;IAErB,MAAM,MAAM,GAAiB,EAAE,CAAC;IAEhC,+EAA+E;IAC/E,kCAAkC;IAClC,+EAA+E;IAE/E,2DAA2D;IAC3D,MAAM,CAAC,IAAI,CAAC;QACX,WAAW,EAAE,iBAAiB;QAC9B,OAAO,EAAE,gCAAgC;QACzC,GAAG,EAAE,yBAAyB,CAAC,CAAC,CAAC,CAAC,IAAI;QACtC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,GAAG,aAAa,oBAAoB;QAC1C,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,KAAK,EAAE,kBAAk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,MAAM,CAAC,MAAM,CAAC,aAAa,kBAAwB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjE,MAAM,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IAE5F,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAkC,aAAa,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAE3E,OAAO;QACN,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,0BAA0B,CAAC,MAAM,CAAC;KAC9C,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,wBAAwB,CACtC,kBAAuC,EACvC,aAAqB,EACrB,OAAkC;IAElC,MAAM,CAAC,MAAM,CAAC,aAAa,aAAmB,OAAO,CAAC,CAAC;IACvD,MAAM,CAAC,MAAM,CAAC,aAAa,kBAAwB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjE,MAAM,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IAE5F,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAkC,aAAa,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAE7E,OAAO;QACN,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,0BAA0B,CAAC,MAAM,CAAC;KAC9C,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIHostingComponent,\n\tIHttpRequestContext,\n\tIRestRoute,\n\tITag\n} from \"@twin.org/api-models\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport type {\n\tIDataspaceControlPlaneComponent,\n\tIRequestTransferRequest,\n\tIRequestTransferResponse,\n\tIGetTransferProcessRequest,\n\tIGetTransferProcessResponse,\n\tIStartTransferRequest,\n\tIStartTransferResponse,\n\tICompleteTransferRequest,\n\tICompleteTransferResponse,\n\tISuspendTransferRequest,\n\tISuspendTransferResponse,\n\tITerminateTransferRequest,\n\tITerminateTransferResponse\n} from \"@twin.org/dataspace-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HeaderHelper, HeaderTypes } from \"@twin.org/web\";\nimport { transformErrorToStatusCode } from \"./utils/transferErrorUtils.js\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"dataspaceControlPlaneRoutes\";\n\n/**\n * The tags to associate with the DSP protocol routes.\n */\nexport const tagsDataspaceControlPlane: ITag[] = [\n\t{\n\t\tname: \"Transfer Process\",\n\t\tdescription:\n\t\t\t\"DSP Transfer Process Protocol endpoints for initiating and managing data transfers.\"\n\t}\n];\n\n/**\n * The REST routes for dataspace control plane (DSP Protocol only).\n * These routes implement the Eclipse Dataspace Protocol Transfer Process Protocol.\n *\n * Contract Negotiation is handled internally via PNP callbacks — no REST endpoints needed.\n * PNP registers its own inbound callback routes for negotiation messages from providers.\n *\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 DSP protocol routes.\n */\nexport function generateRestRoutesDataspaceControlPlane(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst routes: IRestRoute[] = [];\n\n\t// ============================================================================\n\t// TRANSFER PROCESS PROTOCOL (DSP)\n\t// ============================================================================\n\n\t// POST /transfers/request - Request Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"requestTransfer\",\n\t\tsummary: \"Request Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/request`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\trequestTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// GET /transfers/:pid - Get Transfer Process state (DSP)\n\troutes.push({\n\t\toperationId: \"getTransferProcess\",\n\t\tsummary: \"Get Transfer Process state (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/transfers/:pid`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tgetTransferProcessHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// POST /transfers/:pid/start - Start Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"startTransfer\",\n\t\tsummary: \"Start Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/start`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tstartTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// POST /transfers/:pid/complete - Complete Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"completeTransfer\",\n\t\tsummary: \"Complete Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/complete`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tcompleteTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// POST /transfers/:pid/suspend - Suspend Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"suspendTransfer\",\n\t\tsummary: \"Suspend Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/suspend`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tsuspendTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\t// POST /transfers/:pid/terminate - Terminate Transfer Process (DSP)\n\troutes.push({\n\t\toperationId: \"terminateTransfer\",\n\t\tsummary: \"Terminate Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/terminate`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tterminateTransferHandler(httpRequestContext, componentName, request)\n\t});\n\n\treturn routes;\n}\n\n// ============================================================================\n// TRANSFER PROCESS PROTOCOL HANDLERS\n// ============================================================================\n\n/**\n * Request Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers and body.\n * @returns The response.\n */\nasync function requestTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IRequestTransferRequest\n): Promise<IRequestTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.requestTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Get Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers and path parameters.\n * @returns The response.\n */\nasync function getTransferProcessHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IGetTransferProcessRequest\n): Promise<IGetTransferProcessResponse> {\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.pid), request.pathParams.pid);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.getTransferProcess(request.pathParams.pid, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Start Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function startTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IStartTransferRequest\n): Promise<IStartTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst hostingComponent = ComponentFactory.get<IHostingComponent>(\n\t\thttpRequestContext.hostingComponentType ?? \"hosting\"\n\t);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.startTransfer(\n\t\trequest.body,\n\t\tawait hostingComponent.getPublicOrigin(httpRequestContext.serverRequest.url),\n\t\ttrustPayload\n\t);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Complete Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function completeTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ICompleteTransferRequest\n): Promise<ICompleteTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.completeTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Suspend Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function suspendTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ISuspendTransferRequest\n): Promise<ISuspendTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.suspendTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Terminate Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function terminateTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ITerminateTransferRequest\n): Promise<ITerminateTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.terminateTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dataspaceControlPlaneRoutes.js","sourceRoot":"","sources":["../../src/dataspaceControlPlaneRoutes.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM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,CAAC;IACvF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAE7E,OAAO;QACN,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,0BAA0B,CAAC,MAAM,CAAC;KAC9C,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIHostingComponent,\n\tIHttpRequestContext,\n\tIRestRoute,\n\tITag\n} from \"@twin.org/api-models\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport type {\n\tICompleteTransferRequest,\n\tICompleteTransferResponse,\n\tIDataspaceControlPlaneComponent,\n\tIGetTransferProcessRequest,\n\tIGetTransferProcessResponse,\n\tIRequestTransferRequest,\n\tIRequestTransferResponse,\n\tIStartTransferRequest,\n\tIStartTransferResponse,\n\tISuspendTransferRequest,\n\tISuspendTransferResponse,\n\tITerminateTransferRequest,\n\tITerminateTransferResponse\n} from \"@twin.org/dataspace-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDataspaceProtocolContexts,\n\tDataspaceProtocolTransferProcessStateType,\n\tDataspaceProtocolTransferProcessTypes\n} from \"@twin.org/standards-dataspace-protocol\";\nimport { HeaderHelper, HeaderTypes, MimeTypes } from \"@twin.org/web\";\nimport { transformErrorToStatusCode } from \"./utils/transferErrorUtils.js\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"dataspaceControlPlaneRoutes\";\n\n/**\n * The tags to associate with the DSP protocol routes.\n */\nexport const tagsDataspaceControlPlane: ITag[] = [\n\t{\n\t\tname: \"Transfer Process\",\n\t\tdescription:\n\t\t\t\"DSP Transfer Process Protocol endpoints for initiating and managing data transfers.\"\n\t}\n];\n\n// Example objects for API documentation\nconst requestTransferExample = {\n\t\"@context\": DataspaceProtocolContexts.Context,\n\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferRequestMessage,\n\tprocessId: \"urn:uuid:consumer-process-12345\",\n\tconsumerPid: \"urn:uuid:consumer-process-12345\",\n\tproviderPid: \"urn:uuid:provider-process-12345\",\n\tagreementId: \"urn:uuid:agreement-12345\",\n\tdataAddress: {\n\t\t\"@type\": DataspaceProtocolTransferProcessTypes.DataAddress,\n\t\t\"@id\": \"https://provider.example.com/data\",\n\t\tendpointType: \"https://w3id.org/dspace/v1/HttpDataAddress\",\n\t\tbaseUrl: \"https://provider.example.com/data\"\n\t},\n\tcallbackAddress: \"https://consumer.example.com/transfer/webhook\",\n\tformat: \"urn:example:format\"\n};\n\nconst transferProcessExample = {\n\t\"@context\": DataspaceProtocolContexts.Context,\n\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferProcess,\n\tprocessId: \"urn:uuid:provider-process-12345\",\n\tconsumerPid: \"urn:uuid:consumer-process-12345\",\n\tproviderPid: \"urn:uuid:provider-process-12345\",\n\tstate: DataspaceProtocolTransferProcessStateType.STARTED,\n\tdataAddress: {\n\t\t\"@type\": DataspaceProtocolTransferProcessTypes.DataAddress,\n\t\t\"@id\": \"https://provider.example.com/data/transfer-12345\",\n\t\tendpointType: \"https://w3id.org/dspace/v1/HttpDataAddress\",\n\t\tbaseUrl: \"https://provider.example.com/data/transfer-12345\"\n\t}\n};\n\n/**\n * The REST routes for dataspace control plane (DSP Protocol only).\n * These routes implement the Eclipse Dataspace Protocol Transfer Process Protocol.\n *\n * Contract Negotiation is handled internally via PNP callbacks — no REST endpoints needed.\n * PNP registers its own inbound callback routes for negotiation messages from providers.\n *\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 DSP protocol routes.\n */\nexport function generateRestRoutesDataspaceControlPlane(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\t// ============================================================================\n\t// TRANSFER PROCESS PROTOCOL (DSP)\n\t// ============================================================================\n\n\t// POST /transfers/request - Request Transfer Process (DSP)\n\tconst requestTransferRoute: IRestRoute<IRequestTransferRequest, IRequestTransferResponse> = {\n\t\toperationId: \"requestTransfer\",\n\t\tsummary: \"Request Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/request`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\trequestTransferHandler(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\tmimeType: MimeTypes.JsonLd,\n\t\t\ttype: nameof<IRequestTransferRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"requestTransferRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t[HeaderTypes.Authorization]: \"Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: requestTransferExample\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<IRequestTransferResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"requestTransferResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: transferProcessExample\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\t// GET /transfers/:pid - Get Transfer Process state (DSP)\n\tconst getTransferProcessRoute: IRestRoute<\n\t\tIGetTransferProcessRequest,\n\t\tIGetTransferProcessResponse\n\t> = {\n\t\toperationId: \"getTransferProcess\",\n\t\tsummary: \"Get Transfer Process state (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/transfers/:pid`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tgetTransferProcessHandler(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IGetTransferProcessRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"getTransferProcessRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\tauthorization: \"Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tpid: \"urn:uuid:provider-process-12345\"\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<IGetTransferProcessResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"getTransferProcessResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: transferProcessExample\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\t// POST /transfers/:pid/start - Start Transfer Process (DSP)\n\tconst startTransferRoute: IRestRoute<IStartTransferRequest, IStartTransferResponse> = {\n\t\toperationId: \"startTransfer\",\n\t\tsummary: \"Start Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/start`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tstartTransferHandler(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\tmimeType: MimeTypes.JsonLd,\n\t\t\ttype: nameof<IStartTransferRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"startTransferRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t[HeaderTypes.Authorization]: \"Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tpid: \"urn:uuid:consumer-process-12345\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": DataspaceProtocolContexts.Context,\n\t\t\t\t\t\t\t\"@type\": \"TransferStartMessage\",\n\t\t\t\t\t\t\tconsumerPid: \"urn:uuid:consumer-process-12345\",\n\t\t\t\t\t\t\tproviderPid: \"urn:uuid:provider-process-12345\"\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<IStartTransferResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"startTransferResponseExample\",\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\": DataspaceProtocolContexts.Context,\n\t\t\t\t\t\t\t\t\"@type\": DataspaceProtocolTransferProcessTypes.TransferStartMessage,\n\t\t\t\t\t\t\t\tconsumerPid: \"urn:uuid:consumer-process-12345\",\n\t\t\t\t\t\t\t\tproviderPid: \"urn:uuid:provider-process-12345\"\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\t// POST /transfers/:pid/complete - Complete Transfer Process (DSP)\n\tconst completeTransferRoute: IRestRoute<ICompleteTransferRequest, ICompleteTransferResponse> = {\n\t\toperationId: \"completeTransfer\",\n\t\tsummary: \"Complete Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/complete`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tcompleteTransferHandler(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\tmimeType: MimeTypes.JsonLd,\n\t\t\ttype: nameof<ICompleteTransferRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"completeTransferRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t[HeaderTypes.Authorization]: \"Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tpid: \"urn:uuid:consumer-process-12345\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": DataspaceProtocolContexts.Context,\n\t\t\t\t\t\t\t\"@type\": \"TransferCompletionMessage\",\n\t\t\t\t\t\t\tconsumerPid: \"urn:uuid:consumer-process-12345\",\n\t\t\t\t\t\t\tproviderPid: \"urn:uuid:provider-process-12345\"\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<ICompleteTransferResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"completeTransferResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t...transferProcessExample,\n\t\t\t\t\t\t\t\tstate: DataspaceProtocolTransferProcessStateType.COMPLETED\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\t// POST /transfers/:pid/suspend - Suspend Transfer Process (DSP)\n\tconst suspendTransferRoute: IRestRoute<ISuspendTransferRequest, ISuspendTransferResponse> = {\n\t\toperationId: \"suspendTransfer\",\n\t\tsummary: \"Suspend Transfer Process (DSP)\",\n\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/transfers/:pid/suspend`,\n\t\tskipAuth: true,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tsuspendTransferHandler(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\tmimeType: MimeTypes.JsonLd,\n\t\t\ttype: nameof<ISuspendTransferRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"suspendTransferRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t[HeaderTypes.Authorization]: \"Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tpid: \"urn:uuid:consumer-process-12345\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": DataspaceProtocolContexts.Context,\n\t\t\t\t\t\t\t\"@type\": \"TransferSuspensionMessage\",\n\t\t\t\t\t\t\tconsumerPid: \"urn:uuid:consumer-process-12345\",\n\t\t\t\t\t\t\tproviderPid: \"urn:uuid:provider-process-12345\"\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<ISuspendTransferResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"suspendTransferResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t...transferProcessExample,\n\t\t\t\t\t\t\t\tstate: DataspaceProtocolTransferProcessStateType.SUSPENDED\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\t// POST /transfers/:pid/terminate - Terminate Transfer Process (DSP)\n\tconst terminateTransferRoute: IRestRoute<ITerminateTransferRequest, ITerminateTransferResponse> =\n\t\t{\n\t\t\toperationId: \"terminateTransfer\",\n\t\t\tsummary: \"Terminate Transfer Process (DSP)\",\n\t\t\ttag: tagsDataspaceControlPlane[0].name,\n\t\t\tmethod: \"POST\",\n\t\t\tpath: `${baseRouteName}/transfers/:pid/terminate`,\n\t\t\tskipAuth: true,\n\t\t\thandler: async (httpRequestContext, request) =>\n\t\t\t\tterminateTransferHandler(httpRequestContext, componentName, request),\n\t\t\trequestType: {\n\t\t\t\tmimeType: MimeTypes.JsonLd,\n\t\t\t\ttype: nameof<ITerminateTransferRequest>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"terminateTransferRequestExample\",\n\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t[HeaderTypes.Authorization]: \"Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...\"\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\t\tpid: \"urn:uuid:consumer-process-12345\"\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": DataspaceProtocolContexts.Context,\n\t\t\t\t\t\t\t\t\"@type\": \"TransferTerminationMessage\",\n\t\t\t\t\t\t\t\tconsumerPid: \"urn:uuid:consumer-process-12345\",\n\t\t\t\t\t\t\t\tproviderPid: \"urn:uuid:provider-process-12345\"\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\tresponseType: [\n\t\t\t\t{\n\t\t\t\t\ttype: nameof<ITerminateTransferResponse>(),\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"terminateTransferResponseExample\",\n\t\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\t...transferProcessExample,\n\t\t\t\t\t\t\t\t\tstate: DataspaceProtocolTransferProcessStateType.TERMINATED\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\n\treturn [\n\t\trequestTransferRoute,\n\t\tgetTransferProcessRoute,\n\t\tstartTransferRoute,\n\t\tcompleteTransferRoute,\n\t\tsuspendTransferRoute,\n\t\tterminateTransferRoute\n\t];\n}\n\n// ============================================================================\n// TRANSFER PROCESS PROTOCOL HANDLERS\n// ============================================================================\n\n/**\n * Request Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers and body.\n * @returns The response.\n */\nasync function requestTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IRequestTransferRequest\n): Promise<IRequestTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.requestTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Get Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers and path parameters.\n * @returns The response.\n */\nasync function getTransferProcessHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IGetTransferProcessRequest\n): Promise<IGetTransferProcessResponse> {\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.pid), request.pathParams.pid);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.getTransferProcess(request.pathParams.pid, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Start Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function startTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IStartTransferRequest\n): Promise<IStartTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst hostingComponent = ComponentFactory.get<IHostingComponent>(\n\t\thttpRequestContext.hostingComponentType ?? \"hosting\"\n\t);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.startTransfer(\n\t\trequest.body,\n\t\tawait hostingComponent.getPublicOrigin(httpRequestContext.serverRequest.url),\n\t\ttrustPayload\n\t);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Complete Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function completeTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ICompleteTransferRequest\n): Promise<ICompleteTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.completeTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Suspend Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function suspendTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ISuspendTransferRequest\n): Promise<ISuspendTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.suspendTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n\n/**\n * Terminate Transfer Process handler.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use.\n * @param request The API request containing headers, path parameters, and body.\n * @returns The response.\n */\nasync function terminateTransferHandler(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ITerminateTransferRequest\n): Promise<ITerminateTransferResponse> {\n\tGuards.object(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst trustPayload = HeaderHelper.extractBearer(request.headers[HeaderTypes.Authorization]);\n\n\tconst component = ComponentFactory.get<IDataspaceControlPlaneComponent>(componentName);\n\tconst result = await component.terminateTransfer(request.body, trustPayload);\n\n\treturn {\n\t\tbody: result,\n\t\tstatusCode: transformErrorToStatusCode(result)\n\t};\n}\n"]}
|