@twin.org/blob-storage-service 0.0.1 → 0.0.2-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.
- package/dist/cjs/index.cjs +27 -86
- package/dist/esm/index.mjs +27 -86
- package/dist/types/blobStorageService.d.ts +3 -10
- package/dist/types/entities/blobStorageEntry.d.ts +0 -4
- package/dist/types/models/IBlobStorageServiceConfig.d.ts +2 -6
- package/docs/changelog.md +29 -0
- package/docs/open-api/spec.json +10 -9
- package/docs/reference/classes/BlobStorageEntry.md +0 -8
- package/docs/reference/classes/BlobStorageService.md +3 -29
- package/docs/reference/interfaces/IBlobStorageServiceConfig.md +3 -11
- package/package.json +12 -12
package/dist/cjs/index.cjs
CHANGED
|
@@ -492,7 +492,7 @@ async function blobStorageUpdate(httpRequestContext, componentName, request) {
|
|
|
492
492
|
core.Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
493
493
|
core.Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
494
494
|
const component = core.ComponentFactory.get(componentName);
|
|
495
|
-
await component.update(request.pathParams.id, request.body.encodingFormat, request.body.fileExtension, request.body.metadata, httpRequestContext.userIdentity
|
|
495
|
+
await component.update(request.pathParams.id, request.body.encodingFormat, request.body.fileExtension, request.body.metadata, httpRequestContext.userIdentity);
|
|
496
496
|
return {
|
|
497
497
|
statusCode: web.HttpStatusCode.noContent
|
|
498
498
|
};
|
|
@@ -509,7 +509,7 @@ async function blobStorageRemove(httpRequestContext, componentName, request) {
|
|
|
509
509
|
core.Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
510
510
|
core.Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
511
511
|
const component = core.ComponentFactory.get(componentName);
|
|
512
|
-
await component.remove(request.pathParams.id, httpRequestContext.userIdentity
|
|
512
|
+
await component.remove(request.pathParams.id, httpRequestContext.userIdentity);
|
|
513
513
|
return {
|
|
514
514
|
statusCode: web.HttpStatusCode.noContent
|
|
515
515
|
};
|
|
@@ -525,7 +525,7 @@ async function blobStorageList(httpRequestContext, componentName, request) {
|
|
|
525
525
|
core.Guards.object(ROUTES_SOURCE, "request", request);
|
|
526
526
|
const mimeType = request.headers?.[web.HeaderTypes.Accept] === web.MimeTypes.JsonLd ? "jsonld" : "json";
|
|
527
527
|
const component = core.ComponentFactory.get(componentName);
|
|
528
|
-
const result = await component.query(apiModels.HttpParameterHelper.objectFromString(request.query?.conditions), request.query?.orderBy, request.query?.orderByDirection, request.query?.cursor, core.Coerce.number(request.query?.pageSize), httpRequestContext.userIdentity
|
|
528
|
+
const result = await component.query(apiModels.HttpParameterHelper.objectFromString(request.query?.conditions), request.query?.orderBy, request.query?.orderByDirection, request.query?.cursor, core.Coerce.number(request.query?.pageSize), httpRequestContext.userIdentity);
|
|
529
529
|
return {
|
|
530
530
|
headers: {
|
|
531
531
|
[web.HeaderTypes.ContentType]: mimeType === "json" ? web.MimeTypes.Json : web.MimeTypes.JsonLd
|
|
@@ -542,8 +542,9 @@ async function blobStorageList(httpRequestContext, componentName, request) {
|
|
|
542
542
|
class BlobStorageService {
|
|
543
543
|
/**
|
|
544
544
|
* The namespace supported by the blob storage service.
|
|
545
|
+
* @internal
|
|
545
546
|
*/
|
|
546
|
-
static
|
|
547
|
+
static _NAMESPACE = "blob";
|
|
547
548
|
/**
|
|
548
549
|
* Runtime name for the class.
|
|
549
550
|
*/
|
|
@@ -570,15 +571,10 @@ class BlobStorageService {
|
|
|
570
571
|
*/
|
|
571
572
|
_vaultKeyId;
|
|
572
573
|
/**
|
|
573
|
-
* Include the
|
|
574
|
-
* @internal
|
|
575
|
-
*/
|
|
576
|
-
_includeNodeIdentity;
|
|
577
|
-
/**
|
|
578
|
-
* Include the user identity when performing storage operations, defaults to true.
|
|
574
|
+
* Include the user identity when performing storage operations, can be used to partition for users, defaults to false.
|
|
579
575
|
* @internal
|
|
580
576
|
*/
|
|
581
|
-
|
|
577
|
+
_partitionPerUser;
|
|
582
578
|
/**
|
|
583
579
|
* Create a new instance of BlobStorageService.
|
|
584
580
|
* @param options The options for the service.
|
|
@@ -594,8 +590,7 @@ class BlobStorageService {
|
|
|
594
590
|
}
|
|
595
591
|
this._defaultNamespace = options?.config?.defaultNamespace ?? names[0];
|
|
596
592
|
this._vaultKeyId = options?.config?.vaultKeyId;
|
|
597
|
-
this.
|
|
598
|
-
this._includeUserIdentity = options?.config?.includeUserIdentity ?? true;
|
|
593
|
+
this._partitionPerUser = options?.config?.partitionPerUser ?? false;
|
|
599
594
|
standardsSchemaOrg.SchemaOrgDataTypes.registerRedirects();
|
|
600
595
|
}
|
|
601
596
|
/**
|
|
@@ -615,15 +610,12 @@ class BlobStorageService {
|
|
|
615
610
|
*/
|
|
616
611
|
async create(blob, encodingFormat, fileExtension, metadata, options, userIdentity, nodeIdentity) {
|
|
617
612
|
core.Guards.stringBase64(this.CLASS_NAME, "blob", blob);
|
|
618
|
-
if (this.
|
|
613
|
+
if (this._partitionPerUser) {
|
|
619
614
|
core.Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
620
615
|
}
|
|
621
616
|
const disableEncryption = options?.disableEncryption ?? false;
|
|
622
617
|
const vaultKeyId = options?.overrideVaultKeyId ?? this._vaultKeyId;
|
|
623
618
|
const encryptionEnabled = !disableEncryption && core.Is.stringValue(vaultKeyId);
|
|
624
|
-
if (this._includeNodeIdentity || encryptionEnabled) {
|
|
625
|
-
core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
626
|
-
}
|
|
627
619
|
try {
|
|
628
620
|
const connectorNamespace = options?.namespace ?? this._defaultNamespace;
|
|
629
621
|
const blobStorageConnector = blobStorageModels.BlobStorageConnectorFactory.get(connectorNamespace);
|
|
@@ -650,6 +642,7 @@ class BlobStorageService {
|
|
|
650
642
|
}
|
|
651
643
|
// If we have a vault connector then encrypt the data.
|
|
652
644
|
if (encryptionEnabled) {
|
|
645
|
+
core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
653
646
|
if (core.Is.empty(this._vaultConnector)) {
|
|
654
647
|
throw new core.GeneralError(this.CLASS_NAME, "vaultConnectorNotConfigured");
|
|
655
648
|
}
|
|
@@ -670,14 +663,10 @@ class BlobStorageService {
|
|
|
670
663
|
compression: options?.compress
|
|
671
664
|
};
|
|
672
665
|
const conditions = [];
|
|
673
|
-
if (this.
|
|
666
|
+
if (this._partitionPerUser) {
|
|
674
667
|
core.ObjectHelper.propertySet(blobEntry, "userIdentity", userIdentity);
|
|
675
668
|
conditions.push({ property: "userIdentity", value: userIdentity });
|
|
676
669
|
}
|
|
677
|
-
if (this._includeNodeIdentity) {
|
|
678
|
-
core.ObjectHelper.propertySet(blobEntry, "nodeIdentity", nodeIdentity);
|
|
679
|
-
conditions.push({ property: "nodeIdentity", value: nodeIdentity });
|
|
680
|
-
}
|
|
681
670
|
await this._entryEntityStorage.set(blobEntry, conditions);
|
|
682
671
|
return blobId;
|
|
683
672
|
}
|
|
@@ -702,7 +691,7 @@ class BlobStorageService {
|
|
|
702
691
|
const includeContent = options?.includeContent ?? false;
|
|
703
692
|
const vaultKeyId = options?.overrideVaultKeyId ?? this._vaultKeyId;
|
|
704
693
|
const conditions = [];
|
|
705
|
-
if (this.
|
|
694
|
+
if (this._partitionPerUser) {
|
|
706
695
|
core.Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
707
696
|
conditions.push({
|
|
708
697
|
property: "userIdentity",
|
|
@@ -710,16 +699,8 @@ class BlobStorageService {
|
|
|
710
699
|
value: userIdentity
|
|
711
700
|
});
|
|
712
701
|
}
|
|
713
|
-
if (this._includeNodeIdentity || (core.Is.notEmpty(this._vaultConnector) && includeContent)) {
|
|
714
|
-
core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
715
|
-
conditions.push({
|
|
716
|
-
property: "nodeIdentity",
|
|
717
|
-
comparison: entity.ComparisonOperator.Equals,
|
|
718
|
-
value: nodeIdentity
|
|
719
|
-
});
|
|
720
|
-
}
|
|
721
702
|
try {
|
|
722
|
-
const blobEntry = await this.internalGet(id, userIdentity
|
|
703
|
+
const blobEntry = await this.internalGet(id, userIdentity);
|
|
723
704
|
let returnBlob;
|
|
724
705
|
if (includeContent) {
|
|
725
706
|
const blobStorageConnector = this.getConnector(id);
|
|
@@ -730,6 +711,7 @@ class BlobStorageService {
|
|
|
730
711
|
// If the data is encrypted then decrypt it.
|
|
731
712
|
const decryptionEnabled = blobEntry.isEncrypted && core.Is.stringValue(vaultKeyId);
|
|
732
713
|
if (decryptionEnabled) {
|
|
714
|
+
core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
733
715
|
if (core.Is.empty(this._vaultConnector)) {
|
|
734
716
|
throw new core.GeneralError(this.CLASS_NAME, "vaultConnectorNotConfigured");
|
|
735
717
|
}
|
|
@@ -753,18 +735,14 @@ class BlobStorageService {
|
|
|
753
735
|
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
754
736
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
755
737
|
* @param userIdentity The user identity to use with storage operations.
|
|
756
|
-
* @param nodeIdentity The node identity to use with storage operations.
|
|
757
738
|
* @returns Nothing.
|
|
758
739
|
* @throws Not found error if the blob cannot be found.
|
|
759
740
|
*/
|
|
760
|
-
async update(id, encodingFormat, fileExtension, metadata, userIdentity
|
|
741
|
+
async update(id, encodingFormat, fileExtension, metadata, userIdentity) {
|
|
761
742
|
core.Urn.guard(this.CLASS_NAME, "id", id);
|
|
762
|
-
if (this.
|
|
743
|
+
if (this._partitionPerUser) {
|
|
763
744
|
core.Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
764
745
|
}
|
|
765
|
-
if (this._includeNodeIdentity || core.Is.notEmpty(this._vaultConnector)) {
|
|
766
|
-
core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
767
|
-
}
|
|
768
746
|
try {
|
|
769
747
|
const blobEntry = await this._entryEntityStorage.get(id);
|
|
770
748
|
if (core.Is.undefined(blobEntry)) {
|
|
@@ -789,14 +767,10 @@ class BlobStorageService {
|
|
|
789
767
|
compression: blobEntry.compression
|
|
790
768
|
};
|
|
791
769
|
const conditions = [];
|
|
792
|
-
if (this.
|
|
770
|
+
if (this._partitionPerUser) {
|
|
793
771
|
core.ObjectHelper.propertySet(updatedBlobEntry, "userIdentity", userIdentity);
|
|
794
772
|
conditions.push({ property: "userIdentity", value: userIdentity });
|
|
795
773
|
}
|
|
796
|
-
if (this._includeNodeIdentity) {
|
|
797
|
-
core.ObjectHelper.propertySet(updatedBlobEntry, "nodeIdentity", nodeIdentity);
|
|
798
|
-
conditions.push({ property: "nodeIdentity", value: nodeIdentity });
|
|
799
|
-
}
|
|
800
774
|
await this._entryEntityStorage.set(updatedBlobEntry, conditions);
|
|
801
775
|
}
|
|
802
776
|
catch (error) {
|
|
@@ -807,26 +781,19 @@ class BlobStorageService {
|
|
|
807
781
|
* Remove the blob.
|
|
808
782
|
* @param id The id of the blob to remove in urn format.
|
|
809
783
|
* @param userIdentity The user identity to use with storage operations.
|
|
810
|
-
* @param nodeIdentity The node identity to use with storage operations.
|
|
811
784
|
* @returns Nothing.
|
|
812
785
|
*/
|
|
813
|
-
async remove(id, userIdentity
|
|
786
|
+
async remove(id, userIdentity) {
|
|
814
787
|
core.Urn.guard(this.CLASS_NAME, "id", id);
|
|
815
|
-
if (this.
|
|
788
|
+
if (this._partitionPerUser) {
|
|
816
789
|
core.Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
817
790
|
}
|
|
818
|
-
if (this._includeNodeIdentity || core.Is.notEmpty(this._vaultConnector)) {
|
|
819
|
-
core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
820
|
-
}
|
|
821
791
|
try {
|
|
822
792
|
const blobStorageConnector = this.getConnector(id);
|
|
823
793
|
const conditions = [];
|
|
824
|
-
if (this.
|
|
794
|
+
if (this._partitionPerUser) {
|
|
825
795
|
conditions.push({ property: "userIdentity", value: userIdentity });
|
|
826
796
|
}
|
|
827
|
-
if (this._includeNodeIdentity) {
|
|
828
|
-
conditions.push({ property: "nodeIdentity", value: nodeIdentity });
|
|
829
|
-
}
|
|
830
797
|
await this._entryEntityStorage.remove(id, conditions);
|
|
831
798
|
const removed = await blobStorageConnector.remove(id);
|
|
832
799
|
if (!removed) {
|
|
@@ -845,24 +812,15 @@ class BlobStorageService {
|
|
|
845
812
|
* @param cursor The cursor to request the next page of entries.
|
|
846
813
|
* @param pageSize The suggested number of entries to return in each chunk, in some scenarios can return a different amount.
|
|
847
814
|
* @param userIdentity The user identity to use with storage operations.
|
|
848
|
-
* @param nodeIdentity The node identity to use with storage operations.
|
|
849
815
|
* @returns All the entries for the storage matching the conditions,
|
|
850
816
|
* and a cursor which can be used to request more entities.
|
|
851
817
|
*/
|
|
852
|
-
async query(conditions, orderBy, orderByDirection, cursor, pageSize, userIdentity
|
|
818
|
+
async query(conditions, orderBy, orderByDirection, cursor, pageSize, userIdentity) {
|
|
853
819
|
const finalConditions = {
|
|
854
820
|
conditions: [],
|
|
855
821
|
logicalOperator: entity.LogicalOperator.And
|
|
856
822
|
};
|
|
857
|
-
if (this.
|
|
858
|
-
core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
859
|
-
finalConditions.conditions.push({
|
|
860
|
-
property: "nodeIdentity",
|
|
861
|
-
comparison: entity.ComparisonOperator.Equals,
|
|
862
|
-
value: nodeIdentity
|
|
863
|
-
});
|
|
864
|
-
}
|
|
865
|
-
if (this._includeUserIdentity) {
|
|
823
|
+
if (this._partitionPerUser) {
|
|
866
824
|
core.Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
867
825
|
finalConditions.conditions.push({
|
|
868
826
|
property: "userIdentity",
|
|
@@ -908,9 +866,9 @@ class BlobStorageService {
|
|
|
908
866
|
*/
|
|
909
867
|
getConnector(id) {
|
|
910
868
|
const idUri = core.Urn.fromValidString(id);
|
|
911
|
-
if (idUri.namespaceIdentifier() !== BlobStorageService.
|
|
869
|
+
if (idUri.namespaceIdentifier() !== BlobStorageService._NAMESPACE) {
|
|
912
870
|
throw new core.GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
913
|
-
namespace: BlobStorageService.
|
|
871
|
+
namespace: BlobStorageService._NAMESPACE,
|
|
914
872
|
id
|
|
915
873
|
});
|
|
916
874
|
}
|
|
@@ -921,13 +879,12 @@ class BlobStorageService {
|
|
|
921
879
|
* @param id The id of the entity to get, or the index value if secondaryIndex is set.
|
|
922
880
|
* @param secondaryIndex Get the item using a secondary index.
|
|
923
881
|
* @param userIdentity The user identity to use with storage operations.
|
|
924
|
-
* @param nodeIdentity The node identity to use with storage operations.
|
|
925
882
|
* @returns The object if it can be found or throws.
|
|
926
883
|
* @internal
|
|
927
884
|
*/
|
|
928
|
-
async internalGet(id, userIdentity
|
|
885
|
+
async internalGet(id, userIdentity) {
|
|
929
886
|
const conditions = [];
|
|
930
|
-
if (this.
|
|
887
|
+
if (this._partitionPerUser) {
|
|
931
888
|
core.Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
932
889
|
conditions.push({
|
|
933
890
|
property: "userIdentity",
|
|
@@ -935,14 +892,6 @@ class BlobStorageService {
|
|
|
935
892
|
value: userIdentity
|
|
936
893
|
});
|
|
937
894
|
}
|
|
938
|
-
if (this._includeNodeIdentity) {
|
|
939
|
-
core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
940
|
-
conditions.push({
|
|
941
|
-
property: "nodeIdentity",
|
|
942
|
-
comparison: entity.ComparisonOperator.Equals,
|
|
943
|
-
value: nodeIdentity
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
895
|
let entity$1;
|
|
947
896
|
if (conditions.length === 0) {
|
|
948
897
|
entity$1 = await this._entryEntityStorage.get(id);
|
|
@@ -964,7 +913,7 @@ class BlobStorageService {
|
|
|
964
913
|
if (core.Is.empty(entity$1)) {
|
|
965
914
|
throw new core.NotFoundError(this.CLASS_NAME, "entityNotFound", id);
|
|
966
915
|
}
|
|
967
|
-
return core.ObjectHelper.omit(entity$1, ["
|
|
916
|
+
return core.ObjectHelper.omit(entity$1, ["userIdentity"]);
|
|
968
917
|
}
|
|
969
918
|
/**
|
|
970
919
|
* Convert the entry to JSON-LD.
|
|
@@ -1045,10 +994,6 @@ exports.BlobStorageEntry = class BlobStorageEntry {
|
|
|
1045
994
|
* The user identity that created the blob.
|
|
1046
995
|
*/
|
|
1047
996
|
userIdentity;
|
|
1048
|
-
/**
|
|
1049
|
-
* The node identity that created the blob.
|
|
1050
|
-
*/
|
|
1051
|
-
nodeIdentity;
|
|
1052
997
|
};
|
|
1053
998
|
__decorate([
|
|
1054
999
|
entity.property({ type: "string", isPrimary: true }),
|
|
@@ -1099,10 +1044,6 @@ __decorate([
|
|
|
1099
1044
|
entity.property({ type: "string", optional: true }),
|
|
1100
1045
|
__metadata("design:type", String)
|
|
1101
1046
|
], exports.BlobStorageEntry.prototype, "userIdentity", void 0);
|
|
1102
|
-
__decorate([
|
|
1103
|
-
entity.property({ type: "string", optional: true }),
|
|
1104
|
-
__metadata("design:type", String)
|
|
1105
|
-
], exports.BlobStorageEntry.prototype, "nodeIdentity", void 0);
|
|
1106
1047
|
exports.BlobStorageEntry = __decorate([
|
|
1107
1048
|
entity.entity()
|
|
1108
1049
|
], exports.BlobStorageEntry);
|
package/dist/esm/index.mjs
CHANGED
|
@@ -490,7 +490,7 @@ async function blobStorageUpdate(httpRequestContext, componentName, request) {
|
|
|
490
490
|
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
491
491
|
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
492
492
|
const component = ComponentFactory.get(componentName);
|
|
493
|
-
await component.update(request.pathParams.id, request.body.encodingFormat, request.body.fileExtension, request.body.metadata, httpRequestContext.userIdentity
|
|
493
|
+
await component.update(request.pathParams.id, request.body.encodingFormat, request.body.fileExtension, request.body.metadata, httpRequestContext.userIdentity);
|
|
494
494
|
return {
|
|
495
495
|
statusCode: HttpStatusCode.noContent
|
|
496
496
|
};
|
|
@@ -507,7 +507,7 @@ async function blobStorageRemove(httpRequestContext, componentName, request) {
|
|
|
507
507
|
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
508
508
|
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
509
509
|
const component = ComponentFactory.get(componentName);
|
|
510
|
-
await component.remove(request.pathParams.id, httpRequestContext.userIdentity
|
|
510
|
+
await component.remove(request.pathParams.id, httpRequestContext.userIdentity);
|
|
511
511
|
return {
|
|
512
512
|
statusCode: HttpStatusCode.noContent
|
|
513
513
|
};
|
|
@@ -523,7 +523,7 @@ async function blobStorageList(httpRequestContext, componentName, request) {
|
|
|
523
523
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
524
524
|
const mimeType = request.headers?.[HeaderTypes.Accept] === MimeTypes.JsonLd ? "jsonld" : "json";
|
|
525
525
|
const component = ComponentFactory.get(componentName);
|
|
526
|
-
const result = await component.query(HttpParameterHelper.objectFromString(request.query?.conditions), request.query?.orderBy, request.query?.orderByDirection, request.query?.cursor, Coerce.number(request.query?.pageSize), httpRequestContext.userIdentity
|
|
526
|
+
const result = await component.query(HttpParameterHelper.objectFromString(request.query?.conditions), request.query?.orderBy, request.query?.orderByDirection, request.query?.cursor, Coerce.number(request.query?.pageSize), httpRequestContext.userIdentity);
|
|
527
527
|
return {
|
|
528
528
|
headers: {
|
|
529
529
|
[HeaderTypes.ContentType]: mimeType === "json" ? MimeTypes.Json : MimeTypes.JsonLd
|
|
@@ -540,8 +540,9 @@ async function blobStorageList(httpRequestContext, componentName, request) {
|
|
|
540
540
|
class BlobStorageService {
|
|
541
541
|
/**
|
|
542
542
|
* The namespace supported by the blob storage service.
|
|
543
|
+
* @internal
|
|
543
544
|
*/
|
|
544
|
-
static
|
|
545
|
+
static _NAMESPACE = "blob";
|
|
545
546
|
/**
|
|
546
547
|
* Runtime name for the class.
|
|
547
548
|
*/
|
|
@@ -568,15 +569,10 @@ class BlobStorageService {
|
|
|
568
569
|
*/
|
|
569
570
|
_vaultKeyId;
|
|
570
571
|
/**
|
|
571
|
-
* Include the
|
|
572
|
-
* @internal
|
|
573
|
-
*/
|
|
574
|
-
_includeNodeIdentity;
|
|
575
|
-
/**
|
|
576
|
-
* Include the user identity when performing storage operations, defaults to true.
|
|
572
|
+
* Include the user identity when performing storage operations, can be used to partition for users, defaults to false.
|
|
577
573
|
* @internal
|
|
578
574
|
*/
|
|
579
|
-
|
|
575
|
+
_partitionPerUser;
|
|
580
576
|
/**
|
|
581
577
|
* Create a new instance of BlobStorageService.
|
|
582
578
|
* @param options The options for the service.
|
|
@@ -592,8 +588,7 @@ class BlobStorageService {
|
|
|
592
588
|
}
|
|
593
589
|
this._defaultNamespace = options?.config?.defaultNamespace ?? names[0];
|
|
594
590
|
this._vaultKeyId = options?.config?.vaultKeyId;
|
|
595
|
-
this.
|
|
596
|
-
this._includeUserIdentity = options?.config?.includeUserIdentity ?? true;
|
|
591
|
+
this._partitionPerUser = options?.config?.partitionPerUser ?? false;
|
|
597
592
|
SchemaOrgDataTypes.registerRedirects();
|
|
598
593
|
}
|
|
599
594
|
/**
|
|
@@ -613,15 +608,12 @@ class BlobStorageService {
|
|
|
613
608
|
*/
|
|
614
609
|
async create(blob, encodingFormat, fileExtension, metadata, options, userIdentity, nodeIdentity) {
|
|
615
610
|
Guards.stringBase64(this.CLASS_NAME, "blob", blob);
|
|
616
|
-
if (this.
|
|
611
|
+
if (this._partitionPerUser) {
|
|
617
612
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
618
613
|
}
|
|
619
614
|
const disableEncryption = options?.disableEncryption ?? false;
|
|
620
615
|
const vaultKeyId = options?.overrideVaultKeyId ?? this._vaultKeyId;
|
|
621
616
|
const encryptionEnabled = !disableEncryption && Is.stringValue(vaultKeyId);
|
|
622
|
-
if (this._includeNodeIdentity || encryptionEnabled) {
|
|
623
|
-
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
624
|
-
}
|
|
625
617
|
try {
|
|
626
618
|
const connectorNamespace = options?.namespace ?? this._defaultNamespace;
|
|
627
619
|
const blobStorageConnector = BlobStorageConnectorFactory.get(connectorNamespace);
|
|
@@ -648,6 +640,7 @@ class BlobStorageService {
|
|
|
648
640
|
}
|
|
649
641
|
// If we have a vault connector then encrypt the data.
|
|
650
642
|
if (encryptionEnabled) {
|
|
643
|
+
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
651
644
|
if (Is.empty(this._vaultConnector)) {
|
|
652
645
|
throw new GeneralError(this.CLASS_NAME, "vaultConnectorNotConfigured");
|
|
653
646
|
}
|
|
@@ -668,14 +661,10 @@ class BlobStorageService {
|
|
|
668
661
|
compression: options?.compress
|
|
669
662
|
};
|
|
670
663
|
const conditions = [];
|
|
671
|
-
if (this.
|
|
664
|
+
if (this._partitionPerUser) {
|
|
672
665
|
ObjectHelper.propertySet(blobEntry, "userIdentity", userIdentity);
|
|
673
666
|
conditions.push({ property: "userIdentity", value: userIdentity });
|
|
674
667
|
}
|
|
675
|
-
if (this._includeNodeIdentity) {
|
|
676
|
-
ObjectHelper.propertySet(blobEntry, "nodeIdentity", nodeIdentity);
|
|
677
|
-
conditions.push({ property: "nodeIdentity", value: nodeIdentity });
|
|
678
|
-
}
|
|
679
668
|
await this._entryEntityStorage.set(blobEntry, conditions);
|
|
680
669
|
return blobId;
|
|
681
670
|
}
|
|
@@ -700,7 +689,7 @@ class BlobStorageService {
|
|
|
700
689
|
const includeContent = options?.includeContent ?? false;
|
|
701
690
|
const vaultKeyId = options?.overrideVaultKeyId ?? this._vaultKeyId;
|
|
702
691
|
const conditions = [];
|
|
703
|
-
if (this.
|
|
692
|
+
if (this._partitionPerUser) {
|
|
704
693
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
705
694
|
conditions.push({
|
|
706
695
|
property: "userIdentity",
|
|
@@ -708,16 +697,8 @@ class BlobStorageService {
|
|
|
708
697
|
value: userIdentity
|
|
709
698
|
});
|
|
710
699
|
}
|
|
711
|
-
if (this._includeNodeIdentity || (Is.notEmpty(this._vaultConnector) && includeContent)) {
|
|
712
|
-
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
713
|
-
conditions.push({
|
|
714
|
-
property: "nodeIdentity",
|
|
715
|
-
comparison: ComparisonOperator.Equals,
|
|
716
|
-
value: nodeIdentity
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
700
|
try {
|
|
720
|
-
const blobEntry = await this.internalGet(id, userIdentity
|
|
701
|
+
const blobEntry = await this.internalGet(id, userIdentity);
|
|
721
702
|
let returnBlob;
|
|
722
703
|
if (includeContent) {
|
|
723
704
|
const blobStorageConnector = this.getConnector(id);
|
|
@@ -728,6 +709,7 @@ class BlobStorageService {
|
|
|
728
709
|
// If the data is encrypted then decrypt it.
|
|
729
710
|
const decryptionEnabled = blobEntry.isEncrypted && Is.stringValue(vaultKeyId);
|
|
730
711
|
if (decryptionEnabled) {
|
|
712
|
+
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
731
713
|
if (Is.empty(this._vaultConnector)) {
|
|
732
714
|
throw new GeneralError(this.CLASS_NAME, "vaultConnectorNotConfigured");
|
|
733
715
|
}
|
|
@@ -751,18 +733,14 @@ class BlobStorageService {
|
|
|
751
733
|
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
752
734
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
753
735
|
* @param userIdentity The user identity to use with storage operations.
|
|
754
|
-
* @param nodeIdentity The node identity to use with storage operations.
|
|
755
736
|
* @returns Nothing.
|
|
756
737
|
* @throws Not found error if the blob cannot be found.
|
|
757
738
|
*/
|
|
758
|
-
async update(id, encodingFormat, fileExtension, metadata, userIdentity
|
|
739
|
+
async update(id, encodingFormat, fileExtension, metadata, userIdentity) {
|
|
759
740
|
Urn.guard(this.CLASS_NAME, "id", id);
|
|
760
|
-
if (this.
|
|
741
|
+
if (this._partitionPerUser) {
|
|
761
742
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
762
743
|
}
|
|
763
|
-
if (this._includeNodeIdentity || Is.notEmpty(this._vaultConnector)) {
|
|
764
|
-
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
765
|
-
}
|
|
766
744
|
try {
|
|
767
745
|
const blobEntry = await this._entryEntityStorage.get(id);
|
|
768
746
|
if (Is.undefined(blobEntry)) {
|
|
@@ -787,14 +765,10 @@ class BlobStorageService {
|
|
|
787
765
|
compression: blobEntry.compression
|
|
788
766
|
};
|
|
789
767
|
const conditions = [];
|
|
790
|
-
if (this.
|
|
768
|
+
if (this._partitionPerUser) {
|
|
791
769
|
ObjectHelper.propertySet(updatedBlobEntry, "userIdentity", userIdentity);
|
|
792
770
|
conditions.push({ property: "userIdentity", value: userIdentity });
|
|
793
771
|
}
|
|
794
|
-
if (this._includeNodeIdentity) {
|
|
795
|
-
ObjectHelper.propertySet(updatedBlobEntry, "nodeIdentity", nodeIdentity);
|
|
796
|
-
conditions.push({ property: "nodeIdentity", value: nodeIdentity });
|
|
797
|
-
}
|
|
798
772
|
await this._entryEntityStorage.set(updatedBlobEntry, conditions);
|
|
799
773
|
}
|
|
800
774
|
catch (error) {
|
|
@@ -805,26 +779,19 @@ class BlobStorageService {
|
|
|
805
779
|
* Remove the blob.
|
|
806
780
|
* @param id The id of the blob to remove in urn format.
|
|
807
781
|
* @param userIdentity The user identity to use with storage operations.
|
|
808
|
-
* @param nodeIdentity The node identity to use with storage operations.
|
|
809
782
|
* @returns Nothing.
|
|
810
783
|
*/
|
|
811
|
-
async remove(id, userIdentity
|
|
784
|
+
async remove(id, userIdentity) {
|
|
812
785
|
Urn.guard(this.CLASS_NAME, "id", id);
|
|
813
|
-
if (this.
|
|
786
|
+
if (this._partitionPerUser) {
|
|
814
787
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
815
788
|
}
|
|
816
|
-
if (this._includeNodeIdentity || Is.notEmpty(this._vaultConnector)) {
|
|
817
|
-
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
818
|
-
}
|
|
819
789
|
try {
|
|
820
790
|
const blobStorageConnector = this.getConnector(id);
|
|
821
791
|
const conditions = [];
|
|
822
|
-
if (this.
|
|
792
|
+
if (this._partitionPerUser) {
|
|
823
793
|
conditions.push({ property: "userIdentity", value: userIdentity });
|
|
824
794
|
}
|
|
825
|
-
if (this._includeNodeIdentity) {
|
|
826
|
-
conditions.push({ property: "nodeIdentity", value: nodeIdentity });
|
|
827
|
-
}
|
|
828
795
|
await this._entryEntityStorage.remove(id, conditions);
|
|
829
796
|
const removed = await blobStorageConnector.remove(id);
|
|
830
797
|
if (!removed) {
|
|
@@ -843,24 +810,15 @@ class BlobStorageService {
|
|
|
843
810
|
* @param cursor The cursor to request the next page of entries.
|
|
844
811
|
* @param pageSize The suggested number of entries to return in each chunk, in some scenarios can return a different amount.
|
|
845
812
|
* @param userIdentity The user identity to use with storage operations.
|
|
846
|
-
* @param nodeIdentity The node identity to use with storage operations.
|
|
847
813
|
* @returns All the entries for the storage matching the conditions,
|
|
848
814
|
* and a cursor which can be used to request more entities.
|
|
849
815
|
*/
|
|
850
|
-
async query(conditions, orderBy, orderByDirection, cursor, pageSize, userIdentity
|
|
816
|
+
async query(conditions, orderBy, orderByDirection, cursor, pageSize, userIdentity) {
|
|
851
817
|
const finalConditions = {
|
|
852
818
|
conditions: [],
|
|
853
819
|
logicalOperator: LogicalOperator.And
|
|
854
820
|
};
|
|
855
|
-
if (this.
|
|
856
|
-
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
857
|
-
finalConditions.conditions.push({
|
|
858
|
-
property: "nodeIdentity",
|
|
859
|
-
comparison: ComparisonOperator.Equals,
|
|
860
|
-
value: nodeIdentity
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
if (this._includeUserIdentity) {
|
|
821
|
+
if (this._partitionPerUser) {
|
|
864
822
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
865
823
|
finalConditions.conditions.push({
|
|
866
824
|
property: "userIdentity",
|
|
@@ -906,9 +864,9 @@ class BlobStorageService {
|
|
|
906
864
|
*/
|
|
907
865
|
getConnector(id) {
|
|
908
866
|
const idUri = Urn.fromValidString(id);
|
|
909
|
-
if (idUri.namespaceIdentifier() !== BlobStorageService.
|
|
867
|
+
if (idUri.namespaceIdentifier() !== BlobStorageService._NAMESPACE) {
|
|
910
868
|
throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
|
|
911
|
-
namespace: BlobStorageService.
|
|
869
|
+
namespace: BlobStorageService._NAMESPACE,
|
|
912
870
|
id
|
|
913
871
|
});
|
|
914
872
|
}
|
|
@@ -919,13 +877,12 @@ class BlobStorageService {
|
|
|
919
877
|
* @param id The id of the entity to get, or the index value if secondaryIndex is set.
|
|
920
878
|
* @param secondaryIndex Get the item using a secondary index.
|
|
921
879
|
* @param userIdentity The user identity to use with storage operations.
|
|
922
|
-
* @param nodeIdentity The node identity to use with storage operations.
|
|
923
880
|
* @returns The object if it can be found or throws.
|
|
924
881
|
* @internal
|
|
925
882
|
*/
|
|
926
|
-
async internalGet(id, userIdentity
|
|
883
|
+
async internalGet(id, userIdentity) {
|
|
927
884
|
const conditions = [];
|
|
928
|
-
if (this.
|
|
885
|
+
if (this._partitionPerUser) {
|
|
929
886
|
Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
|
|
930
887
|
conditions.push({
|
|
931
888
|
property: "userIdentity",
|
|
@@ -933,14 +890,6 @@ class BlobStorageService {
|
|
|
933
890
|
value: userIdentity
|
|
934
891
|
});
|
|
935
892
|
}
|
|
936
|
-
if (this._includeNodeIdentity) {
|
|
937
|
-
Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
|
|
938
|
-
conditions.push({
|
|
939
|
-
property: "nodeIdentity",
|
|
940
|
-
comparison: ComparisonOperator.Equals,
|
|
941
|
-
value: nodeIdentity
|
|
942
|
-
});
|
|
943
|
-
}
|
|
944
893
|
let entity;
|
|
945
894
|
if (conditions.length === 0) {
|
|
946
895
|
entity = await this._entryEntityStorage.get(id);
|
|
@@ -962,7 +911,7 @@ class BlobStorageService {
|
|
|
962
911
|
if (Is.empty(entity)) {
|
|
963
912
|
throw new NotFoundError(this.CLASS_NAME, "entityNotFound", id);
|
|
964
913
|
}
|
|
965
|
-
return ObjectHelper.omit(entity, ["
|
|
914
|
+
return ObjectHelper.omit(entity, ["userIdentity"]);
|
|
966
915
|
}
|
|
967
916
|
/**
|
|
968
917
|
* Convert the entry to JSON-LD.
|
|
@@ -1043,10 +992,6 @@ let BlobStorageEntry = class BlobStorageEntry {
|
|
|
1043
992
|
* The user identity that created the blob.
|
|
1044
993
|
*/
|
|
1045
994
|
userIdentity;
|
|
1046
|
-
/**
|
|
1047
|
-
* The node identity that created the blob.
|
|
1048
|
-
*/
|
|
1049
|
-
nodeIdentity;
|
|
1050
995
|
};
|
|
1051
996
|
__decorate([
|
|
1052
997
|
property({ type: "string", isPrimary: true }),
|
|
@@ -1097,10 +1042,6 @@ __decorate([
|
|
|
1097
1042
|
property({ type: "string", optional: true }),
|
|
1098
1043
|
__metadata("design:type", String)
|
|
1099
1044
|
], BlobStorageEntry.prototype, "userIdentity", void 0);
|
|
1100
|
-
__decorate([
|
|
1101
|
-
property({ type: "string", optional: true }),
|
|
1102
|
-
__metadata("design:type", String)
|
|
1103
|
-
], BlobStorageEntry.prototype, "nodeIdentity", void 0);
|
|
1104
1045
|
BlobStorageEntry = __decorate([
|
|
1105
1046
|
entity()
|
|
1106
1047
|
], BlobStorageEntry);
|
|
@@ -6,10 +6,6 @@ import type { IBlobStorageServiceConstructorOptions } from "./models/IBlobStorag
|
|
|
6
6
|
* Service for performing blob storage operations to a connector.
|
|
7
7
|
*/
|
|
8
8
|
export declare class BlobStorageService implements IBlobStorageComponent {
|
|
9
|
-
/**
|
|
10
|
-
* The namespace supported by the blob storage service.
|
|
11
|
-
*/
|
|
12
|
-
static readonly NAMESPACE: string;
|
|
13
9
|
/**
|
|
14
10
|
* Runtime name for the class.
|
|
15
11
|
*/
|
|
@@ -64,19 +60,17 @@ export declare class BlobStorageService implements IBlobStorageComponent {
|
|
|
64
60
|
* @param fileExtension Extension for the blob, will be detected if left undefined.
|
|
65
61
|
* @param metadata Data for the custom metadata as JSON-LD.
|
|
66
62
|
* @param userIdentity The user identity to use with storage operations.
|
|
67
|
-
* @param nodeIdentity The node identity to use with storage operations.
|
|
68
63
|
* @returns Nothing.
|
|
69
64
|
* @throws Not found error if the blob cannot be found.
|
|
70
65
|
*/
|
|
71
|
-
update(id: string, encodingFormat?: string, fileExtension?: string, metadata?: IJsonLdNodeObject, userIdentity?: string
|
|
66
|
+
update(id: string, encodingFormat?: string, fileExtension?: string, metadata?: IJsonLdNodeObject, userIdentity?: string): Promise<void>;
|
|
72
67
|
/**
|
|
73
68
|
* Remove the blob.
|
|
74
69
|
* @param id The id of the blob to remove in urn format.
|
|
75
70
|
* @param userIdentity The user identity to use with storage operations.
|
|
76
|
-
* @param nodeIdentity The node identity to use with storage operations.
|
|
77
71
|
* @returns Nothing.
|
|
78
72
|
*/
|
|
79
|
-
remove(id: string, userIdentity?: string
|
|
73
|
+
remove(id: string, userIdentity?: string): Promise<void>;
|
|
80
74
|
/**
|
|
81
75
|
* Query all the blob storage entries which match the conditions.
|
|
82
76
|
* @param conditions The conditions to match for the entries.
|
|
@@ -85,9 +79,8 @@ export declare class BlobStorageService implements IBlobStorageComponent {
|
|
|
85
79
|
* @param cursor The cursor to request the next page of entries.
|
|
86
80
|
* @param pageSize The suggested number of entries to return in each chunk, in some scenarios can return a different amount.
|
|
87
81
|
* @param userIdentity The user identity to use with storage operations.
|
|
88
|
-
* @param nodeIdentity The node identity to use with storage operations.
|
|
89
82
|
* @returns All the entries for the storage matching the conditions,
|
|
90
83
|
* and a cursor which can be used to request more entities.
|
|
91
84
|
*/
|
|
92
|
-
query(conditions?: EntityCondition<IBlobStorageEntry>, orderBy?: keyof Pick<IBlobStorageEntry, "dateCreated" | "dateModified">, orderByDirection?: SortDirection, cursor?: string, pageSize?: number, userIdentity?: string
|
|
85
|
+
query(conditions?: EntityCondition<IBlobStorageEntry>, orderBy?: keyof Pick<IBlobStorageEntry, "dateCreated" | "dateModified">, orderByDirection?: SortDirection, cursor?: string, pageSize?: number, userIdentity?: string): Promise<IBlobStorageEntryList>;
|
|
93
86
|
}
|
|
@@ -12,11 +12,7 @@ export interface IBlobStorageServiceConfig {
|
|
|
12
12
|
*/
|
|
13
13
|
defaultNamespace?: string;
|
|
14
14
|
/**
|
|
15
|
-
* Include the
|
|
15
|
+
* Include the user identity when performing storage operations, allow partitioning per user, defaults to false.
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Include the user identity when performing storage operations, defaults to true.
|
|
20
|
-
*/
|
|
21
|
-
includeUserIdentity?: boolean;
|
|
17
|
+
partitionPerUser?: boolean;
|
|
22
18
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @twin.org/blob-storage-service - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.1](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.2-next.0...blob-storage-service-v0.0.2-next.1) (2025-07-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add compression support ([67d239b](https://github.com/twinfoundation/blob-storage/commit/67d239bca8321bd90bf4ff93167c564130309730))
|
|
9
|
+
* additional encryption options on per item basis ([4b95a65](https://github.com/twinfoundation/blob-storage/commit/4b95a656d19e3b571cea905e36f29b679b13e1e8))
|
|
10
|
+
* remove includeNodeIdentity flag ([13bc334](https://github.com/twinfoundation/blob-storage/commit/13bc33445b179879688af3c98e8be8a5609d3f46))
|
|
11
|
+
* remove unused namespace ([6376433](https://github.com/twinfoundation/blob-storage/commit/637643399ffa42dbf6af07e7579e82e392ac90c9))
|
|
12
|
+
* update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
|
|
13
|
+
* update to support fully qualified data type names ([3297d69](https://github.com/twinfoundation/blob-storage/commit/3297d69d332058b0f0141002087f56ba230620e1))
|
|
14
|
+
* use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
|
|
15
|
+
* use standard list json ld types ([d6bdfd6](https://github.com/twinfoundation/blob-storage/commit/d6bdfd68af47f70f3cc53658b4a12543497e1f48))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* Adding the optional flag to the entity ([#10](https://github.com/twinfoundation/blob-storage/issues/10)) ([626677e](https://github.com/twinfoundation/blob-storage/commit/626677e5730d23535a0eb1f36f8394d941ff2447))
|
|
21
|
+
* query params force coercion ([a5e547a](https://github.com/twinfoundation/blob-storage/commit/a5e547a775f8997cb04780938c7a9561ddb048d1))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Dependencies
|
|
25
|
+
|
|
26
|
+
* The following workspace dependencies were updated
|
|
27
|
+
* dependencies
|
|
28
|
+
* @twin.org/blob-storage-models bumped from 0.0.2-next.0 to 0.0.2-next.1
|
|
29
|
+
* devDependencies
|
|
30
|
+
* @twin.org/blob-storage-connector-memory bumped from 0.0.2-next.0 to 0.0.2-next.1
|
|
31
|
+
|
|
3
32
|
## 0.0.1 (2025-07-04)
|
|
4
33
|
|
|
5
34
|
|
package/docs/open-api/spec.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"openapi": "3.1.
|
|
2
|
+
"openapi": "3.1.1",
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "TWIN - Test Endpoints",
|
|
5
5
|
"description": "REST API for TWIN - Test Endpoints.",
|
|
@@ -986,6 +986,9 @@
|
|
|
986
986
|
"@context": {
|
|
987
987
|
"type": "array",
|
|
988
988
|
"minItems": 2,
|
|
989
|
+
"items": {
|
|
990
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdContextDefinitionElement"
|
|
991
|
+
},
|
|
989
992
|
"description": "JSON-LD Context.",
|
|
990
993
|
"prefixItems": [
|
|
991
994
|
{
|
|
@@ -996,10 +999,7 @@
|
|
|
996
999
|
"type": "string",
|
|
997
1000
|
"const": "https://schema.twindev.org/common/"
|
|
998
1001
|
}
|
|
999
|
-
]
|
|
1000
|
-
"items": {
|
|
1001
|
-
"$ref": "https://schema.twindev.org/json-ld/JsonLdContextDefinitionElement"
|
|
1002
|
-
}
|
|
1002
|
+
]
|
|
1003
1003
|
},
|
|
1004
1004
|
"type": {
|
|
1005
1005
|
"type": "string",
|
|
@@ -1066,6 +1066,9 @@
|
|
|
1066
1066
|
"@context": {
|
|
1067
1067
|
"type": "array",
|
|
1068
1068
|
"minItems": 3,
|
|
1069
|
+
"items": {
|
|
1070
|
+
"$ref": "https://schema.twindev.org/json-ld/JsonLdContextDefinitionElement"
|
|
1071
|
+
},
|
|
1069
1072
|
"description": "JSON-LD Context.",
|
|
1070
1073
|
"prefixItems": [
|
|
1071
1074
|
{
|
|
@@ -1080,10 +1083,7 @@
|
|
|
1080
1083
|
"type": "string",
|
|
1081
1084
|
"const": "https://schema.twindev.org/common/"
|
|
1082
1085
|
}
|
|
1083
|
-
]
|
|
1084
|
-
"items": {
|
|
1085
|
-
"$ref": "https://schema.twindev.org/json-ld/JsonLdContextDefinitionElement"
|
|
1086
|
-
}
|
|
1086
|
+
]
|
|
1087
1087
|
},
|
|
1088
1088
|
"type": {
|
|
1089
1089
|
"type": "string",
|
|
@@ -1092,6 +1092,7 @@
|
|
|
1092
1092
|
},
|
|
1093
1093
|
"itemListElement": {
|
|
1094
1094
|
"type": "array",
|
|
1095
|
+
"items": false,
|
|
1095
1096
|
"description": "The list of entries.",
|
|
1096
1097
|
"prefixItems": [
|
|
1097
1098
|
{
|
|
@@ -28,14 +28,6 @@ The options for the service.
|
|
|
28
28
|
|
|
29
29
|
## Properties
|
|
30
30
|
|
|
31
|
-
### NAMESPACE
|
|
32
|
-
|
|
33
|
-
> `readonly` `static` **NAMESPACE**: `string` = `"blob"`
|
|
34
|
-
|
|
35
|
-
The namespace supported by the blob storage service.
|
|
36
|
-
|
|
37
|
-
***
|
|
38
|
-
|
|
39
31
|
### CLASS\_NAME
|
|
40
32
|
|
|
41
33
|
> `readonly` **CLASS\_NAME**: `string`
|
|
@@ -198,7 +190,7 @@ Not found error if the blob cannot be found.
|
|
|
198
190
|
|
|
199
191
|
### update()
|
|
200
192
|
|
|
201
|
-
> **update**(`id`, `encodingFormat?`, `fileExtension?`, `metadata?`, `userIdentity
|
|
193
|
+
> **update**(`id`, `encodingFormat?`, `fileExtension?`, `metadata?`, `userIdentity?`): `Promise`\<`void`\>
|
|
202
194
|
|
|
203
195
|
Update the blob with metadata.
|
|
204
196
|
|
|
@@ -234,12 +226,6 @@ Data for the custom metadata as JSON-LD.
|
|
|
234
226
|
|
|
235
227
|
The user identity to use with storage operations.
|
|
236
228
|
|
|
237
|
-
##### nodeIdentity?
|
|
238
|
-
|
|
239
|
-
`string`
|
|
240
|
-
|
|
241
|
-
The node identity to use with storage operations.
|
|
242
|
-
|
|
243
229
|
#### Returns
|
|
244
230
|
|
|
245
231
|
`Promise`\<`void`\>
|
|
@@ -258,7 +244,7 @@ Not found error if the blob cannot be found.
|
|
|
258
244
|
|
|
259
245
|
### remove()
|
|
260
246
|
|
|
261
|
-
> **remove**(`id`, `userIdentity
|
|
247
|
+
> **remove**(`id`, `userIdentity?`): `Promise`\<`void`\>
|
|
262
248
|
|
|
263
249
|
Remove the blob.
|
|
264
250
|
|
|
@@ -276,12 +262,6 @@ The id of the blob to remove in urn format.
|
|
|
276
262
|
|
|
277
263
|
The user identity to use with storage operations.
|
|
278
264
|
|
|
279
|
-
##### nodeIdentity?
|
|
280
|
-
|
|
281
|
-
`string`
|
|
282
|
-
|
|
283
|
-
The node identity to use with storage operations.
|
|
284
|
-
|
|
285
265
|
#### Returns
|
|
286
266
|
|
|
287
267
|
`Promise`\<`void`\>
|
|
@@ -296,7 +276,7 @@ Nothing.
|
|
|
296
276
|
|
|
297
277
|
### query()
|
|
298
278
|
|
|
299
|
-
> **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `cursor?`, `pageSize?`, `userIdentity
|
|
279
|
+
> **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `cursor?`, `pageSize?`, `userIdentity?`): `Promise`\<`IBlobStorageEntryList`\>
|
|
300
280
|
|
|
301
281
|
Query all the blob storage entries which match the conditions.
|
|
302
282
|
|
|
@@ -338,12 +318,6 @@ The suggested number of entries to return in each chunk, in some scenarios can r
|
|
|
338
318
|
|
|
339
319
|
The user identity to use with storage operations.
|
|
340
320
|
|
|
341
|
-
##### nodeIdentity?
|
|
342
|
-
|
|
343
|
-
`string`
|
|
344
|
-
|
|
345
|
-
The node identity to use with storage operations.
|
|
346
|
-
|
|
347
321
|
#### Returns
|
|
348
322
|
|
|
349
323
|
`Promise`\<`IBlobStorageEntryList`\>
|
|
@@ -21,16 +21,8 @@ Defaults to the first entry in the factory if not provided.
|
|
|
21
21
|
|
|
22
22
|
***
|
|
23
23
|
|
|
24
|
-
###
|
|
24
|
+
### partitionPerUser?
|
|
25
25
|
|
|
26
|
-
> `optional` **
|
|
26
|
+
> `optional` **partitionPerUser**: `boolean`
|
|
27
27
|
|
|
28
|
-
Include the
|
|
29
|
-
|
|
30
|
-
***
|
|
31
|
-
|
|
32
|
-
### includeUserIdentity?
|
|
33
|
-
|
|
34
|
-
> `optional` **includeUserIdentity**: `boolean`
|
|
35
|
-
|
|
36
|
-
Include the user identity when performing storage operations, defaults to true.
|
|
28
|
+
Include the user identity when performing storage operations, allow partitioning per user, defaults to false.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/blob-storage-service",
|
|
3
|
-
"version": "0.0.1",
|
|
3
|
+
"version": "0.0.2-next.1",
|
|
4
4
|
"description": "Blob storage contract implementation and REST endpoint definitions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/api-models": "
|
|
18
|
-
"@twin.org/blob-storage-models": "
|
|
19
|
-
"@twin.org/core": "
|
|
20
|
-
"@twin.org/crypto": "
|
|
21
|
-
"@twin.org/data-json-ld": "
|
|
22
|
-
"@twin.org/entity": "
|
|
23
|
-
"@twin.org/entity-storage-models": "
|
|
24
|
-
"@twin.org/nameof": "
|
|
25
|
-
"@twin.org/standards-schema-org": "
|
|
26
|
-
"@twin.org/vault-models": "
|
|
27
|
-
"@twin.org/web": "
|
|
17
|
+
"@twin.org/api-models": "next",
|
|
18
|
+
"@twin.org/blob-storage-models": "0.0.2-next.1",
|
|
19
|
+
"@twin.org/core": "next",
|
|
20
|
+
"@twin.org/crypto": "next",
|
|
21
|
+
"@twin.org/data-json-ld": "next",
|
|
22
|
+
"@twin.org/entity": "next",
|
|
23
|
+
"@twin.org/entity-storage-models": "next",
|
|
24
|
+
"@twin.org/nameof": "next",
|
|
25
|
+
"@twin.org/standards-schema-org": "next",
|
|
26
|
+
"@twin.org/vault-models": "next",
|
|
27
|
+
"@twin.org/web": "next"
|
|
28
28
|
},
|
|
29
29
|
"main": "./dist/cjs/index.cjs",
|
|
30
30
|
"module": "./dist/esm/index.mjs",
|