@twin.org/node-core 0.9.3 → 0.9.4-next.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.
Files changed (33) hide show
  1. package/dist/es/builders/engineEnvBuilder.js +451 -363
  2. package/dist/es/builders/engineEnvBuilder.js.map +1 -1
  3. package/dist/es/builders/helper/envHelpers.js +39 -0
  4. package/dist/es/builders/helper/envHelpers.js.map +1 -1
  5. package/dist/es/cli.js +1 -1
  6. package/dist/es/cli.js.map +1 -1
  7. package/dist/es/commands/bootstrapDev.js +3 -3
  8. package/dist/es/commands/bootstrapDev.js.map +1 -1
  9. package/dist/es/commands/help.js +1 -1
  10. package/dist/es/commands/help.js.map +1 -1
  11. package/dist/es/commands/identityCreate.js +2 -2
  12. package/dist/es/commands/identityCreate.js.map +1 -1
  13. package/dist/es/commands/identityVerificationMethodCreate.js +2 -2
  14. package/dist/es/commands/identityVerificationMethodCreate.js.map +1 -1
  15. package/dist/es/commands/userCreate.js +1 -1
  16. package/dist/es/commands/userCreate.js.map +1 -1
  17. package/dist/es/commands/vaultKeyCreate.js +1 -1
  18. package/dist/es/commands/vaultKeyCreate.js.map +1 -1
  19. package/dist/es/commands/vaultKeyImport.js +1 -1
  20. package/dist/es/commands/vaultKeyImport.js.map +1 -1
  21. package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -1
  22. package/dist/es/models/engineEnvironmentVariableKeys.js +7 -2
  23. package/dist/es/models/engineEnvironmentVariableKeys.js.map +1 -1
  24. package/dist/es/node.js +12 -20
  25. package/dist/es/node.js.map +1 -1
  26. package/dist/types/builders/engineEnvBuilder.d.ts +7 -0
  27. package/dist/types/builders/helper/envHelpers.d.ts +30 -0
  28. package/dist/types/models/IEngineEnvironmentVariables.d.ts +24 -8
  29. package/docs/changelog.md +159 -0
  30. package/docs/reference/functions/isMailboxEnabled.md +20 -0
  31. package/docs/reference/index.md +1 -0
  32. package/docs/reference/interfaces/IEngineEnvironmentVariables.md +45 -13
  33. package/package.json +34 -34
@@ -3,13 +3,13 @@
3
3
  import path from "node:path";
4
4
  import { Is, Mutex } from "@twin.org/core";
5
5
  import { EngineCloneMode } from "@twin.org/engine-models";
6
- 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, TracingComponentType, TracingConnectorType, TrustComponentType, TrustVerifierComponentType, VaultConnectorType, WalletConnectorType } from "@twin.org/engine-types";
6
+ 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
7
  import { OpenTelemetryExporterTypes } from "@twin.org/logging-connector-opentelemetry";
8
8
  import { OpenTelemetryReaderTypes } from "@twin.org/telemetry-connector-opentelemetry";
9
9
  import { OpenTelemetryProcessorTypes } from "@twin.org/tracing-connector-opentelemetry";
10
10
  import { CONTEXT_ID_HANDLER_FEATURE_DID, CONTEXT_ID_HANDLER_FEATURE_TENANT } from "../defaults.js";
11
11
  import { isAuthEntityStorageRequired } from "./engineServerEnvBuilder.js";
