@twin.org/engine-server 0.0.2-next.18 → 0.0.2-next.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +245 -165
- package/dist/esm/index.mjs +245 -165
- package/dist/types/engineServer.d.ts +3 -5
- package/dist/types/utils/engineServerConfigHelper.d.ts +1 -1
- package/docs/changelog.md +18 -0
- package/docs/reference/classes/EngineServer.md +2 -14
- package/docs/reference/functions/addDefaultRestPaths.md +1 -1
- package/package.json +12 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -6,6 +6,201 @@ var core = require('@twin.org/core');
|
|
|
6
6
|
var engineServerTypes = require('@twin.org/engine-server-types');
|
|
7
7
|
var modules = require('@twin.org/modules');
|
|
8
8
|
|
|
9
|
+
var serverRestRouteGenerators = [
|
|
10
|
+
{
|
|
11
|
+
type: "informationComponent",
|
|
12
|
+
module: "@twin.org/api-service",
|
|
13
|
+
method: "generateRestRoutesInformation",
|
|
14
|
+
defaultPath: ""
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: "authenticationComponent",
|
|
18
|
+
module: "@twin.org/api-auth-entity-storage-service",
|
|
19
|
+
method: "generateRestRoutesAuthentication",
|
|
20
|
+
defaultPath: "/authentication"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "loggingComponent",
|
|
24
|
+
module: "@twin.org/logging-service",
|
|
25
|
+
method: "generateRestRoutesLogging",
|
|
26
|
+
defaultPath: "/logging"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: "telemetryComponent",
|
|
30
|
+
module: "@twin.org/telemetry-service",
|
|
31
|
+
method: "generateRestRoutesTelemetry",
|
|
32
|
+
defaultPath: "/telemetry"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: "blobStorageComponent",
|
|
36
|
+
module: "@twin.org/blob-storage-service",
|
|
37
|
+
method: "generateRestRoutesBlobStorage",
|
|
38
|
+
defaultPath: "/blob"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: "identityComponent",
|
|
42
|
+
module: "@twin.org/identity-service",
|
|
43
|
+
method: "generateRestRoutesIdentity",
|
|
44
|
+
defaultPath: "/identity"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: "identityResolverComponent",
|
|
48
|
+
module: "@twin.org/identity-service",
|
|
49
|
+
method: "generateRestRoutesIdentityResolver",
|
|
50
|
+
defaultPath: "/identity"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: "identityProfileComponent",
|
|
54
|
+
module: "@twin.org/identity-service",
|
|
55
|
+
method: "generateRestRoutesIdentityProfile",
|
|
56
|
+
defaultPath: "/identity/profile"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: "nftComponent",
|
|
60
|
+
module: "@twin.org/nft-service",
|
|
61
|
+
method: "generateRestRoutesNft",
|
|
62
|
+
defaultPath: "/nft"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: "verifiableStorageComponent",
|
|
66
|
+
module: "@twin.org/verifiable-storage-service",
|
|
67
|
+
method: "generateRestRoutesVerifiableStorage",
|
|
68
|
+
defaultPath: "/verifiable"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: "immutableProofComponent",
|
|
72
|
+
module: "@twin.org/immutable-proof-service",
|
|
73
|
+
method: "generateRestRoutesImmutableProof",
|
|
74
|
+
defaultPath: "/immutable-proof"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: "attestationComponent",
|
|
78
|
+
module: "@twin.org/attestation-service",
|
|
79
|
+
method: "generateRestRoutesAttestation",
|
|
80
|
+
defaultPath: "/attestation"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: "auditableItemGraphComponent",
|
|
84
|
+
module: "@twin.org/auditable-item-graph-service",
|
|
85
|
+
method: "generateRestRoutesAuditableItemGraph",
|
|
86
|
+
defaultPath: "/aig"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: "auditableItemStreamComponent",
|
|
90
|
+
module: "@twin.org/auditable-item-stream-service",
|
|
91
|
+
method: "generateRestRoutesAuditableItemStream",
|
|
92
|
+
defaultPath: "/ais"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: "entityStorageComponent",
|
|
96
|
+
module: "@twin.org/entity-storage-service",
|
|
97
|
+
method: "generateRestRoutesEntityStorage"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: "dataProcessingComponent",
|
|
101
|
+
module: "@twin.org/data-processing-service",
|
|
102
|
+
method: "generateRestRoutesDataProcessing",
|
|
103
|
+
defaultPath: "/data-processing"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
type: "documentManagementComponent",
|
|
107
|
+
module: "@twin.org/document-management-service",
|
|
108
|
+
method: "generateRestRoutesDocumentManagement",
|
|
109
|
+
defaultPath: "/documents"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
type: "rightsManagementPapComponent",
|
|
113
|
+
module: "@twin.org/rights-management-service",
|
|
114
|
+
method: "generateRestRoutesPolicyAdministrationPoint",
|
|
115
|
+
defaultPath: "/rights-management"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
type: "rightsManagementPnpComponent",
|
|
119
|
+
module: "@twin.org/rights-management-service",
|
|
120
|
+
method: "generateRestRoutesPolicyNegotiationPoint",
|
|
121
|
+
defaultPath: "/rights-management"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
type: "rightsManagementPnapComponent",
|
|
125
|
+
module: "@twin.org/rights-management-service",
|
|
126
|
+
method: "generateRestRoutesPolicyNegotiationAdminPoint",
|
|
127
|
+
defaultPath: "/rights-management"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: "rightsManagementDapComponent",
|
|
131
|
+
module: "@twin.org/rights-management-service",
|
|
132
|
+
method: "generateRestRoutesDataAccessPoint",
|
|
133
|
+
defaultPath: "/rights-management"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
type: "synchronisedStorageComponent",
|
|
137
|
+
module: "@twin.org/synchronised-storage-service",
|
|
138
|
+
method: "generateRestRoutesSynchronisedStorage",
|
|
139
|
+
defaultPath: "/synchronised-storage"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
type: "federatedCatalogueComponent",
|
|
143
|
+
module: "@twin.org/federated-catalogue-service",
|
|
144
|
+
method: "generateRestRoutesFederatedCatalogue",
|
|
145
|
+
defaultPath: "/federated-catalogue"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
type: "dataSpaceConnectorComponent",
|
|
149
|
+
module: "@twin.org/data-space-connector-service",
|
|
150
|
+
method: "generateRestRoutesDataSpaceConnector",
|
|
151
|
+
defaultPath: "/data-space-connector"
|
|
152
|
+
}
|
|
153
|
+
];
|
|
154
|
+
|
|
155
|
+
var serverSocketRouteGenerators = [
|
|
156
|
+
{
|
|
157
|
+
type: "eventBusComponent",
|
|
158
|
+
module: "@twin.org/event-bus-service",
|
|
159
|
+
method: "generateSocketRoutesEventBus",
|
|
160
|
+
defaultPath: "event-bus"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
type: "dataSpaceConnectorComponent",
|
|
164
|
+
module: "@twin.org/data-space-connector-service",
|
|
165
|
+
method: "generateSocketRoutesDataSpaceConnector",
|
|
166
|
+
defaultPath: "data-space-connector"
|
|
167
|
+
}
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
var serverTypeInitialisers = [
|
|
171
|
+
{
|
|
172
|
+
type: "authenticationAdminComponent",
|
|
173
|
+
module: "@twin.org/engine-server-types",
|
|
174
|
+
method: "initialiseAuthenticationAdminComponent"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
type: "authenticationComponent",
|
|
178
|
+
module: "@twin.org/engine-server-types",
|
|
179
|
+
method: "initialiseAuthenticationComponent"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
type: "informationComponent",
|
|
183
|
+
module: "@twin.org/engine-server-types",
|
|
184
|
+
method: "initialiseInformationComponent",
|
|
185
|
+
defaultRestPath: ""
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
type: "restRouteProcessor",
|
|
189
|
+
module: "@twin.org/engine-server-types",
|
|
190
|
+
method: "initialiseRestRouteProcessorComponent"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
type: "socketRouteProcessor",
|
|
194
|
+
module: "@twin.org/engine-server-types",
|
|
195
|
+
method: "initialiseSocketRouteProcessorComponent"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
type: "mimeTypeProcessor",
|
|
199
|
+
module: "@twin.org/engine-server-types",
|
|
200
|
+
method: "initialiseMimeTypeProcessorComponent"
|
|
201
|
+
}
|
|
202
|
+
];
|
|
203
|
+
|
|
9
204
|
/**
|
|
10
205
|
* Server for the engine.
|
|
11
206
|
*/
|
|
@@ -112,36 +307,34 @@ class EngineServer {
|
|
|
112
307
|
/**
|
|
113
308
|
* Add a REST route generator.
|
|
114
309
|
* @param type The type to add the generator for.
|
|
115
|
-
* @param typeConfig The type config.
|
|
116
310
|
* @param module The module containing the generator.
|
|
117
311
|
* @param method The method to call on the module.
|
|
118
312
|
*/
|
|
119
|
-
addRestRouteGenerator(type,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
313
|
+
addRestRouteGenerator(type, module, method) {
|
|
314
|
+
core.Guards.stringValue(this.CLASS_NAME, "type", type);
|
|
315
|
+
core.Guards.stringValue(this.CLASS_NAME, "module", module);
|
|
316
|
+
core.Guards.stringValue(this.CLASS_NAME, "method", method);
|
|
317
|
+
this._restRouteGenerators.push({
|
|
318
|
+
type,
|
|
319
|
+
module,
|
|
320
|
+
method
|
|
321
|
+
});
|
|
128
322
|
}
|
|
129
323
|
/**
|
|
130
324
|
* Add a socket route generator.
|
|
131
325
|
* @param type The type to add the generator for.
|
|
132
|
-
* @param typeConfig The type config.
|
|
133
326
|
* @param module The module containing the generator.
|
|
134
327
|
* @param method The method to call on the module.
|
|
135
328
|
*/
|
|
136
|
-
addSocketRouteGenerator(type,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
329
|
+
addSocketRouteGenerator(type, module, method) {
|
|
330
|
+
core.Guards.stringValue(this.CLASS_NAME, "type", type);
|
|
331
|
+
core.Guards.stringValue(this.CLASS_NAME, "module", module);
|
|
332
|
+
core.Guards.stringValue(this.CLASS_NAME, "method", method);
|
|
333
|
+
this._socketRouteGenerators.push({
|
|
334
|
+
type,
|
|
335
|
+
module,
|
|
336
|
+
method
|
|
337
|
+
});
|
|
145
338
|
}
|
|
146
339
|
/**
|
|
147
340
|
* Get the built REST routes.
|
|
@@ -207,8 +400,8 @@ class EngineServer {
|
|
|
207
400
|
*/
|
|
208
401
|
async buildRestRoutes() {
|
|
209
402
|
const routes = [];
|
|
210
|
-
for (const { type,
|
|
211
|
-
await this.initialiseRestTypeRoute(routes, type,
|
|
403
|
+
for (const { type, module, method } of this._restRouteGenerators) {
|
|
404
|
+
await this.initialiseRestTypeRoute(routes, type, module, method);
|
|
212
405
|
}
|
|
213
406
|
return routes;
|
|
214
407
|
}
|
|
@@ -219,8 +412,8 @@ class EngineServer {
|
|
|
219
412
|
*/
|
|
220
413
|
async buildSocketRoutes() {
|
|
221
414
|
const routes = [];
|
|
222
|
-
for (const { type,
|
|
223
|
-
await this.initialiseSocketTypeRoute(routes, type,
|
|
415
|
+
for (const { type, module, method } of this._socketRouteGenerators) {
|
|
416
|
+
await this.initialiseSocketTypeRoute(routes, type, module, method);
|
|
224
417
|
}
|
|
225
418
|
return routes;
|
|
226
419
|
}
|
|
@@ -228,11 +421,11 @@ class EngineServer {
|
|
|
228
421
|
* Initialise the rest routes from connector.
|
|
229
422
|
* @param routes The routes to add to.
|
|
230
423
|
* @param typeKey The key for the default types.
|
|
231
|
-
* @param typeConfig The type config.
|
|
232
424
|
* @param generateRoutes The function to generate the routes.
|
|
233
425
|
* @internal
|
|
234
426
|
*/
|
|
235
|
-
async initialiseRestTypeRoute(routes, typeKey,
|
|
427
|
+
async initialiseRestTypeRoute(routes, typeKey, module, method) {
|
|
428
|
+
const typeConfig = this._engineCore.getTypeConfig(typeKey);
|
|
236
429
|
if (core.Is.arrayValue(typeConfig)) {
|
|
237
430
|
const generateRoutes = await modules.ModuleHelper.getModuleEntry(module, method);
|
|
238
431
|
for (let i = 0; i < typeConfig.length; i++) {
|
|
@@ -259,12 +452,12 @@ class EngineServer {
|
|
|
259
452
|
* Initialise the socket routes from connector.
|
|
260
453
|
* @param routes The routes to add to.
|
|
261
454
|
* @param typeKey The key for the default types.
|
|
262
|
-
* @param typeConfig The type config.
|
|
263
455
|
* @param module The module containing the generator.
|
|
264
456
|
* @param method The method to call on the module.
|
|
265
457
|
* @internal
|
|
266
458
|
*/
|
|
267
|
-
async initialiseSocketTypeRoute(routes, typeKey,
|
|
459
|
+
async initialiseSocketTypeRoute(routes, typeKey, module, method) {
|
|
460
|
+
const typeConfig = this._engineCore.getTypeConfig(typeKey);
|
|
268
461
|
if (core.Is.arrayValue(typeConfig)) {
|
|
269
462
|
const generateRoutes = await modules.ModuleHelper.getModuleEntry(module, method);
|
|
270
463
|
for (let i = 0; i < typeConfig.length; i++) {
|
|
@@ -285,157 +478,44 @@ class EngineServer {
|
|
|
285
478
|
* @internal
|
|
286
479
|
*/
|
|
287
480
|
addServerTypeInitialisers() {
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
this._engineCore.addTypeInitialiser("informationComponent", coreConfig.types.informationComponent, "@twin.org/engine-server-types", "initialiseInformationComponent");
|
|
292
|
-
this._engineCore.addTypeInitialiser("restRouteProcessor", coreConfig.types.restRouteProcessor, "@twin.org/engine-server-types", "initialiseRestRouteProcessorComponent");
|
|
293
|
-
this._engineCore.addTypeInitialiser("socketRouteProcessor", coreConfig.types.socketRouteProcessor, "@twin.org/engine-server-types", "initialiseSocketRouteProcessorComponent");
|
|
294
|
-
this._engineCore.addTypeInitialiser("mimeTypeProcessor", coreConfig.types.mimeTypeProcessor, "@twin.org/engine-server-types", "initialiseMimeTypeProcessorComponent");
|
|
481
|
+
for (const initializer of serverTypeInitialisers) {
|
|
482
|
+
this._engineCore.addTypeInitialiser(initializer.type, initializer.module, initializer.method);
|
|
483
|
+
}
|
|
295
484
|
}
|
|
296
485
|
/**
|
|
297
486
|
* Add the server REST route generators.
|
|
298
487
|
* @internal
|
|
299
488
|
*/
|
|
300
489
|
addServerRestRouteGenerators() {
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
this.addRestRouteGenerator("loggingComponent", coreConfig.types.loggingComponent, "@twin.org/logging-service", "generateRestRoutesLogging");
|
|
305
|
-
this.addRestRouteGenerator("telemetryComponent", coreConfig.types.telemetryComponent, "@twin.org/telemetry-service", "generateRestRoutesTelemetry");
|
|
306
|
-
this.addRestRouteGenerator("blobStorageComponent", coreConfig.types.blobStorageComponent, "@twin.org/blob-storage-service", "generateRestRoutesBlobStorage");
|
|
307
|
-
this.addRestRouteGenerator("identityComponent", coreConfig.types.identityComponent, "@twin.org/identity-service", "generateRestRoutesIdentity");
|
|
308
|
-
this.addRestRouteGenerator("identityResolverComponent", coreConfig.types.identityResolverComponent, "@twin.org/identity-service", "generateRestRoutesIdentityResolver");
|
|
309
|
-
this.addRestRouteGenerator("identityProfileComponent", coreConfig.types.identityProfileComponent, "@twin.org/identity-service", "generateRestRoutesIdentityProfile");
|
|
310
|
-
this.addRestRouteGenerator("nftComponent", coreConfig.types.nftComponent, "@twin.org/nft-service", "generateRestRoutesNft");
|
|
311
|
-
this.addRestRouteGenerator("verifiableStorageComponent", coreConfig.types.verifiableStorageComponent, "@twin.org/verifiable-storage-service", "generateRestRoutesVerifiableStorage");
|
|
312
|
-
this.addRestRouteGenerator("attestationComponent", coreConfig.types.attestationComponent, "@twin.org/attestation-service", "generateRestRoutesAttestation");
|
|
313
|
-
this.addRestRouteGenerator("immutableProofComponent", coreConfig.types.immutableProofComponent, "@twin.org/immutable-proof-service", "generateRestRoutesImmutableProof");
|
|
314
|
-
this.addRestRouteGenerator("auditableItemGraphComponent", coreConfig.types.auditableItemGraphComponent, "@twin.org/auditable-item-graph-service", "generateRestRoutesAuditableItemGraph");
|
|
315
|
-
this.addRestRouteGenerator("auditableItemStreamComponent", coreConfig.types.auditableItemStreamComponent, "@twin.org/auditable-item-stream-service", "generateRestRoutesAuditableItemStream");
|
|
316
|
-
this.addRestRouteGenerator("entityStorageComponent", coreConfig.types.entityStorageComponent, "@twin.org/entity-storage-service", "generateRestRoutesEntityStorage");
|
|
317
|
-
this.addRestRouteGenerator("dataProcessingComponent", coreConfig.types.dataProcessingComponent, "@twin.org/data-processing-service", "generateRestRoutesDataProcessing");
|
|
318
|
-
this.addRestRouteGenerator("documentManagementComponent", coreConfig.types.documentManagementComponent, "@twin.org/document-management-service", "generateRestRoutesDocumentManagement");
|
|
319
|
-
this.addRestRouteGenerator("rightsManagementPapComponent", coreConfig.types.rightsManagementPapComponent, "@twin.org/rights-management-service", "generateRestRoutesPolicyAdministrationPoint");
|
|
320
|
-
this.addRestRouteGenerator("rightsManagementPnpComponent", coreConfig.types.rightsManagementPnpComponent, "@twin.org/rights-management-service", "generateRestRoutesPolicyNegotiationPoint");
|
|
321
|
-
this.addRestRouteGenerator("rightsManagementPnapComponent", coreConfig.types.rightsManagementPnapComponent, "@twin.org/rights-management-service", "generateRestRoutesPolicyNegotiationAdminPoint");
|
|
322
|
-
this.addRestRouteGenerator("rightsManagementDapComponent", coreConfig.types.rightsManagementDapComponent, "@twin.org/rights-management-service", "generateRestRoutesDataAccessPoint");
|
|
323
|
-
this.addRestRouteGenerator("synchronisedStorageComponent", coreConfig.types.synchronisedStorageComponent, "@twin.org/synchronised-storage-service", "generateRestRoutesSynchronisedStorage");
|
|
324
|
-
this.addRestRouteGenerator("federatedCatalogueComponent", coreConfig.types.federatedCatalogueComponent, "@twin.org/federated-catalogue-service", "generateRestRoutesFederatedCatalogue");
|
|
325
|
-
this.addRestRouteGenerator("dataSpaceConnectorComponent", coreConfig.types.dataSpaceConnectorComponent, "@twin.org/data-space-connector-service", "generateRestRoutesDataSpaceConnector");
|
|
490
|
+
for (const generator of serverRestRouteGenerators) {
|
|
491
|
+
this.addRestRouteGenerator(generator.type, generator.module, generator.method);
|
|
492
|
+
}
|
|
326
493
|
}
|
|
327
494
|
/**
|
|
328
495
|
* Add the server socket route generators.
|
|
329
496
|
* @internal
|
|
330
497
|
*/
|
|
331
498
|
addServerSocketRouteGenerators() {
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
499
|
+
for (const generator of serverSocketRouteGenerators) {
|
|
500
|
+
this.addSocketRouteGenerator(generator.type, generator.module, generator.method);
|
|
501
|
+
}
|
|
335
502
|
}
|
|
336
503
|
}
|
|
337
504
|
|
|
338
505
|
// Copyright 2024 IOTA Stiftung.
|
|
339
506
|
// SPDX-License-Identifier: Apache-2.0.
|
|
340
507
|
/**
|
|
341
|
-
* Adds the rest paths to the server config.
|
|
508
|
+
* Adds the rest paths to the server config if not already set.
|
|
342
509
|
* @param serverConfig The server config.
|
|
343
510
|
*/
|
|
344
511
|
function addDefaultRestPaths(serverConfig) {
|
|
345
|
-
|
|
346
|
-
serverConfig.types.
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
if (core.Is.arrayValue(serverConfig.types.blobStorageComponent) &&
|
|
353
|
-
!core.Is.stringValue(serverConfig.types.blobStorageComponent[0].restPath)) {
|
|
354
|
-
serverConfig.types.blobStorageComponent[0].restPath = "/blob";
|
|
355
|
-
}
|
|
356
|
-
if (core.Is.arrayValue(serverConfig.types.loggingComponent) &&
|
|
357
|
-
!core.Is.stringValue(serverConfig.types.loggingComponent[0].restPath)) {
|
|
358
|
-
serverConfig.types.loggingComponent[0].restPath = "/logging";
|
|
359
|
-
}
|
|
360
|
-
if (core.Is.arrayValue(serverConfig.types.telemetryComponent) &&
|
|
361
|
-
!core.Is.stringValue(serverConfig.types.telemetryComponent[0].restPath)) {
|
|
362
|
-
serverConfig.types.telemetryComponent[0].restPath = "/telemetry";
|
|
363
|
-
}
|
|
364
|
-
if (core.Is.arrayValue(serverConfig.types.identityComponent) &&
|
|
365
|
-
!core.Is.stringValue(serverConfig.types.identityComponent[0].restPath)) {
|
|
366
|
-
serverConfig.types.identityComponent[0].restPath = "/identity";
|
|
367
|
-
}
|
|
368
|
-
if (core.Is.arrayValue(serverConfig.types.identityResolverComponent) &&
|
|
369
|
-
!core.Is.stringValue(serverConfig.types.identityResolverComponent[0].restPath)) {
|
|
370
|
-
serverConfig.types.identityResolverComponent[0].restPath = "/identity";
|
|
371
|
-
}
|
|
372
|
-
if (core.Is.arrayValue(serverConfig.types.identityProfileComponent) &&
|
|
373
|
-
!core.Is.stringValue(serverConfig.types.identityProfileComponent[0].restPath)) {
|
|
374
|
-
serverConfig.types.identityProfileComponent[0].restPath = "/identity/profile";
|
|
375
|
-
}
|
|
376
|
-
if (core.Is.arrayValue(serverConfig.types.nftComponent) &&
|
|
377
|
-
!core.Is.stringValue(serverConfig.types.nftComponent[0].restPath)) {
|
|
378
|
-
serverConfig.types.nftComponent[0].restPath = "/nft";
|
|
379
|
-
}
|
|
380
|
-
if (core.Is.arrayValue(serverConfig.types.verifiableStorageComponent) &&
|
|
381
|
-
!core.Is.stringValue(serverConfig.types.verifiableStorageComponent[0].restPath)) {
|
|
382
|
-
serverConfig.types.verifiableStorageComponent[0].restPath = "/verifiable";
|
|
383
|
-
}
|
|
384
|
-
if (core.Is.arrayValue(serverConfig.types.immutableProofComponent) &&
|
|
385
|
-
!core.Is.stringValue(serverConfig.types.immutableProofComponent[0].restPath)) {
|
|
386
|
-
serverConfig.types.immutableProofComponent[0].restPath = "/immutable-proof";
|
|
387
|
-
}
|
|
388
|
-
if (core.Is.arrayValue(serverConfig.types.attestationComponent) &&
|
|
389
|
-
!core.Is.stringValue(serverConfig.types.attestationComponent[0].restPath)) {
|
|
390
|
-
serverConfig.types.attestationComponent[0].restPath = "/attestation";
|
|
391
|
-
}
|
|
392
|
-
if (core.Is.arrayValue(serverConfig.types.auditableItemGraphComponent) &&
|
|
393
|
-
!core.Is.stringValue(serverConfig.types.auditableItemGraphComponent[0].restPath)) {
|
|
394
|
-
serverConfig.types.auditableItemGraphComponent[0].restPath = "/aig";
|
|
395
|
-
}
|
|
396
|
-
if (core.Is.arrayValue(serverConfig.types.auditableItemStreamComponent) &&
|
|
397
|
-
!core.Is.stringValue(serverConfig.types.auditableItemStreamComponent[0].restPath)) {
|
|
398
|
-
serverConfig.types.auditableItemStreamComponent[0].restPath = "/ais";
|
|
399
|
-
}
|
|
400
|
-
if (core.Is.arrayValue(serverConfig.types.dataProcessingComponent) &&
|
|
401
|
-
!core.Is.stringValue(serverConfig.types.dataProcessingComponent[0].restPath)) {
|
|
402
|
-
serverConfig.types.dataProcessingComponent[0].restPath = "/data-processing";
|
|
403
|
-
}
|
|
404
|
-
if (core.Is.arrayValue(serverConfig.types.documentManagementComponent) &&
|
|
405
|
-
!core.Is.stringValue(serverConfig.types.documentManagementComponent[0].restPath)) {
|
|
406
|
-
serverConfig.types.documentManagementComponent[0].restPath = "/documents";
|
|
407
|
-
}
|
|
408
|
-
if (core.Is.arrayValue(serverConfig.types.rightsManagementPapComponent) &&
|
|
409
|
-
!core.Is.stringValue(serverConfig.types.rightsManagementPapComponent[0].restPath)) {
|
|
410
|
-
serverConfig.types.rightsManagementPapComponent[0].restPath = "/rights-management";
|
|
411
|
-
}
|
|
412
|
-
if (core.Is.arrayValue(serverConfig.types.rightsManagementPepComponent) &&
|
|
413
|
-
!core.Is.stringValue(serverConfig.types.rightsManagementPepComponent[0].restPath)) {
|
|
414
|
-
serverConfig.types.rightsManagementPepComponent[0].restPath = "/rights-management";
|
|
415
|
-
}
|
|
416
|
-
if (core.Is.arrayValue(serverConfig.types.rightsManagementPnpComponent) &&
|
|
417
|
-
!core.Is.stringValue(serverConfig.types.rightsManagementPnpComponent[0].restPath)) {
|
|
418
|
-
serverConfig.types.rightsManagementPnpComponent[0].restPath = "/rights-management";
|
|
419
|
-
}
|
|
420
|
-
if (core.Is.arrayValue(serverConfig.types.rightsManagementPnapComponent) &&
|
|
421
|
-
!core.Is.stringValue(serverConfig.types.rightsManagementPnapComponent[0].restPath)) {
|
|
422
|
-
serverConfig.types.rightsManagementPnapComponent[0].restPath = "/rights-management";
|
|
423
|
-
}
|
|
424
|
-
if (core.Is.arrayValue(serverConfig.types.rightsManagementDapComponent) &&
|
|
425
|
-
!core.Is.stringValue(serverConfig.types.rightsManagementDapComponent[0].restPath)) {
|
|
426
|
-
serverConfig.types.rightsManagementDapComponent[0].restPath = "/rights-management";
|
|
427
|
-
}
|
|
428
|
-
if (core.Is.arrayValue(serverConfig.types.synchronisedStorageComponent) &&
|
|
429
|
-
!core.Is.stringValue(serverConfig.types.synchronisedStorageComponent[0].restPath)) {
|
|
430
|
-
serverConfig.types.synchronisedStorageComponent[0].restPath = "/synchronised-storage";
|
|
431
|
-
}
|
|
432
|
-
if (core.Is.arrayValue(serverConfig.types.federatedCatalogueComponent) &&
|
|
433
|
-
!core.Is.stringValue(serverConfig.types.federatedCatalogueComponent[0].restPath)) {
|
|
434
|
-
serverConfig.types.federatedCatalogueComponent[0].restPath = "/federated-catalogue";
|
|
435
|
-
}
|
|
436
|
-
if (core.Is.arrayValue(serverConfig.types.dataSpaceConnectorComponent) &&
|
|
437
|
-
!core.Is.stringValue(serverConfig.types.dataSpaceConnectorComponent[0].restPath)) {
|
|
438
|
-
serverConfig.types.dataSpaceConnectorComponent[0].restPath = "/data-space-connector";
|
|
512
|
+
for (const routeGenerator of serverRestRouteGenerators) {
|
|
513
|
+
const types = serverConfig.types[routeGenerator.type];
|
|
514
|
+
if (core.Is.arrayValue(types) &&
|
|
515
|
+
!core.Is.stringValue(types[0].restPath) &&
|
|
516
|
+
core.Is.string(routeGenerator.defaultPath)) {
|
|
517
|
+
types[0].restPath = routeGenerator.defaultPath;
|
|
518
|
+
}
|
|
439
519
|
}
|
|
440
520
|
}
|
|
441
521
|
/**
|
|
@@ -443,13 +523,13 @@ function addDefaultRestPaths(serverConfig) {
|
|
|
443
523
|
* @param serverConfig The server config.
|
|
444
524
|
*/
|
|
445
525
|
function addDefaultSocketPaths(serverConfig) {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
526
|
+
for (const routeGenerator of serverSocketRouteGenerators) {
|
|
527
|
+
const types = serverConfig.types[routeGenerator.type];
|
|
528
|
+
if (core.Is.arrayValue(types) &&
|
|
529
|
+
!core.Is.stringValue(types[0].socketPath) &&
|
|
530
|
+
core.Is.stringValue(routeGenerator.defaultPath)) {
|
|
531
|
+
types[0].socketPath = routeGenerator.defaultPath;
|
|
532
|
+
}
|
|
453
533
|
}
|
|
454
534
|
}
|
|
455
535
|
|
package/dist/esm/index.mjs
CHANGED
|
@@ -4,6 +4,201 @@ import { Guards, Is, StringHelper } from '@twin.org/core';
|
|
|
4
4
|
import { RestRouteProcessorType, SocketRouteProcessorType } from '@twin.org/engine-server-types';
|
|
5
5
|
import { ModuleHelper } from '@twin.org/modules';
|
|
6
6
|
|
|
7
|
+
var serverRestRouteGenerators = [
|
|
8
|
+
{
|
|
9
|
+
type: "informationComponent",
|
|
10
|
+
module: "@twin.org/api-service",
|
|
11
|
+
method: "generateRestRoutesInformation",
|
|
12
|
+
defaultPath: ""
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: "authenticationComponent",
|
|
16
|
+
module: "@twin.org/api-auth-entity-storage-service",
|
|
17
|
+
method: "generateRestRoutesAuthentication",
|
|
18
|
+
defaultPath: "/authentication"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: "loggingComponent",
|
|
22
|
+
module: "@twin.org/logging-service",
|
|
23
|
+
method: "generateRestRoutesLogging",
|
|
24
|
+
defaultPath: "/logging"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: "telemetryComponent",
|
|
28
|
+
module: "@twin.org/telemetry-service",
|
|
29
|
+
method: "generateRestRoutesTelemetry",
|
|
30
|
+
defaultPath: "/telemetry"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: "blobStorageComponent",
|
|
34
|
+
module: "@twin.org/blob-storage-service",
|
|
35
|
+
method: "generateRestRoutesBlobStorage",
|
|
36
|
+
defaultPath: "/blob"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: "identityComponent",
|
|
40
|
+
module: "@twin.org/identity-service",
|
|
41
|
+
method: "generateRestRoutesIdentity",
|
|
42
|
+
defaultPath: "/identity"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: "identityResolverComponent",
|
|
46
|
+
module: "@twin.org/identity-service",
|
|
47
|
+
method: "generateRestRoutesIdentityResolver",
|
|
48
|
+
defaultPath: "/identity"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: "identityProfileComponent",
|
|
52
|
+
module: "@twin.org/identity-service",
|
|
53
|
+
method: "generateRestRoutesIdentityProfile",
|
|
54
|
+
defaultPath: "/identity/profile"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: "nftComponent",
|
|
58
|
+
module: "@twin.org/nft-service",
|
|
59
|
+
method: "generateRestRoutesNft",
|
|
60
|
+
defaultPath: "/nft"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: "verifiableStorageComponent",
|
|
64
|
+
module: "@twin.org/verifiable-storage-service",
|
|
65
|
+
method: "generateRestRoutesVerifiableStorage",
|
|
66
|
+
defaultPath: "/verifiable"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: "immutableProofComponent",
|
|
70
|
+
module: "@twin.org/immutable-proof-service",
|
|
71
|
+
method: "generateRestRoutesImmutableProof",
|
|
72
|
+
defaultPath: "/immutable-proof"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: "attestationComponent",
|
|
76
|
+
module: "@twin.org/attestation-service",
|
|
77
|
+
method: "generateRestRoutesAttestation",
|
|
78
|
+
defaultPath: "/attestation"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: "auditableItemGraphComponent",
|
|
82
|
+
module: "@twin.org/auditable-item-graph-service",
|
|
83
|
+
method: "generateRestRoutesAuditableItemGraph",
|
|
84
|
+
defaultPath: "/aig"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: "auditableItemStreamComponent",
|
|
88
|
+
module: "@twin.org/auditable-item-stream-service",
|
|
89
|
+
method: "generateRestRoutesAuditableItemStream",
|
|
90
|
+
defaultPath: "/ais"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: "entityStorageComponent",
|
|
94
|
+
module: "@twin.org/entity-storage-service",
|
|
95
|
+
method: "generateRestRoutesEntityStorage"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: "dataProcessingComponent",
|
|
99
|
+
module: "@twin.org/data-processing-service",
|
|
100
|
+
method: "generateRestRoutesDataProcessing",
|
|
101
|
+
defaultPath: "/data-processing"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
type: "documentManagementComponent",
|
|
105
|
+
module: "@twin.org/document-management-service",
|
|
106
|
+
method: "generateRestRoutesDocumentManagement",
|
|
107
|
+
defaultPath: "/documents"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
type: "rightsManagementPapComponent",
|
|
111
|
+
module: "@twin.org/rights-management-service",
|
|
112
|
+
method: "generateRestRoutesPolicyAdministrationPoint",
|
|
113
|
+
defaultPath: "/rights-management"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
type: "rightsManagementPnpComponent",
|
|
117
|
+
module: "@twin.org/rights-management-service",
|
|
118
|
+
method: "generateRestRoutesPolicyNegotiationPoint",
|
|
119
|
+
defaultPath: "/rights-management"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: "rightsManagementPnapComponent",
|
|
123
|
+
module: "@twin.org/rights-management-service",
|
|
124
|
+
method: "generateRestRoutesPolicyNegotiationAdminPoint",
|
|
125
|
+
defaultPath: "/rights-management"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: "rightsManagementDapComponent",
|
|
129
|
+
module: "@twin.org/rights-management-service",
|
|
130
|
+
method: "generateRestRoutesDataAccessPoint",
|
|
131
|
+
defaultPath: "/rights-management"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: "synchronisedStorageComponent",
|
|
135
|
+
module: "@twin.org/synchronised-storage-service",
|
|
136
|
+
method: "generateRestRoutesSynchronisedStorage",
|
|
137
|
+
defaultPath: "/synchronised-storage"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
type: "federatedCatalogueComponent",
|
|
141
|
+
module: "@twin.org/federated-catalogue-service",
|
|
142
|
+
method: "generateRestRoutesFederatedCatalogue",
|
|
143
|
+
defaultPath: "/federated-catalogue"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
type: "dataSpaceConnectorComponent",
|
|
147
|
+
module: "@twin.org/data-space-connector-service",
|
|
148
|
+
method: "generateRestRoutesDataSpaceConnector",
|
|
149
|
+
defaultPath: "/data-space-connector"
|
|
150
|
+
}
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
var serverSocketRouteGenerators = [
|
|
154
|
+
{
|
|
155
|
+
type: "eventBusComponent",
|
|
156
|
+
module: "@twin.org/event-bus-service",
|
|
157
|
+
method: "generateSocketRoutesEventBus",
|
|
158
|
+
defaultPath: "event-bus"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
type: "dataSpaceConnectorComponent",
|
|
162
|
+
module: "@twin.org/data-space-connector-service",
|
|
163
|
+
method: "generateSocketRoutesDataSpaceConnector",
|
|
164
|
+
defaultPath: "data-space-connector"
|
|
165
|
+
}
|
|
166
|
+
];
|
|
167
|
+
|
|
168
|
+
var serverTypeInitialisers = [
|
|
169
|
+
{
|
|
170
|
+
type: "authenticationAdminComponent",
|
|
171
|
+
module: "@twin.org/engine-server-types",
|
|
172
|
+
method: "initialiseAuthenticationAdminComponent"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
type: "authenticationComponent",
|
|
176
|
+
module: "@twin.org/engine-server-types",
|
|
177
|
+
method: "initialiseAuthenticationComponent"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
type: "informationComponent",
|
|
181
|
+
module: "@twin.org/engine-server-types",
|
|
182
|
+
method: "initialiseInformationComponent",
|
|
183
|
+
defaultRestPath: ""
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
type: "restRouteProcessor",
|
|
187
|
+
module: "@twin.org/engine-server-types",
|
|
188
|
+
method: "initialiseRestRouteProcessorComponent"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
type: "socketRouteProcessor",
|
|
192
|
+
module: "@twin.org/engine-server-types",
|
|
193
|
+
method: "initialiseSocketRouteProcessorComponent"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
type: "mimeTypeProcessor",
|
|
197
|
+
module: "@twin.org/engine-server-types",
|
|
198
|
+
method: "initialiseMimeTypeProcessorComponent"
|
|
199
|
+
}
|
|
200
|
+
];
|
|
201
|
+
|
|
7
202
|
/**
|
|
8
203
|
* Server for the engine.
|
|
9
204
|
*/
|
|
@@ -110,36 +305,34 @@ class EngineServer {
|
|
|
110
305
|
/**
|
|
111
306
|
* Add a REST route generator.
|
|
112
307
|
* @param type The type to add the generator for.
|
|
113
|
-
* @param typeConfig The type config.
|
|
114
308
|
* @param module The module containing the generator.
|
|
115
309
|
* @param method The method to call on the module.
|
|
116
310
|
*/
|
|
117
|
-
addRestRouteGenerator(type,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
311
|
+
addRestRouteGenerator(type, module, method) {
|
|
312
|
+
Guards.stringValue(this.CLASS_NAME, "type", type);
|
|
313
|
+
Guards.stringValue(this.CLASS_NAME, "module", module);
|
|
314
|
+
Guards.stringValue(this.CLASS_NAME, "method", method);
|
|
315
|
+
this._restRouteGenerators.push({
|
|
316
|
+
type,
|
|
317
|
+
module,
|
|
318
|
+
method
|
|
319
|
+
});
|
|
126
320
|
}
|
|
127
321
|
/**
|
|
128
322
|
* Add a socket route generator.
|
|
129
323
|
* @param type The type to add the generator for.
|
|
130
|
-
* @param typeConfig The type config.
|
|
131
324
|
* @param module The module containing the generator.
|
|
132
325
|
* @param method The method to call on the module.
|
|
133
326
|
*/
|
|
134
|
-
addSocketRouteGenerator(type,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
327
|
+
addSocketRouteGenerator(type, module, method) {
|
|
328
|
+
Guards.stringValue(this.CLASS_NAME, "type", type);
|
|
329
|
+
Guards.stringValue(this.CLASS_NAME, "module", module);
|
|
330
|
+
Guards.stringValue(this.CLASS_NAME, "method", method);
|
|
331
|
+
this._socketRouteGenerators.push({
|
|
332
|
+
type,
|
|
333
|
+
module,
|
|
334
|
+
method
|
|
335
|
+
});
|
|
143
336
|
}
|
|
144
337
|
/**
|
|
145
338
|
* Get the built REST routes.
|
|
@@ -205,8 +398,8 @@ class EngineServer {
|
|
|
205
398
|
*/
|
|
206
399
|
async buildRestRoutes() {
|
|
207
400
|
const routes = [];
|
|
208
|
-
for (const { type,
|
|
209
|
-
await this.initialiseRestTypeRoute(routes, type,
|
|
401
|
+
for (const { type, module, method } of this._restRouteGenerators) {
|
|
402
|
+
await this.initialiseRestTypeRoute(routes, type, module, method);
|
|
210
403
|
}
|
|
211
404
|
return routes;
|
|
212
405
|
}
|
|
@@ -217,8 +410,8 @@ class EngineServer {
|
|
|
217
410
|
*/
|
|
218
411
|
async buildSocketRoutes() {
|
|
219
412
|
const routes = [];
|
|
220
|
-
for (const { type,
|
|
221
|
-
await this.initialiseSocketTypeRoute(routes, type,
|
|
413
|
+
for (const { type, module, method } of this._socketRouteGenerators) {
|
|
414
|
+
await this.initialiseSocketTypeRoute(routes, type, module, method);
|
|
222
415
|
}
|
|
223
416
|
return routes;
|
|
224
417
|
}
|
|
@@ -226,11 +419,11 @@ class EngineServer {
|
|
|
226
419
|
* Initialise the rest routes from connector.
|
|
227
420
|
* @param routes The routes to add to.
|
|
228
421
|
* @param typeKey The key for the default types.
|
|
229
|
-
* @param typeConfig The type config.
|
|
230
422
|
* @param generateRoutes The function to generate the routes.
|
|
231
423
|
* @internal
|
|
232
424
|
*/
|
|
233
|
-
async initialiseRestTypeRoute(routes, typeKey,
|
|
425
|
+
async initialiseRestTypeRoute(routes, typeKey, module, method) {
|
|
426
|
+
const typeConfig = this._engineCore.getTypeConfig(typeKey);
|
|
234
427
|
if (Is.arrayValue(typeConfig)) {
|
|
235
428
|
const generateRoutes = await ModuleHelper.getModuleEntry(module, method);
|
|
236
429
|
for (let i = 0; i < typeConfig.length; i++) {
|
|
@@ -257,12 +450,12 @@ class EngineServer {
|
|
|
257
450
|
* Initialise the socket routes from connector.
|
|
258
451
|
* @param routes The routes to add to.
|
|
259
452
|
* @param typeKey The key for the default types.
|
|
260
|
-
* @param typeConfig The type config.
|
|
261
453
|
* @param module The module containing the generator.
|
|
262
454
|
* @param method The method to call on the module.
|
|
263
455
|
* @internal
|
|
264
456
|
*/
|
|
265
|
-
async initialiseSocketTypeRoute(routes, typeKey,
|
|
457
|
+
async initialiseSocketTypeRoute(routes, typeKey, module, method) {
|
|
458
|
+
const typeConfig = this._engineCore.getTypeConfig(typeKey);
|
|
266
459
|
if (Is.arrayValue(typeConfig)) {
|
|
267
460
|
const generateRoutes = await ModuleHelper.getModuleEntry(module, method);
|
|
268
461
|
for (let i = 0; i < typeConfig.length; i++) {
|
|
@@ -283,157 +476,44 @@ class EngineServer {
|
|
|
283
476
|
* @internal
|
|
284
477
|
*/
|
|
285
478
|
addServerTypeInitialisers() {
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
this._engineCore.addTypeInitialiser("informationComponent", coreConfig.types.informationComponent, "@twin.org/engine-server-types", "initialiseInformationComponent");
|
|
290
|
-
this._engineCore.addTypeInitialiser("restRouteProcessor", coreConfig.types.restRouteProcessor, "@twin.org/engine-server-types", "initialiseRestRouteProcessorComponent");
|
|
291
|
-
this._engineCore.addTypeInitialiser("socketRouteProcessor", coreConfig.types.socketRouteProcessor, "@twin.org/engine-server-types", "initialiseSocketRouteProcessorComponent");
|
|
292
|
-
this._engineCore.addTypeInitialiser("mimeTypeProcessor", coreConfig.types.mimeTypeProcessor, "@twin.org/engine-server-types", "initialiseMimeTypeProcessorComponent");
|
|
479
|
+
for (const initializer of serverTypeInitialisers) {
|
|
480
|
+
this._engineCore.addTypeInitialiser(initializer.type, initializer.module, initializer.method);
|
|
481
|
+
}
|
|
293
482
|
}
|
|
294
483
|
/**
|
|
295
484
|
* Add the server REST route generators.
|
|
296
485
|
* @internal
|
|
297
486
|
*/
|
|
298
487
|
addServerRestRouteGenerators() {
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
this.addRestRouteGenerator("loggingComponent", coreConfig.types.loggingComponent, "@twin.org/logging-service", "generateRestRoutesLogging");
|
|
303
|
-
this.addRestRouteGenerator("telemetryComponent", coreConfig.types.telemetryComponent, "@twin.org/telemetry-service", "generateRestRoutesTelemetry");
|
|
304
|
-
this.addRestRouteGenerator("blobStorageComponent", coreConfig.types.blobStorageComponent, "@twin.org/blob-storage-service", "generateRestRoutesBlobStorage");
|
|
305
|
-
this.addRestRouteGenerator("identityComponent", coreConfig.types.identityComponent, "@twin.org/identity-service", "generateRestRoutesIdentity");
|
|
306
|
-
this.addRestRouteGenerator("identityResolverComponent", coreConfig.types.identityResolverComponent, "@twin.org/identity-service", "generateRestRoutesIdentityResolver");
|
|
307
|
-
this.addRestRouteGenerator("identityProfileComponent", coreConfig.types.identityProfileComponent, "@twin.org/identity-service", "generateRestRoutesIdentityProfile");
|
|
308
|
-
this.addRestRouteGenerator("nftComponent", coreConfig.types.nftComponent, "@twin.org/nft-service", "generateRestRoutesNft");
|
|
309
|
-
this.addRestRouteGenerator("verifiableStorageComponent", coreConfig.types.verifiableStorageComponent, "@twin.org/verifiable-storage-service", "generateRestRoutesVerifiableStorage");
|
|
310
|
-
this.addRestRouteGenerator("attestationComponent", coreConfig.types.attestationComponent, "@twin.org/attestation-service", "generateRestRoutesAttestation");
|
|
311
|
-
this.addRestRouteGenerator("immutableProofComponent", coreConfig.types.immutableProofComponent, "@twin.org/immutable-proof-service", "generateRestRoutesImmutableProof");
|
|
312
|
-
this.addRestRouteGenerator("auditableItemGraphComponent", coreConfig.types.auditableItemGraphComponent, "@twin.org/auditable-item-graph-service", "generateRestRoutesAuditableItemGraph");
|
|
313
|
-
this.addRestRouteGenerator("auditableItemStreamComponent", coreConfig.types.auditableItemStreamComponent, "@twin.org/auditable-item-stream-service", "generateRestRoutesAuditableItemStream");
|
|
314
|
-
this.addRestRouteGenerator("entityStorageComponent", coreConfig.types.entityStorageComponent, "@twin.org/entity-storage-service", "generateRestRoutesEntityStorage");
|
|
315
|
-
this.addRestRouteGenerator("dataProcessingComponent", coreConfig.types.dataProcessingComponent, "@twin.org/data-processing-service", "generateRestRoutesDataProcessing");
|
|
316
|
-
this.addRestRouteGenerator("documentManagementComponent", coreConfig.types.documentManagementComponent, "@twin.org/document-management-service", "generateRestRoutesDocumentManagement");
|
|
317
|
-
this.addRestRouteGenerator("rightsManagementPapComponent", coreConfig.types.rightsManagementPapComponent, "@twin.org/rights-management-service", "generateRestRoutesPolicyAdministrationPoint");
|
|
318
|
-
this.addRestRouteGenerator("rightsManagementPnpComponent", coreConfig.types.rightsManagementPnpComponent, "@twin.org/rights-management-service", "generateRestRoutesPolicyNegotiationPoint");
|
|
319
|
-
this.addRestRouteGenerator("rightsManagementPnapComponent", coreConfig.types.rightsManagementPnapComponent, "@twin.org/rights-management-service", "generateRestRoutesPolicyNegotiationAdminPoint");
|
|
320
|
-
this.addRestRouteGenerator("rightsManagementDapComponent", coreConfig.types.rightsManagementDapComponent, "@twin.org/rights-management-service", "generateRestRoutesDataAccessPoint");
|
|
321
|
-
this.addRestRouteGenerator("synchronisedStorageComponent", coreConfig.types.synchronisedStorageComponent, "@twin.org/synchronised-storage-service", "generateRestRoutesSynchronisedStorage");
|
|
322
|
-
this.addRestRouteGenerator("federatedCatalogueComponent", coreConfig.types.federatedCatalogueComponent, "@twin.org/federated-catalogue-service", "generateRestRoutesFederatedCatalogue");
|
|
323
|
-
this.addRestRouteGenerator("dataSpaceConnectorComponent", coreConfig.types.dataSpaceConnectorComponent, "@twin.org/data-space-connector-service", "generateRestRoutesDataSpaceConnector");
|
|
488
|
+
for (const generator of serverRestRouteGenerators) {
|
|
489
|
+
this.addRestRouteGenerator(generator.type, generator.module, generator.method);
|
|
490
|
+
}
|
|
324
491
|
}
|
|
325
492
|
/**
|
|
326
493
|
* Add the server socket route generators.
|
|
327
494
|
* @internal
|
|
328
495
|
*/
|
|
329
496
|
addServerSocketRouteGenerators() {
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
497
|
+
for (const generator of serverSocketRouteGenerators) {
|
|
498
|
+
this.addSocketRouteGenerator(generator.type, generator.module, generator.method);
|
|
499
|
+
}
|
|
333
500
|
}
|
|
334
501
|
}
|
|
335
502
|
|
|
336
503
|
// Copyright 2024 IOTA Stiftung.
|
|
337
504
|
// SPDX-License-Identifier: Apache-2.0.
|
|
338
505
|
/**
|
|
339
|
-
* Adds the rest paths to the server config.
|
|
506
|
+
* Adds the rest paths to the server config if not already set.
|
|
340
507
|
* @param serverConfig The server config.
|
|
341
508
|
*/
|
|
342
509
|
function addDefaultRestPaths(serverConfig) {
|
|
343
|
-
|
|
344
|
-
serverConfig.types.
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
if (Is.arrayValue(serverConfig.types.blobStorageComponent) &&
|
|
351
|
-
!Is.stringValue(serverConfig.types.blobStorageComponent[0].restPath)) {
|
|
352
|
-
serverConfig.types.blobStorageComponent[0].restPath = "/blob";
|
|
353
|
-
}
|
|
354
|
-
if (Is.arrayValue(serverConfig.types.loggingComponent) &&
|
|
355
|
-
!Is.stringValue(serverConfig.types.loggingComponent[0].restPath)) {
|
|
356
|
-
serverConfig.types.loggingComponent[0].restPath = "/logging";
|
|
357
|
-
}
|
|
358
|
-
if (Is.arrayValue(serverConfig.types.telemetryComponent) &&
|
|
359
|
-
!Is.stringValue(serverConfig.types.telemetryComponent[0].restPath)) {
|
|
360
|
-
serverConfig.types.telemetryComponent[0].restPath = "/telemetry";
|
|
361
|
-
}
|
|
362
|
-
if (Is.arrayValue(serverConfig.types.identityComponent) &&
|
|
363
|
-
!Is.stringValue(serverConfig.types.identityComponent[0].restPath)) {
|
|
364
|
-
serverConfig.types.identityComponent[0].restPath = "/identity";
|
|
365
|
-
}
|
|
366
|
-
if (Is.arrayValue(serverConfig.types.identityResolverComponent) &&
|
|
367
|
-
!Is.stringValue(serverConfig.types.identityResolverComponent[0].restPath)) {
|
|
368
|
-
serverConfig.types.identityResolverComponent[0].restPath = "/identity";
|
|
369
|
-
}
|
|
370
|
-
if (Is.arrayValue(serverConfig.types.identityProfileComponent) &&
|
|
371
|
-
!Is.stringValue(serverConfig.types.identityProfileComponent[0].restPath)) {
|
|
372
|
-
serverConfig.types.identityProfileComponent[0].restPath = "/identity/profile";
|
|
373
|
-
}
|
|
374
|
-
if (Is.arrayValue(serverConfig.types.nftComponent) &&
|
|
375
|
-
!Is.stringValue(serverConfig.types.nftComponent[0].restPath)) {
|
|
376
|
-
serverConfig.types.nftComponent[0].restPath = "/nft";
|
|
377
|
-
}
|
|
378
|
-
if (Is.arrayValue(serverConfig.types.verifiableStorageComponent) &&
|
|
379
|
-
!Is.stringValue(serverConfig.types.verifiableStorageComponent[0].restPath)) {
|
|
380
|
-
serverConfig.types.verifiableStorageComponent[0].restPath = "/verifiable";
|
|
381
|
-
}
|
|
382
|
-
if (Is.arrayValue(serverConfig.types.immutableProofComponent) &&
|
|
383
|
-
!Is.stringValue(serverConfig.types.immutableProofComponent[0].restPath)) {
|
|
384
|
-
serverConfig.types.immutableProofComponent[0].restPath = "/immutable-proof";
|
|
385
|
-
}
|
|
386
|
-
if (Is.arrayValue(serverConfig.types.attestationComponent) &&
|
|
387
|
-
!Is.stringValue(serverConfig.types.attestationComponent[0].restPath)) {
|
|
388
|
-
serverConfig.types.attestationComponent[0].restPath = "/attestation";
|
|
389
|
-
}
|
|
390
|
-
if (Is.arrayValue(serverConfig.types.auditableItemGraphComponent) &&
|
|
391
|
-
!Is.stringValue(serverConfig.types.auditableItemGraphComponent[0].restPath)) {
|
|
392
|
-
serverConfig.types.auditableItemGraphComponent[0].restPath = "/aig";
|
|
393
|
-
}
|
|
394
|
-
if (Is.arrayValue(serverConfig.types.auditableItemStreamComponent) &&
|
|
395
|
-
!Is.stringValue(serverConfig.types.auditableItemStreamComponent[0].restPath)) {
|
|
396
|
-
serverConfig.types.auditableItemStreamComponent[0].restPath = "/ais";
|
|
397
|
-
}
|
|
398
|
-
if (Is.arrayValue(serverConfig.types.dataProcessingComponent) &&
|
|
399
|
-
!Is.stringValue(serverConfig.types.dataProcessingComponent[0].restPath)) {
|
|
400
|
-
serverConfig.types.dataProcessingComponent[0].restPath = "/data-processing";
|
|
401
|
-
}
|
|
402
|
-
if (Is.arrayValue(serverConfig.types.documentManagementComponent) &&
|
|
403
|
-
!Is.stringValue(serverConfig.types.documentManagementComponent[0].restPath)) {
|
|
404
|
-
serverConfig.types.documentManagementComponent[0].restPath = "/documents";
|
|
405
|
-
}
|
|
406
|
-
if (Is.arrayValue(serverConfig.types.rightsManagementPapComponent) &&
|
|
407
|
-
!Is.stringValue(serverConfig.types.rightsManagementPapComponent[0].restPath)) {
|
|
408
|
-
serverConfig.types.rightsManagementPapComponent[0].restPath = "/rights-management";
|
|
409
|
-
}
|
|
410
|
-
if (Is.arrayValue(serverConfig.types.rightsManagementPepComponent) &&
|
|
411
|
-
!Is.stringValue(serverConfig.types.rightsManagementPepComponent[0].restPath)) {
|
|
412
|
-
serverConfig.types.rightsManagementPepComponent[0].restPath = "/rights-management";
|
|
413
|
-
}
|
|
414
|
-
if (Is.arrayValue(serverConfig.types.rightsManagementPnpComponent) &&
|
|
415
|
-
!Is.stringValue(serverConfig.types.rightsManagementPnpComponent[0].restPath)) {
|
|
416
|
-
serverConfig.types.rightsManagementPnpComponent[0].restPath = "/rights-management";
|
|
417
|
-
}
|
|
418
|
-
if (Is.arrayValue(serverConfig.types.rightsManagementPnapComponent) &&
|
|
419
|
-
!Is.stringValue(serverConfig.types.rightsManagementPnapComponent[0].restPath)) {
|
|
420
|
-
serverConfig.types.rightsManagementPnapComponent[0].restPath = "/rights-management";
|
|
421
|
-
}
|
|
422
|
-
if (Is.arrayValue(serverConfig.types.rightsManagementDapComponent) &&
|
|
423
|
-
!Is.stringValue(serverConfig.types.rightsManagementDapComponent[0].restPath)) {
|
|
424
|
-
serverConfig.types.rightsManagementDapComponent[0].restPath = "/rights-management";
|
|
425
|
-
}
|
|
426
|
-
if (Is.arrayValue(serverConfig.types.synchronisedStorageComponent) &&
|
|
427
|
-
!Is.stringValue(serverConfig.types.synchronisedStorageComponent[0].restPath)) {
|
|
428
|
-
serverConfig.types.synchronisedStorageComponent[0].restPath = "/synchronised-storage";
|
|
429
|
-
}
|
|
430
|
-
if (Is.arrayValue(serverConfig.types.federatedCatalogueComponent) &&
|
|
431
|
-
!Is.stringValue(serverConfig.types.federatedCatalogueComponent[0].restPath)) {
|
|
432
|
-
serverConfig.types.federatedCatalogueComponent[0].restPath = "/federated-catalogue";
|
|
433
|
-
}
|
|
434
|
-
if (Is.arrayValue(serverConfig.types.dataSpaceConnectorComponent) &&
|
|
435
|
-
!Is.stringValue(serverConfig.types.dataSpaceConnectorComponent[0].restPath)) {
|
|
436
|
-
serverConfig.types.dataSpaceConnectorComponent[0].restPath = "/data-space-connector";
|
|
510
|
+
for (const routeGenerator of serverRestRouteGenerators) {
|
|
511
|
+
const types = serverConfig.types[routeGenerator.type];
|
|
512
|
+
if (Is.arrayValue(types) &&
|
|
513
|
+
!Is.stringValue(types[0].restPath) &&
|
|
514
|
+
Is.string(routeGenerator.defaultPath)) {
|
|
515
|
+
types[0].restPath = routeGenerator.defaultPath;
|
|
516
|
+
}
|
|
437
517
|
}
|
|
438
518
|
}
|
|
439
519
|
/**
|
|
@@ -441,13 +521,13 @@ function addDefaultRestPaths(serverConfig) {
|
|
|
441
521
|
* @param serverConfig The server config.
|
|
442
522
|
*/
|
|
443
523
|
function addDefaultSocketPaths(serverConfig) {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
524
|
+
for (const routeGenerator of serverSocketRouteGenerators) {
|
|
525
|
+
const types = serverConfig.types[routeGenerator.type];
|
|
526
|
+
if (Is.arrayValue(types) &&
|
|
527
|
+
!Is.stringValue(types[0].socketPath) &&
|
|
528
|
+
Is.stringValue(routeGenerator.defaultPath)) {
|
|
529
|
+
types[0].socketPath = routeGenerator.defaultPath;
|
|
530
|
+
}
|
|
451
531
|
}
|
|
452
532
|
}
|
|
453
533
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IRestRoute, ISocketRoute } from "@twin.org/api-models";
|
|
2
|
-
import type { IEngineCore,
|
|
2
|
+
import type { IEngineCore, IEngineServer } from "@twin.org/engine-models";
|
|
3
3
|
import { type IEngineServerConfig } from "@twin.org/engine-server-types";
|
|
4
4
|
/**
|
|
5
5
|
* Server for the engine.
|
|
@@ -20,19 +20,17 @@ export declare class EngineServer<T extends IEngineServerConfig = IEngineServerC
|
|
|
20
20
|
/**
|
|
21
21
|
* Add a REST route generator.
|
|
22
22
|
* @param type The type to add the generator for.
|
|
23
|
-
* @param typeConfig The type config.
|
|
24
23
|
* @param module The module containing the generator.
|
|
25
24
|
* @param method The method to call on the module.
|
|
26
25
|
*/
|
|
27
|
-
addRestRouteGenerator(type: string,
|
|
26
|
+
addRestRouteGenerator(type: string, module: string, method: string): void;
|
|
28
27
|
/**
|
|
29
28
|
* Add a socket route generator.
|
|
30
29
|
* @param type The type to add the generator for.
|
|
31
|
-
* @param typeConfig The type config.
|
|
32
30
|
* @param module The module containing the generator.
|
|
33
31
|
* @param method The method to call on the module.
|
|
34
32
|
*/
|
|
35
|
-
addSocketRouteGenerator(type: string,
|
|
33
|
+
addSocketRouteGenerator(type: string, module: string, method: string): void;
|
|
36
34
|
/**
|
|
37
35
|
* Get the built REST routes.
|
|
38
36
|
* @returns The REST routes.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IEngineServerConfig } from "@twin.org/engine-server-types";
|
|
2
2
|
/**
|
|
3
|
-
* Adds the rest paths to the server config.
|
|
3
|
+
* Adds the rest paths to the server config if not already set.
|
|
4
4
|
* @param serverConfig The server config.
|
|
5
5
|
*/
|
|
6
6
|
export declare function addDefaultRestPaths(serverConfig: IEngineServerConfig): void;
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @twin.org/engine-server - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.19](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.2-next.18...engine-server-v0.0.2-next.19) (2025-10-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* simplify config building ([732c871](https://github.com/twinfoundation/engine/commit/732c871c5aca236759168f4bc15aeffd98a330a8))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/engine-core bumped from 0.0.2-next.18 to 0.0.2-next.19
|
|
16
|
+
* @twin.org/engine-models bumped from 0.0.2-next.18 to 0.0.2-next.19
|
|
17
|
+
* @twin.org/engine-server-types bumped from 0.0.2-next.18 to 0.0.2-next.19
|
|
18
|
+
* devDependencies
|
|
19
|
+
* @twin.org/engine bumped from 0.0.2-next.18 to 0.0.2-next.19
|
|
20
|
+
|
|
3
21
|
## [0.0.2-next.18](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.2-next.17...engine-server-v0.0.2-next.18) (2025-09-29)
|
|
4
22
|
|
|
5
23
|
|
|
@@ -48,7 +48,7 @@ Runtime name for the class.
|
|
|
48
48
|
|
|
49
49
|
### addRestRouteGenerator()
|
|
50
50
|
|
|
51
|
-
> **addRestRouteGenerator**(`type`, `
|
|
51
|
+
> **addRestRouteGenerator**(`type`, `module`, `method`): `void`
|
|
52
52
|
|
|
53
53
|
Add a REST route generator.
|
|
54
54
|
|
|
@@ -60,12 +60,6 @@ Add a REST route generator.
|
|
|
60
60
|
|
|
61
61
|
The type to add the generator for.
|
|
62
62
|
|
|
63
|
-
##### typeConfig
|
|
64
|
-
|
|
65
|
-
The type config.
|
|
66
|
-
|
|
67
|
-
`undefined` | `IEngineCoreTypeConfig`[]
|
|
68
|
-
|
|
69
63
|
##### module
|
|
70
64
|
|
|
71
65
|
`string`
|
|
@@ -90,7 +84,7 @@ The method to call on the module.
|
|
|
90
84
|
|
|
91
85
|
### addSocketRouteGenerator()
|
|
92
86
|
|
|
93
|
-
> **addSocketRouteGenerator**(`type`, `
|
|
87
|
+
> **addSocketRouteGenerator**(`type`, `module`, `method`): `void`
|
|
94
88
|
|
|
95
89
|
Add a socket route generator.
|
|
96
90
|
|
|
@@ -102,12 +96,6 @@ Add a socket route generator.
|
|
|
102
96
|
|
|
103
97
|
The type to add the generator for.
|
|
104
98
|
|
|
105
|
-
##### typeConfig
|
|
106
|
-
|
|
107
|
-
The type config.
|
|
108
|
-
|
|
109
|
-
`undefined` | `IEngineCoreTypeConfig`[]
|
|
110
|
-
|
|
111
99
|
##### module
|
|
112
100
|
|
|
113
101
|
`string`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/engine-server",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.19",
|
|
4
4
|
"description": "Engine implementation for a server.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"@twin.org/api-models": "next",
|
|
18
18
|
"@twin.org/api-server-fastify": "next",
|
|
19
19
|
"@twin.org/core": "next",
|
|
20
|
-
"@twin.org/engine-core": "0.0.2-next.
|
|
21
|
-
"@twin.org/engine-models": "0.0.2-next.
|
|
22
|
-
"@twin.org/engine-server-types": "0.0.2-next.
|
|
20
|
+
"@twin.org/engine-core": "0.0.2-next.19",
|
|
21
|
+
"@twin.org/engine-models": "0.0.2-next.19",
|
|
22
|
+
"@twin.org/engine-server-types": "0.0.2-next.19",
|
|
23
23
|
"@twin.org/modules": "next",
|
|
24
24
|
"@twin.org/nameof": "next"
|
|
25
25
|
},
|
|
@@ -40,5 +40,13 @@
|
|
|
40
40
|
"dist/types",
|
|
41
41
|
"locales",
|
|
42
42
|
"docs"
|
|
43
|
+
],
|
|
44
|
+
"keywords": [
|
|
45
|
+
"twin",
|
|
46
|
+
"trade",
|
|
47
|
+
"iota",
|
|
48
|
+
"framework",
|
|
49
|
+
"blockchain",
|
|
50
|
+
"engine"
|
|
43
51
|
]
|
|
44
52
|
}
|