@twin.org/blob-storage-rest-client 0.0.2-next.5 → 0.0.3-next.10

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 CHANGED
@@ -1,6 +1,6 @@
1
- # TWIN Blob Storage Rest Client
1
+ # TWIN Blob Storage REST Client
2
2
 
3
- Blob storage contract implementation which can connect to REST endpoints.
3
+ This package provides client utilities for consuming blob storage service endpoints over HTTP. It helps applications call blob APIs with consistent request construction and response handling.
4
4
 
5
5
  ## Installation
6
6
 
@@ -1,25 +1,31 @@
1
- import { BaseRestClient } from '@twin.org/api-core';
2
- import { HttpParameterHelper } from '@twin.org/api-models';
3
- import { Guards, Urn, Coerce, StringHelper, Is } from '@twin.org/core';
4
- import { HeaderTypes, MimeTypes } from '@twin.org/web';
5
-
6
1
  // Copyright 2024 IOTA Stiftung.
7
2
  // SPDX-License-Identifier: Apache-2.0.
3
+ import { BaseRestClient } from "@twin.org/api-core";
4
+ import { HttpParameterHelper } from "@twin.org/api-models";
5
+ import { Coerce, Guards, Is, StringHelper, Urn } from "@twin.org/core";
6
+ import { HeaderHelper, HeaderTypes, MimeTypes } from "@twin.org/web";
8
7
  /**
9
8
  * Client for performing blob storage through to REST endpoints.
10
9
  */
