@pod-os/core 0.32.0-rc.6b8d332.0 → 0.32.0-rc.9c5d5f9.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
@@ -15495,6 +15495,16 @@ var require_short_unique_id = __commonJS({
15495
15495
  }
15496
15496
  });
15497
15497
 
15498
+ // node_modules/rdflib/lib/tf-types.js
15499
+ var require_tf_types = __commonJS({
15500
+ "node_modules/rdflib/lib/tf-types.js"(exports) {
15501
+ "use strict";
15502
+ Object.defineProperty(exports, "__esModule", {
15503
+ value: true
15504
+ });
15505
+ }
15506
+ });
15507
+
15498
15508
  // ../node_modules/slugify/slugify.js
15499
15509
  var require_slugify = __commonJS({
15500
15510
  "../node_modules/slugify/slugify.js"(exports, module3) {
@@ -30044,6 +30054,17 @@ var Thing = class {
30044
30054
  values: values2[predicate4]
30045
30055
  }));
30046
30056
  }
30057
+ /**
30058
+ * Observe changes in literal values linked to this thing
30059
+ */
30060
+ observeLiterals() {
30061
+ return this.observeSubjectChanges({
30062
+ observes: () => this.literals(),
30063
+ compare: (prev2, curr) => prev2.length === curr.length && prev2.every(
30064
+ (rel2, i) => rel2.predicate === curr[i].predicate && rel2.values.length === curr[i].values.length && rel2.values.every((val, j) => val === curr[i].values[j])
30065
+ )
30066
+ });
30067
+ }
30047
30068
  /**
30048
30069
  * Returns all the unique links from this thing to other resources. This only includes named nodes and excludes rdf:type relations.
30049
30070
  */
