@twin.org/blob-storage-service 0.0.1-next.23 → 0.0.1-next.25

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.
@@ -681,7 +681,7 @@ class BlobStorageService {
681
681
  }
682
682
  }
683
683
  const jsonLd = this.entryToJsonLd(blobEntry, returnBlob);
684
- return dataJsonLd.JsonLdProcessor.compact(jsonLd);
684
+ return dataJsonLd.JsonLdProcessor.compact(jsonLd, jsonLd["@context"]);
685
685
  }
686
686
  catch (error) {
687
687
  throw new core.GeneralError(this.CLASS_NAME, "getFailed", undefined, error);
@@ -824,18 +824,24 @@ class BlobStorageService {
824
824
  core.ObjectHelper.propertyDelete(entity, "nodeIdentity");
825
825
  core.ObjectHelper.propertyDelete(entity, "userIdentity");
826
826
  }
827
+ let context = [
828
+ blobStorageModels.BlobStorageTypes.ContextRoot,
829
+ blobStorageModels.BlobStorageTypes.ContextRootCommon,
830
+ standardsSchemaOrg.SchemaOrgTypes.ContextRoot
831
+ ];
832
+ const entriesJsonLd = [];
833
+ for (const entry of result.entities) {
834
+ // The entries are never Partial as we don't allow custom property requests.
835
+ entriesJsonLd.push(this.entryToJsonLd(entry));
836
+ context = dataJsonLd.JsonLdProcessor.combineContexts(context, entry.annotationObject?.["@context"]);
837
+ }
827
838
  const jsonLd = {
828
- "@context": [
829
- blobStorageModels.BlobStorageTypes.ContextRoot,
830
- blobStorageModels.BlobStorageTypes.ContextRootCommon,
831
- standardsSchemaOrg.SchemaOrgTypes.ContextRoot
832
- ],
839
+ "@context": context,
833
840
  type: blobStorageModels.BlobStorageTypes.EntryList,
834
- // The entries are never Partial as we don't allow custom property requests.
835
- entries: result.entities.map(entry => this.entryToJsonLd(entry)),
841
+ entries: entriesJsonLd,
836
842
  cursor: result.cursor
837
843
  };
838
- return dataJsonLd.JsonLdProcessor.compact(jsonLd);
844
+ return dataJsonLd.JsonLdProcessor.compact(jsonLd, jsonLd["@context"]);
839
845
  }
840
846
  /**
841
847
  * Get the connector from the uri.
@@ -913,12 +919,12 @@ class BlobStorageService {
913
919
  * @internal
914
920
  */
915
921
  entryToJsonLd(entry, blob) {
916
- return {
917
- "@context": [
922
+ const jsonLd = {
923
+ "@context": dataJsonLd.JsonLdProcessor.combineContexts([
918
924
  blobStorageModels.BlobStorageTypes.ContextRoot,
919
925
  blobStorageModels.BlobStorageTypes.ContextRootCommon,
920
926
  standardsSchemaOrg.SchemaOrgTypes.ContextRoot
921
- ],
927
+ ], entry?.annotationObject?.["@context"]),
922
928
  id: entry.id,
923
929
  type: blobStorageModels.BlobStorageTypes.Entry,
924
930
  dateCreated: entry.dateCreated,
@@ -930,6 +936,7 @@ class BlobStorageService {
930
936
  annotationObject: entry?.annotationObject,
931
937
  blob: core.Is.uint8Array(blob) ? core.Converter.bytesToBase64(blob) : undefined
932
938
  };
939
+ return jsonLd;
933
940
  }
934
941
  }
935
942
 
@@ -679,7 +679,7 @@ class BlobStorageService {
679
679
  }
680
680
  }
681
681
  const jsonLd = this.entryToJsonLd(blobEntry, returnBlob);
682
- return JsonLdProcessor.compact(jsonLd);
682
+ return JsonLdProcessor.compact(jsonLd, jsonLd["@context"]);
683
683
  }
684
684
  catch (error) {
685
685
  throw new GeneralError(this.CLASS_NAME, "getFailed", undefined, error);
@@ -822,18 +822,24 @@ class BlobStorageService {
822
822
  ObjectHelper.propertyDelete(entity, "nodeIdentity");
823
823
  ObjectHelper.propertyDelete(entity, "userIdentity");
824
824
  }
825
+ let context = [
826
+ BlobStorageTypes.ContextRoot,
827
+ BlobStorageTypes.ContextRootCommon,
828
+ SchemaOrgTypes.ContextRoot
829
+ ];
830
+ const entriesJsonLd = [];
831
+ for (const entry of result.entities) {
832
+ // The entries are never Partial as we don't allow custom property requests.
833
+ entriesJsonLd.push(this.entryToJsonLd(entry));
834
+ context = JsonLdProcessor.combineContexts(context, entry.annotationObject?.["@context"]);
835
+ }
825
836
  const jsonLd = {
826
- "@context": [
827
- BlobStorageTypes.ContextRoot,
828
- BlobStorageTypes.ContextRootCommon,
829
- SchemaOrgTypes.ContextRoot
830
- ],
837
+ "@context": context,
831
838
  type: BlobStorageTypes.EntryList,
832
- // The entries are never Partial as we don't allow custom property requests.
833
- entries: result.entities.map(entry => this.entryToJsonLd(entry)),
839
+ entries: entriesJsonLd,
834
840
  cursor: result.cursor
835
841
  };
836
- return JsonLdProcessor.compact(jsonLd);
842
+ return JsonLdProcessor.compact(jsonLd, jsonLd["@context"]);
837
843
  }
838
844
  /**
839
845
  * Get the connector from the uri.
@@ -911,12 +917,12 @@ class BlobStorageService {
911
917
  * @internal
912
918
  */
913
919
  entryToJsonLd(entry, blob) {
914
- return {
915
- "@context": [
920
+ const jsonLd = {
921
+ "@context": JsonLdProcessor.combineContexts([
916
922
  BlobStorageTypes.ContextRoot,
917
923
  BlobStorageTypes.ContextRootCommon,
918
924
  SchemaOrgTypes.ContextRoot
919
- ],
925
+ ], entry?.annotationObject?.["@context"]),
920
926
  id: entry.id,
921
927
  type: BlobStorageTypes.Entry,
922
928
  dateCreated: entry.dateCreated,
@@ -928,6 +934,7 @@ class BlobStorageService {
928
934
  annotationObject: entry?.annotationObject,
929
935
  blob: Is.uint8Array(blob) ? Converter.bytesToBase64(blob) : undefined
930
936
  };
937
+ return jsonLd;
931
938
  }
932
939
  }
933
940
 
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/blob-storage-service - Changelog
2
2
 
3
- ## v0.0.1-next.23
3
+ ## v0.0.1-next.25
4
4
 
5
5
  - Initial Release
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/blob-storage-service",
3
- "version": "0.0.1-next.23",
3
+ "version": "0.0.1-next.25",
4
4
  "description": "Blob storage contract implementation and REST endpoint definitions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@twin.org/api-models": "next",
18
- "@twin.org/blob-storage-models": "0.0.1-next.23",
18
+ "@twin.org/blob-storage-models": "0.0.1-next.25",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/crypto": "next",
21
21
  "@twin.org/data-json-ld": "next",