@pod-os/core 0.12.1-6af5683.0 → 0.12.1-a4967bb.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.
@@ -4,7 +4,7 @@ import {
4
4
  lit,
5
5
  namedNode,
6
6
  st
7
- } from "./chunk-GBIS3SJI.js";
7
+ } from "./chunk-7VQUARYZ.js";
8
8
  import {
9
9
  __commonJS,
10
10
  __toESM
@@ -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/contacts-rdflib/dist/rdflib/generate-id.js
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: [{ uri: nameEmailIndexUri }, { uri: groupIndexUri }]
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,63 +718,48 @@ function addContactToGroup(contactQuery, groupQuery) {
597
718
  };
598
719
  }
599
720
 
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) {
721
+ // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addNewEmailAddress.js
722
+ function addNewEmailAddress(contactNode, emailAddress) {
620
723
  const id = generateId();
621
724
  const uri = `${contactNode.doc().uri}#${id}`;
622
725
  return {
623
726
  uri,
624
727
  insertions: [
625
- st(contactNode, vcard("hasTelephone"), namedNode(uri), contactNode.doc()),
626
- st(namedNode(uri), vcard("value"), namedNode("tel:" + phoneNumber), contactNode.doc())
728
+ st(contactNode, vcard("hasEmail"), namedNode(uri), contactNode.doc()),
729
+ st(namedNode(uri), vcard("value"), namedNode("mailto:" + emailAddress), contactNode.doc())
627
730
  ],
628
731
  deletions: [],
629
732
  filesToCreate: []
630
733
  };
631
734
  }
632
735
 
633
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addNewEmailAddress.js
634
- function addNewEmailAddress(contactNode, emailAddress) {
736
+ // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addNewPhoneNumber.js
737
+ function addNewPhoneNumber(contactNode, phoneNumber) {
635
738
  const id = generateId();
636
739
  const uri = `${contactNode.doc().uri}#${id}`;
637
740
  return {
638
741
  uri,
639
742
  insertions: [
640
- st(contactNode, vcard("hasEmail"), namedNode(uri), contactNode.doc()),
641
- st(namedNode(uri), vcard("value"), namedNode("mailto:" + emailAddress), contactNode.doc())
743
+ st(contactNode, vcard("hasTelephone"), namedNode(uri), contactNode.doc()),
744
+ st(namedNode(uri), vcard("value"), namedNode("tel:" + phoneNumber), contactNode.doc())
642
745
  ],
643
746
  deletions: [],
644
747
  filesToCreate: []
645
748
  };
646
749
  }
647
750
 
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());
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
+ }
651
758
  return {
652
- uri: "",
653
759
  insertions: [],
654
760
  deletions: [
655
- ...phoneStatements,
656
- st(contactNode, vcard("hasTelephone"), phoneNode, contactNode.doc())
761
+ st(groupQuery.groupNode, vcard("hasMember"), contactQuery.contactNode, groupQuery.groupNode.doc()),
762
+ st(contactQuery.contactNode, vcard("fn"), lit(member.name), groupQuery.groupNode.doc())
657
763
  ],
658
764
  filesToCreate: []
659
765
  };