12
- import { commaSeparatedListToArray, envArray, envBoolean, envCount, envDateTime, envInteger, envMinToMs, envMinutes, envMs, envSecToMs, envSeconds } from "./helper/envHelpers.js";
12
+ import { commaSeparatedListToArray, envArray, envBoolean, envChoice, envCount, envDateTime, envInteger, envListToArray, envMinToMs, envMinutes, envMs, envSecToMs, envSeconds } from "./helper/envHelpers.js";
13
13
  /**
14
14
  * Build the engine core configuration from environment variables.
15
15
  * @param envVars The environment variables.
@@ -32,7 +32,7 @@ export async function buildEngineConfiguration(envVars) {
32
32
  types: {}
33
33
  };
34
34
  const mutexTimeoutMs = envMs(envVars, "mutexTimeoutDefault");
35
- if (!Is.empty(mutexTimeoutMs)) {
35
+ if (Is.notEmpty(mutexTimeoutMs)) {
36
36
  Mutex.setDefaultTimeoutMs(mutexTimeoutMs);
37
37
  }
38
38
  await configureSchemaMigration(coreConfig, envVars);
@@ -51,6 +51,7 @@ export async function buildEngineConfiguration(envVars) {
51
51
  await configureMetricsCollector(coreConfig, envVars);
52
52
  await configureTracing(coreConfig, envVars);
53
53
  await configureMessaging(coreConfig, envVars);
54
+ await configureMailbox(coreConfig, envVars);
54
55
  await configureAutomation(coreConfig, envVars);
55
56
  await configureHealth(coreConfig, envVars);
56
57
  await configureFaucet(coreConfig, envVars);
@@ -81,163 +82,165 @@ export async function buildEngineConfiguration(envVars) {
81
82
  async function configureEntityStorage(coreConfig, envVars) {
82
83
  coreConfig.types ??= {};
83
84
  coreConfig.types.entityStorageConnector ??= [];
84
- const entityStorageConnectorTypes = commaSeparatedListToArray(envVars.entityStorageConnectorType);
85
- if (entityStorageConnectorTypes.includes(EntityStorageConnectorType.Memory)) {
86
- coreConfig.types.entityStorageConnector.push({
87
- type: EntityStorageConnectorType.Memory,
88
- options: {
89
- config: {
90
- mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout")
91
- }
92
- }
93
- });
94
- }
95
- if (entityStorageConnectorTypes.includes(EntityStorageConnectorType.File)) {
96
- coreConfig.types.entityStorageConnector.push({
97
- type: EntityStorageConnectorType.File,
98
- options: {
99
- config: {
100
- directory: envVars.storageFileRoot ?? "",
101
- mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout")
102
- },
103
- folderPrefix: envVars.entityStorageTablePrefix
104
- }
105
- });
106
- }
107
- if (entityStorageConnectorTypes.includes(EntityStorageConnectorType.AwsDynamoDb)) {
108
- coreConfig.types.entityStorageConnector.push({
109
- type: EntityStorageConnectorType.AwsDynamoDb,
110
- options: {
111
- config: {
112
- region: envVars.awsDynamodbRegion ?? "",
113
- authMode: envVars.awsDynamodbAuthMode,
114
- accessKeyId: envVars.awsDynamodbAccessKeyId,
115
- secretAccessKey: envVars.awsDynamodbSecretAccessKey,
116
- endpoint: envVars.awsDynamodbEndpoint,
117
- connectionTimeoutMs: envMs(envVars, "awsDynamodbConnectionTimeout"),
118
- mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout")
119
- },
120
- tablePrefix: envVars.entityStorageTablePrefix
121
- }
122
- });
123
- }
124
- if (entityStorageConnectorTypes.includes(EntityStorageConnectorType.AzureCosmosDb)) {
125
- coreConfig.types.entityStorageConnector.push({
126
- type: EntityStorageConnectorType.AzureCosmosDb,
127
- options: {
128
- config: {
129
- endpoint: envVars.azureCosmosdbEndpoint ?? "",
130
- key: envVars.azureCosmosdbKey ?? "",
131
- databaseId: envVars.azureCosmosdbDatabaseId ?? "",
132
- containerId: envVars.azureCosmosdbContainerId ?? "",
133
- mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout")
134
- },
135
- tablePrefix: envVars.entityStorageTablePrefix
136
- }
137
- });
138
- }
139
- if (entityStorageConnectorTypes.includes(EntityStorageConnectorType.GcpFirestoreDb)) {
140
- coreConfig.types.entityStorageConnector.push({
141
- type: EntityStorageConnectorType.GcpFirestoreDb,
142
- options: {
143
- config: {
144
- projectId: envVars.gcpFirestoreProjectId ?? "",
145
- credentials: envVars.gcpFirestoreCredentials ?? "",
146
- databaseId: envVars.gcpFirestoreDatabaseId ?? "",
147
- collectionName: envVars.gcpFirestoreCollectionName ?? "",
148
- endpoint: envVars.gcpFirestoreEndpoint ?? "",
149
- mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout")
150
- },
151
- tablePrefix: envVars.entityStorageTablePrefix
152
- }
153
- });
154
- }
155
- if (entityStorageConnectorTypes.includes(EntityStorageConnectorType.ScyllaDb)) {
156
- coreConfig.types.entityStorageConnector.push({
157
- type: EntityStorageConnectorType.ScyllaDb,
158
- options: {
159
- config: {
160
- hosts: commaSeparatedListToArray(envVars.scylladbHosts),
161
- localDataCenter: envVars.scylladbLocalDataCenter ?? "",
162
- keyspace: envVars.scylladbKeyspace ?? "",
163
- port: envInteger(envVars, "scylladbPort"),
164
- mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout"),
165
- pool: {
166
- coreConnectionsPerHost: envCount(envVars, "scylladbPoolCoreConnectionsPerHost"),
167
- maxRequestsPerConnection: envCount(envVars, "scylladbPoolMaxRequestsPerConnection")
168
- }
169
- },
170
- tablePrefix: envVars.entityStorageTablePrefix
171
- }
172
- });
173
- }
174
- if (entityStorageConnectorTypes.includes(EntityStorageConnectorType.MySqlDb)) {
175
- coreConfig.types.entityStorageConnector.push({
176
- type: EntityStorageConnectorType.MySqlDb,
177
- options: {
178
- config: {
179
- host: envVars.mySqlHost ?? "",
180
- port: envInteger(envVars, "mySqlPort"),
181
- user: envVars.mySqlUser ?? "",
182
- password: envVars.mySqlPassword ?? "",
183
- database: envVars.mySqlDatabase ?? "",
184
- mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout"),
185
- pool: {
186
- connectionLimit: envCount(envVars, "mySqlPoolConnectionLimit"),
187
- maxIdle: envCount(envVars, "mySqlPoolMaxIdle"),
188
- idleTimeout: envMs(envVars, "mySqlPoolIdleTimeout"),
189
- enableKeepAlive: envBoolean(envVars, "mySqlPoolEnableKeepAlive"),
190
- waitForConnections: envBoolean(envVars, "mySqlPoolWaitForConnections"),
191
- queueLimit: envCount(envVars, "mySqlPoolQueueLimit")
192
- }
193
- },
194
- tablePrefix: envVars.entityStorageTablePrefix
195
- }
196
- });
197
- }
198
- if (entityStorageConnectorTypes.includes(EntityStorageConnectorType.MongoDb)) {
199
- coreConfig.types.entityStorageConnector.push({
200
- type: EntityStorageConnectorType.MongoDb,
201
- options: {
202
- config: {
203
- host: envVars.mongoDbHost ?? "",
204
- port: envInteger(envVars, "mongoDbPort"),
205
- user: envVars.mongoDbUser ?? "",
206
- password: envVars.mongoDbPassword ?? "",
207
- database: envVars.mongoDbDatabase ?? "",
208
- mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout"),
209
- pool: {
210
- maxPoolSize: envCount(envVars, "mongoDbPoolMaxPoolSize"),
211
- minPoolSize: envCount(envVars, "mongoDbPoolMinPoolSize"),
212
- maxIdleTimeMs: envMs(envVars, "mongoDbPoolMaxIdleTime"),
213
- waitQueueTimeoutMs: envMs(envVars, "mongoDbPoolWaitQueueTimeout")
214
- }
215
- },
216
- tablePrefix: envVars.entityStorageTablePrefix
217
- }
218
- });
219
- }
220
- if (entityStorageConnectorTypes.includes(EntityStorageConnectorType.PostgreSql)) {
221
- coreConfig.types.entityStorageConnector.push({
222
- type: EntityStorageConnectorType.PostgreSql,
223
- options: {
224
- config: {
225
- host: envVars.postgreSqlHost ?? "",
226
- port: envInteger(envVars, "postgreSqlPort"),
227
- user: envVars.postgreSqlUser ?? "",
228
- password: envVars.postgreSqlPassword ?? "",
229
- database: envVars.postgreSqlDatabase ?? "",
230
- mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout"),
231
- pool: {
232
- max: envCount(envVars, "postgreSqlPoolMax"),
233
- idleTimeout: envSeconds(envVars, "postgreSqlPoolIdleTimeout"),
234
- connectTimeout: envSeconds(envVars, "postgreSqlPoolConnectTimeout"),
235
- maxLifetime: envSeconds(envVars, "postgreSqlPoolMaxLifetime")
85
+ const entityStorageConnectorTypes = envListToArray(envVars, "entityStorageConnectorType", Object.values(EntityStorageConnectorType));
86
+ for (const entityStorageConnectorType of entityStorageConnectorTypes) {
87
+ if (entityStorageConnectorType === EntityStorageConnectorType.Memory) {
88
+ coreConfig.types.entityStorageConnector.push({
89
+ type: EntityStorageConnectorType.Memory,
90
+ options: {
91
+ config: {
92
+ mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout")
236
93
  }
237
- },
238
- tablePrefix: envVars.entityStorageTablePrefix
239
- }
240
- });
94
+ }
95
+ });
96
+ }
97
+ else if (entityStorageConnectorType === EntityStorageConnectorType.File) {
98
+ coreConfig.types.entityStorageConnector.push({
99
+ type: EntityStorageConnectorType.File,
100
+ options: {
101
+ config: {
102
+ directory: envVars.storageFileRoot ?? "",
103
+ mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout")
104
+ },
105
+ folderPrefix: envVars.entityStorageTablePrefix
106
+ }
107
+ });
108
+ }
109
+ else if (entityStorageConnectorType === EntityStorageConnectorType.AwsDynamoDb) {
110
+ coreConfig.types.entityStorageConnector.push({
111
+ type: EntityStorageConnectorType.AwsDynamoDb,
112
+ options: {
113
+ config: {
114
+ region: envVars.awsDynamodbRegion ?? "",
115
+ authMode: envVars.awsDynamodbAuthMode,
116
+ accessKeyId: envVars.awsDynamodbAccessKeyId,
117
+ secretAccessKey: envVars.awsDynamodbSecretAccessKey,
118
+ endpoint: envVars.awsDynamodbEndpoint,
119
+ connectionTimeoutMs: envMs(envVars, "awsDynamodbConnectionTimeout"),
120
+ mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout")
121
+ },
122
+ tablePrefix: envVars.entityStorageTablePrefix
123
+ }
124
+ });
125
+ }
126
+ else if (entityStorageConnectorType === EntityStorageConnectorType.AzureCosmosDb) {
127
+ coreConfig.types.entityStorageConnector.push({
128
+ type: EntityStorageConnectorType.AzureCosmosDb,
129
+ options: {
130
+ config: {
131
+ endpoint: envVars.azureCosmosdbEndpoint ?? "",
132
+ key: envVars.azureCosmosdbKey ?? "",
133
+ databaseId: envVars.azureCosmosdbDatabaseId ?? "",
134
+ containerId: envVars.azureCosmosdbContainerId ?? "",
135
+ mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout")
136
+ },
137
+ tablePrefix: envVars.entityStorageTablePrefix
138
+ }
139
+ });
140
+ }
141
+ else if (entityStorageConnectorType === EntityStorageConnectorType.GcpFirestoreDb) {
142
+ coreConfig.types.entityStorageConnector.push({
143
+ type: EntityStorageConnectorType.GcpFirestoreDb,
144
+ options: {
145
+ config: {
146
+ projectId: envVars.gcpFirestoreProjectId ?? "",
147
+ credentials: envVars.gcpFirestoreCredentials ?? "",
148
+ databaseId: envVars.gcpFirestoreDatabaseId ?? "",
149
+ collectionName: envVars.gcpFirestoreCollectionName ?? "",
150
+ endpoint: envVars.gcpFirestoreEndpoint ?? "",
151
+ mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout")
152
+ },
153
+ tablePrefix: envVars.entityStorageTablePrefix
154
+ }
155
+ });
156
+ }
157
+ else if (entityStorageConnectorType === EntityStorageConnectorType.ScyllaDb) {
158
+ coreConfig.types.entityStorageConnector.push({
159
+ type: EntityStorageConnectorType.ScyllaDb,
160
+ options: {
161
+ config: {
162
+ hosts: commaSeparatedListToArray(envVars.scylladbHosts),
163
+ localDataCenter: envVars.scylladbLocalDataCenter ?? "",
164
+ keyspace: envVars.scylladbKeyspace ?? "",
165
+ port: envInteger(envVars, "scylladbPort"),
166
+ mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout"),
167
+ pool: {
168
+ coreConnectionsPerHost: envCount(envVars, "scylladbPoolCoreConnectionsPerHost"),
169
+ maxRequestsPerConnection: envCount(envVars, "scylladbPoolMaxRequestsPerConnection")
170
+ }
171
+ },
172
+ tablePrefix: envVars.entityStorageTablePrefix
173
+ }
174
+ });
175
+ }
176
+ else if (entityStorageConnectorType === EntityStorageConnectorType.MySqlDb) {
177
+ coreConfig.types.entityStorageConnector.push({
178
+ type: EntityStorageConnectorType.MySqlDb,
179
+ options: {
180
+ config: {
181
+ host: envVars.mySqlHost ?? "",
182
+ port: envInteger(envVars, "mySqlPort"),
183
+ user: envVars.mySqlUser ?? "",
184
+ password: envVars.mySqlPassword ?? "",
185
+ database: envVars.mySqlDatabase ?? "",
186
+ mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout"),
187
+ pool: {
188
+ connectionLimit: envCount(envVars, "mySqlPoolConnectionLimit"),
189
+ maxIdle: envCount(envVars, "mySqlPoolMaxIdle"),
190
+ idleTimeout: envMs(envVars, "mySqlPoolIdleTimeout"),
191
+ enableKeepAlive: envBoolean(envVars, "mySqlPoolEnableKeepAlive"),
192
+ waitForConnections: envBoolean(envVars, "mySqlPoolWaitForConnections"),
193
+ queueLimit: envCount(envVars, "mySqlPoolQueueLimit")
194
+ }
195
+ },
196
+ tablePrefix: envVars.entityStorageTablePrefix
197
+ }
198
+ });
199
+ }
200
+ else if (entityStorageConnectorType === EntityStorageConnectorType.MongoDb) {
201
+ coreConfig.types.entityStorageConnector.push({
202
+ type: EntityStorageConnectorType.MongoDb,
203
+ options: {
204
+ config: {
205
+ host: envVars.mongoDbHost ?? "",
206
+ port: envInteger(envVars, "mongoDbPort"),
207
+ user: envVars.mongoDbUser ?? "",
208
+ password: envVars.mongoDbPassword ?? "",
209
+ database: envVars.mongoDbDatabase ?? "",
210
+ mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout"),
211
+ pool: {
212
+ maxPoolSize: envCount(envVars, "mongoDbPoolMaxPoolSize"),
213
+ minPoolSize: envCount(envVars, "mongoDbPoolMinPoolSize"),
214
+ maxIdleTimeMs: envMs(envVars, "mongoDbPoolMaxIdleTime"),
215
+ waitQueueTimeoutMs: envMs(envVars, "mongoDbPoolWaitQueueTimeout")
216
+ }
217
+ },
218
+ tablePrefix: envVars.entityStorageTablePrefix
219
+ }
220
+ });
221
+ }
222
+ else if (entityStorageConnectorType === EntityStorageConnectorType.PostgreSql) {
223
+ coreConfig.types.entityStorageConnector.push({
224
+ type: EntityStorageConnectorType.PostgreSql,
225
+ options: {
226
+ config: {
227
+ host: envVars.postgreSqlHost ?? "",
228
+ port: envInteger(envVars, "postgreSqlPort"),
229
+ user: envVars.postgreSqlUser ?? "",
230
+ password: envVars.postgreSqlPassword ?? "",
231
+ database: envVars.postgreSqlDatabase ?? "",
232
+ mutexTimeoutMs: envMs(envVars, "entityStorageMutexTimeout"),
233
+ pool: {
234
+ max: envCount(envVars, "postgreSqlPoolMax"),
235
+ idleTimeout: envSeconds(envVars, "postgreSqlPoolIdleTimeout"),
236
+ connectTimeout: envSeconds(envVars, "postgreSqlPoolConnectTimeout"),
237
+ maxLifetime: envSeconds(envVars, "postgreSqlPoolMaxLifetime")
238
+ }
239
+ },
240
+ tablePrefix: envVars.entityStorageTablePrefix
241
+ }
242
+ });
243
+ }
241
244
  }
242
245
  const defaultEntityStorageConnectorType = envVars.entityStorageConnectorDefault ?? entityStorageConnectorTypes[0];
243
246
  if (Is.arrayValue(entityStorageConnectorTypes)) {
@@ -257,85 +260,88 @@ async function configureEntityStorage(coreConfig, envVars) {
257
260
  */
