@twin.org/node-core 0.9.3-next.1 → 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 +443 -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 +23 -7
  29. package/docs/changelog.md +34 -3
  30. package/docs/reference/functions/isMailboxEnabled.md +20 -0
  31. package/docs/reference/index.md +1 -0
  32. package/docs/reference/interfaces/IEngineEnvironmentVariables.md +44 -12
  33. package/package.json +1 -1
@@ -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,13 +663,13 @@ async function configureTracing(coreConfig, envVars) {
653
663
  });
654
664
  additionalConnectorCount++;
655
665
  }
656
- else if (tracingConnector === TracingConnectorType.Console) {
666
+ else if (tracingConnectorType === TracingConnectorType.Console) {
657
667
  coreConfig.types.tracingConnector.push({
658
668
  type: TracingConnectorType.Console
659
669
  });
660
670
  additionalConnectorCount++;
661
671
  }
662
- else if (tracingConnector === TracingConnectorType.OpenTelemetry) {
672
+ else if (tracingConnectorType === TracingConnectorType.OpenTelemetry) {
663
673
  const otelTracingConfig = {
664
674
  tracerName: envVars.openTelemetryTracingTracerName,
665
675
  tracerVersion: envVars.openTelemetryTracingTracerVersion
@@ -715,15 +725,13 @@ async function configureAutomation(coreConfig, envVars) {
715
725
  coreConfig.types.automationComponent.push({
716
726
  type: AutomationComponentType.Service
717
727
  });
718
- const automationActionTypes = commaSeparatedListToArray(envVars.automationActionTypes);
719
- if (Is.arrayValue(automationActionTypes)) {
720
- coreConfig.types.automationAction ??= [];
721
- for (const actionType of automationActionTypes) {
722
- coreConfig.types.automationAction.push({
723
- type: actionType,
724
- isMultiInstance: true
725
- });
726
- }
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
+ });
727
735
  }
728
736
  }
729
737
  }
@@ -826,69 +834,89 @@ async function configureContextIdHandlers(coreConfig, envVars) {
826
834
  * @returns A promise that resolves when the messaging configuration has been applied.
827
835
  */
828
836
  async function configureMessaging(coreConfig, envVars) {
829
- if (envBoolean(envVars, "messagingEnabled", false)) {
830
- coreConfig.types.messagingEmailConnector ??= [];
831
- coreConfig.types.messagingSmsConnector ??= [];
832
- coreConfig.types.messagingPushNotificationConnector ??= [];
833
- if (envVars.messagingEmailConnector === MessagingEmailConnectorType.EntityStorage) {
834
- coreConfig.types.messagingEmailConnector.push({
835
- type: MessagingEmailConnectorType.EntityStorage
836
- });
837
- }
838
- else if (envVars.messagingEmailConnector === MessagingEmailConnectorType.Aws) {
839
- coreConfig.types.messagingEmailConnector.push({
840
- type: MessagingEmailConnectorType.Aws,
841
- options: {
842
- config: {
843
- region: envVars.awsSesRegion ?? "",
844
- authMode: envVars.awsSesAuthMode,
845
- accessKeyId: envVars.awsSesAccessKeyId,
846
- secretAccessKey: envVars.awsSesSecretAccessKey,
847
- endpoint: envVars.awsSesEndpoint
848
- }
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
849
856
  }
850
- });
851
- }
852
- if (envVars.messagingSmsConnector === MessagingSmsConnectorType.EntityStorage) {
853
- coreConfig.types.messagingSmsConnector.push({
854
- type: MessagingSmsConnectorType.EntityStorage
855
- });
856
- }
857
- else if (envVars.messagingSmsConnector === MessagingSmsConnectorType.Aws) {
858
- coreConfig.types.messagingSmsConnector.push({
859
- type: MessagingSmsConnectorType.Aws,
860
- options: {
861
- config: {
862
- region: envVars.awsSesRegion ?? "",
863
- authMode: envVars.awsSesAuthMode,
864
- accessKeyId: envVars.awsSesAccessKeyId,
865
- secretAccessKey: envVars.awsSesSecretAccessKey,
866
- endpoint: envVars.awsSesEndpoint
867
- }
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
868
870
  }
869
- });
870
- }
871
- if (envVars.messagingPushNotificationConnector ===
872
- MessagingPushNotificationConnectorType.EntityStorage) {
873
- coreConfig.types.messagingPushNotificationConnector.push({
874
- type: MessagingPushNotificationConnectorType.EntityStorage
875
- });
876
- }
877
- else if (envVars.messagingPushNotificationConnector === MessagingPushNotificationConnectorType.Aws) {
878
- coreConfig.types.messagingPushNotificationConnector.push({
879
- type: MessagingPushNotificationConnectorType.Aws,
880
- options: {
881
- config: {
882
- region: envVars.awsSesRegion ?? "",
883
- authMode: envVars.awsSesAuthMode,
884
- accessKeyId: envVars.awsSesAccessKeyId,
885
- secretAccessKey: envVars.awsSesSecretAccessKey,
886
- endpoint: envVars.awsSesEndpoint,
887
- applicationsSettings: envArray(envVars, "awsMessagingPushNotificationApplications", [])
888
- }
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
889
890
  }
890
- });
891
- }
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) {
892
920
  coreConfig.types.messagingAdminComponent ??= [];
893
921
  coreConfig.types.messagingAdminComponent.push({
894
922
  type: MessagingAdminComponentType.Service
@@ -897,6 +925,40 @@ async function configureMessaging(coreConfig, envVars) {
897
925
  coreConfig.types.messagingComponent.push({ type: MessagingComponentType.Service });
898
926
  }
899
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
+ }
900
962
  /**
901
963
  * Configures the faucet.
902
964
  * @param coreConfig The core config.
@@ -905,12 +967,13 @@ async function configureMessaging(coreConfig, envVars) {
905
967
  */
906
968
  async function configureFaucet(coreConfig, envVars) {
907
969
  coreConfig.types.faucetConnector ??= [];
908
- if (envVars.faucetConnector === FaucetConnectorType.EntityStorage) {
970
+ const faucetConnectorType = envChoice(envVars, "faucetConnector", Object.values(FaucetConnectorType));
971
+ if (faucetConnectorType === FaucetConnectorType.EntityStorage) {
909
972
  coreConfig.types.faucetConnector.push({
910
973
  type: FaucetConnectorType.EntityStorage
911
974
  });
912
975
  }
913
- else if (envVars.faucetConnector === FaucetConnectorType.Iota &&
976
+ else if (faucetConnectorType === FaucetConnectorType.Iota &&
914
977
  Is.stringValue(envVars.iotaFaucetEndpoint)) {
915
978
  const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
916
979
  coreConfig.types.faucetConnector.push({
@@ -933,12 +996,13 @@ async function configureFaucet(coreConfig, envVars) {
933
996
  */
934
997
  async function configureWallet(coreConfig, envVars) {
935
998
  coreConfig.types.walletConnector ??= [];
936
- if (envVars.walletConnector === WalletConnectorType.EntityStorage) {
999
+ const walletConnectorType = envChoice(envVars, "walletConnector", Object.values(WalletConnectorType));
1000
+ if (walletConnectorType === WalletConnectorType.EntityStorage) {
937
1001
  coreConfig.types.walletConnector.push({
938
1002
  type: WalletConnectorType.EntityStorage
939
1003
  });
940
1004
  }
941
- else if (envVars.walletConnector === WalletConnectorType.Iota) {
1005
+ else if (walletConnectorType === WalletConnectorType.Iota) {
942
1006
  const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
943
1007
  coreConfig.types.walletConnector.push({
944
1008
  type: WalletConnectorType.Iota,
@@ -956,12 +1020,13 @@ async function configureWallet(coreConfig, envVars) {
956
1020
  */
957
1021
  async function configureNft(coreConfig, envVars) {
958
1022
  coreConfig.types.nftConnector ??= [];
959
- if (envVars.nftConnector === NftConnectorType.EntityStorage) {
1023
+ const nftConnectorType = envChoice(envVars, "nftConnector", Object.values(NftConnectorType));
1024
+ if (nftConnectorType === NftConnectorType.EntityStorage) {
960
1025
  coreConfig.types.nftConnector.push({
961
1026
  type: NftConnectorType.EntityStorage
962
1027
  });
963
1028
  }
964
- else if (envVars.nftConnector === NftConnectorType.Iota) {
1029
+ else if (nftConnectorType === NftConnectorType.Iota) {
965
1030
  const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
966
1031
  const config = {
967
1032
  ...dltConfig?.options?.config,
@@ -987,12 +1052,13 @@ async function configureNft(coreConfig, envVars) {
987
1052
  */
988
1053
  async function configureNotarization(coreConfig, envVars) {
989
1054
  coreConfig.types.notarizationConnector ??= [];
990
- if (envVars.notarizationConnector === NotarizationConnectorType.EntityStorage) {
1055
+ const notarizationConnectorType = envChoice(envVars, "notarizationConnector", Object.values(NotarizationConnectorType));
1056
+ if (notarizationConnectorType === NotarizationConnectorType.EntityStorage) {
991
1057
  coreConfig.types.notarizationConnector.push({
992
1058
  type: NotarizationConnectorType.EntityStorage
993
1059
  });
994
1060
  }
995
- else if (envVars.notarizationConnector === NotarizationConnectorType.Iota) {
1061
+ else if (notarizationConnectorType === NotarizationConnectorType.Iota) {
996
1062
  const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
997
1063
  coreConfig.types.notarizationConnector.push({
998
1064
  type: NotarizationConnectorType.Iota,
@@ -1042,12 +1108,13 @@ async function configureImmutableProof(coreConfig, envVars) {
1042
1108
  */
1043
1109
  async function configureIdentity(coreConfig, envVars) {
1044
1110
  coreConfig.types.identityConnector ??= [];
1045
- if (envVars.identityConnector === IdentityConnectorType.EntityStorage) {
1111
+ const identityConnectorType = envChoice(envVars, "identityConnector", Object.values(IdentityConnectorType));
1112
+ if (identityConnectorType === IdentityConnectorType.EntityStorage) {
1046
1113
  coreConfig.types.identityConnector.push({
1047
1114
  type: IdentityConnectorType.EntityStorage
1048
1115
  });
1049
1116
  }
1050
- else if (envVars.identityConnector === IdentityConnectorType.Iota) {
1117
+ else if (identityConnectorType === IdentityConnectorType.Iota) {
1051
1118
  const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
1052
1119
  coreConfig.types.identityConnector.push({
1053
1120
  type: IdentityConnectorType.Iota,
@@ -1080,12 +1147,13 @@ async function configureIdentity(coreConfig, envVars) {
1080
1147
  */
1081
1148
  async function configureIdentityResolver(coreConfig, envVars) {
1082
1149
  coreConfig.types.identityResolverConnector ??= [];
1083
- if (envVars.identityResolverConnector === IdentityResolverConnectorType.EntityStorage) {
1150
+ const identityResolverConnectorType = envChoice(envVars, "identityResolverConnector", Object.values(IdentityResolverConnectorType));
1151
+ if (identityResolverConnectorType === IdentityResolverConnectorType.EntityStorage) {
1084
1152
  coreConfig.types.identityResolverConnector.push({
1085
1153
  type: IdentityResolverConnectorType.EntityStorage
1086
1154
  });
1087
1155
  }
1088
- else if (envVars.identityResolverConnector === IdentityResolverConnectorType.Iota) {
1156
+ else if (identityResolverConnectorType === IdentityResolverConnectorType.Iota) {
1089
1157
  const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
1090
1158
  coreConfig.types.identityResolverConnector.push({
1091
1159
  type: IdentityResolverConnectorType.Iota,
@@ -1099,7 +1167,7 @@ async function configureIdentityResolver(coreConfig, envVars) {
1099
1167
  }
1100
1168
  });
1101
1169
  }
1102
- else if (envVars.identityResolverConnector === IdentityResolverConnectorType.Universal) {
1170
+ else if (identityResolverConnectorType === IdentityResolverConnectorType.Universal) {
1103
1171
  coreConfig.types.identityResolverConnector.push({
1104
1172
  type: IdentityResolverConnectorType.Universal,
1105
1173
  options: {
@@ -1124,7 +1192,8 @@ async function configureIdentityResolver(coreConfig, envVars) {
1124
1192
  */
1125
1193
  async function configureIdentityProfile(coreConfig, envVars) {
1126
1194
  coreConfig.types.identityProfileConnector ??= [];
1127
- if (envVars.identityProfileConnector === IdentityConnectorType.EntityStorage) {
1195
+ const identityProfileConnectorType = envChoice(envVars, "identityProfileConnector", Object.values(IdentityProfileConnectorType));
1196
+ if (identityProfileConnectorType === IdentityProfileConnectorType.EntityStorage) {
1128
1197
  coreConfig.types.identityProfileConnector.push({
1129
1198
  type: IdentityProfileConnectorType.EntityStorage
1130
1199
  });
@@ -1142,7 +1211,8 @@ async function configureIdentityProfile(coreConfig, envVars) {
1142
1211
  */
1143
1212
  async function configureAttestation(coreConfig, envVars) {
1144
1213
  coreConfig.types.attestationConnector ??= [];
1145
- if (envVars.attestationConnector === AttestationConnectorType.Nft) {
1214
+ const attestationConnectorType = envChoice(envVars, "attestationConnector", Object.values(AttestationConnectorType));
1215
+ if (attestationConnectorType === AttestationConnectorType.Nft) {
1146
1216
  coreConfig.types.attestationConnector.push({
1147
1217
  type: AttestationConnectorType.Nft
1148
1218
  });
@@ -1204,23 +1274,24 @@ async function configureAuditableItemStream(coreConfig, envVars) {
1204
1274
  * @returns A promise that resolves when the data processing configuration has been applied.
1205
1275
  */
1206
1276
  async function configureDataProcessing(coreConfig, envVars) {
1207
- 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) {
1208
1293
  coreConfig.types.dataProcessingComponent ??= [];
1209
1294
  coreConfig.types.dataProcessingComponent.push({ type: DataProcessingComponentType.Service });
1210
- coreConfig.types.dataConverterConnector ??= [];
1211
- const converterConnectors = commaSeparatedListToArray(envVars.dataConverterConnectors);
1212
- for (const converterConnector of converterConnectors) {
1213
- coreConfig.types.dataConverterConnector.push({
1214
- type: converterConnector
1215
- });
1216
- }
1217
- coreConfig.types.dataExtractorConnector ??= [];
1218
- const extractorConnectors = commaSeparatedListToArray(envVars.dataExtractorConnectors);
1219
- for (const extractorConnector of extractorConnectors) {
1220
- coreConfig.types.dataExtractorConnector.push({
1221
- type: extractorConnector
1222
- });
1223
- }
1224
1295
  }
1225
1296
  }
1226
1297
  /**
@@ -1255,7 +1326,7 @@ async function configureTrust(coreConfig, envVars) {
1255
1326
  type: TrustComponentType.Service
1256
1327
  });
1257
1328
  coreConfig.types.trustGeneratorComponent ??= [];
1258
- const trustGeneratorTypes = commaSeparatedListToArray(envVars.trustGenerators);
1329
+ const trustGeneratorTypes = envListToArray(envVars, "trustGenerators", Object.values(TrustGeneratorComponentType));
1259
1330
  for (const trustGeneratorType of trustGeneratorTypes) {
1260
1331
  coreConfig.types.trustGeneratorComponent.push({
1261
1332
  type: trustGeneratorType,
@@ -1268,12 +1339,11 @@ async function configureTrust(coreConfig, envVars) {
1268
1339
  });
1269
1340
  }
1270
1341
  coreConfig.types.trustVerifierComponent ??= [];
1271
- const trustVerifierTypes = commaSeparatedListToArray(envVars.trustVerifiers);
1342
+ const trustVerifierTypes = envListToArray(envVars, "trustVerifiers", Object.values(TrustVerifierComponentType));
1272
1343
  for (const trustVerifierType of trustVerifierTypes) {
1273
- const type = trustVerifierType;
1274
- if (type === TrustVerifierComponentType.IdentityAllowDeny) {
1344
+ if (trustVerifierType === TrustVerifierComponentType.IdentityAllowDeny) {
1275
1345
  coreConfig.types.trustVerifierComponent.push({
1276
- type,
1346
+ type: TrustVerifierComponentType.IdentityAllowDeny,
1277
1347
  options: {
1278
1348
  config: {
1279
1349
  allowIdentities: commaSeparatedListToArray(envVars.trustIdentitiesAllow),
@@ -1282,9 +1352,9 @@ async function configureTrust(coreConfig, envVars) {
1282
1352
  }
1283
1353
  });
1284
1354
  }
1285
- else {
1355
+ else if (trustVerifierType === TrustVerifierComponentType.JwtVerifiableCredential) {
1286
1356
  coreConfig.types.trustVerifierComponent.push({
1287
- type
1357
+ type: TrustVerifierComponentType.JwtVerifiableCredential
1288
1358
  });
1289
1359
  }
1290
1360
  }
@@ -1362,49 +1432,49 @@ async function configureRightsManagement(coreConfig, envVars) {
1362
1432
  }
1363
1433
  });
1364
1434
  coreConfig.types.rightsManagementPolicyArbiterComponent ??= [];
1365
- const policyArbiterTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyArbiters);
1435
+ const policyArbiterTypes = envListToArray(envVars, "rightsManagementPolicyArbiters", Object.values(RightsManagementPolicyArbiterComponentType));
1366
1436
  for (const policyArbiterType of policyArbiterTypes) {
1367
1437
  coreConfig.types.rightsManagementPolicyArbiterComponent.push({
1368
1438
  type: policyArbiterType
1369
1439
  });
1370
1440
  }
1371
1441
  coreConfig.types.rightsManagementPolicyObligationEnforcerComponent ??= [];
1372
- const policyObligationEnforcerTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyObligationEnforcers);
1442
+ const policyObligationEnforcerTypes = envListToArray(envVars, "rightsManagementPolicyObligationEnforcers", Object.values(RightsManagementPolicyObligationEnforcerComponentType));
1373
1443
  for (const policyObligationEnforcerType of policyObligationEnforcerTypes) {
1374
1444
  coreConfig.types.rightsManagementPolicyObligationEnforcerComponent.push({
1375
1445
  type: policyObligationEnforcerType
1376
1446
  });
1377
1447
  }
1378
1448
  coreConfig.types.rightsManagementPolicyEnforcementProcessorComponent ??= [];
1379
- const policyEnforcementProcessTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyEnforcementProcessors);
1449
+ const policyEnforcementProcessTypes = envListToArray(envVars, "rightsManagementPolicyEnforcementProcessors", Object.values(RightsManagementPolicyEnforcementProcessorComponentType));
1380
1450
  for (const policyEnforcementProcessorType of policyEnforcementProcessTypes) {
1381
1451
  coreConfig.types.rightsManagementPolicyEnforcementProcessorComponent.push({
1382
1452
  type: policyEnforcementProcessorType
1383
1453
  });
1384
1454
  }
1385
1455
  coreConfig.types.rightsManagementPolicyExecutionActionComponent ??= [];
1386
- const policyExecutionActionTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyExecutionActions);
1456
+ const policyExecutionActionTypes = envListToArray(envVars, "rightsManagementPolicyExecutionActions", Object.values(RightsManagementPolicyExecutionActionComponentType));
1387
1457
  for (const policyExecutionActionType of policyExecutionActionTypes) {
1388
1458
  coreConfig.types.rightsManagementPolicyExecutionActionComponent.push({
1389
1459
  type: policyExecutionActionType
1390
1460
  });
1391
1461
  }
1392
1462
  coreConfig.types.rightsManagementPolicyInformationSourceComponent ??= [];
1393
- const policyInformationSourceTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyInformationSources);
1463
+ const policyInformationSourceTypes = envListToArray(envVars, "rightsManagementPolicyInformationSources", Object.values(RightsManagementPolicyInformationSourceComponentType));
1394
1464
  for (const policyInformationSourceType of policyInformationSourceTypes) {
1395
1465
  coreConfig.types.rightsManagementPolicyInformationSourceComponent.push({
1396
1466
  type: policyInformationSourceType
1397
1467
  });
1398
1468
  }
1399
1469
  coreConfig.types.rightsManagementPolicyRequesterComponent ??= [];
1400
- const policyRequesterTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyRequesters);
1470
+ const policyRequesterTypes = envListToArray(envVars, "rightsManagementPolicyRequesters", Object.values(RightsManagementPolicyRequesterComponentType));
1401
1471
  for (const policyRequesterType of policyRequesterTypes) {
1402
1472
  coreConfig.types.rightsManagementPolicyRequesterComponent.push({
1403
1473
  type: policyRequesterType
1404
1474
  });
1405
1475
  }
1406
1476
  coreConfig.types.rightsManagementPolicyNegotiatorComponent ??= [];
1407
- const policyNegotiatorTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyNegotiators);
1477
+ const policyNegotiatorTypes = envListToArray(envVars, "rightsManagementPolicyNegotiators", Object.values(RightsManagementPolicyNegotiatorComponentType));
1408
1478
  for (const policyNegotiatorType of policyNegotiatorTypes) {
1409
1479
  coreConfig.types.rightsManagementPolicyNegotiatorComponent.push({
1410
1480
  type: policyNegotiatorType
@@ -1454,7 +1524,7 @@ async function configureFederatedCatalogue(coreConfig, envVars) {
1454
1524
  }
1455
1525
  });
1456
1526
  coreConfig.types.federatedCatalogueFilterComponent ??= [];
1457
- const filters = commaSeparatedListToArray(envVars.federatedCatalogueFilters);
1527
+ const filters = envListToArray(envVars, "federatedCatalogueFilters", Object.values(FederatedCatalogueFilterComponentType));
1458
1528
  for (const filter of filters) {
1459
1529
  coreConfig.types.federatedCatalogueFilterComponent.push({
1460
1530
  type: filter,
@@ -1625,7 +1695,8 @@ export function isTaskSchedulerRequired(envVars) {
1625
1695
  envBoolean(envVars, "dataspaceEnabled", false) ||
1626
1696
  isRightsManagementRequired(envVars) ||
1627
1697
  isAuthEntityStorageRequired(envVars) ||
1628
- isImmutableProofRequired(envVars));
1698
+ isImmutableProofRequired(envVars) ||
1699
+ isMailboxEnabled(envVars));
1629
1700
  }
1630
1701
  /**
1631
1702
  * Checks if the automation subsystem is required.
@@ -1656,4 +1727,13 @@ export function isTracingEnabled(envVars) {
1656
1727
  t === TracingConnectorType.OpenTelemetry ||
1657
1728
  t === TracingConnectorType.Console);
1658
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);
1738
+ }
1659
1739
  //# sourceMappingURL=engineEnvBuilder.js.map