@pod-os/core 0.18.1-rc.5f8057b.0 → 0.18.1-rc.93bb261.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-3LTXZPFZ.js → chunk-FVHR3ZCY.js} +11810 -21896
- package/dist/dist-B3GAMWT3.js +9771 -0
- package/dist/index.js +10293 -226
- package/lib/index.js +13231 -4157
- package/package.json +2 -2
- package/types/Store.d.ts +1 -2
- package/types/index.d.ts +3 -1
- package/types/offline-cache/index.d.ts +1 -1
- package/types/search/SearchGateway.d.ts +1 -1
- package/types/uri/index.d.ts +1 -0
- package/dist/dist-4BQLT63G.js +0 -694
package/dist/dist-4BQLT63G.js
DELETED
|
@@ -1,694 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Namespace,
|
|
3
|
-
isNamedNode,
|
|
4
|
-
lit,
|
|
5
|
-
namedNode,
|
|
6
|
-
require_short_unique_id,
|
|
7
|
-
st
|
|
8
|
-
} from "./chunk-3LTXZPFZ.js";
|
|
9
|
-
import {
|
|
10
|
-
__toESM
|
|
11
|
-
} from "./chunk-U67V476Y.js";
|
|
12
|
-
|
|
13
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/namespaces.js
|
|
14
|
-
var vcard = Namespace("http://www.w3.org/2006/vcard/ns#");
|
|
15
|
-
var dc = Namespace("http://purl.org/dc/elements/1.1/");
|
|
16
|
-
|
|
17
|
-
// ../node_modules/@solid-data-modules/rdflib-utils/dist/identifier/generate-id.js
|
|
18
|
-
var import_short_unique_id = __toESM(require_short_unique_id(), 1);
|
|
19
|
-
var uid = new import_short_unique_id.default({ length: 10 });
|
|
20
|
-
function generateId() {
|
|
21
|
-
return uid.rnd(6);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/AddressBookQuery.js
|
|
25
|
-
var AddressBookQuery = class {
|
|
26
|
-
constructor(store, addressBookNode) {
|
|
27
|
-
this.store = store;
|
|
28
|
-
this.addressBookNode = addressBookNode;
|
|
29
|
-
this.addressBookDoc = addressBookNode.doc();
|
|
30
|
-
}
|
|
31
|
-
proposeNewContactNode() {
|
|
32
|
-
return this.proposeNewNode("Person");
|
|
33
|
-
}
|
|
34
|
-
proposeNewGroupNode() {
|
|
35
|
-
return this.proposeNewNode("Group");
|
|
36
|
-
}
|
|
37
|
-
proposeNewNode(containerPath) {
|
|
38
|
-
const id = generateId();
|
|
39
|
-
const baseUri = this.addressBookNode.dir()?.uri;
|
|
40
|
-
return namedNode(`${baseUri}${containerPath}/${id}/index.ttl#this`);
|
|
41
|
-
}
|
|
42
|
-
queryTitle() {
|
|
43
|
-
return this.store.anyValue(this.addressBookNode, dc("title"), void 0, this.addressBookDoc) ?? "";
|
|
44
|
-
}
|
|
45
|
-
queryNameEmailIndex() {
|
|
46
|
-
const index = this.store.any(this.addressBookNode, vcard("nameEmailIndex"), void 0, this.addressBookDoc);
|
|
47
|
-
if (isNamedNode(index)) {
|
|
48
|
-
return index;
|
|
49
|
-
} else {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
queryContacts() {
|
|
54
|
-
const nameEmailIndex = this.queryNameEmailIndex();
|
|
55
|
-
return nameEmailIndex && isNamedNode(nameEmailIndex) ? this.store.each(null, vcard("inAddressBook"), this.addressBookNode, nameEmailIndex).filter((it) => isNamedNode(it)).map((node) => ({
|
|
56
|
-
name: this.store.anyValue(node, vcard("fn"), null, nameEmailIndex) ?? "",
|
|
57
|
-
uri: node.value
|
|
58
|
-
})) : [];
|
|
59
|
-
}
|
|
60
|
-
queryGroupIndex() {
|
|
61
|
-
const index = this.store.any(this.addressBookNode, vcard("groupIndex"), void 0, this.addressBookDoc);
|
|
62
|
-
if (isNamedNode(index)) {
|
|
63
|
-
return index;
|
|
64
|
-
} else {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
queryGroups() {
|
|
69
|
-
const groupIndex = this.queryGroupIndex();
|
|
70
|
-
return groupIndex && isNamedNode(groupIndex) ? this.store.each(this.addressBookNode, vcard("includesGroup"), null, groupIndex).filter((it) => isNamedNode(it)).map((node) => ({
|
|
71
|
-
name: this.store.anyValue(node, vcard("fn"), null, groupIndex) ?? "",
|
|
72
|
-
uri: node.value
|
|
73
|
-
})) : [];
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/ContactQuery.js
|
|
78
|
-
var MAILTO_URI_SCHEME = "mailto:";
|
|
79
|
-
var TEl_URI_SCHEME = "tel:";
|
|
80
|
-
var ContactQuery = class {
|
|
81
|
-
constructor(store, contactNode) {
|
|
82
|
-
this.store = store;
|
|
83
|
-
this.contactNode = contactNode;
|
|
84
|
-
this.contactDoc = contactNode.doc();
|
|
85
|
-
}
|
|
86
|
-
queryName() {
|
|
87
|
-
return this.store.anyValue(this.contactNode, vcard("fn"), void 0, this.contactDoc) ?? "";
|
|
88
|
-
}
|
|
89
|
-
queryEmails() {
|
|
90
|
-
const uris = this.getValuesOf(vcard("hasEmail"));
|
|
91
|
-
if (uris.length === 0) {
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
return uris.map((uri) => {
|
|
95
|
-
const valueNode = this.getValueNode(uri);
|
|
96
|
-
if (isMailtoNode(valueNode)) {
|
|
97
|
-
return {
|
|
98
|
-
uri,
|
|
99
|
-
value: valueNode.value.split(MAILTO_URI_SCHEME)[1]
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
}).filter((value) => !!value);
|
|
103
|
-
}
|
|
104
|
-
queryPhoneNumbers() {
|
|
105
|
-
const uris = this.getValuesOf(vcard("hasTelephone"));
|
|
106
|
-
if (uris.length === 0) {
|
|
107
|
-
return [];
|
|
108
|
-
}
|
|
109
|
-
return uris.map((uri) => {
|
|
110
|
-
const valueNode = this.getValueNode(uri);
|
|
111
|
-
if (isTelNode(valueNode)) {
|
|
112
|
-
return {
|
|
113
|
-
uri,
|
|
114
|
-
value: valueNode.value.split(TEl_URI_SCHEME)[1]
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}).filter((value) => !!value);
|
|
118
|
-
}
|
|
119
|
-
getValuesOf(predicate) {
|
|
120
|
-
return this.store.statementsMatching(this.contactNode, predicate, void 0, this.contactDoc).map((it) => it.object.value);
|
|
121
|
-
}
|
|
122
|
-
getValueNode(uri) {
|
|
123
|
-
return this.store.any(namedNode(uri), vcard("value"), void 0, this.contactDoc);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
function isMailtoNode(valueNode) {
|
|
127
|
-
return isNamedNode(valueNode) && valueNode.value.startsWith(MAILTO_URI_SCHEME);
|
|
128
|
-
}
|
|
129
|
-
function isTelNode(valueNode) {
|
|
130
|
-
return isNamedNode(valueNode) && valueNode.value.startsWith(TEl_URI_SCHEME);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/GroupQuery.js
|
|
134
|
-
var GroupQuery = class {
|
|
135
|
-
constructor(store, groupNode) {
|
|
136
|
-
this.store = store;
|
|
137
|
-
this.groupNode = groupNode;
|
|
138
|
-
this.groupDoc = groupNode.doc();
|
|
139
|
-
}
|
|
140
|
-
queryName() {
|
|
141
|
-
return this.store.anyValue(this.groupNode, vcard("fn"), void 0, this.groupDoc) ?? "";
|
|
142
|
-
}
|
|
143
|
-
queryMembers() {
|
|
144
|
-
return this.store.each(this.groupNode, vcard("hasMember"), null, this.groupDoc).filter((it) => isNamedNode(it)).map((node) => ({
|
|
145
|
-
uri: node.value,
|
|
146
|
-
name: this.store.anyValue(node, vcard("fn"), null, this.groupDoc) ?? ""
|
|
147
|
-
}));
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/createAddressBook.js
|
|
152
|
-
function createAddressBook(container, name) {
|
|
153
|
-
const id = generateId();
|
|
154
|
-
const uri = `${container}${id}/index.ttl#this`;
|
|
155
|
-
const nameEmailIndexUri = `${container}${id}/people.ttl`;
|
|
156
|
-
const groupIndexUri = `${container}${id}/groups.ttl`;
|
|
157
|
-
const insertions = [
|
|
158
|
-
st(namedNode(uri), namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vcard("AddressBook"), namedNode(uri).doc()),
|
|
159
|
-
st(namedNode(uri), dc("title"), lit(name), namedNode(uri).doc()),
|
|
160
|
-
st(namedNode(uri), vcard("nameEmailIndex"), namedNode(nameEmailIndexUri), namedNode(uri).doc()),
|
|
161
|
-
st(namedNode(uri), vcard("groupIndex"), namedNode(groupIndexUri), namedNode(uri).doc())
|
|
162
|
-
];
|
|
163
|
-
return {
|
|
164
|
-
uri,
|
|
165
|
-
deletions: [],
|
|
166
|
-
insertions,
|
|
167
|
-
filesToCreate: [{ url: nameEmailIndexUri }, { url: groupIndexUri }]
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// ../node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/executeUpdate.js
|
|
172
|
-
async function executeUpdate(fetcher, updater, operation) {
|
|
173
|
-
await updater.updateMany(operation.deletions, operation.insertions);
|
|
174
|
-
operation.filesToCreate.map((file) => {
|
|
175
|
-
createEmptyTurtleFile(fetcher, file.url);
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
function createEmptyTurtleFile(fetcher, url) {
|
|
179
|
-
return fetcher.webOperation("PUT", url, {
|
|
180
|
-
contentType: "text/turtle"
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// ../node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/fetchNode.js
|
|
185
|
-
async function fetchNode(fetcher, node) {
|
|
186
|
-
if (node) {
|
|
187
|
-
await fetcher.load(node.value);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// ../node_modules/@solid-data-modules/rdflib-utils/dist/namespaces/index.js
|
|
192
|
-
var rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
|
193
|
-
var solid = Namespace("http://www.w3.org/ns/solid/terms#");
|
|
194
|
-
var pim = Namespace("http://www.w3.org/ns/pim/space#");
|
|
195
|
-
var ldp = Namespace("http://www.w3.org/ns/ldp#");
|
|
196
|
-
|
|
197
|
-
// ../node_modules/@solid-data-modules/rdflib-utils/dist/queries/PreferencesQuery.js
|
|
198
|
-
var PreferencesQuery = class {
|
|
199
|
-
constructor(store, webIdNode, preferencesDoc) {
|
|
200
|
-
this.store = store;
|
|
201
|
-
this.webIdNode = webIdNode;
|
|
202
|
-
this.preferencesDoc = preferencesDoc;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Look up the private type index. Returns null if none is found or if the predicated does not link to a proper named node
|
|
206
|
-
*/
|
|
207
|
-
queryPrivateTypeIndex() {
|
|
208
|
-
const node = this.store.any(this.webIdNode, solid("privateTypeIndex"), null, this.preferencesDoc);
|
|
209
|
-
if (isNamedNode(node)) {
|
|
210
|
-
return node;
|
|
211
|
-
}
|
|
212
|
-
return null;
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
// ../node_modules/@solid-data-modules/rdflib-utils/dist/queries/ProfileQuery.js
|
|
217
|
-
var ProfileQuery = class {
|
|
218
|
-
constructor(webIdNode, store) {
|
|
219
|
-
this.webIdNode = webIdNode;
|
|
220
|
-
this.store = store;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Look up the public type index. Returns null if none is found or if the predicated does not link to a proper named node
|
|
224
|
-
*/
|
|
225
|
-
queryPublicTypeIndex() {
|
|
226
|
-
const predicate = solid("publicTypeIndex");
|
|
227
|
-
return this.queryNamedNode(predicate);
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Look up the preferences file. Returns null if none is found or if the predicated does not link to a proper named node
|
|
231
|
-
*/
|
|
232
|
-
queryPreferencesFile() {
|
|
233
|
-
const predicate = pim("preferencesFile");
|
|
234
|
-
return this.queryNamedNode(predicate);
|
|
235
|
-
}
|
|
236
|
-
queryNamedNode(predicate) {
|
|
237
|
-
const node = this.store.any(this.webIdNode, predicate, null, this.webIdNode.doc());
|
|
238
|
-
if (isNamedNode(node)) {
|
|
239
|
-
return node;
|
|
240
|
-
}
|
|
241
|
-
return null;
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
// ../node_modules/@solid-data-modules/rdflib-utils/dist/queries/TypeIndexQuery.js
|
|
246
|
-
var TypeIndexQuery = class {
|
|
247
|
-
constructor(store, typeIndexDoc) {
|
|
248
|
-
this.store = store;
|
|
249
|
-
this.typeIndexDoc = typeIndexDoc;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Look up the instances in the type registration for the given RDF class
|
|
253
|
-
* @param type - The RDF class to look up
|
|
254
|
-
* @returns A list of the URIs of the found instances
|
|
255
|
-
*/
|
|
256
|
-
queryInstancesForClass(type) {
|
|
257
|
-
const registrations = this.store.each(null, solid("forClass"), type, this.typeIndexDoc);
|
|
258
|
-
return registrations.flatMap((registration) => {
|
|
259
|
-
if (!isNamedNode(registration))
|
|
260
|
-
return [];
|
|
261
|
-
return this.getInstanceValues(registration);
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
getInstanceValues(registration) {
|
|
265
|
-
return this.store.each(registration, solid("instance"), null, this.typeIndexDoc).map((it) => it.value);
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
// ../node_modules/@solid-data-modules/rdflib-utils/dist/module/ModuleSupport.js
|
|
270
|
-
var ModuleSupport = class {
|
|
271
|
-
constructor(config) {
|
|
272
|
-
this.store = config.store;
|
|
273
|
-
this.fetcher = config.fetcher;
|
|
274
|
-
this.updater = config.updater;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Nullsafe fetching of a node
|
|
278
|
-
* @param node - A node to fetch, or null to do nothing at all
|
|
279
|
-
*/
|
|
280
|
-
async fetchNode(node) {
|
|
281
|
-
return fetchNode(this.fetcher, node);
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Fetch all the given nodes in parallel
|
|
285
|
-
* @param nodes
|
|
286
|
-
*/
|
|
287
|
-
async fetchAll(nodes) {
|
|
288
|
-
return Promise.all(nodes.map((it) => this.fetchNode(it)));
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Checks whether the resource identified by the given URL is a LDP container
|
|
292
|
-
* @param storageUrl - The URL to check
|
|
293
|
-
* @returns true if it is a container, false otherwise
|
|
294
|
-
*/
|
|
295
|
-
async isContainer(storageUrl) {
|
|
296
|
-
const storageNode = namedNode(storageUrl);
|
|
297
|
-
await this.fetcher.load(storageNode.value);
|
|
298
|
-
return this.store.holds(storageNode, rdf("type"), ldp("Container"), storageNode.doc());
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
// ../node_modules/@solid-data-modules/rdflib-utils/dist/update-operations/addInstanceToTypeIndex.js
|
|
303
|
-
function addInstanceToTypeIndex(typeIndexDoc, instanceUri, type) {
|
|
304
|
-
const registrationNode = namedNode(`${typeIndexDoc.value}#${generateId()}`);
|
|
305
|
-
return {
|
|
306
|
-
deletions: [],
|
|
307
|
-
filesToCreate: [],
|
|
308
|
-
insertions: [
|
|
309
|
-
st(registrationNode, rdf("type"), solid("TypeRegistration"), typeIndexDoc),
|
|
310
|
-
st(registrationNode, solid("forClass"), type, typeIndexDoc),
|
|
311
|
-
st(registrationNode, solid("instance"), namedNode(instanceUri), typeIndexDoc)
|
|
312
|
-
]
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/createNewContact.js
|
|
317
|
-
function createNewContact(addressBook, newContact) {
|
|
318
|
-
const contactNode = addressBook.proposeNewContactNode();
|
|
319
|
-
const nameEmailIndex = addressBook.queryNameEmailIndex();
|
|
320
|
-
if (!nameEmailIndex) {
|
|
321
|
-
throw new Error("name-email index is missing or invalid");
|
|
322
|
-
}
|
|
323
|
-
const insertions = [
|
|
324
|
-
st(contactNode, vcard("inAddressBook"), addressBook.addressBookNode, nameEmailIndex),
|
|
325
|
-
st(contactNode, vcard("fn"), lit(newContact.name), nameEmailIndex),
|
|
326
|
-
st(contactNode, vcard("fn"), lit(newContact.name), contactNode.doc()),
|
|
327
|
-
st(contactNode, rdf("type"), vcard("Individual"), contactNode.doc())
|
|
328
|
-
];
|
|
329
|
-
if (newContact.email) {
|
|
330
|
-
const emailNode = namedNode(contactNode.doc().uri + "#email");
|
|
331
|
-
insertions.push(st(contactNode, vcard("hasEmail"), emailNode, contactNode.doc()), st(emailNode, vcard("value"), namedNode("mailto:" + newContact.email), contactNode.doc()));
|
|
332
|
-
}
|
|
333
|
-
if (newContact.phoneNumber) {
|
|
334
|
-
const phoneNode = namedNode(contactNode.doc().uri + "#phone");
|
|
335
|
-
insertions.push(st(contactNode, vcard("hasTelephone"), phoneNode, contactNode.doc()), st(phoneNode, vcard("value"), namedNode("tel:" + newContact.phoneNumber), contactNode.doc()));
|
|
336
|
-
}
|
|
337
|
-
return {
|
|
338
|
-
uri: contactNode.uri,
|
|
339
|
-
deletions: [],
|
|
340
|
-
insertions,
|
|
341
|
-
filesToCreate: []
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/createNewGroup.js
|
|
346
|
-
function createNewGroup(addressBook, groupName) {
|
|
347
|
-
const groupIndex = addressBook.queryGroupIndex();
|
|
348
|
-
if (!groupIndex) {
|
|
349
|
-
throw new Error("group index is missing or invalid");
|
|
350
|
-
}
|
|
351
|
-
const groupNode = addressBook.proposeNewGroupNode();
|
|
352
|
-
const groupDoc = groupNode.doc();
|
|
353
|
-
return {
|
|
354
|
-
uri: groupNode.uri,
|
|
355
|
-
insertions: [
|
|
356
|
-
st(groupNode, vcard("fn"), lit(groupName), groupIndex),
|
|
357
|
-
st(groupNode, vcard("fn"), lit(groupName), groupDoc),
|
|
358
|
-
st(groupNode, rdf("type"), vcard("Group"), groupDoc),
|
|
359
|
-
st(addressBook.addressBookNode, vcard("includesGroup"), groupNode, groupIndex)
|
|
360
|
-
],
|
|
361
|
-
deletions: [],
|
|
362
|
-
filesToCreate: []
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addContactToGroup.js
|
|
367
|
-
function addContactToGroup(contactQuery, groupQuery) {
|
|
368
|
-
const name = contactQuery.queryName();
|
|
369
|
-
return {
|
|
370
|
-
insertions: [
|
|
371
|
-
st(groupQuery.groupNode, vcard("hasMember"), contactQuery.contactNode, groupQuery.groupNode.doc()),
|
|
372
|
-
st(contactQuery.contactNode, vcard("fn"), lit(name), groupQuery.groupNode.doc())
|
|
373
|
-
],
|
|
374
|
-
deletions: [],
|
|
375
|
-
filesToCreate: []
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addNewEmailAddress.js
|
|
380
|
-
function addNewEmailAddress(contactNode, emailAddress) {
|
|
381
|
-
const id = generateId();
|
|
382
|
-
const uri = `${contactNode.doc().uri}#${id}`;
|
|
383
|
-
return {
|
|
384
|
-
uri,
|
|
385
|
-
insertions: [
|
|
386
|
-
st(contactNode, vcard("hasEmail"), namedNode(uri), contactNode.doc()),
|
|
387
|
-
st(namedNode(uri), vcard("value"), namedNode("mailto:" + emailAddress), contactNode.doc())
|
|
388
|
-
],
|
|
389
|
-
deletions: [],
|
|
390
|
-
filesToCreate: []
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addNewPhoneNumber.js
|
|
395
|
-
function addNewPhoneNumber(contactNode, phoneNumber) {
|
|
396
|
-
const id = generateId();
|
|
397
|
-
const uri = `${contactNode.doc().uri}#${id}`;
|
|
398
|
-
return {
|
|
399
|
-
uri,
|
|
400
|
-
insertions: [
|
|
401
|
-
st(contactNode, vcard("hasTelephone"), namedNode(uri), contactNode.doc()),
|
|
402
|
-
st(namedNode(uri), vcard("value"), namedNode("tel:" + phoneNumber), contactNode.doc())
|
|
403
|
-
],
|
|
404
|
-
deletions: [],
|
|
405
|
-
filesToCreate: []
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removeContactFromGroup.js
|
|
410
|
-
function removeContactFromGroup(contactQuery, groupQuery) {
|
|
411
|
-
const contactUri = contactQuery.contactNode.uri;
|
|
412
|
-
const member = groupQuery.queryMembers().find((it) => it.uri === contactUri);
|
|
413
|
-
if (!member) {
|
|
414
|
-
throw new Error("member not found in group");
|
|
415
|
-
}
|
|
416
|
-
return {
|
|
417
|
-
insertions: [],
|
|
418
|
-
deletions: [
|
|
419
|
-
st(groupQuery.groupNode, vcard("hasMember"), contactQuery.contactNode, groupQuery.groupNode.doc()),
|
|
420
|
-
st(contactQuery.contactNode, vcard("fn"), lit(member.name), groupQuery.groupNode.doc())
|
|
421
|
-
],
|
|
422
|
-
filesToCreate: []
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removeEmailAddress.js
|
|
427
|
-
function removeEmailAddress(contactNode, emailNode, store) {
|
|
428
|
-
const emailStatements = store.statementsMatching(emailNode, null, null, emailNode.doc());
|
|
429
|
-
return {
|
|
430
|
-
insertions: [],
|
|
431
|
-
deletions: [
|
|
432
|
-
...emailStatements,
|
|
433
|
-
st(contactNode, vcard("hasEmail"), emailNode, contactNode.doc())
|
|
434
|
-
],
|
|
435
|
-
filesToCreate: []
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removePhoneNumber.js
|
|
440
|
-
function removePhoneNumber(contactNode, phoneNode, store) {
|
|
441
|
-
const phoneStatements = store.statementsMatching(phoneNode, null, null, phoneNode.doc());
|
|
442
|
-
return {
|
|
443
|
-
insertions: [],
|
|
444
|
-
deletions: [
|
|
445
|
-
...phoneStatements,
|
|
446
|
-
st(contactNode, vcard("hasTelephone"), phoneNode, contactNode.doc())
|
|
447
|
-
],
|
|
448
|
-
filesToCreate: []
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/renameContact.js
|
|
453
|
-
function renameContact(store, contactNode, newName) {
|
|
454
|
-
const deletions = store.statementsMatching(contactNode, vcard("fn"), null, null);
|
|
455
|
-
const insertions = deletions.map((it) => st(it.subject, it.predicate, lit(newName), it.graph));
|
|
456
|
-
return {
|
|
457
|
-
insertions,
|
|
458
|
-
deletions,
|
|
459
|
-
filesToCreate: []
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/updateEmailAddress.js
|
|
464
|
-
function updateEmailAddress(emailAddressNode, newEmailAddress, store) {
|
|
465
|
-
const oldValue = store.any(emailAddressNode, vcard("value"));
|
|
466
|
-
const deletions = oldValue ? [st(emailAddressNode, vcard("value"), oldValue, emailAddressNode.doc())] : [];
|
|
467
|
-
const insertions = [
|
|
468
|
-
st(emailAddressNode, vcard("value"), namedNode("mailto:" + newEmailAddress), emailAddressNode.doc())
|
|
469
|
-
];
|
|
470
|
-
return {
|
|
471
|
-
insertions,
|
|
472
|
-
deletions,
|
|
473
|
-
filesToCreate: []
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/updatePhoneNumber.js
|
|
478
|
-
function updatePhoneNumber(phoneNumberNode, newPhoneNumber, store) {
|
|
479
|
-
const oldValue = store.any(phoneNumberNode, vcard("value"));
|
|
480
|
-
const deletions = oldValue ? [st(phoneNumberNode, vcard("value"), oldValue, phoneNumberNode.doc())] : [];
|
|
481
|
-
const insertions = [
|
|
482
|
-
st(phoneNumberNode, vcard("value"), namedNode("tel:" + newPhoneNumber), phoneNumberNode.doc())
|
|
483
|
-
];
|
|
484
|
-
return {
|
|
485
|
-
insertions,
|
|
486
|
-
deletions,
|
|
487
|
-
filesToCreate: []
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/ContactsModuleRdfLib.js
|
|
492
|
-
var VCARD_ADDRESS_BOOK = vcard("AddressBook");
|
|
493
|
-
var ContactsModuleRdfLib = class {
|
|
494
|
-
constructor(config) {
|
|
495
|
-
this.support = new ModuleSupport(config);
|
|
496
|
-
this.store = config.store;
|
|
497
|
-
this.fetcher = config.fetcher;
|
|
498
|
-
this.updater = config.updater;
|
|
499
|
-
}
|
|
500
|
-
async readAddressBook(uri) {
|
|
501
|
-
const addressBookNode = namedNode(uri);
|
|
502
|
-
await this.support.fetchNode(addressBookNode);
|
|
503
|
-
const query = new AddressBookQuery(this.store, addressBookNode);
|
|
504
|
-
const title = query.queryTitle();
|
|
505
|
-
const nameEmailIndex = query.queryNameEmailIndex();
|
|
506
|
-
const groupIndex = query.queryGroupIndex();
|
|
507
|
-
await this.support.fetchAll([nameEmailIndex, groupIndex]);
|
|
508
|
-
const contacts = query.queryContacts();
|
|
509
|
-
const groups = query.queryGroups();
|
|
510
|
-
return {
|
|
511
|
-
uri,
|
|
512
|
-
title,
|
|
513
|
-
contacts,
|
|
514
|
-
groups
|
|
515
|
-
};
|
|
516
|
-
}
|
|
517
|
-
async createAddressBook({ containerUri, name, ownerWebId }) {
|
|
518
|
-
const operation = createAddressBook(containerUri, name);
|
|
519
|
-
await executeUpdate(this.fetcher, this.updater, operation);
|
|
520
|
-
if (ownerWebId) {
|
|
521
|
-
await this.updatePrivateTypeIndex(ownerWebId, operation.uri);
|
|
522
|
-
}
|
|
523
|
-
return operation.uri;
|
|
524
|
-
}
|
|
525
|
-
async updatePrivateTypeIndex(ownerWebId, addressBookUri) {
|
|
526
|
-
const profileNode = namedNode(ownerWebId);
|
|
527
|
-
await this.support.fetchNode(profileNode);
|
|
528
|
-
const profileQuery = new ProfileQuery(profileNode, this.store);
|
|
529
|
-
const preferencesFile = profileQuery.queryPreferencesFile();
|
|
530
|
-
const privateTypeIndex = await this.fetchPrivateTypeIndex(profileNode, preferencesFile);
|
|
531
|
-
if (!privateTypeIndex) {
|
|
532
|
-
throw new Error(`Private type not found for WebID ${ownerWebId}.`);
|
|
533
|
-
}
|
|
534
|
-
const operation = addInstanceToTypeIndex(privateTypeIndex, addressBookUri, VCARD_ADDRESS_BOOK);
|
|
535
|
-
await executeUpdate(this.fetcher, this.updater, operation);
|
|
536
|
-
}
|
|
537
|
-
async createNewContact({ addressBookUri, contact, groupUris }) {
|
|
538
|
-
const contactQuery = await this.executeCreateNewContact(addressBookUri, contact);
|
|
539
|
-
await this.executeAddContactToGroups(groupUris, contactQuery);
|
|
540
|
-
return contactQuery.contactNode.uri;
|
|
541
|
-
}
|
|
542
|
-
async executeAddContactToGroups(groupUris, contactQuery) {
|
|
543
|
-
const groupNodes = (groupUris ?? []).map((it) => namedNode(it));
|
|
544
|
-
await this.support.fetchAll(groupNodes);
|
|
545
|
-
const groupUpdates = groupNodes.map((groupNode) => {
|
|
546
|
-
const groupQuery = new GroupQuery(this.store, groupNode);
|
|
547
|
-
const operation = addContactToGroup(contactQuery, groupQuery);
|
|
548
|
-
return executeUpdate(this.fetcher, this.updater, operation);
|
|
549
|
-
});
|
|
550
|
-
await Promise.allSettled(groupUpdates);
|
|
551
|
-
}
|
|
552
|
-
async executeCreateNewContact(addressBookUri, contact) {
|
|
553
|
-
const addressBookNode = namedNode(addressBookUri);
|
|
554
|
-
await this.support.fetchNode(addressBookNode);
|
|
555
|
-
const operation = createNewContact(new AddressBookQuery(this.store, addressBookNode), contact);
|
|
556
|
-
await executeUpdate(this.fetcher, this.updater, operation);
|
|
557
|
-
return new ContactQuery(this.store, namedNode(operation.uri));
|
|
558
|
-
}
|
|
559
|
-
async readContact(uri) {
|
|
560
|
-
const contactNode = namedNode(uri);
|
|
561
|
-
await this.support.fetchNode(contactNode);
|
|
562
|
-
const query = new ContactQuery(this.store, contactNode);
|
|
563
|
-
const name = query.queryName();
|
|
564
|
-
const emails = query.queryEmails();
|
|
565
|
-
const phoneNumbers = query.queryPhoneNumbers();
|
|
566
|
-
return {
|
|
567
|
-
uri,
|
|
568
|
-
name,
|
|
569
|
-
emails,
|
|
570
|
-
phoneNumbers
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
async createNewGroup({ addressBookUri, groupName }) {
|
|
574
|
-
const addressBookNode = namedNode(addressBookUri);
|
|
575
|
-
await this.support.fetchNode(addressBookNode);
|
|
576
|
-
const query = new AddressBookQuery(this.store, addressBookNode);
|
|
577
|
-
const operation = createNewGroup(query, groupName);
|
|
578
|
-
await executeUpdate(this.fetcher, this.updater, operation);
|
|
579
|
-
return operation.uri;
|
|
580
|
-
}
|
|
581
|
-
async readGroup(uri) {
|
|
582
|
-
const groupNode = namedNode(uri);
|
|
583
|
-
await this.support.fetchNode(groupNode);
|
|
584
|
-
const query = new GroupQuery(this.store, groupNode);
|
|
585
|
-
const name = query.queryName();
|
|
586
|
-
const members = query.queryMembers();
|
|
587
|
-
return {
|
|
588
|
-
uri,
|
|
589
|
-
name,
|
|
590
|
-
members
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
|
-
async addContactToGroup({ contactUri, groupUri }) {
|
|
594
|
-
const contactNode = namedNode(contactUri);
|
|
595
|
-
const groupNode = namedNode(groupUri);
|
|
596
|
-
await this.support.fetchNode(contactNode);
|
|
597
|
-
const contactQuery = new ContactQuery(this.store, contactNode);
|
|
598
|
-
const groupQuery = new GroupQuery(this.store, groupNode);
|
|
599
|
-
const operation = addContactToGroup(contactQuery, groupQuery);
|
|
600
|
-
await executeUpdate(this.fetcher, this.updater, operation);
|
|
601
|
-
}
|
|
602
|
-
async removeContactFromGroup({ contactUri, groupUri }) {
|
|
603
|
-
const contactNode = namedNode(contactUri);
|
|
604
|
-
const groupNode = namedNode(groupUri);
|
|
605
|
-
await this.support.fetchNode(groupNode);
|
|
606
|
-
const contactQuery = new ContactQuery(this.store, contactNode);
|
|
607
|
-
const groupQuery = new GroupQuery(this.store, groupNode);
|
|
608
|
-
const operation = removeContactFromGroup(contactQuery, groupQuery);
|
|
609
|
-
await executeUpdate(this.fetcher, this.updater, operation);
|
|
610
|
-
}
|
|
611
|
-
async addNewPhoneNumber({ contactUri, newPhoneNumber }) {
|
|
612
|
-
const contactNode = namedNode(contactUri);
|
|
613
|
-
const operation = addNewPhoneNumber(contactNode, newPhoneNumber);
|
|
614
|
-
await executeUpdate(this.fetcher, this.updater, operation);
|
|
615
|
-
return operation.uri;
|
|
616
|
-
}
|
|
617
|
-
async addNewEmailAddress({ contactUri, newEmailAddress }) {
|
|
618
|
-
const contactNode = namedNode(contactUri);
|
|
619
|
-
const operation = addNewEmailAddress(contactNode, newEmailAddress);
|
|
620
|
-
await executeUpdate(this.fetcher, this.updater, operation);
|
|
621
|
-
return operation.uri;
|
|
622
|
-
}
|
|
623
|
-
async removePhoneNumber({ contactUri, phoneNumberUri }) {
|
|
624
|
-
const contactNode = namedNode(contactUri);
|
|
625
|
-
const phoneNumberNode = namedNode(phoneNumberUri);
|
|
626
|
-
await this.support.fetchNode(phoneNumberNode);
|
|
627
|
-
const operation = removePhoneNumber(contactNode, phoneNumberNode, this.store);
|
|
628
|
-
await executeUpdate(this.fetcher, this.updater, operation);
|
|
629
|
-
}
|
|
630
|
-
async removeEmailAddress({ contactUri, emailAddressUri }) {
|
|
631
|
-
const contactNode = namedNode(contactUri);
|
|
632
|
-
const emailAddressNode = namedNode(emailAddressUri);
|
|
633
|
-
await this.support.fetchNode(emailAddressNode);
|
|
634
|
-
const operation = removeEmailAddress(contactNode, emailAddressNode, this.store);
|
|
635
|
-
await executeUpdate(this.fetcher, this.updater, operation);
|
|
636
|
-
}
|
|
637
|
-
async updatePhoneNumber({ phoneNumberUri, newPhoneNumber }) {
|
|
638
|
-
const phoneNumberNode = namedNode(phoneNumberUri);
|
|
639
|
-
await this.support.fetchNode(phoneNumberNode);
|
|
640
|
-
const operation = updatePhoneNumber(phoneNumberNode, newPhoneNumber, this.store);
|
|
641
|
-
await executeUpdate(this.fetcher, this.updater, operation);
|
|
642
|
-
}
|
|
643
|
-
async updateEmailAddress({ emailAddressUri, newEmailAddress }) {
|
|
644
|
-
const emailAddressNode = namedNode(emailAddressUri);
|
|
645
|
-
await this.support.fetchNode(emailAddressNode);
|
|
646
|
-
const operation = updateEmailAddress(emailAddressNode, newEmailAddress, this.store);
|
|
647
|
-
await executeUpdate(this.fetcher, this.updater, operation);
|
|
648
|
-
}
|
|
649
|
-
async listAddressBooks(webId) {
|
|
650
|
-
const profileNode = namedNode(webId);
|
|
651
|
-
await this.support.fetchNode(profileNode);
|
|
652
|
-
const profileQuery = new ProfileQuery(profileNode, this.store);
|
|
653
|
-
const publicTypeIndexNode = profileQuery.queryPublicTypeIndex();
|
|
654
|
-
const preferencesFile = profileQuery.queryPreferencesFile();
|
|
655
|
-
const promisePublicUris = this.fetchIndexedAddressBooks(publicTypeIndexNode);
|
|
656
|
-
const promisePrivateTypeIndex = this.fetchPrivateTypeIndex(profileNode, preferencesFile);
|
|
657
|
-
const [publicUris, privateTypeIndex] = await Promise.allSettled([
|
|
658
|
-
promisePublicUris,
|
|
659
|
-
promisePrivateTypeIndex
|
|
660
|
-
]);
|
|
661
|
-
const privateUris = privateTypeIndex.status === "fulfilled" ? await this.fetchIndexedAddressBooks(privateTypeIndex.value) : [];
|
|
662
|
-
return {
|
|
663
|
-
publicUris: publicUris.status === "fulfilled" ? publicUris.value : [],
|
|
664
|
-
privateUris
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
async fetchIndexedAddressBooks(publicTypeIndexNode) {
|
|
668
|
-
if (!publicTypeIndexNode) {
|
|
669
|
-
return [];
|
|
670
|
-
}
|
|
671
|
-
await this.support.fetchNode(publicTypeIndexNode);
|
|
672
|
-
return new TypeIndexQuery(this.store, publicTypeIndexNode).queryInstancesForClass(VCARD_ADDRESS_BOOK);
|
|
673
|
-
}
|
|
674
|
-
async fetchPrivateTypeIndex(profileNode, preferencesFile) {
|
|
675
|
-
if (!preferencesFile) {
|
|
676
|
-
return null;
|
|
677
|
-
}
|
|
678
|
-
await this.support.fetchNode(preferencesFile);
|
|
679
|
-
const preferencesQuery = new PreferencesQuery(this.store, profileNode, preferencesFile);
|
|
680
|
-
return preferencesQuery.queryPrivateTypeIndex();
|
|
681
|
-
}
|
|
682
|
-
async renameContact({ contactUri, newName }) {
|
|
683
|
-
const contactNode = namedNode(contactUri);
|
|
684
|
-
await this.support.fetchNode(contactNode);
|
|
685
|
-
const operation = renameContact(this.store, contactNode, newName);
|
|
686
|
-
await executeUpdate(this.fetcher, this.updater, operation);
|
|
687
|
-
}
|
|
688
|
-
};
|
|
689
|
-
|
|
690
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/index.js
|
|
691
|
-
var dist_default = ContactsModuleRdfLib;
|
|
692
|
-
export {
|
|
693
|
-
dist_default as default
|
|
694
|
-
};
|