@twin.org/node-core 0.0.2-next.26 → 0.0.2-next.27
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 +6 -20
- package/dist/es/bootstrap.js +374 -0
- package/dist/es/bootstrap.js.map +1 -0
- package/dist/es/builders/engineEnvBuilder.js +1051 -0
- package/dist/es/builders/engineEnvBuilder.js.map +1 -0
- package/dist/es/builders/engineServerEnvBuilder.js +197 -0
- package/dist/es/builders/engineServerEnvBuilder.js.map +1 -0
- package/dist/es/builders/extensionsBuilder.js +100 -0
- package/dist/es/builders/extensionsBuilder.js.map +1 -0
- package/dist/es/defaults.js +9 -0
- package/dist/es/defaults.js.map +1 -0
- package/dist/es/identity.js +169 -0
- package/dist/es/identity.js.map +1 -0
- package/dist/es/index.js +23 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/ICacheMetadata.js +4 -0
- package/dist/es/models/ICacheMetadata.js.map +1 -0
- package/dist/es/models/IEngineEnvironmentVariables.js +4 -0
- package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -0
- package/dist/es/models/IEngineServerEnvironmentVariables.js +2 -0
- package/dist/es/models/IEngineServerEnvironmentVariables.js.map +1 -0
- package/dist/es/models/IModuleProtocol.js +2 -0
- package/dist/es/models/IModuleProtocol.js.map +1 -0
- package/dist/es/models/INodeEngineConfig.js +2 -0
- package/dist/es/models/INodeEngineConfig.js.map +1 -0
- package/dist/es/models/INodeEngineState.js +2 -0
- package/dist/es/models/INodeEngineState.js.map +1 -0
- package/dist/es/models/INodeEnvironmentVariables.js +2 -0
- package/dist/es/models/INodeEnvironmentVariables.js.map +1 -0
- package/dist/es/models/INodeOptions.js +2 -0
- package/dist/es/models/INodeOptions.js.map +1 -0
- package/dist/es/models/IProtocolHandlerResult.js +4 -0
- package/dist/es/models/IProtocolHandlerResult.js.map +1 -0
- package/dist/es/models/moduleProtocol.js +29 -0
- package/dist/es/models/moduleProtocol.js.map +1 -0
- package/dist/es/models/nodeExtensionMethods.js +2 -0
- package/dist/es/models/nodeExtensionMethods.js.map +1 -0
- package/dist/es/models/nodeFeatures.js +21 -0
- package/dist/es/models/nodeFeatures.js.map +1 -0
- package/dist/es/node.js +265 -0
- package/dist/es/node.js.map +1 -0
- package/dist/es/server.js +74 -0
- package/dist/es/server.js.map +1 -0
- package/dist/es/utils.js +418 -0
- package/dist/es/utils.js.map +1 -0
- package/dist/types/bootstrap.d.ts +27 -10
- package/dist/types/builders/engineEnvBuilder.d.ts +3 -2
- package/dist/types/builders/engineServerEnvBuilder.d.ts +3 -2
- package/dist/types/builders/extensionsBuilder.d.ts +2 -2
- package/dist/types/identity.d.ts +14 -0
- package/dist/types/index.d.ts +20 -19
- package/dist/types/models/IEngineEnvironmentVariables.d.ts +12 -5
- package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +1 -1
- package/dist/types/models/IModuleProtocol.d.ts +1 -1
- package/dist/types/models/INodeEngineState.d.ts +22 -0
- package/dist/types/models/INodeEnvironmentVariables.d.ts +24 -8
- package/dist/types/models/INodeOptions.d.ts +13 -3
- package/dist/types/models/nodeExtensionMethods.d.ts +2 -2
- package/dist/types/models/nodeFeatures.d.ts +5 -5
- package/dist/types/node.d.ts +14 -5
- package/dist/types/server.d.ts +7 -6
- package/dist/types/utils.d.ts +5 -5
- package/docs/detailed-guide.md +14 -14
- package/docs/reference/functions/bootstrap.md +1 -1
- package/docs/reference/functions/bootstrapAuth.md +1 -1
- package/docs/reference/functions/bootstrapBlobEncryption.md +1 -1
- package/docs/reference/functions/bootstrapContextIdHandlers.md +35 -0
- package/docs/reference/functions/bootstrapImmutableProofMethod.md +1 -1
- package/docs/reference/functions/{bootstrapNodeUser.md → bootstrapNodeAdminUser.md} +3 -3
- package/docs/reference/functions/{bootstrapNodeIdentity.md → bootstrapNodeId.md} +3 -3
- package/docs/reference/functions/bootstrapSynchronisedStorage.md +1 -1
- package/docs/reference/functions/bootstrapTenantId.md +35 -0
- package/docs/reference/functions/buildConfiguration.md +2 -2
- package/docs/reference/functions/buildEngineConfiguration.md +7 -1
- package/docs/reference/functions/buildEngineServerConfiguration.md +7 -1
- package/docs/reference/functions/run.md +3 -3
- package/docs/reference/functions/start.md +8 -2
- package/docs/reference/index.md +5 -2
- package/docs/reference/interfaces/IEngineEnvironmentVariables.md +24 -9
- package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +36 -13
- package/docs/reference/interfaces/INodeEngineConfig.md +430 -0
- package/docs/reference/interfaces/INodeEngineState.md +39 -0
- package/docs/reference/interfaces/INodeEnvironmentVariables.md +79 -24
- package/docs/reference/interfaces/INodeOptions.md +21 -1
- package/docs/reference/variables/NodeFeatures.md +7 -7
- package/locales/en.json +10 -7
- package/package.json +40 -8
- package/dist/cjs/index.cjs +0 -2570
- package/dist/esm/index.mjs +0 -2508
package/dist/types/index.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
export * from "./bootstrap";
|
|
2
|
-
export * from "./builders/engineEnvBuilder";
|
|
3
|
-
export * from "./builders/engineServerEnvBuilder";
|
|
4
|
-
export * from "./builders/extensionsBuilder";
|
|
5
|
-
export * from "./defaults";
|
|
6
|
-
export * from "./models/ICacheMetadata";
|
|
7
|
-
export * from "./models/IEngineEnvironmentVariables";
|
|
8
|
-
export * from "./models/IEngineServerEnvironmentVariables";
|
|
9
|
-
export * from "./models/IModuleProtocol";
|
|
10
|
-
export * from "./models/INodeEngineConfig";
|
|
11
|
-
export * from "./models/
|
|
12
|
-
export * from "./models/
|
|
13
|
-
export * from "./models/
|
|
14
|
-
export * from "./models/
|
|
15
|
-
export * from "./models/
|
|
16
|
-
export * from "./models/
|
|
17
|
-
export * from "./
|
|
18
|
-
export * from "./
|
|
19
|
-
export * from "./
|
|
1
|
+
export * from "./bootstrap.js";
|
|
2
|
+
export * from "./builders/engineEnvBuilder.js";
|
|
3
|
+
export * from "./builders/engineServerEnvBuilder.js";
|
|
4
|
+
export * from "./builders/extensionsBuilder.js";
|
|
5
|
+
export * from "./defaults.js";
|
|
6
|
+
export * from "./models/ICacheMetadata.js";
|
|
7
|
+
export * from "./models/IEngineEnvironmentVariables.js";
|
|
8
|
+
export * from "./models/IEngineServerEnvironmentVariables.js";
|
|
9
|
+
export * from "./models/IModuleProtocol.js";
|
|
10
|
+
export * from "./models/INodeEngineConfig.js";
|
|
11
|
+
export * from "./models/INodeEngineState.js";
|
|
12
|
+
export * from "./models/INodeEnvironmentVariables.js";
|
|
13
|
+
export * from "./models/INodeOptions.js";
|
|
14
|
+
export * from "./models/IProtocolHandlerResult.js";
|
|
15
|
+
export * from "./models/moduleProtocol.js";
|
|
16
|
+
export * from "./models/nodeExtensionMethods.js";
|
|
17
|
+
export * from "./models/nodeFeatures.js";
|
|
18
|
+
export * from "./node.js";
|
|
19
|
+
export * from "./server.js";
|
|
20
|
+
export * from "./utils.js";
|
|
@@ -14,6 +14,18 @@ export interface IEngineEnvironmentVariables {
|
|
|
14
14
|
* The name of the state file.
|
|
15
15
|
*/
|
|
16
16
|
stateFilename?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Is multi-tenant support enabled, defaults to false.
|
|
19
|
+
*/
|
|
20
|
+
tenantEnabled?: string;
|
|
21
|
+
/**
|
|
22
|
+
* A tenant id to use as a default for the node.
|
|
23
|
+
*/
|
|
24
|
+
tenantId?: string;
|
|
25
|
+
/**
|
|
26
|
+
* A tenant api key to use as a default for the node.
|
|
27
|
+
*/
|
|
28
|
+
tenantApiKey?: string;
|
|
17
29
|
/**
|
|
18
30
|
* The type of the entity storage to create, comma separate for more than one connector.
|
|
19
31
|
* values: file, memory, aws-dynamodb, azure-cosmosdb, gcp-firestoredb, scylladb, mysql, mongodb, postgresql
|
|
@@ -285,11 +297,6 @@ export interface IEngineEnvironmentVariables {
|
|
|
285
297
|
* Are the messaging components enabled, defaults to false.
|
|
286
298
|
*/
|
|
287
299
|
messagingEnabled?: string;
|
|
288
|
-
/**
|
|
289
|
-
* An initial set of templates for the messages.
|
|
290
|
-
* Use the @json: prefix to specify the path to the JSON file.
|
|
291
|
-
*/
|
|
292
|
-
messagingTemplates?: string;
|
|
293
300
|
/**
|
|
294
301
|
* AWS SES region.
|
|
295
302
|
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IEngineState } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* The engine state for the node.
|
|
4
|
+
*/
|
|
5
|
+
export interface INodeEngineState extends IEngineState {
|
|
6
|
+
/**
|
|
7
|
+
* The identity for the node.
|
|
8
|
+
*/
|
|
9
|
+
nodeId?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The tenant id for the node.
|
|
12
|
+
*/
|
|
13
|
+
nodeTenantId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The identity for the organization.
|
|
16
|
+
*/
|
|
17
|
+
nodeOrganizationId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The identity for the admin user.
|
|
20
|
+
*/
|
|
21
|
+
nodeAdminUserId?: string;
|
|
22
|
+
}
|
|
@@ -1,30 +1,46 @@
|
|
|
1
|
-
import type { IEngineServerEnvironmentVariables } from "./IEngineServerEnvironmentVariables";
|
|
1
|
+
import type { IEngineServerEnvironmentVariables } from "./IEngineServerEnvironmentVariables.js";
|
|
2
2
|
/**
|
|
3
3
|
* The environment variables for the node.
|
|
4
4
|
*/
|
|
5
5
|
export interface INodeEnvironmentVariables extends IEngineServerEnvironmentVariables {
|
|
6
6
|
/**
|
|
7
7
|
* The features that are enabled on the node.
|
|
8
|
-
* @default [
|
|
8
|
+
* @default []
|
|
9
9
|
*/
|
|
10
10
|
features?: string;
|
|
11
11
|
/**
|
|
12
12
|
* The identity of the node which, if empty and node-identity feature is enabled it will be generated.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
nodeIdentity?: string;
|
|
15
15
|
/**
|
|
16
16
|
* The mnemonic for the identity, if empty and node-identity feature is enabled it will be randomly generated.
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
nodeMnemonic?: string;
|
|
19
19
|
/**
|
|
20
|
-
* If the node-user feature is enabled, this will be the
|
|
20
|
+
* If the node-admin-user feature is enabled, this will be the organization of the user, if one is not provided it will be generated
|
|
21
|
+
*/
|
|
22
|
+
organizationIdentity?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The mnemonic for the organization, if empty and node-admin-user feature is enabled it will be randomly generated.
|
|
25
|
+
*/
|
|
26
|
+
organizationMnemonic?: string;
|
|
27
|
+
/**
|
|
28
|
+
* If the node-admin-user feature is enabled, this will be the identity of the user, if one is not provided it will be generated
|
|
29
|
+
*/
|
|
30
|
+
adminUserIdentity?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The mnemonic for the admin user, if empty and node-admin-user feature is enabled it will be randomly generated.
|
|
33
|
+
*/
|
|
34
|
+
adminUserMnemonic?: string;
|
|
35
|
+
/**
|
|
36
|
+
* If the node-admin-user feature is enabled, this will be the name of the user.
|
|
21
37
|
* @default admin@node
|
|
22
38
|
*/
|
|
23
|
-
|
|
39
|
+
adminUserName?: string;
|
|
24
40
|
/**
|
|
25
|
-
* If the node-user feature is enabled, this will be the password of the user, if empty it will be randomly generated.
|
|
41
|
+
* If the node-admin-user feature is enabled, this will be the password of the user, if empty it will be randomly generated.
|
|
26
42
|
*/
|
|
27
|
-
|
|
43
|
+
adminUserPassword?: string;
|
|
28
44
|
/**
|
|
29
45
|
* Maximum size in MB for HTTPS extensions downloads.
|
|
30
46
|
* @default 10
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IEngineCore, IEngineServer, IEngineStateStorage } from "@twin.org/engine-models";
|
|
2
2
|
import type { IEngineConfig } from "@twin.org/engine-types";
|
|
3
|
-
import type { INodeEngineConfig } from "./INodeEngineConfig";
|
|
4
|
-
import type { INodeEnvironmentVariables } from "./INodeEnvironmentVariables";
|
|
3
|
+
import type { INodeEngineConfig } from "./INodeEngineConfig.js";
|
|
4
|
+
import type { INodeEnvironmentVariables } from "./INodeEnvironmentVariables.js";
|
|
5
5
|
/**
|
|
6
6
|
* The options when running the node.
|
|
7
7
|
*/
|
|
@@ -15,12 +15,18 @@ export interface INodeOptions {
|
|
|
15
15
|
* The version of the server, defaults to the current version.
|
|
16
16
|
*/
|
|
17
17
|
serverVersion?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Additional environment variables to set.
|
|
20
|
+
*/
|
|
21
|
+
envVars?: {
|
|
22
|
+
[key: string]: string;
|
|
23
|
+
};
|
|
18
24
|
/**
|
|
19
25
|
* Additional environment variable filenames to load, defaults to .env.
|
|
20
26
|
*/
|
|
21
27
|
envFilenames?: string[];
|
|
22
28
|
/**
|
|
23
|
-
* The prefix for environment variables, defaults to "
|
|
29
|
+
* The prefix for environment variables, defaults to "TWIN_".
|
|
24
30
|
*/
|
|
25
31
|
envPrefix?: string;
|
|
26
32
|
/**
|
|
@@ -71,4 +77,8 @@ export interface INodeOptions {
|
|
|
71
77
|
* If not provided, a default file-based state storage will be used.
|
|
72
78
|
*/
|
|
73
79
|
stateStorage?: IEngineStateStorage;
|
|
80
|
+
/**
|
|
81
|
+
* Disables process.exit calls on fatal errors and throws instead.
|
|
82
|
+
*/
|
|
83
|
+
disableProcessExitOnFailure?: boolean;
|
|
74
84
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IEngineCore, IEngineServer } from "@twin.org/engine-models";
|
|
2
|
-
import type { INodeEngineConfig } from "./INodeEngineConfig";
|
|
3
|
-
import type { INodeEnvironmentVariables } from "./INodeEnvironmentVariables";
|
|
2
|
+
import type { INodeEngineConfig } from "./INodeEngineConfig.js";
|
|
3
|
+
import type { INodeEnvironmentVariables } from "./INodeEnvironmentVariables.js";
|
|
4
4
|
/**
|
|
5
5
|
* The type for the initialise method of an extension module.
|
|
6
6
|
* @param envVars The environment variables for the node.
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const NodeFeatures: {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* NodeId - generates an identity for the node if not provided in config.
|
|
7
7
|
*/
|
|
8
|
-
readonly
|
|
8
|
+
readonly NodeId: "node-identity";
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* NodeAdminUser - generates an admin user for the node if not provided in config.
|
|
11
11
|
*/
|
|
12
|
-
readonly
|
|
12
|
+
readonly NodeAdminUser: "node-admin-user";
|
|
13
13
|
/**
|
|
14
|
-
* NodeWallet - generates
|
|
14
|
+
* NodeWallet - generates wallets for any identities that need them.
|
|
15
15
|
*/
|
|
16
16
|
readonly NodeWallet: "node-wallet";
|
|
17
17
|
};
|
package/dist/types/node.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import type { IServerInfo } from "@twin.org/api-models";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
2
|
+
import type { Engine } from "@twin.org/engine";
|
|
3
|
+
import type { EngineServer } from "@twin.org/engine-server";
|
|
4
|
+
import type { IEngineServerConfig } from "@twin.org/engine-server-types";
|
|
5
|
+
import type { INodeEngineConfig } from "./models/INodeEngineConfig.js";
|
|
6
|
+
import type { INodeEngineState } from "./models/INodeEngineState.js";
|
|
7
|
+
import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables.js";
|
|
8
|
+
import type { INodeOptions } from "./models/INodeOptions.js";
|
|
5
9
|
/**
|
|
6
10
|
* Run the TWIN Node server.
|
|
7
11
|
* @param nodeOptions Optional configuration options for running the server.
|
|
8
|
-
* @returns A promise that resolves when the server is started.
|
|
12
|
+
* @returns A promise that resolves when the server is started containing a shutdown method.
|
|
9
13
|
*/
|
|
10
|
-
export declare function run(nodeOptions?: INodeOptions): Promise<
|
|
14
|
+
export declare function run(nodeOptions?: INodeOptions): Promise<{
|
|
15
|
+
engine: Engine<IEngineServerConfig, INodeEngineState>;
|
|
16
|
+
server: EngineServer;
|
|
17
|
+
shutdown: () => Promise<void>;
|
|
18
|
+
} | undefined>;
|
|
11
19
|
/**
|
|
12
20
|
* Build the configuration for the TWIN Node server.
|
|
13
21
|
* @param processEnv The environment variables from the process.
|
|
@@ -23,6 +31,7 @@ export declare function buildConfiguration(processEnv: {
|
|
|
23
31
|
[id: string]: string | unknown;
|
|
24
32
|
};
|
|
25
33
|
nodeEngineConfig: INodeEngineConfig;
|
|
34
|
+
contextIdKeys: string[];
|
|
26
35
|
}>;
|
|
27
36
|
/**
|
|
28
37
|
* Override module imports to support protocol-based loading (npm:, https:) and local files.
|
package/dist/types/server.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { Engine } from "@twin.org/engine";
|
|
2
|
-
import { type IEngineState } from "@twin.org/engine-models";
|
|
3
2
|
import { EngineServer } from "@twin.org/engine-server";
|
|
4
3
|
import type { IEngineServerConfig } from "@twin.org/engine-server-types";
|
|
5
|
-
import type { INodeEngineConfig } from "./models/INodeEngineConfig";
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
4
|
+
import type { INodeEngineConfig } from "./models/INodeEngineConfig.js";
|
|
5
|
+
import type { INodeEngineState } from "./models/INodeEngineState.js";
|
|
6
|
+
import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables.js";
|
|
7
|
+
import type { INodeOptions } from "./models/INodeOptions.js";
|
|
8
8
|
/**
|
|
9
9
|
* Start the engine server.
|
|
10
10
|
* @param nodeOptions Optional run options for the engine server.
|
|
11
11
|
* @param nodeEngineConfig The configuration for the engine server.
|
|
12
12
|
* @param envVars The environment variables.
|
|
13
|
+
* @param contextIdKeys The context ID keys.
|
|
13
14
|
* @returns The engine server.
|
|
14
15
|
*/
|
|
15
|
-
export declare function start(nodeOptions: INodeOptions | undefined, nodeEngineConfig: INodeEngineConfig, envVars: INodeEnvironmentVariables): Promise<{
|
|
16
|
-
engine: Engine<IEngineServerConfig,
|
|
16
|
+
export declare function start(nodeOptions: INodeOptions | undefined, nodeEngineConfig: INodeEngineConfig, envVars: INodeEnvironmentVariables, contextIdKeys?: string[]): Promise<{
|
|
17
|
+
engine: Engine<IEngineServerConfig, INodeEngineState>;
|
|
17
18
|
server: EngineServer;
|
|
18
19
|
shutdown: () => Promise<void>;
|
|
19
20
|
} | undefined>;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { IModuleProtocol } from "./models/IModuleProtocol";
|
|
2
|
-
import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables";
|
|
3
|
-
import type { IProtocolHandlerResult } from "./models/IProtocolHandlerResult";
|
|
4
|
-
import { ModuleProtocol } from "./models/moduleProtocol";
|
|
5
|
-
import { NodeFeatures } from "./models/nodeFeatures";
|
|
1
|
+
import type { IModuleProtocol } from "./models/IModuleProtocol.js";
|
|
2
|
+
import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables.js";
|
|
3
|
+
import type { IProtocolHandlerResult } from "./models/IProtocolHandlerResult.js";
|
|
4
|
+
import { ModuleProtocol } from "./models/moduleProtocol.js";
|
|
5
|
+
import { NodeFeatures } from "./models/nodeFeatures.js";
|
|
6
6
|
/**
|
|
7
7
|
* Initialise the locales for the application.
|
|
8
8
|
* @param localesDirectory The directory containing the locales.
|
package/docs/detailed-guide.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# TWIN Node
|
|
1
|
+
# TWIN Node - Detailed Documentation
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
TWIN Node
|
|
5
|
+
TWIN Node provides the foundational components for running TWIN nodes, including dynamic extension loading, protocol-based module resolution, and lifecycle management.
|
|
6
6
|
|
|
7
7
|
## Protocol-Based Extension Loading
|
|
8
8
|
|
|
9
|
-
The TWIN Node
|
|
9
|
+
The TWIN Node supports dynamic extension loading from multiple sources:
|
|
10
10
|
|
|
11
11
|
### Local Files
|
|
12
12
|
|
|
13
13
|
Load extensions from your filesystem:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
|
|
16
|
+
TWIN_EXTENSIONS="./my-extension.mjs"
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
### NPM Packages
|
|
@@ -21,7 +21,7 @@ TWIN_NODE_EXTENSIONS="./my-extension.mjs"
|
|
|
21
21
|
Automatically install and load npm packages:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
|
|
24
|
+
TWIN_EXTENSIONS="npm:@twin.org/package"
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
### HTTPS URLs
|
|
@@ -29,7 +29,7 @@ TWIN_NODE_EXTENSIONS="npm:@twin.org/package"
|
|
|
29
29
|
Download and cache remote extensions:
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
|
-
|
|
32
|
+
TWIN_EXTENSIONS="https://example.com/extension.mjs"
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
## Extension Lifecycle Hooks
|
|
@@ -69,14 +69,14 @@ export function extensionShutdown() {
|
|
|
69
69
|
|
|
70
70
|
### Cache Management
|
|
71
71
|
|
|
72
|
-
- `
|
|
73
|
-
- `
|
|
74
|
-
- `
|
|
72
|
+
- `TWIN_EXTENSIONS_CACHE_TTL_HOURS` - TTL for HTTPS extensions cache (default: 24)
|
|
73
|
+
- `TWIN_EXTENSIONS_FORCE_REFRESH` - Force refresh all cached extensions (default: false)
|
|
74
|
+
- `TWIN_EXTENSIONS_CACHE_DIRECTORY` - Custom cache directory (default: ".tmp")
|
|
75
75
|
|
|
76
76
|
### Security
|
|
77
77
|
|
|
78
|
-
- `
|
|
79
|
-
- `
|
|
78
|
+
- `TWIN_EXTENSIONS_MAX_SIZE_MB` - Maximum size for HTTPS downloads (default: 10)
|
|
79
|
+
- `TWIN_EXTENSIONS_CLEAR_CACHE` - Clear cache on startup (default: false)
|
|
80
80
|
|
|
81
81
|
## API Reference
|
|
82
82
|
|
|
@@ -111,7 +111,7 @@ Handles download and caching of HTTPS extensions.
|
|
|
111
111
|
## Security Considerations
|
|
112
112
|
|
|
113
113
|
- **HTTPS Only**: Remote extensions must use HTTPS protocol
|
|
114
|
-
- **Size Limits**: Downloads are limited by `
|
|
114
|
+
- **Size Limits**: Downloads are limited by `TWIN_EXTENSIONS_MAX_SIZE_MB`
|
|
115
115
|
- **Cache TTL**: Extensions are automatically refreshed based on TTL
|
|
116
116
|
- **Security Warnings**: Warnings are displayed when loading remote extensions
|
|
117
117
|
|
|
@@ -120,8 +120,8 @@ Handles download and caching of HTTPS extensions.
|
|
|
120
120
|
### Common Issues
|
|
121
121
|
|
|
122
122
|
1. **Extension not found**: Check that the path/URL is correct and accessible
|
|
123
|
-
2. **Cache issues**: Use `
|
|
124
|
-
3. **Size limit exceeded**: Increase `
|
|
123
|
+
2. **Cache issues**: Use `TWIN_EXTENSIONS_FORCE_REFRESH=true` to force refresh
|
|
124
|
+
3. **Size limit exceeded**: Increase `TWIN_EXTENSIONS_MAX_SIZE_MB` if needed
|
|
125
125
|
4. **Network issues**: Ensure HTTPS URLs are accessible and not blocked by firewall
|
|
126
126
|
|
|
127
127
|
### Debug Mode
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Function: bootstrapContextIdHandlers()
|
|
2
|
+
|
|
3
|
+
> **bootstrapContextIdHandlers**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
|
|
4
|
+
|
|
5
|
+
Bootstrap the context id handlers creating any necessary resources.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### engineCore
|
|
10
|
+
|
|
11
|
+
`IEngineCore`
|
|
12
|
+
|
|
13
|
+
The engine core for the node.
|
|
14
|
+
|
|
15
|
+
### context
|
|
16
|
+
|
|
17
|
+
`IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
|
|
18
|
+
|
|
19
|
+
The context for the node.
|
|
20
|
+
|
|
21
|
+
### envVars
|
|
22
|
+
|
|
23
|
+
[`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md)
|
|
24
|
+
|
|
25
|
+
The environment variables for the node.
|
|
26
|
+
|
|
27
|
+
### features
|
|
28
|
+
|
|
29
|
+
[`NodeFeatures`](../type-aliases/NodeFeatures.md)[]
|
|
30
|
+
|
|
31
|
+
The features that are enabled on the node. The features that are enabled on the node.
|
|
32
|
+
|
|
33
|
+
## Returns
|
|
34
|
+
|
|
35
|
+
`Promise`\<`void`\>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Function:
|
|
1
|
+
# Function: bootstrapNodeAdminUser()
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **bootstrapNodeAdminUser**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
|
|
4
4
|
|
|
5
5
|
Bootstrap the user.
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ The engine core for the node.
|
|
|
14
14
|
|
|
15
15
|
### context
|
|
16
16
|
|
|
17
|
-
`IEngineCoreContext`\<`IEngineServerConfig`, `
|
|
17
|
+
`IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
|
|
18
18
|
|
|
19
19
|
The context for the node.
|
|
20
20
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Function:
|
|
1
|
+
# Function: bootstrapNodeId()
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **bootstrapNodeId**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
|
|
4
4
|
|
|
5
5
|
Bootstrap the node creating any necessary resources.
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ The engine core for the node.
|
|
|
14
14
|
|
|
15
15
|
### context
|
|
16
16
|
|
|
17
|
-
`IEngineCoreContext`\<`IEngineServerConfig`, `
|
|
17
|
+
`IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
|
|
18
18
|
|
|
19
19
|
The context for the node.
|
|
20
20
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Function: bootstrapTenantId()
|
|
2
|
+
|
|
3
|
+
> **bootstrapTenantId**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
|
|
4
|
+
|
|
5
|
+
Bootstrap the node creating any necessary resources.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### engineCore
|
|
10
|
+
|
|
11
|
+
`IEngineCore`
|
|
12
|
+
|
|
13
|
+
The engine core for the node.
|
|
14
|
+
|
|
15
|
+
### context
|
|
16
|
+
|
|
17
|
+
`IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
|
|
18
|
+
|
|
19
|
+
The context for the node.
|
|
20
|
+
|
|
21
|
+
### envVars
|
|
22
|
+
|
|
23
|
+
[`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md)
|
|
24
|
+
|
|
25
|
+
The environment variables for the node.
|
|
26
|
+
|
|
27
|
+
### features
|
|
28
|
+
|
|
29
|
+
[`NodeFeatures`](../type-aliases/NodeFeatures.md)[]
|
|
30
|
+
|
|
31
|
+
The features that are enabled on the node. The features that are enabled on the node.
|
|
32
|
+
|
|
33
|
+
## Returns
|
|
34
|
+
|
|
35
|
+
`Promise`\<`void`\>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Function: buildConfiguration()
|
|
2
2
|
|
|
3
|
-
> **buildConfiguration**(`processEnv`, `options`, `serverInfo`): `Promise`\<\{ `nodeEnvVars`: [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md) & `object`; `nodeEngineConfig`: [`INodeEngineConfig`](../interfaces/INodeEngineConfig.md); \}\>
|
|
3
|
+
> **buildConfiguration**(`processEnv`, `options`, `serverInfo`): `Promise`\<\{ `nodeEnvVars`: [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md) & `object`; `nodeEngineConfig`: [`INodeEngineConfig`](../interfaces/INodeEngineConfig.md); `contextIdKeys`: `string`[]; \}\>
|
|
4
4
|
|
|
5
5
|
Build the configuration for the TWIN Node server.
|
|
6
6
|
|
|
@@ -24,7 +24,7 @@ The server information.
|
|
|
24
24
|
|
|
25
25
|
## Returns
|
|
26
26
|
|
|
27
|
-
`Promise`\<\{ `nodeEnvVars`: [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md) & `object`; `nodeEngineConfig`: [`INodeEngineConfig`](../interfaces/INodeEngineConfig.md); \}\>
|
|
27
|
+
`Promise`\<\{ `nodeEnvVars`: [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md) & `object`; `nodeEngineConfig`: [`INodeEngineConfig`](../interfaces/INodeEngineConfig.md); `contextIdKeys`: `string`[]; \}\>
|
|
28
28
|
|
|
29
29
|
A promise that resolves to the engine server configuration, environment prefix, environment variables,
|
|
30
30
|
and options.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Function: buildEngineConfiguration()
|
|
2
2
|
|
|
3
|
-
> **buildEngineConfiguration**(`envVars`): `Promise`\<`IEngineConfig`\>
|
|
3
|
+
> **buildEngineConfiguration**(`envVars`, `contextIdKeys`): `Promise`\<`IEngineConfig`\>
|
|
4
4
|
|
|
5
5
|
Build the engine core configuration from environment variables.
|
|
6
6
|
|
|
@@ -12,6 +12,12 @@ Build the engine core configuration from environment variables.
|
|
|
12
12
|
|
|
13
13
|
The environment variables.
|
|
14
14
|
|
|
15
|
+
### contextIdKeys
|
|
16
|
+
|
|
17
|
+
`string`[]
|
|
18
|
+
|
|
19
|
+
The context ID keys.
|
|
20
|
+
|
|
15
21
|
## Returns
|
|
16
22
|
|
|
17
23
|
`Promise`\<`IEngineConfig`\>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Function: buildEngineServerConfiguration()
|
|
2
2
|
|
|
3
|
-
> **buildEngineServerConfiguration**(`envVars`, `coreEngineConfig`, `serverInfo`, `openApiSpecPath?`, `favIconPath?`): `Promise`\<`IEngineServerConfig`\>
|
|
3
|
+
> **buildEngineServerConfiguration**(`envVars`, `contextIdKeys`, `coreEngineConfig`, `serverInfo`, `openApiSpecPath?`, `favIconPath?`): `Promise`\<`IEngineServerConfig`\>
|
|
4
4
|
|
|
5
5
|
Handles the configuration of the server.
|
|
6
6
|
|
|
@@ -12,6 +12,12 @@ Handles the configuration of the server.
|
|
|
12
12
|
|
|
13
13
|
The environment variables for the engine server.
|
|
14
14
|
|
|
15
|
+
### contextIdKeys
|
|
16
|
+
|
|
17
|
+
`string`[]
|
|
18
|
+
|
|
19
|
+
The context ID keys.
|
|
20
|
+
|
|
15
21
|
### coreEngineConfig
|
|
16
22
|
|
|
17
23
|
`IEngineCoreConfig`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Function: run()
|
|
2
2
|
|
|
3
|
-
> **run**(`nodeOptions?`): `Promise`\<`void
|
|
3
|
+
> **run**(`nodeOptions?`): `Promise`\<`undefined` \| \{ `engine`: `Engine`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>; `server`: `EngineServer`; `shutdown`: () => `Promise`\<`void`\>; \}\>
|
|
4
4
|
|
|
5
5
|
Run the TWIN Node server.
|
|
6
6
|
|
|
@@ -14,6 +14,6 @@ Optional configuration options for running the server.
|
|
|
14
14
|
|
|
15
15
|
## Returns
|
|
16
16
|
|
|
17
|
-
`Promise`\<`void
|
|
17
|
+
`Promise`\<`undefined` \| \{ `engine`: `Engine`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>; `server`: `EngineServer`; `shutdown`: () => `Promise`\<`void`\>; \}\>
|
|
18
18
|
|
|
19
|
-
A promise that resolves when the server is started.
|
|
19
|
+
A promise that resolves when the server is started containing a shutdown method.
|