@twin.org/blob-storage-service 0.0.1-next.24 → 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.
@@ -824,15 +824,21 @@ 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
844
  return dataJsonLd.JsonLdProcessor.compact(jsonLd, jsonLd["@context"]);
@@ -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
 
@@ -822,15 +822,21 @@ 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
842
  return JsonLdProcessor.compact(jsonLd, jsonLd["@context"]);
@@ -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.24
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.24",
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.24",
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",