@twin.org/node-core 0.0.1-next.2 → 0.0.1-next.3
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/dist/cjs/index.cjs +7 -14
- package/dist/esm/index.mjs +7 -14
- package/dist/types/index.d.ts +1 -0
- package/dist/types/models/IRunOptions.d.ts +45 -0
- package/dist/types/node.d.ts +3 -17
- package/dist/types/server.d.ts +2 -2
- package/docs/changelog.md +9 -2
- package/docs/reference/functions/run.md +2 -42
- package/docs/reference/functions/start.md +2 -2
- package/docs/reference/index.md +1 -0
- package/docs/reference/interfaces/IRunOptions.md +92 -0
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -494,10 +494,10 @@ async function bootstrapAuth(engineCore, context, envVars, features) {
|
|
|
494
494
|
* @param envVars The environment variables.
|
|
495
495
|
* @param openApiSpecFile Path to the OpenAPI spec file.
|
|
496
496
|
* @param stateStorage The state storage.
|
|
497
|
-
* @param
|
|
497
|
+
* @param customConfig Extends the engine configuration with any additional custom configuration.
|
|
498
498
|
* @returns The engine server.
|
|
499
499
|
*/
|
|
500
|
-
async function start(serverInfo, envVars, openApiSpecFile, stateStorage,
|
|
500
|
+
async function start(serverInfo, envVars, openApiSpecFile, stateStorage, customConfig) {
|
|
501
501
|
envVars.storageFileRoot ??= "";
|
|
502
502
|
if ((envVars.entityStorageConnectorType === engineTypes.EntityStorageConnectorType.File ||
|
|
503
503
|
envVars.blobStorageConnectorType === engineTypes.BlobStorageConnectorType.File ||
|
|
@@ -508,8 +508,8 @@ async function start(serverInfo, envVars, openApiSpecFile, stateStorage, extendC
|
|
|
508
508
|
// Build the engine configuration from the environment variables.
|
|
509
509
|
const engineConfig = engine.buildEngineConfiguration(envVars);
|
|
510
510
|
// Extend the engine configuration with a custom type.
|
|
511
|
-
if (core.Is.function(
|
|
512
|
-
await
|
|
511
|
+
if (core.Is.function(customConfig)) {
|
|
512
|
+
await customConfig(engineConfig);
|
|
513
513
|
}
|
|
514
514
|
// Build the server configuration from the environment variables.
|
|
515
515
|
const serverConfig = engineServer.buildEngineServerConfiguration(envVars, engineConfig, serverInfo, openApiSpecFile);
|
|
@@ -539,21 +539,14 @@ async function start(serverInfo, envVars, openApiSpecFile, stateStorage, extendC
|
|
|
539
539
|
/* eslint-disable no-console */
|
|
540
540
|
/**
|
|
541
541
|
* Run the TWIN Node server.
|
|
542
|
-
* @param options Optional options for the server.
|
|
543
|
-
* @param options.serverName Optional name of the server, defaults to "TWIN Node Server".
|
|
544
|
-
* @param options.serverVersion Optional version of the server, defaults to current version.
|
|
545
|
-
* @param options.envFilenames Additional environment variable filenames to load, defaults to .env.
|
|
546
|
-
* @param options.envPrefix Optional prefix for environment variables, defaults to "TWIN_NODE_".
|
|
547
|
-
* @param options.executionDirectory Optional directory to override the execution location, defaults to process directory.
|
|
548
|
-
* @param options.localesDirectory Optional directory to override the locales directory, defaults to the locales directory.
|
|
549
|
-
* @param options.openApiSpecFile Optional path to the OpenAPI spec file, defaults to docs/open-api/spec.json.
|
|
542
|
+
* @param options Optional configuration options for running the server.
|
|
550
543
|
* @returns A promise that resolves when the server is started.
|
|
551
544
|
*/
|
|
552
545
|
async function run(options) {
|
|
553
546
|
try {
|
|
554
547
|
const serverInfo = {
|
|
555
548
|
name: options?.serverName ?? "TWIN Node Server",
|
|
556
|
-
version: options?.serverVersion ?? "0.0.1-next.
|
|
549
|
+
version: options?.serverVersion ?? "0.0.1-next.3" // x-release-please-version
|
|
557
550
|
};
|
|
558
551
|
console.log(`\u001B[4m🌩️ ${serverInfo.name} v${serverInfo.version}\u001B[24m\n`);
|
|
559
552
|
const executionDirectory = options?.executionDirectory ?? getExecutionDirectory();
|
|
@@ -580,7 +573,7 @@ async function run(options) {
|
|
|
580
573
|
console.info("Environment Prefix:", envPrefix);
|
|
581
574
|
const envVars = core.EnvHelper.envToJson(process.env, envPrefix);
|
|
582
575
|
console.info();
|
|
583
|
-
const startResult = await start(serverInfo, envVars, options?.openApiSpecFile);
|
|
576
|
+
const startResult = await start(serverInfo, envVars, options?.openApiSpecFile, options.stateStorage, options.customConfig);
|
|
584
577
|
if (!core.Is.empty(startResult)) {
|
|
585
578
|
for (const signal of ["SIGHUP", "SIGINT", "SIGTERM"]) {
|
|
586
579
|
process.on(signal, async () => {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -473,10 +473,10 @@ async function bootstrapAuth(engineCore, context, envVars, features) {
|
|
|
473
473
|
* @param envVars The environment variables.
|
|
474
474
|
* @param openApiSpecFile Path to the OpenAPI spec file.
|
|
475
475
|
* @param stateStorage The state storage.
|
|
476
|
-
* @param
|
|
476
|
+
* @param customConfig Extends the engine configuration with any additional custom configuration.
|
|
477
477
|
* @returns The engine server.
|
|
478
478
|
*/
|
|
479
|
-
async function start(serverInfo, envVars, openApiSpecFile, stateStorage,
|
|
479
|
+
async function start(serverInfo, envVars, openApiSpecFile, stateStorage, customConfig) {
|
|
480
480
|
envVars.storageFileRoot ??= "";
|
|
481
481
|
if ((envVars.entityStorageConnectorType === EntityStorageConnectorType.File ||
|
|
482
482
|
envVars.blobStorageConnectorType === BlobStorageConnectorType.File ||
|
|
@@ -487,8 +487,8 @@ async function start(serverInfo, envVars, openApiSpecFile, stateStorage, extendC
|
|
|
487
487
|
// Build the engine configuration from the environment variables.
|
|
488
488
|
const engineConfig = buildEngineConfiguration(envVars);
|
|
489
489
|
// Extend the engine configuration with a custom type.
|
|
490
|
-
if (Is.function(
|
|
491
|
-
await
|
|
490
|
+
if (Is.function(customConfig)) {
|
|
491
|
+
await customConfig(engineConfig);
|
|
492
492
|
}
|
|
493
493
|
// Build the server configuration from the environment variables.
|
|
494
494
|
const serverConfig = buildEngineServerConfiguration(envVars, engineConfig, serverInfo, openApiSpecFile);
|
|
@@ -518,21 +518,14 @@ async function start(serverInfo, envVars, openApiSpecFile, stateStorage, extendC
|
|
|
518
518
|
/* eslint-disable no-console */
|
|
519
519
|
/**
|
|
520
520
|
* Run the TWIN Node server.
|
|
521
|
-
* @param options Optional options for the server.
|
|
522
|
-
* @param options.serverName Optional name of the server, defaults to "TWIN Node Server".
|
|
523
|
-
* @param options.serverVersion Optional version of the server, defaults to current version.
|
|
524
|
-
* @param options.envFilenames Additional environment variable filenames to load, defaults to .env.
|
|
525
|
-
* @param options.envPrefix Optional prefix for environment variables, defaults to "TWIN_NODE_".
|
|
526
|
-
* @param options.executionDirectory Optional directory to override the execution location, defaults to process directory.
|
|
527
|
-
* @param options.localesDirectory Optional directory to override the locales directory, defaults to the locales directory.
|
|
528
|
-
* @param options.openApiSpecFile Optional path to the OpenAPI spec file, defaults to docs/open-api/spec.json.
|
|
521
|
+
* @param options Optional configuration options for running the server.
|
|
529
522
|
* @returns A promise that resolves when the server is started.
|
|
530
523
|
*/
|
|
531
524
|
async function run(options) {
|
|
532
525
|
try {
|
|
533
526
|
const serverInfo = {
|
|
534
527
|
name: options?.serverName ?? "TWIN Node Server",
|
|
535
|
-
version: options?.serverVersion ?? "0.0.1-next.
|
|
528
|
+
version: options?.serverVersion ?? "0.0.1-next.3" // x-release-please-version
|
|
536
529
|
};
|
|
537
530
|
console.log(`\u001B[4m🌩️ ${serverInfo.name} v${serverInfo.version}\u001B[24m\n`);
|
|
538
531
|
const executionDirectory = options?.executionDirectory ?? getExecutionDirectory();
|
|
@@ -559,7 +552,7 @@ async function run(options) {
|
|
|
559
552
|
console.info("Environment Prefix:", envPrefix);
|
|
560
553
|
const envVars = EnvHelper.envToJson(process.env, envPrefix);
|
|
561
554
|
console.info();
|
|
562
|
-
const startResult = await start(serverInfo, envVars, options?.openApiSpecFile);
|
|
555
|
+
const startResult = await start(serverInfo, envVars, options?.openApiSpecFile, options.stateStorage, options.customConfig);
|
|
563
556
|
if (!Is.empty(startResult)) {
|
|
564
557
|
for (const signal of ["SIGHUP", "SIGINT", "SIGTERM"]) {
|
|
565
558
|
process.on(signal, async () => {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { IEngineStateStorage } from "@twin.org/engine-models";
|
|
2
|
+
import type { IEngineConfig } from "@twin.org/engine-types";
|
|
3
|
+
/**
|
|
4
|
+
* The options when running the node.
|
|
5
|
+
*/
|
|
6
|
+
export interface IRunOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the server, defaults to "TWIN Node Server".
|
|
9
|
+
* @default "TWIN Node Server"
|
|
10
|
+
*/
|
|
11
|
+
serverName?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The version of the server, defaults to the current version.
|
|
14
|
+
*/
|
|
15
|
+
serverVersion?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Additional environment variable filenames to load, defaults to .env.
|
|
18
|
+
*/
|
|
19
|
+
envFilenames?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* The prefix for environment variables, defaults to "TWIN_NODE_".
|
|
22
|
+
*/
|
|
23
|
+
envPrefix?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The directory to override the execution location, defaults to process directory.
|
|
26
|
+
*/
|
|
27
|
+
executionDirectory?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The directory to override the locales directory, defaults to the locales directory.
|
|
30
|
+
*/
|
|
31
|
+
localesDirectory?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The path to the OpenAPI spec file, defaults to docs/open-api/spec.json.
|
|
34
|
+
*/
|
|
35
|
+
openApiSpecFile?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Method to extend the engine configuration with any additional custom configuration.
|
|
38
|
+
*/
|
|
39
|
+
customConfig?: (config: IEngineConfig) => Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* The state storage to use for the engine.
|
|
42
|
+
* If not provided, a default file-based state storage will be used.
|
|
43
|
+
*/
|
|
44
|
+
stateStorage?: IEngineStateStorage;
|
|
45
|
+
}
|
package/dist/types/node.d.ts
CHANGED
|
@@ -1,21 +1,7 @@
|
|
|
1
|
+
import type { IRunOptions } from "./models/IRunOptions";
|
|
1
2
|
/**
|
|
2
3
|
* Run the TWIN Node server.
|
|
3
|
-
* @param options Optional options for the server.
|
|
4
|
-
* @param options.serverName Optional name of the server, defaults to "TWIN Node Server".
|
|
5
|
-
* @param options.serverVersion Optional version of the server, defaults to current version.
|
|
6
|
-
* @param options.envFilenames Additional environment variable filenames to load, defaults to .env.
|
|
7
|
-
* @param options.envPrefix Optional prefix for environment variables, defaults to "TWIN_NODE_".
|
|
8
|
-
* @param options.executionDirectory Optional directory to override the execution location, defaults to process directory.
|
|
9
|
-
* @param options.localesDirectory Optional directory to override the locales directory, defaults to the locales directory.
|
|
10
|
-
* @param options.openApiSpecFile Optional path to the OpenAPI spec file, defaults to docs/open-api/spec.json.
|
|
4
|
+
* @param options Optional configuration options for running the server.
|
|
11
5
|
* @returns A promise that resolves when the server is started.
|
|
12
6
|
*/
|
|
13
|
-
export declare function run(options?:
|
|
14
|
-
serverName?: string;
|
|
15
|
-
serverVersion?: string;
|
|
16
|
-
envFilenames?: string[];
|
|
17
|
-
envPrefix?: string;
|
|
18
|
-
executionDirectory?: string;
|
|
19
|
-
localesDirectory?: string;
|
|
20
|
-
openApiSpecFile?: string;
|
|
21
|
-
}): Promise<void>;
|
|
7
|
+
export declare function run(options?: IRunOptions): Promise<void>;
|
package/dist/types/server.d.ts
CHANGED
|
@@ -12,10 +12,10 @@ import type { INodeVariables } from "./models/INodeVariables";
|
|
|
12
12
|
* @param envVars The environment variables.
|
|
13
13
|
* @param openApiSpecFile Path to the OpenAPI spec file.
|
|
14
14
|
* @param stateStorage The state storage.
|
|
15
|
-
* @param
|
|
15
|
+
* @param customConfig Extends the engine configuration with any additional custom configuration.
|
|
16
16
|
* @returns The engine server.
|
|
17
17
|
*/
|
|
18
|
-
export declare function start(serverInfo: IServerInfo, envVars: INodeVariables, openApiSpecFile?: string, stateStorage?: IEngineStateStorage,
|
|
18
|
+
export declare function start(serverInfo: IServerInfo, envVars: INodeVariables, openApiSpecFile?: string, stateStorage?: IEngineStateStorage, customConfig?: (config: IEngineConfig) => Promise<void>): Promise<{
|
|
19
19
|
engine: Engine<IEngineServerConfig, INodeState>;
|
|
20
20
|
server: EngineServer;
|
|
21
21
|
} | undefined>;
|
package/docs/changelog.md
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.0.1-next.
|
|
3
|
+
## [0.0.1-next.3](https://github.com/twinfoundation/node/compare/node-core-v0.0.1-next.2...node-core-v0.0.1-next.3) (2025-05-27)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* additional run options ([c35e5bb](https://github.com/twinfoundation/node/commit/c35e5bbb8a80fe6a36628d41f64585b3723d9ad7))
|
|
9
|
+
* node app use JavaScript ([14fe08c](https://github.com/twinfoundation/node/commit/14fe08cb760dd885a5dac9056a4d5dbc3d61df64))
|
|
4
10
|
|
|
11
|
+
## [0.0.1-next.2](https://github.com/twinfoundation/node/compare/node-core-v0.0.1-next.1...node-core-v0.0.1-next.2) (2025-05-27)
|
|
5
12
|
|
|
6
13
|
### Features
|
|
7
14
|
|
|
8
|
-
|
|
15
|
+
- initial commit ([522f1e5](https://github.com/twinfoundation/node/commit/522f1e515348f9b1dd1eeb3170b1249e2b0b5371))
|
|
@@ -8,49 +8,9 @@ Run the TWIN Node server.
|
|
|
8
8
|
|
|
9
9
|
### options?
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
[`IRunOptions`](../interfaces/IRunOptions.md)
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`string`
|
|
16
|
-
|
|
17
|
-
Optional name of the server, defaults to "TWIN Node Server".
|
|
18
|
-
|
|
19
|
-
#### serverVersion?
|
|
20
|
-
|
|
21
|
-
`string`
|
|
22
|
-
|
|
23
|
-
Optional version of the server, defaults to current version.
|
|
24
|
-
|
|
25
|
-
#### envFilenames?
|
|
26
|
-
|
|
27
|
-
`string`[]
|
|
28
|
-
|
|
29
|
-
Additional environment variable filenames to load, defaults to .env.
|
|
30
|
-
|
|
31
|
-
#### envPrefix?
|
|
32
|
-
|
|
33
|
-
`string`
|
|
34
|
-
|
|
35
|
-
Optional prefix for environment variables, defaults to "TWIN_NODE_".
|
|
36
|
-
|
|
37
|
-
#### executionDirectory?
|
|
38
|
-
|
|
39
|
-
`string`
|
|
40
|
-
|
|
41
|
-
Optional directory to override the execution location, defaults to process directory.
|
|
42
|
-
|
|
43
|
-
#### localesDirectory?
|
|
44
|
-
|
|
45
|
-
`string`
|
|
46
|
-
|
|
47
|
-
Optional directory to override the locales directory, defaults to the locales directory.
|
|
48
|
-
|
|
49
|
-
#### openApiSpecFile?
|
|
50
|
-
|
|
51
|
-
`string`
|
|
52
|
-
|
|
53
|
-
Optional path to the OpenAPI spec file, defaults to docs/open-api/spec.json.
|
|
13
|
+
Optional configuration options for running the server.
|
|
54
14
|
|
|
55
15
|
## Returns
|
|
56
16
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Function: start()
|
|
2
2
|
|
|
3
|
-
> **start**(`serverInfo`, `envVars`, `openApiSpecFile?`, `stateStorage?`, `
|
|
3
|
+
> **start**(`serverInfo`, `envVars`, `openApiSpecFile?`, `stateStorage?`, `customConfig?`): `Promise`\<`undefined` \| \{ `engine`: `Engine`\<`IEngineServerConfig`, [`INodeState`](../interfaces/INodeState.md)\>; `server`: `EngineServer`; \}\>
|
|
4
4
|
|
|
5
5
|
Start the engine server.
|
|
6
6
|
|
|
@@ -30,7 +30,7 @@ Path to the OpenAPI spec file.
|
|
|
30
30
|
|
|
31
31
|
The state storage.
|
|
32
32
|
|
|
33
|
-
###
|
|
33
|
+
### customConfig?
|
|
34
34
|
|
|
35
35
|
(`config`) => `Promise`\<`void`\>
|
|
36
36
|
|
package/docs/reference/index.md
CHANGED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Interface: IRunOptions
|
|
2
|
+
|
|
3
|
+
The options when running the node.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### serverName?
|
|
8
|
+
|
|
9
|
+
> `optional` **serverName**: `string`
|
|
10
|
+
|
|
11
|
+
The name of the server, defaults to "TWIN Node Server".
|
|
12
|
+
|
|
13
|
+
#### Default
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
"TWIN Node Server"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### serverVersion?
|
|
22
|
+
|
|
23
|
+
> `optional` **serverVersion**: `string`
|
|
24
|
+
|
|
25
|
+
The version of the server, defaults to the current version.
|
|
26
|
+
|
|
27
|
+
***
|
|
28
|
+
|
|
29
|
+
### envFilenames?
|
|
30
|
+
|
|
31
|
+
> `optional` **envFilenames**: `string`[]
|
|
32
|
+
|
|
33
|
+
Additional environment variable filenames to load, defaults to .env.
|
|
34
|
+
|
|
35
|
+
***
|
|
36
|
+
|
|
37
|
+
### envPrefix?
|
|
38
|
+
|
|
39
|
+
> `optional` **envPrefix**: `string`
|
|
40
|
+
|
|
41
|
+
The prefix for environment variables, defaults to "TWIN_NODE_".
|
|
42
|
+
|
|
43
|
+
***
|
|
44
|
+
|
|
45
|
+
### executionDirectory?
|
|
46
|
+
|
|
47
|
+
> `optional` **executionDirectory**: `string`
|
|
48
|
+
|
|
49
|
+
The directory to override the execution location, defaults to process directory.
|
|
50
|
+
|
|
51
|
+
***
|
|
52
|
+
|
|
53
|
+
### localesDirectory?
|
|
54
|
+
|
|
55
|
+
> `optional` **localesDirectory**: `string`
|
|
56
|
+
|
|
57
|
+
The directory to override the locales directory, defaults to the locales directory.
|
|
58
|
+
|
|
59
|
+
***
|
|
60
|
+
|
|
61
|
+
### openApiSpecFile?
|
|
62
|
+
|
|
63
|
+
> `optional` **openApiSpecFile**: `string`
|
|
64
|
+
|
|
65
|
+
The path to the OpenAPI spec file, defaults to docs/open-api/spec.json.
|
|
66
|
+
|
|
67
|
+
***
|
|
68
|
+
|
|
69
|
+
### customConfig()?
|
|
70
|
+
|
|
71
|
+
> `optional` **customConfig**: (`config`) => `Promise`\<`void`\>
|
|
72
|
+
|
|
73
|
+
Method to extend the engine configuration with any additional custom configuration.
|
|
74
|
+
|
|
75
|
+
#### Parameters
|
|
76
|
+
|
|
77
|
+
##### config
|
|
78
|
+
|
|
79
|
+
`IEngineConfig`
|
|
80
|
+
|
|
81
|
+
#### Returns
|
|
82
|
+
|
|
83
|
+
`Promise`\<`void`\>
|
|
84
|
+
|
|
85
|
+
***
|
|
86
|
+
|
|
87
|
+
### stateStorage?
|
|
88
|
+
|
|
89
|
+
> `optional` **stateStorage**: `IEngineStateStorage`\<`IEngineState`\>
|
|
90
|
+
|
|
91
|
+
The state storage to use for the engine.
|
|
92
|
+
If not provided, a default file-based state storage will be used.
|