@twin.org/engine-core 0.0.1-next.13 → 0.0.1-next.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +37 -1761
- package/dist/esm/index.mjs +40 -1761
- package/dist/types/engineCore.d.ts +13 -8
- package/dist/types/index.d.ts +0 -4
- package/dist/types/models/IEngineCoreOptions.d.ts +14 -5
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/EngineCore.md +27 -17
- package/docs/reference/classes/FileStateStorage.md +2 -2
- package/docs/reference/classes/MemoryStateStorage.md +2 -2
- package/docs/reference/index.md +0 -7
- package/docs/reference/interfaces/IEngineCoreOptions.md +43 -5
- package/package.json +4 -3
- package/dist/types/components/attestation.d.ts +0 -21
- package/dist/types/components/auditableItemGraph.d.ts +0 -11
- package/dist/types/components/auditableItemStream.d.ts +0 -11
- package/dist/types/components/backgroundTask.d.ts +0 -11
- package/dist/types/components/blobStorage.d.ts +0 -21
- package/dist/types/components/entityStorage.d.ts +0 -20
- package/dist/types/components/faucet.d.ts +0 -11
- package/dist/types/components/identity.d.ts +0 -21
- package/dist/types/components/identityProfile.d.ts +0 -21
- package/dist/types/components/immutableProof.d.ts +0 -11
- package/dist/types/components/immutableStorage.d.ts +0 -11
- package/dist/types/components/logging.d.ts +0 -21
- package/dist/types/components/nft.d.ts +0 -21
- package/dist/types/components/telemetry.d.ts +0 -21
- package/dist/types/components/vault.d.ts +0 -11
- package/dist/types/components/wallet.d.ts +0 -21
- package/dist/types/models/IEngineCoreEnvironmentVariables.d.ts +0 -265
- package/dist/types/utils/engineCoreEnvBuilder.d.ts +0 -8
- package/dist/types/utils/envHelper.d.ts +0 -15
- package/docs/reference/classes/EnvHelper.md +0 -41
- package/docs/reference/functions/buildEngineCoreConfiguration.md +0 -17
- package/docs/reference/functions/initialiseEntityStorageConnector.md +0 -31
- package/docs/reference/interfaces/IEngineCoreEnvironmentVariables.md +0 -523
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,1193 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var path = require('node:path');
|
|
4
3
|
var core = require('@twin.org/core');
|
|
5
|
-
var engineModels = require('@twin.org/engine-models');
|
|
6
|
-
var entityStorageConnectorCosmosdb = require('@twin.org/entity-storage-connector-cosmosdb');
|
|
7
|
-
var entityStorageConnectorDynamodb = require('@twin.org/entity-storage-connector-dynamodb');
|
|
8
|
-
var entityStorageConnectorFile = require('@twin.org/entity-storage-connector-file');
|
|
9
|
-
var entityStorageConnectorGcpFirestore = require('@twin.org/entity-storage-connector-gcp-firestore');
|
|
10
|
-
var entityStorageConnectorMemory = require('@twin.org/entity-storage-connector-memory');
|
|
11
|
-
var entityStorageConnectorScylladb = require('@twin.org/entity-storage-connector-scylladb');
|
|
12
|
-
var entityStorageModels = require('@twin.org/entity-storage-models');
|
|
13
|
-
var entityStorageService = require('@twin.org/entity-storage-service');
|
|
14
4
|
var loggingConnectorConsole = require('@twin.org/logging-connector-console');
|
|
15
5
|
var loggingModels = require('@twin.org/logging-models');
|
|
16
|
-
var
|
|
17
|
-
var attestationConnectorIota = require('@twin.org/attestation-connector-iota');
|
|
18
|
-
var attestationModels = require('@twin.org/attestation-models');
|
|
19
|
-
var attestationService = require('@twin.org/attestation-service');
|
|
20
|
-
var auditableItemGraphService = require('@twin.org/auditable-item-graph-service');
|
|
21
|
-
var auditableItemStreamService = require('@twin.org/auditable-item-stream-service');
|
|
22
|
-
var backgroundTaskConnectorEntityStorage = require('@twin.org/background-task-connector-entity-storage');
|
|
23
|
-
var backgroundTaskModels = require('@twin.org/background-task-models');
|
|
24
|
-
var blobStorageConnectorAwsS3 = require('@twin.org/blob-storage-connector-aws-s3');
|
|
25
|
-
var blobStorageConnectorAzure = require('@twin.org/blob-storage-connector-azure');
|
|
26
|
-
var blobStorageConnectorFile = require('@twin.org/blob-storage-connector-file');
|
|
27
|
-
var blobStorageConnectorGcp = require('@twin.org/blob-storage-connector-gcp');
|
|
28
|
-
var blobStorageConnectorIpfs = require('@twin.org/blob-storage-connector-ipfs');
|
|
29
|
-
var blobStorageConnectorMemory = require('@twin.org/blob-storage-connector-memory');
|
|
30
|
-
var blobStorageModels = require('@twin.org/blob-storage-models');
|
|
31
|
-
var blobStorageService = require('@twin.org/blob-storage-service');
|
|
32
|
-
var walletConnectorEntityStorage = require('@twin.org/wallet-connector-entity-storage');
|
|
33
|
-
var walletConnectorIota = require('@twin.org/wallet-connector-iota');
|
|
34
|
-
var walletModels = require('@twin.org/wallet-models');
|
|
35
|
-
var identityConnectorEntityStorage = require('@twin.org/identity-connector-entity-storage');
|
|
36
|
-
var identityConnectorIota = require('@twin.org/identity-connector-iota');
|
|
37
|
-
var identityModels = require('@twin.org/identity-models');
|
|
38
|
-
var identityService = require('@twin.org/identity-service');
|
|
39
|
-
var immutableProofService = require('@twin.org/immutable-proof-service');
|
|
40
|
-
var immutableStorageConnectorEntityStorage = require('@twin.org/immutable-storage-connector-entity-storage');
|
|
41
|
-
var immutableStorageConnectorIota = require('@twin.org/immutable-storage-connector-iota');
|
|
42
|
-
var immutableStorageModels = require('@twin.org/immutable-storage-models');
|
|
43
|
-
var loggingConnectorEntityStorage = require('@twin.org/logging-connector-entity-storage');
|
|
44
|
-
var loggingService = require('@twin.org/logging-service');
|
|
45
|
-
var nftConnectorEntityStorage = require('@twin.org/nft-connector-entity-storage');
|
|
46
|
-
var nftConnectorIota = require('@twin.org/nft-connector-iota');
|
|
47
|
-
var nftModels = require('@twin.org/nft-models');
|
|
48
|
-
var nftService = require('@twin.org/nft-service');
|
|
49
|
-
var telemetryConnectorEntityStorage = require('@twin.org/telemetry-connector-entity-storage');
|
|
50
|
-
var telemetryModels = require('@twin.org/telemetry-models');
|
|
51
|
-
var telemetryService = require('@twin.org/telemetry-service');
|
|
52
|
-
var vaultConnectorEntityStorage = require('@twin.org/vault-connector-entity-storage');
|
|
53
|
-
var vaultConnectorHashicorp = require('@twin.org/vault-connector-hashicorp');
|
|
54
|
-
var vaultModels = require('@twin.org/vault-models');
|
|
6
|
+
var modules = require('@twin.org/modules');
|
|
55
7
|
var promises = require('node:fs/promises');
|
|
56
|
-
|
|
57
|
-
// Copyright 2024 IOTA Stiftung.
|
|
58
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
59
|
-
/**
|
|
60
|
-
* Initialise the entity storage connector.
|
|
61
|
-
* @param engineCore The engine core.
|
|
62
|
-
* @param context The context for the engine.
|
|
63
|
-
* @param typeCustom Override the type of connector to use instead of default configuration.
|
|
64
|
-
* @param schema The schema for the entity storage.
|
|
65
|
-
* @throws GeneralError if the connector type is unknown.
|
|
66
|
-
*/
|
|
67
|
-
function initialiseEntityStorageConnector(engineCore, context, typeCustom, schema) {
|
|
68
|
-
const instanceName = core.StringHelper.kebabCase(schema);
|
|
69
|
-
let entityStorageConfig;
|
|
70
|
-
if (core.Is.stringValue(typeCustom)) {
|
|
71
|
-
// A custom type has been specified, so look it up
|
|
72
|
-
entityStorageConfig = context.config.entityStorageConnector?.find(c => c.type === typeCustom || c.overrideInstanceType === typeCustom);
|
|
73
|
-
if (core.Is.empty(entityStorageConfig)) {
|
|
74
|
-
throw new core.GeneralError("engineCore", "entityStorageCustomMissing", {
|
|
75
|
-
typeCustom,
|
|
76
|
-
storageName: instanceName
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
// The default entity storage method is either the one with the isDefault flag set
|
|
82
|
-
// or pick the first one if no default is set.
|
|
83
|
-
entityStorageConfig =
|
|
84
|
-
context.config.entityStorageConnector?.find(c => c.isDefault ?? false) ??
|
|
85
|
-
context.config.entityStorageConnector?.[0];
|
|
86
|
-
if (core.Is.empty(entityStorageConfig)) {
|
|
87
|
-
throw new core.GeneralError("engineCore", "entityStorageMissing", {
|
|
88
|
-
storageName: instanceName
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const type = entityStorageConfig.type;
|
|
93
|
-
let entityStorageConnector;
|
|
94
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuringEntityStorage", {
|
|
95
|
-
element: "Entity Storage",
|
|
96
|
-
storageName: instanceName,
|
|
97
|
-
storageType: type
|
|
98
|
-
}));
|
|
99
|
-
if (type === engineModels.EntityStorageConnectorType.Memory) {
|
|
100
|
-
entityStorageConnector = new entityStorageConnectorMemory.MemoryEntityStorageConnector({
|
|
101
|
-
entitySchema: schema
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
else if (type === engineModels.EntityStorageConnectorType.File) {
|
|
105
|
-
entityStorageConnector = new entityStorageConnectorFile.FileEntityStorageConnector({
|
|
106
|
-
entitySchema: schema,
|
|
107
|
-
...entityStorageConfig.options,
|
|
108
|
-
config: {
|
|
109
|
-
...entityStorageConfig.options.config,
|
|
110
|
-
directory: path.join(entityStorageConfig.options.config.directory, `${entityStorageConfig.options.folderPrefix ?? ""}${instanceName}`)
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
else if (type === engineModels.EntityStorageConnectorType.AwsDynamoDb) {
|
|
115
|
-
entityStorageConnector = new entityStorageConnectorDynamodb.DynamoDbEntityStorageConnector({
|
|
116
|
-
entitySchema: schema,
|
|
117
|
-
...entityStorageConfig.options,
|
|
118
|
-
config: {
|
|
119
|
-
...entityStorageConfig.options.config,
|
|
120
|
-
tableName: `${entityStorageConfig.options.tablePrefix ?? ""}${instanceName}`
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
else if (type === engineModels.EntityStorageConnectorType.AzureCosmosDb) {
|
|
125
|
-
entityStorageConnector = new entityStorageConnectorCosmosdb.CosmosDbEntityStorageConnector({
|
|
126
|
-
entitySchema: schema,
|
|
127
|
-
...entityStorageConfig.options,
|
|
128
|
-
config: {
|
|
129
|
-
...entityStorageConfig.options.config,
|
|
130
|
-
containerId: `${entityStorageConfig.options.tablePrefix ?? ""}${instanceName}`
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
else if (type === engineModels.EntityStorageConnectorType.GcpFirestoreDb) {
|
|
135
|
-
entityStorageConnector = new entityStorageConnectorGcpFirestore.FirestoreEntityStorageConnector({
|
|
136
|
-
entitySchema: schema,
|
|
137
|
-
...entityStorageConfig.options,
|
|
138
|
-
config: {
|
|
139
|
-
...entityStorageConfig.options.config,
|
|
140
|
-
collectionName: `${entityStorageConfig.options.tablePrefix ?? ""}${instanceName}`
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
else if (type === engineModels.EntityStorageConnectorType.ScyllaDb) {
|
|
145
|
-
entityStorageConnector = new entityStorageConnectorScylladb.ScyllaDBTableConnector({
|
|
146
|
-
entitySchema: schema,
|
|
147
|
-
...entityStorageConfig.options,
|
|
148
|
-
config: {
|
|
149
|
-
...entityStorageConfig.options.config,
|
|
150
|
-
tableName: `${entityStorageConfig.options.tablePrefix ?? ""}${instanceName}`
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
156
|
-
type,
|
|
157
|
-
connectorType: "entityStorageConnector"
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
context.componentInstances.push({
|
|
161
|
-
instanceType: instanceName,
|
|
162
|
-
component: entityStorageConnector
|
|
163
|
-
});
|
|
164
|
-
entityStorageModels.EntityStorageConnectorFactory.register(instanceName, () => entityStorageConnector);
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Initialise the entity storage connector.
|
|
168
|
-
* @param engineCore The engine core.
|
|
169
|
-
* @param context The context for the engine.
|
|
170
|
-
* @param instanceConfig The instance config.
|
|
171
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
172
|
-
* @returns The name of the instance created.
|
|
173
|
-
* @throws GeneralError if the connector type is unknown.
|
|
174
|
-
*/
|
|
175
|
-
function initialiseEntityStorageComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
176
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
177
|
-
element: `Entity Storage Component: ${instanceConfig.type}`
|
|
178
|
-
}));
|
|
179
|
-
const type = instanceConfig.type;
|
|
180
|
-
let connector;
|
|
181
|
-
let instanceType;
|
|
182
|
-
if (type === engineModels.EntityStorageComponentType.Service) {
|
|
183
|
-
const kebabName = core.StringHelper.kebabCase(instanceConfig.options.entityStorageType);
|
|
184
|
-
// See if there is a custom entity storage for this type, otherwise just use the default one.
|
|
185
|
-
const hasCustom = context.config.entityStorageConnector?.some(c => c.type === kebabName || c.overrideInstanceType === kebabName);
|
|
186
|
-
initialiseEntityStorageConnector(engineCore, context, hasCustom ? kebabName : undefined, instanceConfig.options.entityStorageType);
|
|
187
|
-
connector = new entityStorageService.EntityStorageService({
|
|
188
|
-
entityStorageType: kebabName,
|
|
189
|
-
config: {
|
|
190
|
-
...instanceConfig.options.config
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
instanceType = core.StringHelper.kebabCase(instanceConfig.options.entityStorageType);
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
197
|
-
type,
|
|
198
|
-
serviceType: "entityStorageComponent"
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
202
|
-
context.componentInstances.push({
|
|
203
|
-
instanceType: finalInstanceType,
|
|
204
|
-
component: connector
|
|
205
|
-
});
|
|
206
|
-
core.ComponentFactory.register(finalInstanceType, () => connector);
|
|
207
|
-
return finalInstanceType;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Copyright 2024 IOTA Stiftung.
|
|
211
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
212
|
-
/**
|
|
213
|
-
* Initialise the attestation connector.
|
|
214
|
-
* @param engineCore The engine core.
|
|
215
|
-
* @param context The context for the engine.
|
|
216
|
-
* @param instanceConfig The instance config.
|
|
217
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
218
|
-
* @returns The name of the instance created.
|
|
219
|
-
* @throws GeneralError if the connector type is unknown.
|
|
220
|
-
*/
|
|
221
|
-
function initialiseAttestationConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
222
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
223
|
-
element: `Attestation Connector: ${instanceConfig.type}`
|
|
224
|
-
}));
|
|
225
|
-
const type = instanceConfig.type;
|
|
226
|
-
let connector;
|
|
227
|
-
let instanceType;
|
|
228
|
-
if (type === engineModels.AttestationConnectorType.Iota) {
|
|
229
|
-
connector = new attestationConnectorIota.IotaAttestationConnector({
|
|
230
|
-
identityConnectorType: context.defaultTypes.identityConnector,
|
|
231
|
-
nftConnectorType: context.defaultTypes.nftConnector,
|
|
232
|
-
...instanceConfig.options
|
|
233
|
-
});
|
|
234
|
-
instanceType = attestationConnectorIota.IotaAttestationConnector.NAMESPACE;
|
|
235
|
-
}
|
|
236
|
-
else if (type === engineModels.AttestationConnectorType.EntityStorage) {
|
|
237
|
-
connector = new attestationConnectorEntityStorage.EntityStorageAttestationConnector({
|
|
238
|
-
identityConnectorType: context.defaultTypes.identityConnector,
|
|
239
|
-
nftConnectorType: context.defaultTypes.nftConnector,
|
|
240
|
-
...instanceConfig.options
|
|
241
|
-
});
|
|
242
|
-
instanceType = attestationConnectorEntityStorage.EntityStorageAttestationConnector.NAMESPACE;
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
246
|
-
type,
|
|
247
|
-
connectorType: "attestationConnector"
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
251
|
-
context.componentInstances.push({
|
|
252
|
-
instanceType: finalInstanceType,
|
|
253
|
-
component: connector
|
|
254
|
-
});
|
|
255
|
-
attestationModels.AttestationConnectorFactory.register(finalInstanceType, () => connector);
|
|
256
|
-
return finalInstanceType;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Initialise the attestation component.
|
|
260
|
-
* @param engineCore The engine core.
|
|
261
|
-
* @param context The context for the engine.
|
|
262
|
-
* @param instanceConfig The instance config.
|
|
263
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
264
|
-
* @returns The name of the instance created.
|
|
265
|
-
* @throws GeneralError if the component type is unknown.
|
|
266
|
-
*/
|
|
267
|
-
function initialiseAttestationComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
268
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
269
|
-
element: `Attestation Component: ${instanceConfig.type}`
|
|
270
|
-
}));
|
|
271
|
-
const type = instanceConfig.type;
|
|
272
|
-
let component;
|
|
273
|
-
let instanceType;
|
|
274
|
-
if (type === engineModels.AttestationComponentType.Service) {
|
|
275
|
-
component = new attestationService.AttestationService({
|
|
276
|
-
walletConnectorType: context.defaultTypes.walletConnector,
|
|
277
|
-
...instanceConfig.options
|
|
278
|
-
});
|
|
279
|
-
instanceType = attestationService.AttestationService.NAMESPACE;
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
283
|
-
type,
|
|
284
|
-
componentType: "attestationComponent"
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
288
|
-
context.componentInstances.push({
|
|
289
|
-
instanceType: finalInstanceType,
|
|
290
|
-
component
|
|
291
|
-
});
|
|
292
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
293
|
-
return finalInstanceType;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Initialise the auditable item graph component.
|
|
298
|
-
* @param engineCore The engine core.
|
|
299
|
-
* @param context The context for the engine.
|
|
300
|
-
* @param instanceConfig The instance config.
|
|
301
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
302
|
-
* @returns The name of the instance created.
|
|
303
|
-
* @throws GeneralError if the component type is unknown.
|
|
304
|
-
*/
|
|
305
|
-
function initialiseAuditableItemGraphComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
306
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
307
|
-
element: `Auditable Item Graph Component: ${instanceConfig.type}`
|
|
308
|
-
}));
|
|
309
|
-
const type = instanceConfig.type;
|
|
310
|
-
let component;
|
|
311
|
-
let instanceType;
|
|
312
|
-
if (type === engineModels.AuditableItemGraphComponentType.Service) {
|
|
313
|
-
auditableItemGraphService.initSchema();
|
|
314
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.vertexEntityStorageType, "AuditableItemGraphVertex");
|
|
315
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.changesetEntityStorageType, "AuditableItemGraphChangeset");
|
|
316
|
-
component = new auditableItemGraphService.AuditableItemGraphService({
|
|
317
|
-
immutableProofComponentType: context.defaultTypes.immutableProofComponent,
|
|
318
|
-
...instanceConfig.options
|
|
319
|
-
});
|
|
320
|
-
instanceType = auditableItemGraphService.AuditableItemGraphService.NAMESPACE;
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
324
|
-
type,
|
|
325
|
-
componentType: "auditableItemGraphComponent"
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
329
|
-
context.componentInstances.push({
|
|
330
|
-
instanceType: finalInstanceType,
|
|
331
|
-
component
|
|
332
|
-
});
|
|
333
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
334
|
-
return finalInstanceType;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Initialise the auditable item stream component.
|
|
339
|
-
* @param engineCore The engine core.
|
|
340
|
-
* @param context The context for the engine.
|
|
341
|
-
* @param instanceConfig The instance config.
|
|
342
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
343
|
-
* @returns The name of the instance created.
|
|
344
|
-
* @throws GeneralError if the component type is unknown.
|
|
345
|
-
*/
|
|
346
|
-
function initialiseAuditableItemStreamComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
347
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
348
|
-
element: `Auditable Item Stream Component: ${instanceConfig.type}`
|
|
349
|
-
}));
|
|
350
|
-
const type = instanceConfig.type;
|
|
351
|
-
let component;
|
|
352
|
-
let instanceType;
|
|
353
|
-
if (type === engineModels.AuditableItemStreamComponentType.Service) {
|
|
354
|
-
auditableItemStreamService.initSchema();
|
|
355
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.streamEntityStorageType, "AuditableItemStream");
|
|
356
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.streamEntryEntityStorageType, "AuditableItemStreamEntry");
|
|
357
|
-
component = new auditableItemStreamService.AuditableItemStreamService({
|
|
358
|
-
immutableProofComponentType: context.defaultTypes.immutableProofComponent,
|
|
359
|
-
...instanceConfig.options
|
|
360
|
-
});
|
|
361
|
-
instanceType = auditableItemStreamService.AuditableItemStreamService.NAMESPACE;
|
|
362
|
-
}
|
|
363
|
-
else {
|
|
364
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
365
|
-
type,
|
|
366
|
-
componentType: "auditableItemStreamComponent"
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
370
|
-
context.componentInstances.push({
|
|
371
|
-
instanceType: finalInstanceType,
|
|
372
|
-
component
|
|
373
|
-
});
|
|
374
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
375
|
-
return finalInstanceType;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
// Copyright 2024 IOTA Stiftung.
|
|
379
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
380
|
-
/**
|
|
381
|
-
* Initialise a background task connector.
|
|
382
|
-
* @param engineCore The engine core.
|
|
383
|
-
* @param context The context for the engine.
|
|
384
|
-
* @param instanceConfig The instance config.
|
|
385
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
386
|
-
* @returns The name of the instance created.
|
|
387
|
-
* @throws GeneralError if the connector type is unknown.
|
|
388
|
-
*/
|
|
389
|
-
function initialiseBackgroundTaskConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
390
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
391
|
-
element: `Background Task Connector: ${instanceConfig.type}`
|
|
392
|
-
}));
|
|
393
|
-
const type = instanceConfig.type;
|
|
394
|
-
let connector;
|
|
395
|
-
let instanceType;
|
|
396
|
-
if (type === engineModels.BackgroundTaskConnectorType.EntityStorage) {
|
|
397
|
-
backgroundTaskConnectorEntityStorage.initSchema();
|
|
398
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.backgroundTaskEntityStorageType, "BackgroundTask");
|
|
399
|
-
connector = new backgroundTaskConnectorEntityStorage.EntityStorageBackgroundTaskConnector({
|
|
400
|
-
loggingConnectorType: context.defaultTypes.loggingConnector,
|
|
401
|
-
...instanceConfig.options
|
|
402
|
-
});
|
|
403
|
-
instanceType = backgroundTaskConnectorEntityStorage.EntityStorageBackgroundTaskConnector.NAMESPACE;
|
|
404
|
-
}
|
|
405
|
-
else {
|
|
406
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
407
|
-
type,
|
|
408
|
-
connectorType: "backgroundTaskConnector"
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
412
|
-
context.componentInstances.push({ instanceType: finalInstanceType, component: connector });
|
|
413
|
-
backgroundTaskModels.BackgroundTaskConnectorFactory.register(finalInstanceType, () => connector);
|
|
414
|
-
return finalInstanceType;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
// Copyright 2024 IOTA Stiftung.
|
|
418
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
419
|
-
/**
|
|
420
|
-
* Initialise the blob storage connector.
|
|
421
|
-
* @param engineCore The engine core.
|
|
422
|
-
* @param context The context for the engine.
|
|
423
|
-
* @param instanceConfig The instance config.
|
|
424
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
425
|
-
* @returns The name of the instance created.
|
|
426
|
-
* @throws GeneralError if the connector type is unknown.
|
|
427
|
-
*/
|
|
428
|
-
function initialiseBlobStorageConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
429
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
430
|
-
element: `Blob Storage Connector: ${instanceConfig.type}`
|
|
431
|
-
}));
|
|
432
|
-
const type = instanceConfig.type;
|
|
433
|
-
let connector;
|
|
434
|
-
let instanceType;
|
|
435
|
-
if (type === engineModels.BlobStorageConnectorType.Ipfs) {
|
|
436
|
-
connector = new blobStorageConnectorIpfs.IpfsBlobStorageConnector(instanceConfig.options);
|
|
437
|
-
instanceType = blobStorageConnectorIpfs.IpfsBlobStorageConnector.NAMESPACE;
|
|
438
|
-
}
|
|
439
|
-
else if (type === engineModels.BlobStorageConnectorType.File) {
|
|
440
|
-
connector = new blobStorageConnectorFile.FileBlobStorageConnector({
|
|
441
|
-
...instanceConfig.options,
|
|
442
|
-
config: {
|
|
443
|
-
...instanceConfig.options.config,
|
|
444
|
-
directory: core.Is.stringValue(instanceConfig.options.storagePrefix)
|
|
445
|
-
? path.join(instanceConfig.options.config.directory, instanceConfig.options.storagePrefix)
|
|
446
|
-
: instanceConfig.options.config.directory
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
instanceType = blobStorageConnectorFile.FileBlobStorageConnector.NAMESPACE;
|
|
450
|
-
}
|
|
451
|
-
else if (type === engineModels.BlobStorageConnectorType.Memory) {
|
|
452
|
-
connector = new blobStorageConnectorMemory.MemoryBlobStorageConnector();
|
|
453
|
-
instanceType = blobStorageConnectorMemory.MemoryBlobStorageConnector.NAMESPACE;
|
|
454
|
-
}
|
|
455
|
-
else if (type === engineModels.BlobStorageConnectorType.AwsS3) {
|
|
456
|
-
connector = new blobStorageConnectorAwsS3.S3BlobStorageConnector({
|
|
457
|
-
...instanceConfig.options,
|
|
458
|
-
config: {
|
|
459
|
-
...instanceConfig.options.config,
|
|
460
|
-
bucketName: `${instanceConfig.options.storagePrefix ?? ""}${instanceConfig.options.config.bucketName}`
|
|
461
|
-
}
|
|
462
|
-
});
|
|
463
|
-
instanceType = blobStorageConnectorAwsS3.S3BlobStorageConnector.NAMESPACE;
|
|
464
|
-
}
|
|
465
|
-
else if (type === engineModels.BlobStorageConnectorType.GcpStorage) {
|
|
466
|
-
connector = new blobStorageConnectorGcp.GcpBlobStorageConnector({
|
|
467
|
-
...instanceConfig.options,
|
|
468
|
-
config: {
|
|
469
|
-
...instanceConfig.options.config,
|
|
470
|
-
bucketName: `${instanceConfig.options.storagePrefix ?? ""}${instanceConfig.options.config.bucketName}`
|
|
471
|
-
}
|
|
472
|
-
});
|
|
473
|
-
instanceType = blobStorageConnectorGcp.GcpBlobStorageConnector.NAMESPACE;
|
|
474
|
-
}
|
|
475
|
-
else if (type === engineModels.BlobStorageConnectorType.AzureStorage) {
|
|
476
|
-
connector = new blobStorageConnectorAzure.AzureBlobStorageConnector({
|
|
477
|
-
...instanceConfig.options,
|
|
478
|
-
config: {
|
|
479
|
-
...instanceConfig.options.config,
|
|
480
|
-
containerName: `${instanceConfig.options.storagePrefix ?? ""}${instanceConfig.options.config.containerName}`
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
instanceType = blobStorageConnectorAzure.AzureBlobStorageConnector.NAMESPACE;
|
|
484
|
-
}
|
|
485
|
-
else {
|
|
486
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
487
|
-
type,
|
|
488
|
-
connectorType: "blobStorageConnector"
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
492
|
-
context.componentInstances.push({
|
|
493
|
-
instanceType: finalInstanceType,
|
|
494
|
-
component: connector
|
|
495
|
-
});
|
|
496
|
-
blobStorageModels.BlobStorageConnectorFactory.register(finalInstanceType, () => connector);
|
|
497
|
-
return finalInstanceType;
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* Initialise the blob storage component.
|
|
501
|
-
* @param engineCore The engine core.
|
|
502
|
-
* @param context The context for the engine.
|
|
503
|
-
* @param instanceConfig The instance config.
|
|
504
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
505
|
-
* @returns The name of the instance created.
|
|
506
|
-
* @throws GeneralError if the component type is unknown.
|
|
507
|
-
*/
|
|
508
|
-
function initialiseBlobStorageComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
509
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
510
|
-
element: `Blob Storage Component: ${instanceConfig.type}`
|
|
511
|
-
}));
|
|
512
|
-
const type = instanceConfig.type;
|
|
513
|
-
let component;
|
|
514
|
-
let instanceType;
|
|
515
|
-
if (type === engineModels.BlobStorageComponentType.Service) {
|
|
516
|
-
blobStorageService.initSchema();
|
|
517
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.entryEntityStorageType, "BlobStorageEntry");
|
|
518
|
-
component = new blobStorageService.BlobStorageService({
|
|
519
|
-
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
520
|
-
...instanceConfig.options
|
|
521
|
-
});
|
|
522
|
-
instanceType = blobStorageService.BlobStorageService.NAMESPACE;
|
|
523
|
-
}
|
|
524
|
-
else {
|
|
525
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
526
|
-
type,
|
|
527
|
-
componentType: "blobStorageComponent"
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
531
|
-
context.componentInstances.push({
|
|
532
|
-
instanceType: finalInstanceType,
|
|
533
|
-
component
|
|
534
|
-
});
|
|
535
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
536
|
-
return finalInstanceType;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
// Copyright 2024 IOTA Stiftung.
|
|
540
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
541
|
-
/**
|
|
542
|
-
* Initialise a faucet connector.
|
|
543
|
-
* @param engineCore The engine core.
|
|
544
|
-
* @param context The context for the engine.
|
|
545
|
-
* @param instanceConfig The instance config.
|
|
546
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
547
|
-
* @returns The name of the instance created.
|
|
548
|
-
* @throws GeneralError if the connector type is unknown.
|
|
549
|
-
*/
|
|
550
|
-
function initialiseFaucetConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
551
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
552
|
-
element: `Faucet Connector: ${instanceConfig.type}`
|
|
553
|
-
}));
|
|
554
|
-
const type = instanceConfig.type;
|
|
555
|
-
let connector;
|
|
556
|
-
let instanceType;
|
|
557
|
-
if (type === engineModels.FaucetConnectorType.Iota) {
|
|
558
|
-
const dltConfig = context.config.dltConfig?.find(dlt => dlt.type === context.defaultTypes.dltConfig);
|
|
559
|
-
connector = new walletConnectorIota.IotaFaucetConnector({
|
|
560
|
-
...instanceConfig.options,
|
|
561
|
-
config: {
|
|
562
|
-
...dltConfig?.options?.config,
|
|
563
|
-
...instanceConfig.options.config
|
|
564
|
-
}
|
|
565
|
-
});
|
|
566
|
-
instanceType = walletConnectorIota.IotaFaucetConnector.NAMESPACE;
|
|
567
|
-
}
|
|
568
|
-
else if (type === engineModels.FaucetConnectorType.EntityStorage) {
|
|
569
|
-
connector = new walletConnectorEntityStorage.EntityStorageFaucetConnector(instanceConfig.options);
|
|
570
|
-
instanceType = walletConnectorEntityStorage.EntityStorageFaucetConnector.NAMESPACE;
|
|
571
|
-
}
|
|
572
|
-
else {
|
|
573
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
574
|
-
type,
|
|
575
|
-
connectorType: "faucetConnector"
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
579
|
-
context.componentInstances.push({
|
|
580
|
-
instanceType: finalInstanceType,
|
|
581
|
-
component: connector
|
|
582
|
-
});
|
|
583
|
-
walletModels.FaucetConnectorFactory.register(finalInstanceType, () => connector);
|
|
584
|
-
return finalInstanceType;
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
// Copyright 2024 IOTA Stiftung.
|
|
588
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
589
|
-
/**
|
|
590
|
-
* Initialise the identity connector.
|
|
591
|
-
* @param engineCore The engine core.
|
|
592
|
-
* @param context The context for the engine.
|
|
593
|
-
* @param instanceConfig The instance config.
|
|
594
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
595
|
-
* @returns The name of the instance created.
|
|
596
|
-
* @throws GeneralError if the connector type is unknown.
|
|
597
|
-
*/
|
|
598
|
-
function initialiseIdentityConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
599
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
600
|
-
element: `Identity Connector: ${instanceConfig.type}`
|
|
601
|
-
}));
|
|
602
|
-
const type = instanceConfig.type;
|
|
603
|
-
let connector;
|
|
604
|
-
let instanceType;
|
|
605
|
-
if (type === engineModels.IdentityConnectorType.Iota) {
|
|
606
|
-
const dltConfig = context.config.dltConfig?.find(dlt => dlt.type === context.defaultTypes.dltConfig);
|
|
607
|
-
connector = new identityConnectorIota.IotaIdentityConnector({
|
|
608
|
-
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
609
|
-
...instanceConfig.options,
|
|
610
|
-
config: {
|
|
611
|
-
...dltConfig?.options?.config,
|
|
612
|
-
...instanceConfig.options.config
|
|
613
|
-
}
|
|
614
|
-
});
|
|
615
|
-
instanceType = identityConnectorIota.IotaIdentityConnector.NAMESPACE;
|
|
616
|
-
}
|
|
617
|
-
else if (type === engineModels.IdentityConnectorType.EntityStorage) {
|
|
618
|
-
identityConnectorEntityStorage.initSchema({ includeProfile: false });
|
|
619
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.didDocumentEntityStorageType, "IdentityDocument");
|
|
620
|
-
connector = new identityConnectorEntityStorage.EntityStorageIdentityConnector({
|
|
621
|
-
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
622
|
-
...instanceConfig.options
|
|
623
|
-
});
|
|
624
|
-
instanceType = identityConnectorEntityStorage.EntityStorageIdentityConnector.NAMESPACE;
|
|
625
|
-
}
|
|
626
|
-
else {
|
|
627
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
628
|
-
type,
|
|
629
|
-
connectorType: "identityConnector"
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
633
|
-
context.componentInstances.push({ instanceType: finalInstanceType, component: connector });
|
|
634
|
-
identityModels.IdentityConnectorFactory.register(finalInstanceType, () => connector);
|
|
635
|
-
return finalInstanceType;
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* Initialise the identity component.
|
|
639
|
-
* @param engineCore The engine core.
|
|
640
|
-
* @param context The context for the engine.
|
|
641
|
-
* @param instanceConfig The instance config.
|
|
642
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
643
|
-
* @returns The name of the instance created.
|
|
644
|
-
* @throws GeneralError if the component type is unknown.
|
|
645
|
-
*/
|
|
646
|
-
function initialiseIdentityComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
647
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
648
|
-
element: `Identity Component: ${instanceConfig.type}`
|
|
649
|
-
}));
|
|
650
|
-
const type = instanceConfig.type;
|
|
651
|
-
let component;
|
|
652
|
-
let instanceType;
|
|
653
|
-
if (type === engineModels.IdentityComponentType.Service) {
|
|
654
|
-
component = new identityService.IdentityService(instanceConfig.options);
|
|
655
|
-
instanceType = identityService.IdentityService.NAMESPACE;
|
|
656
|
-
}
|
|
657
|
-
else {
|
|
658
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
659
|
-
type,
|
|
660
|
-
componentType: "identityComponent"
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
664
|
-
context.componentInstances.push({ instanceType: finalInstanceType, component });
|
|
665
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
666
|
-
return finalInstanceType;
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
// Copyright 2024 IOTA Stiftung.
|
|
670
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
671
|
-
/**
|
|
672
|
-
* Initialise the identity profile connector.
|
|
673
|
-
* @param engineCore The engine core.
|
|
674
|
-
* @param context The context for the engine.
|
|
675
|
-
* @param instanceConfig The instance config.
|
|
676
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
677
|
-
* @returns The name of the instance created.
|
|
678
|
-
* @throws GeneralError if the connector type is unknown.
|
|
679
|
-
*/
|
|
680
|
-
function initialiseIdentityProfileConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
681
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
682
|
-
element: `Identity Profile Connector: ${instanceConfig.type}`
|
|
683
|
-
}));
|
|
684
|
-
const type = instanceConfig.type;
|
|
685
|
-
let connector;
|
|
686
|
-
let instanceType;
|
|
687
|
-
if (type === engineModels.IdentityProfileConnectorType.EntityStorage) {
|
|
688
|
-
identityConnectorEntityStorage.initSchema({ includeDocument: false });
|
|
689
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.profileEntityStorageType, "IdentityProfile");
|
|
690
|
-
connector = new identityConnectorEntityStorage.EntityStorageIdentityProfileConnector(instanceConfig.options);
|
|
691
|
-
instanceType = identityConnectorEntityStorage.EntityStorageIdentityProfileConnector.NAMESPACE;
|
|
692
|
-
}
|
|
693
|
-
else {
|
|
694
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
695
|
-
type,
|
|
696
|
-
serviceType: "identityProfile"
|
|
697
|
-
});
|
|
698
|
-
}
|
|
699
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
700
|
-
context.componentInstances.push({
|
|
701
|
-
instanceType: finalInstanceType,
|
|
702
|
-
component: connector
|
|
703
|
-
});
|
|
704
|
-
identityModels.IdentityProfileConnectorFactory.register(finalInstanceType, () => connector);
|
|
705
|
-
return finalInstanceType;
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* Initialise the identity profile component.
|
|
709
|
-
* @param engineCore The engine core.
|
|
710
|
-
* @param context The context for the engine.
|
|
711
|
-
* @param instanceConfig The instance config.
|
|
712
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
713
|
-
* @returns The name of the instance created.
|
|
714
|
-
* @throws GeneralError if the component type is unknown.
|
|
715
|
-
*/
|
|
716
|
-
function initialiseIdentityProfileComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
717
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
718
|
-
element: `Identity Profile Component: ${instanceConfig.type}`
|
|
719
|
-
}));
|
|
720
|
-
const type = instanceConfig.type;
|
|
721
|
-
let component;
|
|
722
|
-
let instanceType;
|
|
723
|
-
if (type === engineModels.IdentityProfileComponentType.Service) {
|
|
724
|
-
component = new identityService.IdentityProfileService({
|
|
725
|
-
profileEntityConnectorType: context.defaultTypes.identityProfileConnector,
|
|
726
|
-
...instanceConfig.options
|
|
727
|
-
});
|
|
728
|
-
instanceType = identityService.IdentityProfileService.NAMESPACE;
|
|
729
|
-
}
|
|
730
|
-
else {
|
|
731
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
732
|
-
type,
|
|
733
|
-
componentType: "identityProfileComponent"
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
737
|
-
context.componentInstances.push({
|
|
738
|
-
instanceType: finalInstanceType,
|
|
739
|
-
component
|
|
740
|
-
});
|
|
741
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
742
|
-
return finalInstanceType;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
// Copyright 2024 IOTA Stiftung.
|
|
746
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
747
|
-
/**
|
|
748
|
-
* Initialise the immutable proof component.
|
|
749
|
-
* @param engineCore The engine core.
|
|
750
|
-
* @param context The context for the engine.
|
|
751
|
-
* @param instanceConfig The instance config.
|
|
752
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
753
|
-
* @returns The name of the instance created.
|
|
754
|
-
* @throws GeneralError if the component type is unknown.
|
|
755
|
-
*/
|
|
756
|
-
function initialiseImmutableProofComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
757
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
758
|
-
element: `Immutable Proof Component: ${instanceConfig.type}`
|
|
759
|
-
}));
|
|
760
|
-
const type = instanceConfig.type;
|
|
761
|
-
let component;
|
|
762
|
-
let instanceType;
|
|
763
|
-
if (type === engineModels.ImmutableProofComponentType.Service) {
|
|
764
|
-
immutableProofService.initSchema();
|
|
765
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.immutableProofEntityStorageType, "ImmutableProof");
|
|
766
|
-
component = new immutableProofService.ImmutableProofService({
|
|
767
|
-
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
768
|
-
immutableStorageType: context.defaultTypes.immutableStorageConnector,
|
|
769
|
-
identityConnectorType: context.defaultTypes.identityConnector,
|
|
770
|
-
backgroundTaskConnectorType: context.defaultTypes.backgroundTaskConnector,
|
|
771
|
-
...instanceConfig.options
|
|
772
|
-
});
|
|
773
|
-
instanceType = immutableProofService.ImmutableProofService.NAMESPACE;
|
|
774
|
-
}
|
|
775
|
-
else {
|
|
776
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
777
|
-
type,
|
|
778
|
-
componentType: "immutableProofComponent"
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
782
|
-
context.componentInstances.push({
|
|
783
|
-
instanceType: finalInstanceType,
|
|
784
|
-
component
|
|
785
|
-
});
|
|
786
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
787
|
-
return finalInstanceType;
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
// Copyright 2024 IOTA Stiftung.
|
|
791
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
792
|
-
/**
|
|
793
|
-
* Initialise the immutable storage connector.
|
|
794
|
-
* @param engineCore The engine core.
|
|
795
|
-
* @param context The context for the engine.
|
|
796
|
-
* @param instanceConfig The instance config.
|
|
797
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
798
|
-
* @returns The name of the instance created.
|
|
799
|
-
* @throws GeneralError if the connector type is unknown.
|
|
800
|
-
*/
|
|
801
|
-
function initialiseImmutableStorageConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
802
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
803
|
-
element: `Immutable Storage Connector: ${instanceConfig.type}`
|
|
804
|
-
}));
|
|
805
|
-
const type = instanceConfig.type;
|
|
806
|
-
let connector;
|
|
807
|
-
let instanceType;
|
|
808
|
-
if (type === engineModels.ImmutableStorageConnectorType.Iota) {
|
|
809
|
-
const dltConfig = context.config.dltConfig?.find(dlt => dlt.type === context.defaultTypes.dltConfig);
|
|
810
|
-
connector = new immutableStorageConnectorIota.IotaImmutableStorageConnector({
|
|
811
|
-
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
812
|
-
...instanceConfig.options,
|
|
813
|
-
config: {
|
|
814
|
-
...dltConfig?.options?.config,
|
|
815
|
-
...instanceConfig.options.config
|
|
816
|
-
}
|
|
817
|
-
});
|
|
818
|
-
instanceType = immutableStorageConnectorIota.IotaImmutableStorageConnector.NAMESPACE;
|
|
819
|
-
}
|
|
820
|
-
else if (type === engineModels.ImmutableStorageConnectorType.EntityStorage) {
|
|
821
|
-
immutableStorageConnectorEntityStorage.initSchema();
|
|
822
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.immutableStorageEntityStorageType, "ImmutableItem");
|
|
823
|
-
connector = new immutableStorageConnectorEntityStorage.EntityStorageImmutableStorageConnector(instanceConfig.options);
|
|
824
|
-
instanceType = immutableStorageConnectorEntityStorage.EntityStorageImmutableStorageConnector.NAMESPACE;
|
|
825
|
-
}
|
|
826
|
-
else {
|
|
827
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
828
|
-
type,
|
|
829
|
-
connectorType: "immutableStorageConnector"
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
833
|
-
context.componentInstances.push({
|
|
834
|
-
instanceType: finalInstanceType,
|
|
835
|
-
component: connector
|
|
836
|
-
});
|
|
837
|
-
immutableStorageModels.ImmutableStorageConnectorFactory.register(finalInstanceType, () => connector);
|
|
838
|
-
return finalInstanceType;
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
// Copyright 2024 IOTA Stiftung.
|
|
842
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
843
|
-
/**
|
|
844
|
-
* Initialise the logging connector.
|
|
845
|
-
* @param engineCore The engine core.
|
|
846
|
-
* @param context The engine core context.
|
|
847
|
-
* @param instanceConfig The instance config.
|
|
848
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
849
|
-
* @returns The name of the instance created.
|
|
850
|
-
* @throws GeneralError if the connector type is unknown.
|
|
851
|
-
*/
|
|
852
|
-
function initialiseLoggingConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
853
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
854
|
-
element: `Logging Connector: ${instanceConfig.type}`
|
|
855
|
-
}));
|
|
856
|
-
const type = instanceConfig.type;
|
|
857
|
-
let connector;
|
|
858
|
-
let instanceType;
|
|
859
|
-
if (type === engineModels.LoggingConnectorType.Console) {
|
|
860
|
-
connector = new loggingConnectorConsole.ConsoleLoggingConnector(instanceConfig.options);
|
|
861
|
-
instanceType = loggingConnectorConsole.ConsoleLoggingConnector.NAMESPACE;
|
|
862
|
-
}
|
|
863
|
-
else if (type === engineModels.LoggingConnectorType.EntityStorage) {
|
|
864
|
-
loggingConnectorEntityStorage.initSchema();
|
|
865
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.logEntryStorageConnectorType, "LogEntry");
|
|
866
|
-
connector = new loggingConnectorEntityStorage.EntityStorageLoggingConnector(instanceConfig.options);
|
|
867
|
-
instanceType = loggingConnectorEntityStorage.EntityStorageLoggingConnector.NAMESPACE;
|
|
868
|
-
}
|
|
869
|
-
else if (type === engineModels.LoggingConnectorType.Multi) {
|
|
870
|
-
connector = new loggingModels.MultiLoggingConnector(instanceConfig.options);
|
|
871
|
-
instanceType = loggingModels.MultiLoggingConnector.NAMESPACE;
|
|
872
|
-
}
|
|
873
|
-
else {
|
|
874
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
875
|
-
type,
|
|
876
|
-
connectorType: "loggingConnector"
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
880
|
-
context.componentInstances.push({ instanceType: finalInstanceType, component: connector });
|
|
881
|
-
loggingModels.LoggingConnectorFactory.register(finalInstanceType, () => connector);
|
|
882
|
-
return finalInstanceType;
|
|
883
|
-
}
|
|
884
|
-
/**
|
|
885
|
-
* Initialise the logging component.
|
|
886
|
-
* @param engineCore The engine core.
|
|
887
|
-
* @param context The context for the engine.
|
|
888
|
-
* @param instanceConfig The instance config.
|
|
889
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
890
|
-
* @returns The name of the instance created.
|
|
891
|
-
* @throws GeneralError if the component type is unknown.
|
|
892
|
-
*/
|
|
893
|
-
function initialiseLoggingComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
894
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
895
|
-
element: `Logging Component: ${instanceConfig.type}`
|
|
896
|
-
}));
|
|
897
|
-
const type = instanceConfig.type;
|
|
898
|
-
let component;
|
|
899
|
-
let instanceType;
|
|
900
|
-
if (type === engineModels.LoggingComponentType.Service) {
|
|
901
|
-
component = new loggingService.LoggingService({
|
|
902
|
-
loggingConnectorType: context.defaultTypes.loggingConnector,
|
|
903
|
-
...instanceConfig.options
|
|
904
|
-
});
|
|
905
|
-
instanceType = loggingService.LoggingService.NAMESPACE;
|
|
906
|
-
}
|
|
907
|
-
else {
|
|
908
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
909
|
-
type,
|
|
910
|
-
componentType: "loggingComponent"
|
|
911
|
-
});
|
|
912
|
-
}
|
|
913
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
914
|
-
context.componentInstances.push({ instanceType: finalInstanceType, component });
|
|
915
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
916
|
-
return finalInstanceType;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
// Copyright 2024 IOTA Stiftung.
|
|
920
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
921
|
-
/**
|
|
922
|
-
* Initialise the NFT connector.
|
|
923
|
-
* @param engineCore The engine core.
|
|
924
|
-
* @param context The context for the engine.
|
|
925
|
-
* @param instanceConfig The instance config.
|
|
926
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
927
|
-
* @returns The name of the instance created.
|
|
928
|
-
* @throws GeneralError if the connector type is unknown.
|
|
929
|
-
*/
|
|
930
|
-
function initialiseNftConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
931
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
932
|
-
element: `NFT Connector: ${instanceConfig.type}`
|
|
933
|
-
}));
|
|
934
|
-
const type = instanceConfig.type;
|
|
935
|
-
let connector;
|
|
936
|
-
let instanceType;
|
|
937
|
-
if (type === engineModels.NftConnectorType.EntityStorage) {
|
|
938
|
-
nftConnectorEntityStorage.initSchema();
|
|
939
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.nftEntityStorageType, "Nft");
|
|
940
|
-
connector = new nftConnectorEntityStorage.EntityStorageNftConnector(instanceConfig.options);
|
|
941
|
-
instanceType = nftConnectorEntityStorage.EntityStorageNftConnector.NAMESPACE;
|
|
942
|
-
}
|
|
943
|
-
else if (type === engineModels.NftConnectorType.Iota) {
|
|
944
|
-
connector = new nftConnectorIota.IotaNftConnector({
|
|
945
|
-
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
946
|
-
...instanceConfig.options
|
|
947
|
-
});
|
|
948
|
-
instanceType = nftConnectorIota.IotaNftConnector.NAMESPACE;
|
|
949
|
-
}
|
|
950
|
-
else {
|
|
951
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
952
|
-
type,
|
|
953
|
-
connectorType: "nftConnector"
|
|
954
|
-
});
|
|
955
|
-
}
|
|
956
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
957
|
-
context.componentInstances.push({
|
|
958
|
-
instanceType: finalInstanceType,
|
|
959
|
-
component: connector
|
|
960
|
-
});
|
|
961
|
-
nftModels.NftConnectorFactory.register(finalInstanceType, () => connector);
|
|
962
|
-
return finalInstanceType;
|
|
963
|
-
}
|
|
964
|
-
/**
|
|
965
|
-
* Initialise the NFT component.
|
|
966
|
-
* @param engineCore The engine core.
|
|
967
|
-
* @param context The context for the engine.
|
|
968
|
-
* @param instanceConfig The instance config.
|
|
969
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
970
|
-
* @returns The name of the instance created.
|
|
971
|
-
* @throws GeneralError if the component type is unknown.
|
|
972
|
-
*/
|
|
973
|
-
function initialiseNftComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
974
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
975
|
-
element: `Nft Storage Component: ${instanceConfig.type}`
|
|
976
|
-
}));
|
|
977
|
-
const type = instanceConfig.type;
|
|
978
|
-
let component;
|
|
979
|
-
let instanceType;
|
|
980
|
-
if (type === engineModels.NftComponentType.Service) {
|
|
981
|
-
component = new nftService.NftService(instanceConfig.options);
|
|
982
|
-
instanceType = nftService.NftService.NAMESPACE;
|
|
983
|
-
}
|
|
984
|
-
else {
|
|
985
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
986
|
-
type,
|
|
987
|
-
componentType: "nftComponent"
|
|
988
|
-
});
|
|
989
|
-
}
|
|
990
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
991
|
-
context.componentInstances.push({
|
|
992
|
-
instanceType: finalInstanceType,
|
|
993
|
-
component
|
|
994
|
-
});
|
|
995
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
996
|
-
return finalInstanceType;
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
// Copyright 2024 IOTA Stiftung.
|
|
1000
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
1001
|
-
/**
|
|
1002
|
-
* Initialise a telemetry connector.
|
|
1003
|
-
* @param engineCore The engine core.
|
|
1004
|
-
* @param context The context for the engine.
|
|
1005
|
-
* @param instanceConfig The instance config.
|
|
1006
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
1007
|
-
* @returns The name of the instance created.
|
|
1008
|
-
* @throws GeneralError if the connector type is unknown.
|
|
1009
|
-
*/
|
|
1010
|
-
function initialiseTelemetryConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1011
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1012
|
-
element: `Telemetry Connector: ${instanceConfig.type}`
|
|
1013
|
-
}));
|
|
1014
|
-
const type = instanceConfig.type;
|
|
1015
|
-
let connector;
|
|
1016
|
-
let instanceType;
|
|
1017
|
-
if (type === engineModels.TelemetryConnectorType.EntityStorage) {
|
|
1018
|
-
telemetryConnectorEntityStorage.initSchema();
|
|
1019
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.telemetryMetricStorageConnectorType, "TelemetryMetric");
|
|
1020
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.telemetryMetricValueStorageConnectorType, "TelemetryMetricValue");
|
|
1021
|
-
connector = new telemetryConnectorEntityStorage.EntityStorageTelemetryConnector({
|
|
1022
|
-
loggingConnectorType: context.defaultTypes.loggingConnector,
|
|
1023
|
-
...instanceConfig.options
|
|
1024
|
-
});
|
|
1025
|
-
instanceType = telemetryConnectorEntityStorage.EntityStorageTelemetryConnector.NAMESPACE;
|
|
1026
|
-
}
|
|
1027
|
-
else {
|
|
1028
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
1029
|
-
type,
|
|
1030
|
-
connectorType: "telemetryConnector"
|
|
1031
|
-
});
|
|
1032
|
-
}
|
|
1033
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1034
|
-
context.componentInstances.push({ instanceType: finalInstanceType, component: connector });
|
|
1035
|
-
telemetryModels.TelemetryConnectorFactory.register(finalInstanceType, () => connector);
|
|
1036
|
-
return finalInstanceType;
|
|
1037
|
-
}
|
|
1038
|
-
/**
|
|
1039
|
-
* Initialise the telemetry component.
|
|
1040
|
-
* @param engineCore The engine core.
|
|
1041
|
-
* @param context The context for the engine.
|
|
1042
|
-
* @param instanceConfig The instance config.
|
|
1043
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
1044
|
-
* @returns The name of the instance created.
|
|
1045
|
-
* @throws GeneralError if the component type is unknown.
|
|
1046
|
-
*/
|
|
1047
|
-
function initialiseTelemetryComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1048
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1049
|
-
element: `Telemetry Component: ${instanceConfig.type}`
|
|
1050
|
-
}));
|
|
1051
|
-
const type = instanceConfig.type;
|
|
1052
|
-
let component;
|
|
1053
|
-
let instanceType;
|
|
1054
|
-
if (type === engineModels.TelemetryComponentType.Service) {
|
|
1055
|
-
component = new telemetryService.TelemetryService({
|
|
1056
|
-
telemetryConnectorType: context.defaultTypes.telemetryConnector,
|
|
1057
|
-
...instanceConfig.options
|
|
1058
|
-
});
|
|
1059
|
-
instanceType = telemetryService.TelemetryService.NAMESPACE;
|
|
1060
|
-
}
|
|
1061
|
-
else {
|
|
1062
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
1063
|
-
type,
|
|
1064
|
-
componentType: "telemetryComponent"
|
|
1065
|
-
});
|
|
1066
|
-
}
|
|
1067
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1068
|
-
context.componentInstances.push({ instanceType: finalInstanceType, component });
|
|
1069
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
1070
|
-
return finalInstanceType;
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
// Copyright 2024 IOTA Stiftung.
|
|
1074
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
1075
|
-
/**
|
|
1076
|
-
* Initialise the vault connector.
|
|
1077
|
-
* @param engineCore The engine core.
|
|
1078
|
-
* @param context The context for the engine.
|
|
1079
|
-
* @param instanceConfig The instance config.
|
|
1080
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
1081
|
-
* @returns The name of the instance created.
|
|
1082
|
-
* @throws GeneralError if the connector type is unknown.
|
|
1083
|
-
*/
|
|
1084
|
-
function initialiseVaultConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1085
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1086
|
-
element: `Vault Connector: ${instanceConfig.type}`
|
|
1087
|
-
}));
|
|
1088
|
-
const type = instanceConfig.type;
|
|
1089
|
-
let connector;
|
|
1090
|
-
let instanceType;
|
|
1091
|
-
if (type === engineModels.VaultConnectorType.EntityStorage) {
|
|
1092
|
-
vaultConnectorEntityStorage.initSchema();
|
|
1093
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.vaultKeyEntityStorageType, "VaultKey");
|
|
1094
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.vaultSecretEntityStorageType, "VaultSecret");
|
|
1095
|
-
connector = new vaultConnectorEntityStorage.EntityStorageVaultConnector(instanceConfig.options);
|
|
1096
|
-
instanceType = vaultConnectorEntityStorage.EntityStorageVaultConnector.NAMESPACE;
|
|
1097
|
-
}
|
|
1098
|
-
else if (type === engineModels.VaultConnectorType.Hashicorp) {
|
|
1099
|
-
connector = new vaultConnectorHashicorp.HashicorpVaultConnector(instanceConfig.options);
|
|
1100
|
-
instanceType = vaultConnectorHashicorp.HashicorpVaultConnector.NAMESPACE;
|
|
1101
|
-
}
|
|
1102
|
-
else {
|
|
1103
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
1104
|
-
type,
|
|
1105
|
-
connectorType: "vaultConnector"
|
|
1106
|
-
});
|
|
1107
|
-
}
|
|
1108
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1109
|
-
context.componentInstances.push({ instanceType: finalInstanceType, component: connector });
|
|
1110
|
-
vaultModels.VaultConnectorFactory.register(finalInstanceType, () => connector);
|
|
1111
|
-
return finalInstanceType;
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
// Copyright 2024 IOTA Stiftung.
|
|
1115
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
1116
|
-
/**
|
|
1117
|
-
* Initialise a wallet connector.
|
|
1118
|
-
* @param engineCore The engine core.
|
|
1119
|
-
* @param context The context for the node.
|
|
1120
|
-
* @param instanceConfig The instance config.
|
|
1121
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
1122
|
-
* @returns The name of the instance created.
|
|
1123
|
-
* @throws GeneralError if the connector type is unknown.
|
|
1124
|
-
*/
|
|
1125
|
-
function initialiseWalletConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1126
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1127
|
-
element: `Wallet Connector: ${instanceConfig.type}`
|
|
1128
|
-
}));
|
|
1129
|
-
const type = instanceConfig.type;
|
|
1130
|
-
let connector;
|
|
1131
|
-
let instanceType;
|
|
1132
|
-
if (type === engineModels.WalletConnectorType.Iota) {
|
|
1133
|
-
const dltConfig = context.config.dltConfig?.find(dlt => dlt.type === context.defaultTypes.dltConfig);
|
|
1134
|
-
connector = new walletConnectorIota.IotaWalletConnector({
|
|
1135
|
-
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
1136
|
-
faucetConnectorType: context.defaultTypes.faucetConnector,
|
|
1137
|
-
...instanceConfig.options,
|
|
1138
|
-
config: {
|
|
1139
|
-
...dltConfig?.options?.config,
|
|
1140
|
-
...instanceConfig.options.config
|
|
1141
|
-
}
|
|
1142
|
-
});
|
|
1143
|
-
instanceType = walletConnectorIota.IotaWalletConnector.NAMESPACE;
|
|
1144
|
-
}
|
|
1145
|
-
else if (type === engineModels.WalletConnectorType.EntityStorage) {
|
|
1146
|
-
connector = new walletConnectorEntityStorage.EntityStorageWalletConnector({
|
|
1147
|
-
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
1148
|
-
faucetConnectorType: context.defaultTypes.faucetConnector,
|
|
1149
|
-
...instanceConfig.options
|
|
1150
|
-
});
|
|
1151
|
-
instanceType = walletConnectorEntityStorage.EntityStorageWalletConnector.NAMESPACE;
|
|
1152
|
-
}
|
|
1153
|
-
else {
|
|
1154
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
1155
|
-
type,
|
|
1156
|
-
connectorType: "walletConnector"
|
|
1157
|
-
});
|
|
1158
|
-
}
|
|
1159
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1160
|
-
context.componentInstances.push({
|
|
1161
|
-
instanceType: finalInstanceType,
|
|
1162
|
-
component: connector
|
|
1163
|
-
});
|
|
1164
|
-
walletModels.WalletConnectorFactory.register(finalInstanceType, () => connector);
|
|
1165
|
-
return finalInstanceType;
|
|
1166
|
-
}
|
|
1167
|
-
/**
|
|
1168
|
-
* Initialise the wallet storage.
|
|
1169
|
-
* @param engineCore The engine core.
|
|
1170
|
-
* @param context The context for the engine.
|
|
1171
|
-
* @param instanceConfig The instance config.
|
|
1172
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
1173
|
-
* @returns Nothing.
|
|
1174
|
-
* @throws GeneralError if the connector type is unknown.
|
|
1175
|
-
*/
|
|
1176
|
-
function initialiseWalletStorage(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1177
|
-
const type = instanceConfig.type;
|
|
1178
|
-
if (type === engineModels.WalletConnectorType.Iota) ;
|
|
1179
|
-
else if (type === engineModels.WalletConnectorType.EntityStorage) {
|
|
1180
|
-
walletConnectorEntityStorage.initSchema();
|
|
1181
|
-
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.walletAddressEntityStorageType, "WalletAddress");
|
|
1182
|
-
}
|
|
1183
|
-
else {
|
|
1184
|
-
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
1185
|
-
type,
|
|
1186
|
-
connectorType: "walletConnector"
|
|
1187
|
-
});
|
|
1188
|
-
}
|
|
1189
|
-
return undefined;
|
|
1190
|
-
}
|
|
8
|
+
var path = require('node:path');
|
|
1191
9
|
|
|
1192
10
|
// Copyright 2024 IOTA Stiftung.
|
|
1193
11
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -1259,7 +77,6 @@ class EngineCore {
|
|
|
1259
77
|
CLASS_NAME = "EngineCore";
|
|
1260
78
|
/**
|
|
1261
79
|
* The core context.
|
|
1262
|
-
* @internal
|
|
1263
80
|
*/
|
|
1264
81
|
_context;
|
|
1265
82
|
/**
|
|
@@ -1277,6 +94,11 @@ class EngineCore {
|
|
|
1277
94
|
* @internal
|
|
1278
95
|
*/
|
|
1279
96
|
_skipBootstrap;
|
|
97
|
+
/**
|
|
98
|
+
* The logger type name to use.
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
_loggerTypeName;
|
|
1280
102
|
/**
|
|
1281
103
|
* The type initialisers.
|
|
1282
104
|
* @internal
|
|
@@ -1287,6 +109,11 @@ class EngineCore {
|
|
|
1287
109
|
* @internal
|
|
1288
110
|
*/
|
|
1289
111
|
_isStarted;
|
|
112
|
+
/**
|
|
113
|
+
* Add type initialisers to the engine.
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
_populateTypeInitialisers;
|
|
1290
117
|
/**
|
|
1291
118
|
* Method for bootstrapping any data for the engine.
|
|
1292
119
|
* @internal
|
|
@@ -1301,8 +128,11 @@ class EngineCore {
|
|
|
1301
128
|
options.config = options.config ?? {};
|
|
1302
129
|
options.config.debug = options.config.debug ?? false;
|
|
1303
130
|
options.config.silent = options.config.silent ?? false;
|
|
131
|
+
options.config.types ??= {};
|
|
1304
132
|
this._skipBootstrap = options.skipBootstrap ?? false;
|
|
133
|
+
this._populateTypeInitialisers = options.populateTypeInitialisers;
|
|
1305
134
|
this._customBootstrap = options.customBootstrap;
|
|
135
|
+
this._loggerTypeName = options.loggerTypeName ?? EngineCore.LOGGER_TYPE_NAME;
|
|
1306
136
|
this._typeInitialisers = [];
|
|
1307
137
|
this._context = {
|
|
1308
138
|
config: options.config,
|
|
@@ -1313,20 +143,24 @@ class EngineCore {
|
|
|
1313
143
|
};
|
|
1314
144
|
this._stateStorage = options.stateStorage;
|
|
1315
145
|
this._isStarted = false;
|
|
1316
|
-
this.
|
|
146
|
+
if (core.Is.function(this._populateTypeInitialisers)) {
|
|
147
|
+
this._populateTypeInitialisers(this, this._context);
|
|
148
|
+
}
|
|
1317
149
|
}
|
|
1318
150
|
/**
|
|
1319
151
|
* Add a type initialiser.
|
|
1320
152
|
* @param type The type to add the initialiser for.
|
|
1321
153
|
* @param typeConfig The type config.
|
|
1322
|
-
* @param
|
|
154
|
+
* @param module The name of the module which contains the initialiser method.
|
|
155
|
+
* @param method The name of the method to call.
|
|
1323
156
|
*/
|
|
1324
|
-
addTypeInitialiser(type, typeConfig,
|
|
157
|
+
addTypeInitialiser(type, typeConfig, module, method) {
|
|
1325
158
|
if (!core.Is.empty(typeConfig)) {
|
|
1326
159
|
this._typeInitialisers.push({
|
|
1327
160
|
type,
|
|
1328
161
|
typeConfig,
|
|
1329
|
-
|
|
162
|
+
module,
|
|
163
|
+
method
|
|
1330
164
|
});
|
|
1331
165
|
}
|
|
1332
166
|
}
|
|
@@ -1345,8 +179,8 @@ class EngineCore {
|
|
|
1345
179
|
}
|
|
1346
180
|
let canContinue = await this.stateLoad();
|
|
1347
181
|
if (canContinue) {
|
|
1348
|
-
for (const { type, typeConfig,
|
|
1349
|
-
this.initialiseTypeConfig(type, typeConfig,
|
|
182
|
+
for (const { type, typeConfig, module, method } of this._typeInitialisers) {
|
|
183
|
+
await this.initialiseTypeConfig(type, typeConfig, module, method);
|
|
1350
184
|
}
|
|
1351
185
|
canContinue = await this.bootstrap();
|
|
1352
186
|
if (canContinue) {
|
|
@@ -1354,7 +188,7 @@ class EngineCore {
|
|
|
1354
188
|
for (const instance of this._context.componentInstances) {
|
|
1355
189
|
if (core.Is.function(instance.component.start)) {
|
|
1356
190
|
this.logInfo(core.I18n.formatMessage("engineCore.componentStarting", { element: instance.instanceType }));
|
|
1357
|
-
await instance.component.start(this._context.state.nodeIdentity,
|
|
191
|
+
await instance.component.start(this._context.state.nodeIdentity, this._loggerTypeName);
|
|
1358
192
|
}
|
|
1359
193
|
}
|
|
1360
194
|
this.logInfo(core.I18n.formatMessage("engineCore.componentsComplete"));
|
|
@@ -1377,7 +211,7 @@ class EngineCore {
|
|
|
1377
211
|
if (core.Is.function(instance.component.stop)) {
|
|
1378
212
|
this.logInfo(core.I18n.formatMessage("engineCore.componentStopping", { element: instance.instanceType }));
|
|
1379
213
|
try {
|
|
1380
|
-
await instance.component.stop(this._context.state.nodeIdentity,
|
|
214
|
+
await instance.component.stop(this._context.state.nodeIdentity, this._loggerTypeName);
|
|
1381
215
|
}
|
|
1382
216
|
catch (err) {
|
|
1383
217
|
this.logError(new core.GeneralError(this.CLASS_NAME, "componentStopFailed", {
|
|
@@ -1448,7 +282,8 @@ class EngineCore {
|
|
|
1448
282
|
getCloneData() {
|
|
1449
283
|
const cloneData = {
|
|
1450
284
|
config: this._context.config,
|
|
1451
|
-
state: this._context.state
|
|
285
|
+
state: this._context.state,
|
|
286
|
+
typeInitialisers: this._typeInitialisers
|
|
1452
287
|
};
|
|
1453
288
|
return cloneData;
|
|
1454
289
|
}
|
|
@@ -1460,6 +295,7 @@ class EngineCore {
|
|
|
1460
295
|
core.Guards.object(this.CLASS_NAME, "cloneData", cloneData);
|
|
1461
296
|
core.Guards.object(this.CLASS_NAME, "cloneData.config", cloneData.config);
|
|
1462
297
|
core.Guards.object(this.CLASS_NAME, "cloneData.state", cloneData.state);
|
|
298
|
+
core.Guards.array(this.CLASS_NAME, "cloneData.typeInitialisers", cloneData.typeInitialisers);
|
|
1463
299
|
this._context = {
|
|
1464
300
|
config: cloneData.config,
|
|
1465
301
|
defaultTypes: {},
|
|
@@ -1467,7 +303,7 @@ class EngineCore {
|
|
|
1467
303
|
state: { bootstrappedComponents: [] },
|
|
1468
304
|
stateDirty: false
|
|
1469
305
|
};
|
|
1470
|
-
this.
|
|
306
|
+
this._typeInitialisers = cloneData.typeInitialisers;
|
|
1471
307
|
this._stateStorage = new MemoryStateStorage(true, cloneData.state);
|
|
1472
308
|
this._isStarted = false;
|
|
1473
309
|
}
|
|
@@ -1477,8 +313,9 @@ class EngineCore {
|
|
|
1477
313
|
* @param instanceMethod The function to initialise the instance.
|
|
1478
314
|
* @internal
|
|
1479
315
|
*/
|
|
1480
|
-
initialiseTypeConfig(typeKey, typeConfig,
|
|
316
|
+
async initialiseTypeConfig(typeKey, typeConfig, module, method) {
|
|
1481
317
|
if (core.Is.arrayValue(typeConfig)) {
|
|
318
|
+
const instanceMethod = await modules.ModuleHelper.getModuleEntry(module, method);
|
|
1482
319
|
for (let i = 0; i < typeConfig.length; i++) {
|
|
1483
320
|
const instanceType = instanceMethod(this, this._context, typeConfig[i], typeConfig[i].overrideInstanceType);
|
|
1484
321
|
if (core.Is.stringValue(instanceType) &&
|
|
@@ -1501,12 +338,12 @@ class EngineCore {
|
|
|
1501
338
|
}
|
|
1502
339
|
});
|
|
1503
340
|
this._context.componentInstances.push({
|
|
1504
|
-
instanceType:
|
|
341
|
+
instanceType: this._loggerTypeName,
|
|
1505
342
|
component: engineLogger
|
|
1506
343
|
});
|
|
1507
|
-
loggingModels.LoggingConnectorFactory.register(
|
|
344
|
+
loggingModels.LoggingConnectorFactory.register(this._loggerTypeName, () => engineLogger);
|
|
1508
345
|
this._engineLoggingConnector = engineLogger;
|
|
1509
|
-
this._context.defaultTypes.loggingConnector =
|
|
346
|
+
this._context.defaultTypes.loggingConnector = this._loggerTypeName;
|
|
1510
347
|
}
|
|
1511
348
|
}
|
|
1512
349
|
/**
|
|
@@ -1568,7 +405,7 @@ class EngineCore {
|
|
|
1568
405
|
this.logInfo(core.I18n.formatMessage("engineCore.bootstrapping", {
|
|
1569
406
|
element: bootstrapName
|
|
1570
407
|
}));
|
|
1571
|
-
const bootstrapSuccess = await instance.component.bootstrap(
|
|
408
|
+
const bootstrapSuccess = await instance.component.bootstrap(this._loggerTypeName);
|
|
1572
409
|
// If the bootstrap method failed then throw an error
|
|
1573
410
|
if (!bootstrapSuccess) {
|
|
1574
411
|
throw new core.GeneralError(this.CLASS_NAME, "bootstrapFailed", {
|
|
@@ -1599,36 +436,6 @@ class EngineCore {
|
|
|
1599
436
|
}
|
|
1600
437
|
return canContinue;
|
|
1601
438
|
}
|
|
1602
|
-
/**
|
|
1603
|
-
* Add the core type initializers.
|
|
1604
|
-
* @internal
|
|
1605
|
-
*/
|
|
1606
|
-
addCoreTypeInitialisers() {
|
|
1607
|
-
this.addTypeInitialiser("loggingConnector", this._context.config.loggingConnector, initialiseLoggingConnector);
|
|
1608
|
-
this.addTypeInitialiser("loggingComponent", this._context.config.loggingComponent, initialiseLoggingComponent);
|
|
1609
|
-
this.addTypeInitialiser("backgroundTaskConnector", this._context.config.backgroundTaskConnector, initialiseBackgroundTaskConnector);
|
|
1610
|
-
this.addTypeInitialiser("telemetryConnector", this._context.config.telemetryConnector, initialiseTelemetryConnector);
|
|
1611
|
-
this.addTypeInitialiser("telemetryComponent", this._context.config.telemetryComponent, initialiseTelemetryComponent);
|
|
1612
|
-
this.addTypeInitialiser("entityStorageComponent", this._context.config.entityStorageComponent, initialiseEntityStorageComponent);
|
|
1613
|
-
this.addTypeInitialiser("vaultConnector", this._context.config.vaultConnector, initialiseVaultConnector);
|
|
1614
|
-
this.addTypeInitialiser("blobStorageConnector", this._context.config.blobStorageConnector, initialiseBlobStorageConnector);
|
|
1615
|
-
this.addTypeInitialiser("blobStorageComponent", this._context.config.blobStorageComponent, initialiseBlobStorageComponent);
|
|
1616
|
-
this.addTypeInitialiser("immutableStorageConnector", this._context.config.immutableStorageConnector, initialiseImmutableStorageConnector);
|
|
1617
|
-
this.addTypeInitialiser("walletConnector", this._context.config.walletConnector, initialiseWalletStorage);
|
|
1618
|
-
this.addTypeInitialiser("faucetConnector", this._context.config.faucetConnector, initialiseFaucetConnector);
|
|
1619
|
-
this.addTypeInitialiser("walletConnector", this._context.config.walletConnector, initialiseWalletConnector);
|
|
1620
|
-
this.addTypeInitialiser("identityConnector", this._context.config.identityConnector, initialiseIdentityConnector);
|
|
1621
|
-
this.addTypeInitialiser("identityComponent", this._context.config.identityComponent, initialiseIdentityComponent);
|
|
1622
|
-
this.addTypeInitialiser("identityProfileConnector", this._context.config.identityProfileConnector, initialiseIdentityProfileConnector);
|
|
1623
|
-
this.addTypeInitialiser("identityProfileComponent", this._context.config.identityProfileComponent, initialiseIdentityProfileComponent);
|
|
1624
|
-
this.addTypeInitialiser("nftConnector", this._context.config.nftConnector, initialiseNftConnector);
|
|
1625
|
-
this.addTypeInitialiser("nftComponent", this._context.config.nftComponent, initialiseNftComponent);
|
|
1626
|
-
this.addTypeInitialiser("immutableProofComponent", this._context.config.immutableProofComponent, initialiseImmutableProofComponent);
|
|
1627
|
-
this.addTypeInitialiser("attestationConnector", this._context.config.attestationConnector, initialiseAttestationConnector);
|
|
1628
|
-
this.addTypeInitialiser("attestationComponent", this._context.config.attestationComponent, initialiseAttestationComponent);
|
|
1629
|
-
this.addTypeInitialiser("auditableItemGraphComponent", this._context.config.auditableItemGraphComponent, initialiseAuditableItemGraphComponent);
|
|
1630
|
-
this.addTypeInitialiser("auditableItemStreamComponent", this._context.config.auditableItemStreamComponent, initialiseAuditableItemStreamComponent);
|
|
1631
|
-
}
|
|
1632
439
|
}
|
|
1633
440
|
|
|
1634
441
|
// Copyright 2024 IOTA Stiftung.
|
|
@@ -1720,537 +527,6 @@ class FileStateStorage {
|
|
|
1720
527
|
}
|
|
1721
528
|
}
|
|
1722
529
|
|
|
1723
|
-
// Copyright 2024 IOTA Stiftung.
|
|
1724
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
1725
|
-
/**
|
|
1726
|
-
* Build the engine core configuration from environment variables.
|
|
1727
|
-
* @param envVars The environment variables.
|
|
1728
|
-
* @returns The config for the core.
|
|
1729
|
-
*/
|
|
1730
|
-
function buildEngineCoreConfiguration(envVars) {
|
|
1731
|
-
envVars.stateFilename ??= "engine-state.json";
|
|
1732
|
-
envVars.storageFileRoot = path.resolve(envVars.storageFileRoot);
|
|
1733
|
-
envVars.stateFilename = path.join(envVars.storageFileRoot, envVars.stateFilename);
|
|
1734
|
-
envVars.attestationAssertionMethodId ??= "attestation-assertion";
|
|
1735
|
-
envVars.immutableProofHashKeyId ??= "immutable-proof-hash";
|
|
1736
|
-
envVars.immutableProofAssertionMethodId ??= "immutable-proof-assertion";
|
|
1737
|
-
envVars.blobStorageEnableEncryption ??= "false";
|
|
1738
|
-
envVars.blobStorageEncryptionKey ??= "blob-encryption";
|
|
1739
|
-
const coreConfig = {
|
|
1740
|
-
debug: core.Coerce.boolean(envVars.debug) ?? false,
|
|
1741
|
-
loggingConnector: [],
|
|
1742
|
-
loggingComponent: [{ type: engineModels.LoggingComponentType.Service }],
|
|
1743
|
-
entityStorageConnector: [],
|
|
1744
|
-
blobStorageConnector: [],
|
|
1745
|
-
blobStorageComponent: [
|
|
1746
|
-
{
|
|
1747
|
-
type: engineModels.BlobStorageComponentType.Service,
|
|
1748
|
-
options: {
|
|
1749
|
-
config: {
|
|
1750
|
-
vaultKeyId: envVars.blobStorageEncryptionKey
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
],
|
|
1755
|
-
backgroundTaskConnector: [],
|
|
1756
|
-
telemetryConnector: [],
|
|
1757
|
-
telemetryComponent: [{ type: engineModels.TelemetryComponentType.Service }],
|
|
1758
|
-
vaultConnector: [],
|
|
1759
|
-
walletConnector: [],
|
|
1760
|
-
faucetConnector: [],
|
|
1761
|
-
immutableStorageConnector: [],
|
|
1762
|
-
nftConnector: [],
|
|
1763
|
-
nftComponent: [{ type: engineModels.NftComponentType.Service }],
|
|
1764
|
-
identityConnector: [],
|
|
1765
|
-
identityComponent: [{ type: engineModels.IdentityComponentType.Service }],
|
|
1766
|
-
identityProfileConnector: [],
|
|
1767
|
-
identityProfileComponent: [{ type: engineModels.IdentityProfileComponentType.Service }],
|
|
1768
|
-
immutableProofComponent: [
|
|
1769
|
-
{
|
|
1770
|
-
type: engineModels.ImmutableProofComponentType.Service,
|
|
1771
|
-
options: {
|
|
1772
|
-
config: {
|
|
1773
|
-
assertionMethodId: envVars.immutableProofAssertionMethodId,
|
|
1774
|
-
proofHashKeyId: envVars.immutableProofHashKeyId
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
],
|
|
1779
|
-
attestationConnector: [],
|
|
1780
|
-
attestationComponent: [
|
|
1781
|
-
{
|
|
1782
|
-
type: engineModels.AttestationComponentType.Service
|
|
1783
|
-
}
|
|
1784
|
-
],
|
|
1785
|
-
auditableItemGraphComponent: [{ type: engineModels.AuditableItemGraphComponentType.Service }],
|
|
1786
|
-
auditableItemStreamComponent: [{ type: engineModels.AuditableItemStreamComponentType.Service }]
|
|
1787
|
-
};
|
|
1788
|
-
configureEntityStorageConnectors(coreConfig, envVars);
|
|
1789
|
-
configureBlobStorageConnectors(coreConfig, envVars);
|
|
1790
|
-
configureVaultConnectors(coreConfig, envVars);
|
|
1791
|
-
configureLogging(coreConfig, envVars);
|
|
1792
|
-
configureBackgroundTaskConnectors(coreConfig, envVars);
|
|
1793
|
-
configureTelemetryConnectors(coreConfig, envVars);
|
|
1794
|
-
configureFaucetConnectors(coreConfig, envVars);
|
|
1795
|
-
configureWalletConnectors(coreConfig, envVars);
|
|
1796
|
-
configureNftConnectors(coreConfig, envVars);
|
|
1797
|
-
configureImmutableStorageConnectors(coreConfig, envVars);
|
|
1798
|
-
configureIdentityConnectors(coreConfig, envVars);
|
|
1799
|
-
configureIdentityProfileConnectors(coreConfig, envVars);
|
|
1800
|
-
configureAttestationConnectors(coreConfig, envVars);
|
|
1801
|
-
return coreConfig;
|
|
1802
|
-
}
|
|
1803
|
-
/**
|
|
1804
|
-
* Configures the entity storage connectors for the core.
|
|
1805
|
-
* @param coreConfig The core config.
|
|
1806
|
-
* @param envVars The environment variables.
|
|
1807
|
-
*/
|
|
1808
|
-
function configureEntityStorageConnectors(coreConfig, envVars) {
|
|
1809
|
-
coreConfig.entityStorageConnector ??= [];
|
|
1810
|
-
if ((core.Coerce.boolean(envVars.entityMemoryEnable) ?? false) ||
|
|
1811
|
-
envVars.blobStorageConnectorType === engineModels.EntityStorageConnectorType.Memory) {
|
|
1812
|
-
coreConfig.entityStorageConnector.push({
|
|
1813
|
-
type: engineModels.EntityStorageConnectorType.Memory
|
|
1814
|
-
});
|
|
1815
|
-
}
|
|
1816
|
-
if ((core.Coerce.boolean(envVars.entityFileEnable) ?? false) ||
|
|
1817
|
-
envVars.entityStorageConnectorType === engineModels.EntityStorageConnectorType.File) {
|
|
1818
|
-
coreConfig.entityStorageConnector.push({
|
|
1819
|
-
type: engineModels.EntityStorageConnectorType.File,
|
|
1820
|
-
options: {
|
|
1821
|
-
config: { directory: envVars.storageFileRoot },
|
|
1822
|
-
folderPrefix: envVars.entityStorageTablePrefix
|
|
1823
|
-
}
|
|
1824
|
-
});
|
|
1825
|
-
}
|
|
1826
|
-
if (core.Is.stringValue(envVars.awsDynamodbAccessKeyId)) {
|
|
1827
|
-
coreConfig.entityStorageConnector.push({
|
|
1828
|
-
type: engineModels.EntityStorageConnectorType.AwsDynamoDb,
|
|
1829
|
-
options: {
|
|
1830
|
-
config: {
|
|
1831
|
-
region: envVars.awsDynamodbRegion,
|
|
1832
|
-
accessKeyId: envVars.awsDynamodbAccessKeyId,
|
|
1833
|
-
secretAccessKey: envVars.awsDynamodbSecretAccessKey,
|
|
1834
|
-
endpoint: envVars.awsDynamodbEndpoint
|
|
1835
|
-
},
|
|
1836
|
-
tablePrefix: envVars.entityStorageTablePrefix
|
|
1837
|
-
}
|
|
1838
|
-
});
|
|
1839
|
-
}
|
|
1840
|
-
if (core.Is.stringValue(envVars.azureCosmosdbKey)) {
|
|
1841
|
-
coreConfig.entityStorageConnector.push({
|
|
1842
|
-
type: engineModels.EntityStorageConnectorType.AzureCosmosDb,
|
|
1843
|
-
options: {
|
|
1844
|
-
config: {
|
|
1845
|
-
endpoint: envVars.azureCosmosdbEndpoint,
|
|
1846
|
-
key: envVars.azureCosmosdbKey,
|
|
1847
|
-
databaseId: envVars.azureCosmosdbDatabaseId,
|
|
1848
|
-
containerId: envVars.azureCosmosdbContainerId
|
|
1849
|
-
},
|
|
1850
|
-
tablePrefix: envVars.entityStorageTablePrefix
|
|
1851
|
-
}
|
|
1852
|
-
});
|
|
1853
|
-
}
|
|
1854
|
-
if (core.Is.stringValue(envVars.gcpFirestoreCredentials)) {
|
|
1855
|
-
coreConfig.entityStorageConnector.push({
|
|
1856
|
-
type: engineModels.EntityStorageConnectorType.GcpFirestoreDb,
|
|
1857
|
-
options: {
|
|
1858
|
-
config: {
|
|
1859
|
-
projectId: envVars.gcpFirestoreProjectId,
|
|
1860
|
-
credentials: envVars.gcpFirestoreCredentials,
|
|
1861
|
-
databaseId: envVars.gcpFirestoreDatabaseId,
|
|
1862
|
-
collectionName: envVars.gcpFirestoreCollectionName,
|
|
1863
|
-
endpoint: envVars.gcpFirestoreApiEndpoint
|
|
1864
|
-
},
|
|
1865
|
-
tablePrefix: envVars.entityStorageTablePrefix
|
|
1866
|
-
}
|
|
1867
|
-
});
|
|
1868
|
-
}
|
|
1869
|
-
if (core.Is.stringValue(envVars.scylladbHosts)) {
|
|
1870
|
-
coreConfig.entityStorageConnector.push({
|
|
1871
|
-
type: engineModels.EntityStorageConnectorType.ScyllaDb,
|
|
1872
|
-
options: {
|
|
1873
|
-
config: {
|
|
1874
|
-
hosts: envVars.scylladbHosts.split(","),
|
|
1875
|
-
localDataCenter: envVars.scylladbLocalDataCenter,
|
|
1876
|
-
keyspace: envVars.scylladbKeyspace
|
|
1877
|
-
},
|
|
1878
|
-
tablePrefix: envVars.entityStorageTablePrefix
|
|
1879
|
-
}
|
|
1880
|
-
});
|
|
1881
|
-
}
|
|
1882
|
-
const defaultStorageConnector = envVars.entityStorageConnectorType;
|
|
1883
|
-
if (core.Is.stringValue(defaultStorageConnector)) {
|
|
1884
|
-
for (const config of coreConfig.entityStorageConnector) {
|
|
1885
|
-
if (config.type === defaultStorageConnector) {
|
|
1886
|
-
config.isDefault = true;
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
}
|
|
1890
|
-
}
|
|
1891
|
-
/**
|
|
1892
|
-
* Configures the blob storage connectors for the core.
|
|
1893
|
-
* @param coreConfig The core config.
|
|
1894
|
-
* @param envVars The environment variables.
|
|
1895
|
-
*/
|
|
1896
|
-
function configureBlobStorageConnectors(coreConfig, envVars) {
|
|
1897
|
-
coreConfig.blobStorageConnector ??= [];
|
|
1898
|
-
if ((core.Coerce.boolean(envVars.blobMemoryEnable) ?? false) ||
|
|
1899
|
-
envVars.blobStorageConnectorType === engineModels.BlobStorageConnectorType.Memory) {
|
|
1900
|
-
coreConfig.blobStorageConnector.push({
|
|
1901
|
-
type: engineModels.BlobStorageConnectorType.Memory
|
|
1902
|
-
});
|
|
1903
|
-
}
|
|
1904
|
-
if ((core.Coerce.boolean(envVars.blobFileEnable) ?? false) ||
|
|
1905
|
-
envVars.blobStorageConnectorType === engineModels.BlobStorageConnectorType.File) {
|
|
1906
|
-
coreConfig.blobStorageConnector.push({
|
|
1907
|
-
type: engineModels.BlobStorageConnectorType.File,
|
|
1908
|
-
options: {
|
|
1909
|
-
config: { directory: path.join(envVars.storageFileRoot, "blob-storage") },
|
|
1910
|
-
storagePrefix: envVars.blobStoragePrefix
|
|
1911
|
-
}
|
|
1912
|
-
});
|
|
1913
|
-
}
|
|
1914
|
-
if (core.Is.stringValue(envVars.ipfsApiUrl)) {
|
|
1915
|
-
coreConfig.blobStorageConnector.push({
|
|
1916
|
-
type: engineModels.BlobStorageConnectorType.Ipfs,
|
|
1917
|
-
options: {
|
|
1918
|
-
config: {
|
|
1919
|
-
apiUrl: envVars.ipfsApiUrl,
|
|
1920
|
-
bearerToken: envVars.ipfsBearerToken
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
});
|
|
1924
|
-
}
|
|
1925
|
-
if (core.Is.stringValue(envVars.awsS3AccessKeyId)) {
|
|
1926
|
-
coreConfig.blobStorageConnector.push({
|
|
1927
|
-
type: engineModels.BlobStorageConnectorType.AwsS3,
|
|
1928
|
-
options: {
|
|
1929
|
-
config: {
|
|
1930
|
-
region: envVars.awsS3Region,
|
|
1931
|
-
bucketName: envVars.awsS3BucketName,
|
|
1932
|
-
accessKeyId: envVars.awsS3AccessKeyId,
|
|
1933
|
-
secretAccessKey: envVars.awsS3SecretAccessKey,
|
|
1934
|
-
endpoint: envVars.awsS3Endpoint
|
|
1935
|
-
},
|
|
1936
|
-
storagePrefix: envVars.blobStoragePrefix
|
|
1937
|
-
}
|
|
1938
|
-
});
|
|
1939
|
-
}
|
|
1940
|
-
if (core.Is.stringValue(envVars.azureStorageAccountKey)) {
|
|
1941
|
-
coreConfig.blobStorageConnector.push({
|
|
1942
|
-
type: engineModels.BlobStorageConnectorType.AzureStorage,
|
|
1943
|
-
options: {
|
|
1944
|
-
config: {
|
|
1945
|
-
accountName: envVars.azureStorageAccountName,
|
|
1946
|
-
accountKey: envVars.azureStorageAccountKey,
|
|
1947
|
-
containerName: envVars.azureStorageContainerName,
|
|
1948
|
-
endpoint: envVars.azureStorageEndpoint
|
|
1949
|
-
},
|
|
1950
|
-
storagePrefix: envVars.blobStoragePrefix
|
|
1951
|
-
}
|
|
1952
|
-
});
|
|
1953
|
-
}
|
|
1954
|
-
if (core.Is.stringValue(envVars.gcpStorageCredentials)) {
|
|
1955
|
-
coreConfig.blobStorageConnector.push({
|
|
1956
|
-
type: engineModels.BlobStorageConnectorType.GcpStorage,
|
|
1957
|
-
options: {
|
|
1958
|
-
config: {
|
|
1959
|
-
projectId: envVars.gcpStorageProjectId,
|
|
1960
|
-
credentials: envVars.gcpStorageCredentials,
|
|
1961
|
-
bucketName: envVars.gcpStorageBucketName,
|
|
1962
|
-
apiEndpoint: envVars.gcpFirestoreApiEndpoint
|
|
1963
|
-
},
|
|
1964
|
-
storagePrefix: envVars.blobStoragePrefix
|
|
1965
|
-
}
|
|
1966
|
-
});
|
|
1967
|
-
}
|
|
1968
|
-
const defaultStorageConnectorType = envVars.blobStorageConnectorType;
|
|
1969
|
-
if (core.Is.stringValue(defaultStorageConnectorType)) {
|
|
1970
|
-
for (const config of coreConfig.blobStorageConnector) {
|
|
1971
|
-
if (config.type === defaultStorageConnectorType) {
|
|
1972
|
-
config.isDefault = true;
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
1976
|
-
}
|
|
1977
|
-
/**
|
|
1978
|
-
* Configures the logging connectors for the core.
|
|
1979
|
-
* @param coreConfig The core config.
|
|
1980
|
-
* @param envVars The environment variables.
|
|
1981
|
-
*/
|
|
1982
|
-
function configureLogging(coreConfig, envVars) {
|
|
1983
|
-
const loggingConnectors = (envVars.loggingConnector ?? "").split(",");
|
|
1984
|
-
for (const loggingConnector of loggingConnectors) {
|
|
1985
|
-
if (loggingConnector === engineModels.LoggingConnectorType.Console) {
|
|
1986
|
-
coreConfig.loggingConnector?.push({
|
|
1987
|
-
type: engineModels.LoggingConnectorType.Console,
|
|
1988
|
-
options: {
|
|
1989
|
-
config: {
|
|
1990
|
-
translateMessages: true,
|
|
1991
|
-
hideGroups: true
|
|
1992
|
-
}
|
|
1993
|
-
}
|
|
1994
|
-
});
|
|
1995
|
-
}
|
|
1996
|
-
else if (loggingConnector === engineModels.LoggingConnectorType.EntityStorage) {
|
|
1997
|
-
coreConfig.loggingConnector?.push({
|
|
1998
|
-
type: engineModels.LoggingConnectorType.EntityStorage
|
|
1999
|
-
});
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
if (loggingConnectors.length > 1) {
|
|
2003
|
-
coreConfig.loggingConnector?.push({
|
|
2004
|
-
type: engineModels.LoggingConnectorType.Multi,
|
|
2005
|
-
isDefault: true,
|
|
2006
|
-
options: {
|
|
2007
|
-
loggingConnectorTypes: loggingConnectors
|
|
2008
|
-
}
|
|
2009
|
-
});
|
|
2010
|
-
}
|
|
2011
|
-
}
|
|
2012
|
-
/**
|
|
2013
|
-
* Configures the vault connectors for the core.
|
|
2014
|
-
* @param coreConfig The core config.
|
|
2015
|
-
* @param envVars The environment variables.
|
|
2016
|
-
*/
|
|
2017
|
-
function configureVaultConnectors(coreConfig, envVars) {
|
|
2018
|
-
coreConfig.vaultConnector ??= [];
|
|
2019
|
-
if (envVars.vaultConnector === engineModels.VaultConnectorType.EntityStorage) {
|
|
2020
|
-
coreConfig.vaultConnector.push({
|
|
2021
|
-
type: engineModels.VaultConnectorType.EntityStorage
|
|
2022
|
-
});
|
|
2023
|
-
}
|
|
2024
|
-
else if (envVars.vaultConnector === engineModels.VaultConnectorType.Hashicorp) {
|
|
2025
|
-
coreConfig.vaultConnector.push({
|
|
2026
|
-
type: engineModels.VaultConnectorType.Hashicorp,
|
|
2027
|
-
options: {
|
|
2028
|
-
config: { endpoint: envVars.hashicorpVaultEndpoint, token: envVars.hashicorpVaultToken }
|
|
2029
|
-
}
|
|
2030
|
-
});
|
|
2031
|
-
}
|
|
2032
|
-
}
|
|
2033
|
-
/**
|
|
2034
|
-
* Configures the background task connectors for the core.
|
|
2035
|
-
* @param coreConfig The core config.
|
|
2036
|
-
* @param envVars The environment variables.
|
|
2037
|
-
*/
|
|
2038
|
-
function configureBackgroundTaskConnectors(coreConfig, envVars) {
|
|
2039
|
-
coreConfig.backgroundTaskConnector ??= [];
|
|
2040
|
-
if (envVars.backgroundTaskConnector === engineModels.BackgroundTaskConnectorType.EntityStorage) {
|
|
2041
|
-
coreConfig.backgroundTaskConnector.push({
|
|
2042
|
-
type: engineModels.BackgroundTaskConnectorType.EntityStorage
|
|
2043
|
-
});
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
/**
|
|
2047
|
-
* Configures the telemetry connectors for the core.
|
|
2048
|
-
* @param coreConfig The core config.
|
|
2049
|
-
* @param envVars The environment variables.
|
|
2050
|
-
*/
|
|
2051
|
-
function configureTelemetryConnectors(coreConfig, envVars) {
|
|
2052
|
-
coreConfig.telemetryConnector ??= [];
|
|
2053
|
-
if (envVars.telemetryConnector === engineModels.TelemetryConnectorType.EntityStorage) {
|
|
2054
|
-
coreConfig.telemetryConnector.push({
|
|
2055
|
-
type: engineModels.TelemetryConnectorType.EntityStorage
|
|
2056
|
-
});
|
|
2057
|
-
}
|
|
2058
|
-
}
|
|
2059
|
-
/**
|
|
2060
|
-
* Configures the faucet connectors for the core.
|
|
2061
|
-
* @param coreConfig The core config.
|
|
2062
|
-
* @param envVars The environment variables.
|
|
2063
|
-
*/
|
|
2064
|
-
function configureFaucetConnectors(coreConfig, envVars) {
|
|
2065
|
-
coreConfig.faucetConnector ??= [];
|
|
2066
|
-
if (envVars.faucetConnector === engineModels.FaucetConnectorType.EntityStorage) {
|
|
2067
|
-
coreConfig.faucetConnector.push({
|
|
2068
|
-
type: engineModels.FaucetConnectorType.EntityStorage
|
|
2069
|
-
});
|
|
2070
|
-
}
|
|
2071
|
-
else if (envVars.faucetConnector === engineModels.FaucetConnectorType.Iota) {
|
|
2072
|
-
coreConfig.faucetConnector.push({
|
|
2073
|
-
type: engineModels.FaucetConnectorType.Iota,
|
|
2074
|
-
options: {
|
|
2075
|
-
config: {
|
|
2076
|
-
endpoint: envVars.iotaFaucetEndpoint,
|
|
2077
|
-
clientOptions: {
|
|
2078
|
-
nodes: [envVars.iotaNodeEndpoint]
|
|
2079
|
-
},
|
|
2080
|
-
bech32Hrp: envVars.iotaBech32Hrp,
|
|
2081
|
-
coinType: core.Coerce.number(envVars.iotaCoinType)
|
|
2082
|
-
}
|
|
2083
|
-
}
|
|
2084
|
-
});
|
|
2085
|
-
}
|
|
2086
|
-
}
|
|
2087
|
-
/**
|
|
2088
|
-
* Configures the wallet connectors for the core.
|
|
2089
|
-
* @param coreConfig The core config.
|
|
2090
|
-
* @param envVars The environment variables.
|
|
2091
|
-
*/
|
|
2092
|
-
function configureWalletConnectors(coreConfig, envVars) {
|
|
2093
|
-
coreConfig.walletConnector ??= [];
|
|
2094
|
-
if (envVars.walletConnector === engineModels.WalletConnectorType.EntityStorage) {
|
|
2095
|
-
coreConfig.walletConnector.push({
|
|
2096
|
-
type: engineModels.WalletConnectorType.EntityStorage
|
|
2097
|
-
});
|
|
2098
|
-
}
|
|
2099
|
-
else if (envVars.walletConnector === engineModels.WalletConnectorType.Iota) {
|
|
2100
|
-
coreConfig.walletConnector.push({
|
|
2101
|
-
type: engineModels.WalletConnectorType.Iota,
|
|
2102
|
-
options: {
|
|
2103
|
-
config: {
|
|
2104
|
-
clientOptions: {
|
|
2105
|
-
nodes: [envVars.iotaNodeEndpoint]
|
|
2106
|
-
},
|
|
2107
|
-
bech32Hrp: envVars.iotaBech32Hrp,
|
|
2108
|
-
coinType: core.Coerce.number(envVars.iotaCoinType)
|
|
2109
|
-
}
|
|
2110
|
-
}
|
|
2111
|
-
});
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
/**
|
|
2115
|
-
* Configures the NFT connectors for the core.
|
|
2116
|
-
* @param coreConfig The core config.
|
|
2117
|
-
* @param envVars The environment variables.
|
|
2118
|
-
*/
|
|
2119
|
-
function configureNftConnectors(coreConfig, envVars) {
|
|
2120
|
-
coreConfig.nftConnector ??= [];
|
|
2121
|
-
if (envVars.nftConnector === engineModels.NftConnectorType.EntityStorage) {
|
|
2122
|
-
coreConfig.nftConnector.push({
|
|
2123
|
-
type: engineModels.NftConnectorType.EntityStorage
|
|
2124
|
-
});
|
|
2125
|
-
}
|
|
2126
|
-
else if (envVars.nftConnector === engineModels.NftConnectorType.Iota) {
|
|
2127
|
-
coreConfig.nftConnector.push({
|
|
2128
|
-
type: engineModels.NftConnectorType.Iota,
|
|
2129
|
-
options: {
|
|
2130
|
-
config: {
|
|
2131
|
-
clientOptions: {
|
|
2132
|
-
nodes: [envVars.iotaNodeEndpoint]
|
|
2133
|
-
},
|
|
2134
|
-
bech32Hrp: envVars.iotaBech32Hrp,
|
|
2135
|
-
coinType: core.Coerce.number(envVars.iotaCoinType)
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
});
|
|
2139
|
-
}
|
|
2140
|
-
}
|
|
2141
|
-
/**
|
|
2142
|
-
* Configures the immutable storage connectors for the core.
|
|
2143
|
-
* @param coreConfig The core config.
|
|
2144
|
-
* @param envVars The environment variables.
|
|
2145
|
-
*/
|
|
2146
|
-
function configureImmutableStorageConnectors(coreConfig, envVars) {
|
|
2147
|
-
coreConfig.immutableStorageConnector ??= [];
|
|
2148
|
-
if (envVars.immutableStorageConnector === engineModels.ImmutableStorageConnectorType.EntityStorage) {
|
|
2149
|
-
coreConfig.immutableStorageConnector.push({
|
|
2150
|
-
type: engineModels.ImmutableStorageConnectorType.EntityStorage
|
|
2151
|
-
});
|
|
2152
|
-
}
|
|
2153
|
-
else if (envVars.immutableStorageConnector === engineModels.ImmutableStorageConnectorType.Iota) {
|
|
2154
|
-
coreConfig.immutableStorageConnector.push({
|
|
2155
|
-
type: engineModels.ImmutableStorageConnectorType.Iota,
|
|
2156
|
-
options: {
|
|
2157
|
-
config: {
|
|
2158
|
-
clientOptions: {
|
|
2159
|
-
nodes: [envVars.iotaNodeEndpoint]
|
|
2160
|
-
},
|
|
2161
|
-
bech32Hrp: envVars.iotaBech32Hrp,
|
|
2162
|
-
coinType: core.Coerce.number(envVars.iotaCoinType)
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
});
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2168
|
-
/**
|
|
2169
|
-
* Configures the identity connectors for the core.
|
|
2170
|
-
* @param coreConfig The core config.
|
|
2171
|
-
* @param envVars The environment variables.
|
|
2172
|
-
*/
|
|
2173
|
-
function configureIdentityConnectors(coreConfig, envVars) {
|
|
2174
|
-
coreConfig.identityConnector ??= [];
|
|
2175
|
-
if (envVars.identityConnector === engineModels.IdentityConnectorType.EntityStorage) {
|
|
2176
|
-
coreConfig.identityConnector.push({
|
|
2177
|
-
type: engineModels.IdentityConnectorType.EntityStorage
|
|
2178
|
-
});
|
|
2179
|
-
}
|
|
2180
|
-
else if (envVars.identityConnector === engineModels.IdentityConnectorType.Iota) {
|
|
2181
|
-
coreConfig.identityConnector.push({
|
|
2182
|
-
type: engineModels.IdentityConnectorType.Iota,
|
|
2183
|
-
options: {
|
|
2184
|
-
config: {
|
|
2185
|
-
clientOptions: {
|
|
2186
|
-
nodes: [envVars.iotaNodeEndpoint]
|
|
2187
|
-
},
|
|
2188
|
-
bech32Hrp: envVars.iotaBech32Hrp,
|
|
2189
|
-
coinType: core.Coerce.number(envVars.iotaCoinType)
|
|
2190
|
-
}
|
|
2191
|
-
}
|
|
2192
|
-
});
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
/**
|
|
2196
|
-
* Configures the identity profile connectors for the core.
|
|
2197
|
-
* @param coreConfig The core config.
|
|
2198
|
-
* @param envVars The environment variables.
|
|
2199
|
-
*/
|
|
2200
|
-
function configureIdentityProfileConnectors(coreConfig, envVars) {
|
|
2201
|
-
coreConfig.identityProfileConnector ??= [];
|
|
2202
|
-
if (envVars.identityProfileConnector === engineModels.IdentityConnectorType.EntityStorage) {
|
|
2203
|
-
coreConfig.identityProfileConnector.push({
|
|
2204
|
-
type: engineModels.IdentityProfileConnectorType.EntityStorage
|
|
2205
|
-
});
|
|
2206
|
-
}
|
|
2207
|
-
}
|
|
2208
|
-
/**
|
|
2209
|
-
* Configures the attestation connectors for the core.
|
|
2210
|
-
* @param coreConfig The core config.
|
|
2211
|
-
* @param envVars The environment variables.
|
|
2212
|
-
*/
|
|
2213
|
-
function configureAttestationConnectors(coreConfig, envVars) {
|
|
2214
|
-
coreConfig.attestationConnector ??= [];
|
|
2215
|
-
if (envVars.attestationConnector === engineModels.AttestationConnectorType.EntityStorage) {
|
|
2216
|
-
coreConfig.attestationConnector.push({
|
|
2217
|
-
type: engineModels.AttestationConnectorType.EntityStorage
|
|
2218
|
-
});
|
|
2219
|
-
}
|
|
2220
|
-
else if (envVars.attestationConnector === engineModels.AttestationConnectorType.Iota) {
|
|
2221
|
-
coreConfig.attestationConnector.push({
|
|
2222
|
-
type: engineModels.AttestationConnectorType.Iota
|
|
2223
|
-
});
|
|
2224
|
-
}
|
|
2225
|
-
}
|
|
2226
|
-
|
|
2227
|
-
// Copyright 2024 IOTA Stiftung.
|
|
2228
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
2229
|
-
/**
|
|
2230
|
-
* Environment variable helper.
|
|
2231
|
-
*/
|
|
2232
|
-
class EnvHelper {
|
|
2233
|
-
/**
|
|
2234
|
-
* Get the environment variable as an object with camel cased names.
|
|
2235
|
-
* @param envVars The environment variables.
|
|
2236
|
-
* @param prefix The prefix of the environment variables.
|
|
2237
|
-
* @returns The object with camel cased names.
|
|
2238
|
-
*/
|
|
2239
|
-
static envToJson(envVars, prefix) {
|
|
2240
|
-
const result = {};
|
|
2241
|
-
for (const envVar in envVars) {
|
|
2242
|
-
if (envVar.startsWith(prefix) && core.Is.stringValue(process.env[envVar])) {
|
|
2243
|
-
const camelCaseName = core.StringHelper.camelCase(envVar.replace(prefix, "").toLowerCase());
|
|
2244
|
-
core.ObjectHelper.propertySet(result, camelCaseName, process.env[envVar]);
|
|
2245
|
-
}
|
|
2246
|
-
}
|
|
2247
|
-
return result;
|
|
2248
|
-
}
|
|
2249
|
-
}
|
|
2250
|
-
|
|
2251
530
|
exports.EngineCore = EngineCore;
|
|
2252
|
-
exports.EnvHelper = EnvHelper;
|
|
2253
531
|
exports.FileStateStorage = FileStateStorage;
|
|
2254
532
|
exports.MemoryStateStorage = MemoryStateStorage;
|
|
2255
|
-
exports.buildEngineCoreConfiguration = buildEngineCoreConfiguration;
|
|
2256
|
-
exports.initialiseEntityStorageConnector = initialiseEntityStorageConnector;
|