toolroll 0.9.41 → 0.9.42

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cli.js +3 -1
  3. package/dist/coding-types.d.ts +2 -24
  4. package/dist/coding-workspace.js +12 -11
  5. package/dist/contracts/cli.d.ts +736 -0
  6. package/dist/contracts/cli.js +223 -0
  7. package/dist/contracts/coding-activity.d.ts +64 -0
  8. package/dist/contracts/coding-activity.js +58 -0
  9. package/dist/contracts/console-api.d.ts +483 -0
  10. package/dist/contracts/console-api.js +273 -0
  11. package/dist/contracts/diff-stat.d.ts +58 -0
  12. package/dist/contracts/diff-stat.js +59 -0
  13. package/dist/contracts/integration-metadata.d.ts +99 -0
  14. package/dist/contracts/integration-metadata.js +101 -0
  15. package/dist/contracts/model-catalog.d.ts +21 -0
  16. package/dist/contracts/model-catalog.js +14 -0
  17. package/dist/contracts/native-census.d.ts +42 -0
  18. package/dist/contracts/native-census.js +36 -0
  19. package/dist/contracts/observation-request.d.ts +37 -0
  20. package/dist/contracts/observation-request.js +25 -0
  21. package/dist/contracts/provider.d.ts +30 -0
  22. package/dist/contracts/provider.js +15 -0
  23. package/dist/contracts/recipes.d.ts +166 -0
  24. package/dist/contracts/recipes.js +52 -0
  25. package/dist/contracts/retention.d.ts +42 -0
  26. package/dist/contracts/retention.js +24 -0
  27. package/dist/contracts/storage.d.ts +23 -0
  28. package/dist/contracts/storage.js +10 -0
  29. package/dist/contracts/store-json.d.ts +315 -0
  30. package/dist/contracts/store-json.js +196 -0
  31. package/dist/contracts/trigger-payloads.d.ts +369 -0
  32. package/dist/contracts/trigger-payloads.js +144 -0
  33. package/dist/contracts/update-journal.d.ts +254 -0
  34. package/dist/contracts/update-journal.js +155 -0
  35. package/dist/contracts/verification-view.d.ts +93 -0
  36. package/dist/contracts/verification-view.js +43 -0
  37. package/dist/control-setup.d.ts +1 -1
  38. package/dist/desktop-update.d.ts +7 -40
  39. package/dist/desktop-update.js +36 -8
  40. package/dist/evidence.d.ts +3 -19
  41. package/dist/flow-triggers.js +61 -60
  42. package/dist/mcp-connect.js +37 -22
  43. package/dist/model-catalog.js +8 -6
  44. package/dist/observations.d.ts +2 -6
  45. package/dist/observations.js +13 -9
  46. package/dist/operate.js +2 -1
  47. package/dist/process-recovery-native.d.ts +2 -13
  48. package/dist/process-recovery-native.js +8 -5
  49. package/dist/project-tools.d.ts +6 -24
  50. package/dist/project-tools.js +22 -18
  51. package/dist/provider.d.ts +3 -8
  52. package/dist/provider.js +15 -11
  53. package/dist/recipes.d.ts +3 -28
  54. package/dist/recipes.js +79 -52
  55. package/dist/retention.d.ts +4 -5
  56. package/dist/retention.js +5 -4
  57. package/dist/serve.js +142 -28
  58. package/dist/storage.d.ts +2 -1
  59. package/dist/storage.js +12 -9
  60. package/dist/store.d.ts +3 -15
  61. package/dist/store.js +80 -158
  62. package/dist/surface.d.ts +6 -54
  63. package/dist/surface.js +6 -1
  64. package/dist/toolroll-update.d.ts +8 -99
  65. package/dist/toolroll-update.js +28 -18
  66. package/dist/verification-evidence.js +27 -12
  67. package/package.json +1 -1
