@twin.org/blob-storage-service 0.0.3-next.1 → 0.0.3-next.2

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.
@@ -105,9 +105,9 @@ export function generateRestRoutesBlobStorage(baseRouteName, componentName, opti
105
105
  response: {
106
106
  body: {
107
107
  "@context": [
108
- BlobStorageContexts.ContextRoot,
109
- BlobStorageContexts.ContextRootCommon,
110
- SchemaOrgContexts.ContextRoot
108
+ BlobStorageContexts.Namespace,
109
+ BlobStorageContexts.NamespaceCommon,
110
+ SchemaOrgContexts.Namespace
111
111
  ],
112
112
  type: BlobStorageTypes.Entry,
113
113
  id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
@@ -136,9 +136,9 @@ export function generateRestRoutesBlobStorage(baseRouteName, componentName, opti
136
136
  response: {
137
137
  body: {
138
138
  "@context": [
139
- BlobStorageContexts.ContextRoot,
140
- BlobStorageContexts.ContextRootCommon,
141
- SchemaOrgContexts.ContextRoot
139
+ BlobStorageContexts.Namespace,
140
+ BlobStorageContexts.NamespaceCommon,
141
+ SchemaOrgContexts.Namespace
142
142
  ],
143
143
  type: BlobStorageTypes.Entry,
144
144
  id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
@@ -293,17 +293,17 @@ export function generateRestRoutesBlobStorage(baseRouteName, componentName, opti
293
293
  response: {
294
294
  body: {
295
295
  "@context": [
296
- SchemaOrgContexts.ContextRoot,
297
- BlobStorageContexts.ContextRoot,
298
- BlobStorageContexts.ContextRootCommon
296
+ SchemaOrgContexts.Namespace,
297
+ BlobStorageContexts.Namespace,
298
+ BlobStorageContexts.NamespaceCommon
299
299
  ],
300
300
  type: SchemaOrgTypes.ItemList,
301
301
  [SchemaOrgTypes.ItemListElement]: [
302
302
  {
303
303
  "@context": [
304
- BlobStorageContexts.ContextRoot,
305
- BlobStorageContexts.ContextRootCommon,
306
- SchemaOrgContexts.ContextRoot
304
+ BlobStorageContexts.Namespace,
305
+ BlobStorageContexts.NamespaceCommon,
306
+ SchemaOrgContexts.Namespace
307
307
  ],
308
308
  type: BlobStorageTypes.Entry,
309
309
  id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
@@ -334,17 +334,17 @@ export function generateRestRoutesBlobStorage(baseRouteName, componentName, opti
334
334
  response: {
335
335
  body: {
336
336
  "@context": [
337
- SchemaOrgContexts.ContextRoot,
338
- BlobStorageContexts.ContextRoot,
339
- BlobStorageContexts.ContextRootCommon
337
+ SchemaOrgContexts.Namespace,
338
+ BlobStorageContexts.Namespace,
339
+ BlobStorageContexts.NamespaceCommon
340
340
  ],
341
341
  type: SchemaOrgTypes.ItemList,
342
342
  [SchemaOrgTypes.ItemListElement]: [
343
343
  {
344
344
  "@context": [
345
- BlobStorageContexts.ContextRoot,
346
- BlobStorageContexts.ContextRootCommon,
347
- SchemaOrgContexts.ContextRoot
345
+ BlobStorageContexts.Namespace,
346
+ BlobStorageContexts.NamespaceCommon,
347
+ SchemaOrgContexts.Namespace
348
348
  ],
349
349
  type: BlobStorageTypes.Entry,
350
350
  id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
@@ -1 +1 @@
1
- {"version":3,"file":"blobStorageRoutes.js","sourceRoot":"","sources":["../../src/blobStorageRoutes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,mBAAmB,EAQnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,0BAA0B,EAC1B,mBAAmB,EACnB,gBAAgB,EAWhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE/F,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gCAAg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AAa,CAAC,CAAC;IAE7E,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,CACnC,mBAAmB,CAAC,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,EAC/D,OAAO,CAAC,KAAK,EAAE,OAAO,EACtB,OAAO,CAAC,KAAK,EAAE,gBAAgB,EAC/B,OAAO,CAAC,KAAK,EAAE,MAAM,EACrB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CACnC,CAAC;IAEF,OAAO;QACN,OAAO,EAAE;YACR,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM;SAClF;QACD,IAAI,EAAE,MAAM;KACZ,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tHttpParameterHelper,\n\ttype ICreatedResponse,\n\ttype IHttpRequestContext,\n\ttype INoContentResponse,\n\ttype INotFoundResponse,\n\ttype IRestRoute,\n\ttype IRestRouteResponseOptions,\n\ttype ITag\n} from \"@twin.org/api-models\";\nimport {\n\tBlobStorageCompressionType,\n\tBlobStorageContexts,\n\tBlobStorageTypes,\n\ttype IBlobStorageComponent,\n\ttype IBlobStorageCreateRequest,\n\ttype IBlobStorageGetContentRequest,\n\ttype IBlobStorageGetContentResponse,\n\ttype IBlobStorageGetRequest,\n\ttype IBlobStorageGetResponse,\n\ttype IBlobStorageListRequest,\n\ttype IBlobStorageListResponse,\n\ttype IBlobStorageRemoveRequest,\n\ttype IBlobStorageUpdateRequest\n} from \"@twin.org/blob-storage-models\";\nimport { Coerce, ComponentFactory, Converter, Guards, Is, StringHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { SchemaOrgContexts, SchemaOrgTypes } from \"@twin.org/standards-schema-org\";\nimport { HeaderTypes, HttpStatusCode, MimeTypeHelper, MimeTypes } from \"@twin.org/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"blobStorageRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsBlobStorage: ITag[] = [\n\t{\n\t\tname: \"Blob Storage\",\n\t\tdescription: \"Endpoints which are modelled to access a blob storage contract.\"\n\t}\n];\n\n/**\n * The REST routes for blob storage.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param options Additional options for the routes.\n * @param options.typeName Optional type name to use in the routes, defaults to Blob Storage.\n * @param options.tagName Optional name to use in OpenAPI spec for tag.\n * @returns The generated routes.\n */\nexport function generateRestRoutesBlobStorage(\n\tbaseRouteName: string,\n\tcomponentName: string,\n\toptions?: {\n\t\ttypeName?: string;\n\t\ttagName?: string;\n\t}\n): IRestRoute[] {\n\tconst typeName = options?.typeName ?? \"Blob Storage\";\n\tconst lowerName = typeName.toLowerCase();\n\tconst camelTypeName = StringHelper.camelCase(typeName);\n\n\tconst blobStorageCreateRoute: IRestRoute<IBlobStorageCreateRequest, ICreatedResponse> = {\n\t\toperationId: `${camelTypeName}Create`,\n\t\tsummary: `Create an entry in ${lowerName}`,\n\t\ttag: options?.tagName ?? tagsBlobStorage[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tblobStorageCreate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IBlobStorageCreateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}CreateRequestExample`,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tblob: \"VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==\",\n\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\"@type\": \"DigitalDocument\",\n\t\t\t\t\t\t\t\tname: \"myfile.pdf\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ICreatedResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}CreateResponseExample`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: HttpStatusCode.created,\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t[HeaderTypes.Location]:\n\t\t\t\t\t\t\t\t\t\"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst blobStorageGetRoute: IRestRoute<IBlobStorageGetRequest, IBlobStorageGetResponse> = {\n\t\toperationId: `${camelTypeName}Get`,\n\t\tsummary: `Get the metadata for an item from ${lowerName}`,\n\t\ttag: options?.tagName ?? tagsBlobStorage[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tblobStorageGet(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IBlobStorageGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}GetRequestExample`,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tincludeContent: \"true\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IBlobStorageGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}GetResponseExample`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextRoot,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextRootCommon,\n\t\t\t\t\t\t\t\t\tSchemaOrgContexts.ContextRoot\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\ttype: BlobStorageTypes.Entry,\n\t\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\tdateCreated: \"2024-01-01T00:00:00Z\",\n\t\t\t\t\t\t\t\tencodingFormat: MimeTypes.Pdf,\n\t\t\t\t\t\t\t\tblobSize: 42,\n\t\t\t\t\t\t\t\tblobHash: \"sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\tfileExtension: \"pdf\",\n\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"DigitalDocument\",\n\t\t\t\t\t\t\t\t\tname: \"myfile.pdf\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tblob: \"VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IBlobStorageGetResponse>(),\n\t\t\t\tmimeType: MimeTypes.JsonLd,\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}GetResponseJsonLdExample`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextRoot,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextRootCommon,\n\t\t\t\t\t\t\t\t\tSchemaOrgContexts.ContextRoot\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\ttype: BlobStorageTypes.Entry,\n\t\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\tdateCreated: \"2024-01-01T00:00:00Z\",\n\t\t\t\t\t\t\t\tencodingFormat: MimeTypes.Pdf,\n\t\t\t\t\t\t\t\tblobSize: 42,\n\t\t\t\t\t\t\t\tblobHash: \"sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\tfileExtension: \"pdf\",\n\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"DigitalDocument\",\n\t\t\t\t\t\t\t\t\tname: \"myfile.pdf\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tblob: \"VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst blobStorageGetContentRoute: IRestRoute<\n\t\tIBlobStorageGetContentRequest,\n\t\tIBlobStorageGetContentResponse & IRestRouteResponseOptions\n\t> = {\n\t\toperationId: `${camelTypeName}GetContent`,\n\t\tsummary: `Get the content for an item in ${lowerName}`,\n\t\ttag: options?.tagName ?? tagsBlobStorage[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:id/content`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tblobStorageGetContent(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IBlobStorageGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}GetContentRequestExample`,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tdownload: \"true\",\n\t\t\t\t\t\t\tfilename: \"my-file.pdf\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<Uint8Array>(),\n\t\t\t\tmimeType: MimeTypes.OctetStream,\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}GetContentResponseExample`,\n\t\t\t\t\t\tdescription: `The content of the blob, which will be a specific mime type if one can be detected from the content (or set as encodingFormat in the entry), or defaults to ${MimeTypes.OctetStream}.`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: new Uint8Array()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst blobStorageUpdateRoute: IRestRoute<IBlobStorageUpdateRequest, INoContentResponse> = {\n\t\toperationId: `${camelTypeName}Update`,\n\t\tsummary: `Update the metadata for an item in ${lowerName}`,\n\t\ttag: options?.tagName ?? tagsBlobStorage[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tblobStorageUpdate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IBlobStorageUpdateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}UpdateRequestExample`,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\"@type\": \"DigitalDocument\",\n\t\t\t\t\t\t\t\tname: \"myfile.pdf\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst blobStorageRemoveRoute: IRestRoute<IBlobStorageRemoveRequest, INoContentResponse> = {\n\t\toperationId: `${camelTypeName}Remove`,\n\t\tsummary: `Remove an item from ${lowerName}`,\n\t\ttag: options?.tagName ?? tagsBlobStorage[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tblobStorageRemove(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IBlobStorageRemoveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}RemoveRequestExample`,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst blobStorageListRoute: IRestRoute<IBlobStorageListRequest, IBlobStorageListResponse> = {\n\t\toperationId: `${camelTypeName}Query`,\n\t\tsummary: `Query the items from ${lowerName}`,\n\t\ttag: options?.tagName ?? tagsBlobStorage[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tblobStorageList(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IBlobStorageListRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}ListRequestExample`,\n\t\t\t\t\trequest: {}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IBlobStorageListResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}ListResponseExample`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\tSchemaOrgContexts.ContextRoot,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextRoot,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextRootCommon\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\ttype: SchemaOrgTypes.ItemList,\n\t\t\t\t\t\t\t\t[SchemaOrgTypes.ItemListElement]: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextRoot,\n\t\t\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextRootCommon,\n\t\t\t\t\t\t\t\t\t\t\tSchemaOrgContexts.ContextRoot\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\ttype: BlobStorageTypes.Entry,\n\t\t\t\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\t\t\tdateCreated: \"2024-01-01T00:00:00Z\",\n\t\t\t\t\t\t\t\t\t\tencodingFormat: MimeTypes.Pdf,\n\t\t\t\t\t\t\t\t\t\tblobSize: 42,\n\t\t\t\t\t\t\t\t\t\tblobHash:\n\t\t\t\t\t\t\t\t\t\t\t\"sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\t\t\tfileExtension: \"pdf\",\n\t\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\t\t\"@type\": \"DigitalDocument\",\n\t\t\t\t\t\t\t\t\t\t\tname: \"myfile.pdf\"\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tblob: \"VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IBlobStorageListResponse>(),\n\t\t\t\tmimeType: MimeTypes.JsonLd,\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}ListResponseJsonLdExample`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\tSchemaOrgContexts.ContextRoot,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextRoot,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextRootCommon\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\ttype: SchemaOrgTypes.ItemList,\n\t\t\t\t\t\t\t\t[SchemaOrgTypes.ItemListElement]: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextRoot,\n\t\t\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextRootCommon,\n\t\t\t\t\t\t\t\t\t\t\tSchemaOrgContexts.ContextRoot\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\ttype: BlobStorageTypes.Entry,\n\t\t\t\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\t\t\tdateCreated: \"2024-01-01T00:00:00Z\",\n\t\t\t\t\t\t\t\t\t\tencodingFormat: MimeTypes.Pdf,\n\t\t\t\t\t\t\t\t\t\tblobSize: 42,\n\t\t\t\t\t\t\t\t\t\tblobHash:\n\t\t\t\t\t\t\t\t\t\t\t\"sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\t\t\tfileExtension: \"pdf\",\n\t\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\t\t\"@type\": \"DigitalDocument\",\n\t\t\t\t\t\t\t\t\t\t\tname: \"myfile.pdf\"\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tblob: \"VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [\n\t\tblobStorageCreateRoute,\n\t\tblobStorageGetRoute,\n\t\tblobStorageGetContentRoute,\n\t\tblobStorageUpdateRoute,\n\t\tblobStorageRemoveRoute,\n\t\tblobStorageListRoute\n\t];\n}\n\n/**\n * Create a blob in storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function blobStorageCreate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IBlobStorageCreateRequest\n): Promise<ICreatedResponse> {\n\tGuards.object<IBlobStorageCreateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IBlobStorageCreateRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\tGuards.stringBase64(ROUTES_SOURCE, nameof(request.body.blob), request.body.blob);\n\n\tconst component = ComponentFactory.get<IBlobStorageComponent>(componentName);\n\tconst id = await component.create(\n\t\trequest.body.blob,\n\t\trequest.body.encodingFormat,\n\t\trequest.body.fileExtension,\n\t\trequest.body.metadata,\n\t\t{\n\t\t\tdisableEncryption: request.body.disableEncryption,\n\t\t\toverrideVaultKeyId: request.body.overrideVaultKeyId,\n\t\t\tnamespace: request.body.namespace\n\t\t}\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.created,\n\t\theaders: {\n\t\t\tlocation: id\n\t\t}\n\t};\n}\n\n/**\n * Get the blob from storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function blobStorageGet(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IBlobStorageGetRequest\n): Promise<IBlobStorageGetResponse> {\n\tGuards.object<IBlobStorageGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IBlobStorageGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? \"jsonld\" : \"json\";\n\n\tconst component = ComponentFactory.get<IBlobStorageComponent>(componentName);\n\n\tconst result = await component.get(request.pathParams.id, {\n\t\tincludeContent: Coerce.boolean(request.query?.includeContent),\n\t\tdecompress: Coerce.boolean(request.query?.decompress),\n\t\toverrideVaultKeyId: request.query?.overrideVaultKeyId\n\t});\n\n\treturn {\n\t\theaders: {\n\t\t\t[HeaderTypes.ContentType]: mimeType === \"json\" ? MimeTypes.Json : MimeTypes.JsonLd\n\t\t},\n\t\tbody: result\n\t};\n}\n\n/**\n * Get the blob from storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function blobStorageGetContent(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IBlobStorageGetContentRequest\n): Promise<IBlobStorageGetContentResponse & IRestRouteResponseOptions> {\n\tGuards.object<IBlobStorageGetContentRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IBlobStorageGetContentRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IBlobStorageComponent>(componentName);\n\n\tconst decompress = Coerce.boolean(request.query?.decompress);\n\tconst download = Coerce.boolean(request.query?.download) ?? false;\n\n\tconst result = await component.get(request.pathParams.id, {\n\t\tincludeContent: true,\n\t\tdecompress,\n\t\toverrideVaultKeyId: request.query?.overrideVaultKeyId\n\t});\n\n\tconst encodingFormat = result?.encodingFormat ?? MimeTypes.OctetStream;\n\tlet compressedEncodingFormat: MimeTypes | undefined;\n\tlet compressedExtension: string = \"\";\n\n\t// If the entry is compressed and we are not decompressing\n\t// we need to override the encoding format to the compressed type\n\t// and append an additional extension to the filename.\n\tif (result.compression && !decompress) {\n\t\tcompressedEncodingFormat =\n\t\t\tresult.compression === BlobStorageCompressionType.Gzip ? MimeTypes.Gzip : MimeTypes.Zlib;\n\t\tcompressedExtension = `.${MimeTypeHelper.defaultExtension(compressedEncodingFormat)}`;\n\t}\n\n\tlet filename = request.query?.filename;\n\tif (!Is.stringValue(filename)) {\n\t\tfilename = `file.${result.fileExtension ?? MimeTypeHelper.defaultExtension(encodingFormat)}${compressedExtension}`;\n\t}\n\n\treturn {\n\t\tbody: Is.stringBase64(result.blob) ? Converter.base64ToBytes(result.blob) : new Uint8Array(),\n\t\tattachment: {\n\t\t\tmimeType: compressedEncodingFormat ?? encodingFormat,\n\t\t\tfilename,\n\t\t\tinline: !download\n\t\t}\n\t};\n}\n\n/**\n * Update the blob storage metadata.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function blobStorageUpdate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IBlobStorageUpdateRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IBlobStorageUpdateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IBlobStorageUpdateRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IBlobStorageComponent>(componentName);\n\n\tawait component.update(\n\t\trequest.pathParams.id,\n\t\trequest.body.encodingFormat,\n\t\trequest.body.fileExtension,\n\t\trequest.body.metadata\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Remove the blob from storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function blobStorageRemove(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IBlobStorageRemoveRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IBlobStorageRemoveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IBlobStorageGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IBlobStorageComponent>(componentName);\n\n\tawait component.remove(request.pathParams.id);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * List the entries from blob storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function blobStorageList(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IBlobStorageListRequest\n): Promise<IBlobStorageListResponse> {\n\tGuards.object<IBlobStorageListRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tconst mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? \"jsonld\" : \"json\";\n\n\tconst component = ComponentFactory.get<IBlobStorageComponent>(componentName);\n\n\tconst result = await component.query(\n\t\tHttpParameterHelper.objectFromString(request.query?.conditions),\n\t\trequest.query?.orderBy,\n\t\trequest.query?.orderByDirection,\n\t\trequest.query?.cursor,\n\t\tCoerce.number(request.query?.limit)\n\t);\n\n\treturn {\n\t\theaders: {\n\t\t\t[HeaderTypes.ContentType]: mimeType === \"json\" ? MimeTypes.Json : MimeTypes.JsonLd\n\t\t},\n\t\tbody: result\n\t};\n}\n"]}
1
+ {"version":3,"file":"blobStorageRoutes.js","sourceRoot":"","sources":["../../src/blobStorageRoutes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,mBAAmB,EAQnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,0BAA0B,EAC1B,mBAAmB,EACnB,gBAAgB,EAWhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE/F,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEvF;;GAEG;AACH,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAW;IACtC;QACC,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,iEAAiE;KAC9E;CACD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CAC5C,aAAqB,EACrB,aAAqB,EACrB,OAGC;IAED,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,cAAc,CAAC;IACrD,MAAM,SAAS,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACzC,MAAM,aAAa,GAAG,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAEvD,MAAM,sBAAsB,GAA4D;QACvF,WAAW,EAAE,GAAG,aAAa,QAAQ;QACrC,OAAO,EAAE,sBAAsB,SAAS,EAAE;QAC1C,GAAG,EAAE,OAAO,EAAE,OAAO,IAA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a,CAAC,CAAC;IAE7E,MAAM,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAE9C,OAAO;QACN,UAAU,EAAE,cAAc,CAAC,SAAS;KACpC,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,kBAAuC,EACvC,aAAqB,EACrB,OAAgC;IAEhC,MAAM,CAAC,MAAM,CAA0B,aAAa,aAAmB,OAAO,CAAC,CAAC;IAEhF,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IAEhG,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAwB,aAAa,CAAC,CAAC;IAE7E,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,CACnC,mBAAmB,CAAC,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,EAC/D,OAAO,CAAC,KAAK,EAAE,OAAO,EACtB,OAAO,CAAC,KAAK,EAAE,gBAAgB,EAC/B,OAAO,CAAC,KAAK,EAAE,MAAM,EACrB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CACnC,CAAC;IAEF,OAAO;QACN,OAAO,EAAE;YACR,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM;SAClF;QACD,IAAI,EAAE,MAAM;KACZ,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tHttpParameterHelper,\n\ttype ICreatedResponse,\n\ttype IHttpRequestContext,\n\ttype INoContentResponse,\n\ttype INotFoundResponse,\n\ttype IRestRoute,\n\ttype IRestRouteResponseOptions,\n\ttype ITag\n} from \"@twin.org/api-models\";\nimport {\n\tBlobStorageCompressionType,\n\tBlobStorageContexts,\n\tBlobStorageTypes,\n\ttype IBlobStorageComponent,\n\ttype IBlobStorageCreateRequest,\n\ttype IBlobStorageGetContentRequest,\n\ttype IBlobStorageGetContentResponse,\n\ttype IBlobStorageGetRequest,\n\ttype IBlobStorageGetResponse,\n\ttype IBlobStorageListRequest,\n\ttype IBlobStorageListResponse,\n\ttype IBlobStorageRemoveRequest,\n\ttype IBlobStorageUpdateRequest\n} from \"@twin.org/blob-storage-models\";\nimport { Coerce, ComponentFactory, Converter, Guards, Is, StringHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { SchemaOrgContexts, SchemaOrgTypes } from \"@twin.org/standards-schema-org\";\nimport { HeaderTypes, HttpStatusCode, MimeTypeHelper, MimeTypes } from \"@twin.org/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"blobStorageRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsBlobStorage: ITag[] = [\n\t{\n\t\tname: \"Blob Storage\",\n\t\tdescription: \"Endpoints which are modelled to access a blob storage contract.\"\n\t}\n];\n\n/**\n * The REST routes for blob storage.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param options Additional options for the routes.\n * @param options.typeName Optional type name to use in the routes, defaults to Blob Storage.\n * @param options.tagName Optional name to use in OpenAPI spec for tag.\n * @returns The generated routes.\n */\nexport function generateRestRoutesBlobStorage(\n\tbaseRouteName: string,\n\tcomponentName: string,\n\toptions?: {\n\t\ttypeName?: string;\n\t\ttagName?: string;\n\t}\n): IRestRoute[] {\n\tconst typeName = options?.typeName ?? \"Blob Storage\";\n\tconst lowerName = typeName.toLowerCase();\n\tconst camelTypeName = StringHelper.camelCase(typeName);\n\n\tconst blobStorageCreateRoute: IRestRoute<IBlobStorageCreateRequest, ICreatedResponse> = {\n\t\toperationId: `${camelTypeName}Create`,\n\t\tsummary: `Create an entry in ${lowerName}`,\n\t\ttag: options?.tagName ?? tagsBlobStorage[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tblobStorageCreate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IBlobStorageCreateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}CreateRequestExample`,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tblob: \"VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==\",\n\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\"@type\": \"DigitalDocument\",\n\t\t\t\t\t\t\t\tname: \"myfile.pdf\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ICreatedResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}CreateResponseExample`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: HttpStatusCode.created,\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t[HeaderTypes.Location]:\n\t\t\t\t\t\t\t\t\t\"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst blobStorageGetRoute: IRestRoute<IBlobStorageGetRequest, IBlobStorageGetResponse> = {\n\t\toperationId: `${camelTypeName}Get`,\n\t\tsummary: `Get the metadata for an item from ${lowerName}`,\n\t\ttag: options?.tagName ?? tagsBlobStorage[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tblobStorageGet(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IBlobStorageGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}GetRequestExample`,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tincludeContent: \"true\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IBlobStorageGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}GetResponseExample`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.Namespace,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.NamespaceCommon,\n\t\t\t\t\t\t\t\t\tSchemaOrgContexts.Namespace\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\ttype: BlobStorageTypes.Entry,\n\t\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\tdateCreated: \"2024-01-01T00:00:00Z\",\n\t\t\t\t\t\t\t\tencodingFormat: MimeTypes.Pdf,\n\t\t\t\t\t\t\t\tblobSize: 42,\n\t\t\t\t\t\t\t\tblobHash: \"sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\tfileExtension: \"pdf\",\n\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"DigitalDocument\",\n\t\t\t\t\t\t\t\t\tname: \"myfile.pdf\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tblob: \"VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IBlobStorageGetResponse>(),\n\t\t\t\tmimeType: MimeTypes.JsonLd,\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}GetResponseJsonLdExample`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.Namespace,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.NamespaceCommon,\n\t\t\t\t\t\t\t\t\tSchemaOrgContexts.Namespace\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\ttype: BlobStorageTypes.Entry,\n\t\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\tdateCreated: \"2024-01-01T00:00:00Z\",\n\t\t\t\t\t\t\t\tencodingFormat: MimeTypes.Pdf,\n\t\t\t\t\t\t\t\tblobSize: 42,\n\t\t\t\t\t\t\t\tblobHash: \"sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\tfileExtension: \"pdf\",\n\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\"@type\": \"DigitalDocument\",\n\t\t\t\t\t\t\t\t\tname: \"myfile.pdf\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tblob: \"VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst blobStorageGetContentRoute: IRestRoute<\n\t\tIBlobStorageGetContentRequest,\n\t\tIBlobStorageGetContentResponse & IRestRouteResponseOptions\n\t> = {\n\t\toperationId: `${camelTypeName}GetContent`,\n\t\tsummary: `Get the content for an item in ${lowerName}`,\n\t\ttag: options?.tagName ?? tagsBlobStorage[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:id/content`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tblobStorageGetContent(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IBlobStorageGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}GetContentRequestExample`,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tdownload: \"true\",\n\t\t\t\t\t\t\tfilename: \"my-file.pdf\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<Uint8Array>(),\n\t\t\t\tmimeType: MimeTypes.OctetStream,\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}GetContentResponseExample`,\n\t\t\t\t\t\tdescription: `The content of the blob, which will be a specific mime type if one can be detected from the content (or set as encodingFormat in the entry), or defaults to ${MimeTypes.OctetStream}.`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: new Uint8Array()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst blobStorageUpdateRoute: IRestRoute<IBlobStorageUpdateRequest, INoContentResponse> = {\n\t\toperationId: `${camelTypeName}Update`,\n\t\tsummary: `Update the metadata for an item in ${lowerName}`,\n\t\ttag: options?.tagName ?? tagsBlobStorage[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tblobStorageUpdate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IBlobStorageUpdateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}UpdateRequestExample`,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\"@type\": \"DigitalDocument\",\n\t\t\t\t\t\t\t\tname: \"myfile.pdf\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst blobStorageRemoveRoute: IRestRoute<IBlobStorageRemoveRequest, INoContentResponse> = {\n\t\toperationId: `${camelTypeName}Remove`,\n\t\tsummary: `Remove an item from ${lowerName}`,\n\t\ttag: options?.tagName ?? tagsBlobStorage[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tblobStorageRemove(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IBlobStorageRemoveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}RemoveRequestExample`,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst blobStorageListRoute: IRestRoute<IBlobStorageListRequest, IBlobStorageListResponse> = {\n\t\toperationId: `${camelTypeName}Query`,\n\t\tsummary: `Query the items from ${lowerName}`,\n\t\ttag: options?.tagName ?? tagsBlobStorage[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tblobStorageList(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IBlobStorageListRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}ListRequestExample`,\n\t\t\t\t\trequest: {}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IBlobStorageListResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}ListResponseExample`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\tSchemaOrgContexts.Namespace,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.Namespace,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.NamespaceCommon\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\ttype: SchemaOrgTypes.ItemList,\n\t\t\t\t\t\t\t\t[SchemaOrgTypes.ItemListElement]: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\t\t\tBlobStorageContexts.Namespace,\n\t\t\t\t\t\t\t\t\t\t\tBlobStorageContexts.NamespaceCommon,\n\t\t\t\t\t\t\t\t\t\t\tSchemaOrgContexts.Namespace\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\ttype: BlobStorageTypes.Entry,\n\t\t\t\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\t\t\tdateCreated: \"2024-01-01T00:00:00Z\",\n\t\t\t\t\t\t\t\t\t\tencodingFormat: MimeTypes.Pdf,\n\t\t\t\t\t\t\t\t\t\tblobSize: 42,\n\t\t\t\t\t\t\t\t\t\tblobHash:\n\t\t\t\t\t\t\t\t\t\t\t\"sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\t\t\tfileExtension: \"pdf\",\n\t\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\t\t\"@type\": \"DigitalDocument\",\n\t\t\t\t\t\t\t\t\t\t\tname: \"myfile.pdf\"\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tblob: \"VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IBlobStorageListResponse>(),\n\t\t\t\tmimeType: MimeTypes.JsonLd,\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}ListResponseJsonLdExample`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\tSchemaOrgContexts.Namespace,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.Namespace,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.NamespaceCommon\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\ttype: SchemaOrgTypes.ItemList,\n\t\t\t\t\t\t\t\t[SchemaOrgTypes.ItemListElement]: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"@context\": [\n\t\t\t\t\t\t\t\t\t\t\tBlobStorageContexts.Namespace,\n\t\t\t\t\t\t\t\t\t\t\tBlobStorageContexts.NamespaceCommon,\n\t\t\t\t\t\t\t\t\t\t\tSchemaOrgContexts.Namespace\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\ttype: BlobStorageTypes.Entry,\n\t\t\t\t\t\t\t\t\t\tid: \"blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\t\t\tdateCreated: \"2024-01-01T00:00:00Z\",\n\t\t\t\t\t\t\t\t\t\tencodingFormat: MimeTypes.Pdf,\n\t\t\t\t\t\t\t\t\t\tblobSize: 42,\n\t\t\t\t\t\t\t\t\t\tblobHash:\n\t\t\t\t\t\t\t\t\t\t\t\"sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70\",\n\t\t\t\t\t\t\t\t\t\tfileExtension: \"pdf\",\n\t\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\t\t\t\t\"@type\": \"DigitalDocument\",\n\t\t\t\t\t\t\t\t\t\t\tname: \"myfile.pdf\"\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tblob: \"VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [\n\t\tblobStorageCreateRoute,\n\t\tblobStorageGetRoute,\n\t\tblobStorageGetContentRoute,\n\t\tblobStorageUpdateRoute,\n\t\tblobStorageRemoveRoute,\n\t\tblobStorageListRoute\n\t];\n}\n\n/**\n * Create a blob in storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function blobStorageCreate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IBlobStorageCreateRequest\n): Promise<ICreatedResponse> {\n\tGuards.object<IBlobStorageCreateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IBlobStorageCreateRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\tGuards.stringBase64(ROUTES_SOURCE, nameof(request.body.blob), request.body.blob);\n\n\tconst component = ComponentFactory.get<IBlobStorageComponent>(componentName);\n\tconst id = await component.create(\n\t\trequest.body.blob,\n\t\trequest.body.encodingFormat,\n\t\trequest.body.fileExtension,\n\t\trequest.body.metadata,\n\t\t{\n\t\t\tdisableEncryption: request.body.disableEncryption,\n\t\t\toverrideVaultKeyId: request.body.overrideVaultKeyId,\n\t\t\tnamespace: request.body.namespace\n\t\t}\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.created,\n\t\theaders: {\n\t\t\tlocation: id\n\t\t}\n\t};\n}\n\n/**\n * Get the blob from storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function blobStorageGet(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IBlobStorageGetRequest\n): Promise<IBlobStorageGetResponse> {\n\tGuards.object<IBlobStorageGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IBlobStorageGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? \"jsonld\" : \"json\";\n\n\tconst component = ComponentFactory.get<IBlobStorageComponent>(componentName);\n\n\tconst result = await component.get(request.pathParams.id, {\n\t\tincludeContent: Coerce.boolean(request.query?.includeContent),\n\t\tdecompress: Coerce.boolean(request.query?.decompress),\n\t\toverrideVaultKeyId: request.query?.overrideVaultKeyId\n\t});\n\n\treturn {\n\t\theaders: {\n\t\t\t[HeaderTypes.ContentType]: mimeType === \"json\" ? MimeTypes.Json : MimeTypes.JsonLd\n\t\t},\n\t\tbody: result\n\t};\n}\n\n/**\n * Get the blob from storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function blobStorageGetContent(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IBlobStorageGetContentRequest\n): Promise<IBlobStorageGetContentResponse & IRestRouteResponseOptions> {\n\tGuards.object<IBlobStorageGetContentRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IBlobStorageGetContentRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IBlobStorageComponent>(componentName);\n\n\tconst decompress = Coerce.boolean(request.query?.decompress);\n\tconst download = Coerce.boolean(request.query?.download) ?? false;\n\n\tconst result = await component.get(request.pathParams.id, {\n\t\tincludeContent: true,\n\t\tdecompress,\n\t\toverrideVaultKeyId: request.query?.overrideVaultKeyId\n\t});\n\n\tconst encodingFormat = result?.encodingFormat ?? MimeTypes.OctetStream;\n\tlet compressedEncodingFormat: MimeTypes | undefined;\n\tlet compressedExtension: string = \"\";\n\n\t// If the entry is compressed and we are not decompressing\n\t// we need to override the encoding format to the compressed type\n\t// and append an additional extension to the filename.\n\tif (result.compression && !decompress) {\n\t\tcompressedEncodingFormat =\n\t\t\tresult.compression === BlobStorageCompressionType.Gzip ? MimeTypes.Gzip : MimeTypes.Zlib;\n\t\tcompressedExtension = `.${MimeTypeHelper.defaultExtension(compressedEncodingFormat)}`;\n\t}\n\n\tlet filename = request.query?.filename;\n\tif (!Is.stringValue(filename)) {\n\t\tfilename = `file.${result.fileExtension ?? MimeTypeHelper.defaultExtension(encodingFormat)}${compressedExtension}`;\n\t}\n\n\treturn {\n\t\tbody: Is.stringBase64(result.blob) ? Converter.base64ToBytes(result.blob) : new Uint8Array(),\n\t\tattachment: {\n\t\t\tmimeType: compressedEncodingFormat ?? encodingFormat,\n\t\t\tfilename,\n\t\t\tinline: !download\n\t\t}\n\t};\n}\n\n/**\n * Update the blob storage metadata.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function blobStorageUpdate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IBlobStorageUpdateRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IBlobStorageUpdateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IBlobStorageUpdateRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IBlobStorageComponent>(componentName);\n\n\tawait component.update(\n\t\trequest.pathParams.id,\n\t\trequest.body.encodingFormat,\n\t\trequest.body.fileExtension,\n\t\trequest.body.metadata\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Remove the blob from storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function blobStorageRemove(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IBlobStorageRemoveRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IBlobStorageRemoveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IBlobStorageGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IBlobStorageComponent>(componentName);\n\n\tawait component.remove(request.pathParams.id);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * List the entries from blob storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function blobStorageList(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IBlobStorageListRequest\n): Promise<IBlobStorageListResponse> {\n\tGuards.object<IBlobStorageListRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tconst mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? \"jsonld\" : \"json\";\n\n\tconst component = ComponentFactory.get<IBlobStorageComponent>(componentName);\n\n\tconst result = await component.query(\n\t\tHttpParameterHelper.objectFromString(request.query?.conditions),\n\t\trequest.query?.orderBy,\n\t\trequest.query?.orderByDirection,\n\t\trequest.query?.cursor,\n\t\tCoerce.number(request.query?.limit)\n\t);\n\n\treturn {\n\t\theaders: {\n\t\t\t[HeaderTypes.ContentType]: mimeType === \"json\" ? MimeTypes.Json : MimeTypes.JsonLd\n\t\t},\n\t\tbody: result\n\t};\n}\n"]}
@@ -264,9 +264,9 @@ export class BlobStorageService {
264
264
  }
265
265
  ], undefined, cursor, limit);
266
266
  let context = [
267
- SchemaOrgContexts.ContextRoot,
268
- BlobStorageContexts.ContextRoot,
269
- BlobStorageContexts.ContextRootCommon
267
+ SchemaOrgContexts.Namespace,
268
+ BlobStorageContexts.Namespace,
269
+ BlobStorageContexts.NamespaceCommon
270
270
  ];
271
271
  const entriesJsonLd = [];
272
272
  for (const entry of result.entities) {
@@ -336,9 +336,9 @@ export class BlobStorageService {
336
336
  entryToJsonLd(entry, blob) {
337
337
  const jsonLd = {
338
338
  "@context": JsonLdProcessor.combineContexts([
339
- BlobStorageContexts.ContextRoot,
340
- BlobStorageContexts.ContextRootCommon,
341
- SchemaOrgContexts.ContextRoot
339
+ BlobStorageContexts.Namespace,
340
+ BlobStorageContexts.NamespaceCommon,
341
+ SchemaOrgContexts.Namespace
342
342
  ], entry?.metadata?.["@context"]),
343
343
  id: entry.id,
344
344
  type: BlobStorageTypes.Entry,
@@ -1 +1 @@
1
- {"version":3,"file":"blobStorageService.js","sourceRoot":"","sources":["../../src/blobStorageService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAMhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EACN,WAAW,EACX,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,aAAa,EACb,GAAG,EACH,UAAU,EAEV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,eAAe,EAA0B,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EACN,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,aAAa,EAEb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACN,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,qBAAqB,EACrB,mBAAmB,EAEnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI/C;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC9B;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC;IAEzE;;;OAGG;IACK,MAAM,CAAU,UAAU,GAAW,MAAM,CAAC;IAEpD;;;;OAIG;IACc,iBAAiB,CAAS;IAE3C;;;OAGG;IACc,mBAAmB,CAA4C;IAEhF;;;OAGG;IACc,eAAe,CAAmB;IAEnD;;;OAGG;IACc,WAAW,CAAqB;IAEjD;;;OAGG;IACH,YAAY,OAA+C;QAC1D,MAAM,KAAK,GAAG,2BAA2B,CAAC,K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C,EAAE,CAAC;YACtB,MAAM,IAAI,aAAa,CAAC,kBAAkB,CAAC,UAAU,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;;;OAMG;IACK,aAAa,CAAC,KAAuB,EAAE,IAAiB;QAC/D,MAAM,MAAM,GAAsB;YACjC,UAAU,EAAE,eAAe,CAAC,eAAe,CAC1C;gBACC,mBAAmB,CAAC,WAAW;gBAC/B,mBAAmB,CAAC,iBAAiB;gBACrC,iBAAiB,CAAC,WAAW;aAC7B,EACD,KAAK,EAAE,QAAQ,EAAE,CAAC,UAAU,CAAC,CACI;YAClC,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,IAAI,EAAE,gBAAgB,CAAC,KAAK;YAC5B,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,cAAc,EAAE,KAAK,EAAE,cAAc;YACrC,aAAa,EAAE,KAAK,EAAE,aAAa;YACnC,QAAQ,EAAE,KAAK,EAAE,QAAQ;YACzB,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;YACrE,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,WAAW,EAAE,KAAK,CAAC,WAAW;SAC9B,CAAC;QAEF,OAAO,MAAM,CAAC;IACf,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tBlobStorageConnectorFactory,\n\tBlobStorageContexts,\n\tBlobStorageTypes,\n\ttype BlobStorageCompressionType,\n\ttype IBlobStorageComponent,\n\ttype IBlobStorageConnector,\n\ttype IBlobStorageEntry,\n\ttype IBlobStorageEntryList\n} from \"@twin.org/blob-storage-models\";\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport {\n\tCompression,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tNotFoundError,\n\tUrn,\n\tValidation,\n\ttype IValidationFailure\n} from \"@twin.org/core\";\nimport { Sha256 } from \"@twin.org/crypto\";\nimport { JsonLdHelper, JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport {\n\tComparisonOperator,\n\tEntitySchemaHelper,\n\tLogicalOperator,\n\tSortDirection,\n\ttype EntityCondition\n} from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tSchemaOrgContexts,\n\tSchemaOrgDataTypes,\n\tSchemaOrgTypes\n} from \"@twin.org/standards-schema-org\";\nimport {\n\tVaultConnectorFactory,\n\tVaultEncryptionType,\n\ttype IVaultConnector\n} from \"@twin.org/vault-models\";\nimport { MimeTypeHelper } from \"@twin.org/web\";\nimport type { BlobStorageEntry } from \"./entities/blobStorageEntry.js\";\nimport type { IBlobStorageServiceConstructorOptions } from \"./models/IBlobStorageServiceConstructorOptions.js\";\n\n/**\n * Service for performing blob storage operations to a connector.\n */\nexport class BlobStorageService implements IBlobStorageComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<BlobStorageService>();\n\n\t/**\n\t * The namespace supported by the blob storage service.\n\t * @internal\n\t */\n\tprivate static readonly _NAMESPACE: string = \"blob\";\n\n\t/**\n\t * The namespace of the default storage connector to use.\n\t * Defaults to the first entry in the factory if not provided.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * The storage connector for the metadata.\n\t * @internal\n\t */\n\tprivate readonly _entryEntityStorage: IEntityStorageConnector<BlobStorageEntry>;\n\n\t/**\n\t * The vault connector for the encryption, can be undefined if no encryption required.\n\t * @internal\n\t */\n\tprivate readonly _vaultConnector?: IVaultConnector;\n\n\t/**\n\t * The id of the vault key to use for encryption if the service has a vault connector configured.\n\t * @internal\n\t */\n\tprivate readonly _vaultKeyId: string | undefined;\n\n\t/**\n\t * Create a new instance of BlobStorageService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IBlobStorageServiceConstructorOptions) {\n\t\tconst names = BlobStorageConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._entryEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.entryEntityStorageType ?? \"blob-storage-entry\"\n\t\t);\n\t\tif (Is.stringValue(options?.vaultConnectorType)) {\n\t\t\tthis._vaultConnector = VaultConnectorFactory.get(options.vaultConnectorType);\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\n\t\tthis._vaultKeyId = options?.config?.vaultKeyId;\n\n\t\tSchemaOrgDataTypes.registerRedirects();\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 BlobStorageService.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.compress Optional compression type to use for the blob, defaults to no compression.\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\tcompress?: BlobStorageCompressionType;\n\t\t\tnamespace?: string;\n\t\t}\n\t): Promise<string> {\n\t\tGuards.stringBase64(BlobStorageService.CLASS_NAME, nameof(blob), blob);\n\n\t\tconst disableEncryption = options?.disableEncryption ?? false;\n\t\tconst vaultKeyId = options?.overrideVaultKeyId ?? this._vaultKeyId;\n\t\tconst encryptionEnabled = !disableEncryption && Is.stringValue(vaultKeyId);\n\n\t\ttry {\n\t\t\tconst connectorNamespace = options?.namespace ?? this._defaultNamespace;\n\n\t\t\tconst blobStorageConnector =\n\t\t\t\tBlobStorageConnectorFactory.get<IBlobStorageConnector>(connectorNamespace);\n\n\t\t\t// Convert the base64 data into bytes\n\t\t\tlet storeBlob = Converter.base64ToBytes(blob);\n\t\t\tconst blobSize = storeBlob.length;\n\n\t\t\t// See if we can detect the mime type and default extension for the data.\n\t\t\t// If not already supplied by the caller. We have to perform this operation\n\t\t\t// on the unencrypted data.\n\t\t\tif (!Is.stringValue(encodingFormat)) {\n\t\t\t\tencodingFormat = await MimeTypeHelper.detect(storeBlob);\n\t\t\t}\n\n\t\t\tif (!Is.stringValue(fileExtension) && Is.stringValue(encodingFormat)) {\n\t\t\t\tfileExtension = MimeTypeHelper.defaultExtension(encodingFormat);\n\t\t\t}\n\n\t\t\tif (Is.object(metadata)) {\n\t\t\t\tconst validationFailures: IValidationFailure[] = [];\n\t\t\t\tawait JsonLdHelper.validate(metadata, validationFailures);\n\t\t\t\tValidation.asValidationError(\n\t\t\t\t\tBlobStorageService.CLASS_NAME,\n\t\t\t\t\tnameof(metadata),\n\t\t\t\t\tvalidationFailures\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst blobHash = `sha256:${Converter.bytesToBase64(Sha256.sum256(storeBlob))}`;\n\n\t\t\tif (!Is.empty(options?.compress)) {\n\t\t\t\tstoreBlob = await Compression.compress(storeBlob, options.compress);\n\t\t\t}\n\n\t\t\t// If we have a vault connector then encrypt the data.\n\t\t\tif (encryptionEnabled) {\n\t\t\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\t\t\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\t\t\t\tif (Is.empty(this._vaultConnector)) {\n\t\t\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"vaultConnectorNotConfigured\");\n\t\t\t\t}\n\t\t\t\tstoreBlob = await this._vaultConnector.encrypt(\n\t\t\t\t\t`${contextIds[ContextIdKeys.Organization]}/${vaultKeyId}`,\n\t\t\t\t\tVaultEncryptionType.ChaCha20Poly1305,\n\t\t\t\t\tstoreBlob\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Set the blob in the storage connector, which may now be encrypted\n\t\t\tconst blobId = await blobStorageConnector.set(storeBlob);\n\n\t\t\t// Now store the entry in entity storage\n\t\t\tconst blobEntry: BlobStorageEntry = {\n\t\t\t\tid: blobId,\n\t\t\t\tdateCreated: new Date(Date.now()).toISOString(),\n\t\t\t\tblobSize,\n\t\t\t\tblobHash,\n\t\t\t\tencodingFormat,\n\t\t\t\tfileExtension,\n\t\t\t\tmetadata,\n\t\t\t\tisEncrypted: encryptionEnabled,\n\t\t\t\tcompression: options?.compress\n\t\t\t};\n\n\t\t\tawait this._entryEntityStorage.set(blobEntry);\n\n\t\t\treturn blobId;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"createFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the blob entry.\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 entry 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(BlobStorageService.CLASS_NAME, nameof(id), id);\n\n\t\tconst includeContent = options?.includeContent ?? false;\n\t\tconst vaultKeyId = options?.overrideVaultKeyId ?? this._vaultKeyId;\n\n\t\ttry {\n\t\t\tconst blobEntry = await this.internalGet(id);\n\n\t\t\tlet returnBlob: Uint8Array | undefined;\n\t\t\tif (includeContent) {\n\t\t\t\tconst blobStorageConnector = this.getConnector(id);\n\t\t\t\treturnBlob = await blobStorageConnector.get(id);\n\t\t\t\tif (Is.undefined(returnBlob)) {\n\t\t\t\t\tthrow new NotFoundError(BlobStorageService.CLASS_NAME, \"blobNotFound\", id);\n\t\t\t\t}\n\n\t\t\t\t// If the data is encrypted then decrypt it.\n\t\t\t\tconst decryptionEnabled = blobEntry.isEncrypted && Is.stringValue(vaultKeyId);\n\t\t\t\tif (decryptionEnabled) {\n\t\t\t\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\t\t\t\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\t\t\t\t\tif (Is.empty(this._vaultConnector)) {\n\t\t\t\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"vaultConnectorNotConfigured\");\n\t\t\t\t\t}\n\n\t\t\t\t\treturnBlob = await this._vaultConnector.decrypt(\n\t\t\t\t\t\t`${contextIds[ContextIdKeys.Organization]}/${vaultKeyId}`,\n\t\t\t\t\t\tVaultEncryptionType.ChaCha20Poly1305,\n\t\t\t\t\t\treturnBlob\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (!Is.empty(blobEntry.compression) && (options?.decompress ?? true)) {\n\t\t\t\t\treturnBlob = await Compression.decompress(returnBlob, blobEntry.compression);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst jsonLd = this.entryToJsonLd(blobEntry, returnBlob);\n\t\t\tconst result = await JsonLdProcessor.compact(jsonLd, jsonLd[\"@context\"]);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"getFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Update the blob with metadata.\n\t * @param id The id of the blob entry 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(BlobStorageService.CLASS_NAME, nameof(id), id);\n\n\t\ttry {\n\t\t\tconst blobEntry = await this._entryEntityStorage.get(id);\n\n\t\t\tif (Is.undefined(blobEntry)) {\n\t\t\t\tthrow new NotFoundError(BlobStorageService.CLASS_NAME, \"blobNotFound\", id);\n\t\t\t}\n\n\t\t\tif (Is.object(metadata)) {\n\t\t\t\tconst validationFailures: IValidationFailure[] = [];\n\t\t\t\tawait JsonLdHelper.validate(metadata, validationFailures);\n\t\t\t\tValidation.asValidationError(\n\t\t\t\t\tBlobStorageService.CLASS_NAME,\n\t\t\t\t\tnameof(metadata),\n\t\t\t\t\tvalidationFailures\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Now store the entry in entity storage\n\t\t\tconst updatedBlobEntry: BlobStorageEntry = {\n\t\t\t\tid: blobEntry.id,\n\t\t\t\tdateCreated: blobEntry.dateCreated,\n\t\t\t\tdateModified: new Date(Date.now()).toISOString(),\n\t\t\t\tblobSize: blobEntry.blobSize,\n\t\t\t\tblobHash: blobEntry.blobHash,\n\t\t\t\tencodingFormat: encodingFormat ?? blobEntry.encodingFormat,\n\t\t\t\tfileExtension: fileExtension ?? blobEntry.fileExtension,\n\t\t\t\tmetadata: metadata ?? blobEntry.metadata,\n\t\t\t\tisEncrypted: blobEntry.isEncrypted,\n\t\t\t\tcompression: blobEntry.compression\n\t\t\t};\n\n\t\t\tawait this._entryEntityStorage.set(updatedBlobEntry);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"updateFailed\", undefined, error);\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(BlobStorageService.CLASS_NAME, nameof(id), id);\n\n\t\ttry {\n\t\t\tconst blobStorageConnector = this.getConnector(id);\n\n\t\t\tawait this._entryEntityStorage.remove(id);\n\n\t\t\tconst removed = await blobStorageConnector.remove(id);\n\n\t\t\tif (!removed) {\n\t\t\t\tthrow new NotFoundError(BlobStorageService.CLASS_NAME, \"blobNotFound\", id);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"removeFailed\", undefined, error);\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 orderProperty = orderBy ?? \"dateCreated\";\n\t\tconst orderDirection = orderByDirection ?? SortDirection.Descending;\n\n\t\tconst result = await this._entryEntityStorage.query(\n\t\t\tconditions,\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tproperty: orderProperty,\n\t\t\t\t\tsortDirection: orderDirection\n\t\t\t\t}\n\t\t\t],\n\t\t\tundefined,\n\t\t\tcursor,\n\t\t\tlimit\n\t\t);\n\n\t\tlet context: IBlobStorageEntryList[\"@context\"] = [\n\t\t\tSchemaOrgContexts.ContextRoot,\n\t\t\tBlobStorageContexts.ContextRoot,\n\t\t\tBlobStorageContexts.ContextRootCommon\n\t\t];\n\t\tconst entriesJsonLd = [];\n\n\t\tfor (const entry of result.entities) {\n\t\t\t// The entries are never Partial as we don't allow custom property requests.\n\t\t\tentriesJsonLd.push(this.entryToJsonLd(entry as BlobStorageEntry));\n\t\t\tcontext = JsonLdProcessor.combineContexts(\n\t\t\t\tcontext,\n\t\t\t\tentry.metadata?.[\"@context\"]\n\t\t\t) as IBlobStorageEntryList[\"@context\"];\n\t\t}\n\n\t\tconst jsonLd: IBlobStorageEntryList = {\n\t\t\t\"@context\": context,\n\t\t\ttype: SchemaOrgTypes.ItemList,\n\t\t\t[SchemaOrgTypes.ItemListElement]: entriesJsonLd,\n\t\t\t[SchemaOrgTypes.NextItem]: result.cursor\n\t\t};\n\n\t\treturn JsonLdProcessor.compact(jsonLd, jsonLd[\"@context\"]);\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the blob storage item in urn format.\n\t * @returns The connector.\n\t * @internal\n\t */\n\tprivate getConnector(id: string): IBlobStorageConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== BlobStorageService._NAMESPACE) {\n\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: BlobStorageService._NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn BlobStorageConnectorFactory.get<IBlobStorageConnector>(idUri.namespaceMethod());\n\t}\n\n\t/**\n\t * Get an entity.\n\t * @param id The id of the entity to get, or the index value if secondaryIndex is set.\n\t * @param secondaryIndex Get the item using a secondary index.\n\t * @param partitionKey The optional partition key to use.\n\t * @returns The object if it can be found or throws.\n\t * @internal\n\t */\n\tprivate async internalGet(id: string): Promise<BlobStorageEntry> {\n\t\tconst schema = this._entryEntityStorage.getSchema();\n\t\tconst primaryKey = EntitySchemaHelper.getPrimaryKey(schema);\n\n\t\tconst conditions: EntityCondition<BlobStorageEntry>[] = [\n\t\t\t{\n\t\t\t\tproperty: primaryKey.property,\n\t\t\t\tcomparison: ComparisonOperator.Equals,\n\t\t\t\tvalue: id\n\t\t\t}\n\t\t];\n\n\t\tconst results = await this._entryEntityStorage.query(\n\t\t\t{\n\t\t\t\tconditions,\n\t\t\t\tlogicalOperator: LogicalOperator.And\n\t\t\t},\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\t1\n\t\t);\n\n\t\tconst entity = results.entities[0] as BlobStorageEntry;\n\n\t\tif (Is.empty(entity)) {\n\t\t\tthrow new NotFoundError(BlobStorageService.CLASS_NAME, \"entityNotFound\", id);\n\t\t}\n\n\t\treturn entity;\n\t}\n\n\t/**\n\t * Convert the entry to JSON-LD.\n\t * @param entry The entry to convert.\n\t * @param blob The optional blob to return.\n\t * @returns The JSON-LD representation of the entry.\n\t * @internal\n\t */\n\tprivate entryToJsonLd(entry: BlobStorageEntry, blob?: Uint8Array): IBlobStorageEntry {\n\t\tconst jsonLd: IBlobStorageEntry = {\n\t\t\t\"@context\": JsonLdProcessor.combineContexts(\n\t\t\t\t[\n\t\t\t\t\tBlobStorageContexts.ContextRoot,\n\t\t\t\t\tBlobStorageContexts.ContextRootCommon,\n\t\t\t\t\tSchemaOrgContexts.ContextRoot\n\t\t\t\t],\n\t\t\t\tentry?.metadata?.[\"@context\"]\n\t\t\t) as IBlobStorageEntry[\"@context\"],\n\t\t\tid: entry.id,\n\t\t\ttype: BlobStorageTypes.Entry,\n\t\t\tdateCreated: entry.dateCreated,\n\t\t\tdateModified: entry.dateModified,\n\t\t\tblobSize: entry.blobSize,\n\t\t\tblobHash: entry.blobHash,\n\t\t\tencodingFormat: entry?.encodingFormat,\n\t\t\tfileExtension: entry?.fileExtension,\n\t\t\tmetadata: entry?.metadata,\n\t\t\tblob: Is.uint8Array(blob) ? Converter.bytesToBase64(blob) : undefined,\n\t\t\tisEncrypted: entry.isEncrypted,\n\t\t\tcompression: entry.compression\n\t\t};\n\n\t\treturn jsonLd;\n\t}\n}\n"]}
1
+ {"version":3,"file":"blobStorageService.js","sourceRoot":"","sources":["../../src/blobStorageService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAMhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EACN,WAAW,EACX,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,aAAa,EACb,GAAG,EACH,UAAU,EAEV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,eAAe,EAA0B,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EACN,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,aAAa,EAEb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACN,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,qBAAqB,EACrB,mBAAmB,EAEnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI/C;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC9B;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC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C9B,CAAC;QAEF,OAAO,MAAM,CAAC;IACf,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tBlobStorageConnectorFactory,\n\tBlobStorageContexts,\n\tBlobStorageTypes,\n\ttype BlobStorageCompressionType,\n\ttype IBlobStorageComponent,\n\ttype IBlobStorageConnector,\n\ttype IBlobStorageEntry,\n\ttype IBlobStorageEntryList\n} from \"@twin.org/blob-storage-models\";\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport {\n\tCompression,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tNotFoundError,\n\tUrn,\n\tValidation,\n\ttype IValidationFailure\n} from \"@twin.org/core\";\nimport { Sha256 } from \"@twin.org/crypto\";\nimport { JsonLdHelper, JsonLdProcessor, type IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport {\n\tComparisonOperator,\n\tEntitySchemaHelper,\n\tLogicalOperator,\n\tSortDirection,\n\ttype EntityCondition\n} from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tSchemaOrgContexts,\n\tSchemaOrgDataTypes,\n\tSchemaOrgTypes\n} from \"@twin.org/standards-schema-org\";\nimport {\n\tVaultConnectorFactory,\n\tVaultEncryptionType,\n\ttype IVaultConnector\n} from \"@twin.org/vault-models\";\nimport { MimeTypeHelper } from \"@twin.org/web\";\nimport type { BlobStorageEntry } from \"./entities/blobStorageEntry.js\";\nimport type { IBlobStorageServiceConstructorOptions } from \"./models/IBlobStorageServiceConstructorOptions.js\";\n\n/**\n * Service for performing blob storage operations to a connector.\n */\nexport class BlobStorageService implements IBlobStorageComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<BlobStorageService>();\n\n\t/**\n\t * The namespace supported by the blob storage service.\n\t * @internal\n\t */\n\tprivate static readonly _NAMESPACE: string = \"blob\";\n\n\t/**\n\t * The namespace of the default storage connector to use.\n\t * Defaults to the first entry in the factory if not provided.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * The storage connector for the metadata.\n\t * @internal\n\t */\n\tprivate readonly _entryEntityStorage: IEntityStorageConnector<BlobStorageEntry>;\n\n\t/**\n\t * The vault connector for the encryption, can be undefined if no encryption required.\n\t * @internal\n\t */\n\tprivate readonly _vaultConnector?: IVaultConnector;\n\n\t/**\n\t * The id of the vault key to use for encryption if the service has a vault connector configured.\n\t * @internal\n\t */\n\tprivate readonly _vaultKeyId: string | undefined;\n\n\t/**\n\t * Create a new instance of BlobStorageService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IBlobStorageServiceConstructorOptions) {\n\t\tconst names = BlobStorageConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._entryEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.entryEntityStorageType ?? \"blob-storage-entry\"\n\t\t);\n\t\tif (Is.stringValue(options?.vaultConnectorType)) {\n\t\t\tthis._vaultConnector = VaultConnectorFactory.get(options.vaultConnectorType);\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\n\t\tthis._vaultKeyId = options?.config?.vaultKeyId;\n\n\t\tSchemaOrgDataTypes.registerRedirects();\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 BlobStorageService.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.compress Optional compression type to use for the blob, defaults to no compression.\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\tcompress?: BlobStorageCompressionType;\n\t\t\tnamespace?: string;\n\t\t}\n\t): Promise<string> {\n\t\tGuards.stringBase64(BlobStorageService.CLASS_NAME, nameof(blob), blob);\n\n\t\tconst disableEncryption = options?.disableEncryption ?? false;\n\t\tconst vaultKeyId = options?.overrideVaultKeyId ?? this._vaultKeyId;\n\t\tconst encryptionEnabled = !disableEncryption && Is.stringValue(vaultKeyId);\n\n\t\ttry {\n\t\t\tconst connectorNamespace = options?.namespace ?? this._defaultNamespace;\n\n\t\t\tconst blobStorageConnector =\n\t\t\t\tBlobStorageConnectorFactory.get<IBlobStorageConnector>(connectorNamespace);\n\n\t\t\t// Convert the base64 data into bytes\n\t\t\tlet storeBlob = Converter.base64ToBytes(blob);\n\t\t\tconst blobSize = storeBlob.length;\n\n\t\t\t// See if we can detect the mime type and default extension for the data.\n\t\t\t// If not already supplied by the caller. We have to perform this operation\n\t\t\t// on the unencrypted data.\n\t\t\tif (!Is.stringValue(encodingFormat)) {\n\t\t\t\tencodingFormat = await MimeTypeHelper.detect(storeBlob);\n\t\t\t}\n\n\t\t\tif (!Is.stringValue(fileExtension) && Is.stringValue(encodingFormat)) {\n\t\t\t\tfileExtension = MimeTypeHelper.defaultExtension(encodingFormat);\n\t\t\t}\n\n\t\t\tif (Is.object(metadata)) {\n\t\t\t\tconst validationFailures: IValidationFailure[] = [];\n\t\t\t\tawait JsonLdHelper.validate(metadata, validationFailures);\n\t\t\t\tValidation.asValidationError(\n\t\t\t\t\tBlobStorageService.CLASS_NAME,\n\t\t\t\t\tnameof(metadata),\n\t\t\t\t\tvalidationFailures\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst blobHash = `sha256:${Converter.bytesToBase64(Sha256.sum256(storeBlob))}`;\n\n\t\t\tif (!Is.empty(options?.compress)) {\n\t\t\t\tstoreBlob = await Compression.compress(storeBlob, options.compress);\n\t\t\t}\n\n\t\t\t// If we have a vault connector then encrypt the data.\n\t\t\tif (encryptionEnabled) {\n\t\t\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\t\t\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\t\t\t\tif (Is.empty(this._vaultConnector)) {\n\t\t\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"vaultConnectorNotConfigured\");\n\t\t\t\t}\n\t\t\t\tstoreBlob = await this._vaultConnector.encrypt(\n\t\t\t\t\t`${contextIds[ContextIdKeys.Organization]}/${vaultKeyId}`,\n\t\t\t\t\tVaultEncryptionType.ChaCha20Poly1305,\n\t\t\t\t\tstoreBlob\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Set the blob in the storage connector, which may now be encrypted\n\t\t\tconst blobId = await blobStorageConnector.set(storeBlob);\n\n\t\t\t// Now store the entry in entity storage\n\t\t\tconst blobEntry: BlobStorageEntry = {\n\t\t\t\tid: blobId,\n\t\t\t\tdateCreated: new Date(Date.now()).toISOString(),\n\t\t\t\tblobSize,\n\t\t\t\tblobHash,\n\t\t\t\tencodingFormat,\n\t\t\t\tfileExtension,\n\t\t\t\tmetadata,\n\t\t\t\tisEncrypted: encryptionEnabled,\n\t\t\t\tcompression: options?.compress\n\t\t\t};\n\n\t\t\tawait this._entryEntityStorage.set(blobEntry);\n\n\t\t\treturn blobId;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"createFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the blob entry.\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 entry 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(BlobStorageService.CLASS_NAME, nameof(id), id);\n\n\t\tconst includeContent = options?.includeContent ?? false;\n\t\tconst vaultKeyId = options?.overrideVaultKeyId ?? this._vaultKeyId;\n\n\t\ttry {\n\t\t\tconst blobEntry = await this.internalGet(id);\n\n\t\t\tlet returnBlob: Uint8Array | undefined;\n\t\t\tif (includeContent) {\n\t\t\t\tconst blobStorageConnector = this.getConnector(id);\n\t\t\t\treturnBlob = await blobStorageConnector.get(id);\n\t\t\t\tif (Is.undefined(returnBlob)) {\n\t\t\t\t\tthrow new NotFoundError(BlobStorageService.CLASS_NAME, \"blobNotFound\", id);\n\t\t\t\t}\n\n\t\t\t\t// If the data is encrypted then decrypt it.\n\t\t\t\tconst decryptionEnabled = blobEntry.isEncrypted && Is.stringValue(vaultKeyId);\n\t\t\t\tif (decryptionEnabled) {\n\t\t\t\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\t\t\t\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\t\t\t\t\tif (Is.empty(this._vaultConnector)) {\n\t\t\t\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"vaultConnectorNotConfigured\");\n\t\t\t\t\t}\n\n\t\t\t\t\treturnBlob = await this._vaultConnector.decrypt(\n\t\t\t\t\t\t`${contextIds[ContextIdKeys.Organization]}/${vaultKeyId}`,\n\t\t\t\t\t\tVaultEncryptionType.ChaCha20Poly1305,\n\t\t\t\t\t\treturnBlob\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (!Is.empty(blobEntry.compression) && (options?.decompress ?? true)) {\n\t\t\t\t\treturnBlob = await Compression.decompress(returnBlob, blobEntry.compression);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst jsonLd = this.entryToJsonLd(blobEntry, returnBlob);\n\t\t\tconst result = await JsonLdProcessor.compact(jsonLd, jsonLd[\"@context\"]);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"getFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Update the blob with metadata.\n\t * @param id The id of the blob entry 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(BlobStorageService.CLASS_NAME, nameof(id), id);\n\n\t\ttry {\n\t\t\tconst blobEntry = await this._entryEntityStorage.get(id);\n\n\t\t\tif (Is.undefined(blobEntry)) {\n\t\t\t\tthrow new NotFoundError(BlobStorageService.CLASS_NAME, \"blobNotFound\", id);\n\t\t\t}\n\n\t\t\tif (Is.object(metadata)) {\n\t\t\t\tconst validationFailures: IValidationFailure[] = [];\n\t\t\t\tawait JsonLdHelper.validate(metadata, validationFailures);\n\t\t\t\tValidation.asValidationError(\n\t\t\t\t\tBlobStorageService.CLASS_NAME,\n\t\t\t\t\tnameof(metadata),\n\t\t\t\t\tvalidationFailures\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Now store the entry in entity storage\n\t\t\tconst updatedBlobEntry: BlobStorageEntry = {\n\t\t\t\tid: blobEntry.id,\n\t\t\t\tdateCreated: blobEntry.dateCreated,\n\t\t\t\tdateModified: new Date(Date.now()).toISOString(),\n\t\t\t\tblobSize: blobEntry.blobSize,\n\t\t\t\tblobHash: blobEntry.blobHash,\n\t\t\t\tencodingFormat: encodingFormat ?? blobEntry.encodingFormat,\n\t\t\t\tfileExtension: fileExtension ?? blobEntry.fileExtension,\n\t\t\t\tmetadata: metadata ?? blobEntry.metadata,\n\t\t\t\tisEncrypted: blobEntry.isEncrypted,\n\t\t\t\tcompression: blobEntry.compression\n\t\t\t};\n\n\t\t\tawait this._entryEntityStorage.set(updatedBlobEntry);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"updateFailed\", undefined, error);\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(BlobStorageService.CLASS_NAME, nameof(id), id);\n\n\t\ttry {\n\t\t\tconst blobStorageConnector = this.getConnector(id);\n\n\t\t\tawait this._entryEntityStorage.remove(id);\n\n\t\t\tconst removed = await blobStorageConnector.remove(id);\n\n\t\t\tif (!removed) {\n\t\t\t\tthrow new NotFoundError(BlobStorageService.CLASS_NAME, \"blobNotFound\", id);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"removeFailed\", undefined, error);\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 orderProperty = orderBy ?? \"dateCreated\";\n\t\tconst orderDirection = orderByDirection ?? SortDirection.Descending;\n\n\t\tconst result = await this._entryEntityStorage.query(\n\t\t\tconditions,\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tproperty: orderProperty,\n\t\t\t\t\tsortDirection: orderDirection\n\t\t\t\t}\n\t\t\t],\n\t\t\tundefined,\n\t\t\tcursor,\n\t\t\tlimit\n\t\t);\n\n\t\tlet context: IBlobStorageEntryList[\"@context\"] = [\n\t\t\tSchemaOrgContexts.Namespace,\n\t\t\tBlobStorageContexts.Namespace,\n\t\t\tBlobStorageContexts.NamespaceCommon\n\t\t];\n\t\tconst entriesJsonLd = [];\n\n\t\tfor (const entry of result.entities) {\n\t\t\t// The entries are never Partial as we don't allow custom property requests.\n\t\t\tentriesJsonLd.push(this.entryToJsonLd(entry as BlobStorageEntry));\n\t\t\tcontext = JsonLdProcessor.combineContexts(\n\t\t\t\tcontext,\n\t\t\t\tentry.metadata?.[\"@context\"]\n\t\t\t) as IBlobStorageEntryList[\"@context\"];\n\t\t}\n\n\t\tconst jsonLd: IBlobStorageEntryList = {\n\t\t\t\"@context\": context,\n\t\t\ttype: SchemaOrgTypes.ItemList,\n\t\t\t[SchemaOrgTypes.ItemListElement]: entriesJsonLd,\n\t\t\t[SchemaOrgTypes.NextItem]: result.cursor\n\t\t};\n\n\t\treturn JsonLdProcessor.compact(jsonLd, jsonLd[\"@context\"]);\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the blob storage item in urn format.\n\t * @returns The connector.\n\t * @internal\n\t */\n\tprivate getConnector(id: string): IBlobStorageConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== BlobStorageService._NAMESPACE) {\n\t\t\tthrow new GeneralError(BlobStorageService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: BlobStorageService._NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn BlobStorageConnectorFactory.get<IBlobStorageConnector>(idUri.namespaceMethod());\n\t}\n\n\t/**\n\t * Get an entity.\n\t * @param id The id of the entity to get, or the index value if secondaryIndex is set.\n\t * @param secondaryIndex Get the item using a secondary index.\n\t * @param partitionKey The optional partition key to use.\n\t * @returns The object if it can be found or throws.\n\t * @internal\n\t */\n\tprivate async internalGet(id: string): Promise<BlobStorageEntry> {\n\t\tconst schema = this._entryEntityStorage.getSchema();\n\t\tconst primaryKey = EntitySchemaHelper.getPrimaryKey(schema);\n\n\t\tconst conditions: EntityCondition<BlobStorageEntry>[] = [\n\t\t\t{\n\t\t\t\tproperty: primaryKey.property,\n\t\t\t\tcomparison: ComparisonOperator.Equals,\n\t\t\t\tvalue: id\n\t\t\t}\n\t\t];\n\n\t\tconst results = await this._entryEntityStorage.query(\n\t\t\t{\n\t\t\t\tconditions,\n\t\t\t\tlogicalOperator: LogicalOperator.And\n\t\t\t},\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\t1\n\t\t);\n\n\t\tconst entity = results.entities[0] as BlobStorageEntry;\n\n\t\tif (Is.empty(entity)) {\n\t\t\tthrow new NotFoundError(BlobStorageService.CLASS_NAME, \"entityNotFound\", id);\n\t\t}\n\n\t\treturn entity;\n\t}\n\n\t/**\n\t * Convert the entry to JSON-LD.\n\t * @param entry The entry to convert.\n\t * @param blob The optional blob to return.\n\t * @returns The JSON-LD representation of the entry.\n\t * @internal\n\t */\n\tprivate entryToJsonLd(entry: BlobStorageEntry, blob?: Uint8Array): IBlobStorageEntry {\n\t\tconst jsonLd: IBlobStorageEntry = {\n\t\t\t\"@context\": JsonLdProcessor.combineContexts(\n\t\t\t\t[\n\t\t\t\t\tBlobStorageContexts.Namespace,\n\t\t\t\t\tBlobStorageContexts.NamespaceCommon,\n\t\t\t\t\tSchemaOrgContexts.Namespace\n\t\t\t\t],\n\t\t\t\tentry?.metadata?.[\"@context\"]\n\t\t\t) as IBlobStorageEntry[\"@context\"],\n\t\t\tid: entry.id,\n\t\t\ttype: BlobStorageTypes.Entry,\n\t\t\tdateCreated: entry.dateCreated,\n\t\t\tdateModified: entry.dateModified,\n\t\t\tblobSize: entry.blobSize,\n\t\t\tblobHash: entry.blobHash,\n\t\t\tencodingFormat: entry?.encodingFormat,\n\t\t\tfileExtension: entry?.fileExtension,\n\t\t\tmetadata: entry?.metadata,\n\t\t\tblob: Is.uint8Array(blob) ? Converter.bytesToBase64(blob) : undefined,\n\t\t\tisEncrypted: entry.isEncrypted,\n\t\t\tcompression: entry.compression\n\t\t};\n\n\t\treturn jsonLd;\n\t}\n}\n"]}
package/docs/changelog.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @twin.org/blob-storage-service - Changelog
2
2
 
3
+ ## [0.0.3-next.2](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.3-next.1...blob-storage-service-v0.0.3-next.2) (2026-01-14)
4
+
5
+
6
+ ### Features
7
+
8
+ * update contexts and namespaces ([#32](https://github.com/twinfoundation/blob-storage/issues/32)) ([187ed36](https://github.com/twinfoundation/blob-storage/commit/187ed36a7d83062665f70689ec5e2b2f553a592e))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * api docs ([0f5d3ad](https://github.com/twinfoundation/blob-storage/commit/0f5d3ad88c4c048495ffd64886d00ceb25a976d6))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * The following workspace dependencies were updated
19
+ * dependencies
20
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.1 to 0.0.3-next.2
21
+ * devDependencies
22
+ * @twin.org/blob-storage-connector-memory bumped from 0.0.3-next.1 to 0.0.3-next.2
23
+
3
24
  ## [0.0.3-next.1](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.3-next.0...blob-storage-service-v0.0.3-next.1) (2025-11-11)
4
25
 
5
26
 
@@ -57,15 +57,8 @@
57
57
  }
58
58
  },
59
59
  "responses": {
60
- "200": {
60
+ "201": {
61
61
  "description": "The rest request ended in created response.",
62
- "content": {
63
- "text/plain": {
64
- "schema": {
65
- "$ref": "#/components/schemas/CreatedResponse"
66
- }
67
- }
68
- },
69
62
  "headers": {
70
63
  "location": {
71
64
  "schema": {
@@ -74,6 +67,63 @@
74
67
  "description": "e.g. blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70"
75
68
  }
76
69
  }
70
+ },
71
+ "400": {
72
+ "description": "The server cannot process the request, see the content for more details.",
73
+ "content": {
74
+ "application/json": {
75
+ "schema": {
76
+ "$ref": "#/components/schemas/Error"
77
+ },
78
+ "examples": {
79
+ "exampleResponse": {
80
+ "value": {
81
+ "name": "GeneralError",
82
+ "message": "errorMessage",
83
+ "properties": {
84
+ "foo": "bar"
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
91
+ },
92
+ "401": {
93
+ "description": "You are not authorized to use the API or no credentials were supplied, see the content for more details.",
94
+ "content": {
95
+ "application/json": {
96
+ "schema": {
97
+ "$ref": "#/components/schemas/Error"
98
+ },
99
+ "examples": {
100
+ "exampleResponse": {
101
+ "value": {
102
+ "name": "UnauthorizedError",
103
+ "message": "errorMessage"
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
109
+ },
110
+ "500": {
111
+ "description": "The server has encountered a situation it does not know how to handle, see the content for more details.",
112
+ "content": {
113
+ "application/json": {
114
+ "schema": {
115
+ "$ref": "#/components/schemas/Error"
116
+ },
117
+ "examples": {
118
+ "exampleResponse": {
119
+ "value": {
120
+ "name": "InternalServerError",
121
+ "message": "errorMessage"
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }
77
127
  }
78
128
  }
79
129
  },
@@ -150,11 +200,45 @@
150
200
  ],
151
201
  "responses": {
152
202
  "200": {
153
- "description": "The resource you tried to access does not exist, see the content for more details.",
203
+ "description": "Response to getting the list of entries from a query.",
154
204
  "content": {
155
205
  "application/json": {
156
206
  "schema": {
157
- "$ref": "#/components/schemas/NotFoundResponse"
207
+ "$ref": "#/components/schemas/BlobStorageEntryList"
208
+ },
209
+ "examples": {
210
+ "blobStorageListResponseExample": {
211
+ "value": {
212
+ "@context": [
213
+ "https://schema.org",
214
+ "https://schema.twindev.org/blob-storage/",
215
+ "https://schema.twindev.org/common/"
216
+ ],
217
+ "type": "ItemList",
218
+ "itemListElement": [
219
+ {
220
+ "@context": [
221
+ "https://schema.twindev.org/blob-storage/",
222
+ "https://schema.twindev.org/common/",
223
+ "https://schema.org"
224
+ ],
225
+ "type": "BlobStorageEntry",
226
+ "id": "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
227
+ "dateCreated": "2024-01-01T00:00:00Z",
228
+ "encodingFormat": "application/pdf",
229
+ "blobSize": 42,
230
+ "blobHash": "sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
231
+ "fileExtension": "pdf",
232
+ "metadata": {
233
+ "@context": "https://schema.org",
234
+ "@type": "DigitalDocument",
235
+ "name": "myfile.pdf"
236
+ },
237
+ "blob": "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=="
238
+ }
239
+ ]
240
+ }
241
+ }
158
242
  }
159
243
  },
160
244
  "application/ld+json": {
@@ -197,6 +281,84 @@
197
281
  }
198
282
  }
199
283
  }
284
+ },
285
+ "400": {
286
+ "description": "The server cannot process the request, see the content for more details.",
287
+ "content": {
288
+ "application/json": {
289
+ "schema": {
290
+ "$ref": "#/components/schemas/Error"
291
+ },
292
+ "examples": {
293
+ "exampleResponse": {
294
+ "value": {
295
+ "name": "GeneralError",
296
+ "message": "errorMessage",
297
+ "properties": {
298
+ "foo": "bar"
299
+ }
300
+ }
301
+ }
302
+ }
303
+ }
304
+ }
305
+ },
306
+ "401": {
307
+ "description": "You are not authorized to use the API or no credentials were supplied, see the content for more details.",
308
+ "content": {
309
+ "application/json": {
310
+ "schema": {
311
+ "$ref": "#/components/schemas/Error"
312
+ },
313
+ "examples": {
314
+ "exampleResponse": {
315
+ "value": {
316
+ "name": "UnauthorizedError",
317
+ "message": "errorMessage"
318
+ }
319
+ }
320
+ }
321
+ }
322
+ }
323
+ },
324
+ "404": {
325
+ "description": "The resource you tried to access does not exist, see the content for more details.",
326
+ "content": {
327
+ "application/json": {
328
+ "schema": {
329
+ "$ref": "#/components/schemas/NotFoundResponse"
330
+ },
331
+ "examples": {
332
+ "exampleResponse": {
333
+ "value": {
334
+ "name": "NotFoundError",
335
+ "message": "errorMessage",
336
+ "properties": {
337
+ "notFoundId": "1"
338
+ }
339
+ }
340
+ }
341
+ }
342
+ }
343
+ }
344
+ },
345
+ "500": {
346
+ "description": "The server has encountered a situation it does not know how to handle, see the content for more details.",
347
+ "content": {
348
+ "application/json": {
349
+ "schema": {
350
+ "$ref": "#/components/schemas/Error"
351
+ },
352
+ "examples": {
353
+ "exampleResponse": {
354
+ "value": {
355
+ "name": "InternalServerError",
356
+ "message": "errorMessage"
357
+ }
358
+ }
359
+ }
360
+ }
361
+ }
200
362
  }
201
363
  }
202
364
  }
@@ -226,10 +388,7 @@
226
388
  "in": "query",
227
389
  "required": false,
228
390
  "schema": {
229
- "type": [
230
- "boolean",
231
- "string"
232
- ]
391
+ "type": "string"
233
392
  },
234
393
  "example": "true"
235
394
  },
@@ -239,10 +398,7 @@
239
398
  "in": "query",
240
399
  "required": false,
241
400
  "schema": {
242
- "type": [
243
- "boolean",
244
- "string"
245
- ]
401
+ "type": "string"
246
402
  }
247
403
  },
248
404
  {
@@ -271,11 +427,35 @@
271
427
  ],
272
428
  "responses": {
273
429
  "200": {
274
- "description": "The resource you tried to access does not exist, see the content for more details.",
430
+ "description": "Response to get an entry from blob storage.",
275
431
  "content": {
276
432
  "application/json": {
277
433
  "schema": {
278
- "$ref": "#/components/schemas/NotFoundResponse"
434
+ "$ref": "#/components/schemas/BlobStorageEntry"
435
+ },
436
+ "examples": {
437
+ "blobStorageGetResponseExample": {
438
+ "value": {
439
+ "@context": [
440
+ "https://schema.twindev.org/blob-storage/",
441
+ "https://schema.twindev.org/common/",
442
+ "https://schema.org"
443
+ ],
444
+ "type": "BlobStorageEntry",
445
+ "id": "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
446
+ "dateCreated": "2024-01-01T00:00:00Z",
447
+ "encodingFormat": "application/pdf",
448
+ "blobSize": 42,
449
+ "blobHash": "sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
450
+ "fileExtension": "pdf",
451
+ "metadata": {
452
+ "@context": "https://schema.org",
453
+ "@type": "DigitalDocument",
454
+ "name": "myfile.pdf"
455
+ },
456
+ "blob": "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=="
457
+ }
458
+ }
279
459
  }
280
460
  },
281
461
  "application/ld+json": {
@@ -308,6 +488,84 @@
308
488
  }
309
489
  }
310
490
  }
491
+ },
492
+ "400": {
493
+ "description": "The server cannot process the request, see the content for more details.",
494
+ "content": {
495
+ "application/json": {
496
+ "schema": {
497
+ "$ref": "#/components/schemas/Error"
498
+ },
499
+ "examples": {
500
+ "exampleResponse": {
501
+ "value": {
502
+ "name": "GeneralError",
503
+ "message": "errorMessage",
504
+ "properties": {
505
+ "foo": "bar"
506
+ }
507
+ }
508
+ }
509
+ }
510
+ }
511
+ }
512
+ },
513
+ "401": {
514
+ "description": "You are not authorized to use the API or no credentials were supplied, see the content for more details.",
515
+ "content": {
516
+ "application/json": {
517
+ "schema": {
518
+ "$ref": "#/components/schemas/Error"
519
+ },
520
+ "examples": {
521
+ "exampleResponse": {
522
+ "value": {
523
+ "name": "UnauthorizedError",
524
+ "message": "errorMessage"
525
+ }
526
+ }
527
+ }
528
+ }
529
+ }
530
+ },
531
+ "404": {
532
+ "description": "The resource you tried to access does not exist, see the content for more details.",
533
+ "content": {
534
+ "application/json": {
535
+ "schema": {
536
+ "$ref": "#/components/schemas/NotFoundResponse"
537
+ },
538
+ "examples": {
539
+ "exampleResponse": {
540
+ "value": {
541
+ "name": "NotFoundError",
542
+ "message": "errorMessage",
543
+ "properties": {
544
+ "notFoundId": "1"
545
+ }
546
+ }
547
+ }
548
+ }
549
+ }
550
+ }
551
+ },
552
+ "500": {
553
+ "description": "The server has encountered a situation it does not know how to handle, see the content for more details.",
554
+ "content": {
555
+ "application/json": {
556
+ "schema": {
557
+ "$ref": "#/components/schemas/Error"
558
+ },
559
+ "examples": {
560
+ "exampleResponse": {
561
+ "value": {
562
+ "name": "InternalServerError",
563
+ "message": "errorMessage"
564
+ }
565
+ }
566
+ }
567
+ }
568
+ }
311
569
  }
312
570
  }
313
571
  },
@@ -358,12 +616,62 @@
358
616
  }
359
617
  },
360
618
  "responses": {
361
- "200": {
362
- "description": "The rest request ended in success with no data.",
619
+ "204": {
620
+ "description": "The rest request ended in success with no data."
621
+ },
622
+ "400": {
623
+ "description": "The server cannot process the request, see the content for more details.",
363
624
  "content": {
364
- "text/plain": {
625
+ "application/json": {
365
626
  "schema": {
366
- "$ref": "#/components/schemas/NoContentResponse"
627
+ "$ref": "#/components/schemas/Error"
628
+ },
629
+ "examples": {
630
+ "exampleResponse": {
631
+ "value": {
632
+ "name": "GeneralError",
633
+ "message": "errorMessage",
634
+ "properties": {
635
+ "foo": "bar"
636
+ }
637
+ }
638
+ }
639
+ }
640
+ }
641
+ }
642
+ },
643
+ "401": {
644
+ "description": "You are not authorized to use the API or no credentials were supplied, see the content for more details.",
645
+ "content": {
646
+ "application/json": {
647
+ "schema": {
648
+ "$ref": "#/components/schemas/Error"
649
+ },
650
+ "examples": {
651
+ "exampleResponse": {
652
+ "value": {
653
+ "name": "UnauthorizedError",
654
+ "message": "errorMessage"
655
+ }
656
+ }
657
+ }
658
+ }
659
+ }
660
+ },
661
+ "500": {
662
+ "description": "The server has encountered a situation it does not know how to handle, see the content for more details.",
663
+ "content": {
664
+ "application/json": {
665
+ "schema": {
666
+ "$ref": "#/components/schemas/Error"
667
+ },
668
+ "examples": {
669
+ "exampleResponse": {
670
+ "value": {
671
+ "name": "InternalServerError",
672
+ "message": "errorMessage"
673
+ }
674
+ }
367
675
  }
368
676
  }
369
677
  }
@@ -395,17 +703,83 @@
395
703
  }
396
704
  ],
397
705
  "responses": {
398
- "200": {
399
- "description": "The resource you tried to access does not exist, see the content for more details.",
706
+ "204": {
707
+ "description": "The rest request ended in success with no data."
708
+ },
709
+ "400": {
710
+ "description": "The server cannot process the request, see the content for more details.",
711
+ "content": {
712
+ "application/json": {
713
+ "schema": {
714
+ "$ref": "#/components/schemas/Error"
715
+ },
716
+ "examples": {
717
+ "exampleResponse": {
718
+ "value": {
719
+ "name": "GeneralError",
720
+ "message": "errorMessage",
721
+ "properties": {
722
+ "foo": "bar"
723
+ }
724
+ }
725
+ }
726
+ }
727
+ }
728
+ }
729
+ },
730
+ "401": {
731
+ "description": "You are not authorized to use the API or no credentials were supplied, see the content for more details.",
400
732
  "content": {
401
- "text/plain": {
733
+ "application/json": {
402
734
  "schema": {
403
- "$ref": "#/components/schemas/NoContentResponse"
735
+ "$ref": "#/components/schemas/Error"
736
+ },
737
+ "examples": {
738
+ "exampleResponse": {
739
+ "value": {
740
+ "name": "UnauthorizedError",
741
+ "message": "errorMessage"
742
+ }
743
+ }
404
744
  }
405
- },
745
+ }
746
+ }
747
+ },
748
+ "404": {
749
+ "description": "The resource you tried to access does not exist, see the content for more details.",
750
+ "content": {
406
751
  "application/json": {
407
752
  "schema": {
408
753
  "$ref": "#/components/schemas/NotFoundResponse"
754
+ },
755
+ "examples": {
756
+ "exampleResponse": {
757
+ "value": {
758
+ "name": "NotFoundError",
759
+ "message": "errorMessage",
760
+ "properties": {
761
+ "notFoundId": "1"
762
+ }
763
+ }
764
+ }
765
+ }
766
+ }
767
+ }
768
+ },
769
+ "500": {
770
+ "description": "The server has encountered a situation it does not know how to handle, see the content for more details.",
771
+ "content": {
772
+ "application/json": {
773
+ "schema": {
774
+ "$ref": "#/components/schemas/Error"
775
+ },
776
+ "examples": {
777
+ "exampleResponse": {
778
+ "value": {
779
+ "name": "InternalServerError",
780
+ "message": "errorMessage"
781
+ }
782
+ }
409
783
  }
410
784
  }
411
785
  }
@@ -440,7 +814,7 @@
440
814
  ],
441
815
  "responses": {
442
816
  "200": {
443
- "description": "The resource you tried to access does not exist, see the content for more details.",
817
+ "description": "The content of the blob, which will be a specific mime type if one can be detected from the content (or set as encodingFormat in the entry), or defaults to application/octet-stream.",
444
818
  "content": {
445
819
  "application/octet-stream": {
446
820
  "schema": {
@@ -453,10 +827,83 @@
453
827
  "value": ""
454
828
  }
455
829
  }
456
- },
830
+ }
831
+ }
832
+ },
833
+ "400": {
834
+ "description": "The server cannot process the request, see the content for more details.",
835
+ "content": {
836
+ "application/json": {
837
+ "schema": {
838
+ "$ref": "#/components/schemas/Error"
839
+ },
840
+ "examples": {
841
+ "exampleResponse": {
842
+ "value": {
843
+ "name": "GeneralError",
844
+ "message": "errorMessage",
845
+ "properties": {
846
+ "foo": "bar"
847
+ }
848
+ }
849
+ }
850
+ }
851
+ }
852
+ }
853
+ },
854
+ "401": {
855
+ "description": "You are not authorized to use the API or no credentials were supplied, see the content for more details.",
856
+ "content": {
857
+ "application/json": {
858
+ "schema": {
859
+ "$ref": "#/components/schemas/Error"
860
+ },
861
+ "examples": {
862
+ "exampleResponse": {
863
+ "value": {
864
+ "name": "UnauthorizedError",
865
+ "message": "errorMessage"
866
+ }
867
+ }
868
+ }
869
+ }
870
+ }
871
+ },
872
+ "404": {
873
+ "description": "The resource you tried to access does not exist, see the content for more details.",
874
+ "content": {
457
875
  "application/json": {
458
876
  "schema": {
459
877
  "$ref": "#/components/schemas/NotFoundResponse"
878
+ },
879
+ "examples": {
880
+ "exampleResponse": {
881
+ "value": {
882
+ "name": "NotFoundError",
883
+ "message": "errorMessage",
884
+ "properties": {
885
+ "notFoundId": "1"
886
+ }
887
+ }
888
+ }
889
+ }
890
+ }
891
+ }
892
+ },
893
+ "500": {
894
+ "description": "The server has encountered a situation it does not know how to handle, see the content for more details.",
895
+ "content": {
896
+ "application/json": {
897
+ "schema": {
898
+ "$ref": "#/components/schemas/Error"
899
+ },
900
+ "examples": {
901
+ "exampleResponse": {
902
+ "value": {
903
+ "name": "InternalServerError",
904
+ "message": "errorMessage"
905
+ }
906
+ }
460
907
  }
461
908
  }
462
909
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/blob-storage-service",
3
- "version": "0.0.3-next.1",
3
+ "version": "0.0.3-next.2",
4
4
  "description": "Blob storage contract implementation and REST endpoint definitions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@twin.org/api-models": "next",
18
- "@twin.org/blob-storage-models": "0.0.3-next.1",
18
+ "@twin.org/blob-storage-models": "0.0.3-next.2",
19
19
  "@twin.org/context": "next",
20
20
  "@twin.org/core": "next",
21
21
  "@twin.org/crypto": "next",