11
- class BlobStorageRestClient extends BaseRestClient {
10
+ export class BlobStorageRestClient extends BaseRestClient {
12
11
  /**
13
12
  * Runtime name for the class.
14
13
  */
15
14
  static CLASS_NAME = "BlobStorageRestClient";
16
15
  /**
17
- * Create a new instance of BlobStorageClient.
16
+ * Create a new instance of BlobStorageRestClient.
18
17
  * @param config The configuration for the client.
19
18
  */
20
19
  constructor(config) {
21
20
  super(BlobStorageRestClient.CLASS_NAME, config, "blob");
22
21
  }
22
+ /**
23
+ * Returns the class name of the component.
24
+ * @returns The class name of the component.
25
+ */
26
+ className() {
27
+ return BlobStorageRestClient.CLASS_NAME;
28
+ }
23
29
  /**
24
30
  * Create the blob with some metadata.
25
31
  * @param blob The data for the blob in base64 format.
@@ -132,7 +138,11 @@ class BlobStorageRestClient extends BaseRestClient {
132
138
  cursor
133
139
  }
134
140
  });
135
- return response.body;
141
+ return {
142
+ entries: response.body,
143
+ cursor: HeaderHelper.extractLinkHeaderRelation(response.headers?.[HeaderTypes.Link], "next")
144
+ ?.urlQueryParams?.cursor
145
+ };
136
146
  }
137
147
  /**
138
148
  * Create a download link for the blob.
@@ -158,5 +168,4 @@ class BlobStorageRestClient extends BaseRestClient {
158
168
  return link;
159
169
  }
160
170
  }
161
-
162
- export { BlobStorageRestClient };
171
+ //# sourceMappingURL=blobStorageRestClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blobStorageRestClient.js","sourceRoot":"","sources":["../../src/blobStorageRestClient.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport {\n\tHttpParameterHelper,\n\ttype IBaseRestClientConfig,\n\ttype ICreatedResponse,\n\ttype INoContentResponse\n} from \"@twin.org/api-models\";\nimport type {\n\tIBlobStorageComponent,\n\tIBlobStorageCreateRequest,\n\tIBlobStorageEntry,\n\tIBlobStorageEntryList,\n\tIBlobStorageGetRequest,\n\tIBlobStorageGetResponse,\n\tIBlobStorageListRequest,\n\tIBlobStorageListResponse,\n\tIBlobStorageRemoveRequest,\n\tIBlobStorageUpdateRequest\n} from \"@twin.org/blob-storage-models\";\nimport { Coerce, Guards, Is, StringHelper, Urn } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport type { EntityCondition, SortDirection } from \"@twin.org/entity\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HeaderHelper, HeaderTypes, MimeTypes } from \"@twin.org/web\";\n\n/**\n * Client for performing blob storage through to REST endpoints.\n */\nexport class BlobStorageRestClient extends BaseRestClient implements IBlobStorageComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<BlobStorageRestClient>();\n\n\t/**\n\t * Create a new instance of BlobStorageRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(BlobStorageRestClient.CLASS_NAME, config, \"blob\");\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 BlobStorageRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create the blob with some metadata.\n\t * @param blob The data for the blob in base64 format.\n\t * @param encodingFormat Mime type for the blob, will be detected if left undefined.\n\t * @param fileExtension Extension for the blob, will be detected if left undefined.\n\t * @param metadata Data for the custom metadata as JSON-LD.\n\t * @param options Optional options for the creation of the blob.\n\t * @param options.disableEncryption Disables encryption if enabled by default.\n\t * @param options.overrideVaultKeyId Use a different vault key id for encryption, if not provided the default vault key id will be used.\n\t * @param options.namespace The namespace to use for storing, defaults to component configured namespace.\n\t * @returns The id of the stored blob in urn format.\n\t */\n\tpublic async create(\n\t\tblob: string,\n\t\tencodingFormat?: string,\n\t\tfileExtension?: string,\n\t\tmetadata?: IJsonLdNodeObject,\n\t\toptions?: {\n\t\t\tdisableEncryption?: boolean;\n\t\t\toverrideVaultKeyId?: string;\n\t\t\tnamespace?: string;\n\t\t}\n\t): Promise<string> {\n\t\tGuards.stringBase64(BlobStorageRestClient.CLASS_NAME, nameof(blob), blob);\n\n\t\tconst response = await this.fetch<IBlobStorageCreateRequest, ICreatedResponse>(\"/\", \"POST\", {\n\t\t\tbody: {\n\t\t\t\tblob,\n\t\t\t\tencodingFormat,\n\t\t\t\tfileExtension,\n\t\t\t\tmetadata,\n\t\t\t\tdisableEncryption: options?.disableEncryption,\n\t\t\t\toverrideVaultKeyId: options?.overrideVaultKeyId,\n\t\t\t\tnamespace: options?.namespace\n\t\t\t}\n\t\t});\n\n\t\treturn response.headers[HeaderTypes.Location];\n\t}\n\n\t/**\n\t * Get the blob and metadata.\n\t * @param id The id of the blob to get in urn format.\n\t * @param options Optional options for the retrieval of the blob.\n\t * @param options.includeContent Include the content, or just get the metadata.\n\t * @param options.overrideVaultKeyId Use a different vault key id for decryption, if not provided the default vault key id will be used.\n\t * @param options.decompress If the content should be decompressed, if it was compressed when stored, defaults to true.\n\t * @returns The metadata and data for the blob if it can be found.\n\t * @throws Not found error if the blob cannot be found.\n\t */\n\tpublic async get(\n\t\tid: string,\n\t\toptions?: {\n\t\t\tincludeContent?: boolean;\n\t\t\tdecompress?: boolean;\n\t\t\toverrideVaultKeyId?: string;\n\t\t}\n\t): Promise<IBlobStorageEntry> {\n\t\tUrn.guard(BlobStorageRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tconst response = await this.fetch<IBlobStorageGetRequest, IBlobStorageGetResponse>(\n\t\t\t\"/:id\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t\t},\n\t\t\t\tpathParams: {\n\t\t\t\t\tid\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\tincludeContent: Coerce.string(options?.includeContent),\n\t\t\t\t\tdecompress: Coerce.string(options?.decompress),\n\t\t\t\t\toverrideVaultKeyId: options?.overrideVaultKeyId\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Update the blob with metadata.\n\t * @param id The id of the blob metadata to update.\n\t * @param encodingFormat Mime type for the blob, will be detected if left undefined.\n\t * @param fileExtension Extension for the blob, will be detected if left undefined.\n\t * @param metadata Data for the custom metadata as JSON-LD.\n\t * @returns Nothing.\n\t * @throws Not found error if the blob cannot be found.\n\t */\n\tpublic async update(\n\t\tid: string,\n\t\tencodingFormat?: string,\n\t\tfileExtension?: string,\n\t\tmetadata?: IJsonLdNodeObject\n\t): Promise<void> {\n\t\tUrn.guard(BlobStorageRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tawait this.fetch<IBlobStorageUpdateRequest, INoContentResponse>(\"/:id\", \"PUT\", {\n\t\t\tpathParams: {\n\t\t\t\tid\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tencodingFormat,\n\t\t\t\tfileExtension,\n\t\t\t\tmetadata\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 Nothing.\n\t */\n\tpublic async remove(id: string): Promise<void> {\n\t\tUrn.guard(BlobStorageRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tawait this.fetch<IBlobStorageRemoveRequest, INoContentResponse>(\"/:id\", \"DELETE\", {\n\t\t\tpathParams: {\n\t\t\t\tid\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Query all the blob storage entries which match the conditions.\n\t * @param conditions The conditions to match for the entries.\n\t * @param orderBy The order for the results, defaults to created.\n\t * @param orderByDirection The direction for the order, defaults to descending.\n\t * @param cursor The cursor to request the next page of entries.\n\t * @param limit The suggested number of entries to return in each chunk, in some scenarios can return a different amount.\n\t * @returns All the entries for the storage matching the conditions,\n\t * and a cursor which can be used to request more entities.\n\t */\n\tpublic async query(\n\t\tconditions?: EntityCondition<IBlobStorageEntry>,\n\t\torderBy?: keyof Pick<IBlobStorageEntry, \"dateCreated\" | \"dateModified\">,\n\t\torderByDirection?: SortDirection,\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\tentries: IBlobStorageEntryList;\n\t\tcursor?: string;\n\t}> {\n\t\tconst response = await this.fetch<IBlobStorageListRequest, IBlobStorageListResponse>(\n\t\t\t\"/\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.JsonLd\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\tconditions: HttpParameterHelper.objectToString(conditions),\n\t\t\t\t\torderBy,\n\t\t\t\t\torderByDirection,\n\t\t\t\t\tlimit: Coerce.string(limit),\n\t\t\t\t\tcursor\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn {\n\t\t\tentries: response.body,\n\t\t\tcursor: HeaderHelper.extractLinkHeaderRelation(response.headers?.[HeaderTypes.Link], \"next\")\n\t\t\t\t?.urlQueryParams?.cursor\n\t\t};\n\t}\n\n\t/**\n\t * Create a download link for the blob.\n\t * @param id The id of the blob to get in urn format.\n\t * @param download Should the content disposition be set to download.\n\t * @param filename The filename to use for the download.\n\t * @returns The download link.\n\t */\n\tpublic createDownloadLink(id: string, download?: boolean, filename?: string): string {\n\t\tUrn.guard(BlobStorageRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tlet link = StringHelper.trimTrailingSlashes(this.getEndpointWithPrefix());\n\t\tlink += `/${id}/content`;\n\n\t\tconst downloadQuery: string[] = [];\n\t\tif (download) {\n\t\t\tdownloadQuery.push(\"download=true\");\n\t\t}\n\t\tif (Is.stringValue(filename)) {\n\t\t\tdownloadQuery.push(`filename=${encodeURIComponent(filename)}`);\n\t\t}\n\t\tif (downloadQuery.length > 0) {\n\t\t\tlink += `?${downloadQuery.join(\"&\")}`;\n\t\t}\n\n\t\treturn link;\n\t}\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./blobStorageRestClient.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,4BAA4B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./blobStorageRestClient.js\";\n"]}
@@ -12,10 +12,15 @@ export declare class BlobStorageRestClient extends BaseRestClient implements IBl
12
12
  */
13
13
  static readonly CLASS_NAME: string;
14
14
  /**
15
- * Create a new instance of BlobStorageClient.
15
+ * Create a new instance of BlobStorageRestClient.
16
16
  * @param config The configuration for the client.
17
17
  */
18
18
  constructor(config: IBaseRestClientConfig);
19
+ /**
20
+ * Returns the class name of the component.
21
+ * @returns The class name of the component.
22
+ */
23
+ className(): string;
19
24
  /**
20
25
  * Create the blob with some metadata.
21
26
  * @param blob The data for the blob in base64 format.
@@ -74,7 +79,10 @@ export declare class BlobStorageRestClient extends BaseRestClient implements IBl
74
79
  * @returns All the entries for the storage matching the conditions,
75
80
  * and a cursor which can be used to request more entities.
76
81
  */
77
- query(conditions?: EntityCondition<IBlobStorageEntry>, orderBy?: keyof Pick<IBlobStorageEntry, "dateCreated" | "dateModified">, orderByDirection?: SortDirection, cursor?: string, limit?: number): Promise<IBlobStorageEntryList>;
82
+ query(conditions?: EntityCondition<IBlobStorageEntry>, orderBy?: keyof Pick<IBlobStorageEntry, "dateCreated" | "dateModified">, orderByDirection?: SortDirection, cursor?: string, limit?: number): Promise<{
83
+ entries: IBlobStorageEntryList;
84
+ cursor?: string;
85
+ }>;
78
86
  /**
79
87
  * Create a download link for the blob.
80
88
  * @param id The id of the blob to get in urn format.
@@ -1 +1 @@
1
- export * from "./blobStorageRestClient";
1
+ export * from "./blobStorageRestClient.js";
package/docs/changelog.md CHANGED
@@ -1,11 +1,166 @@
1
- # @twin.org/blob-storage-rest-client - Changelog
1
+ # Changelog
2
2
 
3
- ## [0.0.2-next.5](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.2-next.4...blob-storage-rest-client-v0.0.2-next.5) (2025-10-09)
3
+ ## [0.0.3-next.10](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.3-next.9...blob-storage-rest-client-v0.0.3-next.10) (2026-05-07)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **blob-storage-rest-client:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.9 to 0.0.3-next.10
16
+
17
+ ## [0.0.3-next.9](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.3-next.8...blob-storage-rest-client-v0.0.3-next.9) (2026-05-07)
18
+
19
+
20
+ ### Features
21
+
22
+ * add compression support ([67d239b](https://github.com/iotaledger/twin-blob-storage/commit/67d239bca8321bd90bf4ff93167c564130309730))
23
+ * add context id features ([#30](https://github.com/iotaledger/twin-blob-storage/issues/30)) ([fbf1c92](https://github.com/iotaledger/twin-blob-storage/commit/fbf1c9276424c841ef5ef3f4de8469ab3fba7e9c))
24
+ * add validate-locales ([f20fcec](https://github.com/iotaledger/twin-blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
25
+ * additional encryption options on per item basis ([4b95a65](https://github.com/iotaledger/twin-blob-storage/commit/4b95a656d19e3b571cea905e36f29b679b13e1e8))
26
+ * eslint migration to flat config ([e4239dd](https://github.com/iotaledger/twin-blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
27
+ * replace nextItem property with Link header ([#37](https://github.com/iotaledger/twin-blob-storage/issues/37)) ([0b68da5](https://github.com/iotaledger/twin-blob-storage/commit/0b68da58549c9e52eb2313ea5a868573840d5ca6))
28
+ * update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
29
+ * update framework core ([ff339fe](https://github.com/iotaledger/twin-blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
30
+ * use shared store mechanism ([#12](https://github.com/iotaledger/twin-blob-storage/issues/12)) ([cae8110](https://github.com/iotaledger/twin-blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
31
+
32
+
33
+ ### Dependencies
34
+
35
+ * The following workspace dependencies were updated
36
+ * dependencies
37
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.8 to 0.0.3-next.9
38
+
39
+ ## [0.0.3-next.8](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.3-next.7...blob-storage-rest-client-v0.0.3-next.8) (2026-05-07)
40
+
41
+
42
+ ### Miscellaneous Chores
43
+
44
+ * **blob-storage-rest-client:** Synchronize repo versions
45
+
46
+
47
+ ### Dependencies
48
+
49
+ * The following workspace dependencies were updated
50
+ * dependencies
51
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.7 to 0.0.3-next.8
52
+
53
+ ## [0.0.3-next.7](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.3-next.6...blob-storage-rest-client-v0.0.3-next.7) (2026-02-25)
54
+
55
+
56
+ ### Miscellaneous Chores
57
+
58
+ * **blob-storage-rest-client:** Synchronize repo versions
59
+
60
+
61
+ ### Dependencies
62
+
63
+ * The following workspace dependencies were updated
64
+ * dependencies
65
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.6 to 0.0.3-next.7
66
+
67
+ ## [0.0.3-next.6](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.3-next.5...blob-storage-rest-client-v0.0.3-next.6) (2026-02-09)
68
+
69
+
70
+ ### Miscellaneous Chores
71
+
72
+ * **blob-storage-rest-client:** Synchronize repo versions
73
+
74
+
75
+ ### Dependencies
76
+
77
+ * The following workspace dependencies were updated
78
+ * dependencies
79
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.5 to 0.0.3-next.6
80
+
81
+ ## [0.0.3-next.5](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.3-next.4...blob-storage-rest-client-v0.0.3-next.5) (2026-01-26)
82
+
83
+
84
+ ### Miscellaneous Chores
85
+
86
+ * **blob-storage-rest-client:** Synchronize repo versions
87
+
88
+
89
+ ### Dependencies
90
+
91
+ * The following workspace dependencies were updated
92
+ * dependencies
93
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.4 to 0.0.3-next.5
94
+
95
+ ## [0.0.3-next.4](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.3-next.3...blob-storage-rest-client-v0.0.3-next.4) (2026-01-23)
96
+
97
+
98
+ ### Features
99
+
100
+ * replace nextItem property with Link header ([#37](https://github.com/iotaledger/twin-blob-storage/issues/37)) ([0b68da5](https://github.com/iotaledger/twin-blob-storage/commit/0b68da58549c9e52eb2313ea5a868573840d5ca6))
101
+
102
+
103
+ ### Dependencies
104
+
105
+ * The following workspace dependencies were updated
106
+ * dependencies
107
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.3 to 0.0.3-next.4
108
+
109
+ ## [0.0.3-next.3](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.3-next.2...blob-storage-rest-client-v0.0.3-next.3) (2026-01-21)
110
+
111
+
112
+ ### Miscellaneous Chores
113
+
114
+ * **blob-storage-rest-client:** Synchronize repo versions
115
+
116
+
117
+ ### Dependencies
118
+
119
+ * The following workspace dependencies were updated
120
+ * dependencies
121
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.2 to 0.0.3-next.3
122
+
123
+ ## [0.0.3-next.2](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.3-next.1...blob-storage-rest-client-v0.0.3-next.2) (2026-01-14)
124
+
125
+
126
+ ### Miscellaneous Chores
127
+
128
+ * **blob-storage-rest-client:** Synchronize repo versions
129
+
130
+
131
+ ### Dependencies
132
+
133
+ * The following workspace dependencies were updated
134
+ * dependencies
135
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.1 to 0.0.3-next.2
136
+
137
+ ## [0.0.3-next.1](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.3-next.0...blob-storage-rest-client-v0.0.3-next.1) (2025-11-11)
138
+
139
+
140
+ ### Features
141
+
142
+ * add compression support ([67d239b](https://github.com/iotaledger/twin-blob-storage/commit/67d239bca8321bd90bf4ff93167c564130309730))
143
+ * add context id features ([#30](https://github.com/iotaledger/twin-blob-storage/issues/30)) ([fbf1c92](https://github.com/iotaledger/twin-blob-storage/commit/fbf1c9276424c841ef5ef3f4de8469ab3fba7e9c))
144
+ * add validate-locales ([f20fcec](https://github.com/iotaledger/twin-blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
145
+ * additional encryption options on per item basis ([4b95a65](https://github.com/iotaledger/twin-blob-storage/commit/4b95a656d19e3b571cea905e36f29b679b13e1e8))
146
+ * eslint migration to flat config ([e4239dd](https://github.com/iotaledger/twin-blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
147
+ * update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
148
+ * update framework core ([ff339fe](https://github.com/iotaledger/twin-blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
149
+ * use shared store mechanism ([#12](https://github.com/iotaledger/twin-blob-storage/issues/12)) ([cae8110](https://github.com/iotaledger/twin-blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
150
+
151
+
152
+ ### Dependencies
153
+
154
+ * The following workspace dependencies were updated
155
+ * dependencies
156
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.0 to 0.0.3-next.1
157
+
158
+ ## [0.0.2-next.5](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.2-next.4...blob-storage-rest-client-v0.0.2-next.5) (2025-10-09)
4
159
 
5
160
 
6
161
  ### Features
7
162
 
8
- * add validate-locales ([f20fcec](https://github.com/twinfoundation/blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
163
+ * add validate-locales ([f20fcec](https://github.com/iotaledger/twin-blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
9
164
 
10
165
 
11
166
  ### Dependencies
@@ -14,7 +169,7 @@
14
169
  * dependencies
15
170
  * @twin.org/blob-storage-models bumped from 0.0.2-next.4 to 0.0.2-next.5
16
171
 
17
- ## [0.0.2-next.4](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.2-next.3...blob-storage-rest-client-v0.0.2-next.4) (2025-10-02)
172
+ ## [0.0.2-next.4](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.2-next.3...blob-storage-rest-client-v0.0.2-next.4) (2025-10-02)
18
173
 
19
174
 
20
175
  ### Miscellaneous Chores
@@ -28,12 +183,12 @@
28
183
  * dependencies
29
184
  * @twin.org/blob-storage-models bumped from 0.0.2-next.3 to 0.0.2-next.4
30
185
 
31
- ## [0.0.2-next.3](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.2-next.2...blob-storage-rest-client-v0.0.2-next.3) (2025-08-29)
186
+ ## [0.0.2-next.3](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.2-next.2...blob-storage-rest-client-v0.0.2-next.3) (2025-08-29)
32
187
 
33
188
 
34
189
  ### Features
35
190
 
36
- * eslint migration to flat config ([e4239dd](https://github.com/twinfoundation/blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
191
+ * eslint migration to flat config ([e4239dd](https://github.com/iotaledger/twin-blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
37
192
 
38
193
 
39
194
  ### Dependencies
@@ -42,12 +197,12 @@
42
197
  * dependencies
43
198
  * @twin.org/blob-storage-models bumped from 0.0.2-next.2 to 0.0.2-next.3
44
199
 
45
- ## [0.0.2-next.2](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.2-next.1...blob-storage-rest-client-v0.0.2-next.2) (2025-08-20)
200
+ ## [0.0.2-next.2](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.2-next.1...blob-storage-rest-client-v0.0.2-next.2) (2025-08-20)
46
201
 
47
202
 
48
203
  ### Features
49
204
 
50
- * update framework core ([ff339fe](https://github.com/twinfoundation/blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
205
+ * update framework core ([ff339fe](https://github.com/iotaledger/twin-blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
51
206
 
52
207
 
53
208
  ### Dependencies
@@ -56,15 +211,15 @@
56
211
  * dependencies
57
212
  * @twin.org/blob-storage-models bumped from 0.0.2-next.1 to 0.0.2-next.2
58
213
 
59
- ## [0.0.2-next.1](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.2-next.0...blob-storage-rest-client-v0.0.2-next.1) (2025-07-24)
214
+ ## [0.0.2-next.1](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.2-next.0...blob-storage-rest-client-v0.0.2-next.1) (2025-07-24)
60
215
 
61
216
 
62
217
  ### Features
63
218
 
64
- * add compression support ([67d239b](https://github.com/twinfoundation/blob-storage/commit/67d239bca8321bd90bf4ff93167c564130309730))
65
- * additional encryption options on per item basis ([4b95a65](https://github.com/twinfoundation/blob-storage/commit/4b95a656d19e3b571cea905e36f29b679b13e1e8))
66
- * update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
67
- * use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
219
+ * add compression support ([67d239b](https://github.com/iotaledger/twin-blob-storage/commit/67d239bca8321bd90bf4ff93167c564130309730))
220
+ * additional encryption options on per item basis ([4b95a65](https://github.com/iotaledger/twin-blob-storage/commit/4b95a656d19e3b571cea905e36f29b679b13e1e8))
221
+ * update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
222
+ * use shared store mechanism ([#12](https://github.com/iotaledger/twin-blob-storage/issues/12)) ([cae8110](https://github.com/iotaledger/twin-blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
68
223
 
69
224
 
70
225
  ### Dependencies
@@ -78,7 +233,7 @@
78
233
 
79
234
  ### Features
80
235
 
81
- * release to production ([eacfe75](https://github.com/twinfoundation/blob-storage/commit/eacfe754a0dcd9243d9e13d86422327d0a605164))
236
+ * release to production ([eacfe75](https://github.com/iotaledger/twin-blob-storage/commit/eacfe754a0dcd9243d9e13d86422327d0a605164))
82
237
 
83
238
 
84
239
  ### Dependencies
@@ -87,7 +242,7 @@
87
242
  * dependencies
88
243
  * @twin.org/blob-storage-models bumped from ^0.0.0 to ^0.0.1
89
244
 
90
- ## [0.0.1-next.37](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.1-next.36...blob-storage-rest-client-v0.0.1-next.37) (2025-06-20)
245
+ ## [0.0.1-next.37](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.1-next.36...blob-storage-rest-client-v0.0.1-next.37) (2025-06-20)
91
246
 
92
247
 
93
248
  ### Miscellaneous Chores
@@ -101,12 +256,12 @@
101
256
  * dependencies
102
257
  * @twin.org/blob-storage-models bumped from 0.0.1-next.36 to 0.0.1-next.37
103
258
 
104
- ## [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)
259
+ ## [0.0.1-next.36](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.1-next.35...blob-storage-rest-client-v0.0.1-next.36) (2025-06-19)
105
260
 
106
261
 
107
262
  ### Features
108
263
 
109
- * add compression support ([67d239b](https://github.com/twinfoundation/blob-storage/commit/67d239bca8321bd90bf4ff93167c564130309730))
264
+ * add compression support ([67d239b](https://github.com/iotaledger/twin-blob-storage/commit/67d239bca8321bd90bf4ff93167c564130309730))
110
265
 
111
266
 
112
267
  ### Dependencies
@@ -115,12 +270,12 @@
115
270
  * dependencies
116
271
  * @twin.org/blob-storage-models bumped from 0.0.1-next.35 to 0.0.1-next.36
117
272
 
118
- ## [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)
273
+ ## [0.0.1-next.35](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.1-next.34...blob-storage-rest-client-v0.0.1-next.35) (2025-06-17)
119
274
 
120
275
 
121
276
  ### Features
122
277
 
123
- * additional encryption options on per item basis ([4b95a65](https://github.com/twinfoundation/blob-storage/commit/4b95a656d19e3b571cea905e36f29b679b13e1e8))
278
+ * additional encryption options on per item basis ([4b95a65](https://github.com/iotaledger/twin-blob-storage/commit/4b95a656d19e3b571cea905e36f29b679b13e1e8))
124
279
 
125
280
 
126
281
  ### Dependencies
@@ -129,12 +284,12 @@
129
284
  * dependencies
130
285
  * @twin.org/blob-storage-models bumped from 0.0.1-next.34 to 0.0.1-next.35
131
286
 
132
- ## [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)
287
+ ## [0.0.1-next.34](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.1-next.33...blob-storage-rest-client-v0.0.1-next.34) (2025-06-12)
133
288
 
134
289
 
135
290
  ### Features
136
291
 
137
- * update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
292
+ * update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
138
293
 
139
294
 
140
295
  ### Dependencies
@@ -143,7 +298,7 @@
143
298
  * dependencies
144
299
  * @twin.org/blob-storage-models bumped from 0.0.1-next.33 to 0.0.1-next.34
145
300
 
146
- ## [0.0.1-next.33](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.1-next.32...blob-storage-rest-client-v0.0.1-next.33) (2025-06-03)
301
+ ## [0.0.1-next.33](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.1-next.32...blob-storage-rest-client-v0.0.1-next.33) (2025-06-03)
147
302
 
148
303
 
149
304
  ### Miscellaneous Chores
@@ -157,7 +312,7 @@
157
312
  * dependencies
158
313
  * @twin.org/blob-storage-models bumped from 0.0.1-next.32 to 0.0.1-next.33
159
314
 
160
- ## [0.0.1-next.32](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.1-next.31...blob-storage-rest-client-v0.0.1-next.32) (2025-05-28)
315
+ ## [0.0.1-next.32](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.1-next.31...blob-storage-rest-client-v0.0.1-next.32) (2025-05-28)
161
316
 
162
317
 
163
318
  ### Miscellaneous Chores
@@ -171,7 +326,7 @@
171
326
  * dependencies
172
327
  * @twin.org/blob-storage-models bumped from 0.0.1-next.31 to 0.0.1-next.32
173
328
 
174
- ## [0.0.1-next.31](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.1-next.30...blob-storage-rest-client-v0.0.1-next.31) (2025-05-08)
329
+ ## [0.0.1-next.31](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.1-next.30...blob-storage-rest-client-v0.0.1-next.31) (2025-05-08)
175
330
 
176
331
 
177
332
  ### Miscellaneous Chores
@@ -185,12 +340,12 @@
185
340
  * dependencies
186
341
  * @twin.org/blob-storage-models bumped from 0.0.1-next.30 to 0.0.1-next.31
187
342
 
188
- ## [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)
343
+ ## [0.0.1-next.30](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.1-next.29...blob-storage-rest-client-v0.0.1-next.30) (2025-04-17)
189
344
 
190
345
 
191
346
  ### Features
192
347
 
193
- * use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
348
+ * use shared store mechanism ([#12](https://github.com/iotaledger/twin-blob-storage/issues/12)) ([cae8110](https://github.com/iotaledger/twin-blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
194
349
 
195
350
 
196
351
  ### Dependencies
@@ -199,7 +354,7 @@
199
354
  * dependencies
200
355
  * @twin.org/blob-storage-models bumped from 0.0.1-next.29 to 0.0.1-next.30
201
356
 
202
- ## [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)
357
+ ## [0.0.1-next.29](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-rest-client-v0.0.1-next.28...blob-storage-rest-client-v0.0.1-next.29) (2025-03-28)
203
358
 
204
359
 
205
360
  ### Miscellaneous Chores
package/docs/examples.md CHANGED
@@ -1 +1,98 @@
1
- # @twin.org/blob-storage-rest-client - Examples
1
+ # REST Client Examples
2
+
3
+ Use these snippets to create, query, and manage blobs through HTTP endpoints with strongly typed requests and responses.
4
+
5
+ ## BlobStorageRestClient
6
+
7
+ ```typescript
8
+ import { BlobStorageRestClient } from '@twin.org/blob-storage-rest-client';
9
+
10
+ const client = new BlobStorageRestClient({
11
+ endpoint: 'https://api.example.com',
12
+ pathPrefix: '/v1'
13
+ });
14
+
15
+ console.log(client.className()); // BlobStorageRestClient
16
+ ```
17
+
18
+ ```typescript
19
+ import { BlobStorageRestClient } from '@twin.org/blob-storage-rest-client';
20
+
21
+ const client = new BlobStorageRestClient({
22
+ endpoint: 'https://api.example.com',
23
+ pathPrefix: '/v1'
24
+ });
25
+
26
+ const blobId = await client.create(
27
+ 'SGVsbG8gVFdJTiE=',
28
+ 'text/plain',
29
+ 'txt',
30
+ {
31
+ '@context': 'https://schema.org',
32
+ type: 'DigitalDocument',
33
+ name: 'greeting'
34
+ },
35
+ {
36
+ disableEncryption: false,
37
+ namespace: 'tenant-a'
38
+ }
39
+ );
40
+ console.log(blobId); // blob:urn:blob:...
41
+
42
+ const blobEntry = await client.get(blobId, { includeContent: true, decompress: true });
43
+ console.log(blobEntry.encodingFormat); // text/plain
44
+
45
+ await client.update(blobId, 'text/plain', 'txt', {
46
+ '@context': 'https://schema.org',
47
+ type: 'DigitalDocument',
48
+ name: 'greeting-v2'
49
+ });
50
+ console.log(blobId); // blob:urn:blob:...
51
+ ```
52
+
53
+ ```typescript
54
+ import {
55
+ type EntityCondition,
56
+ ComparisonOperator,
57
+ LogicalOperator,
58
+ SortDirection
59
+ } from '@twin.org/entity';
60
+ import type { IBlobStorageEntry } from '@twin.org/blob-storage-models';
61
+ import { BlobStorageRestClient } from '@twin.org/blob-storage-rest-client';
62
+
63
+ const client = new BlobStorageRestClient({
64
+ endpoint: 'https://api.example.com',
65
+ pathPrefix: '/v1'
66
+ });
67
+
68
+ const conditions: EntityCondition<IBlobStorageEntry> = {
69
+ logicalOperator: LogicalOperator.And,
70
+ conditions: [
71
+ {
72
+ property: 'encodingFormat',
73
+ comparison: ComparisonOperator.Equals,
74
+ value: 'text/plain'
75
+ }
76
+ ]
77
+ };
78
+
79
+ const queryResult = await client.query(conditions, 'dateCreated', SortDirection.Descending, '', 25);
80
+ console.log(queryResult.entries.itemListElement.length); // 1
81
+ console.log(queryResult.cursor); // eyJwYWdlIjoyfQ==
82
+ ```
83
+
84
+ ```typescript
85
+ import { BlobStorageRestClient } from '@twin.org/blob-storage-rest-client';
86
+
87
+ const client = new BlobStorageRestClient({
88
+ endpoint: 'https://api.example.com',
89
+ pathPrefix: '/v1'
90
+ });
91
+
92
+ const blobId = 'blob:urn:blob:file:4ef42bb1b8d31f0c';
93
+ const downloadLink = client.createDownloadLink(blobId, true, 'report.txt');
94
+ console.log(downloadLink); // https://api.example.com/v1/blob/blob:urn:blob:file:4ef42bb1b8d31f0c/content?download=true&filename=report.txt
95
+
96
+ await client.remove(blobId);
97
+ console.log(blobId); // blob:urn:blob:file:4ef42bb1b8d31f0c
98
+ ```
@@ -16,7 +16,7 @@ Client for performing blob storage through to REST endpoints.
16
16
 
17
17
  > **new BlobStorageRestClient**(`config`): `BlobStorageRestClient`
18
18
 
19
- Create a new instance of BlobStorageClient.
19
+ Create a new instance of BlobStorageRestClient.
20
20
 
21
21
  #### Parameters
22
22
 
@@ -36,7 +36,7 @@ The configuration for the client.
36
36
 
37
37
  ## Properties
38
38
 
39
- ### CLASS\_NAME
39
+ ### CLASS\_NAME {#class_name}
40
40
 
41
41
  > `readonly` `static` **CLASS\_NAME**: `string`
42
42
 
@@ -44,7 +44,25 @@ Runtime name for the class.
44
44
 
45
45
  ## Methods
46
46
 
47
- ### create()
47
+ ### className() {#classname}
48
+
49
+ > **className**(): `string`
50
+
51
+ Returns the class name of the component.
52
+
53
+ #### Returns
54
+
55
+ `string`
56
+
57
+ The class name of the component.
58
+
59
+ #### Implementation of
60
+
61
+ `IBlobStorageComponent.className`
62
+
63
+ ***
64
+
65
+ ### create() {#create}
48
66
 
49
67
  > **create**(`blob`, `encodingFormat?`, `fileExtension?`, `metadata?`, `options?`): `Promise`\<`string`\>
50
68
 
@@ -110,7 +128,7 @@ The id of the stored blob in urn format.
110
128
 
111
129
  ***
112
130
 
113
- ### get()
131
+ ### get() {#get}
114
132
 
115
133
  > **get**(`id`, `options?`): `Promise`\<`IBlobStorageEntry`\>
116
134
 
@@ -162,7 +180,7 @@ Not found error if the blob cannot be found.
162
180
 
163
181
  ***
164
182
 
165
- ### update()
183
+ ### update() {#update}
166
184
 
167
185
  > **update**(`id`, `encodingFormat?`, `fileExtension?`, `metadata?`): `Promise`\<`void`\>
168
186
 
@@ -210,7 +228,7 @@ Not found error if the blob cannot be found.
210
228
 
211
229
  ***
212
230
 
213
- ### remove()
231
+ ### remove() {#remove}
214
232
 
215
233
  > **remove**(`id`): `Promise`\<`void`\>
216
234
 
@@ -236,9 +254,9 @@ Nothing.
236
254
 
237
255
  ***
238
256
 
239
- ### query()
257
+ ### query() {#query}
240
258
 
241
- > **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `cursor?`, `limit?`): `Promise`\<`IBlobStorageEntryList`\>
259
+ > **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `cursor?`, `limit?`): `Promise`\<\{ `entries`: `IBlobStorageEntryList`; `cursor?`: `string`; \}\>
242
260
 
243
261
  Query all the blob storage entries which match the conditions.
244
262
 
@@ -252,9 +270,9 @@ The conditions to match for the entries.
252
270
 
253
271
  ##### orderBy?
254
272
 
255
- The order for the results, defaults to created.
273
+ `"dateCreated"` \| `"dateModified"`
256
274
 
257
- `"dateCreated"` | `"dateModified"`
275
+ The order for the results, defaults to created.
258
276
 
259
277
  ##### orderByDirection?
260
278
 
@@ -276,7 +294,7 @@ The suggested number of entries to return in each chunk, in some scenarios can r
276
294
 
277
295
  #### Returns
278
296
 
279
- `Promise`\<`IBlobStorageEntryList`\>
297
+ `Promise`\<\{ `entries`: `IBlobStorageEntryList`; `cursor?`: `string`; \}\>
280
298
 
281
299
  All the entries for the storage matching the conditions,
282
300
  and a cursor which can be used to request more entities.
@@ -287,7 +305,7 @@ and a cursor which can be used to request more entities.
287
305
 
288
306
  ***
289
307
 
290
- ### createDownloadLink()
308
+ ### createDownloadLink() {#createdownloadlink}
291
309
 
292
310
  > **createDownloadLink**(`id`, `download?`, `filename?`): `string`
293
311
 
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@twin.org/blob-storage-rest-client",
3
- "version": "0.0.2-next.5",
4
- "description": "Blob storage implementation which can connect to REST endpoints",
3
+ "version": "0.0.3-next.10",
4
+ "description": "Offers client utilities for calling blob service endpoints with consistent request handling.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/twinfoundation/blob-storage.git",
7
+ "url": "git+https://github.com/iotaledger/blob-storage.git",
8
8
  "directory": "packages/blob-storage-rest-client"
9
9
  },
10
10
  "author": "martyn.janes@iota.org",
@@ -16,27 +16,25 @@
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.2-next.5",
19
+ "@twin.org/blob-storage-models": "0.0.3-next.10",
20
20
  "@twin.org/core": "next",
21
21
  "@twin.org/data-json-ld": "next",
22
22
  "@twin.org/entity": "next",
23
23
  "@twin.org/nameof": "next",
24
24
  "@twin.org/web": "next"
25
25
  },
26
- "main": "./dist/cjs/index.cjs",
27
- "module": "./dist/esm/index.mjs",
26
+ "main": "./dist/es/index.js",
28
27
  "types": "./dist/types/index.d.ts",
29
28
  "exports": {
30
29
  ".": {
31
30
  "types": "./dist/types/index.d.ts",
32
- "require": "./dist/cjs/index.cjs",
33
- "import": "./dist/esm/index.mjs"
31
+ "import": "./dist/es/index.js",
32
+ "default": "./dist/es/index.js"
34
33
  },
35
34
  "./locales/*.json": "./locales/*.json"
36
35
  },
37
36
  "files": [
38
- "dist/cjs",
39
- "dist/esm",
37
+ "dist/es",
40
38
  "dist/types",
41
39
  "locales",
42
40
  "docs"
@@ -54,7 +52,7 @@
54
52
  "binary"
55
53
  ],
56
54
  "bugs": {
57
- "url": "git+https://github.com/twinfoundation/blob-storage/issues"
55
+ "url": "git+https://github.com/iotaledger/blob-storage/issues"
58
56
  },
59
57
  "homepage": "https://twindev.org"
60
58
  }
@@ -1,164 +0,0 @@
1
- 'use strict';
2
-
3
- var apiCore = require('@twin.org/api-core');
4
- var apiModels = require('@twin.org/api-models');
5
- var core = require('@twin.org/core');
6
- var web = require('@twin.org/web');
7
-
8
- // Copyright 2024 IOTA Stiftung.
9
- // SPDX-License-Identifier: Apache-2.0.
10
- /**
11
- * Client for performing blob storage through to REST endpoints.
12
- */
13
- class BlobStorageRestClient extends apiCore.BaseRestClient {
14
- /**
15
- * Runtime name for the class.
16
- */
17
- static CLASS_NAME = "BlobStorageRestClient";
18
- /**
19
- * Create a new instance of BlobStorageClient.
20
- * @param config The configuration for the client.
21
- */
22
- constructor(config) {
23
- super(BlobStorageRestClient.CLASS_NAME, config, "blob");
24
- }
25
- /**
26
- * Create the blob with some metadata.
27
- * @param blob The data for the blob in base64 format.
28
- * @param encodingFormat Mime type for the blob, will be detected if left undefined.
29
- * @param fileExtension Extension for the blob, will be detected if left undefined.
30
- * @param metadata Data for the custom metadata as JSON-LD.
31
- * @param options Optional options for the creation of the blob.
32
- * @param options.disableEncryption Disables encryption if enabled by default.
33
- * @param options.overrideVaultKeyId Use a different vault key id for encryption, if not provided the default vault key id will be used.
34
- * @param options.namespace The namespace to use for storing, defaults to component configured namespace.
35
- * @returns The id of the stored blob in urn format.
36
- */
37
- async create(blob, encodingFormat, fileExtension, metadata, options) {
38
- core.Guards.stringBase64(BlobStorageRestClient.CLASS_NAME, "blob", blob);
39
- const response = await this.fetch("/", "POST", {
40
- body: {
41
- blob,
42
- encodingFormat,
43
- fileExtension,
44
- metadata,
45
- disableEncryption: options?.disableEncryption,
46
- overrideVaultKeyId: options?.overrideVaultKeyId,
47
- namespace: options?.namespace
48
- }
49
- });
50
- return response.headers[web.HeaderTypes.Location];
51
- }
52
- /**
53
- * Get the blob and metadata.
54
- * @param id The id of the blob to get in urn format.
55
- * @param options Optional options for the retrieval of the blob.
56
- * @param options.includeContent Include the content, or just get the metadata.
57
- * @param options.overrideVaultKeyId Use a different vault key id for decryption, if not provided the default vault key id will be used.
58
- * @param options.decompress If the content should be decompressed, if it was compressed when stored, defaults to true.
59
- * @returns The metadata and data for the blob if it can be found.
60
- * @throws Not found error if the blob cannot be found.
61
- */
62
- async get(id, options) {
63
- core.Urn.guard(BlobStorageRestClient.CLASS_NAME, "id", id);
64
- const response = await this.fetch("/:id", "GET", {
65
- headers: {
66
- [web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
67
- },
68
- pathParams: {
69
- id
70
- },
71
- query: {
72
- includeContent: core.Coerce.string(options?.includeContent),
73
- decompress: core.Coerce.string(options?.decompress),
74
- overrideVaultKeyId: options?.overrideVaultKeyId
75
- }
76
- });
77
- return response.body;
78
- }
79
- /**
80
- * Update the blob with metadata.
81
- * @param id The id of the blob metadata to update.
82
- * @param encodingFormat Mime type for the blob, will be detected if left undefined.
83
- * @param fileExtension Extension for the blob, will be detected if left undefined.
84
- * @param metadata Data for the custom metadata as JSON-LD.
85
- * @returns Nothing.
86
- * @throws Not found error if the blob cannot be found.
87
- */
88
- async update(id, encodingFormat, fileExtension, metadata) {
89
- core.Urn.guard(BlobStorageRestClient.CLASS_NAME, "id", id);
90
- await this.fetch("/:id", "PUT", {
91
- pathParams: {
92
- id
93
- },
94
- body: {
95
- encodingFormat,
96
- fileExtension,
97
- metadata
98
- }
99
- });
100
- }
101
- /**
102
- * Remove the blob.
103
- * @param id The id of the blob to remove in urn format.
104
- * @returns Nothing.
105
- */
106
- async remove(id) {
107
- core.Urn.guard(BlobStorageRestClient.CLASS_NAME, "id", id);
108
- await this.fetch("/:id", "DELETE", {
109
- pathParams: {
110
- id
111
- }
112
- });
113
- }
114
- /**
115
- * Query all the blob storage entries which match the conditions.
116
- * @param conditions The conditions to match for the entries.
117
- * @param orderBy The order for the results, defaults to created.
118
- * @param orderByDirection The direction for the order, defaults to descending.
119
- * @param cursor The cursor to request the next page of entries.
120
- * @param limit The suggested number of entries to return in each chunk, in some scenarios can return a different amount.
121
- * @returns All the entries for the storage matching the conditions,
122
- * and a cursor which can be used to request more entities.
123
- */
124
- async query(conditions, orderBy, orderByDirection, cursor, limit) {
125
- const response = await this.fetch("/", "GET", {
126
- headers: {
127
- [web.HeaderTypes.Accept]: web.MimeTypes.JsonLd
128
- },
129
- query: {
130
- conditions: apiModels.HttpParameterHelper.objectToString(conditions),
131
- orderBy,
132
- orderByDirection,
133
- limit: core.Coerce.string(limit),
134
- cursor
135
- }
136
- });
137
- return response.body;
138
- }
139
- /**
140
- * Create a download link for the blob.
141
- * @param id The id of the blob to get in urn format.
142
- * @param download Should the content disposition be set to download.
143
- * @param filename The filename to use for the download.
144
- * @returns The download link.
145
- */
146
- createDownloadLink(id, download, filename) {
147
- core.Urn.guard(BlobStorageRestClient.CLASS_NAME, "id", id);
148
- let link = core.StringHelper.trimTrailingSlashes(this.getEndpointWithPrefix());
149
- link += `/${id}/content`;
150
- const downloadQuery = [];
151
- if (download) {
152
- downloadQuery.push("download=true");
153
- }
154
- if (core.Is.stringValue(filename)) {
155
- downloadQuery.push(`filename=${encodeURIComponent(filename)}`);
156
- }
157
- if (downloadQuery.length > 0) {
158
- link += `?${downloadQuery.join("&")}`;
159
- }
160
- return link;
161
- }
162
- }
163
-
164
- exports.BlobStorageRestClient = BlobStorageRestClient;