@twin.org/engine-server 0.0.3-next.3 → 0.0.3-next.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TWIN Engine Server
2
2
 
3
- Engine implementation for a server.
3
+ Engine Server exposes runtime capabilities through REST and socket routes and integrates hosting concerns with engine orchestration. It is intended for service deployments that need structured API entry points backed by shared runtime conventions.
4
4
 
5
5
  ## Installation
6
6
 
@@ -11,12 +11,30 @@
11
11
  "method": "generateRestRoutesAuthentication",
12
12
  "defaultPath": "/authentication"
13
13
  },
14
+ {
15
+ "type": "authenticationAdminComponent",
16
+ "module": "@twin.org/api-auth-entity-storage-service",
17
+ "method": "generateRestRoutesAuthenticationAdmin",
18
+ "defaultPath": "/authentication/admin"
19
+ },
20
+ {
21
+ "type": "authenticationAuditComponent",
22
+ "module": "@twin.org/api-auth-entity-storage-service",
23
+ "method": "generateRestRoutesAuthenticationAudit",
24
+ "defaultPath": "/authentication/audit"
25
+ },
14
26
  {
15
27
  "type": "loggingComponent",
16
28
  "module": "@twin.org/logging-service",
17
29
  "method": "generateRestRoutesLogging",
18
30
  "defaultPath": "/logging"
19
31
  },
32
+ {
33
+ "type": "tenantAdminComponent",
34
+ "module": "@twin.org/api-tenant-processor",
35
+ "method": "generateRestRoutesTenants",
36
+ "defaultPath": "/tenants"
37
+ },
20
38
  {
21
39
  "type": "telemetryComponent",
22
40
  "module": "@twin.org/telemetry-service",
@@ -53,6 +71,12 @@
53
71
  "method": "generateRestRoutesNft",
54
72
  "defaultPath": "/nft"
55
73
  },
74
+ {
75
+ "type": "notarizationComponent",
76
+ "module": "@twin.org/notarization-service",
77
+ "method": "generateRestRoutesNotarization",
78
+ "defaultPath": "/notarization"
79
+ },
56
80
  {
57
81
  "type": "verifiableStorageComponent",
58
82
  "module": "@twin.org/verifiable-storage-service",
@@ -118,12 +142,6 @@
118
142
  "method": "generateRestRoutesPolicyNegotiationAdminPoint",
119
143
  "defaultPath": "/rights-management"
120
144
  },
121
- {
122
- "type": "rightsManagementDapComponent",
123
- "module": "@twin.org/rights-management-service",
124
- "method": "generateRestRoutesDataAccessPoint",
125
- "defaultPath": "/rights-management"
126
- },
127
145
  {
128
146
  "type": "synchronisedStorageComponent",
129
147
  "module": "@twin.org/synchronised-storage-service",
@@ -137,9 +155,15 @@
137
155
  "defaultPath": "/federated-catalogue"
138
156
  },
139
157
  {
140
- "type": "dataSpaceConnectorComponent",
141
- "module": "@twin.org/data-space-connector-service",
142
- "method": "generateRestRoutesDataSpaceConnector",
143
- "defaultPath": "/data-space-connector"
158
+ "type": "dataspaceControlPlaneComponent",
159
+ "module": "@twin.org/dataspace-control-plane-service",
160
+ "method": "generateRestRoutesDataspaceControlPlane",
161
+ "defaultPath": "/dataspace"
162
+ },
163
+ {
164
+ "type": "dataspaceDataPlaneComponent",
165
+ "module": "@twin.org/dataspace-data-plane-service",
166
+ "method": "generateRestRoutesDataspaceDataPlane",
167
+ "defaultPath": "/dataspace"
144
168
  }
145
169
  ]
@@ -6,9 +6,9 @@
6
6
  "defaultPath": "event-bus"
7
7
  },
8
8
  {
9
- "type": "dataSpaceConnectorComponent",
10
- "module": "@twin.org/data-space-connector-service",
11
- "method": "generateSocketRoutesDataSpaceConnector",
12
- "defaultPath": "data-space-connector"
9
+ "type": "dataspaceDataPlaneComponent",
10
+ "module": "@twin.org/dataspace-data-plane-service",
11
+ "method": "generateSocketRoutesDataspaceDataPlane",
12
+ "defaultPath": "dataspace"
13
13
  }
14
14
  ]
