@twin.org/engine-server 0.0.1-next.67 → 0.0.1-next.69
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 +80 -54
- package/dist/esm/index.mjs +79 -55
- package/dist/types/engineServer.d.ts +11 -0
- package/dist/types/utils/engineServerEnvBuilder.d.ts +10 -0
- package/docs/changelog.md +41 -0
- package/docs/reference/classes/EngineServer.md +34 -4
- package/docs/reference/functions/addDefaultRestPaths.md +17 -0
- package/docs/reference/functions/addDefaultSocketPaths.md +17 -0
- package/docs/reference/functions/buildEngineServerConfiguration.md +1 -1
- package/docs/reference/index.md +2 -0
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -39,6 +39,16 @@ class EngineServer {
|
|
|
39
39
|
* @internal
|
|
40
40
|
*/
|
|
41
41
|
_loggingConnectorType;
|
|
42
|
+
/**
|
|
43
|
+
* The REST routes for the application.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
_restRoutes;
|
|
47
|
+
/**
|
|
48
|
+
* The Socket routes for the application.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
_socketRoutes;
|
|
42
52
|
/**
|
|
43
53
|
* Create a new instance of EngineServer.
|
|
44
54
|
* @param options The options for the engine.
|
|
@@ -50,6 +60,8 @@ class EngineServer {
|
|
|
50
60
|
this._engineCore = options.engineCore;
|
|
51
61
|
this._restRouteGenerators = [];
|
|
52
62
|
this._socketRouteGenerators = [];
|
|
63
|
+
this._restRoutes = [];
|
|
64
|
+
this._socketRoutes = [];
|
|
53
65
|
const coreConfig = this._engineCore.getConfig();
|
|
54
66
|
if (!core.Is.arrayValue(coreConfig.types.restRouteProcessor)) {
|
|
55
67
|
coreConfig.types.restRouteProcessor = [];
|
|
@@ -131,6 +143,20 @@ class EngineServer {
|
|
|
131
143
|
});
|
|
132
144
|
}
|
|
133
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Get the built REST routes.
|
|
148
|
+
* @returns The REST routes.
|
|
149
|
+
*/
|
|
150
|
+
getRestRoutes() {
|
|
151
|
+
return this._restRoutes;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get the built socket routes.
|
|
155
|
+
* @returns The socket routes.
|
|
156
|
+
*/
|
|
157
|
+
getSocketRoutes() {
|
|
158
|
+
return this._socketRoutes;
|
|
159
|
+
}
|
|
134
160
|
/**
|
|
135
161
|
* Start the engine server.
|
|
136
162
|
* @returns True if the start was successful.
|
|
@@ -158,8 +184,8 @@ class EngineServer {
|
|
|
158
184
|
* @internal
|
|
159
185
|
*/
|
|
160
186
|
async startWebServer() {
|
|
161
|
-
|
|
162
|
-
|
|
187
|
+
this._restRoutes = await this.buildRestRoutes();
|
|
188
|
+
this._socketRoutes = await this.buildSocketRoutes();
|
|
163
189
|
const restRouteProcessors = apiModels.RestRouteProcessorFactory.names().map(n => apiModels.RestRouteProcessorFactory.get(n));
|
|
164
190
|
const socketRouteProcessors = apiModels.SocketRouteProcessorFactory.names().map(n => apiModels.SocketRouteProcessorFactory.get(n));
|
|
165
191
|
const mimeTypeProcessors = apiModels.MimeTypeProcessorFactory.names().map(n => apiModels.MimeTypeProcessorFactory.get(n));
|
|
@@ -170,7 +196,7 @@ class EngineServer {
|
|
|
170
196
|
loggingConnectorType: this._loggingConnectorType,
|
|
171
197
|
mimeTypeProcessors
|
|
172
198
|
});
|
|
173
|
-
await this._webServer.build(restRouteProcessors,
|
|
199
|
+
await this._webServer.build(restRouteProcessors, this._restRoutes, socketRouteProcessors, this._socketRoutes, coreConfig.web);
|
|
174
200
|
await this._webServer.start();
|
|
175
201
|
}
|
|
176
202
|
/**
|
|
@@ -416,16 +442,15 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, o
|
|
|
416
442
|
}
|
|
417
443
|
});
|
|
418
444
|
}
|
|
419
|
-
|
|
420
|
-
|
|
445
|
+
addDefaultRestPaths(serverConfig);
|
|
446
|
+
addDefaultSocketPaths(serverConfig);
|
|
421
447
|
return serverConfig;
|
|
422
448
|
}
|
|
423
449
|
/**
|
|
424
450
|
* Adds the rest paths to the server config.
|
|
425
|
-
* @param coreEngineConfig The core engine config.
|
|
426
451
|
* @param serverConfig The server config.
|
|
427
452
|
*/
|
|
428
|
-
function
|
|
453
|
+
function addDefaultRestPaths(serverConfig) {
|
|
429
454
|
if (core.Is.arrayValue(serverConfig.types.informationComponent)) {
|
|
430
455
|
serverConfig.types.informationComponent[0].restPath = "";
|
|
431
456
|
}
|
|
@@ -433,74 +458,75 @@ function addRestPaths(coreEngineConfig, serverConfig) {
|
|
|
433
458
|
!core.Is.stringValue(serverConfig.types.authenticationComponent[0].restPath)) {
|
|
434
459
|
serverConfig.types.authenticationComponent[0].restPath = "authentication";
|
|
435
460
|
}
|
|
436
|
-
if (core.Is.arrayValue(
|
|
437
|
-
!core.Is.stringValue(
|
|
438
|
-
|
|
461
|
+
if (core.Is.arrayValue(serverConfig.types.blobStorageComponent) &&
|
|
462
|
+
!core.Is.stringValue(serverConfig.types.blobStorageComponent[0].restPath)) {
|
|
463
|
+
serverConfig.types.blobStorageComponent[0].restPath = "blob";
|
|
439
464
|
}
|
|
440
|
-
if (core.Is.arrayValue(
|
|
441
|
-
!core.Is.stringValue(
|
|
442
|
-
|
|
465
|
+
if (core.Is.arrayValue(serverConfig.types.loggingComponent) &&
|
|
466
|
+
!core.Is.stringValue(serverConfig.types.loggingComponent[0].restPath)) {
|
|
467
|
+
serverConfig.types.loggingComponent[0].restPath = "logging";
|
|
443
468
|
}
|
|
444
|
-
if (core.Is.arrayValue(
|
|
445
|
-
!core.Is.stringValue(
|
|
446
|
-
|
|
469
|
+
if (core.Is.arrayValue(serverConfig.types.telemetryComponent) &&
|
|
470
|
+
!core.Is.stringValue(serverConfig.types.telemetryComponent[0].restPath)) {
|
|
471
|
+
serverConfig.types.telemetryComponent[0].restPath = "telemetry";
|
|
447
472
|
}
|
|
448
|
-
if (core.Is.arrayValue(
|
|
449
|
-
!core.Is.stringValue(
|
|
450
|
-
|
|
473
|
+
if (core.Is.arrayValue(serverConfig.types.identityComponent) &&
|
|
474
|
+
!core.Is.stringValue(serverConfig.types.identityComponent[0].restPath)) {
|
|
475
|
+
serverConfig.types.identityComponent[0].restPath = "identity";
|
|
451
476
|
}
|
|
452
|
-
if (core.Is.arrayValue(
|
|
453
|
-
!core.Is.stringValue(
|
|
454
|
-
|
|
477
|
+
if (core.Is.arrayValue(serverConfig.types.identityResolverComponent) &&
|
|
478
|
+
!core.Is.stringValue(serverConfig.types.identityResolverComponent[0].restPath)) {
|
|
479
|
+
serverConfig.types.identityResolverComponent[0].restPath = "identity";
|
|
455
480
|
}
|
|
456
|
-
if (core.Is.arrayValue(
|
|
457
|
-
!core.Is.stringValue(
|
|
458
|
-
|
|
481
|
+
if (core.Is.arrayValue(serverConfig.types.identityProfileComponent) &&
|
|
482
|
+
!core.Is.stringValue(serverConfig.types.identityProfileComponent[0].restPath)) {
|
|
483
|
+
serverConfig.types.identityProfileComponent[0].restPath = "identity/profile";
|
|
459
484
|
}
|
|
460
|
-
if (core.Is.arrayValue(
|
|
461
|
-
!core.Is.stringValue(
|
|
462
|
-
|
|
485
|
+
if (core.Is.arrayValue(serverConfig.types.nftComponent) &&
|
|
486
|
+
!core.Is.stringValue(serverConfig.types.nftComponent[0].restPath)) {
|
|
487
|
+
serverConfig.types.nftComponent[0].restPath = "nft";
|
|
463
488
|
}
|
|
464
|
-
if (core.Is.arrayValue(
|
|
465
|
-
!core.Is.stringValue(
|
|
466
|
-
|
|
489
|
+
if (core.Is.arrayValue(serverConfig.types.verifiableStorageComponent) &&
|
|
490
|
+
!core.Is.stringValue(serverConfig.types.verifiableStorageComponent[0].restPath)) {
|
|
491
|
+
serverConfig.types.verifiableStorageComponent[0].restPath = "verifiable";
|
|
467
492
|
}
|
|
468
|
-
if (core.Is.arrayValue(
|
|
469
|
-
!core.Is.stringValue(
|
|
470
|
-
|
|
493
|
+
if (core.Is.arrayValue(serverConfig.types.immutableProofComponent) &&
|
|
494
|
+
!core.Is.stringValue(serverConfig.types.immutableProofComponent[0].restPath)) {
|
|
495
|
+
serverConfig.types.immutableProofComponent[0].restPath = "immutable-proof";
|
|
471
496
|
}
|
|
472
|
-
if (core.Is.arrayValue(
|
|
473
|
-
!core.Is.stringValue(
|
|
474
|
-
|
|
497
|
+
if (core.Is.arrayValue(serverConfig.types.attestationComponent) &&
|
|
498
|
+
!core.Is.stringValue(serverConfig.types.attestationComponent[0].restPath)) {
|
|
499
|
+
serverConfig.types.attestationComponent[0].restPath = "attestation";
|
|
475
500
|
}
|
|
476
|
-
if (core.Is.arrayValue(
|
|
477
|
-
!core.Is.stringValue(
|
|
478
|
-
|
|
501
|
+
if (core.Is.arrayValue(serverConfig.types.auditableItemGraphComponent) &&
|
|
502
|
+
!core.Is.stringValue(serverConfig.types.auditableItemGraphComponent[0].restPath)) {
|
|
503
|
+
serverConfig.types.auditableItemGraphComponent[0].restPath = "aig";
|
|
479
504
|
}
|
|
480
|
-
if (core.Is.arrayValue(
|
|
481
|
-
!core.Is.stringValue(
|
|
482
|
-
|
|
505
|
+
if (core.Is.arrayValue(serverConfig.types.auditableItemStreamComponent) &&
|
|
506
|
+
!core.Is.stringValue(serverConfig.types.auditableItemStreamComponent[0].restPath)) {
|
|
507
|
+
serverConfig.types.auditableItemStreamComponent[0].restPath = "ais";
|
|
483
508
|
}
|
|
484
|
-
if (core.Is.arrayValue(
|
|
485
|
-
!core.Is.stringValue(
|
|
486
|
-
|
|
509
|
+
if (core.Is.arrayValue(serverConfig.types.dataProcessingComponent) &&
|
|
510
|
+
!core.Is.stringValue(serverConfig.types.dataProcessingComponent[0].restPath)) {
|
|
511
|
+
serverConfig.types.dataProcessingComponent[0].restPath = "data-processing";
|
|
487
512
|
}
|
|
488
|
-
if (core.Is.arrayValue(
|
|
489
|
-
!core.Is.stringValue(
|
|
490
|
-
|
|
513
|
+
if (core.Is.arrayValue(serverConfig.types.documentManagementComponent) &&
|
|
514
|
+
!core.Is.stringValue(serverConfig.types.documentManagementComponent[0].restPath)) {
|
|
515
|
+
serverConfig.types.documentManagementComponent[0].restPath = "documents";
|
|
491
516
|
}
|
|
492
517
|
}
|
|
493
518
|
/**
|
|
494
519
|
* Adds the socket paths to the server config.
|
|
495
|
-
* @param coreEngineConfig The core engine config.
|
|
496
520
|
* @param serverConfig The server config.
|
|
497
521
|
*/
|
|
498
|
-
function
|
|
499
|
-
if (core.Is.arrayValue(
|
|
500
|
-
!core.Is.stringValue(
|
|
501
|
-
|
|
522
|
+
function addDefaultSocketPaths(serverConfig) {
|
|
523
|
+
if (core.Is.arrayValue(serverConfig.types.eventBusComponent) &&
|
|
524
|
+
!core.Is.stringValue(serverConfig.types.eventBusComponent[0].socketPath)) {
|
|
525
|
+
serverConfig.types.eventBusComponent[0].socketPath = "event-bus";
|
|
502
526
|
}
|
|
503
527
|
}
|
|
504
528
|
|
|
505
529
|
exports.EngineServer = EngineServer;
|
|
530
|
+
exports.addDefaultRestPaths = addDefaultRestPaths;
|
|
531
|
+
exports.addDefaultSocketPaths = addDefaultSocketPaths;
|
|
506
532
|
exports.buildEngineServerConfiguration = buildEngineServerConfiguration;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -37,6 +37,16 @@ class EngineServer {
|
|
|
37
37
|
* @internal
|
|
38
38
|
*/
|
|
39
39
|
_loggingConnectorType;
|
|
40
|
+
/**
|
|
41
|
+
* The REST routes for the application.
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
_restRoutes;
|
|
45
|
+
/**
|
|
46
|
+
* The Socket routes for the application.
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
_socketRoutes;
|
|
40
50
|
/**
|
|
41
51
|
* Create a new instance of EngineServer.
|
|
42
52
|
* @param options The options for the engine.
|
|
@@ -48,6 +58,8 @@ class EngineServer {
|
|
|
48
58
|
this._engineCore = options.engineCore;
|
|
49
59
|
this._restRouteGenerators = [];
|
|
50
60
|
this._socketRouteGenerators = [];
|
|
61
|
+
this._restRoutes = [];
|
|
62
|
+
this._socketRoutes = [];
|
|
51
63
|
const coreConfig = this._engineCore.getConfig();
|
|
52
64
|
if (!Is.arrayValue(coreConfig.types.restRouteProcessor)) {
|
|
53
65
|
coreConfig.types.restRouteProcessor = [];
|
|
@@ -129,6 +141,20 @@ class EngineServer {
|
|
|
129
141
|
});
|
|
130
142
|
}
|
|
131
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Get the built REST routes.
|
|
146
|
+
* @returns The REST routes.
|
|
147
|
+
*/
|
|
148
|
+
getRestRoutes() {
|
|
149
|
+
return this._restRoutes;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get the built socket routes.
|
|
153
|
+
* @returns The socket routes.
|
|
154
|
+
*/
|
|
155
|
+
getSocketRoutes() {
|
|
156
|
+
return this._socketRoutes;
|
|
157
|
+
}
|
|
132
158
|
/**
|
|
133
159
|
* Start the engine server.
|
|
134
160
|
* @returns True if the start was successful.
|
|
@@ -156,8 +182,8 @@ class EngineServer {
|
|
|
156
182
|
* @internal
|
|
157
183
|
*/
|
|
158
184
|
async startWebServer() {
|
|
159
|
-
|
|
160
|
-
|
|
185
|
+
this._restRoutes = await this.buildRestRoutes();
|
|
186
|
+
this._socketRoutes = await this.buildSocketRoutes();
|
|
161
187
|
const restRouteProcessors = RestRouteProcessorFactory.names().map(n => RestRouteProcessorFactory.get(n));
|
|
162
188
|
const socketRouteProcessors = SocketRouteProcessorFactory.names().map(n => SocketRouteProcessorFactory.get(n));
|
|
163
189
|
const mimeTypeProcessors = MimeTypeProcessorFactory.names().map(n => MimeTypeProcessorFactory.get(n));
|
|
@@ -168,7 +194,7 @@ class EngineServer {
|
|
|
168
194
|
loggingConnectorType: this._loggingConnectorType,
|
|
169
195
|
mimeTypeProcessors
|
|
170
196
|
});
|
|
171
|
-
await this._webServer.build(restRouteProcessors,
|
|
197
|
+
await this._webServer.build(restRouteProcessors, this._restRoutes, socketRouteProcessors, this._socketRoutes, coreConfig.web);
|
|
172
198
|
await this._webServer.start();
|
|
173
199
|
}
|
|
174
200
|
/**
|
|
@@ -414,16 +440,15 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, o
|
|
|
414
440
|
}
|
|
415
441
|
});
|
|
416
442
|
}
|
|
417
|
-
|
|
418
|
-
|
|
443
|
+
addDefaultRestPaths(serverConfig);
|
|
444
|
+
addDefaultSocketPaths(serverConfig);
|
|
419
445
|
return serverConfig;
|
|
420
446
|
}
|
|
421
447
|
/**
|
|
422
448
|
* Adds the rest paths to the server config.
|
|
423
|
-
* @param coreEngineConfig The core engine config.
|
|
424
449
|
* @param serverConfig The server config.
|
|
425
450
|
*/
|
|
426
|
-
function
|
|
451
|
+
function addDefaultRestPaths(serverConfig) {
|
|
427
452
|
if (Is.arrayValue(serverConfig.types.informationComponent)) {
|
|
428
453
|
serverConfig.types.informationComponent[0].restPath = "";
|
|
429
454
|
}
|
|
@@ -431,73 +456,72 @@ function addRestPaths(coreEngineConfig, serverConfig) {
|
|
|
431
456
|
!Is.stringValue(serverConfig.types.authenticationComponent[0].restPath)) {
|
|
432
457
|
serverConfig.types.authenticationComponent[0].restPath = "authentication";
|
|
433
458
|
}
|
|
434
|
-
if (Is.arrayValue(
|
|
435
|
-
!Is.stringValue(
|
|
436
|
-
|
|
459
|
+
if (Is.arrayValue(serverConfig.types.blobStorageComponent) &&
|
|
460
|
+
!Is.stringValue(serverConfig.types.blobStorageComponent[0].restPath)) {
|
|
461
|
+
serverConfig.types.blobStorageComponent[0].restPath = "blob";
|
|
437
462
|
}
|
|
438
|
-
if (Is.arrayValue(
|
|
439
|
-
!Is.stringValue(
|
|
440
|
-
|
|
463
|
+
if (Is.arrayValue(serverConfig.types.loggingComponent) &&
|
|
464
|
+
!Is.stringValue(serverConfig.types.loggingComponent[0].restPath)) {
|
|
465
|
+
serverConfig.types.loggingComponent[0].restPath = "logging";
|
|
441
466
|
}
|
|
442
|
-
if (Is.arrayValue(
|
|
443
|
-
!Is.stringValue(
|
|
444
|
-
|
|
467
|
+
if (Is.arrayValue(serverConfig.types.telemetryComponent) &&
|
|
468
|
+
!Is.stringValue(serverConfig.types.telemetryComponent[0].restPath)) {
|
|
469
|
+
serverConfig.types.telemetryComponent[0].restPath = "telemetry";
|
|
445
470
|
}
|
|
446
|
-
if (Is.arrayValue(
|
|
447
|
-
!Is.stringValue(
|
|
448
|
-
|
|
471
|
+
if (Is.arrayValue(serverConfig.types.identityComponent) &&
|
|
472
|
+
!Is.stringValue(serverConfig.types.identityComponent[0].restPath)) {
|
|
473
|
+
serverConfig.types.identityComponent[0].restPath = "identity";
|
|
449
474
|
}
|
|
450
|
-
if (Is.arrayValue(
|
|
451
|
-
!Is.stringValue(
|
|
452
|
-
|
|
475
|
+
if (Is.arrayValue(serverConfig.types.identityResolverComponent) &&
|
|
476
|
+
!Is.stringValue(serverConfig.types.identityResolverComponent[0].restPath)) {
|
|
477
|
+
serverConfig.types.identityResolverComponent[0].restPath = "identity";
|
|
453
478
|
}
|
|
454
|
-
if (Is.arrayValue(
|
|
455
|
-
!Is.stringValue(
|
|
456
|
-
|
|
479
|
+
if (Is.arrayValue(serverConfig.types.identityProfileComponent) &&
|
|
480
|
+
!Is.stringValue(serverConfig.types.identityProfileComponent[0].restPath)) {
|
|
481
|
+
serverConfig.types.identityProfileComponent[0].restPath = "identity/profile";
|
|
457
482
|
}
|
|
458
|
-
if (Is.arrayValue(
|
|
459
|
-
!Is.stringValue(
|
|
460
|
-
|
|
483
|
+
if (Is.arrayValue(serverConfig.types.nftComponent) &&
|
|
484
|
+
!Is.stringValue(serverConfig.types.nftComponent[0].restPath)) {
|
|
485
|
+
serverConfig.types.nftComponent[0].restPath = "nft";
|
|
461
486
|
}
|
|
462
|
-
if (Is.arrayValue(
|
|
463
|
-
!Is.stringValue(
|
|
464
|
-
|
|
487
|
+
if (Is.arrayValue(serverConfig.types.verifiableStorageComponent) &&
|
|
488
|
+
!Is.stringValue(serverConfig.types.verifiableStorageComponent[0].restPath)) {
|
|
489
|
+
serverConfig.types.verifiableStorageComponent[0].restPath = "verifiable";
|
|
465
490
|
}
|
|
466
|
-
if (Is.arrayValue(
|
|
467
|
-
!Is.stringValue(
|
|
468
|
-
|
|
491
|
+
if (Is.arrayValue(serverConfig.types.immutableProofComponent) &&
|
|
492
|
+
!Is.stringValue(serverConfig.types.immutableProofComponent[0].restPath)) {
|
|
493
|
+
serverConfig.types.immutableProofComponent[0].restPath = "immutable-proof";
|
|
469
494
|
}
|
|
470
|
-
if (Is.arrayValue(
|
|
471
|
-
!Is.stringValue(
|
|
472
|
-
|
|
495
|
+
if (Is.arrayValue(serverConfig.types.attestationComponent) &&
|
|
496
|
+
!Is.stringValue(serverConfig.types.attestationComponent[0].restPath)) {
|
|
497
|
+
serverConfig.types.attestationComponent[0].restPath = "attestation";
|
|
473
498
|
}
|
|
474
|
-
if (Is.arrayValue(
|
|
475
|
-
!Is.stringValue(
|
|
476
|
-
|
|
499
|
+
if (Is.arrayValue(serverConfig.types.auditableItemGraphComponent) &&
|
|
500
|
+
!Is.stringValue(serverConfig.types.auditableItemGraphComponent[0].restPath)) {
|
|
501
|
+
serverConfig.types.auditableItemGraphComponent[0].restPath = "aig";
|
|
477
502
|
}
|
|
478
|
-
if (Is.arrayValue(
|
|
479
|
-
!Is.stringValue(
|
|
480
|
-
|
|
503
|
+
if (Is.arrayValue(serverConfig.types.auditableItemStreamComponent) &&
|
|
504
|
+
!Is.stringValue(serverConfig.types.auditableItemStreamComponent[0].restPath)) {
|
|
505
|
+
serverConfig.types.auditableItemStreamComponent[0].restPath = "ais";
|
|
481
506
|
}
|
|
482
|
-
if (Is.arrayValue(
|
|
483
|
-
!Is.stringValue(
|
|
484
|
-
|
|
507
|
+
if (Is.arrayValue(serverConfig.types.dataProcessingComponent) &&
|
|
508
|
+
!Is.stringValue(serverConfig.types.dataProcessingComponent[0].restPath)) {
|
|
509
|
+
serverConfig.types.dataProcessingComponent[0].restPath = "data-processing";
|
|
485
510
|
}
|
|
486
|
-
if (Is.arrayValue(
|
|
487
|
-
!Is.stringValue(
|
|
488
|
-
|
|
511
|
+
if (Is.arrayValue(serverConfig.types.documentManagementComponent) &&
|
|
512
|
+
!Is.stringValue(serverConfig.types.documentManagementComponent[0].restPath)) {
|
|
513
|
+
serverConfig.types.documentManagementComponent[0].restPath = "documents";
|
|
489
514
|
}
|
|
490
515
|
}
|
|
491
516
|
/**
|
|
492
517
|
* Adds the socket paths to the server config.
|
|
493
|
-
* @param coreEngineConfig The core engine config.
|
|
494
518
|
* @param serverConfig The server config.
|
|
495
519
|
*/
|
|
496
|
-
function
|
|
497
|
-
if (Is.arrayValue(
|
|
498
|
-
!Is.stringValue(
|
|
499
|
-
|
|
520
|
+
function addDefaultSocketPaths(serverConfig) {
|
|
521
|
+
if (Is.arrayValue(serverConfig.types.eventBusComponent) &&
|
|
522
|
+
!Is.stringValue(serverConfig.types.eventBusComponent[0].socketPath)) {
|
|
523
|
+
serverConfig.types.eventBusComponent[0].socketPath = "event-bus";
|
|
500
524
|
}
|
|
501
525
|
}
|
|
502
526
|
|
|
503
|
-
export { EngineServer, buildEngineServerConfiguration };
|
|
527
|
+
export { EngineServer, addDefaultRestPaths, addDefaultSocketPaths, buildEngineServerConfiguration };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IRestRoute, ISocketRoute } from "@twin.org/api-models";
|
|
1
2
|
import type { IEngineCore, IEngineCoreTypeConfig, IEngineServer } from "@twin.org/engine-models";
|
|
2
3
|
import { type IEngineServerConfig } from "@twin.org/engine-server-types";
|
|
3
4
|
/**
|
|
@@ -32,6 +33,16 @@ export declare class EngineServer<T extends IEngineServerConfig = IEngineServerC
|
|
|
32
33
|
* @param method The method to call on the module.
|
|
33
34
|
*/
|
|
34
35
|
addSocketRouteGenerator(type: string, typeConfig: IEngineCoreTypeConfig[] | undefined, module: string, method: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Get the built REST routes.
|
|
38
|
+
* @returns The REST routes.
|
|
39
|
+
*/
|
|
40
|
+
getRestRoutes(): IRestRoute[];
|
|
41
|
+
/**
|
|
42
|
+
* Get the built socket routes.
|
|
43
|
+
* @returns The socket routes.
|
|
44
|
+
*/
|
|
45
|
+
getSocketRoutes(): ISocketRoute[];
|
|
35
46
|
/**
|
|
36
47
|
* Start the engine server.
|
|
37
48
|
* @returns True if the start was successful.
|
|
@@ -11,3 +11,13 @@ import type { IEngineServerEnvironmentVariables } from "../models/IEngineServerE
|
|
|
11
11
|
* @returns The the config for the core and the server.
|
|
12
12
|
*/
|
|
13
13
|
export declare function buildEngineServerConfiguration(envVars: IEngineServerEnvironmentVariables, coreEngineConfig: IEngineCoreConfig, serverInfo: IServerInfo, openApiSpecPath?: string): IEngineServerConfig;
|
|
14
|
+
/**
|
|
15
|
+
* Adds the rest paths to the server config.
|
|
16
|
+
* @param serverConfig The server config.
|
|
17
|
+
*/
|
|
18
|
+
export declare function addDefaultRestPaths(serverConfig: IEngineServerConfig): void;
|
|
19
|
+
/**
|
|
20
|
+
* Adds the socket paths to the server config.
|
|
21
|
+
* @param serverConfig The server config.
|
|
22
|
+
*/
|
|
23
|
+
export declare function addDefaultSocketPaths(serverConfig: IEngineServerConfig): void;
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @twin.org/engine-server - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.1-next.69](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.1-next.68...engine-server-v0.0.1-next.69) (2025-04-25)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* expose default rest and socket path creation ([e6c6e26](https://github.com/twinfoundation/engine/commit/e6c6e266c8017212a74d4997e2e335347457a2bc))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* use abbreviated docs path ([9258a72](https://github.com/twinfoundation/engine/commit/9258a72adf266ddcc4f98002a07a7a162755f24b))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Dependencies
|
|
17
|
+
|
|
18
|
+
* The following workspace dependencies were updated
|
|
19
|
+
* dependencies
|
|
20
|
+
* @twin.org/engine-core bumped from 0.0.1-next.68 to 0.0.1-next.69
|
|
21
|
+
* @twin.org/engine-models bumped from 0.0.1-next.68 to 0.0.1-next.69
|
|
22
|
+
* @twin.org/engine-server-types bumped from 0.0.1-next.68 to 0.0.1-next.69
|
|
23
|
+
* devDependencies
|
|
24
|
+
* @twin.org/engine bumped from 0.0.1-next.68 to 0.0.1-next.69
|
|
25
|
+
|
|
26
|
+
## [0.0.1-next.68](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.1-next.67...engine-server-v0.0.1-next.68) (2025-04-17)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* use shared store mechanism ([#2](https://github.com/twinfoundation/engine/issues/2)) ([9eed8d7](https://github.com/twinfoundation/engine/commit/9eed8d7766388479b42f03e2542fe761f2156408))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Dependencies
|
|
35
|
+
|
|
36
|
+
* The following workspace dependencies were updated
|
|
37
|
+
* dependencies
|
|
38
|
+
* @twin.org/engine-core bumped from 0.0.1-next.67 to 0.0.1-next.68
|
|
39
|
+
* @twin.org/engine-models bumped from 0.0.1-next.67 to 0.0.1-next.68
|
|
40
|
+
* @twin.org/engine-server-types bumped from 0.0.1-next.67 to 0.0.1-next.68
|
|
41
|
+
* devDependencies
|
|
42
|
+
* @twin.org/engine bumped from 0.0.1-next.67 to 0.0.1-next.68
|
|
43
|
+
|
|
3
44
|
## [0.0.1-next.67](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.1-next.66...engine-server-v0.0.1-next.67) (2025-03-28)
|
|
4
45
|
|
|
5
46
|
|
|
@@ -4,7 +4,9 @@ Server for the engine.
|
|
|
4
4
|
|
|
5
5
|
## Type Parameters
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
### T
|
|
8
|
+
|
|
9
|
+
`T` *extends* `IEngineServerConfig` = `IEngineServerConfig`
|
|
8
10
|
|
|
9
11
|
## Implements
|
|
10
12
|
|
|
@@ -12,9 +14,9 @@ Server for the engine.
|
|
|
12
14
|
|
|
13
15
|
## Constructors
|
|
14
16
|
|
|
15
|
-
###
|
|
17
|
+
### Constructor
|
|
16
18
|
|
|
17
|
-
> **new EngineServer**\<`T`\>(`options`):
|
|
19
|
+
> **new EngineServer**\<`T`\>(`options`): `EngineServer`\<`T`\>
|
|
18
20
|
|
|
19
21
|
Create a new instance of EngineServer.
|
|
20
22
|
|
|
@@ -32,7 +34,7 @@ The engine core to serve from.
|
|
|
32
34
|
|
|
33
35
|
#### Returns
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
`EngineServer`\<`T`\>
|
|
36
38
|
|
|
37
39
|
## Properties
|
|
38
40
|
|
|
@@ -128,6 +130,34 @@ The method to call on the module.
|
|
|
128
130
|
|
|
129
131
|
***
|
|
130
132
|
|
|
133
|
+
### getRestRoutes()
|
|
134
|
+
|
|
135
|
+
> **getRestRoutes**(): `IRestRoute`\<`any`, `any`\>[]
|
|
136
|
+
|
|
137
|
+
Get the built REST routes.
|
|
138
|
+
|
|
139
|
+
#### Returns
|
|
140
|
+
|
|
141
|
+
`IRestRoute`\<`any`, `any`\>[]
|
|
142
|
+
|
|
143
|
+
The REST routes.
|
|
144
|
+
|
|
145
|
+
***
|
|
146
|
+
|
|
147
|
+
### getSocketRoutes()
|
|
148
|
+
|
|
149
|
+
> **getSocketRoutes**(): `ISocketRoute`\<`any`, `any`\>[]
|
|
150
|
+
|
|
151
|
+
Get the built socket routes.
|
|
152
|
+
|
|
153
|
+
#### Returns
|
|
154
|
+
|
|
155
|
+
`ISocketRoute`\<`any`, `any`\>[]
|
|
156
|
+
|
|
157
|
+
The socket routes.
|
|
158
|
+
|
|
159
|
+
***
|
|
160
|
+
|
|
131
161
|
### start()
|
|
132
162
|
|
|
133
163
|
> **start**(): `Promise`\<`boolean`\>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Function: addDefaultRestPaths()
|
|
2
|
+
|
|
3
|
+
> **addDefaultRestPaths**(`serverConfig`): `void`
|
|
4
|
+
|
|
5
|
+
Adds the rest paths to the server config.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### serverConfig
|
|
10
|
+
|
|
11
|
+
`IEngineServerConfig`
|
|
12
|
+
|
|
13
|
+
The server config.
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
`void`
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Function: addDefaultSocketPaths()
|
|
2
|
+
|
|
3
|
+
> **addDefaultSocketPaths**(`serverConfig`): `void`
|
|
4
|
+
|
|
5
|
+
Adds the socket paths to the server config.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### serverConfig
|
|
10
|
+
|
|
11
|
+
`IEngineServerConfig`
|
|
12
|
+
|
|
13
|
+
The server config.
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
`void`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Function: buildEngineServerConfiguration()
|
|
2
2
|
|
|
3
|
-
> **buildEngineServerConfiguration**(`envVars`, `coreEngineConfig`, `serverInfo`, `openApiSpecPath
|
|
3
|
+
> **buildEngineServerConfiguration**(`envVars`, `coreEngineConfig`, `serverInfo`, `openApiSpecPath?`): `IEngineServerConfig`
|
|
4
4
|
|
|
5
5
|
Handles the configuration of the server.
|
|
6
6
|
|
package/docs/reference/index.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/engine-server",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.69",
|
|
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.1-next.
|
|
21
|
-
"@twin.org/engine-models": "0.0.1-next.
|
|
22
|
-
"@twin.org/engine-server-types": "0.0.1-next.
|
|
20
|
+
"@twin.org/engine-core": "0.0.1-next.69",
|
|
21
|
+
"@twin.org/engine-models": "0.0.1-next.69",
|
|
22
|
+
"@twin.org/engine-server-types": "0.0.1-next.69",
|
|
23
23
|
"@twin.org/modules": "next",
|
|
24
24
|
"@twin.org/nameof": "next"
|
|
25
25
|
},
|