@twin.org/engine-server 0.0.1-next.4 → 0.0.1-next.41

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,13 @@
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
+ * @param openApiSpecPath The path to the open api spec.
11
+ * @returns The the config for the core and the server.
12
+ */
13
+ export declare function buildEngineServerConfiguration(envVars: IEngineServerEnvironmentVariables, coreEngineConfig: IEngineCoreConfig, serverInfo: IServerInfo, openApiSpecPath?: string): IEngineServerConfig;
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/engine-server - Changelog
2
2
 
3
- ## v0.0.1-next.4
3
+ ## v0.0.1-next.37
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,27 +14,25 @@ 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
 
17
21
  #### Parameters
18
22
 
19
- **options**
23
+ ##### options
20
24
 
21
25
  The options for the engine.
22
26
 
23
- **options.engineCore**: `IEngineCore`\<`IEngineState`\>
24
-
25
- The engine core to serve from.
27
+ ###### engineCore
26
28
 
27
- • **options.server?**: `IEngineServerConfig`
29
+ `IEngineCore`\<`T`\>
28
30
 
29
- The server options for the engine.
31
+ The engine core to serve from.
30
32
 
31
33
  #### Returns
32
34
 
33
- [`EngineServer`](EngineServer.md)
35
+ [`EngineServer`](EngineServer.md)\<`T`\>
34
36
 
35
37
  ## Properties
36
38
 
@@ -40,35 +42,39 @@ The server options for the engine.
40
42
 
41
43
  Runtime name for the class.
42
44
 
43
- ***
44
-
45
- ### \_config
46
-
47
- > `protected` `readonly` **\_config**: `IEngineServerConfig`
48
-
49
- The server config.
50
-
51
45
  ## Methods
52
46
 
53
47
  ### addRestRouteGenerator()
54
48
 
55
- > **addRestRouteGenerator**(`type`, `typeConfig`, `generator`): `void`
49
+ > **addRestRouteGenerator**(`type`, `typeConfig`, `module`, `method`): `void`
56
50
 
57
51
  Add a REST route generator.
58
52
 
59
53
  #### Parameters
60
54
 
61
- **type**: `string`
55
+ ##### type
56
+
57
+ `string`
62
58
 
63
59
  The type to add the generator for.
64
60
 
65
- **typeConfig**: `undefined` \| `IEngineCoreTypeConfig`[]
61
+ ##### typeConfig
66
62
 
67
63
  The type config.
68
64
 
69
- **generator**: `RestRouteGenerator`
65
+ `undefined` | `IEngineCoreTypeConfig`[]
66
+
67
+ ##### module
70
68
 
71
- The generator to add.
69
+ `string`
70
+
71
+ The module containing the generator.
72
+
73
+ ##### method
74
+
75
+ `string`
76
+
77
+ The method to call on the module.
72
78
 
73
79
  #### Returns
74
80
 
@@ -82,23 +88,35 @@ The generator to add.
82
88
 
83
89
  ### addSocketRouteGenerator()
84
90
 
85
- > **addSocketRouteGenerator**(`type`, `typeConfig`, `generator`): `void`
91
+ > **addSocketRouteGenerator**(`type`, `typeConfig`, `module`, `method`): `void`
86
92
 
87
93
  Add a socket route generator.
88
94
 
89
95
  #### Parameters
90
96
 
91
- **type**: `string`
97
+ ##### type
98
+
99
+ `string`
92
100
 
93
101
  The type to add the generator for.
94
102
 
95
- **typeConfig**: `undefined` \| `IEngineCoreTypeConfig`[]
103
+ ##### typeConfig
96
104
 
97
105
  The type config.
98
106
 
99
- **generator**: `SocketRouteGenerator`
107
+ `undefined` | `IEngineCoreTypeConfig`[]
108
+
109
+ ##### module
100
110
 
101
- The generator to add.
111
+ `string`
112
+
113
+ The module containing the generator.
114
+
115
+ ##### method
116
+
117
+ `string`
118
+
119
+ The method to call on the module.
102
120
 
103
121
  #### Returns
104
122
 
@@ -112,15 +130,15 @@ The generator to add.
112
130
 
113
131
  ### start()
114
132
 
115
- > **start**(): `Promise`\<`void`\>
133
+ > **start**(): `Promise`\<`boolean`\>
116
134
 
117
135
  Start the engine server.
118
136
 
119
137
  #### Returns
120
138
 
121
- `Promise`\<`void`\>
139
+ `Promise`\<`boolean`\>
122
140
 
123
- Nothing.
141
+ True if the start was successful.
124
142
 
125
143
  #### Implementation of
126
144
 
@@ -0,0 +1,37 @@
1
+ # Function: buildEngineServerConfiguration()
2
+
3
+ > **buildEngineServerConfiguration**(`envVars`, `coreEngineConfig`, `serverInfo`, `openApiSpecPath`?): `IEngineServerConfig`
4
+
5
+ Handles the configuration of the server.
6
+
7
+ ## Parameters
8
+
9
+ ### envVars
10
+
11
+ [`IEngineServerEnvironmentVariables`](../interfaces/IEngineServerEnvironmentVariables.md)
12
+
13
+ The environment variables.
14
+
15
+ ### coreEngineConfig
16
+
17
+ `IEngineCoreConfig`
18
+
19
+ The core engine config.
20
+
21
+ ### serverInfo
22
+
23
+ `IServerInfo`
24
+
25
+ The server information.
26
+
27
+ ### openApiSpecPath?
28
+
29
+ `string`
30
+
31
+ The path to the open api spec.
32
+
33
+ ## Returns
34
+
35
+ `IEngineServerConfig`
36
+
37
+ 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.4",
3
+ "version": "0.0.1-next.41",
4
4
  "description": "Engine implementation for a server.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,83 +14,23 @@
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.4",
47
- "@twin.org/engine-models": "0.0.1-next.4",
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.41",
21
+ "@twin.org/engine-models": "0.0.1-next.41",
22
+ "@twin.org/engine-server-types": "0.0.1-next.41",
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",
88
28
  "types": "./dist/types/index.d.ts",
89
29
  "exports": {
90
30
  ".": {
31
+ "types": "./dist/types/index.d.ts",
91
32
  "require": "./dist/cjs/index.cjs",
92
- "import": "./dist/esm/index.mjs",
93
- "types": "./dist/types/index.d.ts"
33
+ "import": "./dist/esm/index.mjs"
94
34
  },
95
35
  "./locales/*.json": "./locales/*.json"
96
36
  },
@@ -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;