@twin.org/engine-server 0.0.1-next.13 → 0.0.1-next.14

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.
@@ -1,263 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var apiAuthEntityStorageService = require('@twin.org/api-auth-entity-storage-service');
4
3
  var apiModels = require('@twin.org/api-models');
5
4
  var apiServerFastify = require('@twin.org/api-server-fastify');
6
- var apiService = require('@twin.org/api-service');
7
- var attestationService = require('@twin.org/attestation-service');
8
- var auditableItemGraphService = require('@twin.org/auditable-item-graph-service');
9
- var auditableItemStreamService = require('@twin.org/auditable-item-stream-service');
10
- var blobStorageService = require('@twin.org/blob-storage-service');
11
5
  var core = require('@twin.org/core');
12
- var engineModels = require('@twin.org/engine-models');
13
- var entityStorageService = require('@twin.org/entity-storage-service');
14
- var identityService = require('@twin.org/identity-service');
15
- var loggingService = require('@twin.org/logging-service');
16
- var nftService = require('@twin.org/nft-service');
17
- var telemetryService = require('@twin.org/telemetry-service');
18
- var engineCore = require('@twin.org/engine-core');
19
- var apiProcessors = require('@twin.org/api-processors');
6
+ var engineServerTypes = require('@twin.org/engine-server-types');
7
+ var modules = require('@twin.org/modules');
20
8
 