@@ -30063,18 +30084,59 @@ var Thing = class {
30063
30084
  * Observe changes in links from this thing to other resources
30064
30085
  */
30065
30086
  observeRelations(predicate4) {
30087
+ return this.observeSubjectChanges({
30088
+ observes: () => this.relations(predicate4),
30089
+ compare: (prev2, curr) => prev2.length === curr.length && prev2.every(
30090
+ (rel2, i) => rel2.predicate === curr[i].predicate && rel2.uris.length === curr[i].uris.length
30091
+ )
30092
+ });
30093
+ }
30094
+ /**
30095
+ * Generic observable creator that watches the store for changes
30096
+ * that have this thing as a subject
30097
+ * @param args.observedValue Function that returns the current value to observe
30098
+ * @param args.compare Function that compares previous and current values for distinctUntilChanged
30099
+ */
30100
+ observeSubjectChanges(args) {
30101
+ const { observes, compare } = args;
30102
+ return this.observeChanges({
30103
+ filterFn: (quad3) => quad3.subject.value === this.uri,
30104
+ observes,
30105
+ compare
30106
+ });
30107
+ }
30108
+ /**
30109
+ * Generic observable creator that watches the store for changes
30110
+ * that have this thing as an object
30111
+ * @param args.observedValue Function that returns the current value to observe
30112
+ * @param args.compare Function that compares previous and current values for distinctUntilChanged
30113
+ */
30114
+ observeObjectChanges(args) {
30115
+ const { observes, compare } = args;
30116
+ return this.observeChanges({
30117
+ filterFn: (quad3) => quad3.object.value === this.uri,
30118
+ observes,
30119
+ compare
30120
+ });
30121
+ }
30122
+ /**
30123
+ * Generic observable creator that watches the store for changes
30124
+ * that match the given filter function before comparing values of this thing for possible changes.
30125
+ * The observable only emits a new value if relevant quads are added or removed, and in consequence
30126
+ * the observed value changes according to the compare function
30127
+ *
30128
+ * @param args.filterFn Filter for relevant quads
30129
+ * @param args.observedValue Function that returns the value to observe
30130
+ * @param args.compare Function that compares previous and current values
30131
+ */
30132
+ observeChanges(args) {
30133
+ const { observes, compare, filterFn } = args;
30066
30134
  return merge(this.store.additions$, this.store.removals$).pipe(
30067
- // Note: we assume that cost of filtering by the optional predicate is not worthwhile
30068
- filter((quad3) => quad3.subject.value === this.uri),
30135
+ filter(filterFn),
30069
30136
  debounceTime(250),
30070
- map(() => this.relations(predicate4)),
30071
- startWith(this.relations(predicate4)),
30072
- // Note: label is constructed from predicate and is therefore irrelevant to the comparison
30073
- distinctUntilChanged(
30074
- (prev2, curr) => prev2.length === curr.length && prev2.every(
30075
- (rel2, i) => rel2.predicate === curr[i].predicate && rel2.uris.length === curr[i].uris.length
30076
- )
30077
- )
30137
+ map(observes),
30138
+ startWith(observes()),
30139
+ distinctUntilChanged(compare)
30078
30140
  );
30079
30141
  }
30080
30142
  /**
@@ -30097,19 +30159,12 @@ var Thing = class {
30097
30159
  * Observe changes in links from other resources to this thing
30098
30160
  */
30099
30161
  observeReverseRelations(predicate4) {
30100
- return merge(this.store.additions$, this.store.removals$).pipe(
30101
- // Note: we assume that cost of filtering by the optional predicate is not worthwhile
30102
- filter((quad3) => quad3.object.value === this.uri),
30103
- debounceTime(250),
30104
- map(() => this.reverseRelations(predicate4)),
30105
- startWith(this.reverseRelations(predicate4)),
30106
- // Note: label is constructed from predicate and is therefore irrelevant to the comparison
30107
- distinctUntilChanged(
30108
- (prev2, curr) => prev2.length === curr.length && prev2.every(
30109
- (rel2, i) => rel2.predicate === curr[i].predicate && rel2.uris.length === curr[i].uris.length
30110
- )
30162
+ return this.observeObjectChanges({
30163
+ observes: () => this.reverseRelations(predicate4),
30164
+ compare: (prev2, curr) => prev2.length === curr.length && prev2.every(
30165
+ (rel2, i) => rel2.predicate === curr[i].predicate && rel2.uris.length === curr[i].uris.length
30111
30166
  )
30112
- );
30167
+ });
30113
30168
  }
30114
30169
  /**
30115
30170
  * Returns any value linked from this thing via one of the given predicates
@@ -30839,6 +30894,7 @@ var AssumeAlwaysOnline = class {
30839
30894
  };
30840
30895
 
30841
30896
  // src/Store.ts
30897
+ var import_tf_types = __toESM(require_tf_types(), 1);
30842
30898
  var Store = class {
30843
30899
  constructor(session4, offlineCache = new NoOfflineCache(), onlineStatus = new AssumeAlwaysOnline(), internalStore = graph()) {
30844
30900
  this.DESCRIBEDBY = iana("describedby");
@@ -53265,6 +53321,7 @@ var PodOS = class {
53265
53321
  return proposeAppsFor(thing);
53266
53322
  }
53267
53323
  };
53324
+ var export_Quad = import_tf_types.Quad;
53268
53325
  export {
53269
53326
  AnonymousSession,
53270
53327
  AssumeAlwaysOnline,
@@ -53281,6 +53338,7 @@ export {
53281
53338
  PictureGateway,
53282
53339
  PodOS,
53283
53340
  ProfileGateway,
53341
+ export_Quad as Quad,
53284
53342
  RdfDocument,
53285
53343
  SearchGateway,
53286
53344
  SearchIndex,
package/lib/index.js CHANGED
@@ -23899,6 +23899,16 @@ var PodOS = (() => {
23899
23899
  }
23900
23900
  });
23901
23901
 
23902
+ // node_modules/rdflib/lib/tf-types.js
23903
+ var require_tf_types = __commonJS({
23904
+ "node_modules/rdflib/lib/tf-types.js"(exports) {
23905
+ "use strict";
23906
+ Object.defineProperty(exports, "__esModule", {
23907
+ value: true
23908
+ });
23909
+ }
23910
+ });
23911
+
23902
23912
  // ../node_modules/slugify/slugify.js
23903
23913
  var require_slugify = __commonJS({
23904
23914
  "../node_modules/slugify/slugify.js"(exports, module3) {
@@ -23967,6 +23977,7 @@ var PodOS = (() => {
23967
23977
  PictureGateway: () => PictureGateway,
23968
23978
  PodOS: () => PodOS,
23969
23979
  ProfileGateway: () => ProfileGateway,
23980
+ Quad: () => import_tf_types.Quad,
23970
23981
  RdfDocument: () => RdfDocument,
23971
23982
  SearchGateway: () => SearchGateway,
23972
23983
  SearchIndex: () => SearchIndex,
@@ -38481,6 +38492,17 @@ _:patch
38481
38492
  values: values2[predicate4]
38482
38493
  }));
38483
38494
  }
38495
+ /**
38496
+ * Observe changes in literal values linked to this thing
38497
+ */
38498
+ observeLiterals() {
38499
+ return this.observeSubjectChanges({
38500
+ observes: () => this.literals(),
38501
+ compare: (prev2, curr) => prev2.length === curr.length && prev2.every(
38502
+ (rel2, i) => rel2.predicate === curr[i].predicate && rel2.values.length === curr[i].values.length && rel2.values.every((val, j) => val === curr[i].values[j])
38503
+ )
38504
+ });
38505
+ }
38484
38506
  /**
38485
38507
  * Returns all the unique links from this thing to other resources. This only includes named nodes and excludes rdf:type relations.
38486
38508
  */
@@ -38500,18 +38522,59 @@ _:patch
38500
38522
  * Observe changes in links from this thing to other resources
38501
38523
  */
38502
38524
  observeRelations(predicate4) {
38525
+ return this.observeSubjectChanges({
38526
+ observes: () => this.relations(predicate4),
38527
+ compare: (prev2, curr) => prev2.length === curr.length && prev2.every(
38528
+ (rel2, i) => rel2.predicate === curr[i].predicate && rel2.uris.length === curr[i].uris.length
38529
+ )
38530
+ });
38531
+ }
38532
+ /**
38533
+ * Generic observable creator that watches the store for changes
38534
+ * that have this thing as a subject
38535
+ * @param args.observedValue Function that returns the current value to observe
38536
+ * @param args.compare Function that compares previous and current values for distinctUntilChanged
38537
+ */
38538
+ observeSubjectChanges(args) {
38539
+ const { observes, compare } = args;
38540
+ return this.observeChanges({
38541
+ filterFn: (quad3) => quad3.subject.value === this.uri,
38542
+ observes,
38543
+ compare
38544
+ });
38545
+ }
38546
+ /**
38547
+ * Generic observable creator that watches the store for changes
38548
+ * that have this thing as an object
38549
+ * @param args.observedValue Function that returns the current value to observe
38550
+ * @param args.compare Function that compares previous and current values for distinctUntilChanged
38551
+ */
38552
+ observeObjectChanges(args) {
38553
+ const { observes, compare } = args;
38554
+ return this.observeChanges({
38555
+ filterFn: (quad3) => quad3.object.value === this.uri,
38556
+ observes,
38557
+ compare
38558
+ });
38559
+ }
38560
+ /**
38561
+ * Generic observable creator that watches the store for changes
38562
+ * that match the given filter function before comparing values of this thing for possible changes.
38563
+ * The observable only emits a new value if relevant quads are added or removed, and in consequence
38564
+ * the observed value changes according to the compare function
38565
+ *
38566
+ * @param args.filterFn Filter for relevant quads
38567
+ * @param args.observedValue Function that returns the value to observe
38568
+ * @param args.compare Function that compares previous and current values
38569
+ */
38570
+ observeChanges(args) {
38571
+ const { observes, compare, filterFn } = args;
38503
38572
  return merge(this.store.additions$, this.store.removals$).pipe(
38504
- // Note: we assume that cost of filtering by the optional predicate is not worthwhile
38505
- filter((quad3) => quad3.subject.value === this.uri),
38573
+ filter(filterFn),
38506
38574
  debounceTime(250),
38507
- map(() => this.relations(predicate4)),
38508
- startWith(this.relations(predicate4)),
38509
- // Note: label is constructed from predicate and is therefore irrelevant to the comparison
38510
- distinctUntilChanged(
38511
- (prev2, curr) => prev2.length === curr.length && prev2.every(
38512
- (rel2, i) => rel2.predicate === curr[i].predicate && rel2.uris.length === curr[i].uris.length
38513
- )
38514
- )
38575
+ map(observes),
38576
+ startWith(observes()),
38577
+ distinctUntilChanged(compare)
38515
38578
  );
38516
38579
  }
38517
38580
  /**
@@ -38534,19 +38597,12 @@ _:patch
38534
38597
  * Observe changes in links from other resources to this thing
38535
38598
  */
38536
38599
  observeReverseRelations(predicate4) {
38537
- return merge(this.store.additions$, this.store.removals$).pipe(
38538
- // Note: we assume that cost of filtering by the optional predicate is not worthwhile
38539
- filter((quad3) => quad3.object.value === this.uri),
38540
- debounceTime(250),
38541
- map(() => this.reverseRelations(predicate4)),
38542
- startWith(this.reverseRelations(predicate4)),
38543
- // Note: label is constructed from predicate and is therefore irrelevant to the comparison
38544
- distinctUntilChanged(
38545
- (prev2, curr) => prev2.length === curr.length && prev2.every(
38546
- (rel2, i) => rel2.predicate === curr[i].predicate && rel2.uris.length === curr[i].uris.length
38547
- )
38600
+ return this.observeObjectChanges({
38601
+ observes: () => this.reverseRelations(predicate4),
38602
+ compare: (prev2, curr) => prev2.length === curr.length && prev2.every(
38603
+ (rel2, i) => rel2.predicate === curr[i].predicate && rel2.uris.length === curr[i].uris.length
38548
38604
  )
38549
- );
38605
+ });
38550
38606
  }
38551
38607
  /**
38552
38608
  * Returns any value linked from this thing via one of the given predicates
@@ -39276,6 +39332,7 @@ _:patch
39276
39332
  };
39277
39333
 
39278
39334
  // src/Store.ts
39335
+ var import_tf_types = __toESM(require_tf_types(), 1);
39279
39336
  var Store = class {
39280
39337
  constructor(session4, offlineCache = new NoOfflineCache(), onlineStatus = new AssumeAlwaysOnline(), internalStore = graph()) {
39281
39338
  this.DESCRIBEDBY = iana("describedby");
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.32.0-rc.6b8d332.0",
4
+ "version": "0.32.0-rc.9c5d5f9.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./types/index.d.ts",
package/types/Store.d.ts CHANGED
@@ -5,6 +5,7 @@ import { ModuleConfig, PreferencesQuery, ProfileQuery, UpdateOperation } from "@
5
5
  import { OfflineCache, OnlineStatus } from "./offline-cache";
6
6
  import { Observable, Subject } from "rxjs";
7
7
  import { BlankNode, Quad, Quad_Graph, Quad_Object, Quad_Predicate, Quad_Subject, Term } from "rdflib/lib/tf-types";
8
+ export { Quad } from "rdflib/lib/tf-types";
8
9
  /**
9
10
  * The Store contains all data that is known locally.
10
11
  * It can be used to fetch additional data from the web and also update data and sync it back to editable resources.
@@ -41,6 +41,10 @@ export declare class Thing {
41
41
  * Returns all the literal values that are linked to this thing
42
42
  */
43
43
  literals(): Literal[];
44
+ /**
45
+ * Observe changes in literal values linked to this thing
46
+ */
47
+ observeLiterals(): Observable<Literal[]>;
44
48
  /**
45
49
  * Returns all the unique links from this thing to other resources. This only includes named nodes and excludes rdf:type relations.
46
50
  */
@@ -49,6 +53,31 @@ export declare class Thing {
49
53
  * Observe changes in links from this thing to other resources
50
54
  */
51
55
  observeRelations(predicate?: string): Observable<Relation[]>;
56
+ /**
57
+ * Generic observable creator that watches the store for changes
58
+ * that have this thing as a subject
59
+ * @param args.observedValue Function that returns the current value to observe
60
+ * @param args.compare Function that compares previous and current values for distinctUntilChanged
61
+ */
62
+ private observeSubjectChanges;
63
+ /**
64
+ * Generic observable creator that watches the store for changes
65
+ * that have this thing as an object
66
+ * @param args.observedValue Function that returns the current value to observe
67
+ * @param args.compare Function that compares previous and current values for distinctUntilChanged
68
+ */
69
+ private observeObjectChanges;
70
+ /**
71
+ * Generic observable creator that watches the store for changes
72
+ * that match the given filter function before comparing values of this thing for possible changes.
73
+ * The observable only emits a new value if relevant quads are added or removed, and in consequence
74
+ * the observed value changes according to the compare function
75
+ *
76
+ * @param args.filterFn Filter for relevant quads
77
+ * @param args.observedValue Function that returns the value to observe
78
+ * @param args.compare Function that compares previous and current values
79
+ */
80
+ private observeChanges;
52
81
  /**
53
82
  * Returns all the unique links from other resources to this thing
54
83
  */