@@ -0,0 +1,369 @@
1
+ /**
2
+ * What a flow trigger reads from outside (flow-triggers.ts): GitHub's issues, pull requests, workflow runs and webhook
3
+ * events, Linear's GraphQL answers and webhook events, a plain webhook's JSON, a mailbox's normalized message and a
4
+ * shared form's fields.
5
+ *
6
+ * These payloads belong to the services that send them, so each schema describes only the fields Toolroll reads and
7
+ * ignores every other key. A field of the wrong type reads as missing (as the hand reader's `text()` and `record()`
8
+ * did), so no delivery or poll is ever refused here: what was accepted before is accepted now, and what a payload
9
+ * lacks is decided after parsing, with the same answer and plain reason as before. Numbers stay as sent (`number`,
10
+ * `webhookTimestamp`) and are coerced with `Number()` after parsing, as they always were; so do the values whose mere
11
+ * presence counts (`pull_request`, `updatedFrom.stateId`).
12
+ */
13
+ import { z } from "zod";
14
+ import type { InboundMail } from "../mailbox.js";
15
+ /** A GitHub issue or pull request, from a poll or inside a webhook event. */
16
+ export declare const githubIssueSchema: z.ZodCatch<z.ZodObject<{
17
+ number: z.ZodOptional<z.ZodUnknown>;
18
+ pull_request: z.ZodOptional<z.ZodUnknown>;
19
+ draft: z.ZodCatch<z.ZodOptional<z.ZodBoolean>>;
20
+ labels: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodCatch<z.ZodObject<{
21
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
22
+ }, z.core.$strip>>>>>;
23
+ title: z.ZodCatch<z.ZodOptional<z.ZodString>>;
24
+ body: z.ZodCatch<z.ZodOptional<z.ZodString>>;
25
+ html_url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
26
+ author_association: z.ZodCatch<z.ZodOptional<z.ZodString>>;
27
+ user: z.ZodCatch<z.ZodOptional<z.ZodObject<{
28
+ login: z.ZodCatch<z.ZodOptional<z.ZodString>>;
29
+ }, z.core.$strip>>>;
30
+ head: z.ZodCatch<z.ZodOptional<z.ZodObject<{
31
+ ref: z.ZodCatch<z.ZodOptional<z.ZodString>>;
32
+ }, z.core.$strip>>>;
33
+ base: z.ZodCatch<z.ZodOptional<z.ZodObject<{
34
+ ref: z.ZodCatch<z.ZodOptional<z.ZodString>>;
35
+ }, z.core.$strip>>>;
36
+ created_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
37
+ updated_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
38
+ }, z.core.$strip>>;
39
+ /** A GitHub Actions workflow run. */
40
+ export declare const githubRunSchema: z.ZodCatch<z.ZodObject<{
41
+ conclusion: z.ZodCatch<z.ZodOptional<z.ZodString>>;
42
+ head_branch: z.ZodCatch<z.ZodOptional<z.ZodString>>;
43
+ head_sha: z.ZodCatch<z.ZodOptional<z.ZodString>>;
44
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
45
+ display_title: z.ZodCatch<z.ZodOptional<z.ZodString>>;
46
+ created_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
47
+ html_url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
48
+ }, z.core.$strip>>;
49
+ /** `repos/:repo/issues` and `repos/:repo/pulls`: a list (anything else reads as an empty one). */
50
+ export declare const githubIssueListSchema: z.ZodCatch<z.ZodArray<z.ZodCatch<z.ZodObject<{
51
+ number: z.ZodOptional<z.ZodUnknown>;
52
+ pull_request: z.ZodOptional<z.ZodUnknown>;
53
+ draft: z.ZodCatch<z.ZodOptional<z.ZodBoolean>>;
54
+ labels: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodCatch<z.ZodObject<{
55
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
56
+ }, z.core.$strip>>>>>;
57
+ title: z.ZodCatch<z.ZodOptional<z.ZodString>>;
58
+ body: z.ZodCatch<z.ZodOptional<z.ZodString>>;
59
+ html_url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
60
+ author_association: z.ZodCatch<z.ZodOptional<z.ZodString>>;
61
+ user: z.ZodCatch<z.ZodOptional<z.ZodObject<{
62
+ login: z.ZodCatch<z.ZodOptional<z.ZodString>>;
63
+ }, z.core.$strip>>>;
64
+ head: z.ZodCatch<z.ZodOptional<z.ZodObject<{
65
+ ref: z.ZodCatch<z.ZodOptional<z.ZodString>>;
66
+ }, z.core.$strip>>>;
67
+ base: z.ZodCatch<z.ZodOptional<z.ZodObject<{
68
+ ref: z.ZodCatch<z.ZodOptional<z.ZodString>>;
69
+ }, z.core.$strip>>>;
70
+ created_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
71
+ updated_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
72
+ }, z.core.$strip>>>>;
73
+ /** `repos/:repo/issues/events`: a list of issue events. */
74
+ export declare const githubIssueEventListSchema: z.ZodCatch<z.ZodArray<z.ZodCatch<z.ZodObject<{
75
+ event: z.ZodCatch<z.ZodOptional<z.ZodString>>;
76
+ label: z.ZodCatch<z.ZodOptional<z.ZodCatch<z.ZodObject<{
77
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
78
+ }, z.core.$strip>>>>;
79
+ created_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
80
+ issue: z.ZodOptional<z.ZodCatch<z.ZodObject<{
81
+ number: z.ZodOptional<z.ZodUnknown>;
82
+ pull_request: z.ZodOptional<z.ZodUnknown>;
83
+ draft: z.ZodCatch<z.ZodOptional<z.ZodBoolean>>;
84
+ labels: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodCatch<z.ZodObject<{
85
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
86
+ }, z.core.$strip>>>>>;
87
+ title: z.ZodCatch<z.ZodOptional<z.ZodString>>;
88
+ body: z.ZodCatch<z.ZodOptional<z.ZodString>>;
89
+ html_url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
90
+ author_association: z.ZodCatch<z.ZodOptional<z.ZodString>>;
91
+ user: z.ZodCatch<z.ZodOptional<z.ZodObject<{
92
+ login: z.ZodCatch<z.ZodOptional<z.ZodString>>;
93
+ }, z.core.$strip>>>;
94
+ head: z.ZodCatch<z.ZodOptional<z.ZodObject<{
95
+ ref: z.ZodCatch<z.ZodOptional<z.ZodString>>;
96
+ }, z.core.$strip>>>;
97
+ base: z.ZodCatch<z.ZodOptional<z.ZodObject<{
98
+ ref: z.ZodCatch<z.ZodOptional<z.ZodString>>;
99
+ }, z.core.$strip>>>;
100
+ created_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
101
+ updated_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
102
+ }, z.core.$strip>>>;
103
+ }, z.core.$strip>>>>;
104
+ /** `repos/:repo/actions/runs`. */
105
+ export declare const githubRunListSchema: z.ZodCatch<z.ZodObject<{
106
+ workflow_runs: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodCatch<z.ZodObject<{
107
+ conclusion: z.ZodCatch<z.ZodOptional<z.ZodString>>;
108
+ head_branch: z.ZodCatch<z.ZodOptional<z.ZodString>>;
109
+ head_sha: z.ZodCatch<z.ZodOptional<z.ZodString>>;
110
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
111
+ display_title: z.ZodCatch<z.ZodOptional<z.ZodString>>;
112
+ created_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
113
+ html_url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
114
+ }, z.core.$strip>>>>>;
115
+ }, z.core.$strip>>;
116
+ /** A signed GitHub webhook event (`issues`, `pull_request`, `workflow_run`; a `ping` reads as an empty one). */
117
+ export declare const githubEventSchema: z.ZodCatch<z.ZodObject<{
118
+ action: z.ZodCatch<z.ZodOptional<z.ZodString>>;
119
+ repository: z.ZodCatch<z.ZodOptional<z.ZodObject<{
120
+ full_name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
121
+ }, z.core.$strip>>>;
122
+ label: z.ZodCatch<z.ZodOptional<z.ZodCatch<z.ZodObject<{
123
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
124
+ }, z.core.$strip>>>>;
125
+ issue: z.ZodOptional<z.ZodCatch<z.ZodObject<{
126
+ number: z.ZodOptional<z.ZodUnknown>;
127
+ pull_request: z.ZodOptional<z.ZodUnknown>;
128
+ draft: z.ZodCatch<z.ZodOptional<z.ZodBoolean>>;
129
+ labels: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodCatch<z.ZodObject<{
130
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
131
+ }, z.core.$strip>>>>>;
132
+ title: z.ZodCatch<z.ZodOptional<z.ZodString>>;
133
+ body: z.ZodCatch<z.ZodOptional<z.ZodString>>;
134
+ html_url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
135
+ author_association: z.ZodCatch<z.ZodOptional<z.ZodString>>;
136
+ user: z.ZodCatch<z.ZodOptional<z.ZodObject<{
137
+ login: z.ZodCatch<z.ZodOptional<z.ZodString>>;
138
+ }, z.core.$strip>>>;
139
+ head: z.ZodCatch<z.ZodOptional<z.ZodObject<{
140
+ ref: z.ZodCatch<z.ZodOptional<z.ZodString>>;
141
+ }, z.core.$strip>>>;
142
+ base: z.ZodCatch<z.ZodOptional<z.ZodObject<{
143
+ ref: z.ZodCatch<z.ZodOptional<z.ZodString>>;
144
+ }, z.core.$strip>>>;
145
+ created_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
146
+ updated_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
147
+ }, z.core.$strip>>>;
148
+ pull_request: z.ZodOptional<z.ZodCatch<z.ZodObject<{
149
+ number: z.ZodOptional<z.ZodUnknown>;
150
+ pull_request: z.ZodOptional<z.ZodUnknown>;
151
+ draft: z.ZodCatch<z.ZodOptional<z.ZodBoolean>>;
152
+ labels: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodCatch<z.ZodObject<{
153
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
154
+ }, z.core.$strip>>>>>;
155
+ title: z.ZodCatch<z.ZodOptional<z.ZodString>>;
156
+ body: z.ZodCatch<z.ZodOptional<z.ZodString>>;
157
+ html_url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
158
+ author_association: z.ZodCatch<z.ZodOptional<z.ZodString>>;
159
+ user: z.ZodCatch<z.ZodOptional<z.ZodObject<{
160
+ login: z.ZodCatch<z.ZodOptional<z.ZodString>>;
161
+ }, z.core.$strip>>>;
162
+ head: z.ZodCatch<z.ZodOptional<z.ZodObject<{
163
+ ref: z.ZodCatch<z.ZodOptional<z.ZodString>>;
164
+ }, z.core.$strip>>>;
165
+ base: z.ZodCatch<z.ZodOptional<z.ZodObject<{
166
+ ref: z.ZodCatch<z.ZodOptional<z.ZodString>>;
167
+ }, z.core.$strip>>>;
168
+ created_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
169
+ updated_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
170
+ }, z.core.$strip>>>;
171
+ workflow_run: z.ZodOptional<z.ZodCatch<z.ZodObject<{
172
+ conclusion: z.ZodCatch<z.ZodOptional<z.ZodString>>;
173
+ head_branch: z.ZodCatch<z.ZodOptional<z.ZodString>>;
174
+ head_sha: z.ZodCatch<z.ZodOptional<z.ZodString>>;
175
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
176
+ display_title: z.ZodCatch<z.ZodOptional<z.ZodString>>;
177
+ created_at: z.ZodCatch<z.ZodOptional<z.ZodString>>;
178
+ html_url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
179
+ }, z.core.$strip>>>;
180
+ }, z.core.$strip>>;
181
+ /** A Linear issue, from the GraphQL query (`labels { nodes }`) or a webhook's `data` (`labels` as a list). */
182
+ export declare const linearIssueSchema: z.ZodCatch<z.ZodObject<{
183
+ identifier: z.ZodCatch<z.ZodOptional<z.ZodString>>;
184
+ title: z.ZodCatch<z.ZodOptional<z.ZodString>>;
185
+ description: z.ZodCatch<z.ZodOptional<z.ZodString>>;
186
+ url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
187
+ updatedAt: z.ZodCatch<z.ZodOptional<z.ZodString>>;
188
+ state: z.ZodCatch<z.ZodOptional<z.ZodCatch<z.ZodObject<{
189
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
190
+ }, z.core.$strip>>>>;
191
+ team: z.ZodCatch<z.ZodOptional<z.ZodObject<{
192
+ key: z.ZodCatch<z.ZodOptional<z.ZodString>>;
193
+ }, z.core.$strip>>>;
194
+ labels: z.ZodCatch<z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodCatch<z.ZodObject<{
195
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
196
+ }, z.core.$strip>>>, z.ZodObject<{
197
+ nodes: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodCatch<z.ZodObject<{
198
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
199
+ }, z.core.$strip>>>>>;
200
+ }, z.core.$strip>]>>>;
201
+ }, z.core.$strip>>;
202
+ /** Linear's GraphQL answer to LINEAR_QUERY. */
203
+ export declare const linearAnswerSchema: z.ZodCatch<z.ZodObject<{
204
+ errors: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodCatch<z.ZodObject<{
205
+ message: z.ZodCatch<z.ZodOptional<z.ZodString>>;
206
+ }, z.core.$strip>>>>>;
207
+ data: z.ZodCatch<z.ZodOptional<z.ZodObject<{
208
+ issues: z.ZodCatch<z.ZodOptional<z.ZodObject<{
209
+ nodes: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodCatch<z.ZodObject<{
210
+ identifier: z.ZodCatch<z.ZodOptional<z.ZodString>>;
211
+ title: z.ZodCatch<z.ZodOptional<z.ZodString>>;
212
+ description: z.ZodCatch<z.ZodOptional<z.ZodString>>;
213
+ url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
214
+ updatedAt: z.ZodCatch<z.ZodOptional<z.ZodString>>;
215
+ state: z.ZodCatch<z.ZodOptional<z.ZodCatch<z.ZodObject<{
216
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
217
+ }, z.core.$strip>>>>;
218
+ team: z.ZodCatch<z.ZodOptional<z.ZodObject<{
219
+ key: z.ZodCatch<z.ZodOptional<z.ZodString>>;
220
+ }, z.core.$strip>>>;
221
+ labels: z.ZodCatch<z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodCatch<z.ZodObject<{
222
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
223
+ }, z.core.$strip>>>, z.ZodObject<{
224
+ nodes: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodCatch<z.ZodObject<{
225
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
226
+ }, z.core.$strip>>>>>;
227
+ }, z.core.$strip>]>>>;
228
+ }, z.core.$strip>>>>>;
229
+ }, z.core.$strip>>>;
230
+ }, z.core.$strip>>>;
231
+ }, z.core.$strip>>;
232
+ /** A signed Linear webhook event. */
233
+ export declare const linearEventSchema: z.ZodCatch<z.ZodObject<{
234
+ type: z.ZodCatch<z.ZodOptional<z.ZodString>>;
235
+ action: z.ZodCatch<z.ZodOptional<z.ZodString>>;
236
+ webhookTimestamp: z.ZodOptional<z.ZodUnknown>;
237
+ updatedFrom: z.ZodCatch<z.ZodOptional<z.ZodObject<{
238
+ stateId: z.ZodOptional<z.ZodUnknown>;
239
+ }, z.core.$strip>>>;
240
+ data: z.ZodOptional<z.ZodCatch<z.ZodObject<{
241
+ identifier: z.ZodCatch<z.ZodOptional<z.ZodString>>;
242
+ title: z.ZodCatch<z.ZodOptional<z.ZodString>>;
243
+ description: z.ZodCatch<z.ZodOptional<z.ZodString>>;
244
+ url: z.ZodCatch<z.ZodOptional<z.ZodString>>;
245
+ updatedAt: z.ZodCatch<z.ZodOptional<z.ZodString>>;
246
+ state: z.ZodCatch<z.ZodOptional<z.ZodCatch<z.ZodObject<{
247
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
248
+ }, z.core.$strip>>>>;
249
+ team: z.ZodCatch<z.ZodOptional<z.ZodObject<{
250
+ key: z.ZodCatch<z.ZodOptional<z.ZodString>>;
251
+ }, z.core.$strip>>>;
252
+ labels: z.ZodCatch<z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodCatch<z.ZodObject<{
253
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
254
+ }, z.core.$strip>>>, z.ZodObject<{
255
+ nodes: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodCatch<z.ZodObject<{
256
+ name: z.ZodCatch<z.ZodOptional<z.ZodString>>;
257
+ }, z.core.$strip>>>>>;
258
+ }, z.core.$strip>]>>>;
259
+ }, z.core.$strip>>>;
260
+ }, z.core.$strip>>;
261
+ /**
262
+ * A plain webhook's body: any JSON. The trigger's own `titleField` and `bodyField` paths (or title/summary/message and
263
+ * description/body/text) are picked from it after parsing, and a body without one is shown whole, so it is kept as sent.
264
+ */
265
+ export declare const webhookPayloadSchema: z.ZodUnknown;
266
+ /** A message as the mailbox reader hands it on (mailbox.ts normalizes and clips the raw mail before this). */
267
+ export declare const inboundMailSchema: z.ZodObject<{
268
+ uid: z.ZodNumber;
269
+ messageId: z.ZodNullable<z.ZodString>;
270
+ inReplyTo: z.ZodNullable<z.ZodString>;
271
+ references: z.ZodArray<z.ZodString>;
272
+ from: z.ZodString;
273
+ fromName: z.ZodNullable<z.ZodString>;
274
+ subject: z.ZodString;
275
+ text: z.ZodString;
276
+ automatic: z.ZodBoolean;
277
+ }, z.core.$strip>;
278
+ /** A shared form's submission: the first value of each field, as URLSearchParams.get reads it (null when absent). */
279
+ export declare const formSubmissionSchema: z.ZodObject<{
280
+ t: z.ZodNullable<z.ZodString>;
281
+ website: z.ZodNullable<z.ZodString>;
282
+ answers: z.ZodArray<z.ZodNullable<z.ZodString>>;
283
+ }, z.core.$strip>;
284
+ export type GithubIssue = z.infer<typeof githubIssueSchema>;
285
+ export type GithubRun = z.infer<typeof githubRunSchema>;
286
+ export type GithubEvent = z.infer<typeof githubEventSchema>;
287
+ export type LinearIssue = z.infer<typeof linearIssueSchema>;
288
+ export type LinearAnswer = z.infer<typeof linearAnswerSchema>;
289
+ export type LinearEvent = z.infer<typeof linearEventSchema>;
290
+ export type FormSubmission = z.infer<typeof formSubmissionSchema>;
291
+ /** Every field a schema reads; none of these readers refuses (a field of the wrong type reads as missing). */
292
+ export declare const readGithubIssue: (raw: unknown) => GithubIssue;
293
+ export declare const readGithubRun: (raw: unknown) => GithubRun;
294
+ export declare const readGithubIssueList: (raw: unknown) => {
295
+ number?: unknown;
296
+ pull_request?: unknown;
297
+ draft?: boolean | undefined;
298
+ labels?: {
299
+ name?: string | undefined;
300
+ }[] | undefined;
301
+ title?: string | undefined;
302
+ body?: string | undefined;
303
+ html_url?: string | undefined;
304
+ author_association?: string | undefined;
305
+ user?: {
306
+ login?: string | undefined;
307
+ } | undefined;
308
+ head?: {
309
+ ref?: string | undefined;
310
+ } | undefined;
311
+ base?: {
312
+ ref?: string | undefined;
313
+ } | undefined;
314
+ created_at?: string | undefined;
315
+ updated_at?: string | undefined;
316
+ }[];
317
+ export declare const readGithubIssueEventList: (raw: unknown) => {
318
+ event?: string | undefined;
319
+ label?: {
320
+ name?: string | undefined;
321
+ } | undefined;
322
+ created_at?: string | undefined;
323
+ issue?: {
324
+ number?: unknown;
325
+ pull_request?: unknown;
326
+ draft?: boolean | undefined;
327
+ labels?: {
328
+ name?: string | undefined;
329
+ }[] | undefined;
330
+ title?: string | undefined;
331
+ body?: string | undefined;
332
+ html_url?: string | undefined;
333
+ author_association?: string | undefined;
334
+ user?: {
335
+ login?: string | undefined;
336
+ } | undefined;
337
+ head?: {
338
+ ref?: string | undefined;
339
+ } | undefined;
340
+ base?: {
341
+ ref?: string | undefined;
342
+ } | undefined;
343
+ created_at?: string | undefined;
344
+ updated_at?: string | undefined;
345
+ } | undefined;
346
+ }[];
347
+ export declare const readGithubRunList: (raw: unknown) => {
348
+ workflow_runs?: {
349
+ conclusion?: string | undefined;
350
+ head_branch?: string | undefined;
351
+ head_sha?: string | undefined;
352
+ name?: string | undefined;
353
+ display_title?: string | undefined;
354
+ created_at?: string | undefined;
355
+ html_url?: string | undefined;
356
+ }[] | undefined;
357
+ };
358
+ export declare const readGithubEvent: (raw: unknown) => GithubEvent;
359
+ export declare const readLinearIssue: (raw: unknown) => LinearIssue;
360
+ export declare const readLinearAnswer: (raw: unknown) => LinearAnswer;
361
+ export declare const readLinearEvent: (raw: unknown) => LinearEvent;
362
+ export declare const readWebhookPayload: (raw: unknown) => unknown;
363
+ /** A Linear issue's label names, from either shape. */
364
+ export declare function linearLabelNames(issue: LinearIssue): string[];
365
+ /** A message from the mailbox reader. It is the mailbox's own type, so it always reads; one that somehow didn't is
366
+ * used as it came, as before. */
367
+ export declare function readInboundMail(mail: InboundMail): InboundMail;
368
+ /** A shared form's fields: the first value of each, and one answer per question (`a0` …). Strings always read. */
369
+ export declare function readFormSubmission(fields: URLSearchParams, questions: number): FormSubmission;
@@ -0,0 +1,144 @@
1
+ /**
2
+ * What a flow trigger reads from outside (flow-triggers.ts): GitHub's issues, pull requests, workflow runs and webhook
3
+ * events, Linear's GraphQL answers and webhook events, a plain webhook's JSON, a mailbox's normalized message and a
4
+ * shared form's fields.
5
+ *
6
+ * These payloads belong to the services that send them, so each schema describes only the fields Toolroll reads and
7
+ * ignores every other key. A field of the wrong type reads as missing (as the hand reader's `text()` and `record()`
8
+ * did), so no delivery or poll is ever refused here: what was accepted before is accepted now, and what a payload
9
+ * lacks is decided after parsing, with the same answer and plain reason as before. Numbers stay as sent (`number`,
10
+ * `webhookTimestamp`) and are coerced with `Number()` after parsing, as they always were; so do the values whose mere
11
+ * presence counts (`pull_request`, `updatedFrom.stateId`).
12
+ */
13
+ import { z } from "zod";
14
+ /** A field read when it has the type Toolroll expects, and read as missing when it has any other. */
15
+ const loose = (schema) => schema.optional().catch(undefined);
16
+ const text = loose(z.string());
17
+ const named = z.object({ name: text }).catch({});
18
+ /** A GitHub issue or pull request, from a poll or inside a webhook event. */
19
+ export const githubIssueSchema = z.object({
20
+ /** Coerced with `Number()` after parsing; a card needs a safe integer. */
21
+ number: z.unknown().optional(),
22
+ /** An issue that is a pull request carries this (any value). */
23
+ pull_request: z.unknown().optional(),
24
+ draft: loose(z.boolean()),
25
+ labels: loose(z.array(named)),
26
+ title: text,
27
+ body: text,
28
+ html_url: text,
29
+ author_association: text,
30
+ user: loose(z.object({ login: text })),
31
+ head: loose(z.object({ ref: text })),
32
+ base: loose(z.object({ ref: text })),
33
+ created_at: text,
34
+ updated_at: text,
35
+ }).catch({});
36
+ /** A GitHub Actions workflow run. */
37
+ export const githubRunSchema = z.object({
38
+ conclusion: text,
39
+ head_branch: text,
40
+ head_sha: text,
41
+ name: text,
42
+ display_title: text,
43
+ created_at: text,
44
+ html_url: text,
45
+ }).catch({});
46
+ /** `repos/:repo/issues` and `repos/:repo/pulls`: a list (anything else reads as an empty one). */
47
+ export const githubIssueListSchema = z.array(githubIssueSchema).catch([]);
48
+ /** `repos/:repo/issues/events`: a list of issue events. */
49
+ export const githubIssueEventListSchema = z.array(z.object({ event: text, label: loose(named), created_at: text, issue: githubIssueSchema.optional() }).catch({})).catch([]);
50
+ /** `repos/:repo/actions/runs`. */
51
+ export const githubRunListSchema = z.object({ workflow_runs: loose(z.array(githubRunSchema)) }).catch({});
52
+ /** A signed GitHub webhook event (`issues`, `pull_request`, `workflow_run`; a `ping` reads as an empty one). */
53
+ export const githubEventSchema = z.object({
54
+ action: text,
55
+ repository: loose(z.object({ full_name: text })),
56
+ label: loose(named),
57
+ issue: githubIssueSchema.optional(),
58
+ pull_request: githubIssueSchema.optional(),
59
+ workflow_run: githubRunSchema.optional(),
60
+ }).catch({});
61
+ /** A Linear issue, from the GraphQL query (`labels { nodes }`) or a webhook's `data` (`labels` as a list). */
62
+ export const linearIssueSchema = z.object({
63
+ identifier: text,
64
+ title: text,
65
+ description: text,
66
+ url: text,
67
+ updatedAt: text,
68
+ state: loose(named),
69
+ team: loose(z.object({ key: text })),
70
+ labels: loose(z.union([z.array(named), z.object({ nodes: loose(z.array(named)) })])),
71
+ }).catch({});
72
+ /** Linear's GraphQL answer to LINEAR_QUERY. */
73
+ export const linearAnswerSchema = z.object({
74
+ errors: loose(z.array(z.object({ message: text }).catch({}))),
75
+ data: loose(z.object({ issues: loose(z.object({ nodes: loose(z.array(linearIssueSchema)) })) })),
76
+ }).catch({});
77
+ /** A signed Linear webhook event. */
78
+ export const linearEventSchema = z.object({
79
+ type: text,
80
+ action: text,
81
+ /** Milliseconds; coerced with `Number()` after parsing. */
82
+ webhookTimestamp: z.unknown().optional(),
83
+ /** An update that moved the issue's state carries `stateId` (any value). */
84
+ updatedFrom: loose(z.object({ stateId: z.unknown().optional() })),
85
+ data: linearIssueSchema.optional(),
86
+ }).catch({});
87
+ /**
88
+ * A plain webhook's body: any JSON. The trigger's own `titleField` and `bodyField` paths (or title/summary/message and
89
+ * description/body/text) are picked from it after parsing, and a body without one is shown whole, so it is kept as sent.
90
+ */
91
+ export const webhookPayloadSchema = z.unknown();
92
+ /** A message as the mailbox reader hands it on (mailbox.ts normalizes and clips the raw mail before this). */
93
+ export const inboundMailSchema = z.object({
94
+ uid: z.number(),
95
+ messageId: z.string().nullable(),
96
+ inReplyTo: z.string().nullable(),
97
+ references: z.array(z.string()),
98
+ from: z.string(),
99
+ fromName: z.string().nullable(),
100
+ subject: z.string(),
101
+ text: z.string(),
102
+ automatic: z.boolean(),
103
+ });
104
+ /** A shared form's submission: the first value of each field, as URLSearchParams.get reads it (null when absent). */
105
+ export const formSubmissionSchema = z.object({
106
+ /** When the page was shown, in milliseconds; coerced with `Number()` after parsing. */
107
+ t: z.string().nullable(),
108
+ /** The trap a person never fills in. */
109
+ website: z.string().nullable(),
110
+ /** `a0`, `a1`, … one per question. */
111
+ answers: z.array(z.string().nullable()),
112
+ });
113
+ const mailMatchesSchema = true;
114
+ void mailMatchesSchema;
115
+ /** Every field a schema reads; none of these readers refuses (a field of the wrong type reads as missing). */
116
+ export const readGithubIssue = (raw) => githubIssueSchema.parse(raw);
117
+ export const readGithubRun = (raw) => githubRunSchema.parse(raw);
118
+ export const readGithubIssueList = (raw) => githubIssueListSchema.parse(raw);
119
+ export const readGithubIssueEventList = (raw) => githubIssueEventListSchema.parse(raw);
120
+ export const readGithubRunList = (raw) => githubRunListSchema.parse(raw);
121
+ export const readGithubEvent = (raw) => githubEventSchema.parse(raw);
122
+ export const readLinearIssue = (raw) => linearIssueSchema.parse(raw);
123
+ export const readLinearAnswer = (raw) => linearAnswerSchema.parse(raw);
124
+ export const readLinearEvent = (raw) => linearEventSchema.parse(raw);
125
+ export const readWebhookPayload = (raw) => webhookPayloadSchema.parse(raw);
126
+ /** A Linear issue's label names, from either shape. */
127
+ export function linearLabelNames(issue) {
128
+ const labels = issue.labels;
129
+ return (Array.isArray(labels) ? labels : labels?.nodes ?? []).map(one => one.name ?? "");
130
+ }
131
+ /** A message from the mailbox reader. It is the mailbox's own type, so it always reads; one that somehow didn't is
132
+ * used as it came, as before. */
133
+ export function readInboundMail(mail) {
134
+ const read = inboundMailSchema.safeParse(mail);
135
+ return read.success ? read.data : mail;
136
+ }
137
+ /** A shared form's fields: the first value of each, and one answer per question (`a0` …). Strings always read. */
138
+ export function readFormSubmission(fields, questions) {
139
+ return formSubmissionSchema.parse({
140
+ t: fields.get("t"),
141
+ website: fields.get("website"),
142
+ answers: Array.from({ length: questions }, (_one, index) => fields.get(`a${index}`)),
143
+ });
144
+ }