@pod-os/core 0.34.0-rc.a31f2a2.0 → 0.34.0-rc.aaf1e4e.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 +152 -63
- package/lib/index.js +152 -63
- package/package.json +4 -4
- package/types/Store.d.ts +1 -1
- package/types/index.d.ts +8 -4
- package/types/search/SearchGateway.d.ts +23 -4
- package/types/search/SearchGateway.spec.d.ts +1 -0
- package/types/search/SearchIndex.d.ts +4 -3
package/dist/index.js
CHANGED
|
@@ -17179,6 +17179,40 @@ function from(input2, scheduler) {
|
|
|
17179
17179
|
return scheduler ? scheduled(input2, scheduler) : innerFrom(input2);
|
|
17180
17180
|
}
|
|
17181
17181
|
|
|
17182
|
+
// ../node_modules/rxjs/dist/esm5/internal/util/EmptyError.js
|
|
17183
|
+
var EmptyError = createErrorClass(function(_super) {
|
|
17184
|
+
return function EmptyErrorImpl() {
|
|
17185
|
+
_super(this);
|
|
17186
|
+
this.name = "EmptyError";
|
|
17187
|
+
this.message = "no elements in sequence";
|
|
17188
|
+
};
|
|
17189
|
+
});
|
|
17190
|
+
|
|
17191
|
+
// ../node_modules/rxjs/dist/esm5/internal/lastValueFrom.js
|
|
17192
|
+
function lastValueFrom(source10, config2) {
|
|
17193
|
+
var hasConfig = typeof config2 === "object";
|
|
17194
|
+
return new Promise(function(resolve, reject) {
|
|
17195
|
+
var _hasValue = false;
|
|
17196
|
+
var _value2;
|
|
17197
|
+
source10.subscribe({
|
|
17198
|
+
next: function(value8) {
|
|
17199
|
+
_value2 = value8;
|
|
17200
|
+
_hasValue = true;
|
|
17201
|
+
},
|
|
17202
|
+
error: reject,
|
|
17203
|
+
complete: function() {
|
|
17204
|
+
if (_hasValue) {
|
|
17205
|
+
resolve(_value2);
|
|
17206
|
+
} else if (hasConfig) {
|
|
17207
|
+
resolve(config2.defaultValue);
|
|
17208
|
+
} else {
|
|
17209
|
+
reject(new EmptyError());
|
|
17210
|
+
}
|
|
17211
|
+
}
|
|
17212
|
+
});
|
|
17213
|
+
});
|
|
17214
|
+
}
|
|
17215
|
+
|
|
17182
17216
|
// ../node_modules/rxjs/dist/esm5/internal/operators/map.js
|
|
17183
17217
|
function map(project, thisArg) {
|
|
17184
17218
|
return operate(function(source10, subscriber3) {
|
|
@@ -18428,7 +18462,8 @@ var Mime = class {
|
|
|
18428
18462
|
getAllExtensions(type5) {
|
|
18429
18463
|
if (typeof type5 !== "string")
|
|
18430
18464
|
return null;
|
|
18431
|
-
|
|
18465
|
+
type5 = type5.split(";")[0].trim().toLowerCase();
|
|
18466
|
+
return __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type5) ?? null;
|
|
18432
18467
|
}
|
|
18433
18468
|
_freeze() {
|
|
18434
18469
|
this.define = () => {
|
|
@@ -20100,7 +20135,7 @@ var Serializer = class _Serializer {
|
|
|
20100
20135
|
return self2.atomicTermToN3(x);
|
|
20101
20136
|
}
|
|
20102
20137
|
var list = x.elements;
|
|
20103
|
-
var rest3 = kb.sym(rdfns + "
|
|
20138
|
+
var rest3 = kb.sym(rdfns + "nil");
|
|
20104
20139
|
for (var i2 = list.length - 1; i2 >= 0; i2--) {
|
|
20105
20140
|
var bnode = factory.blankNode();
|
|
20106
20141
|
str += termToNT(bnode) + " " + termToNT(kb.sym(rdfns + "first")) + " " + termToNT(list[i2]) + ".\n";
|
|
@@ -20410,7 +20445,7 @@ var Serializer = class _Serializer {
|
|
|
20410
20445
|
var canSplit = !namespaceIsBaseDir && !forbidDotLocal && namesp.length > minNamespaceLength && this.isValidPNLocal(localid);
|
|
20411
20446
|
if (canSplit) {
|
|
20412
20447
|
if (this.defaultNamespace && this.defaultNamespace === namesp && this.flags.indexOf("d") < 0) {
|
|
20413
|
-
if (this.flags.indexOf("k") >= 0 && this.
|
|
20448
|
+
if (this.flags.indexOf("k") >= 0 && this.keywords.indexOf(localid) < 0) {
|
|
20414
20449
|
return localid;
|
|
20415
20450
|
}
|
|
20416
20451
|
return ":" + localid;
|
|
@@ -27433,7 +27468,7 @@ function parse2(str, kb, base2, contentType4 = "text/turtle", callback) {
|
|
|
27433
27468
|
contentType4 = contentType4 || TurtleContentType;
|
|
27434
27469
|
contentType4 = contentType4.split(";")[0];
|
|
27435
27470
|
try {
|
|
27436
|
-
if (contentType4 === N3ContentType || contentType4 === TurtleContentType) {
|
|
27471
|
+
if (contentType4 === N3ContentType || contentType4 === TurtleContentType || contentType4 === NTriplesContentType) {
|
|
27437
27472
|
var p = n3parser_default(kb, kb, base2, base2, null, null, "", null);
|
|
27438
27473
|
p.loadBuf(str);
|
|
27439
27474
|
executeCallback();
|
|
@@ -27479,7 +27514,8 @@ function parse2(str, kb, base2, contentType4 = "text/turtle", callback) {
|
|
|
27479
27514
|
"application/sparql-update-single-match": true,
|
|
27480
27515
|
"application/ld+json": true,
|
|
27481
27516
|
"application/nquads": true,
|
|
27482
|
-
"application/n-quads": true
|
|
27517
|
+
"application/n-quads": true,
|
|
27518
|
+
"application/n-triples": true
|
|
27483
27519
|
};
|
|
27484
27520
|
function executeCallback() {
|
|
27485
27521
|
if (callback) {
|
|
@@ -28013,15 +28049,24 @@ var Fetcher = class _Fetcher {
|
|
|
28013
28049
|
options = this.initFetchOptions(docuri, options);
|
|
28014
28050
|
const meta2 = this.appNode;
|
|
28015
28051
|
const kb = this.store;
|
|
28016
|
-
const requests = kb.statementsMatching(void 0, this.ns.link("requestedURI"), kb.
|
|
28052
|
+
const requests = kb.statementsMatching(void 0, this.ns.link("requestedURI"), kb.rdfFactory.literal(docuri), meta2).map((st2) => st2.subject);
|
|
28053
|
+
let answered = false;
|
|
28054
|
+
let usableAnswer = false;
|
|
28017
28055
|
for (const request2 of requests) {
|
|
28018
28056
|
const response6 = kb.any(request2, this.ns.link("response"), null, meta2);
|
|
28019
|
-
if (response6
|
|
28020
|
-
|
|
28021
|
-
kb.remove(quad3);
|
|
28022
|
-
options.force = true;
|
|
28023
|
-
options.clearPreviousData = true;
|
|
28057
|
+
if (response6 == null) {
|
|
28058
|
+
continue;
|
|
28024
28059
|
}
|
|
28060
|
+
answered = true;
|
|
28061
|
+
const outOfDate = kb.anyJS(response6, this.ns.link("outOfDate"), null, meta2);
|
|
28062
|
+
if (!outOfDate) {
|
|
28063
|
+
usableAnswer = true;
|
|
28064
|
+
break;
|
|
28065
|
+
}
|
|
28066
|
+
}
|
|
28067
|
+
if (answered && !usableAnswer) {
|
|
28068
|
+
options.force = true;
|
|
28069
|
+
options.clearPreviousData = true;
|
|
28025
28070
|
}
|
|
28026
28071
|
const initialisedOptions = this.initFetchOptions(docuri, options);
|
|
28027
28072
|
return this.pendingFetchPromise(docuri, initialisedOptions.baseURI, initialisedOptions);
|
|
@@ -30574,16 +30619,20 @@ var SearchIndex = class {
|
|
|
30574
30619
|
this.index = this.rebuild().index;
|
|
30575
30620
|
}
|
|
30576
30621
|
/**
|
|
30577
|
-
* Recreates the search index with the current data from all label indexes
|
|
30622
|
+
* Recreates the search index with the current data from all label indexes.
|
|
30623
|
+
* Optionally replaces the captured label indexes before rebuilding.
|
|
30578
30624
|
*/
|
|
30579
|
-
rebuild() {
|
|
30580
|
-
|
|
30625
|
+
rebuild(labelIndexes) {
|
|
30626
|
+
if (labelIndexes) {
|
|
30627
|
+
this.labelIndexes = labelIndexes;
|
|
30628
|
+
}
|
|
30629
|
+
const captured = this.labelIndexes;
|
|
30581
30630
|
this.index = (0, import_lunr.default)(function() {
|
|
30582
30631
|
this.ref("uri");
|
|
30583
30632
|
this.field("uri");
|
|
30584
30633
|
this.field("label");
|
|
30585
30634
|
this.metadataWhitelist = ["position"];
|
|
30586
|
-
const items2 =
|
|
30635
|
+
const items2 = captured.flatMap((it) => it.getIndexedItems());
|
|
30587
30636
|
items2.forEach((item4) => {
|
|
30588
30637
|
this.add({
|
|
30589
30638
|
uri: item4.uri,
|
|
@@ -30782,30 +30831,69 @@ var addToLabelIndex = (thing, labelIndex) => {
|
|
|
30782
30831
|
|
|
30783
30832
|
// src/search/SearchGateway.ts
|
|
30784
30833
|
var SearchGateway = class {
|
|
30785
|
-
constructor(store) {
|
|
30834
|
+
constructor(store, session4, profileGateway) {
|
|
30786
30835
|
this.store = store;
|
|
30836
|
+
this.session = session4;
|
|
30837
|
+
this.profileGateway = profileGateway;
|
|
30787
30838
|
}
|
|
30788
30839
|
/**
|
|
30789
|
-
*
|
|
30790
|
-
*
|
|
30840
|
+
* Build a search index on demand.
|
|
30841
|
+
*
|
|
30842
|
+
* While logged in, the profile is resolved from the current session's webId
|
|
30843
|
+
* and the index is built from the profile's label indexes and cached, so that
|
|
30844
|
+
* repeated calls return the same instance.
|
|
30845
|
+
*
|
|
30846
|
+
* While logged out, a fresh empty index is returned that is NOT cached —
|
|
30847
|
+
* the next call after login is a cache miss and builds.
|
|
30791
30848
|
*/
|
|
30792
|
-
async buildSearchIndex(
|
|
30793
|
-
const
|
|
30794
|
-
|
|
30795
|
-
|
|
30796
|
-
|
|
30797
|
-
|
|
30798
|
-
|
|
30799
|
-
|
|
30849
|
+
async buildSearchIndex() {
|
|
30850
|
+
const session4 = await lastValueFrom(
|
|
30851
|
+
this.session.observeSession().pipe(take(1))
|
|
30852
|
+
);
|
|
30853
|
+
if (!session4.isLoggedIn) {
|
|
30854
|
+
return new SearchIndex([]);
|
|
30855
|
+
}
|
|
30856
|
+
const webId = session4.webId;
|
|
30857
|
+
const profile2 = await this.profileGateway.fetchProfile(webId);
|
|
30858
|
+
if (!this.cached) {
|
|
30859
|
+
const labelIndexUris = profile2.getPrivateLabelIndexes();
|
|
30860
|
+
this.cached = await this.buildIndex(labelIndexUris);
|
|
30800
30861
|
}
|
|
30801
|
-
return
|
|
30862
|
+
return this.cached;
|
|
30863
|
+
}
|
|
30864
|
+
/**
|
|
30865
|
+
* Empties the cached search index in place and drops the cache reference, so
|
|
30866
|
+
* that consumers already holding the instance see an empty index immediately
|
|
30867
|
+
* and the next call to {@link buildSearchIndex} builds a new index.
|
|
30868
|
+
*/
|
|
30869
|
+
clear() {
|
|
30870
|
+
this.cached?.clear();
|
|
30871
|
+
this.cached = void 0;
|
|
30872
|
+
}
|
|
30873
|
+
async buildIndex(labelIndexUris) {
|
|
30874
|
+
const labelIndex = await this.resolveLabelIndexes(labelIndexUris);
|
|
30875
|
+
return new SearchIndex(labelIndex);
|
|
30876
|
+
}
|
|
30877
|
+
async resolveLabelIndexes(labelIndexUris) {
|
|
30878
|
+
await this.store.fetchAll(labelIndexUris);
|
|
30879
|
+
return labelIndexUris.map(
|
|
30880
|
+
(uri6) => this.store.get(uri6).assume(LabelIndex)
|
|
30881
|
+
);
|
|
30802
30882
|
}
|
|
30803
30883
|
async addToLabelIndex(thing, labelIndex) {
|
|
30804
30884
|
await this.store.executeUpdate(addToLabelIndex(thing, labelIndex));
|
|
30885
|
+
if (this.cached) {
|
|
30886
|
+
this.cached.rebuild();
|
|
30887
|
+
}
|
|
30805
30888
|
}
|
|
30806
30889
|
async createDefaultLabelIndex(profile2) {
|
|
30807
30890
|
const operation3 = createDefaultLabelIndex(profile2);
|
|
30808
30891
|
await this.store.executeUpdate(operation3);
|
|
30892
|
+
if (this.cached) {
|
|
30893
|
+
this.cached.rebuild(
|
|
30894
|
+
await this.resolveLabelIndexes(profile2.getPrivateLabelIndexes())
|
|
30895
|
+
);
|
|
30896
|
+
}
|
|
30809
30897
|
return this.store.get(operation3.uri).assume(LabelIndex);
|
|
30810
30898
|
}
|
|
30811
30899
|
};
|
|
@@ -30920,11 +31008,6 @@ var Store = class {
|
|
|
30920
31008
|
*/
|
|
30921
31009
|
async fetch(uri6) {
|
|
30922
31010
|
const response6 = await this.fetcher.load(namedNode2(uri6), {
|
|
30923
|
-
// force fetching due to
|
|
30924
|
-
// https://github.com/linkeddata/rdflib.js/issues/247
|
|
30925
|
-
// and
|
|
30926
|
-
// https://github.com/linkeddata/rdflib.js/issues/441
|
|
30927
|
-
force: true,
|
|
30928
31011
|
// explicitly omit credentials due to
|
|
30929
31012
|
// https://github.com/pod-os/PodOS/issues/17
|
|
30930
31013
|
credentials: "omit"
|
|
@@ -30938,7 +31021,6 @@ var Store = class {
|
|
|
30938
31021
|
if (descriptionResourceUri) {
|
|
30939
31022
|
try {
|
|
30940
31023
|
await this.fetcher.load(namedNode2(descriptionResourceUri.value), {
|
|
30941
|
-
force: true,
|
|
30942
31024
|
credentials: "omit"
|
|
30943
31025
|
});
|
|
30944
31026
|
} catch {
|
|
@@ -31034,30 +31116,28 @@ var Store = class {
|
|
|
31034
31116
|
return docUrl;
|
|
31035
31117
|
}
|
|
31036
31118
|
async addNewThing(uri6, name9, type5) {
|
|
31037
|
-
|
|
31038
|
-
|
|
31039
|
-
|
|
31040
|
-
|
|
31041
|
-
|
|
31042
|
-
|
|
31043
|
-
|
|
31044
|
-
|
|
31045
|
-
|
|
31046
|
-
|
|
31047
|
-
|
|
31048
|
-
|
|
31049
|
-
|
|
31050
|
-
|
|
31051
|
-
)
|
|
31052
|
-
|
|
31053
|
-
|
|
31054
|
-
|
|
31055
|
-
|
|
31056
|
-
|
|
31057
|
-
|
|
31058
|
-
|
|
31059
|
-
}
|
|
31060
|
-
);
|
|
31119
|
+
const typeInsertion = type5 ? [
|
|
31120
|
+
st(
|
|
31121
|
+
namedNode2(uri6),
|
|
31122
|
+
namedNode2("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
|
|
31123
|
+
namedNode2(type5),
|
|
31124
|
+
namedNode2(uri6).doc()
|
|
31125
|
+
)
|
|
31126
|
+
] : [];
|
|
31127
|
+
const insertions = [
|
|
31128
|
+
...typeInsertion,
|
|
31129
|
+
st(
|
|
31130
|
+
namedNode2(uri6),
|
|
31131
|
+
namedNode2("http://www.w3.org/2000/01/rdf-schema#label"),
|
|
31132
|
+
lit(name9),
|
|
31133
|
+
namedNode2(uri6).doc()
|
|
31134
|
+
)
|
|
31135
|
+
];
|
|
31136
|
+
await this.updater.update([], insertions, void 0, false, {
|
|
31137
|
+
// explicitly omit credentials due to
|
|
31138
|
+
// https://github.com/pod-os/PodOS/issues/17
|
|
31139
|
+
credentials: "omit"
|
|
31140
|
+
});
|
|
31061
31141
|
}
|
|
31062
31142
|
async executeUpdate(operation3) {
|
|
31063
31143
|
await executeUpdate(this.fetcher, this.updater, operation3);
|
|
@@ -53198,14 +53278,18 @@ var PodOS = class {
|
|
|
53198
53278
|
onlineStatus,
|
|
53199
53279
|
internalStore
|
|
53200
53280
|
);
|
|
53201
|
-
this.
|
|
53281
|
+
this.profileGateway = new ProfileGateway(this.store);
|
|
53282
|
+
this.searchGateway = new SearchGateway(
|
|
53283
|
+
this.store,
|
|
53284
|
+
this.session,
|
|
53285
|
+
this.profileGateway
|
|
53286
|
+
);
|
|
53202
53287
|
this.fileFetcher = new FileFetcher(this.session);
|
|
53203
53288
|
this.fileGateway = new FileGateway(this.store, this.fileFetcher);
|
|
53204
53289
|
this.attachmentGateway = new AttachmentGateway(this.fileGateway);
|
|
53205
53290
|
this.pictureGateway = new PictureGateway(this.fileGateway);
|
|
53206
53291
|
this.flagAuthorizationMetaDataOnSessionChange();
|
|
53207
53292
|
this.uriService = new UriService(this.store);
|
|
53208
|
-
this.profileGateway = new ProfileGateway(this.store);
|
|
53209
53293
|
}
|
|
53210
53294
|
/*
|
|
53211
53295
|
Flagging authorization metadata is necessary every time the user
|
|
@@ -53218,6 +53302,7 @@ var PodOS = class {
|
|
|
53218
53302
|
this.session.observeSession().pipe(
|
|
53219
53303
|
tap(() => {
|
|
53220
53304
|
this.store.flagAuthorizationMetadata();
|
|
53305
|
+
this.searchGateway.clear();
|
|
53221
53306
|
})
|
|
53222
53307
|
).subscribe();
|
|
53223
53308
|
}
|
|
@@ -53293,11 +53378,15 @@ var PodOS = class {
|
|
|
53293
53378
|
return this.profileGateway.fetchProfile(webId);
|
|
53294
53379
|
}
|
|
53295
53380
|
/**
|
|
53296
|
-
*
|
|
53297
|
-
*
|
|
53381
|
+
* Build the search index on demand.
|
|
53382
|
+
*
|
|
53383
|
+
* While logged in, the index is built from the logged-in user's label indexes
|
|
53384
|
+
* and cached, so repeated calls return the same instance.
|
|
53385
|
+
*
|
|
53386
|
+
* While logged out, a fresh empty index is returned that is not cached.
|
|
53298
53387
|
*/
|
|
53299
|
-
async buildSearchIndex(
|
|
53300
|
-
return this.searchGateway.buildSearchIndex(
|
|
53388
|
+
async buildSearchIndex() {
|
|
53389
|
+
return this.searchGateway.buildSearchIndex();
|
|
53301
53390
|
}
|
|
53302
53391
|
logout() {
|
|
53303
53392
|
this.offlineCache.clear();
|
package/lib/index.js
CHANGED
|
@@ -25621,6 +25621,40 @@ var PodOS = (() => {
|
|
|
25621
25621
|
return scheduler ? scheduled(input2, scheduler) : innerFrom(input2);
|
|
25622
25622
|
}
|
|
25623
25623
|
|
|
25624
|
+
// ../node_modules/rxjs/dist/esm5/internal/util/EmptyError.js
|
|
25625
|
+
var EmptyError = createErrorClass(function(_super) {
|
|
25626
|
+
return function EmptyErrorImpl() {
|
|
25627
|
+
_super(this);
|
|
25628
|
+
this.name = "EmptyError";
|
|
25629
|
+
this.message = "no elements in sequence";
|
|
25630
|
+
};
|
|
25631
|
+
});
|
|
25632
|
+
|
|
25633
|
+
// ../node_modules/rxjs/dist/esm5/internal/lastValueFrom.js
|
|
25634
|
+
function lastValueFrom(source10, config2) {
|
|
25635
|
+
var hasConfig = typeof config2 === "object";
|
|
25636
|
+
return new Promise(function(resolve, reject) {
|
|
25637
|
+
var _hasValue = false;
|
|
25638
|
+
var _value2;
|
|
25639
|
+
source10.subscribe({
|
|
25640
|
+
next: function(value8) {
|
|
25641
|
+
_value2 = value8;
|
|
25642
|
+
_hasValue = true;
|
|
25643
|
+
},
|
|
25644
|
+
error: reject,
|
|
25645
|
+
complete: function() {
|
|
25646
|
+
if (_hasValue) {
|
|
25647
|
+
resolve(_value2);
|
|
25648
|
+
} else if (hasConfig) {
|
|
25649
|
+
resolve(config2.defaultValue);
|
|
25650
|
+
} else {
|
|
25651
|
+
reject(new EmptyError());
|
|
25652
|
+
}
|
|
25653
|
+
}
|
|
25654
|
+
});
|
|
25655
|
+
});
|
|
25656
|
+
}
|
|
25657
|
+
|
|
25624
25658
|
// ../node_modules/rxjs/dist/esm5/internal/operators/map.js
|
|
25625
25659
|
function map(project, thisArg) {
|
|
25626
25660
|
return operate(function(source10, subscriber3) {
|
|
@@ -26870,7 +26904,8 @@ var PodOS = (() => {
|
|
|
26870
26904
|
getAllExtensions(type5) {
|
|
26871
26905
|
if (typeof type5 !== "string")
|
|
26872
26906
|
return null;
|
|
26873
|
-
|
|
26907
|
+
type5 = type5.split(";")[0].trim().toLowerCase();
|
|
26908
|
+
return __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type5) ?? null;
|
|
26874
26909
|
}
|
|
26875
26910
|
_freeze() {
|
|
26876
26911
|
this.define = () => {
|
|
@@ -28542,7 +28577,7 @@ var PodOS = (() => {
|
|
|
28542
28577
|
return self2.atomicTermToN3(x);
|
|
28543
28578
|
}
|
|
28544
28579
|
var list = x.elements;
|
|
28545
|
-
var rest3 = kb.sym(rdfns + "
|
|
28580
|
+
var rest3 = kb.sym(rdfns + "nil");
|
|
28546
28581
|
for (var i2 = list.length - 1; i2 >= 0; i2--) {
|
|
28547
28582
|
var bnode = factory.blankNode();
|
|
28548
28583
|
str += termToNT(bnode) + " " + termToNT(kb.sym(rdfns + "first")) + " " + termToNT(list[i2]) + ".\n";
|
|
@@ -28852,7 +28887,7 @@ var PodOS = (() => {
|
|
|
28852
28887
|
var canSplit = !namespaceIsBaseDir && !forbidDotLocal && namesp.length > minNamespaceLength && this.isValidPNLocal(localid);
|
|
28853
28888
|
if (canSplit) {
|
|
28854
28889
|
if (this.defaultNamespace && this.defaultNamespace === namesp && this.flags.indexOf("d") < 0) {
|
|
28855
|
-
if (this.flags.indexOf("k") >= 0 && this.
|
|
28890
|
+
if (this.flags.indexOf("k") >= 0 && this.keywords.indexOf(localid) < 0) {
|
|
28856
28891
|
return localid;
|
|
28857
28892
|
}
|
|
28858
28893
|
return ":" + localid;
|
|
@@ -35875,7 +35910,7 @@ var PodOS = (() => {
|
|
|
35875
35910
|
contentType4 = contentType4 || TurtleContentType;
|
|
35876
35911
|
contentType4 = contentType4.split(";")[0];
|
|
35877
35912
|
try {
|
|
35878
|
-
if (contentType4 === N3ContentType || contentType4 === TurtleContentType) {
|
|
35913
|
+
if (contentType4 === N3ContentType || contentType4 === TurtleContentType || contentType4 === NTriplesContentType) {
|
|
35879
35914
|
var p = n3parser_default(kb, kb, base2, base2, null, null, "", null);
|
|
35880
35915
|
p.loadBuf(str);
|
|
35881
35916
|
executeCallback();
|
|
@@ -35921,7 +35956,8 @@ var PodOS = (() => {
|
|
|
35921
35956
|
"application/sparql-update-single-match": true,
|
|
35922
35957
|
"application/ld+json": true,
|
|
35923
35958
|
"application/nquads": true,
|
|
35924
|
-
"application/n-quads": true
|
|
35959
|
+
"application/n-quads": true,
|
|
35960
|
+
"application/n-triples": true
|
|
35925
35961
|
};
|
|
35926
35962
|
function executeCallback() {
|
|
35927
35963
|
if (callback) {
|
|
@@ -36455,15 +36491,24 @@ var PodOS = (() => {
|
|
|
36455
36491
|
options = this.initFetchOptions(docuri, options);
|
|
36456
36492
|
const meta2 = this.appNode;
|
|
36457
36493
|
const kb = this.store;
|
|
36458
|
-
const requests = kb.statementsMatching(void 0, this.ns.link("requestedURI"), kb.
|
|
36494
|
+
const requests = kb.statementsMatching(void 0, this.ns.link("requestedURI"), kb.rdfFactory.literal(docuri), meta2).map((st2) => st2.subject);
|
|
36495
|
+
let answered = false;
|
|
36496
|
+
let usableAnswer = false;
|
|
36459
36497
|
for (const request2 of requests) {
|
|
36460
36498
|
const response6 = kb.any(request2, this.ns.link("response"), null, meta2);
|
|
36461
|
-
if (response6
|
|
36462
|
-
|
|
36463
|
-
kb.remove(quad3);
|
|
36464
|
-
options.force = true;
|
|
36465
|
-
options.clearPreviousData = true;
|
|
36499
|
+
if (response6 == null) {
|
|
36500
|
+
continue;
|
|
36466
36501
|
}
|
|
36502
|
+
answered = true;
|
|
36503
|
+
const outOfDate = kb.anyJS(response6, this.ns.link("outOfDate"), null, meta2);
|
|
36504
|
+
if (!outOfDate) {
|
|
36505
|
+
usableAnswer = true;
|
|
36506
|
+
break;
|
|
36507
|
+
}
|
|
36508
|
+
}
|
|
36509
|
+
if (answered && !usableAnswer) {
|
|
36510
|
+
options.force = true;
|
|
36511
|
+
options.clearPreviousData = true;
|
|
36467
36512
|
}
|
|
36468
36513
|
const initialisedOptions = this.initFetchOptions(docuri, options);
|
|
36469
36514
|
return this.pendingFetchPromise(docuri, initialisedOptions.baseURI, initialisedOptions);
|
|
@@ -39016,16 +39061,20 @@ _:patch
|
|
|
39016
39061
|
this.index = this.rebuild().index;
|
|
39017
39062
|
}
|
|
39018
39063
|
/**
|
|
39019
|
-
* Recreates the search index with the current data from all label indexes
|
|
39064
|
+
* Recreates the search index with the current data from all label indexes.
|
|
39065
|
+
* Optionally replaces the captured label indexes before rebuilding.
|
|
39020
39066
|
*/
|
|
39021
|
-
rebuild() {
|
|
39022
|
-
|
|
39067
|
+
rebuild(labelIndexes) {
|
|
39068
|
+
if (labelIndexes) {
|
|
39069
|
+
this.labelIndexes = labelIndexes;
|
|
39070
|
+
}
|
|
39071
|
+
const captured = this.labelIndexes;
|
|
39023
39072
|
this.index = (0, import_lunr.default)(function() {
|
|
39024
39073
|
this.ref("uri");
|
|
39025
39074
|
this.field("uri");
|
|
39026
39075
|
this.field("label");
|
|
39027
39076
|
this.metadataWhitelist = ["position"];
|
|
39028
|
-
const items2 =
|
|
39077
|
+
const items2 = captured.flatMap((it) => it.getIndexedItems());
|
|
39029
39078
|
items2.forEach((item4) => {
|
|
39030
39079
|
this.add({
|
|
39031
39080
|
uri: item4.uri,
|
|
@@ -39224,30 +39273,69 @@ _:patch
|
|
|
39224
39273
|
|
|
39225
39274
|
// src/search/SearchGateway.ts
|
|
39226
39275
|
var SearchGateway = class {
|
|
39227
|
-
constructor(store) {
|
|
39276
|
+
constructor(store, session4, profileGateway) {
|
|
39228
39277
|
this.store = store;
|
|
39278
|
+
this.session = session4;
|
|
39279
|
+
this.profileGateway = profileGateway;
|
|
39229
39280
|
}
|
|
39230
39281
|
/**
|
|
39231
|
-
*
|
|
39232
|
-
*
|
|
39282
|
+
* Build a search index on demand.
|
|
39283
|
+
*
|
|
39284
|
+
* While logged in, the profile is resolved from the current session's webId
|
|
39285
|
+
* and the index is built from the profile's label indexes and cached, so that
|
|
39286
|
+
* repeated calls return the same instance.
|
|
39287
|
+
*
|
|
39288
|
+
* While logged out, a fresh empty index is returned that is NOT cached —
|
|
39289
|
+
* the next call after login is a cache miss and builds.
|
|
39233
39290
|
*/
|
|
39234
|
-
async buildSearchIndex(
|
|
39235
|
-
const
|
|
39236
|
-
|
|
39237
|
-
|
|
39238
|
-
|
|
39239
|
-
|
|
39240
|
-
|
|
39241
|
-
|
|
39291
|
+
async buildSearchIndex() {
|
|
39292
|
+
const session4 = await lastValueFrom(
|
|
39293
|
+
this.session.observeSession().pipe(take(1))
|
|
39294
|
+
);
|
|
39295
|
+
if (!session4.isLoggedIn) {
|
|
39296
|
+
return new SearchIndex([]);
|
|
39297
|
+
}
|
|
39298
|
+
const webId = session4.webId;
|
|
39299
|
+
const profile2 = await this.profileGateway.fetchProfile(webId);
|
|
39300
|
+
if (!this.cached) {
|
|
39301
|
+
const labelIndexUris = profile2.getPrivateLabelIndexes();
|
|
39302
|
+
this.cached = await this.buildIndex(labelIndexUris);
|
|
39242
39303
|
}
|
|
39243
|
-
return
|
|
39304
|
+
return this.cached;
|
|
39305
|
+
}
|
|
39306
|
+
/**
|
|
39307
|
+
* Empties the cached search index in place and drops the cache reference, so
|
|
39308
|
+
* that consumers already holding the instance see an empty index immediately
|
|
39309
|
+
* and the next call to {@link buildSearchIndex} builds a new index.
|
|
39310
|
+
*/
|
|
39311
|
+
clear() {
|
|
39312
|
+
this.cached?.clear();
|
|
39313
|
+
this.cached = void 0;
|
|
39314
|
+
}
|
|
39315
|
+
async buildIndex(labelIndexUris) {
|
|
39316
|
+
const labelIndex = await this.resolveLabelIndexes(labelIndexUris);
|
|
39317
|
+
return new SearchIndex(labelIndex);
|
|
39318
|
+
}
|
|
39319
|
+
async resolveLabelIndexes(labelIndexUris) {
|
|
39320
|
+
await this.store.fetchAll(labelIndexUris);
|
|
39321
|
+
return labelIndexUris.map(
|
|
39322
|
+
(uri6) => this.store.get(uri6).assume(LabelIndex)
|
|
39323
|
+
);
|
|
39244
39324
|
}
|
|
39245
39325
|
async addToLabelIndex(thing, labelIndex) {
|
|
39246
39326
|
await this.store.executeUpdate(addToLabelIndex(thing, labelIndex));
|
|
39327
|
+
if (this.cached) {
|
|
39328
|
+
this.cached.rebuild();
|
|
39329
|
+
}
|
|
39247
39330
|
}
|
|
39248
39331
|
async createDefaultLabelIndex(profile2) {
|
|
39249
39332
|
const operation3 = createDefaultLabelIndex(profile2);
|
|
39250
39333
|
await this.store.executeUpdate(operation3);
|
|
39334
|
+
if (this.cached) {
|
|
39335
|
+
this.cached.rebuild(
|
|
39336
|
+
await this.resolveLabelIndexes(profile2.getPrivateLabelIndexes())
|
|
39337
|
+
);
|
|
39338
|
+
}
|
|
39251
39339
|
return this.store.get(operation3.uri).assume(LabelIndex);
|
|
39252
39340
|
}
|
|
39253
39341
|
};
|
|
@@ -39362,11 +39450,6 @@ _:patch
|
|
|
39362
39450
|
*/
|
|
39363
39451
|
async fetch(uri6) {
|
|
39364
39452
|
const response6 = await this.fetcher.load(namedNode2(uri6), {
|
|
39365
|
-
// force fetching due to
|
|
39366
|
-
// https://github.com/linkeddata/rdflib.js/issues/247
|
|
39367
|
-
// and
|
|
39368
|
-
// https://github.com/linkeddata/rdflib.js/issues/441
|
|
39369
|
-
force: true,
|
|
39370
39453
|
// explicitly omit credentials due to
|
|
39371
39454
|
// https://github.com/pod-os/PodOS/issues/17
|
|
39372
39455
|
credentials: "omit"
|
|
@@ -39380,7 +39463,6 @@ _:patch
|
|
|
39380
39463
|
if (descriptionResourceUri) {
|
|
39381
39464
|
try {
|
|
39382
39465
|
await this.fetcher.load(namedNode2(descriptionResourceUri.value), {
|
|
39383
|
-
force: true,
|
|
39384
39466
|
credentials: "omit"
|
|
39385
39467
|
});
|
|
39386
39468
|
} catch {
|
|
@@ -39476,30 +39558,28 @@ _:patch
|
|
|
39476
39558
|
return docUrl;
|
|
39477
39559
|
}
|
|
39478
39560
|
async addNewThing(uri6, name9, type5) {
|
|
39479
|
-
|
|
39480
|
-
|
|
39481
|
-
|
|
39482
|
-
|
|
39483
|
-
|
|
39484
|
-
|
|
39485
|
-
|
|
39486
|
-
|
|
39487
|
-
|
|
39488
|
-
|
|
39489
|
-
|
|
39490
|
-
|
|
39491
|
-
|
|
39492
|
-
|
|
39493
|
-
)
|
|
39494
|
-
|
|
39495
|
-
|
|
39496
|
-
|
|
39497
|
-
|
|
39498
|
-
|
|
39499
|
-
|
|
39500
|
-
|
|
39501
|
-
}
|
|
39502
|
-
);
|
|
39561
|
+
const typeInsertion = type5 ? [
|
|
39562
|
+
st(
|
|
39563
|
+
namedNode2(uri6),
|
|
39564
|
+
namedNode2("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
|
|
39565
|
+
namedNode2(type5),
|
|
39566
|
+
namedNode2(uri6).doc()
|
|
39567
|
+
)
|
|
39568
|
+
] : [];
|
|
39569
|
+
const insertions = [
|
|
39570
|
+
...typeInsertion,
|
|
39571
|
+
st(
|
|
39572
|
+
namedNode2(uri6),
|
|
39573
|
+
namedNode2("http://www.w3.org/2000/01/rdf-schema#label"),
|
|
39574
|
+
lit(name9),
|
|
39575
|
+
namedNode2(uri6).doc()
|
|
39576
|
+
)
|
|
39577
|
+
];
|
|
39578
|
+
await this.updater.update([], insertions, void 0, false, {
|
|
39579
|
+
// explicitly omit credentials due to
|
|
39580
|
+
// https://github.com/pod-os/PodOS/issues/17
|
|
39581
|
+
credentials: "omit"
|
|
39582
|
+
});
|
|
39503
39583
|
}
|
|
39504
39584
|
async executeUpdate(operation3) {
|
|
39505
39585
|
await executeUpdate(this.fetcher, this.updater, operation3);
|
|
@@ -61640,14 +61720,18 @@ _:patch
|
|
|
61640
61720
|
onlineStatus,
|
|
61641
61721
|
internalStore
|
|
61642
61722
|
);
|
|
61643
|
-
this.
|
|
61723
|
+
this.profileGateway = new ProfileGateway(this.store);
|
|
61724
|
+
this.searchGateway = new SearchGateway(
|
|
61725
|
+
this.store,
|
|
61726
|
+
this.session,
|
|
61727
|
+
this.profileGateway
|
|
61728
|
+
);
|
|
61644
61729
|
this.fileFetcher = new FileFetcher(this.session);
|
|
61645
61730
|
this.fileGateway = new FileGateway(this.store, this.fileFetcher);
|
|
61646
61731
|
this.attachmentGateway = new AttachmentGateway(this.fileGateway);
|
|
61647
61732
|
this.pictureGateway = new PictureGateway(this.fileGateway);
|
|
61648
61733
|
this.flagAuthorizationMetaDataOnSessionChange();
|
|
61649
61734
|
this.uriService = new UriService(this.store);
|
|
61650
|
-
this.profileGateway = new ProfileGateway(this.store);
|
|
61651
61735
|
}
|
|
61652
61736
|
/*
|
|
61653
61737
|
Flagging authorization metadata is necessary every time the user
|
|
@@ -61660,6 +61744,7 @@ _:patch
|
|
|
61660
61744
|
this.session.observeSession().pipe(
|
|
61661
61745
|
tap(() => {
|
|
61662
61746
|
this.store.flagAuthorizationMetadata();
|
|
61747
|
+
this.searchGateway.clear();
|
|
61663
61748
|
})
|
|
61664
61749
|
).subscribe();
|
|
61665
61750
|
}
|
|
@@ -61735,11 +61820,15 @@ _:patch
|
|
|
61735
61820
|
return this.profileGateway.fetchProfile(webId);
|
|
61736
61821
|
}
|
|
61737
61822
|
/**
|
|
61738
|
-
*
|
|
61739
|
-
*
|
|
61823
|
+
* Build the search index on demand.
|
|
61824
|
+
*
|
|
61825
|
+
* While logged in, the index is built from the logged-in user's label indexes
|
|
61826
|
+
* and cached, so repeated calls return the same instance.
|
|
61827
|
+
*
|
|
61828
|
+
* While logged out, a fresh empty index is returned that is not cached.
|
|
61740
61829
|
*/
|
|
61741
|
-
async buildSearchIndex(
|
|
61742
|
-
return this.searchGateway.buildSearchIndex(
|
|
61830
|
+
async buildSearchIndex() {
|
|
61831
|
+
return this.searchGateway.buildSearchIndex();
|
|
61743
61832
|
}
|
|
61744
61833
|
logout() {
|
|
61745
61834
|
this.offlineCache.clear();
|
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.34.0-rc.
|
|
4
|
+
"version": "0.34.0-rc.aaf1e4e.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./types/index.d.ts",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"rimraf": "^6.1.3",
|
|
54
54
|
"sparqljs": "^3.7.4",
|
|
55
55
|
"typedoc": "^0.28.20",
|
|
56
|
-
"typedoc-plugin-markdown": "^4.
|
|
56
|
+
"typedoc-plugin-markdown": "^4.14.0",
|
|
57
57
|
"typescript": "^6.0.3",
|
|
58
58
|
"typescript-eslint": "^8.71.0",
|
|
59
59
|
"vitest": "^4.1.11",
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"@types/lunr": "^2.3.7",
|
|
65
65
|
"buffer": "^6.0.3",
|
|
66
66
|
"lunr": "^2.3.9",
|
|
67
|
-
"mime": "^4.1.
|
|
67
|
+
"mime": "^4.1.1",
|
|
68
68
|
"neverthrow": "^8.2.0",
|
|
69
69
|
"rdf-namespaces": "^1.17.0",
|
|
70
|
-
"rdflib": "2.4.
|
|
70
|
+
"rdflib": "2.4.1",
|
|
71
71
|
"rxjs": "^7.8.2",
|
|
72
72
|
"slugify": "^1.6.9",
|
|
73
73
|
"url": "^0.11.4",
|
package/types/Store.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ export declare class Store {
|
|
|
59
59
|
*/
|
|
60
60
|
addRelation(thing: Thing, property: string, uri: string): Promise<void>;
|
|
61
61
|
private determineDocumentToUpdate;
|
|
62
|
-
addNewThing(uri: string, name: string, type
|
|
62
|
+
addNewThing(uri: string, name: string, type?: string): Promise<void>;
|
|
63
63
|
executeUpdate(operation: UpdateOperation): Promise<void>;
|
|
64
64
|
flagAuthorizationMetadata(): void;
|
|
65
65
|
loadModule<T>(module: PodOsModule<T>): T;
|
package/types/index.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ export declare class PodOS {
|
|
|
84
84
|
*/
|
|
85
85
|
addRelation(thing: Thing, property: string, value: string): Promise<void>;
|
|
86
86
|
listKnownTerms(): Term[];
|
|
87
|
-
addNewThing(uri: string, name: string, type
|
|
87
|
+
addNewThing(uri: string, name: string, type?: string): Promise<void>;
|
|
88
88
|
proposeUriForNewThing(referenceUri: string, name: string): string;
|
|
89
89
|
/**
|
|
90
90
|
* returns a behavior subject that can be used to observe changes in the session state
|
|
@@ -96,10 +96,14 @@ export declare class PodOS {
|
|
|
96
96
|
*/
|
|
97
97
|
fetchProfile(webId: string): Promise<WebIdProfile>;
|
|
98
98
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
99
|
+
* Build the search index on demand.
|
|
100
|
+
*
|
|
101
|
+
* While logged in, the index is built from the logged-in user's label indexes
|
|
102
|
+
* and cached, so repeated calls return the same instance.
|
|
103
|
+
*
|
|
104
|
+
* While logged out, a fresh empty index is returned that is not cached.
|
|
101
105
|
*/
|
|
102
|
-
buildSearchIndex(
|
|
106
|
+
buildSearchIndex(): Promise<import("./search").SearchIndex>;
|
|
103
107
|
logout(): Promise<void>;
|
|
104
108
|
login(oidcIssuer?: string): Promise<void>;
|
|
105
109
|
/**
|
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
import { WebIdProfile } from "../profile";
|
|
2
|
+
import { ProfileGateway } from "../profile";
|
|
2
3
|
import { Store } from "../Store";
|
|
3
4
|
import { LabelIndex } from "./LabelIndex";
|
|
5
|
+
import { PodOsSession } from "../authentication";
|
|
4
6
|
import { Thing } from "../thing";
|
|
5
7
|
import { SearchIndex } from "./SearchIndex";
|
|
6
8
|
export declare class SearchGateway {
|
|
7
9
|
private readonly store;
|
|
8
|
-
|
|
10
|
+
private readonly profileGateway;
|
|
11
|
+
private readonly session;
|
|
12
|
+
private cached?;
|
|
13
|
+
constructor(store: Store, session: PodOsSession, profileGateway: ProfileGateway);
|
|
9
14
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
15
|
+
* Build a search index on demand.
|
|
16
|
+
*
|
|
17
|
+
* While logged in, the profile is resolved from the current session's webId
|
|
18
|
+
* and the index is built from the profile's label indexes and cached, so that
|
|
19
|
+
* repeated calls return the same instance.
|
|
20
|
+
*
|
|
21
|
+
* While logged out, a fresh empty index is returned that is NOT cached —
|
|
22
|
+
* the next call after login is a cache miss and builds.
|
|
12
23
|
*/
|
|
13
|
-
buildSearchIndex(
|
|
24
|
+
buildSearchIndex(): Promise<SearchIndex>;
|
|
25
|
+
/**
|
|
26
|
+
* Empties the cached search index in place and drops the cache reference, so
|
|
27
|
+
* that consumers already holding the instance see an empty index immediately
|
|
28
|
+
* and the next call to {@link buildSearchIndex} builds a new index.
|
|
29
|
+
*/
|
|
30
|
+
clear(): void;
|
|
31
|
+
private buildIndex;
|
|
32
|
+
private resolveLabelIndexes;
|
|
14
33
|
addToLabelIndex(thing: Thing, labelIndex: LabelIndex): Promise<void>;
|
|
15
34
|
createDefaultLabelIndex(profile: WebIdProfile): Promise<LabelIndex>;
|
|
16
35
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,12 +5,13 @@ import { Index } from "lunr";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class SearchIndex {
|
|
7
7
|
private index;
|
|
8
|
-
private
|
|
8
|
+
private labelIndexes;
|
|
9
9
|
constructor(labelIndexes: LabelIndex[]);
|
|
10
10
|
/**
|
|
11
|
-
* Recreates the search index with the current data from all label indexes
|
|
11
|
+
* Recreates the search index with the current data from all label indexes.
|
|
12
|
+
* Optionally replaces the captured label indexes before rebuilding.
|
|
12
13
|
*/
|
|
13
|
-
rebuild(): this;
|
|
14
|
+
rebuild(labelIndexes?: LabelIndex[]): this;
|
|
14
15
|
/**
|
|
15
16
|
* Search the index for a given term. It finds partial matches, but will rank exact matches higher.
|
|
16
17
|
*
|