21
- /**
22
- * Initialise the authentication.
23
- * @param engineCore The engine core.
24
- * @param context The context for the engine.
25
- * @param instanceConfig The instance config.
26
- * @param overrideInstanceType The instance type to override the default.
27
- * @returns The name of the instance created.
28
- * @throws GeneralError if the component type is unknown.
29
- */
30
- function initialiseAuthenticationComponent(engineCore$1, context, instanceConfig, overrideInstanceType) {
31
- engineCore$1.logInfo(core.I18n.formatMessage("engineCore.configuring", {
32
- element: `Authentication Component: ${instanceConfig.type}`
33
- }));
34
- const type = instanceConfig.type;
35
- let component;
36
- let instanceType;
37
- if (type === engineModels.AuthenticationComponentType.EntityStorage) {
38
- apiAuthEntityStorageService.initSchema();
39
- engineCore.initialiseEntityStorageConnector(engineCore$1, context, instanceConfig.options?.userEntityStorageType, "AuthenticationUser");
40
- component = new apiAuthEntityStorageService.EntityStorageAuthenticationService({
41
- vaultConnectorType: context.defaultTypes.vaultConnector,
42
- ...instanceConfig.options
43
- });
44
- instanceType = apiAuthEntityStorageService.EntityStorageAuthenticationService.NAMESPACE;
45
- }
46
- else {
47
- throw new core.GeneralError("engineCore", "componentUnknownType", {
48
- type,
49
- componentType: "authenticationComponent"
50
- });
51
- }
52
- const finalInstanceType = overrideInstanceType ?? instanceType;
53
- context.componentInstances.push({
54
- instanceType: finalInstanceType,
55
- component
56
- });
57
- core.ComponentFactory.register(finalInstanceType, () => component);
58
- return finalInstanceType;
59
- }
60
-
61
- /**
62
- * Initialise the information component.
63
- * @param engineCore The engine core.
64
- * @param context The context for the engine.
65
- * @param instanceConfig The instance config.
66
- * @param overrideInstanceType The instance type to override the default.
67
- * @returns The name of the instance created.
68
- * @throws GeneralError if the component type is unknown.
69
- */
70
- function initialiseInformationComponent(engineCore, context, instanceConfig, overrideInstanceType) {
71
- engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
72
- element: `Information Component: ${instanceConfig.type}`
73
- }));
74
- const type = instanceConfig.type;
75
- let component;
76
- let instanceType;
77
- if (type === engineModels.InformationComponentType.Service) {
78
- component = new apiService.InformationService(instanceConfig.options);
79
- instanceType = apiService.InformationService.NAMESPACE;
80
- }
81
- else {
82
- throw new core.GeneralError("engineCore", "componentUnknownType", {
83
- type,
84
- componentType: "informationComponent"
85
- });
86
- }
87
- const finalInstanceType = overrideInstanceType ?? instanceType;
88
- context.componentInstances.push({
89
- instanceType: finalInstanceType,
90
- component
91
- });
92
- core.ComponentFactory.register(finalInstanceType, () => component);
93
- return finalInstanceType;
94
- }
95
-
96
- // Copyright 2024 IOTA Stiftung.
97
- // SPDX-License-Identifier: Apache-2.0.
98
- /**
99
- * Initialise the mime type processor.
100
- * @param engineCore The engine core.
101
- * @param context The context for the engine.
102
- * @param instanceConfig The instance config.
103
- * @param overrideInstanceType The instance type to override the default.
104
- * @returns The name of the instance created.
105
- * @throws GeneralError if the component type is unknown.
106
- */
107
- function initialiseMimeTypeProcessorComponent(engineCore, context, instanceConfig, overrideInstanceType) {
108
- engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
109
- element: `Mime Type Processor: ${instanceConfig.type}`
110
- }));
111
- const type = instanceConfig.type;
112
- let component;
113
- let instanceType;
114
- if (type === engineModels.MimeTypeProcessorType.Jwt) {
115
- component = new apiProcessors.JwtMimeTypeProcessor();
116
- instanceType = apiProcessors.JwtMimeTypeProcessor.NAMESPACE;
117
- }
118
- else {
119
- throw new core.GeneralError("engineCore", "componentUnknownType", {
120
- type,
121
- componentType: "mimeTypeProcessorComponent"
122
- });
123
- }
124
- const finalInstanceType = overrideInstanceType ?? instanceType;
125
- context.componentInstances.push({
126
- instanceType: finalInstanceType,
127
- component
128
- });
129
- apiModels.MimeTypeProcessorFactory.register(finalInstanceType, () => component);
130
- return finalInstanceType;
131
- }
132
-
133
- // Copyright 2024 IOTA Stiftung.
134
- // SPDX-License-Identifier: Apache-2.0.
135
- /**
136
- * Initialise the rest route processor.
137
- * @param engineCore The engine core.
138
- * @param context The context for the engine.
139
- * @param instanceConfig The instance config.
140
- * @param overrideInstanceType The instance type to override the default.
141
- * @returns The name of the instance created.
142
- * @throws GeneralError if the component type is unknown.
143
- */
144
- function initialiseRestRouteProcessorComponent(engineCore, context, instanceConfig, overrideInstanceType) {
145
- engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
146
- element: `REST Route Processor: ${instanceConfig.type}`
147
- }));
148
- const type = instanceConfig.type;
149
- let component;
150
- let instanceType;
151
- if (type === engineModels.RestRouteProcessorType.AuthHeader) {
152
- component = new apiAuthEntityStorageService.AuthHeaderProcessor({
153
- vaultConnectorType: context.defaultTypes.vaultConnector,
154
- config: {
155
- ...instanceConfig.options?.config
156
- }
157
- });
158
- instanceType = apiAuthEntityStorageService.AuthHeaderProcessor.NAMESPACE;
159
- }
160
- else if (type === engineModels.RestRouteProcessorType.Logging) {
161
- component = new apiProcessors.LoggingProcessor({
162
- loggingConnectorType: context.defaultTypes.loggingConnector,
163
- config: {
164
- ...instanceConfig.options?.config
165
- }
166
- });
167
- instanceType = apiProcessors.LoggingProcessor.NAMESPACE;
168
- }
169
- else if (type === engineModels.RestRouteProcessorType.NodeIdentity) {
170
- component = new apiProcessors.NodeIdentityProcessor();
171
- instanceType = apiProcessors.NodeIdentityProcessor.NAMESPACE;
172
- }
173
- else if (type === engineModels.RestRouteProcessorType.StaticUserIdentity) {
174
- component = new apiProcessors.StaticUserIdentityProcessor(instanceConfig.options);
175
- instanceType = apiProcessors.StaticUserIdentityProcessor.NAMESPACE;
176
- }
177
- else if (type === engineModels.RestRouteProcessorType.RestRoute) {
178
- component = new apiProcessors.RestRouteProcessor(instanceConfig.options);
179
- instanceType = apiProcessors.RestRouteProcessor.NAMESPACE;
180
- }
181
- else {
182
- throw new core.GeneralError("engineCore", "componentUnknownType", {
183
- type,
184
- componentType: "restRouteProcessorComponent"
185
- });
186
- }
187
- const finalInstanceType = overrideInstanceType ?? instanceType;
188
- context.componentInstances.push({
189
- instanceType: finalInstanceType,
190
- component
191
- });
192
- apiModels.RestRouteProcessorFactory.register(finalInstanceType, () => component);
193
- return finalInstanceType;
194
- }
195
-
196
- // Copyright 2024 IOTA Stiftung.
197
- // SPDX-License-Identifier: Apache-2.0.
198
- /**
199
- * Initialise the socket route processor.
200
- * @param engineCore The engine core.
201
- * @param context The context for the engine.
202
- * @param instanceConfig The instance config.
203
- * @param overrideInstanceType The instance type to override the default.
204
- * @returns The name of the instance created.
205
- * @throws GeneralError if the component type is unknown.
206
- */
207
- function initialiseSocketRouteProcessorComponent(engineCore, context, instanceConfig, overrideInstanceType) {
208
- engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
209
- element: `Socket Route Processor: ${instanceConfig.type}`
210
- }));
211
- const type = instanceConfig.type;
212
- let component;
213
- let instanceType;
214
- if (type === engineModels.SocketRouteProcessorType.AuthHeader) {
215
- component = new apiAuthEntityStorageService.AuthHeaderProcessor({
216
- vaultConnectorType: context.defaultTypes.vaultConnector,
217
- config: {
218
- ...instanceConfig.options?.config
219
- }
220
- });
221
- instanceType = apiAuthEntityStorageService.AuthHeaderProcessor.NAMESPACE;
222
- }
223
- else if (type === engineModels.SocketRouteProcessorType.Logging) {
224
- component = new apiProcessors.LoggingProcessor({
225
- loggingConnectorType: context.defaultTypes.loggingConnector,
226
- config: {
227
- ...instanceConfig.options?.config
228
- }
229
- });
230
- instanceType = apiProcessors.LoggingProcessor.NAMESPACE;
231
- }
232
- else if (type === engineModels.SocketRouteProcessorType.NodeIdentity) {
233
- component = new apiProcessors.NodeIdentityProcessor();
234
- instanceType = apiProcessors.NodeIdentityProcessor.NAMESPACE;
235
- }
236
- else if (type === engineModels.SocketRouteProcessorType.StaticUserIdentity) {
237
- component = new apiProcessors.StaticUserIdentityProcessor(instanceConfig.options);
238
- instanceType = apiProcessors.StaticUserIdentityProcessor.NAMESPACE;
239
- }
240
- else if (type === engineModels.SocketRouteProcessorType.SocketRoute) {
241
- component = new apiProcessors.SocketRouteProcessor(instanceConfig.options);
242
- instanceType = apiProcessors.SocketRouteProcessor.NAMESPACE;
243
- }
244
- else {
245
- throw new core.GeneralError("engineCore", "componentUnknownType", {
246
- type,
247
- componentType: "socketRouteProcessorComponent"
248
- });
249
- }
250
- const finalInstanceType = overrideInstanceType ?? instanceType;
251
- context.componentInstances.push({
252
- instanceType: finalInstanceType,
253
- component
254
- });
255
- apiModels.SocketRouteProcessorFactory.register(finalInstanceType, () => component);
256
- return finalInstanceType;
257
- }
258
-
259
- // Copyright 2024 IOTA Stiftung.
260
- // SPDX-License-Identifier: Apache-2.0.
261
9
  /**
262
10
  * Server for the engine.
263
11
  */
