@twin.org/node-core 0.9.5-next.1 → 0.10.0
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/es/builders/engineEnvBuilder.js +78 -2
- package/dist/es/builders/engineEnvBuilder.js.map +1 -1
- package/dist/es/defaults.js +34 -0
- package/dist/es/defaults.js.map +1 -1
- package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -1
- package/dist/es/models/engineEnvironmentVariableKeys.js +7 -0
- package/dist/es/models/engineEnvironmentVariableKeys.js.map +1 -1
- package/dist/es/node.js +1 -1
- package/dist/es/node.js.map +1 -1
- package/dist/types/defaults.d.ts +19 -0
- package/dist/types/models/IEngineEnvironmentVariables.d.ts +38 -0
- package/docs/changelog.md +41 -0
- package/docs/reference/index.md +4 -0
- package/docs/reference/interfaces/IEngineEnvironmentVariables.md +62 -0
- package/docs/reference/variables/COMPONENT_FACTORY_TYPE_NAME.md +5 -0
- package/docs/reference/variables/DEFAULT_TRACING_FACADE_COMPONENT_EXCLUDE_TYPES.md +8 -0
- package/docs/reference/variables/DEFAULT_TRACING_FACADE_FACTORIES.md +5 -0
- package/docs/reference/variables/TRACING_FACADE_NAME.md +5 -0
- package/package.json +35 -34
|
@@ -4,11 +4,12 @@ import { cpus } from "node:os";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { Is, Mutex } from "@twin.org/core";
|
|
6
6
|
import { EngineCloneMode } from "@twin.org/engine-models";
|
|
7
|
-
import { AttestationComponentType, AttestationConnectorType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, AutomationActionType, AutomationComponentType, BackgroundTaskComponentType, BlobStorageComponentType, BlobStorageConnectorType, ContextIdHandlerComponentType, DataConverterConnectorType, DataExtractorConnectorType, DataProcessingComponentType, DataspaceControlPlaneComponentType, DataspaceDataPlaneComponentType, DltConfigType, DocumentManagementComponentType, EmailProtocolConnectorType, EngineTypeHelper, EntityStorageConnectorType, EventBusComponentType, EventBusConnectorType, FaucetConnectorType, FederatedCatalogueComponentType, FederatedCatalogueFilterComponentType, HealthComponentType, IdentityComponentType, IdentityConnectorType, IdentityProfileComponentType, IdentityProfileConnectorType, IdentityResolverComponentType, IdentityResolverConnectorType, ImmutableProofComponentType, LoggingComponentType, LoggingConnectorType, MailboxComponentType, MailStorageComponentType, MessagingAdminComponentType, MessagingComponentType, MessagingEmailConnectorType, MessagingPushNotificationConnectorType, MessagingSmsConnectorType, MetricsCollectorComponentType, MetricsProducerComponentType, NftComponentType, NftConnectorType, NotarizationComponentType, NotarizationConnectorType, PlatformComponentType, RightsManagementPapComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementPipComponentType, RightsManagementPmpComponentType, RightsManagementPnapComponentType, RightsManagementPnpComponentType, RightsManagementPolicyArbiterComponentType, RightsManagementPolicyEnforcementProcessorComponentType, RightsManagementPolicyExecutionActionComponentType, RightsManagementPolicyInformationSourceComponentType, RightsManagementPolicyNegotiatorComponentType, RightsManagementPolicyObligationEnforcerComponentType, RightsManagementPolicyRequesterComponentType, RightsManagementPxpComponentType, SchemaVersionMigrationComponentType, TaskSchedulerComponentType, TelemetryComponentType, TelemetryConnectorType, TenantAdminComponentType, TracingComponentType, TracingConnectorType, TrustComponentType, TrustGeneratorComponentType, TrustVerifierComponentType, VaultConnectorType, WalletConnectorType } from "@twin.org/engine-types";
|
|
7
|
+
import { AttestationComponentType, AttestationConnectorType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, AutomationActionType, AutomationComponentType, BackgroundTaskComponentType, BlobStorageComponentType, BlobStorageConnectorType, ContextIdHandlerComponentType, DataConverterConnectorType, DataExtractorConnectorType, DataProcessingComponentType, DataspaceControlPlaneComponentType, DataspaceDataPlaneComponentType, DltConfigType, DocumentManagementComponentType, EmailProtocolConnectorType, EngineTypeHelper, EntityStorageConnectorType, EventBusComponentType, EventBusConnectorType, FacadeType, FaucetConnectorType, FederatedCatalogueComponentType, FederatedCatalogueFilterComponentType, HealthComponentType, IdentityComponentType, IdentityConnectorType, IdentityProfileComponentType, IdentityProfileConnectorType, IdentityResolverComponentType, IdentityResolverConnectorType, ImmutableProofComponentType, LoggingComponentType, LoggingConnectorType, MailboxComponentType, MailStorageComponentType, MessagingAdminComponentType, MessagingComponentType, MessagingEmailConnectorType, MessagingPushNotificationConnectorType, MessagingSmsConnectorType, MetricsCollectorComponentType, MetricsProducerComponentType, NftComponentType, NftConnectorType, NotarizationComponentType, NotarizationConnectorType, PlatformComponentType, RightsManagementPapComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementPipComponentType, RightsManagementPmpComponentType, RightsManagementPnapComponentType, RightsManagementPnpComponentType, RightsManagementPolicyArbiterComponentType, RightsManagementPolicyEnforcementProcessorComponentType, RightsManagementPolicyExecutionActionComponentType, RightsManagementPolicyInformationSourceComponentType, RightsManagementPolicyNegotiatorComponentType, RightsManagementPolicyObligationEnforcerComponentType, RightsManagementPolicyRequesterComponentType, RightsManagementPxpComponentType, SchemaVersionMigrationComponentType, TaskSchedulerComponentType, TelemetryComponentType, TelemetryConnectorType, TenantAdminComponentType, TracingComponentType, TracingConnectorType, TrustComponentType, TrustGeneratorComponentType, TrustVerifierComponentType, VaultConnectorType, WalletConnectorType } from "@twin.org/engine-types";
|
|
8
8
|
import { OpenTelemetryExporterTypes } from "@twin.org/logging-connector-opentelemetry";
|
|
9
9
|
import { OpenTelemetryReaderTypes } from "@twin.org/telemetry-connector-opentelemetry";
|
|
10
10
|
import { OpenTelemetryProcessorTypes } from "@twin.org/tracing-connector-opentelemetry";
|
|
11
|
-
import {
|
|
11
|
+
import { TracingFacade } from "@twin.org/tracing-facades";
|
|
12
|
+
import { CONTEXT_ID_HANDLER_FEATURE_DID, CONTEXT_ID_HANDLER_FEATURE_TENANT, COMPONENT_FACTORY_TYPE_NAME, DEFAULT_HEALTH_EXCLUDE_CLONE_COMPONENTS, DEFAULT_TRACING_FACADE_COMPONENT_EXCLUDE_TYPES, DEFAULT_TRACING_FACADE_FACTORIES, TRACING_FACADE_NAME } from "../defaults.js";
|
|
12
13
|
import { isAuthEntityStorageRequired } from "./engineServerEnvBuilder.js";
|
|
13
14
|
import { commaSeparatedListToArray, envArray, envBoolean, envChoice, envCount, envDateTime, envInteger, envListToArray, envMinToMs, envMinutes, envMs, envSecToMs, envSeconds } from "./helper/envHelpers.js";
|
|
14
15
|
/**
|
|
@@ -51,6 +52,7 @@ export async function buildEngineConfiguration(envVars) {
|
|
|
51
52
|
await configureTelemetry(coreConfig, envVars);
|
|
52
53
|
await configureMetricsCollector(coreConfig, envVars);
|
|
53
54
|
await configureTracing(coreConfig, envVars);
|
|
55
|
+
await configureFacades(coreConfig, envVars);
|
|
54
56
|
await configureMessaging(coreConfig, envVars);
|
|
55
57
|
await configureMailbox(coreConfig, envVars);
|
|
56
58
|
await configureAutomation(coreConfig, envVars);
|
|
@@ -719,6 +721,80 @@ async function configureTracing(coreConfig, envVars) {
|
|
|
719
721
|
coreConfig.types.tracingComponent.push({ type: TracingComponentType.Service });
|
|
720
722
|
}
|
|
721
723
|
}
|
|
724
|
+
/**
|
|
725
|
+
* Configures the facades.
|
|
726
|
+
* @param coreConfig The core config.
|
|
727
|
+
* @param envVars The environment variables.
|
|
728
|
+
* @returns A promise that resolves when the facade configuration has been applied.
|
|
729
|
+
*/
|
|
730
|
+
async function configureFacades(coreConfig, envVars) {
|
|
731
|
+
const facadeTypes = envListToArray(envVars, "facade", Object.values(FacadeType));
|
|
732
|
+
if (!Is.arrayValue(facadeTypes)) {
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
coreConfig.types.facade ??= [];
|
|
736
|
+
coreConfig.facades ??= {};
|
|
737
|
+
for (const facadeType of facadeTypes) {
|
|
738
|
+
if (facadeType === FacadeType.Tracing) {
|
|
739
|
+
configureTracingFacade(coreConfig.types.facade, coreConfig.facades, envVars);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Configures the tracing facade.
|
|
745
|
+
* @param facadeTypeConfigs The facade type configs to add to.
|
|
746
|
+
* @param facades The facades to activate, keyed by the type name of the factory they apply to.
|
|
747
|
+
* @param envVars The environment variables.
|
|
748
|
+
*/
|
|
749
|
+
function configureTracingFacade(facadeTypeConfigs, facades, envVars) {
|
|
750
|
+
// The facade records its spans through the tracing subsystem, without it there is nothing to record to.
|
|
751
|
+
if (!isTracingEnabled(envVars)) {
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
// The facade is meaningless without factories to activate it on, so fall back to the defaults.
|
|
755
|
+
const configuredFactoryTypeNames = commaSeparatedListToArray(envVars.tracingFacadeFactories);
|
|
756
|
+
const factoryTypeNames = [
|
|
757
|
+
...new Set(Is.arrayValue(configuredFactoryTypeNames)
|
|
758
|
+
? configuredFactoryTypeNames
|
|
759
|
+
: DEFAULT_TRACING_FACADE_FACTORIES)
|
|
760
|
+
];
|
|
761
|
+
const config = {};
|
|
762
|
+
// Adding to the default excludes. We want to keep default list as a base and only add to it.
|
|
763
|
+
const excludeParams = commaSeparatedListToArray(envVars.tracingFacadeExcludeParams);
|
|
764
|
+
if (Is.arrayValue(excludeParams)) {
|
|
765
|
+
config.excludeParams = [
|
|
766
|
+
...new Set([...TracingFacade.DEFAULT_EXCLUDE_PARAMS, ...excludeParams])
|
|
767
|
+
];
|
|
768
|
+
}
|
|
769
|
+
const excludeMethods = commaSeparatedListToArray(envVars.tracingFacadeExcludeMethods);
|
|
770
|
+
if (Is.arrayValue(excludeMethods)) {
|
|
771
|
+
config.excludeMethods = [
|
|
772
|
+
...new Set([...TracingFacade.DEFAULT_EXCLUDE_METHODS, ...excludeMethods])
|
|
773
|
+
];
|
|
774
|
+
}
|
|
775
|
+
const includeObjects = commaSeparatedListToArray(envVars.tracingFacadeIncludeObjects);
|
|
776
|
+
if (Is.arrayValue(includeObjects)) {
|
|
777
|
+
config.includeObjects = includeObjects;
|
|
778
|
+
}
|
|
779
|
+
facadeTypeConfigs.push({
|
|
780
|
+
type: FacadeType.Tracing,
|
|
781
|
+
options: Is.objectValue(config) ? { config } : undefined,
|
|
782
|
+
cloneMode: EngineCloneMode.Always
|
|
783
|
+
});
|
|
784
|
+
const componentExcludeTypes = [
|
|
785
|
+
...new Set([
|
|
786
|
+
...DEFAULT_TRACING_FACADE_COMPONENT_EXCLUDE_TYPES,
|
|
787
|
+
...commaSeparatedListToArray(envVars.tracingFacadeComponentExcludeTypes)
|
|
788
|
+
])
|
|
789
|
+
];
|
|
790
|
+
for (const factoryTypeName of factoryTypeNames) {
|
|
791
|
+
facades[factoryTypeName] ??= [];
|
|
792
|
+
facades[factoryTypeName].push({
|
|
793
|
+
name: TRACING_FACADE_NAME,
|
|
794
|
+
excludeTypes: factoryTypeName === COMPONENT_FACTORY_TYPE_NAME ? componentExcludeTypes : undefined
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
}
|
|
722
798
|
/**
|
|
723
799
|
* Configures the automation.
|
|
724
800
|
* @param coreConfig The core config.
|