@twin.org/engine-server 0.0.1-next.2 → 0.0.1-next.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,45 +1,42 @@
1
- import { type IEngineCore, type IEngineCoreTypeConfig, type IEngineServer, type IEngineServerConfig, type RestRouteGenerator, type SocketRouteGenerator } from "@twin.org/engine-models";
1
+ import type { IEngineCore, IEngineCoreTypeConfig, IEngineServer } from "@twin.org/engine-models";
2
+ import { type IEngineServerConfig } from "@twin.org/engine-server-types";
2
3
  /**
3
4
  * Server for the engine.
4
5
  */
5
- export declare class EngineServer implements IEngineServer {
6
+ export declare class EngineServer<T extends IEngineServerConfig = IEngineServerConfig> implements IEngineServer {
6
7
  /**
7
8
  * Runtime name for the class.
8
9
  */
9
10
  readonly CLASS_NAME: string;
10
- /**
11
- * The server config.
12
- */
13
- protected readonly _config: IEngineServerConfig;
14
11
  /**
15
12
  * Create a new instance of EngineServer.
16
13
  * @param options The options for the engine.
17
- * @param options.server The server options for the engine.
18
14
  * @param options.engineCore The engine core to serve from.
19
15
  */
20
16
  constructor(options: {
21
- engineCore: IEngineCore;
22
- server?: IEngineServerConfig;
17
+ engineCore: IEngineCore<T>;
23
18
  });
24
19
  /**
25
20
  * Add a REST route generator.
26
21
  * @param type The type to add the generator for.
27
22
  * @param typeConfig The type config.
28
- * @param generator The generator to add.
23
+ * @param module The module containing the generator.
24
+ * @param method The method to call on the module.
29
25
  */
30
- addRestRouteGenerator(type: string, typeConfig: IEngineCoreTypeConfig[] | undefined, generator: RestRouteGenerator): void;
26
+ addRestRouteGenerator(type: string, typeConfig: IEngineCoreTypeConfig[] | undefined, module: string, method: string): void;
31
27
  /**
32
28
  * Add a socket route generator.
33
29
  * @param type The type to add the generator for.
34
30
  * @param typeConfig The type config.
35
- * @param generator The generator to add.
31
+ * @param module The module containing the generator.
32
+ * @param method The method to call on the module.
36
33
  */
37
- addSocketRouteGenerator(type: string, typeConfig: IEngineCoreTypeConfig[] | undefined, generator: SocketRouteGenerator): void;
34
+ addSocketRouteGenerator(type: string, typeConfig: IEngineCoreTypeConfig[] | undefined, module: string, method: string): void;
38
35
  /**
39
36
  * Start the engine server.
40
- * @returns Nothing.
37
+ * @returns True if the start was successful.
41
38
  */
42
- start(): Promise<void>;
39
+ start(): Promise<boolean>;
43
40
  /**
44
41
  * Stop the engine server.
45
42
  * @returns Nothing.
@@ -1 +1,3 @@
1
1
  export * from "./engineServer";
2
+ export * from "./models/IEngineServerEnvironmentVariables";
3
+ export * from "./utils/engineServerEnvBuilder";
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The engine server environment variables.
3
+ */
4
+ export interface IEngineServerEnvironmentVariables {
5
+ /**
6
+ * The port to serve the API from.
7
+ */
8
+ port?: string;
9
+ /**
10
+ * The host to serve the API from.
11
+ */
12
+ host?: string;
13
+ /**
14
+ * The CORS origins to allow, defaults to *.
15
+ */
16
+ corsOrigins?: string;
17
+ /**
18
+ * The CORS methods to allow, defaults to GET, POST, PUT, DELETE, OPTIONS.
19
+ */
20
+ httpMethods?: string;
21
+ /**
22
+ * The CORS headers to allow.
23
+ */
24
+ httpAllowedHeaders?: string;
25
+ /**
26
+ * The CORS headers to expose.
27
+ */
28
+ httpExposedHeaders?: string;
29
+ /**
30
+ * The type of auth processor to use on the API: entity-storage.
31
+ */
32
+ authProcessorType?: string;
33
+ /**
34
+ * The id of the key in the vault to use for signing in auth operations.
35
+ */
36
+ authSigningKeyId?: string;
37
+ }
@@ -0,0 +1,12 @@
1
+ import type { IServerInfo } from "@twin.org/api-models";
2
+ import type { IEngineCoreConfig } from "@twin.org/engine-models";
3
+ import { type IEngineServerConfig } from "@twin.org/engine-server-types";
4
+ import type { IEngineServerEnvironmentVariables } from "../models/IEngineServerEnvironmentVariables";
5
+ /**
6
+ * Handles the configuration of the server.
7
+ * @param envVars The environment variables.
8
+ * @param coreEngineConfig The core engine config.
9
+ * @param serverInfo The server information.
10
+ * @returns The the config for the core and the server.
11
+ */
12
+ export declare function buildEngineServerConfiguration(envVars: IEngineServerEnvironmentVariables, coreEngineConfig: IEngineCoreConfig, serverInfo: IServerInfo): IEngineServerConfig;
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/engine-server - Changelog
2
2
 
3
- ## v0.0.1-next.2
3
+ ## v0.0.1-next.20
4
4
 
5
5
  - Initial Release
@@ -1,7 +1,11 @@
1
- # Class: EngineServer
1
+ # Class: EngineServer\<T\>
2
2
 
3
3
  Server for the engine.
4
4
 
5
+ ## Type Parameters
6
+
7
+ • **T** *extends* `IEngineServerConfig` = `IEngineServerConfig`
8
+
5
9
  ## Implements
6
10
 
7
11
  - `IEngineServer`
@@ -10,7 +14,7 @@ Server for the engine.
10
14
 
11
15
  ### new EngineServer()
12
16
 
13
- > **new EngineServer**(`options`): [`EngineServer`](EngineServer.md)
17
+ > **new EngineServer**\<`T`\>(`options`): [`EngineServer`](EngineServer.md)\<`T`\>
14
18
 
15
19
  Create a new instance of EngineServer.
16
20
 
@@ -20,17 +24,13 @@ Create a new instance of EngineServer.
20
24
 
21
25
  The options for the engine.
22
26
 
23
- • **options.engineCore**: `IEngineCore`\<`IEngineState`\>
27
+ • **options.engineCore**: `IEngineCore`\<`T`, `IEngineState`\>
24
28
 
25
29
  The engine core to serve from.
26
30
 
27
- • **options.server?**: `IEngineServerConfig`
28
-
29
- The server options for the engine.
30
-
31
31
  #### Returns
32
32
 
33
- [`EngineServer`](EngineServer.md)
33
+ [`EngineServer`](EngineServer.md)\<`T`\>
34
34
 
35
35
  ## Properties
36
36
 
@@ -40,19 +40,11 @@ The server options for the engine.
40
40
 
41
41
  Runtime name for the class.
42
42
 
43
- ***
44
-
45
- ### \_config
46
-
47
- > `protected` `readonly` **\_config**: `IEngineServerConfig`
48
-
49
- The server config.
50
-
51
43
  ## Methods
52
44
 
53
45
  ### addRestRouteGenerator()
54
46
 
55
- > **addRestRouteGenerator**(`type`, `typeConfig`, `generator`): `void`
47
+ > **addRestRouteGenerator**(`type`, `typeConfig`, `module`, `method`): `void`
56
48
 
57
49
  Add a REST route generator.
58
50
 
@@ -66,9 +58,13 @@ The type to add the generator for.
66
58
 
67
59
  The type config.
68
60
 
69
- • **generator**: `RestRouteGenerator`
61
+ • **module**: `string`
62
+
63
+ The module containing the generator.
70
64
 
71
- The generator to add.
65
+ **method**: `string`
66
+
67
+ The method to call on the module.
72
68
 
73
69
  #### Returns
74
70
 
@@ -82,7 +78,7 @@ The generator to add.
82
78
 
83
79
  ### addSocketRouteGenerator()
84
80
 
85
- > **addSocketRouteGenerator**(`type`, `typeConfig`, `generator`): `void`
81
+ > **addSocketRouteGenerator**(`type`, `typeConfig`, `module`, `method`): `void`
86
82
 
87
83
  Add a socket route generator.
88
84
 
@@ -96,9 +92,13 @@ The type to add the generator for.
96
92
 
97
93
  The type config.
98
94
 
99
- • **generator**: `SocketRouteGenerator`
95
+ • **module**: `string`
96
+
97
+ The module containing the generator.
100
98
 
101
- The generator to add.
99
+ **method**: `string`
100
+
101
+ The method to call on the module.
102
102
 
103
103
  #### Returns
104
104
 
@@ -112,15 +112,15 @@ The generator to add.
112
112
 
113
113
  ### start()
114
114
 
115
- > **start**(): `Promise`\<`void`\>
115
+ > **start**(): `Promise`\<`boolean`\>
116
116
 
117
117
  Start the engine server.
118
118
 
119
119
  #### Returns
120
120
 
121
- `Promise`\<`void`\>
121
+ `Promise`\<`boolean`\>
122
122
 
123
- Nothing.
123
+ True if the start was successful.
124
124
 
125
125
  #### Implementation of
126
126
 
@@ -0,0 +1,25 @@
1
+ # Function: buildEngineServerConfiguration()
2
+
3
+ > **buildEngineServerConfiguration**(`envVars`, `coreEngineConfig`, `serverInfo`): `IEngineServerConfig`
4
+
5
+ Handles the configuration of the server.
6
+
7
+ ## Parameters
8
+
9
+ • **envVars**: [`IEngineServerEnvironmentVariables`](../interfaces/IEngineServerEnvironmentVariables.md)
10
+
11
+ The environment variables.
12
+
13
+ • **coreEngineConfig**: `IEngineCoreConfig`
14
+
15
+ The core engine config.
16
+
17
+ • **serverInfo**: `IServerInfo`
18
+
19
+ The server information.
20
+
21
+ ## Returns
22
+
23
+ `IEngineServerConfig`
24
+
25
+ The the config for the core and the server.
@@ -3,3 +3,11 @@
3
3
  ## Classes
4
4
 
5
5
  - [EngineServer](classes/EngineServer.md)
6
+
7
+ ## Interfaces
8
+
9
+ - [IEngineServerEnvironmentVariables](interfaces/IEngineServerEnvironmentVariables.md)
10
+
11
+ ## Functions
12
+
13
+ - [buildEngineServerConfiguration](functions/buildEngineServerConfiguration.md)
@@ -0,0 +1,67 @@
1
+ # Interface: IEngineServerEnvironmentVariables
2
+
3
+ The engine server environment variables.
4
+
5
+ ## Properties
6
+
7
+ ### port?
8
+
9
+ > `optional` **port**: `string`
10
+
11
+ The port to serve the API from.
12
+
13
+ ***
14
+
15
+ ### host?
16
+
17
+ > `optional` **host**: `string`
18
+
19
+ The host to serve the API from.
20
+
21
+ ***
22
+
23
+ ### corsOrigins?
24
+
25
+ > `optional` **corsOrigins**: `string`
26
+
27
+ The CORS origins to allow, defaults to *.
28
+
29
+ ***
30
+
31
+ ### httpMethods?
32
+
33
+ > `optional` **httpMethods**: `string`
34
+
35
+ The CORS methods to allow, defaults to GET, POST, PUT, DELETE, OPTIONS.
36
+
37
+ ***
38
+
39
+ ### httpAllowedHeaders?
40
+
41
+ > `optional` **httpAllowedHeaders**: `string`
42
+
43
+ The CORS headers to allow.
44
+
45
+ ***
46
+
47
+ ### httpExposedHeaders?
48
+
49
+ > `optional` **httpExposedHeaders**: `string`
50
+
51
+ The CORS headers to expose.
52
+
53
+ ***
54
+
55
+ ### authProcessorType?
56
+
57
+ > `optional` **authProcessorType**: `string`
58
+
59
+ The type of auth processor to use on the API: entity-storage.
60
+
61
+ ***
62
+
63
+ ### authSigningKeyId?
64
+
65
+ > `optional` **authSigningKeyId**: `string`
66
+
67
+ The id of the key in the vault to use for signing in auth operations.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/engine-server",
3
- "version": "0.0.1-next.2",
3
+ "version": "0.0.1-next.20",
4
4
  "description": "Engine implementation for a server.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,74 +14,14 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/api-auth-entity-storage-service": "next",
18
- "@twin.org/api-core": "next",
19
17
  "@twin.org/api-models": "next",
20
- "@twin.org/api-processors": "next",
21
18
  "@twin.org/api-server-fastify": "next",
22
- "@twin.org/api-service": "next",
23
- "@twin.org/attestation-connector-entity-storage": "next",
24
- "@twin.org/attestation-connector-iota": "next",
25
- "@twin.org/attestation-models": "next",
26
- "@twin.org/attestation-service": "next",
27
- "@twin.org/auditable-item-graph-models": "next",
28
- "@twin.org/auditable-item-graph-service": "next",
29
- "@twin.org/auditable-item-stream-models": "next",
30
- "@twin.org/auditable-item-stream-service": "next",
31
- "@twin.org/background-task-connector-entity-storage": "next",
32
- "@twin.org/background-task-models": "next",
33
- "@twin.org/blob-storage-connector-aws-s3": "next",
34
- "@twin.org/blob-storage-connector-azure": "next",
35
- "@twin.org/blob-storage-connector-file": "next",
36
- "@twin.org/blob-storage-connector-gcp": "next",
37
- "@twin.org/blob-storage-connector-ipfs": "next",
38
- "@twin.org/blob-storage-connector-memory": "next",
39
- "@twin.org/blob-storage-models": "next",
40
- "@twin.org/blob-storage-service": "next",
41
- "@twin.org/cli-core": "next",
42
19
  "@twin.org/core": "next",
43
- "@twin.org/crypto": "next",
44
- "@twin.org/data-core": "next",
45
- "@twin.org/data-schema-org": "next",
46
- "@twin.org/engine-core": "0.0.1-next.2",
47
- "@twin.org/engine-models": "0.0.1-next.2",
48
- "@twin.org/entity": "next",
49
- "@twin.org/entity-storage-connector-cosmosdb": "next",
50
- "@twin.org/entity-storage-connector-dynamodb": "next",
51
- "@twin.org/entity-storage-connector-file": "next",
52
- "@twin.org/entity-storage-connector-gcp-firestore": "next",
53
- "@twin.org/entity-storage-connector-memory": "next",
54
- "@twin.org/entity-storage-connector-scylladb": "next",
55
- "@twin.org/entity-storage-models": "next",
56
- "@twin.org/entity-storage-service": "next",
57
- "@twin.org/identity-connector-entity-storage": "next",
58
- "@twin.org/identity-connector-iota": "next",
59
- "@twin.org/identity-models": "next",
60
- "@twin.org/identity-service": "next",
61
- "@twin.org/immutable-proof-models": "next",
62
- "@twin.org/immutable-proof-service": "next",
63
- "@twin.org/immutable-storage-connector-entity-storage": "next",
64
- "@twin.org/immutable-storage-connector-iota": "next",
65
- "@twin.org/immutable-storage-models": "next",
66
- "@twin.org/logging-connector-console": "next",
67
- "@twin.org/logging-connector-entity-storage": "next",
68
- "@twin.org/logging-models": "next",
69
- "@twin.org/logging-service": "next",
70
- "@twin.org/nameof": "next",
71
- "@twin.org/nft-connector-entity-storage": "next",
72
- "@twin.org/nft-connector-iota": "next",
73
- "@twin.org/nft-models": "next",
74
- "@twin.org/nft-service": "next",
75
- "@twin.org/telemetry-connector-entity-storage": "next",
76
- "@twin.org/telemetry-models": "next",
77
- "@twin.org/telemetry-service": "next",
78
- "@twin.org/vault-connector-entity-storage": "next",
79
- "@twin.org/vault-connector-hashicorp": "next",
80
- "@twin.org/vault-models": "next",
81
- "@twin.org/wallet-connector-entity-storage": "next",
82
- "@twin.org/wallet-connector-iota": "next",
83
- "@twin.org/wallet-models": "next",
84
- "@twin.org/web": "next"
20
+ "@twin.org/engine-core": "0.0.1-next.20",
21
+ "@twin.org/engine-models": "0.0.1-next.20",
22
+ "@twin.org/engine-server-types": "0.0.1-next.20",
23
+ "@twin.org/modules": "next",
24
+ "@twin.org/nameof": "next"
85
25
  },
86
26
  "main": "./dist/cjs/index.cjs",
87
27
  "module": "./dist/esm/index.mjs",
@@ -1,11 +0,0 @@
1
- import { type IEngineCoreContext, type AuthenticationComponentConfig, type IEngineCore } from "@twin.org/engine-models";
2
- /**
3
- * Initialise the authentication.
4
- * @param engineCore The engine core.
5
- * @param context The context for the engine.
6
- * @param instanceConfig The instance config.
7
- * @param overrideInstanceType The instance type to override the default.
8
- * @returns The name of the instance created.
9
- * @throws GeneralError if the component type is unknown.
10
- */
11
- export declare function initialiseAuthenticationComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: AuthenticationComponentConfig, overrideInstanceType?: string): string | undefined;
@@ -1,11 +0,0 @@
1
- import { type IEngineCore, type IEngineCoreContext, type InformationComponentConfig } from "@twin.org/engine-models";
2
- /**
3
- * Initialise the information component.
4
- * @param engineCore The engine core.
5
- * @param context The context for the engine.
6
- * @param instanceConfig The instance config.
7
- * @param overrideInstanceType The instance type to override the default.
8
- * @returns The name of the instance created.
9
- * @throws GeneralError if the component type is unknown.
10
- */
11
- export declare function initialiseInformationComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: InformationComponentConfig, overrideInstanceType?: string): string | undefined;
@@ -1,11 +0,0 @@
1
- import { type IEngineCore, type IEngineCoreContext, type MimeTypeProcessorConfig } from "@twin.org/engine-models";
2
- /**
3
- * Initialise the mime type processor.
4
- * @param engineCore The engine core.
5
- * @param context The context for the engine.
6
- * @param instanceConfig The instance config.
7
- * @param overrideInstanceType The instance type to override the default.
8
- * @returns The name of the instance created.
9
- * @throws GeneralError if the component type is unknown.
10
- */
11
- export declare function initialiseMimeTypeProcessorComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: MimeTypeProcessorConfig, overrideInstanceType?: string): string | undefined;
@@ -1,11 +0,0 @@
1
- import { type IEngineCoreContext, type IEngineCore, type RestRouteProcessorConfig } from "@twin.org/engine-models";
2
- /**
3
- * Initialise the rest route processor.
4
- * @param engineCore The engine core.
5
- * @param context The context for the engine.
6
- * @param instanceConfig The instance config.
7
- * @param overrideInstanceType The instance type to override the default.
8
- * @returns The name of the instance created.
9
- * @throws GeneralError if the component type is unknown.
10
- */
11
- export declare function initialiseRestRouteProcessorComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: RestRouteProcessorConfig, overrideInstanceType?: string): string | undefined;
@@ -1,11 +0,0 @@
1
- import { type IEngineCoreContext, type IEngineCore, type SocketRouteProcessorConfig } from "@twin.org/engine-models";
2
- /**
3
- * Initialise the socket route processor.
4
- * @param engineCore The engine core.
5
- * @param context The context for the engine.
6
- * @param instanceConfig The instance config.
7
- * @param overrideInstanceType The instance type to override the default.
8
- * @returns The name of the instance created.
9
- * @throws GeneralError if the component type is unknown.
10
- */
11
- export declare function initialiseSocketRouteProcessorComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: SocketRouteProcessorConfig, overrideInstanceType?: string): string | undefined;