@twin.org/node-core 0.0.3-next.33 → 0.0.3-next.35

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.
Files changed (34) hide show
  1. package/dist/es/builders/engineEnvBuilder.js +145 -9
  2. package/dist/es/builders/engineEnvBuilder.js.map +1 -1
  3. package/dist/es/builders/engineServerEnvBuilder.js +18 -2
  4. package/dist/es/builders/engineServerEnvBuilder.js.map +1 -1
  5. package/dist/es/commands/bootstrapLegacy.js +28 -16
  6. package/dist/es/commands/bootstrapLegacy.js.map +1 -1
  7. package/dist/es/defaults.js +3 -1
  8. package/dist/es/defaults.js.map +1 -1
  9. package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -1
  10. package/dist/es/models/IEngineServerEnvironmentVariables.js.map +1 -1
  11. package/dist/es/node.js +1 -1
  12. package/dist/es/node.js.map +1 -1
  13. package/dist/types/builders/engineEnvBuilder.d.ts +56 -0
  14. package/dist/types/builders/engineServerEnvBuilder.d.ts +7 -0
  15. package/dist/types/defaults.d.ts +1 -0
  16. package/dist/types/models/IEngineEnvironmentVariables.d.ts +18 -23
  17. package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +4 -0
  18. package/docs/changelog.md +252 -237
  19. package/docs/reference/functions/isAuthEntityStorageRequired.md +20 -0
  20. package/docs/reference/functions/isAutomationRequired.md +20 -0
  21. package/docs/reference/functions/isBackgroundTasksRequired.md +20 -0
  22. package/docs/reference/functions/isFederatedCatalogueRequired.md +20 -0
  23. package/docs/reference/functions/isImmutableProofRequired.md +20 -0
  24. package/docs/reference/functions/isRightsManagementRequired.md +20 -0
  25. package/docs/reference/functions/isTaskSchedulerRequired.md +20 -0
  26. package/docs/reference/functions/isTrustRequired.md +20 -0
  27. package/docs/reference/functions/isUrlTransformerRequired.md +20 -0
  28. package/docs/reference/index.md +10 -0
  29. package/docs/reference/interfaces/IEngineEnvironmentVariables.md +27 -44
  30. package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +44 -65
  31. package/docs/reference/interfaces/INodeEnvironmentVariables.md +48 -65
  32. package/docs/reference/variables/URL_TRANSFORMER_ENCRYPTION_KEY_ID.md +3 -0
  33. package/locales/en.json +2 -1
  34. package/package.json +3 -3
@@ -2,8 +2,9 @@
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
3
  import path from "node:path";
4
4
  import { Coerce, Is } from "@twin.org/core";
