@pod-os/core 0.12.0 → 0.12.1-6af5683.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,11 +4,11 @@ import {
4
4
  lit,
5
5
  namedNode,
6
6
  st
7
- } from "./chunk-7C7N3OSJ.js";
7
+ } from "./chunk-GBIS3SJI.js";
8
8
  import {
9
9
  __commonJS,
10
10
  __toESM
11
- } from "./chunk-5NEDDTD5.js";
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({
@@ -731,6 +731,63 @@ var PreferencesQuery = class {
731
731
  }
732
732
  };
733
733
 
734
+ // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/update-operations/renameContact.js
735
+ function renameContact(store, contactNode, newName) {
736
+ const deletions = store.statementsMatching(contactNode, vcard("fn"), null, null);
737
+ const insertions = deletions.map((it) => st(it.subject, it.predicate, lit(newName), it.graph));
738
+ return {
739
+ uri: "",
740
+ insertions,
741
+ deletions,
742
+ filesToCreate: []
743
+ };
744
+ }
745
+
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())] : [];
765
+ const insertions = [
766
+ st(phoneNumberNode, vcard("value"), namedNode("tel:" + newPhoneNumber), phoneNumberNode.doc())
767
+ ];
768
+ return {
769
+ uri: "",
770
+ insertions,
771
+ deletions,
772
+ filesToCreate: []
773
+ };
774
+ }
775
+
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())] : [];
780
+ const insertions = [
781
+ st(emailAddressNode, vcard("value"), namedNode("mailto:" + newEmailAddress), emailAddressNode.doc())
782
+ ];
783
+ return {
784
+ uri: "",
785
+ insertions,
786
+ deletions,
787
+ filesToCreate: []
788
+ };
789
+ }
790
+
734
791
  // ../node_modules/@solid-data-modules/contacts-rdflib/dist/rdflib/ContactsModuleRdfLib.js
735
792
  var ContactsModuleRdfLib = class {
736
793
  constructor(config) {
@@ -765,11 +822,26 @@ var ContactsModuleRdfLib = class {
765
822
  async fetchAll(nodes) {
766
823
  return Promise.all(nodes.map((it) => this.fetchNode(it)));
767
824
  }
768
- async createAddressBook({ containerUri, name }) {
825
+ async createAddressBook({ containerUri, name, ownerWebId }) {
769
826
  const operation = createAddressBook(containerUri, name);
770
827
  await executeUpdate(this.fetcher, this.updater, operation);
828
+ if (ownerWebId) {
829
+ await this.updatePrivateTypeIndex(ownerWebId, operation.uri);
830
+ }
771
831
  return operation.uri;
772
832
  }
833
+ async updatePrivateTypeIndex(ownerWebId, addressBookUri) {
834
+ const profileNode = namedNode(ownerWebId);
835
+ await this.fetchNode(profileNode);
836
+ const profileQuery = new ProfileQuery(profileNode, this.store);
837
+ const preferencesFile = profileQuery.queryPreferencesFile();
838
+ const privateTypeIndex = await this.fetchPrivateTypeIndex(profileNode, preferencesFile);
839
+ if (!privateTypeIndex) {
840
+ throw new Error(`Private type not found for WebID ${ownerWebId}.`);
841
+ }
842
+ const operation = addAddressBookToTypeIndex(privateTypeIndex, addressBookUri);
843
+ await executeUpdate(this.fetcher, this.updater, operation);
844
+ }
773
845
  async createNewContact({ addressBookUri, contact, groupUris }) {
774
846
  const contactQuery = await this.executeCreateNewContact(addressBookUri, contact);
775
847
  await this.executeAddContactToGroups(groupUris, contactQuery);
@@ -870,6 +942,18 @@ var ContactsModuleRdfLib = class {
870
942
  const operation = removeEmailAddress(contactNode, emailAddressNode, this.store);
871
943
  await executeUpdate(this.fetcher, this.updater, operation);
872
944
  }
945
+ async updatePhoneNumber({ phoneNumberUri, newPhoneNumber }) {
946
+ const phoneNumberNode = namedNode(phoneNumberUri);
947
+ await this.fetchNode(phoneNumberNode);
948
+ const operation = updatePhoneNumber(phoneNumberNode, newPhoneNumber, this.store);
949
+ await executeUpdate(this.fetcher, this.updater, operation);
950
+ }
951
+ async updateEmailAddress({ emailAddressUri, newEmailAddress }) {
952
+ const emailAddressNode = namedNode(emailAddressUri);
953
+ await this.fetchNode(emailAddressNode);
954
+ const operation = updateEmailAddress(emailAddressNode, newEmailAddress, this.store);
955
+ await executeUpdate(this.fetcher, this.updater, operation);
956
+ }
873
957
  async listAddressBooks(webId) {
874
958
  const profileNode = namedNode(webId);
875
959
  await this.fetchNode(profileNode);
@@ -903,6 +987,12 @@ var ContactsModuleRdfLib = class {
903
987
  const preferencesQuery = new PreferencesQuery(this.store, profileNode, preferencesFile);
904
988
  return preferencesQuery.queryPrivateTypeIndex();
905
989
  }
990
+ async renameContact({ contactUri, newName }) {
991
+ const contactNode = namedNode(contactUri);
992
+ await this.fetchNode(contactNode);
993
+ const operation = renameContact(this.store, contactNode, newName);
994
+ await executeUpdate(this.fetcher, this.updater, operation);
995
+ }
906
996
  };
907
997
 
908
998
  // ../node_modules/@solid-data-modules/contacts-rdflib/dist/index.js