@twin.org/node-core 0.0.2-next.6 → 0.0.2-next.7

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.
@@ -96,13 +96,21 @@ async function fileExists(filename) {
96
96
  return false;
97
97
  }
98
98
  }
99
+ /**
100
+ * Load the text file.
101
+ * @param filename The filename of the text file to load.
102
+ * @returns The contents of the text file if it could not be loaded.
103
+ */
104
+ async function loadTextFile(filename) {
105
+ return promises.readFile(filename, "utf8");
106
+ }
99
107
  /**
100
108
  * Load the JSON file.
101
109
  * @param filename The filename of the JSON file to load.
102
110
  * @returns The contents of the JSON file or null if it could not be loaded.
103
111
  */
104
112
  async function loadJsonFile(filename) {
105
- const content = await promises.readFile(filename, "utf8");
113
+ const content = await loadTextFile(filename);
106
114
  return JSON.parse(content);
107
115
  }
108
116
  /**
@@ -591,6 +599,7 @@ function buildEngineConfiguration(envVars) {
591
599
  configureTaskScheduler(coreConfig, envVars);
592
600
  configureSynchronisedStorage(coreConfig, envVars);
593
601
  configureFederatedCatalogue(coreConfig, envVars);
602
+ configureDataSpaceConnector(coreConfig, envVars);
594
603
  return coreConfig;
595
604
  }
596
605
  /**
@@ -1442,8 +1451,7 @@ function configureSynchronisedStorage(coreConfig, envVars) {
1442
1451
  * @param envVars The environment variables.
1443
1452
  */