@@ -663,7 +769,6 @@ function removePhoneNumber(contactNode, phoneNode, store) {
663
769
  function removeEmailAddress(contactNode, emailNode, store) {
664
770
  const emailStatements = store.statementsMatching(emailNode, null, null, emailNode.doc());
665
771
  return {
666
- uri: "",
667
772
  insertions: [],
668
773
  deletions: [
669
774
  ...emailStatements,
@@ -673,115 +778,52 @@ function removeEmailAddress(contactNode, emailNode, store) {
673
778
  };
674
779
  }
675
780
 
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
- };
781
+ // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/removePhoneNumber.js
782
+ function removePhoneNumber(contactNode, phoneNode, store) {
783
+ const phoneStatements = store.statementsMatching(phoneNode, null, null, phoneNode.doc());
784
+ return {
785
+ insertions: [],
786
+ deletions: [
787
+ ...phoneStatements,
788
+ st(contactNode, vcard("hasTelephone"), phoneNode, contactNode.doc())
789
+ ],
790
+ filesToCreate: []
791
+ };
792
+ }
733
793
 
734
794
  // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/renameContact.js
735
795
  function renameContact(store, contactNode, newName) {
736
796
  const deletions = store.statementsMatching(contactNode, vcard("fn"), null, null);
737
797
  const insertions = deletions.map((it) => st(it.subject, it.predicate, lit(newName), it.graph));
738
798
  return {
739
- uri: "",
740
799
  insertions,
741
800
  deletions,
742
801
  filesToCreate: []
743
802
  };
744
803
  }
745
804
 
746
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/addAddressBookToTypeIndex.js
747
- function addAddressBookToTypeIndex(typeIndexDoc, addressBookUri) {
748
- const registrationNode = namedNode(`${typeIndexDoc.value}#${generateId()}`);
749
- return {
750
- deletions: [],
751
- filesToCreate: [],
752
- insertions: [
753
- st(registrationNode, rdf("type"), solid("TypeRegistration"), typeIndexDoc),
754
- st(registrationNode, solid("forClass"), vcard("AddressBook"), typeIndexDoc),
755
- st(registrationNode, solid("instance"), namedNode(addressBookUri), typeIndexDoc)
756
- ],
757
- uri: ""
758
- };
759
- }
760
-
761
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/updatePhoneNumber.js
762
- function updatePhoneNumber(phoneNumberNode, newPhoneNumber, store) {
763
- const oldValue = store.any(phoneNumberNode, vcard("value"));
764
- const deletions = oldValue ? [st(phoneNumberNode, vcard("value"), oldValue, phoneNumberNode.doc())] : [];
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())] : [];
765
809
  const insertions = [
766
- st(phoneNumberNode, vcard("value"), namedNode("tel:" + newPhoneNumber), phoneNumberNode.doc())
810
+ st(emailAddressNode, vcard("value"), namedNode("mailto:" + newEmailAddress), emailAddressNode.doc())
767
811
  ];
768
812
  return {
769
- uri: "",
770
813
  insertions,
771
814
  deletions,
772
815
  filesToCreate: []
773
816
  };
774
817
  }
775
818
 
776
- // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/updateEmailAddress.js
777
- function updateEmailAddress(emailAddressNode, newEmailAddress, store) {
778
- const oldValue = store.any(emailAddressNode, vcard("value"));
779
- const deletions = oldValue ? [st(emailAddressNode, vcard("value"), oldValue, emailAddressNode.doc())] : [];
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())] : [];
780
823
  const insertions = [
781
- st(emailAddressNode, vcard("value"), namedNode("mailto:" + newEmailAddress), emailAddressNode.doc())
824
+ st(phoneNumberNode, vcard("value"), namedNode("tel:" + newPhoneNumber), phoneNumberNode.doc())
782
825
  ];
