@twin.org/node-core 0.0.2-next.6 → 0.0.2-next.8
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 +80 -8
- package/dist/esm/index.mjs +80 -10
- package/dist/types/models/IEngineEnvironmentVariables.d.ts +9 -0
- package/dist/types/node.d.ts +5 -0
- package/dist/types/utils.d.ts +6 -0
- package/docs/changelog.md +16 -0
- package/docs/reference/functions/loadTextFile.md +19 -0
- package/docs/reference/functions/overrideModuleImport.md +17 -0
- package/docs/reference/index.md +2 -0
- package/docs/reference/interfaces/IEngineEnvironmentVariables.md +17 -0
- package/docs/reference/interfaces/INodeEnvironmentVariables.md +25 -0
- package/package.json +3 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -12,6 +12,7 @@ var walletModels = require('@twin.org/wallet-models');
|
|
|
12
12
|
var promises = require('node:fs/promises');
|
|
13
13
|
var path = require('node:path');
|
|
14
14
|
var engineServer = require('@twin.org/engine-server');
|
|
15
|
+
var modules = require('@twin.org/modules');
|
|
15
16
|
var dotenv = require('dotenv');
|
|
16
17
|
var engine = require('@twin.org/engine');
|
|
17
18
|
var engineCore = require('@twin.org/engine-core');
|
|
@@ -96,13 +97,21 @@ async function fileExists(filename) {
|
|
|
96
97
|
return false;
|
|
97
98
|
}
|
|
98
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Load the text file.
|
|
102
|
+
* @param filename The filename of the text file to load.
|
|
103
|
+
* @returns The contents of the text file if it could not be loaded.
|
|
104
|
+
*/
|
|
105
|
+
async function loadTextFile(filename) {
|
|
106
|
+
return promises.readFile(filename, "utf8");
|
|
107
|
+
}
|
|
99
108
|
/**
|
|
100
109
|
* Load the JSON file.
|
|
101
110
|
* @param filename The filename of the JSON file to load.
|
|
102
111
|
* @returns The contents of the JSON file or null if it could not be loaded.
|
|
103
112
|
*/
|
|
104
113
|
async function loadJsonFile(filename) {
|
|
105
|
-
const content = await
|
|
114
|
+
const content = await loadTextFile(filename);
|
|
106
115
|
return JSON.parse(content);
|
|
107
116
|
}
|
|
108
117
|
/**
|
|
@@ -591,6 +600,7 @@ function buildEngineConfiguration(envVars) {
|
|
|
591
600
|
configureTaskScheduler(coreConfig, envVars);
|
|
592
601
|
configureSynchronisedStorage(coreConfig, envVars);
|
|
593
602
|
configureFederatedCatalogue(coreConfig, envVars);
|
|
603
|
+
configureDataSpaceConnector(coreConfig, envVars);
|
|
594
604
|
return coreConfig;
|
|
595
605
|
}
|
|
596
606
|
/**
|
|
@@ -1442,8 +1452,7 @@ function configureSynchronisedStorage(coreConfig, envVars) {
|
|
|
1442
1452
|
* @param envVars The environment variables.
|
|
1443
1453
|
*/
|
|
1444
1454
|
function configureFederatedCatalogue(coreConfig, envVars) {
|
|
1445
|
-
if (core.
|
|
1446
|
-
(core.Coerce.boolean(envVars.federatedCatalogueEnabled) ?? false)) {
|
|
1455
|
+
if (core.Coerce.boolean(envVars.federatedCatalogueEnabled) ?? false) {
|
|
1447
1456
|
coreConfig.types.federatedCatalogueComponent ??= [];
|
|
1448
1457
|
coreConfig.types.federatedCatalogueComponent.push({
|
|
1449
1458
|
type: engineTypes.FederatedCatalogueComponentType.Service,
|
|
@@ -1456,6 +1465,26 @@ function configureFederatedCatalogue(coreConfig, envVars) {
|
|
|
1456
1465
|
});
|
|
1457
1466
|
}
|
|
1458
1467
|
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Configures the data space connector.
|
|
1470
|
+
* @param coreConfig The core config.
|
|
1471
|
+
* @param envVars The environment variables.
|
|
1472
|
+
*/
|
|
1473
|
+
function configureDataSpaceConnector(coreConfig, envVars) {
|
|
1474
|
+
if (core.Coerce.boolean(envVars.dataSpaceConnectorEnabled) ?? false) {
|
|
1475
|
+
coreConfig.types.dataSpaceConnectorComponent ??= [];
|
|
1476
|
+
coreConfig.types.dataSpaceConnectorComponent.push({
|
|
1477
|
+
type: engineTypes.DataSpaceConnectorComponentType.Service,
|
|
1478
|
+
options: {
|
|
1479
|
+
config: {
|
|
1480
|
+
dataSpaceConnectorAppDescriptors: core.Is.arrayValue(envVars.dataSpaceConnectorApps)
|
|
1481
|
+
? envVars.dataSpaceConnectorApps
|
|
1482
|
+
: undefined
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1459
1488
|
/**
|
|
1460
1489
|
* Configures the DLT.
|
|
1461
1490
|
* @param coreConfig The core config.
|
|
@@ -1699,7 +1728,7 @@ async function run(nodeOptions) {
|
|
|
1699
1728
|
nodeOptions ??= {};
|
|
1700
1729
|
const serverInfo = {
|
|
1701
1730
|
name: nodeOptions?.serverName ?? "TWIN Node Server",
|
|
1702
|
-
version: nodeOptions?.serverVersion ?? "0.0.2-next.
|
|
1731
|
+
version: nodeOptions?.serverVersion ?? "0.0.2-next.8" // x-release-please-version
|
|
1703
1732
|
};
|
|
1704
1733
|
console.log(`\u001B[4m🌩️ ${serverInfo.name} v${serverInfo.version}\u001B[24m\n`);
|
|
1705
1734
|
if (!core.Is.stringValue(nodeOptions?.executionDirectory)) {
|
|
@@ -1729,6 +1758,7 @@ async function run(nodeOptions) {
|
|
|
1729
1758
|
}
|
|
1730
1759
|
nodeOptions.envPrefix ??= "TWIN_NODE_";
|
|
1731
1760
|
console.info("Environment Prefix:", nodeOptions.envPrefix);
|
|
1761
|
+
overrideModuleImport(nodeOptions.executionDirectory ?? "");
|
|
1732
1762
|
const { engineServerConfig, nodeEnvVars: envVars } = await buildConfiguration(process.env, nodeOptions, serverInfo);
|
|
1733
1763
|
console.info();
|
|
1734
1764
|
const startResult = await start(nodeOptions, engineServerConfig, envVars);
|
|
@@ -1781,12 +1811,18 @@ async function buildConfiguration(processEnv, options, serverInfo) {
|
|
|
1781
1811
|
// Expand any environment variables that use the @file: syntax
|
|
1782
1812
|
const keys = Object.keys(envVars);
|
|
1783
1813
|
for (const key of keys) {
|
|
1784
|
-
if (core.Is.stringValue(envVars[key]) &&
|
|
1814
|
+
if (core.Is.stringValue(envVars[key]) &&
|
|
1815
|
+
(envVars[key].startsWith("@text:") || envVars[key].startsWith("@json:"))) {
|
|
1785
1816
|
const filePath = envVars[key].slice(6).trim();
|
|
1786
1817
|
const embeddedFile = path.resolve(path.join(options.executionDirectory ?? "", filePath));
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1818
|
+
if (envVars[key].startsWith("@text:")) {
|
|
1819
|
+
console.info(`Expanding Environment Variable: ${key} from text file: ${embeddedFile}`);
|
|
1820
|
+
envVars[key] = await loadTextFile(embeddedFile);
|
|
1821
|
+
}
|
|
1822
|
+
else if (envVars[key].startsWith("@json:")) {
|
|
1823
|
+
console.info(`Expanding Environment Variable: ${key} from JSON file: ${embeddedFile}`);
|
|
1824
|
+
envVars[key] = await loadJsonFile(embeddedFile);
|
|
1825
|
+
}
|
|
1790
1826
|
}
|
|
1791
1827
|
}
|
|
1792
1828
|
// Extend the environment variables with any additional custom configuration.
|
|
@@ -1817,6 +1853,40 @@ async function buildConfiguration(processEnv, options, serverInfo) {
|
|
|
1817
1853
|
}
|
|
1818
1854
|
return { engineServerConfig, nodeEnvVars: envVars };
|
|
1819
1855
|
}
|
|
1856
|
+
/**
|
|
1857
|
+
* Override module imports to use local files where possible.
|
|
1858
|
+
* @param executionDirectory The execution directory for resolving local module paths.
|
|
1859
|
+
*/
|
|
1860
|
+
function overrideModuleImport(executionDirectory) {
|
|
1861
|
+
modules.ModuleHelper.overrideImport(async (moduleName) => {
|
|
1862
|
+
// If the module path for example when dynamically loading
|
|
1863
|
+
// modules looks like a local file then we try to resolve
|
|
1864
|
+
// using the local file system
|
|
1865
|
+
const isLocal = modules.ModuleHelper.isLocalModule(moduleName);
|
|
1866
|
+
if (isLocal) {
|
|
1867
|
+
// See if we can just resolve the filename locally
|
|
1868
|
+
let localFilename = path.resolve(moduleName);
|
|
1869
|
+
let exists = await fileExists(localFilename);
|
|
1870
|
+
if (!exists) {
|
|
1871
|
+
// Doesn't exist in the current directory, try the execution directory
|
|
1872
|
+
localFilename = path.resolve(executionDirectory, moduleName);
|
|
1873
|
+
exists = await fileExists(localFilename);
|
|
1874
|
+
}
|
|
1875
|
+
if (exists) {
|
|
1876
|
+
// If the module exists then we can load it, otherwise
|
|
1877
|
+
// we fallback to regular handling to see if that can import it
|
|
1878
|
+
return {
|
|
1879
|
+
module: await import(process.platform === "win32" ? `file://${localFilename}` : localFilename),
|
|
1880
|
+
useDefault: false
|
|
1881
|
+
};
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
// The filename doesn't look like a local module, so just use default handling
|
|
1885
|
+
return {
|
|
1886
|
+
useDefault: true
|
|
1887
|
+
};
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1820
1890
|
|
|
1821
1891
|
exports.NodeFeatures = NodeFeatures;
|
|
1822
1892
|
exports.bootstrap = bootstrap;
|
|
@@ -1834,5 +1904,7 @@ exports.getExecutionDirectory = getExecutionDirectory;
|
|
|
1834
1904
|
exports.getFeatures = getFeatures;
|
|
1835
1905
|
exports.initialiseLocales = initialiseLocales;
|
|
1836
1906
|
exports.loadJsonFile = loadJsonFile;
|
|
1907
|
+
exports.loadTextFile = loadTextFile;
|
|
1908
|
+
exports.overrideModuleImport = overrideModuleImport;
|
|
1837
1909
|
exports.run = run;
|
|
1838
1910
|
exports.start = start;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { PasswordHelper } from '@twin.org/api-auth-entity-storage-service';
|
|
|
2
2
|
import { I18n, Is, Converter, RandomHelper, StringHelper, Coerce, Urn, GeneralError, ErrorHelper, EnvHelper } from '@twin.org/core';
|
|
3
3
|
import { PasswordGenerator, Bip39 } from '@twin.org/crypto';
|
|
4
4
|
import { AuthenticationComponentType, InformationComponentType, RestRouteProcessorType, SocketRouteProcessorType, AuthenticationAdminComponentType } from '@twin.org/engine-server-types';
|
|
5
|
-
import { WalletConnectorType, IdentityConnectorType, EntityStorageConnectorType, BlobStorageConnectorType, BlobStorageComponentType, VaultConnectorType, DltConfigType, LoggingConnectorType, LoggingComponentType, BackgroundTaskConnectorType, EventBusConnectorType, EventBusComponentType, TelemetryConnectorType, TelemetryComponentType, MessagingEmailConnectorType, MessagingSmsConnectorType, MessagingPushNotificationConnectorType, MessagingComponentType, FaucetConnectorType, NftConnectorType, NftComponentType, VerifiableStorageConnectorType, VerifiableStorageComponentType, ImmutableProofComponentType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, IdentityComponentType, IdentityResolverConnectorType, IdentityResolverComponentType, IdentityProfileConnectorType, IdentityProfileComponentType, AttestationConnectorType, AttestationComponentType, DataConverterConnectorType, DataExtractorConnectorType, DataProcessingComponentType, DocumentManagementComponentType, RightsManagementPapComponentType, RightsManagementPmpComponentType, RightsManagementPipComponentType, RightsManagementPxpComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementComponentType, TaskSchedulerComponentType, SynchronisedStorageComponentType, FederatedCatalogueComponentType } from '@twin.org/engine-types';
|
|
5
|
+
import { WalletConnectorType, IdentityConnectorType, EntityStorageConnectorType, BlobStorageConnectorType, BlobStorageComponentType, VaultConnectorType, DltConfigType, LoggingConnectorType, LoggingComponentType, BackgroundTaskConnectorType, EventBusConnectorType, EventBusComponentType, TelemetryConnectorType, TelemetryComponentType, MessagingEmailConnectorType, MessagingSmsConnectorType, MessagingPushNotificationConnectorType, MessagingComponentType, FaucetConnectorType, NftConnectorType, NftComponentType, VerifiableStorageConnectorType, VerifiableStorageComponentType, ImmutableProofComponentType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, IdentityComponentType, IdentityResolverConnectorType, IdentityResolverComponentType, IdentityProfileConnectorType, IdentityProfileComponentType, AttestationConnectorType, AttestationComponentType, DataConverterConnectorType, DataExtractorConnectorType, DataProcessingComponentType, DocumentManagementComponentType, RightsManagementPapComponentType, RightsManagementPmpComponentType, RightsManagementPipComponentType, RightsManagementPxpComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementComponentType, TaskSchedulerComponentType, SynchronisedStorageComponentType, FederatedCatalogueComponentType, DataSpaceConnectorComponentType } from '@twin.org/engine-types';
|
|
6
6
|
import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
|
|
7
7
|
import { IdentityProfileConnectorFactory, IdentityConnectorFactory, IdentityResolverConnectorFactory, DocumentHelper } from '@twin.org/identity-models';
|
|
8
8
|
import { VaultConnectorFactory, VaultKeyType } from '@twin.org/vault-models';
|
|
@@ -10,6 +10,7 @@ import { WalletConnectorFactory } from '@twin.org/wallet-models';
|
|
|
10
10
|
import { readFile, stat } from 'node:fs/promises';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { addDefaultRestPaths, addDefaultSocketPaths, EngineServer } from '@twin.org/engine-server';
|
|
13
|
+
import { ModuleHelper } from '@twin.org/modules';
|
|
13
14
|
import * as dotenv from 'dotenv';
|
|
14
15
|
import { Engine } from '@twin.org/engine';
|
|
15
16
|
import { FileStateStorage } from '@twin.org/engine-core';
|
|
@@ -75,13 +76,21 @@ async function fileExists(filename) {
|
|
|
75
76
|
return false;
|
|
76
77
|
}
|
|
77
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Load the text file.
|
|
81
|
+
* @param filename The filename of the text file to load.
|
|
82
|
+
* @returns The contents of the text file if it could not be loaded.
|
|
83
|
+
*/
|
|
84
|
+
async function loadTextFile(filename) {
|
|
85
|
+
return readFile(filename, "utf8");
|
|
86
|
+
}
|
|
78
87
|
/**
|
|
79
88
|
* Load the JSON file.
|
|
80
89
|
* @param filename The filename of the JSON file to load.
|
|
81
90
|
* @returns The contents of the JSON file or null if it could not be loaded.
|
|
82
91
|
*/
|
|
83
92
|
async function loadJsonFile(filename) {
|
|
84
|
-
const content = await
|
|
93
|
+
const content = await loadTextFile(filename);
|
|
85
94
|
return JSON.parse(content);
|
|
86
95
|
}
|
|
87
96
|
/**
|
|
@@ -570,6 +579,7 @@ function buildEngineConfiguration(envVars) {
|
|
|
570
579
|
configureTaskScheduler(coreConfig, envVars);
|
|
571
580
|
configureSynchronisedStorage(coreConfig, envVars);
|
|
572
581
|
configureFederatedCatalogue(coreConfig, envVars);
|
|
582
|
+
configureDataSpaceConnector(coreConfig, envVars);
|
|
573
583
|
return coreConfig;
|
|
574
584
|
}
|
|
575
585
|
/**
|
|
@@ -1421,8 +1431,7 @@ function configureSynchronisedStorage(coreConfig, envVars) {
|
|
|
1421
1431
|
* @param envVars The environment variables.
|
|
1422
1432
|
*/
|
|
1423
1433
|
function configureFederatedCatalogue(coreConfig, envVars) {
|
|
1424
|
-
if (
|
|
1425
|
-
(Coerce.boolean(envVars.federatedCatalogueEnabled) ?? false)) {
|
|
1434
|
+
if (Coerce.boolean(envVars.federatedCatalogueEnabled) ?? false) {
|
|
1426
1435
|
coreConfig.types.federatedCatalogueComponent ??= [];
|
|
1427
1436
|
coreConfig.types.federatedCatalogueComponent.push({
|
|
1428
1437
|
type: FederatedCatalogueComponentType.Service,
|
|
@@ -1435,6 +1444,26 @@ function configureFederatedCatalogue(coreConfig, envVars) {
|
|
|
1435
1444
|
});
|
|
1436
1445
|
}
|
|
1437
1446
|
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Configures the data space connector.
|
|
1449
|
+
* @param coreConfig The core config.
|
|
1450
|
+
* @param envVars The environment variables.
|
|
1451
|
+
*/
|
|
1452
|
+
function configureDataSpaceConnector(coreConfig, envVars) {
|
|
1453
|
+
if (Coerce.boolean(envVars.dataSpaceConnectorEnabled) ?? false) {
|
|
1454
|
+
coreConfig.types.dataSpaceConnectorComponent ??= [];
|
|
1455
|
+
coreConfig.types.dataSpaceConnectorComponent.push({
|
|
1456
|
+
type: DataSpaceConnectorComponentType.Service,
|
|
1457
|
+
options: {
|
|
1458
|
+
config: {
|
|
1459
|
+
dataSpaceConnectorAppDescriptors: Is.arrayValue(envVars.dataSpaceConnectorApps)
|
|
1460
|
+
? envVars.dataSpaceConnectorApps
|
|
1461
|
+
: undefined
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1438
1467
|
/**
|
|
1439
1468
|
* Configures the DLT.
|
|
1440
1469
|
* @param coreConfig The core config.
|
|
@@ -1678,7 +1707,7 @@ async function run(nodeOptions) {
|
|
|
1678
1707
|
nodeOptions ??= {};
|
|
1679
1708
|
const serverInfo = {
|
|
1680
1709
|
name: nodeOptions?.serverName ?? "TWIN Node Server",
|
|
1681
|
-
version: nodeOptions?.serverVersion ?? "0.0.2-next.
|
|
1710
|
+
version: nodeOptions?.serverVersion ?? "0.0.2-next.8" // x-release-please-version
|
|
1682
1711
|
};
|
|
1683
1712
|
console.log(`\u001B[4m🌩️ ${serverInfo.name} v${serverInfo.version}\u001B[24m\n`);
|
|
1684
1713
|
if (!Is.stringValue(nodeOptions?.executionDirectory)) {
|
|
@@ -1708,6 +1737,7 @@ async function run(nodeOptions) {
|
|
|
1708
1737
|
}
|
|
1709
1738
|
nodeOptions.envPrefix ??= "TWIN_NODE_";
|
|
1710
1739
|
console.info("Environment Prefix:", nodeOptions.envPrefix);
|
|
1740
|
+
overrideModuleImport(nodeOptions.executionDirectory ?? "");
|
|
1711
1741
|
const { engineServerConfig, nodeEnvVars: envVars } = await buildConfiguration(process.env, nodeOptions, serverInfo);
|
|
1712
1742
|
console.info();
|
|
1713
1743
|
const startResult = await start(nodeOptions, engineServerConfig, envVars);
|
|
@@ -1760,12 +1790,18 @@ async function buildConfiguration(processEnv, options, serverInfo) {
|
|
|
1760
1790
|
// Expand any environment variables that use the @file: syntax
|
|
1761
1791
|
const keys = Object.keys(envVars);
|
|
1762
1792
|
for (const key of keys) {
|
|
1763
|
-
if (Is.stringValue(envVars[key]) &&
|
|
1793
|
+
if (Is.stringValue(envVars[key]) &&
|
|
1794
|
+
(envVars[key].startsWith("@text:") || envVars[key].startsWith("@json:"))) {
|
|
1764
1795
|
const filePath = envVars[key].slice(6).trim();
|
|
1765
1796
|
const embeddedFile = path.resolve(path.join(options.executionDirectory ?? "", filePath));
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1797
|
+
if (envVars[key].startsWith("@text:")) {
|
|
1798
|
+
console.info(`Expanding Environment Variable: ${key} from text file: ${embeddedFile}`);
|
|
1799
|
+
envVars[key] = await loadTextFile(embeddedFile);
|
|
1800
|
+
}
|
|
1801
|
+
else if (envVars[key].startsWith("@json:")) {
|
|
1802
|
+
console.info(`Expanding Environment Variable: ${key} from JSON file: ${embeddedFile}`);
|
|
1803
|
+
envVars[key] = await loadJsonFile(embeddedFile);
|
|
1804
|
+
}
|
|
1769
1805
|
}
|
|
1770
1806
|
}
|
|
1771
1807
|
// Extend the environment variables with any additional custom configuration.
|
|
@@ -1796,5 +1832,39 @@ async function buildConfiguration(processEnv, options, serverInfo) {
|
|
|
1796
1832
|
}
|
|
1797
1833
|
return { engineServerConfig, nodeEnvVars: envVars };
|
|
1798
1834
|
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Override module imports to use local files where possible.
|
|
1837
|
+
* @param executionDirectory The execution directory for resolving local module paths.
|
|
1838
|
+
*/
|
|
1839
|
+
function overrideModuleImport(executionDirectory) {
|
|
1840
|
+
ModuleHelper.overrideImport(async (moduleName) => {
|
|
1841
|
+
// If the module path for example when dynamically loading
|
|
1842
|
+
// modules looks like a local file then we try to resolve
|
|
1843
|
+
// using the local file system
|
|
1844
|
+
const isLocal = ModuleHelper.isLocalModule(moduleName);
|
|
1845
|
+
if (isLocal) {
|
|
1846
|
+
// See if we can just resolve the filename locally
|
|
1847
|
+
let localFilename = path.resolve(moduleName);
|
|
1848
|
+
let exists = await fileExists(localFilename);
|
|
1849
|
+
if (!exists) {
|
|
1850
|
+
// Doesn't exist in the current directory, try the execution directory
|
|
1851
|
+
localFilename = path.resolve(executionDirectory, moduleName);
|
|
1852
|
+
exists = await fileExists(localFilename);
|
|
1853
|
+
}
|
|
1854
|
+
if (exists) {
|
|
1855
|
+
// If the module exists then we can load it, otherwise
|
|
1856
|
+
// we fallback to regular handling to see if that can import it
|
|
1857
|
+
return {
|
|
1858
|
+
module: await import(process.platform === "win32" ? `file://${localFilename}` : localFilename),
|
|
1859
|
+
useDefault: false
|
|
1860
|
+
};
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
// The filename doesn't look like a local module, so just use default handling
|
|
1864
|
+
return {
|
|
1865
|
+
useDefault: true
|
|
1866
|
+
};
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
1799
1869
|
|
|
1800
|
-
export { NodeFeatures, bootstrap, bootstrapAuth, bootstrapBlobEncryption, bootstrapImmutableProofMethod, bootstrapNodeIdentity, bootstrapNodeUser, bootstrapSynchronisedStorage, buildConfiguration, buildEngineConfiguration, buildEngineServerConfiguration, fileExists, getExecutionDirectory, getFeatures, initialiseLocales, loadJsonFile, run, start };
|
|
1870
|
+
export { NodeFeatures, bootstrap, bootstrapAuth, bootstrapBlobEncryption, bootstrapImmutableProofMethod, bootstrapNodeIdentity, bootstrapNodeUser, bootstrapSynchronisedStorage, buildConfiguration, buildEngineConfiguration, buildEngineServerConfiguration, fileExists, getExecutionDirectory, getFeatures, initialiseLocales, loadJsonFile, loadTextFile, overrideModuleImport, run, start };
|
|
@@ -446,4 +446,13 @@ export interface IEngineEnvironmentVariables {
|
|
|
446
446
|
* Is the task scheduler enabled, defaults to false.
|
|
447
447
|
*/
|
|
448
448
|
taskSchedulerEnabled?: string;
|
|
449
|
+
/**
|
|
450
|
+
* Is the data space connector enabled, defaults to false.
|
|
451
|
+
*/
|
|
452
|
+
dataSpaceConnectorEnabled?: string;
|
|
453
|
+
/**
|
|
454
|
+
* The application configuration for the data space connector.
|
|
455
|
+
* Use the @json: prefix to specify the path to the JSON configuration file.
|
|
456
|
+
*/
|
|
457
|
+
dataSpaceConnectorApps?: string;
|
|
449
458
|
}
|
package/dist/types/node.d.ts
CHANGED
|
@@ -24,3 +24,8 @@ export declare function buildConfiguration(processEnv: {
|
|
|
24
24
|
};
|
|
25
25
|
engineServerConfig: IEngineServerConfig;
|
|
26
26
|
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Override module imports to use local files where possible.
|
|
29
|
+
* @param executionDirectory The execution directory for resolving local module paths.
|
|
30
|
+
*/
|
|
31
|
+
export declare function overrideModuleImport(executionDirectory: string): void;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -16,6 +16,12 @@ export declare function getExecutionDirectory(): string;
|
|
|
16
16
|
* @returns True if the file exists.
|
|
17
17
|
*/
|
|
18
18
|
export declare function fileExists(filename: string): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Load the text file.
|
|
21
|
+
* @param filename The filename of the text file to load.
|
|
22
|
+
* @returns The contents of the text file if it could not be loaded.
|
|
23
|
+
*/
|
|
24
|
+
export declare function loadTextFile(filename: string): Promise<string>;
|
|
19
25
|
/**
|
|
20
26
|
* Load the JSON file.
|
|
21
27
|
* @param filename The filename of the JSON file to load.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @twin.org/node-core - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.8](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.7...node-core-v0.0.2-next.8) (2025-08-27)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add module override for better local import resolution ([ba00d17](https://github.com/twinfoundation/node/commit/ba00d17beea0a9a1851c89ad7c6a33256051c818))
|
|
9
|
+
|
|
10
|
+
## [0.0.2-next.7](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.6...node-core-v0.0.2-next.7) (2025-08-26)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add data space connector ([5a57087](https://github.com/twinfoundation/node/commit/5a57087d938265d3a4a812ff7c83d130ea4e103c))
|
|
16
|
+
* add data space connector ([f7a3644](https://github.com/twinfoundation/node/commit/f7a364477ec664e333e5ad018795acec6ee61edc))
|
|
17
|
+
* add data space connector ([157e8b0](https://github.com/twinfoundation/node/commit/157e8b0a76e3a8a63c1991924f7f963eb83e27ae))
|
|
18
|
+
|
|
3
19
|
## [0.0.2-next.6](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.5...node-core-v0.0.2-next.6) (2025-08-22)
|
|
4
20
|
|
|
5
21
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Function: loadTextFile()
|
|
2
|
+
|
|
3
|
+
> **loadTextFile**(`filename`): `Promise`\<`string`\>
|
|
4
|
+
|
|
5
|
+
Load the text file.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### filename
|
|
10
|
+
|
|
11
|
+
`string`
|
|
12
|
+
|
|
13
|
+
The filename of the text file to load.
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
`Promise`\<`string`\>
|
|
18
|
+
|
|
19
|
+
The contents of the text file if it could not be loaded.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Function: overrideModuleImport()
|
|
2
|
+
|
|
3
|
+
> **overrideModuleImport**(`executionDirectory`): `void`
|
|
4
|
+
|
|
5
|
+
Override module imports to use local files where possible.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### executionDirectory
|
|
10
|
+
|
|
11
|
+
`string`
|
|
12
|
+
|
|
13
|
+
The execution directory for resolving local module paths.
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
`void`
|
package/docs/reference/index.md
CHANGED
|
@@ -28,9 +28,11 @@
|
|
|
28
28
|
- [buildEngineServerConfiguration](functions/buildEngineServerConfiguration.md)
|
|
29
29
|
- [run](functions/run.md)
|
|
30
30
|
- [buildConfiguration](functions/buildConfiguration.md)
|
|
31
|
+
- [overrideModuleImport](functions/overrideModuleImport.md)
|
|
31
32
|
- [start](functions/start.md)
|
|
32
33
|
- [initialiseLocales](functions/initialiseLocales.md)
|
|
33
34
|
- [getExecutionDirectory](functions/getExecutionDirectory.md)
|
|
34
35
|
- [fileExists](functions/fileExists.md)
|
|
36
|
+
- [loadTextFile](functions/loadTextFile.md)
|
|
35
37
|
- [loadJsonFile](functions/loadJsonFile.md)
|
|
36
38
|
- [getFeatures](functions/getFeatures.md)
|
|
@@ -901,3 +901,20 @@ Is the rights management enabled, defaults to false.
|
|
|
901
901
|
> `optional` **taskSchedulerEnabled**: `string`
|
|
902
902
|
|
|
903
903
|
Is the task scheduler enabled, defaults to false.
|
|
904
|
+
|
|
905
|
+
***
|
|
906
|
+
|
|
907
|
+
### dataSpaceConnectorEnabled?
|
|
908
|
+
|
|
909
|
+
> `optional` **dataSpaceConnectorEnabled**: `string`
|
|
910
|
+
|
|
911
|
+
Is the data space connector enabled, defaults to false.
|
|
912
|
+
|
|
913
|
+
***
|
|
914
|
+
|
|
915
|
+
### dataSpaceConnectorApps?
|
|
916
|
+
|
|
917
|
+
> `optional` **dataSpaceConnectorApps**: `string`
|
|
918
|
+
|
|
919
|
+
The application configuration for the data space connector.
|
|
920
|
+
Use the @json: prefix to specify the path to the JSON configuration file.
|
|
@@ -1336,6 +1336,31 @@ Is the task scheduler enabled, defaults to false.
|
|
|
1336
1336
|
|
|
1337
1337
|
***
|
|
1338
1338
|
|
|
1339
|
+
### dataSpaceConnectorEnabled?
|
|
1340
|
+
|
|
1341
|
+
> `optional` **dataSpaceConnectorEnabled**: `string`
|
|
1342
|
+
|
|
1343
|
+
Is the data space connector enabled, defaults to false.
|
|
1344
|
+
|
|
1345
|
+
#### Inherited from
|
|
1346
|
+
|
|
1347
|
+
[`IEngineEnvironmentVariables`](IEngineEnvironmentVariables.md).[`dataSpaceConnectorEnabled`](IEngineEnvironmentVariables.md#dataspaceconnectorenabled)
|
|
1348
|
+
|
|
1349
|
+
***
|
|
1350
|
+
|
|
1351
|
+
### dataSpaceConnectorApps?
|
|
1352
|
+
|
|
1353
|
+
> `optional` **dataSpaceConnectorApps**: `string`
|
|
1354
|
+
|
|
1355
|
+
The application configuration for the data space connector.
|
|
1356
|
+
Use the @json: prefix to specify the path to the JSON configuration file.
|
|
1357
|
+
|
|
1358
|
+
#### Inherited from
|
|
1359
|
+
|
|
1360
|
+
[`IEngineEnvironmentVariables`](IEngineEnvironmentVariables.md).[`dataSpaceConnectorApps`](IEngineEnvironmentVariables.md#dataspaceconnectorapps)
|
|
1361
|
+
|
|
1362
|
+
***
|
|
1363
|
+
|
|
1339
1364
|
### port?
|
|
1340
1365
|
|
|
1341
1366
|
> `optional` **port**: `string`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/node-core",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.8",
|
|
4
4
|
"description": "TWIN Node Core for serving APIs using the specified configuration",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"@twin.org/api-auth-entity-storage-service": "next",
|
|
18
18
|
"@twin.org/core": "next",
|
|
19
19
|
"@twin.org/crypto": "next",
|
|
20
|
+
"@twin.org/data-space-connector-models": "next",
|
|
20
21
|
"@twin.org/engine": "next",
|
|
21
22
|
"@twin.org/engine-core": "next",
|
|
22
23
|
"@twin.org/engine-models": "next",
|
|
@@ -26,6 +27,7 @@
|
|
|
26
27
|
"@twin.org/entity": "next",
|
|
27
28
|
"@twin.org/entity-storage-models": "next",
|
|
28
29
|
"@twin.org/identity-models": "next",
|
|
30
|
+
"@twin.org/modules": "next",
|
|
29
31
|
"@twin.org/vault-models": "next",
|
|
30
32
|
"@twin.org/wallet-models": "next",
|
|
31
33
|
"dotenv": "17.2.1",
|