@twin.org/blob-storage-connector-gcp 0.0.3-next.9 → 0.9.0
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/README.md +1 -1
- package/dist/es/gcpBlobStorageConnector.js +68 -2
- package/dist/es/gcpBlobStorageConnector.js.map +1 -1
- package/dist/types/gcpBlobStorageConnector.d.ts +11 -0
- package/docs/changelog.md +135 -0
- package/docs/reference/classes/GcpBlobStorageConnector.md +44 -0
- package/locales/en.json +8 -4
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install @twin.org/blob-storage-connector-gcp
|
|
|
13
13
|
To perform testing of this component it may be necessary to launch a local instance to communicate with.
|
|
14
14
|
|
|
15
15
|
```shell
|
|
16
|
-
docker run -d --name twin-blob-storage-gcp -p 4443:4443 fsouza/fake-gcs-server:latest -scheme http
|
|
16
|
+
docker run -d --name twin-blob-storage-gcp -p 4443:4443 fsouza/fake-gcs-server:latest -scheme http -external-url http://localhost:4443
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Examples
|
|
@@ -73,7 +73,11 @@ export class GcpBlobStorageConnector {
|
|
|
73
73
|
{
|
|
74
74
|
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
75
75
|
status: HealthStatus.Ok,
|
|
76
|
-
description: "healthDescription"
|
|
76
|
+
description: "healthDescription",
|
|
77
|
+
data: {
|
|
78
|
+
bucketName: this._config.bucketName,
|
|
79
|
+
projectId: this._config.projectId
|
|
80
|
+
}
|
|
77
81
|
}
|
|
78
82
|
];
|
|
79
83
|
}
|
|
@@ -83,7 +87,11 @@ export class GcpBlobStorageConnector {
|
|
|
83
87
|
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
84
88
|
status: HealthStatus.Error,
|
|
85
89
|
description: "healthDescription",
|
|
86
|
-
message: "healthCheckFailed"
|
|
90
|
+
message: "healthCheckFailed",
|
|
91
|
+
data: {
|
|
92
|
+
bucketName: this._config.bucketName,
|
|
93
|
+
projectId: this._config.projectId
|
|
94
|
+
}
|
|
87
95
|
}
|
|
88
96
|
];
|
|
89
97
|
}
|
|
@@ -187,6 +195,64 @@ export class GcpBlobStorageConnector {
|
|
|
187
195
|
throw new GeneralError(GcpBlobStorageConnector.CLASS_NAME, "getBlobFailed", { id }, err);
|
|
188
196
|
}
|
|
189
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Teardown the component and remove any resources it created.
|
|
200
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
201
|
+
* @returns True if the teardown process was successful.
|
|
202
|
+
*/
|
|
203
|
+
async teardown(nodeLoggingComponentType) {
|
|
204
|
+
const nodeLogging = ComponentFactory.getIfExists(nodeLoggingComponentType);
|
|
205
|
+
await nodeLogging?.log({
|
|
206
|
+
level: "info",
|
|
207
|
+
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
208
|
+
message: "bucketDeleting",
|
|
209
|
+
data: {
|
|
210
|
+
bucket: this._config.bucketName
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
try {
|
|
214
|
+
const bucket = this._storage.bucket(this._config.bucketName);
|
|
215
|
+
await bucket.deleteFiles({ force: true });
|
|
216
|
+
await bucket.delete();
|
|
217
|
+
await nodeLogging?.log({
|
|
218
|
+
level: "info",
|
|
219
|
+
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
220
|
+
message: "bucketDeleted",
|
|
221
|
+
data: {
|
|
222
|
+
bucket: this._config.bucketName
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
catch (err) {
|
|
228
|
+
await nodeLogging?.log({
|
|
229
|
+
level: "error",
|
|
230
|
+
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
231
|
+
message: "teardownFailed",
|
|
232
|
+
data: {
|
|
233
|
+
bucket: this._config.bucketName
|
|
234
|
+
},
|
|
235
|
+
error: BaseError.fromError(err)
|
|
236
|
+
});
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Remove all blobs from the storage.
|
|
242
|
+
* @returns A promise that resolves when all blobs in the current partition have been removed.
|
|
243
|
+
*/
|
|
244
|
+
async empty() {
|
|
245
|
+
try {
|
|
246
|
+
const contextIds = await ContextIdStore.getContextIds();
|
|
247
|
+
const partitionKey = ContextIdHelper.combinedContextKey(contextIds, this._partitionContextIds);
|
|
248
|
+
const prefix = `${partitionKey ?? "root"}/`;
|
|
249
|
+
const bucket = this._storage.bucket(this._config.bucketName);
|
|
250
|
+
await bucket.deleteFiles({ force: true, prefix });
|
|
251
|
+
}
|
|
252
|
+
catch (err) {
|
|
253
|
+
throw new GeneralError(GcpBlobStorageConnector.CLASS_NAME, "emptyFailed", { bucketName: this._config.bucketName }, err);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
190
256
|
/**
|
|
191
257
|
* Remove the blob.
|
|
192
258
|
* @param id The id of the blob to remove in urn format.
|
|
@@ -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,UA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AC,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}\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}\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 * 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,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,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,MAAM,cAAc,CAAC,aAAa,EAAE,CAAC;QACxD,MAAM,YAAY,GAAG,eAAe,CAAC,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAE/F,MAAM,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAE1C,IAAI,SAAS,CAAC,eAAe,EAAE,KAAK,uBAAuB,CAAC,SAAS,EAAE,CAAC;YACvE,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"]}
|
|
@@ -47,6 +47,17 @@ export declare class GcpBlobStorageConnector implements IBlobStorageConnector {
|
|
|
47
47
|
* @returns The data for the blob if it can be found or undefined.
|
|
48
48
|
*/
|
|
49
49
|
get(id: string): Promise<Uint8Array | undefined>;
|
|
50
|
+
/**
|
|
51
|
+
* Teardown the component and remove any resources it created.
|
|
52
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
53
|
+
* @returns True if the teardown process was successful.
|
|
54
|
+
*/
|
|
55
|
+
teardown(nodeLoggingComponentType?: string): Promise<boolean>;
|
|
56
|
+
/**
|
|
57
|
+
* Remove all blobs from the storage.
|
|
58
|
+
* @returns A promise that resolves when all blobs in the current partition have been removed.
|
|
59
|
+
*/
|
|
60
|
+
empty(): Promise<void>;
|
|
50
61
|
/**
|
|
51
62
|
* Remove the blob.
|
|
52
63
|
* @param id The id of the blob to remove in urn format.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,140 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.0](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-gcp-v0.9.0...blob-storage-connector-gcp-v0.9.0) (2026-06-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* release to production ([eacfe75](https://github.com/iotaledger/twin-blob-storage/commit/eacfe754a0dcd9243d9e13d86422327d0a605164))
|
|
9
|
+
* release to production ([#70](https://github.com/iotaledger/twin-blob-storage/issues/70)) ([6a38fe5](https://github.com/iotaledger/twin-blob-storage/commit/6a38fe583076baf1fc53d1d891d294b75ebbefd1))
|
|
10
|
+
|
|
11
|
+
## [0.9.0-next.1](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-gcp-v0.9.0-next.0...blob-storage-connector-gcp-v0.9.0-next.1) (2026-06-23)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* add context id features ([#30](https://github.com/iotaledger/twin-blob-storage/issues/30)) ([fbf1c92](https://github.com/iotaledger/twin-blob-storage/commit/fbf1c9276424c841ef5ef3f4de8469ab3fba7e9c))
|
|
17
|
+
* 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))
|
|
18
|
+
* 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))
|
|
19
|
+
* add validate-locales ([f20fcec](https://github.com/iotaledger/twin-blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
|
|
20
|
+
* additional information in health ([1ef83be](https://github.com/iotaledger/twin-blob-storage/commit/1ef83bef81148489b7950d5131a2af5121910e99))
|
|
21
|
+
* async getStore ([#59](https://github.com/iotaledger/twin-blob-storage/issues/59)) ([2de1ae5](https://github.com/iotaledger/twin-blob-storage/commit/2de1ae5c274b84a2320f75ac4628b81e9459c540))
|
|
22
|
+
* eslint migration to flat config ([e4239dd](https://github.com/iotaledger/twin-blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
|
|
23
|
+
* health check failure testing ([2107f66](https://github.com/iotaledger/twin-blob-storage/commit/2107f66a418ecf5e78e86319af3d2113d9f09cc6))
|
|
24
|
+
* health checks ([#44](https://github.com/iotaledger/twin-blob-storage/issues/44)) ([4a4041c](https://github.com/iotaledger/twin-blob-storage/commit/4a4041c19b68c40ed1aba6d1cdb4318ac4208b7d))
|
|
25
|
+
* skip ci for tests ([f1260dd](https://github.com/iotaledger/twin-blob-storage/commit/f1260dd7ba4fb3640bc021f1478e6a4b6c91fe9c))
|
|
26
|
+
* skip ci for tests ([02b8095](https://github.com/iotaledger/twin-blob-storage/commit/02b8095dfabf8d9b3c6248a054a7657bfab1a374))
|
|
27
|
+
* typescript 6 update ([4eed54f](https://github.com/iotaledger/twin-blob-storage/commit/4eed54f5ce2dc697c06597269c97ad4cad108be5))
|
|
28
|
+
* update dependencies ([ca3c571](https://github.com/iotaledger/twin-blob-storage/commit/ca3c571573c771b8d25594f729651c8214e28263))
|
|
29
|
+
* update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
|
|
30
|
+
* update framework core ([ff339fe](https://github.com/iotaledger/twin-blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
|
|
31
|
+
* use shared store mechanism ([#12](https://github.com/iotaledger/twin-blob-storage/issues/12)) ([cae8110](https://github.com/iotaledger/twin-blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Dependencies
|
|
35
|
+
|
|
36
|
+
* The following workspace dependencies were updated
|
|
37
|
+
* dependencies
|
|
38
|
+
* @twin.org/blob-storage-models bumped from 0.9.0-next.0 to 0.9.0-next.1
|
|
39
|
+
|
|
40
|
+
## [0.0.3-next.16](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-gcp-v0.0.3-next.15...blob-storage-connector-gcp-v0.0.3-next.16) (2026-06-18)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Miscellaneous Chores
|
|
44
|
+
|
|
45
|
+
* **blob-storage-connector-gcp:** Synchronize repo versions
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Dependencies
|
|
49
|
+
|
|
50
|
+
* The following workspace dependencies were updated
|
|
51
|
+
* dependencies
|
|
52
|
+
* @twin.org/blob-storage-models bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
53
|
+
|
|
54
|
+
## [0.0.3-next.15](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-gcp-v0.0.3-next.14...blob-storage-connector-gcp-v0.0.3-next.15) (2026-06-15)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### Features
|
|
58
|
+
|
|
59
|
+
* async getStore ([#59](https://github.com/iotaledger/twin-blob-storage/issues/59)) ([2de1ae5](https://github.com/iotaledger/twin-blob-storage/commit/2de1ae5c274b84a2320f75ac4628b81e9459c540))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Dependencies
|
|
63
|
+
|
|
64
|
+
* The following workspace dependencies were updated
|
|
65
|
+
* dependencies
|
|
66
|
+
* @twin.org/blob-storage-models bumped from 0.0.3-next.14 to 0.0.3-next.15
|
|
67
|
+
|
|
68
|
+
## [0.0.3-next.14](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-gcp-v0.0.3-next.13...blob-storage-connector-gcp-v0.0.3-next.14) (2026-06-11)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
### Miscellaneous Chores
|
|
72
|
+
|
|
73
|
+
* **blob-storage-connector-gcp:** Synchronize repo versions
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### Dependencies
|
|
77
|
+
|
|
78
|
+
* The following workspace dependencies were updated
|
|
79
|
+
* dependencies
|
|
80
|
+
* @twin.org/blob-storage-models bumped from 0.0.3-next.13 to 0.0.3-next.14
|
|
81
|
+
|
|
82
|
+
## [0.0.3-next.13](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-gcp-v0.0.3-next.12...blob-storage-connector-gcp-v0.0.3-next.13) (2026-05-20)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### Features
|
|
86
|
+
|
|
87
|
+
* update dependencies ([ca3c571](https://github.com/iotaledger/twin-blob-storage/commit/ca3c571573c771b8d25594f729651c8214e28263))
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
### Dependencies
|
|
91
|
+
|
|
92
|
+
* The following workspace dependencies were updated
|
|
93
|
+
* dependencies
|
|
94
|
+
* @twin.org/blob-storage-models bumped from 0.0.3-next.12 to 0.0.3-next.13
|
|
95
|
+
|
|
96
|
+
## [0.0.3-next.12](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-gcp-v0.0.3-next.11...blob-storage-connector-gcp-v0.0.3-next.12) (2026-05-11)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Features
|
|
100
|
+
|
|
101
|
+
* typescript 6 update ([4eed54f](https://github.com/iotaledger/twin-blob-storage/commit/4eed54f5ce2dc697c06597269c97ad4cad108be5))
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
### Dependencies
|
|
105
|
+
|
|
106
|
+
* The following workspace dependencies were updated
|
|
107
|
+
* dependencies
|
|
108
|
+
* @twin.org/blob-storage-models bumped from 0.0.3-next.11 to 0.0.3-next.12
|
|
109
|
+
|
|
110
|
+
## [0.0.3-next.11](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-gcp-v0.0.3-next.10...blob-storage-connector-gcp-v0.0.3-next.11) (2026-05-08)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
### Features
|
|
114
|
+
|
|
115
|
+
* 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))
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
### Dependencies
|
|
119
|
+
|
|
120
|
+
* The following workspace dependencies were updated
|
|
121
|
+
* dependencies
|
|
122
|
+
* @twin.org/blob-storage-models bumped from 0.0.3-next.10 to 0.0.3-next.11
|
|
123
|
+
|
|
124
|
+
## [0.0.3-next.10](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-gcp-v0.0.3-next.9...blob-storage-connector-gcp-v0.0.3-next.10) (2026-05-07)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
### Features
|
|
128
|
+
|
|
129
|
+
* additional information in health ([1ef83be](https://github.com/iotaledger/twin-blob-storage/commit/1ef83bef81148489b7950d5131a2af5121910e99))
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
### Dependencies
|
|
133
|
+
|
|
134
|
+
* The following workspace dependencies were updated
|
|
135
|
+
* dependencies
|
|
136
|
+
* @twin.org/blob-storage-models bumped from 0.0.3-next.9 to 0.0.3-next.10
|
|
137
|
+
|
|
3
138
|
## [0.0.3-next.9](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-gcp-v0.0.3-next.8...blob-storage-connector-gcp-v0.0.3-next.9) (2026-05-07)
|
|
4
139
|
|
|
5
140
|
|
|
@@ -159,6 +159,50 @@ The data for the blob if it can be found or undefined.
|
|
|
159
159
|
|
|
160
160
|
***
|
|
161
161
|
|
|
162
|
+
### teardown() {#teardown}
|
|
163
|
+
|
|
164
|
+
> **teardown**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
|
|
165
|
+
|
|
166
|
+
Teardown the component and remove any resources it created.
|
|
167
|
+
|
|
168
|
+
#### Parameters
|
|
169
|
+
|
|
170
|
+
##### nodeLoggingComponentType?
|
|
171
|
+
|
|
172
|
+
`string`
|
|
173
|
+
|
|
174
|
+
The node logging component type.
|
|
175
|
+
|
|
176
|
+
#### Returns
|
|
177
|
+
|
|
178
|
+
`Promise`\<`boolean`\>
|
|
179
|
+
|
|
180
|
+
True if the teardown process was successful.
|
|
181
|
+
|
|
182
|
+
#### Implementation of
|
|
183
|
+
|
|
184
|
+
`IBlobStorageConnector.teardown`
|
|
185
|
+
|
|
186
|
+
***
|
|
187
|
+
|
|
188
|
+
### empty() {#empty}
|
|
189
|
+
|
|
190
|
+
> **empty**(): `Promise`\<`void`\>
|
|
191
|
+
|
|
192
|
+
Remove all blobs from the storage.
|
|
193
|
+
|
|
194
|
+
#### Returns
|
|
195
|
+
|
|
196
|
+
`Promise`\<`void`\>
|
|
197
|
+
|
|
198
|
+
A promise that resolves when all blobs in the current partition have been removed.
|
|
199
|
+
|
|
200
|
+
#### Implementation of
|
|
201
|
+
|
|
202
|
+
`IBlobStorageConnector.empty`
|
|
203
|
+
|
|
204
|
+
***
|
|
205
|
+
|
|
162
206
|
### remove() {#remove}
|
|
163
207
|
|
|
164
208
|
> **remove**(`id`): `Promise`\<`boolean`\>
|
package/locales/en.json
CHANGED
|
@@ -2,22 +2,26 @@
|
|
|
2
2
|
"info": {
|
|
3
3
|
"gcpBlobStorageConnector": {
|
|
4
4
|
"bucketCreating": "Creating bucket \"{bucket}\"",
|
|
5
|
-
"bucketExists": "Skipping create bucket \"{bucket}\" as it already exists"
|
|
5
|
+
"bucketExists": "Skipping create bucket \"{bucket}\" as it already exists",
|
|
6
|
+
"bucketDeleting": "Deleting bucket \"{bucket}\"",
|
|
7
|
+
"bucketDeleted": "Bucket \"{bucket}\" deleted"
|
|
6
8
|
}
|
|
7
9
|
},
|
|
8
10
|
"health": {
|
|
9
11
|
"gcpBlobStorageConnector": {
|
|
10
|
-
"healthDescription": "GCP blob storage connector is healthy",
|
|
11
|
-
"healthCheckFailed": "Failed to connect to GCP storage bucket"
|
|
12
|
+
"healthDescription": "GCP blob storage connector is healthy, bucket \"{bucketName}\" in project \"{projectId}\"",
|
|
13
|
+
"healthCheckFailed": "Failed to connect to GCP storage bucket \"{bucketName}\" in project \"{projectId}\""
|
|
12
14
|
}
|
|
13
15
|
},
|
|
14
16
|
"error": {
|
|
15
17
|
"gcpBlobStorageConnector": {
|
|
16
18
|
"bucketCreateFailed": "Creating bucket \"{bucket}\" failed",
|
|
19
|
+
"teardownFailed": "Failed to teardown GCP storage bucket \"{bucket}\"",
|
|
17
20
|
"namespaceMismatch": "The namespace in the urn \"{id}\" does not match the namespace of the blob storage \"{namespace}\"",
|
|
18
21
|
"getBlobFailed": "Failed to get blob in GCP",
|
|
19
22
|
"setBlobFailed": "Failed to set blob in GCP",
|
|
20
|
-
"removeBlobFailed": "Failed to remove blob in GCP"
|
|
23
|
+
"removeBlobFailed": "Failed to remove blob in GCP",
|
|
24
|
+
"emptyFailed": "Failed to empty GCP storage bucket \"{bucketName}\""
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/blob-storage-connector-gcp",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Stores and retrieves blobs in Google Cloud Storage buckets.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/iotaledger/blob-storage.git",
|
|
7
|
+
"url": "git+https://github.com/iotaledger/twin-blob-storage.git",
|
|
8
8
|
"directory": "packages/blob-storage-connector-gcp"
|
|
9
9
|
},
|
|
10
10
|
"author": "cornel.filip@iota.org",
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@google-cloud/storage": "7.
|
|
18
|
-
"@twin.org/blob-storage-models": "0.0
|
|
19
|
-
"@twin.org/context": "
|
|
20
|
-
"@twin.org/core": "
|
|
21
|
-
"@twin.org/crypto": "
|
|
22
|
-
"@twin.org/logging-models": "
|
|
23
|
-
"@twin.org/nameof": "
|
|
24
|
-
"@twin.org/web": "
|
|
17
|
+
"@google-cloud/storage": "7.21.0",
|
|
18
|
+
"@twin.org/blob-storage-models": "^0.9.0",
|
|
19
|
+
"@twin.org/context": "^0.9.0",
|
|
20
|
+
"@twin.org/core": "^0.9.0",
|
|
21
|
+
"@twin.org/crypto": "^0.9.0",
|
|
22
|
+
"@twin.org/logging-models": "^0.9.0",
|
|
23
|
+
"@twin.org/nameof": "^0.9.0",
|
|
24
|
+
"@twin.org/web": "^0.9.0"
|
|
25
25
|
},
|
|
26
26
|
"main": "./dist/es/index.js",
|
|
27
27
|
"types": "./dist/types/index.d.ts",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"integration"
|
|
56
56
|
],
|
|
57
57
|
"bugs": {
|
|
58
|
-
"url": "git+https://github.com/iotaledger/blob-storage/issues"
|
|
58
|
+
"url": "git+https://github.com/iotaledger/twin-blob-storage/issues"
|
|
59
59
|
},
|
|
60
60
|
"homepage": "https://twindev.org"
|
|
61
61
|
}
|