1444
1453
  function configureFederatedCatalogue(coreConfig, envVars) {
1445
- if (core.Is.arrayValue(coreConfig.types.identityResolverComponent) &&
1446
- (core.Coerce.boolean(envVars.federatedCatalogueEnabled) ?? false)) {
1454
+ if (core.Coerce.boolean(envVars.federatedCatalogueEnabled) ?? false) {
1447
1455
  coreConfig.types.federatedCatalogueComponent ??= [];
1448
1456
  coreConfig.types.federatedCatalogueComponent.push({
1449
1457
  type: engineTypes.FederatedCatalogueComponentType.Service,
@@ -1456,6 +1464,26 @@ function configureFederatedCatalogue(coreConfig, envVars) {
1456
1464
  });
1457
1465
  }
1458
1466
  }
1467
+ /**
1468
+ * Configures the data space connector.
1469
+ * @param coreConfig The core config.
1470
+ * @param envVars The environment variables.
1471
+ */
1472
+ function configureDataSpaceConnector(coreConfig, envVars) {
1473
+ if (core.Coerce.boolean(envVars.dataSpaceConnectorEnabled) ?? false) {
1474
+ coreConfig.types.dataSpaceConnectorComponent ??= [];
1475
+ coreConfig.types.dataSpaceConnectorComponent.push({
1476
+ type: engineTypes.DataSpaceConnectorComponentType.Service,
1477
+ options: {
1478
+ config: {
1479
+ dataSpaceConnectorAppDescriptors: core.Is.arrayValue(envVars.dataSpaceConnectorApps)
1480
+ ? envVars.dataSpaceConnectorApps
1481
+ : undefined
1482
+ }
1483
+ }
1484
+ });
1485
+ }
1486
+ }
1459
1487
  /**
1460
1488
  * Configures the DLT.
1461
1489
  * @param coreConfig The core config.
@@ -1699,7 +1727,7 @@ async function run(nodeOptions) {
1699
1727
  nodeOptions ??= {};
1700
1728
  const serverInfo = {
1701
1729
  name: nodeOptions?.serverName ?? "TWIN Node Server",
1702
- version: nodeOptions?.serverVersion ?? "0.0.2-next.6" // x-release-please-version
1730
+ version: nodeOptions?.serverVersion ?? "0.0.2-next.7" // x-release-please-version
1703
1731
  };
1704
1732
  console.log(`\u001B[4m🌩️ ${serverInfo.name} v${serverInfo.version}\u001B[24m\n`);
1705
1733
  if (!core.Is.stringValue(nodeOptions?.executionDirectory)) {
@@ -1781,12 +1809,18 @@ async function buildConfiguration(processEnv, options, serverInfo) {
1781
1809
  // Expand any environment variables that use the @file: syntax
1782
1810
  const keys = Object.keys(envVars);
1783
1811
  for (const key of keys) {
1784
- if (core.Is.stringValue(envVars[key]) && envVars[key].startsWith("@file:")) {
1812
+ if (core.Is.stringValue(envVars[key]) &&
1813
+ (envVars[key].startsWith("@text:") || envVars[key].startsWith("@json:"))) {
1785
1814
  const filePath = envVars[key].slice(6).trim();
1786
1815
  const embeddedFile = path.resolve(path.join(options.executionDirectory ?? "", filePath));
1787
- console.info(`Expanding Environment Variable: ${key} from file: ${embeddedFile}`);
1788
- const fileContent = await loadJsonFile(embeddedFile);
1789
- envVars[key] = fileContent;
1816
+ if (envVars[key].startsWith("@text:")) {
1817
+ console.info(`Expanding Environment Variable: ${key} from text file: ${embeddedFile}`);
1818
+ envVars[key] = await loadTextFile(embeddedFile);
1819
+ }
1820
+ else if (envVars[key].startsWith("@json:")) {
1821
+ console.info(`Expanding Environment Variable: ${key} from JSON file: ${embeddedFile}`);
1822
+ envVars[key] = await loadJsonFile(embeddedFile);
1823
+ }
1790
1824
  }
1791
1825
  }
1792
1826
  // Extend the environment variables with any additional custom configuration.
@@ -1834,5 +1868,6 @@ exports.getExecutionDirectory = getExecutionDirectory;
1834
1868
  exports.getFeatures = getFeatures;
1835
1869
  exports.initialiseLocales = initialiseLocales;
1836
1870
  exports.loadJsonFile = loadJsonFile;
1871
+ exports.loadTextFile = loadTextFile;
1837
1872
  exports.run = run;
1838
1873
  exports.start = start;
@@ -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';
@@ -75,13 +75,21 @@ async function fileExists(filename) {
75
75
  return false;
76
76
  }
77
77
  }
78
+ /**
79
+ * Load the text file.
80
+ * @param filename The filename of the text file to load.
81
+ * @returns The contents of the text file if it could not be loaded.
82
+ */
83
+ async function loadTextFile(filename) {
84
+ return readFile(filename, "utf8");
85
+ }
78
86
  /**
79
87
  * Load the JSON file.
80
88
  * @param filename The filename of the JSON file to load.
81
89
  * @returns The contents of the JSON file or null if it could not be loaded.
82
90
  */
83
91
  async function loadJsonFile(filename) {
84
- const content = await readFile(filename, "utf8");
92
+ const content = await loadTextFile(filename);
85
93
  return JSON.parse(content);
86
94
  }
87
95
  /**
@@ -570,6 +578,7 @@ function buildEngineConfiguration(envVars) {
570
578
  configureTaskScheduler(coreConfig, envVars);
571
579
  configureSynchronisedStorage(coreConfig, envVars);
572
580
  configureFederatedCatalogue(coreConfig, envVars);
581
+ configureDataSpaceConnector(coreConfig, envVars);
573
582
  return coreConfig;
574
583
  }
575
584
  /**
@@ -1421,8 +1430,7 @@ function configureSynchronisedStorage(coreConfig, envVars) {
1421
1430
  * @param envVars The environment variables.
1422
1431
  */
1423
1432
  function configureFederatedCatalogue(coreConfig, envVars) {
1424
- if (Is.arrayValue(coreConfig.types.identityResolverComponent) &&
1425
- (Coerce.boolean(envVars.federatedCatalogueEnabled) ?? false)) {
1433
+ if (Coerce.boolean(envVars.federatedCatalogueEnabled) ?? false) {
1426
1434
  coreConfig.types.federatedCatalogueComponent ??= [];
1427
1435
  coreConfig.types.federatedCatalogueComponent.push({
1428
1436
  type: FederatedCatalogueComponentType.Service,
@@ -1435,6 +1443,26 @@ function configureFederatedCatalogue(coreConfig, envVars) {
1435
1443
  });
1436
1444
  }
1437
1445
  }
1446
+ /**
1447
+ * Configures the data space connector.
1448
+ * @param coreConfig The core config.
1449
+ * @param envVars The environment variables.
1450
+ */
1451
+ function configureDataSpaceConnector(coreConfig, envVars) {
1452
+ if (Coerce.boolean(envVars.dataSpaceConnectorEnabled) ?? false) {
1453
+ coreConfig.types.dataSpaceConnectorComponent ??= [];
1454
+ coreConfig.types.dataSpaceConnectorComponent.push({
1455
+ type: DataSpaceConnectorComponentType.Service,
1456
+ options: {
1457
+ config: {
1458
+ dataSpaceConnectorAppDescriptors: Is.arrayValue(envVars.dataSpaceConnectorApps)
1459
+ ? envVars.dataSpaceConnectorApps
1460
+ : undefined
1461
+ }
1462
+ }
1463
+ });
1464
+ }
1465
+ }
1438
1466
  /**
1439
1467
  * Configures the DLT.
1440
1468
  * @param coreConfig The core config.
@@ -1678,7 +1706,7 @@ async function run(nodeOptions) {
1678
1706
  nodeOptions ??= {};
1679
1707
  const serverInfo = {
1680
1708
  name: nodeOptions?.serverName ?? "TWIN Node Server",
1681
- version: nodeOptions?.serverVersion ?? "0.0.2-next.6" // x-release-please-version
1709
+ version: nodeOptions?.serverVersion ?? "0.0.2-next.7" // x-release-please-version
1682
1710
  };
1683
1711
  console.log(`\u001B[4m🌩️ ${serverInfo.name} v${serverInfo.version}\u001B[24m\n`);
1684
1712
  if (!Is.stringValue(nodeOptions?.executionDirectory)) {
@@ -1760,12 +1788,18 @@ async function buildConfiguration(processEnv, options, serverInfo) {
1760
1788
  // Expand any environment variables that use the @file: syntax
1761
1789
  const keys = Object.keys(envVars);
1762
1790
  for (const key of keys) {
1763
- if (Is.stringValue(envVars[key]) && envVars[key].startsWith("@file:")) {
1791
+ if (Is.stringValue(envVars[key]) &&
1792
+ (envVars[key].startsWith("@text:") || envVars[key].startsWith("@json:"))) {
1764
1793
  const filePath = envVars[key].slice(6).trim();
1765
1794
  const embeddedFile = path.resolve(path.join(options.executionDirectory ?? "", filePath));
1766
- console.info(`Expanding Environment Variable: ${key} from file: ${embeddedFile}`);
1767
- const fileContent = await loadJsonFile(embeddedFile);
1768
- envVars[key] = fileContent;
1795
+ if (envVars[key].startsWith("@text:")) {
1796
+ console.info(`Expanding Environment Variable: ${key} from text file: ${embeddedFile}`);
1797
+ envVars[key] = await loadTextFile(embeddedFile);
1798
+ }
1799
+ else if (envVars[key].startsWith("@json:")) {
1800
+ console.info(`Expanding Environment Variable: ${key} from JSON file: ${embeddedFile}`);
1801
+ envVars[key] = await loadJsonFile(embeddedFile);
1802
+ }
1769
1803
  }
1770
1804
  }
1771
1805
  // Extend the environment variables with any additional custom configuration.
@@ -1797,4 +1831,4 @@ async function buildConfiguration(processEnv, options, serverInfo) {
1797
1831
  return { engineServerConfig, nodeEnvVars: envVars };
1798
1832
  }
1799
1833
 
1800
- export { NodeFeatures, bootstrap, bootstrapAuth, bootstrapBlobEncryption, bootstrapImmutableProofMethod, bootstrapNodeIdentity, bootstrapNodeUser, bootstrapSynchronisedStorage, buildConfiguration, buildEngineConfiguration, buildEngineServerConfiguration, fileExists, getExecutionDirectory, getFeatures, initialiseLocales, loadJsonFile, run, start };
1834
+ export { NodeFeatures, bootstrap, bootstrapAuth, bootstrapBlobEncryption, bootstrapImmutableProofMethod, bootstrapNodeIdentity, bootstrapNodeUser, bootstrapSynchronisedStorage, buildConfiguration, buildEngineConfiguration, buildEngineServerConfiguration, fileExists, getExecutionDirectory, getFeatures, initialiseLocales, loadJsonFile, loadTextFile, 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
  }
@@ -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,14 @@
1
1
  # @twin.org/node-core - Changelog
2
2
 
3
+ ## [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)
4
+
5
+
6
+ ### Features
7
+
8
+ * add data space connector ([5a57087](https://github.com/twinfoundation/node/commit/5a57087d938265d3a4a812ff7c83d130ea4e103c))
9
+ * add data space connector ([f7a3644](https://github.com/twinfoundation/node/commit/f7a364477ec664e333e5ad018795acec6ee61edc))
10
+ * add data space connector ([157e8b0](https://github.com/twinfoundation/node/commit/157e8b0a76e3a8a63c1991924f7f963eb83e27ae))
11
+
3
12
  ## [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
13
 
5
14
 
@@ -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.
@@ -32,5 +32,6 @@
32
32
  - [initialiseLocales](functions/initialiseLocales.md)
33
33
  - [getExecutionDirectory](functions/getExecutionDirectory.md)
34
34
  - [fileExists](functions/fileExists.md)
35
+ - [loadTextFile](functions/loadTextFile.md)
35
36
  - [loadJsonFile](functions/loadJsonFile.md)
36
37
  - [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.6",
3
+ "version": "0.0.2-next.7",
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",