@twin.org/blob-storage-rest-client 0.0.3-next.1 → 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
 
@@ -3,7 +3,7 @@
3
3
  import { BaseRestClient } from "@twin.org/api-core";
4
4
  import { HttpParameterHelper } from "@twin.org/api-models";
5
5
  import { Coerce, Guards, Is, StringHelper, Urn } from "@twin.org/core";
6
- import { HeaderTypes, MimeTypes } from "@twin.org/web";
6
+ import { HeaderHelper, HeaderTypes, MimeTypes } from "@twin.org/web";
7
7
  /**
8
8
  * Client for performing blob storage through to REST endpoints.
9
9
  */
@@ -138,7 +138,11 @@ export class BlobStorageRestClient extends BaseRestClient {
138
138
  cursor
139
139
  }
140
140
  });
141
- return response.body;
141
+ return {
142
+ entries: response.body,
143
+ cursor: HeaderHelper.extractLinkHeaderRelation(response.headers?.[HeaderTypes.Link], "next")
144
+ ?.urlQueryParams?.cursor
145
+ };
142
146
  }
143
147
  /**
144
148
  * Create a download link for the blob.
@@ -1 +1 @@
1
- {"version":3,"file":"blobStorageRestClient.js","sourceRoot":"","sources":["../../src/blobStorageRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACN,mBAAmB,EAInB,MAAM,sBAAsB,CAAC;AAa9B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAIvE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAA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,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC3B,MAAM;aACN;SACD,CACD,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACI,kBAAkB,CAAC,EAAU,EAAE,QAAkB,EAAE,QAAiB;QAC1E,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,UAAU,QAAc,EAAE,CAAC,CAAC;QAE5D,IAAI,IAAI,GAAG,YAAY,CAAC,mBAAmB,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAC1E,IAAI,IAAI,IAAI,EAAE,UAAU,CAAC;QAEzB,MAAM,aAAa,GAAa,EAAE,CAAC;QACnC,IAAI,QAAQ,EAAE,CAAC;YACd,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,aAAa,CAAC,IAAI,CAAC,YAAY,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,IAAI,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACvC,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC","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 { 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<IBlobStorageEntryList> {\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 response.body;\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"]}
1
+ {"version":3,"file":"blobStorageRestClient.js","sourceRoot":"","sources":["../../src/blobStorageRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACN,mBAAmB,EAInB,MAAM,sBAAsB,CAAC;AAa9B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,gBAA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c,CAAC,UAAU,CAAC;gBAC1D,OAAO;gBACP,gBAAgB;gBAChB,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC3B,MAAM;aACN;SACD,CACD,CAAC;QAEF,OAAO;YACN,OAAO,EAAE,QAAQ,CAAC,IAAI;YACtB,MAAM,EAAE,YAAY,CAAC,yBAAyB,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAC3F,EAAE,cAAc,EAAE,MAAM;SACzB,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACI,kBAAkB,CAAC,EAAU,EAAE,QAAkB,EAAE,QAAiB;QAC1E,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,UAAU,QAAc,EAAE,CAAC,CAAC;QAE5D,IAAI,IAAI,GAAG,YAAY,CAAC,mBAAmB,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAC1E,IAAI,IAAI,IAAI,EAAE,UAAU,CAAC;QAEzB,MAAM,aAAa,GAAa,EAAE,CAAC;QACnC,IAAI,QAAQ,EAAE,CAAC;YACd,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,aAAa,CAAC,IAAI,CAAC,YAAY,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,IAAI,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACvC,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC","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"]}
@@ -79,7 +79,10 @@ export declare class BlobStorageRestClient extends BaseRestClient implements IBl
79
79
  * @returns All the entries for the storage matching the conditions,
80
80
  * and a cursor which can be used to request more entities.
81
81
  */
