@pod-os/core 0.11.2-fe7524c.0 → 0.12.1-eddb6ac.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-NJZBRQIY.js → chunk-7C7N3OSJ.js} +376 -542
- package/dist/dist-762OQHAF.js +912 -0
- package/dist/index.js +1860 -95
- package/lib/index.js +3091 -945
- package/package.json +8 -7
- package/types/authentication/index.d.ts +10 -2
- package/types/authentication/observeSession.d.ts +4 -0
- package/types/authentication/observeSession.spec.d.ts +1 -0
- package/types/index.d.ts +19 -4
- package/dist/dist-D3HKZNEN.js +0 -384
|
@@ -0,0 +1,912 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Namespace,
|
|
3
|
+
isNamedNode,
|
|
4
|
+
lit,
|
|
5
|
+
namedNode,
|
|
6
|
+
st
|
|
7
|
+
} from "./chunk-7C7N3OSJ.js";
|
|
8
|
+
import {
|
|
9
|
+
__commonJS,
|
|
10
|
+
__toESM
|
|
11
|
+
} from "./chunk-5NEDDTD5.js";
|
|
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
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/namespaces.js
|
|
356
|
+
var rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
|
357
|
+
var vcard = Namespace("http://www.w3.org/2006/vcard/ns#");
|
|
358
|
+
var solid = Namespace("http://www.w3.org/ns/solid/terms#");
|
|
359
|
+
var pim = Namespace("http://www.w3.org/ns/pim/space#");
|
|
360
|
+
var dc = Namespace("http://purl.org/dc/elements/1.1/");
|
|
361
|
+
|
|
362
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/generate-id.js
|
|
363
|
+
var import_short_unique_id = __toESM(require_short_unique_id(), 1);
|
|
364
|
+
var uid = new import_short_unique_id.default({ length: 10 });
|
|
365
|
+
function generateId() {
|
|
366
|
+
return uid.rnd(6);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/AddressBookQuery.js
|
|
370
|
+
var AddressBookQuery = class {
|
|
371
|
+
constructor(store, addressBookNode) {
|
|
372
|
+
this.store = store;
|
|
373
|
+
this.addressBookNode = addressBookNode;
|
|
374
|
+
this.addressBookDoc = addressBookNode.doc();
|
|
375
|
+
}
|
|
376
|
+
proposeNewContactNode() {
|
|
377
|
+
return this.proposeNewNode("Person");
|
|
378
|
+
}
|
|
379
|
+
proposeNewGroupNode() {
|
|
380
|
+
return this.proposeNewNode("Group");
|
|
381
|
+
}
|
|
382
|
+
proposeNewNode(containerPath) {
|
|
383
|
+
const id = generateId();
|
|
384
|
+
const baseUri = this.addressBookNode.dir()?.uri;
|
|
385
|
+
return namedNode(`${baseUri}${containerPath}/${id}/index.ttl#this`);
|
|
386
|
+
}
|
|
387
|
+
queryTitle() {
|
|
388
|
+
return this.store.anyValue(this.addressBookNode, dc("title"), void 0, this.addressBookDoc) ?? "";
|
|
389
|
+
}
|
|
390
|
+
queryNameEmailIndex() {
|
|
391
|
+
const index = this.store.any(this.addressBookNode, vcard("nameEmailIndex"), void 0, this.addressBookDoc);
|
|
392
|
+
if (isNamedNode(index)) {
|
|
393
|
+
return index;
|
|
394
|
+
} else {
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
queryContacts() {
|
|
399
|
+
const nameEmailIndex = this.queryNameEmailIndex();
|
|
400
|
+
return nameEmailIndex && isNamedNode(nameEmailIndex) ? this.store.each(null, vcard("inAddressBook"), this.addressBookNode, nameEmailIndex).filter((it) => isNamedNode(it)).map((node) => ({
|
|
401
|
+
name: this.store.anyValue(node, vcard("fn"), null, nameEmailIndex) ?? "",
|
|
402
|
+
uri: node.value
|
|
403
|
+
})) : [];
|
|
404
|
+
}
|
|
405
|
+
queryGroupIndex() {
|
|
406
|
+
const index = this.store.any(this.addressBookNode, vcard("groupIndex"), void 0, this.addressBookDoc);
|
|
407
|
+
if (isNamedNode(index)) {
|
|
408
|
+
return index;
|
|
409
|
+
} else {
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
queryGroups() {
|
|
414
|
+
const groupIndex = this.queryGroupIndex();
|
|
415
|
+
return groupIndex && isNamedNode(groupIndex) ? this.store.each(this.addressBookNode, vcard("includesGroup"), null, groupIndex).filter((it) => isNamedNode(it)).map((node) => ({
|
|
416
|
+
name: this.store.anyValue(node, vcard("fn"), null, groupIndex) ?? "",
|
|
417
|
+
uri: node.value
|
|
418
|
+
})) : [];
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/ContactQuery.js
|
|
423
|
+
var MAILTO_URI_SCHEME = "mailto:";
|
|
424
|
+
var TEl_URI_SCHEME = "tel:";
|
|
425
|
+
var ContactQuery = class {
|
|
426
|
+
constructor(store, contactNode) {
|
|
427
|
+
this.store = store;
|
|
428
|
+
this.contactNode = contactNode;
|
|
429
|
+
this.contactDoc = contactNode.doc();
|
|
430
|
+
}
|
|
431
|
+
queryName() {
|
|
432
|
+
return this.store.anyValue(this.contactNode, vcard("fn"), void 0, this.contactDoc) ?? "";
|
|
433
|
+
}
|
|
434
|
+
queryEmails() {
|
|
435
|
+
const uris = this.getValuesOf(vcard("hasEmail"));
|
|
436
|
+
if (uris.length === 0) {
|
|
437
|
+
return [];
|
|
438
|
+
}
|
|
439
|
+
return uris.map((uri) => {
|
|
440
|
+
const valueNode = this.getValueNode(uri);
|
|
441
|
+
if (isMailtoNode(valueNode)) {
|
|
442
|
+
return {
|
|
443
|
+
uri,
|
|
444
|
+
value: valueNode.value.split(MAILTO_URI_SCHEME)[1]
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
}).filter((value) => !!value);
|
|
448
|
+
}
|
|
449
|
+
queryPhoneNumbers() {
|
|
450
|
+
const uris = this.getValuesOf(vcard("hasTelephone"));
|
|
451
|
+
if (uris.length === 0) {
|
|
452
|
+
return [];
|
|
453
|
+
}
|
|
454
|
+
return uris.map((uri) => {
|
|
455
|
+
const valueNode = this.getValueNode(uri);
|
|
456
|
+
if (isTelNode(valueNode)) {
|
|
457
|
+
return {
|
|
458
|
+
uri,
|
|
459
|
+
value: valueNode.value.split(TEl_URI_SCHEME)[1]
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
}).filter((value) => !!value);
|
|
463
|
+
}
|
|
464
|
+
getValuesOf(predicate) {
|
|
465
|
+
return this.store.statementsMatching(this.contactNode, predicate, void 0, this.contactDoc).map((it) => it.object.value);
|
|
466
|
+
}
|
|
467
|
+
getValueNode(uri) {
|
|
468
|
+
return this.store.any(namedNode(uri), vcard("value"), void 0, this.contactDoc);
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
function isMailtoNode(valueNode) {
|
|
472
|
+
return isNamedNode(valueNode) && valueNode.value.startsWith(MAILTO_URI_SCHEME);
|
|
473
|
+
}
|
|
474
|
+
function isTelNode(valueNode) {
|
|
475
|
+
return isNamedNode(valueNode) && valueNode.value.startsWith(TEl_URI_SCHEME);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/createAddressBook.js
|
|
479
|
+
function createAddressBook(container, name) {
|
|
480
|
+
const id = generateId();
|
|
481
|
+
const uri = `${container}${id}/index.ttl#this`;
|
|
482
|
+
const nameEmailIndexUri = `${container}${id}/people.ttl`;
|
|
483
|
+
const groupIndexUri = `${container}${id}/groups.ttl`;
|
|
484
|
+
const insertions = [
|
|
485
|
+
st(namedNode(uri), namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vcard("AddressBook"), namedNode(uri).doc()),
|
|
486
|
+
st(namedNode(uri), dc("title"), lit(name), namedNode(uri).doc()),
|
|
487
|
+
st(namedNode(uri), vcard("nameEmailIndex"), namedNode(nameEmailIndexUri), namedNode(uri).doc()),
|
|
488
|
+
st(namedNode(uri), vcard("groupIndex"), namedNode(groupIndexUri), namedNode(uri).doc())
|
|
489
|
+
];
|
|
490
|
+
return {
|
|
491
|
+
uri,
|
|
492
|
+
deletions: [],
|
|
493
|
+
insertions,
|
|
494
|
+
filesToCreate: [{ uri: nameEmailIndexUri }, { uri: groupIndexUri }]
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/createNewContact.js
|
|
499
|
+
function createNewContact(addressBook, newContact) {
|
|
500
|
+
const contactNode = addressBook.proposeNewContactNode();
|
|
501
|
+
const nameEmailIndex = addressBook.queryNameEmailIndex();
|
|
502
|
+
if (!nameEmailIndex) {
|
|
503
|
+
throw new Error("name-email index is missing or invalid");
|
|
504
|
+
}
|
|
505
|
+
const insertions = [
|
|
506
|
+
st(contactNode, vcard("inAddressBook"), addressBook.addressBookNode, nameEmailIndex),
|
|
507
|
+
st(contactNode, vcard("fn"), lit(newContact.name), nameEmailIndex),
|
|
508
|
+
st(contactNode, vcard("fn"), lit(newContact.name), contactNode.doc()),
|
|
509
|
+
st(contactNode, rdf("type"), vcard("Individual"), contactNode.doc())
|
|
510
|
+
];
|
|
511
|
+
if (newContact.email) {
|
|
512
|
+
const emailNode = namedNode(contactNode.doc().uri + "#email");
|
|
513
|
+
insertions.push(st(contactNode, vcard("hasEmail"), emailNode, contactNode.doc()), st(emailNode, vcard("value"), namedNode("mailto:" + newContact.email), contactNode.doc()));
|
|
514
|
+
}
|
|
515
|
+
if (newContact.phoneNumber) {
|
|
516
|
+
const phoneNode = namedNode(contactNode.doc().uri + "#phone");
|
|
517
|
+
insertions.push(st(contactNode, vcard("hasTelephone"), phoneNode, contactNode.doc()), st(phoneNode, vcard("value"), namedNode("tel:" + newContact.phoneNumber), contactNode.doc()));
|
|
518
|
+
}
|
|
519
|
+
return {
|
|
520
|
+
uri: contactNode.uri,
|
|
521
|
+
deletions: [],
|
|
522
|
+
insertions,
|
|
523
|
+
filesToCreate: []
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/web-operations/executeUpdate.js
|
|
528
|
+
async function executeUpdate(fetcher, updater, operation) {
|
|
529
|
+
await updater.updateMany(operation.deletions, operation.insertions);
|
|
530
|
+
operation.filesToCreate.map((file) => {
|
|
531
|
+
createEmptyTurtleFile(fetcher, file.uri);
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
function createEmptyTurtleFile(fetcher, uri) {
|
|
535
|
+
return fetcher.webOperation("PUT", uri, {
|
|
536
|
+
contentType: "text/turtle"
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/web-operations/fetchNode.js
|
|
541
|
+
async function fetchNode(fetcher, node) {
|
|
542
|
+
if (node) {
|
|
543
|
+
await fetcher.load(node.value);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/createNewGroup.js
|
|
548
|
+
function createNewGroup(addressBook, groupName) {
|
|
549
|
+
const groupIndex = addressBook.queryGroupIndex();
|
|
550
|
+
if (!groupIndex) {
|
|
551
|
+
throw new Error("group index is missing or invalid");
|
|
552
|
+
}
|
|
553
|
+
const groupNode = addressBook.proposeNewGroupNode();
|
|
554
|
+
const groupDoc = groupNode.doc();
|
|
555
|
+
return {
|
|
556
|
+
uri: groupNode.uri,
|
|
557
|
+
insertions: [
|
|
558
|
+
st(groupNode, vcard("fn"), lit(groupName), groupIndex),
|
|
559
|
+
st(groupNode, vcard("fn"), lit(groupName), groupDoc),
|
|
560
|
+
st(groupNode, rdf("type"), vcard("Group"), groupDoc),
|
|
561
|
+
st(addressBook.addressBookNode, vcard("includesGroup"), groupNode, groupIndex)
|
|
562
|
+
],
|
|
563
|
+
deletions: [],
|
|
564
|
+
filesToCreate: []
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/GroupQuery.js
|
|
569
|
+
var GroupQuery = class {
|
|
570
|
+
constructor(store, groupNode) {
|
|
571
|
+
this.store = store;
|
|
572
|
+
this.groupNode = groupNode;
|
|
573
|
+
this.groupDoc = groupNode.doc();
|
|
574
|
+
}
|
|
575
|
+
queryName() {
|
|
576
|
+
return this.store.anyValue(this.groupNode, vcard("fn"), void 0, this.groupDoc) ?? "";
|
|
577
|
+
}
|
|
578
|
+
queryMembers() {
|
|
579
|
+
return this.store.each(this.groupNode, vcard("hasMember"), null, this.groupDoc).filter((it) => isNamedNode(it)).map((node) => ({
|
|
580
|
+
uri: node.value,
|
|
581
|
+
name: this.store.anyValue(node, vcard("fn"), null, this.groupDoc) ?? ""
|
|
582
|
+
}));
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addContactToGroup.js
|
|
587
|
+
function addContactToGroup(contactQuery, groupQuery) {
|
|
588
|
+
const name = contactQuery.queryName();
|
|
589
|
+
return {
|
|
590
|
+
uri: "",
|
|
591
|
+
insertions: [
|
|
592
|
+
st(groupQuery.groupNode, vcard("hasMember"), contactQuery.contactNode, groupQuery.groupNode.doc()),
|
|
593
|
+
st(contactQuery.contactNode, vcard("fn"), lit(name), groupQuery.groupNode.doc())
|
|
594
|
+
],
|
|
595
|
+
deletions: [],
|
|
596
|
+
filesToCreate: []
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removeContactFromGroup.js
|
|
601
|
+
function removeContactFromGroup(contactQuery, groupQuery) {
|
|
602
|
+
const contactUri = contactQuery.contactNode.uri;
|
|
603
|
+
const member = groupQuery.queryMembers().find((it) => it.uri === contactUri);
|
|
604
|
+
if (!member) {
|
|
605
|
+
throw new Error("member not found in group");
|
|
606
|
+
}
|
|
607
|
+
return {
|
|
608
|
+
uri: "",
|
|
609
|
+
insertions: [],
|
|
610
|
+
deletions: [
|
|
611
|
+
st(groupQuery.groupNode, vcard("hasMember"), contactQuery.contactNode, groupQuery.groupNode.doc()),
|
|
612
|
+
st(contactQuery.contactNode, vcard("fn"), lit(member.name), groupQuery.groupNode.doc())
|
|
613
|
+
],
|
|
614
|
+
filesToCreate: []
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addNewPhoneNumber.js
|
|
619
|
+
function addNewPhoneNumber(contactNode, phoneNumber) {
|
|
620
|
+
const id = generateId();
|
|
621
|
+
const uri = `${contactNode.doc().uri}#${id}`;
|
|
622
|
+
return {
|
|
623
|
+
uri,
|
|
624
|
+
insertions: [
|
|
625
|
+
st(contactNode, vcard("hasTelephone"), namedNode(uri), contactNode.doc()),
|
|
626
|
+
st(namedNode(uri), vcard("value"), namedNode("tel:" + phoneNumber), contactNode.doc())
|
|
627
|
+
],
|
|
628
|
+
deletions: [],
|
|
629
|
+
filesToCreate: []
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addNewEmailAddress.js
|
|
634
|
+
function addNewEmailAddress(contactNode, emailAddress) {
|
|
635
|
+
const id = generateId();
|
|
636
|
+
const uri = `${contactNode.doc().uri}#${id}`;
|
|
637
|
+
return {
|
|
638
|
+
uri,
|
|
639
|
+
insertions: [
|
|
640
|
+
st(contactNode, vcard("hasEmail"), namedNode(uri), contactNode.doc()),
|
|
641
|
+
st(namedNode(uri), vcard("value"), namedNode("mailto:" + emailAddress), contactNode.doc())
|
|
642
|
+
],
|
|
643
|
+
deletions: [],
|
|
644
|
+
filesToCreate: []
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removePhoneNumber.js
|
|
649
|
+
function removePhoneNumber(contactNode, phoneNode, store) {
|
|
650
|
+
const phoneStatements = store.statementsMatching(phoneNode, null, null, phoneNode.doc());
|
|
651
|
+
return {
|
|
652
|
+
uri: "",
|
|
653
|
+
insertions: [],
|
|
654
|
+
deletions: [
|
|
655
|
+
...phoneStatements,
|
|
656
|
+
st(contactNode, vcard("hasTelephone"), phoneNode, contactNode.doc())
|
|
657
|
+
],
|
|
658
|
+
filesToCreate: []
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removeEmailAddress.js
|
|
663
|
+
function removeEmailAddress(contactNode, emailNode, store) {
|
|
664
|
+
const emailStatements = store.statementsMatching(emailNode, null, null, emailNode.doc());
|
|
665
|
+
return {
|
|
666
|
+
uri: "",
|
|
667
|
+
insertions: [],
|
|
668
|
+
deletions: [
|
|
669
|
+
...emailStatements,
|
|
670
|
+
st(contactNode, vcard("hasEmail"), emailNode, contactNode.doc())
|
|
671
|
+
],
|
|
672
|
+
filesToCreate: []
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/ProfileQuery.js
|
|
677
|
+
var ProfileQuery = class {
|
|
678
|
+
constructor(webIdNode, store) {
|
|
679
|
+
this.webIdNode = webIdNode;
|
|
680
|
+
this.store = store;
|
|
681
|
+
}
|
|
682
|
+
queryPublicTypeIndex() {
|
|
683
|
+
const predicate = solid("publicTypeIndex");
|
|
684
|
+
return this.queryNamedNode(predicate);
|
|
685
|
+
}
|
|
686
|
+
queryPreferencesFile() {
|
|
687
|
+
const predicate = pim("preferencesFile");
|
|
688
|
+
return this.queryNamedNode(predicate);
|
|
689
|
+
}
|
|
690
|
+
queryNamedNode(predicate) {
|
|
691
|
+
const node = this.store.any(this.webIdNode, predicate, null, this.webIdNode.doc());
|
|
692
|
+
if (isNamedNode(node)) {
|
|
693
|
+
return node;
|
|
694
|
+
}
|
|
695
|
+
return null;
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/TypeIndexQuery.js
|
|
700
|
+
var TypeIndexQuery = class {
|
|
701
|
+
constructor(store, typeIndexDoc) {
|
|
702
|
+
this.store = store;
|
|
703
|
+
this.typeIndexDoc = typeIndexDoc;
|
|
704
|
+
}
|
|
705
|
+
queryAddressBookInstances() {
|
|
706
|
+
const addressBookRegistrations = this.store.each(null, solid("forClass"), vcard("AddressBook"), this.typeIndexDoc);
|
|
707
|
+
return addressBookRegistrations.flatMap((registration) => {
|
|
708
|
+
if (!isNamedNode(registration))
|
|
709
|
+
return [];
|
|
710
|
+
return this.getInstanceValues(registration);
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
getInstanceValues(registration) {
|
|
714
|
+
return this.store.each(registration, solid("instance"), null, this.typeIndexDoc).map((it) => it.value);
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/PreferencesQuery.js
|
|
719
|
+
var PreferencesQuery = class {
|
|
720
|
+
constructor(store, webIdNode, preferencesDoc) {
|
|
721
|
+
this.store = store;
|
|
722
|
+
this.webIdNode = webIdNode;
|
|
723
|
+
this.preferencesDoc = preferencesDoc;
|
|
724
|
+
}
|
|
725
|
+
queryPrivateTypeIndex() {
|
|
726
|
+
const node = this.store.any(this.webIdNode, solid("privateTypeIndex"), null, this.preferencesDoc);
|
|
727
|
+
if (isNamedNode(node)) {
|
|
728
|
+
return node;
|
|
729
|
+
}
|
|
730
|
+
return null;
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/ContactsModuleRdfLib.js
|
|
735
|
+
var ContactsModuleRdfLib = class {
|
|
736
|
+
constructor(config) {
|
|
737
|
+
this.store = config.store;
|
|
738
|
+
this.fetcher = config.fetcher;
|
|
739
|
+
this.updater = config.updater;
|
|
740
|
+
}
|
|
741
|
+
async readAddressBook(uri) {
|
|
742
|
+
const addressBookNode = namedNode(uri);
|
|
743
|
+
await this.fetchNode(addressBookNode);
|
|
744
|
+
const query = new AddressBookQuery(this.store, addressBookNode);
|
|
745
|
+
const title = query.queryTitle();
|
|
746
|
+
const nameEmailIndex = query.queryNameEmailIndex();
|
|
747
|
+
const groupIndex = query.queryGroupIndex();
|
|
748
|
+
await Promise.allSettled([
|
|
749
|
+
this.fetchNode(nameEmailIndex),
|
|
750
|
+
this.fetchNode(groupIndex)
|
|
751
|
+
]);
|
|
752
|
+
await this.fetchAll([nameEmailIndex, groupIndex]);
|
|
753
|
+
const contacts = query.queryContacts();
|
|
754
|
+
const groups = query.queryGroups();
|
|
755
|
+
return {
|
|
756
|
+
uri,
|
|
757
|
+
title,
|
|
758
|
+
contacts,
|
|
759
|
+
groups
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
async fetchNode(node) {
|
|
763
|
+
return fetchNode(this.fetcher, node);
|
|
764
|
+
}
|
|
765
|
+
async fetchAll(nodes) {
|
|
766
|
+
return Promise.all(nodes.map((it) => this.fetchNode(it)));
|
|
767
|
+
}
|
|
768
|
+
async createAddressBook({ containerUri, name }) {
|
|
769
|
+
const operation = createAddressBook(containerUri, name);
|
|
770
|
+
await executeUpdate(this.fetcher, this.updater, operation);
|
|
771
|
+
return operation.uri;
|
|
772
|
+
}
|
|
773
|
+
async createNewContact({ addressBookUri, contact, groupUris }) {
|
|
774
|
+
const contactQuery = await this.executeCreateNewContact(addressBookUri, contact);
|
|
775
|
+
await this.executeAddContactToGroups(groupUris, contactQuery);
|
|
776
|
+
return contactQuery.contactNode.uri;
|
|
777
|
+
}
|
|
778
|
+
async executeAddContactToGroups(groupUris, contactQuery) {
|
|
779
|
+
const groupNodes = (groupUris ?? []).map((it) => namedNode(it));
|
|
780
|
+
await this.fetchAll(groupNodes);
|
|
781
|
+
const groupUpdates = groupNodes.map((groupNode) => {
|
|
782
|
+
const groupQuery = new GroupQuery(this.store, groupNode);
|
|
783
|
+
const operation = addContactToGroup(contactQuery, groupQuery);
|
|
784
|
+
return executeUpdate(this.fetcher, this.updater, operation);
|
|
785
|
+
});
|
|
786
|
+
await Promise.allSettled(groupUpdates);
|
|
787
|
+
}
|
|
788
|
+
async executeCreateNewContact(addressBookUri, contact) {
|
|
789
|
+
const addressBookNode = namedNode(addressBookUri);
|
|
790
|
+
await this.fetchNode(addressBookNode);
|
|
791
|
+
const operation = createNewContact(new AddressBookQuery(this.store, addressBookNode), contact);
|
|
792
|
+
await executeUpdate(this.fetcher, this.updater, operation);
|
|
793
|
+
return new ContactQuery(this.store, namedNode(operation.uri));
|
|
794
|
+
}
|
|
795
|
+
async readContact(uri) {
|
|
796
|
+
const contactNode = namedNode(uri);
|
|
797
|
+
await this.fetchNode(contactNode);
|
|
798
|
+
const query = new ContactQuery(this.store, contactNode);
|
|
799
|
+
const name = query.queryName();
|
|
800
|
+
const emails = query.queryEmails();
|
|
801
|
+
const phoneNumbers = query.queryPhoneNumbers();
|
|
802
|
+
return {
|
|
803
|
+
uri,
|
|
804
|
+
name,
|
|
805
|
+
emails,
|
|
806
|
+
phoneNumbers
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
async createNewGroup({ addressBookUri, groupName }) {
|
|
810
|
+
const addressBookNode = namedNode(addressBookUri);
|
|
811
|
+
await this.fetchNode(addressBookNode);
|
|
812
|
+
const query = new AddressBookQuery(this.store, addressBookNode);
|
|
813
|
+
const operation = createNewGroup(query, groupName);
|
|
814
|
+
await executeUpdate(this.fetcher, this.updater, operation);
|
|
815
|
+
return operation.uri;
|
|
816
|
+
}
|
|
817
|
+
async readGroup(uri) {
|
|
818
|
+
const groupNode = namedNode(uri);
|
|
819
|
+
await this.fetchNode(groupNode);
|
|
820
|
+
const query = new GroupQuery(this.store, groupNode);
|
|
821
|
+
const name = query.queryName();
|
|
822
|
+
const members = query.queryMembers();
|
|
823
|
+
return {
|
|
824
|
+
uri,
|
|
825
|
+
name,
|
|
826
|
+
members
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
async addContactToGroup({ contactUri, groupUri }) {
|
|
830
|
+
const contactNode = namedNode(contactUri);
|
|
831
|
+
const groupNode = namedNode(groupUri);
|
|
832
|
+
await this.fetchNode(contactNode);
|
|
833
|
+
const contactQuery = new ContactQuery(this.store, contactNode);
|
|
834
|
+
const groupQuery = new GroupQuery(this.store, groupNode);
|
|
835
|
+
const operation = addContactToGroup(contactQuery, groupQuery);
|
|
836
|
+
await executeUpdate(this.fetcher, this.updater, operation);
|
|
837
|
+
}
|
|
838
|
+
async removeContactFromGroup({ contactUri, groupUri }) {
|
|
839
|
+
const contactNode = namedNode(contactUri);
|
|
840
|
+
const groupNode = namedNode(groupUri);
|
|
841
|
+
await this.fetchNode(groupNode);
|
|
842
|
+
const contactQuery = new ContactQuery(this.store, contactNode);
|
|
843
|
+
const groupQuery = new GroupQuery(this.store, groupNode);
|
|
844
|
+
const operation = removeContactFromGroup(contactQuery, groupQuery);
|
|
845
|
+
await executeUpdate(this.fetcher, this.updater, operation);
|
|
846
|
+
}
|
|
847
|
+
async addNewPhoneNumber({ contactUri, newPhoneNumber }) {
|
|
848
|
+
const contactNode = namedNode(contactUri);
|
|
849
|
+
const operation = addNewPhoneNumber(contactNode, newPhoneNumber);
|
|
850
|
+
await executeUpdate(this.fetcher, this.updater, operation);
|
|
851
|
+
return operation.uri;
|
|
852
|
+
}
|
|
853
|
+
async addNewEmailAddress({ contactUri, newEmailAddress }) {
|
|
854
|
+
const contactNode = namedNode(contactUri);
|
|
855
|
+
const operation = addNewEmailAddress(contactNode, newEmailAddress);
|
|
856
|
+
await executeUpdate(this.fetcher, this.updater, operation);
|
|
857
|
+
return operation.uri;
|
|
858
|
+
}
|
|
859
|
+
async removePhoneNumber({ contactUri, phoneNumberUri }) {
|
|
860
|
+
const contactNode = namedNode(contactUri);
|
|
861
|
+
const phoneNumberNode = namedNode(phoneNumberUri);
|
|
862
|
+
await this.fetchNode(phoneNumberNode);
|
|
863
|
+
const operation = removePhoneNumber(contactNode, phoneNumberNode, this.store);
|
|
864
|
+
await executeUpdate(this.fetcher, this.updater, operation);
|
|
865
|
+
}
|
|
866
|
+
async removeEmailAddress({ contactUri, emailAddressUri }) {
|
|
867
|
+
const contactNode = namedNode(contactUri);
|
|
868
|
+
const emailAddressNode = namedNode(emailAddressUri);
|
|
869
|
+
await this.fetchNode(emailAddressNode);
|
|
870
|
+
const operation = removeEmailAddress(contactNode, emailAddressNode, this.store);
|
|
871
|
+
await executeUpdate(this.fetcher, this.updater, operation);
|
|
872
|
+
}
|
|
873
|
+
async listAddressBooks(webId) {
|
|
874
|
+
const profileNode = namedNode(webId);
|
|
875
|
+
await this.fetchNode(profileNode);
|
|
876
|
+
const profileQuery = new ProfileQuery(profileNode, this.store);
|
|
877
|
+
const publicTypeIndexNode = profileQuery.queryPublicTypeIndex();
|
|
878
|
+
const preferencesFile = profileQuery.queryPreferencesFile();
|
|
879
|
+
const promisePublicUris = this.fetchIndexedAddressBooks(publicTypeIndexNode);
|
|
880
|
+
const promisePrivateTypeIndex = this.fetchPrivateTypeIndex(profileNode, preferencesFile);
|
|
881
|
+
const [publicUris, privateTypeIndex] = await Promise.allSettled([
|
|
882
|
+
promisePublicUris,
|
|
883
|
+
promisePrivateTypeIndex
|
|
884
|
+
]);
|
|
885
|
+
const privateUris = privateTypeIndex.status === "fulfilled" ? await this.fetchIndexedAddressBooks(privateTypeIndex.value) : [];
|
|
886
|
+
return {
|
|
887
|
+
publicUris: publicUris.status === "fulfilled" ? publicUris.value : [],
|
|
888
|
+
privateUris
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
async fetchIndexedAddressBooks(publicTypeIndexNode) {
|
|
892
|
+
if (!publicTypeIndexNode) {
|
|
893
|
+
return [];
|
|
894
|
+
}
|
|
895
|
+
await this.fetchNode(publicTypeIndexNode);
|
|
896
|
+
return new TypeIndexQuery(this.store, publicTypeIndexNode).queryAddressBookInstances();
|
|
897
|
+
}
|
|
898
|
+
async fetchPrivateTypeIndex(profileNode, preferencesFile) {
|
|
899
|
+
if (!preferencesFile) {
|
|
900
|
+
return null;
|
|
901
|
+
}
|
|
902
|
+
await this.fetchNode(preferencesFile);
|
|
903
|
+
const preferencesQuery = new PreferencesQuery(this.store, profileNode, preferencesFile);
|
|
904
|
+
return preferencesQuery.queryPrivateTypeIndex();
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/index.js
|
|
909
|
+
var dist_default = ContactsModuleRdfLib;
|
|
910
|
+
export {
|
|
911
|
+
dist_default as default
|
|
912
|
+
};
|