783
826
  return {
784
- uri: "",
785
827
  insertions,
786
828
  deletions,
787
829
  filesToCreate: []
@@ -789,24 +831,22 @@ function updateEmailAddress(emailAddressNode, newEmailAddress, store) {
789
831
  }
790
832
 
791
833
  // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/ContactsModuleRdfLib.js
834
+ var VCARD_ADDRESS_BOOK = vcard("AddressBook");
792
835
  var ContactsModuleRdfLib = class {
793
836
  constructor(config) {
837
+ this.support = new ModuleSupport(config);
794
838
  this.store = config.store;
795
839
  this.fetcher = config.fetcher;
796
840
  this.updater = config.updater;
797
841
  }
798
842
  async readAddressBook(uri) {
799
843
  const addressBookNode = namedNode(uri);
800
- await this.fetchNode(addressBookNode);
844
+ await this.support.fetchNode(addressBookNode);
801
845
  const query = new AddressBookQuery(this.store, addressBookNode);
802
846
  const title = query.queryTitle();
803
847
  const nameEmailIndex = query.queryNameEmailIndex();
804
848
  const groupIndex = query.queryGroupIndex();
805
- await Promise.allSettled([
806
- this.fetchNode(nameEmailIndex),
807
- this.fetchNode(groupIndex)
808
- ]);
809
- await this.fetchAll([nameEmailIndex, groupIndex]);
849
+ await this.support.fetchAll([nameEmailIndex, groupIndex]);
810
850
  const contacts = query.queryContacts();
811
851
  const groups = query.queryGroups();
812
852
  return {
@@ -816,12 +856,6 @@ var ContactsModuleRdfLib = class {
816
856
  groups
817
857
  };
818
858
  }
819
- async fetchNode(node) {
820
- return fetchNode(this.fetcher, node);
821
- }
822
- async fetchAll(nodes) {
823
- return Promise.all(nodes.map((it) => this.fetchNode(it)));
824
- }
825
859
  async createAddressBook({ containerUri, name, ownerWebId }) {
826
860
  const operation = createAddressBook(containerUri, name);
827
861
  await executeUpdate(this.fetcher, this.updater, operation);
@@ -832,14 +866,14 @@ var ContactsModuleRdfLib = class {
832
866
  }
833
867
  async updatePrivateTypeIndex(ownerWebId, addressBookUri) {
834
868
  const profileNode = namedNode(ownerWebId);
835
- await this.fetchNode(profileNode);
869
+ await this.support.fetchNode(profileNode);
836
870
  const profileQuery = new ProfileQuery(profileNode, this.store);
837
871
  const preferencesFile = profileQuery.queryPreferencesFile();
838
872
  const privateTypeIndex = await this.fetchPrivateTypeIndex(profileNode, preferencesFile);
839
873
  if (!privateTypeIndex) {
840
874
  throw new Error(`Private type not found for WebID ${ownerWebId}.`);
841
875
  }
842
- const operation = addAddressBookToTypeIndex(privateTypeIndex, addressBookUri);
876
+ const operation = addInstanceToTypeIndex(privateTypeIndex, addressBookUri, VCARD_ADDRESS_BOOK);
843
877
  await executeUpdate(this.fetcher, this.updater, operation);
844
878
  }
845
879
  async createNewContact({ addressBookUri, contact, groupUris }) {
@@ -849,7 +883,7 @@ var ContactsModuleRdfLib = class {
849
883
  }
850
884
  async executeAddContactToGroups(groupUris, contactQuery) {
851
885
  const groupNodes = (groupUris ?? []).map((it) => namedNode(it));
852
- await this.fetchAll(groupNodes);
886
+ await this.support.fetchAll(groupNodes);
853
887
  const groupUpdates = groupNodes.map((groupNode) => {
854
888
  const groupQuery = new GroupQuery(this.store, groupNode);
855
889
  const operation = addContactToGroup(contactQuery, groupQuery);
@@ -859,14 +893,14 @@ var ContactsModuleRdfLib = class {
859
893
  }
860
894
  async executeCreateNewContact(addressBookUri, contact) {
861
895
  const addressBookNode = namedNode(addressBookUri);
862
- await this.fetchNode(addressBookNode);
896
+ await this.support.fetchNode(addressBookNode);
863
897
  const operation = createNewContact(new AddressBookQuery(this.store, addressBookNode), contact);
864
898
  await executeUpdate(this.fetcher, this.updater, operation);
865
899
  return new ContactQuery(this.store, namedNode(operation.uri));
866
900
  }
867
901
  async readContact(uri) {
868
902
  const contactNode = namedNode(uri);
869
- await this.fetchNode(contactNode);
903
+ await this.support.fetchNode(contactNode);
870
904
  const query = new ContactQuery(this.store, contactNode);
871
905
  const name = query.queryName();
872
906
  const emails = query.queryEmails();
@@ -880,7 +914,7 @@ var ContactsModuleRdfLib = class {
880
914
  }
881
915
  async createNewGroup({ addressBookUri, groupName }) {
882
916
  const addressBookNode = namedNode(addressBookUri);
883
- await this.fetchNode(addressBookNode);
917
+ await this.support.fetchNode(addressBookNode);
884
918
  const query = new AddressBookQuery(this.store, addressBookNode);
885
919
  const operation = createNewGroup(query, groupName);
886
920
  await executeUpdate(this.fetcher, this.updater, operation);
@@ -888,7 +922,7 @@ var ContactsModuleRdfLib = class {
888
922
  }
889
923
  async readGroup(uri) {
890
924
  const groupNode = namedNode(uri);
891
- await this.fetchNode(groupNode);
925
+ await this.support.fetchNode(groupNode);
892
926
  const query = new GroupQuery(this.store, groupNode);
893
927
  const name = query.queryName();
894
928
  const members = query.queryMembers();
@@ -901,7 +935,7 @@ var ContactsModuleRdfLib = class {
901
935
  async addContactToGroup({ contactUri, groupUri }) {
902
936
  const contactNode = namedNode(contactUri);
903
937
  const groupNode = namedNode(groupUri);
904
- await this.fetchNode(contactNode);
938
+ await this.support.fetchNode(contactNode);
905
939
  const contactQuery = new ContactQuery(this.store, contactNode);
906
940
  const groupQuery = new GroupQuery(this.store, groupNode);
907
941
  const operation = addContactToGroup(contactQuery, groupQuery);
@@ -910,7 +944,7 @@ var ContactsModuleRdfLib = class {
910
944
  async removeContactFromGroup({ contactUri, groupUri }) {
911
945
  const contactNode = namedNode(contactUri);
912
946
  const groupNode = namedNode(groupUri);
913
- await this.fetchNode(groupNode);
947
+ await this.support.fetchNode(groupNode);
914
948
  const contactQuery = new ContactQuery(this.store, contactNode);
915
949
  const groupQuery = new GroupQuery(this.store, groupNode);
916
950
  const operation = removeContactFromGroup(contactQuery, groupQuery);
@@ -931,32 +965,32 @@ var ContactsModuleRdfLib = class {
931
965
  async removePhoneNumber({ contactUri, phoneNumberUri }) {
932
966
  const contactNode = namedNode(contactUri);
933
967
  const phoneNumberNode = namedNode(phoneNumberUri);
934
- await this.fetchNode(phoneNumberNode);
968
+ await this.support.fetchNode(phoneNumberNode);
935
969
  const operation = removePhoneNumber(contactNode, phoneNumberNode, this.store);
936
970
  await executeUpdate(this.fetcher, this.updater, operation);
937
971
  }
938
972
  async removeEmailAddress({ contactUri, emailAddressUri }) {
939
973
  const contactNode = namedNode(contactUri);
940
974
  const emailAddressNode = namedNode(emailAddressUri);
941
- await this.fetchNode(emailAddressNode);
975
+ await this.support.fetchNode(emailAddressNode);
942
976
  const operation = removeEmailAddress(contactNode, emailAddressNode, this.store);
943
977
  await executeUpdate(this.fetcher, this.updater, operation);
944
978
  }
945
979
  async updatePhoneNumber({ phoneNumberUri, newPhoneNumber }) {
946
980
  const phoneNumberNode = namedNode(phoneNumberUri);
947
- await this.fetchNode(phoneNumberNode);
981
+ await this.support.fetchNode(phoneNumberNode);
948
982
  const operation = updatePhoneNumber(phoneNumberNode, newPhoneNumber, this.store);
949
983
  await executeUpdate(this.fetcher, this.updater, operation);
950
984
  }
951
985
  async updateEmailAddress({ emailAddressUri, newEmailAddress }) {
952
986
  const emailAddressNode = namedNode(emailAddressUri);
953
- await this.fetchNode(emailAddressNode);
987
+ await this.support.fetchNode(emailAddressNode);
954
988
  const operation = updateEmailAddress(emailAddressNode, newEmailAddress, this.store);
955
989
  await executeUpdate(this.fetcher, this.updater, operation);
956
990
  }
957
991
  async listAddressBooks(webId) {
958
992
  const profileNode = namedNode(webId);
959
- await this.fetchNode(profileNode);
993
+ await this.support.fetchNode(profileNode);
960
994
  const profileQuery = new ProfileQuery(profileNode, this.store);
961
995
  const publicTypeIndexNode = profileQuery.queryPublicTypeIndex();
962
996
  const preferencesFile = profileQuery.queryPreferencesFile();
@@ -976,20 +1010,20 @@ var ContactsModuleRdfLib = class {
976
1010
  if (!publicTypeIndexNode) {
977
1011
  return [];
978
1012
  }
979
- await this.fetchNode(publicTypeIndexNode);
980
- return new TypeIndexQuery(this.store, publicTypeIndexNode).queryAddressBookInstances();
1013
+ await this.support.fetchNode(publicTypeIndexNode);
1014
+ return new TypeIndexQuery(this.store, publicTypeIndexNode).queryInstancesForClass(VCARD_ADDRESS_BOOK);
981
1015
  }
982
1016
  async fetchPrivateTypeIndex(profileNode, preferencesFile) {
983
1017
  if (!preferencesFile) {
984
1018
  return null;
985
1019
  }
986
- await this.fetchNode(preferencesFile);
1020
+ await this.support.fetchNode(preferencesFile);
987
1021
  const preferencesQuery = new PreferencesQuery(this.store, profileNode, preferencesFile);
988
1022
  return preferencesQuery.queryPrivateTypeIndex();
989
1023
  }
990
1024
  async renameContact({ contactUri, newName }) {
991
1025
  const contactNode = namedNode(contactUri);
992
- await this.fetchNode(contactNode);
1026
+ await this.support.fetchNode(contactNode);
993
1027
  const operation = renameContact(this.store, contactNode, newName);
994
1028
  await executeUpdate(this.fetcher, this.updater, operation);
995
1029
  }