5
- import { AttestationComponentType, AttestationConnectorType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, AutomationComponentType, BackgroundTaskComponentType, BlobStorageComponentType, BlobStorageConnectorType, ContextIdHandlerComponentType, DataProcessingComponentType, DataspaceControlPlaneComponentType, DataspaceDataPlaneComponentType, DltConfigType, DocumentManagementComponentType, EngineTypeHelper, EntityStorageConnectorType, EventBusComponentType, EventBusConnectorType, FaucetConnectorType, FederatedCatalogueComponentType, IdentityComponentType, IdentityConnectorType, IdentityProfileComponentType, IdentityProfileConnectorType, IdentityResolverComponentType, IdentityResolverConnectorType, ImmutableProofComponentType, LoggingComponentType, LoggingConnectorType, MessagingAdminComponentType, MessagingComponentType, MessagingEmailConnectorType, MessagingPushNotificationConnectorType, MessagingSmsConnectorType, NftComponentType, NftConnectorType, NotarizationComponentType, NotarizationConnectorType, RightsManagementPapComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementPipComponentType, RightsManagementPmpComponentType, RightsManagementPnapComponentType, RightsManagementPnpComponentType, RightsManagementPxpComponentType, SynchronisedStorageComponentType, TaskSchedulerComponentType, TelemetryComponentType, TelemetryConnectorType, TenantAdminComponentType, TrustComponentType, VaultConnectorType, VerifiableStorageComponentType, VerifiableStorageConnectorType, WalletConnectorType } from "@twin.org/engine-types";
5
+ import { AttestationComponentType, AttestationConnectorType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, AutomationComponentType, BackgroundTaskComponentType, BlobStorageComponentType, BlobStorageConnectorType, ContextIdHandlerComponentType, DataProcessingComponentType, DataspaceControlPlaneComponentType, DataspaceDataPlaneComponentType, DltConfigType, DocumentManagementComponentType, EngineTypeHelper, EntityStorageConnectorType, EventBusComponentType, EventBusConnectorType, FaucetConnectorType, FederatedCatalogueComponentType, HealthComponentType, IdentityComponentType, IdentityConnectorType, IdentityProfileComponentType, IdentityProfileConnectorType, IdentityResolverComponentType, IdentityResolverConnectorType, ImmutableProofComponentType, LoggingComponentType, LoggingConnectorType, MessagingAdminComponentType, MessagingComponentType, MessagingEmailConnectorType, MessagingPushNotificationConnectorType, MessagingSmsConnectorType, NftComponentType, NftConnectorType, NotarizationComponentType, NotarizationConnectorType, RightsManagementPapComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementPipComponentType, RightsManagementPmpComponentType, RightsManagementPnapComponentType, RightsManagementPnpComponentType, RightsManagementPxpComponentType, SynchronisedStorageComponentType, TaskSchedulerComponentType, TelemetryComponentType, TelemetryConnectorType, TenantAdminComponentType, TrustComponentType, UrlTransformerComponentType, VaultConnectorType, VerifiableStorageComponentType, VerifiableStorageConnectorType, WalletConnectorType } from "@twin.org/engine-types";
6
6
  import { CONTEXT_ID_HANDLER_FEATURE_DID, CONTEXT_ID_HANDLER_FEATURE_TENANT } from "../defaults.js";
7
+ import { isAuthEntityStorageRequired } from "./engineServerEnvBuilder.js";
7
8
  /**
8
9
  * Build the engine core configuration from environment variables.
9
10
  * @param envVars The environment variables.
@@ -34,11 +35,14 @@ export async function buildEngineConfiguration(envVars, contextIdKeys) {
34
35
  await configureTelemetry(coreConfig, envVars);
35
36
  await configureMessaging(coreConfig, envVars);
36
37
  await configureAutomation(coreConfig, envVars);
38
+ await configureHealth(coreConfig, envVars);
39
+ await configureUrlTransformer(coreConfig, envVars);
37
40
  await configureFaucet(coreConfig, envVars);
38
41
  await configureWallet(coreConfig, envVars);
39
42
  await configureNft(coreConfig, envVars);
40
43
  await configureNotarization(coreConfig, envVars);
41
44
  await configureVerifiableStorage(coreConfig, envVars);
45
+ await configureImmutableProof(coreConfig, envVars);
42
46
  await configureIdentity(coreConfig, envVars);
43
47
  await configureIdentityResolver(coreConfig, envVars);
44
48
  await configureIdentityProfile(coreConfig, envVars);
@@ -391,7 +395,7 @@ async function configureVault(coreConfig, envVars) {
391
395
  */
