# Written by `tilo-app surface`; review changes like an API change.

[[resources]]
kind = "contacts.book"
label = "Contacts"
version = 1
fields = [
  { path = "contacts", type = "Keyed<Contact>", stored = "keyed" },
  { path = "contacts.*.id", type = "ContactId", readonly = true },
  { path = "contacts.*.first", type = "String", label = true },
  { path = "contacts.*.last", type = "String" },
  { path = "contacts.*.org", type = "String" },
  { path = "contacts.*.title", type = "String" },
  { path = "contacts.*.website", type = "String" },
  { path = "contacts.*.birthday", type = "Option<Birthday>" },
  { path = "contacts.*.notes", type = "String" },
  { path = "contacts.*.phones", type = "Ordered<Labeled>", stored = "collection" },
  { path = "contacts.*.phones.*.id", type = "Uuid", readonly = true },
  { path = "contacts.*.phones.*.label", type = "String" },
  { path = "contacts.*.phones.*.value", type = "String", label = true },
  { path = "contacts.*.emails", type = "Ordered<Labeled>", stored = "collection" },
  { path = "contacts.*.emails.*.id", type = "Uuid", readonly = true },
  { path = "contacts.*.emails.*.label", type = "String" },
  { path = "contacts.*.emails.*.value", type = "String", label = true },
  { path = "contacts.*.addresses", type = "Ordered<Address>", stored = "collection" },
  { path = "contacts.*.addresses.*.id", type = "Uuid", readonly = true },
  { path = "contacts.*.addresses.*.label", type = "String" },
  { path = "contacts.*.addresses.*.street", type = "String", label = true },
  { path = "contacts.*.addresses.*.city", type = "String" },
  { path = "contacts.*.addresses.*.region", type = "String" },
  { path = "contacts.*.addresses.*.postal", type = "String" },
  { path = "contacts.*.addresses.*.country", type = "String" },
  { path = "contacts.*.groups", type = "Ordered<GroupEntry>", stored = "collection" },
  { path = "contacts.*.groups.*.id", type = "Uuid", readonly = true },
  { path = "contacts.*.groups.*.value", type = "String", label = true },
  { path = "contacts.*.favorite", type = "bool" },
  { path = "removed", type = "Set<ContactId>", readonly = true },
]

[[resources.verbs]]
id = "new-contact"
kind = "undoable"
params = [
  { name = "name", required = true, schema = { type = "string" } },
]

[[resources.verbs]]
id = "add-contacts"
kind = "undoable"
params = [
  { name = "contacts", required = true, schema = { type = "array", items = { type = "object", additionalProperties = false, properties = { addresses = { type = "array", items = { type = "object", additionalProperties = false, properties = { city = { type = "string" }, country = { type = "string" }, id = { type = "string", format = "uuid" }, label = { type = "string" }, postal = { type = "string" }, region = { type = "string" }, street = { type = "string" } }, required = ["id", "label", "street", "city", "region", "postal", "country"] } }, birthday = { oneOf = [{ type = "null" }, { oneOf = [{ type = "object", additionalProperties = false, properties = { Full = { type = "object", additionalProperties = false, properties = { day = { type = "integer", maximum = 4294967295, minimum = 0 }, month = { type = "integer", maximum = 4294967295, minimum = 0 }, year = { type = "integer", maximum = 2147483647, minimum = -2147483648 } }, required = ["year", "month", "day"] } }, required = ["Full"] }, { type = "object", additionalProperties = false, properties = { MonthDay = { type = "object", additionalProperties = false, properties = { day = { type = "integer", maximum = 4294967295, minimum = 0 }, month = { type = "integer", maximum = 4294967295, minimum = 0 } }, required = ["month", "day"] } }, required = ["MonthDay"] }] }] }, emails = { type = "array", items = { type = "object", additionalProperties = false, properties = { id = { type = "string", format = "uuid" }, label = { type = "string" }, value = { type = "string" } }, required = ["id", "label", "value"] } }, favorite = { type = "boolean" }, first = { type = "string" }, groups = { type = "array", items = { type = "object", additionalProperties = false, properties = { id = { type = "string", format = "uuid" }, value = { type = "string" } }, required = ["id", "value"] } }, id = { type = "string", format = "uuid" }, last = { type = "string" }, notes = { type = "string" }, org = { type = "string" }, phones = { type = "array", items = { type = "object", additionalProperties = false, properties = { id = { type = "string", format = "uuid" }, label = { type = "string" }, value = { type = "string" } }, required = ["id", "label", "value"] } }, title = { type = "string" }, website = { type = "string" } }, required = ["id", "first", "last", "org", "title", "website", "notes", "phones", "emails", "addresses", "groups", "favorite"] } } },
]