@@ -1,4 +1,14 @@
1
1
  [
2
+ {
3
+ "type": "authenticationAuditComponent",
4
+ "module": "@twin.org/engine-server-types",
5
+ "method": "initialiseAuthenticationAuditComponent"
6
+ },
7
+ {
8
+ "type": "authenticationRateComponent",
9
+ "module": "@twin.org/engine-server-types",
10
+ "method": "initialiseAuthenticationRateComponent"
11
+ },
2
12
  {
3
13
  "type": "authenticationAdminComponent",
4
14
  "module": "@twin.org/engine-server-types",
@@ -15,6 +25,11 @@
15
25
  "method": "initialiseInformationComponent",
16
26
  "defaultRestPath": ""
17
27
  },
28
+ {
29
+ "type": "hostingComponent",
30
+ "module": "@twin.org/engine-server-types",
31
+ "method": "initialiseHostingComponent"
32
+ },
18
33
  {
19
34
  "type": "restRouteProcessor",
20
35
  "module": "@twin.org/engine-server-types",
@@ -167,16 +167,13 @@ export class EngineServer {
167
167
  }
168
168
  /**
169
169
  * Start the engine server.
170
- * @returns True if the start was successful.
170
+ * @returns Nothing.
171
171
  */
172
172
  async start() {
173
- const canContinue = await this._engineCore.start();
174
- if (canContinue) {
175
- await ContextIdStore.run(this._engineCore.getContextIds() ?? {}, async () => {
176
- await this.startWebServer();
177
- });
178
- }
179
- return canContinue;
173
+ await this._engineCore.start();
174
+ await ContextIdStore.run(this._engineCore.getContextIds() ?? {}, async () => {
175
+ await this.startWebServer();
176
+ });
180
177
  }
181
178
  /**
182
179
  * Stop the engine server.
@@ -206,8 +203,10 @@ export class EngineServer {
206
203
  const loggingComponentType = coreConfig.silent
207
204
  ? undefined
208
205
  : this._engineCore.getRegisteredInstanceType("loggingComponent");
206
+ const hostingComponentType = this._engineCore.getRegisteredInstanceTypeOptional("hostingComponent");
209
207
  this._webServer = new FastifyWebServer({
210
208
  loggingComponentType,
209
+ hostingComponentType,
211
210
  mimeTypeProcessors
212
211
  });
213
212
  await this._webServer.build(restRouteProcessors, this._restRoutes, socketRouteProcessors, this._socketRoutes, coreConfig.web);
@@ -1 +1 @@
1
- {"version":3,"file":"engineServer.js","sourceRoot":"","sources":["../../src/engineServer.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,EAA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AAC;gBAClD,IAAI,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC3B,MAAM,WAAW,GAChB,UAAU,CAAC,CAAC,CAAC,CAAC,oBAAoB;wBAClC,IAAI,CAAC,WAAW,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;oBACrD,IAAI,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;wBACjC,MAAM,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,UAAU,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC;oBACxE,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED;;;OAGG;IACK,yBAAyB;QAChC,KAAK,MAAM,WAAW,IAAI,sBAAsB,EAAE,CAAC;YAClD,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QAC/F,CAAC;IACF,CAAC;IAED;;;OAGG;IACK,4BAA4B;QACnC,KAAK,MAAM,SAAS,IAAI,yBAAyB,EAAE,CAAC;YACnD,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAChF,CAAC;IACF,CAAC;IAED;;;OAGG;IACK,8BAA8B;QACrC,KAAK,MAAM,SAAS,IAAI,2BAA2B,EAAE,CAAC;YACrD,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAClF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRoute, ISocketRoute, IWebServer } from \"@twin.org/api-models\";\nimport {\n\tMimeTypeProcessorFactory,\n\tRestRouteProcessorFactory,\n\tSocketRouteProcessorFactory\n} from \"@twin.org/api-models\";\nimport { FastifyWebServer } from \"@twin.org/api-server-fastify\";\nimport { ContextIdStore } from \"@twin.org/context\";\nimport { Guards, Is, StringHelper } from \"@twin.org/core\";\nimport type { IEngineCore, IEngineCoreTypeConfig, IEngineServer } from \"@twin.org/engine-models\";\nimport {\n\tRestRouteProcessorType,\n\tSocketRouteProcessorType,\n\ttype IEngineServerConfig\n} from \"@twin.org/engine-server-types\";\nimport { ModuleHelper } from \"@twin.org/modules\";\nimport { nameof } from \"@twin.org/nameof\";\nimport serverRestRouteGenerators from \"./data/serverRestRouteGenerators.json\" with { type: \"json\" };\nimport serverSocketRouteGenerators from \"./data/serverSocketRouteGenerators.json\" with { type: \"json\" };\nimport serverTypeInitialisers from \"./data/serverTypeInitialisers.json\" with { type: \"json\" };\n\n/**\n * Server for the engine.\n */\nexport class EngineServer<T extends IEngineServerConfig = IEngineServerConfig>\n\timplements IEngineServer\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EngineServer>();\n\n\t/**\n\t * The engine.\n\t * @internal\n\t */\n\tprivate readonly _engineCore: IEngineCore<T>;\n\n\t/**\n\t * The REST route generators.\n\t * @internal\n\t */\n\tprivate readonly _restRouteGenerators: {\n\t\ttype: string;\n\t\tmodule: string;\n\t\tmethod: string;\n\t}[];\n\n\t/**\n\t * The socket route generators.\n\t * @internal\n\t */\n\tprivate readonly _socketRouteGenerators: {\n\t\ttype: string;\n\t\tmodule: string;\n\t\tmethod: string;\n\t}[];\n\n\t/**\n\t * The web server.\n\t * @internal\n\t */\n\tprivate _webServer?: IWebServer<unknown>;\n\n\t/**\n\t * The REST routes for the application.\n\t * @internal\n\t */\n\tprivate _restRoutes: IRestRoute[];\n\n\t/**\n\t * The Socket routes for the application.\n\t * @internal\n\t */\n\tprivate _socketRoutes: ISocketRoute[];\n\n\t/**\n\t * Create a new instance of EngineServer.\n\t * @param options The options for the engine.\n\t * @param options.engineCore The engine core to serve from.\n\t */\n\tconstructor(options: { engineCore: IEngineCore<T> }) {\n\t\tGuards.object(EngineServer.CLASS_NAME, nameof(options), options);\n\t\tGuards.object(EngineServer.CLASS_NAME, nameof(options.engineCore), options.engineCore);\n\n\t\tthis._engineCore = options.engineCore;\n\t\tthis._restRouteGenerators = [];\n\t\tthis._socketRouteGenerators = [];\n\t\tthis._restRoutes = [];\n\t\tthis._socketRoutes = [];\n\n\t\tconst coreConfig = this._engineCore.getConfig();\n\n\t\tif (!Is.arrayValue(coreConfig.types.restRouteProcessor)) {\n\t\t\tcoreConfig.types.restRouteProcessor = [];\n\n\t\t\tif (!coreConfig.silent) {\n\t\t\t\tcoreConfig.types.restRouteProcessor.push({\n\t\t\t\t\ttype: RestRouteProcessorType.Logging,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tincludeBody: coreConfig.debug\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\tcoreConfig.types.restRouteProcessor.push({\n\t\t\t\ttype: RestRouteProcessorType.RestRoute,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tincludeErrorStack: coreConfig.debug\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tif (!Is.arrayValue(coreConfig.types.socketRouteProcessor)) {\n\t\t\tcoreConfig.types.socketRouteProcessor = [];\n\n\t\t\tif (!coreConfig.silent) {\n\t\t\t\tcoreConfig.types.socketRouteProcessor.push({\n\t\t\t\t\ttype: SocketRouteProcessorType.Logging,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tincludeBody: coreConfig.debug\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\tcoreConfig.types.socketRouteProcessor.push({\n\t\t\t\ttype: SocketRouteProcessorType.SocketRoute,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tincludeErrorStack: coreConfig.debug\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tthis.addServerTypeInitialisers();\n\t\tthis.addServerRestRouteGenerators();\n\t\tthis.addServerSocketRouteGenerators();\n\t}\n\n\t/**\n\t * Add a REST route generator.\n\t * @param type The type to add the generator for.\n\t * @param module The module containing the generator.\n\t * @param method The method to call on the module.\n\t */\n\tpublic addRestRouteGenerator(type: string, module: string, method: string): void {\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(type), type);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(module), module);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(method), method);\n\n\t\tconst currentIndex = this._restRouteGenerators.findIndex(r => r.type === type);\n\t\tif (currentIndex >= 0) {\n\t\t\tthis._restRouteGenerators[currentIndex].module = module;\n\t\t\tthis._restRouteGenerators[currentIndex].method = method;\n\t\t} else {\n\t\t\tthis._restRouteGenerators.push({\n\t\t\t\ttype,\n\t\t\t\tmodule,\n\t\t\t\tmethod\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Add a socket route generator.\n\t * @param type The type to add the generator for.\n\t * @param module The module containing the generator.\n\t * @param method The method to call on the module.\n\t */\n\tpublic addSocketRouteGenerator(type: string, module: string, method: string): void {\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(type), type);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(module), module);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(method), method);\n\n\t\tconst currentIndex = this._socketRouteGenerators.findIndex(s => s.type === type);\n\t\tif (currentIndex >= 0) {\n\t\t\tthis._socketRouteGenerators[currentIndex].module = module;\n\t\t\tthis._socketRouteGenerators[currentIndex].method = method;\n\t\t} else {\n\t\t\tthis._socketRouteGenerators.push({\n\t\t\t\ttype,\n\t\t\t\tmodule,\n\t\t\t\tmethod\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get the built REST routes.\n\t * @returns The REST routes.\n\t */\n\tpublic getRestRoutes(): IRestRoute[] {\n\t\treturn this._restRoutes;\n\t}\n\n\t/**\n\t * Get the built socket routes.\n\t * @returns The socket routes.\n\t */\n\tpublic getSocketRoutes(): ISocketRoute[] {\n\t\treturn this._socketRoutes;\n\t}\n\n\t/**\n\t * Start the engine server.\n\t * @returns True if the start was successful.\n\t */\n\tpublic async start(): Promise<boolean> {\n\t\tconst canContinue = await this._engineCore.start();\n\n\t\tif (canContinue) {\n\t\t\tawait ContextIdStore.run(this._engineCore.getContextIds() ?? {}, async () => {\n\t\t\t\tawait this.startWebServer();\n\t\t\t});\n\t\t}\n\n\t\treturn canContinue;\n\t}\n\n\t/**\n\t * Stop the engine server.\n\t * @returns Nothing.\n\t */\n\tpublic async stop(): Promise<void> {\n\t\tawait ContextIdStore.run(this._engineCore.getContextIds() ?? {}, async () => {\n\t\t\tif (this._webServer) {\n\t\t\t\tconst webServer = this._webServer;\n\t\t\t\tthis._webServer = undefined;\n\t\t\t\tawait webServer.stop();\n\t\t\t}\n\t\t});\n\n\t\tawait this._engineCore.stop();\n\t}\n\n\t/**\n\t * Starts the web server.\n\t * @internal\n\t */\n\tprivate async startWebServer(): Promise<void> {\n\t\tthis._restRoutes = await this.buildRestRoutes();\n\t\tthis._socketRoutes = await this.buildSocketRoutes();\n\t\tconst restRouteProcessors = RestRouteProcessorFactory.names().map(n =>\n\t\t\tRestRouteProcessorFactory.get(n)\n\t\t);\n\t\tconst socketRouteProcessors = SocketRouteProcessorFactory.names().map(n =>\n\t\t\tSocketRouteProcessorFactory.get(n)\n\t\t);\n\t\tconst mimeTypeProcessors = MimeTypeProcessorFactory.names().map(n =>\n\t\t\tMimeTypeProcessorFactory.get(n)\n\t\t);\n\n\t\tconst coreConfig = this._engineCore.getConfig();\n\t\tconst loggingComponentType = coreConfig.silent\n\t\t\t? undefined\n\t\t\t: this._engineCore.getRegisteredInstanceType(\"loggingComponent\");\n\n\t\tthis._webServer = new FastifyWebServer({\n\t\t\tloggingComponentType,\n\t\t\tmimeTypeProcessors\n\t\t});\n\n\t\tawait this._webServer.build(\n\t\t\trestRouteProcessors,\n\t\t\tthis._restRoutes,\n\t\t\tsocketRouteProcessors,\n\t\t\tthis._socketRoutes,\n\t\t\tcoreConfig.web\n\t\t);\n\t\tawait this._webServer.start();\n\t}\n\n\t/**\n\t * The REST routes for the application.\n\t * @returns The REST routes for the application.\n\t * @internal\n\t */\n\tprivate async buildRestRoutes(): Promise<IRestRoute[]> {\n\t\tconst routes: IRestRoute[] = [];\n\n\t\tfor (const { type, module, method } of this._restRouteGenerators) {\n\t\t\tawait this.initialiseRestTypeRoute(routes, type, module, method);\n\t\t}\n\n\t\treturn routes;\n\t}\n\n\t/**\n\t * The socket routes for the application.\n\t * @returns The socket routes for the application.\n\t * @internal\n\t */\n\tprivate async buildSocketRoutes(): Promise<ISocketRoute[]> {\n\t\tconst routes: ISocketRoute[] = [];\n\n\t\tfor (const { type, module, method } of this._socketRouteGenerators) {\n\t\t\tawait this.initialiseSocketTypeRoute(routes, type, module, method);\n\t\t}\n\n\t\treturn routes;\n\t}\n\n\t/**\n\t * Initialise the rest routes from connector.\n\t * @param routes The routes to add to.\n\t * @param typeKey The key for the default types.\n\t * @param generateRoutes The function to generate the routes.\n\t * @internal\n\t */\n\tprivate async initialiseRestTypeRoute(\n\t\troutes: IRestRoute[],\n\t\ttypeKey: string,\n\t\tmodule: string,\n\t\tmethod: string\n\t): Promise<void> {\n\t\tconst typeConfig: IEngineCoreTypeConfig[] | undefined = this._engineCore.getTypeConfig(typeKey);\n\n\t\tif (Is.arrayValue(typeConfig)) {\n\t\t\tconst generateRoutes = await ModuleHelper.getModuleEntry<\n\t\t\t\t(baseRouteName: string, componentName: string, options?: unknown) => IRestRoute[]\n\t\t\t>(module, method);\n\n\t\t\tfor (let i = 0; i < typeConfig.length; i++) {\n\t\t\t\tconst restPath = typeConfig[i].restPath;\n\t\t\t\tconst restOptions = typeConfig[i].restOptions;\n\n\t\t\t\tif (Is.string(restPath)) {\n\t\t\t\t\tconst serviceType =\n\t\t\t\t\t\ttypeConfig[i].overrideInstanceType ??\n\t\t\t\t\t\tthis._engineCore.getRegisteredInstanceType(typeKey);\n\t\t\t\t\tif (Is.stringValue(serviceType)) {\n\t\t\t\t\t\tconst generatedRoutes = generateRoutes(restPath, serviceType, restOptions);\n\t\t\t\t\t\tfor (const route of generatedRoutes) {\n\t\t\t\t\t\t\t// Don't strip trailing slashes from the root path.\n\t\t\t\t\t\t\tif (Is.stringValue(route.path) && route.path.length > 1) {\n\t\t\t\t\t\t\t\troute.path = StringHelper.trimTrailingSlashes(route.path);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\troutes.push(...generatedRoutes);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Initialise the socket routes from connector.\n\t * @param routes The routes to add to.\n\t * @param typeKey The key for the default types.\n\t * @param module The module containing the generator.\n\t * @param method The method to call on the module.\n\t * @internal\n\t */\n\tprivate async initialiseSocketTypeRoute(\n\t\troutes: ISocketRoute[],\n\t\ttypeKey: string,\n\t\tmodule: string,\n\t\tmethod: string\n\t): Promise<void> {\n\t\tconst typeConfig: IEngineCoreTypeConfig[] | undefined = this._engineCore.getTypeConfig(typeKey);\n\n\t\tif (Is.arrayValue(typeConfig)) {\n\t\t\tconst generateRoutes = await ModuleHelper.getModuleEntry<\n\t\t\t\t(baseRouteName: string, componentName: string, options?: unknown) => ISocketRoute[]\n\t\t\t>(module, method);\n\n\t\t\tfor (let i = 0; i < typeConfig.length; i++) {\n\t\t\t\tconst socketPath = typeConfig[i].socketPath;\n\t\t\t\tconst socketOptions = typeConfig[i].socketOptions;\n\t\t\t\tif (Is.string(socketPath)) {\n\t\t\t\t\tconst serviceType =\n\t\t\t\t\t\ttypeConfig[i].overrideInstanceType ??\n\t\t\t\t\t\tthis._engineCore.getRegisteredInstanceType(typeKey);\n\t\t\t\t\tif (Is.stringValue(serviceType)) {\n\t\t\t\t\t\troutes.push(...generateRoutes(socketPath, serviceType, socketOptions));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Add the server type initializers.\n\t * @internal\n\t */\n\tprivate addServerTypeInitialisers(): void {\n\t\tfor (const initializer of serverTypeInitialisers) {\n\t\t\tthis._engineCore.addTypeInitialiser(initializer.type, initializer.module, initializer.method);\n\t\t}\n\t}\n\n\t/**\n\t * Add the server REST route generators.\n\t * @internal\n\t */\n\tprivate addServerRestRouteGenerators(): void {\n\t\tfor (const generator of serverRestRouteGenerators) {\n\t\t\tthis.addRestRouteGenerator(generator.type, generator.module, generator.method);\n\t\t}\n\t}\n\n\t/**\n\t * Add the server socket route generators.\n\t * @internal\n\t */\n\tprivate addServerSocketRouteGenerators(): void {\n\t\tfor (const generator of serverSocketRouteGenerators) {\n\t\t\tthis.addSocketRouteGenerator(generator.type, generator.module, generator.method);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"engineServer.js","sourceRoot":"","sources":["../../src/engineServer.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EACN,sBAAsB,EACtB,wBAAwB,EAExB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,yBAAyB,MAAM,uCAAuC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACpG,OAAO,2BAA2B,MAAM,yCAAyC,CAAC,OAAO,IAAI,EAAE,MAAM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C,GAAG,cAAc,CAAC,UAAU,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC;oBACxE,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED;;;OAGG;IACK,yBAAyB;QAChC,KAAK,MAAM,WAAW,IAAI,sBAAsB,EAAE,CAAC;YAClD,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QAC/F,CAAC;IACF,CAAC;IAED;;;OAGG;IACK,4BAA4B;QACnC,KAAK,MAAM,SAAS,IAAI,yBAAyB,EAAE,CAAC;YACnD,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAChF,CAAC;IACF,CAAC;IAED;;;OAGG;IACK,8BAA8B;QACrC,KAAK,MAAM,SAAS,IAAI,2BAA2B,EAAE,CAAC;YACrD,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAClF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRoute, ISocketRoute, IWebServer } from \"@twin.org/api-models\";\nimport {\n\tMimeTypeProcessorFactory,\n\tRestRouteProcessorFactory,\n\tSocketRouteProcessorFactory\n} from \"@twin.org/api-models\";\nimport { FastifyWebServer } from \"@twin.org/api-server-fastify\";\nimport { ContextIdStore } from \"@twin.org/context\";\nimport { Guards, Is, StringHelper } from \"@twin.org/core\";\nimport type { IEngineCore, IEngineCoreTypeConfig, IEngineServer } from \"@twin.org/engine-models\";\nimport {\n\tRestRouteProcessorType,\n\tSocketRouteProcessorType,\n\ttype IEngineServerConfig\n} from \"@twin.org/engine-server-types\";\nimport { ModuleHelper } from \"@twin.org/modules\";\nimport { nameof } from \"@twin.org/nameof\";\nimport serverRestRouteGenerators from \"./data/serverRestRouteGenerators.json\" with { type: \"json\" };\nimport serverSocketRouteGenerators from \"./data/serverSocketRouteGenerators.json\" with { type: \"json\" };\nimport serverTypeInitialisers from \"./data/serverTypeInitialisers.json\" with { type: \"json\" };\n\n/**\n * Server for the engine.\n */\nexport class EngineServer<\n\tT extends IEngineServerConfig = IEngineServerConfig\n> implements IEngineServer {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EngineServer>();\n\n\t/**\n\t * The engine.\n\t * @internal\n\t */\n\tprivate readonly _engineCore: IEngineCore<T>;\n\n\t/**\n\t * The REST route generators.\n\t * @internal\n\t */\n\tprivate readonly _restRouteGenerators: {\n\t\ttype: string;\n\t\tmodule: string;\n\t\tmethod: string;\n\t}[];\n\n\t/**\n\t * The socket route generators.\n\t * @internal\n\t */\n\tprivate readonly _socketRouteGenerators: {\n\t\ttype: string;\n\t\tmodule: string;\n\t\tmethod: string;\n\t}[];\n\n\t/**\n\t * The web server.\n\t * @internal\n\t */\n\tprivate _webServer?: IWebServer<unknown>;\n\n\t/**\n\t * The REST routes for the application.\n\t * @internal\n\t */\n\tprivate _restRoutes: IRestRoute[];\n\n\t/**\n\t * The Socket routes for the application.\n\t * @internal\n\t */\n\tprivate _socketRoutes: ISocketRoute[];\n\n\t/**\n\t * Create a new instance of EngineServer.\n\t * @param options The options for the engine.\n\t * @param options.engineCore The engine core to serve from.\n\t */\n\tconstructor(options: { engineCore: IEngineCore<T> }) {\n\t\tGuards.object(EngineServer.CLASS_NAME, nameof(options), options);\n\t\tGuards.object(EngineServer.CLASS_NAME, nameof(options.engineCore), options.engineCore);\n\n\t\tthis._engineCore = options.engineCore;\n\t\tthis._restRouteGenerators = [];\n\t\tthis._socketRouteGenerators = [];\n\t\tthis._restRoutes = [];\n\t\tthis._socketRoutes = [];\n\n\t\tconst coreConfig = this._engineCore.getConfig();\n\n\t\tif (!Is.arrayValue(coreConfig.types.restRouteProcessor)) {\n\t\t\tcoreConfig.types.restRouteProcessor = [];\n\n\t\t\tif (!coreConfig.silent) {\n\t\t\t\tcoreConfig.types.restRouteProcessor.push({\n\t\t\t\t\ttype: RestRouteProcessorType.Logging,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tincludeBody: coreConfig.debug\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\tcoreConfig.types.restRouteProcessor.push({\n\t\t\t\ttype: RestRouteProcessorType.RestRoute,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tincludeErrorStack: coreConfig.debug\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tif (!Is.arrayValue(coreConfig.types.socketRouteProcessor)) {\n\t\t\tcoreConfig.types.socketRouteProcessor = [];\n\n\t\t\tif (!coreConfig.silent) {\n\t\t\t\tcoreConfig.types.socketRouteProcessor.push({\n\t\t\t\t\ttype: SocketRouteProcessorType.Logging,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tincludeBody: coreConfig.debug\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\tcoreConfig.types.socketRouteProcessor.push({\n\t\t\t\ttype: SocketRouteProcessorType.SocketRoute,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tincludeErrorStack: coreConfig.debug\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tthis.addServerTypeInitialisers();\n\t\tthis.addServerRestRouteGenerators();\n\t\tthis.addServerSocketRouteGenerators();\n\t}\n\n\t/**\n\t * Add a REST route generator.\n\t * @param type The type to add the generator for.\n\t * @param module The module containing the generator.\n\t * @param method The method to call on the module.\n\t */\n\tpublic addRestRouteGenerator(type: string, module: string, method: string): void {\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(type), type);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(module), module);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(method), method);\n\n\t\tconst currentIndex = this._restRouteGenerators.findIndex(r => r.type === type);\n\t\tif (currentIndex >= 0) {\n\t\t\tthis._restRouteGenerators[currentIndex].module = module;\n\t\t\tthis._restRouteGenerators[currentIndex].method = method;\n\t\t} else {\n\t\t\tthis._restRouteGenerators.push({\n\t\t\t\ttype,\n\t\t\t\tmodule,\n\t\t\t\tmethod\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Add a socket route generator.\n\t * @param type The type to add the generator for.\n\t * @param module The module containing the generator.\n\t * @param method The method to call on the module.\n\t */\n\tpublic addSocketRouteGenerator(type: string, module: string, method: string): void {\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(type), type);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(module), module);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(method), method);\n\n\t\tconst currentIndex = this._socketRouteGenerators.findIndex(s => s.type === type);\n\t\tif (currentIndex >= 0) {\n\t\t\tthis._socketRouteGenerators[currentIndex].module = module;\n\t\t\tthis._socketRouteGenerators[currentIndex].method = method;\n\t\t} else {\n\t\t\tthis._socketRouteGenerators.push({\n\t\t\t\ttype,\n\t\t\t\tmodule,\n\t\t\t\tmethod\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get the built REST routes.\n\t * @returns The REST routes.\n\t */\n\tpublic getRestRoutes(): IRestRoute[] {\n\t\treturn this._restRoutes;\n\t}\n\n\t/**\n\t * Get the built socket routes.\n\t * @returns The socket routes.\n\t */\n\tpublic getSocketRoutes(): ISocketRoute[] {\n\t\treturn this._socketRoutes;\n\t}\n\n\t/**\n\t * Start the engine server.\n\t * @returns Nothing.\n\t */\n\tpublic async start(): Promise<void> {\n\t\tawait this._engineCore.start();\n\n\t\tawait ContextIdStore.run(this._engineCore.getContextIds() ?? {}, async () => {\n\t\t\tawait this.startWebServer();\n\t\t});\n\t}\n\n\t/**\n\t * Stop the engine server.\n\t * @returns Nothing.\n\t */\n\tpublic async stop(): Promise<void> {\n\t\tawait ContextIdStore.run(this._engineCore.getContextIds() ?? {}, async () => {\n\t\t\tif (this._webServer) {\n\t\t\t\tconst webServer = this._webServer;\n\t\t\t\tthis._webServer = undefined;\n\t\t\t\tawait webServer.stop();\n\t\t\t}\n\t\t});\n\n\t\tawait this._engineCore.stop();\n\t}\n\n\t/**\n\t * Starts the web server.\n\t * @internal\n\t */\n\tprivate async startWebServer(): Promise<void> {\n\t\tthis._restRoutes = await this.buildRestRoutes();\n\t\tthis._socketRoutes = await this.buildSocketRoutes();\n\t\tconst restRouteProcessors = RestRouteProcessorFactory.names().map(n =>\n\t\t\tRestRouteProcessorFactory.get(n)\n\t\t);\n\t\tconst socketRouteProcessors = SocketRouteProcessorFactory.names().map(n =>\n\t\t\tSocketRouteProcessorFactory.get(n)\n\t\t);\n\t\tconst mimeTypeProcessors = MimeTypeProcessorFactory.names().map(n =>\n\t\t\tMimeTypeProcessorFactory.get(n)\n\t\t);\n\n\t\tconst coreConfig = this._engineCore.getConfig();\n\t\tconst loggingComponentType = coreConfig.silent\n\t\t\t? undefined\n\t\t\t: this._engineCore.getRegisteredInstanceType(\"loggingComponent\");\n\t\tconst hostingComponentType =\n\t\t\tthis._engineCore.getRegisteredInstanceTypeOptional(\"hostingComponent\");\n\n\t\tthis._webServer = new FastifyWebServer({\n\t\t\tloggingComponentType,\n\t\t\thostingComponentType,\n\t\t\tmimeTypeProcessors\n\t\t});\n\n\t\tawait this._webServer.build(\n\t\t\trestRouteProcessors,\n\t\t\tthis._restRoutes,\n\t\t\tsocketRouteProcessors,\n\t\t\tthis._socketRoutes,\n\t\t\tcoreConfig.web\n\t\t);\n\t\tawait this._webServer.start();\n\t}\n\n\t/**\n\t * The REST routes for the application.\n\t * @returns The REST routes for the application.\n\t * @internal\n\t */\n\tprivate async buildRestRoutes(): Promise<IRestRoute[]> {\n\t\tconst routes: IRestRoute[] = [];\n\n\t\tfor (const { type, module, method } of this._restRouteGenerators) {\n\t\t\tawait this.initialiseRestTypeRoute(routes, type, module, method);\n\t\t}\n\n\t\treturn routes;\n\t}\n\n\t/**\n\t * The socket routes for the application.\n\t * @returns The socket routes for the application.\n\t * @internal\n\t */\n\tprivate async buildSocketRoutes(): Promise<ISocketRoute[]> {\n\t\tconst routes: ISocketRoute[] = [];\n\n\t\tfor (const { type, module, method } of this._socketRouteGenerators) {\n\t\t\tawait this.initialiseSocketTypeRoute(routes, type, module, method);\n\t\t}\n\n\t\treturn routes;\n\t}\n\n\t/**\n\t * Initialise the rest routes from connector.\n\t * @param routes The routes to add to.\n\t * @param typeKey The key for the default types.\n\t * @param generateRoutes The function to generate the routes.\n\t * @internal\n\t */\n\tprivate async initialiseRestTypeRoute(\n\t\troutes: IRestRoute[],\n\t\ttypeKey: string,\n\t\tmodule: string,\n\t\tmethod: string\n\t): Promise<void> {\n\t\tconst typeConfig: IEngineCoreTypeConfig[] | undefined = this._engineCore.getTypeConfig(typeKey);\n\n\t\tif (Is.arrayValue(typeConfig)) {\n\t\t\tconst generateRoutes = await ModuleHelper.getModuleEntry<\n\t\t\t\t(baseRouteName: string, componentName: string, options?: unknown) => IRestRoute[]\n\t\t\t>(module, method);\n\n\t\t\tfor (let i = 0; i < typeConfig.length; i++) {\n\t\t\t\tconst restPath = typeConfig[i].restPath;\n\t\t\t\tconst restOptions = typeConfig[i].restOptions;\n\n\t\t\t\tif (Is.string(restPath)) {\n\t\t\t\t\tconst serviceType =\n\t\t\t\t\t\ttypeConfig[i].overrideInstanceType ??\n\t\t\t\t\t\tthis._engineCore.getRegisteredInstanceType(typeKey);\n\t\t\t\t\tif (Is.stringValue(serviceType)) {\n\t\t\t\t\t\tconst generatedRoutes = generateRoutes(restPath, serviceType, restOptions);\n\t\t\t\t\t\tfor (const route of generatedRoutes) {\n\t\t\t\t\t\t\t// Don't strip trailing slashes from the root path.\n\t\t\t\t\t\t\tif (Is.stringValue(route.path) && route.path.length > 1) {\n\t\t\t\t\t\t\t\troute.path = StringHelper.trimTrailingSlashes(route.path);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\troutes.push(...generatedRoutes);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Initialise the socket routes from connector.\n\t * @param routes The routes to add to.\n\t * @param typeKey The key for the default types.\n\t * @param module The module containing the generator.\n\t * @param method The method to call on the module.\n\t * @internal\n\t */\n\tprivate async initialiseSocketTypeRoute(\n\t\troutes: ISocketRoute[],\n\t\ttypeKey: string,\n\t\tmodule: string,\n\t\tmethod: string\n\t): Promise<void> {\n\t\tconst typeConfig: IEngineCoreTypeConfig[] | undefined = this._engineCore.getTypeConfig(typeKey);\n\n\t\tif (Is.arrayValue(typeConfig)) {\n\t\t\tconst generateRoutes = await ModuleHelper.getModuleEntry<\n\t\t\t\t(baseRouteName: string, componentName: string, options?: unknown) => ISocketRoute[]\n\t\t\t>(module, method);\n\n\t\t\tfor (let i = 0; i < typeConfig.length; i++) {\n\t\t\t\tconst socketPath = typeConfig[i].socketPath;\n\t\t\t\tconst socketOptions = typeConfig[i].socketOptions;\n\t\t\t\tif (Is.string(socketPath)) {\n\t\t\t\t\tconst serviceType =\n\t\t\t\t\t\ttypeConfig[i].overrideInstanceType ??\n\t\t\t\t\t\tthis._engineCore.getRegisteredInstanceType(typeKey);\n\t\t\t\t\tif (Is.stringValue(serviceType)) {\n\t\t\t\t\t\troutes.push(...generateRoutes(socketPath, serviceType, socketOptions));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Add the server type initializers.\n\t * @internal\n\t */\n\tprivate addServerTypeInitialisers(): void {\n\t\tfor (const initializer of serverTypeInitialisers) {\n\t\t\tthis._engineCore.addTypeInitialiser(initializer.type, initializer.module, initializer.method);\n\t\t}\n\t}\n\n\t/**\n\t * Add the server REST route generators.\n\t * @internal\n\t */\n\tprivate addServerRestRouteGenerators(): void {\n\t\tfor (const generator of serverRestRouteGenerators) {\n\t\t\tthis.addRestRouteGenerator(generator.type, generator.module, generator.method);\n\t\t}\n\t}\n\n\t/**\n\t * Add the server socket route generators.\n\t * @internal\n\t */\n\tprivate addServerSocketRouteGenerators(): void {\n\t\tfor (const generator of serverSocketRouteGenerators) {\n\t\t\tthis.addSocketRouteGenerator(generator.type, generator.module, generator.method);\n\t\t}\n\t}\n}\n"]}
@@ -43,9 +43,9 @@ export declare class EngineServer<T extends IEngineServerConfig = IEngineServerC
43
43
  getSocketRoutes(): ISocketRoute[];
44
44
  /**
45
45
  * Start the engine server.
46
- * @returns True if the start was successful.
46
+ * @returns Nothing.
47
47
  */
48
- start(): Promise<boolean>;
48
+ start(): Promise<void>;
49
49
  /**
50
50
  * Stop the engine server.
51
51
  * @returns Nothing.
package/docs/changelog.md CHANGED
@@ -1,4 +1,603 @@
1
- # @twin.org/engine-server - Changelog
1
+ # Changelog
2
+
3
+ ## [0.0.3-next.31](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.30...engine-server-v0.0.3-next.31) (2026-04-22)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **engine-server:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/engine-core bumped from 0.0.3-next.30 to 0.0.3-next.31
16
+ * @twin.org/engine-models bumped from 0.0.3-next.30 to 0.0.3-next.31
17
+ * @twin.org/engine-server-types bumped from 0.0.3-next.30 to 0.0.3-next.31
18
+ * devDependencies
19
+ * @twin.org/engine bumped from 0.0.3-next.30 to 0.0.3-next.31
20
+
21
+ ## [0.0.3-next.30](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.29...engine-server-v0.0.3-next.30) (2026-04-16)
22
+
23
+
24
+ ### Features
25
+
26
+ * add notarization ([#98](https://github.com/twinfoundation/engine/issues/98)) ([f560e2a](https://github.com/twinfoundation/engine/commit/f560e2a12a5fba01c95e47518ebdc4220801f8b8))
27
+
28
+
29
+ ### Dependencies
30
+
31
+ * The following workspace dependencies were updated
32
+ * dependencies
33
+ * @twin.org/engine-core bumped from 0.0.3-next.29 to 0.0.3-next.30
34
+ * @twin.org/engine-models bumped from 0.0.3-next.29 to 0.0.3-next.30
35
+ * @twin.org/engine-server-types bumped from 0.0.3-next.29 to 0.0.3-next.30
36
+ * devDependencies
37
+ * @twin.org/engine bumped from 0.0.3-next.29 to 0.0.3-next.30
38
+
39
+ ## [0.0.3-next.29](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.28...engine-server-v0.0.3-next.29) (2026-04-14)
40
+
41
+
42
+ ### Features
43
+
44
+ * add authentication rate and audit services ([#95](https://github.com/twinfoundation/engine/issues/95)) ([55e2b08](https://github.com/twinfoundation/engine/commit/55e2b089661529e0556115817cc435cc6e4292cc))
45
+
46
+
47
+ ### Dependencies
48
+
49
+ * The following workspace dependencies were updated
50
+ * dependencies
51
+ * @twin.org/engine-core bumped from 0.0.3-next.28 to 0.0.3-next.29
52
+ * @twin.org/engine-models bumped from 0.0.3-next.28 to 0.0.3-next.29
53
+ * @twin.org/engine-server-types bumped from 0.0.3-next.28 to 0.0.3-next.29
54
+ * devDependencies
55
+ * @twin.org/engine bumped from 0.0.3-next.28 to 0.0.3-next.29
56
+
57
+ ## [0.0.3-next.28](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.27...engine-server-v0.0.3-next.28) (2026-04-10)
58
+
59
+
60
+ ### Features
61
+
62
+ * use tenant admin service instead of custom tenant tracking ([72553d2](https://github.com/twinfoundation/engine/commit/72553d2c3e3b46fec77d3049bd0271bfec69ffc6))
63
+
64
+
65
+ ### Dependencies
66
+
67
+ * The following workspace dependencies were updated
68
+ * dependencies
69
+ * @twin.org/engine-core bumped from 0.0.3-next.27 to 0.0.3-next.28
70
+ * @twin.org/engine-models bumped from 0.0.3-next.27 to 0.0.3-next.28
71
+ * @twin.org/engine-server-types bumped from 0.0.3-next.27 to 0.0.3-next.28
72
+ * devDependencies
73
+ * @twin.org/engine bumped from 0.0.3-next.27 to 0.0.3-next.28
74
+
75
+ ## [0.0.3-next.27](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.26...engine-server-v0.0.3-next.27) (2026-03-20)
76
+
77
+
78
+ ### Features
79
+
80
+ * update dependencies ([e6ebe42](https://github.com/twinfoundation/engine/commit/e6ebe42b9d61066227ad8b45dae14c8f8615b760))
81
+
82
+
83
+ ### Dependencies
84
+
85
+ * The following workspace dependencies were updated
86
+ * dependencies
87
+ * @twin.org/engine-core bumped from 0.0.3-next.26 to 0.0.3-next.27
88
+ * @twin.org/engine-models bumped from 0.0.3-next.26 to 0.0.3-next.27
89
+ * @twin.org/engine-server-types bumped from 0.0.3-next.26 to 0.0.3-next.27
90
+ * devDependencies
91
+ * @twin.org/engine bumped from 0.0.3-next.26 to 0.0.3-next.27
92
+
93
+ ## [0.0.3-next.26](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.25...engine-server-v0.0.3-next.26) (2026-03-05)
94
+
95
+
96
+ ### Miscellaneous Chores
97
+
98
+ * **engine-server:** Synchronize repo versions
99
+
100
+
101
+ ### Dependencies
102
+
103
+ * The following workspace dependencies were updated
104
+ * dependencies
105
+ * @twin.org/engine-core bumped from 0.0.3-next.25 to 0.0.3-next.26
106
+ * @twin.org/engine-models bumped from 0.0.3-next.25 to 0.0.3-next.26
107
+ * @twin.org/engine-server-types bumped from 0.0.3-next.25 to 0.0.3-next.26
108
+ * devDependencies
109
+ * @twin.org/engine bumped from 0.0.3-next.25 to 0.0.3-next.26
110
+
111
+ ## [0.0.3-next.25](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.24...engine-server-v0.0.3-next.25) (2026-03-02)
112
+
113
+
114
+ ### Features
115
+
116
+ * replace unified data space connector with control plane and data plane components ([#78](https://github.com/twinfoundation/engine/issues/78)) ([a6ebace](https://github.com/twinfoundation/engine/commit/a6ebace389dafe754a3ca0827999966b5a101a59))
117
+
118
+
119
+ ### Dependencies
120
+
121
+ * The following workspace dependencies were updated
122
+ * dependencies
123
+ * @twin.org/engine-core bumped from 0.0.3-next.24 to 0.0.3-next.25
124
+ * @twin.org/engine-models bumped from 0.0.3-next.24 to 0.0.3-next.25
125
+ * @twin.org/engine-server-types bumped from 0.0.3-next.24 to 0.0.3-next.25
126
+ * devDependencies
127
+ * @twin.org/engine bumped from 0.0.3-next.24 to 0.0.3-next.25
128
+
129
+ ## [0.0.3-next.24](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.23...engine-server-v0.0.3-next.24) (2026-02-26)
130
+
131
+
132
+ ### Miscellaneous Chores
133
+
134
+ * **engine-server:** Synchronize repo versions
135
+
136
+
137
+ ### Dependencies
138
+
139
+ * The following workspace dependencies were updated
140
+ * dependencies
141
+ * @twin.org/engine-core bumped from 0.0.3-next.23 to 0.0.3-next.24
142
+ * @twin.org/engine-models bumped from 0.0.3-next.23 to 0.0.3-next.24
143
+ * @twin.org/engine-server-types bumped from 0.0.3-next.23 to 0.0.3-next.24
144
+ * devDependencies
145
+ * @twin.org/engine bumped from 0.0.3-next.23 to 0.0.3-next.24
146
+
147
+ ## [0.0.3-next.23](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.22...engine-server-v0.0.3-next.23) (2026-02-23)
148
+
149
+
150
+ ### Features
151
+
152
+ * add auth admin component ([201cd06](https://github.com/twinfoundation/engine/commit/201cd061be83afccb5a6b06856ffe7cf8db7d6b3))
153
+ * add authentication admin routes ([c912019](https://github.com/twinfoundation/engine/commit/c9120198cd5c86e20bab588f2a9f20415baf56ca))
154
+ * add context id features ([#51](https://github.com/twinfoundation/engine/issues/51)) ([eaef180](https://github.com/twinfoundation/engine/commit/eaef1807397a907bc7655ef1545a151a710ca2f1))
155
+ * add data space connector ([a824d99](https://github.com/twinfoundation/engine/commit/a824d9931faeaa8115e01f8e7545b802d0e7ac70))
156
+ * add default logging component for web server ([8ad94f0](https://github.com/twinfoundation/engine/commit/8ad94f0d2d9a5241a8854b1e59fb9a55ce310142))
157
+ * add entity storage to task scheduler ([da4dc0f](https://github.com/twinfoundation/engine/commit/da4dc0f26ee4d506d35cd267144c8300a8b52f90))
158
+ * add fed cat filters ([a52cbf1](https://github.com/twinfoundation/engine/commit/a52cbf1eaf85e6cad61de9ea9448932fb5ae0f43))
159
+ * add federated catalogue ([1b15dd0](https://github.com/twinfoundation/engine/commit/1b15dd059a11446457651c411a73145fab37f025))
160
+ * add hosting component ([#70](https://github.com/twinfoundation/engine/issues/70)) ([2ab0dec](https://github.com/twinfoundation/engine/commit/2ab0dec8fdb979395c639b73f394a40a0dd7e55a))
161
+ * add isPrimary and isClone methods ([a7c63e9](https://github.com/twinfoundation/engine/commit/a7c63e97f54c95b104cc81e66d3fa42c6607bdc1))
162
+ * add latest rights management components ([2d305c8](https://github.com/twinfoundation/engine/commit/2d305c8c85c77bb4f5694c76422db4a11efc1a40))
163
+ * add mimeTypeProcessors and disableNodeIdentity ([bb7e81e](https://github.com/twinfoundation/engine/commit/bb7e81e2036fe042068a5645ec59b22e20d33aad))
164
+ * add rest clients as components ([c6f956a](https://github.com/twinfoundation/engine/commit/c6f956afe4fc22cd552174539c92a109448dc242))
165
+ * add REST options for route construction ([4adf0af](https://github.com/twinfoundation/engine/commit/4adf0af8a03689a4dbdf67e8527d6db0d2c5d59d))
166
+ * add rights management modules ([e02cadc](https://github.com/twinfoundation/engine/commit/e02cadc840d242fe16a73ab41ba61376c7467e50))
167
+ * add rights management negotiation ([84ef46b](https://github.com/twinfoundation/engine/commit/84ef46bff110611a19512793425c8c873ee2a590))
168
+ * add synchronised storage support ([5142e34](https://github.com/twinfoundation/engine/commit/5142e3488f09195cf9f48a9c6c6d1014231a4c2c))
169
+ * add task scheduler ([0951107](https://github.com/twinfoundation/engine/commit/09511073ad042194a45206303f0ef31d8d6af5db))
170
+ * add tenant admin routes ([#76](https://github.com/twinfoundation/engine/issues/76)) ([3c0af90](https://github.com/twinfoundation/engine/commit/3c0af90a572fcda08d8720bdcee9b9f1cd02b872))
171
+ * add trust and rights management plugins ([eea0807](https://github.com/twinfoundation/engine/commit/eea0807601833220bd9fd8605b5e4383fbc0ebae))
172
+ * add validate-locales ([b92ea09](https://github.com/twinfoundation/engine/commit/b92ea09dbcfe35225271a51f24d231f59e2d363e))
173
+ * eslint migration to flat config ([6b978da](https://github.com/twinfoundation/engine/commit/6b978daf777a615d7758b63c3df57d5a376f6dfb))
174
+ * expose default rest and socket path creation ([e6c6e26](https://github.com/twinfoundation/engine/commit/e6c6e266c8017212a74d4997e2e335347457a2bc))
175
+ * improve startup error handling ([#65](https://github.com/twinfoundation/engine/issues/65)) ([5b2d1c5](https://github.com/twinfoundation/engine/commit/5b2d1c539cf5484afa85e294d6d6c18f24ef8274))
176
+ * interlock stop method ([3806ba7](https://github.com/twinfoundation/engine/commit/3806ba7b44b3cb3ce130f4e3684a666533674663))
177
+ * iota rebased release ([474d92b](https://github.com/twinfoundation/engine/commit/474d92b352f4ccc431a4f138afee2ee89824664d))
178
+ * modifying the engine to run the new services ([#10](https://github.com/twinfoundation/engine/issues/10)) ([6f7141f](https://github.com/twinfoundation/engine/commit/6f7141fe0a6d05c725066b274bcc18b5490e580b))
179
+ * move environment variable processing to node level ([2223c12](https://github.com/twinfoundation/engine/commit/2223c12f49f3d34051ecec9687351aa5dd094e54))
180
+ * multi instance component support ([#83](https://github.com/twinfoundation/engine/issues/83)) ([6012b50](https://github.com/twinfoundation/engine/commit/6012b50959df5af893f05516d42eea2e0800b31a))
181
+ * override type initialisers with new registrations ([5b4ff56](https://github.com/twinfoundation/engine/commit/5b4ff561d06b6513c870a72bb20ba23c0653cfe8))
182
+ * remove additional identity auth components ([409b2e6](https://github.com/twinfoundation/engine/commit/409b2e6a5a543d0795b01916349b39922afb6d88))
183
+ * remove authentication generator components ([#67](https://github.com/twinfoundation/engine/issues/67)) ([62f7984](https://github.com/twinfoundation/engine/commit/62f798468f567fdbf648401aa0dc51cda871c913))
184
+ * remove dap and darp ([d568c4f](https://github.com/twinfoundation/engine/commit/d568c4fc58a3159378e1d65f93228ae84f34a31d))
185
+ * simplify config building ([732c871](https://github.com/twinfoundation/engine/commit/732c871c5aca236759168f4bc15aeffd98a330a8))
186
+ * standardised engine logging naming ([0dbf857](https://github.com/twinfoundation/engine/commit/0dbf857587641f86ddf010143519d0e8333489ff))
187
+ * update dependencies ([034adac](https://github.com/twinfoundation/engine/commit/034adac97b177d8df9775da92f0cc0dbdfc8ab55))
188
+ * update dependencies ([97c9f64](https://github.com/twinfoundation/engine/commit/97c9f64b6ef096963bcc5de338a2a9e99bdc1a11))
189
+ * update framework core ([acc0f8d](https://github.com/twinfoundation/engine/commit/acc0f8d455a4b8ec47f1da643139fa0f07775fa6))
190
+ * update includeUserIdentity usage ([d34f597](https://github.com/twinfoundation/engine/commit/d34f597a61f9645a029411d2911bbda20ddc9eb9))
191
+ * update rights management and add authentication generators ([f728a1e](https://github.com/twinfoundation/engine/commit/f728a1efea15ada8d10cfbe17cafe7e2b252f527))
192
+ * update rights management components ([#74](https://github.com/twinfoundation/engine/issues/74)) ([be94ba8](https://github.com/twinfoundation/engine/commit/be94ba837999c586266a7c73228689566ec9876b))
193
+ * update rights management dependencies ([14d06fb](https://github.com/twinfoundation/engine/commit/14d06fb6604ad04e4094da7b51b61a01a0280b8b))
194
+ * upgrade framework components ([efd52e8](https://github.com/twinfoundation/engine/commit/efd52e80564fff29c3897bfa09b6305b3a322812))
195
+ * use peer dependencies ([69dd744](https://github.com/twinfoundation/engine/commit/69dd7449010b8e6f5f35e7fad201ad4c1cab400c))
196
+ * use shared store mechanism ([#2](https://github.com/twinfoundation/engine/issues/2)) ([9eed8d7](https://github.com/twinfoundation/engine/commit/9eed8d7766388479b42f03e2542fe761f2156408))
197
+
198
+
199
+ ### Bug Fixes
200
+
201
+ * import path ([8e3c186](https://github.com/twinfoundation/engine/commit/8e3c186bd26c84b2a45290efd8e7924c2b75a484))
202
+ * method docs ([fb3d73f](https://github.com/twinfoundation/engine/commit/fb3d73fa9e71ab392378fe7bad7a3677e5e7b132))
203
+ * use abbreviated docs path ([9258a72](https://github.com/twinfoundation/engine/commit/9258a72adf266ddcc4f98002a07a7a162755f24b))
204
+
205
+
206
+ ### Dependencies
207
+
208
+ * The following workspace dependencies were updated
209
+ * dependencies
210
+ * @twin.org/engine-core bumped from 0.0.3-next.22 to 0.0.3-next.23
211
+ * @twin.org/engine-models bumped from 0.0.3-next.22 to 0.0.3-next.23
212
+ * @twin.org/engine-server-types bumped from 0.0.3-next.22 to 0.0.3-next.23
213
+ * devDependencies
214
+ * @twin.org/engine bumped from 0.0.3-next.22 to 0.0.3-next.23
215
+
216
+ ## [0.0.3-next.22](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.21...engine-server-v0.0.3-next.22) (2026-02-23)
217
+
218
+
219
+ ### Miscellaneous Chores
220
+
221
+ * **engine-server:** Synchronize repo versions
222
+
223
+
224
+ ### Dependencies
225
+
226
+ * The following workspace dependencies were updated
227
+ * dependencies
228
+ * @twin.org/engine-core bumped from 0.0.3-next.21 to 0.0.3-next.22
229
+ * @twin.org/engine-models bumped from 0.0.3-next.21 to 0.0.3-next.22
230
+ * @twin.org/engine-server-types bumped from 0.0.3-next.21 to 0.0.3-next.22
231
+ * devDependencies
232
+ * @twin.org/engine bumped from 0.0.3-next.21 to 0.0.3-next.22
233
+
234
+ ## [0.0.3-next.21](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.20...engine-server-v0.0.3-next.21) (2026-02-13)
235
+
236
+
237
+ ### Features
238
+
239
+ * multi instance component support ([#83](https://github.com/twinfoundation/engine/issues/83)) ([6012b50](https://github.com/twinfoundation/engine/commit/6012b50959df5af893f05516d42eea2e0800b31a))
240
+
241
+
242
+ ### Dependencies
243
+
244
+ * The following workspace dependencies were updated
245
+ * dependencies
246
+ * @twin.org/engine-core bumped from 0.0.3-next.20 to 0.0.3-next.21
247
+ * @twin.org/engine-models bumped from 0.0.3-next.20 to 0.0.3-next.21
248
+ * @twin.org/engine-server-types bumped from 0.0.3-next.20 to 0.0.3-next.21
249
+ * devDependencies
250
+ * @twin.org/engine bumped from 0.0.3-next.20 to 0.0.3-next.21
251
+
252
+ ## [0.0.3-next.20](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.19...engine-server-v0.0.3-next.20) (2026-02-06)
253
+
254
+
255
+ ### Features
256
+
257
+ * add authentication admin routes ([c912019](https://github.com/twinfoundation/engine/commit/c9120198cd5c86e20bab588f2a9f20415baf56ca))
258
+
259
+
260
+ ### Dependencies
261
+
262
+ * The following workspace dependencies were updated
263
+ * dependencies
264
+ * @twin.org/engine-core bumped from 0.0.3-next.19 to 0.0.3-next.20
265
+ * @twin.org/engine-models bumped from 0.0.3-next.19 to 0.0.3-next.20
266
+ * @twin.org/engine-server-types bumped from 0.0.3-next.19 to 0.0.3-next.20
267
+ * devDependencies
268
+ * @twin.org/engine bumped from 0.0.3-next.19 to 0.0.3-next.20
269
+
270
+ ## [0.0.3-next.19](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.18...engine-server-v0.0.3-next.19) (2026-02-05)
271
+
272
+
273
+ ### Miscellaneous Chores
274
+
275
+ * **engine-server:** Synchronize repo versions
276
+
277
+
278
+ ### Dependencies
279
+
280
+ * The following workspace dependencies were updated
281
+ * dependencies
282
+ * @twin.org/engine-core bumped from 0.0.3-next.18 to 0.0.3-next.19
283
+ * @twin.org/engine-models bumped from 0.0.3-next.18 to 0.0.3-next.19
284
+ * @twin.org/engine-server-types bumped from 0.0.3-next.18 to 0.0.3-next.19
285
+ * devDependencies
286
+ * @twin.org/engine bumped from 0.0.3-next.18 to 0.0.3-next.19
287
+
288
+ ## [0.0.3-next.18](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.17...engine-server-v0.0.3-next.18) (2026-02-04)
289
+
290
+
291
+ ### Features
292
+
293
+ * add tenant admin routes ([#76](https://github.com/twinfoundation/engine/issues/76)) ([3c0af90](https://github.com/twinfoundation/engine/commit/3c0af90a572fcda08d8720bdcee9b9f1cd02b872))
294
+
295
+
296
+ ### Dependencies
297
+
298
+ * The following workspace dependencies were updated
299
+ * dependencies
300
+ * @twin.org/engine-core bumped from 0.0.3-next.17 to 0.0.3-next.18
301
+ * @twin.org/engine-models bumped from 0.0.3-next.17 to 0.0.3-next.18
302
+ * @twin.org/engine-server-types bumped from 0.0.3-next.17 to 0.0.3-next.18
303
+ * devDependencies
304
+ * @twin.org/engine bumped from 0.0.3-next.17 to 0.0.3-next.18
305
+
306
+ ## [0.0.3-next.17](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.16...engine-server-v0.0.3-next.17) (2026-02-02)
307
+
308
+
309
+ ### Features
310
+
311
+ * update rights management components ([#74](https://github.com/twinfoundation/engine/issues/74)) ([be94ba8](https://github.com/twinfoundation/engine/commit/be94ba837999c586266a7c73228689566ec9876b))
312
+
313
+
314
+ ### Dependencies
315
+
316
+ * The following workspace dependencies were updated
317
+ * dependencies
318
+ * @twin.org/engine-core bumped from 0.0.3-next.16 to 0.0.3-next.17
319
+ * @twin.org/engine-models bumped from 0.0.3-next.16 to 0.0.3-next.17
320
+ * @twin.org/engine-server-types bumped from 0.0.3-next.16 to 0.0.3-next.17
321
+ * devDependencies
322
+ * @twin.org/engine bumped from 0.0.3-next.16 to 0.0.3-next.17
323
+
324
+ ## [0.0.3-next.16](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.15...engine-server-v0.0.3-next.16) (2026-01-28)
325
+
326
+
327
+ ### Features
328
+
329
+ * remove dap and darp ([d568c4f](https://github.com/twinfoundation/engine/commit/d568c4fc58a3159378e1d65f93228ae84f34a31d))
330
+
331
+
332
+ ### Dependencies
333
+
334
+ * The following workspace dependencies were updated
335
+ * dependencies
336
+ * @twin.org/engine-core bumped from 0.0.3-next.15 to 0.0.3-next.16
337
+ * @twin.org/engine-models bumped from 0.0.3-next.15 to 0.0.3-next.16
338
+ * @twin.org/engine-server-types bumped from 0.0.3-next.15 to 0.0.3-next.16
339
+ * devDependencies
340
+ * @twin.org/engine bumped from 0.0.3-next.15 to 0.0.3-next.16
341
+
342
+ ## [0.0.3-next.15](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.14...engine-server-v0.0.3-next.15) (2026-01-26)
343
+
344
+
345
+ ### Features
346
+
347
+ * add hosting component ([#70](https://github.com/twinfoundation/engine/issues/70)) ([2ab0dec](https://github.com/twinfoundation/engine/commit/2ab0dec8fdb979395c639b73f394a40a0dd7e55a))
348
+
349
+
350
+ ### Dependencies
351
+
352
+ * The following workspace dependencies were updated
353
+ * dependencies
354
+ * @twin.org/engine-core bumped from 0.0.3-next.14 to 0.0.3-next.15
355
+ * @twin.org/engine-models bumped from 0.0.3-next.14 to 0.0.3-next.15
356
+ * @twin.org/engine-server-types bumped from 0.0.3-next.14 to 0.0.3-next.15
357
+ * devDependencies
358
+ * @twin.org/engine bumped from 0.0.3-next.14 to 0.0.3-next.15
359
+
360
+ ## [0.0.3-next.14](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.13...engine-server-v0.0.3-next.14) (2026-01-19)
361
+
362
+
363
+ ### Features
364
+
365
+ * add auth admin component ([201cd06](https://github.com/twinfoundation/engine/commit/201cd061be83afccb5a6b06856ffe7cf8db7d6b3))
366
+ * add context id features ([#51](https://github.com/twinfoundation/engine/issues/51)) ([eaef180](https://github.com/twinfoundation/engine/commit/eaef1807397a907bc7655ef1545a151a710ca2f1))
367
+ * add data space connector ([a824d99](https://github.com/twinfoundation/engine/commit/a824d9931faeaa8115e01f8e7545b802d0e7ac70))
368
+ * add default logging component for web server ([8ad94f0](https://github.com/twinfoundation/engine/commit/8ad94f0d2d9a5241a8854b1e59fb9a55ce310142))
369
+ * add fed cat filters ([a52cbf1](https://github.com/twinfoundation/engine/commit/a52cbf1eaf85e6cad61de9ea9448932fb5ae0f43))
370
+ * add federated catalogue ([1b15dd0](https://github.com/twinfoundation/engine/commit/1b15dd059a11446457651c411a73145fab37f025))
371
+ * add isPrimary and isClone methods ([a7c63e9](https://github.com/twinfoundation/engine/commit/a7c63e97f54c95b104cc81e66d3fa42c6607bdc1))
372
+ * add latest rights management components ([2d305c8](https://github.com/twinfoundation/engine/commit/2d305c8c85c77bb4f5694c76422db4a11efc1a40))
373
+ * add mimeTypeProcessors and disableNodeIdentity ([bb7e81e](https://github.com/twinfoundation/engine/commit/bb7e81e2036fe042068a5645ec59b22e20d33aad))
374
+ * add rest clients as components ([c6f956a](https://github.com/twinfoundation/engine/commit/c6f956afe4fc22cd552174539c92a109448dc242))
375
+ * add REST options for route construction ([4adf0af](https://github.com/twinfoundation/engine/commit/4adf0af8a03689a4dbdf67e8527d6db0d2c5d59d))
376
+ * add rights management modules ([e02cadc](https://github.com/twinfoundation/engine/commit/e02cadc840d242fe16a73ab41ba61376c7467e50))
377
+ * add rights management negotiation ([84ef46b](https://github.com/twinfoundation/engine/commit/84ef46bff110611a19512793425c8c873ee2a590))
378
+ * add synchronised storage support ([5142e34](https://github.com/twinfoundation/engine/commit/5142e3488f09195cf9f48a9c6c6d1014231a4c2c))
379
+ * add task scheduler ([0951107](https://github.com/twinfoundation/engine/commit/09511073ad042194a45206303f0ef31d8d6af5db))
380
+ * add trust and rights management plugins ([eea0807](https://github.com/twinfoundation/engine/commit/eea0807601833220bd9fd8605b5e4383fbc0ebae))
381
+ * add validate-locales ([b92ea09](https://github.com/twinfoundation/engine/commit/b92ea09dbcfe35225271a51f24d231f59e2d363e))
382
+ * eslint migration to flat config ([6b978da](https://github.com/twinfoundation/engine/commit/6b978daf777a615d7758b63c3df57d5a376f6dfb))
383
+ * expose default rest and socket path creation ([e6c6e26](https://github.com/twinfoundation/engine/commit/e6c6e266c8017212a74d4997e2e335347457a2bc))
384
+ * improve startup error handling ([#65](https://github.com/twinfoundation/engine/issues/65)) ([5b2d1c5](https://github.com/twinfoundation/engine/commit/5b2d1c539cf5484afa85e294d6d6c18f24ef8274))
385
+ * interlock stop method ([3806ba7](https://github.com/twinfoundation/engine/commit/3806ba7b44b3cb3ce130f4e3684a666533674663))
386
+ * iota rebased release ([474d92b](https://github.com/twinfoundation/engine/commit/474d92b352f4ccc431a4f138afee2ee89824664d))
387
+ * modifying the engine to run the new services ([#10](https://github.com/twinfoundation/engine/issues/10)) ([6f7141f](https://github.com/twinfoundation/engine/commit/6f7141fe0a6d05c725066b274bcc18b5490e580b))
388
+ * move environment variable processing to node level ([2223c12](https://github.com/twinfoundation/engine/commit/2223c12f49f3d34051ecec9687351aa5dd094e54))
389
+ * override type initialisers with new registrations ([5b4ff56](https://github.com/twinfoundation/engine/commit/5b4ff561d06b6513c870a72bb20ba23c0653cfe8))
390
+ * remove additional identity auth components ([409b2e6](https://github.com/twinfoundation/engine/commit/409b2e6a5a543d0795b01916349b39922afb6d88))
391
+ * remove authentication generator components ([#67](https://github.com/twinfoundation/engine/issues/67)) ([62f7984](https://github.com/twinfoundation/engine/commit/62f798468f567fdbf648401aa0dc51cda871c913))
392
+ * simplify config building ([732c871](https://github.com/twinfoundation/engine/commit/732c871c5aca236759168f4bc15aeffd98a330a8))
393
+ * standardised engine logging naming ([0dbf857](https://github.com/twinfoundation/engine/commit/0dbf857587641f86ddf010143519d0e8333489ff))
394
+ * update dependencies ([034adac](https://github.com/twinfoundation/engine/commit/034adac97b177d8df9775da92f0cc0dbdfc8ab55))
395
+ * update dependencies ([97c9f64](https://github.com/twinfoundation/engine/commit/97c9f64b6ef096963bcc5de338a2a9e99bdc1a11))
396
+ * update framework core ([acc0f8d](https://github.com/twinfoundation/engine/commit/acc0f8d455a4b8ec47f1da643139fa0f07775fa6))
397
+ * update includeUserIdentity usage ([d34f597](https://github.com/twinfoundation/engine/commit/d34f597a61f9645a029411d2911bbda20ddc9eb9))
398
+ * update rights management and add authentication generators ([f728a1e](https://github.com/twinfoundation/engine/commit/f728a1efea15ada8d10cfbe17cafe7e2b252f527))
399
+ * update rights management dependencies ([14d06fb](https://github.com/twinfoundation/engine/commit/14d06fb6604ad04e4094da7b51b61a01a0280b8b))
400
+ * upgrade framework components ([efd52e8](https://github.com/twinfoundation/engine/commit/efd52e80564fff29c3897bfa09b6305b3a322812))
401
+ * use peer dependencies ([69dd744](https://github.com/twinfoundation/engine/commit/69dd7449010b8e6f5f35e7fad201ad4c1cab400c))
402
+ * use shared store mechanism ([#2](https://github.com/twinfoundation/engine/issues/2)) ([9eed8d7](https://github.com/twinfoundation/engine/commit/9eed8d7766388479b42f03e2542fe761f2156408))
403
+
404
+
405
+ ### Bug Fixes
406
+
407
+ * import path ([8e3c186](https://github.com/twinfoundation/engine/commit/8e3c186bd26c84b2a45290efd8e7924c2b75a484))
408
+ * method docs ([fb3d73f](https://github.com/twinfoundation/engine/commit/fb3d73fa9e71ab392378fe7bad7a3677e5e7b132))
409
+ * use abbreviated docs path ([9258a72](https://github.com/twinfoundation/engine/commit/9258a72adf266ddcc4f98002a07a7a162755f24b))
410
+
411
+
412
+ ### Dependencies
413
+
414
+ * The following workspace dependencies were updated
415
+ * dependencies
416
+ * @twin.org/engine-core bumped from 0.0.3-next.13 to 0.0.3-next.14
417
+ * @twin.org/engine-models bumped from 0.0.3-next.13 to 0.0.3-next.14
418
+ * @twin.org/engine-server-types bumped from 0.0.3-next.13 to 0.0.3-next.14
419
+ * devDependencies
420
+ * @twin.org/engine bumped from 0.0.3-next.13 to 0.0.3-next.14
421
+
422
+ ## [0.0.3-next.13](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.12...engine-server-v0.0.3-next.13) (2026-01-19)
423
+
424
+
425
+ ### Features
426
+
427
+ * remove authentication generator components ([#67](https://github.com/twinfoundation/engine/issues/67)) ([62f7984](https://github.com/twinfoundation/engine/commit/62f798468f567fdbf648401aa0dc51cda871c913))
428
+
429
+
430
+ ### Dependencies
431
+
432
+ * The following workspace dependencies were updated
433
+ * dependencies
434
+ * @twin.org/engine-core bumped from 0.0.3-next.12 to 0.0.3-next.13
435
+ * @twin.org/engine-models bumped from 0.0.3-next.12 to 0.0.3-next.13
436
+ * @twin.org/engine-server-types bumped from 0.0.3-next.12 to 0.0.3-next.13
437
+ * devDependencies
438
+ * @twin.org/engine bumped from 0.0.3-next.12 to 0.0.3-next.13
439
+
440
+ ## [0.0.3-next.12](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.11...engine-server-v0.0.3-next.12) (2026-01-19)
441
+
442
+
443
+ ### Features
444
+
445
+ * improve startup error handling ([#65](https://github.com/twinfoundation/engine/issues/65)) ([5b2d1c5](https://github.com/twinfoundation/engine/commit/5b2d1c539cf5484afa85e294d6d6c18f24ef8274))
446
+
447
+
448
+ ### Dependencies
449
+
450
+ * The following workspace dependencies were updated
451
+ * dependencies
452
+ * @twin.org/engine-core bumped from 0.0.3-next.11 to 0.0.3-next.12
453
+ * @twin.org/engine-models bumped from 0.0.3-next.11 to 0.0.3-next.12
454
+ * @twin.org/engine-server-types bumped from 0.0.3-next.11 to 0.0.3-next.12
455
+ * devDependencies
456
+ * @twin.org/engine bumped from 0.0.3-next.11 to 0.0.3-next.12
457
+
458
+ ## [0.0.3-next.11](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.10...engine-server-v0.0.3-next.11) (2026-01-16)
459
+
460
+
461
+ ### Miscellaneous Chores
462
+
463
+ * **engine-server:** Synchronize repo versions
464
+
465
+
466
+ ### Dependencies
467
+
468
+ * The following workspace dependencies were updated
469
+ * dependencies
470
+ * @twin.org/engine-core bumped from 0.0.3-next.10 to 0.0.3-next.11
471
+ * @twin.org/engine-models bumped from 0.0.3-next.10 to 0.0.3-next.11
472
+ * @twin.org/engine-server-types bumped from 0.0.3-next.10 to 0.0.3-next.11
473
+ * devDependencies
474
+ * @twin.org/engine bumped from 0.0.3-next.10 to 0.0.3-next.11
475
+
476
+ ## [0.0.3-next.10](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.9...engine-server-v0.0.3-next.10) (2026-01-13)
477
+
478
+
479
+ ### Miscellaneous Chores
480
+
481
+ * **engine-server:** Synchronize repo versions
482
+
483
+
484
+ ### Dependencies
485
+
486
+ * The following workspace dependencies were updated
487
+ * dependencies
488
+ * @twin.org/engine-core bumped from 0.0.3-next.9 to 0.0.3-next.10
489
+ * @twin.org/engine-models bumped from 0.0.3-next.9 to 0.0.3-next.10
490
+ * @twin.org/engine-server-types bumped from 0.0.3-next.9 to 0.0.3-next.10
491
+ * devDependencies
492
+ * @twin.org/engine bumped from 0.0.3-next.9 to 0.0.3-next.10
493
+
494
+ ## [0.0.3-next.9](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.8...engine-server-v0.0.3-next.9) (2026-01-07)
495
+
496
+
497
+ ### Miscellaneous Chores
498
+
499
+ * **engine-server:** Synchronize repo versions
500
+
501
+
502
+ ### Dependencies
503
+
504
+ * The following workspace dependencies were updated
505
+ * dependencies
506
+ * @twin.org/engine-core bumped from 0.0.3-next.8 to 0.0.3-next.9
507
+ * @twin.org/engine-models bumped from 0.0.3-next.8 to 0.0.3-next.9
508
+ * @twin.org/engine-server-types bumped from 0.0.3-next.8 to 0.0.3-next.9
509
+ * devDependencies
510
+ * @twin.org/engine bumped from 0.0.3-next.8 to 0.0.3-next.9
511
+
512
+ ## [0.0.3-next.8](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.7...engine-server-v0.0.3-next.8) (2026-01-06)
513
+
514
+
515
+ ### Features
516
+
517
+ * update dependencies ([034adac](https://github.com/twinfoundation/engine/commit/034adac97b177d8df9775da92f0cc0dbdfc8ab55))
518
+
519
+
520
+ ### Dependencies
521
+
522
+ * The following workspace dependencies were updated
523
+ * dependencies
524
+ * @twin.org/engine-core bumped from 0.0.3-next.7 to 0.0.3-next.8
525
+ * @twin.org/engine-models bumped from 0.0.3-next.7 to 0.0.3-next.8
526
+ * @twin.org/engine-server-types bumped from 0.0.3-next.7 to 0.0.3-next.8
527
+ * devDependencies
528
+ * @twin.org/engine bumped from 0.0.3-next.7 to 0.0.3-next.8
529
+
530
+ ## [0.0.3-next.7](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.6...engine-server-v0.0.3-next.7) (2025-12-04)
531
+
532
+
533
+ ### Features
534
+
535
+ * add trust and rights management plugins ([eea0807](https://github.com/twinfoundation/engine/commit/eea0807601833220bd9fd8605b5e4383fbc0ebae))
536
+
537
+
538
+ ### Dependencies
539
+
540
+ * The following workspace dependencies were updated
541
+ * dependencies
542
+ * @twin.org/engine-core bumped from 0.0.3-next.6 to 0.0.3-next.7
543
+ * @twin.org/engine-models bumped from 0.0.3-next.6 to 0.0.3-next.7
544
+ * @twin.org/engine-server-types bumped from 0.0.3-next.6 to 0.0.3-next.7
545
+ * devDependencies
546
+ * @twin.org/engine bumped from 0.0.3-next.6 to 0.0.3-next.7
547
+
548
+ ## [0.0.3-next.6](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.5...engine-server-v0.0.3-next.6) (2025-11-28)
549
+
550
+
551
+ ### Features
552
+
553
+ * add fed cat filters ([a52cbf1](https://github.com/twinfoundation/engine/commit/a52cbf1eaf85e6cad61de9ea9448932fb5ae0f43))
554
+
555
+
556
+ ### Dependencies
557
+
558
+ * The following workspace dependencies were updated
559
+ * dependencies
560
+ * @twin.org/engine-core bumped from 0.0.3-next.5 to 0.0.3-next.6
561
+ * @twin.org/engine-models bumped from 0.0.3-next.5 to 0.0.3-next.6
562
+ * @twin.org/engine-server-types bumped from 0.0.3-next.5 to 0.0.3-next.6
563
+ * devDependencies
564
+ * @twin.org/engine bumped from 0.0.3-next.5 to 0.0.3-next.6
565
+
566
+ ## [0.0.3-next.5](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.4...engine-server-v0.0.3-next.5) (2025-11-20)
567
+
568
+
569
+ ### Miscellaneous Chores
570
+
571
+ * **engine-server:** Synchronize repo versions
572
+
573
+
574
+ ### Dependencies
575
+
576
+ * The following workspace dependencies were updated
577
+ * dependencies
578
+ * @twin.org/engine-core bumped from 0.0.3-next.4 to 0.0.3-next.5
579
+ * @twin.org/engine-models bumped from 0.0.3-next.4 to 0.0.3-next.5
580
+ * @twin.org/engine-server-types bumped from 0.0.3-next.4 to 0.0.3-next.5
581
+ * devDependencies
582
+ * @twin.org/engine bumped from 0.0.3-next.4 to 0.0.3-next.5
583
+
584
+ ## [0.0.3-next.4](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.3...engine-server-v0.0.3-next.4) (2025-11-20)
585
+
586
+
587
+ ### Features
588
+
589
+ * interlock stop method ([3806ba7](https://github.com/twinfoundation/engine/commit/3806ba7b44b3cb3ce130f4e3684a666533674663))
590
+
591
+
592
+ ### Dependencies
593
+
594
+ * The following workspace dependencies were updated
595
+ * dependencies
596
+ * @twin.org/engine-core bumped from 0.0.3-next.3 to 0.0.3-next.4
597
+ * @twin.org/engine-models bumped from 0.0.3-next.3 to 0.0.3-next.4
598
+ * @twin.org/engine-server-types bumped from 0.0.3-next.3 to 0.0.3-next.4
599
+ * devDependencies
600
+ * @twin.org/engine bumped from 0.0.3-next.3 to 0.0.3-next.4
2
601
 
3
602
  ## [0.0.3-next.3](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.2...engine-server-v0.0.3-next.3) (2025-11-14)
4
603
 
package/docs/examples.md CHANGED
@@ -1 +1,79 @@
1
- # @twin.org/engine-server - Examples
1
+ # Engine Server Examples
2
+
3
+ These examples show how to wire a core instance into an HTTP server and apply default REST and socket paths.
4
+
5
+ ## EngineServer
6
+
7
+ ```typescript
8
+ import { Engine } from '@twin.org/engine';
9
+ import { EngineServer } from '@twin.org/engine-server';
10
+ import type { IEngineServerConfig } from '@twin.org/engine-server-types';
11
+ import {
12
+ HostingComponentType,
13
+ InformationComponentType,
14
+ RestRouteProcessorType,
15
+ SocketRouteProcessorType
16
+ } from '@twin.org/engine-server-types';
17
+
18
+ const config: IEngineServerConfig = {
19
+ debug: false,
20
+ silent: true,
21
+ web: { port: 3001 },
22
+ types: {
23
+ hostingComponent: [{ type: HostingComponentType.Service }],
24
+ informationComponent: [{ type: InformationComponentType.Service, restPath: '/info' }],
25
+ restRouteProcessor: [{ type: RestRouteProcessorType.RestRoute }],
26
+ socketRouteProcessor: [{ type: SocketRouteProcessorType.SocketRoute }]
27
+ }
28
+ };
29
+
30
+ const engine = new Engine({ config, skipBootstrap: true });
31
+ const server = new EngineServer({ engineCore: engine });
32
+
33
+ server.addRestRouteGenerator(
34
+ 'informationComponent',
35
+ '@twin.org/engine-server-types',
36
+ 'generateInformationRestRoutes'
37
+ );
38
+ server.addSocketRouteGenerator(
39
+ 'informationComponent',
40
+ '@twin.org/engine-server-types',
41
+ 'generateInformationSocketRoutes'
42
+ );
43
+
44
+ console.log(server.getRestRoutes().length); // 0
45
+ console.log(server.getSocketRoutes().length); // 0
46
+
47
+ await server.start();
48
+ console.log(server.getRestRoutes().length > 0); // true
49
+
50
+ await server.stop();
51
+ ```
52
+
53
+ ## addDefaultRestPaths and addDefaultSocketPaths
54
+
55
+ ```typescript
56
+ import { addDefaultRestPaths, addDefaultSocketPaths } from '@twin.org/engine-server';
57
+ import type { IEngineServerConfig } from '@twin.org/engine-server-types';
58
+ import {
59
+ InformationComponentType,
60
+ RestRouteProcessorType,
61
+ SocketRouteProcessorType
62
+ } from '@twin.org/engine-server-types';
63
+
64
+ const serverConfig: IEngineServerConfig = {
65
+ debug: false,
66
+ silent: false,
67
+ types: {
68
+ informationComponent: [{ type: InformationComponentType.Service }],
69
+ restRouteProcessor: [{ type: RestRouteProcessorType.RestRoute }],
70
+ socketRouteProcessor: [{ type: SocketRouteProcessorType.SocketRoute }]
71
+ }
72
+ };
73
+
74
+ addDefaultRestPaths(serverConfig);
75
+ addDefaultSocketPaths(serverConfig);
76
+
77
+ console.log(typeof serverConfig.types.informationComponent?.[0].restPath === 'string'); // true
78
+ console.log(typeof serverConfig.types.informationComponent?.[0].socketPath === 'string'); // true
79
+ ```
@@ -38,7 +38,7 @@ The engine core to serve from.
38
38
 
39
39
  ## Properties
40
40
 
41
- ### CLASS\_NAME
41
+ ### CLASS\_NAME {#class_name}
42
42
 
43
43
  > `readonly` `static` **CLASS\_NAME**: `string`
44
44
 
@@ -46,7 +46,7 @@ Runtime name for the class.
46
46
 
47
47
  ## Methods
48
48
 
49
- ### addRestRouteGenerator()
49
+ ### addRestRouteGenerator() {#addrestroutegenerator}
50
50
 
51
51
  > **addRestRouteGenerator**(`type`, `module`, `method`): `void`
52
52
 
@@ -82,7 +82,7 @@ The method to call on the module.
82
82
 
83
83
  ***
84
84
 
85
- ### addSocketRouteGenerator()
85
+ ### addSocketRouteGenerator() {#addsocketroutegenerator}
86
86
 
87
87
  > **addSocketRouteGenerator**(`type`, `module`, `method`): `void`
88
88
 
@@ -118,7 +118,7 @@ The method to call on the module.
118
118
 
119
119
  ***
120
120
 
121
- ### getRestRoutes()
121
+ ### getRestRoutes() {#getrestroutes}
122
122
 
123
123
  > **getRestRoutes**(): `IRestRoute`\<`any`, `any`\>[]
124
124
 
@@ -132,7 +132,7 @@ The REST routes.
132
132
 
133
133
  ***
134
134
 
135
- ### getSocketRoutes()
135
+ ### getSocketRoutes() {#getsocketroutes}
136
136
 
137
137
  > **getSocketRoutes**(): `ISocketRoute`\<`any`, `any`\>[]
138
138
 
@@ -146,17 +146,17 @@ The socket routes.
146
146
 
147
147
  ***
148
148
 
149
- ### start()
149
+ ### start() {#start}
150
150
 
151
- > **start**(): `Promise`\<`boolean`\>
151
+ > **start**(): `Promise`\<`void`\>
152
152
 
153
153
  Start the engine server.
154
154
 
155
155
  #### Returns
156
156
 
157
- `Promise`\<`boolean`\>
157
+ `Promise`\<`void`\>
158
158
 
159
- True if the start was successful.
159
+ Nothing.
160
160
 
161
161
  #### Implementation of
162
162
 
@@ -164,7 +164,7 @@ True if the start was successful.
164
164
 
165
165
  ***
166
166
 
167
- ### stop()
167
+ ### stop() {#stop}
168
168
 
169
169
  > **stop**(): `Promise`\<`void`\>
170
170
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@twin.org/engine-server",
3
- "version": "0.0.3-next.3",
4
- "description": "Engine implementation for a server.",
3
+ "version": "0.0.3-next.31",
4
+ "description": "Server runtime that exposes engine components through REST and socket routes.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/twinfoundation/engine.git",
@@ -18,9 +18,9 @@
18
18
  "@twin.org/api-server-fastify": "next",
19
19
  "@twin.org/context": "next",
20
20
  "@twin.org/core": "next",
21
- "@twin.org/engine-core": "0.0.3-next.3",
22
- "@twin.org/engine-models": "0.0.3-next.3",
23
- "@twin.org/engine-server-types": "0.0.3-next.3",
21
+ "@twin.org/engine-core": "0.0.3-next.31",
22
+ "@twin.org/engine-models": "0.0.3-next.31",
23
+ "@twin.org/engine-server-types": "0.0.3-next.31",
24
24
  "@twin.org/modules": "next",
25
25
  "@twin.org/nameof": "next"
26
26
  },