@twin.org/engine-types 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/LICENSE +201 -0
- package/README.md +21 -0
- package/dist/cjs/index.cjs +1640 -0
- package/dist/esm/index.mjs +1589 -0
- package/dist/types/components/attestation.d.ts +24 -0
- package/dist/types/components/auditableItemGraph.d.ts +13 -0
- package/dist/types/components/auditableItemStream.d.ts +13 -0
- package/dist/types/components/backgroundTask.d.ts +13 -0
- package/dist/types/components/blobStorage.d.ts +24 -0
- package/dist/types/components/entityStorage.d.ts +22 -0
- package/dist/types/components/faucet.d.ts +13 -0
- package/dist/types/components/identity.d.ts +24 -0
- package/dist/types/components/identityProfile.d.ts +24 -0
- package/dist/types/components/immutableProof.d.ts +13 -0
- package/dist/types/components/immutableStorage.d.ts +13 -0
- package/dist/types/components/logging.d.ts +24 -0
- package/dist/types/components/nft.d.ts +24 -0
- package/dist/types/components/telemetry.d.ts +24 -0
- package/dist/types/components/vault.d.ts +13 -0
- package/dist/types/components/wallet.d.ts +23 -0
- package/dist/types/index.d.ts +67 -0
- package/dist/types/models/IEngineCoreTypesConfig.d.ts +137 -0
- package/dist/types/models/config/attestationComponentConfig.d.ts +12 -0
- package/dist/types/models/config/attestationConnectorConfig.d.ts +21 -0
- package/dist/types/models/config/auditableItemGraphComponentConfig.d.ts +14 -0
- package/dist/types/models/config/auditableItemStreamComponentConfig.d.ts +14 -0
- package/dist/types/models/config/backgroundTaskConnectorConfig.d.ts +13 -0
- package/dist/types/models/config/blobStorageComponentConfig.d.ts +13 -0
- package/dist/types/models/config/blobStorageConnectorConfig.d.ts +42 -0
- package/dist/types/models/config/dltConfig.d.ts +11 -0
- package/dist/types/models/config/entityStorageComponentConfig.d.ts +12 -0
- package/dist/types/models/config/entityStorageConnectorConfig.d.ts +47 -0
- package/dist/types/models/config/faucetConnectorConfig.d.ts +18 -0
- package/dist/types/models/config/identityComponentConfig.d.ts +11 -0
- package/dist/types/models/config/identityConnectorConfig.d.ts +18 -0
- package/dist/types/models/config/identityProfileComponentConfig.d.ts +10 -0
- package/dist/types/models/config/identityProfileConnectorConfig.d.ts +10 -0
- package/dist/types/models/config/immutableProofComponentConfig.d.ts +16 -0
- package/dist/types/models/config/immutableStorageConnectorConfig.d.ts +17 -0
- package/dist/types/models/config/loggingComponentConfig.d.ts +10 -0
- package/dist/types/models/config/loggingConnectorConfig.d.ts +25 -0
- package/dist/types/models/config/nftComponentConfig.d.ts +11 -0
- package/dist/types/models/config/nftConnectorConfig.d.ts +17 -0
- package/dist/types/models/config/telemetryComponentConfig.d.ts +10 -0
- package/dist/types/models/config/telemetryConnectorConfig.d.ts +12 -0
- package/dist/types/models/config/vaultConnectorConfig.d.ts +17 -0
- package/dist/types/models/config/walletConnectorConfig.d.ts +22 -0
- package/dist/types/models/types/attestationComponentType.d.ts +13 -0
- package/dist/types/models/types/attestationConnectorType.d.ts +17 -0
- package/dist/types/models/types/auditableItemGraphComponentType.d.ts +13 -0
- package/dist/types/models/types/auditableItemStreamComponentType.d.ts +13 -0
- package/dist/types/models/types/backgroundTaskConnectorType.d.ts +13 -0
- package/dist/types/models/types/blobStorageComponentType.d.ts +13 -0
- package/dist/types/models/types/blobStorageConnectorType.d.ts +33 -0
- package/dist/types/models/types/dltConfigType.d.ts +13 -0
- package/dist/types/models/types/entityStorageComponentType.d.ts +13 -0
- package/dist/types/models/types/entityStorageConnectorType.d.ts +33 -0
- package/dist/types/models/types/faucetConnectorType.d.ts +17 -0
- package/dist/types/models/types/identityComponentType.d.ts +13 -0
- package/dist/types/models/types/identityConnectorType.d.ts +17 -0
- package/dist/types/models/types/identityProfileComponentType.d.ts +13 -0
- package/dist/types/models/types/identityProfileConnectorType.d.ts +13 -0
- package/dist/types/models/types/immutableProofComponentType.d.ts +13 -0
- package/dist/types/models/types/immutableStorageConnectorType.d.ts +17 -0
- package/dist/types/models/types/loggingComponentType.d.ts +13 -0
- package/dist/types/models/types/loggingConnectorType.d.ts +21 -0
- package/dist/types/models/types/nftComponentType.d.ts +13 -0
- package/dist/types/models/types/nftConnectorType.d.ts +17 -0
- package/dist/types/models/types/telemetryComponentType.d.ts +13 -0
- package/dist/types/models/types/telemetryConnectorType.d.ts +13 -0
- package/dist/types/models/types/vaultConnectorType.d.ts +17 -0
- package/dist/types/models/types/walletConnectorType.d.ts +17 -0
- package/docs/changelog.md +5 -0
- package/docs/examples.md +1 -0
- package/docs/reference/functions/initialiseAttestationComponent.md +33 -0
- package/docs/reference/functions/initialiseAttestationConnector.md +33 -0
- package/docs/reference/functions/initialiseAuditableItemGraphComponent.md +33 -0
- package/docs/reference/functions/initialiseAuditableItemStreamComponent.md +33 -0
- package/docs/reference/functions/initialiseBackgroundTaskConnector.md +33 -0
- package/docs/reference/functions/initialiseBlobStorageComponent.md +33 -0
- package/docs/reference/functions/initialiseBlobStorageConnector.md +33 -0
- package/docs/reference/functions/initialiseEntityStorageComponent.md +33 -0
- package/docs/reference/functions/initialiseEntityStorageConnector.md +31 -0
- package/docs/reference/functions/initialiseFaucetConnector.md +33 -0
- package/docs/reference/functions/initialiseIdentityComponent.md +33 -0
- package/docs/reference/functions/initialiseIdentityConnector.md +33 -0
- package/docs/reference/functions/initialiseIdentityProfileComponent.md +33 -0
- package/docs/reference/functions/initialiseIdentityProfileConnector.md +33 -0
- package/docs/reference/functions/initialiseImmutableProofComponent.md +33 -0
- package/docs/reference/functions/initialiseImmutableStorageConnector.md +33 -0
- package/docs/reference/functions/initialiseLoggingComponent.md +33 -0
- package/docs/reference/functions/initialiseLoggingConnector.md +33 -0
- package/docs/reference/functions/initialiseNftComponent.md +33 -0
- package/docs/reference/functions/initialiseNftConnector.md +33 -0
- package/docs/reference/functions/initialiseTelemetryComponent.md +33 -0
- package/docs/reference/functions/initialiseTelemetryConnector.md +33 -0
- package/docs/reference/functions/initialiseVaultConnector.md +33 -0
- package/docs/reference/functions/initialiseWalletConnector.md +33 -0
- package/docs/reference/functions/initialiseWalletStorage.md +33 -0
- package/docs/reference/index.md +114 -0
- package/docs/reference/interfaces/IEngineCoreTypesConfig.md +173 -0
- package/docs/reference/type-aliases/AttestationComponentConfig.md +23 -0
- package/docs/reference/type-aliases/AttestationComponentType.md +5 -0
- package/docs/reference/type-aliases/AttestationConnectorConfig.md +5 -0
- package/docs/reference/type-aliases/AttestationConnectorType.md +5 -0
- package/docs/reference/type-aliases/AuditableItemGraphComponentConfig.md +31 -0
- package/docs/reference/type-aliases/AuditableItemGraphComponentType.md +5 -0
- package/docs/reference/type-aliases/AuditableItemStreamComponentConfig.md +31 -0
- package/docs/reference/type-aliases/AuditableItemStreamComponentType.md +5 -0
- package/docs/reference/type-aliases/BackgroundTaskConnectorConfig.md +27 -0
- package/docs/reference/type-aliases/BackgroundTaskConnectorType.md +5 -0
- package/docs/reference/type-aliases/BlobStorageComponentConfig.md +27 -0
- package/docs/reference/type-aliases/BlobStorageComponentType.md +5 -0
- package/docs/reference/type-aliases/BlobStorageConnectorConfig.md +5 -0
- package/docs/reference/type-aliases/BlobStorageConnectorType.md +5 -0
- package/docs/reference/type-aliases/DltConfig.md +19 -0
- package/docs/reference/type-aliases/DltConfigType.md +5 -0
- package/docs/reference/type-aliases/EntityStorageComponentConfig.md +23 -0
- package/docs/reference/type-aliases/EntityStorageComponentType.md +5 -0
- package/docs/reference/type-aliases/EntityStorageConnectorConfig.md +5 -0
- package/docs/reference/type-aliases/EntityStorageConnectorType.md +5 -0
- package/docs/reference/type-aliases/FaucetConnectorConfig.md +5 -0
- package/docs/reference/type-aliases/FaucetConnectorType.md +5 -0
- package/docs/reference/type-aliases/IImmutableProofComponentType.md +5 -0
- package/docs/reference/type-aliases/IdentityComponentConfig.md +19 -0
- package/docs/reference/type-aliases/IdentityComponentType.md +5 -0
- package/docs/reference/type-aliases/IdentityConnectorConfig.md +5 -0
- package/docs/reference/type-aliases/IdentityConnectorType.md +5 -0
- package/docs/reference/type-aliases/IdentityProfileComponentConfig.md +19 -0
- package/docs/reference/type-aliases/IdentityProfileComponentType.md +5 -0
- package/docs/reference/type-aliases/IdentityProfileConnectorConfig.md +19 -0
- package/docs/reference/type-aliases/IdentityProfileConnectorType.md +5 -0
- package/docs/reference/type-aliases/ImmutableProofComponentConfig.md +39 -0
- package/docs/reference/type-aliases/ImmutableStorageConnectorConfig.md +5 -0
- package/docs/reference/type-aliases/ImmutableStorageConnectorType.md +5 -0
- package/docs/reference/type-aliases/LoggingComponentConfig.md +19 -0
- package/docs/reference/type-aliases/LoggingComponentType.md +5 -0
- package/docs/reference/type-aliases/LoggingConnectorConfig.md +5 -0
- package/docs/reference/type-aliases/LoggingConnectorType.md +5 -0
- package/docs/reference/type-aliases/NftComponentConfig.md +19 -0
- package/docs/reference/type-aliases/NftComponentType.md +5 -0
- package/docs/reference/type-aliases/NftConnectorConfig.md +5 -0
- package/docs/reference/type-aliases/NftConnectorType.md +5 -0
- package/docs/reference/type-aliases/TelemetryComponentConfig.md +19 -0
- package/docs/reference/type-aliases/TelemetryComponentType.md +5 -0
- package/docs/reference/type-aliases/TelemetryConnectorConfig.md +27 -0
- package/docs/reference/type-aliases/TelemetryConnectorType.md +5 -0
- package/docs/reference/type-aliases/VaultConnectorConfig.md +5 -0
- package/docs/reference/type-aliases/VaultConnectorType.md +5 -0
- package/docs/reference/type-aliases/WalletConnectorConfig.md +5 -0
- package/docs/reference/type-aliases/WalletConnectorType.md +5 -0
- package/docs/reference/variables/AttestationComponentType.md +13 -0
- package/docs/reference/variables/AttestationConnectorType.md +19 -0
- package/docs/reference/variables/AuditableItemGraphComponentType.md +13 -0
- package/docs/reference/variables/AuditableItemStreamComponentType.md +13 -0
- package/docs/reference/variables/BackgroundTaskConnectorType.md +13 -0
- package/docs/reference/variables/BlobStorageComponentType.md +13 -0
- package/docs/reference/variables/BlobStorageConnectorType.md +43 -0
- package/docs/reference/variables/DltConfigType.md +13 -0
- package/docs/reference/variables/EntityStorageComponentType.md +13 -0
- package/docs/reference/variables/EntityStorageConnectorType.md +43 -0
- package/docs/reference/variables/FaucetConnectorType.md +19 -0
- package/docs/reference/variables/IdentityComponentType.md +13 -0
- package/docs/reference/variables/IdentityConnectorType.md +19 -0
- package/docs/reference/variables/IdentityProfileComponentType.md +13 -0
- package/docs/reference/variables/IdentityProfileConnectorType.md +13 -0
- package/docs/reference/variables/ImmutableProofComponentType.md +13 -0
- package/docs/reference/variables/ImmutableStorageConnectorType.md +19 -0
- package/docs/reference/variables/LoggingComponentType.md +13 -0
- package/docs/reference/variables/LoggingConnectorType.md +25 -0
- package/docs/reference/variables/NftComponentType.md +13 -0
- package/docs/reference/variables/NftConnectorType.md +19 -0
- package/docs/reference/variables/TelemetryComponentType.md +13 -0
- package/docs/reference/variables/TelemetryConnectorType.md +13 -0
- package/docs/reference/variables/VaultConnectorType.md +19 -0
- package/docs/reference/variables/WalletConnectorType.md +19 -0
- package/locales/en.json +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,1640 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var attestationConnectorEntityStorage = require('@twin.org/attestation-connector-entity-storage');
|
|
4
|
+
var attestationConnectorIota = require('@twin.org/attestation-connector-iota');
|
|
5
|
+
var attestationModels = require('@twin.org/attestation-models');
|
|
6
|
+
var attestationService = require('@twin.org/attestation-service');
|
|
7
|
+
var core = require('@twin.org/core');
|
|
8
|
+
var auditableItemGraphService = require('@twin.org/auditable-item-graph-service');
|
|
9
|
+
var path = require('node:path');
|
|
10
|
+
var entityStorageConnectorCosmosdb = require('@twin.org/entity-storage-connector-cosmosdb');
|
|
11
|
+
var entityStorageConnectorDynamodb = require('@twin.org/entity-storage-connector-dynamodb');
|
|
12
|
+
var entityStorageConnectorFile = require('@twin.org/entity-storage-connector-file');
|
|
13
|
+
var entityStorageConnectorGcpFirestore = require('@twin.org/entity-storage-connector-gcp-firestore');
|
|
14
|
+
var entityStorageConnectorMemory = require('@twin.org/entity-storage-connector-memory');
|
|
15
|
+
var entityStorageConnectorScylladb = require('@twin.org/entity-storage-connector-scylladb');
|
|
16
|
+
var entityStorageModels = require('@twin.org/entity-storage-models');
|
|
17
|
+
var entityStorageService = require('@twin.org/entity-storage-service');
|
|
18
|
+
var auditableItemStreamService = require('@twin.org/auditable-item-stream-service');
|
|
19
|
+
var backgroundTaskConnectorEntityStorage = require('@twin.org/background-task-connector-entity-storage');
|
|
20
|
+
var backgroundTaskModels = require('@twin.org/background-task-models');
|
|
21
|
+
var blobStorageConnectorAwsS3 = require('@twin.org/blob-storage-connector-aws-s3');
|
|
22
|
+
var blobStorageConnectorAzure = require('@twin.org/blob-storage-connector-azure');
|
|
23
|
+
var blobStorageConnectorFile = require('@twin.org/blob-storage-connector-file');
|
|
24
|
+
var blobStorageConnectorGcp = require('@twin.org/blob-storage-connector-gcp');
|
|
25
|
+
var blobStorageConnectorIpfs = require('@twin.org/blob-storage-connector-ipfs');
|
|
26
|
+
var blobStorageConnectorMemory = require('@twin.org/blob-storage-connector-memory');
|
|
27
|
+
var blobStorageModels = require('@twin.org/blob-storage-models');
|
|
28
|
+
var blobStorageService = require('@twin.org/blob-storage-service');
|
|
29
|
+
var walletConnectorEntityStorage = require('@twin.org/wallet-connector-entity-storage');
|
|
30
|
+
var walletConnectorIota = require('@twin.org/wallet-connector-iota');
|
|
31
|
+
var walletModels = require('@twin.org/wallet-models');
|
|
32
|
+
var identityConnectorEntityStorage = require('@twin.org/identity-connector-entity-storage');
|
|
33
|
+
var identityConnectorIota = require('@twin.org/identity-connector-iota');
|
|
34
|
+
var identityModels = require('@twin.org/identity-models');
|
|
35
|
+
var identityService = require('@twin.org/identity-service');
|
|
36
|
+
var immutableProofService = require('@twin.org/immutable-proof-service');
|
|
37
|
+
var immutableStorageConnectorEntityStorage = require('@twin.org/immutable-storage-connector-entity-storage');
|
|
38
|
+
var immutableStorageConnectorIota = require('@twin.org/immutable-storage-connector-iota');
|
|
39
|
+
var immutableStorageModels = require('@twin.org/immutable-storage-models');
|
|
40
|
+
var loggingConnectorConsole = require('@twin.org/logging-connector-console');
|
|
41
|
+
var loggingConnectorEntityStorage = require('@twin.org/logging-connector-entity-storage');
|
|
42
|
+
var loggingModels = require('@twin.org/logging-models');
|
|
43
|
+
var loggingService = require('@twin.org/logging-service');
|
|
44
|
+
var nftConnectorEntityStorage = require('@twin.org/nft-connector-entity-storage');
|
|
45
|
+
var nftConnectorIota = require('@twin.org/nft-connector-iota');
|
|
46
|
+
var nftModels = require('@twin.org/nft-models');
|
|
47
|
+
var nftService = require('@twin.org/nft-service');
|
|
48
|
+
var telemetryConnectorEntityStorage = require('@twin.org/telemetry-connector-entity-storage');
|
|
49
|
+
var telemetryModels = require('@twin.org/telemetry-models');
|
|
50
|
+
var telemetryService = require('@twin.org/telemetry-service');
|
|
51
|
+
var vaultConnectorEntityStorage = require('@twin.org/vault-connector-entity-storage');
|
|
52
|
+
var vaultConnectorHashicorp = require('@twin.org/vault-connector-hashicorp');
|
|
53
|
+
var vaultModels = require('@twin.org/vault-models');
|
|
54
|
+
|
|
55
|
+
// Copyright 2024 IOTA Stiftung.
|
|
56
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
57
|
+
/**
|
|
58
|
+
* Attestation component types.
|
|
59
|
+
*/
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
61
|
+
const AttestationComponentType = {
|
|
62
|
+
/**
|
|
63
|
+
* Service.
|
|
64
|
+
*/
|
|
65
|
+
Service: "service"
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Copyright 2024 IOTA Stiftung.
|
|
69
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
70
|
+
/**
|
|
71
|
+
* Attestation connector types.
|
|
72
|
+
*/
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
74
|
+
const AttestationConnectorType = {
|
|
75
|
+
/**
|
|
76
|
+
* Entity storage.
|
|
77
|
+
*/
|
|
78
|
+
EntityStorage: "entity-storage",
|
|
79
|
+
/**
|
|
80
|
+
* IOTA.
|
|
81
|
+
*/
|
|
82
|
+
Iota: "iota"
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Copyright 2024 IOTA Stiftung.
|
|
86
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
87
|
+
/**
|
|
88
|
+
* Initialise the attestation connector.
|
|
89
|
+
* @param engineCore The engine core.
|
|
90
|
+
* @param context The context for the engine.
|
|
91
|
+
* @param instanceConfig The instance config.
|
|
92
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
93
|
+
* @returns The name of the instance created.
|
|
94
|
+
* @throws GeneralError if the connector type is unknown.
|
|
95
|
+
*/
|
|
96
|
+
function initialiseAttestationConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
97
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
98
|
+
element: `Attestation Connector: ${instanceConfig.type}`
|
|
99
|
+
}));
|
|
100
|
+
const type = instanceConfig.type;
|
|
101
|
+
let connector;
|
|
102
|
+
let instanceType;
|
|
103
|
+
if (type === AttestationConnectorType.Iota) {
|
|
104
|
+
connector = new attestationConnectorIota.IotaAttestationConnector({
|
|
105
|
+
identityConnectorType: context.defaultTypes.identityConnector,
|
|
106
|
+
nftConnectorType: context.defaultTypes.nftConnector,
|
|
107
|
+
...instanceConfig.options
|
|
108
|
+
});
|
|
109
|
+
instanceType = attestationConnectorIota.IotaAttestationConnector.NAMESPACE;
|
|
110
|
+
}
|
|
111
|
+
else if (type === AttestationConnectorType.EntityStorage) {
|
|
112
|
+
connector = new attestationConnectorEntityStorage.EntityStorageAttestationConnector({
|
|
113
|
+
identityConnectorType: context.defaultTypes.identityConnector,
|
|
114
|
+
nftConnectorType: context.defaultTypes.nftConnector,
|
|
115
|
+
...instanceConfig.options
|
|
116
|
+
});
|
|
117
|
+
instanceType = attestationConnectorEntityStorage.EntityStorageAttestationConnector.NAMESPACE;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
121
|
+
type,
|
|
122
|
+
connectorType: "attestationConnector"
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
126
|
+
context.componentInstances.push({
|
|
127
|
+
instanceType: finalInstanceType,
|
|
128
|
+
component: connector
|
|
129
|
+
});
|
|
130
|
+
attestationModels.AttestationConnectorFactory.register(finalInstanceType, () => connector);
|
|
131
|
+
return finalInstanceType;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Initialise the attestation component.
|
|
135
|
+
* @param engineCore The engine core.
|
|
136
|
+
* @param context The context for the engine.
|
|
137
|
+
* @param instanceConfig The instance config.
|
|
138
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
139
|
+
* @returns The name of the instance created.
|
|
140
|
+
* @throws GeneralError if the component type is unknown.
|
|
141
|
+
*/
|
|
142
|
+
function initialiseAttestationComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
143
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
144
|
+
element: `Attestation Component: ${instanceConfig.type}`
|
|
145
|
+
}));
|
|
146
|
+
const type = instanceConfig.type;
|
|
147
|
+
let component;
|
|
148
|
+
let instanceType;
|
|
149
|
+
if (type === AttestationComponentType.Service) {
|
|
150
|
+
component = new attestationService.AttestationService({
|
|
151
|
+
walletConnectorType: context.defaultTypes.walletConnector,
|
|
152
|
+
...instanceConfig.options
|
|
153
|
+
});
|
|
154
|
+
instanceType = attestationService.AttestationService.NAMESPACE;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
158
|
+
type,
|
|
159
|
+
componentType: "attestationComponent"
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
163
|
+
context.componentInstances.push({
|
|
164
|
+
instanceType: finalInstanceType,
|
|
165
|
+
component
|
|
166
|
+
});
|
|
167
|
+
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
168
|
+
return finalInstanceType;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Copyright 2024 IOTA Stiftung.
|
|
172
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
173
|
+
/**
|
|
174
|
+
* Entity storage component types.
|
|
175
|
+
*/
|
|
176
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
177
|
+
const EntityStorageComponentType = {
|
|
178
|
+
/**
|
|
179
|
+
* Service.
|
|
180
|
+
*/
|
|
181
|
+
Service: "service"
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// Copyright 2024 IOTA Stiftung.
|
|
185
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
186
|
+
/**
|
|
187
|
+
* Entity storage connector types.
|
|
188
|
+
*/
|
|
189
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
190
|
+
const EntityStorageConnectorType = {
|
|
191
|
+
/**
|
|
192
|
+
* Use storage.
|
|
193
|
+
*/
|
|
194
|
+
File: "file",
|
|
195
|
+
/**
|
|
196
|
+
* Memory.
|
|
197
|
+
*/
|
|
198
|
+
Memory: "memory",
|
|
199
|
+
/**
|
|
200
|
+
* ScyllaDb.
|
|
201
|
+
*/
|
|
202
|
+
ScyllaDb: "scylladb",
|
|
203
|
+
/**
|
|
204
|
+
* AWS DynamoDB.
|
|
205
|
+
*/
|
|
206
|
+
AwsDynamoDb: "aws-dynamodb",
|
|
207
|
+
/**
|
|
208
|
+
* Azure CosmosDB.
|
|
209
|
+
*/
|
|
210
|
+
AzureCosmosDb: "azure-cosmosdb",
|
|
211
|
+
/**
|
|
212
|
+
* GCP Firestore.
|
|
213
|
+
*/
|
|
214
|
+
GcpFirestoreDb: "gcp-firestoredb"
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// Copyright 2024 IOTA Stiftung.
|
|
218
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
219
|
+
/**
|
|
220
|
+
* Initialise the entity storage connector.
|
|
221
|
+
* @param engineCore The engine core.
|
|
222
|
+
* @param context The context for the engine.
|
|
223
|
+
* @param typeCustom Override the type of connector to use instead of default configuration.
|
|
224
|
+
* @param schema The schema for the entity storage.
|
|
225
|
+
* @throws GeneralError if the connector type is unknown.
|
|
226
|
+
*/
|
|
227
|
+
function initialiseEntityStorageConnector(engineCore, context, typeCustom, schema) {
|
|
228
|
+
const instanceName = core.StringHelper.kebabCase(schema);
|
|
229
|
+
let entityStorageConfig;
|
|
230
|
+
if (core.Is.stringValue(typeCustom)) {
|
|
231
|
+
// A custom type has been specified, so look it up
|
|
232
|
+
entityStorageConfig = context.config.types.entityStorageConnector?.find(c => c.type === typeCustom || c.overrideInstanceType === typeCustom);
|
|
233
|
+
if (core.Is.empty(entityStorageConfig)) {
|
|
234
|
+
throw new core.GeneralError("engineCore", "entityStorageCustomMissing", {
|
|
235
|
+
typeCustom,
|
|
236
|
+
storageName: instanceName
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
// The default entity storage method is either the one with the isDefault flag set
|
|
242
|
+
// or pick the first one if no default is set.
|
|
243
|
+
entityStorageConfig =
|
|
244
|
+
context.config.types.entityStorageConnector?.find(c => c.isDefault ?? false) ??
|
|
245
|
+
context.config.types.entityStorageConnector?.[0];
|
|
246
|
+
if (core.Is.empty(entityStorageConfig)) {
|
|
247
|
+
throw new core.GeneralError("engineCore", "entityStorageMissing", {
|
|
248
|
+
storageName: instanceName
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const type = entityStorageConfig.type;
|
|
253
|
+
let entityStorageConnector;
|
|
254
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuringEntityStorage", {
|
|
255
|
+
element: "Entity Storage",
|
|
256
|
+
storageName: instanceName,
|
|
257
|
+
storageType: type
|
|
258
|
+
}));
|
|
259
|
+
if (type === EntityStorageConnectorType.Memory) {
|
|
260
|
+
entityStorageConnector = new entityStorageConnectorMemory.MemoryEntityStorageConnector({
|
|
261
|
+
entitySchema: schema
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
else if (type === EntityStorageConnectorType.File) {
|
|
265
|
+
entityStorageConnector = new entityStorageConnectorFile.FileEntityStorageConnector({
|
|
266
|
+
entitySchema: schema,
|
|
267
|
+
...entityStorageConfig.options,
|
|
268
|
+
config: {
|
|
269
|
+
...entityStorageConfig.options.config,
|
|
270
|
+
directory: path.join(entityStorageConfig.options.config.directory, `${entityStorageConfig.options.folderPrefix ?? ""}${instanceName}`)
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
else if (type === EntityStorageConnectorType.AwsDynamoDb) {
|
|
275
|
+
entityStorageConnector = new entityStorageConnectorDynamodb.DynamoDbEntityStorageConnector({
|
|
276
|
+
entitySchema: schema,
|
|
277
|
+
...entityStorageConfig.options,
|
|
278
|
+
config: {
|
|
279
|
+
...entityStorageConfig.options.config,
|
|
280
|
+
tableName: `${entityStorageConfig.options.tablePrefix ?? ""}${instanceName}`
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
else if (type === EntityStorageConnectorType.AzureCosmosDb) {
|
|
285
|
+
entityStorageConnector = new entityStorageConnectorCosmosdb.CosmosDbEntityStorageConnector({
|
|
286
|
+
entitySchema: schema,
|
|
287
|
+
...entityStorageConfig.options,
|
|
288
|
+
config: {
|
|
289
|
+
...entityStorageConfig.options.config,
|
|
290
|
+
containerId: `${entityStorageConfig.options.tablePrefix ?? ""}${instanceName}`
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
else if (type === EntityStorageConnectorType.GcpFirestoreDb) {
|
|
295
|
+
entityStorageConnector = new entityStorageConnectorGcpFirestore.FirestoreEntityStorageConnector({
|
|
296
|
+
entitySchema: schema,
|
|
297
|
+
...entityStorageConfig.options,
|
|
298
|
+
config: {
|
|
299
|
+
...entityStorageConfig.options.config,
|
|
300
|
+
collectionName: `${entityStorageConfig.options.tablePrefix ?? ""}${instanceName}`
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
else if (type === EntityStorageConnectorType.ScyllaDb) {
|
|
305
|
+
entityStorageConnector = new entityStorageConnectorScylladb.ScyllaDBTableConnector({
|
|
306
|
+
entitySchema: schema,
|
|
307
|
+
...entityStorageConfig.options,
|
|
308
|
+
config: {
|
|
309
|
+
...entityStorageConfig.options.config,
|
|
310
|
+
tableName: `${entityStorageConfig.options.tablePrefix ?? ""}${instanceName}`
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
316
|
+
type,
|
|
317
|
+
connectorType: "entityStorageConnector"
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
context.componentInstances.push({
|
|
321
|
+
instanceType: instanceName,
|
|
322
|
+
component: entityStorageConnector
|
|
323
|
+
});
|
|
324
|
+
entityStorageModels.EntityStorageConnectorFactory.register(instanceName, () => entityStorageConnector);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Initialise the entity storage connector.
|
|
328
|
+
* @param engineCore The engine core.
|
|
329
|
+
* @param context The context for the engine.
|
|
330
|
+
* @param instanceConfig The instance config.
|
|
331
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
332
|
+
* @returns The name of the instance created.
|
|
333
|
+
* @throws GeneralError if the connector type is unknown.
|
|
334
|
+
*/
|
|
335
|
+
function initialiseEntityStorageComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
336
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
337
|
+
element: `Entity Storage Component: ${instanceConfig.type}`
|
|
338
|
+
}));
|
|
339
|
+
const type = instanceConfig.type;
|
|
340
|
+
let connector;
|
|
341
|
+
let instanceType;
|
|
342
|
+
if (type === EntityStorageComponentType.Service) {
|
|
343
|
+
const kebabName = core.StringHelper.kebabCase(instanceConfig.options.entityStorageType);
|
|
344
|
+
// See if there is a custom entity storage for this type, otherwise just use the default one.
|
|
345
|
+
const hasCustom = context.config.types.entityStorageConnector?.some(c => c.type === kebabName || c.overrideInstanceType === kebabName);
|
|
346
|
+
initialiseEntityStorageConnector(engineCore, context, hasCustom ? kebabName : undefined, instanceConfig.options.entityStorageType);
|
|
347
|
+
connector = new entityStorageService.EntityStorageService({
|
|
348
|
+
entityStorageType: kebabName,
|
|
349
|
+
config: {
|
|
350
|
+
...instanceConfig.options.config
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
instanceType = core.StringHelper.kebabCase(instanceConfig.options.entityStorageType);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
357
|
+
type,
|
|
358
|
+
serviceType: "entityStorageComponent"
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
362
|
+
context.componentInstances.push({
|
|
363
|
+
instanceType: finalInstanceType,
|
|
364
|
+
component: connector
|
|
365
|
+
});
|
|
366
|
+
core.ComponentFactory.register(finalInstanceType, () => connector);
|
|
367
|
+
return finalInstanceType;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Copyright 2024 IOTA Stiftung.
|
|
371
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
372
|
+
/**
|
|
373
|
+
* Auditable item graph component types.
|
|
374
|
+
*/
|
|
375
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
376
|
+
const AuditableItemGraphComponentType = {
|
|
377
|
+
/**
|
|
378
|
+
* Service.
|
|
379
|
+
*/
|
|
380
|
+
Service: "service"
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Initialise the auditable item graph component.
|
|
385
|
+
* @param engineCore The engine core.
|
|
386
|
+
* @param context The context for the engine.
|
|
387
|
+
* @param instanceConfig The instance config.
|
|
388
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
389
|
+
* @returns The name of the instance created.
|
|
390
|
+
* @throws GeneralError if the component type is unknown.
|
|
391
|
+
*/
|
|
392
|
+
function initialiseAuditableItemGraphComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
393
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
394
|
+
element: `Auditable Item Graph Component: ${instanceConfig.type}`
|
|
395
|
+
}));
|
|
396
|
+
const type = instanceConfig.type;
|
|
397
|
+
let component;
|
|
398
|
+
let instanceType;
|
|
399
|
+
if (type === AuditableItemGraphComponentType.Service) {
|
|
400
|
+
auditableItemGraphService.initSchema();
|
|
401
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.vertexEntityStorageType, "AuditableItemGraphVertex");
|
|
402
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.changesetEntityStorageType, "AuditableItemGraphChangeset");
|
|
403
|
+
component = new auditableItemGraphService.AuditableItemGraphService({
|
|
404
|
+
immutableProofComponentType: context.defaultTypes.immutableProofComponent,
|
|
405
|
+
...instanceConfig.options
|
|
406
|
+
});
|
|
407
|
+
instanceType = auditableItemGraphService.AuditableItemGraphService.NAMESPACE;
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
411
|
+
type,
|
|
412
|
+
componentType: "auditableItemGraphComponent"
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
416
|
+
context.componentInstances.push({
|
|
417
|
+
instanceType: finalInstanceType,
|
|
418
|
+
component
|
|
419
|
+
});
|
|
420
|
+
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
421
|
+
return finalInstanceType;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// Copyright 2024 IOTA Stiftung.
|
|
425
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
426
|
+
/**
|
|
427
|
+
* Auditable item stream component types.
|
|
428
|
+
*/
|
|
429
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
430
|
+
const AuditableItemStreamComponentType = {
|
|
431
|
+
/**
|
|
432
|
+
* Service.
|
|
433
|
+
*/
|
|
434
|
+
Service: "service"
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Initialise the auditable item stream component.
|
|
439
|
+
* @param engineCore The engine core.
|
|
440
|
+
* @param context The context for the engine.
|
|
441
|
+
* @param instanceConfig The instance config.
|
|
442
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
443
|
+
* @returns The name of the instance created.
|
|
444
|
+
* @throws GeneralError if the component type is unknown.
|
|
445
|
+
*/
|
|
446
|
+
function initialiseAuditableItemStreamComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
447
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
448
|
+
element: `Auditable Item Stream Component: ${instanceConfig.type}`
|
|
449
|
+
}));
|
|
450
|
+
const type = instanceConfig.type;
|
|
451
|
+
let component;
|
|
452
|
+
let instanceType;
|
|
453
|
+
if (type === AuditableItemStreamComponentType.Service) {
|
|
454
|
+
auditableItemStreamService.initSchema();
|
|
455
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.streamEntityStorageType, "AuditableItemStream");
|
|
456
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.streamEntryEntityStorageType, "AuditableItemStreamEntry");
|
|
457
|
+
component = new auditableItemStreamService.AuditableItemStreamService({
|
|
458
|
+
immutableProofComponentType: context.defaultTypes.immutableProofComponent,
|
|
459
|
+
...instanceConfig.options
|
|
460
|
+
});
|
|
461
|
+
instanceType = auditableItemStreamService.AuditableItemStreamService.NAMESPACE;
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
465
|
+
type,
|
|
466
|
+
componentType: "auditableItemStreamComponent"
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
470
|
+
context.componentInstances.push({
|
|
471
|
+
instanceType: finalInstanceType,
|
|
472
|
+
component
|
|
473
|
+
});
|
|
474
|
+
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
475
|
+
return finalInstanceType;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// Copyright 2024 IOTA Stiftung.
|
|
479
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
480
|
+
/**
|
|
481
|
+
* Background task connector types.
|
|
482
|
+
*/
|
|
483
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
484
|
+
const BackgroundTaskConnectorType = {
|
|
485
|
+
/**
|
|
486
|
+
* Entity storage.
|
|
487
|
+
*/
|
|
488
|
+
EntityStorage: "entity-storage"
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
// Copyright 2024 IOTA Stiftung.
|
|
492
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
493
|
+
/**
|
|
494
|
+
* Initialise a background task connector.
|
|
495
|
+
* @param engineCore The engine core.
|
|
496
|
+
* @param context The context for the engine.
|
|
497
|
+
* @param instanceConfig The instance config.
|
|
498
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
499
|
+
* @returns The name of the instance created.
|
|
500
|
+
* @throws GeneralError if the connector type is unknown.
|
|
501
|
+
*/
|
|
502
|
+
function initialiseBackgroundTaskConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
503
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
504
|
+
element: `Background Task Connector: ${instanceConfig.type}`
|
|
505
|
+
}));
|
|
506
|
+
const type = instanceConfig.type;
|
|
507
|
+
let connector;
|
|
508
|
+
let instanceType;
|
|
509
|
+
if (type === BackgroundTaskConnectorType.EntityStorage) {
|
|
510
|
+
backgroundTaskConnectorEntityStorage.initSchema();
|
|
511
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.backgroundTaskEntityStorageType, "BackgroundTask");
|
|
512
|
+
connector = new backgroundTaskConnectorEntityStorage.EntityStorageBackgroundTaskConnector({
|
|
513
|
+
loggingConnectorType: context.defaultTypes.loggingConnector,
|
|
514
|
+
...instanceConfig.options
|
|
515
|
+
});
|
|
516
|
+
instanceType = backgroundTaskConnectorEntityStorage.EntityStorageBackgroundTaskConnector.NAMESPACE;
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
520
|
+
type,
|
|
521
|
+
connectorType: "backgroundTaskConnector"
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
525
|
+
context.componentInstances.push({ instanceType: finalInstanceType, component: connector });
|
|
526
|
+
backgroundTaskModels.BackgroundTaskConnectorFactory.register(finalInstanceType, () => connector);
|
|
527
|
+
return finalInstanceType;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// Copyright 2024 IOTA Stiftung.
|
|
531
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
532
|
+
/**
|
|
533
|
+
* Blob storage component types.
|
|
534
|
+
*/
|
|
535
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
536
|
+
const BlobStorageComponentType = {
|
|
537
|
+
/**
|
|
538
|
+
* Service.
|
|
539
|
+
*/
|
|
540
|
+
Service: "service"
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
// Copyright 2024 IOTA Stiftung.
|
|
544
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
545
|
+
/**
|
|
546
|
+
* Blob storage connector types.
|
|
547
|
+
*/
|
|
548
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
549
|
+
const BlobStorageConnectorType = {
|
|
550
|
+
/**
|
|
551
|
+
* File storage.
|
|
552
|
+
*/
|
|
553
|
+
File: "file",
|
|
554
|
+
/**
|
|
555
|
+
* Memory.
|
|
556
|
+
*/
|
|
557
|
+
Memory: "memory",
|
|
558
|
+
/**
|
|
559
|
+
* IPFS.
|
|
560
|
+
*/
|
|
561
|
+
Ipfs: "ipfs",
|
|
562
|
+
/**
|
|
563
|
+
* AWS S3.
|
|
564
|
+
*/
|
|
565
|
+
AwsS3: "aws-s3",
|
|
566
|
+
/**
|
|
567
|
+
* Azure Storage.
|
|
568
|
+
*/
|
|
569
|
+
AzureStorage: "azure-storage",
|
|
570
|
+
/**
|
|
571
|
+
* GCP Storage.
|
|
572
|
+
*/
|
|
573
|
+
GcpStorage: "gcp-storage"
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
// Copyright 2024 IOTA Stiftung.
|
|
577
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
578
|
+
/**
|
|
579
|
+
* Initialise the blob storage connector.
|
|
580
|
+
* @param engineCore The engine core.
|
|
581
|
+
* @param context The context for the engine.
|
|
582
|
+
* @param instanceConfig The instance config.
|
|
583
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
584
|
+
* @returns The name of the instance created.
|
|
585
|
+
* @throws GeneralError if the connector type is unknown.
|
|
586
|
+
*/
|
|
587
|
+
function initialiseBlobStorageConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
588
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
589
|
+
element: `Blob Storage Connector: ${instanceConfig.type}`
|
|
590
|
+
}));
|
|
591
|
+
const type = instanceConfig.type;
|
|
592
|
+
let connector;
|
|
593
|
+
let instanceType;
|
|
594
|
+
if (type === BlobStorageConnectorType.Ipfs) {
|
|
595
|
+
connector = new blobStorageConnectorIpfs.IpfsBlobStorageConnector(instanceConfig.options);
|
|
596
|
+
instanceType = blobStorageConnectorIpfs.IpfsBlobStorageConnector.NAMESPACE;
|
|
597
|
+
}
|
|
598
|
+
else if (type === BlobStorageConnectorType.File) {
|
|
599
|
+
connector = new blobStorageConnectorFile.FileBlobStorageConnector({
|
|
600
|
+
...instanceConfig.options,
|
|
601
|
+
config: {
|
|
602
|
+
...instanceConfig.options.config,
|
|
603
|
+
directory: core.Is.stringValue(instanceConfig.options.storagePrefix)
|
|
604
|
+
? path.join(instanceConfig.options.config.directory, instanceConfig.options.storagePrefix)
|
|
605
|
+
: instanceConfig.options.config.directory
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
instanceType = blobStorageConnectorFile.FileBlobStorageConnector.NAMESPACE;
|
|
609
|
+
}
|
|
610
|
+
else if (type === BlobStorageConnectorType.Memory) {
|
|
611
|
+
connector = new blobStorageConnectorMemory.MemoryBlobStorageConnector();
|
|
612
|
+
instanceType = blobStorageConnectorMemory.MemoryBlobStorageConnector.NAMESPACE;
|
|
613
|
+
}
|
|
614
|
+
else if (type === BlobStorageConnectorType.AwsS3) {
|
|
615
|
+
connector = new blobStorageConnectorAwsS3.S3BlobStorageConnector({
|
|
616
|
+
...instanceConfig.options,
|
|
617
|
+
config: {
|
|
618
|
+
...instanceConfig.options.config,
|
|
619
|
+
bucketName: `${instanceConfig.options.storagePrefix ?? ""}${instanceConfig.options.config.bucketName}`
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
instanceType = blobStorageConnectorAwsS3.S3BlobStorageConnector.NAMESPACE;
|
|
623
|
+
}
|
|
624
|
+
else if (type === BlobStorageConnectorType.GcpStorage) {
|
|
625
|
+
connector = new blobStorageConnectorGcp.GcpBlobStorageConnector({
|
|
626
|
+
...instanceConfig.options,
|
|
627
|
+
config: {
|
|
628
|
+
...instanceConfig.options.config,
|
|
629
|
+
bucketName: `${instanceConfig.options.storagePrefix ?? ""}${instanceConfig.options.config.bucketName}`
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
instanceType = blobStorageConnectorGcp.GcpBlobStorageConnector.NAMESPACE;
|
|
633
|
+
}
|
|
634
|
+
else if (type === BlobStorageConnectorType.AzureStorage) {
|
|
635
|
+
connector = new blobStorageConnectorAzure.AzureBlobStorageConnector({
|
|
636
|
+
...instanceConfig.options,
|
|
637
|
+
config: {
|
|
638
|
+
...instanceConfig.options.config,
|
|
639
|
+
containerName: `${instanceConfig.options.storagePrefix ?? ""}${instanceConfig.options.config.containerName}`
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
instanceType = blobStorageConnectorAzure.AzureBlobStorageConnector.NAMESPACE;
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
645
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
646
|
+
type,
|
|
647
|
+
connectorType: "blobStorageConnector"
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
651
|
+
context.componentInstances.push({
|
|
652
|
+
instanceType: finalInstanceType,
|
|
653
|
+
component: connector
|
|
654
|
+
});
|
|
655
|
+
blobStorageModels.BlobStorageConnectorFactory.register(finalInstanceType, () => connector);
|
|
656
|
+
return finalInstanceType;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Initialise the blob storage component.
|
|
660
|
+
* @param engineCore The engine core.
|
|
661
|
+
* @param context The context for the engine.
|
|
662
|
+
* @param instanceConfig The instance config.
|
|
663
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
664
|
+
* @returns The name of the instance created.
|
|
665
|
+
* @throws GeneralError if the component type is unknown.
|
|
666
|
+
*/
|
|
667
|
+
function initialiseBlobStorageComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
668
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
669
|
+
element: `Blob Storage Component: ${instanceConfig.type}`
|
|
670
|
+
}));
|
|
671
|
+
const type = instanceConfig.type;
|
|
672
|
+
let component;
|
|
673
|
+
let instanceType;
|
|
674
|
+
if (type === BlobStorageComponentType.Service) {
|
|
675
|
+
blobStorageService.initSchema();
|
|
676
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.entryEntityStorageType, "BlobStorageEntry");
|
|
677
|
+
component = new blobStorageService.BlobStorageService({
|
|
678
|
+
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
679
|
+
...instanceConfig.options
|
|
680
|
+
});
|
|
681
|
+
instanceType = blobStorageService.BlobStorageService.NAMESPACE;
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
685
|
+
type,
|
|
686
|
+
componentType: "blobStorageComponent"
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
690
|
+
context.componentInstances.push({
|
|
691
|
+
instanceType: finalInstanceType,
|
|
692
|
+
component
|
|
693
|
+
});
|
|
694
|
+
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
695
|
+
return finalInstanceType;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// Copyright 2024 IOTA Stiftung.
|
|
699
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
700
|
+
/**
|
|
701
|
+
* Faucet connector types.
|
|
702
|
+
*/
|
|
703
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
704
|
+
const FaucetConnectorType = {
|
|
705
|
+
/**
|
|
706
|
+
* Entity storage.
|
|
707
|
+
*/
|
|
708
|
+
EntityStorage: "entity-storage",
|
|
709
|
+
/**
|
|
710
|
+
* IOTA.
|
|
711
|
+
*/
|
|
712
|
+
Iota: "iota"
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
// Copyright 2024 IOTA Stiftung.
|
|
716
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
717
|
+
/**
|
|
718
|
+
* Initialise a faucet connector.
|
|
719
|
+
* @param engineCore The engine core.
|
|
720
|
+
* @param context The context for the engine.
|
|
721
|
+
* @param instanceConfig The instance config.
|
|
722
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
723
|
+
* @returns The name of the instance created.
|
|
724
|
+
* @throws GeneralError if the connector type is unknown.
|
|
725
|
+
*/
|
|
726
|
+
function initialiseFaucetConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
727
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
728
|
+
element: `Faucet Connector: ${instanceConfig.type}`
|
|
729
|
+
}));
|
|
730
|
+
const type = instanceConfig.type;
|
|
731
|
+
let connector;
|
|
732
|
+
let instanceType;
|
|
733
|
+
if (type === FaucetConnectorType.Iota) {
|
|
734
|
+
const dltConfig = context.config.types.dltConfig?.find(dlt => dlt.type === context.defaultTypes.dltConfig);
|
|
735
|
+
connector = new walletConnectorIota.IotaFaucetConnector({
|
|
736
|
+
...instanceConfig.options,
|
|
737
|
+
config: {
|
|
738
|
+
...dltConfig?.options?.config,
|
|
739
|
+
...instanceConfig.options.config
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
instanceType = walletConnectorIota.IotaFaucetConnector.NAMESPACE;
|
|
743
|
+
}
|
|
744
|
+
else if (type === FaucetConnectorType.EntityStorage) {
|
|
745
|
+
connector = new walletConnectorEntityStorage.EntityStorageFaucetConnector(instanceConfig.options);
|
|
746
|
+
instanceType = walletConnectorEntityStorage.EntityStorageFaucetConnector.NAMESPACE;
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
750
|
+
type,
|
|
751
|
+
connectorType: "faucetConnector"
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
755
|
+
context.componentInstances.push({
|
|
756
|
+
instanceType: finalInstanceType,
|
|
757
|
+
component: connector
|
|
758
|
+
});
|
|
759
|
+
walletModels.FaucetConnectorFactory.register(finalInstanceType, () => connector);
|
|
760
|
+
return finalInstanceType;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// Copyright 2024 IOTA Stiftung.
|
|
764
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
765
|
+
/**
|
|
766
|
+
* Identity component types.
|
|
767
|
+
*/
|
|
768
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
769
|
+
const IdentityComponentType = {
|
|
770
|
+
/**
|
|
771
|
+
* Service.
|
|
772
|
+
*/
|
|
773
|
+
Service: "service"
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
// Copyright 2024 IOTA Stiftung.
|
|
777
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
778
|
+
/**
|
|
779
|
+
* Identity connector types.
|
|
780
|
+
*/
|
|
781
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
782
|
+
const IdentityConnectorType = {
|
|
783
|
+
/**
|
|
784
|
+
* Entity storage.
|
|
785
|
+
*/
|
|
786
|
+
EntityStorage: "entity-storage",
|
|
787
|
+
/**
|
|
788
|
+
* IOTA.
|
|
789
|
+
*/
|
|
790
|
+
Iota: "iota"
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
// Copyright 2024 IOTA Stiftung.
|
|
794
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
795
|
+
/**
|
|
796
|
+
* Initialise the identity connector.
|
|
797
|
+
* @param engineCore The engine core.
|
|
798
|
+
* @param context The context for the engine.
|
|
799
|
+
* @param instanceConfig The instance config.
|
|
800
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
801
|
+
* @returns The name of the instance created.
|
|
802
|
+
* @throws GeneralError if the connector type is unknown.
|
|
803
|
+
*/
|
|
804
|
+
function initialiseIdentityConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
805
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
806
|
+
element: `Identity Connector: ${instanceConfig.type}`
|
|
807
|
+
}));
|
|
808
|
+
const type = instanceConfig.type;
|
|
809
|
+
let connector;
|
|
810
|
+
let instanceType;
|
|
811
|
+
if (type === IdentityConnectorType.Iota) {
|
|
812
|
+
const dltConfig = context.config.types.dltConfig?.find(dlt => dlt.type === context.defaultTypes.dltConfig);
|
|
813
|
+
connector = new identityConnectorIota.IotaIdentityConnector({
|
|
814
|
+
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
815
|
+
...instanceConfig.options,
|
|
816
|
+
config: {
|
|
817
|
+
...dltConfig?.options?.config,
|
|
818
|
+
...instanceConfig.options.config
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
instanceType = identityConnectorIota.IotaIdentityConnector.NAMESPACE;
|
|
822
|
+
}
|
|
823
|
+
else if (type === IdentityConnectorType.EntityStorage) {
|
|
824
|
+
identityConnectorEntityStorage.initSchema({ includeProfile: false });
|
|
825
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.didDocumentEntityStorageType, "IdentityDocument");
|
|
826
|
+
connector = new identityConnectorEntityStorage.EntityStorageIdentityConnector({
|
|
827
|
+
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
828
|
+
...instanceConfig.options
|
|
829
|
+
});
|
|
830
|
+
instanceType = identityConnectorEntityStorage.EntityStorageIdentityConnector.NAMESPACE;
|
|
831
|
+
}
|
|
832
|
+
else {
|
|
833
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
834
|
+
type,
|
|
835
|
+
connectorType: "identityConnector"
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
839
|
+
context.componentInstances.push({ instanceType: finalInstanceType, component: connector });
|
|
840
|
+
identityModels.IdentityConnectorFactory.register(finalInstanceType, () => connector);
|
|
841
|
+
return finalInstanceType;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Initialise the identity component.
|
|
845
|
+
* @param engineCore The engine core.
|
|
846
|
+
* @param context The context for the engine.
|
|
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 component type is unknown.
|
|
851
|
+
*/
|
|
852
|
+
function initialiseIdentityComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
853
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
854
|
+
element: `Identity Component: ${instanceConfig.type}`
|
|
855
|
+
}));
|
|
856
|
+
const type = instanceConfig.type;
|
|
857
|
+
let component;
|
|
858
|
+
let instanceType;
|
|
859
|
+
if (type === IdentityComponentType.Service) {
|
|
860
|
+
component = new identityService.IdentityService(instanceConfig.options);
|
|
861
|
+
instanceType = identityService.IdentityService.NAMESPACE;
|
|
862
|
+
}
|
|
863
|
+
else {
|
|
864
|
+
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
865
|
+
type,
|
|
866
|
+
componentType: "identityComponent"
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
870
|
+
context.componentInstances.push({ instanceType: finalInstanceType, component });
|
|
871
|
+
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
872
|
+
return finalInstanceType;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
// Copyright 2024 IOTA Stiftung.
|
|
876
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
877
|
+
/**
|
|
878
|
+
* Identity profile component types.
|
|
879
|
+
*/
|
|
880
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
881
|
+
const IdentityProfileComponentType = {
|
|
882
|
+
/**
|
|
883
|
+
* Service.
|
|
884
|
+
*/
|
|
885
|
+
Service: "service"
|
|
886
|
+
};
|
|
887
|
+
|
|
888
|
+
// Copyright 2024 IOTA Stiftung.
|
|
889
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
890
|
+
/**
|
|
891
|
+
* Identity profile connector types.
|
|
892
|
+
*/
|
|
893
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
894
|
+
const IdentityProfileConnectorType = {
|
|
895
|
+
/**
|
|
896
|
+
* Entity storage.
|
|
897
|
+
*/
|
|
898
|
+
EntityStorage: "entity-storage"
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
// Copyright 2024 IOTA Stiftung.
|
|
902
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
903
|
+
/**
|
|
904
|
+
* Initialise the identity profile connector.
|
|
905
|
+
* @param engineCore The engine core.
|
|
906
|
+
* @param context The context for the engine.
|
|
907
|
+
* @param instanceConfig The instance config.
|
|
908
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
909
|
+
* @returns The name of the instance created.
|
|
910
|
+
* @throws GeneralError if the connector type is unknown.
|
|
911
|
+
*/
|
|
912
|
+
function initialiseIdentityProfileConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
913
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
914
|
+
element: `Identity Profile Connector: ${instanceConfig.type}`
|
|
915
|
+
}));
|
|
916
|
+
const type = instanceConfig.type;
|
|
917
|
+
let connector;
|
|
918
|
+
let instanceType;
|
|
919
|
+
if (type === IdentityProfileConnectorType.EntityStorage) {
|
|
920
|
+
identityConnectorEntityStorage.initSchema({ includeDocument: false });
|
|
921
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.profileEntityStorageType, "IdentityProfile");
|
|
922
|
+
connector = new identityConnectorEntityStorage.EntityStorageIdentityProfileConnector(instanceConfig.options);
|
|
923
|
+
instanceType = identityConnectorEntityStorage.EntityStorageIdentityProfileConnector.NAMESPACE;
|
|
924
|
+
}
|
|
925
|
+
else {
|
|
926
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
927
|
+
type,
|
|
928
|
+
serviceType: "identityProfile"
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
932
|
+
context.componentInstances.push({
|
|
933
|
+
instanceType: finalInstanceType,
|
|
934
|
+
component: connector
|
|
935
|
+
});
|
|
936
|
+
identityModels.IdentityProfileConnectorFactory.register(finalInstanceType, () => connector);
|
|
937
|
+
return finalInstanceType;
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Initialise the identity profile component.
|
|
941
|
+
* @param engineCore The engine core.
|
|
942
|
+
* @param context The context for the engine.
|
|
943
|
+
* @param instanceConfig The instance config.
|
|
944
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
945
|
+
* @returns The name of the instance created.
|
|
946
|
+
* @throws GeneralError if the component type is unknown.
|
|
947
|
+
*/
|
|
948
|
+
function initialiseIdentityProfileComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
949
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
950
|
+
element: `Identity Profile Component: ${instanceConfig.type}`
|
|
951
|
+
}));
|
|
952
|
+
const type = instanceConfig.type;
|
|
953
|
+
let component;
|
|
954
|
+
let instanceType;
|
|
955
|
+
if (type === IdentityProfileComponentType.Service) {
|
|
956
|
+
component = new identityService.IdentityProfileService({
|
|
957
|
+
profileEntityConnectorType: context.defaultTypes.identityProfileConnector,
|
|
958
|
+
...instanceConfig.options
|
|
959
|
+
});
|
|
960
|
+
instanceType = identityService.IdentityProfileService.NAMESPACE;
|
|
961
|
+
}
|
|
962
|
+
else {
|
|
963
|
+
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
964
|
+
type,
|
|
965
|
+
componentType: "identityProfileComponent"
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
969
|
+
context.componentInstances.push({
|
|
970
|
+
instanceType: finalInstanceType,
|
|
971
|
+
component
|
|
972
|
+
});
|
|
973
|
+
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
974
|
+
return finalInstanceType;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// Copyright 2024 IOTA Stiftung.
|
|
978
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
979
|
+
/**
|
|
980
|
+
* Immutable proof component types.
|
|
981
|
+
*/
|
|
982
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
983
|
+
const ImmutableProofComponentType = {
|
|
984
|
+
/**
|
|
985
|
+
* Service.
|
|
986
|
+
*/
|
|
987
|
+
Service: "service"
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
// Copyright 2024 IOTA Stiftung.
|
|
991
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
992
|
+
/**
|
|
993
|
+
* Initialise the immutable proof component.
|
|
994
|
+
* @param engineCore The engine core.
|
|
995
|
+
* @param context The context for the engine.
|
|
996
|
+
* @param instanceConfig The instance config.
|
|
997
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
998
|
+
* @returns The name of the instance created.
|
|
999
|
+
* @throws GeneralError if the component type is unknown.
|
|
1000
|
+
*/
|
|
1001
|
+
function initialiseImmutableProofComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1002
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1003
|
+
element: `Immutable Proof Component: ${instanceConfig.type}`
|
|
1004
|
+
}));
|
|
1005
|
+
const type = instanceConfig.type;
|
|
1006
|
+
let component;
|
|
1007
|
+
let instanceType;
|
|
1008
|
+
if (type === ImmutableProofComponentType.Service) {
|
|
1009
|
+
immutableProofService.initSchema();
|
|
1010
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.immutableProofEntityStorageType, "ImmutableProof");
|
|
1011
|
+
component = new immutableProofService.ImmutableProofService({
|
|
1012
|
+
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
1013
|
+
immutableStorageType: context.defaultTypes.immutableStorageConnector,
|
|
1014
|
+
identityConnectorType: context.defaultTypes.identityConnector,
|
|
1015
|
+
backgroundTaskConnectorType: context.defaultTypes.backgroundTaskConnector,
|
|
1016
|
+
...instanceConfig.options
|
|
1017
|
+
});
|
|
1018
|
+
instanceType = immutableProofService.ImmutableProofService.NAMESPACE;
|
|
1019
|
+
}
|
|
1020
|
+
else {
|
|
1021
|
+
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
1022
|
+
type,
|
|
1023
|
+
componentType: "immutableProofComponent"
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1027
|
+
context.componentInstances.push({
|
|
1028
|
+
instanceType: finalInstanceType,
|
|
1029
|
+
component
|
|
1030
|
+
});
|
|
1031
|
+
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
1032
|
+
return finalInstanceType;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1036
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1037
|
+
/**
|
|
1038
|
+
* Immutable storage connector types.
|
|
1039
|
+
*/
|
|
1040
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1041
|
+
const ImmutableStorageConnectorType = {
|
|
1042
|
+
/**
|
|
1043
|
+
* Entity storage.
|
|
1044
|
+
*/
|
|
1045
|
+
EntityStorage: "entity-storage",
|
|
1046
|
+
/**
|
|
1047
|
+
* IOTA.
|
|
1048
|
+
*/
|
|
1049
|
+
Iota: "iota"
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1053
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1054
|
+
/**
|
|
1055
|
+
* Initialise the immutable storage connector.
|
|
1056
|
+
* @param engineCore The engine core.
|
|
1057
|
+
* @param context The context for the engine.
|
|
1058
|
+
* @param instanceConfig The instance config.
|
|
1059
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
1060
|
+
* @returns The name of the instance created.
|
|
1061
|
+
* @throws GeneralError if the connector type is unknown.
|
|
1062
|
+
*/
|
|
1063
|
+
function initialiseImmutableStorageConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1064
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1065
|
+
element: `Immutable Storage Connector: ${instanceConfig.type}`
|
|
1066
|
+
}));
|
|
1067
|
+
const type = instanceConfig.type;
|
|
1068
|
+
let connector;
|
|
1069
|
+
let instanceType;
|
|
1070
|
+
if (type === ImmutableStorageConnectorType.Iota) {
|
|
1071
|
+
const dltConfig = context.config.types.dltConfig?.find(dlt => dlt.type === context.defaultTypes.dltConfig);
|
|
1072
|
+
connector = new immutableStorageConnectorIota.IotaImmutableStorageConnector({
|
|
1073
|
+
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
1074
|
+
...instanceConfig.options,
|
|
1075
|
+
config: {
|
|
1076
|
+
...dltConfig?.options?.config,
|
|
1077
|
+
...instanceConfig.options.config
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
instanceType = immutableStorageConnectorIota.IotaImmutableStorageConnector.NAMESPACE;
|
|
1081
|
+
}
|
|
1082
|
+
else if (type === ImmutableStorageConnectorType.EntityStorage) {
|
|
1083
|
+
immutableStorageConnectorEntityStorage.initSchema();
|
|
1084
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.immutableStorageEntityStorageType, "ImmutableItem");
|
|
1085
|
+
connector = new immutableStorageConnectorEntityStorage.EntityStorageImmutableStorageConnector(instanceConfig.options);
|
|
1086
|
+
instanceType = immutableStorageConnectorEntityStorage.EntityStorageImmutableStorageConnector.NAMESPACE;
|
|
1087
|
+
}
|
|
1088
|
+
else {
|
|
1089
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
1090
|
+
type,
|
|
1091
|
+
connectorType: "immutableStorageConnector"
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1095
|
+
context.componentInstances.push({
|
|
1096
|
+
instanceType: finalInstanceType,
|
|
1097
|
+
component: connector
|
|
1098
|
+
});
|
|
1099
|
+
immutableStorageModels.ImmutableStorageConnectorFactory.register(finalInstanceType, () => connector);
|
|
1100
|
+
return finalInstanceType;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1104
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1105
|
+
/**
|
|
1106
|
+
* Logging component types.
|
|
1107
|
+
*/
|
|
1108
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1109
|
+
const LoggingComponentType = {
|
|
1110
|
+
/**
|
|
1111
|
+
* Service.
|
|
1112
|
+
*/
|
|
1113
|
+
Service: "service"
|
|
1114
|
+
};
|
|
1115
|
+
|
|
1116
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1117
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1118
|
+
/**
|
|
1119
|
+
* Logging connector types.
|
|
1120
|
+
*/
|
|
1121
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1122
|
+
const LoggingConnectorType = {
|
|
1123
|
+
/**
|
|
1124
|
+
* Entity storage.
|
|
1125
|
+
*/
|
|
1126
|
+
EntityStorage: "entity-storage",
|
|
1127
|
+
/**
|
|
1128
|
+
* Console.
|
|
1129
|
+
*/
|
|
1130
|
+
Console: "console",
|
|
1131
|
+
/**
|
|
1132
|
+
* Multi combines other loggers.
|
|
1133
|
+
*/
|
|
1134
|
+
Multi: "multi"
|
|
1135
|
+
};
|
|
1136
|
+
|
|
1137
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1138
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1139
|
+
/**
|
|
1140
|
+
* Initialise the logging connector.
|
|
1141
|
+
* @param engineCore The engine core.
|
|
1142
|
+
* @param context The engine core context.
|
|
1143
|
+
* @param instanceConfig The instance config.
|
|
1144
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
1145
|
+
* @returns The name of the instance created.
|
|
1146
|
+
* @throws GeneralError if the connector type is unknown.
|
|
1147
|
+
*/
|
|
1148
|
+
function initialiseLoggingConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1149
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1150
|
+
element: `Logging Connector: ${instanceConfig.type}`
|
|
1151
|
+
}));
|
|
1152
|
+
const type = instanceConfig.type;
|
|
1153
|
+
let connector;
|
|
1154
|
+
let instanceType;
|
|
1155
|
+
if (type === LoggingConnectorType.Console) {
|
|
1156
|
+
connector = new loggingConnectorConsole.ConsoleLoggingConnector(instanceConfig.options);
|
|
1157
|
+
instanceType = loggingConnectorConsole.ConsoleLoggingConnector.NAMESPACE;
|
|
1158
|
+
}
|
|
1159
|
+
else if (type === LoggingConnectorType.EntityStorage) {
|
|
1160
|
+
loggingConnectorEntityStorage.initSchema();
|
|
1161
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.logEntryStorageConnectorType, "LogEntry");
|
|
1162
|
+
connector = new loggingConnectorEntityStorage.EntityStorageLoggingConnector(instanceConfig.options);
|
|
1163
|
+
instanceType = loggingConnectorEntityStorage.EntityStorageLoggingConnector.NAMESPACE;
|
|
1164
|
+
}
|
|
1165
|
+
else if (type === LoggingConnectorType.Multi) {
|
|
1166
|
+
connector = new loggingModels.MultiLoggingConnector(instanceConfig.options);
|
|
1167
|
+
instanceType = loggingModels.MultiLoggingConnector.NAMESPACE;
|
|
1168
|
+
}
|
|
1169
|
+
else {
|
|
1170
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
1171
|
+
type,
|
|
1172
|
+
connectorType: "loggingConnector"
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1176
|
+
context.componentInstances.push({ instanceType: finalInstanceType, component: connector });
|
|
1177
|
+
loggingModels.LoggingConnectorFactory.register(finalInstanceType, () => connector);
|
|
1178
|
+
return finalInstanceType;
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Initialise the logging component.
|
|
1182
|
+
* @param engineCore The engine core.
|
|
1183
|
+
* @param context The context for the engine.
|
|
1184
|
+
* @param instanceConfig The instance config.
|
|
1185
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
1186
|
+
* @returns The name of the instance created.
|
|
1187
|
+
* @throws GeneralError if the component type is unknown.
|
|
1188
|
+
*/
|
|
1189
|
+
function initialiseLoggingComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1190
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1191
|
+
element: `Logging Component: ${instanceConfig.type}`
|
|
1192
|
+
}));
|
|
1193
|
+
const type = instanceConfig.type;
|
|
1194
|
+
let component;
|
|
1195
|
+
let instanceType;
|
|
1196
|
+
if (type === LoggingComponentType.Service) {
|
|
1197
|
+
component = new loggingService.LoggingService({
|
|
1198
|
+
loggingConnectorType: context.defaultTypes.loggingConnector,
|
|
1199
|
+
...instanceConfig.options
|
|
1200
|
+
});
|
|
1201
|
+
instanceType = loggingService.LoggingService.NAMESPACE;
|
|
1202
|
+
}
|
|
1203
|
+
else {
|
|
1204
|
+
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
1205
|
+
type,
|
|
1206
|
+
componentType: "loggingComponent"
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1210
|
+
context.componentInstances.push({ instanceType: finalInstanceType, component });
|
|
1211
|
+
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
1212
|
+
return finalInstanceType;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1216
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1217
|
+
/**
|
|
1218
|
+
* NFT component types.
|
|
1219
|
+
*/
|
|
1220
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1221
|
+
const NftComponentType = {
|
|
1222
|
+
/**
|
|
1223
|
+
* Service.
|
|
1224
|
+
*/
|
|
1225
|
+
Service: "service"
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1229
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1230
|
+
/**
|
|
1231
|
+
* NFT connector types.
|
|
1232
|
+
*/
|
|
1233
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1234
|
+
const NftConnectorType = {
|
|
1235
|
+
/**
|
|
1236
|
+
* Entity storage.
|
|
1237
|
+
*/
|
|
1238
|
+
EntityStorage: "entity-storage",
|
|
1239
|
+
/**
|
|
1240
|
+
* IOTA.
|
|
1241
|
+
*/
|
|
1242
|
+
Iota: "iota"
|
|
1243
|
+
};
|
|
1244
|
+
|
|
1245
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1246
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1247
|
+
/**
|
|
1248
|
+
* Initialise the NFT connector.
|
|
1249
|
+
* @param engineCore The engine core.
|
|
1250
|
+
* @param context The context for the engine.
|
|
1251
|
+
* @param instanceConfig The instance config.
|
|
1252
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
1253
|
+
* @returns The name of the instance created.
|
|
1254
|
+
* @throws GeneralError if the connector type is unknown.
|
|
1255
|
+
*/
|
|
1256
|
+
function initialiseNftConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1257
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1258
|
+
element: `NFT Connector: ${instanceConfig.type}`
|
|
1259
|
+
}));
|
|
1260
|
+
const type = instanceConfig.type;
|
|
1261
|
+
let connector;
|
|
1262
|
+
let instanceType;
|
|
1263
|
+
if (type === NftConnectorType.EntityStorage) {
|
|
1264
|
+
nftConnectorEntityStorage.initSchema();
|
|
1265
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.nftEntityStorageType, "Nft");
|
|
1266
|
+
connector = new nftConnectorEntityStorage.EntityStorageNftConnector(instanceConfig.options);
|
|
1267
|
+
instanceType = nftConnectorEntityStorage.EntityStorageNftConnector.NAMESPACE;
|
|
1268
|
+
}
|
|
1269
|
+
else if (type === NftConnectorType.Iota) {
|
|
1270
|
+
connector = new nftConnectorIota.IotaNftConnector({
|
|
1271
|
+
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
1272
|
+
...instanceConfig.options
|
|
1273
|
+
});
|
|
1274
|
+
instanceType = nftConnectorIota.IotaNftConnector.NAMESPACE;
|
|
1275
|
+
}
|
|
1276
|
+
else {
|
|
1277
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
1278
|
+
type,
|
|
1279
|
+
connectorType: "nftConnector"
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1283
|
+
context.componentInstances.push({
|
|
1284
|
+
instanceType: finalInstanceType,
|
|
1285
|
+
component: connector
|
|
1286
|
+
});
|
|
1287
|
+
nftModels.NftConnectorFactory.register(finalInstanceType, () => connector);
|
|
1288
|
+
return finalInstanceType;
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Initialise the NFT component.
|
|
1292
|
+
* @param engineCore The engine core.
|
|
1293
|
+
* @param context The context for the engine.
|
|
1294
|
+
* @param instanceConfig The instance config.
|
|
1295
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
1296
|
+
* @returns The name of the instance created.
|
|
1297
|
+
* @throws GeneralError if the component type is unknown.
|
|
1298
|
+
*/
|
|
1299
|
+
function initialiseNftComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1300
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1301
|
+
element: `Nft Storage Component: ${instanceConfig.type}`
|
|
1302
|
+
}));
|
|
1303
|
+
const type = instanceConfig.type;
|
|
1304
|
+
let component;
|
|
1305
|
+
let instanceType;
|
|
1306
|
+
if (type === NftComponentType.Service) {
|
|
1307
|
+
component = new nftService.NftService(instanceConfig.options);
|
|
1308
|
+
instanceType = nftService.NftService.NAMESPACE;
|
|
1309
|
+
}
|
|
1310
|
+
else {
|
|
1311
|
+
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
1312
|
+
type,
|
|
1313
|
+
componentType: "nftComponent"
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1317
|
+
context.componentInstances.push({
|
|
1318
|
+
instanceType: finalInstanceType,
|
|
1319
|
+
component
|
|
1320
|
+
});
|
|
1321
|
+
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
1322
|
+
return finalInstanceType;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1326
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1327
|
+
/**
|
|
1328
|
+
* Telemetry component types.
|
|
1329
|
+
*/
|
|
1330
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1331
|
+
const TelemetryComponentType = {
|
|
1332
|
+
/**
|
|
1333
|
+
* Service.
|
|
1334
|
+
*/
|
|
1335
|
+
Service: "service"
|
|
1336
|
+
};
|
|
1337
|
+
|
|
1338
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1339
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1340
|
+
/**
|
|
1341
|
+
* Telemetry connector types.
|
|
1342
|
+
*/
|
|
1343
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1344
|
+
const TelemetryConnectorType = {
|
|
1345
|
+
/**
|
|
1346
|
+
* Entity storage.
|
|
1347
|
+
*/
|
|
1348
|
+
EntityStorage: "entity-storage"
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1352
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1353
|
+
/**
|
|
1354
|
+
* Initialise a telemetry connector.
|
|
1355
|
+
* @param engineCore The engine core.
|
|
1356
|
+
* @param context The context for the engine.
|
|
1357
|
+
* @param instanceConfig The instance config.
|
|
1358
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
1359
|
+
* @returns The name of the instance created.
|
|
1360
|
+
* @throws GeneralError if the connector type is unknown.
|
|
1361
|
+
*/
|
|
1362
|
+
function initialiseTelemetryConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1363
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1364
|
+
element: `Telemetry Connector: ${instanceConfig.type}`
|
|
1365
|
+
}));
|
|
1366
|
+
const type = instanceConfig.type;
|
|
1367
|
+
let connector;
|
|
1368
|
+
let instanceType;
|
|
1369
|
+
if (type === TelemetryConnectorType.EntityStorage) {
|
|
1370
|
+
telemetryConnectorEntityStorage.initSchema();
|
|
1371
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.telemetryMetricStorageConnectorType, "TelemetryMetric");
|
|
1372
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.telemetryMetricValueStorageConnectorType, "TelemetryMetricValue");
|
|
1373
|
+
connector = new telemetryConnectorEntityStorage.EntityStorageTelemetryConnector({
|
|
1374
|
+
loggingConnectorType: context.defaultTypes.loggingConnector,
|
|
1375
|
+
...instanceConfig.options
|
|
1376
|
+
});
|
|
1377
|
+
instanceType = telemetryConnectorEntityStorage.EntityStorageTelemetryConnector.NAMESPACE;
|
|
1378
|
+
}
|
|
1379
|
+
else {
|
|
1380
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
1381
|
+
type,
|
|
1382
|
+
connectorType: "telemetryConnector"
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1386
|
+
context.componentInstances.push({ instanceType: finalInstanceType, component: connector });
|
|
1387
|
+
telemetryModels.TelemetryConnectorFactory.register(finalInstanceType, () => connector);
|
|
1388
|
+
return finalInstanceType;
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Initialise the telemetry component.
|
|
1392
|
+
* @param engineCore The engine core.
|
|
1393
|
+
* @param context The context for the engine.
|
|
1394
|
+
* @param instanceConfig The instance config.
|
|
1395
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
1396
|
+
* @returns The name of the instance created.
|
|
1397
|
+
* @throws GeneralError if the component type is unknown.
|
|
1398
|
+
*/
|
|
1399
|
+
function initialiseTelemetryComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1400
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1401
|
+
element: `Telemetry Component: ${instanceConfig.type}`
|
|
1402
|
+
}));
|
|
1403
|
+
const type = instanceConfig.type;
|
|
1404
|
+
let component;
|
|
1405
|
+
let instanceType;
|
|
1406
|
+
if (type === TelemetryComponentType.Service) {
|
|
1407
|
+
component = new telemetryService.TelemetryService({
|
|
1408
|
+
telemetryConnectorType: context.defaultTypes.telemetryConnector,
|
|
1409
|
+
...instanceConfig.options
|
|
1410
|
+
});
|
|
1411
|
+
instanceType = telemetryService.TelemetryService.NAMESPACE;
|
|
1412
|
+
}
|
|
1413
|
+
else {
|
|
1414
|
+
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
1415
|
+
type,
|
|
1416
|
+
componentType: "telemetryComponent"
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1420
|
+
context.componentInstances.push({ instanceType: finalInstanceType, component });
|
|
1421
|
+
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
1422
|
+
return finalInstanceType;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1426
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1427
|
+
/**
|
|
1428
|
+
* Vault connector types.
|
|
1429
|
+
*/
|
|
1430
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1431
|
+
const VaultConnectorType = {
|
|
1432
|
+
/**
|
|
1433
|
+
* Entity storage.
|
|
1434
|
+
*/
|
|
1435
|
+
EntityStorage: "entity-storage",
|
|
1436
|
+
/**
|
|
1437
|
+
* Hashicorp.
|
|
1438
|
+
*/
|
|
1439
|
+
Hashicorp: "hashicorp"
|
|
1440
|
+
};
|
|
1441
|
+
|
|
1442
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1443
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1444
|
+
/**
|
|
1445
|
+
* Initialise the vault connector.
|
|
1446
|
+
* @param engineCore The engine core.
|
|
1447
|
+
* @param context The context for the engine.
|
|
1448
|
+
* @param instanceConfig The instance config.
|
|
1449
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
1450
|
+
* @returns The name of the instance created.
|
|
1451
|
+
* @throws GeneralError if the connector type is unknown.
|
|
1452
|
+
*/
|
|
1453
|
+
function initialiseVaultConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1454
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1455
|
+
element: `Vault Connector: ${instanceConfig.type}`
|
|
1456
|
+
}));
|
|
1457
|
+
const type = instanceConfig.type;
|
|
1458
|
+
let connector;
|
|
1459
|
+
let instanceType;
|
|
1460
|
+
if (type === VaultConnectorType.EntityStorage) {
|
|
1461
|
+
vaultConnectorEntityStorage.initSchema();
|
|
1462
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.vaultKeyEntityStorageType, "VaultKey");
|
|
1463
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.vaultSecretEntityStorageType, "VaultSecret");
|
|
1464
|
+
connector = new vaultConnectorEntityStorage.EntityStorageVaultConnector(instanceConfig.options);
|
|
1465
|
+
instanceType = vaultConnectorEntityStorage.EntityStorageVaultConnector.NAMESPACE;
|
|
1466
|
+
}
|
|
1467
|
+
else if (type === VaultConnectorType.Hashicorp) {
|
|
1468
|
+
connector = new vaultConnectorHashicorp.HashicorpVaultConnector(instanceConfig.options);
|
|
1469
|
+
instanceType = vaultConnectorHashicorp.HashicorpVaultConnector.NAMESPACE;
|
|
1470
|
+
}
|
|
1471
|
+
else {
|
|
1472
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
1473
|
+
type,
|
|
1474
|
+
connectorType: "vaultConnector"
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1477
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1478
|
+
context.componentInstances.push({ instanceType: finalInstanceType, component: connector });
|
|
1479
|
+
vaultModels.VaultConnectorFactory.register(finalInstanceType, () => connector);
|
|
1480
|
+
return finalInstanceType;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1484
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1485
|
+
/**
|
|
1486
|
+
* Wallet connector types.
|
|
1487
|
+
*/
|
|
1488
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1489
|
+
const WalletConnectorType = {
|
|
1490
|
+
/**
|
|
1491
|
+
* Entity storage.
|
|
1492
|
+
*/
|
|
1493
|
+
EntityStorage: "entity-storage",
|
|
1494
|
+
/**
|
|
1495
|
+
* IOTA.
|
|
1496
|
+
*/
|
|
1497
|
+
Iota: "iota"
|
|
1498
|
+
};
|
|
1499
|
+
|
|
1500
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1501
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1502
|
+
/**
|
|
1503
|
+
* Initialise a wallet connector.
|
|
1504
|
+
* @param engineCore The engine core.
|
|
1505
|
+
* @param context The context for the node.
|
|
1506
|
+
* @param instanceConfig The instance config.
|
|
1507
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
1508
|
+
* @returns The name of the instance created.
|
|
1509
|
+
* @throws GeneralError if the connector type is unknown.
|
|
1510
|
+
*/
|
|
1511
|
+
function initialiseWalletConnector(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1512
|
+
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
1513
|
+
element: `Wallet Connector: ${instanceConfig.type}`
|
|
1514
|
+
}));
|
|
1515
|
+
const type = instanceConfig.type;
|
|
1516
|
+
let connector;
|
|
1517
|
+
let instanceType;
|
|
1518
|
+
if (type === WalletConnectorType.Iota) {
|
|
1519
|
+
const dltConfig = context.config.types.dltConfig?.find(dlt => dlt.type === context.defaultTypes.dltConfig);
|
|
1520
|
+
connector = new walletConnectorIota.IotaWalletConnector({
|
|
1521
|
+
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
1522
|
+
faucetConnectorType: context.defaultTypes.faucetConnector,
|
|
1523
|
+
...instanceConfig.options,
|
|
1524
|
+
config: {
|
|
1525
|
+
...dltConfig?.options?.config,
|
|
1526
|
+
...instanceConfig.options.config
|
|
1527
|
+
}
|
|
1528
|
+
});
|
|
1529
|
+
instanceType = walletConnectorIota.IotaWalletConnector.NAMESPACE;
|
|
1530
|
+
}
|
|
1531
|
+
else if (type === WalletConnectorType.EntityStorage) {
|
|
1532
|
+
connector = new walletConnectorEntityStorage.EntityStorageWalletConnector({
|
|
1533
|
+
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
1534
|
+
faucetConnectorType: context.defaultTypes.faucetConnector,
|
|
1535
|
+
...instanceConfig.options
|
|
1536
|
+
});
|
|
1537
|
+
instanceType = walletConnectorEntityStorage.EntityStorageWalletConnector.NAMESPACE;
|
|
1538
|
+
}
|
|
1539
|
+
else {
|
|
1540
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
1541
|
+
type,
|
|
1542
|
+
connectorType: "walletConnector"
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
1546
|
+
context.componentInstances.push({
|
|
1547
|
+
instanceType: finalInstanceType,
|
|
1548
|
+
component: connector
|
|
1549
|
+
});
|
|
1550
|
+
walletModels.WalletConnectorFactory.register(finalInstanceType, () => connector);
|
|
1551
|
+
return finalInstanceType;
|
|
1552
|
+
}
|
|
1553
|
+
/**
|
|
1554
|
+
* Initialise the wallet storage.
|
|
1555
|
+
* @param engineCore The engine core.
|
|
1556
|
+
* @param context The context for the engine.
|
|
1557
|
+
* @param instanceConfig The instance config.
|
|
1558
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
1559
|
+
* @returns Nothing.
|
|
1560
|
+
* @throws GeneralError if the connector type is unknown.
|
|
1561
|
+
*/
|
|
1562
|
+
function initialiseWalletStorage(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
1563
|
+
const type = instanceConfig.type;
|
|
1564
|
+
if (type === WalletConnectorType.Iota) ;
|
|
1565
|
+
else if (type === WalletConnectorType.EntityStorage) {
|
|
1566
|
+
walletConnectorEntityStorage.initSchema();
|
|
1567
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.walletAddressEntityStorageType, "WalletAddress");
|
|
1568
|
+
}
|
|
1569
|
+
else {
|
|
1570
|
+
throw new core.GeneralError("engineCore", "connectorUnknownType", {
|
|
1571
|
+
type,
|
|
1572
|
+
connectorType: "walletConnector"
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
return undefined;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
// Copyright 2024 IOTA Stiftung.
|
|
1579
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1580
|
+
/**
|
|
1581
|
+
* DLT config types.
|
|
1582
|
+
*/
|
|
1583
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1584
|
+
const DltConfigType = {
|
|
1585
|
+
/**
|
|
1586
|
+
* IOTA.
|
|
1587
|
+
*/
|
|
1588
|
+
Iota: "iota"
|
|
1589
|
+
};
|
|
1590
|
+
|
|
1591
|
+
exports.AttestationComponentType = AttestationComponentType;
|
|
1592
|
+
exports.AttestationConnectorType = AttestationConnectorType;
|
|
1593
|
+
exports.AuditableItemGraphComponentType = AuditableItemGraphComponentType;
|
|
1594
|
+
exports.AuditableItemStreamComponentType = AuditableItemStreamComponentType;
|
|
1595
|
+
exports.BackgroundTaskConnectorType = BackgroundTaskConnectorType;
|
|
1596
|
+
exports.BlobStorageComponentType = BlobStorageComponentType;
|
|
1597
|
+
exports.BlobStorageConnectorType = BlobStorageConnectorType;
|
|
1598
|
+
exports.DltConfigType = DltConfigType;
|
|
1599
|
+
exports.EntityStorageComponentType = EntityStorageComponentType;
|
|
1600
|
+
exports.EntityStorageConnectorType = EntityStorageConnectorType;
|
|
1601
|
+
exports.FaucetConnectorType = FaucetConnectorType;
|
|
1602
|
+
exports.IdentityComponentType = IdentityComponentType;
|
|
1603
|
+
exports.IdentityConnectorType = IdentityConnectorType;
|
|
1604
|
+
exports.IdentityProfileComponentType = IdentityProfileComponentType;
|
|
1605
|
+
exports.IdentityProfileConnectorType = IdentityProfileConnectorType;
|
|
1606
|
+
exports.ImmutableProofComponentType = ImmutableProofComponentType;
|
|
1607
|
+
exports.ImmutableStorageConnectorType = ImmutableStorageConnectorType;
|
|
1608
|
+
exports.LoggingComponentType = LoggingComponentType;
|
|
1609
|
+
exports.LoggingConnectorType = LoggingConnectorType;
|
|
1610
|
+
exports.NftComponentType = NftComponentType;
|
|
1611
|
+
exports.NftConnectorType = NftConnectorType;
|
|
1612
|
+
exports.TelemetryComponentType = TelemetryComponentType;
|
|
1613
|
+
exports.TelemetryConnectorType = TelemetryConnectorType;
|
|
1614
|
+
exports.VaultConnectorType = VaultConnectorType;
|
|
1615
|
+
exports.WalletConnectorType = WalletConnectorType;
|
|
1616
|
+
exports.initialiseAttestationComponent = initialiseAttestationComponent;
|
|
1617
|
+
exports.initialiseAttestationConnector = initialiseAttestationConnector;
|
|
1618
|
+
exports.initialiseAuditableItemGraphComponent = initialiseAuditableItemGraphComponent;
|
|
1619
|
+
exports.initialiseAuditableItemStreamComponent = initialiseAuditableItemStreamComponent;
|
|
1620
|
+
exports.initialiseBackgroundTaskConnector = initialiseBackgroundTaskConnector;
|
|
1621
|
+
exports.initialiseBlobStorageComponent = initialiseBlobStorageComponent;
|
|
1622
|
+
exports.initialiseBlobStorageConnector = initialiseBlobStorageConnector;
|
|
1623
|
+
exports.initialiseEntityStorageComponent = initialiseEntityStorageComponent;
|
|
1624
|
+
exports.initialiseEntityStorageConnector = initialiseEntityStorageConnector;
|
|
1625
|
+
exports.initialiseFaucetConnector = initialiseFaucetConnector;
|
|
1626
|
+
exports.initialiseIdentityComponent = initialiseIdentityComponent;
|
|
1627
|
+
exports.initialiseIdentityConnector = initialiseIdentityConnector;
|
|
1628
|
+
exports.initialiseIdentityProfileComponent = initialiseIdentityProfileComponent;
|
|
1629
|
+
exports.initialiseIdentityProfileConnector = initialiseIdentityProfileConnector;
|
|
1630
|
+
exports.initialiseImmutableProofComponent = initialiseImmutableProofComponent;
|
|
1631
|
+
exports.initialiseImmutableStorageConnector = initialiseImmutableStorageConnector;
|
|
1632
|
+
exports.initialiseLoggingComponent = initialiseLoggingComponent;
|
|
1633
|
+
exports.initialiseLoggingConnector = initialiseLoggingConnector;
|
|
1634
|
+
exports.initialiseNftComponent = initialiseNftComponent;
|
|
1635
|
+
exports.initialiseNftConnector = initialiseNftConnector;
|
|
1636
|
+
exports.initialiseTelemetryComponent = initialiseTelemetryComponent;
|
|
1637
|
+
exports.initialiseTelemetryConnector = initialiseTelemetryConnector;
|
|
1638
|
+
exports.initialiseVaultConnector = initialiseVaultConnector;
|
|
1639
|
+
exports.initialiseWalletConnector = initialiseWalletConnector;
|
|
1640
|
+
exports.initialiseWalletStorage = initialiseWalletStorage;
|