-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
141 lines (120 loc) · 7.05 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
const { dependencies, endpoints, environment, imports, schema, expressions, tests } = program;
// Environment
environment
.add('CLIENT_ID', 'The API clientID')
.add('CLIENT_SECRET', 'The API client secret')
.add('SERVICE_ACCOUNT_JSON', 'The API Service Account key in JSON format. Get it at https://console.cloud.google.com/apis/credentials')
tests
.add('auth', 'The driver has authenticated correctly with the Gmail API')
.add('access', 'The driver can acces the Gmail API and retrieve data')
.add('webhooks', 'The driver can receive webhooks from gmail')
// Imports
// imports
// .add('googlepubsub')
// Dependencies
// dependencies
// .add('pubsub', 'googlepubsub:Root', 'The Google Pub Sub root type. Used to listen for changes')
// Endpoints
endpoints
.https('auth', 'Visit this endpoint to authorize access to your account', { response: true })
.https('redirect', 'Set this URL in Google API Console for oauth redirect')
// Parseable expressions
expressions
.add('url', '^https://mail.google.com/.+$')
// Types
schema.type('Root')
.field('threads', 'ThreadCollection')
.field('messages', 'MessageCollection')
.field('labels', 'LabelCollection')
schema.type('ThreadCollection')
.computed('one', 'Thread', 'A thread. A set of messages grouped by subject')
.param('id', 'String', 'The id of the message')
.computed('page', 'ThreadPage', 'All the threads')
.param('pageSize', 'Int', 'Maximum number of threads to return. Originally "maxResults"')
.param('includeSpamTrash', 'Boolean', 'Include threads from SPAM and TRASH in the results')
.param('labelIds', 'String', 'Only return threads with labels that match all of the specified label IDs')
.param('pageToken', 'String', 'Page token to retrieve a specific page of results in the list')
.param('q', 'String', 'Only return threads matching the specified query. Supports the same query format as the Gmail search box')
schema.type('ThreadPage')
.computed('items', '[ThreadPageItem]')
.computed('next', 'ThreadPage*')
schema.type('ThreadPageItem')
.field('id', 'String', 'The immutable ID of the thread')
.field('snippet', 'String', 'A short part of the message text')
.field('historyId', 'Int', 'The ID of the last history record that modified this thread')
.field('messages', '[Message]', 'The list of messages in the thread')
.computed('self', 'Thread*', 'A reference to the thread represented by this item')
schema.type('Thread', 'A collection of messages representing a conversation')
.field('id', 'String', 'The immutable ID of the thread')
.field('snippet', 'String', 'A short part of the message text')
.field('historyId', 'Int', 'The ID of the last history record that modified this thread')
.field('messages', '[Message]', 'The list of messages in the thread')
.computed('self', 'Thread*', 'A reference to the thread represented by this item')
schema.type('MessageCollection')
.computed('one', 'Message', 'A message')
.param('id', 'String', 'The id of the message')
.computed('page', 'MessagePage', 'All the messages')
.param('pageSize', 'Int', 'Maximum number of messages to return. Originally "maxResults"')
.param('includeSpamTrash', 'Boolean', 'Include messages from SPAM and TRASH in the results')
.param('labelIds', 'String', 'Only return messages with labels that match all of the specified label IDs')
.param('pageToken', 'String', 'Page token to retrieve a specific page of results in the list')
.param('q', 'String', 'Only return messages matching the specified query. Supports the same query format as the Gmail search box')
.action('send')
.param('to', 'String', 'to email address of the receiver')
.param('from', 'String', 'from email address of the sender, the mailbox account')
.param('subject', 'String', 'subject of the email')
.param('body', 'String', 'body text of the email')
schema.type('MessagePage')
.computed('items', '[MessagePageItem]')
.computed('next', 'MessagePage*')
schema.type('MessagePageItem')
.field('id', 'String', 'The immutable ID of the thread')
.computed('thread', 'Thread*', 'The thread this message belongs to')
.computed('self', 'Message*', 'A reference to the message represented by this item')
schema.type('Message')
.field('id', 'String', 'The immutable ID of the message')
.field('snippet', 'String', 'A short part of the message text')
.computed('thread', 'Thread*', 'The thread this message belongs to')
.field('labelIds', '[String]', 'List of IDs of labels applied to this message')
.field('historyId', 'Int', 'The ID of the last history record that modified this message')
.field('internalDate', 'String', 'The internal message creation timestamp')
.field('payload', 'MessagePayload', 'The parsed email structure in the message parts')
.computed('text', 'String', 'Gets all the text/plain parts concatenated')
.computed('self', 'Message*', 'A reference to the message represented by this item')
schema.type('LabelCollection')
.computed('one', 'Label', 'A label')
.param('id', 'String', 'The id of the label')
.computed('withName', 'Label*', 'A label with the provided name')
.param('name', 'String', 'The name of the label')
.computed('items', '[Label]', 'All the labels')
schema.type('Label')
.field('id', 'String', 'The immutable ID of the label')
.field('name', 'String', 'The display name of the label')
.field('type', 'String', 'The owner type for the lable') // TODO: make this an enum
.field('messagesTotal', 'Int', 'The total number of messages with the label')
.field('messagesUnread', 'Int', 'The number of unread messages with the label')
.field('threadsTotal', 'Int', 'The total number of threads with the label')
.field('threadsUnread', 'Int', 'The number of unread threads with the label')
.event('messageAdded', 'Triggered when a message is added to this label')
.param('message', 'Message*', 'The message that was added to this label')
schema.type('MessagePayload')
.field('partId', 'String', 'The immutable ID of the message part')
.field('mimeType', 'String', 'The MIME type of the message part')
.field('filename', 'String', 'The filename of the attachment')
.field('headers', 'HeaderCollection', 'The collection of headers on this message part')
// .field('body', 'Attachment', 'The message part body for this part, which may be empty for container MIME message parts')
// .field('parts', 'MessagePart', 'The child MIME message parts of this part')
schema.type('HeaderCollection')
.computed('one', 'Header')
.param('name', 'String')
// TODO: See todo below
.computed('items', '[Header]')
schema.type('Header')
.field('name', 'String', 'The name of the header before the ":" separator')
.field('value', 'String', 'The value of the header after the ":" separator')
// TODO: This is an interesting case for the self property that cannot be
// implemented at the moment. The "source" arg doesn't have enough information
// to fully computed "self", a header doesn't know the message it belongs to so
// we need to look at the ref of the list which is currently not provided to the
// resolver so we need to fix that
.computed('self', 'Header*')