@twin.org/blob-storage-service 0.0.3-next.1 → 0.0.3-next.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/es/blobStorageRoutes.js +73 -31
- package/dist/es/blobStorageRoutes.js.map +1 -1
- package/dist/es/blobStorageService.js +40 -16
- package/dist/es/blobStorageService.js.map +1 -1
- package/dist/es/entities/blobStorageEntry.js +3 -3
- package/dist/es/entities/blobStorageEntry.js.map +1 -1
- package/dist/types/blobStorageRoutes.d.ts +9 -1
- package/dist/types/blobStorageService.d.ts +9 -1
- package/dist/types/entities/blobStorageEntry.d.ts +2 -2
- package/docs/changelog.md +245 -52
- package/docs/examples.md +109 -1
- package/docs/open-api/spec.json +593 -102
- package/docs/reference/classes/BlobStorageEntry.md +17 -17
- package/docs/reference/classes/BlobStorageService.md +29 -11
- package/docs/reference/functions/blobStorageEmpty.md +31 -0
- package/docs/reference/index.md +1 -0
- package/docs/reference/interfaces/IBlobStorageServiceConfig.md +4 -4
- package/docs/reference/interfaces/IBlobStorageServiceConstructorOptions.md +6 -6
- package/locales/en.json +1 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TWIN Blob Storage Service
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package exposes service-side components and endpoint definitions for blob upload, retrieval, and management operations. It bridges shared blob models with application service layers so APIs can be published with consistent behaviour.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -4,7 +4,7 @@ import { HttpParameterHelper } from "@twin.org/api-models";
|
|
|
4
4
|
import { BlobStorageCompressionType, BlobStorageContexts, BlobStorageTypes } from "@twin.org/blob-storage-models";
|
|
5
5
|
import { Coerce, ComponentFactory, Converter, Guards, Is, StringHelper } from "@twin.org/core";
|
|
6
6
|
import { SchemaOrgContexts, SchemaOrgTypes } from "@twin.org/standards-schema-org";
|
|
7
|
-
import { HeaderTypes, HttpStatusCode, MimeTypeHelper, MimeTypes } from "@twin.org/web";
|
|
7
|
+
import { HeaderHelper, HeaderTypes, HttpStatusCode, MimeTypeHelper, MimeTypes } from "@twin.org/web";
|
|
8
8
|
/**
|
|
9
9
|
* The source used when communicating about these routes.
|
|
10
10
|
*/
|
|
@@ -105,16 +105,16 @@ export function generateRestRoutesBlobStorage(baseRouteName, componentName, opti
|
|
|
105
105
|
response: {
|
|
106
106
|
body: {
|
|
107
107
|
"@context": [
|
|
108
|
-
BlobStorageContexts.
|
|
109
|
-
BlobStorageContexts.
|
|
110
|
-
SchemaOrgContexts.
|
|
108
|
+
BlobStorageContexts.Context,
|
|
109
|
+
BlobStorageContexts.ContextCommon,
|
|
110
|
+
SchemaOrgContexts.Context
|
|
111
111
|
],
|
|
112
112
|
type: BlobStorageTypes.Entry,
|
|
113
113
|
id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
114
114
|
dateCreated: "2024-01-01T00:00:00Z",
|
|
115
115
|
encodingFormat: MimeTypes.Pdf,
|
|
116
116
|
blobSize: 42,
|
|
117
|
-
|
|
117
|
+
integrity: "sha256-xX2UsIj0xtLLMt7QFIExDHhqoAE0yO4i+EseJUVgKnA=",
|
|
118
118
|
fileExtension: "pdf",
|
|
119
119
|
metadata: {
|
|
120
120
|
"@context": "https://schema.org",
|
|
@@ -136,16 +136,16 @@ export function generateRestRoutesBlobStorage(baseRouteName, componentName, opti
|
|
|
136
136
|
response: {
|
|
137
137
|
body: {
|
|
138
138
|
"@context": [
|
|
139
|
-
BlobStorageContexts.
|
|
140
|
-
BlobStorageContexts.
|
|
141
|
-
SchemaOrgContexts.
|
|
139
|
+
BlobStorageContexts.Context,
|
|
140
|
+
BlobStorageContexts.ContextCommon,
|
|
141
|
+
SchemaOrgContexts.Context
|
|
142
142
|
],
|
|
143
143
|
type: BlobStorageTypes.Entry,
|
|
144
144
|
id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
145
145
|
dateCreated: "2024-01-01T00:00:00Z",
|
|
146
146
|
encodingFormat: MimeTypes.Pdf,
|
|
147
147
|
blobSize: 42,
|
|
148
|
-
|
|
148
|
+
integrity: "sha256-xX2UsIj0xtLLMt7QFIExDHhqoAE0yO4i+EseJUVgKnA=",
|
|
149
149
|
fileExtension: "pdf",
|
|
150
150
|
metadata: {
|
|
151
151
|
"@context": "https://schema.org",
|
|
@@ -268,6 +268,28 @@ export function generateRestRoutesBlobStorage(baseRouteName, componentName, opti
|
|
|
268
268
|
}
|
|
269
269
|
]
|
|
270
270
|
};
|
|
271
|
+
const blobStorageEmptyRoute = {
|
|
272
|
+
operationId: `${camelTypeName}Empty`,
|
|
273
|
+
summary: `Remove all entries from ${lowerName}`,
|
|
274
|
+
tag: options?.tagName ?? tagsBlobStorage[0].name,
|
|
275
|
+
method: "DELETE",
|
|
276
|
+
path: `${baseRouteName}/`,
|
|
277
|
+
handler: async (httpRequestContext, request) => blobStorageEmpty(httpRequestContext, componentName, request),
|
|
278
|
+
requestType: {
|
|
279
|
+
type: "IBlobStorageEmptyRequest",
|
|
280
|
+
examples: [
|
|
281
|
+
{
|
|
282
|
+
id: `${camelTypeName}EmptyRequestExample`,
|
|
283
|
+
request: {}
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
},
|
|
287
|
+
responseType: [
|
|
288
|
+
{
|
|
289
|
+
type: "INoContentResponse"
|
|
290
|
+
}
|
|
291
|
+
]
|
|
292
|
+
};
|
|
271
293
|
const blobStorageListRoute = {
|
|
272
294
|
operationId: `${camelTypeName}Query`,
|
|
273
295
|
summary: `Query the items from ${lowerName}`,
|
|
@@ -293,24 +315,24 @@ export function generateRestRoutesBlobStorage(baseRouteName, componentName, opti
|
|
|
293
315
|
response: {
|
|
294
316
|
body: {
|
|
295
317
|
"@context": [
|
|
296
|
-
SchemaOrgContexts.
|
|
297
|
-
BlobStorageContexts.
|
|
298
|
-
BlobStorageContexts.
|
|
318
|
+
SchemaOrgContexts.Context,
|
|
319
|
+
BlobStorageContexts.Context,
|
|
320
|
+
BlobStorageContexts.ContextCommon
|
|
299
321
|
],
|
|
300
322
|
type: SchemaOrgTypes.ItemList,
|
|
301
323
|
[SchemaOrgTypes.ItemListElement]: [
|
|
302
324
|
{
|
|
303
325
|
"@context": [
|
|
304
|
-
BlobStorageContexts.
|
|
305
|
-
BlobStorageContexts.
|
|
306
|
-
SchemaOrgContexts.
|
|
326
|
+
BlobStorageContexts.Context,
|
|
327
|
+
BlobStorageContexts.ContextCommon,
|
|
328
|
+
SchemaOrgContexts.Context
|
|
307
329
|
],
|
|
308
330
|
type: BlobStorageTypes.Entry,
|
|
309
331
|
id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
310
332
|
dateCreated: "2024-01-01T00:00:00Z",
|
|
311
333
|
encodingFormat: MimeTypes.Pdf,
|
|
312
334
|
blobSize: 42,
|
|
313
|
-
|
|
335
|
+
integrity: "sha256-xX2UsIj0xtLLMt7QFIExDHhqoAE0yO4i+EseJUVgKnA=",
|
|
314
336
|
fileExtension: "pdf",
|
|
315
337
|
metadata: {
|
|
316
338
|
"@context": "https://schema.org",
|
|
@@ -334,24 +356,24 @@ export function generateRestRoutesBlobStorage(baseRouteName, componentName, opti
|
|
|
334
356
|
response: {
|
|
335
357
|
body: {
|
|
336
358
|
"@context": [
|
|
337
|
-
SchemaOrgContexts.
|
|
338
|
-
BlobStorageContexts.
|
|
339
|
-
BlobStorageContexts.
|
|
359
|
+
SchemaOrgContexts.Context,
|
|
360
|
+
BlobStorageContexts.Context,
|
|
361
|
+
BlobStorageContexts.ContextCommon
|
|
340
362
|
],
|
|
341
363
|
type: SchemaOrgTypes.ItemList,
|
|
342
364
|
[SchemaOrgTypes.ItemListElement]: [
|
|
343
365
|
{
|
|
344
366
|
"@context": [
|
|
345
|
-
BlobStorageContexts.
|
|
346
|
-
BlobStorageContexts.
|
|
347
|
-
SchemaOrgContexts.
|
|
367
|
+
BlobStorageContexts.Context,
|
|
368
|
+
BlobStorageContexts.ContextCommon,
|
|
369
|
+
SchemaOrgContexts.Context
|
|
348
370
|
],
|
|
349
371
|
type: BlobStorageTypes.Entry,
|
|
350
372
|
id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
351
373
|
dateCreated: "2024-01-01T00:00:00Z",
|
|
352
374
|
encodingFormat: MimeTypes.Pdf,
|
|
353
375
|
blobSize: 42,
|
|
354
|
-
|
|
376
|
+
integrity: "sha256-xX2UsIj0xtLLMt7QFIExDHhqoAE0yO4i+EseJUVgKnA=",
|
|
355
377
|
fileExtension: "pdf",
|
|
356
378
|
metadata: {
|
|
357
379
|
"@context": "https://schema.org",
|
|
@@ -377,6 +399,7 @@ export function generateRestRoutesBlobStorage(baseRouteName, componentName, opti
|
|
|
377
399
|
blobStorageGetContentRoute,
|
|
378
400
|
blobStorageUpdateRoute,
|
|
379
401
|
blobStorageRemoveRoute,
|
|
402
|
+
blobStorageEmptyRoute,
|
|
380
403
|
blobStorageListRoute
|
|
381
404
|
];
|
|
382
405
|
}
|
|
@@ -400,7 +423,7 @@ export async function blobStorageCreate(httpRequestContext, componentName, reque
|
|
|
400
423
|
return {
|
|
401
424
|
statusCode: HttpStatusCode.created,
|
|
402
425
|
headers: {
|
|
403
|
-
|
|
426
|
+
[HeaderTypes.Location]: id
|
|
404
427
|
}
|
|
405
428
|
};
|
|
406
429
|
}
|
|
@@ -415,7 +438,6 @@ export async function blobStorageGet(httpRequestContext, componentName, request)
|
|
|
415
438
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
416
439
|
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
417
440
|
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
418
|
-
const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
419
441
|
const component = ComponentFactory.get(componentName);
|
|
420
442
|
const result = await component.get(request.pathParams.id, {
|
|
421
443
|
includeContent: Coerce.boolean(request.query?.includeContent),
|
|
@@ -424,7 +446,9 @@ export async function blobStorageGet(httpRequestContext, componentName, request)
|
|
|
424
446
|
});
|
|
425
447
|
return {
|
|
426
448
|
headers: {
|
|
427
|
-
[HeaderTypes.ContentType]:
|
|
449
|
+
[HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd
|
|
450
|
+
? MimeTypes.JsonLd
|
|
451
|
+
: MimeTypes.Json
|
|
428
452
|
},
|
|
429
453
|
body: result
|
|
430
454
|
};
|
|
@@ -506,6 +530,20 @@ export async function blobStorageRemove(httpRequestContext, componentName, reque
|
|
|
506
530
|
statusCode: HttpStatusCode.noContent
|
|
507
531
|
};
|
|
508
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* Remove all entries from blob storage.
|
|
535
|
+
* @param httpRequestContext The request context for the API.
|
|
536
|
+
* @param componentName The name of the component to use in the routes.
|
|
537
|
+
* @param request The request.
|
|
538
|
+
* @returns The response object with additional http response properties.
|
|
539
|
+
*/
|
|
540
|
+
export async function blobStorageEmpty(httpRequestContext, componentName, request) {
|
|
541
|
+
const component = ComponentFactory.get(componentName);
|
|
542
|
+
await component.empty();
|
|
543
|
+
return {
|
|
544
|
+
statusCode: HttpStatusCode.noContent
|
|
545
|
+
};
|
|
546
|
+
}
|
|
509
547
|
/**
|
|
510
548
|
* List the entries from blob storage.
|
|
511
549
|
* @param httpRequestContext The request context for the API.
|
|
@@ -515,14 +553,18 @@ export async function blobStorageRemove(httpRequestContext, componentName, reque
|
|
|
515
553
|
*/
|
|
516
554
|
export async function blobStorageList(httpRequestContext, componentName, request) {
|
|
517
555
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
518
|
-
const
|
|
556
|
+
const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
|
|
519
557
|
const component = ComponentFactory.get(componentName);
|
|
520
558
|
const result = await component.query(HttpParameterHelper.objectFromString(request.query?.conditions), request.query?.orderBy, request.query?.orderByDirection, request.query?.cursor, Coerce.number(request.query?.limit));
|
|
559
|
+
const headers = {
|
|
560
|
+
[HeaderTypes.ContentType]: request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json
|
|
561
|
+
};
|
|
562
|
+
if (Is.stringValue(result.cursor)) {
|
|
563
|
+
headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(await hostingComponent.buildPublicUrl(httpRequestContext.serverRequest.url), { cursor: result.cursor }, "next");
|
|
564
|
+
}
|
|
521
565
|
return {
|
|
522
|
-
headers
|
|
523
|
-
|
|
524
|
-
},
|
|
525
|
-
body: result
|
|
566
|
+
headers,
|
|
567
|
+
body: result.entries
|
|
526
568
|
};
|
|
527
569
|
}
|
|
528
570
|
//# sourceMappingURL=blobStorageRoutes.js.map
|
|
@@ -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,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;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AAK,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/blobSt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,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,MAAM,OAAO,GAAwC;QACpD,CAAC,WAAW,CAAC,WAAW,CAAC,EACxB,OAAO,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI;KAC/F,CAAC;IAEF,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACnC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,gBAAgB,CACxD,MAAM,gBAAgB,CAAC,cAAc,CAAC,kBAAkB,CAAC,aAAa,CAAC,GAAG,CAAC,EAC3E,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,EACzB,MAAM,CACN,CAAC;IACH,CAAC;IAED,OAAO;QACN,OAAO;QACP,IAAI,EAAE,MAAM,CAAC,OAAO;KACpB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tHttpParameterHelper,\n\ttype IHostingComponent,\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 IBlobStorageEmptyRequest,\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 {\n\tHeaderHelper,\n\tHeaderTypes,\n\tHttpStatusCode,\n\tMimeTypeHelper,\n\tMimeTypes\n} 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.Context,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextCommon,\n\t\t\t\t\t\t\t\t\tSchemaOrgContexts.Context\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\tintegrity: \"sha256-xX2UsIj0xtLLMt7QFIExDHhqoAE0yO4i+EseJUVgKnA=\",\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.Context,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextCommon,\n\t\t\t\t\t\t\t\t\tSchemaOrgContexts.Context\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\tintegrity: \"sha256-xX2UsIj0xtLLMt7QFIExDHhqoAE0yO4i+EseJUVgKnA=\",\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 blobStorageEmptyRoute: IRestRoute<IBlobStorageEmptyRequest, INoContentResponse> = {\n\t\toperationId: `${camelTypeName}Empty`,\n\t\tsummary: `Remove all entries from ${lowerName}`,\n\t\ttag: options?.tagName ?? tagsBlobStorage[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tblobStorageEmpty(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IBlobStorageEmptyRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}EmptyRequestExample`,\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<INoContentResponse>()\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.Context,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.Context,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextCommon\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.Context,\n\t\t\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextCommon,\n\t\t\t\t\t\t\t\t\t\t\tSchemaOrgContexts.Context\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\tintegrity: \"sha256-xX2UsIj0xtLLMt7QFIExDHhqoAE0yO4i+EseJUVgKnA=\",\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.Context,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.Context,\n\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextCommon\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.Context,\n\t\t\t\t\t\t\t\t\t\t\tBlobStorageContexts.ContextCommon,\n\t\t\t\t\t\t\t\t\t\t\tSchemaOrgContexts.Context\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\tintegrity: \"sha256-xX2UsIj0xtLLMt7QFIExDHhqoAE0yO4i+EseJUVgKnA=\",\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\tblobStorageEmptyRoute,\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\t[HeaderTypes.Location]: 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 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]:\n\t\t\t\trequest.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd\n\t\t\t\t\t? MimeTypes.JsonLd\n\t\t\t\t\t: MimeTypes.Json\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 * Remove all 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 blobStorageEmpty(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IBlobStorageEmptyRequest\n): Promise<INoContentResponse> {\n\tconst component = ComponentFactory.get<IBlobStorageComponent>(componentName);\n\tawait component.empty();\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 hostingComponent = ComponentFactory.get<IHostingComponent>(\n\t\thttpRequestContext.hostingComponentType ?? \"hosting\"\n\t);\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\tconst headers: IBlobStorageListResponse[\"headers\"] = {\n\t\t[HeaderTypes.ContentType]:\n\t\t\trequest.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? MimeTypes.JsonLd : MimeTypes.Json\n\t};\n\n\tif (Is.stringValue(result.cursor)) {\n\t\theaders[HeaderTypes.Link] = HeaderHelper.createLinkHeader(\n\t\t\tawait hostingComponent.buildPublicUrl(httpRequestContext.serverRequest.url),\n\t\t\t{ cursor: result.cursor },\n\t\t\t\"next\"\n\t\t);\n\t}\n\n\treturn {\n\t\theaders,\n\t\tbody: result.entries\n\t};\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { BlobStorageConnectorFactory, BlobStorageContexts, BlobStorageTypes } from "@twin.org/blob-storage-models";
|
|
4
4
|
import { ContextIdHelper, ContextIdKeys, ContextIdStore } from "@twin.org/context";
|
|
5
5
|
import { Compression, Converter, GeneralError, Guards, Is, NotFoundError, Urn, Validation } from "@twin.org/core";
|
|
6
|
-
import {
|
|
6
|
+
import { IntegrityAlgorithm, IntegrityHelper } from "@twin.org/crypto";
|
|
7
7
|
import { JsonLdHelper, JsonLdProcessor } from "@twin.org/data-json-ld";
|
|
8
8
|
import { ComparisonOperator, EntitySchemaHelper, LogicalOperator, SortDirection } from "@twin.org/entity";
|
|
9
9
|
import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
|
|
@@ -106,7 +106,7 @@ export class BlobStorageService {
|
|
|
106
106
|
await JsonLdHelper.validate(metadata, validationFailures);
|
|
107
107
|
Validation.asValidationError(BlobStorageService.CLASS_NAME, "metadata", validationFailures);
|
|
108
108
|
}
|
|
109
|
-
const
|
|
109
|
+
const integrity = IntegrityHelper.generate(IntegrityAlgorithm.Sha256, storeBlob);
|
|
110
110
|
if (!Is.empty(options?.compress)) {
|
|
111
111
|
storeBlob = await Compression.compress(storeBlob, options.compress);
|
|
112
112
|
}
|
|
@@ -126,7 +126,7 @@ export class BlobStorageService {
|
|
|
126
126
|
id: blobId,
|
|
127
127
|
dateCreated: new Date(Date.now()).toISOString(),
|
|
128
128
|
blobSize,
|
|
129
|
-
|
|
129
|
+
integrity,
|
|
130
130
|
encodingFormat,
|
|
131
131
|
fileExtension,
|
|
132
132
|
metadata,
|
|
@@ -212,7 +212,7 @@ export class BlobStorageService {
|
|
|
212
212
|
dateCreated: blobEntry.dateCreated,
|
|
213
213
|
dateModified: new Date(Date.now()).toISOString(),
|
|
214
214
|
blobSize: blobEntry.blobSize,
|
|
215
|
-
|
|
215
|
+
integrity: blobEntry.integrity,
|
|
216
216
|
encodingFormat: encodingFormat ?? blobEntry.encodingFormat,
|
|
217
217
|
fileExtension: fileExtension ?? blobEntry.fileExtension,
|
|
218
218
|
metadata: metadata ?? blobEntry.metadata,
|
|
@@ -225,6 +225,32 @@ export class BlobStorageService {
|
|
|
225
225
|
throw new GeneralError(BlobStorageService.CLASS_NAME, "updateFailed", undefined, error);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Remove all blobs from the storage.
|
|
230
|
+
* @returns Nothing.
|
|
231
|
+
*/
|
|
232
|
+
async empty() {
|
|
233
|
+
try {
|
|
234
|
+
let moreData = true;
|
|
235
|
+
while (moreData) {
|
|
236
|
+
const result = await this._entryEntityStorage.query(undefined, undefined, undefined, undefined, 100);
|
|
237
|
+
if (result.entities.length === 0) {
|
|
238
|
+
moreData = false;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
for (const entity of result.entities) {
|
|
242
|
+
const entry = entity;
|
|
243
|
+
const blobStorageConnector = this.getConnector(entry.id);
|
|
244
|
+
await blobStorageConnector.remove(entry.id);
|
|
245
|
+
await this._entryEntityStorage.remove(entry.id);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
throw new GeneralError(BlobStorageService.CLASS_NAME, "emptyFailed", undefined, error);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
228
254
|
/**
|
|
229
255
|
* Remove the blob.
|
|
230
256
|
* @param id The id of the blob to remove in urn format.
|
|
@@ -264,9 +290,9 @@ export class BlobStorageService {
|
|
|
264
290
|
}
|
|
265
291
|
], undefined, cursor, limit);
|
|
266
292
|
let context = [
|
|
267
|
-
SchemaOrgContexts.
|
|
268
|
-
BlobStorageContexts.
|
|
269
|
-
BlobStorageContexts.
|
|
293
|
+
SchemaOrgContexts.Context,
|
|
294
|
+
BlobStorageContexts.Context,
|
|
295
|
+
BlobStorageContexts.ContextCommon
|
|
270
296
|
];
|
|
271
297
|
const entriesJsonLd = [];
|
|
272
298
|
for (const entry of result.entities) {
|
|
@@ -277,10 +303,12 @@ export class BlobStorageService {
|
|
|
277
303
|
const jsonLd = {
|
|
278
304
|
"@context": context,
|
|
279
305
|
type: SchemaOrgTypes.ItemList,
|
|
280
|
-
[SchemaOrgTypes.ItemListElement]: entriesJsonLd
|
|
281
|
-
|
|
306
|
+
[SchemaOrgTypes.ItemListElement]: entriesJsonLd
|
|
307
|
+
};
|
|
308
|
+
return {
|
|
309
|
+
entries: await JsonLdProcessor.compact(jsonLd, jsonLd["@context"]),
|
|
310
|
+
cursor: result.cursor
|
|
282
311
|
};
|
|
283
|
-
return JsonLdProcessor.compact(jsonLd, jsonLd["@context"]);
|
|
284
312
|
}
|
|
285
313
|
/**
|
|
286
314
|
* Get the connector from the uri.
|
|
@@ -335,17 +363,13 @@ export class BlobStorageService {
|
|
|
335
363
|
*/
|
|
336
364
|
entryToJsonLd(entry, blob) {
|
|
337
365
|
const jsonLd = {
|
|
338
|
-
"@context": JsonLdProcessor.combineContexts([
|
|
339
|
-
BlobStorageContexts.ContextRoot,
|
|
340
|
-
BlobStorageContexts.ContextRootCommon,
|
|
341
|
-
SchemaOrgContexts.ContextRoot
|
|
342
|
-
], entry?.metadata?.["@context"]),
|
|
366
|
+
"@context": JsonLdProcessor.combineContexts([BlobStorageContexts.Context, BlobStorageContexts.ContextCommon, SchemaOrgContexts.Context], entry?.metadata?.["@context"]),
|
|
343
367
|
id: entry.id,
|
|
344
368
|
type: BlobStorageTypes.Entry,
|
|
345
369
|
dateCreated: entry.dateCreated,
|
|
346
370
|
dateModified: entry.dateModified,
|
|
347
371
|
blobSize: entry.blobSize,
|
|
348
|
-
|
|
372
|
+
integrity: entry.integrity,
|
|
349
373
|
encodingFormat: entry?.encodingFormat,
|
|
350
374
|
fileExtension: entry?.fileExtension,
|
|
351
375
|
metadata: entry?.metadata,
|