@twin.org/node-core 0.9.1-next.8 → 0.9.1

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.
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
3
  import path from "node:path";
4
4
  import { Coerce, Is, Mutex } 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, HealthComponentType, IdentityComponentType, IdentityConnectorType, IdentityProfileComponentType, IdentityProfileConnectorType, IdentityResolverComponentType, IdentityResolverConnectorType, ImmutableProofComponentType, LoggingComponentType, LoggingConnectorType, MessagingAdminComponentType, MessagingComponentType, MessagingEmailConnectorType, MessagingPushNotificationConnectorType, MessagingSmsConnectorType, MetricsCollectorComponentType, MetricsProducerComponentType, NftComponentType, NftConnectorType, NotarizationComponentType, NotarizationConnectorType, PlatformComponentType, RightsManagementPapComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementPipComponentType, RightsManagementPmpComponentType, RightsManagementPnapComponentType, RightsManagementPnpComponentType, RightsManagementPxpComponentType, TaskSchedulerComponentType, TelemetryComponentType, TelemetryConnectorType, TenantAdminComponentType, TrustComponentType, TrustVerifierComponentType, VaultConnectorType, 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, MetricsCollectorComponentType, MetricsProducerComponentType, NftComponentType, NftConnectorType, NotarizationComponentType, NotarizationConnectorType, PlatformComponentType, RightsManagementPapComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementPipComponentType, RightsManagementPmpComponentType, RightsManagementPnapComponentType, RightsManagementPnpComponentType, RightsManagementPxpComponentType, SchemaVersionMigrationComponentType, TaskSchedulerComponentType, TelemetryComponentType, TelemetryConnectorType, TenantAdminComponentType, TrustComponentType, TrustVerifierComponentType, VaultConnectorType, WalletConnectorType } from "@twin.org/engine-types";
6
6
  import { OpenTelemetryExporterTypes } from "@twin.org/logging-connector-opentelemetry";
7
7
  import { OpenTelemetryReaderTypes } from "@twin.org/telemetry-connector-opentelemetry";
8
8
  import { CONTEXT_ID_HANDLER_FEATURE_DID, CONTEXT_ID_HANDLER_FEATURE_TENANT } from "../defaults.js";
@@ -28,6 +28,7 @@ export async function buildEngineConfiguration(envVars) {
28
28
  if (!Is.empty(mutexTimeoutMs)) {
29
29
  Mutex.setDefaultTimeoutMs(mutexTimeoutMs);
30
30
  }
31
+ await configureSchemaMigration(coreConfig, envVars);
31
32
  await configurePlatform(coreConfig, envVars);
32
33
  await configureTenant(coreConfig, envVars);
33
34
  await configureContextIdHandlers(coreConfig, envVars);
@@ -343,6 +344,10 @@ async function configureLogging(coreConfig, envVars) {
343
344
  config: {
344
345
  batchSize: Coerce.integer(envVars.loggingBatchSize),
345
346
  batchIntervalMs: (Coerce.integer(envVars.loggingBatchFlushInterval) ?? 5) * 1000,
347
+ retainForMs: (Coerce.integer(envVars.loggingRetainFor) ?? 2880) * 60_000,
348
+ maxEntries: Coerce.integer(envVars.loggingMaxEntries),
349
+ retentionIntervalMs: (Coerce.integer(envVars.loggingRetentionInterval) ?? 5) * 60_000,
350
+ retentionBatchSize: Coerce.integer(envVars.loggingRetentionBatchSize),
346
351
  mutexTimeoutMs: Coerce.integer(envVars.loggingMutexTimeout)
347
352
  }
348
353
  }
@@ -372,6 +377,21 @@ async function configureLogging(coreConfig, envVars) {
372
377
  });
373
378
  additionalConnectorCount++;
374
379
  }
380
+ else if (loggingConnector === LoggingConnectorType.File) {
381
+ coreConfig.types.loggingConnector.push({
382
+ type: LoggingConnectorType.File,
383
+ options: {
384
+ config: {
385
+ directory: envVars.loggingFileDirectory ?? envVars.storageFileRoot ?? "",
386
+ filename: envVars.loggingFileFilename,
387
+ maxFileSizeBytes: Coerce.integer(envVars.loggingFileMaxFileSizeBytes),
388
+ maxRetainedFiles: Coerce.integer(envVars.loggingFileMaxRetainedFiles),
389
+ mutexTimeoutMs: Coerce.integer(envVars.loggingMutexTimeout)
390
+ }
391
+ }
392
+ });
393
+ additionalConnectorCount++;
394
+ }
375
395
  }
