@twin.org/node-core 0.0.3-next.34 → 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 (29) hide show
  1. package/dist/es/builders/engineEnvBuilder.js +110 -10
  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 -23
  6. package/dist/es/commands/bootstrapLegacy.js.map +1 -1
  7. package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -1
  8. package/dist/es/models/IEngineServerEnvironmentVariables.js.map +1 -1
  9. package/dist/es/node.js +1 -1
  10. package/dist/es/node.js.map +1 -1
  11. package/dist/types/builders/engineEnvBuilder.d.ts +56 -0
  12. package/dist/types/builders/engineServerEnvBuilder.d.ts +7 -0
  13. package/dist/types/models/IEngineEnvironmentVariables.d.ts +10 -27
  14. package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +4 -0
  15. package/docs/changelog.md +10 -2
  16. package/docs/reference/functions/isAuthEntityStorageRequired.md +20 -0
  17. package/docs/reference/functions/isAutomationRequired.md +20 -0
  18. package/docs/reference/functions/isBackgroundTasksRequired.md +20 -0
  19. package/docs/reference/functions/isFederatedCatalogueRequired.md +20 -0
  20. package/docs/reference/functions/isImmutableProofRequired.md +20 -0
  21. package/docs/reference/functions/isRightsManagementRequired.md +20 -0
  22. package/docs/reference/functions/isTaskSchedulerRequired.md +20 -0
  23. package/docs/reference/functions/isTrustRequired.md +20 -0
  24. package/docs/reference/functions/isUrlTransformerRequired.md +20 -0
  25. package/docs/reference/index.md +9 -0
  26. package/docs/reference/interfaces/IEngineEnvironmentVariables.md +11 -52
  27. package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +20 -77
  28. package/docs/reference/interfaces/INodeEnvironmentVariables.md +24 -77
  29. package/package.json +3 -3
@@ -4,6 +4,7 @@ import path from "node:path";
4
4
  import { Coerce, Is } from "@twin.org/core";