[[resources.verbs]]
id = "delete-contact"
destructive = true
kind = "undoable"
params = [
  { name = "contact", required = true, schema = { type = "string" } },
]

[[resources.verbs]]
id = "merge-contacts"
destructive = true
kind = "undoable"
params = [
  { name = "contact", required = true, schema = { type = "string" } },
  { name = "source", required = true, schema = { type = "string", format = "uuid" } },
  { name = "take_from_source", required = true, schema = { type = "array", items = { type = "string", enum = ["First", "Last", "Organization", "Title", "Website", "Birthday", "Notes"] } } },
]

[[resources]]
kind = "tilo.contacts.identities"
label = "Contact identities"
version = 1
person = true
fields = [
  { path = "people", type = "Collection<Person>", stored = "collection" },
  { path = "people.*.label", type = "String" },
  { path = "people.*.removed", type = "bool" },
  { path = "people.*.phones", type = "Json<Vec<String>>" },
  { path = "people.*.emails", type = "Json<Vec<String>>" },
  { path = "people.*.endpoints", type = "Collection<Endpoint>", stored = "collection" },
  { path = "people.*.endpoints.*.service", type = "String" },
  { path = "people.*.endpoints.*.recipient", type = "String" },
  { path = "people.*.endpoints.*.scope", type = "String" },
  { path = "people.*.endpoints.*.revision", type = "String" },
  { path = "people.*.endpoints.*.removed", type = "bool" },
]

[[resources.verbs]]
id = "project-contact"
kind = "undoable"
params = [
  { name = "person", required = true, schema = { type = "string" } },
  { name = "label", required = true, schema = { type = "string" } },
]

[[resources.verbs]]
id = "remove-contact"
kind = "undoable"
params = [
  { name = "person", required = true, schema = { type = "string" } },
]

[[resources.verbs]]
id = "confirm-endpoint"
destructive = true
kind = "undoable"
params = [
  { name = "person", required = true, schema = { type = "string" } },
  { name = "endpoint", required = true, schema = { type = "string" } },
  { name = "service", required = true, schema = { type = "string" } },
  { name = "recipient", required = true, schema = { type = "string" } },
]

[[resources.verbs]]
id = "confirm-account"
destructive = true
kind = "undoable"
params = [
  { name = "person", required = true, schema = { type = "string" } },
  { name = "endpoint", required = true, schema = { type = "string" } },
  { name = "service", required = true, schema = { type = "string" } },
  { name = "scope", required = true, schema = { type = "string" } },
  { name = "recipient", required = true, schema = { type = "string" } },
  { name = "revision", required = true, schema = { type = "string" } },
]

[[resources.verbs]]
id = "replace-endpoint"
destructive = true
kind = "undoable"
params = [
  { name = "person", required = true, schema = { type = "string" } },
  { name = "previous", required = true, schema = { type = "string" } },
  { name = "endpoint", required = true, schema = { type = "string" } },
  { name = "service", required = true, schema = { type = "string" } },
  { name = "recipient", required = true, schema = { type = "string" } },
]

[[resources.verbs]]
id = "replace-account"
destructive = true
kind = "undoable"
params = [
  { name = "person", required = true, schema = { type = "string" } },
  { name = "previous", required = true, schema = { type = "string" } },
  { name = "endpoint", required = true, schema = { type = "string" } },
  { name = "service", required = true, schema = { type = "string" } },
  { name = "scope", required = true, schema = { type = "string" } },
  { name = "recipient", required = true, schema = { type = "string" } },
  { name = "revision", required = true, schema = { type = "string" } },
]

[[resources.verbs]]
id = "project-phones"
kind = "undoable"
params = [
  { name = "person", required = true, schema = { type = "string" } },
  { name = "phones", required = true, schema = { type = "array", items = { type = "string" } } },
]

[[resources.verbs]]
id = "project-emails"
kind = "undoable"
params = [
  { name = "person", required = true, schema = { type = "string" } },
  { name = "emails", required = true, schema = { type = "array", items = { type = "string" } } },
]

[[resources.verbs]]
id = "project-contacts"
kind = "undoable"
params = [
  { name = "people", required = true, schema = { type = "array", items = { type = "object", additionalProperties = false, properties = { emails = { type = "array", items = { type = "string" } }, label = { type = "string" }, person = { type = "string" }, phones = { type = "array", items = { type = "string" } } }, required = ["person", "label", "phones", "emails"] } } },
  { name = "removed", required = true, schema = { type = "array", items = { type = "string" } } },
]

[[resources.verbs]]
id = "forget-endpoint"
destructive = true
kind = "undoable"
params = [
  { name = "person", required = true, schema = { type = "string" } },
  { name = "endpoint", required = true, schema = { type = "string" } },
]