258
261
  async function configureBlobStorage(coreConfig, envVars) {
259
262
  coreConfig.types.blobStorageConnector ??= [];
260
- const blobStorageConnectorTypes = commaSeparatedListToArray(envVars.blobStorageConnectorType);
261
- if (blobStorageConnectorTypes.includes(BlobStorageConnectorType.Memory)) {
262
- coreConfig.types.blobStorageConnector.push({
263
- type: BlobStorageConnectorType.Memory
264
- });
265
- }
266
- if (blobStorageConnectorTypes.includes(BlobStorageConnectorType.File)) {
267
- coreConfig.types.blobStorageConnector.push({
268
- type: BlobStorageConnectorType.File,
269
- options: {
270
- config: {
271
- directory: Is.stringValue(envVars.storageFileRoot)
272
- ? path.join(envVars.storageFileRoot, "blob-storage")
273
- : ""
274
- },
275
- storagePrefix: envVars.blobStoragePrefix
276
- }
277
- });
278
- }
279
- if (blobStorageConnectorTypes.includes(BlobStorageConnectorType.Ipfs)) {
280
- coreConfig.types.blobStorageConnector.push({
281
- type: BlobStorageConnectorType.Ipfs,
282
- options: {
283
- config: {
284
- apiUrl: envVars.ipfsApiUrl ?? "",
285
- bearerToken: envVars.ipfsBearerToken
263
+ const blobStorageConnectorTypes = envListToArray(envVars, "blobStorageConnectorType", Object.values(BlobStorageConnectorType));
264
+ for (const blobStorageConnectorType of blobStorageConnectorTypes) {
265
+ if (blobStorageConnectorType === BlobStorageConnectorType.Memory) {
266
+ coreConfig.types.blobStorageConnector.push({
267
+ type: BlobStorageConnectorType.Memory
268
+ });
269
+ }
270
+ else if (blobStorageConnectorType === BlobStorageConnectorType.File) {
271
+ coreConfig.types.blobStorageConnector.push({
272
+ type: BlobStorageConnectorType.File,
273
+ options: {
274
+ config: {
275
+ directory: Is.stringValue(envVars.storageFileRoot)
276
+ ? path.join(envVars.storageFileRoot, "blob-storage")
277
+ : ""
278
+ },
279
+ storagePrefix: envVars.blobStoragePrefix
286
280
  }
287
- }
288
- });
289
- }
290
- if (blobStorageConnectorTypes.includes(BlobStorageConnectorType.AwsS3)) {
291
- coreConfig.types.blobStorageConnector.push({
292
- type: BlobStorageConnectorType.AwsS3,
293
- options: {
294
- config: {
295
- region: envVars.awsS3Region ?? "",
296
- bucketName: envVars.awsS3BucketName ?? "",
297
- authMode: envVars.awsS3AuthMode,
298
- accessKeyId: envVars.awsS3AccessKeyId,
299
- secretAccessKey: envVars.awsS3SecretAccessKey,
300
- endpoint: envVars.awsS3Endpoint
301
- },
302
- storagePrefix: envVars.blobStoragePrefix
303
- }
304
- });
305
- }
306
- if (blobStorageConnectorTypes.includes(BlobStorageConnectorType.AzureStorage)) {
307
- coreConfig.types.blobStorageConnector.push({
308
- type: BlobStorageConnectorType.AzureStorage,
309
- options: {
310
- config: {
311
- accountName: envVars.azureStorageAccountName ?? "",
312
- accountKey: envVars.azureStorageAccountKey ?? "",
313
- containerName: envVars.azureStorageContainerName ?? "",
314
- endpoint: envVars.azureStorageEndpoint ?? ""
315
- },
316
- storagePrefix: envVars.blobStoragePrefix
317
- }
318
- });
319
- }
320
- if (blobStorageConnectorTypes.includes(BlobStorageConnectorType.GcpStorage)) {
321
- coreConfig.types.blobStorageConnector.push({
322
- type: BlobStorageConnectorType.GcpStorage,
323
- options: {
324
- config: {
325
- projectId: envVars.gcpStorageProjectId ?? "",
326
- credentials: envVars.gcpStorageCredentials ?? "",
327
- bucketName: envVars.gcpStorageBucketName ?? "",
328
- apiEndpoint: envVars.gcpFirestoreEndpoint
329
- },
330
- storagePrefix: envVars.blobStoragePrefix
331
- }
332
- });
281
+ });
282
+ }
283
+ else if (blobStorageConnectorType === BlobStorageConnectorType.Ipfs) {
284
+ coreConfig.types.blobStorageConnector.push({
285
+ type: BlobStorageConnectorType.Ipfs,
286
+ options: {
287
+ config: {
288
+ apiUrl: envVars.ipfsApiUrl ?? "",
289
+ bearerToken: envVars.ipfsBearerToken
290
+ }
291
+ }
292
+ });
293
+ }
294
+ else if (blobStorageConnectorType === BlobStorageConnectorType.AwsS3) {
295
+ coreConfig.types.blobStorageConnector.push({
296
+ type: BlobStorageConnectorType.AwsS3,
297
+ options: {
298
+ config: {
299
+ region: envVars.awsS3Region ?? "",
300
+ bucketName: envVars.awsS3BucketName ?? "",
301
+ authMode: envVars.awsS3AuthMode,
302
+ accessKeyId: envVars.awsS3AccessKeyId,
303
+ secretAccessKey: envVars.awsS3SecretAccessKey,
304
+ endpoint: envVars.awsS3Endpoint
305
+ },
306
+ storagePrefix: envVars.blobStoragePrefix
307
+ }
308
+ });
309
+ }
310
+ else if (blobStorageConnectorType === BlobStorageConnectorType.AzureStorage) {
311
+ coreConfig.types.blobStorageConnector.push({
312
+ type: BlobStorageConnectorType.AzureStorage,
313
+ options: {
314
+ config: {
315
+ accountName: envVars.azureStorageAccountName ?? "",
316
+ accountKey: envVars.azureStorageAccountKey ?? "",
317
+ containerName: envVars.azureStorageContainerName ?? "",
318
+ endpoint: envVars.azureStorageEndpoint ?? ""
319
+ },
320
+ storagePrefix: envVars.blobStoragePrefix
321
+ }
322
+ });
323
+ }
324
+ else if (blobStorageConnectorType === BlobStorageConnectorType.GcpStorage) {
325
+ coreConfig.types.blobStorageConnector.push({
326
+ type: BlobStorageConnectorType.GcpStorage,
327
+ options: {
328
+ config: {
329
+ projectId: envVars.gcpStorageProjectId ?? "",
330
+ credentials: envVars.gcpStorageCredentials ?? "",
331
+ bucketName: envVars.gcpStorageBucketName ?? "",
332
+ apiEndpoint: envVars.gcpFirestoreEndpoint
333
+ },
334
+ storagePrefix: envVars.blobStoragePrefix
335
+ }
336
+ });
337
+ }
333
338
  }
334
339
  if (Is.arrayValue(blobStorageConnectorTypes)) {
335
340
  const defaultStorageConnectorType = envVars.blobStorageConnectorDefault ?? blobStorageConnectorTypes[0];
336
341
  for (const config of coreConfig.types.blobStorageConnector) {
337
342
  if (config.type === defaultStorageConnectorType) {
338
343
  config.isDefault = true;
344
+ break;
339
345
  }
340
346
  }
341
347
  }
@@ -361,7 +367,7 @@ async function configureBlobStorage(coreConfig, envVars) {
361
367
  */
362
368
  async function configureLogging(coreConfig, envVars) {
363
369
  coreConfig.types.loggingConnector ??= [];
364
- const loggingConnectorTypes = commaSeparatedListToArray(envVars.loggingConnector);
370
+ const loggingConnectorTypes = envListToArray(envVars, "loggingConnector", Object.values(LoggingConnectorType));
365
371
  let additionalConnectorCount = 0;
366
372
  for (const loggingConnector of loggingConnectorTypes) {
367
373
  if (loggingConnector === LoggingConnectorType.Console) {
@@ -463,7 +469,8 @@ async function configureLogging(coreConfig, envVars) {
463
469
  */
464
470
  async function configureVault(coreConfig, envVars) {
465
471
  coreConfig.types.vaultConnector ??= [];
466
- if (envVars.vaultConnector === VaultConnectorType.EntityStorage) {
472
+ const vaultConnectorType = envChoice(envVars, "vaultConnector", Object.values(VaultConnectorType));
473
+ if (vaultConnectorType === VaultConnectorType.EntityStorage) {
467
474
  coreConfig.types.vaultConnector.push({
468
475
  type: VaultConnectorType.EntityStorage,
469
476
  options: {
@@ -473,7 +480,7 @@ async function configureVault(coreConfig, envVars) {
473
480
  }
474
481
  });
475
482
  }
476
- else if (envVars.vaultConnector === VaultConnectorType.Hashicorp) {
483
+ else if (vaultConnectorType === VaultConnectorType.Hashicorp) {
477
484
  coreConfig.types.vaultConnector.push({
478
485
  type: VaultConnectorType.Hashicorp,
479
486
  options: {
@@ -508,7 +515,8 @@ async function configureBackgroundTask(coreConfig, envVars) {
508
515
  */
509
516
  async function configureEventBus(coreConfig, envVars) {
510
517
  coreConfig.types.eventBusConnector ??= [];
511
- if (envVars.eventBusConnector === EventBusConnectorType.Local) {
518
+ const eventBusConnectorType = envChoice(envVars, "eventBusConnector", Object.values(EventBusConnectorType));
519
+ if (eventBusConnectorType === EventBusConnectorType.Local) {
512
520
  coreConfig.types.eventBusConnector.push({
513
521
  type: EventBusConnectorType.Local
514
522
  });
@@ -526,16 +534,16 @@ async function configureEventBus(coreConfig, envVars) {
526
534
  */
527
535
  async function configureTelemetry(coreConfig, envVars) {
528
536
  coreConfig.types.telemetryConnector ??= [];
529
- const telemetryConnectorTypes = commaSeparatedListToArray(envVars.telemetryConnector);
537
+ const telemetryConnectorTypes = envListToArray(envVars, "telemetryConnector", Object.values(TelemetryConnectorType));
530
538
  let additionalConnectorCount = 0;
531
- for (const telemetryConnector of telemetryConnectorTypes) {
532
- if (telemetryConnector === TelemetryConnectorType.Silent) {
539
+ for (const telemetryConnectorType of telemetryConnectorTypes) {
540
+ if (telemetryConnectorType === TelemetryConnectorType.Silent) {
533
541
  coreConfig.types.telemetryConnector.push({
534
542
  type: TelemetryConnectorType.Silent
535
543
  });
536
544
  additionalConnectorCount++;
537
545
  }
538
- else if (telemetryConnector === TelemetryConnectorType.EntityStorage) {
546
+ else if (telemetryConnectorType === TelemetryConnectorType.EntityStorage) {
539
547
  coreConfig.types.telemetryConnector.push({
540
548
  type: TelemetryConnectorType.EntityStorage,
541
549
  options: {
@@ -551,7 +559,7 @@ async function configureTelemetry(coreConfig, envVars) {
551
559
  });
552
560
  additionalConnectorCount++;
553
561
  }
554
- else if (telemetryConnector === TelemetryConnectorType.OpenTelemetry) {
562
+ else if (telemetryConnectorType === TelemetryConnectorType.OpenTelemetry) {
555
563
  let readers;
556
564
  if (envVars.openTelemetryReader === OpenTelemetryReaderTypes.Prometheus) {
557
565
  readers = {
@@ -614,8 +622,10 @@ async function configureMetricsCollector(coreConfig, envVars) {
614
622
  cloneMode: EngineCloneMode.Never
615
623
  });
616
624
  coreConfig.types.metricsProducerComponent ??= [];
617
- const metricsProducers = commaSeparatedListToArray(envVars.telemetryMetricsProducers ??
618
- [MetricsProducerComponentType.System, MetricsProducerComponentType.Process].join(","));
625
+ const metricsProducers = envListToArray(envVars, "telemetryMetricsProducers", Object.values(MetricsProducerComponentType), [
626
+ MetricsProducerComponentType.System,
627
+ MetricsProducerComponentType.Process
628
+ ]);
619
629
  for (const producerType of metricsProducers) {
620
630
  coreConfig.types.metricsProducerComponent.push({
621
631
  type: producerType,
@@ -633,16 +643,16 @@ async function configureMetricsCollector(coreConfig, envVars) {
633
643
  */
634
644
  async function configureTracing(coreConfig, envVars) {
635
645
  coreConfig.types.tracingConnector ??= [];
636
- const tracingConnectorTypes = commaSeparatedListToArray(envVars.tracingConnector);
646
+ const tracingConnectorTypes = envListToArray(envVars, "tracingConnector", Object.values(TracingConnectorType));
637
647
  let additionalConnectorCount = 0;
638
- for (const tracingConnector of tracingConnectorTypes) {
639
- if (tracingConnector === TracingConnectorType.Silent) {
648
+ for (const tracingConnectorType of tracingConnectorTypes) {
649
+ if (tracingConnectorType === TracingConnectorType.Silent) {
640
650
  coreConfig.types.tracingConnector.push({
641
651
  type: TracingConnectorType.Silent
642
652
  });
643
653
  additionalConnectorCount++;
644
654
  }
645
- else if (tracingConnector === TracingConnectorType.EntityStorage) {
655
+ else if (tracingConnectorType === TracingConnectorType.EntityStorage) {
646
656
  coreConfig.types.tracingConnector.push({
647
657
  type: TracingConnectorType.EntityStorage,
648
658
  options: {
@@ -653,7 +663,13 @@ async function configureTracing(coreConfig, envVars) {
653
663
  });
654
664
  additionalConnectorCount++;
655
665
  }
656
- else if (tracingConnector === TracingConnectorType.OpenTelemetry) {
666
+ else if (tracingConnectorType === TracingConnectorType.Console) {
667
+ coreConfig.types.tracingConnector.push({
668
+ type: TracingConnectorType.Console
669
+ });
670
+ additionalConnectorCount++;
671
+ }
672
+ else if (tracingConnectorType === TracingConnectorType.OpenTelemetry) {
657
673
  const otelTracingConfig = {
658
674
  tracerName: envVars.openTelemetryTracingTracerName,
659
675
  tracerVersion: envVars.openTelemetryTracingTracerVersion
@@ -709,15 +725,13 @@ async function configureAutomation(coreConfig, envVars) {
709
725
  coreConfig.types.automationComponent.push({
710
726
  type: AutomationComponentType.Service
711
727
  });
712
- const automationActionTypes = commaSeparatedListToArray(envVars.automationActionTypes);
713
- if (Is.arrayValue(automationActionTypes)) {
714
- coreConfig.types.automationAction ??= [];
715
- for (const actionType of automationActionTypes) {
716
- coreConfig.types.automationAction.push({
717
- type: actionType,
718
- isMultiInstance: true
719
- });
720
- }
728
+ const automationActionTypes = envListToArray(envVars, "automationActionTypes", Object.values(AutomationActionType));
729
+ coreConfig.types.automationAction ??= [];
730
+ for (const actionType of automationActionTypes) {
731
+ coreConfig.types.automationAction.push({
732
+ type: actionType,
733
+ isMultiInstance: true
734
+ });
721
735
  }
722
736
  }
723
737
  }
@@ -820,69 +834,89 @@ async function configureContextIdHandlers(coreConfig, envVars) {
820
834
  * @returns A promise that resolves when the messaging configuration has been applied.
821
835
  */
822
836
  async function configureMessaging(coreConfig, envVars) {
823
- if (envBoolean(envVars, "messagingEnabled", false)) {
824
- coreConfig.types.messagingEmailConnector ??= [];
825
- coreConfig.types.messagingSmsConnector ??= [];
826
- coreConfig.types.messagingPushNotificationConnector ??= [];
827
- if (envVars.messagingEmailConnector === MessagingEmailConnectorType.EntityStorage) {
828
- coreConfig.types.messagingEmailConnector.push({
829
- type: MessagingEmailConnectorType.EntityStorage
830
- });
831
- }
832
- else if (envVars.messagingEmailConnector === MessagingEmailConnectorType.Aws) {
833
- coreConfig.types.messagingEmailConnector.push({
834
- type: MessagingEmailConnectorType.Aws,
835
- options: {
836
- config: {
837
- region: envVars.awsSesRegion ?? "",
838
- authMode: envVars.awsSesAuthMode,
839
- accessKeyId: envVars.awsSesAccessKeyId,
840
- secretAccessKey: envVars.awsSesSecretAccessKey,
841
- endpoint: envVars.awsSesEndpoint
842
- }
837
+ coreConfig.types.messagingEmailConnector ??= [];
838
+ coreConfig.types.messagingSmsConnector ??= [];
839
+ coreConfig.types.messagingPushNotificationConnector ??= [];
840
+ const messagingEmailConnectorType = envChoice(envVars, "messagingEmailConnector", Object.values(MessagingEmailConnectorType));
841
+ if (messagingEmailConnectorType === MessagingEmailConnectorType.EntityStorage) {
842
+ coreConfig.types.messagingEmailConnector.push({
843
+ type: MessagingEmailConnectorType.EntityStorage
844
+ });
845
+ }
846
+ else if (messagingEmailConnectorType === MessagingEmailConnectorType.Aws) {
847
+ coreConfig.types.messagingEmailConnector.push({
848
+ type: MessagingEmailConnectorType.Aws,
849
+ options: {
850
+ config: {
851
+ region: envVars.awsSesRegion ?? "",
852
+ authMode: envVars.awsSesAuthMode,
853
+ accessKeyId: envVars.awsSesAccessKeyId,
854
+ secretAccessKey: envVars.awsSesSecretAccessKey,
855
+ endpoint: envVars.awsSesEndpoint
843
856
  }
844
- });
845
- }
846
- if (envVars.messagingSmsConnector === MessagingSmsConnectorType.EntityStorage) {
847
- coreConfig.types.messagingSmsConnector.push({
848
- type: MessagingSmsConnectorType.EntityStorage
849
- });
850
- }
851
- else if (envVars.messagingSmsConnector === MessagingSmsConnectorType.Aws) {
852
- coreConfig.types.messagingSmsConnector.push({
853
- type: MessagingSmsConnectorType.Aws,
854
- options: {
855
- config: {
856
- region: envVars.awsSesRegion ?? "",
857
- authMode: envVars.awsSesAuthMode,
858
- accessKeyId: envVars.awsSesAccessKeyId,
859
- secretAccessKey: envVars.awsSesSecretAccessKey,
860
- endpoint: envVars.awsSesEndpoint
861
- }
857
+ }
858
+ });
859
+ }
860
+ else if (messagingEmailConnectorType === MessagingEmailConnectorType.Smtp) {
861
+ coreConfig.types.messagingEmailConnector.push({
862
+ type: MessagingEmailConnectorType.Smtp,
863
+ options: {
864
+ config: {
865
+ host: envVars.smtpHost ?? "",
866
+ port: envInteger(envVars, "smtpPort"),
867
+ secure: envBoolean(envVars, "smtpSecure"),
868
+ username: envVars.smtpUsername,
869
+ password: envVars.smtpPassword
862
870
  }
863
- });
864
- }
865
- if (envVars.messagingPushNotificationConnector ===
866
- MessagingPushNotificationConnectorType.EntityStorage) {
867
- coreConfig.types.messagingPushNotificationConnector.push({
868
- type: MessagingPushNotificationConnectorType.EntityStorage
869
- });
870
- }
871
- else if (envVars.messagingPushNotificationConnector === MessagingPushNotificationConnectorType.Aws) {
872
- coreConfig.types.messagingPushNotificationConnector.push({
873
- type: MessagingPushNotificationConnectorType.Aws,
874
- options: {
875
- config: {
876
- region: envVars.awsSesRegion ?? "",
877
- authMode: envVars.awsSesAuthMode,
878
- accessKeyId: envVars.awsSesAccessKeyId,
879
- secretAccessKey: envVars.awsSesSecretAccessKey,
880
- endpoint: envVars.awsSesEndpoint,
881
- applicationsSettings: envArray(envVars, "awsMessagingPushNotificationApplications", [])
882
- }
871
+ }
872
+ });
873
+ }
874
+ const messagingSmsConnectorType = envChoice(envVars, "messagingSmsConnector", Object.values(MessagingSmsConnectorType));
875
+ if (messagingSmsConnectorType === MessagingSmsConnectorType.EntityStorage) {
876
+ coreConfig.types.messagingSmsConnector.push({
877
+ type: MessagingSmsConnectorType.EntityStorage
878
+ });
879
+ }
880
+ else if (messagingSmsConnectorType === MessagingSmsConnectorType.Aws) {
881
+ coreConfig.types.messagingSmsConnector.push({
882
+ type: MessagingSmsConnectorType.Aws,
883
+ options: {
884
+ config: {
885
+ region: envVars.awsSesRegion ?? "",
886
+ authMode: envVars.awsSesAuthMode,
887
+ accessKeyId: envVars.awsSesAccessKeyId,
888
+ secretAccessKey: envVars.awsSesSecretAccessKey,
889
+ endpoint: envVars.awsSesEndpoint
883
890
  }
884
- });
885
- }
891
+ }
892
+ });
893
+ }
894
+ const messagingPushConnectorType = envChoice(envVars, "messagingPushNotificationConnector", Object.values(MessagingPushNotificationConnectorType));
895
+ if (messagingPushConnectorType === MessagingPushNotificationConnectorType.EntityStorage) {
896
+ coreConfig.types.messagingPushNotificationConnector.push({
897
+ type: MessagingPushNotificationConnectorType.EntityStorage
898
+ });
899
+ }
900
+ else if (messagingPushConnectorType === MessagingPushNotificationConnectorType.Aws) {
901
+ coreConfig.types.messagingPushNotificationConnector.push({
902
+ type: MessagingPushNotificationConnectorType.Aws,
903
+ options: {
904
+ config: {
905
+ region: envVars.awsSesRegion ?? "",
906
+ authMode: envVars.awsSesAuthMode,
907
+ accessKeyId: envVars.awsSesAccessKeyId,
908
+ secretAccessKey: envVars.awsSesSecretAccessKey,
909
+ endpoint: envVars.awsSesEndpoint,
910
+ applicationsSettings: envArray(envVars, "awsMessagingPushNotificationApplications", [])
911
+ }
912
+ }
913
+ });
914
+ }
915
+ // If any messaging connectors are configured, then we should configure the messaging admin and
916
+ // service components as well since they are required for the messaging connectors to work.
917
+ if (coreConfig.types.messagingEmailConnector.length > 0 ||
918
+ coreConfig.types.messagingSmsConnector.length > 0 ||
919
+ coreConfig.types.messagingPushNotificationConnector.length > 0) {
886
920
  coreConfig.types.messagingAdminComponent ??= [];
887
921
  coreConfig.types.messagingAdminComponent.push({
888
922
  type: MessagingAdminComponentType.Service
@@ -891,6 +925,40 @@ async function configureMessaging(coreConfig, envVars) {
891
925
  coreConfig.types.messagingComponent.push({ type: MessagingComponentType.Service });
892
926
  }
893
927
  }
928
+ /**
929
+ * Configures mailbox components, mail storage components, and email protocol connectors.
930
+ * @param coreConfig The core config.
931
+ * @param envVars The environment variables.
932
+ * @returns A promise that resolves when the mailbox configuration has been applied.
933
+ */
934
+ async function configureMailbox(coreConfig, envVars) {
935
+ coreConfig.types.emailProtocolConnector ??= [];
936
+ const emailProtocolConnectorTypes = envListToArray(envVars, "emailProtocolConnector", Object.values(EmailProtocolConnectorType));
937
+ for (const emailProtocolConnectorType of emailProtocolConnectorTypes) {
938
+ coreConfig.types.emailProtocolConnector.push({
939
+ type: emailProtocolConnectorType,
940
+ options: {
941
+ config: {}
942
+ },
943
+ cloneMode: EngineCloneMode.Never,
944
+ isMultiInstance: true
945
+ });
946
+ }
947
+ // If email protocol connectors are configured, then we should configure the mailbox and mail store
948
+ // components as well, since they are required for the email protocol connectors to work.
949
+ if (coreConfig.types.emailProtocolConnector.length > 0) {
950
+ coreConfig.types.mailStorageComponent ??= [];
951
+ coreConfig.types.mailStorageComponent.push({
952
+ type: MailStorageComponentType.Service,
953
+ cloneMode: EngineCloneMode.Never
954
+ });
955
+ coreConfig.types.mailboxComponent ??= [];
956
+ coreConfig.types.mailboxComponent.push({
957
+ type: MailboxComponentType.Service,
958
+ cloneMode: EngineCloneMode.Never
959
+ });
960
+ }
961
+ }
894
962
  /**
895
963
  * Configures the faucet.
896
964
  * @param coreConfig The core config.
@@ -899,12 +967,13 @@ async function configureMessaging(coreConfig, envVars) {
899
967
  */
900
968
  async function configureFaucet(coreConfig, envVars) {
901
969
  coreConfig.types.faucetConnector ??= [];
902
- if (envVars.faucetConnector === FaucetConnectorType.EntityStorage) {
970
+ const faucetConnectorType = envChoice(envVars, "faucetConnector", Object.values(FaucetConnectorType));
971
+ if (faucetConnectorType === FaucetConnectorType.EntityStorage) {
903
972
  coreConfig.types.faucetConnector.push({
904
973
  type: FaucetConnectorType.EntityStorage
905
974
  });
906
975
  }
907
- else if (envVars.faucetConnector === FaucetConnectorType.Iota &&
976
+ else if (faucetConnectorType === FaucetConnectorType.Iota &&
908
977
  Is.stringValue(envVars.iotaFaucetEndpoint)) {
909
978
  const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
910
979
  coreConfig.types.faucetConnector.push({
@@ -927,12 +996,13 @@ async function configureFaucet(coreConfig, envVars) {
927
996
  */
928
997
  async function configureWallet(coreConfig, envVars) {
929
998
  coreConfig.types.walletConnector ??= [];
930
- if (envVars.walletConnector === WalletConnectorType.EntityStorage) {
999
+ const walletConnectorType = envChoice(envVars, "walletConnector", Object.values(WalletConnectorType));
1000
+ if (walletConnectorType === WalletConnectorType.EntityStorage) {
931
1001
  coreConfig.types.walletConnector.push({
932
1002
  type: WalletConnectorType.EntityStorage
933
1003
  });
934
1004
  }
935
- else if (envVars.walletConnector === WalletConnectorType.Iota) {
1005
+ else if (walletConnectorType === WalletConnectorType.Iota) {
936
1006
  const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
937
1007
  coreConfig.types.walletConnector.push({
938
1008
  type: WalletConnectorType.Iota,
@@ -950,12 +1020,13 @@ async function configureWallet(coreConfig, envVars) {
950
1020
  */
951
1021
  async function configureNft(coreConfig, envVars) {
952
1022
  coreConfig.types.nftConnector ??= [];
953
- if (envVars.nftConnector === NftConnectorType.EntityStorage) {
1023
+ const nftConnectorType = envChoice(envVars, "nftConnector", Object.values(NftConnectorType));
1024
+ if (nftConnectorType === NftConnectorType.EntityStorage) {
954
1025
  coreConfig.types.nftConnector.push({
955
1026
  type: NftConnectorType.EntityStorage
956
1027
  });
957
1028
  }
958
- else if (envVars.nftConnector === NftConnectorType.Iota) {
1029
+ else if (nftConnectorType === NftConnectorType.Iota) {
959
1030
  const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
960
1031
  const config = {
961
1032
  ...dltConfig?.options?.config,
@@ -981,12 +1052,13 @@ async function configureNft(coreConfig, envVars) {
981
1052
  */
982
1053
  async function configureNotarization(coreConfig, envVars) {
983
1054
  coreConfig.types.notarizationConnector ??= [];
984
- if (envVars.notarizationConnector === NotarizationConnectorType.EntityStorage) {
1055
+ const notarizationConnectorType = envChoice(envVars, "notarizationConnector", Object.values(NotarizationConnectorType));
1056
+ if (notarizationConnectorType === NotarizationConnectorType.EntityStorage) {
985
1057
  coreConfig.types.notarizationConnector.push({
986
1058
  type: NotarizationConnectorType.EntityStorage
987
1059
  });
988
1060
  }
989
- else if (envVars.notarizationConnector === NotarizationConnectorType.Iota) {
1061
+ else if (notarizationConnectorType === NotarizationConnectorType.Iota) {
990
1062
  const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
991
1063
  coreConfig.types.notarizationConnector.push({
992
1064
  type: NotarizationConnectorType.Iota,
@@ -1036,12 +1108,13 @@ async function configureImmutableProof(coreConfig, envVars) {
1036
1108
  */
1037
1109
  async function configureIdentity(coreConfig, envVars) {
1038
1110
  coreConfig.types.identityConnector ??= [];
1039
- if (envVars.identityConnector === IdentityConnectorType.EntityStorage) {
1111
+ const identityConnectorType = envChoice(envVars, "identityConnector", Object.values(IdentityConnectorType));
1112
+ if (identityConnectorType === IdentityConnectorType.EntityStorage) {
1040
1113
  coreConfig.types.identityConnector.push({
1041
1114
  type: IdentityConnectorType.EntityStorage
1042
1115
  });
1043
1116
  }
1044
- else if (envVars.identityConnector === IdentityConnectorType.Iota) {
1117
+ else if (identityConnectorType === IdentityConnectorType.Iota) {
1045
1118
  const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
1046
1119
  coreConfig.types.identityConnector.push({
1047
1120
  type: IdentityConnectorType.Iota,
@@ -1074,12 +1147,13 @@ async function configureIdentity(coreConfig, envVars) {
1074
1147
  */
1075
1148
  async function configureIdentityResolver(coreConfig, envVars) {
1076
1149
  coreConfig.types.identityResolverConnector ??= [];
1077
- if (envVars.identityResolverConnector === IdentityResolverConnectorType.EntityStorage) {
1150
+ const identityResolverConnectorType = envChoice(envVars, "identityResolverConnector", Object.values(IdentityResolverConnectorType));
1151
+ if (identityResolverConnectorType === IdentityResolverConnectorType.EntityStorage) {
1078
1152
  coreConfig.types.identityResolverConnector.push({
1079
1153
  type: IdentityResolverConnectorType.EntityStorage
1080
1154
  });
1081
1155
  }
1082
- else if (envVars.identityResolverConnector === IdentityResolverConnectorType.Iota) {
1156
+ else if (identityResolverConnectorType === IdentityResolverConnectorType.Iota) {
1083
1157
  const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
1084
1158
  coreConfig.types.identityResolverConnector.push({
1085
1159
  type: IdentityResolverConnectorType.Iota,
@@ -1093,7 +1167,7 @@ async function configureIdentityResolver(coreConfig, envVars) {
1093
1167
  }
1094
1168
  });
1095
1169
  }
1096
- else if (envVars.identityResolverConnector === IdentityResolverConnectorType.Universal) {
1170
+ else if (identityResolverConnectorType === IdentityResolverConnectorType.Universal) {
1097
1171
  coreConfig.types.identityResolverConnector.push({
1098
1172
  type: IdentityResolverConnectorType.Universal,
1099
1173
  options: {
@@ -1118,7 +1192,8 @@ async function configureIdentityResolver(coreConfig, envVars) {
1118
1192
  */
1119
1193
  async function configureIdentityProfile(coreConfig, envVars) {
1120
1194
  coreConfig.types.identityProfileConnector ??= [];
1121
- if (envVars.identityProfileConnector === IdentityConnectorType.EntityStorage) {
1195
+ const identityProfileConnectorType = envChoice(envVars, "identityProfileConnector", Object.values(IdentityProfileConnectorType));
1196
+ if (identityProfileConnectorType === IdentityProfileConnectorType.EntityStorage) {
1122
1197
  coreConfig.types.identityProfileConnector.push({
1123
1198
  type: IdentityProfileConnectorType.EntityStorage
1124
1199
  });
@@ -1136,7 +1211,8 @@ async function configureIdentityProfile(coreConfig, envVars) {
1136
1211
  */
1137
1212
  async function configureAttestation(coreConfig, envVars) {
1138
1213
  coreConfig.types.attestationConnector ??= [];
1139
- if (envVars.attestationConnector === AttestationConnectorType.Nft) {
1214
+ const attestationConnectorType = envChoice(envVars, "attestationConnector", Object.values(AttestationConnectorType));
1215
+ if (attestationConnectorType === AttestationConnectorType.Nft) {
1140
1216
  coreConfig.types.attestationConnector.push({
1141
1217
  type: AttestationConnectorType.Nft
1142
1218
  });
@@ -1198,23 +1274,24 @@ async function configureAuditableItemStream(coreConfig, envVars) {
1198
1274
  * @returns A promise that resolves when the data processing configuration has been applied.
1199
1275
  */
1200
1276
  async function configureDataProcessing(coreConfig, envVars) {
1201
- if (envBoolean(envVars, "dataProcessingEnabled", false)) {
1277
+ coreConfig.types.dataConverterConnector ??= [];
1278
+ const converterConnectors = envListToArray(envVars, "dataConverterConnectors", Object.values(DataConverterConnectorType));
1279
+ for (const converterConnector of converterConnectors) {
1280
+ coreConfig.types.dataConverterConnector.push({
1281
+ type: converterConnector
1282
+ });
1283
+ }
1284
+ coreConfig.types.dataExtractorConnector ??= [];
1285
+ const extractorConnectors = envListToArray(envVars, "dataExtractorConnectors", Object.values(DataExtractorConnectorType));
1286
+ for (const extractorConnector of extractorConnectors) {
1287
+ coreConfig.types.dataExtractorConnector.push({
1288
+ type: extractorConnector
1289
+ });
1290
+ }
1291
+ if (coreConfig.types.dataConverterConnector.length > 0 ||
1292
+ coreConfig.types.dataExtractorConnector.length > 0) {
1202
1293
  coreConfig.types.dataProcessingComponent ??= [];
1203
1294
  coreConfig.types.dataProcessingComponent.push({ type: DataProcessingComponentType.Service });
1204
- coreConfig.types.dataConverterConnector ??= [];
1205
- const converterConnectors = commaSeparatedListToArray(envVars.dataConverterConnectors);
1206
- for (const converterConnector of converterConnectors) {
1207
- coreConfig.types.dataConverterConnector.push({
1208
- type: converterConnector
1209
- });
1210
- }
1211
- coreConfig.types.dataExtractorConnector ??= [];
1212
- const extractorConnectors = commaSeparatedListToArray(envVars.dataExtractorConnectors);
1213
- for (const extractorConnector of extractorConnectors) {
1214
- coreConfig.types.dataExtractorConnector.push({
1215
- type: extractorConnector
1216
- });
1217
- }
1218
1295
  }
1219
1296
  }
1220
1297
  /**
@@ -1249,7 +1326,7 @@ async function configureTrust(coreConfig, envVars) {
1249
1326
  type: TrustComponentType.Service
1250
1327
  });
1251
1328
  coreConfig.types.trustGeneratorComponent ??= [];
1252
- const trustGeneratorTypes = commaSeparatedListToArray(envVars.trustGenerators);
1329
+ const trustGeneratorTypes = envListToArray(envVars, "trustGenerators", Object.values(TrustGeneratorComponentType));
1253
1330
  for (const trustGeneratorType of trustGeneratorTypes) {
1254
1331
  coreConfig.types.trustGeneratorComponent.push({
1255
1332
  type: trustGeneratorType,
@@ -1262,12 +1339,11 @@ async function configureTrust(coreConfig, envVars) {
1262
1339
  });
1263
1340
  }
1264
1341
  coreConfig.types.trustVerifierComponent ??= [];
1265
- const trustVerifierTypes = commaSeparatedListToArray(envVars.trustVerifiers);
1342
+ const trustVerifierTypes = envListToArray(envVars, "trustVerifiers", Object.values(TrustVerifierComponentType));
1266
1343
  for (const trustVerifierType of trustVerifierTypes) {
1267
- const type = trustVerifierType;
1268
- if (type === TrustVerifierComponentType.IdentityAllowDeny) {
1344
+ if (trustVerifierType === TrustVerifierComponentType.IdentityAllowDeny) {
1269
1345
  coreConfig.types.trustVerifierComponent.push({
1270
- type,
1346
+ type: TrustVerifierComponentType.IdentityAllowDeny,
1271
1347
  options: {
1272
1348
  config: {
1273
1349
  allowIdentities: commaSeparatedListToArray(envVars.trustIdentitiesAllow),
@@ -1276,9 +1352,9 @@ async function configureTrust(coreConfig, envVars) {
1276
1352
  }
1277
1353
  });
1278
1354
  }
1279
- else {
1355
+ else if (trustVerifierType === TrustVerifierComponentType.JwtVerifiableCredential) {
1280
1356
  coreConfig.types.trustVerifierComponent.push({
1281
- type
1357
+ type: TrustVerifierComponentType.JwtVerifiableCredential
1282
1358
  });
1283
1359
  }
1284
1360
  }
@@ -1356,49 +1432,49 @@ async function configureRightsManagement(coreConfig, envVars) {
1356
1432
  }
1357
1433
  });
1358
1434
  coreConfig.types.rightsManagementPolicyArbiterComponent ??= [];
1359
- const policyArbiterTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyArbiters);
1435
+ const policyArbiterTypes = envListToArray(envVars, "rightsManagementPolicyArbiters", Object.values(RightsManagementPolicyArbiterComponentType));
1360
1436
  for (const policyArbiterType of policyArbiterTypes) {
1361
1437
  coreConfig.types.rightsManagementPolicyArbiterComponent.push({
1362
1438
  type: policyArbiterType
1363
1439
  });
1364
1440
  }
1365
1441
  coreConfig.types.rightsManagementPolicyObligationEnforcerComponent ??= [];
1366
- const policyObligationEnforcerTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyObligationEnforcers);
1442
+ const policyObligationEnforcerTypes = envListToArray(envVars, "rightsManagementPolicyObligationEnforcers", Object.values(RightsManagementPolicyObligationEnforcerComponentType));
1367
1443
  for (const policyObligationEnforcerType of policyObligationEnforcerTypes) {
1368
1444
  coreConfig.types.rightsManagementPolicyObligationEnforcerComponent.push({
1369
1445
  type: policyObligationEnforcerType
1370
1446
  });
1371
1447
  }
1372
1448
  coreConfig.types.rightsManagementPolicyEnforcementProcessorComponent ??= [];
1373
- const policyEnforcementProcessTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyEnforcementProcessors);
1449
+ const policyEnforcementProcessTypes = envListToArray(envVars, "rightsManagementPolicyEnforcementProcessors", Object.values(RightsManagementPolicyEnforcementProcessorComponentType));
1374
1450
  for (const policyEnforcementProcessorType of policyEnforcementProcessTypes) {
1375
1451
  coreConfig.types.rightsManagementPolicyEnforcementProcessorComponent.push({
1376
1452
  type: policyEnforcementProcessorType
1377
1453
  });
1378
1454
  }
1379
1455
  coreConfig.types.rightsManagementPolicyExecutionActionComponent ??= [];
1380
- const policyExecutionActionTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyExecutionActions);
1456
+ const policyExecutionActionTypes = envListToArray(envVars, "rightsManagementPolicyExecutionActions", Object.values(RightsManagementPolicyExecutionActionComponentType));
1381
1457
  for (const policyExecutionActionType of policyExecutionActionTypes) {
1382
1458
  coreConfig.types.rightsManagementPolicyExecutionActionComponent.push({
1383
1459
  type: policyExecutionActionType
1384
1460
  });
1385
1461
  }
1386
1462
  coreConfig.types.rightsManagementPolicyInformationSourceComponent ??= [];
1387
- const policyInformationSourceTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyInformationSources);
1463
+ const policyInformationSourceTypes = envListToArray(envVars, "rightsManagementPolicyInformationSources", Object.values(RightsManagementPolicyInformationSourceComponentType));
1388
1464
  for (const policyInformationSourceType of policyInformationSourceTypes) {
1389
1465
  coreConfig.types.rightsManagementPolicyInformationSourceComponent.push({
1390
1466
  type: policyInformationSourceType
1391
1467
  });
1392
1468
  }
1393
1469
  coreConfig.types.rightsManagementPolicyRequesterComponent ??= [];
1394
- const policyRequesterTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyRequesters);
1470
+ const policyRequesterTypes = envListToArray(envVars, "rightsManagementPolicyRequesters", Object.values(RightsManagementPolicyRequesterComponentType));
1395
1471
  for (const policyRequesterType of policyRequesterTypes) {
1396
1472
  coreConfig.types.rightsManagementPolicyRequesterComponent.push({
1397
1473
  type: policyRequesterType
1398
1474
  });
1399
1475
  }
1400
1476
  coreConfig.types.rightsManagementPolicyNegotiatorComponent ??= [];
1401
- const policyNegotiatorTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyNegotiators);
1477
+ const policyNegotiatorTypes = envListToArray(envVars, "rightsManagementPolicyNegotiators", Object.values(RightsManagementPolicyNegotiatorComponentType));
1402
1478
  for (const policyNegotiatorType of policyNegotiatorTypes) {
1403
1479
  coreConfig.types.rightsManagementPolicyNegotiatorComponent.push({
1404
1480
  type: policyNegotiatorType
@@ -1448,7 +1524,7 @@ async function configureFederatedCatalogue(coreConfig, envVars) {
1448
1524
  }
1449
1525
  });
1450
1526
  coreConfig.types.federatedCatalogueFilterComponent ??= [];
1451
- const filters = commaSeparatedListToArray(envVars.federatedCatalogueFilters);
1527
+ const filters = envListToArray(envVars, "federatedCatalogueFilters", Object.values(FederatedCatalogueFilterComponentType));
1452
1528
  for (const filter of filters) {
1453
1529
  coreConfig.types.federatedCatalogueFilterComponent.push({
1454
1530
  type: filter,
@@ -1619,7 +1695,8 @@ export function isTaskSchedulerRequired(envVars) {
1619
1695
  envBoolean(envVars, "dataspaceEnabled", false) ||
1620
1696
  isRightsManagementRequired(envVars) ||
1621
1697
  isAuthEntityStorageRequired(envVars) ||
1622
- isImmutableProofRequired(envVars));
1698
+ isImmutableProofRequired(envVars) ||
1699
+ isMailboxEnabled(envVars));
1623
1700
  }
1624
1701
  /**
1625
1702
  * Checks if the automation subsystem is required.
@@ -1646,6 +1723,17 @@ export function isTelemetryEnabled(envVars) {
1646
1723
  * @returns True if tracing is enabled.
1647
1724
  */
1648
1725
  export function isTracingEnabled(envVars) {
1649
- return commaSeparatedListToArray(envVars.tracingConnector).some(t => t === TracingConnectorType.EntityStorage || t === TracingConnectorType.OpenTelemetry);
1726
+ return commaSeparatedListToArray(envVars.tracingConnector).some(t => t === TracingConnectorType.EntityStorage ||
1727
+ t === TracingConnectorType.OpenTelemetry ||
1728
+ t === TracingConnectorType.Console);
1729
+ }
1730
+ /**
1731
+ * Checks if the mailbox subsystem is enabled.
1732
+ * Returns true when any component that depends on the mailbox subsystem is enabled.
1733
+ * @param envVars The environment variables.
1734
+ * @returns True if mailbox is enabled.
1735
+ */
1736
+ export function isMailboxEnabled(envVars) {
1737
+ return commaSeparatedListToArray(envVars.emailProtocolConnector).some(t => t === EmailProtocolConnectorType.Imap || t === EmailProtocolConnectorType.Pop3);
1650
1738
  }
1651
1739
  //# sourceMappingURL=engineEnvBuilder.js.map