@twin.org/blob-storage-rest-client 0.0.1-next.3 → 0.0.1-next.30
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 +42 -17
- package/dist/esm/index.mjs +42 -17
- package/dist/types/blobStorageClient.d.ts +21 -14
- package/docs/changelog.md +29 -1
- package/docs/reference/classes/BlobStorageClient.md +107 -40
- package/package.json +8 -32
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var apiCore = require('@twin.org/api-core');
|
|
4
|
+
var apiModels = require('@twin.org/api-models');
|
|
4
5
|
var core = require('@twin.org/core');
|
|
6
|
+
var web = require('@twin.org/web');
|
|
5
7
|
|
|
6
8
|
// Copyright 2024 IOTA Stiftung.
|
|
7
9
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -28,24 +30,24 @@ class BlobStorageClient extends apiCore.BaseRestClient {
|
|
|
28
30
|
/**
|
|
29
31
|
* Create the blob with some metadata.
|
|
30
32
|
* @param blob The data for the blob in base64 format.
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
+
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
34
|
+
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
33
35
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
34
36
|
* @param namespace The namespace to use for storing, defaults to component configured namespace.
|
|
35
37
|
* @returns The id of the stored blob in urn format.
|
|
36
38
|
*/
|
|
37
|
-
async create(blob,
|
|
39
|
+
async create(blob, encodingFormat, fileExtension, metadata, namespace) {
|
|
38
40
|
core.Guards.stringBase64(this.CLASS_NAME, "blob", blob);
|
|
39
41
|
const response = await this.fetch("/", "POST", {
|
|
40
42
|
body: {
|
|
41
43
|
blob,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
encodingFormat,
|
|
45
|
+
fileExtension,
|
|
44
46
|
metadata,
|
|
45
47
|
namespace
|
|
46
48
|
}
|
|
47
49
|
});
|
|
48
|
-
return response.headers.Location;
|
|
50
|
+
return response.headers[web.HeaderTypes.Location];
|
|
49
51
|
}
|
|
50
52
|
/**
|
|
51
53
|
* Get the blob and metadata.
|
|
@@ -57,6 +59,9 @@ class BlobStorageClient extends apiCore.BaseRestClient {
|
|
|
57
59
|
async get(id, includeContent) {
|
|
58
60
|
core.Urn.guard(this.CLASS_NAME, "id", id);
|
|
59
61
|
const response = await this.fetch("/:id", "GET", {
|
|
62
|
+
headers: {
|
|
63
|
+
[web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
|
|
64
|
+
},
|
|
60
65
|
pathParams: {
|
|
61
66
|
id
|
|
62
67
|
},
|
|
@@ -64,31 +69,26 @@ class BlobStorageClient extends apiCore.BaseRestClient {
|
|
|
64
69
|
includeContent
|
|
65
70
|
}
|
|
66
71
|
});
|
|
67
|
-
return
|
|
68
|
-
blob: response.body.blob,
|
|
69
|
-
mimeType: response.body.mimeType,
|
|
70
|
-
extension: response.body.extension,
|
|
71
|
-
metadata: response.body.metadata
|
|
72
|
-
};
|
|
72
|
+
return response.body;
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Update the blob with metadata.
|
|
76
76
|
* @param id The id of the blob metadata to update.
|
|
77
|
-
* @param
|
|
78
|
-
* @param
|
|
77
|
+
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
78
|
+
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
79
79
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
80
80
|
* @returns Nothing.
|
|
81
81
|
* @throws Not found error if the blob cannot be found.
|
|
82
82
|
*/
|
|
83
|
-
async update(id,
|
|
83
|
+
async update(id, encodingFormat, fileExtension, metadata) {
|
|
84
84
|
core.Urn.guard(this.CLASS_NAME, "id", id);
|
|
85
85
|
await this.fetch("/:id", "PUT", {
|
|
86
86
|
pathParams: {
|
|
87
87
|
id
|
|
88
88
|
},
|
|
89
89
|
body: {
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
encodingFormat,
|
|
91
|
+
fileExtension,
|
|
92
92
|
metadata
|
|
93
93
|
}
|
|
94
94
|
});
|
|
@@ -106,6 +106,31 @@ class BlobStorageClient extends apiCore.BaseRestClient {
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Query all the blob storage entries which match the conditions.
|
|
111
|
+
* @param conditions The conditions to match for the entries.
|
|
112
|
+
* @param orderBy The order for the results, defaults to created.
|
|
113
|
+
* @param orderByDirection The direction for the order, defaults to descending.
|
|
114
|
+
* @param cursor The cursor to request the next page of entries.
|
|
115
|
+
* @param pageSize The suggested number of entries to return in each chunk, in some scenarios can return a different amount.
|
|
116
|
+
* @returns All the entries for the storage matching the conditions,
|
|
117
|
+
* and a cursor which can be used to request more entities.
|
|
118
|
+
*/
|
|
119
|
+
async query(conditions, orderBy, orderByDirection, cursor, pageSize) {
|
|
120
|
+
const response = await this.fetch("/", "GET", {
|
|
121
|
+
headers: {
|
|
122
|
+
[web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
|
|
123
|
+
},
|
|
124
|
+
query: {
|
|
125
|
+
conditions: apiModels.HttpParameterHelper.objectToString(conditions),
|
|
126
|
+
orderBy,
|
|
127
|
+
orderByDirection,
|
|
128
|
+
pageSize,
|
|
129
|
+
cursor
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
return response.body;
|
|
133
|
+
}
|
|
109
134
|
/**
|
|
110
135
|
* Create a download link for the blob.
|
|
111
136
|
* @param id The id of the blob to get in urn format.
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { BaseRestClient } from '@twin.org/api-core';
|
|
2
|
+
import { HttpParameterHelper } from '@twin.org/api-models';
|
|
2
3
|
import { Guards, Urn, StringHelper, Is } from '@twin.org/core';
|
|
4
|
+
import { HeaderTypes, MimeTypes } from '@twin.org/web';
|
|
3
5
|
|
|
4
6
|
// Copyright 2024 IOTA Stiftung.
|
|
5
7
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -26,24 +28,24 @@ class BlobStorageClient extends BaseRestClient {
|
|
|
26
28
|
/**
|
|
27
29
|
* Create the blob with some metadata.
|
|
28
30
|
* @param blob The data for the blob in base64 format.
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
31
|
+
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
32
|
+
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
31
33
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
32
34
|
* @param namespace The namespace to use for storing, defaults to component configured namespace.
|
|
33
35
|
* @returns The id of the stored blob in urn format.
|
|
34
36
|
*/
|
|
35
|
-
async create(blob,
|
|
37
|
+
async create(blob, encodingFormat, fileExtension, metadata, namespace) {
|
|
36
38
|
Guards.stringBase64(this.CLASS_NAME, "blob", blob);
|
|
37
39
|
const response = await this.fetch("/", "POST", {
|
|
38
40
|
body: {
|
|
39
41
|
blob,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
encodingFormat,
|
|
43
|
+
fileExtension,
|
|
42
44
|
metadata,
|
|
43
45
|
namespace
|
|
44
46
|
}
|
|
45
47
|
});
|
|
46
|
-
return response.headers.Location;
|
|
48
|
+
return response.headers[HeaderTypes.Location];
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* Get the blob and metadata.
|
|
@@ -55,6 +57,9 @@ class BlobStorageClient extends BaseRestClient {
|
|
|
55
57
|
async get(id, includeContent) {
|
|
56
58
|
Urn.guard(this.CLASS_NAME, "id", id);
|
|
57
59
|
const response = await this.fetch("/:id", "GET", {
|
|
60
|
+
headers: {
|
|
61
|
+
[HeaderTypes.Accept]: MimeTypes.JsonLd
|
|
62
|
+
},
|
|
58
63
|
pathParams: {
|
|
59
64
|
id
|
|
60
65
|
},
|
|
@@ -62,31 +67,26 @@ class BlobStorageClient extends BaseRestClient {
|
|
|
62
67
|
includeContent
|
|
63
68
|
}
|
|
64
69
|
});
|
|
65
|
-
return
|
|
66
|
-
blob: response.body.blob,
|
|
67
|
-
mimeType: response.body.mimeType,
|
|
68
|
-
extension: response.body.extension,
|
|
69
|
-
metadata: response.body.metadata
|
|
70
|
-
};
|
|
70
|
+
return response.body;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Update the blob with metadata.
|
|
74
74
|
* @param id The id of the blob metadata to update.
|
|
75
|
-
* @param
|
|
76
|
-
* @param
|
|
75
|
+
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
76
|
+
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
77
77
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
78
78
|
* @returns Nothing.
|
|
79
79
|
* @throws Not found error if the blob cannot be found.
|
|
80
80
|
*/
|
|
81
|
-
async update(id,
|
|
81
|
+
async update(id, encodingFormat, fileExtension, metadata) {
|
|
82
82
|
Urn.guard(this.CLASS_NAME, "id", id);
|
|
83
83
|
await this.fetch("/:id", "PUT", {
|
|
84
84
|
pathParams: {
|
|
85
85
|
id
|
|
86
86
|
},
|
|
87
87
|
body: {
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
encodingFormat,
|
|
89
|
+
fileExtension,
|
|
90
90
|
metadata
|
|
91
91
|
}
|
|
92
92
|
});
|
|
@@ -104,6 +104,31 @@ class BlobStorageClient extends BaseRestClient {
|
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Query all the blob storage entries which match the conditions.
|
|
109
|
+
* @param conditions The conditions to match for the entries.
|
|
110
|
+
* @param orderBy The order for the results, defaults to created.
|
|
111
|
+
* @param orderByDirection The direction for the order, defaults to descending.
|
|
112
|
+
* @param cursor The cursor to request the next page of entries.
|
|
113
|
+
* @param pageSize The suggested number of entries to return in each chunk, in some scenarios can return a different amount.
|
|
114
|
+
* @returns All the entries for the storage matching the conditions,
|
|
115
|
+
* and a cursor which can be used to request more entities.
|
|
116
|
+
*/
|
|
117
|
+
async query(conditions, orderBy, orderByDirection, cursor, pageSize) {
|
|
118
|
+
const response = await this.fetch("/", "GET", {
|
|
119
|
+
headers: {
|
|
120
|
+
[HeaderTypes.Accept]: MimeTypes.JsonLd
|
|
121
|
+
},
|
|
122
|
+
query: {
|
|
123
|
+
conditions: HttpParameterHelper.objectToString(conditions),
|
|
124
|
+
orderBy,
|
|
125
|
+
orderByDirection,
|
|
126
|
+
pageSize,
|
|
127
|
+
cursor
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
return response.body;
|
|
131
|
+
}
|
|
107
132
|
/**
|
|
108
133
|
* Create a download link for the blob.
|
|
109
134
|
* @param id The id of the blob to get in urn format.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BaseRestClient } from "@twin.org/api-core";
|
|
2
|
-
import type
|
|
3
|
-
import type { IBlobStorageComponent } from "@twin.org/blob-storage-models";
|
|
2
|
+
import { type IBaseRestClientConfig } from "@twin.org/api-models";
|
|
3
|
+
import type { IBlobStorageComponent, IBlobStorageEntry, IBlobStorageEntryList } from "@twin.org/blob-storage-models";
|
|
4
4
|
import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
5
|
+
import type { EntityCondition, SortDirection } from "@twin.org/entity";
|
|
5
6
|
/**
|
|
6
7
|
* Client for performing blob storage through to REST endpoints.
|
|
7
8
|
*/
|
|
@@ -18,13 +19,13 @@ export declare class BlobStorageClient extends BaseRestClient implements IBlobSt
|
|
|
18
19
|
/**
|
|
19
20
|
* Create the blob with some metadata.
|
|
20
21
|
* @param blob The data for the blob in base64 format.
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
22
|
+
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
23
|
+
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
23
24
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
24
25
|
* @param namespace The namespace to use for storing, defaults to component configured namespace.
|
|
25
26
|
* @returns The id of the stored blob in urn format.
|
|
26
27
|
*/
|
|
27
|
-
create(blob: string,
|
|
28
|
+
create(blob: string, encodingFormat?: string, fileExtension?: string, metadata?: IJsonLdNodeObject, namespace?: string): Promise<string>;
|
|
28
29
|
/**
|
|
29
30
|
* Get the blob and metadata.
|
|
30
31
|
* @param id The id of the blob to get in urn format.
|
|
@@ -32,28 +33,34 @@ export declare class BlobStorageClient extends BaseRestClient implements IBlobSt
|
|
|
32
33
|
* @returns The metadata and data for the blob if it can be found.
|
|
33
34
|
* @throws Not found error if the blob cannot be found.
|
|
34
35
|
*/
|
|
35
|
-
get(id: string, includeContent: boolean): Promise<
|
|
36
|
-
blob?: string;
|
|
37
|
-
mimeType?: string;
|
|
38
|
-
extension?: string;
|
|
39
|
-
metadata?: IJsonLdNodeObject;
|
|
40
|
-
}>;
|
|
36
|
+
get(id: string, includeContent: boolean): Promise<IBlobStorageEntry>;
|
|
41
37
|
/**
|
|
42
38
|
* Update the blob with metadata.
|
|
43
39
|
* @param id The id of the blob metadata to update.
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
40
|
+
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
41
|
+
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
46
42
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
47
43
|
* @returns Nothing.
|
|
48
44
|
* @throws Not found error if the blob cannot be found.
|
|
49
45
|
*/
|
|
50
|
-
update(id: string,
|
|
46
|
+
update(id: string, encodingFormat?: string, fileExtension?: string, metadata?: IJsonLdNodeObject): Promise<void>;
|
|
51
47
|
/**
|
|
52
48
|
* Remove the blob.
|
|
53
49
|
* @param id The id of the blob to remove in urn format.
|
|
54
50
|
* @returns Nothing.
|
|
55
51
|
*/
|
|
56
52
|
remove(id: string): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Query all the blob storage entries which match the conditions.
|
|
55
|
+
* @param conditions The conditions to match for the entries.
|
|
56
|
+
* @param orderBy The order for the results, defaults to created.
|
|
57
|
+
* @param orderByDirection The direction for the order, defaults to descending.
|
|
58
|
+
* @param cursor The cursor to request the next page of entries.
|
|
59
|
+
* @param pageSize The suggested number of entries to return in each chunk, in some scenarios can return a different amount.
|
|
60
|
+
* @returns All the entries for the storage matching the conditions,
|
|
61
|
+
* and a cursor which can be used to request more entities.
|
|
62
|
+
*/
|
|
63
|
+
query(conditions?: EntityCondition<IBlobStorageEntry>, orderBy?: keyof Pick<IBlobStorageEntry, "dateCreated" | "dateModified">, orderByDirection?: SortDirection, cursor?: string, pageSize?: number): Promise<IBlobStorageEntryList>;
|
|
57
64
|
/**
|
|
58
65
|
* Create a download link for the blob.
|
|
59
66
|
* @param id The id of the blob to get in urn format.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @twin.org/blob-storage-rest-client - Changelog
|
|
2
2
|
|
|
3
|
-
## v0.0.1-next.
|
|
3
|
+
## [0.0.1-next.30](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.1-next.29...blob-storage-rest-client-v0.0.1-next.30) (2025-04-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
|
|
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.29 to 0.0.1-next.30
|
|
16
|
+
|
|
17
|
+
## [0.0.1-next.29](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.1-next.28...blob-storage-rest-client-v0.0.1-next.29) (2025-03-28)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Miscellaneous Chores
|
|
21
|
+
|
|
22
|
+
* **blob-storage-rest-client:** 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.1-next.28 to 0.0.1-next.29
|
|
30
|
+
|
|
31
|
+
## v0.0.1-next.28
|
|
4
32
|
|
|
5
33
|
- Initial Release
|
|
@@ -12,21 +12,23 @@ Client for performing blob storage through to REST endpoints.
|
|
|
12
12
|
|
|
13
13
|
## Constructors
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### Constructor
|
|
16
16
|
|
|
17
|
-
> **new BlobStorageClient**(`config`):
|
|
17
|
+
> **new BlobStorageClient**(`config`): `BlobStorageClient`
|
|
18
18
|
|
|
19
19
|
Create a new instance of BlobStorageClient.
|
|
20
20
|
|
|
21
21
|
#### Parameters
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
##### config
|
|
24
|
+
|
|
25
|
+
`IBaseRestClientConfig`
|
|
24
26
|
|
|
25
27
|
The configuration for the client.
|
|
26
28
|
|
|
27
29
|
#### Returns
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
`BlobStorageClient`
|
|
30
32
|
|
|
31
33
|
#### Overrides
|
|
32
34
|
|
|
@@ -48,29 +50,39 @@ Runtime name for the class.
|
|
|
48
50
|
|
|
49
51
|
### create()
|
|
50
52
|
|
|
51
|
-
> **create**(`blob`, `
|
|
53
|
+
> **create**(`blob`, `encodingFormat?`, `fileExtension?`, `metadata?`, `namespace?`): `Promise`\<`string`\>
|
|
52
54
|
|
|
53
55
|
Create the blob with some metadata.
|
|
54
56
|
|
|
55
57
|
#### Parameters
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
##### blob
|
|
60
|
+
|
|
61
|
+
`string`
|
|
58
62
|
|
|
59
63
|
The data for the blob in base64 format.
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
##### encodingFormat?
|
|
66
|
+
|
|
67
|
+
`string`
|
|
62
68
|
|
|
63
69
|
Mime type for the blob, will be detected if left undefined.
|
|
64
70
|
|
|
65
|
-
|
|
71
|
+
##### fileExtension?
|
|
72
|
+
|
|
73
|
+
`string`
|
|
66
74
|
|
|
67
75
|
Extension for the blob, will be detected if left undefined.
|
|
68
76
|
|
|
69
|
-
|
|
77
|
+
##### metadata?
|
|
78
|
+
|
|
79
|
+
`IJsonLdNodeObject`
|
|
70
80
|
|
|
71
81
|
Data for the custom metadata as JSON-LD.
|
|
72
82
|
|
|
73
|
-
|
|
83
|
+
##### namespace?
|
|
84
|
+
|
|
85
|
+
`string`
|
|
74
86
|
|
|
75
87
|
The namespace to use for storing, defaults to component configured namespace.
|
|
76
88
|
|
|
@@ -88,42 +100,30 @@ The id of the stored blob in urn format.
|
|
|
88
100
|
|
|
89
101
|
### get()
|
|
90
102
|
|
|
91
|
-
> **get**(`id`, `includeContent`): `Promise`\<`
|
|
103
|
+
> **get**(`id`, `includeContent`): `Promise`\<`IBlobStorageEntry`\>
|
|
92
104
|
|
|
93
105
|
Get the blob and metadata.
|
|
94
106
|
|
|
95
107
|
#### Parameters
|
|
96
108
|
|
|
97
|
-
|
|
109
|
+
##### id
|
|
110
|
+
|
|
111
|
+
`string`
|
|
98
112
|
|
|
99
113
|
The id of the blob to get in urn format.
|
|
100
114
|
|
|
101
|
-
|
|
115
|
+
##### includeContent
|
|
116
|
+
|
|
117
|
+
`boolean`
|
|
102
118
|
|
|
103
119
|
Include the content, or just get the metadata.
|
|
104
120
|
|
|
105
121
|
#### Returns
|
|
106
122
|
|
|
107
|
-
`Promise`\<`
|
|
123
|
+
`Promise`\<`IBlobStorageEntry`\>
|
|
108
124
|
|
|
109
125
|
The metadata and data for the blob if it can be found.
|
|
110
126
|
|
|
111
|
-
##### blob?
|
|
112
|
-
|
|
113
|
-
> `optional` **blob**: `string`
|
|
114
|
-
|
|
115
|
-
##### mimeType?
|
|
116
|
-
|
|
117
|
-
> `optional` **mimeType**: `string`
|
|
118
|
-
|
|
119
|
-
##### extension?
|
|
120
|
-
|
|
121
|
-
> `optional` **extension**: `string`
|
|
122
|
-
|
|
123
|
-
##### metadata?
|
|
124
|
-
|
|
125
|
-
> `optional` **metadata**: `IJsonLdNodeObject`
|
|
126
|
-
|
|
127
127
|
#### Throws
|
|
128
128
|
|
|
129
129
|
Not found error if the blob cannot be found.
|
|
@@ -136,25 +136,33 @@ Not found error if the blob cannot be found.
|
|
|
136
136
|
|
|
137
137
|
### update()
|
|
138
138
|
|
|
139
|
-
> **update**(`id`, `
|
|
139
|
+
> **update**(`id`, `encodingFormat?`, `fileExtension?`, `metadata?`): `Promise`\<`void`\>
|
|
140
140
|
|
|
141
141
|
Update the blob with metadata.
|
|
142
142
|
|
|
143
143
|
#### Parameters
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
##### id
|
|
146
|
+
|
|
147
|
+
`string`
|
|
146
148
|
|
|
147
149
|
The id of the blob metadata to update.
|
|
148
150
|
|
|
149
|
-
|
|
151
|
+
##### encodingFormat?
|
|
152
|
+
|
|
153
|
+
`string`
|
|
150
154
|
|
|
151
155
|
Mime type for the blob, will be detected if left undefined.
|
|
152
156
|
|
|
153
|
-
|
|
157
|
+
##### fileExtension?
|
|
158
|
+
|
|
159
|
+
`string`
|
|
154
160
|
|
|
155
161
|
Extension for the blob, will be detected if left undefined.
|
|
156
162
|
|
|
157
|
-
|
|
163
|
+
##### metadata?
|
|
164
|
+
|
|
165
|
+
`IJsonLdNodeObject`
|
|
158
166
|
|
|
159
167
|
Data for the custom metadata as JSON-LD.
|
|
160
168
|
|
|
@@ -182,7 +190,9 @@ Remove the blob.
|
|
|
182
190
|
|
|
183
191
|
#### Parameters
|
|
184
192
|
|
|
185
|
-
|
|
193
|
+
##### id
|
|
194
|
+
|
|
195
|
+
`string`
|
|
186
196
|
|
|
187
197
|
The id of the blob to remove in urn format.
|
|
188
198
|
|
|
@@ -198,23 +208,80 @@ Nothing.
|
|
|
198
208
|
|
|
199
209
|
***
|
|
200
210
|
|
|
211
|
+
### query()
|
|
212
|
+
|
|
213
|
+
> **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `cursor?`, `pageSize?`): `Promise`\<`IBlobStorageEntryList`\>
|
|
214
|
+
|
|
215
|
+
Query all the blob storage entries which match the conditions.
|
|
216
|
+
|
|
217
|
+
#### Parameters
|
|
218
|
+
|
|
219
|
+
##### conditions?
|
|
220
|
+
|
|
221
|
+
`EntityCondition`\<`IBlobStorageEntry`\>
|
|
222
|
+
|
|
223
|
+
The conditions to match for the entries.
|
|
224
|
+
|
|
225
|
+
##### orderBy?
|
|
226
|
+
|
|
227
|
+
The order for the results, defaults to created.
|
|
228
|
+
|
|
229
|
+
`"dateCreated"` | `"dateModified"`
|
|
230
|
+
|
|
231
|
+
##### orderByDirection?
|
|
232
|
+
|
|
233
|
+
`SortDirection`
|
|
234
|
+
|
|
235
|
+
The direction for the order, defaults to descending.
|
|
236
|
+
|
|
237
|
+
##### cursor?
|
|
238
|
+
|
|
239
|
+
`string`
|
|
240
|
+
|
|
241
|
+
The cursor to request the next page of entries.
|
|
242
|
+
|
|
243
|
+
##### pageSize?
|
|
244
|
+
|
|
245
|
+
`number`
|
|
246
|
+
|
|
247
|
+
The suggested number of entries to return in each chunk, in some scenarios can return a different amount.
|
|
248
|
+
|
|
249
|
+
#### Returns
|
|
250
|
+
|
|
251
|
+
`Promise`\<`IBlobStorageEntryList`\>
|
|
252
|
+
|
|
253
|
+
All the entries for the storage matching the conditions,
|
|
254
|
+
and a cursor which can be used to request more entities.
|
|
255
|
+
|
|
256
|
+
#### Implementation of
|
|
257
|
+
|
|
258
|
+
`IBlobStorageComponent.query`
|
|
259
|
+
|
|
260
|
+
***
|
|
261
|
+
|
|
201
262
|
### createDownloadLink()
|
|
202
263
|
|
|
203
|
-
> **createDownloadLink**(`id`, `download
|
|
264
|
+
> **createDownloadLink**(`id`, `download?`, `filename?`): `string`
|
|
204
265
|
|
|
205
266
|
Create a download link for the blob.
|
|
206
267
|
|
|
207
268
|
#### Parameters
|
|
208
269
|
|
|
209
|
-
|
|
270
|
+
##### id
|
|
271
|
+
|
|
272
|
+
`string`
|
|
210
273
|
|
|
211
274
|
The id of the blob to get in urn format.
|
|
212
275
|
|
|
213
|
-
|
|
276
|
+
##### download?
|
|
277
|
+
|
|
278
|
+
`boolean`
|
|
214
279
|
|
|
215
280
|
Should the content disposition be set to download.
|
|
216
281
|
|
|
217
|
-
|
|
282
|
+
##### filename?
|
|
283
|
+
|
|
284
|
+
`string`
|
|
218
285
|
|
|
219
286
|
The filename to use for the download.
|
|
220
287
|
|
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.30",
|
|
4
4
|
"description": "Blob storage implementation which can connect to REST endpoints",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,50 +13,26 @@
|
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"clean": "rimraf dist coverage docs/reference",
|
|
18
|
-
"build": "tspc",
|
|
19
|
-
"test": "vitest --run --config ./vitest.config.ts --no-cache",
|
|
20
|
-
"coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
|
|
21
|
-
"bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
|
|
22
|
-
"bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
|
|
23
|
-
"bundle": "npm run bundle:esm && npm run bundle:cjs",
|
|
24
|
-
"docs:clean": "rimraf docs/reference",
|
|
25
|
-
"docs:generate": "typedoc",
|
|
26
|
-
"docs": "npm run docs:clean && npm run docs:generate",
|
|
27
|
-
"dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
|
|
28
|
-
},
|
|
29
16
|
"dependencies": {
|
|
30
17
|
"@twin.org/api-core": "next",
|
|
31
18
|
"@twin.org/api-models": "next",
|
|
32
|
-
"@twin.org/blob-storage-models": "0.0.1-next.
|
|
19
|
+
"@twin.org/blob-storage-models": "0.0.1-next.30",
|
|
33
20
|
"@twin.org/core": "next",
|
|
34
21
|
"@twin.org/data-json-ld": "next",
|
|
35
|
-
"@twin.org/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"@twin.org/nameof-transformer": "next",
|
|
39
|
-
"@vitest/coverage-v8": "2.1.1",
|
|
40
|
-
"copyfiles": "2.4.1",
|
|
41
|
-
"rimraf": "6.0.1",
|
|
42
|
-
"rollup": "4.22.0",
|
|
43
|
-
"rollup-plugin-typescript2": "0.36.0",
|
|
44
|
-
"ts-patch": "3.2.1",
|
|
45
|
-
"typedoc": "0.26.7",
|
|
46
|
-
"typedoc-plugin-markdown": "4.2.7",
|
|
47
|
-
"typescript": "5.6.2",
|
|
48
|
-
"vitest": "2.1.1"
|
|
22
|
+
"@twin.org/entity": "next",
|
|
23
|
+
"@twin.org/nameof": "next",
|
|
24
|
+
"@twin.org/web": "next"
|
|
49
25
|
},
|
|
50
26
|
"main": "./dist/cjs/index.cjs",
|
|
51
27
|
"module": "./dist/esm/index.mjs",
|
|
52
28
|
"types": "./dist/types/index.d.ts",
|
|
53
29
|
"exports": {
|
|
54
30
|
".": {
|
|
31
|
+
"types": "./dist/types/index.d.ts",
|
|
55
32
|
"require": "./dist/cjs/index.cjs",
|
|
56
|
-
"import": "./dist/esm/index.mjs"
|
|
57
|
-
"types": "./dist/types/index.d.ts"
|
|
33
|
+
"import": "./dist/esm/index.mjs"
|
|
58
34
|
},
|
|
59
|
-
"./locales": "./locales"
|
|
35
|
+
"./locales/*.json": "./locales/*.json"
|
|
60
36
|
},
|
|
61
37
|
"files": [
|
|
62
38
|
"dist/cjs",
|