@startinblox/core 0.18.0-beta.1 → 0.18.0-beta.2

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.
@@ -50,6 +50,7 @@ class Store {
50
50
  this.subscriptionVirtualContainersIndex = new Map();
51
51
  this.loadingList = new Set();
52
52
  this.headers = {
53
+ 'Accept': 'application/ld+json',
53
54
  'Content-Type': 'application/ld+json',
54
55
  'Cache-Control': 'must-revalidate'
55
56
  };
@@ -236,7 +237,10 @@ class Store {
236
237
  credentials: 'include'
237
238
  });
238
239
  const resourceProxy = store.get(id);
239
- const clientContext = resourceProxy ? resourceProxy.clientContext : resource['@context'];
240
+ const clientContext = resourceProxy ? {
241
+ ...resourceProxy.clientContext,
242
+ ...resource['@context']
243
+ } : resource['@context'];
240
244
  this.clearCache(id);
241
245
  await this.getData(id, clientContext, '', resource);
242
246
  return {
@@ -548,8 +552,7 @@ _Symbol$toPrimitive = Symbol.toPrimitive;
548
552
  class CustomGetter {
549
553
  // search attributes to give to server
550
554
 
551
- constructor(resourceId, resource, clientContext) {
552
- let serverContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
555
+ constructor(resourceId, resource, clientContext, serverContext) {
553
556
  let parentId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
554
557
  let serverPagination = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
555
558
  let serverSearch = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {};
@@ -613,7 +616,10 @@ class CustomGetter {
613
616
  let value;
614
617
  if (!this.isFullResource()) {
615
618
  // if resource is not complete, fetch it first
616
- await this.getResource(this.resourceId, this.clientContext, this.parentId);
619
+ await this.getResource(this.resourceId, {
620
+ ...this.clientContext,
621
+ ...this.serverContext
622
+ }, this.parentId);
617
623
  }
618
624
  while (true) {
619
625
  try {
@@ -628,11 +634,17 @@ class CustomGetter {
628
634
  if (path2.length === 0) {
629
635
  // end of the path
630
636
  if (!value || !value['@id']) return value; // no value or not a resource
631
- return await this.getResource(value['@id'], this.clientContext, this.parentId || this.resourceId); // return complete resource
637
+ return await this.getResource(value['@id'], {
638
+ ...this.clientContext,
639
+ ...this.serverContext
640
+ }, this.parentId || this.resourceId); // return complete resource
632
641
  }
633
642
 
634
643
  if (!value) return undefined;
635
- let resource = await this.getResource(value['@id'], this.clientContext, this.parentId || this.resourceId);
644
+ let resource = await this.getResource(value['@id'], {
645
+ ...this.clientContext,
646
+ ...this.serverContext
647
+ }, this.parentId || this.resourceId);
636
648
  store.subscribeResourceTo(this.resourceId, value['@id']);
637
649
  return resource ? await resource[path2.join('.')] : undefined; // return value
638
650
  }
@@ -720,7 +732,10 @@ class CustomGetter {
720
732
  let permissions = this.resource[permissionPredicate];
721
733
  if (!permissions) {
722
734
  // if no permission, re-fetch data
723
- await this.getResource(this.resourceId, this.clientContext, this.parentId, true);
735
+ await this.getResource(this.resourceId, {
736
+ ...this.clientContext,
737
+ ...this.serverContext
738
+ }, this.parentId, true);
724
739
  permissions = this.resource[permissionPredicate];
725
740
  }
726
741
  return permissions ? permissions.map(perm => ContextParser.expandTerm(perm.mode['@type'], this.serverContext, true)) : [];
@@ -733,13 +748,22 @@ class CustomGetter {
733
748
  store.clearCache(this.resourceId);
734
749
  }
735
750
  getExpandedPredicate(property) {
736
- return ContextParser.expandTerm(property, this.clientContext, true);
751
+ return ContextParser.expandTerm(property, {
752
+ ...this.clientContext,
753
+ ...this.serverContext
754
+ }, true);
737
755
  }
738
756
  getCompactedPredicate(property) {
739
- return ContextParser.compactIri(property, this.clientContext, true);
757
+ return ContextParser.compactIri(property, {
758
+ ...this.clientContext,
759
+ ...this.serverContext
760
+ }, true);
740
761
  }
741
762
  getCompactedIri(id) {
742
- return ContextParser.compactIri(id, this.clientContext);
763
+ return ContextParser.compactIri(id, {
764
+ ...this.clientContext,
765
+ ...this.serverContext
766
+ });
743
767
  }
744
768
  toString() {
745
769
  return this.getCompactedIri(this.resource['@id']);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/core",
3
- "version": "0.18.0-beta.1",
3
+ "version": "0.18.0-beta.2",
4
4
  "description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",