@pod-os/core 0.12.1-eddb6ac.0 → 0.12.1-facecbd.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-7C7N3OSJ.js → chunk-7VQUARYZ.js} +421 -623
- package/dist/{dist-762OQHAF.js → dist-F3EUFQHU.js} +283 -159
- package/dist/index.js +1961 -2495
- package/dist/{jsonld-REJIJLLT.js → jsonld-ECVURSS6.js} +2 -3
- package/lib/index.js +2856 -3379
- package/package.json +16 -16
- package/types/Store.spec.d.ts +0 -1
- package/types/thing/Thing.d.ts +2 -0
- package/types/thing/index.d.ts +1 -0
- package/types/thing/labelFromUri.d.ts +1 -0
- package/types/thing/labelFromUri.spec.d.ts +1 -0
- /package/dist/{chunk-5NEDDTD5.js → chunk-U67V476Y.js} +0 -0
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
lit,
|
|
5
5
|
namedNode,
|
|
6
6
|
st
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-7VQUARYZ.js";
|
|
8
8
|
import {
|
|
9
9
|
__commonJS,
|
|
10
10
|
__toESM
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-U67V476Y.js";
|
|
12
12
|
|
|
13
13
|
// ../node_modules/short-unique-id/dist/short-unique-id.js
|
|
14
14
|
var require_short_unique_id = __commonJS({
|
|
@@ -353,13 +353,10 @@ var require_short_unique_id = __commonJS({
|
|
|
353
353
|
});
|
|
354
354
|
|
|
355
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
356
|
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
357
|
var dc = Namespace("http://purl.org/dc/elements/1.1/");
|
|
361
358
|
|
|
362
|
-
// ../node_modules/@solid-data-modules/
|
|
359
|
+
// ../node_modules/@solid-data-modules/rdflib-utils/dist/identifier/generate-id.js
|
|
363
360
|
var import_short_unique_id = __toESM(require_short_unique_id(), 1);
|
|
364
361
|
var uid = new import_short_unique_id.default({ length: 10 });
|
|
365
362
|
function generateId() {
|
|
@@ -475,6 +472,24 @@ function isTelNode(valueNode) {
|
|
|
475
472
|
return isNamedNode(valueNode) && valueNode.value.startsWith(TEl_URI_SCHEME);
|
|
476
473
|
}
|
|
477
474
|
|
|
475
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/queries/GroupQuery.js
|
|
476
|
+
var GroupQuery = class {
|
|
477
|
+
constructor(store, groupNode) {
|
|
478
|
+
this.store = store;
|
|
479
|
+
this.groupNode = groupNode;
|
|
480
|
+
this.groupDoc = groupNode.doc();
|
|
481
|
+
}
|
|
482
|
+
queryName() {
|
|
483
|
+
return this.store.anyValue(this.groupNode, vcard("fn"), void 0, this.groupDoc) ?? "";
|
|
484
|
+
}
|
|
485
|
+
queryMembers() {
|
|
486
|
+
return this.store.each(this.groupNode, vcard("hasMember"), null, this.groupDoc).filter((it) => isNamedNode(it)).map((node) => ({
|
|
487
|
+
uri: node.value,
|
|
488
|
+
name: this.store.anyValue(node, vcard("fn"), null, this.groupDoc) ?? ""
|
|
489
|
+
}));
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
|
|
478
493
|
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/createAddressBook.js
|
|
479
494
|
function createAddressBook(container, name) {
|
|
480
495
|
const id = generateId();
|
|
@@ -491,7 +506,152 @@ function createAddressBook(container, name) {
|
|
|
491
506
|
uri,
|
|
492
507
|
deletions: [],
|
|
493
508
|
insertions,
|
|
494
|
-
filesToCreate: [{
|
|
509
|
+
filesToCreate: [{ url: nameEmailIndexUri }, { url: groupIndexUri }]
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// ../node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/executeUpdate.js
|
|
514
|
+
async function executeUpdate(fetcher, updater, operation) {
|
|
515
|
+
await updater.updateMany(operation.deletions, operation.insertions);
|
|
516
|
+
operation.filesToCreate.map((file) => {
|
|
517
|
+
createEmptyTurtleFile(fetcher, file.url);
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
function createEmptyTurtleFile(fetcher, url) {
|
|
521
|
+
return fetcher.webOperation("PUT", url, {
|
|
522
|
+
contentType: "text/turtle"
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// ../node_modules/@solid-data-modules/rdflib-utils/dist/web-operations/fetchNode.js
|
|
527
|
+
async function fetchNode(fetcher, node) {
|
|
528
|
+
if (node) {
|
|
529
|
+
await fetcher.load(node.value);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// ../node_modules/@solid-data-modules/rdflib-utils/dist/namespaces/index.js
|
|
534
|
+
var rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
|
|
535
|
+
var solid = Namespace("http://www.w3.org/ns/solid/terms#");
|
|
536
|
+
var pim = Namespace("http://www.w3.org/ns/pim/space#");
|
|
537
|
+
var ldp = Namespace("http://www.w3.org/ns/ldp#");
|
|
538
|
+
|
|
539
|
+
// ../node_modules/@solid-data-modules/rdflib-utils/dist/queries/PreferencesQuery.js
|
|
540
|
+
var PreferencesQuery = class {
|
|
541
|
+
constructor(store, webIdNode, preferencesDoc) {
|
|
542
|
+
this.store = store;
|
|
543
|
+
this.webIdNode = webIdNode;
|
|
544
|
+
this.preferencesDoc = preferencesDoc;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Look up the private type index. Returns null if none is found or if the predicated does not link to a proper named node
|
|
548
|
+
*/
|
|
549
|
+
queryPrivateTypeIndex() {
|
|
550
|
+
const node = this.store.any(this.webIdNode, solid("privateTypeIndex"), null, this.preferencesDoc);
|
|
551
|
+
if (isNamedNode(node)) {
|
|
552
|
+
return node;
|
|
553
|
+
}
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
// ../node_modules/@solid-data-modules/rdflib-utils/dist/queries/ProfileQuery.js
|
|
559
|
+
var ProfileQuery = class {
|
|
560
|
+
constructor(webIdNode, store) {
|
|
561
|
+
this.webIdNode = webIdNode;
|
|
562
|
+
this.store = store;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Look up the public type index. Returns null if none is found or if the predicated does not link to a proper named node
|
|
566
|
+
*/
|
|
567
|
+
queryPublicTypeIndex() {
|
|
568
|
+
const predicate = solid("publicTypeIndex");
|
|
569
|
+
return this.queryNamedNode(predicate);
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Look up the preferences file. Returns null if none is found or if the predicated does not link to a proper named node
|
|
573
|
+
*/
|
|
574
|
+
queryPreferencesFile() {
|
|
575
|
+
const predicate = pim("preferencesFile");
|
|
576
|
+
return this.queryNamedNode(predicate);
|
|
577
|
+
}
|
|
578
|
+
queryNamedNode(predicate) {
|
|
579
|
+
const node = this.store.any(this.webIdNode, predicate, null, this.webIdNode.doc());
|
|
580
|
+
if (isNamedNode(node)) {
|
|
581
|
+
return node;
|
|
582
|
+
}
|
|
583
|
+
return null;
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
// ../node_modules/@solid-data-modules/rdflib-utils/dist/queries/TypeIndexQuery.js
|
|
588
|
+
var TypeIndexQuery = class {
|
|
589
|
+
constructor(store, typeIndexDoc) {
|
|
590
|
+
this.store = store;
|
|
591
|
+
this.typeIndexDoc = typeIndexDoc;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Look up the instances in the type registration for the given RDF class
|
|
595
|
+
* @param type - The RDF class to look up
|
|
596
|
+
* @returns A list of the URIs of the found instances
|
|
597
|
+
*/
|
|
598
|
+
queryInstancesForClass(type) {
|
|
599
|
+
const registrations = this.store.each(null, solid("forClass"), type, this.typeIndexDoc);
|
|
600
|
+
return registrations.flatMap((registration) => {
|
|
601
|
+
if (!isNamedNode(registration))
|
|
602
|
+
return [];
|
|
603
|
+
return this.getInstanceValues(registration);
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
getInstanceValues(registration) {
|
|
607
|
+
return this.store.each(registration, solid("instance"), null, this.typeIndexDoc).map((it) => it.value);
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
// ../node_modules/@solid-data-modules/rdflib-utils/dist/module/ModuleSupport.js
|
|
612
|
+
var ModuleSupport = class {
|
|
613
|
+
constructor(config) {
|
|
614
|
+
this.store = config.store;
|
|
615
|
+
this.fetcher = config.fetcher;
|
|
616
|
+
this.updater = config.updater;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Nullsafe fetching of a node
|
|
620
|
+
* @param node - A node to fetch, or null to do nothing at all
|
|
621
|
+
*/
|
|
622
|
+
async fetchNode(node) {
|
|
623
|
+
return fetchNode(this.fetcher, node);
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Fetch all the given nodes in parallel
|
|
627
|
+
* @param nodes
|
|
628
|
+
*/
|
|
629
|
+
async fetchAll(nodes) {
|
|
630
|
+
return Promise.all(nodes.map((it) => this.fetchNode(it)));
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Checks whether the resource identified by the given URL is a LDP container
|
|
634
|
+
* @param storageUrl - The URL to check
|
|
635
|
+
* @returns true if it is a container, false otherwise
|
|
636
|
+
*/
|
|
637
|
+
async isContainer(storageUrl) {
|
|
638
|
+
const storageNode = namedNode(storageUrl);
|
|
639
|
+
await this.fetcher.load(storageNode.value);
|
|
640
|
+
return this.store.holds(storageNode, rdf("type"), ldp("Container"), storageNode.doc());
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
// ../node_modules/@solid-data-modules/rdflib-utils/dist/update-operations/addInstanceToTypeIndex.js
|
|
645
|
+
function addInstanceToTypeIndex(typeIndexDoc, instanceUri, type) {
|
|
646
|
+
const registrationNode = namedNode(`${typeIndexDoc.value}#${generateId()}`);
|
|
647
|
+
return {
|
|
648
|
+
deletions: [],
|
|
649
|
+
filesToCreate: [],
|
|
650
|
+
insertions: [
|
|
651
|
+
st(registrationNode, rdf("type"), solid("TypeRegistration"), typeIndexDoc),
|
|
652
|
+
st(registrationNode, solid("forClass"), type, typeIndexDoc),
|
|
653
|
+
st(registrationNode, solid("instance"), namedNode(instanceUri), typeIndexDoc)
|
|
654
|
+
]
|
|
495
655
|
};
|
|
496
656
|
}
|
|
497
657
|
|
|
@@ -524,26 +684,6 @@ function createNewContact(addressBook, newContact) {
|
|
|
524
684
|
};
|
|
525
685
|
}
|
|
526
686
|
|
|
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
687
|
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/createNewGroup.js
|
|
548
688
|
function createNewGroup(addressBook, groupName) {
|
|
549
689
|
const groupIndex = addressBook.queryGroupIndex();
|
|
@@ -565,29 +705,10 @@ function createNewGroup(addressBook, groupName) {
|
|
|
565
705
|
};
|
|
566
706
|
}
|
|
567
707
|
|
|
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
708
|
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addContactToGroup.js
|
|
587
709
|
function addContactToGroup(contactQuery, groupQuery) {
|
|
588
710
|
const name = contactQuery.queryName();
|
|
589
711
|
return {
|
|
590
|
-
uri: "",
|
|
591
712
|
insertions: [
|
|
592
713
|
st(groupQuery.groupNode, vcard("hasMember"), contactQuery.contactNode, groupQuery.groupNode.doc()),
|
|
593
714
|
st(contactQuery.contactNode, vcard("fn"), lit(name), groupQuery.groupNode.doc())
|
|
@@ -597,20 +718,17 @@ function addContactToGroup(contactQuery, groupQuery) {
|
|
|
597
718
|
};
|
|
598
719
|
}
|
|
599
720
|
|
|
600
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/
|
|
601
|
-
function
|
|
602
|
-
const
|
|
603
|
-
const
|
|
604
|
-
if (!member) {
|
|
605
|
-
throw new Error("member not found in group");
|
|
606
|
-
}
|
|
721
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addNewEmailAddress.js
|
|
722
|
+
function addNewEmailAddress(contactNode, emailAddress) {
|
|
723
|
+
const id = generateId();
|
|
724
|
+
const uri = `${contactNode.doc().uri}#${id}`;
|
|
607
725
|
return {
|
|
608
|
-
uri
|
|
609
|
-
insertions: [
|
|
610
|
-
|
|
611
|
-
st(
|
|
612
|
-
st(contactQuery.contactNode, vcard("fn"), lit(member.name), groupQuery.groupNode.doc())
|
|
726
|
+
uri,
|
|
727
|
+
insertions: [
|
|
728
|
+
st(contactNode, vcard("hasEmail"), namedNode(uri), contactNode.doc()),
|
|
729
|
+
st(namedNode(uri), vcard("value"), namedNode("mailto:" + emailAddress), contactNode.doc())
|
|
613
730
|
],
|
|
731
|
+
deletions: [],
|
|
614
732
|
filesToCreate: []
|
|
615
733
|
};
|
|
616
734
|
}
|
|
@@ -630,17 +748,32 @@ function addNewPhoneNumber(contactNode, phoneNumber) {
|
|
|
630
748
|
};
|
|
631
749
|
}
|
|
632
750
|
|
|
633
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/
|
|
634
|
-
function
|
|
635
|
-
const
|
|
636
|
-
const
|
|
751
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removeContactFromGroup.js
|
|
752
|
+
function removeContactFromGroup(contactQuery, groupQuery) {
|
|
753
|
+
const contactUri = contactQuery.contactNode.uri;
|
|
754
|
+
const member = groupQuery.queryMembers().find((it) => it.uri === contactUri);
|
|
755
|
+
if (!member) {
|
|
756
|
+
throw new Error("member not found in group");
|
|
757
|
+
}
|
|
637
758
|
return {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
st(
|
|
641
|
-
st(
|
|
759
|
+
insertions: [],
|
|
760
|
+
deletions: [
|
|
761
|
+
st(groupQuery.groupNode, vcard("hasMember"), contactQuery.contactNode, groupQuery.groupNode.doc()),
|
|
762
|
+
st(contactQuery.contactNode, vcard("fn"), lit(member.name), groupQuery.groupNode.doc())
|
|
763
|
+
],
|
|
764
|
+
filesToCreate: []
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removeEmailAddress.js
|
|
769
|
+
function removeEmailAddress(contactNode, emailNode, store) {
|
|
770
|
+
const emailStatements = store.statementsMatching(emailNode, null, null, emailNode.doc());
|
|
771
|
+
return {
|
|
772
|
+
insertions: [],
|
|
773
|
+
deletions: [
|
|
774
|
+
...emailStatements,
|
|
775
|
+
st(contactNode, vcard("hasEmail"), emailNode, contactNode.doc())
|
|
642
776
|
],
|
|
643
|
-
deletions: [],
|
|
644
777
|
filesToCreate: []
|
|
645
778
|
};
|
|
646
779
|
}
|
|
@@ -649,7 +782,6 @@ function addNewEmailAddress(contactNode, emailAddress) {
|
|
|
649
782
|
function removePhoneNumber(contactNode, phoneNode, store) {
|
|
650
783
|
const phoneStatements = store.statementsMatching(phoneNode, null, null, phoneNode.doc());
|
|
651
784
|
return {
|
|
652
|
-
uri: "",
|
|
653
785
|
insertions: [],
|
|
654
786
|
deletions: [
|
|
655
787
|
...phoneStatements,
|
|
@@ -659,97 +791,62 @@ function removePhoneNumber(contactNode, phoneNode, store) {
|
|
|
659
791
|
};
|
|
660
792
|
}
|
|
661
793
|
|
|
662
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/
|
|
663
|
-
function
|
|
664
|
-
const
|
|
794
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/renameContact.js
|
|
795
|
+
function renameContact(store, contactNode, newName) {
|
|
796
|
+
const deletions = store.statementsMatching(contactNode, vcard("fn"), null, null);
|
|
797
|
+
const insertions = deletions.map((it) => st(it.subject, it.predicate, lit(newName), it.graph));
|
|
665
798
|
return {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
deletions: [
|
|
669
|
-
...emailStatements,
|
|
670
|
-
st(contactNode, vcard("hasEmail"), emailNode, contactNode.doc())
|
|
671
|
-
],
|
|
799
|
+
insertions,
|
|
800
|
+
deletions,
|
|
672
801
|
filesToCreate: []
|
|
673
802
|
};
|
|
674
803
|
}
|
|
675
804
|
|
|
676
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
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
|
-
};
|
|
805
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/updateEmailAddress.js
|
|
806
|
+
function updateEmailAddress(emailAddressNode, newEmailAddress, store) {
|
|
807
|
+
const oldValue = store.any(emailAddressNode, vcard("value"));
|
|
808
|
+
const deletions = oldValue ? [st(emailAddressNode, vcard("value"), oldValue, emailAddressNode.doc())] : [];
|
|
809
|
+
const insertions = [
|
|
810
|
+
st(emailAddressNode, vcard("value"), namedNode("mailto:" + newEmailAddress), emailAddressNode.doc())
|
|
811
|
+
];
|
|
812
|
+
return {
|
|
813
|
+
insertions,
|
|
814
|
+
deletions,
|
|
815
|
+
filesToCreate: []
|
|
816
|
+
};
|
|
817
|
+
}
|
|
717
818
|
|
|
718
|
-
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
}
|
|
732
|
-
};
|
|
819
|
+
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/updatePhoneNumber.js
|
|
820
|
+
function updatePhoneNumber(phoneNumberNode, newPhoneNumber, store) {
|
|
821
|
+
const oldValue = store.any(phoneNumberNode, vcard("value"));
|
|
822
|
+
const deletions = oldValue ? [st(phoneNumberNode, vcard("value"), oldValue, phoneNumberNode.doc())] : [];
|
|
823
|
+
const insertions = [
|
|
824
|
+
st(phoneNumberNode, vcard("value"), namedNode("tel:" + newPhoneNumber), phoneNumberNode.doc())
|
|
825
|
+
];
|
|
826
|
+
return {
|
|
827
|
+
insertions,
|
|
828
|
+
deletions,
|
|
829
|
+
filesToCreate: []
|
|
830
|
+
};
|
|
831
|
+
}
|
|
733
832
|
|
|
734
833
|
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/ContactsModuleRdfLib.js
|
|
834
|
+
var VCARD_ADDRESS_BOOK = vcard("AddressBook");
|
|
735
835
|
var ContactsModuleRdfLib = class {
|
|
736
836
|
constructor(config) {
|
|
837
|
+
this.support = new ModuleSupport(config);
|
|
737
838
|
this.store = config.store;
|
|
738
839
|
this.fetcher = config.fetcher;
|
|
739
840
|
this.updater = config.updater;
|
|
740
841
|
}
|
|
741
842
|
async readAddressBook(uri) {
|
|
742
843
|
const addressBookNode = namedNode(uri);
|
|
743
|
-
await this.fetchNode(addressBookNode);
|
|
844
|
+
await this.support.fetchNode(addressBookNode);
|
|
744
845
|
const query = new AddressBookQuery(this.store, addressBookNode);
|
|
745
846
|
const title = query.queryTitle();
|
|
746
847
|
const nameEmailIndex = query.queryNameEmailIndex();
|
|
747
848
|
const groupIndex = query.queryGroupIndex();
|
|
748
|
-
await
|
|
749
|
-
this.fetchNode(nameEmailIndex),
|
|
750
|
-
this.fetchNode(groupIndex)
|
|
751
|
-
]);
|
|
752
|
-
await this.fetchAll([nameEmailIndex, groupIndex]);
|
|
849
|
+
await this.support.fetchAll([nameEmailIndex, groupIndex]);
|
|
753
850
|
const contacts = query.queryContacts();
|
|
754
851
|
const groups = query.queryGroups();
|
|
755
852
|
return {
|
|
@@ -759,17 +856,26 @@ var ContactsModuleRdfLib = class {
|
|
|
759
856
|
groups
|
|
760
857
|
};
|
|
761
858
|
}
|
|
762
|
-
async
|
|
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 }) {
|
|
859
|
+
async createAddressBook({ containerUri, name, ownerWebId }) {
|
|
769
860
|
const operation = createAddressBook(containerUri, name);
|
|
770
861
|
await executeUpdate(this.fetcher, this.updater, operation);
|
|
862
|
+
if (ownerWebId) {
|
|
863
|
+
await this.updatePrivateTypeIndex(ownerWebId, operation.uri);
|
|
864
|
+
}
|
|
771
865
|
return operation.uri;
|
|
772
866
|
}
|
|
867
|
+
async updatePrivateTypeIndex(ownerWebId, addressBookUri) {
|
|
868
|
+
const profileNode = namedNode(ownerWebId);
|
|
869
|
+
await this.support.fetchNode(profileNode);
|
|
870
|
+
const profileQuery = new ProfileQuery(profileNode, this.store);
|
|
871
|
+
const preferencesFile = profileQuery.queryPreferencesFile();
|
|
872
|
+
const privateTypeIndex = await this.fetchPrivateTypeIndex(profileNode, preferencesFile);
|
|
873
|
+
if (!privateTypeIndex) {
|
|
874
|
+
throw new Error(`Private type not found for WebID ${ownerWebId}.`);
|
|
875
|
+
}
|
|
876
|
+
const operation = addInstanceToTypeIndex(privateTypeIndex, addressBookUri, VCARD_ADDRESS_BOOK);
|
|
877
|
+
await executeUpdate(this.fetcher, this.updater, operation);
|
|
878
|
+
}
|
|
773
879
|
async createNewContact({ addressBookUri, contact, groupUris }) {
|
|
774
880
|
const contactQuery = await this.executeCreateNewContact(addressBookUri, contact);
|
|
775
881
|
await this.executeAddContactToGroups(groupUris, contactQuery);
|
|
@@ -777,7 +883,7 @@ var ContactsModuleRdfLib = class {
|
|
|
777
883
|
}
|
|
778
884
|
async executeAddContactToGroups(groupUris, contactQuery) {
|
|
779
885
|
const groupNodes = (groupUris ?? []).map((it) => namedNode(it));
|
|
780
|
-
await this.fetchAll(groupNodes);
|
|
886
|
+
await this.support.fetchAll(groupNodes);
|
|
781
887
|
const groupUpdates = groupNodes.map((groupNode) => {
|
|
782
888
|
const groupQuery = new GroupQuery(this.store, groupNode);
|
|
783
889
|
const operation = addContactToGroup(contactQuery, groupQuery);
|
|
@@ -787,14 +893,14 @@ var ContactsModuleRdfLib = class {
|
|
|
787
893
|
}
|
|
788
894
|
async executeCreateNewContact(addressBookUri, contact) {
|
|
789
895
|
const addressBookNode = namedNode(addressBookUri);
|
|
790
|
-
await this.fetchNode(addressBookNode);
|
|
896
|
+
await this.support.fetchNode(addressBookNode);
|
|
791
897
|
const operation = createNewContact(new AddressBookQuery(this.store, addressBookNode), contact);
|
|
792
898
|
await executeUpdate(this.fetcher, this.updater, operation);
|
|
793
899
|
return new ContactQuery(this.store, namedNode(operation.uri));
|
|
794
900
|
}
|
|
795
901
|
async readContact(uri) {
|
|
796
902
|
const contactNode = namedNode(uri);
|
|
797
|
-
await this.fetchNode(contactNode);
|
|
903
|
+
await this.support.fetchNode(contactNode);
|
|
798
904
|
const query = new ContactQuery(this.store, contactNode);
|
|
799
905
|
const name = query.queryName();
|
|
800
906
|
const emails = query.queryEmails();
|
|
@@ -808,7 +914,7 @@ var ContactsModuleRdfLib = class {
|
|
|
808
914
|
}
|
|
809
915
|
async createNewGroup({ addressBookUri, groupName }) {
|
|
810
916
|
const addressBookNode = namedNode(addressBookUri);
|
|
811
|
-
await this.fetchNode(addressBookNode);
|
|
917
|
+
await this.support.fetchNode(addressBookNode);
|
|
812
918
|
const query = new AddressBookQuery(this.store, addressBookNode);
|
|
813
919
|
const operation = createNewGroup(query, groupName);
|
|
814
920
|
await executeUpdate(this.fetcher, this.updater, operation);
|
|
@@ -816,7 +922,7 @@ var ContactsModuleRdfLib = class {
|
|
|
816
922
|
}
|
|
817
923
|
async readGroup(uri) {
|
|
818
924
|
const groupNode = namedNode(uri);
|
|
819
|
-
await this.fetchNode(groupNode);
|
|
925
|
+
await this.support.fetchNode(groupNode);
|
|
820
926
|
const query = new GroupQuery(this.store, groupNode);
|
|
821
927
|
const name = query.queryName();
|
|
822
928
|
const members = query.queryMembers();
|
|
@@ -829,7 +935,7 @@ var ContactsModuleRdfLib = class {
|
|
|
829
935
|
async addContactToGroup({ contactUri, groupUri }) {
|
|
830
936
|
const contactNode = namedNode(contactUri);
|
|
831
937
|
const groupNode = namedNode(groupUri);
|
|
832
|
-
await this.fetchNode(contactNode);
|
|
938
|
+
await this.support.fetchNode(contactNode);
|
|
833
939
|
const contactQuery = new ContactQuery(this.store, contactNode);
|
|
834
940
|
const groupQuery = new GroupQuery(this.store, groupNode);
|
|
835
941
|
const operation = addContactToGroup(contactQuery, groupQuery);
|
|
@@ -838,7 +944,7 @@ var ContactsModuleRdfLib = class {
|
|
|
838
944
|
async removeContactFromGroup({ contactUri, groupUri }) {
|
|
839
945
|
const contactNode = namedNode(contactUri);
|
|
840
946
|
const groupNode = namedNode(groupUri);
|
|
841
|
-
await this.fetchNode(groupNode);
|
|
947
|
+
await this.support.fetchNode(groupNode);
|
|
842
948
|
const contactQuery = new ContactQuery(this.store, contactNode);
|
|
843
949
|
const groupQuery = new GroupQuery(this.store, groupNode);
|
|
844
950
|
const operation = removeContactFromGroup(contactQuery, groupQuery);
|
|
@@ -859,20 +965,32 @@ var ContactsModuleRdfLib = class {
|
|
|
859
965
|
async removePhoneNumber({ contactUri, phoneNumberUri }) {
|
|
860
966
|
const contactNode = namedNode(contactUri);
|
|
861
967
|
const phoneNumberNode = namedNode(phoneNumberUri);
|
|
862
|
-
await this.fetchNode(phoneNumberNode);
|
|
968
|
+
await this.support.fetchNode(phoneNumberNode);
|
|
863
969
|
const operation = removePhoneNumber(contactNode, phoneNumberNode, this.store);
|
|
864
970
|
await executeUpdate(this.fetcher, this.updater, operation);
|
|
865
971
|
}
|
|
866
972
|
async removeEmailAddress({ contactUri, emailAddressUri }) {
|
|
867
973
|
const contactNode = namedNode(contactUri);
|
|
868
974
|
const emailAddressNode = namedNode(emailAddressUri);
|
|
869
|
-
await this.fetchNode(emailAddressNode);
|
|
975
|
+
await this.support.fetchNode(emailAddressNode);
|
|
870
976
|
const operation = removeEmailAddress(contactNode, emailAddressNode, this.store);
|
|
871
977
|
await executeUpdate(this.fetcher, this.updater, operation);
|
|
872
978
|
}
|
|
979
|
+
async updatePhoneNumber({ phoneNumberUri, newPhoneNumber }) {
|
|
980
|
+
const phoneNumberNode = namedNode(phoneNumberUri);
|
|
981
|
+
await this.support.fetchNode(phoneNumberNode);
|
|
982
|
+
const operation = updatePhoneNumber(phoneNumberNode, newPhoneNumber, this.store);
|
|
983
|
+
await executeUpdate(this.fetcher, this.updater, operation);
|
|
984
|
+
}
|
|
985
|
+
async updateEmailAddress({ emailAddressUri, newEmailAddress }) {
|
|
986
|
+
const emailAddressNode = namedNode(emailAddressUri);
|
|
987
|
+
await this.support.fetchNode(emailAddressNode);
|
|
988
|
+
const operation = updateEmailAddress(emailAddressNode, newEmailAddress, this.store);
|
|
989
|
+
await executeUpdate(this.fetcher, this.updater, operation);
|
|
990
|
+
}
|
|
873
991
|
async listAddressBooks(webId) {
|
|
874
992
|
const profileNode = namedNode(webId);
|
|
875
|
-
await this.fetchNode(profileNode);
|
|
993
|
+
await this.support.fetchNode(profileNode);
|
|
876
994
|
const profileQuery = new ProfileQuery(profileNode, this.store);
|
|
877
995
|
const publicTypeIndexNode = profileQuery.queryPublicTypeIndex();
|
|
878
996
|
const preferencesFile = profileQuery.queryPreferencesFile();
|
|
@@ -892,17 +1010,23 @@ var ContactsModuleRdfLib = class {
|
|
|
892
1010
|
if (!publicTypeIndexNode) {
|
|
893
1011
|
return [];
|
|
894
1012
|
}
|
|
895
|
-
await this.fetchNode(publicTypeIndexNode);
|
|
896
|
-
return new TypeIndexQuery(this.store, publicTypeIndexNode).
|
|
1013
|
+
await this.support.fetchNode(publicTypeIndexNode);
|
|
1014
|
+
return new TypeIndexQuery(this.store, publicTypeIndexNode).queryInstancesForClass(VCARD_ADDRESS_BOOK);
|
|
897
1015
|
}
|
|
898
1016
|
async fetchPrivateTypeIndex(profileNode, preferencesFile) {
|
|
899
1017
|
if (!preferencesFile) {
|
|
900
1018
|
return null;
|
|
901
1019
|
}
|
|
902
|
-
await this.fetchNode(preferencesFile);
|
|
1020
|
+
await this.support.fetchNode(preferencesFile);
|
|
903
1021
|
const preferencesQuery = new PreferencesQuery(this.store, profileNode, preferencesFile);
|
|
904
1022
|
return preferencesQuery.queryPrivateTypeIndex();
|
|
905
1023
|
}
|
|
1024
|
+
async renameContact({ contactUri, newName }) {
|
|
1025
|
+
const contactNode = namedNode(contactUri);
|
|
1026
|
+
await this.support.fetchNode(contactNode);
|
|
1027
|
+
const operation = renameContact(this.store, contactNode, newName);
|
|
1028
|
+
await executeUpdate(this.fetcher, this.updater, operation);
|
|
1029
|
+
}
|
|
906
1030
|
};
|
|
907
1031
|
|
|
908
1032
|
// ../node_modules/@solid-data-modules/contacts-rdflib/dist/index.js
|