@twin.org/blob-storage-rest-client 0.0.1-next.34 → 0.0.1-next.36
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
|
@@ -33,10 +33,13 @@ class BlobStorageClient extends apiCore.BaseRestClient {
|
|
|
33
33
|
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
34
34
|
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
35
35
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
36
|
-
* @param
|
|
36
|
+
* @param options Optional options for the creation of the blob.
|
|
37
|
+
* @param options.disableEncryption Disables encryption if enabled by default.
|
|
38
|
+
* @param options.overrideVaultKeyId Use a different vault key id for encryption, if not provided the default vault key id will be used.
|
|
39
|
+
* @param options.namespace The namespace to use for storing, defaults to component configured namespace.
|
|
37
40
|
* @returns The id of the stored blob in urn format.
|
|
38
41
|
*/
|
|
39
|
-
async create(blob, encodingFormat, fileExtension, metadata,
|
|
42
|
+
async create(blob, encodingFormat, fileExtension, metadata, options) {
|
|
40
43
|
core.Guards.stringBase64(this.CLASS_NAME, "blob", blob);
|
|
41
44
|
const response = await this.fetch("/", "POST", {
|
|
42
45
|
body: {
|
|
@@ -44,7 +47,9 @@ class BlobStorageClient extends apiCore.BaseRestClient {
|
|
|
44
47
|
encodingFormat,
|
|
45
48
|
fileExtension,
|
|
46
49
|
metadata,
|
|
47
|
-
|
|
50
|
+
disableEncryption: options?.disableEncryption,
|
|
51
|
+
overrideVaultKeyId: options?.overrideVaultKeyId,
|
|
52
|
+
namespace: options?.namespace
|
|
48
53
|
}
|
|
49
54
|
});
|
|
50
55
|
return response.headers[web.HeaderTypes.Location];
|
|
@@ -52,11 +57,14 @@ class BlobStorageClient extends apiCore.BaseRestClient {
|
|
|
52
57
|
/**
|
|
53
58
|
* Get the blob and metadata.
|
|
54
59
|
* @param id The id of the blob to get in urn format.
|
|
55
|
-
* @param
|
|
60
|
+
* @param options Optional options for the retrieval of the blob.
|
|
61
|
+
* @param options.includeContent Include the content, or just get the metadata.
|
|
62
|
+
* @param options.overrideVaultKeyId Use a different vault key id for decryption, if not provided the default vault key id will be used.
|
|
63
|
+
* @param options.decompress If the content should be decompressed, if it was compressed when stored, defaults to true.
|
|
56
64
|
* @returns The metadata and data for the blob if it can be found.
|
|
57
65
|
* @throws Not found error if the blob cannot be found.
|
|
58
66
|
*/
|
|
59
|
-
async get(id,
|
|
67
|
+
async get(id, options) {
|
|
60
68
|
core.Urn.guard(this.CLASS_NAME, "id", id);
|
|
61
69
|
const response = await this.fetch("/:id", "GET", {
|
|
62
70
|
headers: {
|
|
@@ -66,7 +74,9 @@ class BlobStorageClient extends apiCore.BaseRestClient {
|
|
|
66
74
|
id
|
|
67
75
|
},
|
|
68
76
|
query: {
|
|
69
|
-
includeContent
|
|
77
|
+
includeContent: core.Coerce.string(options?.includeContent),
|
|
78
|
+
decompress: core.Coerce.string(options?.decompress),
|
|
79
|
+
overrideVaultKeyId: options?.overrideVaultKeyId
|
|
70
80
|
}
|
|
71
81
|
});
|
|
72
82
|
return response.body;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseRestClient } from '@twin.org/api-core';
|
|
2
2
|
import { HttpParameterHelper } from '@twin.org/api-models';
|
|
3
|
-
import { Guards, Urn, StringHelper, Is } from '@twin.org/core';
|
|
3
|
+
import { Guards, Urn, Coerce, StringHelper, Is } from '@twin.org/core';
|
|
4
4
|
import { HeaderTypes, MimeTypes } from '@twin.org/web';
|
|
5
5
|
|
|
6
6
|
// Copyright 2024 IOTA Stiftung.
|
|
@@ -31,10 +31,13 @@ class BlobStorageClient extends BaseRestClient {
|
|
|
31
31
|
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
32
32
|
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
33
33
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
34
|
-
* @param
|
|
34
|
+
* @param options Optional options for the creation of the blob.
|
|
35
|
+
* @param options.disableEncryption Disables encryption if enabled by default.
|
|
36
|
+
* @param options.overrideVaultKeyId Use a different vault key id for encryption, if not provided the default vault key id will be used.
|
|
37
|
+
* @param options.namespace The namespace to use for storing, defaults to component configured namespace.
|
|
35
38
|
* @returns The id of the stored blob in urn format.
|
|
36
39
|
*/
|
|
37
|
-
async create(blob, encodingFormat, fileExtension, metadata,
|
|
40
|
+
async create(blob, encodingFormat, fileExtension, metadata, options) {
|
|
38
41
|
Guards.stringBase64(this.CLASS_NAME, "blob", blob);
|
|
39
42
|
const response = await this.fetch("/", "POST", {
|
|
40
43
|
body: {
|
|
@@ -42,7 +45,9 @@ class BlobStorageClient extends BaseRestClient {
|
|
|
42
45
|
encodingFormat,
|
|
43
46
|
fileExtension,
|
|
44
47
|
metadata,
|
|
45
|
-
|
|
48
|
+
disableEncryption: options?.disableEncryption,
|
|
49
|
+
overrideVaultKeyId: options?.overrideVaultKeyId,
|
|
50
|
+
namespace: options?.namespace
|
|
46
51
|
}
|
|
47
52
|
});
|
|
48
53
|
return response.headers[HeaderTypes.Location];
|
|
@@ -50,11 +55,14 @@ class BlobStorageClient extends BaseRestClient {
|
|
|
50
55
|
/**
|
|
51
56
|
* Get the blob and metadata.
|
|
52
57
|
* @param id The id of the blob to get in urn format.
|
|
53
|
-
* @param
|
|
58
|
+
* @param options Optional options for the retrieval of the blob.
|
|
59
|
+
* @param options.includeContent Include the content, or just get the metadata.
|
|
60
|
+
* @param options.overrideVaultKeyId Use a different vault key id for decryption, if not provided the default vault key id will be used.
|
|
61
|
+
* @param options.decompress If the content should be decompressed, if it was compressed when stored, defaults to true.
|
|
54
62
|
* @returns The metadata and data for the blob if it can be found.
|
|
55
63
|
* @throws Not found error if the blob cannot be found.
|
|
56
64
|
*/
|
|
57
|
-
async get(id,
|
|
65
|
+
async get(id, options) {
|
|
58
66
|
Urn.guard(this.CLASS_NAME, "id", id);
|
|
59
67
|
const response = await this.fetch("/:id", "GET", {
|
|
60
68
|
headers: {
|
|
@@ -64,7 +72,9 @@ class BlobStorageClient extends BaseRestClient {
|
|
|
64
72
|
id
|
|
65
73
|
},
|
|
66
74
|
query: {
|
|
67
|
-
includeContent
|
|
75
|
+
includeContent: Coerce.string(options?.includeContent),
|
|
76
|
+
decompress: Coerce.string(options?.decompress),
|
|
77
|
+
overrideVaultKeyId: options?.overrideVaultKeyId
|
|
68
78
|
}
|
|
69
79
|
});
|
|
70
80
|
return response.body;
|
|
@@ -22,18 +22,32 @@ export declare class BlobStorageClient extends BaseRestClient implements IBlobSt
|
|
|
22
22
|
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
23
23
|
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
24
24
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
25
|
-
* @param
|
|
25
|
+
* @param options Optional options for the creation of the blob.
|
|
26
|
+
* @param options.disableEncryption Disables encryption if enabled by default.
|
|
27
|
+
* @param options.overrideVaultKeyId Use a different vault key id for encryption, if not provided the default vault key id will be used.
|
|
28
|
+
* @param options.namespace The namespace to use for storing, defaults to component configured namespace.
|
|
26
29
|
* @returns The id of the stored blob in urn format.
|
|
27
30
|
*/
|
|
28
|
-
create(blob: string, encodingFormat?: string, fileExtension?: string, metadata?: IJsonLdNodeObject,
|
|
31
|
+
create(blob: string, encodingFormat?: string, fileExtension?: string, metadata?: IJsonLdNodeObject, options?: {
|
|
32
|
+
disableEncryption?: boolean;
|
|
33
|
+
overrideVaultKeyId?: string;
|
|
34
|
+
namespace?: string;
|
|
35
|
+
}): Promise<string>;
|
|
29
36
|
/**
|
|
30
37
|
* Get the blob and metadata.
|
|
31
38
|
* @param id The id of the blob to get in urn format.
|
|
32
|
-
* @param
|
|
39
|
+
* @param options Optional options for the retrieval of the blob.
|
|
40
|
+
* @param options.includeContent Include the content, or just get the metadata.
|
|
41
|
+
* @param options.overrideVaultKeyId Use a different vault key id for decryption, if not provided the default vault key id will be used.
|
|
42
|
+
* @param options.decompress If the content should be decompressed, if it was compressed when stored, defaults to true.
|
|
33
43
|
* @returns The metadata and data for the blob if it can be found.
|
|
34
44
|
* @throws Not found error if the blob cannot be found.
|
|
35
45
|
*/
|
|
36
|
-
get(id: string,
|
|
46
|
+
get(id: string, options?: {
|
|
47
|
+
includeContent?: boolean;
|
|
48
|
+
decompress?: boolean;
|
|
49
|
+
overrideVaultKeyId?: string;
|
|
50
|
+
}): Promise<IBlobStorageEntry>;
|
|
37
51
|
/**
|
|
38
52
|
* Update the blob with metadata.
|
|
39
53
|
* @param id The id of the blob metadata to update.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @twin.org/blob-storage-rest-client - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.1-next.36](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.1-next.35...blob-storage-rest-client-v0.0.1-next.36) (2025-06-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add compression support ([67d239b](https://github.com/twinfoundation/blob-storage/commit/67d239bca8321bd90bf4ff93167c564130309730))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/blob-storage-models bumped from 0.0.1-next.35 to 0.0.1-next.36
|
|
16
|
+
|
|
17
|
+
## [0.0.1-next.35](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.1-next.34...blob-storage-rest-client-v0.0.1-next.35) (2025-06-17)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* additional encryption options on per item basis ([4b95a65](https://github.com/twinfoundation/blob-storage/commit/4b95a656d19e3b571cea905e36f29b679b13e1e8))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/blob-storage-models bumped from 0.0.1-next.34 to 0.0.1-next.35
|
|
30
|
+
|
|
3
31
|
## [0.0.1-next.34](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.1-next.33...blob-storage-rest-client-v0.0.1-next.34) (2025-06-12)
|
|
4
32
|
|
|
5
33
|
|
|
@@ -50,7 +50,7 @@ Runtime name for the class.
|
|
|
50
50
|
|
|
51
51
|
### create()
|
|
52
52
|
|
|
53
|
-
> **create**(`blob`, `encodingFormat?`, `fileExtension?`, `metadata?`, `
|
|
53
|
+
> **create**(`blob`, `encodingFormat?`, `fileExtension?`, `metadata?`, `options?`): `Promise`\<`string`\>
|
|
54
54
|
|
|
55
55
|
Create the blob with some metadata.
|
|
56
56
|
|
|
@@ -80,7 +80,23 @@ Extension for the blob, will be detected if left undefined.
|
|
|
80
80
|
|
|
81
81
|
Data for the custom metadata as JSON-LD.
|
|
82
82
|
|
|
83
|
-
#####
|
|
83
|
+
##### options?
|
|
84
|
+
|
|
85
|
+
Optional options for the creation of the blob.
|
|
86
|
+
|
|
87
|
+
###### disableEncryption?
|
|
88
|
+
|
|
89
|
+
`boolean`
|
|
90
|
+
|
|
91
|
+
Disables encryption if enabled by default.
|
|
92
|
+
|
|
93
|
+
###### overrideVaultKeyId?
|
|
94
|
+
|
|
95
|
+
`string`
|
|
96
|
+
|
|
97
|
+
Use a different vault key id for encryption, if not provided the default vault key id will be used.
|
|
98
|
+
|
|
99
|
+
###### namespace?
|
|
84
100
|
|
|
85
101
|
`string`
|
|
86
102
|
|
|
@@ -100,7 +116,7 @@ The id of the stored blob in urn format.
|
|
|
100
116
|
|
|
101
117
|
### get()
|
|
102
118
|
|
|
103
|
-
> **get**(`id`, `
|
|
119
|
+
> **get**(`id`, `options?`): `Promise`\<`IBlobStorageEntry`\>
|
|
104
120
|
|
|
105
121
|
Get the blob and metadata.
|
|
106
122
|
|
|
@@ -112,12 +128,28 @@ Get the blob and metadata.
|
|
|
112
128
|
|
|
113
129
|
The id of the blob to get in urn format.
|
|
114
130
|
|
|
115
|
-
#####
|
|
131
|
+
##### options?
|
|
132
|
+
|
|
133
|
+
Optional options for the retrieval of the blob.
|
|
134
|
+
|
|
135
|
+
###### includeContent?
|
|
116
136
|
|
|
117
137
|
`boolean`
|
|
118
138
|
|
|
119
139
|
Include the content, or just get the metadata.
|
|
120
140
|
|
|
141
|
+
###### decompress?
|
|
142
|
+
|
|
143
|
+
`boolean`
|
|
144
|
+
|
|
145
|
+
If the content should be decompressed, if it was compressed when stored, defaults to true.
|
|
146
|
+
|
|
147
|
+
###### overrideVaultKeyId?
|
|
148
|
+
|
|
149
|
+
`string`
|
|
150
|
+
|
|
151
|
+
Use a different vault key id for decryption, if not provided the default vault key id will be used.
|
|
152
|
+
|
|
121
153
|
#### Returns
|
|
122
154
|
|
|
123
155
|
`Promise`\<`IBlobStorageEntry`\>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/blob-storage-rest-client",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.36",
|
|
4
4
|
"description": "Blob storage implementation which can connect to REST endpoints",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/api-core": "next",
|
|
18
18
|
"@twin.org/api-models": "next",
|
|
19
|
-
"@twin.org/blob-storage-models": "0.0.1-next.
|
|
19
|
+
"@twin.org/blob-storage-models": "0.0.1-next.36",
|
|
20
20
|
"@twin.org/core": "next",
|
|
21
21
|
"@twin.org/data-json-ld": "next",
|
|
22
22
|
"@twin.org/entity": "next",
|