@twin.org/blob-storage-connector-gcp 0.9.1 → 0.9.2-next.2
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.
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Copyright 2024 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
3
|
import { Storage } from "@google-cloud/storage";
|
|
4
|
+
import { HealthCategory, HealthStatus } from "@twin.org/api-models";
|
|
4
5
|
import { ContextIdHelper, ContextIdStore } from "@twin.org/context";
|
|
5
|
-
import { BaseError, ComponentFactory, Converter, GeneralError, Guards,
|
|
6
|
+
import { BaseError, ComponentFactory, Converter, GeneralError, Guards, Is, ObjectHelper, Urn } from "@twin.org/core";
|
|
6
7
|
import { Sha256 } from "@twin.org/crypto";
|
|
7
8
|
import { MimeTypes } from "@twin.org/web";
|
|
8
9
|
/**
|
|
@@ -64,14 +65,16 @@ export class GcpBlobStorageConnector {
|
|
|
64
65
|
}
|
|
65
66
|
/**
|
|
66
67
|
* Returns the health status of the component.
|
|
68
|
+
* @param lastTimestamp The Unix timestamp (ms) recorded at the start of the previous cycle.
|
|
67
69
|
* @returns The health status of the component.
|
|
68
70
|
*/
|
|
69
|
-
async health() {
|
|
71
|
+
async health(lastTimestamp) {
|
|
70
72
|
try {
|
|
71
73
|
await this._storage.bucket(this._config.bucketName).exists();
|
|
72
74
|
return [
|
|
73
75
|
{
|
|
74
76
|
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
77
|
+
category: HealthCategory.Connectivity,
|
|
75
78
|
status: HealthStatus.Ok,
|
|
76
79
|
description: "healthDescription",
|
|
77
80
|
data: {
|
|
@@ -85,6 +88,7 @@ export class GcpBlobStorageConnector {
|
|
|
85
88
|
return [
|
|
86
89
|
{
|
|
87
90
|
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
91
|
+
category: HealthCategory.Connectivity,
|
|
88
92
|
status: HealthStatus.Error,
|
|
89
93
|
description: "healthDescription",
|
|
90
94
|
message: "healthCheckFailed",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcpBlobStorageConnector.js","sourceRoot":"","sources":["../../src/gcpBlobStorageConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EACN,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,EAAE,EACF,YAAY,EACZ,GAAG,EAEH,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAK1C;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IACnC;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,KAAK,CAAC;IAEjD;;OAEG;IACI,MAAM,CAAU,UAAU,6BAA6C;IAE9E;;;OAGG;IACc,OAAO,CAAiC;IAEzD;;;OAGG;IACc,oBAAoB,CAAY;IAEjD;;;OAGG;IACc,QAAQ,CAAU;IAEnC;;;OAGG;IACH,YAAY,OAAmD;QAC9D,MAAM,CAAC,MAAM,CAAC,uBAAuB,CAAC,UAAU,aAAmB,OAAO,CAAC,CAAC;QAC5E,MAAM,CAAC,MAAM,CACZ,uBAAuB,CAAC,UAAU,oBAElC,OAAO,CAAC,MAAM,CACd,CAAC;QACF,MAAM,CAAC,WAAW,CACjB,uBAAuB,CAAC,UAAU,8BAElC,OAAO,CAAC,MAAM,CAAC,SAAS,CACxB,CAAC;QAEF,IAAI,WAAiC,CAAC;QACtC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;YAC3C,MAAM,CAAC,YAAY,CACl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E,MAAM,IAAI,YAAY,CAAC,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBAC/E,SAAS,EAAE,uBAAuB,CAAC,SAAS;gBAC5C,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACJ,MAAM,GAAG,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;YAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAC7D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,IAAI,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC;YAE7D,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;YACrC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACb,OAAO,KAAK,CAAC;YACd,CAAC;YAED,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC;QACb,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,YAAY,CAAC,uBAAuB,CAAC,UAAU,EAAE,kBAAkB,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;QAC7F,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Storage } from \"@google-cloud/storage\";\nimport type { IBlobStorageConnector } from \"@twin.org/blob-storage-models\";\nimport { ContextIdHelper, ContextIdStore } from \"@twin.org/context\";\nimport {\n\tBaseError,\n\tComponentFactory,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tHealthStatus,\n\tIs,\n\tObjectHelper,\n\tUrn,\n\ttype IHealth\n} from \"@twin.org/core\";\nimport { Sha256 } from \"@twin.org/crypto\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { MimeTypes } from \"@twin.org/web\";\nimport type { JWTInput } from \"google-auth-library\";\nimport type { IGcpBlobStorageConnectorConfig } from \"./models/IGcpBlobStorageConnectorConfig.js\";\nimport type { IGcpBlobStorageConnectorConstructorOptions } from \"./models/IGcpBlobStorageConnectorConstructorOptions.js\";\n\n/**\n * Class for performing blob storage operations on GCP Storage.\n * See https://cloud.google.com/storage/docs/reference/libraries for more information.\n */\nexport class GcpBlobStorageConnector implements IBlobStorageConnector {\n\t/**\n\t * The namespace for the items.\n\t */\n\tpublic static readonly NAMESPACE: string = \"gcp\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<GcpBlobStorageConnector>();\n\n\t/**\n\t * The configuration for the connector.\n\t * @internal\n\t */\n\tprivate readonly _config: IGcpBlobStorageConnectorConfig;\n\n\t/**\n\t * The keys to use from the context ids to create partitions.\n\t * @internal\n\t */\n\tprivate readonly _partitionContextIds?: string[];\n\n\t/**\n\t * The GCP Storage client.\n\t * @internal\n\t */\n\tprivate readonly _storage: Storage;\n\n\t/**\n\t * Create a new instance of GcpBlobStorageConnector.\n\t * @param options The options for the connector.\n\t */\n\tconstructor(options: IGcpBlobStorageConnectorConstructorOptions) {\n\t\tGuards.object(GcpBlobStorageConnector.CLASS_NAME, nameof(options), options);\n\t\tGuards.object<IGcpBlobStorageConnectorConfig>(\n\t\t\tGcpBlobStorageConnector.CLASS_NAME,\n\t\t\tnameof(options.config),\n\t\t\toptions.config\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tGcpBlobStorageConnector.CLASS_NAME,\n\t\t\tnameof(options.config.projectId),\n\t\t\toptions.config.projectId\n\t\t);\n\n\t\tlet credentials: JWTInput | undefined;\n\t\tif (!Is.empty(options.config.credentials)) {\n\t\t\tGuards.stringBase64(\n\t\t\t\tGcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\tnameof(options.config.credentials),\n\t\t\t\toptions.config.credentials\n\t\t\t);\n\t\t\tcredentials = ObjectHelper.fromBytes<JWTInput>(\n\t\t\t\tConverter.base64ToBytes(options.config.credentials)\n\t\t\t);\n\t\t}\n\n\t\tGuards.stringValue(\n\t\t\tGcpBlobStorageConnector.CLASS_NAME,\n\t\t\tnameof(options.config.bucketName),\n\t\t\toptions.config.bucketName\n\t\t);\n\n\t\tthis._config = options.config;\n\t\tthis._partitionContextIds = options.partitionContextIds;\n\t\tthis._storage = new Storage({\n\t\t\tprojectId: this._config.projectId,\n\t\t\tapiEndpoint: this._config.apiEndpoint,\n\t\t\tcredentials\n\t\t});\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn GcpBlobStorageConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Returns the health status of the component.\n\t * @returns The health status of the component.\n\t */\n\tpublic async health(): Promise<IHealth[]> {\n\t\ttry {\n\t\t\tawait this._storage.bucket(this._config.bucketName).exists();\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\t\tstatus: HealthStatus.Ok,\n\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tbucketName: this._config.bucketName,\n\t\t\t\t\t\tprojectId: this._config.projectId\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t];\n\t\t} catch {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\t\tstatus: HealthStatus.Error,\n\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\tmessage: \"healthCheckFailed\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tbucketName: this._config.bucketName,\n\t\t\t\t\t\tprojectId: this._config.projectId\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t];\n\t\t}\n\t}\n\n\t/**\n\t * Bootstrap the component by creating and initializing any resources it needs.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns True if the bootstrapping process was successful.\n\t */\n\tpublic async bootstrap(nodeLoggingComponentType?: string): Promise<boolean> {\n\t\tconst nodeLogging = ComponentFactory.getIfExists<ILoggingComponent>(nodeLoggingComponentType);\n\n\t\ttry {\n\t\t\tconst [buckets] = await this._storage.getBuckets();\n\t\t\tconst bucketExists = buckets.some(bucket => bucket.name === this._config.bucketName);\n\n\t\t\tif (bucketExists) {\n\t\t\t\tawait nodeLogging?.log({\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\t\tmessage: \"bucketExists\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tbucket: this._config.bucketName\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tawait nodeLogging?.log({\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\t\tmessage: \"bucketCreating\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tbucket: this._config.bucketName\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tawait this._storage.createBucket(this._config.bucketName);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tawait nodeLogging?.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\tmessage: \"bucketCreateFailed\",\n\t\t\t\tdata: {\n\t\t\t\t\tbucket: this._config.bucketName\n\t\t\t\t},\n\t\t\t\terror: BaseError.fromError(err)\n\t\t\t});\n\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Set the blob.\n\t * @param blob The data for the blob.\n\t * @returns The id of the stored blob in urn format.\n\t */\n\tpublic async set(blob: Uint8Array): Promise<string> {\n\t\tGuards.uint8Array(GcpBlobStorageConnector.CLASS_NAME, nameof(blob), blob);\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst partitionKey = ContextIdHelper.combinedContextKey(contextIds, this._partitionContextIds);\n\n\t\ttry {\n\t\t\tconst id = Converter.bytesToHex(Sha256.sum256(blob));\n\t\t\tconst bucket = this._storage.bucket(this._config.bucketName);\n\t\t\tconst file = bucket.file(`${partitionKey ?? \"root\"}/${id}`);\n\n\t\t\tawait file.save(blob, {\n\t\t\t\tcontentType: MimeTypes.OctetStream\n\t\t\t});\n\n\t\t\treturn `blob:${new Urn(GcpBlobStorageConnector.NAMESPACE, id).toString()}`;\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(GcpBlobStorageConnector.CLASS_NAME, \"setBlobFailed\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Get the blob.\n\t * @param id The id of the blob to get in urn format.\n\t * @returns The data for the blob if it can be found or undefined.\n\t */\n\tpublic async get(id: string): Promise<Uint8Array | undefined> {\n\t\tUrn.guard(GcpBlobStorageConnector.CLASS_NAME, nameof(id), id);\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst partitionKey = ContextIdHelper.combinedContextKey(contextIds, this._partitionContextIds);\n\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceMethod() !== GcpBlobStorageConnector.NAMESPACE) {\n\t\t\tthrow new GeneralError(GcpBlobStorageConnector.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: GcpBlobStorageConnector.NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst key = urnParsed.namespaceSpecific(1);\n\t\t\tconst bucket = this._storage.bucket(this._config.bucketName);\n\t\t\tconst file = bucket.file(`${partitionKey ?? \"root\"}/${key}`);\n\n\t\t\tconst [exists] = await file.exists();\n\t\t\tif (!exists) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst [contents] = await file.download();\n\t\t\treturn new Uint8Array(contents);\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(GcpBlobStorageConnector.CLASS_NAME, \"getBlobFailed\", { id }, err);\n\t\t}\n\t}\n\n\t/**\n\t * Teardown the component and remove any resources it created.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns True if the teardown process was successful.\n\t */\n\tpublic async teardown(nodeLoggingComponentType?: string): Promise<boolean> {\n\t\tconst nodeLogging = ComponentFactory.getIfExists<ILoggingComponent>(nodeLoggingComponentType);\n\n\t\tawait nodeLogging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\tmessage: \"bucketDeleting\",\n\t\t\tdata: {\n\t\t\t\tbucket: this._config.bucketName\n\t\t\t}\n\t\t});\n\n\t\ttry {\n\t\t\tconst bucket = this._storage.bucket(this._config.bucketName);\n\t\t\tawait bucket.deleteFiles({ force: true });\n\t\t\tawait bucket.delete();\n\n\t\t\tawait nodeLogging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\tmessage: \"bucketDeleted\",\n\t\t\t\tdata: {\n\t\t\t\t\tbucket: this._config.bucketName\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn true;\n\t\t} catch (err) {\n\t\t\tawait nodeLogging?.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\tmessage: \"teardownFailed\",\n\t\t\t\tdata: {\n\t\t\t\t\tbucket: this._config.bucketName\n\t\t\t\t},\n\t\t\t\terror: BaseError.fromError(err)\n\t\t\t});\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Remove all blobs from the storage.\n\t * @returns A promise that resolves when all blobs in the current partition have been removed.\n\t */\n\tpublic async empty(): Promise<void> {\n\t\ttry {\n\t\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\t\tconst partitionKey = ContextIdHelper.combinedContextKey(\n\t\t\t\tcontextIds,\n\t\t\t\tthis._partitionContextIds\n\t\t\t);\n\t\t\tconst prefix = `${partitionKey ?? \"root\"}/`;\n\n\t\t\tconst bucket = this._storage.bucket(this._config.bucketName);\n\t\t\tawait bucket.deleteFiles({ force: true, prefix });\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tGcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\t\"emptyFailed\",\n\t\t\t\t{ bucketName: this._config.bucketName },\n\t\t\t\terr\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove the blob.\n\t * @param id The id of the blob to remove in urn format.\n\t * @returns True if the blob was found.\n\t */\n\tpublic async remove(id: string): Promise<boolean> {\n\t\tUrn.guard(GcpBlobStorageConnector.CLASS_NAME, nameof(id), id);\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst partitionKey = ContextIdHelper.combinedContextKey(contextIds, this._partitionContextIds);\n\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceMethod() !== GcpBlobStorageConnector.NAMESPACE) {\n\t\t\tthrow new GeneralError(GcpBlobStorageConnector.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: GcpBlobStorageConnector.NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst key = urnParsed.namespaceSpecific(1);\n\t\t\tconst bucket = this._storage.bucket(this._config.bucketName);\n\t\t\tconst file = bucket.file(`${partitionKey ?? \"root\"}/${key}`);\n\n\t\t\tconst [exists] = await file.exists();\n\t\t\tif (!exists) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tawait file.delete();\n\t\t\treturn true;\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(GcpBlobStorageConnector.CLASS_NAME, \"removeBlobFailed\", { id }, err);\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"gcpBlobStorageConnector.js","sourceRoot":"","sources":["../../src/gcpBlobStorageConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,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AAE;gBAC/E,SAAS,EAAE,uBAAuB,CAAC,SAAS;gBAC5C,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACJ,MAAM,GAAG,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;YAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAC7D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,IAAI,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC;YAE7D,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;YACrC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACb,OAAO,KAAK,CAAC;YACd,CAAC;YAED,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC;QACb,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,YAAY,CAAC,uBAAuB,CAAC,UAAU,EAAE,kBAAkB,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;QAC7F,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Storage } from \"@google-cloud/storage\";\nimport {\n\tHealthCategory,\n\tHealthStatus,\n\ttype IHealth,\n\ttype IHealthProviderComponent\n} from \"@twin.org/api-models\";\nimport type { IBlobStorageConnector } from \"@twin.org/blob-storage-models\";\nimport { ContextIdHelper, ContextIdStore } from \"@twin.org/context\";\nimport {\n\tBaseError,\n\tComponentFactory,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tObjectHelper,\n\tUrn\n} from \"@twin.org/core\";\nimport { Sha256 } from \"@twin.org/crypto\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { MimeTypes } from \"@twin.org/web\";\nimport type { JWTInput } from \"google-auth-library\";\nimport type { IGcpBlobStorageConnectorConfig } from \"./models/IGcpBlobStorageConnectorConfig.js\";\nimport type { IGcpBlobStorageConnectorConstructorOptions } from \"./models/IGcpBlobStorageConnectorConstructorOptions.js\";\n\n/**\n * Class for performing blob storage operations on GCP Storage.\n * See https://cloud.google.com/storage/docs/reference/libraries for more information.\n */\nexport class GcpBlobStorageConnector implements IBlobStorageConnector, IHealthProviderComponent {\n\t/**\n\t * The namespace for the items.\n\t */\n\tpublic static readonly NAMESPACE: string = \"gcp\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<GcpBlobStorageConnector>();\n\n\t/**\n\t * The configuration for the connector.\n\t * @internal\n\t */\n\tprivate readonly _config: IGcpBlobStorageConnectorConfig;\n\n\t/**\n\t * The keys to use from the context ids to create partitions.\n\t * @internal\n\t */\n\tprivate readonly _partitionContextIds?: string[];\n\n\t/**\n\t * The GCP Storage client.\n\t * @internal\n\t */\n\tprivate readonly _storage: Storage;\n\n\t/**\n\t * Create a new instance of GcpBlobStorageConnector.\n\t * @param options The options for the connector.\n\t */\n\tconstructor(options: IGcpBlobStorageConnectorConstructorOptions) {\n\t\tGuards.object(GcpBlobStorageConnector.CLASS_NAME, nameof(options), options);\n\t\tGuards.object<IGcpBlobStorageConnectorConfig>(\n\t\t\tGcpBlobStorageConnector.CLASS_NAME,\n\t\t\tnameof(options.config),\n\t\t\toptions.config\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tGcpBlobStorageConnector.CLASS_NAME,\n\t\t\tnameof(options.config.projectId),\n\t\t\toptions.config.projectId\n\t\t);\n\n\t\tlet credentials: JWTInput | undefined;\n\t\tif (!Is.empty(options.config.credentials)) {\n\t\t\tGuards.stringBase64(\n\t\t\t\tGcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\tnameof(options.config.credentials),\n\t\t\t\toptions.config.credentials\n\t\t\t);\n\t\t\tcredentials = ObjectHelper.fromBytes<JWTInput>(\n\t\t\t\tConverter.base64ToBytes(options.config.credentials)\n\t\t\t);\n\t\t}\n\n\t\tGuards.stringValue(\n\t\t\tGcpBlobStorageConnector.CLASS_NAME,\n\t\t\tnameof(options.config.bucketName),\n\t\t\toptions.config.bucketName\n\t\t);\n\n\t\tthis._config = options.config;\n\t\tthis._partitionContextIds = options.partitionContextIds;\n\t\tthis._storage = new Storage({\n\t\t\tprojectId: this._config.projectId,\n\t\t\tapiEndpoint: this._config.apiEndpoint,\n\t\t\tcredentials\n\t\t});\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn GcpBlobStorageConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Returns the health status of the component.\n\t * @param lastTimestamp The Unix timestamp (ms) recorded at the start of the previous cycle.\n\t * @returns The health status of the component.\n\t */\n\tpublic async health(lastTimestamp: number): Promise<IHealth[]> {\n\t\ttry {\n\t\t\tawait this._storage.bucket(this._config.bucketName).exists();\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\t\tcategory: HealthCategory.Connectivity,\n\t\t\t\t\tstatus: HealthStatus.Ok,\n\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tbucketName: this._config.bucketName,\n\t\t\t\t\t\tprojectId: this._config.projectId\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t];\n\t\t} catch {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\t\tcategory: HealthCategory.Connectivity,\n\t\t\t\t\tstatus: HealthStatus.Error,\n\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\tmessage: \"healthCheckFailed\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tbucketName: this._config.bucketName,\n\t\t\t\t\t\tprojectId: this._config.projectId\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t];\n\t\t}\n\t}\n\n\t/**\n\t * Bootstrap the component by creating and initializing any resources it needs.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns True if the bootstrapping process was successful.\n\t */\n\tpublic async bootstrap(nodeLoggingComponentType?: string): Promise<boolean> {\n\t\tconst nodeLogging = ComponentFactory.getIfExists<ILoggingComponent>(nodeLoggingComponentType);\n\n\t\ttry {\n\t\t\tconst [buckets] = await this._storage.getBuckets();\n\t\t\tconst bucketExists = buckets.some(bucket => bucket.name === this._config.bucketName);\n\n\t\t\tif (bucketExists) {\n\t\t\t\tawait nodeLogging?.log({\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\t\tmessage: \"bucketExists\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tbucket: this._config.bucketName\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tawait nodeLogging?.log({\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\t\tmessage: \"bucketCreating\",\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tbucket: this._config.bucketName\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tawait this._storage.createBucket(this._config.bucketName);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tawait nodeLogging?.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\tmessage: \"bucketCreateFailed\",\n\t\t\t\tdata: {\n\t\t\t\t\tbucket: this._config.bucketName\n\t\t\t\t},\n\t\t\t\terror: BaseError.fromError(err)\n\t\t\t});\n\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Set the blob.\n\t * @param blob The data for the blob.\n\t * @returns The id of the stored blob in urn format.\n\t */\n\tpublic async set(blob: Uint8Array): Promise<string> {\n\t\tGuards.uint8Array(GcpBlobStorageConnector.CLASS_NAME, nameof(blob), blob);\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst partitionKey = ContextIdHelper.combinedContextKey(contextIds, this._partitionContextIds);\n\n\t\ttry {\n\t\t\tconst id = Converter.bytesToHex(Sha256.sum256(blob));\n\t\t\tconst bucket = this._storage.bucket(this._config.bucketName);\n\t\t\tconst file = bucket.file(`${partitionKey ?? \"root\"}/${id}`);\n\n\t\t\tawait file.save(blob, {\n\t\t\t\tcontentType: MimeTypes.OctetStream\n\t\t\t});\n\n\t\t\treturn `blob:${new Urn(GcpBlobStorageConnector.NAMESPACE, id).toString()}`;\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(GcpBlobStorageConnector.CLASS_NAME, \"setBlobFailed\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Get the blob.\n\t * @param id The id of the blob to get in urn format.\n\t * @returns The data for the blob if it can be found or undefined.\n\t */\n\tpublic async get(id: string): Promise<Uint8Array | undefined> {\n\t\tUrn.guard(GcpBlobStorageConnector.CLASS_NAME, nameof(id), id);\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst partitionKey = ContextIdHelper.combinedContextKey(contextIds, this._partitionContextIds);\n\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceMethod() !== GcpBlobStorageConnector.NAMESPACE) {\n\t\t\tthrow new GeneralError(GcpBlobStorageConnector.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: GcpBlobStorageConnector.NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst key = urnParsed.namespaceSpecific(1);\n\t\t\tconst bucket = this._storage.bucket(this._config.bucketName);\n\t\t\tconst file = bucket.file(`${partitionKey ?? \"root\"}/${key}`);\n\n\t\t\tconst [exists] = await file.exists();\n\t\t\tif (!exists) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst [contents] = await file.download();\n\t\t\treturn new Uint8Array(contents);\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(GcpBlobStorageConnector.CLASS_NAME, \"getBlobFailed\", { id }, err);\n\t\t}\n\t}\n\n\t/**\n\t * Teardown the component and remove any resources it created.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns True if the teardown process was successful.\n\t */\n\tpublic async teardown(nodeLoggingComponentType?: string): Promise<boolean> {\n\t\tconst nodeLogging = ComponentFactory.getIfExists<ILoggingComponent>(nodeLoggingComponentType);\n\n\t\tawait nodeLogging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\tmessage: \"bucketDeleting\",\n\t\t\tdata: {\n\t\t\t\tbucket: this._config.bucketName\n\t\t\t}\n\t\t});\n\n\t\ttry {\n\t\t\tconst bucket = this._storage.bucket(this._config.bucketName);\n\t\t\tawait bucket.deleteFiles({ force: true });\n\t\t\tawait bucket.delete();\n\n\t\t\tawait nodeLogging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\tmessage: \"bucketDeleted\",\n\t\t\t\tdata: {\n\t\t\t\t\tbucket: this._config.bucketName\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn true;\n\t\t} catch (err) {\n\t\t\tawait nodeLogging?.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tsource: GcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\tmessage: \"teardownFailed\",\n\t\t\t\tdata: {\n\t\t\t\t\tbucket: this._config.bucketName\n\t\t\t\t},\n\t\t\t\terror: BaseError.fromError(err)\n\t\t\t});\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Remove all blobs from the storage.\n\t * @returns A promise that resolves when all blobs in the current partition have been removed.\n\t */\n\tpublic async empty(): Promise<void> {\n\t\ttry {\n\t\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\t\tconst partitionKey = ContextIdHelper.combinedContextKey(\n\t\t\t\tcontextIds,\n\t\t\t\tthis._partitionContextIds\n\t\t\t);\n\t\t\tconst prefix = `${partitionKey ?? \"root\"}/`;\n\n\t\t\tconst bucket = this._storage.bucket(this._config.bucketName);\n\t\t\tawait bucket.deleteFiles({ force: true, prefix });\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tGcpBlobStorageConnector.CLASS_NAME,\n\t\t\t\t\"emptyFailed\",\n\t\t\t\t{ bucketName: this._config.bucketName },\n\t\t\t\terr\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove the blob.\n\t * @param id The id of the blob to remove in urn format.\n\t * @returns True if the blob was found.\n\t */\n\tpublic async remove(id: string): Promise<boolean> {\n\t\tUrn.guard(GcpBlobStorageConnector.CLASS_NAME, nameof(id), id);\n\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst partitionKey = ContextIdHelper.combinedContextKey(contextIds, this._partitionContextIds);\n\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceMethod() !== GcpBlobStorageConnector.NAMESPACE) {\n\t\t\tthrow new GeneralError(GcpBlobStorageConnector.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: GcpBlobStorageConnector.NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst key = urnParsed.namespaceSpecific(1);\n\t\t\tconst bucket = this._storage.bucket(this._config.bucketName);\n\t\t\tconst file = bucket.file(`${partitionKey ?? \"root\"}/${key}`);\n\n\t\t\tconst [exists] = await file.exists();\n\t\t\tif (!exists) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tawait file.delete();\n\t\t\treturn true;\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(GcpBlobStorageConnector.CLASS_NAME, \"removeBlobFailed\", { id }, err);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { type IHealth, type IHealthProviderComponent } from "@twin.org/api-models";
|
|
1
2
|
import type { IBlobStorageConnector } from "@twin.org/blob-storage-models";
|
|
2
|
-
import { type IHealth } from "@twin.org/core";
|
|
3
3
|
import type { IGcpBlobStorageConnectorConstructorOptions } from "./models/IGcpBlobStorageConnectorConstructorOptions.js";
|
|
4
4
|
/**
|
|
5
5
|
* Class for performing blob storage operations on GCP Storage.
|
|
6
6
|
* See https://cloud.google.com/storage/docs/reference/libraries for more information.
|
|
7
7
|
*/
|
|
8
|
-
export declare class GcpBlobStorageConnector implements IBlobStorageConnector {
|
|
8
|
+
export declare class GcpBlobStorageConnector implements IBlobStorageConnector, IHealthProviderComponent {
|
|
9
9
|
/**
|
|
10
10
|
* The namespace for the items.
|
|
11
11
|
*/
|
|
@@ -26,9 +26,10 @@ export declare class GcpBlobStorageConnector implements IBlobStorageConnector {
|
|
|
26
26
|
className(): string;
|
|
27
27
|
/**
|
|
28
28
|
* Returns the health status of the component.
|
|
29
|
+
* @param lastTimestamp The Unix timestamp (ms) recorded at the start of the previous cycle.
|
|
29
30
|
* @returns The health status of the component.
|
|
30
31
|
*/
|
|
31
|
-
health(): Promise<IHealth[]>;
|
|
32
|
+
health(lastTimestamp: number): Promise<IHealth[]>;
|
|
32
33
|
/**
|
|
33
34
|
* Bootstrap the component by creating and initializing any resources it needs.
|
|
34
35
|
* @param nodeLoggingComponentType The node logging component type.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.2-next.2](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-gcp-v0.9.2-next.1...blob-storage-connector-gcp-v0.9.2-next.2) (2026-08-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* update health signatures ([#93](https://github.com/iotaledger/twin-blob-storage/issues/93)) ([01775fa](https://github.com/iotaledger/twin-blob-storage/commit/01775faf45a6c5a179b47fe21e05f8beab430a57))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/blob-storage-models bumped from 0.9.2-next.1 to 0.9.2-next.2
|
|
16
|
+
|
|
17
|
+
## [0.9.2-next.1](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-gcp-v0.9.2-next.0...blob-storage-connector-gcp-v0.9.2-next.1) (2026-07-30)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add context id features ([#30](https://github.com/iotaledger/twin-blob-storage/issues/30)) ([fbf1c92](https://github.com/iotaledger/twin-blob-storage/commit/fbf1c9276424c841ef5ef3f4de8469ab3fba7e9c))
|
|
23
|
+
* add empty and teardown methods ([#49](https://github.com/iotaledger/twin-blob-storage/issues/49)) ([cec6248](https://github.com/iotaledger/twin-blob-storage/commit/cec624809ffd2f2baa4b7b8cbf72a7247b8703ed))
|
|
24
|
+
* Add GCP blob storage connector ([#8](https://github.com/iotaledger/twin-blob-storage/issues/8)) ([4f6d579](https://github.com/iotaledger/twin-blob-storage/commit/4f6d579c01b3ae13ebcd9029b279da62e4fde859))
|
|
25
|
+
* add validate-locales ([f20fcec](https://github.com/iotaledger/twin-blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
|
|
26
|
+
* additional information in health ([1ef83be](https://github.com/iotaledger/twin-blob-storage/commit/1ef83bef81148489b7950d5131a2af5121910e99))
|
|
27
|
+
* async getStore ([#59](https://github.com/iotaledger/twin-blob-storage/issues/59)) ([2de1ae5](https://github.com/iotaledger/twin-blob-storage/commit/2de1ae5c274b84a2320f75ac4628b81e9459c540))
|
|
28
|
+
* eslint migration to flat config ([e4239dd](https://github.com/iotaledger/twin-blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
|
|
29
|
+
* health check failure testing ([2107f66](https://github.com/iotaledger/twin-blob-storage/commit/2107f66a418ecf5e78e86319af3d2113d9f09cc6))
|
|
30
|
+
* health checks ([#44](https://github.com/iotaledger/twin-blob-storage/issues/44)) ([4a4041c](https://github.com/iotaledger/twin-blob-storage/commit/4a4041c19b68c40ed1aba6d1cdb4318ac4208b7d))
|
|
31
|
+
* skip ci for tests ([f1260dd](https://github.com/iotaledger/twin-blob-storage/commit/f1260dd7ba4fb3640bc021f1478e6a4b6c91fe9c))
|
|
32
|
+
* skip ci for tests ([02b8095](https://github.com/iotaledger/twin-blob-storage/commit/02b8095dfabf8d9b3c6248a054a7657bfab1a374))
|
|
33
|
+
* typescript 6 update ([4eed54f](https://github.com/iotaledger/twin-blob-storage/commit/4eed54f5ce2dc697c06597269c97ad4cad108be5))
|
|
34
|
+
* update dependencies ([ca3c571](https://github.com/iotaledger/twin-blob-storage/commit/ca3c571573c771b8d25594f729651c8214e28263))
|
|
35
|
+
* update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
|
|
36
|
+
* update framework core ([ff339fe](https://github.com/iotaledger/twin-blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
|
|
37
|
+
* use shared store mechanism ([#12](https://github.com/iotaledger/twin-blob-storage/issues/12)) ([cae8110](https://github.com/iotaledger/twin-blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Dependencies
|
|
41
|
+
|
|
42
|
+
* The following workspace dependencies were updated
|
|
43
|
+
* dependencies
|
|
44
|
+
* @twin.org/blob-storage-models bumped from 0.9.2-next.0 to 0.9.2-next.1
|
|
45
|
+
|
|
3
46
|
## [0.9.1](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-gcp-v0.9.1...blob-storage-connector-gcp-v0.9.1) (2026-07-27)
|
|
4
47
|
|
|
5
48
|
|
|
@@ -6,6 +6,7 @@ See https://cloud.google.com/storage/docs/reference/libraries for more informati
|
|
|
6
6
|
## Implements
|
|
7
7
|
|
|
8
8
|
- `IBlobStorageConnector`
|
|
9
|
+
- `IHealthProviderComponent`
|
|
9
10
|
|
|
10
11
|
## Constructors
|
|
11
12
|
|
|
@@ -65,10 +66,18 @@ The class name of the component.
|
|
|
65
66
|
|
|
66
67
|
### health() {#health}
|
|
67
68
|
|
|
68
|
-
> **health**(): `Promise`\<`IHealth`[]\>
|
|
69
|
+
> **health**(`lastTimestamp`): `Promise`\<`IHealth`[]\>
|
|
69
70
|
|
|
70
71
|
Returns the health status of the component.
|
|
71
72
|
|
|
73
|
+
#### Parameters
|
|
74
|
+
|
|
75
|
+
##### lastTimestamp
|
|
76
|
+
|
|
77
|
+
`number`
|
|
78
|
+
|
|
79
|
+
The Unix timestamp (ms) recorded at the start of the previous cycle.
|
|
80
|
+
|
|
72
81
|
#### Returns
|
|
73
82
|
|
|
74
83
|
`Promise`\<`IHealth`[]\>
|
|
@@ -77,7 +86,7 @@ The health status of the component.
|
|
|
77
86
|
|
|
78
87
|
#### Implementation of
|
|
79
88
|
|
|
80
|
-
`
|
|
89
|
+
`IHealthProviderComponent.health`
|
|
81
90
|
|
|
82
91
|
***
|
|
83
92
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/blob-storage-connector-gcp",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2-next.2",
|
|
4
4
|
"description": "Stores and retrieves blobs in Google Cloud Storage buckets.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@google-cloud/storage": "7.21.0",
|
|
18
|
-
"@twin.org/
|
|
19
|
-
"@twin.org/
|
|
20
|
-
"@twin.org/
|
|
21
|
-
"@twin.org/
|
|
22
|
-
"@twin.org/
|
|
23
|
-
"@twin.org/
|
|
24
|
-
"@twin.org/
|
|
18
|
+
"@twin.org/api-models": "next",
|
|
19
|
+
"@twin.org/blob-storage-models": "0.9.2-next.2",
|
|
20
|
+
"@twin.org/context": "next",
|
|
21
|
+
"@twin.org/core": "next",
|
|
22
|
+
"@twin.org/crypto": "next",
|
|
23
|
+
"@twin.org/logging-models": "next",
|
|
24
|
+
"@twin.org/nameof": "next",
|
|
25
|
+
"@twin.org/web": "next"
|
|
25
26
|
},
|
|
26
27
|
"main": "./dist/es/index.js",
|
|
27
28
|
"types": "./dist/types/index.d.ts",
|