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