@twin.org/engine-server 0.0.2-next.2 → 0.0.2-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.
@@ -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
  */
@@ -34,11 +229,6 @@ class EngineServer {
34
229
  * @internal
35
230
  */
36
231
  _webServer;
37
- /**
38
- * The logging connector type.
39
- * @internal
40
- */
41
- _loggingConnectorType;
42
232
  /**
43
233
  * The REST routes for the application.
44
234
  * @internal
@@ -112,36 +302,34 @@ class EngineServer {
112
302
  /**
113
303
  * Add a REST route generator.
114
304
  * @param type The type to add the generator for.
115
- * @param typeConfig The type config.
116
305
  * @param module The module containing the generator.
117
306
  * @param method The method to call on the module.
118
307
  */
119
- addRestRouteGenerator(type, typeConfig, module, method) {
120
- if (!core.Is.empty(typeConfig)) {
121
- this._restRouteGenerators.push({
122
- type,
123
- typeConfig,
124
- module,
125
- method
126
- });
127
- }
308
+ addRestRouteGenerator(type, module, method) {
309
+ core.Guards.stringValue(this.CLASS_NAME, "type", type);
310
+ core.Guards.stringValue(this.CLASS_NAME, "module", module);
311
+ core.Guards.stringValue(this.CLASS_NAME, "method", method);
312
+ this._restRouteGenerators.push({
313
+ type,
314
+ module,
315
+ method
316
+ });
128
317
  }
129
318
  /**
130
319
  * Add a socket route generator.
131
320
  * @param type The type to add the generator for.
132
- * @param typeConfig The type config.
133
321
  * @param module The module containing the generator.
134
322
  * @param method The method to call on the module.
135
323
  */
136
- addSocketRouteGenerator(type, typeConfig, module, method) {
137
- if (!core.Is.empty(typeConfig)) {
138
- this._socketRouteGenerators.push({
139
- type,
140
- typeConfig,
141
- module,
142
- method
143
- });
144
- }
324
+ addSocketRouteGenerator(type, module, method) {
325
+ core.Guards.stringValue(this.CLASS_NAME, "type", type);
326
+ core.Guards.stringValue(this.CLASS_NAME, "module", module);
327
+ core.Guards.stringValue(this.CLASS_NAME, "method", method);
328
+ this._socketRouteGenerators.push({
329
+ type,
330
+ module,
331
+ method
332
+ });
145
333
  }
146
334
  /**
147
335
  * Get the built REST routes.
@@ -190,10 +378,11 @@ class EngineServer {
190
378
  const socketRouteProcessors = apiModels.SocketRouteProcessorFactory.names().map(n => apiModels.SocketRouteProcessorFactory.get(n));
191
379
  const mimeTypeProcessors = apiModels.MimeTypeProcessorFactory.names().map(n => apiModels.MimeTypeProcessorFactory.get(n));
192
380
  const coreConfig = this._engineCore.getConfig();
193
- const defaults = this._engineCore.getDefaultTypes();
194
- this._loggingConnectorType = coreConfig.silent ? undefined : defaults.loggingConnector;
381
+ const loggingComponentType = coreConfig.silent
382
+ ? undefined
383
+ : this._engineCore.getRegisteredInstanceType("loggingComponent");
195
384
  this._webServer = new apiServerFastify.FastifyWebServer({
196
- loggingConnectorType: this._loggingConnectorType,
385
+ loggingComponentType,
197
386
  mimeTypeProcessors
198
387
  });
199
388
  await this._webServer.build(restRouteProcessors, this._restRoutes, socketRouteProcessors, this._socketRoutes, coreConfig.web);
@@ -206,8 +395,8 @@ class EngineServer {
206
395
  */
207
396
  async buildRestRoutes() {
208
397
  const routes = [];
209
- for (const { type, typeConfig, module, method } of this._restRouteGenerators) {
210
- await this.initialiseRestTypeRoute(routes, type, typeConfig, module, method);
398
+ for (const { type, module, method } of this._restRouteGenerators) {
399
+ await this.initialiseRestTypeRoute(routes, type, module, method);
211
400
  }
212
401
  return routes;
213
402
  }
@@ -218,8 +407,8 @@ class EngineServer {
218
407
  */
219
408
  async buildSocketRoutes() {
220
409
  const routes = [];
221
- for (const { type, typeConfig, module, method } of this._socketRouteGenerators) {
222
- await this.initialiseSocketTypeRoute(routes, type, typeConfig, module, method);
410
+ for (const { type, module, method } of this._socketRouteGenerators) {
411
+ await this.initialiseSocketTypeRoute(routes, type, module, method);
223
412
  }
224
413
  return routes;
225
414
  }
@@ -227,20 +416,21 @@ class EngineServer {
227
416
  * Initialise the rest routes from connector.
228
417
  * @param routes The routes to add to.
229
418
  * @param typeKey The key for the default types.
230
- * @param typeConfig The type config.
231
419
  * @param generateRoutes The function to generate the routes.
232
420
  * @internal
233
421
  */
234
- async initialiseRestTypeRoute(routes, typeKey, typeConfig, module, method) {
422
+ async initialiseRestTypeRoute(routes, typeKey, module, method) {
423
+ const typeConfig = this._engineCore.getTypeConfig(typeKey);
235
424
  if (core.Is.arrayValue(typeConfig)) {
236
- const defaultEngineTypes = this._engineCore.getDefaultTypes();
237
425
  const generateRoutes = await modules.ModuleHelper.getModuleEntry(module, method);
238
426
  for (let i = 0; i < typeConfig.length; i++) {
239
427
  const restPath = typeConfig[i].restPath;
428
+ const restOptions = typeConfig[i].restOptions;
240
429
  if (core.Is.string(restPath)) {
241
- const serviceType = typeConfig[i].overrideInstanceType ?? defaultEngineTypes[typeKey];
430
+ const serviceType = typeConfig[i].overrideInstanceType ??
431
+ this._engineCore.getRegisteredInstanceType(typeKey);
242
432
  if (core.Is.stringValue(serviceType)) {
243
- const generatedRoutes = generateRoutes(restPath, serviceType);
433
+ const generatedRoutes = generateRoutes(restPath, serviceType, restOptions);
244
434
  for (const route of generatedRoutes) {
245
435
  // Don't strip trailing slashes from the root path.
246
436
  if (core.Is.stringValue(route.path) && route.path.length > 1) {
@@ -257,21 +447,22 @@ class EngineServer {
257
447
  * Initialise the socket routes from connector.
258
448
  * @param routes The routes to add to.
259
449
  * @param typeKey The key for the default types.
260
- * @param typeConfig The type config.
261
450
  * @param module The module containing the generator.
262
451
  * @param method The method to call on the module.
263
452
  * @internal
264
453
  */
265
- async initialiseSocketTypeRoute(routes, typeKey, typeConfig, module, method) {
454
+ async initialiseSocketTypeRoute(routes, typeKey, module, method) {
455
+ const typeConfig = this._engineCore.getTypeConfig(typeKey);
266
456
  if (core.Is.arrayValue(typeConfig)) {
267
- const defaultEngineTypes = this._engineCore.getDefaultTypes();
268
457
  const generateRoutes = await modules.ModuleHelper.getModuleEntry(module, method);
269
458
  for (let i = 0; i < typeConfig.length; i++) {
270
459
  const socketPath = typeConfig[i].socketPath;
460
+ const socketOptions = typeConfig[i].socketOptions;
271
461
  if (core.Is.string(socketPath)) {
272
- const serviceType = typeConfig[i].overrideInstanceType ?? defaultEngineTypes[typeKey];
462
+ const serviceType = typeConfig[i].overrideInstanceType ??
463
+ this._engineCore.getRegisteredInstanceType(typeKey);
273
464
  if (core.Is.stringValue(serviceType)) {
274
- routes.push(...generateRoutes(socketPath, serviceType));
465
+ routes.push(...generateRoutes(socketPath, serviceType, socketOptions));
275
466
  }
276
467
  }
277
468
  }
@@ -282,127 +473,44 @@ class EngineServer {
282
473
  * @internal
283
474
  */
284
475
  addServerTypeInitialisers() {
285
- const coreConfig = this._engineCore.getConfig();
286
- this._engineCore.addTypeInitialiser("authenticationAdminComponent", coreConfig.types.authenticationAdminComponent, "@twin.org/engine-server-types", "initialiseAuthenticationAdminComponent");
287
- this._engineCore.addTypeInitialiser("authenticationComponent", coreConfig.types.authenticationComponent, "@twin.org/engine-server-types", "initialiseAuthenticationComponent");
288
- this._engineCore.addTypeInitialiser("informationComponent", coreConfig.types.informationComponent, "@twin.org/engine-server-types", "initialiseInformationComponent");
289
- this._engineCore.addTypeInitialiser("restRouteProcessor", coreConfig.types.restRouteProcessor, "@twin.org/engine-server-types", "initialiseRestRouteProcessorComponent");
290
- this._engineCore.addTypeInitialiser("socketRouteProcessor", coreConfig.types.socketRouteProcessor, "@twin.org/engine-server-types", "initialiseSocketRouteProcessorComponent");
291
- this._engineCore.addTypeInitialiser("mimeTypeProcessor", coreConfig.types.mimeTypeProcessor, "@twin.org/engine-server-types", "initialiseMimeTypeProcessorComponent");
476
+ for (const initializer of serverTypeInitialisers) {
477
+ this._engineCore.addTypeInitialiser(initializer.type, initializer.module, initializer.method);
478
+ }
292
479
  }
293
480
  /**
294
481
  * Add the server REST route generators.
295
482
  * @internal
296
483
  */
297
484
  addServerRestRouteGenerators() {
298
- const coreConfig = this._engineCore.getConfig();
299
- this.addRestRouteGenerator("informationComponent", coreConfig.types.informationComponent, "@twin.org/api-service", "generateRestRoutesInformation");
300
- this.addRestRouteGenerator("authenticationComponent", coreConfig.types.authenticationComponent, "@twin.org/api-auth-entity-storage-service", "generateRestRoutesAuthentication");
301
- this.addRestRouteGenerator("loggingComponent", coreConfig.types.loggingComponent, "@twin.org/logging-service", "generateRestRoutesLogging");
302
- this.addRestRouteGenerator("telemetryComponent", coreConfig.types.telemetryComponent, "@twin.org/telemetry-service", "generateRestRoutesTelemetry");
303
- this.addRestRouteGenerator("blobStorageComponent", coreConfig.types.blobStorageComponent, "@twin.org/blob-storage-service", "generateRestRoutesBlobStorage");
304
- this.addRestRouteGenerator("identityComponent", coreConfig.types.identityComponent, "@twin.org/identity-service", "generateRestRoutesIdentity");
305
- this.addRestRouteGenerator("identityResolverComponent", coreConfig.types.identityResolverComponent, "@twin.org/identity-service", "generateRestRoutesIdentityResolver");
306
- this.addRestRouteGenerator("identityProfileComponent", coreConfig.types.identityProfileComponent, "@twin.org/identity-service", "generateRestRoutesIdentityProfile");
307
- this.addRestRouteGenerator("nftComponent", coreConfig.types.nftComponent, "@twin.org/nft-service", "generateRestRoutesNft");
308
- this.addRestRouteGenerator("verifiableStorageComponent", coreConfig.types.verifiableStorageComponent, "@twin.org/verifiable-storage-service", "generateRestRoutesVerifiableStorage");
309
- this.addRestRouteGenerator("attestationComponent", coreConfig.types.attestationComponent, "@twin.org/attestation-service", "generateRestRoutesAttestation");
310
- this.addRestRouteGenerator("immutableProofComponent", coreConfig.types.immutableProofComponent, "@twin.org/immutable-proof-service", "generateRestRoutesImmutableProof");
311
- this.addRestRouteGenerator("auditableItemGraphComponent", coreConfig.types.auditableItemGraphComponent, "@twin.org/auditable-item-graph-service", "generateRestRoutesAuditableItemGraph");
312
- this.addRestRouteGenerator("auditableItemStreamComponent", coreConfig.types.auditableItemStreamComponent, "@twin.org/auditable-item-stream-service", "generateRestRoutesAuditableItemStream");
313
- this.addRestRouteGenerator("entityStorageComponent", coreConfig.types.entityStorageComponent, "@twin.org/entity-storage-service", "generateRestRoutesEntityStorage");
314
- this.addRestRouteGenerator("dataProcessingComponent", coreConfig.types.dataProcessingComponent, "@twin.org/data-processing-service", "generateRestRoutesDataProcessing");
315
- this.addRestRouteGenerator("documentManagementComponent", coreConfig.types.documentManagementComponent, "@twin.org/document-management-service", "generateRestRoutesDocumentManagement");
316
- this.addRestRouteGenerator("federatedCatalogueComponent", coreConfig.types.federatedCatalogueComponent, "@twin.org/federated-catalogue-service", "generateRestRoutesFederatedCatalogue");
317
- this.addRestRouteGenerator("rightsManagementComponent", coreConfig.types.rightsManagementComponent, "@twin.org/rights-management-service", "generateRestRoutesRightsManagement");
485
+ for (const generator of serverRestRouteGenerators) {
486
+ this.addRestRouteGenerator(generator.type, generator.module, generator.method);
487
+ }
318
488
  }
319
489
  /**
320
490
  * Add the server socket route generators.
321
491
  * @internal
322
492
  */
323
493
  addServerSocketRouteGenerators() {
324
- const coreConfig = this._engineCore.getConfig();
325
- this.addSocketRouteGenerator("eventBusComponent", coreConfig.types.eventBusComponent, "@twin.org/event-bus-service", "generateSocketRoutesEventBus");
494
+ for (const generator of serverSocketRouteGenerators) {
495
+ this.addSocketRouteGenerator(generator.type, generator.module, generator.method);
496
+ }
326
497
  }
327
498
  }
328
499
 
329
500
  // Copyright 2024 IOTA Stiftung.
330
501
  // SPDX-License-Identifier: Apache-2.0.
331
502
  /**
332
- * Adds the rest paths to the server config.
503
+ * Adds the rest paths to the server config if not already set.
333
504
  * @param serverConfig The server config.
334
505
  */
335
506
  function addDefaultRestPaths(serverConfig) {
336
- if (core.Is.arrayValue(serverConfig.types.informationComponent)) {
337
- serverConfig.types.informationComponent[0].restPath = "";
338
- }
339
- if (core.Is.arrayValue(serverConfig.types.authenticationComponent) &&
340
- !core.Is.stringValue(serverConfig.types.authenticationComponent[0].restPath)) {
341
- serverConfig.types.authenticationComponent[0].restPath = "/authentication";
342
- }
343
- if (core.Is.arrayValue(serverConfig.types.blobStorageComponent) &&
344
- !core.Is.stringValue(serverConfig.types.blobStorageComponent[0].restPath)) {
345
- serverConfig.types.blobStorageComponent[0].restPath = "/blob";
346
- }
347
- if (core.Is.arrayValue(serverConfig.types.loggingComponent) &&
348
- !core.Is.stringValue(serverConfig.types.loggingComponent[0].restPath)) {
349
- serverConfig.types.loggingComponent[0].restPath = "/logging";
350
- }
351
- if (core.Is.arrayValue(serverConfig.types.telemetryComponent) &&
352
- !core.Is.stringValue(serverConfig.types.telemetryComponent[0].restPath)) {
353
- serverConfig.types.telemetryComponent[0].restPath = "/telemetry";
354
- }
355
- if (core.Is.arrayValue(serverConfig.types.identityComponent) &&
356
- !core.Is.stringValue(serverConfig.types.identityComponent[0].restPath)) {
357
- serverConfig.types.identityComponent[0].restPath = "/identity";
358
- }
359
- if (core.Is.arrayValue(serverConfig.types.identityResolverComponent) &&
360
- !core.Is.stringValue(serverConfig.types.identityResolverComponent[0].restPath)) {
361
- serverConfig.types.identityResolverComponent[0].restPath = "/identity";
362
- }
363
- if (core.Is.arrayValue(serverConfig.types.identityProfileComponent) &&
364
- !core.Is.stringValue(serverConfig.types.identityProfileComponent[0].restPath)) {
365
- serverConfig.types.identityProfileComponent[0].restPath = "/identity/profile";
366
- }
367
- if (core.Is.arrayValue(serverConfig.types.nftComponent) &&
368
- !core.Is.stringValue(serverConfig.types.nftComponent[0].restPath)) {
369
- serverConfig.types.nftComponent[0].restPath = "/nft";
370
- }
371
- if (core.Is.arrayValue(serverConfig.types.verifiableStorageComponent) &&
372
- !core.Is.stringValue(serverConfig.types.verifiableStorageComponent[0].restPath)) {
373
- serverConfig.types.verifiableStorageComponent[0].restPath = "/verifiable";
374
- }
375
- if (core.Is.arrayValue(serverConfig.types.immutableProofComponent) &&
376
- !core.Is.stringValue(serverConfig.types.immutableProofComponent[0].restPath)) {
377
- serverConfig.types.immutableProofComponent[0].restPath = "/immutable-proof";
378
- }
379
- if (core.Is.arrayValue(serverConfig.types.attestationComponent) &&
380
- !core.Is.stringValue(serverConfig.types.attestationComponent[0].restPath)) {
381
- serverConfig.types.attestationComponent[0].restPath = "/attestation";
382
- }
383
- if (core.Is.arrayValue(serverConfig.types.auditableItemGraphComponent) &&
384
- !core.Is.stringValue(serverConfig.types.auditableItemGraphComponent[0].restPath)) {
385
- serverConfig.types.auditableItemGraphComponent[0].restPath = "/aig";
386
- }
387
- if (core.Is.arrayValue(serverConfig.types.auditableItemStreamComponent) &&
388
- !core.Is.stringValue(serverConfig.types.auditableItemStreamComponent[0].restPath)) {
389
- serverConfig.types.auditableItemStreamComponent[0].restPath = "/ais";
390
- }
391
- if (core.Is.arrayValue(serverConfig.types.dataProcessingComponent) &&
392
- !core.Is.stringValue(serverConfig.types.dataProcessingComponent[0].restPath)) {
393
- serverConfig.types.dataProcessingComponent[0].restPath = "/data-processing";
394
- }
395
- if (core.Is.arrayValue(serverConfig.types.documentManagementComponent) &&
396
- !core.Is.stringValue(serverConfig.types.documentManagementComponent[0].restPath)) {
397
- serverConfig.types.documentManagementComponent[0].restPath = "/documents";
398
- }
399
- if (core.Is.arrayValue(serverConfig.types.federatedCatalogueComponent) &&
400
- !core.Is.stringValue(serverConfig.types.federatedCatalogueComponent[0].restPath)) {
401
- serverConfig.types.federatedCatalogueComponent[0].restPath = "/federated-catalogue";
402
- }
403
- if (core.Is.arrayValue(serverConfig.types.rightsManagementComponent) &&
404
- !core.Is.stringValue(serverConfig.types.rightsManagementComponent[0].restPath)) {
405
- serverConfig.types.rightsManagementComponent[0].restPath = "/rights-management";
507
+ for (const routeGenerator of serverRestRouteGenerators) {
508
+ const types = serverConfig.types[routeGenerator.type];
509
+ if (core.Is.arrayValue(types) &&
510
+ !core.Is.stringValue(types[0].restPath) &&
511
+ core.Is.string(routeGenerator.defaultPath)) {
512
+ types[0].restPath = routeGenerator.defaultPath;
513
+ }
406
514
  }
407
515
  }
408
516
  /**
@@ -410,9 +518,13 @@ function addDefaultRestPaths(serverConfig) {
410
518
  * @param serverConfig The server config.
411
519
  */
412
520
  function addDefaultSocketPaths(serverConfig) {
413
- if (core.Is.arrayValue(serverConfig.types.eventBusComponent) &&
414
- !core.Is.stringValue(serverConfig.types.eventBusComponent[0].socketPath)) {
415
- serverConfig.types.eventBusComponent[0].socketPath = "event-bus";
521
+ for (const routeGenerator of serverSocketRouteGenerators) {
522
+ const types = serverConfig.types[routeGenerator.type];
523
+ if (core.Is.arrayValue(types) &&
524
+ !core.Is.stringValue(types[0].socketPath) &&
525
+ core.Is.stringValue(routeGenerator.defaultPath)) {
526
+ types[0].socketPath = routeGenerator.defaultPath;
527
+ }
416
528
  }
417
529
  }
418
530