@twin.org/blob-storage-connector-gcp 0.0.2-next.3 → 0.0.2-next.5
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
CHANGED
|
@@ -19,7 +19,7 @@ class GcpBlobStorageConnector {
|
|
|
19
19
|
/**
|
|
20
20
|
* Runtime name for the class.
|
|
21
21
|
*/
|
|
22
|
-
CLASS_NAME = "GcpBlobStorageConnector";
|
|
22
|
+
static CLASS_NAME = "GcpBlobStorageConnector";
|
|
23
23
|
/**
|
|
24
24
|
* The configuration for the connector.
|
|
25
25
|
* @internal
|
|
@@ -35,15 +35,15 @@ class GcpBlobStorageConnector {
|
|
|
35
35
|
* @param options The options for the connector.
|
|
36
36
|
*/
|
|
37
37
|
constructor(options) {
|
|
38
|
-
core.Guards.object(
|
|
39
|
-
core.Guards.object(
|
|
40
|
-
core.Guards.stringValue(
|
|
38
|
+
core.Guards.object(GcpBlobStorageConnector.CLASS_NAME, "options", options);
|
|
39
|
+
core.Guards.object(GcpBlobStorageConnector.CLASS_NAME, "options.config", options.config);
|
|
40
|
+
core.Guards.stringValue(GcpBlobStorageConnector.CLASS_NAME, "options.config.projectId", options.config.projectId);
|
|
41
41
|
let credentials;
|
|
42
42
|
if (!core.Is.empty(options.config.credentials)) {
|
|
43
|
-
core.Guards.stringBase64(
|
|
43
|
+
core.Guards.stringBase64(GcpBlobStorageConnector.CLASS_NAME, "options.config.credentials", options.config.credentials);
|
|
44
44
|
credentials = core.ObjectHelper.fromBytes(core.Converter.base64ToBytes(options.config.credentials));
|
|
45
45
|
}
|
|
46
|
-
core.Guards.stringValue(
|
|
46
|
+
core.Guards.stringValue(GcpBlobStorageConnector.CLASS_NAME, "options.config.bucketName", options.config.bucketName);
|
|
47
47
|
this._config = options.config;
|
|
48
48
|
this._storage = new storage.Storage({
|
|
49
49
|
projectId: this._config.projectId,
|
|
@@ -61,7 +61,7 @@ class GcpBlobStorageConnector {
|
|
|
61
61
|
try {
|
|
62
62
|
await nodeLogging?.log({
|
|
63
63
|
level: "info",
|
|
64
|
-
source:
|
|
64
|
+
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
65
65
|
message: "bucketCreating",
|
|
66
66
|
data: {
|
|
67
67
|
bucket: this._config.bucketName
|
|
@@ -72,7 +72,7 @@ class GcpBlobStorageConnector {
|
|
|
72
72
|
if (bucketExists) {
|
|
73
73
|
await nodeLogging?.log({
|
|
74
74
|
level: "info",
|
|
75
|
-
source:
|
|
75
|
+
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
76
76
|
message: "bucketExists",
|
|
77
77
|
data: {
|
|
78
78
|
bucket: this._config.bucketName
|
|
@@ -83,7 +83,7 @@ class GcpBlobStorageConnector {
|
|
|
83
83
|
await this._storage.createBucket(this._config.bucketName);
|
|
84
84
|
await nodeLogging?.log({
|
|
85
85
|
level: "info",
|
|
86
|
-
source:
|
|
86
|
+
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
87
87
|
message: "bucketCreated",
|
|
88
88
|
data: {
|
|
89
89
|
bucket: this._config.bucketName
|
|
@@ -94,7 +94,7 @@ class GcpBlobStorageConnector {
|
|
|
94
94
|
catch (err) {
|
|
95
95
|
await nodeLogging?.log({
|
|
96
96
|
level: "error",
|
|
97
|
-
source:
|
|
97
|
+
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
98
98
|
message: "bucketCreateFailed",
|
|
99
99
|
data: {
|
|
100
100
|
bucket: this._config.bucketName
|
|
@@ -111,7 +111,7 @@ class GcpBlobStorageConnector {
|
|
|
111
111
|
* @returns The id of the stored blob in urn format.
|
|
112
112
|
*/
|
|
113
113
|
async set(blob) {
|
|
114
|
-
core.Guards.uint8Array(
|
|
114
|
+
core.Guards.uint8Array(GcpBlobStorageConnector.CLASS_NAME, "blob", blob);
|
|
115
115
|
try {
|
|
116
116
|
const id = core.Converter.bytesToHex(crypto.Sha256.sum256(blob));
|
|
117
117
|
const bucket = this._storage.bucket(this._config.bucketName);
|
|
@@ -122,7 +122,7 @@ class GcpBlobStorageConnector {
|
|
|
122
122
|
return `blob:${new core.Urn(GcpBlobStorageConnector.NAMESPACE, id).toString()}`;
|
|
123
123
|
}
|
|
124
124
|
catch (err) {
|
|
125
|
-
throw new core.GeneralError(
|
|
125
|
+
throw new core.GeneralError(GcpBlobStorageConnector.CLASS_NAME, "setBlobFailed", undefined, err);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
@@ -131,10 +131,10 @@ class GcpBlobStorageConnector {
|
|
|
131
131
|
* @returns The data for the blob if it can be found or undefined.
|
|
132
132
|
*/
|
|
133
133
|
async get(id) {
|
|
134
|
-
core.Urn.guard(
|
|
134
|
+
core.Urn.guard(GcpBlobStorageConnector.CLASS_NAME, "id", id);
|
|
135
135
|
const urnParsed = core.Urn.fromValidString(id);
|
|
136
136
|
if (urnParsed.namespaceMethod() !== GcpBlobStorageConnector.NAMESPACE) {
|
|
137
|
-
throw new core.GeneralError(
|
|
137
|
+
throw new core.GeneralError(GcpBlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
|
|
138
138
|
namespace: GcpBlobStorageConnector.NAMESPACE,
|
|
139
139
|
id
|
|
140
140
|
});
|
|
@@ -151,7 +151,7 @@ class GcpBlobStorageConnector {
|
|
|
151
151
|
return new Uint8Array(contents);
|
|
152
152
|
}
|
|
153
153
|
catch (err) {
|
|
154
|
-
throw new core.GeneralError(
|
|
154
|
+
throw new core.GeneralError(GcpBlobStorageConnector.CLASS_NAME, "getBlobFailed", { id }, err);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
@@ -160,10 +160,10 @@ class GcpBlobStorageConnector {
|
|
|
160
160
|
* @returns True if the blob was found.
|
|
161
161
|
*/
|
|
162
162
|
async remove(id) {
|
|
163
|
-
core.Urn.guard(
|
|
163
|
+
core.Urn.guard(GcpBlobStorageConnector.CLASS_NAME, "id", id);
|
|
164
164
|
const urnParsed = core.Urn.fromValidString(id);
|
|
165
165
|
if (urnParsed.namespaceMethod() !== GcpBlobStorageConnector.NAMESPACE) {
|
|
166
|
-
throw new core.GeneralError(
|
|
166
|
+
throw new core.GeneralError(GcpBlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
|
|
167
167
|
namespace: GcpBlobStorageConnector.NAMESPACE,
|
|
168
168
|
id
|
|
169
169
|
});
|
|
@@ -180,7 +180,7 @@ class GcpBlobStorageConnector {
|
|
|
180
180
|
return true;
|
|
181
181
|
}
|
|
182
182
|
catch (err) {
|
|
183
|
-
throw new core.GeneralError(
|
|
183
|
+
throw new core.GeneralError(GcpBlobStorageConnector.CLASS_NAME, "removeBlobFailed", { id }, err);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ class GcpBlobStorageConnector {
|
|
|
17
17
|
/**
|
|
18
18
|
* Runtime name for the class.
|
|
19
19
|
*/
|
|
20
|
-
CLASS_NAME = "GcpBlobStorageConnector";
|
|
20
|
+
static CLASS_NAME = "GcpBlobStorageConnector";
|
|
21
21
|
/**
|
|
22
22
|
* The configuration for the connector.
|
|
23
23
|
* @internal
|
|
@@ -33,15 +33,15 @@ class GcpBlobStorageConnector {
|
|
|
33
33
|
* @param options The options for the connector.
|
|
34
34
|
*/
|
|
35
35
|
constructor(options) {
|
|
36
|
-
Guards.object(
|
|
37
|
-
Guards.object(
|
|
38
|
-
Guards.stringValue(
|
|
36
|
+
Guards.object(GcpBlobStorageConnector.CLASS_NAME, "options", options);
|
|
37
|
+
Guards.object(GcpBlobStorageConnector.CLASS_NAME, "options.config", options.config);
|
|
38
|
+
Guards.stringValue(GcpBlobStorageConnector.CLASS_NAME, "options.config.projectId", options.config.projectId);
|
|
39
39
|
let credentials;
|
|
40
40
|
if (!Is.empty(options.config.credentials)) {
|
|
41
|
-
Guards.stringBase64(
|
|
41
|
+
Guards.stringBase64(GcpBlobStorageConnector.CLASS_NAME, "options.config.credentials", options.config.credentials);
|
|
42
42
|
credentials = ObjectHelper.fromBytes(Converter.base64ToBytes(options.config.credentials));
|
|
43
43
|
}
|
|
44
|
-
Guards.stringValue(
|
|
44
|
+
Guards.stringValue(GcpBlobStorageConnector.CLASS_NAME, "options.config.bucketName", options.config.bucketName);
|
|
45
45
|
this._config = options.config;
|
|
46
46
|
this._storage = new Storage({
|
|
47
47
|
projectId: this._config.projectId,
|
|
@@ -59,7 +59,7 @@ class GcpBlobStorageConnector {
|
|
|
59
59
|
try {
|
|
60
60
|
await nodeLogging?.log({
|
|
61
61
|
level: "info",
|
|
62
|
-
source:
|
|
62
|
+
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
63
63
|
message: "bucketCreating",
|
|
64
64
|
data: {
|
|
65
65
|
bucket: this._config.bucketName
|
|
@@ -70,7 +70,7 @@ class GcpBlobStorageConnector {
|
|
|
70
70
|
if (bucketExists) {
|
|
71
71
|
await nodeLogging?.log({
|
|
72
72
|
level: "info",
|
|
73
|
-
source:
|
|
73
|
+
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
74
74
|
message: "bucketExists",
|
|
75
75
|
data: {
|
|
76
76
|
bucket: this._config.bucketName
|
|
@@ -81,7 +81,7 @@ class GcpBlobStorageConnector {
|
|
|
81
81
|
await this._storage.createBucket(this._config.bucketName);
|
|
82
82
|
await nodeLogging?.log({
|
|
83
83
|
level: "info",
|
|
84
|
-
source:
|
|
84
|
+
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
85
85
|
message: "bucketCreated",
|
|
86
86
|
data: {
|
|
87
87
|
bucket: this._config.bucketName
|
|
@@ -92,7 +92,7 @@ class GcpBlobStorageConnector {
|
|
|
92
92
|
catch (err) {
|
|
93
93
|
await nodeLogging?.log({
|
|
94
94
|
level: "error",
|
|
95
|
-
source:
|
|
95
|
+
source: GcpBlobStorageConnector.CLASS_NAME,
|
|
96
96
|
message: "bucketCreateFailed",
|
|
97
97
|
data: {
|
|
98
98
|
bucket: this._config.bucketName
|
|
@@ -109,7 +109,7 @@ class GcpBlobStorageConnector {
|
|
|
109
109
|
* @returns The id of the stored blob in urn format.
|
|
110
110
|
*/
|
|
111
111
|
async set(blob) {
|
|
112
|
-
Guards.uint8Array(
|
|
112
|
+
Guards.uint8Array(GcpBlobStorageConnector.CLASS_NAME, "blob", blob);
|
|
113
113
|
try {
|
|
114
114
|
const id = Converter.bytesToHex(Sha256.sum256(blob));
|
|
115
115
|
const bucket = this._storage.bucket(this._config.bucketName);
|
|
@@ -120,7 +120,7 @@ class GcpBlobStorageConnector {
|
|
|
120
120
|
return `blob:${new Urn(GcpBlobStorageConnector.NAMESPACE, id).toString()}`;
|
|
121
121
|
}
|
|
122
122
|
catch (err) {
|
|
123
|
-
throw new GeneralError(
|
|
123
|
+
throw new GeneralError(GcpBlobStorageConnector.CLASS_NAME, "setBlobFailed", undefined, err);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
@@ -129,10 +129,10 @@ class GcpBlobStorageConnector {
|
|
|
129
129
|
* @returns The data for the blob if it can be found or undefined.
|
|
130
130
|
*/
|
|
131
131
|
async get(id) {
|
|
132
|
-
Urn.guard(
|
|
132
|
+
Urn.guard(GcpBlobStorageConnector.CLASS_NAME, "id", id);
|
|
133
133
|
const urnParsed = Urn.fromValidString(id);
|
|
134
134
|
if (urnParsed.namespaceMethod() !== GcpBlobStorageConnector.NAMESPACE) {
|
|
135
|
-
throw new GeneralError(
|
|
135
|
+
throw new GeneralError(GcpBlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
|
|
136
136
|
namespace: GcpBlobStorageConnector.NAMESPACE,
|
|
137
137
|
id
|
|
138
138
|
});
|
|
@@ -149,7 +149,7 @@ class GcpBlobStorageConnector {
|
|
|
149
149
|
return new Uint8Array(contents);
|
|
150
150
|
}
|
|
151
151
|
catch (err) {
|
|
152
|
-
throw new GeneralError(
|
|
152
|
+
throw new GeneralError(GcpBlobStorageConnector.CLASS_NAME, "getBlobFailed", { id }, err);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
@@ -158,10 +158,10 @@ class GcpBlobStorageConnector {
|
|
|
158
158
|
* @returns True if the blob was found.
|
|
159
159
|
*/
|
|
160
160
|
async remove(id) {
|
|
161
|
-
Urn.guard(
|
|
161
|
+
Urn.guard(GcpBlobStorageConnector.CLASS_NAME, "id", id);
|
|
162
162
|
const urnParsed = Urn.fromValidString(id);
|
|
163
163
|
if (urnParsed.namespaceMethod() !== GcpBlobStorageConnector.NAMESPACE) {
|
|
164
|
-
throw new GeneralError(
|
|
164
|
+
throw new GeneralError(GcpBlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
|
|
165
165
|
namespace: GcpBlobStorageConnector.NAMESPACE,
|
|
166
166
|
id
|
|
167
167
|
});
|
|
@@ -178,7 +178,7 @@ class GcpBlobStorageConnector {
|
|
|
178
178
|
return true;
|
|
179
179
|
}
|
|
180
180
|
catch (err) {
|
|
181
|
-
throw new GeneralError(
|
|
181
|
+
throw new GeneralError(GcpBlobStorageConnector.CLASS_NAME, "removeBlobFailed", { id }, err);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
}
|
|
@@ -12,7 +12,7 @@ export declare class GcpBlobStorageConnector implements IBlobStorageConnector {
|
|
|
12
12
|
/**
|
|
13
13
|
* Runtime name for the class.
|
|
14
14
|
*/
|
|
15
|
-
readonly CLASS_NAME: string;
|
|
15
|
+
static readonly CLASS_NAME: string;
|
|
16
16
|
/**
|
|
17
17
|
* Create a new instance of GcpBlobStorageConnector.
|
|
18
18
|
* @param options The options for the connector.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @twin.org/blob-storage-connector-gcp - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.5](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-gcp-v0.0.2-next.4...blob-storage-connector-gcp-v0.0.2-next.5) (2025-10-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add validate-locales ([f20fcec](https://github.com/twinfoundation/blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/blob-storage-models bumped from 0.0.2-next.4 to 0.0.2-next.5
|
|
16
|
+
|
|
17
|
+
## [0.0.2-next.4](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-gcp-v0.0.2-next.3...blob-storage-connector-gcp-v0.0.2-next.4) (2025-10-02)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Miscellaneous Chores
|
|
21
|
+
|
|
22
|
+
* **blob-storage-connector-gcp:** Synchronize repo versions
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/blob-storage-models bumped from 0.0.2-next.3 to 0.0.2-next.4
|
|
30
|
+
|
|
3
31
|
## [0.0.2-next.3](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-gcp-v0.0.2-next.2...blob-storage-connector-gcp-v0.0.2-next.3) (2025-08-29)
|
|
4
32
|
|
|
5
33
|
|
|
@@ -39,14 +39,10 @@ The namespace for the items.
|
|
|
39
39
|
|
|
40
40
|
### CLASS\_NAME
|
|
41
41
|
|
|
42
|
-
> `readonly` **CLASS\_NAME**: `string`
|
|
42
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
43
43
|
|
|
44
44
|
Runtime name for the class.
|
|
45
45
|
|
|
46
|
-
#### Implementation of
|
|
47
|
-
|
|
48
|
-
`IBlobStorageConnector.CLASS_NAME`
|
|
49
|
-
|
|
50
46
|
## Methods
|
|
51
47
|
|
|
52
48
|
### bootstrap()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/blob-storage-connector-gcp",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.5",
|
|
4
4
|
"description": "Blob Storage connector implementation using Google Cloud Storage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@google-cloud/storage": "7.17.
|
|
18
|
-
"@twin.org/blob-storage-models": "0.0.2-next.
|
|
17
|
+
"@google-cloud/storage": "7.17.2",
|
|
18
|
+
"@twin.org/blob-storage-models": "0.0.2-next.5",
|
|
19
19
|
"@twin.org/core": "next",
|
|
20
20
|
"@twin.org/crypto": "next",
|
|
21
21
|
"@twin.org/logging-models": "next",
|
|
@@ -39,5 +39,24 @@
|
|
|
39
39
|
"dist/types",
|
|
40
40
|
"locales",
|
|
41
41
|
"docs"
|
|
42
|
-
]
|
|
42
|
+
],
|
|
43
|
+
"keywords": [
|
|
44
|
+
"twin",
|
|
45
|
+
"trade",
|
|
46
|
+
"iota",
|
|
47
|
+
"framework",
|
|
48
|
+
"blockchain",
|
|
49
|
+
"blob-storage",
|
|
50
|
+
"blob",
|
|
51
|
+
"storage",
|
|
52
|
+
"files",
|
|
53
|
+
"binary",
|
|
54
|
+
"connector",
|
|
55
|
+
"adapter",
|
|
56
|
+
"integration"
|
|
57
|
+
],
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "git+https://github.com/twinfoundation/blob-storage/issues"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://twindev.org"
|
|
43
62
|
}
|