]> git.notmuchmail.org Git - notmuch/blob - devel/schemata
292f2876868063f4b8a54aae0be33cd46b457cbe
[notmuch] / devel / schemata
1 This file describes the schemata used for notmuch's structured output
2 format (currently JSON and S-Expressions).
3
4 []'s indicate lists.  List items can be marked with a '?', meaning
5 they are optional; or a '*', meaning there can be zero or more of that
6 item.  {}'s indicate an object that maps from field identifiers to
7 values.  An object field marked '?' is optional.  |'s indicate
8 alternates (e.g., int|string means something can be an int or a
9 string).
10
11 For S-Expression output, lists are printed delimited by () instead of
12 []. Objects are printed as p-lists, i.e. lists where the keys and values
13 are interleaved. Keys are printed as keywords (symbols preceded by a
14 colon), e.g. (:id "123" :time 54321 :from "foobar"). Null is printed as
15 nil, true as t and false as nil.
16
17 This is version 1 of the structured output format.
18
19 Common non-terminals
20 --------------------
21
22 # Number of seconds since the Epoch
23 unix_time = int
24
25 # Thread ID, sans "thread:"
26 threadid = string
27
28 # Message ID, sans "id:"
29 messageid = string
30
31 notmuch show schema
32 -------------------
33
34 # A top-level set of threads (do_show)
35 # Returned by notmuch show without a --part argument
36 thread_set = [thread*]
37
38 # Top-level messages in a thread (show_messages)
39 thread = [thread_node*]
40
41 # A message and its replies (show_messages)
42 thread_node = [
43     message|null,             # null if not matched and not --entire-thread
44     [thread_node*]            # children of message
45 ]
46
47 # A message (format_part_sprinter)
48 message = {
49     # (format_message_sprinter)
50     id:             messageid,
51     match:          bool,
52     filename:       string,
53     timestamp:      unix_time, # date header as unix time
54     date_relative:  string,   # user-friendly timestamp
55     tags:           [string*],
56
57     headers:        headers,
58     body?:          [part]    # omitted if --body=false
59 }
60
61 # A MIME part (format_part_sprinter)
62 part = {
63     id:             int|string, # part id (currently DFS part number)
64
65     encstatus?:     encstatus,
66     sigstatus?:     sigstatus,
67
68     content-type:   string,
69     content-id?:    string,
70     # if content-type starts with "multipart/":
71     content:        [part*],
72     # if content-type is "message/rfc822":
73     content:        [{headers: headers, body: [part]}],
74     # otherwise (leaf parts):
75     filename?:      string,
76     content-charset?: string,
77     # A leaf part's body content is optional, but may be included if
78     # it can be correctly encoded as a string.  Consumers should use
79     # this in preference to fetching the part content separately.
80     content?:       string
81 }
82
83 # The headers of a message or part (format_headers_sprinter with reply = FALSE)
84 headers = {
85     Subject:        string,
86     From:           string,
87     To?:            string,
88     Cc?:            string,
89     Bcc?:           string,
90     Reply-To?:      string,
91     Date:           string
92 }
93
94 # Encryption status (format_part_sprinter)
95 encstatus = [{status: "good"|"bad"}]
96
97 # Signature status (format_part_sigstatus_sprinter)
98 sigstatus = [signature*]
99
100 signature = {
101     # (signature_status_to_string)
102     status:         "none"|"good"|"bad"|"error"|"unknown",
103     # if status is "good":
104     fingerprint?:   string,
105     created?:       unix_time,
106     expires?:       unix_time,
107     userid?:        string
108     # if status is not "good":
109     keyid?:         string
110     # if the signature has errors:
111     errors?:        int
112 }
113
114 notmuch search schema
115 ---------------------
116
117 # --output=summary
118 summary = [thread*]
119
120 # --output=threads
121 threads = [threadid*]
122
123 # --output=messages
124 messages = [messageid*]
125
126 # --output=files
127 files = [string*]
128
129 # --output=tags
130 tags = [string*]
131
132 thread = {
133     thread:         threadid,
134     timestamp:      unix_time,
135     date_relative:  string,   # user-friendly timestamp
136     matched:        int,      # number of matched messages
137     total:          int,      # total messages in thread
138     authors:        string,   # comma-separated names with | between
139                               # matched and unmatched
140     subject:        string,
141     tags:           [string*]
142 }
143
144 notmuch reply schema
145 --------------------
146
147 reply = {
148     # The headers of the constructed reply
149     reply-headers: reply_headers,
150
151     # As in the show format (format_part_sprinter)
152     original: message
153 }
154
155 # Reply headers (format_headers_sprinter with reply = TRUE)
156 reply_headers = {
157     Subject:        string,
158     From:           string,
159     To?:            string,
160     Cc?:            string,
161     Bcc?:           string,
162     In-reply-to:    string,
163     References:     string
164 }