82
- 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
+ }>;
83
86
  /**
84
87
  * Create a download link for the blob.
85
88
  * @param id The id of the blob to get in urn format.
package/docs/changelog.md CHANGED
@@ -1,18 +1,152 @@
1
- # @twin.org/blob-storage-rest-client - Changelog
1
+ # Changelog
2
2
 
3
- ## [0.0.3-next.1](https://github.com/twinfoundation/blob-storage/compare/blob-storage-rest-client-v0.0.3-next.0...blob-storage-rest-client-v0.0.3-next.1) (2025-11-11)
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)
4
138
 
5
139
 
6
140
  ### Features
7
141
 
8
- * add compression support ([67d239b](https://github.com/twinfoundation/blob-storage/commit/67d239bca8321bd90bf4ff93167c564130309730))
9
- * add context id features ([#30](https://github.com/twinfoundation/blob-storage/issues/30)) ([fbf1c92](https://github.com/twinfoundation/blob-storage/commit/fbf1c9276424c841ef5ef3f4de8469ab3fba7e9c))
10
- * add validate-locales ([f20fcec](https://github.com/twinfoundation/blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
11
- * additional encryption options on per item basis ([4b95a65](https://github.com/twinfoundation/blob-storage/commit/4b95a656d19e3b571cea905e36f29b679b13e1e8))
12
- * eslint migration to flat config ([e4239dd](https://github.com/twinfoundation/blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
13
- * update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
14
- * update framework core ([ff339fe](https://github.com/twinfoundation/blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
15
- * use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
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))
16
150
 
17
151
 
18
152
  ### Dependencies
@@ -21,12 +155,12 @@
21
155
  * dependencies
22
156
  * @twin.org/blob-storage-models bumped from 0.0.3-next.0 to 0.0.3-next.1
23
157
 
24
- ## [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)
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)
25
159
 
26
160
 
27
161
  ### Features
28
162
 
29
- * 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))
30
164
 
31
165
 
32
166
  ### Dependencies
@@ -35,7 +169,7 @@
35
169
  * dependencies
36
170
  * @twin.org/blob-storage-models bumped from 0.0.2-next.4 to 0.0.2-next.5
37
171
 
38
- ## [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)
39
173
 
40
174
 
41
175
  ### Miscellaneous Chores
@@ -49,12 +183,12 @@
49
183
  * dependencies
50
184
  * @twin.org/blob-storage-models bumped from 0.0.2-next.3 to 0.0.2-next.4
51
185
 
52
- ## [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)
53
187
 
54
188
 
55
189
  ### Features
56
190
 
57
- * 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))
58
192
 
59
193
 
60
194
  ### Dependencies
@@ -63,12 +197,12 @@
63
197
  * dependencies
64
198
  * @twin.org/blob-storage-models bumped from 0.0.2-next.2 to 0.0.2-next.3
65
199
 
66
- ## [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)
67
201
 
68
202
 
69
203
  ### Features
70
204
 
71
- * 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))
72
206
 
73
207
 
74
208
  ### Dependencies
@@ -77,15 +211,15 @@
77
211
  * dependencies
78
212
  * @twin.org/blob-storage-models bumped from 0.0.2-next.1 to 0.0.2-next.2
79
213
 
80
- ## [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)
81
215
 
82
216
 
83
217
  ### Features
84
218
 
85
- * add compression support ([67d239b](https://github.com/twinfoundation/blob-storage/commit/67d239bca8321bd90bf4ff93167c564130309730))
86
- * additional encryption options on per item basis ([4b95a65](https://github.com/twinfoundation/blob-storage/commit/4b95a656d19e3b571cea905e36f29b679b13e1e8))
87
- * update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
88
- * 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))
89
223
 
90
224
 
91
225
  ### Dependencies
@@ -99,7 +233,7 @@
99
233
 
100
234
  ### Features
101
235
 
102
- * 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))
103
237
 
104
238
 
105
239
  ### Dependencies
@@ -108,7 +242,7 @@
108
242
  * dependencies
109
243
  * @twin.org/blob-storage-models bumped from ^0.0.0 to ^0.0.1
110
244
 
111
- ## [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)
112
246
 
113
247
 
114
248
  ### Miscellaneous Chores
@@ -122,12 +256,12 @@
122
256
  * dependencies
123
257
  * @twin.org/blob-storage-models bumped from 0.0.1-next.36 to 0.0.1-next.37
124
258
 
125
- ## [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)
126
260
 
127
261
 
128
262
  ### Features
129
263
 
130
- * 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))
131
265
 
132
266
 
133
267
  ### Dependencies
@@ -136,12 +270,12 @@
136
270
  * dependencies
137
271
  * @twin.org/blob-storage-models bumped from 0.0.1-next.35 to 0.0.1-next.36
138
272
 
139
- ## [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)
140
274
 
141
275
 
142
276
  ### Features
143
277
 
144
- * 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))
145
279
 
146
280
 
147
281
  ### Dependencies
@@ -150,12 +284,12 @@
150
284
  * dependencies
151
285
  * @twin.org/blob-storage-models bumped from 0.0.1-next.34 to 0.0.1-next.35
152
286
 
153
- ## [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)
154
288
 
155
289
 
156
290
  ### Features
157
291
 
158
- * update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
292
+ * update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
159
293
 
160
294
 
161
295
  ### Dependencies
@@ -164,7 +298,7 @@
164
298
  * dependencies
165
299
  * @twin.org/blob-storage-models bumped from 0.0.1-next.33 to 0.0.1-next.34
166
300
 
167
- ## [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)
168
302
 
169
303
 
170
304
  ### Miscellaneous Chores
@@ -178,7 +312,7 @@
178
312
  * dependencies
179
313
  * @twin.org/blob-storage-models bumped from 0.0.1-next.32 to 0.0.1-next.33
180
314
 
181
- ## [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)
182
316
 
183
317
 
184
318
  ### Miscellaneous Chores
@@ -192,7 +326,7 @@
192
326
  * dependencies
193
327
  * @twin.org/blob-storage-models bumped from 0.0.1-next.31 to 0.0.1-next.32
194
328
 
195
- ## [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)
196
330
 
197
331
 
198
332
  ### Miscellaneous Chores
@@ -206,12 +340,12 @@
206
340
  * dependencies
207
341
  * @twin.org/blob-storage-models bumped from 0.0.1-next.30 to 0.0.1-next.31
208
342
 
209
- ## [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)
210
344
 
211
345
 
212
346
  ### Features
213
347
 
214
- * 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))
215
349
 
216
350
 
217
351
  ### Dependencies
@@ -220,7 +354,7 @@
220
354
  * dependencies
221
355
  * @twin.org/blob-storage-models bumped from 0.0.1-next.29 to 0.0.1-next.30
222
356
 
223
- ## [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)
224
358
 
225
359
 
226
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
+ ```
@@ -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,7 @@ Runtime name for the class.
44
44
 
45
45
  ## Methods
46
46
 
47
- ### className()
47
+ ### className() {#classname}
48
48
 
49
49
  > **className**(): `string`
50
50
 
@@ -62,7 +62,7 @@ The class name of the component.
62
62
 
63
63
  ***
64
64
 
65
- ### create()
65
+ ### create() {#create}
66
66
 
67
67
  > **create**(`blob`, `encodingFormat?`, `fileExtension?`, `metadata?`, `options?`): `Promise`\<`string`\>
68
68
 
@@ -128,7 +128,7 @@ The id of the stored blob in urn format.
128
128
 
129
129
  ***
130
130
 
131
- ### get()
131
+ ### get() {#get}
132
132
 
133
133
  > **get**(`id`, `options?`): `Promise`\<`IBlobStorageEntry`\>
134
134
 
@@ -180,7 +180,7 @@ Not found error if the blob cannot be found.
180
180
 
181
181
  ***
182
182
 
183
- ### update()
183
+ ### update() {#update}
184
184
 
185
185
  > **update**(`id`, `encodingFormat?`, `fileExtension?`, `metadata?`): `Promise`\<`void`\>
186
186
 
@@ -228,7 +228,7 @@ Not found error if the blob cannot be found.
228
228
 
229
229
  ***
230
230
 
231
- ### remove()
231
+ ### remove() {#remove}
232
232
 
233
233
  > **remove**(`id`): `Promise`\<`void`\>
234
234
 
@@ -254,9 +254,9 @@ Nothing.
254
254
 
255
255
  ***
256
256
 
257
- ### query()
257
+ ### query() {#query}
258
258
 
259
- > **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `cursor?`, `limit?`): `Promise`\<`IBlobStorageEntryList`\>
259
+ > **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `cursor?`, `limit?`): `Promise`\<\{ `entries`: `IBlobStorageEntryList`; `cursor?`: `string`; \}\>
260
260
 
261
261
  Query all the blob storage entries which match the conditions.
262
262
 
@@ -270,9 +270,9 @@ The conditions to match for the entries.
270
270
 
271
271
  ##### orderBy?
272
272
 
273
- The order for the results, defaults to created.
273
+ `"dateCreated"` \| `"dateModified"`
274
274
 
275
- `"dateCreated"` | `"dateModified"`
275
+ The order for the results, defaults to created.
276
276
 
277
277
  ##### orderByDirection?
278
278
 
@@ -294,7 +294,7 @@ The suggested number of entries to return in each chunk, in some scenarios can r
294
294
 
295
295
  #### Returns
296
296
 
297
- `Promise`\<`IBlobStorageEntryList`\>
297
+ `Promise`\<\{ `entries`: `IBlobStorageEntryList`; `cursor?`: `string`; \}\>
298
298
 
299
299
  All the entries for the storage matching the conditions,
300
300
  and a cursor which can be used to request more entities.
@@ -305,7 +305,7 @@ and a cursor which can be used to request more entities.
305
305
 
306
306
  ***
307
307
 
308
- ### createDownloadLink()
308
+ ### createDownloadLink() {#createdownloadlink}
309
309
 
310
310
  > **createDownloadLink**(`id`, `download?`, `filename?`): `string`
311
311
 
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@twin.org/blob-storage-rest-client",
3
- "version": "0.0.3-next.1",
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,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.3-next.1",
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",
@@ -52,7 +52,7 @@
52
52
  "binary"
53
53
  ],
54
54
  "bugs": {
55
- "url": "git+https://github.com/twinfoundation/blob-storage/issues"
55
+ "url": "git+https://github.com/iotaledger/blob-storage/issues"
56
56
  },
57
57
  "homepage": "https://twindev.org"
58
58
  }