@pod-os/core 0.13.1-ebe6b8e.0 → 0.14.1-01c71c6.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.
@@ -3,355 +3,13 @@ import {
3
3
  isNamedNode,
4
4
  lit,
5
5
  namedNode,
6
+ require_short_unique_id,
6
7
  st
7
- } from "./chunk-7VQUARYZ.js";
8
+ } from "./chunk-RI2OJWF3.js";
8
9
  import {
9
- __commonJS,
10
10
  __toESM
11
11
  } from "./chunk-U67V476Y.js";
12
12
 
13
- // ../node_modules/short-unique-id/dist/short-unique-id.js
14
- var require_short_unique_id = __commonJS({
15
- "../node_modules/short-unique-id/dist/short-unique-id.js"(exports, module) {
16
- "use strict";
17
- var ShortUniqueId2 = (() => {
18
- var __defProp = Object.defineProperty;
19
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
20
- var __getOwnPropNames = Object.getOwnPropertyNames;
21
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
22
- var __hasOwnProp = Object.prototype.hasOwnProperty;
23
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
24
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
25
- var __spreadValues = (a, b) => {
26
- for (var prop in b || (b = {}))
27
- if (__hasOwnProp.call(b, prop))
28
- __defNormalProp(a, prop, b[prop]);
29
- if (__getOwnPropSymbols)
30
- for (var prop of __getOwnPropSymbols(b)) {
31
- if (__propIsEnum.call(b, prop))
32
- __defNormalProp(a, prop, b[prop]);
33
- }
34
- return a;
35
- };
36
- var __export = (target, all) => {
37
- for (var name in all)
38
- __defProp(target, name, { get: all[name], enumerable: true });
39
- };
40
- var __copyProps = (to, from, except, desc) => {
41
- if (from && typeof from === "object" || typeof from === "function") {
42
- for (let key of __getOwnPropNames(from))
43
- if (!__hasOwnProp.call(to, key) && key !== except)
44
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
45
- }
46
- return to;
47
- };
48
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
49
- var __publicField = (obj, key, value) => {
50
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
51
- return value;
52
- };
53
- var src_exports = {};
54
- __export(src_exports, {
55
- DEFAULT_OPTIONS: () => DEFAULT_OPTIONS,
56
- DEFAULT_UUID_LENGTH: () => DEFAULT_UUID_LENGTH,
57
- default: () => ShortUniqueId3
58
- });
59
- var version = "5.2.0";
60
- var DEFAULT_UUID_LENGTH = 6;
61
- var DEFAULT_OPTIONS = {
62
- dictionary: "alphanum",
63
- shuffle: true,
64
- debug: false,
65
- length: DEFAULT_UUID_LENGTH,
66
- counter: 0
67
- };
68
- var _ShortUniqueId = class _ShortUniqueId {
69
- constructor(argOptions = {}) {
70
- __publicField(this, "counter");
71
- __publicField(this, "debug");
72
- __publicField(this, "dict");
73
- __publicField(this, "version");
74
- __publicField(this, "dictIndex", 0);
75
- __publicField(this, "dictRange", []);
76
- __publicField(this, "lowerBound", 0);
77
- __publicField(this, "upperBound", 0);
78
- __publicField(this, "dictLength", 0);
79
- __publicField(this, "uuidLength");
80
- __publicField(this, "_digit_first_ascii", 48);
81
- __publicField(this, "_digit_last_ascii", 58);
82
- __publicField(this, "_alpha_lower_first_ascii", 97);
83
- __publicField(this, "_alpha_lower_last_ascii", 123);
84
- __publicField(this, "_hex_last_ascii", 103);
85
- __publicField(this, "_alpha_upper_first_ascii", 65);
86
- __publicField(this, "_alpha_upper_last_ascii", 91);
87
- __publicField(this, "_number_dict_ranges", {
88
- digits: [this._digit_first_ascii, this._digit_last_ascii]
89
- });
90
- __publicField(this, "_alpha_dict_ranges", {
91
- lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii],
92
- upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
93
- });
94
- __publicField(this, "_alpha_lower_dict_ranges", {
95
- lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii]
96
- });
97
- __publicField(this, "_alpha_upper_dict_ranges", {
98
- upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
99
- });
100
- __publicField(this, "_alphanum_dict_ranges", {
101
- digits: [this._digit_first_ascii, this._digit_last_ascii],
102
- lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii],
103
- upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
104
- });
105
- __publicField(this, "_alphanum_lower_dict_ranges", {
106
- digits: [this._digit_first_ascii, this._digit_last_ascii],
107
- lowerCase: [this._alpha_lower_first_ascii, this._alpha_lower_last_ascii]
108
- });
109
- __publicField(this, "_alphanum_upper_dict_ranges", {
110
- digits: [this._digit_first_ascii, this._digit_last_ascii],
111
- upperCase: [this._alpha_upper_first_ascii, this._alpha_upper_last_ascii]
112
- });
113
- __publicField(this, "_hex_dict_ranges", {
114
- decDigits: [this._digit_first_ascii, this._digit_last_ascii],
115
- alphaDigits: [this._alpha_lower_first_ascii, this._hex_last_ascii]
116
- });
117
- __publicField(this, "_dict_ranges", {
118
- _number_dict_ranges: this._number_dict_ranges,
119
- _alpha_dict_ranges: this._alpha_dict_ranges,
120
- _alpha_lower_dict_ranges: this._alpha_lower_dict_ranges,
121
- _alpha_upper_dict_ranges: this._alpha_upper_dict_ranges,
122
- _alphanum_dict_ranges: this._alphanum_dict_ranges,
123
- _alphanum_lower_dict_ranges: this._alphanum_lower_dict_ranges,
124
- _alphanum_upper_dict_ranges: this._alphanum_upper_dict_ranges,
125
- _hex_dict_ranges: this._hex_dict_ranges
126
- });
127
- __publicField(this, "log", (...args) => {
128
- const finalArgs = [...args];
129
- finalArgs[0] = `[short-unique-id] ${args[0]}`;
130
- if (this.debug === true) {
131
- if (typeof console !== "undefined" && console !== null) {
132
- return console.log(...finalArgs);
133
- }
134
- }
135
- });
136
- __publicField(this, "_normalizeDictionary", (dictionary2, shuffle2) => {
137
- let finalDict;
138
- if (dictionary2 && Array.isArray(dictionary2) && dictionary2.length > 1) {
139
- finalDict = dictionary2;
140
- } else {
141
- finalDict = [];
142
- let i;
143
- this.dictIndex = i = 0;
144
- const rangesName = `_${dictionary2}_dict_ranges`;
145
- const ranges = this._dict_ranges[rangesName];
146
- Object.keys(ranges).forEach((rangeType) => {
147
- const rangeTypeKey = rangeType;
148
- this.dictRange = ranges[rangeTypeKey];
149
- this.lowerBound = this.dictRange[0];
150
- this.upperBound = this.dictRange[1];
151
- for (this.dictIndex = i = this.lowerBound; this.lowerBound <= this.upperBound ? i < this.upperBound : i > this.upperBound; this.dictIndex = this.lowerBound <= this.upperBound ? i += 1 : i -= 1) {
152
- finalDict.push(String.fromCharCode(this.dictIndex));
153
- }
154
- });
155
- }
156
- if (shuffle2) {
157
- const PROBABILITY = 0.5;
158
- finalDict = finalDict.sort(() => Math.random() - PROBABILITY);
159
- }
160
- return finalDict;
161
- });
162
- __publicField(this, "setDictionary", (dictionary2, shuffle2) => {
163
- this.dict = this._normalizeDictionary(dictionary2, shuffle2);
164
- this.dictLength = this.dict.length;
165
- this.setCounter(0);
166
- });
167
- __publicField(this, "seq", () => {
168
- return this.sequentialUUID();
169
- });
170
- __publicField(this, "sequentialUUID", () => {
171
- let counterDiv;
172
- let counterRem;
173
- let id = "";
174
- counterDiv = this.counter;
175
- do {
176
- counterRem = counterDiv % this.dictLength;
177
- counterDiv = Math.trunc(counterDiv / this.dictLength);
178
- id += this.dict[counterRem];
179
- } while (counterDiv !== 0);
180
- this.counter += 1;
181
- return id;
182
- });
183
- __publicField(this, "rnd", (uuidLength = this.uuidLength || DEFAULT_UUID_LENGTH) => {
184
- return this.randomUUID(uuidLength);
185
- });
186
- __publicField(this, "randomUUID", (uuidLength = this.uuidLength || DEFAULT_UUID_LENGTH) => {
187
- let id;
188
- let randomPartIdx;
189
- let j;
190
- if (uuidLength === null || typeof uuidLength === "undefined" || uuidLength < 1) {
191
- throw new Error("Invalid UUID Length Provided");
192
- }
193
- const isPositive = uuidLength >= 0;
194
- id = "";
195
- for (j = 0; j < uuidLength; j += 1) {
196
- randomPartIdx = parseInt(
197
- (Math.random() * this.dictLength).toFixed(0),
198
- 10
199
- ) % this.dictLength;
200
- id += this.dict[randomPartIdx];
201
- }
202
- return id;
203
- });
204
- __publicField(this, "fmt", (format, date) => {
205
- return this.formattedUUID(format, date);
206
- });
207
- __publicField(this, "formattedUUID", (format, date) => {
208
- const fnMap = {
209
- "$r": this.randomUUID,
210
- "$s": this.sequentialUUID,
211
- "$t": this.stamp
212
- };
213
- const result = format.replace(
214
- /\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,
215
- (m) => {
216
- const fn = m.slice(0, 2);
217
- const len = parseInt(m.slice(2), 10);
218
- if (fn === "$s") {
219
- return fnMap[fn]().padStart(len, "0");
220
- }
221
- if (fn === "$t" && date) {
222
- return fnMap[fn](len, date);
223
- }
224
- return fnMap[fn](len);
225
- }
226
- );
227
- return result;
228
- });
229
- __publicField(this, "availableUUIDs", (uuidLength = this.uuidLength) => {
230
- return parseFloat(
231
- Math.pow([...new Set(this.dict)].length, uuidLength).toFixed(0)
232
- );
233
- });
234
- __publicField(this, "approxMaxBeforeCollision", (rounds = this.availableUUIDs(this.uuidLength)) => {
235
- return parseFloat(
236
- Math.sqrt(Math.PI / 2 * rounds).toFixed(20)
237
- );
238
- });
239
- __publicField(this, "collisionProbability", (rounds = this.availableUUIDs(this.uuidLength), uuidLength = this.uuidLength) => {
240
- return parseFloat(
241
- (this.approxMaxBeforeCollision(rounds) / this.availableUUIDs(uuidLength)).toFixed(20)
242
- );
243
- });
244
- __publicField(this, "uniqueness", (rounds = this.availableUUIDs(this.uuidLength)) => {
245
- const score = parseFloat(
246
- (1 - this.approxMaxBeforeCollision(rounds) / rounds).toFixed(20)
247
- );
248
- return score > 1 ? 1 : score < 0 ? 0 : score;
249
- });
250
- __publicField(this, "getVersion", () => {
251
- return this.version;
252
- });
253
- __publicField(this, "stamp", (finalLength, date) => {
254
- const hexStamp = Math.floor(+(date || /* @__PURE__ */ new Date()) / 1e3).toString(16);
255
- if (typeof finalLength === "number" && finalLength === 0) {
256
- return hexStamp;
257
- }
258
- if (typeof finalLength !== "number" || finalLength < 10) {
259
- throw new Error(
260
- [
261
- "Param finalLength must be a number greater than or equal to 10,",
262
- "or 0 if you want the raw hexadecimal timestamp"
263
- ].join("\n")
264
- );
265
- }
266
- const idLength = finalLength - 9;
267
- const rndIdx = Math.round(Math.random() * (idLength > 15 ? 15 : idLength));
268
- const id = this.randomUUID(idLength);
269
- return `${id.substring(0, rndIdx)}${hexStamp}${id.substring(rndIdx)}${rndIdx.toString(16)}`;
270
- });
271
- __publicField(this, "parseStamp", (suid, format) => {
272
- if (format && !/t0|t[1-9]\d{1,}/.test(format)) {
273
- throw new Error("Cannot extract date from a formated UUID with no timestamp in the format");
274
- }
275
- const stamp = format ? format.replace(
276
- /\$[rs]\d{0,}|\$t0|\$t[1-9]\d{1,}/g,
277
- (m) => {
278
- const fnMap = {
279
- "$r": (len2) => [...Array(len2)].map(() => "r").join(""),
280
- "$s": (len2) => [...Array(len2)].map(() => "s").join(""),
281
- "$t": (len2) => [...Array(len2)].map(() => "t").join("")
282
- };
283
- const fn = m.slice(0, 2);
284
- const len = parseInt(m.slice(2), 10);
285
- return fnMap[fn](len);
286
- }
287
- ).replace(
288
- /^(.*?)(t{8,})(.*)$/g,
289
- (_m, p1, p2) => {
290
- return suid.substring(p1.length, p1.length + p2.length);
291
- }
292
- ) : suid;
293
- if (stamp.length === 8) {
294
- return new Date(parseInt(stamp, 16) * 1e3);
295
- }
296
- if (stamp.length < 10) {
297
- throw new Error("Stamp length invalid");
298
- }
299
- const rndIdx = parseInt(stamp.substring(stamp.length - 1), 16);
300
- return new Date(parseInt(stamp.substring(rndIdx, rndIdx + 8), 16) * 1e3);
301
- });
302
- __publicField(this, "setCounter", (counter2) => {
303
- this.counter = counter2;
304
- });
305
- __publicField(this, "validate", (uid2, dictionary2) => {
306
- const finalDictionary = dictionary2 ? this._normalizeDictionary(dictionary2) : this.dict;
307
- return uid2.split("").every((c) => finalDictionary.includes(c));
308
- });
309
- const options = __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), argOptions);
310
- this.counter = 0;
311
- this.debug = false;
312
- this.dict = [];
313
- this.version = version;
314
- const {
315
- dictionary,
316
- shuffle,
317
- length,
318
- counter
319
- } = options;
320
- this.uuidLength = length;
321
- this.setDictionary(dictionary, shuffle);
322
- this.setCounter(counter);
323
- this.debug = options.debug;
324
- this.log(this.dict);
325
- this.log(
326
- `Generator instantiated with Dictionary Size ${this.dictLength} and counter set to ${this.counter}`
327
- );
328
- this.log = this.log.bind(this);
329
- this.setDictionary = this.setDictionary.bind(this);
330
- this.setCounter = this.setCounter.bind(this);
331
- this.seq = this.seq.bind(this);
332
- this.sequentialUUID = this.sequentialUUID.bind(this);
333
- this.rnd = this.rnd.bind(this);
334
- this.randomUUID = this.randomUUID.bind(this);
335
- this.fmt = this.fmt.bind(this);
336
- this.formattedUUID = this.formattedUUID.bind(this);
337
- this.availableUUIDs = this.availableUUIDs.bind(this);
338
- this.approxMaxBeforeCollision = this.approxMaxBeforeCollision.bind(this);
339
- this.collisionProbability = this.collisionProbability.bind(this);
340
- this.uniqueness = this.uniqueness.bind(this);
341
- this.getVersion = this.getVersion.bind(this);
342
- this.stamp = this.stamp.bind(this);
343
- this.parseStamp = this.parseStamp.bind(this);
344
- return this;
345
- }
346
- };
347
- __publicField(_ShortUniqueId, "default", _ShortUniqueId);
348
- var ShortUniqueId3 = _ShortUniqueId;
349
- return __toCommonJS(src_exports);
350
- })();
351
- "undefined" != typeof module && (module.exports = ShortUniqueId2.default), "undefined" != typeof window && (ShortUniqueId2 = ShortUniqueId2.default);
352
- }
353
- });
354
-
355
13
  // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/namespaces.js
