-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contacts: add phone number to new contact
- Loading branch information
Showing
3 changed files
with
63 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
import {ContactsModule} from '../dist/rdflib/index.js'; | ||
import {Fetcher, graph, UpdateManager} from "rdflib"; | ||
import {faker} from '@faker-js/faker'; | ||
import { ContactsModule } from "../dist/rdflib/index.js"; | ||
import { Fetcher, graph, UpdateManager } from "rdflib"; | ||
import { faker } from "@faker-js/faker"; | ||
|
||
const store = graph(); | ||
const fetcher = new Fetcher(store); | ||
const updater = new UpdateManager(store); | ||
const contacts = new ContactsModule({ store, fetcher, updater }); | ||
|
||
const store = graph() | ||
const fetcher = new Fetcher(store) | ||
const updater = new UpdateManager(store) | ||
const contacts = new ContactsModule({store, fetcher, updater}) | ||
|
||
let addressBook = "http://localhost:3000/alice/public-write/ab9694d6-120e-415d-a315-90cd84c2e062/index.ttl#this"; | ||
let addressBook = | ||
"http://localhost:3000/alice/public-write/ab9694d6-120e-415d-a315-90cd84c2e062/index.ttl#this"; | ||
|
||
const firstName = faker.person.firstName(); | ||
const lastName = faker.person.lastName(); | ||
const contact = { | ||
name: firstName + " " + lastName, | ||
email: faker.internet.email({ firstName, lastName }), | ||
phoneNumber: faker.helpers.fromRegExp( | ||
/[0-9]{2,4}-[0-9]{2,4}-[0-9]{2,4}-[0-9]{2,4}/, | ||
), | ||
}; | ||
const uri = await contacts.createNewContact({ | ||
addressBook: addressBook, | ||
contact: { | ||
name: firstName + " " + lastName, | ||
email: faker.internet.email({firstName, lastName}) | ||
} | ||
}) | ||
console.log("created contact:", firstName, lastName, uri) | ||
addressBook: addressBook, | ||
contact, | ||
}); | ||
console.log("created contact:", contact, "at", uri); | ||
|
||
const result = await contacts.readAddressBook(addressBook) | ||
console.log("the updated address book:", result) | ||
const result = await contacts.readAddressBook(addressBook); | ||
console.log("the updated address book:", result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters