@twin.org/node-core 0.0.1-next.10

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.
Files changed (43) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +21 -0
  3. package/dist/cjs/index.cjs +1718 -0
  4. package/dist/esm/index.mjs +1681 -0
  5. package/dist/types/bootstrap.d.ts +59 -0
  6. package/dist/types/builders/engineEnvBuilder.d.ts +8 -0
  7. package/dist/types/builders/engineServerEnvBuilder.d.ts +13 -0
  8. package/dist/types/index.d.ts +10 -0
  9. package/dist/types/models/IEngineEnvironmentVariables.d.ts +389 -0
  10. package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +45 -0
  11. package/dist/types/models/INodeEnvironmentVariables.d.ts +29 -0
  12. package/dist/types/models/INodeOptions.d.ts +69 -0
  13. package/dist/types/models/nodeFeatures.d.ts +17 -0
  14. package/dist/types/node.d.ts +26 -0
  15. package/dist/types/server.d.ts +17 -0
  16. package/dist/types/utils.d.ts +30 -0
  17. package/docs/changelog.md +76 -0
  18. package/docs/examples.md +1 -0
  19. package/docs/reference/functions/bootstrap.md +29 -0
  20. package/docs/reference/functions/bootstrapAttestationMethod.md +35 -0
  21. package/docs/reference/functions/bootstrapAuth.md +35 -0
  22. package/docs/reference/functions/bootstrapBlobEncryption.md +35 -0
  23. package/docs/reference/functions/bootstrapImmutableProofMethod.md +35 -0
  24. package/docs/reference/functions/bootstrapNodeIdentity.md +35 -0
  25. package/docs/reference/functions/bootstrapNodeUser.md +35 -0
  26. package/docs/reference/functions/buildConfiguration.md +30 -0
  27. package/docs/reference/functions/buildEngineConfiguration.md +19 -0
  28. package/docs/reference/functions/fileExists.md +19 -0
  29. package/docs/reference/functions/getExecutionDirectory.md +11 -0
  30. package/docs/reference/functions/getFeatures.md +19 -0
  31. package/docs/reference/functions/initialiseLocales.md +17 -0
  32. package/docs/reference/functions/loadJsonFile.md +25 -0
  33. package/docs/reference/functions/run.md +19 -0
  34. package/docs/reference/functions/start.md +31 -0
  35. package/docs/reference/index.md +35 -0
  36. package/docs/reference/interfaces/IEngineEnvironmentVariables.md +775 -0
  37. package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +87 -0
  38. package/docs/reference/interfaces/INodeEnvironmentVariables.md +1331 -0
  39. package/docs/reference/interfaces/INodeOptions.md +165 -0
  40. package/docs/reference/type-aliases/NodeFeatures.md +5 -0
  41. package/docs/reference/variables/NodeFeatures.md +19 -0
  42. package/locales/en.json +34 -0
  43. package/package.json +52 -0
@@ -0,0 +1,59 @@
1
+ import type { IEngineCore, IEngineCoreContext, IEngineState } from "@twin.org/engine-models";
2
+ import type { IEngineServerConfig } from "@twin.org/engine-server-types";
3
+ import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables";
4
+ import { NodeFeatures } from "./models/nodeFeatures";
5
+ /**
6
+ * Bootstrap the application.
7
+ * @param engineCore The engine core for the node.
8
+ * @param context The context for the node.
9
+ * @param envVars The environment variables for the node.
10
+ */
11
+ export declare function bootstrap(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, IEngineState>, envVars: INodeEnvironmentVariables): Promise<void>;
12
+ /**
13
+ * Bootstrap the node creating any necessary resources.
14
+ * @param engineCore The engine core for the node.
15
+ * @param context The context for the node.
16
+ * @param envVars The environment variables for the node.
17
+ * @param features The features that are enabled on the node. The features that are enabled on the node.
18
+ */
19
+ export declare function bootstrapNodeIdentity(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, IEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
20
+ /**
21
+ * Bootstrap the user.
22
+ * @param engineCore The engine core for the node.
23
+ * @param context The context for the node.
24
+ * @param envVars The environment variables for the node.
25
+ * @param features The features that are enabled on the node.
26
+ */
27
+ export declare function bootstrapNodeUser(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, IEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
28
+ /**
29
+ * Bootstrap the attestation verification methods.
30
+ * @param engineCore The engine core for the node.
31
+ * @param context The context for the node.
32
+ * @param envVars The environment variables for the node.
33
+ * @param features The features that are enabled on the node.
34
+ */
35
+ export declare function bootstrapAttestationMethod(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, IEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
36
+ /**
37
+ * Bootstrap the immutable proof verification methods.
38
+ * @param engineCore The engine core for the node.
39
+ * @param context The context for the node.
40
+ * @param envVars The environment variables for the node.
41
+ * @param features The features that are enabled on the node.
42
+ */
43
+ export declare function bootstrapImmutableProofMethod(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, IEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
44
+ /**
45
+ * Bootstrap the keys for blob encryption.
46
+ * @param engineCore The engine core for the node.
47
+ * @param context The context for the node.
48
+ * @param envVars The environment variables for the node.
49
+ * @param features The features that are enabled on the node.
50
+ */
51
+ export declare function bootstrapBlobEncryption(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, IEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
52
+ /**
53
+ * Bootstrap the JWT signing key.
54
+ * @param engineCore The engine core for the node.
55
+ * @param context The context for the node.
56
+ * @param envVars The environment variables for the node.
57
+ * @param features The features that are enabled on the node.
58
+ */
59
+ export declare function bootstrapAuth(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, IEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
@@ -0,0 +1,8 @@
1
+ import { type IEngineConfig } from "@twin.org/engine-types";
2
+ import type { IEngineEnvironmentVariables } from "../models/IEngineEnvironmentVariables";
3
+ /**
4
+ * Build the engine core configuration from environment variables.
5
+ * @param envVars The environment variables.
6
+ * @returns The config for the core.
7
+ */
8
+ export declare function buildEngineConfiguration(envVars: IEngineEnvironmentVariables): IEngineConfig;
@@ -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 for the engine server.
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;
@@ -0,0 +1,10 @@
1
+ export * from "./bootstrap";
2
+ export * from "./builders/engineEnvBuilder";
3
+ export * from "./models/IEngineEnvironmentVariables";
4
+ export * from "./models/IEngineServerEnvironmentVariables";
5
+ export * from "./models/INodeEnvironmentVariables";
6
+ export * from "./models/INodeOptions";
7
+ export * from "./models/nodeFeatures";
8
+ export * from "./node";
9
+ export * from "./server";
10
+ export * from "./utils";
@@ -0,0 +1,389 @@
1
+ /**
2
+ * The engine core environment variables.
3
+ */
4
+ export interface IEngineEnvironmentVariables {
5
+ /**
6
+ * Start the engine in debug mode.
7
+ */
8
+ debug?: string;
9
+ /**
10
+ * The root directory for storing items like state file.
11
+ */
12
+ storageFileRoot?: string;
13
+ /**
14
+ * The name of the state file.
15
+ */
16
+ stateFilename?: string;
17
+ /**
18
+ * The type of the default entity storage: file, memory, aws-dynamodb, azure-cosmosdb, gcp-firestoredb, scylladb, mysql, mongodb, postgresql.
19
+ */
20
+ entityStorageConnectorType?: string;
21
+ /**
22
+ * A prefix for all the table in entity-storage, can be empty.
23
+ */
24
+ entityStorageTablePrefix?: string;
25
+ /**
26
+ * Enable the file entity storage connector.
27
+ */
28
+ entityFileEnable?: string;
29
+ /**
30
+ * Enable the memory entity storage connector.
31
+ */
32
+ entityMemoryEnable?: string;
33
+ /**
34
+ * AWS Dynamo DB access key id.
35
+ */
36
+ awsDynamodbAccessKeyId?: string;
37
+ /**
38
+ * AWS Dynamo DB Endpoint if running local instance.
39
+ */
40
+ awsDynamodbEndpoint?: string;
41
+ /**
42
+ * AWS Dynamo DB region.
43
+ */
44
+ awsDynamodbRegion?: string;
45
+ /**
46
+ * AWS Dynamo DB secret access key.
47
+ */
48
+ awsDynamodbSecretAccessKey?: string;
49
+ /**
50
+ * Azure Cosmos DB key.
51
+ */
52
+ azureCosmosdbKey?: string;
53
+ /**
54
+ * Azure Cosmos DB container id.
55
+ */
56
+ azureCosmosdbContainerId?: string;
57
+ /**
58
+ * Azure Cosmos DB database id.
59
+ */
60
+ azureCosmosdbDatabaseId?: string;
61
+ /**
62
+ * Azure Cosmos DB endpoint.
63
+ */
64
+ azureCosmosdbEndpoint?: string;
65
+ /**
66
+ * GCP Firestore collection name.
67
+ */
68
+ gcpFirestoreCollectionName?: string;
69
+ /**
70
+ * GCP Firestore credentials.
71
+ */
72
+ gcpFirestoreCredentials?: string;
73
+ /**
74
+ * GCP Firestore database id.
75
+ */
76
+ gcpFirestoreDatabaseId?: string;
77
+ /**
78
+ * GCP Firestore endpoint.
79
+ */
80
+ gcpFirestoreApiEndpoint?: string;
81
+ /**
82
+ * GCP Firestore project id.
83
+ */
84
+ gcpFirestoreProjectId?: string;
85
+ /**
86
+ * ScyllaDB hosts as comma separated string.
87
+ */
88
+ scylladbHosts?: string;
89
+ /**
90
+ * ScyllaDB keyspace.
91
+ */
92
+ scylladbKeyspace?: string;
93
+ /**
94
+ * ScyllaDB local data center.
95
+ */
96
+ scylladbLocalDataCenter?: string;
97
+ /**
98
+ * MySQL host.
99
+ */
100
+ mySqlHost?: string;
101
+ /**
102
+ * MySQL port.
103
+ */
104
+ mySqlPort?: number;
105
+ /**
106
+ * MySQL username.
107
+ */
108
+ mySqlUser?: string;
109
+ /**
110
+ * MySQL password.
111
+ */
112
+ mySqlPassword?: string;
113
+ /**
114
+ * MySQL Database.
115
+ */
116
+ mySqlDatabase?: string;
117
+ /**
118
+ * MongoDB host.
119
+ */
120
+ mongoDbHost?: string;
121
+ /**
122
+ * MongoDB port.
123
+ */
124
+ mongoDbPort?: number;
125
+ /**
126
+ * MongoDB username.
127
+ */
128
+ mongoDbUser?: string;
129
+ /**
130
+ * MongoDB password.
131
+ */
132
+ mongoDbPassword?: string;
133
+ /**
134
+ * MongoDB Database.
135
+ */
136
+ mongoDbDatabase?: string;
137
+ /**
138
+ * PostgreSQl host.
139
+ */
140
+ postgreSqlHost?: string;
141
+ /**
142
+ * PostgreSQl port.
143
+ */
144
+ postgreSqlPort?: number;
145
+ /**
146
+ * PostgreSQl username.
147
+ */
148
+ postgreSqlUser?: string;
149
+ /**
150
+ * PostgreSQl password.
151
+ */
152
+ postgreSqlPassword?: string;
153
+ /**
154
+ * PostgreSQl Database.
155
+ */
156
+ postgreSqlDatabase?: string;
157
+ /**
158
+ * The security token for accessing IPFS API.
159
+ */
160
+ ipfsBearerToken?: string;
161
+ /**
162
+ * The url for accessing IPFS API.
163
+ */
164
+ ipfsApiUrl?: string;
165
+ /**
166
+ * The type of the default blob storage: memory, file, ipfs, aws-s3, azure-storage, gcp-storage.
167
+ */
168
+ blobStorageConnectorType?: string;
169
+ /**
170
+ * Enable encryption for the blob storage.
171
+ */
172
+ blobStorageEnableEncryption?: string;
173
+ /**
174
+ * The encryption key for the blob storage.
175
+ */
176
+ blobStorageEncryptionKey?: string;
177
+ /**
178
+ * A prefix for all the blobs in blob-storage, can be empty.
179
+ */
180
+ blobStoragePrefix?: string;
181
+ /**
182
+ * Enable the file blob storage connector.
183
+ */
184
+ blobFileEnable?: string;
185
+ /**
186
+ * Enable the memory blob storage connector.
187
+ */
188
+ blobMemoryEnable?: string;
189
+ /**
190
+ * AWS S3 access key id.
191
+ */
192
+ awsS3AccessKeyId?: string;
193
+ /**
194
+ * AWS S3 bucket name.
195
+ */
196
+ awsS3BucketName?: string;
197
+ /**
198
+ * AWS S3 endpoint.
199
+ */
200
+ awsS3Endpoint?: string;
201
+ /**
202
+ * AWS S3 region.
203
+ */
204
+ awsS3Region?: string;
205
+ /**
206
+ * AWS S3 secret access key.
207
+ */
208
+ awsS3SecretAccessKey?: string;
209
+ /**
210
+ * Azure Storage account key.
211
+ */
212
+ azureStorageAccountKey?: string;
213
+ /**
214
+ * Azure Storage account name.
215
+ */
216
+ azureStorageAccountName?: string;
217
+ /**
218
+ * Azure Storage container.
219
+ */
220
+ azureStorageContainerName?: string;
221
+ /**
222
+ * Azure Storage endpoint.
223
+ */
224
+ azureStorageEndpoint?: string;
225
+ /**
226
+ * GCP Storage bucket.
227
+ */
228
+ gcpStorageBucketName?: string;
229
+ /**
230
+ * GCP Storage credentials.
231
+ */
232
+ gcpStorageCredentials?: string;
233
+ /**
234
+ * GCP Storage endpoint.
235
+ */
236
+ gcpStorageEndpoint?: string;
237
+ /**
238
+ * GCP Storage project id.
239
+ */
240
+ gcpStorageProjectId?: string;
241
+ /**
242
+ * The type of the default vault connector: entity-storage, hashicorp.
243
+ */
244
+ vaultConnector?: string;
245
+ /**
246
+ * Hashicorp Vault token.
247
+ */
248
+ hashicorpVaultToken?: string;
249
+ /**
250
+ * Hashicorp Vault endpoint.
251
+ */
252
+ hashicorpVaultEndpoint?: string;
253
+ /**
254
+ * The type of background task connector, can be a comma separated list: console, entity-storage.
255
+ */
256
+ loggingConnector?: string;
257
+ /**
258
+ * The type of background task connector: entity-storage.
259
+ */
260
+ backgroundTaskConnector?: string;
261
+ /**
262
+ * The type of event bus connector: local.
263
+ */
264
+ eventBusConnector?: string;
265
+ /**
266
+ * The type of event bus component: service.
267
+ */
268
+ eventBusComponent?: string;
269
+ /**
270
+ * The type of messaging email connector: entity-storage, aws.
271
+ */
272
+ messagingEmailConnector?: string;
273
+ /**
274
+ * The type of messaging sms connector: entity-storage, aws.
275
+ */
276
+ messagingSmsConnector?: string;
277
+ /**
278
+ * The type of messaging push notification connector: entity-storage, aws.
279
+ */
280
+ messagingPushNotificationConnector?: string;
281
+ /**
282
+ * The applications for the push notifications JSON stringified array of IAwsApplicationSettings.
283
+ */
284
+ awsMessagingPushNotificationApplications?: string;
285
+ /**
286
+ * The type of messaging component: service.
287
+ */
288
+ messagingComponent?: string;
289
+ /**
290
+ * The type of telemetry connector: entity-storage.
291
+ */
292
+ telemetryConnector?: string;
293
+ /**
294
+ * The type of faucet connector: entity-storage, iota.
295
+ */
296
+ faucetConnector?: string;
297
+ /**
298
+ * The type of wallet connector: entity-storage, iota.
299
+ */
300
+ walletConnector?: string;
301
+ /**
302
+ * The type of NFT connector: entity-storage, iota.
303
+ */
304
+ nftConnector?: string;
305
+ /**
306
+ * The type of identity connector: entity-storage, iota.
307
+ */
308
+ identityConnector?: string;
309
+ /**
310
+ * The type of identity resolver connector: entity-storage, iota.
311
+ */
312
+ identityResolverConnector?: string;
313
+ /**
314
+ * The type of verifiable storage connector: entity-storage, iota.
315
+ */
316
+ verifiableStorageConnector?: string;
317
+ /**
318
+ * IOTA Faucet Endpoint.
319
+ */
320
+ iotaFaucetEndpoint?: string;
321
+ /**
322
+ * IOTA Node Endpoint.
323
+ */
324
+ iotaNodeEndpoint?: string;
325
+ /**
326
+ * IOTA network.
327
+ */
328
+ iotaNetwork?: string;
329
+ /**
330
+ * IOTA coin type.
331
+ */
332
+ iotaCoinType?: string;
333
+ /**
334
+ * IOTA Explorer Endpoint.
335
+ */
336
+ iotaExplorerEndpoint?: string;
337
+ /**
338
+ * IOTA Gas Station Endpoint.
339
+ */
340
+ iotaGasStationEndpoint?: string;
341
+ /**
342
+ * IOTA Gas Station Authentication Token.
343
+ */
344
+ iotaGasStationAuthToken?: string;
345
+ /**
346
+ * Universal Resolver Endpoint.
347
+ */
348
+ universalResolverEndpoint?: string;
349
+ /**
350
+ * The type of identity profile connector: entity-storage.
351
+ */
352
+ identityProfileConnector?: string;
353
+ /**
354
+ * The identity verification method id to use with immutable proofs.
355
+ */
356
+ immutableProofVerificationMethodId?: string;
357
+ /**
358
+ * The type of attestation connector: entity-storage, iota.
359
+ */
360
+ attestationConnector?: string;
361
+ /**
362
+ * The identity verification method id to use with attestation.
363
+ */
364
+ attestationVerificationMethodId?: string;
365
+ /**
366
+ * The type of the default data converters, can be a comma separated list: json, xml.
367
+ */
368
+ dataConverterConnectors?: string;
369
+ /**
370
+ * The type of the default data extractor, can be a comma separated list: json-path.
371
+ */
372
+ dataExtractorConnectors?: string;
373
+ /**
374
+ * Federated catalog TTL for the cache.
375
+ */
376
+ federatedCatalogueCacheTtlMs?: number;
377
+ /**
378
+ * Federated catalog clearing house approver list, stringified array of DIDs.
379
+ */
380
+ federatedCatalogueClearingHouseApproverList?: string;
381
+ /**
382
+ * Is the rights management enabled, defaults to false.
383
+ */
384
+ rightsManagementEnabled?: string;
385
+ /**
386
+ * Is the task scheduler enabled, defaults to true.
387
+ */
388
+ taskSchedulerEnabled?: string;
389
+ }
@@ -0,0 +1,45 @@
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
+ /**
38
+ * Additional MIME type processors to include, comma separated.
39
+ */
40
+ mimeTypeProcessors?: string;
41
+ /**
42
+ * Disable Node Identity route processors.
43
+ */
44
+ disableNodeIdentity?: string;
45
+ }
@@ -0,0 +1,29 @@
1
+ import type { IEngineEnvironmentVariables } from "./IEngineEnvironmentVariables";
2
+ import type { IEngineServerEnvironmentVariables } from "./IEngineServerEnvironmentVariables";
3
+ /**
4
+ * The environment variables for the node.
5
+ */
6
+ export interface INodeEnvironmentVariables extends IEngineEnvironmentVariables, IEngineServerEnvironmentVariables {
7
+ /**
8
+ * The features that are enabled on the node.
9
+ * @default [NodeFeatures.NodeIdentity]
10
+ */
11
+ features?: string;
12
+ /**
13
+ * The identity of the node which, if empty and node-identity feature is enabled it will be generated.
14
+ */
15
+ identity?: string;
16
+ /**
17
+ * The mnemonic for the identity, if empty and node-identity feature is enabled it will be randomly generated.
18
+ */
19
+ mnemonic?: string;
20
+ /**
21
+ * If the node-user feature is enabled, this will be the name of the user.
22
+ * @default admin@node
23
+ */
24
+ username?: string;
25
+ /**
26
+ * If the node-user feature is enabled, this will be the password of the user, if empty it will be randomly generated.
27
+ */
28
+ password?: string;
29
+ }
@@ -0,0 +1,69 @@
1
+ import type { IEngineCore, IEngineServer, IEngineStateStorage } from "@twin.org/engine-models";
2
+ import type { IEngineConfig } from "@twin.org/engine-types";
3
+ import type { INodeEnvironmentVariables } from "./INodeEnvironmentVariables";
4
+ /**
5
+ * The options when running the node.
6
+ */
7
+ export interface INodeOptions {
8
+ /**
9
+ * The name of the server, defaults to "TWIN Node Server".
10
+ * @default "TWIN Node Server"
11
+ */
12
+ serverName?: string;
13
+ /**
14
+ * The version of the server, defaults to the current version.
15
+ */
16
+ serverVersion?: string;
17
+ /**
18
+ * Additional environment variable filenames to load, defaults to .env.
19
+ */
20
+ envFilenames?: string[];
21
+ /**
22
+ * The prefix for environment variables, defaults to "TWIN_NODE_".
23
+ */
24
+ envPrefix?: string;
25
+ /**
26
+ * A list of JSON files to load as configuration files.
27
+ * The files will be loaded in the order they are provided, and the last one will
28
+ * override any previous values.
29
+ */
30
+ configFilenames?: string[];
31
+ /**
32
+ * Provides the ability to have some initial custom configuration for the engine.
33
+ * This will be merged with any configuration loaded from the environment variables.
34
+ */
35
+ config?: IEngineConfig;
36
+ /**
37
+ * The directory to override the execution location, defaults to process directory.
38
+ */
39
+ executionDirectory?: string;
40
+ /**
41
+ * The directory to override the locales directory, defaults to the locales directory.
42
+ */
43
+ localesDirectory?: string;
44
+ /**
45
+ * The path to the OpenAPI spec file, defaults to docs/open-api/spec.json.
46
+ */
47
+ openApiSpecFile?: string;
48
+ /**
49
+ * Method to extend the engine environment variables with any additional custom configuration.
50
+ */
51
+ extendEnvVars?: (envVars: INodeEnvironmentVariables) => Promise<void>;
52
+ /**
53
+ * Method to extend the engine configuration with any additional custom configuration.
54
+ */
55
+ extendConfig?: (config: IEngineConfig) => Promise<void>;
56
+ /**
57
+ * Method to extend the engine with any additional options.
58
+ */
59
+ extendEngine?: (engine: IEngineCore) => Promise<void>;
60
+ /**
61
+ * Method to extend the engine server with any additional options.
62
+ */
63
+ extendEngineServer?: (engineServer: IEngineServer) => Promise<void>;
64
+ /**
65
+ * The state storage to use for the engine.
66
+ * If not provided, a default file-based state storage will be used.
67
+ */
68
+ stateStorage?: IEngineStateStorage;
69
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The features that can be enabled on the node.
3
+ */
4
+ export declare const NodeFeatures: {
5
+ /**
6
+ * NodeIdentity - generates an identity for the node if not provided in config.
7
+ */
8
+ readonly NodeIdentity: "node-identity";
9
+ /**
10
+ * NodeUser - generates a user for the node if not provided in config.
11
+ */
12
+ readonly NodeUser: "node-user";
13
+ };
14
+ /**
15
+ * The features that can be enabled on the node.
16
+ */
17
+ export type NodeFeatures = (typeof NodeFeatures)[keyof typeof NodeFeatures];
@@ -0,0 +1,26 @@
1
+ import type { IServerInfo } from "@twin.org/api-models";
2
+ import type { IEngineServerConfig } from "@twin.org/engine-server-types";
3
+ import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables";
4
+ import type { INodeOptions } from "./models/INodeOptions";
5
+ /**
6
+ * Run the TWIN Node server.
7
+ * @param nodeOptions Optional configuration options for running the server.
8
+ * @returns A promise that resolves when the server is started.
9
+ */
10
+ export declare function run(nodeOptions?: INodeOptions): Promise<void>;
11
+ /**
12
+ * Build the configuration for the TWIN Node server.
13
+ * @param processEnv The environment variables from the process.
14
+ * @param options The options for running the server.
15
+ * @param serverInfo The server information.
16
+ * @returns A promise that resolves to the engine server configuration, environment prefix, environment variables,
17
+ * and options.
18
+ */
19
+ export declare function buildConfiguration(processEnv: {
20
+ [id: string]: string;
21
+ }, options: INodeOptions, serverInfo: IServerInfo): Promise<{
22
+ nodeEnvVars: INodeEnvironmentVariables & {
23
+ [id: string]: string | unknown;
24
+ };
25
+ engineServerConfig: IEngineServerConfig;
26
+ }>;
@@ -0,0 +1,17 @@
1
+ import { Engine } from "@twin.org/engine";
2
+ import { type IEngineState } from "@twin.org/engine-models";
3
+ import { EngineServer } from "@twin.org/engine-server";
4
+ import type { IEngineServerConfig } from "@twin.org/engine-server-types";
5
+ import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables";
6
+ import type { INodeOptions } from "./models/INodeOptions";
7
+ /**
8
+ * Start the engine server.
9
+ * @param nodeOptions Optional run options for the engine server.
10
+ * @param engineServerConfig The configuration for the engine server.
11
+ * @param envVars The environment variables.
12
+ * @returns The engine server.
13
+ */
14
+ export declare function start(nodeOptions: INodeOptions | undefined, engineServerConfig: IEngineServerConfig, envVars: INodeEnvironmentVariables): Promise<{
15
+ engine: Engine<IEngineServerConfig, IEngineState>;
16
+ server: EngineServer;
17
+ } | undefined>;