@twin.org/node-core 0.0.3-next.27 → 0.0.3-next.29
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 +3 -1
- package/dist/es/commands/bootstrapLegacy.js +2 -1
- package/dist/es/commands/bootstrapLegacy.js.map +1 -1
- package/dist/es/commands/identityVerificationMethodCreate.js +1 -1
- package/dist/es/commands/identityVerificationMethodCreate.js.map +1 -1
- package/dist/es/node.js +1 -1
- package/dist/es/node.js.map +1 -1
- package/docs/changelog.md +15 -1
- package/docs/examples.md +99 -1
- package/docs/reference/functions/start.md +2 -2
- package/docs/reference/interfaces/ICacheMetadata.md +3 -3
- package/docs/reference/interfaces/ICliArgs.md +6 -6
- package/docs/reference/interfaces/ICliCommand.md +2 -2
- package/docs/reference/interfaces/ICliCommandDefinition.md +11 -11
- package/docs/reference/interfaces/ICliCommandDefinitionParam.md +11 -11
- package/docs/reference/interfaces/IEngineEnvironmentVariables.md +280 -280
- package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +308 -308
- package/docs/reference/interfaces/IModuleProtocol.md +3 -3
- package/docs/reference/interfaces/INodeEngineState.md +4 -4
- package/docs/reference/interfaces/INodeEnvironmentVariables.md +318 -318
- package/docs/reference/interfaces/INodeOptions.md +36 -36
- package/docs/reference/interfaces/IProtocolHandlerResult.md +2 -2
- package/docs/reference/type-aliases/NodeExtensionInitialiseEngineMethod.md +1 -1
- package/docs/reference/type-aliases/NodeExtensionInitialiseEngineServerMethod.md +1 -1
- package/docs/reference/type-aliases/NodeExtensionInitialiseMethod.md +1 -1
- package/docs/reference/type-aliases/NodeExtensionShutdownMethod.md +1 -1
- package/docs/reference/variables/ModuleProtocol.md +5 -5
- package/package.json +1 -1
- package/docs/detailed-guide.md +0 -129
|
@@ -4,9 +4,9 @@ The options when running the node.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
### serverName?
|
|
7
|
+
### serverName? {#servername}
|
|
8
8
|
|
|
9
|
-
> `optional` **serverName
|
|
9
|
+
> `optional` **serverName?**: `string`
|
|
10
10
|
|
|
11
11
|
The name of the server, defaults to "TWIN Node".
|
|
12
12
|
|
|
@@ -18,17 +18,17 @@ The name of the server, defaults to "TWIN Node".
|
|
|
18
18
|
|
|
19
19
|
***
|
|
20
20
|
|
|
21
|
-
### serverVersion?
|
|
21
|
+
### serverVersion? {#serverversion}
|
|
22
22
|
|
|
23
|
-
> `optional` **serverVersion
|
|
23
|
+
> `optional` **serverVersion?**: `string`
|
|
24
24
|
|
|
25
25
|
The version of the server, defaults to the current version.
|
|
26
26
|
|
|
27
27
|
***
|
|
28
28
|
|
|
29
|
-
### envVars?
|
|
29
|
+
### envVars? {#envvars}
|
|
30
30
|
|
|
31
|
-
> `optional` **envVars
|
|
31
|
+
> `optional` **envVars?**: `object`
|
|
32
32
|
|
|
33
33
|
Additional environment variables to set.
|
|
34
34
|
|
|
@@ -38,25 +38,25 @@ Additional environment variables to set.
|
|
|
38
38
|
|
|
39
39
|
***
|
|
40
40
|
|
|
41
|
-
### envFilenames?
|
|
41
|
+
### envFilenames? {#envfilenames}
|
|
42
42
|
|
|
43
|
-
> `optional` **envFilenames
|
|
43
|
+
> `optional` **envFilenames?**: `string`[]
|
|
44
44
|
|
|
45
45
|
Additional environment variable filenames to load, defaults to .env.
|
|
46
46
|
|
|
47
47
|
***
|
|
48
48
|
|
|
49
|
-
### envPrefix?
|
|
49
|
+
### envPrefix? {#envprefix}
|
|
50
50
|
|
|
51
|
-
> `optional` **envPrefix
|
|
51
|
+
> `optional` **envPrefix?**: `string`
|
|
52
52
|
|
|
53
53
|
The prefix for environment variables, defaults to "TWIN_".
|
|
54
54
|
|
|
55
55
|
***
|
|
56
56
|
|
|
57
|
-
### configFilenames?
|
|
57
|
+
### configFilenames? {#configfilenames}
|
|
58
58
|
|
|
59
|
-
> `optional` **configFilenames
|
|
59
|
+
> `optional` **configFilenames?**: `string`[]
|
|
60
60
|
|
|
61
61
|
A list of JSON files to load as configuration files.
|
|
62
62
|
The files will be loaded in the order they are provided, and the last one will
|
|
@@ -64,58 +64,58 @@ override any previous values.
|
|
|
64
64
|
|
|
65
65
|
***
|
|
66
66
|
|
|
67
|
-
### config?
|
|
67
|
+
### config? {#config}
|
|
68
68
|
|
|
69
|
-
> `optional` **config
|
|
69
|
+
> `optional` **config?**: `IEngineConfig`
|
|
70
70
|
|
|
71
71
|
Provides the ability to have some initial custom configuration for the engine.
|
|
72
72
|
This will be merged with any configuration loaded from the environment variables.
|
|
73
73
|
|
|
74
74
|
***
|
|
75
75
|
|
|
76
|
-
### scriptDirectory?
|
|
76
|
+
### scriptDirectory? {#scriptdirectory}
|
|
77
77
|
|
|
78
|
-
> `optional` **scriptDirectory
|
|
78
|
+
> `optional` **scriptDirectory?**: `string`
|
|
79
79
|
|
|
80
80
|
The directory to override the script location, defaults to location of index.js.
|
|
81
81
|
|
|
82
82
|
***
|
|
83
83
|
|
|
84
|
-
### executionDirectory?
|
|
84
|
+
### executionDirectory? {#executiondirectory}
|
|
85
85
|
|
|
86
|
-
> `optional` **executionDirectory
|
|
86
|
+
> `optional` **executionDirectory?**: `string`
|
|
87
87
|
|
|
88
88
|
The directory to override the execution location, defaults to process directory.
|
|
89
89
|
|
|
90
90
|
***
|
|
91
91
|
|
|
92
|
-
### localesDirectory?
|
|
92
|
+
### localesDirectory? {#localesdirectory}
|
|
93
93
|
|
|
94
|
-
> `optional` **localesDirectory
|
|
94
|
+
> `optional` **localesDirectory?**: `string`
|
|
95
95
|
|
|
96
96
|
The directory to override the locales directory, defaults to the locales directory.
|
|
97
97
|
|
|
98
98
|
***
|
|
99
99
|
|
|
100
|
-
### openApiSpecFile?
|
|
100
|
+
### openApiSpecFile? {#openapispecfile}
|
|
101
101
|
|
|
102
|
-
> `optional` **openApiSpecFile
|
|
102
|
+
> `optional` **openApiSpecFile?**: `string`
|
|
103
103
|
|
|
104
104
|
The path to the OpenAPI spec file, defaults to docs/open-api/spec.json.
|
|
105
105
|
|
|
106
106
|
***
|
|
107
107
|
|
|
108
|
-
### favIconFile?
|
|
108
|
+
### favIconFile? {#faviconfile}
|
|
109
109
|
|
|
110
|
-
> `optional` **favIconFile
|
|
110
|
+
> `optional` **favIconFile?**: `string`
|
|
111
111
|
|
|
112
112
|
The path to the favicon, defaults to static/favicon.png.
|
|
113
113
|
|
|
114
114
|
***
|
|
115
115
|
|
|
116
|
-
### extendEnvVars
|
|
116
|
+
### extendEnvVars? {#extendenvvars}
|
|
117
117
|
|
|
118
|
-
> `optional` **extendEnvVars
|
|
118
|
+
> `optional` **extendEnvVars?**: (`envVars`) => `Promise`\<`void`\>
|
|
119
119
|
|
|
120
120
|
Method to extend the engine environment variables with any additional custom configuration.
|
|
121
121
|
|
|
@@ -131,9 +131,9 @@ Method to extend the engine environment variables with any additional custom con
|
|
|
131
131
|
|
|
132
132
|
***
|
|
133
133
|
|
|
134
|
-
### extendConfig
|
|
134
|
+
### extendConfig? {#extendconfig}
|
|
135
135
|
|
|
136
|
-
> `optional` **extendConfig
|
|
136
|
+
> `optional` **extendConfig?**: (`envVars`, `config`) => `Promise`\<`void`\>
|
|
137
137
|
|
|
138
138
|
Method to extend the engine configuration with any additional custom configuration.
|
|
139
139
|
|
|
@@ -153,9 +153,9 @@ Method to extend the engine configuration with any additional custom configurati
|
|
|
153
153
|
|
|
154
154
|
***
|
|
155
155
|
|
|
156
|
-
### extendEngine
|
|
156
|
+
### extendEngine? {#extendengine}
|
|
157
157
|
|
|
158
|
-
> `optional` **extendEngine
|
|
158
|
+
> `optional` **extendEngine?**: (`engine`) => `Promise`\<`void`\>
|
|
159
159
|
|
|
160
160
|
Method to extend the engine with any additional options.
|
|
161
161
|
|
|
@@ -171,9 +171,9 @@ Method to extend the engine with any additional options.
|
|
|
171
171
|
|
|
172
172
|
***
|
|
173
173
|
|
|
174
|
-
### extendEngineServer
|
|
174
|
+
### extendEngineServer? {#extendengineserver}
|
|
175
175
|
|
|
176
|
-
> `optional` **extendEngineServer
|
|
176
|
+
> `optional` **extendEngineServer?**: (`engineServer`) => `Promise`\<`void`\>
|
|
177
177
|
|
|
178
178
|
Method to extend the engine server with any additional options.
|
|
179
179
|
|
|
@@ -189,17 +189,17 @@ Method to extend the engine server with any additional options.
|
|
|
189
189
|
|
|
190
190
|
***
|
|
191
191
|
|
|
192
|
-
### stateStorage?
|
|
192
|
+
### stateStorage? {#statestorage}
|
|
193
193
|
|
|
194
|
-
> `optional` **stateStorage
|
|
194
|
+
> `optional` **stateStorage?**: `IEngineStateStorage`\<`IEngineState`\>
|
|
195
195
|
|
|
196
196
|
The state storage to use for the engine.
|
|
197
197
|
If not provided, a default file-based state storage will be used.
|
|
198
198
|
|
|
199
199
|
***
|
|
200
200
|
|
|
201
|
-
### disableProcessExitOnFailure?
|
|
201
|
+
### disableProcessExitOnFailure? {#disableprocessexitonfailure}
|
|
202
202
|
|
|
203
|
-
> `optional` **disableProcessExitOnFailure
|
|
203
|
+
> `optional` **disableProcessExitOnFailure?**: `boolean`
|
|
204
204
|
|
|
205
205
|
Disables process.exit calls on fatal errors and throws instead.
|
|
@@ -4,7 +4,7 @@ The result from a protocol handler.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
### resolvedPath
|
|
7
|
+
### resolvedPath {#resolvedpath}
|
|
8
8
|
|
|
9
9
|
> **resolvedPath**: `string`
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ The resolved path to the module file.
|
|
|
12
12
|
|
|
13
13
|
***
|
|
14
14
|
|
|
15
|
-
### cached
|
|
15
|
+
### cached {#cached}
|
|
16
16
|
|
|
17
17
|
> **cached**: `boolean`
|
|
18
18
|
|
|
@@ -6,31 +6,31 @@ The protocol types for modules.
|
|
|
6
6
|
|
|
7
7
|
## Type Declaration
|
|
8
8
|
|
|
9
|
-
### Local
|
|
9
|
+
### Local {#local}
|
|
10
10
|
|
|
11
11
|
> `readonly` **Local**: `"local"` = `"local"`
|
|
12
12
|
|
|
13
13
|
Local module (starts with . or / or file://).
|
|
14
14
|
|
|
15
|
-
### Npm
|
|
15
|
+
### Npm {#npm}
|
|
16
16
|
|
|
17
17
|
> `readonly` **Npm**: `"npm"` = `"npm"`
|
|
18
18
|
|
|
19
19
|
NPM package (starts with npm:).
|
|
20
20
|
|
|
21
|
-
### Https
|
|
21
|
+
### Https {#https}
|
|
22
22
|
|
|
23
23
|
> `readonly` **Https**: `"https"` = `"https"`
|
|
24
24
|
|
|
25
25
|
HTTPS URL (starts with https://).
|
|
26
26
|
|
|
27
|
-
### Http
|
|
27
|
+
### Http {#http}
|
|
28
28
|
|
|
29
29
|
> `readonly` **Http**: `"http"` = `"http"`
|
|
30
30
|
|
|
31
31
|
HTTP URL (starts with http://).
|
|
32
32
|
|
|
33
|
-
### Default
|
|
33
|
+
### Default {#default}
|
|
34
34
|
|
|
35
35
|
> `readonly` **Default**: `"default"` = `"default"`
|
|
36
36
|
|
package/package.json
CHANGED
package/docs/detailed-guide.md
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
# TWIN Node - Detailed Documentation
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
TWIN Node provides the foundational components for running TWIN nodes, including dynamic extension loading, protocol-based module resolution, and lifecycle management.
|
|
6
|
-
|
|
7
|
-
## Protocol-Based Extension Loading
|
|
8
|
-
|
|
9
|
-
The TWIN Node supports dynamic extension loading from multiple sources:
|
|
10
|
-
|
|
11
|
-
### Local Files
|
|
12
|
-
|
|
13
|
-
Load extensions from your filesystem:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
TWIN_EXTENSIONS="./my-extension.mjs"
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### NPM Packages
|
|
20
|
-
|
|
21
|
-
Automatically install and load npm packages:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
TWIN_EXTENSIONS="npm:@twin.org/package"
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### HTTPS URLs
|
|
28
|
-
|
|
29
|
-
Download and cache remote extensions:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
TWIN_EXTENSIONS="https://example.com/extension.mjs"
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Extension Lifecycle Hooks
|
|
36
|
-
|
|
37
|
-
Extensions can implement lifecycle hooks to customize node behavior at different stages:
|
|
38
|
-
|
|
39
|
-
- **`extensionInitialise`** - Called before engine initialization
|
|
40
|
-
- **`extensionInitialiseEngine`** - Called during engine initialization
|
|
41
|
-
- **`extensionInitialiseEngineServer`** - Called during server initialization
|
|
42
|
-
- **`extensionShutdown`** - Called during graceful shutdown
|
|
43
|
-
|
|
44
|
-
### Example Extension
|
|
45
|
-
|
|
46
|
-
```javascript
|
|
47
|
-
// my-extension.mjs
|
|
48
|
-
export function extensionInitialise() {
|
|
49
|
-
console.log('Extension initializing...');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function extensionInitialiseEngine(engine) {
|
|
53
|
-
console.log('Configuring engine...');
|
|
54
|
-
// Add custom components, routes, etc.
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function extensionInitialiseEngineServer(server) {
|
|
58
|
-
console.log('Configuring server...');
|
|
59
|
-
// Add middleware, routes, etc.
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function extensionShutdown() {
|
|
63
|
-
console.log('Extension shutting down...');
|
|
64
|
-
// Cleanup resources
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Configuration Options
|
|
69
|
-
|
|
70
|
-
### Cache Management
|
|
71
|
-
|
|
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
|
-
|
|
76
|
-
### Security
|
|
77
|
-
|
|
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
|
-
|
|
81
|
-
## API Reference
|
|
82
|
-
|
|
83
|
-
### Core Functions
|
|
84
|
-
|
|
85
|
-
#### `overrideModuleImport(executionDirectory, envVars)`
|
|
86
|
-
|
|
87
|
-
Sets up protocol-based module resolution for extensions.
|
|
88
|
-
|
|
89
|
-
#### `buildConfiguration(options)`
|
|
90
|
-
|
|
91
|
-
Builds node configuration from environment variables and options.
|
|
92
|
-
|
|
93
|
-
#### `start(options)`
|
|
94
|
-
|
|
95
|
-
Starts the TWIN node with the specified configuration.
|
|
96
|
-
|
|
97
|
-
### Utility Functions
|
|
98
|
-
|
|
99
|
-
#### `parseModuleProtocol(moduleName)`
|
|
100
|
-
|
|
101
|
-
Parses module name to determine protocol type (npm, https, local, etc.).
|
|
102
|
-
|
|
103
|
-
#### `handleNpmProtocol(packageName, executionDirectory, cacheDirectory)`
|
|
104
|
-
|
|
105
|
-
Handles installation and resolution of npm packages.
|
|
106
|
-
|
|
107
|
-
#### `handleHttpsProtocol(url, executionDirectory, maxSizeMb, cacheDirectory, ttlHours, forceRefresh)`
|
|
108
|
-
|
|
109
|
-
Handles download and caching of HTTPS extensions.
|
|
110
|
-
|
|
111
|
-
## Security Considerations
|
|
112
|
-
|
|
113
|
-
- **HTTPS Only**: Remote extensions must use HTTPS protocol
|
|
114
|
-
- **Size Limits**: Downloads are limited by `TWIN_EXTENSIONS_MAX_SIZE_MB`
|
|
115
|
-
- **Cache TTL**: Extensions are automatically refreshed based on TTL
|
|
116
|
-
- **Security Warnings**: Warnings are displayed when loading remote extensions
|
|
117
|
-
|
|
118
|
-
## Troubleshooting
|
|
119
|
-
|
|
120
|
-
### Common Issues
|
|
121
|
-
|
|
122
|
-
1. **Extension not found**: Check that the path/URL is correct and accessible
|
|
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
|
-
4. **Network issues**: Ensure HTTPS URLs are accessible and not blocked by firewall
|
|
126
|
-
|
|
127
|
-
### Debug Mode
|
|
128
|
-
|
|
129
|
-
Set `NODE_ENV=development` for additional debug output during extension loading.
|