@pod-os/core 0.14.0 → 0.14.1-0e23431.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/{chunk-XBA7NYKJ.js → chunk-RI2OJWF3.js} +9880 -12611
- package/dist/{dist-5TZZFAHE.js → dist-SZGBZENE.js} +1 -1
- package/dist/index.js +83 -17
- package/dist/{jsonld-ECVURSS6.js → jsonld-RY2OHZTS.js} +2 -2
- package/lib/index.js +10136 -12906
- package/package.json +1 -1
- package/types/Store.d.ts +2 -2
- package/types/index.d.ts +10 -2
- package/types/namespaces/index.d.ts +1 -0
- package/types/search/SearchGateway.d.ts +16 -0
- package/types/search/SearchGateway.integration.spec.d.ts +1 -0
- package/types/search/SearchIndex.d.ts +6 -1
- package/types/search/createDefaultLabelIndex.d.ts +5 -0
- package/types/search/createDefaultLabelIndex.spec.d.ts +1 -0
- package/types/search/index.d.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
namedNode,
|
|
11
11
|
require_short_unique_id,
|
|
12
12
|
st
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-RI2OJWF3.js";
|
|
14
14
|
import {
|
|
15
15
|
__commonJS,
|
|
16
16
|
__export,
|
|
@@ -13589,7 +13589,7 @@ var FileFetcher = class {
|
|
|
13589
13589
|
|
|
13590
13590
|
// src/modules/contacts.ts
|
|
13591
13591
|
async function loadContactsModule(store) {
|
|
13592
|
-
const module2 = await import("./dist-
|
|
13592
|
+
const module2 = await import("./dist-SZGBZENE.js");
|
|
13593
13593
|
return new module2.default({
|
|
13594
13594
|
store: store.graph,
|
|
13595
13595
|
fetcher: store.fetcher,
|
|
@@ -13833,13 +13833,21 @@ var WebIdProfile = class extends Thing {
|
|
|
13833
13833
|
// src/search/SearchIndex.ts
|
|
13834
13834
|
var import_lunr = __toESM(require_lunr());
|
|
13835
13835
|
var SearchIndex = class {
|
|
13836
|
-
constructor(
|
|
13836
|
+
constructor(labelIndexes) {
|
|
13837
|
+
this.labelIndexes = labelIndexes;
|
|
13838
|
+
this.index = this.rebuild().index;
|
|
13839
|
+
}
|
|
13840
|
+
/**
|
|
13841
|
+
* Recreates the search index with the current data from all label indexes
|
|
13842
|
+
*/
|
|
13843
|
+
rebuild() {
|
|
13844
|
+
const labelIndexes = this.labelIndexes;
|
|
13837
13845
|
this.index = (0, import_lunr.default)(function() {
|
|
13838
13846
|
this.ref("uri");
|
|
13839
13847
|
this.field("uri");
|
|
13840
13848
|
this.field("label");
|
|
13841
13849
|
this.metadataWhitelist = ["position"];
|
|
13842
|
-
const items2 =
|
|
13850
|
+
const items2 = labelIndexes.flatMap((it) => it.getIndexedItems());
|
|
13843
13851
|
items2.forEach((item4) => {
|
|
13844
13852
|
this.add({
|
|
13845
13853
|
uri: item4.uri,
|
|
@@ -13847,6 +13855,7 @@ var SearchIndex = class {
|
|
|
13847
13855
|
});
|
|
13848
13856
|
});
|
|
13849
13857
|
});
|
|
13858
|
+
return this;
|
|
13850
13859
|
}
|
|
13851
13860
|
/**
|
|
13852
13861
|
* Search the index for a given term. It finds partial matches, but will rank exact matches higher.
|
|
@@ -13902,6 +13911,7 @@ var RdfDocument = class extends Thing {
|
|
|
13902
13911
|
|
|
13903
13912
|
// src/namespaces/index.ts
|
|
13904
13913
|
var rdfs = Namespace("http://www.w3.org/2000/01/rdf-schema#");
|
|
13914
|
+
var pim = Namespace("http://www.w3.org/ns/pim/space#");
|
|
13905
13915
|
|
|
13906
13916
|
// src/search/LabelIndex.ts
|
|
13907
13917
|
var LabelIndex = class extends RdfDocument {
|
|
@@ -13949,13 +13959,37 @@ function createEmptyTurtleFile(fetcher2, url7) {
|
|
|
13949
13959
|
// node_modules/@solid-data-modules/rdflib-utils/dist/namespaces/index.js
|
|
13950
13960
|
var rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
|
13951
13961
|
var solid = Namespace("http://www.w3.org/ns/solid/terms#");
|
|
13952
|
-
var
|
|
13962
|
+
var pim2 = Namespace("http://www.w3.org/ns/pim/space#");
|
|
13953
13963
|
var ldp = Namespace("http://www.w3.org/ns/ldp#");
|
|
13954
13964
|
|
|
13955
13965
|
// node_modules/@solid-data-modules/rdflib-utils/dist/identifier/generate-id.js
|
|
13956
13966
|
var import_short_unique_id = __toESM(require_short_unique_id(), 1);
|
|
13957
13967
|
var uid = new import_short_unique_id.default({ length: 10 });
|
|
13958
13968
|
|
|
13969
|
+
// src/search/createDefaultLabelIndex.ts
|
|
13970
|
+
function createDefaultLabelIndex(profile2) {
|
|
13971
|
+
const webId = namedNode(profile2.webId);
|
|
13972
|
+
const preferencesFile2 = profile2.getPreferencesFile();
|
|
13973
|
+
const defaultFileName = "privateLabelIndex.ttl";
|
|
13974
|
+
const indexUrl = preferencesFile2 ? new URL(defaultFileName, preferencesFile2).href : new URL(defaultFileName, webId.uri).href;
|
|
13975
|
+
const preferencesOrProfileDoc = preferencesFile2 ? namedNode(preferencesFile2) : webId.doc();
|
|
13976
|
+
const indexDocument = namedNode(indexUrl);
|
|
13977
|
+
return {
|
|
13978
|
+
uri: indexDocument.uri,
|
|
13979
|
+
insertions: [
|
|
13980
|
+
st(
|
|
13981
|
+
webId,
|
|
13982
|
+
solid("privateLabelIndex"),
|
|
13983
|
+
indexDocument,
|
|
13984
|
+
preferencesOrProfileDoc
|
|
13985
|
+
),
|
|
13986
|
+
st(indexDocument, rdfs("label"), lit("Default Index"), indexDocument)
|
|
13987
|
+
],
|
|
13988
|
+
deletions: [],
|
|
13989
|
+
filesToCreate: []
|
|
13990
|
+
};
|
|
13991
|
+
}
|
|
13992
|
+
|
|
13959
13993
|
// src/search/addToLabelIndex.ts
|
|
13960
13994
|
var addToLabelIndex = (thing, labelIndex) => {
|
|
13961
13995
|
return {
|
|
@@ -13972,6 +14006,36 @@ var addToLabelIndex = (thing, labelIndex) => {
|
|
|
13972
14006
|
};
|
|
13973
14007
|
};
|
|
13974
14008
|
|
|
14009
|
+
// src/search/SearchGateway.ts
|
|
14010
|
+
var SearchGateway = class {
|
|
14011
|
+
constructor(store) {
|
|
14012
|
+
this.store = store;
|
|
14013
|
+
}
|
|
14014
|
+
/**
|
|
14015
|
+
* Fetch the private label index for the given profile and build a search index from it
|
|
14016
|
+
* @param webId
|
|
14017
|
+
*/
|
|
14018
|
+
async buildSearchIndex(profile2) {
|
|
14019
|
+
const labelIndexUris = profile2.getPrivateLabelIndexes();
|
|
14020
|
+
if (labelIndexUris.length > 0) {
|
|
14021
|
+
await this.store.fetchAll(labelIndexUris);
|
|
14022
|
+
const labelIndex = labelIndexUris.map(
|
|
14023
|
+
(uri6) => this.store.get(uri6).assume(LabelIndex)
|
|
14024
|
+
);
|
|
14025
|
+
return new SearchIndex(labelIndex);
|
|
14026
|
+
}
|
|
14027
|
+
return new SearchIndex([]);
|
|
14028
|
+
}
|
|
14029
|
+
async addToLabelIndex(thing, labelIndex) {
|
|
14030
|
+
await this.store.executeUpdate(addToLabelIndex(thing, labelIndex));
|
|
14031
|
+
}
|
|
14032
|
+
async createDefaultLabelIndex(profile2) {
|
|
14033
|
+
const operation3 = createDefaultLabelIndex(profile2);
|
|
14034
|
+
await this.store.executeUpdate(operation3);
|
|
14035
|
+
return this.store.get(operation3.uri).assume(LabelIndex);
|
|
14036
|
+
}
|
|
14037
|
+
};
|
|
14038
|
+
|
|
13975
14039
|
// src/Store.ts
|
|
13976
14040
|
var Store = class {
|
|
13977
14041
|
constructor(session4) {
|
|
@@ -14056,8 +14120,7 @@ var Store = class {
|
|
|
14056
14120
|
}
|
|
14057
14121
|
);
|
|
14058
14122
|
}
|
|
14059
|
-
async
|
|
14060
|
-
const operation3 = addToLabelIndex(thing, labelIndex);
|
|
14123
|
+
async executeUpdate(operation3) {
|
|
14061
14124
|
await executeUpdate(this.fetcher, this.updater, operation3);
|
|
14062
14125
|
}
|
|
14063
14126
|
};
|
|
@@ -34412,6 +34475,7 @@ var PodOS = class {
|
|
|
34412
34475
|
constructor() {
|
|
34413
34476
|
this.session = new BrowserSession();
|
|
34414
34477
|
this.store = new Store(this.session);
|
|
34478
|
+
this.searchGateway = new SearchGateway(this.store);
|
|
34415
34479
|
this.flagAuthorizationMetaDataOnSessionChange();
|
|
34416
34480
|
this.uriService = new UriService(this.store);
|
|
34417
34481
|
this.fileFetcher = new FileFetcher(this.session);
|
|
@@ -34494,15 +34558,7 @@ var PodOS = class {
|
|
|
34494
34558
|
* @param webId
|
|
34495
34559
|
*/
|
|
34496
34560
|
async buildSearchIndex(profile2) {
|
|
34497
|
-
|
|
34498
|
-
if (labelIndexUris.length > 0) {
|
|
34499
|
-
await this.fetchAll(labelIndexUris);
|
|
34500
|
-
const labelIndex = labelIndexUris.map(
|
|
34501
|
-
(uri6) => this.store.get(uri6).assume(LabelIndex)
|
|
34502
|
-
);
|
|
34503
|
-
return new SearchIndex(labelIndex);
|
|
34504
|
-
}
|
|
34505
|
-
return new SearchIndex([]);
|
|
34561
|
+
return this.searchGateway.buildSearchIndex(profile2);
|
|
34506
34562
|
}
|
|
34507
34563
|
logout() {
|
|
34508
34564
|
return this.session.logout();
|
|
@@ -34519,7 +34575,16 @@ var PodOS = class {
|
|
|
34519
34575
|
* @param labelIndex - The index to update
|
|
34520
34576
|
*/
|
|
34521
34577
|
async addToLabelIndex(thing, labelIndex) {
|
|
34522
|
-
await this.
|
|
34578
|
+
await this.searchGateway.addToLabelIndex(thing, labelIndex);
|
|
34579
|
+
}
|
|
34580
|
+
/**
|
|
34581
|
+
* Creates a new label index document at a default location and links it to the user's profile or preferences document
|
|
34582
|
+
*
|
|
34583
|
+
* @param profile - The profile for that to create the index
|
|
34584
|
+
* @returns the newly created label index
|
|
34585
|
+
*/
|
|
34586
|
+
async createDefaultLabelIndex(profile2) {
|
|
34587
|
+
return await this.searchGateway.createDefaultLabelIndex(profile2);
|
|
34523
34588
|
}
|
|
34524
34589
|
};
|
|
34525
34590
|
export {
|
|
@@ -34531,6 +34596,7 @@ export {
|
|
|
34531
34596
|
LdpContainer,
|
|
34532
34597
|
PodOS,
|
|
34533
34598
|
RdfDocument,
|
|
34599
|
+
SearchGateway,
|
|
34534
34600
|
SearchIndex,
|
|
34535
34601
|
Thing,
|
|
34536
34602
|
WebIdProfile,
|
|
@@ -3049,14 +3049,14 @@ var require_ContextResolver = __commonJS({
|
|
|
3049
3049
|
}
|
|
3050
3050
|
} catch (e) {
|
|
3051
3051
|
throw new JsonLdError(
|
|
3052
|
-
|
|
3052
|
+
`Dereferencing a URL did not result in a valid JSON-LD object. Possible causes are an inaccessible URL perhaps due to a same-origin policy (ensure the server uses CORS if you are using client-side JavaScript), too many redirects, a non-JSON response, or more than one HTTP Link Header was provided for a remote context. URL: "${url}".`,
|
|
3053
3053
|
"jsonld.InvalidUrl",
|
|
3054
3054
|
{ code: "loading remote context failed", url, cause: e }
|
|
3055
3055
|
);
|
|
3056
3056
|
}
|
|
3057
3057
|
if (!_isObject(context)) {
|
|
3058
3058
|
throw new JsonLdError(
|
|
3059
|
-
|
|
3059
|
+
`Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object. URL: "${url}".`,
|
|
3060
3060
|
"jsonld.InvalidUrl",
|
|
3061
3061
|
{ code: "invalid remote context", url }
|
|
3062
3062
|
);
|