5
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.
@@ -41,6 +42,7 @@ export async function buildEngineConfiguration(envVars, contextIdKeys) {
41
42
  await configureNft(coreConfig, envVars);
42
43
  await configureNotarization(coreConfig, envVars);
43
44
  await configureVerifiableStorage(coreConfig, envVars);
45
+ await configureImmutableProof(coreConfig, envVars);
44
46
  await configureIdentity(coreConfig, envVars);
45
47
  await configureIdentityResolver(coreConfig, envVars);
46
48
  await configureIdentityProfile(coreConfig, envVars);
@@ -393,7 +395,7 @@ async function configureVault(coreConfig, envVars) {
393
395
  */
394
396
  async function configureBackgroundTask(coreConfig, envVars) {
395
397
  coreConfig.types.backgroundTaskComponent ??= [];
396
- if (Coerce.boolean(envVars.backgroundTasksEnabled) ?? false) {
398
+ if (isBackgroundTasksRequired(envVars)) {
397
399
  coreConfig.types.backgroundTaskComponent.push({
398
400
  type: BackgroundTaskComponentType.Service
399
401
  });
@@ -440,7 +442,7 @@ async function configureTelemetry(coreConfig, envVars) {
440
442
  */
441
443
  async function configureAutomation(coreConfig, envVars) {
442
444
  coreConfig.types.automationComponent ??= [];
443
- if (Coerce.boolean(envVars.automationEnabled) ?? false) {
445
+ if (isAutomationRequired(envVars)) {
444
446
  coreConfig.types.automationComponent.push({
445
447
  type: AutomationComponentType.Service
446
448
  });
@@ -465,7 +467,12 @@ async function configureHealth(coreConfig, envVars) {
465
467
  coreConfig.types.healthComponent ??= [];
466
468
  if (Coerce.boolean(envVars.healthEnabled) ?? false) {
467
469
  coreConfig.types.healthComponent.push({
468
- type: HealthComponentType.Service
470
+ type: HealthComponentType.Service,
471
+ options: {
472
+ config: {
473
+ healthCheckInterval: (Coerce.integer(envVars.healthIntervalSeconds) ?? 60) * 1000
474
+ }
475
+ }
469
476
  });
470
477
  }
471
478
  }
@@ -476,7 +483,7 @@ async function configureHealth(coreConfig, envVars) {
476
483
  */
477
484
  async function configureUrlTransformer(coreConfig, envVars) {
478
485
  coreConfig.types.urlTransformerComponent ??= [];
479
- if (Coerce.boolean(envVars.urlTransformerEnabled) ?? false) {
486
+ if (isUrlTransformerRequired(envVars) ?? false) {
480
487
  coreConfig.types.urlTransformerComponent.push({
481
488
  type: UrlTransformerComponentType.Service,
482
489
  options: {
@@ -728,6 +735,15 @@ async function configureVerifiableStorage(coreConfig, envVars) {
728
735
  coreConfig.types.verifiableStorageComponent.push({
729
736
  type: VerifiableStorageComponentType.Service
730
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)) {
731
747
  coreConfig.types.immutableProofComponent ??= [];
732
748
  coreConfig.types.immutableProofComponent.push({
733
749
  type: ImmutableProofComponentType.Service,
@@ -917,7 +933,7 @@ async function configureDocumentManagement(coreConfig, envVars) {
917
933
  * @param envVars The environment variables.
918
934
  */
919
935
  async function configureTrust(coreConfig, envVars) {
920
- if (Coerce.boolean(envVars.trustEnabled) ?? false) {
936
+ if (isTrustRequired(envVars)) {
921
937
  coreConfig.types.trustComponent ??= [];
922
938
  coreConfig.types.trustComponent.push({
923
939
  type: TrustComponentType.Service
@@ -950,7 +966,7 @@ async function configureTrust(coreConfig, envVars) {
950
966
  * @param envVars The environment variables.
951
967
  */
952
968
  async function configureRightsManagement(coreConfig, envVars) {
953
- if (Coerce.boolean(envVars.rightsManagementEnabled) ?? false) {
969
+ if (isRightsManagementRequired(envVars)) {
954
970
  coreConfig.types.rightsManagementPapComponent ??= [];
955
971
  coreConfig.types.rightsManagementPapComponent.push({
956
972
  type: RightsManagementPapComponentType.Service
@@ -976,6 +992,8 @@ async function configureRightsManagement(coreConfig, envVars) {
976
992
  type: RightsManagementPepComponentType.Service
977
993
  });
978
994
  coreConfig.types.rightsManagementPnpComponent ??= [];
995
+ // Single source of truth for the rights-management mount path.
996
+ const rightsManagementPath = envVars.rightsManagementCallbackPath ?? "rights-management";
979
997
  // We add a multi instance REST client for the remote negotiations
980
998
  // use a dummy endpoint for now as the actual endpoint will be provided in the config
981
999
  // of the policy negotiator when it is used for remote negotiations
@@ -984,7 +1002,8 @@ async function configureRightsManagement(coreConfig, envVars) {
984
1002
  coreConfig.types.rightsManagementPnpComponent.push({
985
1003
  type: RightsManagementPnpComponentType.RestClient,
986
1004
  options: {
987
- endpoint: "http://localhost"
1005
+ endpoint: "http://localhost",
1006
+ pathPrefix: rightsManagementPath
988
1007
  },
989
1008
  isMultiInstance: true,
990
1009
  features: ["remote"]
@@ -993,7 +1012,7 @@ async function configureRightsManagement(coreConfig, envVars) {
993
1012
  type: RightsManagementPnpComponentType.Service,
994
1013
  options: {
995
1014
  config: {
996
- callbackPath: envVars.rightsManagementCallbackPath ?? "",
1015
+ callbackPath: rightsManagementPath,
997
1016
  includeErrorDetails: coreConfig.debug ?? false
998
1017
  }
999
1018
  },
@@ -1060,7 +1079,7 @@ async function configureRightsManagement(coreConfig, envVars) {
1060
1079
  * @param envVars The environment variables.
1061
1080
  */
1062
1081
  async function configureTaskScheduler(coreConfig, envVars) {
1063
- if (Coerce.boolean(envVars.taskSchedulerEnabled) ?? false) {
1082
+ if (isTaskSchedulerRequired(envVars)) {
1064
1083
  coreConfig.types.taskSchedulerComponent ??= [];
1065
1084
  coreConfig.types.taskSchedulerComponent.push({
1066
1085
  type: TaskSchedulerComponentType.Service
@@ -1115,7 +1134,7 @@ async function configureSynchronisedStorage(coreConfig, envVars) {
1115
1134
  * @param envVars The environment variables.
1116
1135
  */
1117
1136
  async function configureFederatedCatalogue(coreConfig, envVars) {
1118
- if (Coerce.boolean(envVars.federatedCatalogueEnabled) ?? false) {
1137
+ if (isFederatedCatalogueRequired(envVars)) {
1119
1138
  // If synchronised storage is enabled, then we need to add an entity storage connector
1120
1139
  // using synchronised storage for the federated catalogue component
1121
1140
  // as it relies on the synchronised storage to sync the data between the different instances of the federated catalogue
@@ -1225,4 +1244,85 @@ function commaSeparatedListToArray(value) {
1225
1244
  .map(item => item.trim())
1226
1245
  .filter(item => item.length > 0);
1227
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
+ }
1228
1328
  //# sourceMappingURL=engineEnvBuilder.js.map