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

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.
@@ -0,0 +1,528 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { HttpParameterHelper } from "@twin.org/api-models";
4
+ import { BlobStorageCompressionType, BlobStorageContexts, BlobStorageTypes } from "@twin.org/blob-storage-models";
5
+ import { Coerce, ComponentFactory, Converter, Guards, Is, StringHelper } from "@twin.org/core";
6
+ import { SchemaOrgContexts, SchemaOrgTypes } from "@twin.org/standards-schema-org";
7
+ import { HeaderTypes, HttpStatusCode, MimeTypeHelper, MimeTypes } from "@twin.org/web";
8
+ /**
9
+ * The source used when communicating about these routes.
10
+ */
11
+ const ROUTES_SOURCE = "blobStorageRoutes";
12
+ /**
13
+ * The tag to associate with the routes.
14
+ */
15
+ export const tagsBlobStorage = [
16
+ {
17
+ name: "Blob Storage",
18
+ description: "Endpoints which are modelled to access a blob storage contract."
19
+ }
20
+ ];
21
+ /**
22
+ * The REST routes for blob storage.
23
+ * @param baseRouteName Prefix to prepend to the paths.
24
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
25
+ * @param options Additional options for the routes.
26
+ * @param options.typeName Optional type name to use in the routes, defaults to Blob Storage.
27
+ * @param options.tagName Optional name to use in OpenAPI spec for tag.
28
+ * @returns The generated routes.
29
+ */
30
+ export function generateRestRoutesBlobStorage(baseRouteName, componentName, options) {
31
+ const typeName = options?.typeName ?? "Blob Storage";
32
+ const lowerName = typeName.toLowerCase();
33
+ const camelTypeName = StringHelper.camelCase(typeName);
34
+ const blobStorageCreateRoute = {
35
+ operationId: `${camelTypeName}Create`,
36
+ summary: `Create an entry in ${lowerName}`,
37
+ tag: options?.tagName ?? tagsBlobStorage[0].name,
38
+ method: "POST",
39
+ path: `${baseRouteName}/`,
40
+ handler: async (httpRequestContext, request) => blobStorageCreate(httpRequestContext, componentName, request),
41
+ requestType: {
42
+ type: "IBlobStorageCreateRequest",
43
+ examples: [
44
+ {
45
+ id: `${camelTypeName}CreateRequestExample`,
46
+ request: {
47
+ body: {
48
+ blob: "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==",
49
+ metadata: {
50
+ "@context": "https://schema.org",
51
+ "@type": "DigitalDocument",
52
+ name: "myfile.pdf"
53
+ }
54
+ }
55
+ }
56
+ }
57
+ ]
58
+ },
59
+ responseType: [
60
+ {
61
+ type: "ICreatedResponse",
62
+ examples: [
63
+ {
64
+ id: `${camelTypeName}CreateResponseExample`,
65
+ response: {
66
+ statusCode: HttpStatusCode.created,
67
+ headers: {
68
+ [HeaderTypes.Location]: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70"
69
+ }
70
+ }
71
+ }
72
+ ]
73
+ }
74
+ ]
75
+ };
76
+ const blobStorageGetRoute = {
77
+ operationId: `${camelTypeName}Get`,
78
+ summary: `Get the metadata for an item from ${lowerName}`,
79
+ tag: options?.tagName ?? tagsBlobStorage[0].name,
80
+ method: "GET",
81
+ path: `${baseRouteName}/:id`,
82
+ handler: async (httpRequestContext, request) => blobStorageGet(httpRequestContext, componentName, request),
83
+ requestType: {
84
+ type: "IBlobStorageGetRequest",
85
+ examples: [
86
+ {
87
+ id: `${camelTypeName}GetRequestExample`,
88
+ request: {
89
+ pathParams: {
90
+ id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70"
91
+ },
92
+ query: {
93
+ includeContent: "true"
94
+ }
95
+ }
96
+ }
97
+ ]
98
+ },
99
+ responseType: [
100
+ {
101
+ type: "IBlobStorageGetResponse",
102
+ examples: [
103
+ {
104
+ id: `${camelTypeName}GetResponseExample`,
105
+ response: {
106
+ body: {
107
+ "@context": [
108
+ BlobStorageContexts.ContextRoot,
109
+ BlobStorageContexts.ContextRootCommon,
110
+ SchemaOrgContexts.ContextRoot
111
+ ],
112
+ type: BlobStorageTypes.Entry,
113
+ id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
114
+ dateCreated: "2024-01-01T00:00:00Z",
115
+ encodingFormat: MimeTypes.Pdf,
116
+ blobSize: 42,
117
+ blobHash: "sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
118
+ fileExtension: "pdf",
119
+ metadata: {
120
+ "@context": "https://schema.org",
121
+ "@type": "DigitalDocument",
122
+ name: "myfile.pdf"
123
+ },
124
+ blob: "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=="
125
+ }
126
+ }
127
+ }
128
+ ]
129
+ },
130
+ {
131
+ type: "IBlobStorageGetResponse",
132
+ mimeType: MimeTypes.JsonLd,
133
+ examples: [
134
+ {
135
+ id: `${camelTypeName}GetResponseJsonLdExample`,
136
+ response: {
137
+ body: {
138
+ "@context": [
139
+ BlobStorageContexts.ContextRoot,
140
+ BlobStorageContexts.ContextRootCommon,
141
+ SchemaOrgContexts.ContextRoot
142
+ ],
143
+ type: BlobStorageTypes.Entry,
144
+ id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
145
+ dateCreated: "2024-01-01T00:00:00Z",
146
+ encodingFormat: MimeTypes.Pdf,
147
+ blobSize: 42,
148
+ blobHash: "sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
149
+ fileExtension: "pdf",
150
+ metadata: {
151
+ "@context": "https://schema.org",
152
+ "@type": "DigitalDocument",
153
+ name: "myfile.pdf"
154
+ },
155
+ blob: "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=="
156
+ }
157
+ }
158
+ }
159
+ ]
160
+ },
161
+ {
162
+ type: "INotFoundResponse"
163
+ }
164
+ ]
165
+ };
166
+ const blobStorageGetContentRoute = {
167
+ operationId: `${camelTypeName}GetContent`,
168
+ summary: `Get the content for an item in ${lowerName}`,
169
+ tag: options?.tagName ?? tagsBlobStorage[0].name,
170
+ method: "GET",
171
+ path: `${baseRouteName}/:id/content`,
172
+ handler: async (httpRequestContext, request) => blobStorageGetContent(httpRequestContext, componentName, request),
173
+ requestType: {
174
+ type: "IBlobStorageGetRequest",
175
+ examples: [
176
+ {
177
+ id: `${camelTypeName}GetContentRequestExample`,
178
+ request: {
179
+ pathParams: {
180
+ id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70"
181
+ },
182
+ query: {
183
+ download: "true",
184
+ filename: "my-file.pdf"
185
+ }
186
+ }
187
+ }
188
+ ]
189
+ },
190
+ responseType: [
191
+ {
192
+ type: "Uint8Array",
193
+ mimeType: MimeTypes.OctetStream,
194
+ examples: [
195
+ {
196
+ id: `${camelTypeName}GetContentResponseExample`,
197
+ 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 ${MimeTypes.OctetStream}.`,
198
+ response: {
199
+ body: new Uint8Array()
200
+ }
201
+ }
202
+ ]
203
+ },
204
+ {
205
+ type: "INotFoundResponse"
206
+ }
207
+ ]
208
+ };
209
+ const blobStorageUpdateRoute = {
210
+ operationId: `${camelTypeName}Update`,
211
+ summary: `Update the metadata for an item in ${lowerName}`,
212
+ tag: options?.tagName ?? tagsBlobStorage[0].name,
213
+ method: "PUT",
214
+ path: `${baseRouteName}/:id`,
215
+ handler: async (httpRequestContext, request) => blobStorageUpdate(httpRequestContext, componentName, request),
216
+ requestType: {
217
+ type: "IBlobStorageUpdateRequest",
218
+ examples: [
219
+ {
220
+ id: `${camelTypeName}UpdateRequestExample`,
221
+ request: {
222
+ pathParams: {
223
+ id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70"
224
+ },
225
+ body: {
226
+ metadata: {
227
+ "@context": "https://schema.org",
228
+ "@type": "DigitalDocument",
229
+ name: "myfile.pdf"
230
+ }
231
+ }
232
+ }
233
+ }
234
+ ]
235
+ },
236
+ responseType: [
237
+ {
238
+ type: "INoContentResponse"
239
+ }
240
+ ]
241
+ };
242
+ const blobStorageRemoveRoute = {
243
+ operationId: `${camelTypeName}Remove`,
244
+ summary: `Remove an item from ${lowerName}`,
245
+ tag: options?.tagName ?? tagsBlobStorage[0].name,
246
+ method: "DELETE",
247
+ path: `${baseRouteName}/:id`,
248
+ handler: async (httpRequestContext, request) => blobStorageRemove(httpRequestContext, componentName, request),
249
+ requestType: {
250
+ type: "IBlobStorageRemoveRequest",
251
+ examples: [
252
+ {
253
+ id: `${camelTypeName}RemoveRequestExample`,
254
+ request: {
255
+ pathParams: {
256
+ id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70"
257
+ }
258
+ }
259
+ }
260
+ ]
261
+ },
262
+ responseType: [
263
+ {
264
+ type: "INoContentResponse"
265
+ },
266
+ {
267
+ type: "INotFoundResponse"
268
+ }
269
+ ]
270
+ };
271
+ const blobStorageListRoute = {
272
+ operationId: `${camelTypeName}Query`,
273
+ summary: `Query the items from ${lowerName}`,
274
+ tag: options?.tagName ?? tagsBlobStorage[0].name,
275
+ method: "GET",
276
+ path: `${baseRouteName}/`,
277
+ handler: async (httpRequestContext, request) => blobStorageList(httpRequestContext, componentName, request),
278
+ requestType: {
279
+ type: "IBlobStorageListRequest",
280
+ examples: [
281
+ {
282
+ id: `${camelTypeName}ListRequestExample`,
283
+ request: {}
284
+ }
285
+ ]
286
+ },
287
+ responseType: [
288
+ {
289
+ type: "IBlobStorageListResponse",
290
+ examples: [
291
+ {
292
+ id: `${camelTypeName}ListResponseExample`,
293
+ response: {
294
+ body: {
295
+ "@context": [
296
+ SchemaOrgContexts.ContextRoot,
297
+ BlobStorageContexts.ContextRoot,
298
+ BlobStorageContexts.ContextRootCommon
299
+ ],
300
+ type: SchemaOrgTypes.ItemList,
301
+ [SchemaOrgTypes.ItemListElement]: [
302
+ {
303
+ "@context": [
304
+ BlobStorageContexts.ContextRoot,
305
+ BlobStorageContexts.ContextRootCommon,
306
+ SchemaOrgContexts.ContextRoot
307
+ ],
308
+ type: BlobStorageTypes.Entry,
309
+ id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
310
+ dateCreated: "2024-01-01T00:00:00Z",
311
+ encodingFormat: MimeTypes.Pdf,
312
+ blobSize: 42,
313
+ blobHash: "sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
314
+ fileExtension: "pdf",
315
+ metadata: {
316
+ "@context": "https://schema.org",
317
+ "@type": "DigitalDocument",
318
+ name: "myfile.pdf"
319
+ },
320
+ blob: "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=="
321
+ }
322
+ ]
323
+ }
324
+ }
325
+ }
326
+ ]
327
+ },
328
+ {
329
+ type: "IBlobStorageListResponse",
330
+ mimeType: MimeTypes.JsonLd,
331
+ examples: [
332
+ {
333
+ id: `${camelTypeName}ListResponseJsonLdExample`,
334
+ response: {
335
+ body: {
336
+ "@context": [
337
+ SchemaOrgContexts.ContextRoot,
338
+ BlobStorageContexts.ContextRoot,
339
+ BlobStorageContexts.ContextRootCommon
340
+ ],
341
+ type: SchemaOrgTypes.ItemList,
342
+ [SchemaOrgTypes.ItemListElement]: [
343
+ {
344
+ "@context": [
345
+ BlobStorageContexts.ContextRoot,
346
+ BlobStorageContexts.ContextRootCommon,
347
+ SchemaOrgContexts.ContextRoot
348
+ ],
349
+ type: BlobStorageTypes.Entry,
350
+ id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
351
+ dateCreated: "2024-01-01T00:00:00Z",
352
+ encodingFormat: MimeTypes.Pdf,
353
+ blobSize: 42,
354
+ blobHash: "sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
355
+ fileExtension: "pdf",
356
+ metadata: {
357
+ "@context": "https://schema.org",
358
+ "@type": "DigitalDocument",
359
+ name: "myfile.pdf"
360
+ },
361
+ blob: "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=="
362
+ }
363
+ ]
364
+ }
365
+ }
366
+ }
367
+ ]
368
+ },
369
+ {
370
+ type: "INotFoundResponse"
371
+ }
372
+ ]
373
+ };
374
+ return [
375
+ blobStorageCreateRoute,
376
+ blobStorageGetRoute,
377
+ blobStorageGetContentRoute,
378
+ blobStorageUpdateRoute,
379
+ blobStorageRemoveRoute,
380
+ blobStorageListRoute
381
+ ];
382
+ }
383
+ /**
384
+ * Create a blob in storage.
385
+ * @param httpRequestContext The request context for the API.
386
+ * @param componentName The name of the component to use in the routes.
387
+ * @param request The request.
388
+ * @returns The response object with additional http response properties.
389
+ */
390
+ export async function blobStorageCreate(httpRequestContext, componentName, request) {
391
+ Guards.object(ROUTES_SOURCE, "request", request);
392
+ Guards.object(ROUTES_SOURCE, "request.body", request.body);
393
+ Guards.stringBase64(ROUTES_SOURCE, "request.body.blob", request.body.blob);
394
+ const component = ComponentFactory.get(componentName);
395
+ const id = await component.create(request.body.blob, request.body.encodingFormat, request.body.fileExtension, request.body.metadata, {
396
+ disableEncryption: request.body.disableEncryption,
397
+ overrideVaultKeyId: request.body.overrideVaultKeyId,
398
+ namespace: request.body.namespace
399
+ });
400
+ return {
401
+ statusCode: HttpStatusCode.created,
402
+ headers: {
403
+ location: id
404
+ }
405
+ };
406
+ }
407
+ /**
408
+ * Get the blob from storage.
409
+ * @param httpRequestContext The request context for the API.
410
+ * @param componentName The name of the component to use in the routes.
411
+ * @param request The request.
412
+ * @returns The response object with additional http response properties.
413
+ */
414
+ export async function blobStorageGet(httpRequestContext, componentName, request) {
415
+ Guards.object(ROUTES_SOURCE, "request", request);
416
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
417
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
418
+ const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
419
+ const component = ComponentFactory.get(componentName);
420
+ const result = await component.get(request.pathParams.id, {
421
+ includeContent: Coerce.boolean(request.query?.includeContent),
422
+ decompress: Coerce.boolean(request.query?.decompress),
423
+ overrideVaultKeyId: request.query?.overrideVaultKeyId
424
+ });
425
+ return {
426
+ headers: {
427
+ [HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
428
+ },
429
+ body: result
430
+ };
431
+ }
432
+ /**
433
+ * Get the blob from storage.
434
+ * @param httpRequestContext The request context for the API.
435
+ * @param componentName The name of the component to use in the routes.
436
+ * @param request The request.
437
+ * @returns The response object with additional http response properties.
438
+ */
439
+ export async function blobStorageGetContent(httpRequestContext, componentName, request) {
440
+ Guards.object(ROUTES_SOURCE, "request", request);
441
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
442
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
443
+ const component = ComponentFactory.get(componentName);
444
+ const decompress = Coerce.boolean(request.query?.decompress);
445
+ const download = Coerce.boolean(request.query?.download) ?? false;
446
+ const result = await component.get(request.pathParams.id, {
447
+ includeContent: true,
448
+ decompress,
449
+ overrideVaultKeyId: request.query?.overrideVaultKeyId
450
+ });
451
+ const encodingFormat = result?.encodingFormat ?? MimeTypes.OctetStream;
452
+ let compressedEncodingFormat;
453
+ let compressedExtension = "";
454
+ // If the entry is compressed and we are not decompressing
455
+ // we need to override the encoding format to the compressed type
456
+ // and append an additional extension to the filename.
457
+ if (result.compression && !decompress) {
458
+ compressedEncodingFormat =
459
+ result.compression === BlobStorageCompressionType.Gzip ? MimeTypes.Gzip : MimeTypes.Zlib;
460
+ compressedExtension = `.${MimeTypeHelper.defaultExtension(compressedEncodingFormat)}`;
461
+ }
462
+ let filename = request.query?.filename;
463
+ if (!Is.stringValue(filename)) {
464
+ filename = `file.${result.fileExtension ?? MimeTypeHelper.defaultExtension(encodingFormat)}${compressedExtension}`;
465
+ }
466
+ return {
467
+ body: Is.stringBase64(result.blob) ? Converter.base64ToBytes(result.blob) : new Uint8Array(),
468
+ attachment: {
469
+ mimeType: compressedEncodingFormat ?? encodingFormat,
470
+ filename,
471
+ inline: !download
472
+ }
473
+ };
474
+ }
475
+ /**
476
+ * Update the blob storage metadata.
477
+ * @param httpRequestContext The request context for the API.
478
+ * @param componentName The name of the component to use in the routes.
479
+ * @param request The request.
480
+ * @returns The response object with additional http response properties.
481
+ */
482
+ export async function blobStorageUpdate(httpRequestContext, componentName, request) {
483
+ Guards.object(ROUTES_SOURCE, "request", request);
484
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
485
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
486
+ const component = ComponentFactory.get(componentName);
487
+ await component.update(request.pathParams.id, request.body.encodingFormat, request.body.fileExtension, request.body.metadata);
488
+ return {
489
+ statusCode: HttpStatusCode.noContent
490
+ };
491
+ }
492
+ /**
493
+ * Remove the blob from storage.
494
+ * @param httpRequestContext The request context for the API.
495
+ * @param componentName The name of the component to use in the routes.
496
+ * @param request The request.
497
+ * @returns The response object with additional http response properties.
498
+ */
499
+ export async function blobStorageRemove(httpRequestContext, componentName, request) {
500
+ Guards.object(ROUTES_SOURCE, "request", request);
501
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
502
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
503
+ const component = ComponentFactory.get(componentName);
504
+ await component.remove(request.pathParams.id);
505
+ return {
506
+ statusCode: HttpStatusCode.noContent
507
+ };
508
+ }
509
+ /**
510
+ * List the entries from blob storage.
511
+ * @param httpRequestContext The request context for the API.
512
+ * @param componentName The name of the component to use in the routes.
513
+ * @param request The request.
514
+ * @returns The response object with additional http response properties.
515
+ */
516
+ export async function blobStorageList(httpRequestContext, componentName, request) {
517
+ Guards.object(ROUTES_SOURCE, "request", request);
518
+ const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
519
+ const component = ComponentFactory.get(componentName);
520
+ const result = await component.query(HttpParameterHelper.objectFromString(request.query?.conditions), request.query?.orderBy, request.query?.orderByDirection, request.query?.cursor, Coerce.number(request.query?.limit));
521
+ return {
522
+ headers: {
523
+ [HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
524
+ },
525
+ body: result
526
+ };
527
+ }
528
+ //# sourceMappingURL=blobStorageRoutes.js.map
@@ -0,0 +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;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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AAW,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"]}