376
396
  // If more than one logging connector, then we need to add a multi connector
377
397
  // and set it as the default one
@@ -510,7 +530,8 @@ async function configureMetricsCollector(coreConfig, envVars) {
510
530
  coreConfig.types.metricsCollectorComponent ??= [];
511
531
  coreConfig.types.metricsCollectorComponent.push({
512
532
  type: MetricsCollectorComponentType.Service,
513
- options: { config: { intervalMs: intervalSec * 1000 } }
533
+ options: { config: { intervalMs: intervalSec * 1000 } },
534
+ isCloneable: false
514
535
  });
515
536
  const maxHistory = Coerce.integer(envVars.telemetryMetricsProducerMaxHistory) ?? 1440;
516
537
  coreConfig.types.metricsProducerComponent ??= [];
@@ -519,7 +540,8 @@ async function configureMetricsCollector(coreConfig, envVars) {
519
540
  for (const producerType of metricsProducers) {
520
541
  coreConfig.types.metricsProducerComponent.push({
521
542
  type: producerType,
522
- options: { maxHistory }
543
+ options: { maxHistory },
544
+ isCloneable: false
523
545
  });
524
546
  }
525
547
  }
@@ -564,7 +586,24 @@ async function configureHealth(coreConfig, envVars) {
564
586
  healthCheckInterval: (Coerce.integer(envVars.healthInterval) ?? 60) * 1000,
565
587
  initialInterval: (Coerce.integer(envVars.healthStartupInterval) ?? 2) * 1000
566
588
  }
567
- }
589
+ },
590
+ isCloneable: false
591
+ });
592
+ }
593
+ }
594
+ /**
595
+ * Configures the schema migration.
596
+ * @param coreConfig The core config.
597
+ * @param envVars The environment variables.
598
+ * @returns A promise that resolves when the schema migration configuration has been applied.
599
+ */
600
+ async function configureSchemaMigration(coreConfig, envVars) {
601
+ const isSchemaMigrationEnabled = Coerce.boolean(envVars.schemaMigrationEnabled) ?? true;
602
+ if (isSchemaMigrationEnabled) {
603
+ coreConfig.types.schemaVersionMigrationComponent ??= [];
604
+ coreConfig.types.schemaVersionMigrationComponent.push({
605
+ type: SchemaVersionMigrationComponentType.Service,
606
+ isCloneable: false
568
607
  });
569
608
  }
570
609
  }
@@ -858,7 +897,8 @@ async function configureIdentity(coreConfig, envVars) {
858
897
  identityPkgId: Is.stringValue(envVars.iotaIdentityPackageId)
859
898
  ? envVars.iotaIdentityPackageId
860
899
  : undefined,
861
- walletAddressIndex: Coerce.integer(envVars.identityWalletAddressIndex) ?? 0
900
+ walletAddressIndex: Coerce.integer(envVars.identityWalletAddressIndex) ?? 0,
901
+ didResolutionCacheTtlMs: Coerce.integer(envVars.identityDidResolutionCacheTtlMs)
862
902
  }
863
903
  }
864
904
  });
@@ -1235,7 +1275,8 @@ async function configureFederatedCatalogue(coreConfig, envVars) {
1235
1275
  coreConfig.types.federatedCatalogueComponent.push({
1236
1276
  type: FederatedCatalogueComponentType.RestClient,
1237
1277
  options: {
1238
- endpoint: envVars.federatedCatalogueRemoteEndpoint
1278
+ endpoint: envVars.federatedCatalogueRemoteEndpoint,
1279
+ pathPrefix: envVars.federatedCatalogueRestClientPathPrefix ?? "federated-catalogue"
1239
1280
  }
1240
1281
  });
1241
1282
  }
@@ -1345,7 +1386,9 @@ async function configureDlt(coreConfig, envVars) {
1345
1386
  },
1346
1387
  network: envVars.iotaNetwork ?? "",
1347
1388
  coinType: Coerce.integer(envVars.iotaCoinType),
1348
- gasStation: gasStationConfig
1389
+ gasStation: gasStationConfig,
1390
+ gasBudget: Coerce.integer(envVars.iotaGasBudget),
1391
+ gasReservationDuration: Coerce.integer(envVars.iotaGasReservationDuration)
1349
1392
  }
1350
1393
  }
1351
1394
  });