@twin.org/engine-core 0.0.1-next.6 → 0.0.1-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +29 -13
- package/dist/esm/index.mjs +29 -13
- package/dist/types/models/IEngineCoreEnvironmentVariables.d.ts +16 -0
- package/dist/types/utils/envHelper.d.ts +2 -1
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/EnvHelper.md +2 -2
- package/docs/reference/interfaces/IEngineCoreEnvironmentVariables.md +32 -0
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -1673,13 +1673,24 @@ function buildEngineCoreConfiguration(envVars) {
|
|
|
1673
1673
|
envVars.attestationAssertionMethodId ??= "attestation-assertion";
|
|
1674
1674
|
envVars.immutableProofHashKeyId ??= "immutable-proof-hash";
|
|
1675
1675
|
envVars.immutableProofAssertionMethodId ??= "immutable-proof-assertion";
|
|
1676
|
+
envVars.blobStorageEnableEncryption ??= "false";
|
|
1677
|
+
envVars.blobStorageEncryptionKey ??= "blob-encryption";
|
|
1676
1678
|
const coreConfig = {
|
|
1677
1679
|
debug: core.Coerce.boolean(envVars.debug) ?? false,
|
|
1678
1680
|
loggingConnector: [],
|
|
1679
1681
|
loggingComponent: [{ type: engineModels.LoggingComponentType.Service }],
|
|
1680
1682
|
entityStorageConnector: [],
|
|
1681
1683
|
blobStorageConnector: [],
|
|
1682
|
-
blobStorageComponent: [
|
|
1684
|
+
blobStorageComponent: [
|
|
1685
|
+
{
|
|
1686
|
+
type: engineModels.BlobStorageComponentType.Service,
|
|
1687
|
+
options: {
|
|
1688
|
+
config: {
|
|
1689
|
+
vaultKeyId: envVars.blobStorageEncryptionKey
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
],
|
|
1683
1694
|
backgroundTaskConnector: [],
|
|
1684
1695
|
telemetryConnector: [],
|
|
1685
1696
|
telemetryComponent: [{ type: engineModels.TelemetryComponentType.Service }],
|
|
@@ -1735,10 +1746,14 @@ function buildEngineCoreConfiguration(envVars) {
|
|
|
1735
1746
|
*/
|
|
1736
1747
|
function configureEntityStorageConnectors(coreConfig, envVars) {
|
|
1737
1748
|
coreConfig.entityStorageConnector ??= [];
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1749
|
+
if ((core.Coerce.boolean(envVars.entityMemoryEnable) ?? false) ||
|
|
1750
|
+
envVars.blobStorageConnectorType === engineModels.EntityStorageConnectorType.Memory) {
|
|
1751
|
+
coreConfig.entityStorageConnector.push({
|
|
1752
|
+
type: engineModels.EntityStorageConnectorType.Memory
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1755
|
+
if ((core.Coerce.boolean(envVars.entityFileEnable) ?? false) ||
|
|
1756
|
+
envVars.entityStorageConnectorType === engineModels.EntityStorageConnectorType.File) {
|
|
1742
1757
|
coreConfig.entityStorageConnector.push({
|
|
1743
1758
|
type: engineModels.EntityStorageConnectorType.File,
|
|
1744
1759
|
options: { config: { directory: envVars.storageFileRoot } }
|
|
@@ -1815,13 +1830,15 @@ function configureEntityStorageConnectors(coreConfig, envVars) {
|
|
|
1815
1830
|
* @param envVars The environment variables.
|
|
1816
1831
|
*/
|
|
1817
1832
|
function configureBlobStorageConnectors(coreConfig, envVars) {
|
|
1818
|
-
envVars.blobStorageEnableEncryption ??= "false";
|
|
1819
|
-
envVars.blobStorageEncryptionKey ??= "blob-encryption";
|
|
1820
1833
|
coreConfig.blobStorageConnector ??= [];
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1834
|
+
if ((core.Coerce.boolean(envVars.blobMemoryEnable) ?? false) ||
|
|
1835
|
+
envVars.blobStorageConnectorType === engineModels.BlobStorageConnectorType.Memory) {
|
|
1836
|
+
coreConfig.blobStorageConnector.push({
|
|
1837
|
+
type: engineModels.BlobStorageConnectorType.Memory
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
if ((core.Coerce.boolean(envVars.blobFileEnable) ?? false) ||
|
|
1841
|
+
envVars.blobStorageConnectorType === engineModels.BlobStorageConnectorType.File) {
|
|
1825
1842
|
coreConfig.blobStorageConnector.push({
|
|
1826
1843
|
type: engineModels.BlobStorageConnectorType.File,
|
|
1827
1844
|
options: {
|
|
@@ -2145,7 +2162,6 @@ function configureAttestationConnectors(coreConfig, envVars) {
|
|
|
2145
2162
|
|
|
2146
2163
|
// Copyright 2024 IOTA Stiftung.
|
|
2147
2164
|
// SPDX-License-Identifier: Apache-2.0.
|
|
2148
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
2149
2165
|
/**
|
|
2150
2166
|
* Environment variable helper.
|
|
2151
2167
|
*/
|
|
@@ -2156,7 +2172,7 @@ class EnvHelper {
|
|
|
2156
2172
|
* @param prefix The prefix of the environment variables.
|
|
2157
2173
|
* @returns The object with camel cased names.
|
|
2158
2174
|
*/
|
|
2159
|
-
envToJson(envVars, prefix) {
|
|
2175
|
+
static envToJson(envVars, prefix) {
|
|
2160
2176
|
const result = {};
|
|
2161
2177
|
for (const envVar in envVars) {
|
|
2162
2178
|
if (envVar.startsWith(prefix) && core.Is.stringValue(process.env[envVar])) {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1671,13 +1671,24 @@ function buildEngineCoreConfiguration(envVars) {
|
|
|
1671
1671
|
envVars.attestationAssertionMethodId ??= "attestation-assertion";
|
|
1672
1672
|
envVars.immutableProofHashKeyId ??= "immutable-proof-hash";
|
|
1673
1673
|
envVars.immutableProofAssertionMethodId ??= "immutable-proof-assertion";
|
|
1674
|
+
envVars.blobStorageEnableEncryption ??= "false";
|
|
1675
|
+
envVars.blobStorageEncryptionKey ??= "blob-encryption";
|
|
1674
1676
|
const coreConfig = {
|
|
1675
1677
|
debug: Coerce.boolean(envVars.debug) ?? false,
|
|
1676
1678
|
loggingConnector: [],
|
|
1677
1679
|
loggingComponent: [{ type: LoggingComponentType.Service }],
|
|
1678
1680
|
entityStorageConnector: [],
|
|
1679
1681
|
blobStorageConnector: [],
|
|
1680
|
-
blobStorageComponent: [
|
|
1682
|
+
blobStorageComponent: [
|
|
1683
|
+
{
|
|
1684
|
+
type: BlobStorageComponentType.Service,
|
|
1685
|
+
options: {
|
|
1686
|
+
config: {
|
|
1687
|
+
vaultKeyId: envVars.blobStorageEncryptionKey
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
],
|
|
1681
1692
|
backgroundTaskConnector: [],
|
|
1682
1693
|
telemetryConnector: [],
|
|
1683
1694
|
telemetryComponent: [{ type: TelemetryComponentType.Service }],
|
|
@@ -1733,10 +1744,14 @@ function buildEngineCoreConfiguration(envVars) {
|
|
|
1733
1744
|
*/
|
|
1734
1745
|
function configureEntityStorageConnectors(coreConfig, envVars) {
|
|
1735
1746
|
coreConfig.entityStorageConnector ??= [];
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1747
|
+
if ((Coerce.boolean(envVars.entityMemoryEnable) ?? false) ||
|
|
1748
|
+
envVars.blobStorageConnectorType === EntityStorageConnectorType.Memory) {
|
|
1749
|
+
coreConfig.entityStorageConnector.push({
|
|
1750
|
+
type: EntityStorageConnectorType.Memory
|
|
1751
|
+
});
|
|
1752
|
+
}
|
|
1753
|
+
if ((Coerce.boolean(envVars.entityFileEnable) ?? false) ||
|
|
1754
|
+
envVars.entityStorageConnectorType === EntityStorageConnectorType.File) {
|
|
1740
1755
|
coreConfig.entityStorageConnector.push({
|
|
1741
1756
|
type: EntityStorageConnectorType.File,
|
|
1742
1757
|
options: { config: { directory: envVars.storageFileRoot } }
|
|
@@ -1813,13 +1828,15 @@ function configureEntityStorageConnectors(coreConfig, envVars) {
|
|
|
1813
1828
|
* @param envVars The environment variables.
|
|
1814
1829
|
*/
|
|
1815
1830
|
function configureBlobStorageConnectors(coreConfig, envVars) {
|
|
1816
|
-
envVars.blobStorageEnableEncryption ??= "false";
|
|
1817
|
-
envVars.blobStorageEncryptionKey ??= "blob-encryption";
|
|
1818
1831
|
coreConfig.blobStorageConnector ??= [];
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1832
|
+
if ((Coerce.boolean(envVars.blobMemoryEnable) ?? false) ||
|
|
1833
|
+
envVars.blobStorageConnectorType === BlobStorageConnectorType.Memory) {
|
|
1834
|
+
coreConfig.blobStorageConnector.push({
|
|
1835
|
+
type: BlobStorageConnectorType.Memory
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
if ((Coerce.boolean(envVars.blobFileEnable) ?? false) ||
|
|
1839
|
+
envVars.blobStorageConnectorType === BlobStorageConnectorType.File) {
|
|
1823
1840
|
coreConfig.blobStorageConnector.push({
|
|
1824
1841
|
type: BlobStorageConnectorType.File,
|
|
1825
1842
|
options: {
|
|
@@ -2143,7 +2160,6 @@ function configureAttestationConnectors(coreConfig, envVars) {
|
|
|
2143
2160
|
|
|
2144
2161
|
// Copyright 2024 IOTA Stiftung.
|
|
2145
2162
|
// SPDX-License-Identifier: Apache-2.0.
|
|
2146
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
2147
2163
|
/**
|
|
2148
2164
|
* Environment variable helper.
|
|
2149
2165
|
*/
|
|
@@ -2154,7 +2170,7 @@ class EnvHelper {
|
|
|
2154
2170
|
* @param prefix The prefix of the environment variables.
|
|
2155
2171
|
* @returns The object with camel cased names.
|
|
2156
2172
|
*/
|
|
2157
|
-
envToJson(envVars, prefix) {
|
|
2173
|
+
static envToJson(envVars, prefix) {
|
|
2158
2174
|
const result = {};
|
|
2159
2175
|
for (const envVar in envVars) {
|
|
2160
2176
|
if (envVar.startsWith(prefix) && Is.stringValue(process.env[envVar])) {
|
|
@@ -22,6 +22,14 @@ export interface IEngineCoreEnvironmentVariables {
|
|
|
22
22
|
* A prefix for all the table in entity-storage, can be empty.
|
|
23
23
|
*/
|
|
24
24
|
entityStorageTablePrefix: string;
|
|
25
|
+
/**
|
|
26
|
+
* Enable the file entity storage connector.
|
|
27
|
+
*/
|
|
28
|
+
entityFileEnable: string;
|
|
29
|
+
/**
|
|
30
|
+
* Enable the memory entity storage connector.
|
|
31
|
+
*/
|
|
32
|
+
entityMemoryEnable: string;
|
|
25
33
|
/**
|
|
26
34
|
* AWS Dynamo DB access key id.
|
|
27
35
|
*/
|
|
@@ -110,6 +118,14 @@ export interface IEngineCoreEnvironmentVariables {
|
|
|
110
118
|
* A prefix for all the blobs in blob-storage, can be empty.
|
|
111
119
|
*/
|
|
112
120
|
blobStoragePrefix: string;
|
|
121
|
+
/**
|
|
122
|
+
* Enable the file blob storage connector.
|
|
123
|
+
*/
|
|
124
|
+
blobFileEnable: string;
|
|
125
|
+
/**
|
|
126
|
+
* Enable the memory blob storage connector.
|
|
127
|
+
*/
|
|
128
|
+
blobMemoryEnable: string;
|
|
113
129
|
/**
|
|
114
130
|
* AWS S3 access key id.
|
|
115
131
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IEngineCoreEnvironmentVariables } from "../models/IEngineCoreEnvironmentVariables";
|
|
1
2
|
/**
|
|
2
3
|
* Environment variable helper.
|
|
3
4
|
*/
|
|
@@ -8,7 +9,7 @@ export declare class EnvHelper {
|
|
|
8
9
|
* @param prefix The prefix of the environment variables.
|
|
9
10
|
* @returns The object with camel cased names.
|
|
10
11
|
*/
|
|
11
|
-
envToJson<T =
|
|
12
|
+
static envToJson<T = IEngineCoreEnvironmentVariables>(envVars: {
|
|
12
13
|
[id: string]: string | undefined;
|
|
13
14
|
}, prefix: string): T;
|
|
14
15
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -16,13 +16,13 @@ Environment variable helper.
|
|
|
16
16
|
|
|
17
17
|
### envToJson()
|
|
18
18
|
|
|
19
|
-
> **envToJson**\<`T`\>(`envVars`, `prefix`): `T`
|
|
19
|
+
> `static` **envToJson**\<`T`\>(`envVars`, `prefix`): `T`
|
|
20
20
|
|
|
21
21
|
Get the environment variable as an object with camel cased names.
|
|
22
22
|
|
|
23
23
|
#### Type Parameters
|
|
24
24
|
|
|
25
|
-
• **T** = `
|
|
25
|
+
• **T** = [`IEngineCoreEnvironmentVariables`](../interfaces/IEngineCoreEnvironmentVariables.md)
|
|
26
26
|
|
|
27
27
|
#### Parameters
|
|
28
28
|
|
|
@@ -44,6 +44,22 @@ A prefix for all the table in entity-storage, can be empty.
|
|
|
44
44
|
|
|
45
45
|
***
|
|
46
46
|
|
|
47
|
+
### entityFileEnable
|
|
48
|
+
|
|
49
|
+
> **entityFileEnable**: `string`
|
|
50
|
+
|
|
51
|
+
Enable the file entity storage connector.
|
|
52
|
+
|
|
53
|
+
***
|
|
54
|
+
|
|
55
|
+
### entityMemoryEnable
|
|
56
|
+
|
|
57
|
+
> **entityMemoryEnable**: `string`
|
|
58
|
+
|
|
59
|
+
Enable the memory entity storage connector.
|
|
60
|
+
|
|
61
|
+
***
|
|
62
|
+
|
|
47
63
|
### awsDynamodbAccessKeyId
|
|
48
64
|
|
|
49
65
|
> **awsDynamodbAccessKeyId**: `string`
|
|
@@ -220,6 +236,22 @@ A prefix for all the blobs in blob-storage, can be empty.
|
|
|
220
236
|
|
|
221
237
|
***
|
|
222
238
|
|
|
239
|
+
### blobFileEnable
|
|
240
|
+
|
|
241
|
+
> **blobFileEnable**: `string`
|
|
242
|
+
|
|
243
|
+
Enable the file blob storage connector.
|
|
244
|
+
|
|
245
|
+
***
|
|
246
|
+
|
|
247
|
+
### blobMemoryEnable
|
|
248
|
+
|
|
249
|
+
> **blobMemoryEnable**: `string`
|
|
250
|
+
|
|
251
|
+
Enable the memory blob storage connector.
|
|
252
|
+
|
|
253
|
+
***
|
|
254
|
+
|
|
223
255
|
### awsS3AccessKeyId
|
|
224
256
|
|
|
225
257
|
> **awsS3AccessKeyId**: `string`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/engine-core",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.8",
|
|
4
4
|
"description": "Engine implementation for a core.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@twin.org/crypto": "next",
|
|
44
44
|
"@twin.org/data-core": "next",
|
|
45
45
|
"@twin.org/data-schema-org": "next",
|
|
46
|
-
"@twin.org/engine-models": "0.0.1-next.
|
|
46
|
+
"@twin.org/engine-models": "0.0.1-next.8",
|
|
47
47
|
"@twin.org/entity": "next",
|
|
48
48
|
"@twin.org/entity-storage-connector-cosmosdb": "next",
|
|
49
49
|
"@twin.org/entity-storage-connector-dynamodb": "next",
|