@twin.org/blob-storage-service 0.0.1-next.21 → 0.0.1-next.23
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/dist/cjs/index.cjs +82 -43
- package/dist/esm/index.mjs +82 -43
- package/dist/types/blobStorageRoutes.d.ts +1 -1
- package/dist/types/blobStorageService.d.ts +7 -7
- package/dist/types/entities/blobStorageEntry.d.ts +6 -2
- package/dist/types/models/IBlobStorageServiceConstructorOptions.d.ts +1 -1
- package/docs/changelog.md +1 -1
- package/docs/open-api/spec.json +151 -121
- package/docs/reference/classes/BlobStorageEntry.md +11 -3
- package/docs/reference/classes/BlobStorageService.md +9 -9
- package/docs/reference/functions/blobStorageUpdate.md +1 -1
- package/docs/reference/interfaces/IBlobStorageServiceConstructorOptions.md +1 -1
- package/package.json +3 -2
package/dist/esm/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { BlobStorageTypes, BlobStorageConnectorFactory } from '@twin.org/blob-st
|
|
|
3
3
|
import { StringHelper, Guards, ComponentFactory, Is, Converter, Coerce, GeneralError, Validation, ObjectHelper, Urn, NotFoundError } from '@twin.org/core';
|
|
4
4
|
import { SchemaOrgTypes, SchemaOrgDataTypes } from '@twin.org/standards-schema-org';
|
|
5
5
|
import { HttpStatusCode, HeaderTypes, MimeTypes, MimeTypeHelper } from '@twin.org/web';
|
|
6
|
+
import { Sha256 } from '@twin.org/crypto';
|
|
6
7
|
import { JsonLdHelper, JsonLdProcessor } from '@twin.org/data-json-ld';
|
|
7
8
|
import { ComparisonOperator, LogicalOperator, SortDirection, EntitySchemaHelper, property, entity, EntitySchemaFactory } from '@twin.org/entity';
|
|
8
9
|
import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
|
|
@@ -51,7 +52,7 @@ function generateRestRoutesBlobStorage(baseRouteName, componentName, options) {
|
|
|
51
52
|
request: {
|
|
52
53
|
body: {
|
|
53
54
|
blob: "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==",
|
|
54
|
-
|
|
55
|
+
annotationObject: {
|
|
55
56
|
"@context": "https://schema.org",
|
|
56
57
|
"@type": "DigitalDocument",
|
|
57
58
|
name: "myfile.pdf"
|
|
@@ -80,7 +81,7 @@ function generateRestRoutesBlobStorage(baseRouteName, componentName, options) {
|
|
|
80
81
|
};
|
|
81
82
|
const blobStorageGetRoute = {
|
|
82
83
|
operationId: `${camelTypeName}Get`,
|
|
83
|
-
summary: `Get the
|
|
84
|
+
summary: `Get the annotation for an item from ${lowerName}`,
|
|
84
85
|
tag: options?.tagName ?? tagsBlobStorage[0].name,
|
|
85
86
|
method: "GET",
|
|
86
87
|
path: `${baseRouteName}/:id`,
|
|
@@ -109,14 +110,19 @@ function generateRestRoutesBlobStorage(baseRouteName, componentName, options) {
|
|
|
109
110
|
id: `${camelTypeName}GetResponseExample`,
|
|
110
111
|
response: {
|
|
111
112
|
body: {
|
|
112
|
-
"@context": [
|
|
113
|
+
"@context": [
|
|
114
|
+
BlobStorageTypes.ContextRoot,
|
|
115
|
+
BlobStorageTypes.ContextRootCommon,
|
|
116
|
+
SchemaOrgTypes.ContextRoot
|
|
117
|
+
],
|
|
113
118
|
type: BlobStorageTypes.Entry,
|
|
114
119
|
id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
115
120
|
dateCreated: "2024-01-01T00:00:00Z",
|
|
116
121
|
encodingFormat: MimeTypes.Pdf,
|
|
117
122
|
blobSize: 42,
|
|
123
|
+
blobHash: "sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
118
124
|
fileExtension: "pdf",
|
|
119
|
-
|
|
125
|
+
annotationObject: {
|
|
120
126
|
"@context": "https://schema.org",
|
|
121
127
|
"@type": "DigitalDocument",
|
|
122
128
|
name: "myfile.pdf"
|
|
@@ -135,14 +141,19 @@ function generateRestRoutesBlobStorage(baseRouteName, componentName, options) {
|
|
|
135
141
|
id: `${camelTypeName}GetResponseJsonLdExample`,
|
|
136
142
|
response: {
|
|
137
143
|
body: {
|
|
138
|
-
"@context": [
|
|
144
|
+
"@context": [
|
|
145
|
+
BlobStorageTypes.ContextRoot,
|
|
146
|
+
BlobStorageTypes.ContextRootCommon,
|
|
147
|
+
SchemaOrgTypes.ContextRoot
|
|
148
|
+
],
|
|
139
149
|
type: BlobStorageTypes.Entry,
|
|
140
150
|
id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
141
151
|
dateCreated: "2024-01-01T00:00:00Z",
|
|
142
152
|
encodingFormat: MimeTypes.Pdf,
|
|
143
153
|
blobSize: 42,
|
|
154
|
+
blobHash: "sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
144
155
|
fileExtension: "pdf",
|
|
145
|
-
|
|
156
|
+
annotationObject: {
|
|
146
157
|
"@context": "https://schema.org",
|
|
147
158
|
"@type": "DigitalDocument",
|
|
148
159
|
name: "myfile.pdf"
|
|
@@ -203,7 +214,7 @@ function generateRestRoutesBlobStorage(baseRouteName, componentName, options) {
|
|
|
203
214
|
};
|
|
204
215
|
const blobStorageUpdateRoute = {
|
|
205
216
|
operationId: `${camelTypeName}Update`,
|
|
206
|
-
summary: `Update the
|
|
217
|
+
summary: `Update the annotation for an item in ${lowerName}`,
|
|
207
218
|
tag: options?.tagName ?? tagsBlobStorage[0].name,
|
|
208
219
|
method: "PUT",
|
|
209
220
|
path: `${baseRouteName}/:id`,
|
|
@@ -218,7 +229,7 @@ function generateRestRoutesBlobStorage(baseRouteName, componentName, options) {
|
|
|
218
229
|
id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70"
|
|
219
230
|
},
|
|
220
231
|
body: {
|
|
221
|
-
|
|
232
|
+
annotationObject: {
|
|
222
233
|
"@context": "https://schema.org",
|
|
223
234
|
"@type": "DigitalDocument",
|
|
224
235
|
name: "myfile.pdf"
|
|
@@ -287,18 +298,23 @@ function generateRestRoutesBlobStorage(baseRouteName, componentName, options) {
|
|
|
287
298
|
id: `${camelTypeName}ListResponseExample`,
|
|
288
299
|
response: {
|
|
289
300
|
body: {
|
|
290
|
-
"@context": [BlobStorageTypes.ContextRoot],
|
|
301
|
+
"@context": [BlobStorageTypes.ContextRoot, BlobStorageTypes.ContextRootCommon],
|
|
291
302
|
type: BlobStorageTypes.EntryList,
|
|
292
303
|
entries: [
|
|
293
304
|
{
|
|
294
|
-
"@context": [
|
|
305
|
+
"@context": [
|
|
306
|
+
BlobStorageTypes.ContextRoot,
|
|
307
|
+
BlobStorageTypes.ContextRootCommon,
|
|
308
|
+
SchemaOrgTypes.ContextRoot
|
|
309
|
+
],
|
|
295
310
|
type: BlobStorageTypes.Entry,
|
|
296
311
|
id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
297
312
|
dateCreated: "2024-01-01T00:00:00Z",
|
|
298
313
|
encodingFormat: MimeTypes.Pdf,
|
|
299
314
|
blobSize: 42,
|
|
315
|
+
blobHash: "sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
300
316
|
fileExtension: "pdf",
|
|
301
|
-
|
|
317
|
+
annotationObject: {
|
|
302
318
|
"@context": "https://schema.org",
|
|
303
319
|
"@type": "DigitalDocument",
|
|
304
320
|
name: "myfile.pdf"
|
|
@@ -319,18 +335,23 @@ function generateRestRoutesBlobStorage(baseRouteName, componentName, options) {
|
|
|
319
335
|
id: `${camelTypeName}ListResponseJsonLdExample`,
|
|
320
336
|
response: {
|
|
321
337
|
body: {
|
|
322
|
-
"@context": [BlobStorageTypes.ContextRoot],
|
|
338
|
+
"@context": [BlobStorageTypes.ContextRoot, BlobStorageTypes.ContextRootCommon],
|
|
323
339
|
type: BlobStorageTypes.EntryList,
|
|
324
340
|
entries: [
|
|
325
341
|
{
|
|
326
|
-
"@context": [
|
|
342
|
+
"@context": [
|
|
343
|
+
BlobStorageTypes.ContextRoot,
|
|
344
|
+
BlobStorageTypes.ContextRootCommon,
|
|
345
|
+
SchemaOrgTypes.ContextRoot
|
|
346
|
+
],
|
|
327
347
|
type: BlobStorageTypes.Entry,
|
|
328
348
|
id: "blob-memory:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
329
349
|
dateCreated: "2024-01-01T00:00:00Z",
|
|
330
350
|
encodingFormat: MimeTypes.Pdf,
|
|
331
351
|
blobSize: 42,
|
|
352
|
+
blobHash: "sha256:c57d94b088f4c6d2cb32ded014813d0c786aa00134c8ee22f84b1e2545602a70",
|
|
332
353
|
fileExtension: "pdf",
|
|
333
|
-
|
|
354
|
+
annotationObject: {
|
|
334
355
|
"@context": "https://schema.org",
|
|
335
356
|
"@type": "DigitalDocument",
|
|
336
357
|
name: "myfile.pdf"
|
|
@@ -369,7 +390,7 @@ async function blobStorageCreate(httpRequestContext, componentName, request) {
|
|
|
369
390
|
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
370
391
|
Guards.stringBase64(ROUTES_SOURCE, "request.body.blob", request.body.blob);
|
|
371
392
|
const component = ComponentFactory.get(componentName);
|
|
372
|
-
const id = await component.create(request.body.blob, request.body.encodingFormat, request.body.fileExtension, request.body.
|
|
393
|
+
const id = await component.create(request.body.blob, request.body.encodingFormat, request.body.fileExtension, request.body.annotationObject, request.body.namespace, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
|
|
373
394
|
return {
|
|
374
395
|
statusCode: HttpStatusCode.created,
|
|
375
396
|
headers: {
|
|
@@ -426,7 +447,7 @@ async function blobStorageGetContent(httpRequestContext, componentName, request)
|
|
|
426
447
|
};
|
|
427
448
|
}
|
|
428
449
|
/**
|
|
429
|
-
* Update the blob storage
|
|
450
|
+
* Update the blob storage annotation.
|
|
430
451
|
* @param httpRequestContext The request context for the API.
|
|
431
452
|
* @param componentName The name of the component to use in the routes.
|
|
432
453
|
* @param request The request.
|
|
@@ -437,7 +458,7 @@ async function blobStorageUpdate(httpRequestContext, componentName, request) {
|
|
|
437
458
|
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
438
459
|
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
439
460
|
const component = ComponentFactory.get(componentName);
|
|
440
|
-
await component.update(request.pathParams.id, request.body.encodingFormat, request.body.fileExtension, request.body.
|
|
461
|
+
await component.update(request.pathParams.id, request.body.encodingFormat, request.body.fileExtension, request.body.annotationObject, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
|
|
441
462
|
return {
|
|
442
463
|
statusCode: HttpStatusCode.noContent
|
|
443
464
|
};
|
|
@@ -500,7 +521,7 @@ class BlobStorageService {
|
|
|
500
521
|
*/
|
|
501
522
|
_defaultNamespace;
|
|
502
523
|
/**
|
|
503
|
-
* The storage connector for the
|
|
524
|
+
* The storage connector for the annotation.
|
|
504
525
|
* @internal
|
|
505
526
|
*/
|
|
506
527
|
_entryEntityStorage;
|
|
@@ -544,17 +565,17 @@ class BlobStorageService {
|
|
|
544
565
|
SchemaOrgDataTypes.registerRedirects();
|
|
545
566
|
}
|
|
546
567
|
/**
|
|
547
|
-
* Create the blob with some
|
|
568
|
+
* Create the blob with some annotation.
|
|
548
569
|
* @param blob The data for the blob in base64 format.
|
|
549
570
|
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
550
571
|
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
551
|
-
* @param
|
|
572
|
+
* @param annotationObject Data for the custom annotation as JSON-LD.
|
|
552
573
|
* @param namespace The namespace to use for storing, defaults to component configured namespace.
|
|
553
574
|
* @param userIdentity The user identity to use with storage operations.
|
|
554
575
|
* @param nodeIdentity The node identity to use with storage operations.
|
|
555
576
|
* @returns The id of the stored blob in urn format.
|
|
556
577
|
*/
|
|
557
|
-
async create(blob, encodingFormat, fileExtension,
|
|
578
|
+
async create(blob, encodingFormat, fileExtension, annotationObject, namespace, userIdentity, nodeIdentity) {
|
|
558
579
|
Guards.stringBase64(this.CLASS_NAME, "blob", blob);
|
|
559
580
|
if (this._includeUserIdentity) {
|
|
560
581
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
@@ -577,11 +598,12 @@ class BlobStorageService {
|
|
|
577
598
|
if (!Is.stringValue(fileExtension) && Is.stringValue(encodingFormat)) {
|
|
578
599
|
fileExtension = await MimeTypeHelper.defaultExtension(encodingFormat);
|
|
579
600
|
}
|
|
580
|
-
if (Is.object(
|
|
601
|
+
if (Is.object(annotationObject)) {
|
|
581
602
|
const validationFailures = [];
|
|
582
|
-
JsonLdHelper.validate(
|
|
583
|
-
Validation.asValidationError(this.CLASS_NAME, "
|
|
603
|
+
JsonLdHelper.validate(annotationObject, validationFailures);
|
|
604
|
+
Validation.asValidationError(this.CLASS_NAME, "annotationObject", validationFailures);
|
|
584
605
|
}
|
|
606
|
+
const blobHash = `sha256:${Converter.bytesToBase64(Sha256.sum256(storeBlob))}`;
|
|
585
607
|
// If we have a vault connector then encrypt the data.
|
|
586
608
|
if (this._vaultConnector) {
|
|
587
609
|
storeBlob = await this._vaultConnector.encrypt(`${nodeIdentity}/${this._vaultKeyId}`, VaultEncryptionType.ChaCha20Poly1305, storeBlob);
|
|
@@ -593,9 +615,10 @@ class BlobStorageService {
|
|
|
593
615
|
id: blobId,
|
|
594
616
|
dateCreated: new Date(Date.now()).toISOString(),
|
|
595
617
|
blobSize,
|
|
618
|
+
blobHash,
|
|
596
619
|
encodingFormat,
|
|
597
620
|
fileExtension,
|
|
598
|
-
|
|
621
|
+
annotationObject
|
|
599
622
|
};
|
|
600
623
|
const conditions = [];
|
|
601
624
|
if (this._includeUserIdentity) {
|
|
@@ -616,7 +639,7 @@ class BlobStorageService {
|
|
|
616
639
|
/**
|
|
617
640
|
* Get the blob entry.
|
|
618
641
|
* @param id The id of the blob to get in urn format.
|
|
619
|
-
* @param includeContent Include the content, or just get the
|
|
642
|
+
* @param includeContent Include the content, or just get the annotation.
|
|
620
643
|
* @param userIdentity The user identity to use with storage operations.
|
|
621
644
|
* @param nodeIdentity The node identity to use with storage operations.
|
|
622
645
|
* @returns The entry and data for the blob if it can be found.
|
|
@@ -656,25 +679,24 @@ class BlobStorageService {
|
|
|
656
679
|
}
|
|
657
680
|
}
|
|
658
681
|
const jsonLd = this.entryToJsonLd(blobEntry, returnBlob);
|
|
659
|
-
|
|
660
|
-
return compacted;
|
|
682
|
+
return JsonLdProcessor.compact(jsonLd);
|
|
661
683
|
}
|
|
662
684
|
catch (error) {
|
|
663
685
|
throw new GeneralError(this.CLASS_NAME, "getFailed", undefined, error);
|
|
664
686
|
}
|
|
665
687
|
}
|
|
666
688
|
/**
|
|
667
|
-
* Update the blob with
|
|
689
|
+
* Update the blob with annotation.
|
|
668
690
|
* @param id The id of the blob entry to update.
|
|
669
691
|
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
670
692
|
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
671
|
-
* @param
|
|
693
|
+
* @param annotationObject Data for the custom annotation as JSON-LD.
|
|
672
694
|
* @param userIdentity The user identity to use with storage operations.
|
|
673
695
|
* @param nodeIdentity The node identity to use with storage operations.
|
|
674
696
|
* @returns Nothing.
|
|
675
697
|
* @throws Not found error if the blob cannot be found.
|
|
676
698
|
*/
|
|
677
|
-
async update(id, encodingFormat, fileExtension,
|
|
699
|
+
async update(id, encodingFormat, fileExtension, annotationObject, userIdentity, nodeIdentity) {
|
|
678
700
|
Urn.guard(this.CLASS_NAME, "id", id);
|
|
679
701
|
if (this._includeUserIdentity) {
|
|
680
702
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
@@ -687,10 +709,10 @@ class BlobStorageService {
|
|
|
687
709
|
if (Is.undefined(blobEntry)) {
|
|
688
710
|
throw new NotFoundError(this.CLASS_NAME, "blobNotFound", id);
|
|
689
711
|
}
|
|
690
|
-
if (Is.object(
|
|
712
|
+
if (Is.object(annotationObject)) {
|
|
691
713
|
const validationFailures = [];
|
|
692
|
-
await JsonLdHelper.validate(
|
|
693
|
-
Validation.asValidationError(this.CLASS_NAME, "
|
|
714
|
+
await JsonLdHelper.validate(annotationObject, validationFailures);
|
|
715
|
+
Validation.asValidationError(this.CLASS_NAME, "annotationObject", validationFailures);
|
|
694
716
|
}
|
|
695
717
|
// Now store the entry in entity storage
|
|
696
718
|
const updatedBlobEntry = {
|
|
@@ -698,9 +720,10 @@ class BlobStorageService {
|
|
|
698
720
|
dateCreated: blobEntry.dateCreated,
|
|
699
721
|
dateModified: new Date(Date.now()).toISOString(),
|
|
700
722
|
blobSize: blobEntry.blobSize,
|
|
723
|
+
blobHash: blobEntry.blobHash,
|
|
701
724
|
encodingFormat: encodingFormat ?? blobEntry.encodingFormat,
|
|
702
725
|
fileExtension: fileExtension ?? blobEntry.fileExtension,
|
|
703
|
-
|
|
726
|
+
annotationObject: annotationObject ?? blobEntry.annotationObject
|
|
704
727
|
};
|
|
705
728
|
const conditions = [];
|
|
706
729
|
if (this._includeUserIdentity) {
|
|
@@ -800,14 +823,17 @@ class BlobStorageService {
|
|
|
800
823
|
ObjectHelper.propertyDelete(entity, "userIdentity");
|
|
801
824
|
}
|
|
802
825
|
const jsonLd = {
|
|
803
|
-
"@context": [
|
|
826
|
+
"@context": [
|
|
827
|
+
BlobStorageTypes.ContextRoot,
|
|
828
|
+
BlobStorageTypes.ContextRootCommon,
|
|
829
|
+
SchemaOrgTypes.ContextRoot
|
|
830
|
+
],
|
|
804
831
|
type: BlobStorageTypes.EntryList,
|
|
805
832
|
// The entries are never Partial as we don't allow custom property requests.
|
|
806
833
|
entries: result.entities.map(entry => this.entryToJsonLd(entry)),
|
|
807
834
|
cursor: result.cursor
|
|
808
835
|
};
|
|
809
|
-
|
|
810
|
-
return compacted;
|
|
836
|
+
return JsonLdProcessor.compact(jsonLd);
|
|
811
837
|
}
|
|
812
838
|
/**
|
|
813
839
|
* Get the connector from the uri.
|
|
@@ -886,15 +912,20 @@ class BlobStorageService {
|
|
|
886
912
|
*/
|
|
887
913
|
entryToJsonLd(entry, blob) {
|
|
888
914
|
return {
|
|
889
|
-
"@context": [
|
|
915
|
+
"@context": [
|
|
916
|
+
BlobStorageTypes.ContextRoot,
|
|
917
|
+
BlobStorageTypes.ContextRootCommon,
|
|
918
|
+
SchemaOrgTypes.ContextRoot
|
|
919
|
+
],
|
|
890
920
|
id: entry.id,
|
|
891
921
|
type: BlobStorageTypes.Entry,
|
|
892
922
|
dateCreated: entry.dateCreated,
|
|
893
923
|
dateModified: entry.dateModified,
|
|
894
924
|
blobSize: entry.blobSize,
|
|
925
|
+
blobHash: entry.blobHash,
|
|
895
926
|
encodingFormat: entry?.encodingFormat,
|
|
896
927
|
fileExtension: entry?.fileExtension,
|
|
897
|
-
|
|
928
|
+
annotationObject: entry?.annotationObject,
|
|
898
929
|
blob: Is.uint8Array(blob) ? Converter.bytesToBase64(blob) : undefined
|
|
899
930
|
};
|
|
900
931
|
}
|
|
@@ -920,6 +951,10 @@ let BlobStorageEntry = class BlobStorageEntry {
|
|
|
920
951
|
* The length of the data in the blob.
|
|
921
952
|
*/
|
|
922
953
|
blobSize;
|
|
954
|
+
/**
|
|
955
|
+
* The hash of the data in the blob.
|
|
956
|
+
*/
|
|
957
|
+
blobHash;
|
|
923
958
|
/**
|
|
924
959
|
* The mime type for the blob.
|
|
925
960
|
*/
|
|
@@ -929,9 +964,9 @@ let BlobStorageEntry = class BlobStorageEntry {
|
|
|
929
964
|
*/
|
|
930
965
|
fileExtension;
|
|
931
966
|
/**
|
|
932
|
-
* The
|
|
967
|
+
* The annotation object for the blob as JSON-LD.
|
|
933
968
|
*/
|
|
934
|
-
|
|
969
|
+
annotationObject;
|
|
935
970
|
/**
|
|
936
971
|
* The user identity that created the blob.
|
|
937
972
|
*/
|
|
@@ -957,6 +992,10 @@ __decorate([
|
|
|
957
992
|
property({ type: "number" }),
|
|
958
993
|
__metadata("design:type", Number)
|
|
959
994
|
], BlobStorageEntry.prototype, "blobSize", void 0);
|
|
995
|
+
__decorate([
|
|
996
|
+
property({ type: "string" }),
|
|
997
|
+
__metadata("design:type", String)
|
|
998
|
+
], BlobStorageEntry.prototype, "blobHash", void 0);
|
|
960
999
|
__decorate([
|
|
961
1000
|
property({ type: "string" }),
|
|
962
1001
|
__metadata("design:type", String)
|
|
@@ -968,7 +1007,7 @@ __decorate([
|
|
|
968
1007
|
__decorate([
|
|
969
1008
|
property({ type: "object", itemTypeRef: "IJsonLdNodeObject" }),
|
|
970
1009
|
__metadata("design:type", Object)
|
|
971
|
-
], BlobStorageEntry.prototype, "
|
|
1010
|
+
], BlobStorageEntry.prototype, "annotationObject", void 0);
|
|
972
1011
|
__decorate([
|
|
973
1012
|
property({ type: "string" }),
|
|
974
1013
|
__metadata("design:type", String)
|
|
@@ -42,7 +42,7 @@ export declare function blobStorageGet(httpRequestContext: IHttpRequestContext,
|
|
|
42
42
|
*/
|
|
43
43
|
export declare function blobStorageGetContent(httpRequestContext: IHttpRequestContext, componentName: string, request: IBlobStorageGetContentRequest): Promise<IBlobStorageGetContentResponse & IRestRouteResponseOptions>;
|
|
44
44
|
/**
|
|
45
|
-
* Update the blob storage
|
|
45
|
+
* Update the blob storage annotation.
|
|
46
46
|
* @param httpRequestContext The request context for the API.
|
|
47
47
|
* @param componentName The name of the component to use in the routes.
|
|
48
48
|
* @param request The request.
|
|
@@ -20,21 +20,21 @@ export declare class BlobStorageService implements IBlobStorageComponent {
|
|
|
20
20
|
*/
|
|
21
21
|
constructor(options?: IBlobStorageServiceConstructorOptions);
|
|
22
22
|
/**
|
|
23
|
-
* Create the blob with some
|
|
23
|
+
* Create the blob with some annotation.
|
|
24
24
|
* @param blob The data for the blob in base64 format.
|
|
25
25
|
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
26
26
|
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
27
|
-
* @param
|
|
27
|
+
* @param annotationObject Data for the custom annotation as JSON-LD.
|
|
28
28
|
* @param namespace The namespace to use for storing, defaults to component configured namespace.
|
|
29
29
|
* @param userIdentity The user identity to use with storage operations.
|
|
30
30
|
* @param nodeIdentity The node identity to use with storage operations.
|
|
31
31
|
* @returns The id of the stored blob in urn format.
|
|
32
32
|
*/
|
|
33
|
-
create(blob: string, encodingFormat?: string, fileExtension?: string,
|
|
33
|
+
create(blob: string, encodingFormat?: string, fileExtension?: string, annotationObject?: IJsonLdNodeObject, namespace?: string, userIdentity?: string, nodeIdentity?: string): Promise<string>;
|
|
34
34
|
/**
|
|
35
35
|
* Get the blob entry.
|
|
36
36
|
* @param id The id of the blob to get in urn format.
|
|
37
|
-
* @param includeContent Include the content, or just get the
|
|
37
|
+
* @param includeContent Include the content, or just get the annotation.
|
|
38
38
|
* @param userIdentity The user identity to use with storage operations.
|
|
39
39
|
* @param nodeIdentity The node identity to use with storage operations.
|
|
40
40
|
* @returns The entry and data for the blob if it can be found.
|
|
@@ -42,17 +42,17 @@ export declare class BlobStorageService implements IBlobStorageComponent {
|
|
|
42
42
|
*/
|
|
43
43
|
get(id: string, includeContent: boolean, userIdentity?: string, nodeIdentity?: string): Promise<IBlobStorageEntry>;
|
|
44
44
|
/**
|
|
45
|
-
* Update the blob with
|
|
45
|
+
* Update the blob with annotation.
|
|
46
46
|
* @param id The id of the blob entry to update.
|
|
47
47
|
* @param encodingFormat Mime type for the blob, will be detected if left undefined.
|
|
48
48
|
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
49
|
-
* @param
|
|
49
|
+
* @param annotationObject Data for the custom annotation as JSON-LD.
|
|
50
50
|
* @param userIdentity The user identity to use with storage operations.
|
|
51
51
|
* @param nodeIdentity The node identity to use with storage operations.
|
|
52
52
|
* @returns Nothing.
|
|
53
53
|
* @throws Not found error if the blob cannot be found.
|
|
54
54
|
*/
|
|
55
|
-
update(id: string, encodingFormat?: string, fileExtension?: string,
|
|
55
|
+
update(id: string, encodingFormat?: string, fileExtension?: string, annotationObject?: IJsonLdNodeObject, userIdentity?: string, nodeIdentity?: string): Promise<void>;
|
|
56
56
|
/**
|
|
57
57
|
* Remove the blob.
|
|
58
58
|
* @param id The id of the blob to remove in urn format.
|
|
@@ -19,6 +19,10 @@ export declare class BlobStorageEntry {
|
|
|
19
19
|
* The length of the data in the blob.
|
|
20
20
|
*/
|
|
21
21
|
blobSize: number;
|
|
22
|
+
/**
|
|
23
|
+
* The hash of the data in the blob.
|
|
24
|
+
*/
|
|
25
|
+
blobHash: string;
|
|
22
26
|
/**
|
|
23
27
|
* The mime type for the blob.
|
|
24
28
|
*/
|
|
@@ -28,9 +32,9 @@ export declare class BlobStorageEntry {
|
|
|
28
32
|
*/
|
|
29
33
|
fileExtension?: string;
|
|
30
34
|
/**
|
|
31
|
-
* The
|
|
35
|
+
* The annotation object for the blob as JSON-LD.
|
|
32
36
|
*/
|
|
33
|
-
|
|
37
|
+
annotationObject?: IJsonLdNodeObject;
|
|
34
38
|
/**
|
|
35
39
|
* The user identity that created the blob.
|
|
36
40
|
*/
|
|
@@ -4,7 +4,7 @@ import type { IBlobStorageServiceConfig } from "./IBlobStorageServiceConfig";
|
|
|
4
4
|
*/
|
|
5
5
|
export interface IBlobStorageServiceConstructorOptions {
|
|
6
6
|
/**
|
|
7
|
-
* The type of the storage connector for the
|
|
7
|
+
* The type of the storage connector for the annotation.
|
|
8
8
|
* @default blob-storage-entry
|
|
9
9
|
*/
|
|
10
10
|
entryEntityStorageType?: string;
|
package/docs/changelog.md
CHANGED