@@ -266,10 +14,6 @@ class EngineServer {
266
14
  * Runtime name for the class.
267
15
  */
268
16
  CLASS_NAME = "EngineServer";
269
- /**
270
- * The server config.
271
- */
272
- _config;
273
17
  /**
274
18
  * The engine.
275
19
  * @internal
@@ -298,22 +42,20 @@ class EngineServer {
298
42
  /**
299
43
  * Create a new instance of EngineServer.
300
44
  * @param options The options for the engine.
301
- * @param options.server The server options for the engine.
302
45
  * @param options.engineCore The engine core to serve from.
303
46
  */
304
47
  constructor(options) {
305
48
  core.Guards.object(this.CLASS_NAME, "options", options);
306
49
  core.Guards.object(this.CLASS_NAME, "options.engineCore", options.engineCore);
307
- this._config = options?.server ?? {};
308
50
  this._engineCore = options.engineCore;
309
51
  this._restRouteGenerators = [];
310
52
  this._socketRouteGenerators = [];
311
53
  const coreConfig = this._engineCore.getConfig();
312
- if (!core.Is.arrayValue(this._config.restRouteProcessor)) {
313
- this._config.restRouteProcessor = [];
54
+ if (!core.Is.arrayValue(coreConfig.types.restRouteProcessor)) {
55
+ coreConfig.types.restRouteProcessor = [];
314
56
  if (!coreConfig.silent) {
315
- this._config.restRouteProcessor.push({
316
- type: engineModels.RestRouteProcessorType.Logging,
57
+ coreConfig.types.restRouteProcessor.push({
58
+ type: engineServerTypes.RestRouteProcessorType.Logging,
317
59
  options: {
318
60
  config: {
319
61
  includeBody: coreConfig.debug
@@ -321,8 +63,8 @@ class EngineServer {
321
63
  }
322
64
  });
323
65
  }
324
- this._config.restRouteProcessor.push({
325
- type: engineModels.RestRouteProcessorType.RestRoute,
66
+ coreConfig.types.restRouteProcessor.push({
67
+ type: engineServerTypes.RestRouteProcessorType.RestRoute,
326
68
  options: {
327
69
  config: {
328
70
  includeErrorStack: coreConfig.debug
@@ -338,14 +80,16 @@ class EngineServer {
338
80
  * Add a REST route generator.
339
81
  * @param type The type to add the generator for.
340
82
  * @param typeConfig The type config.
341
- * @param generator The generator to add.
83
+ * @param module The module containing the generator.
84
+ * @param method The method to call on the module.
342
85
  */
343
- addRestRouteGenerator(type, typeConfig, generator) {
86
+ addRestRouteGenerator(type, typeConfig, module, method) {
344
87
  if (!core.Is.empty(typeConfig)) {
345
88
  this._restRouteGenerators.push({
346
89
  type,
347
90
  typeConfig,
348
- generator
91
+ module,
92
+ method
349
93
  });
350
94
  }
351
95
  }
@@ -353,14 +97,16 @@ class EngineServer {
353
97
  * Add a socket route generator.
354
98
  * @param type The type to add the generator for.
355
99
  * @param typeConfig The type config.
356
- * @param generator The generator to add.
100
+ * @param module The module containing the generator.
101
+ * @param method The method to call on the module.
357
102
  */
358
- addSocketRouteGenerator(type, typeConfig, generator) {
103
+ addSocketRouteGenerator(type, typeConfig, module, method) {
359
104
  if (!core.Is.empty(typeConfig)) {
360
105
  this._socketRouteGenerators.push({
361
106
  type,
362
107
  typeConfig,
363
- generator
108
+ module,
109
+ method
364
110
  });
365
111
  }
366
112
  }
@@ -391,8 +137,8 @@ class EngineServer {
391
137
  * @internal
392
138
  */
393
139
  async startWebServer() {
394
- const restRoutes = this.buildRestRoutes();
395
- const socketRoutes = this.buildSocketRoutes();
140
+ const restRoutes = await this.buildRestRoutes();
141
+ const socketRoutes = await this.buildSocketRoutes();
396
142
  const restRouteProcessors = apiModels.RestRouteProcessorFactory.names().map(n => apiModels.RestRouteProcessorFactory.get(n));
397
143
  const socketRouteProcessors = apiModels.SocketRouteProcessorFactory.names().map(n => apiModels.SocketRouteProcessorFactory.get(n));
398
144
  const mimeTypeProcessors = apiModels.MimeTypeProcessorFactory.names().map(n => apiModels.MimeTypeProcessorFactory.get(n));
@@ -403,7 +149,7 @@ class EngineServer {
403
149
  loggingConnectorType: this._loggingConnectorType,
404
150
  mimeTypeProcessors
405
151
  });
406
- await this._webServer.build(restRouteProcessors, restRoutes, socketRouteProcessors, socketRoutes, this._config.web);
152
+ await this._webServer.build(restRouteProcessors, restRoutes, socketRouteProcessors, socketRoutes, coreConfig.web);
407
153
  await this._webServer.start();
408
154
  }
409
155
  /**
@@ -411,10 +157,10 @@ class EngineServer {
411
157
  * @returns The REST routes for the application.
412
158
  * @internal
413
159
  */
414
- buildRestRoutes() {
160
+ async buildRestRoutes() {
415
161
  const routes = [];
416
- for (const { type, typeConfig, generator } of this._restRouteGenerators) {
417
- this.initialiseRestTypeRoute(routes, type, typeConfig, generator);
162
+ for (const { type, typeConfig, module, method } of this._restRouteGenerators) {
163
+ await this.initialiseRestTypeRoute(routes, type, typeConfig, module, method);
418
164
  }
419
165
  return routes;
420
166
  }
@@ -423,10 +169,10 @@ class EngineServer {
423
169
  * @returns The socket routes for the application.
424
170
  * @internal
425
171
  */
426
- buildSocketRoutes() {
172
+ async buildSocketRoutes() {
427
173
  const routes = [];
428
- for (const { type, typeConfig, generator } of this._socketRouteGenerators) {
429
- this.initialiseSocketTypeRoute(routes, type, typeConfig, generator);
174
+ for (const { type, typeConfig, module, method } of this._socketRouteGenerators) {
175
+ await this.initialiseSocketTypeRoute(routes, type, typeConfig, module, method);
430
176
  }
431
177
  return routes;
432
178
  }
@@ -438,9 +184,10 @@ class EngineServer {
438
184
  * @param generateRoutes The function to generate the routes.
439
185
  * @internal
440
186
  */
441
- initialiseRestTypeRoute(routes, typeKey, typeConfig, generateRoutes) {
187
+ async initialiseRestTypeRoute(routes, typeKey, typeConfig, module, method) {
442
188
  if (core.Is.arrayValue(typeConfig)) {
443
189
  const defaultEngineTypes = this._engineCore.getDefaultTypes();
190
+ const generateRoutes = await modules.ModuleHelper.getModuleEntry(module, method);
444
191
  for (let i = 0; i < typeConfig.length; i++) {
445
192
  const restPath = typeConfig[i].restPath;
446
193
  if (core.Is.string(restPath)) {
@@ -457,12 +204,14 @@ class EngineServer {
457
204
  * @param routes The routes to add to.
458
205
  * @param typeKey The key for the default types.
459
206
  * @param typeConfig The type config.
460
- * @param generateRoutes The function to generate the routes.
207
+ * @param module The module containing the generator.
208
+ * @param method The method to call on the module.
461
209
  * @internal
462
210
  */
463
- initialiseSocketTypeRoute(routes, typeKey, typeConfig, generateRoutes) {
211
+ async initialiseSocketTypeRoute(routes, typeKey, typeConfig, module, method) {
464
212
  if (core.Is.arrayValue(typeConfig)) {
465
213
  const defaultEngineTypes = this._engineCore.getDefaultTypes();
214
+ const generateRoutes = await modules.ModuleHelper.getModuleEntry(module, method);
466
215
  for (let i = 0; i < typeConfig.length; i++) {
467
216
  const socketPath = typeConfig[i].socketPath;
468
217
  if (core.Is.string(socketPath)) {
@@ -479,30 +228,31 @@ class EngineServer {
479
228
  * @internal
480
229
  */
481
230
  addServerTypeInitialisers() {
482
- this._engineCore.addTypeInitialiser("authenticationComponent", this._config.authenticationComponent, initialiseAuthenticationComponent);
483
- this._engineCore.addTypeInitialiser("informationComponent", this._config.informationComponent, initialiseInformationComponent);
484
- this._engineCore.addTypeInitialiser("restRouteProcessor", this._config.restRouteProcessor, initialiseRestRouteProcessorComponent);
485
- this._engineCore.addTypeInitialiser("socketRouteProcessor", this._config.socketRouteProcessor, initialiseSocketRouteProcessorComponent);
486
- this._engineCore.addTypeInitialiser("mimeTypeProcessor", this._config.mimeTypeProcessor, initialiseMimeTypeProcessorComponent);
231
+ const coreConfig = this._engineCore.getConfig();
232
+ this._engineCore.addTypeInitialiser("authenticationComponent", coreConfig.types.authenticationComponent, "@twin.org/engine-server-types", "initialiseAuthenticationComponent");
233
+ this._engineCore.addTypeInitialiser("informationComponent", coreConfig.types.informationComponent, "@twin.org/engine-server-types", "initialiseInformationComponent");
234
+ this._engineCore.addTypeInitialiser("restRouteProcessor", coreConfig.types.restRouteProcessor, "@twin.org/engine-server-types", "initialiseRestRouteProcessorComponent");
235
+ this._engineCore.addTypeInitialiser("socketRouteProcessor", coreConfig.types.socketRouteProcessor, "@twin.org/engine-server-types", "initialiseSocketRouteProcessorComponent");
236
+ this._engineCore.addTypeInitialiser("mimeTypeProcessor", coreConfig.types.mimeTypeProcessor, "@twin.org/engine-server-types", "initialiseMimeTypeProcessorComponent");
487
237
  }
488
238
  /**
489
239
  * Add the server REST route generators.
490
240
  * @internal
491
241
  */
492
242
  addServerRestRouteGenerators() {
493
- this.addRestRouteGenerator("informationComponent", this._config.informationComponent, apiService.generateRestRoutesInformation);
494
- this.addRestRouteGenerator("authenticationComponent", this._config.authenticationComponent, apiAuthEntityStorageService.generateRestRoutesAuthentication);
495
243
  const coreConfig = this._engineCore.getConfig();
496
- this.addRestRouteGenerator("loggingComponent", coreConfig.loggingComponent, loggingService.generateRestRoutesLogging);
497
- this.addRestRouteGenerator("telemetryComponent", coreConfig.telemetryComponent, telemetryService.generateRestRoutesTelemetry);
498
- this.addRestRouteGenerator("blobStorageComponent", coreConfig.blobStorageComponent, blobStorageService.generateRestRoutesBlobStorage);
499
- this.addRestRouteGenerator("identityComponent", coreConfig.identityComponent, identityService.generateRestRoutesIdentity);
500
- this.addRestRouteGenerator("identityProfileComponent", coreConfig.identityProfileComponent, identityService.generateRestRoutesIdentityProfile);
501
- this.addRestRouteGenerator("nftComponent", coreConfig.nftComponent, nftService.generateRestRoutesNft);
502
- this.addRestRouteGenerator("attestationComponent", coreConfig.attestationComponent, attestationService.generateRestRoutesAttestation);
503
- this.addRestRouteGenerator("auditableItemGraphComponent", coreConfig.auditableItemGraphComponent, auditableItemGraphService.generateRestRoutesAuditableItemGraph);
504
- this.addRestRouteGenerator("auditableItemStreamComponent", coreConfig.auditableItemStreamComponent, auditableItemStreamService.generateRestRoutesAuditableItemStream);
505
- this.addRestRouteGenerator("entityStorageComponent", coreConfig.entityStorageComponent, entityStorageService.generateRestRoutesEntityStorage);
244
+ this.addRestRouteGenerator("informationComponent", coreConfig.types.informationComponent, "@twin.org/api-service", "generateRestRoutesInformation");
245
+ this.addRestRouteGenerator("authenticationComponent", coreConfig.types.authenticationComponent, "@twin.org/api-auth-entity-storage-service", "generateRestRoutesAuthentication");
246
+ this.addRestRouteGenerator("loggingComponent", coreConfig.types.loggingComponent, "@twin.org/logging-service", "generateRestRoutesLogging");
247
+ this.addRestRouteGenerator("telemetryComponent", coreConfig.types.telemetryComponent, "@twin.org/telemetry-service", "generateRestRoutesTelemetry");
248
+ this.addRestRouteGenerator("blobStorageComponent", coreConfig.types.blobStorageComponent, "@twin.org/blob-storage-service", "generateRestRoutesBlobStorage");
249
+ this.addRestRouteGenerator("identityComponent", coreConfig.types.identityComponent, "@twin.org/identity-service", "generateRestRoutesIdentity");
250
+ this.addRestRouteGenerator("identityProfileComponent", coreConfig.types.identityProfileComponent, "@twin.org/identity-service", "generateRestRoutesIdentityProfile");
251
+ this.addRestRouteGenerator("nftComponent", coreConfig.types.nftComponent, "@twin.org/nft-service", "generateRestRoutesNft");
252
+ this.addRestRouteGenerator("attestationComponent", coreConfig.types.attestationComponent, "@twin.org/attestation-service", "generateRestRoutesAttestation");
253
+ this.addRestRouteGenerator("auditableItemGraphComponent", coreConfig.types.auditableItemGraphComponent, "@twin.org/auditable-item-graph-service", "generateRestRoutesAuditableItemGraph");
254
+ this.addRestRouteGenerator("auditableItemStreamComponent", coreConfig.types.auditableItemStreamComponent, "@twin.org/auditable-item-stream-service", "generateRestRoutesAuditableItemStream");
255
+ this.addRestRouteGenerator("entityStorageComponent", coreConfig.types.entityStorageComponent, "@twin.org/entity-storage-service", "generateRestRoutesEntityStorage");
506
256
  }
507
257
  /**
508
258
  * Add the server socket route generators.
@@ -540,38 +290,42 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo) {
540
290
  };
541
291
  const authProcessorType = envVars.authProcessorType;
542
292
  const serverConfig = {
293
+ ...coreEngineConfig,
543
294
  web: webServerOptions,
544
- informationComponent: [
545
- {
546
- type: engineModels.InformationComponentType.Service,
547
- options: {
548
- config: {
549
- serverInfo
295
+ types: {
296
+ ...coreEngineConfig.types,
297
+ informationComponent: [
298
+ {
299
+ type: engineServerTypes.InformationComponentType.Service,
300
+ options: {
301
+ config: {
302
+ serverInfo
303
+ }
550
304
  }
551
305
  }
552
- }
553
- ],
554
- restRouteProcessor: []
306
+ ],
307
+ restRouteProcessor: []
308
+ }
555
309
  };
556
- serverConfig.restRouteProcessor ??= [];
557
- serverConfig.socketRouteProcessor ??= [];
558
- serverConfig.restRouteProcessor.push({
559
- type: engineModels.RestRouteProcessorType.NodeIdentity
310
+ serverConfig.types.restRouteProcessor ??= [];
311
+ serverConfig.types.socketRouteProcessor ??= [];
312
+ serverConfig.types.restRouteProcessor.push({
313
+ type: engineServerTypes.RestRouteProcessorType.NodeIdentity
560
314
  });
561
- serverConfig.socketRouteProcessor.push({
562
- type: engineModels.SocketRouteProcessorType.NodeIdentity
315
+ serverConfig.types.socketRouteProcessor.push({
316
+ type: engineServerTypes.SocketRouteProcessorType.NodeIdentity
563
317
  });
564
318
  if (!coreEngineConfig.silent) {
565
- serverConfig.restRouteProcessor.push({
566
- type: engineModels.RestRouteProcessorType.Logging,
319
+ serverConfig.types.restRouteProcessor.push({
320
+ type: engineServerTypes.RestRouteProcessorType.Logging,
567
321
  options: {
568
322
  config: {
569
323
  includeBody: coreEngineConfig.debug
570
324
  }
571
325
  }
572
326
  });
573
- serverConfig.socketRouteProcessor.push({
574
- type: engineModels.SocketRouteProcessorType.Logging,
327
+ serverConfig.types.socketRouteProcessor.push({
328
+ type: engineServerTypes.SocketRouteProcessorType.Logging,
575
329
  options: {
576
330
  config: {
577
331
  includeBody: coreEngineConfig.debug
@@ -579,42 +333,42 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo) {
579
333
  }
580
334
  });
581
335
  }
582
- serverConfig.restRouteProcessor.push({
583
- type: engineModels.RestRouteProcessorType.RestRoute,
336
+ serverConfig.types.restRouteProcessor.push({
337
+ type: engineServerTypes.RestRouteProcessorType.RestRoute,
584
338
  options: {
585
339
  config: {
586
340
  includeErrorStack: coreEngineConfig.debug
587
341
  }
588
342
  }
589
343
  });
590
- serverConfig.socketRouteProcessor.push({
591
- type: engineModels.SocketRouteProcessorType.SocketRoute,
344
+ serverConfig.types.socketRouteProcessor.push({
345
+ type: engineServerTypes.SocketRouteProcessorType.SocketRoute,
592
346
  options: {
593
347
  config: {
594
348
  includeErrorStack: coreEngineConfig.debug
595
349
  }
596
350
  }
597
351
  });
598
- if (authProcessorType === engineModels.AuthenticationComponentType.EntityStorage) {
599
- serverConfig.authenticationComponent ??= [];
600
- serverConfig.authenticationComponent.push({
601
- type: engineModels.AuthenticationComponentType.EntityStorage,
352
+ if (authProcessorType === engineServerTypes.AuthenticationComponentType.EntityStorage) {
353
+ serverConfig.types.authenticationComponent ??= [];
354
+ serverConfig.types.authenticationComponent.push({
355
+ type: engineServerTypes.AuthenticationComponentType.EntityStorage,
602
356
  options: {
603
357
  config: {
604
358
  signingKeyName: envVars.authSigningKeyId
605
359
  }
606
360
  }
607
361
  });
608
- serverConfig.restRouteProcessor.push({
609
- type: engineModels.RestRouteProcessorType.AuthHeader,
362
+ serverConfig.types.restRouteProcessor.push({
363
+ type: engineServerTypes.RestRouteProcessorType.AuthHeader,
610
364
  options: {
611
365
  config: {
612
366
  signingKeyName: envVars.authSigningKeyId
613
367
  }
614
368
  }
615
369
  });
616
- serverConfig.socketRouteProcessor.push({
617
- type: engineModels.SocketRouteProcessorType.AuthHeader,
370
+ serverConfig.types.socketRouteProcessor.push({
371
+ type: engineServerTypes.SocketRouteProcessorType.AuthHeader,
618
372
  options: {
619
373
  config: {
620
374
  signingKeyName: envVars.authSigningKeyId
@@ -631,38 +385,38 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo) {
631
385
  * @param serverConfig The server config.
632
386
  */
633
387
  function addRestPaths(coreEngineConfig, serverConfig) {
634
- if (core.Is.arrayValue(serverConfig.informationComponent)) {
635
- serverConfig.informationComponent[0].restPath = "";
388
+ if (core.Is.arrayValue(serverConfig.types.informationComponent)) {
389
+ serverConfig.types.informationComponent[0].restPath = "";
636
390
  }
637
- if (core.Is.arrayValue(serverConfig.authenticationComponent)) {
638
- serverConfig.authenticationComponent[0].restPath = "authentication";
391
+ if (core.Is.arrayValue(serverConfig.types.authenticationComponent)) {
392
+ serverConfig.types.authenticationComponent[0].restPath = "authentication";
639
393
  }
640
- if (core.Is.arrayValue(coreEngineConfig.blobStorageComponent)) {
641
- coreEngineConfig.blobStorageComponent[0].restPath = "blob";
394
+ if (core.Is.arrayValue(coreEngineConfig.types.blobStorageComponent)) {
395
+ coreEngineConfig.types.blobStorageComponent[0].restPath = "blob";
642
396
  }
643
- if (core.Is.arrayValue(coreEngineConfig.loggingComponent)) {
644
- coreEngineConfig.loggingComponent[0].restPath = "logging";
397
+ if (core.Is.arrayValue(coreEngineConfig.types.loggingComponent)) {
398
+ coreEngineConfig.types.loggingComponent[0].restPath = "logging";
645
399
  }
646
- if (core.Is.arrayValue(coreEngineConfig.telemetryComponent)) {
647
- coreEngineConfig.telemetryComponent[0].restPath = "telemetry";
400
+ if (core.Is.arrayValue(coreEngineConfig.types.telemetryComponent)) {
401
+ coreEngineConfig.types.telemetryComponent[0].restPath = "telemetry";
648
402
  }
649
- if (core.Is.arrayValue(coreEngineConfig.identityComponent)) {
650
- coreEngineConfig.identityComponent[0].restPath = "identity";
403
+ if (core.Is.arrayValue(coreEngineConfig.types.identityComponent)) {
404
+ coreEngineConfig.types.identityComponent[0].restPath = "identity";
651
405
  }
652
- if (core.Is.arrayValue(coreEngineConfig.identityProfileComponent)) {
653
- coreEngineConfig.identityProfileComponent[0].restPath = "identity/profile";
406
+ if (core.Is.arrayValue(coreEngineConfig.types.identityProfileComponent)) {
407
+ coreEngineConfig.types.identityProfileComponent[0].restPath = "identity/profile";
654
408
  }
655
- if (core.Is.arrayValue(coreEngineConfig.nftComponent)) {
656
- coreEngineConfig.nftComponent[0].restPath = "nft";
409
+ if (core.Is.arrayValue(coreEngineConfig.types.nftComponent)) {
410
+ coreEngineConfig.types.nftComponent[0].restPath = "nft";
657
411
  }
658
- if (core.Is.arrayValue(coreEngineConfig.attestationComponent)) {
659
- coreEngineConfig.attestationComponent[0].restPath = "attestation";
412
+ if (core.Is.arrayValue(coreEngineConfig.types.attestationComponent)) {
413
+ coreEngineConfig.types.attestationComponent[0].restPath = "attestation";
660
414
  }
661
- if (core.Is.arrayValue(coreEngineConfig.auditableItemGraphComponent)) {
662
- coreEngineConfig.auditableItemGraphComponent[0].restPath = "aig";
415
+ if (core.Is.arrayValue(coreEngineConfig.types.auditableItemGraphComponent)) {
416
+ coreEngineConfig.types.auditableItemGraphComponent[0].restPath = "aig";
663
417
  }
664
- if (core.Is.arrayValue(coreEngineConfig.auditableItemStreamComponent)) {
665
- coreEngineConfig.auditableItemStreamComponent[0].restPath = "ais";
418
+ if (core.Is.arrayValue(coreEngineConfig.types.auditableItemStreamComponent)) {
419
+ coreEngineConfig.types.auditableItemStreamComponent[0].restPath = "ais";
666
420
  }
667
421
  }
668
422