@pod-os/core 0.26.0 → 0.27.0-rc.7dc4621.0

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/index.js CHANGED
@@ -14395,18 +14395,18 @@ function pipeFromArray(fns) {
14395
14395
 
14396
14396
  // ../node_modules/rxjs/dist/esm5/internal/Observable.js
14397
14397
  var Observable = (function() {
14398
- function Observable4(subscribe) {
14398
+ function Observable5(subscribe) {
14399
14399
  if (subscribe) {
14400
14400
  this._subscribe = subscribe;
14401
14401
  }
14402
14402
  }
14403
- Observable4.prototype.lift = function(operator2) {
14404
- var observable2 = new Observable4();
14403
+ Observable5.prototype.lift = function(operator2) {
14404
+ var observable2 = new Observable5();
14405
14405
  observable2.source = this;
14406
14406
  observable2.operator = operator2;
14407
14407
  return observable2;
14408
14408
  };
14409
- Observable4.prototype.subscribe = function(observerOrNext, error4, complete2) {
14409
+ Observable5.prototype.subscribe = function(observerOrNext, error4, complete2) {
14410
14410
  var _this = this;
14411
14411
  var subscriber3 = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error4, complete2);
14412
14412
  errorContext(function() {
@@ -14415,14 +14415,14 @@ var Observable = (function() {
14415
14415
  });
14416
14416
  return subscriber3;
14417
14417
  };
14418
- Observable4.prototype._trySubscribe = function(sink) {
14418
+ Observable5.prototype._trySubscribe = function(sink) {
14419
14419
  try {
14420
14420
  return this._subscribe(sink);
14421
14421
  } catch (err2) {
14422
14422
  sink.error(err2);
14423
14423
  }
14424
14424
  };
14425
- Observable4.prototype.forEach = function(next4, promiseCtor) {
14425
+ Observable5.prototype.forEach = function(next4, promiseCtor) {
14426
14426
  var _this = this;
14427
14427
  promiseCtor = getPromiseCtor(promiseCtor);
14428
14428
  return new promiseCtor(function(resolve, reject) {
@@ -14441,21 +14441,21 @@ var Observable = (function() {
14441
14441
  _this.subscribe(subscriber3);
14442
14442
  });
14443
14443
  };
14444
- Observable4.prototype._subscribe = function(subscriber3) {
14444
+ Observable5.prototype._subscribe = function(subscriber3) {
14445
14445
  var _a;
14446
14446
  return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber3);
14447
14447
  };
14448
- Observable4.prototype[observable] = function() {
14448
+ Observable5.prototype[observable] = function() {
14449
14449
  return this;
14450
14450
  };
14451
- Observable4.prototype.pipe = function() {
14451
+ Observable5.prototype.pipe = function() {
14452
14452
  var operations = [];
14453
14453
  for (var _i = 0; _i < arguments.length; _i++) {
14454
14454
  operations[_i] = arguments[_i];
14455
14455
  }
14456
14456
  return pipeFromArray(operations)(this);
14457
14457
  };
14458
- Observable4.prototype.toPromise = function(promiseCtor) {
14458
+ Observable5.prototype.toPromise = function(promiseCtor) {
14459
14459
  var _this = this;
14460
14460
  promiseCtor = getPromiseCtor(promiseCtor);
14461
14461
  return new promiseCtor(function(resolve, reject) {
@@ -14469,10 +14469,10 @@ var Observable = (function() {
14469
14469
  });
14470
14470
  });
14471
14471
  };
14472
- Observable4.create = function(subscribe) {
14473
- return new Observable4(subscribe);
14472
+ Observable5.create = function(subscribe) {
14473
+ return new Observable5(subscribe);
14474
14474
  };
14475
- return Observable4;
14475
+ return Observable5;
14476
14476
  })();
14477
14477
  function getPromiseCtor(promiseCtor) {
14478
14478
  var _a;
@@ -27869,6 +27869,7 @@ var flow = Namespace("http://www.w3.org/2005/01/wf/flow#");
27869
27869
  // src/thing/accumulateSubjects.ts
27870
27870
  var accumulateSubjects = (accumulator, current3) => {
27871
27871
  const existing = accumulator[current3.predicate.uri];
27872
+ if (existing && existing.includes(current3.subject.value)) return accumulator;
27872
27873
  return {
27873
27874
  ...accumulator,
27874
27875
  [current3.predicate.uri]: existing ? [...existing, current3.subject.value] : [current3.subject.value]
@@ -27878,6 +27879,7 @@ var accumulateSubjects = (accumulator, current3) => {
27878
27879
  // src/thing/accumulateValues.ts
27879
27880
  var accumulateValues = (accumulator, current3) => {
27880
27881
  const existing = accumulator[current3.predicate.uri];
27882
+ if (existing && existing.includes(current3.object.value)) return accumulator;
27881
27883
  return {
27882
27884
  ...accumulator,
27883
27885
  [current3.predicate.uri]: existing ? [...existing, current3.object.value] : [current3.object.value]
@@ -27971,7 +27973,7 @@ var Thing = class {
27971
27973
  }));
27972
27974
  }
27973
27975
  /**
27974
- * Returns all the links from this thing to other resources
27976
+ * Returns all the unique links from this thing to other resources. This only includes named nodes and excludes rdf:type relations.
27975
27977
  */
27976
27978
  relations(predicate4) {
27977
27979
  const statements = this.store.statementsMatching(
@@ -27986,7 +27988,25 @@ var Thing = class {
27986
27988
  }));
27987
27989
  }
27988
27990
  /**
27989
- * Returns all the links from other resources to this thing
27991
+ * Observe changes in links from this thing to other resources
27992
+ */
27993
+ observeRelations(predicate4) {
27994
+ return merge(this.store.additions$, this.store.removals$).pipe(
27995
+ // Note: we assume that cost of filtering by the optional predicate is not worthwhile
27996
+ filter((quad3) => quad3.subject.value === this.uri),
27997
+ debounceTime(250),
27998
+ map(() => this.relations(predicate4)),
27999
+ startWith(this.relations(predicate4)),
28000
+ // Note: label is constructed from predicate and is therefore irrelevant to the comparison
28001
+ distinctUntilChanged(
28002
+ (prev2, curr) => prev2.length === curr.length && prev2.every(
28003
+ (rel2, i) => rel2.predicate === curr[i].predicate && rel2.uris.length === curr[i].uris.length
28004
+ )
28005
+ )
28006
+ );
28007
+ }
28008
+ /**
28009
+ * Returns all the unique links from other resources to this thing
27990
28010
  */
27991
28011
  reverseRelations(predicate4) {
27992
28012
  const statements = this.store.statementsMatching(
@@ -28001,6 +28021,24 @@ var Thing = class {
28001
28021
  uris: values2[predicate5]
28002
28022
  }));
28003
28023
  }
28024
+ /**
28025
+ * Observe changes in links from other resources to this thing
28026
+ */
28027
+ observeReverseRelations(predicate4) {
28028
+ return merge(this.store.additions$, this.store.removals$).pipe(
28029
+ // Note: we assume that cost of filtering by the optional predicate is not worthwhile
28030
+ filter((quad3) => quad3.object.value === this.uri),
28031
+ debounceTime(250),
28032
+ map(() => this.reverseRelations(predicate4)),
28033
+ startWith(this.reverseRelations(predicate4)),
28034
+ // Note: label is constructed from predicate and is therefore irrelevant to the comparison
28035
+ distinctUntilChanged(
28036
+ (prev2, curr) => prev2.length === curr.length && prev2.every(
28037
+ (rel2, i) => rel2.predicate === curr[i].predicate && rel2.uris.length === curr[i].uris.length
28038
+ )
28039
+ )
28040
+ );
28041
+ }
28004
28042
  /**
28005
28043
  * Returns any value linked from this thing via one of the given predicates
28006
28044
  * @param predicateUris
@@ -28088,6 +28126,19 @@ var Thing = class {
28088
28126
  label: labelForType(uri6)
28089
28127
  }));
28090
28128
  }
28129
+ /**
28130
+ * Observe changes to the list of RDF types for this thing
28131
+ */
28132
+ observeTypes() {
28133
+ return merge(this.store.additions$, this.store.removals$).pipe(
28134
+ filter(
28135
+ (quad3) => quad3.subject.value === this.uri && quad3.predicate.value === "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" || quad3.predicate.value === "http://www.w3.org/2000/01/rdf-schema#subClassOf"
28136
+ ),
28137
+ map(() => this.types()),
28138
+ startWith(this.types()),
28139
+ distinctUntilChanged((prev2, curr) => prev2.length === curr.length)
28140
+ );
28141
+ }
28091
28142
  /**
28092
28143
  * Returns all attachments linked to this thing
28093
28144
  */
@@ -28154,7 +28205,7 @@ var LdpContainer = class extends Thing {
28154
28205
  observeContains() {
28155
28206
  return merge(this.store.additions$, this.store.removals$).pipe(
28156
28207
  filter(
28157
- (quad3) => quad3.graph.value == this.uri && quad3.predicate.value == "http://www.w3.org/ns/ldp#contains"
28208
+ (quad3) => quad3.graph.value === this.uri && quad3.predicate.value === "http://www.w3.org/ns/ldp#contains"
28158
28209
  ),
28159
28210
  debounceTime(250),
28160
28211
  map(() => this.contains()),
@@ -28808,7 +28859,7 @@ var Store = class {
28808
28859
  ),
28809
28860
  map(() => this.findMembers(classUri)),
28810
28861
  startWith(this.findMembers(classUri)),
28811
- distinctUntilChanged((prev2, curr) => prev2.length == curr.length)
28862
+ distinctUntilChanged((prev2, curr) => prev2.length === curr.length)
28812
28863
  );
28813
28864
  }
28814
28865
  /**
@@ -28895,7 +28946,7 @@ var Store = class {
28895
28946
  graph3,
28896
28947
  justOne
28897
28948
  );
28898
- if (statements.length == 0) return null;
28949
+ if (statements.length === 0) return null;
28899
28950
  if (!subject8) {
28900
28951
  return statements[0].subject;
28901
28952
  } else if (!predicate4) {
package/lib/index.js CHANGED
@@ -22832,18 +22832,18 @@ var PodOS = (() => {
22832
22832
 
22833
22833
  // ../node_modules/rxjs/dist/esm5/internal/Observable.js
22834
22834
  var Observable = (function() {
22835
- function Observable4(subscribe) {
22835
+ function Observable5(subscribe) {
22836
22836
  if (subscribe) {
22837
22837
  this._subscribe = subscribe;
22838
22838
  }
22839
22839
  }
22840
- Observable4.prototype.lift = function(operator2) {
22841
- var observable2 = new Observable4();
22840
+ Observable5.prototype.lift = function(operator2) {
22841
+ var observable2 = new Observable5();
22842
22842
  observable2.source = this;
22843
22843
  observable2.operator = operator2;
22844
22844
  return observable2;
22845
22845
  };
22846
- Observable4.prototype.subscribe = function(observerOrNext, error4, complete2) {
22846
+ Observable5.prototype.subscribe = function(observerOrNext, error4, complete2) {
22847
22847
  var _this = this;
22848
22848
  var subscriber3 = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error4, complete2);
22849
22849
  errorContext(function() {
@@ -22852,14 +22852,14 @@ var PodOS = (() => {
22852
22852
  });
22853
22853
  return subscriber3;
22854
22854
  };
22855
- Observable4.prototype._trySubscribe = function(sink) {
22855
+ Observable5.prototype._trySubscribe = function(sink) {
22856
22856
  try {
22857
22857
  return this._subscribe(sink);
22858
22858
  } catch (err2) {
22859
22859
  sink.error(err2);
22860
22860
  }
22861
22861
  };
22862
- Observable4.prototype.forEach = function(next4, promiseCtor) {
22862
+ Observable5.prototype.forEach = function(next4, promiseCtor) {
22863
22863
  var _this = this;
22864
22864
  promiseCtor = getPromiseCtor(promiseCtor);
22865
22865
  return new promiseCtor(function(resolve, reject) {
@@ -22878,21 +22878,21 @@ var PodOS = (() => {
22878
22878
  _this.subscribe(subscriber3);
22879
22879
  });
22880
22880
  };
22881
- Observable4.prototype._subscribe = function(subscriber3) {
22881
+ Observable5.prototype._subscribe = function(subscriber3) {
22882
22882
  var _a;
22883
22883
  return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber3);
22884
22884
  };
22885
- Observable4.prototype[observable] = function() {
22885
+ Observable5.prototype[observable] = function() {
22886
22886
  return this;
22887
22887
  };
22888
- Observable4.prototype.pipe = function() {
22888
+ Observable5.prototype.pipe = function() {
22889
22889
  var operations = [];
22890
22890
  for (var _i = 0; _i < arguments.length; _i++) {
22891
22891
  operations[_i] = arguments[_i];
22892
22892
  }
22893
22893
  return pipeFromArray(operations)(this);
22894
22894
  };
22895
- Observable4.prototype.toPromise = function(promiseCtor) {
22895
+ Observable5.prototype.toPromise = function(promiseCtor) {
22896
22896
  var _this = this;
22897
22897
  promiseCtor = getPromiseCtor(promiseCtor);
22898
22898
  return new promiseCtor(function(resolve, reject) {
@@ -22906,10 +22906,10 @@ var PodOS = (() => {
22906
22906
  });
22907
22907
  });
22908
22908
  };
22909
- Observable4.create = function(subscribe) {
22910
- return new Observable4(subscribe);
22909
+ Observable5.create = function(subscribe) {
22910
+ return new Observable5(subscribe);
22911
22911
  };
22912
- return Observable4;
22912
+ return Observable5;
22913
22913
  })();
22914
22914
  function getPromiseCtor(promiseCtor) {
22915
22915
  var _a;
@@ -36306,6 +36306,7 @@ _:patch
36306
36306
  // src/thing/accumulateSubjects.ts
36307
36307
  var accumulateSubjects = (accumulator, current3) => {
36308
36308
  const existing = accumulator[current3.predicate.uri];
36309
+ if (existing && existing.includes(current3.subject.value)) return accumulator;
36309
36310
  return {
36310
36311
  ...accumulator,
36311
36312
  [current3.predicate.uri]: existing ? [...existing, current3.subject.value] : [current3.subject.value]
@@ -36315,6 +36316,7 @@ _:patch
36315
36316
  // src/thing/accumulateValues.ts
36316
36317
  var accumulateValues = (accumulator, current3) => {
36317
36318
  const existing = accumulator[current3.predicate.uri];
36319
+ if (existing && existing.includes(current3.object.value)) return accumulator;
36318
36320
  return {
36319
36321
  ...accumulator,
36320
36322
  [current3.predicate.uri]: existing ? [...existing, current3.object.value] : [current3.object.value]
@@ -36408,7 +36410,7 @@ _:patch
36408
36410
  }));
36409
36411
  }
36410
36412
  /**
36411
- * Returns all the links from this thing to other resources
36413
+ * Returns all the unique links from this thing to other resources. This only includes named nodes and excludes rdf:type relations.
36412
36414
  */
36413
36415
  relations(predicate4) {
36414
36416
  const statements = this.store.statementsMatching(
@@ -36423,7 +36425,25 @@ _:patch
36423
36425
  }));
36424
36426
  }
36425
36427
  /**
36426
- * Returns all the links from other resources to this thing
36428
+ * Observe changes in links from this thing to other resources
36429
+ */
36430
+ observeRelations(predicate4) {
36431
+ return merge(this.store.additions$, this.store.removals$).pipe(
36432
+ // Note: we assume that cost of filtering by the optional predicate is not worthwhile
36433
+ filter((quad3) => quad3.subject.value === this.uri),
36434
+ debounceTime(250),
36435
+ map(() => this.relations(predicate4)),
36436
+ startWith(this.relations(predicate4)),
36437
+ // Note: label is constructed from predicate and is therefore irrelevant to the comparison
36438
+ distinctUntilChanged(
36439
+ (prev2, curr) => prev2.length === curr.length && prev2.every(
36440
+ (rel2, i) => rel2.predicate === curr[i].predicate && rel2.uris.length === curr[i].uris.length
36441
+ )
36442
+ )
36443
+ );
36444
+ }
36445
+ /**
36446
+ * Returns all the unique links from other resources to this thing
36427
36447
  */
36428
36448
  reverseRelations(predicate4) {
36429
36449
  const statements = this.store.statementsMatching(
@@ -36438,6 +36458,24 @@ _:patch
36438
36458
  uris: values2[predicate5]
36439
36459
  }));
36440
36460
  }
36461
+ /**
36462
+ * Observe changes in links from other resources to this thing
36463
+ */
36464
+ observeReverseRelations(predicate4) {
36465
+ return merge(this.store.additions$, this.store.removals$).pipe(
36466
+ // Note: we assume that cost of filtering by the optional predicate is not worthwhile
36467
+ filter((quad3) => quad3.object.value === this.uri),
36468
+ debounceTime(250),
36469
+ map(() => this.reverseRelations(predicate4)),
36470
+ startWith(this.reverseRelations(predicate4)),
36471
+ // Note: label is constructed from predicate and is therefore irrelevant to the comparison
36472
+ distinctUntilChanged(
36473
+ (prev2, curr) => prev2.length === curr.length && prev2.every(
36474
+ (rel2, i) => rel2.predicate === curr[i].predicate && rel2.uris.length === curr[i].uris.length
36475
+ )
36476
+ )
36477
+ );
36478
+ }
36441
36479
  /**
36442
36480
  * Returns any value linked from this thing via one of the given predicates
36443
36481
  * @param predicateUris
@@ -36525,6 +36563,19 @@ _:patch
36525
36563
  label: labelForType(uri6)
36526
36564
  }));
36527
36565
  }
36566
+ /**
36567
+ * Observe changes to the list of RDF types for this thing
36568
+ */
36569
+ observeTypes() {
36570
+ return merge(this.store.additions$, this.store.removals$).pipe(
36571
+ filter(
36572
+ (quad3) => quad3.subject.value === this.uri && quad3.predicate.value === "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" || quad3.predicate.value === "http://www.w3.org/2000/01/rdf-schema#subClassOf"
36573
+ ),
36574
+ map(() => this.types()),
36575
+ startWith(this.types()),
36576
+ distinctUntilChanged((prev2, curr) => prev2.length === curr.length)
36577
+ );
36578
+ }
36528
36579
  /**
36529
36580
  * Returns all attachments linked to this thing
36530
36581
  */
@@ -36591,7 +36642,7 @@ _:patch
36591
36642
  observeContains() {
36592
36643
  return merge(this.store.additions$, this.store.removals$).pipe(
36593
36644
  filter(
36594
- (quad3) => quad3.graph.value == this.uri && quad3.predicate.value == "http://www.w3.org/ns/ldp#contains"
36645
+ (quad3) => quad3.graph.value === this.uri && quad3.predicate.value === "http://www.w3.org/ns/ldp#contains"
36595
36646
  ),
36596
36647
  debounceTime(250),
36597
36648
  map(() => this.contains()),
@@ -37245,7 +37296,7 @@ _:patch
37245
37296
  ),
37246
37297
  map(() => this.findMembers(classUri)),
37247
37298
  startWith(this.findMembers(classUri)),
37248
- distinctUntilChanged((prev2, curr) => prev2.length == curr.length)
37299
+ distinctUntilChanged((prev2, curr) => prev2.length === curr.length)
37249
37300
  );
37250
37301
  }
37251
37302
  /**
@@ -37332,7 +37383,7 @@ _:patch
37332
37383
  graph3,
37333
37384
  justOne
37334
37385
  );
37335
- if (statements.length == 0) return null;
37386
+ if (statements.length === 0) return null;
37336
37387
  if (!subject8) {
37337
37388
  return statements[0].subject;
37338
37389
  } else if (!predicate4) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pod-os/core",
3
3
  "description": "Core module of PodOS",
4
- "version": "0.26.0",
4
+ "version": "0.27.0-rc.7dc4621.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./types/index.d.ts",
@@ -1,4 +1,5 @@
1
1
  import { Store } from "../Store";
2
+ import { Observable } from "rxjs";
2
3
  export interface Literal {
3
4
  predicate: string;
4
5
  label: string;
@@ -41,13 +42,21 @@ export declare class Thing {
41
42
  */
42
43
  literals(): Literal[];
43
44
  /**
44
- * Returns all the links from this thing to other resources
45
+ * Returns all the unique links from this thing to other resources. This only includes named nodes and excludes rdf:type relations.
45
46
  */
46
47
  relations(predicate?: string): Relation[];
47
48
  /**
48
- * Returns all the links from other resources to this thing
49
+ * Observe changes in links from this thing to other resources
50
+ */
51
+ observeRelations(predicate?: string): Observable<Relation[]>;
52
+ /**
53
+ * Returns all the unique links from other resources to this thing
49
54
  */
50
55
  reverseRelations(predicate?: string): Relation[];
56
+ /**
57
+ * Observe changes in links from other resources to this thing
58
+ */
59
+ observeReverseRelations(predicate?: string): Observable<Relation[]>;
51
60
  /**
52
61
  * Returns any value linked from this thing via one of the given predicates
53
62
  * @param predicateUris
@@ -73,6 +82,10 @@ export declare class Thing {
73
82
  * Retrieves a list of RDF types for this thing.
74
83
  */
75
84
  types(): RdfType[];
85
+ /**
86
+ * Observe changes to the list of RDF types for this thing
87
+ */
88
+ observeTypes(): Observable<RdfType[]>;
76
89
  /**
77
90
  * Returns all attachments linked to this thing
78
91
  */
@@ -7,7 +7,5 @@ interface Accumulator {
7
7
  * @param accumulator - Target javascript object to accumulate the values to
8
8
  * @param current - A statement with data to add to the accumulator
9
9
  */
10
- export declare const accumulateSubjects: (accumulator: Accumulator, current: Statement) => {
11
- [x: string]: string[];
12
- };
10
+ export declare const accumulateSubjects: (accumulator: Accumulator, current: Statement) => Accumulator;
13
11
  export {};
@@ -7,7 +7,5 @@ interface Accumulator {
7
7
  * @param accumulator - Target object to accumulate the values to
8
8
  * @param current - A statement with data to add to the object
9
9
  */
10
- export declare const accumulateValues: (accumulator: Accumulator, current: Statement) => {
11
- [x: string]: string[];
12
- };
10
+ export declare const accumulateValues: (accumulator: Accumulator, current: Statement) => Accumulator;
13
11
  export {};