@twin.org/node-core 0.0.2-next.24 → 0.0.2-next.26
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 +21 -7
- package/dist/cjs/index.cjs +389 -51
- package/dist/esm/index.mjs +385 -56
- package/dist/types/index.d.ts +4 -0
- package/dist/types/models/ICacheMetadata.d.ts +17 -0
- package/dist/types/models/IModuleProtocol.d.ts +18 -0
- package/dist/types/models/INodeEnvironmentVariables.d.ts +25 -0
- package/dist/types/models/IProtocolHandlerResult.d.ts +13 -0
- package/dist/types/models/moduleProtocol.d.ts +29 -0
- package/dist/types/node.d.ts +3 -2
- package/dist/types/utils.d.ts +67 -0
- package/docs/changelog.md +14 -0
- package/docs/detailed-guide.md +129 -0
- package/docs/reference/functions/createModuleImportUrl.md +21 -0
- package/docs/reference/functions/getExtensionsCacheDir.md +31 -0
- package/docs/reference/functions/handleHttpsProtocol.md +49 -0
- package/docs/reference/functions/handleNpmProtocol.md +31 -0
- package/docs/reference/functions/hashUrl.md +19 -0
- package/docs/reference/functions/isCacheExpired.md +31 -0
- package/docs/reference/functions/overrideModuleImport.md +8 -2
- package/docs/reference/functions/parseModuleProtocol.md +19 -0
- package/docs/reference/functions/resolvePackageEntryPoint.md +32 -0
- package/docs/reference/index.md +13 -0
- package/docs/reference/interfaces/ICacheMetadata.md +27 -0
- package/docs/reference/interfaces/IModuleProtocol.md +27 -0
- package/docs/reference/interfaces/INodeEnvironmentVariables.md +70 -0
- package/docs/reference/interfaces/IProtocolHandlerResult.md +19 -0
- package/docs/reference/type-aliases/ModuleProtocol.md +5 -0
- package/docs/reference/variables/ModuleProtocol.md +37 -0
- package/locales/en.json +11 -2
- package/package.json +7 -3
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import type { IModuleProtocol } from "./models/IModuleProtocol";
|
|
1
2
|
import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables";
|
|
3
|
+
import type { IProtocolHandlerResult } from "./models/IProtocolHandlerResult";
|
|
4
|
+
import { ModuleProtocol } from "./models/moduleProtocol";
|
|
2
5
|
import { NodeFeatures } from "./models/nodeFeatures";
|
|
3
6
|
/**
|
|
4
7
|
* Initialise the locales for the application.
|
|
@@ -52,3 +55,67 @@ export declare function loadJsonFile<T>(filename: string): Promise<T>;
|
|
|
52
55
|
* @returns The features that are enabled on the node.
|
|
53
56
|
*/
|
|
54
57
|
export declare function getFeatures(env: INodeEnvironmentVariables): NodeFeatures[];
|
|
58
|
+
/**
|
|
59
|
+
* Parse the protocol from a module name.
|
|
60
|
+
* @param moduleName The module name to parse.
|
|
61
|
+
* @returns The parsed protocol information.
|
|
62
|
+
*/
|
|
63
|
+
export declare function parseModuleProtocol(moduleName: string): IModuleProtocol;
|
|
64
|
+
/**
|
|
65
|
+
* Hash a URL to create a safe filename.
|
|
66
|
+
* @param url The URL to hash.
|
|
67
|
+
* @returns A hashed filename safe for the filesystem.
|
|
68
|
+
*/
|
|
69
|
+
export declare function hashUrl(url: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Get the extensions cache directory.
|
|
72
|
+
* @param executionDirectory The execution directory.
|
|
73
|
+
* @param protocol The protocol type for subdirectory organization.
|
|
74
|
+
* @param cacheDirectory The cache directory base path.
|
|
75
|
+
* @returns The cache directory path.
|
|
76
|
+
*/
|
|
77
|
+
export declare function getExtensionsCacheDir(executionDirectory: string, protocol: ModuleProtocol, cacheDirectory?: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* Handle the npm: protocol by installing the package if needed.
|
|
80
|
+
* @param packageName The npm package name (without npm: prefix).
|
|
81
|
+
* @param executionDirectory The execution directory.
|
|
82
|
+
* @param cacheDirectory The cache directory base path.
|
|
83
|
+
* @returns The resolved path to the installed module.
|
|
84
|
+
*/
|
|
85
|
+
export declare function handleNpmProtocol(packageName: string, executionDirectory: string, cacheDirectory?: string): Promise<IProtocolHandlerResult>;
|
|
86
|
+
/**
|
|
87
|
+
* Check if a cached file has expired based on TTL and force refresh settings.
|
|
88
|
+
* @param metadataPath Path to the cache metadata file.
|
|
89
|
+
* @param ttlHours Time to live in hours.
|
|
90
|
+
* @param forceRefresh Whether to force refresh regardless of TTL.
|
|
91
|
+
* @returns True if the cache is expired or should be refreshed.
|
|
92
|
+
*/
|
|
93
|
+
export declare function isCacheExpired(metadataPath: string, ttlHours: number, forceRefresh: boolean): Promise<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* Handle the https: protocol by downloading the module if needed.
|
|
96
|
+
* @param url The HTTPS URL to download from.
|
|
97
|
+
* @param executionDirectory The execution directory.
|
|
98
|
+
* @param maxSizeMb The maximum size in MB for the download.
|
|
99
|
+
* @param cacheDirectory The cache directory base path.
|
|
100
|
+
* @param ttlHours TTL in hours for cache expiration.
|
|
101
|
+
* @param forceRefresh Whether to force refresh the cache.
|
|
102
|
+
* @returns The resolved path to the downloaded module.
|
|
103
|
+
*/
|
|
104
|
+
export declare function handleHttpsProtocol(url: string, executionDirectory: string, maxSizeMb: number, cacheDirectory?: string, ttlHours?: number, forceRefresh?: boolean): Promise<IProtocolHandlerResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Resolve the main entry point from a package directory using Node.js resolution with fallback.
|
|
107
|
+
* Uses require.resolve() when possible for standard Node.js behavior, with manual fallback.
|
|
108
|
+
* @param packagePath The absolute path to the package directory.
|
|
109
|
+
* @param packageName The package name for require.resolve().
|
|
110
|
+
* @param fallback The fallback file name if no entry point is found.
|
|
111
|
+
* @returns The resolved entry point file name (relative to package directory).
|
|
112
|
+
*/
|
|
113
|
+
export declare function resolvePackageEntryPoint(packagePath: string, packageName: string, fallback?: string): Promise<string>;
|
|
114
|
+
/**
|
|
115
|
+
* Convert a file path to an import-compatible URL for cross-platform module loading.
|
|
116
|
+
* On Windows, adds the 'file://' protocol prefix required for dynamic imports.
|
|
117
|
+
* On other platforms, returns the path unchanged.
|
|
118
|
+
* @param filePath The absolute file path to convert.
|
|
119
|
+
* @returns A URL string compatible with dynamic import().
|
|
120
|
+
*/
|
|
121
|
+
export declare function createModuleImportUrl(filePath: string): string;
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @twin.org/node-core - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.26](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.25...node-core-v0.0.2-next.26) (2025-10-10)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* adding npm and https protocols to load extensions ([#45](https://github.com/twinfoundation/node/issues/45)) ([33940b7](https://github.com/twinfoundation/node/commit/33940b7e771a0c5af32c18d442deb26a8631fd02))
|
|
9
|
+
|
|
10
|
+
## [0.0.2-next.25](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.24...node-core-v0.0.2-next.25) (2025-10-09)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add validate-locales ([1a19dcb](https://github.com/twinfoundation/node/commit/1a19dcb005c2f0e3103e290db28c48a3464094cb))
|
|
16
|
+
|
|
3
17
|
## [0.0.2-next.24](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.23...node-core-v0.0.2-next.24) (2025-10-08)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# TWIN Node Core - Detailed Documentation
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
TWIN Node Core 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 Core supports dynamic extension loading from multiple sources:
|
|
10
|
+
|
|
11
|
+
### Local Files
|
|
12
|
+
|
|
13
|
+
Load extensions from your filesystem:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
TWIN_NODE_EXTENSIONS="./my-extension.mjs"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### NPM Packages
|
|
20
|
+
|
|
21
|
+
Automatically install and load npm packages:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
TWIN_NODE_EXTENSIONS="npm:@twin.org/package"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### HTTPS URLs
|
|
28
|
+
|
|
29
|
+
Download and cache remote extensions:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
TWIN_NODE_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_NODE_EXTENSIONS_CACHE_TTL_HOURS` - TTL for HTTPS extensions cache (default: 24)
|
|
73
|
+
- `TWIN_NODE_EXTENSIONS_FORCE_REFRESH` - Force refresh all cached extensions (default: false)
|
|
74
|
+
- `TWIN_NODE_EXTENSIONS_CACHE_DIRECTORY` - Custom cache directory (default: ".tmp")
|
|
75
|
+
|
|
76
|
+
### Security
|
|
77
|
+
|
|
78
|
+
- `TWIN_NODE_EXTENSIONS_MAX_SIZE_MB` - Maximum size for HTTPS downloads (default: 10)
|
|
79
|
+
- `TWIN_NODE_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_NODE_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_NODE_EXTENSIONS_FORCE_REFRESH=true` to force refresh
|
|
124
|
+
3. **Size limit exceeded**: Increase `TWIN_NODE_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.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Function: createModuleImportUrl()
|
|
2
|
+
|
|
3
|
+
> **createModuleImportUrl**(`filePath`): `string`
|
|
4
|
+
|
|
5
|
+
Convert a file path to an import-compatible URL for cross-platform module loading.
|
|
6
|
+
On Windows, adds the 'file://' protocol prefix required for dynamic imports.
|
|
7
|
+
On other platforms, returns the path unchanged.
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
### filePath
|
|
12
|
+
|
|
13
|
+
`string`
|
|
14
|
+
|
|
15
|
+
The absolute file path to convert.
|
|
16
|
+
|
|
17
|
+
## Returns
|
|
18
|
+
|
|
19
|
+
`string`
|
|
20
|
+
|
|
21
|
+
A URL string compatible with dynamic import().
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Function: getExtensionsCacheDir()
|
|
2
|
+
|
|
3
|
+
> **getExtensionsCacheDir**(`executionDirectory`, `protocol`, `cacheDirectory?`): `string`
|
|
4
|
+
|
|
5
|
+
Get the extensions cache directory.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### executionDirectory
|
|
10
|
+
|
|
11
|
+
`string`
|
|
12
|
+
|
|
13
|
+
The execution directory.
|
|
14
|
+
|
|
15
|
+
### protocol
|
|
16
|
+
|
|
17
|
+
[`ModuleProtocol`](../type-aliases/ModuleProtocol.md)
|
|
18
|
+
|
|
19
|
+
The protocol type for subdirectory organization.
|
|
20
|
+
|
|
21
|
+
### cacheDirectory?
|
|
22
|
+
|
|
23
|
+
`string`
|
|
24
|
+
|
|
25
|
+
The cache directory base path.
|
|
26
|
+
|
|
27
|
+
## Returns
|
|
28
|
+
|
|
29
|
+
`string`
|
|
30
|
+
|
|
31
|
+
The cache directory path.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Function: handleHttpsProtocol()
|
|
2
|
+
|
|
3
|
+
> **handleHttpsProtocol**(`url`, `executionDirectory`, `maxSizeMb`, `cacheDirectory?`, `ttlHours?`, `forceRefresh?`): `Promise`\<[`IProtocolHandlerResult`](../interfaces/IProtocolHandlerResult.md)\>
|
|
4
|
+
|
|
5
|
+
Handle the https: protocol by downloading the module if needed.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### url
|
|
10
|
+
|
|
11
|
+
`string`
|
|
12
|
+
|
|
13
|
+
The HTTPS URL to download from.
|
|
14
|
+
|
|
15
|
+
### executionDirectory
|
|
16
|
+
|
|
17
|
+
`string`
|
|
18
|
+
|
|
19
|
+
The execution directory.
|
|
20
|
+
|
|
21
|
+
### maxSizeMb
|
|
22
|
+
|
|
23
|
+
`number`
|
|
24
|
+
|
|
25
|
+
The maximum size in MB for the download.
|
|
26
|
+
|
|
27
|
+
### cacheDirectory?
|
|
28
|
+
|
|
29
|
+
`string`
|
|
30
|
+
|
|
31
|
+
The cache directory base path.
|
|
32
|
+
|
|
33
|
+
### ttlHours?
|
|
34
|
+
|
|
35
|
+
`number`
|
|
36
|
+
|
|
37
|
+
TTL in hours for cache expiration.
|
|
38
|
+
|
|
39
|
+
### forceRefresh?
|
|
40
|
+
|
|
41
|
+
`boolean`
|
|
42
|
+
|
|
43
|
+
Whether to force refresh the cache.
|
|
44
|
+
|
|
45
|
+
## Returns
|
|
46
|
+
|
|
47
|
+
`Promise`\<[`IProtocolHandlerResult`](../interfaces/IProtocolHandlerResult.md)\>
|
|
48
|
+
|
|
49
|
+
The resolved path to the downloaded module.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Function: handleNpmProtocol()
|
|
2
|
+
|
|
3
|
+
> **handleNpmProtocol**(`packageName`, `executionDirectory`, `cacheDirectory?`): `Promise`\<[`IProtocolHandlerResult`](../interfaces/IProtocolHandlerResult.md)\>
|
|
4
|
+
|
|
5
|
+
Handle the npm: protocol by installing the package if needed.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### packageName
|
|
10
|
+
|
|
11
|
+
`string`
|
|
12
|
+
|
|
13
|
+
The npm package name (without npm: prefix).
|
|
14
|
+
|
|
15
|
+
### executionDirectory
|
|
16
|
+
|
|
17
|
+
`string`
|
|
18
|
+
|
|
19
|
+
The execution directory.
|
|
20
|
+
|
|
21
|
+
### cacheDirectory?
|
|
22
|
+
|
|
23
|
+
`string`
|
|
24
|
+
|
|
25
|
+
The cache directory base path.
|
|
26
|
+
|
|
27
|
+
## Returns
|
|
28
|
+
|
|
29
|
+
`Promise`\<[`IProtocolHandlerResult`](../interfaces/IProtocolHandlerResult.md)\>
|
|
30
|
+
|
|
31
|
+
The resolved path to the installed module.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Function: hashUrl()
|
|
2
|
+
|
|
3
|
+
> **hashUrl**(`url`): `string`
|
|
4
|
+
|
|
5
|
+
Hash a URL to create a safe filename.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### url
|
|
10
|
+
|
|
11
|
+
`string`
|
|
12
|
+
|
|
13
|
+
The URL to hash.
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
`string`
|
|
18
|
+
|
|
19
|
+
A hashed filename safe for the filesystem.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Function: isCacheExpired()
|
|
2
|
+
|
|
3
|
+
> **isCacheExpired**(`metadataPath`, `ttlHours`, `forceRefresh`): `Promise`\<`boolean`\>
|
|
4
|
+
|
|
5
|
+
Check if a cached file has expired based on TTL and force refresh settings.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### metadataPath
|
|
10
|
+
|
|
11
|
+
`string`
|
|
12
|
+
|
|
13
|
+
Path to the cache metadata file.
|
|
14
|
+
|
|
15
|
+
### ttlHours
|
|
16
|
+
|
|
17
|
+
`number`
|
|
18
|
+
|
|
19
|
+
Time to live in hours.
|
|
20
|
+
|
|
21
|
+
### forceRefresh
|
|
22
|
+
|
|
23
|
+
`boolean`
|
|
24
|
+
|
|
25
|
+
Whether to force refresh regardless of TTL.
|
|
26
|
+
|
|
27
|
+
## Returns
|
|
28
|
+
|
|
29
|
+
`Promise`\<`boolean`\>
|
|
30
|
+
|
|
31
|
+
True if the cache is expired or should be refreshed.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Function: overrideModuleImport()
|
|
2
2
|
|
|
3
|
-
> **overrideModuleImport**(`executionDirectory`): `void`
|
|
3
|
+
> **overrideModuleImport**(`executionDirectory`, `envVars?`): `void`
|
|
4
4
|
|
|
5
|
-
Override module imports to
|
|
5
|
+
Override module imports to support protocol-based loading (npm:, https:) and local files.
|
|
6
6
|
|
|
7
7
|
## Parameters
|
|
8
8
|
|
|
@@ -12,6 +12,12 @@ Override module imports to use local files where possible.
|
|
|
12
12
|
|
|
13
13
|
The execution directory for resolving local module paths.
|
|
14
14
|
|
|
15
|
+
### envVars?
|
|
16
|
+
|
|
17
|
+
[`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md)
|
|
18
|
+
|
|
19
|
+
The environment variables containing extension configuration (optional, uses defaults if not provided).
|
|
20
|
+
|
|
15
21
|
## Returns
|
|
16
22
|
|
|
17
23
|
`void`
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Function: parseModuleProtocol()
|
|
2
|
+
|
|
3
|
+
> **parseModuleProtocol**(`moduleName`): [`IModuleProtocol`](../interfaces/IModuleProtocol.md)
|
|
4
|
+
|
|
5
|
+
Parse the protocol from a module name.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### moduleName
|
|
10
|
+
|
|
11
|
+
`string`
|
|
12
|
+
|
|
13
|
+
The module name to parse.
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
[`IModuleProtocol`](../interfaces/IModuleProtocol.md)
|
|
18
|
+
|
|
19
|
+
The parsed protocol information.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Function: resolvePackageEntryPoint()
|
|
2
|
+
|
|
3
|
+
> **resolvePackageEntryPoint**(`packagePath`, `packageName`, `fallback`): `Promise`\<`string`\>
|
|
4
|
+
|
|
5
|
+
Resolve the main entry point from a package directory using Node.js resolution with fallback.
|
|
6
|
+
Uses require.resolve() when possible for standard Node.js behavior, with manual fallback.
|
|
7
|
+
|
|
8
|
+
## Parameters
|
|
9
|
+
|
|
10
|
+
### packagePath
|
|
11
|
+
|
|
12
|
+
`string`
|
|
13
|
+
|
|
14
|
+
The absolute path to the package directory.
|
|
15
|
+
|
|
16
|
+
### packageName
|
|
17
|
+
|
|
18
|
+
`string`
|
|
19
|
+
|
|
20
|
+
The package name for require.resolve().
|
|
21
|
+
|
|
22
|
+
### fallback
|
|
23
|
+
|
|
24
|
+
`string` = `"index.js"`
|
|
25
|
+
|
|
26
|
+
The fallback file name if no entry point is found.
|
|
27
|
+
|
|
28
|
+
## Returns
|
|
29
|
+
|
|
30
|
+
`Promise`\<`string`\>
|
|
31
|
+
|
|
32
|
+
The resolved entry point file name (relative to package directory).
|
package/docs/reference/index.md
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## Interfaces
|
|
4
4
|
|
|
5
|
+
- [ICacheMetadata](interfaces/ICacheMetadata.md)
|
|
5
6
|
- [IEngineEnvironmentVariables](interfaces/IEngineEnvironmentVariables.md)
|
|
6
7
|
- [IEngineServerEnvironmentVariables](interfaces/IEngineServerEnvironmentVariables.md)
|
|
8
|
+
- [IModuleProtocol](interfaces/IModuleProtocol.md)
|
|
7
9
|
- [INodeEngineConfig](interfaces/INodeEngineConfig.md)
|
|
8
10
|
- [INodeEnvironmentVariables](interfaces/INodeEnvironmentVariables.md)
|
|
9
11
|
- [INodeOptions](interfaces/INodeOptions.md)
|
|
12
|
+
- [IProtocolHandlerResult](interfaces/IProtocolHandlerResult.md)
|
|
10
13
|
|
|
11
14
|
## Type Aliases
|
|
12
15
|
|
|
16
|
+
- [ModuleProtocol](type-aliases/ModuleProtocol.md)
|
|
13
17
|
- [NodeExtensionInitialiseMethod](type-aliases/NodeExtensionInitialiseMethod.md)
|
|
14
18
|
- [NodeExtensionInitialiseEngineMethod](type-aliases/NodeExtensionInitialiseEngineMethod.md)
|
|
15
19
|
- [NodeExtensionInitialiseEngineServerMethod](type-aliases/NodeExtensionInitialiseEngineServerMethod.md)
|
|
@@ -24,6 +28,7 @@
|
|
|
24
28
|
- [SYNCHRONISED\_STORAGE\_BLOB\_STORAGE\_ENCRYPTION\_KEY\_ID](variables/SYNCHRONISED_STORAGE_BLOB_STORAGE_ENCRYPTION_KEY_ID.md)
|
|
25
29
|
- [VC\_AUTHENTICATION\_VERIFICATION\_METHOD\_ID](variables/VC_AUTHENTICATION_VERIFICATION_METHOD_ID.md)
|
|
26
30
|
- [AUTH\_SIGNING\_KEY\_ID](variables/AUTH_SIGNING_KEY_ID.md)
|
|
31
|
+
- [ModuleProtocol](variables/ModuleProtocol.md)
|
|
27
32
|
- [NodeFeatures](variables/NodeFeatures.md)
|
|
28
33
|
|
|
29
34
|
## Functions
|
|
@@ -54,3 +59,11 @@
|
|
|
54
59
|
- [loadTextFile](functions/loadTextFile.md)
|
|
55
60
|
- [loadJsonFile](functions/loadJsonFile.md)
|
|
56
61
|
- [getFeatures](functions/getFeatures.md)
|
|
62
|
+
- [parseModuleProtocol](functions/parseModuleProtocol.md)
|
|
63
|
+
- [hashUrl](functions/hashUrl.md)
|
|
64
|
+
- [getExtensionsCacheDir](functions/getExtensionsCacheDir.md)
|
|
65
|
+
- [handleNpmProtocol](functions/handleNpmProtocol.md)
|
|
66
|
+
- [isCacheExpired](functions/isCacheExpired.md)
|
|
67
|
+
- [handleHttpsProtocol](functions/handleHttpsProtocol.md)
|
|
68
|
+
- [resolvePackageEntryPoint](functions/resolvePackageEntryPoint.md)
|
|
69
|
+
- [createModuleImportUrl](functions/createModuleImportUrl.md)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Interface: ICacheMetadata
|
|
2
|
+
|
|
3
|
+
Metadata for cached HTTPS extensions.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### downloadedAt
|
|
8
|
+
|
|
9
|
+
> **downloadedAt**: `number`
|
|
10
|
+
|
|
11
|
+
Timestamp when the file was downloaded.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### url
|
|
16
|
+
|
|
17
|
+
> **url**: `string`
|
|
18
|
+
|
|
19
|
+
Original URL of the cached file.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### size
|
|
24
|
+
|
|
25
|
+
> **size**: `number`
|
|
26
|
+
|
|
27
|
+
Size of the cached file in bytes.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Interface: IModuleProtocol
|
|
2
|
+
|
|
3
|
+
The parsed module protocol information.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### protocol
|
|
8
|
+
|
|
9
|
+
> **protocol**: [`ModuleProtocol`](../type-aliases/ModuleProtocol.md)
|
|
10
|
+
|
|
11
|
+
The protocol type.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### identifier
|
|
16
|
+
|
|
17
|
+
> **identifier**: `string`
|
|
18
|
+
|
|
19
|
+
The identifier after the protocol (or the original if no protocol).
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### original
|
|
24
|
+
|
|
25
|
+
> **original**: `string`
|
|
26
|
+
|
|
27
|
+
The original module string.
|
|
@@ -1861,3 +1861,73 @@ admin@node
|
|
|
1861
1861
|
> `optional` **password**: `string`
|
|
1862
1862
|
|
|
1863
1863
|
If the node-user feature is enabled, this will be the password of the user, if empty it will be randomly generated.
|
|
1864
|
+
|
|
1865
|
+
***
|
|
1866
|
+
|
|
1867
|
+
### extensionsMaxSizeMb?
|
|
1868
|
+
|
|
1869
|
+
> `optional` **extensionsMaxSizeMb**: `number`
|
|
1870
|
+
|
|
1871
|
+
Maximum size in MB for HTTPS extensions downloads.
|
|
1872
|
+
|
|
1873
|
+
#### Default
|
|
1874
|
+
|
|
1875
|
+
```ts
|
|
1876
|
+
10
|
|
1877
|
+
```
|
|
1878
|
+
|
|
1879
|
+
***
|
|
1880
|
+
|
|
1881
|
+
### extensionsClearCache?
|
|
1882
|
+
|
|
1883
|
+
> `optional` **extensionsClearCache**: `boolean`
|
|
1884
|
+
|
|
1885
|
+
Whether to clear the extensions cache on startup.
|
|
1886
|
+
|
|
1887
|
+
#### Default
|
|
1888
|
+
|
|
1889
|
+
```ts
|
|
1890
|
+
false
|
|
1891
|
+
```
|
|
1892
|
+
|
|
1893
|
+
***
|
|
1894
|
+
|
|
1895
|
+
### extensionsCacheDirectory?
|
|
1896
|
+
|
|
1897
|
+
> `optional` **extensionsCacheDirectory**: `string`
|
|
1898
|
+
|
|
1899
|
+
Custom directory for extensions cache storage.
|
|
1900
|
+
|
|
1901
|
+
#### Default
|
|
1902
|
+
|
|
1903
|
+
```ts
|
|
1904
|
+
".tmp"
|
|
1905
|
+
```
|
|
1906
|
+
|
|
1907
|
+
***
|
|
1908
|
+
|
|
1909
|
+
### extensionsCacheTtlHours?
|
|
1910
|
+
|
|
1911
|
+
> `optional` **extensionsCacheTtlHours**: `number`
|
|
1912
|
+
|
|
1913
|
+
TTL in hours for HTTPS extensions cache.
|
|
1914
|
+
|
|
1915
|
+
#### Default
|
|
1916
|
+
|
|
1917
|
+
```ts
|
|
1918
|
+
24
|
|
1919
|
+
```
|
|
1920
|
+
|
|
1921
|
+
***
|
|
1922
|
+
|
|
1923
|
+
### extensionsForceRefresh?
|
|
1924
|
+
|
|
1925
|
+
> `optional` **extensionsForceRefresh**: `boolean`
|
|
1926
|
+
|
|
1927
|
+
Force refresh of all cached extensions.
|
|
1928
|
+
|
|
1929
|
+
#### Default
|
|
1930
|
+
|
|
1931
|
+
```ts
|
|
1932
|
+
false
|
|
1933
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Interface: IProtocolHandlerResult
|
|
2
|
+
|
|
3
|
+
The result from a protocol handler.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### resolvedPath
|
|
8
|
+
|
|
9
|
+
> **resolvedPath**: `string`
|
|
10
|
+
|
|
11
|
+
The resolved path to the module file.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### cached
|
|
16
|
+
|
|
17
|
+
> **cached**: `boolean`
|
|
18
|
+
|
|
19
|
+
Whether the module was cached.
|