392
396
  async function configureBackgroundTask(coreConfig, envVars) {
393
397
  coreConfig.types.backgroundTaskComponent ??= [];
394
- if (Coerce.boolean(envVars.backgroundTasksEnabled) ?? false) {
398
+ if (isBackgroundTasksRequired(envVars)) {
395
399
  coreConfig.types.backgroundTaskComponent.push({
396
400
  type: BackgroundTaskComponentType.Service
397
401
  });
@@ -438,7 +442,7 @@ async function configureTelemetry(coreConfig, envVars) {
438
442
  */
439
443
  async function configureAutomation(coreConfig, envVars) {
440
444
  coreConfig.types.automationComponent ??= [];
441
- if (Coerce.boolean(envVars.automationEnabled) ?? false) {
445
+ if (isAutomationRequired(envVars)) {
442
446
  coreConfig.types.automationComponent.push({
443
447
  type: AutomationComponentType.Service
444
448
  });
@@ -454,6 +458,45 @@ async function configureAutomation(coreConfig, envVars) {
454
458
  }
455
459
  }
456
460
  }
461
+ /**
462
+ * Configures the health.
463
+ * @param coreConfig The core config.
464
+ * @param envVars The environment variables.
465
+ */
466
+ async function configureHealth(coreConfig, envVars) {
467
+ coreConfig.types.healthComponent ??= [];
468
+ if (Coerce.boolean(envVars.healthEnabled) ?? false) {
469
+ coreConfig.types.healthComponent.push({
470
+ type: HealthComponentType.Service,
471
+ options: {
472
+ config: {
473
+ healthCheckInterval: (Coerce.integer(envVars.healthIntervalSeconds) ?? 60) * 1000
474
+ }
475
+ }
476
+ });
477
+ }
478
+ }
479
+ /**
480
+ * Configures the url transformer.
481
+ * @param coreConfig The core config.
482
+ * @param envVars The environment variables.
483
+ */
484
+ async function configureUrlTransformer(coreConfig, envVars) {
485
+ coreConfig.types.urlTransformerComponent ??= [];
486
+ if (isUrlTransformerRequired(envVars) ?? false) {
487
+ coreConfig.types.urlTransformerComponent.push({
488
+ type: UrlTransformerComponentType.Service,
489
+ options: {
490
+ config: {
491
+ paramEncryptionKeyName: envVars.urlTransformerEncryptionKeyId,
492
+ queryParamNames: {
493
+ tenant: "tenant-token"
494
+ }
495
+ }
496
+ }
497
+ });
498
+ }
499
+ }
457
500
  /**
458
501
  * Configures the tenant.
459
502
  * @param coreConfig The core config.
@@ -692,6 +735,15 @@ async function configureVerifiableStorage(coreConfig, envVars) {
692
735
  coreConfig.types.verifiableStorageComponent.push({
693
736
  type: VerifiableStorageComponentType.Service
694
737
  });
738
+ }
739
+ }
740
+ /**
741
+ * Configures the immutable proof.
742
+ * @param coreConfig The core config.
743
+ * @param envVars The environment variables.
744
+ */
745
+ async function configureImmutableProof(coreConfig, envVars) {
746
+ if (isImmutableProofRequired(envVars)) {
695
747
  coreConfig.types.immutableProofComponent ??= [];
696
748
  coreConfig.types.immutableProofComponent.push({
697
749
  type: ImmutableProofComponentType.Service,
@@ -881,7 +933,7 @@ async function configureDocumentManagement(coreConfig, envVars) {
881
933
  * @param envVars The environment variables.
882
934
  */
883
935
  async function configureTrust(coreConfig, envVars) {
884
- if (Coerce.boolean(envVars.trustEnabled) ?? false) {
936
+ if (isTrustRequired(envVars)) {
885
937
  coreConfig.types.trustComponent ??= [];
886
938
  coreConfig.types.trustComponent.push({
887
939
  type: TrustComponentType.Service
@@ -914,7 +966,7 @@ async function configureTrust(coreConfig, envVars) {
914
966
  * @param envVars The environment variables.
915
967
  */
916
968
  async function configureRightsManagement(coreConfig, envVars) {
917
- if (Coerce.boolean(envVars.rightsManagementEnabled) ?? false) {
969
+ if (isRightsManagementRequired(envVars)) {
918
970
  coreConfig.types.rightsManagementPapComponent ??= [];
919
971
  coreConfig.types.rightsManagementPapComponent.push({
920
972
  type: RightsManagementPapComponentType.Service
@@ -940,6 +992,8 @@ async function configureRightsManagement(coreConfig, envVars) {
940
992
  type: RightsManagementPepComponentType.Service
941
993
  });
942
994
  coreConfig.types.rightsManagementPnpComponent ??= [];
995
+ // Single source of truth for the rights-management mount path.
996
+ const rightsManagementPath = envVars.rightsManagementCallbackPath ?? "rights-management";
943
997
  // We add a multi instance REST client for the remote negotiations
944
998
  // use a dummy endpoint for now as the actual endpoint will be provided in the config
945
999
  // of the policy negotiator when it is used for remote negotiations
@@ -948,7 +1002,8 @@ async function configureRightsManagement(coreConfig, envVars) {
948
1002
  coreConfig.types.rightsManagementPnpComponent.push({
949
1003
  type: RightsManagementPnpComponentType.RestClient,
950
1004
  options: {
951
- endpoint: "http://localhost"
1005
+ endpoint: "http://localhost",
1006
+ pathPrefix: rightsManagementPath
952
1007
  },
953
1008
  isMultiInstance: true,
954
1009
  features: ["remote"]
@@ -957,7 +1012,7 @@ async function configureRightsManagement(coreConfig, envVars) {
957
1012
  type: RightsManagementPnpComponentType.Service,
958
1013
  options: {
959
1014
  config: {
960
- callbackPath: envVars.rightsManagementCallbackPath ?? "",
1015
+ callbackPath: rightsManagementPath,
961
1016
  includeErrorDetails: coreConfig.debug ?? false
962
1017
  }
963
1018
  },
@@ -1024,7 +1079,7 @@ async function configureRightsManagement(coreConfig, envVars) {
1024
1079
  * @param envVars The environment variables.
1025
1080
  */
1026
1081
  async function configureTaskScheduler(coreConfig, envVars) {
1027
- if (Coerce.boolean(envVars.taskSchedulerEnabled) ?? false) {
1082
+ if (isTaskSchedulerRequired(envVars)) {
1028
1083
  coreConfig.types.taskSchedulerComponent ??= [];
1029
1084
  coreConfig.types.taskSchedulerComponent.push({
1030
1085
  type: TaskSchedulerComponentType.Service
@@ -1079,7 +1134,7 @@ async function configureSynchronisedStorage(coreConfig, envVars) {
1079
1134
  * @param envVars The environment variables.
1080
1135
  */
1081
1136
  async function configureFederatedCatalogue(coreConfig, envVars) {
1082
- if (Coerce.boolean(envVars.federatedCatalogueEnabled) ?? false) {
1137
+ if (isFederatedCatalogueRequired(envVars)) {
1083
1138
  // If synchronised storage is enabled, then we need to add an entity storage connector
1084
1139
  // using synchronised storage for the federated catalogue component
1085
1140
  // as it relies on the synchronised storage to sync the data between the different instances of the federated catalogue
@@ -1189,4 +1244,85 @@ function commaSeparatedListToArray(value) {
1189
1244
  .map(item => item.trim())
1190
1245
  .filter(item => item.length > 0);
1191
1246
  }
1247
+ /**
1248
+ * Checks if the trust subsystem is required.
1249
+ * Returns true when any component that depends on the trust subsystem is enabled.
1250
+ * @param envVars The environment variables.
1251
+ * @returns True if rights-management, synchronised-storage, or dataspace is enabled.
1252
+ */
1253
+ export function isTrustRequired(envVars) {
1254
+ return (isRightsManagementRequired(envVars) ||
1255
+ (Coerce.boolean(envVars.dataspaceEnabled) ?? false) ||
1256
+ (Coerce.boolean(envVars.synchronisedStorageEnabled) ?? false));
1257
+ }
1258
+ /**
1259
+ * Checks if the URL transformer subsystem is required.
1260
+ * Returns true when any component that depends on the URL transformer subsystem is enabled.
1261
+ * @param envVars The environment variables.
1262
+ * @returns True if rights-management, dataspace, federated-catalogue, or tenant is enabled.
1263
+ */
1264
+ export function isUrlTransformerRequired(envVars) {
1265
+ return (isRightsManagementRequired(envVars) ||
1266
+ (Coerce.boolean(envVars.dataspaceEnabled) ?? false) ||
1267
+ (Coerce.boolean(envVars.tenantEnabled) ?? false) ||
1268
+ isFederatedCatalogueRequired(envVars));
1269
+ }
1270
+ /**
1271
+ * Checks if the background tasks subsystem is required.
1272
+ * Returns true when any component that depends on the background tasks subsystem is enabled.
1273
+ * @param envVars The environment variables.
1274
+ * @returns True if dataspace or verifiable storage is enabled.
1275
+ */
1276
+ export function isBackgroundTasksRequired(envVars) {
1277
+ return (Coerce.boolean(envVars.dataspaceEnabled) ?? false) || isImmutableProofRequired(envVars);
1278
+ }
1279
+ /**
1280
+ * Checks if the immutable proof subsystem is required.
1281
+ * Returns true when any component that depends on the immutable proof subsystem is enabled.
1282
+ * @param envVars The environment variables.
1283
+ * @returns True if verifiable storage is enabled.
1284
+ */
1285
+ export function isImmutableProofRequired(envVars) {
1286
+ return (envVars.verifiableStorageConnector === VerifiableStorageConnectorType.EntityStorage ||
1287
+ envVars.verifiableStorageConnector === VerifiableStorageConnectorType.Iota);
1288
+ }
1289
+ /**
1290
+ * Checks if the immutable proof subsystem is required.
1291
+ * Returns true when any component that depends on the immutable proof subsystem is enabled.
1292
+ * @param envVars The environment variables.
1293
+ * @returns True if verifiable storage is enabled.
1294
+ */
1295
+ export function isFederatedCatalogueRequired(envVars) {
1296
+ return Coerce.boolean(envVars.dataspaceEnabled) ?? false;
1297
+ }
1298
+ /**
1299
+ * Checks if the rights management subsystem is required.
1300
+ * Returns true when any component that depends on the rights management subsystem is enabled.
1301
+ * @param envVars The environment variables.
1302
+ * @returns True if rights management is enabled.
1303
+ */
1304
+ export function isRightsManagementRequired(envVars) {
1305
+ return Coerce.boolean(envVars.dataspaceEnabled) ?? false;
1306
+ }
1307
+ /**
1308
+ * Checks if the task scheduler subsystem is required.
1309
+ * Returns true when any component that depends on the task scheduler subsystem is enabled.
1310
+ * @param envVars The environment variables.
1311
+ * @returns True if task scheduler is enabled.
1312
+ */
1313
+ export function isTaskSchedulerRequired(envVars) {
1314
+ return ((Coerce.boolean(envVars.dataspaceEnabled) ?? false) ||
1315
+ (Coerce.boolean(envVars.synchronisedStorageEnabled) ?? false) ||
1316
+ isRightsManagementRequired(envVars) ||
1317
+ isAuthEntityStorageRequired(envVars));
1318
+ }
1319
+ /**
1320
+ * Checks if the automation subsystem is required.
1321
+ * Returns true when any component that depends on the automation subsystem is enabled.
1322
+ * @param envVars The environment variables.
1323
+ * @returns True if automation is enabled.
1324
+ */
1325
+ export function isAutomationRequired(envVars) {
1326
+ return isRightsManagementRequired(envVars);
1327
+ }
1192
1328
  //# sourceMappingURL=engineEnvBuilder.js.map