356
14
  var vcard = Namespace("http://www.w3.org/2006/vcard/ns#");
357
15
  var dc = Namespace("http://purl.org/dc/elements/1.1/");
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ Namespace,
2
3
  UpdateManager,
3
4
  fetcher,
4
5
  graph,
@@ -7,8 +8,9 @@ import {
7
8
  isNamedNode,
8
9
  lit,
9
10
  namedNode,
11
+ require_short_unique_id,
10
12
  st
11
- } from "./chunk-7VQUARYZ.js";
13
+ } from "./chunk-RI2OJWF3.js";
12
14
  import {
13
15
  __commonJS,
14
16
  __export,
@@ -13587,7 +13589,7 @@ var FileFetcher = class {
13587
13589
 
13588
13590
  // src/modules/contacts.ts
13589
13591
  async function loadContactsModule(store) {
13590
- const module2 = await import("./dist-F3EUFQHU.js");
13592
+ const module2 = await import("./dist-SZGBZENE.js");
13591
13593
  return new module2.default({
13592
13594
  store: store.graph,
13593
13595
  fetcher: store.fetcher,
@@ -13831,13 +13833,21 @@ var WebIdProfile = class extends Thing {
13831
13833
  // src/search/SearchIndex.ts
13832
13834
  var import_lunr = __toESM(require_lunr());
13833
13835
  var SearchIndex = class {
13834
- constructor(indexes) {
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;
13835
13845
  this.index = (0, import_lunr.default)(function() {
13836
13846
  this.ref("uri");
13837
13847
  this.field("uri");
13838
13848
  this.field("label");
13839
13849
  this.metadataWhitelist = ["position"];
13840
- const items2 = indexes.flatMap((it) => it.getIndexedItems());
13850
+ const items2 = labelIndexes.flatMap((it) => it.getIndexedItems());
13841
13851
  items2.forEach((item4) => {
13842
13852
  this.add({
13843
13853
  uri: item4.uri,
@@ -13845,6 +13855,7 @@ var SearchIndex = class {
13845
13855
  });
13846
13856
  });
13847
13857
  });
13858
+ return this;
13848
13859
  }
13849
13860
  /**
13850
13861
  * Search the index for a given term. It finds partial matches, but will rank exact matches higher.
@@ -13898,6 +13909,10 @@ var RdfDocument = class extends Thing {
13898
13909
  }
13899
13910
  };
13900
13911
 
13912
+ // src/namespaces/index.ts
13913
+ var rdfs = Namespace("http://www.w3.org/2000/01/rdf-schema#");
13914
+ var pim = Namespace("http://www.w3.org/ns/pim/space#");
13915
+
13901
13916
  // src/search/LabelIndex.ts
13902
13917
  var LabelIndex = class extends RdfDocument {
13903
13918
  constructor(uri6, store, editable = false) {
@@ -13912,7 +13927,7 @@ var LabelIndex = class extends RdfDocument {
13912
13927
  getIndexedItems() {
13913
13928
  const matches = this.store.statementsMatching(
13914
13929
  null,
13915
- namedNode("http://www.w3.org/2000/01/rdf-schema#label"),
13930
+ rdfs("label"),
13916
13931
  null,
13917
13932
  namedNode(this.uri)
13918
13933
  );
@@ -13923,6 +13938,102 @@ var LabelIndex = class extends RdfDocument {
13923
13938
  };
13924
13939
  });
13925
13940
  }
13941
+ contains(uri6) {
13942
+ return this.store.holds(namedNode(uri6), rdfs("label"), null, namedNode(this.uri));
13943
+ }
13944
+ };
13945
+
13946
+ // node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/executeUpdate.js
13947
+ async function executeUpdate(fetcher2, updater, operation3) {
13948
+ await updater.updateMany(operation3.deletions, operation3.insertions);
13949
+ operation3.filesToCreate.map((file2) => {
13950
+ createEmptyTurtleFile(fetcher2, file2.url);
13951
+ });
13952
+ }
13953
+ function createEmptyTurtleFile(fetcher2, url7) {
13954
+ return fetcher2.webOperation("PUT", url7, {
13955
+ contentType: "text/turtle"
13956
+ });
13957
+ }
13958
+
13959
+ // node_modules/@solid-data-modules/rdflib-utils/dist/namespaces/index.js
13960
+ var rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
13961
+ var solid = Namespace("http://www.w3.org/ns/solid/terms#");
13962
+ var pim2 = Namespace("http://www.w3.org/ns/pim/space#");
13963
+ var ldp = Namespace("http://www.w3.org/ns/ldp#");
13964
+
13965
+ // node_modules/@solid-data-modules/rdflib-utils/dist/identifier/generate-id.js
13966
+ var import_short_unique_id = __toESM(require_short_unique_id(), 1);
13967
+ var uid = new import_short_unique_id.default({ length: 10 });
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
+
13993
+ // src/search/addToLabelIndex.ts
13994
+ var addToLabelIndex = (thing, labelIndex) => {
13995
+ return {
13996
+ deletions: [],
13997
+ filesToCreate: [],
13998
+ insertions: [
13999
+ st(
14000
+ namedNode(thing.uri),
14001
+ rdfs("label"),
14002
+ lit(thing.label()),
14003
+ namedNode(labelIndex.uri)
14004
+ )
14005
+ ]
14006
+ };
14007
+ };
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
+ }
13926
14037
  };
13927
14038
 
13928
14039
  // src/Store.ts
@@ -14009,6 +14120,9 @@ var Store = class {
14009
14120
  }
14010
14121
  );
14011
14122
  }
14123
+ async executeUpdate(operation3) {
14124
+ await executeUpdate(this.fetcher, this.updater, operation3);
14125
+ }
14012
14126
  };
14013
14127
 
14014
14128
  // ../node_modules/rdf-namespaces/dist/index.es.js
@@ -14025,21 +14139,21 @@ __export(index_es_exports, {
14025
14139
  foaf: () => foaf,
14026
14140
  http: () => http,
14027
14141
  hydra: () => hydra,
14028
- ldp: () => ldp,
14142
+ ldp: () => ldp2,
14029
14143
  link: () => link3,
14030
14144
  log: () => log,
14031
14145
  meeting: () => meeting,
14032
14146
  owl: () => owl,
14033
14147
  qu: () => qu,
14034
- rdf: () => rdf,
14035
- rdfs: () => rdfs,
14148
+ rdf: () => rdf2,
14149
+ rdfs: () => rdfs2,
14036
14150
  sched: () => sched,
14037
14151
  schema: () => schema,
14038
14152
  schema_https: () => schema_https,
14039
14153
  sec: () => sec,
14040
14154
  sioc: () => sioc,
14041
14155
  skos: () => skos,
14042
- solid: () => solid,
14156
+ solid: () => solid2,
14043
14157
  space: () => space,
14044
14158
  tab: () => tab,
14045
14159
  tabont: () => tabont,
@@ -14392,7 +14506,7 @@ var recurrenceId = "http://www.w3.org/2002/12/cal/ical#recurrenceId";
14392
14506
  var DomainOf_rrule = "http://www.w3.org/2002/12/cal/ical#DomainOf_rrule";
14393
14507
  var relatedTo = "http://www.w3.org/2002/12/cal/ical#relatedTo";
14394
14508
  var url2 = "http://www.w3.org/2002/12/cal/ical#url";
14395
- var uid = "http://www.w3.org/2002/12/cal/ical#uid";
14509
+ var uid2 = "http://www.w3.org/2002/12/cal/ical#uid";
14396
14510
  var exdate = "http://www.w3.org/2002/12/cal/ical#exdate";
14397
14511
  var exrule = "http://www.w3.org/2002/12/cal/ical#exrule";
14398
14512
  var Value_RECUR = "http://www.w3.org/2002/12/cal/ical#Value_RECUR";
@@ -14452,7 +14566,7 @@ var calImport = /* @__PURE__ */ Object.freeze({
14452
14566
  DomainOf_rrule,
14453
14567
  relatedTo,
14454
14568
  url: url2,
14455
- uid,
14569
+ uid: uid2,
14456
14570
  exdate,
14457
14571
  exrule,
14458
14572
  Value_RECUR,
@@ -16880,7 +16994,7 @@ var _containedItemQuantity = "http://hl7.org/fhir/_containedItemQuantity";
16880
16994
  var _daysSupply = "http://hl7.org/fhir/_daysSupply";
16881
16995
  var reportingVendor = "http://hl7.org/fhir/reportingVendor";
16882
16996
  var current = "http://hl7.org/fhir/current";
16883
- var uid2 = "http://hl7.org/fhir/uid";
16997
+ var uid3 = "http://hl7.org/fhir/uid";
16884
16998
  var order = "http://hl7.org/fhir/order";
16885
16999
  var priorPrescription = "http://hl7.org/fhir/priorPrescription";
16886
17000
  var distanceFromLandmark = "http://hl7.org/fhir/distanceFromLandmark";
@@ -21113,7 +21227,7 @@ var fhirImport = /* @__PURE__ */ Object.freeze({
21113
21227
  _daysSupply,
21114
21228
  reportingVendor,
21115
21229
  current,
21116
- uid: uid2,
21230
+ uid: uid3,
21117
21231
  order,
21118
21232
  priorPrescription,
21119
21233
  distanceFromLandmark,
@@ -34274,22 +34388,22 @@ var fhir = fhirImport;
34274
34388
  var foaf = foafImport;
34275
34389
  var http = httpImport;
34276
34390
  var hydra = hydraImport;
34277
- var ldp = ldpImport;
34391
+ var ldp2 = ldpImport;
34278
34392
  var link3 = linkImport;
34279
34393
  var log = logImport;
34280
34394
  var meeting = meetingImport;
34281
34395
  var owl = owlImport;
34282
34396
  var qu = quImport;
34283
34397
  var trip3 = tripImport;
34284
- var rdf = rdfImport;
34285
- var rdfs = rdfsImport;
34398
+ var rdf2 = rdfImport;
34399
+ var rdfs2 = rdfsImport;
34286
34400
  var sched = schedImport;
34287
34401
  var schema = schemaImport;
34288
34402
  var schema_https = schema_httpsImport;
34289
34403
  var sec = secImport;
34290
34404
  var sioc = siocImport;
34291
34405
  var skos = skosImport;
34292
- var solid = solidImport;
34406
+ var solid2 = solidImport;
34293
34407
  var space = spaceImport;
34294
34408
  var tab = tabImport;
34295
34409
  var tabont = tabontImport;
@@ -34361,6 +34475,7 @@ var PodOS = class {
34361
34475
  constructor() {
34362
34476
  this.session = new BrowserSession();
34363
34477
  this.store = new Store(this.session);
34478
+ this.searchGateway = new SearchGateway(this.store);
34364
34479
  this.flagAuthorizationMetaDataOnSessionChange();
34365
34480
  this.uriService = new UriService(this.store);
34366
34481
  this.fileFetcher = new FileFetcher(this.session);
@@ -34443,15 +34558,7 @@ var PodOS = class {
34443
34558
  * @param webId
34444
34559
  */
34445
34560
  async buildSearchIndex(profile2) {
34446
- const labelIndexUris = profile2.getPrivateLabelIndexes();
34447
- if (labelIndexUris.length > 0) {
34448
- await this.fetchAll(labelIndexUris);
34449
- const labelIndex = labelIndexUris.map(
34450
- (uri6) => this.store.get(uri6).assume(LabelIndex)
34451
- );
34452
- return new SearchIndex(labelIndex);
34453
- }
34454
- return new SearchIndex([]);
34561
+ return this.searchGateway.buildSearchIndex(profile2);
34455
34562
  }
34456
34563
  logout() {
34457
34564
  return this.session.logout();
@@ -34462,6 +34569,23 @@ var PodOS = class {
34462
34569
  loadContactsModule() {
34463
34570
  return loadContactsModule(this.store);
34464
34571
  }
34572
+ /**
34573
+ * Adds a label of the given thing to the label index, so that it can be found after the search index has been rebuilt
34574
+ * @param thing - The thing to index
34575
+ * @param labelIndex - The index to update
34576
+ */
34577
+ async addToLabelIndex(thing, labelIndex) {
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);
34588
+ }
34465
34589
  };
34466
34590
  export {
34467
34591
  BinaryFile,
@@ -34472,6 +34596,7 @@ export {
34472
34596
  LdpContainer,
34473
34597
  PodOS,
34474
34598
  RdfDocument,
34599
+ SearchGateway,
34475
34600
  SearchIndex,
34476
34601
  Thing,
34477
34602
  WebIdProfile,