@automate.ax/integration-contracts 0.55.0

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 (136) hide show
  1. package/dist/airtable/api.d.ts +19 -0
  2. package/dist/airtable/api.js +44 -0
  3. package/dist/airtable/index.d.ts +353 -0
  4. package/dist/airtable/index.js +32 -0
  5. package/dist/airtable/schemas.d.ts +716 -0
  6. package/dist/airtable/schemas.js +184 -0
  7. package/dist/asana/api.d.ts +70 -0
  8. package/dist/asana/api.js +119 -0
  9. package/dist/asana/index.d.ts +384 -0
  10. package/dist/asana/index.js +38 -0
  11. package/dist/asana/schemas.d.ts +1060 -0
  12. package/dist/asana/schemas.js +512 -0
  13. package/dist/brevo/api.d.ts +31 -0
  14. package/dist/brevo/api.js +64 -0
  15. package/dist/brevo/index.d.ts +822 -0
  16. package/dist/brevo/index.js +51 -0
  17. package/dist/brevo/schemas.d.ts +1217 -0
  18. package/dist/brevo/schemas.js +332 -0
  19. package/dist/github/index.d.ts +37 -0
  20. package/dist/github/index.js +106 -0
  21. package/dist/github/schemas.d.ts +8014 -0
  22. package/dist/github/schemas.js +113 -0
  23. package/dist/gmail/gmail.d.ts +172 -0
  24. package/dist/gmail/gmail.js +405 -0
  25. package/dist/gmail/index.d.ts +262 -0
  26. package/dist/gmail/index.js +23 -0
  27. package/dist/gmail/schemas.d.ts +444 -0
  28. package/dist/gmail/schemas.js +242 -0
  29. package/dist/google-calendar/event-schemas.d.ts +117 -0
  30. package/dist/google-calendar/event-schemas.js +13 -0
  31. package/dist/google-calendar/google-calendar.d.ts +147 -0
  32. package/dist/google-calendar/google-calendar.js +583 -0
  33. package/dist/google-calendar/index.d.ts +365 -0
  34. package/dist/google-calendar/index.js +24 -0
  35. package/dist/google-calendar/schemas.d.ts +592 -0
  36. package/dist/google-calendar/schemas.js +379 -0
  37. package/dist/google-forms/event-schemas.d.ts +105 -0
  38. package/dist/google-forms/event-schemas.js +20 -0
  39. package/dist/google-forms/google-forms.d.ts +243 -0
  40. package/dist/google-forms/google-forms.js +581 -0
  41. package/dist/google-forms/index.d.ts +141 -0
  42. package/dist/google-forms/index.js +20 -0
  43. package/dist/google-forms/schemas.d.ts +618 -0
  44. package/dist/google-forms/schemas.js +383 -0
  45. package/dist/linear/api.d.ts +63 -0
  46. package/dist/linear/api.js +88 -0
  47. package/dist/linear/index.d.ts +1338 -0
  48. package/dist/linear/index.js +55 -0
  49. package/dist/linear/schemas.d.ts +1795 -0
  50. package/dist/linear/schemas.js +760 -0
  51. package/dist/outlook/graph.d.ts +34 -0
  52. package/dist/outlook/graph.js +98 -0
  53. package/dist/outlook/index.d.ts +115 -0
  54. package/dist/outlook/index.js +11 -0
  55. package/dist/outlook/schemas.d.ts +529 -0
  56. package/dist/outlook/schemas.js +312 -0
  57. package/dist/resend/index.d.ts +707 -0
  58. package/dist/resend/index.js +54 -0
  59. package/dist/resend/schemas.d.ts +1033 -0
  60. package/dist/resend/schemas.js +377 -0
  61. package/dist/slack/index.d.ts +151 -0
  62. package/dist/slack/index.js +22 -0
  63. package/dist/slack/schemas.d.ts +641 -0
  64. package/dist/slack/schemas.js +581 -0
  65. package/dist/teams/graph.d.ts +33 -0
  66. package/dist/teams/graph.js +95 -0
  67. package/dist/teams/index.d.ts +164 -0
  68. package/dist/teams/index.js +21 -0
  69. package/dist/teams/schemas.d.ts +675 -0
  70. package/dist/teams/schemas.js +365 -0
  71. package/dist/trello/api.d.ts +69 -0
  72. package/dist/trello/api.js +140 -0
  73. package/dist/trello/event-schemas.d.ts +1101 -0
  74. package/dist/trello/event-schemas.js +233 -0
  75. package/dist/trello/index.d.ts +721 -0
  76. package/dist/trello/index.js +35 -0
  77. package/dist/trello/schemas.d.ts +283 -0
  78. package/dist/trello/schemas.js +401 -0
  79. package/dist/triggers.d.ts +26 -0
  80. package/dist/triggers.js +33 -0
  81. package/dist/vercel/index.d.ts +1065 -0
  82. package/dist/vercel/index.js +114 -0
  83. package/dist/vercel/schemas.d.ts +1518 -0
  84. package/dist/vercel/schemas.js +335 -0
  85. package/dist/whatsapp/api.d.ts +62 -0
  86. package/dist/whatsapp/api.js +121 -0
  87. package/dist/whatsapp/index.d.ts +614 -0
  88. package/dist/whatsapp/index.js +35 -0
  89. package/dist/whatsapp/schemas.d.ts +926 -0
  90. package/dist/whatsapp/schemas.js +326 -0
  91. package/package.json +169 -0
  92. package/src/airtable/api.ts +66 -0
  93. package/src/airtable/index.ts +41 -0
  94. package/src/airtable/schemas.ts +231 -0
  95. package/src/asana/api.ts +171 -0
  96. package/src/asana/index.ts +49 -0
  97. package/src/asana/schemas.ts +655 -0
  98. package/src/brevo/api.ts +89 -0
  99. package/src/brevo/index.ts +66 -0
  100. package/src/brevo/schemas.ts +449 -0
  101. package/src/github/index.ts +217 -0
  102. package/src/github/schemas.ts +435 -0
  103. package/src/gmail/gmail.ts +577 -0
  104. package/src/gmail/index.ts +26 -0
  105. package/src/gmail/schemas.ts +327 -0
  106. package/src/google-calendar/event-schemas.ts +16 -0
  107. package/src/google-calendar/google-calendar.ts +727 -0
  108. package/src/google-calendar/index.ts +27 -0
  109. package/src/google-calendar/schemas.ts +529 -0
  110. package/src/google-forms/event-schemas.ts +26 -0
  111. package/src/google-forms/google-forms.ts +683 -0
  112. package/src/google-forms/index.ts +23 -0
  113. package/src/google-forms/schemas.ts +499 -0
  114. package/src/linear/api.ts +141 -0
  115. package/src/linear/index.ts +71 -0
  116. package/src/linear/schemas.ts +1060 -0
  117. package/src/outlook/graph.ts +132 -0
  118. package/src/outlook/index.ts +14 -0
  119. package/src/outlook/schemas.ts +388 -0
  120. package/src/resend/index.ts +70 -0
  121. package/src/resend/schemas.ts +462 -0
  122. package/src/slack/index.ts +29 -0
  123. package/src/slack/schemas.ts +737 -0
  124. package/src/teams/graph.ts +130 -0
  125. package/src/teams/index.ts +27 -0
  126. package/src/teams/schemas.ts +463 -0
  127. package/src/trello/api.ts +190 -0
  128. package/src/trello/event-schemas.ts +290 -0
  129. package/src/trello/index.ts +45 -0
  130. package/src/trello/schemas.ts +507 -0
  131. package/src/triggers.ts +68 -0
  132. package/src/vercel/index.ts +147 -0
  133. package/src/vercel/schemas.ts +594 -0
  134. package/src/whatsapp/api.ts +171 -0
  135. package/src/whatsapp/index.ts +46 -0
  136. package/src/whatsapp/schemas.ts +341 -0
@@ -0,0 +1,581 @@
1
+ import { z } from "zod";
2
+ export const SLACK_JSON_OBJECT_SCHEMA = z.record(z.string(), z.json());
3
+ export const SLACK_BLOCKS_SCHEMA = SLACK_JSON_OBJECT_SCHEMA.array().max(50);
4
+ export const SLACK_RESPONSE_METADATA_SCHEMA = z.object({
5
+ /** Opaque cursor for the next page, when more results are available. */
6
+ nextCursor: z.string().optional(),
7
+ });
8
+ export const SLACK_TOPIC_SCHEMA = z.object({
9
+ /** Slack user ID that last changed the value. */
10
+ creatorId: z.string().optional(),
11
+ /** Unix timestamp in seconds when the value was last changed. */
12
+ lastSetAt: z.number().int().nonnegative().optional(),
13
+ /** Current topic or purpose text. */
14
+ value: z.string(),
15
+ });
16
+ export const SLACK_CONVERSATION_SCHEMA = z.object({
17
+ /** Unix timestamp in seconds when Slack created the conversation. */
18
+ createdAt: z.number().int().nonnegative().optional(),
19
+ /** Slack user ID that created the conversation. */
20
+ creatorId: z.string().optional(),
21
+ /** Stable Slack conversation ID. */
22
+ id: z.string(),
23
+ /** Whether the conversation is archived. */
24
+ isArchived: z.boolean().optional(),
25
+ /** Whether this is the workspace's general channel. */
26
+ isGeneral: z.boolean().optional(),
27
+ /** Whether the authenticated bot belongs to the conversation. */
28
+ isMember: z.boolean().optional(),
29
+ /** Whether this is a direct-message conversation. */
30
+ isDirectMessage: z.boolean().optional(),
31
+ /** Whether this is a multi-person direct-message conversation. */
32
+ isGroupDirectMessage: z.boolean().optional(),
33
+ /** Whether this conversation is private. */
34
+ isPrivate: z.boolean().optional(),
35
+ /** Whether this conversation is shared with another workspace. */
36
+ isShared: z.boolean().optional(),
37
+ /** Human-readable conversation name, when applicable. */
38
+ name: z.string().optional(),
39
+ /** Slack-normalized conversation name. */
40
+ normalizedName: z.string().optional(),
41
+ /** Number of conversation members, when Slack includes it. */
42
+ memberCount: z.number().int().nonnegative().optional(),
43
+ /** Conversation purpose metadata. */
44
+ purpose: SLACK_TOPIC_SCHEMA.optional(),
45
+ /** Conversation topic metadata. */
46
+ topic: SLACK_TOPIC_SCHEMA.optional(),
47
+ /** Slack user ID for the other participant in a direct message. */
48
+ userId: z.string().optional(),
49
+ });
50
+ export const SLACK_MEMBER_PROFILE_SCHEMA = z.object({
51
+ /** User's selected display name. */
52
+ displayName: z.string().optional(),
53
+ /** Email address, only when the account also has `users:read.email`. */
54
+ email: z.string().optional(),
55
+ /** User's first name. */
56
+ firstName: z.string().optional(),
57
+ /** URL for the user's 192-pixel avatar. */
58
+ image192: z.string().optional(),
59
+ /** URL for the user's 512-pixel avatar. */
60
+ image512: z.string().optional(),
61
+ /** URL for the user's 72-pixel avatar. */
62
+ image72: z.string().optional(),
63
+ /** User's last name. */
64
+ lastName: z.string().optional(),
65
+ /** Preferred pronouns. */
66
+ pronouns: z.string().optional(),
67
+ /** User's real name from their profile. */
68
+ realName: z.string().optional(),
69
+ /** Emoji used for the user's custom status. */
70
+ statusEmoji: z.string().optional(),
71
+ /** Unix timestamp when the custom status expires. */
72
+ statusExpiration: z.number().int().nonnegative().optional(),
73
+ /** User's custom status text. */
74
+ statusText: z.string().optional(),
75
+ /** User's job title. */
76
+ title: z.string().optional(),
77
+ });
78
+ export const SLACK_MEMBER_SCHEMA = z.object({
79
+ /** Whether this member represents an installed Slack app. */
80
+ isAppUser: z.boolean().optional(),
81
+ /** Whether this member is a workspace administrator. */
82
+ isAdmin: z.boolean().optional(),
83
+ /** Whether this member is a bot. */
84
+ isBot: z.boolean().optional(),
85
+ /** Whether this member is the workspace owner. */
86
+ isOwner: z.boolean().optional(),
87
+ /** Whether this member is a guest. */
88
+ isRestricted: z.boolean().optional(),
89
+ /** Whether this member is a single-channel guest. */
90
+ isUltraRestricted: z.boolean().optional(),
91
+ /** Whether this member has been deactivated. */
92
+ deleted: z.boolean().optional(),
93
+ /** Stable Slack user ID. */
94
+ id: z.string(),
95
+ /** Legacy Slack username. */
96
+ name: z.string().optional(),
97
+ /** Rich workspace profile fields. */
98
+ profile: SLACK_MEMBER_PROFILE_SCHEMA,
99
+ /** IANA time zone name configured for the member. */
100
+ timeZone: z.string().optional(),
101
+ /** Human-readable time zone label. */
102
+ timeZoneLabel: z.string().optional(),
103
+ /** Time zone offset from UTC in seconds. */
104
+ timeZoneOffset: z.number().int().optional(),
105
+ /** Unix timestamp in seconds when the member was last updated. */
106
+ updatedAt: z.number().int().nonnegative().optional(),
107
+ /** Slack workspace ID containing the member. */
108
+ workspaceId: z.string().optional(),
109
+ });
110
+ export const SLACK_REACTION_SCHEMA = z.object({
111
+ /** Number of users that added this reaction. */
112
+ count: z.number().int().nonnegative(),
113
+ /** Emoji name without surrounding colons. */
114
+ name: z.string(),
115
+ /** Slack user IDs included in the response sample. */
116
+ userIds: z.string().array(),
117
+ });
118
+ export const SLACK_MESSAGE_SCHEMA = z.object({
119
+ /** Slack app ID that produced the message. */
120
+ appId: z.string().optional(),
121
+ /** Provider-native legacy attachment payloads. */
122
+ attachments: SLACK_JSON_OBJECT_SCHEMA.array().optional(),
123
+ /** Block Kit content. */
124
+ blocks: SLACK_BLOCKS_SCHEMA.optional(),
125
+ /** Slack bot ID that produced the message. */
126
+ botId: z.string().optional(),
127
+ /** Files attached to the message as provider-native Slack objects. */
128
+ files: SLACK_JSON_OBJECT_SCHEMA.array().optional(),
129
+ /** Slack user ID of the thread parent author. */
130
+ parentUserId: z.string().optional(),
131
+ /** Emoji reactions currently attached to the message. */
132
+ reactions: SLACK_REACTION_SCHEMA.array().optional(),
133
+ /** Number of replies to this message. */
134
+ replyCount: z.number().int().nonnegative().optional(),
135
+ /** Message subtype supplied by Slack. */
136
+ subtype: z.string().optional(),
137
+ /** Plain-text message content or accessibility fallback. */
138
+ text: z.string(),
139
+ /** Parent message timestamp when this message belongs to a thread. */
140
+ threadTimestamp: z.string().optional(),
141
+ /** Stable Slack message timestamp. */
142
+ timestamp: z.string(),
143
+ /** Slack message event type. */
144
+ type: z.string(),
145
+ /** Slack user ID that authored the message. */
146
+ userId: z.string().optional(),
147
+ });
148
+ export const SLACK_REACTION_ITEM_SCHEMA = z.discriminatedUnion("type", [
149
+ z.object({
150
+ /** Slack conversation containing the reacted-to message. */
151
+ conversationId: z.string(),
152
+ /** Provider conversation category such as `channel`, `group`, or `im`. */
153
+ conversationType: z.string().optional(),
154
+ /** Timestamp identifying the reacted-to message. */
155
+ messageTimestamp: z.string(),
156
+ type: z.literal("message"),
157
+ }),
158
+ z.object({
159
+ /** Stable Slack file ID. */
160
+ fileId: z.string(),
161
+ type: z.literal("file"),
162
+ }),
163
+ z.object({
164
+ /** Stable Slack file ID. */
165
+ fileId: z.string(),
166
+ /** Stable Slack file-comment ID. */
167
+ fileCommentId: z.string(),
168
+ type: z.literal("fileComment"),
169
+ }),
170
+ ]);
171
+ export const SLACK_REACTION_EVENT_SCHEMA = z.object({
172
+ /** Slack timestamp identifying when the event occurred. */
173
+ eventTimestamp: z.string(),
174
+ /** Reacted-to Slack item. */
175
+ item: SLACK_REACTION_ITEM_SCHEMA,
176
+ /** Author of the reacted-to item, when Slack can identify one. */
177
+ itemUserId: z.string().optional(),
178
+ /** Emoji name without surrounding colons. */
179
+ reaction: z.string(),
180
+ /** Slack user who added or removed the reaction. */
181
+ userId: z.string(),
182
+ /** Slack workspace in which the event occurred. */
183
+ workspaceId: z.string(),
184
+ });
185
+ export const SLACK_FILE_SCHEMA = z.object({
186
+ /** Channels in which the file is shared. */
187
+ channelIds: z.string().array().optional(),
188
+ /** Unix timestamp in seconds when Slack created the file. */
189
+ createdAt: z.number().int().nonnegative().optional(),
190
+ /** Slack file type such as `png` or `javascript`. */
191
+ fileType: z.string().optional(),
192
+ /** Stable Slack file ID. */
193
+ id: z.string(),
194
+ /** MIME media type reported by Slack. */
195
+ mimeType: z.string().optional(),
196
+ /** Original filename. */
197
+ name: z.string().optional(),
198
+ /** Slack permalink for the file. */
199
+ permalink: z.string().optional(),
200
+ /** File size in bytes. */
201
+ size: z.number().int().nonnegative().optional(),
202
+ /** Human-readable title. */
203
+ title: z.string().optional(),
204
+ /** Authenticated URL for downloading the file. */
205
+ urlPrivate: z.string().optional(),
206
+ /** Slack user ID that uploaded the file. */
207
+ userId: z.string().optional(),
208
+ });
209
+ export const SLACK_WORKSPACE_IDENTITY_SCHEMA = z.object({
210
+ /** Slack bot ID for the authenticated installation. */
211
+ botId: z.string().optional(),
212
+ /** Enterprise Grid organization ID, when applicable. */
213
+ enterpriseId: z.string().optional(),
214
+ /** Human-readable authenticated bot name. */
215
+ user: z.string().optional(),
216
+ /** Slack user ID for the authenticated bot. */
217
+ userId: z.string(),
218
+ /** Workspace URL. */
219
+ url: z.string().optional(),
220
+ /** Human-readable workspace name. */
221
+ workspace: z.string(),
222
+ /** Stable Slack workspace ID. */
223
+ workspaceId: z.string(),
224
+ });
225
+ export const SLACK_MESSAGE_CONTENT_SCHEMA = z
226
+ .object({
227
+ /** Provider-native legacy attachment payloads. */
228
+ attachments: SLACK_JSON_OBJECT_SCHEMA.array().max(100).optional(),
229
+ /** Block Kit content. */
230
+ blocks: SLACK_BLOCKS_SCHEMA.optional(),
231
+ /** Whether Slack should parse and unfurl links. */
232
+ unfurlLinks: z.boolean().optional(),
233
+ /** Whether Slack should unfurl media. */
234
+ unfurlMedia: z.boolean().optional(),
235
+ /** Plain text or accessibility fallback for Block Kit messages. */
236
+ text: z.string().optional(),
237
+ })
238
+ .refine(({ attachments, blocks, text }) => attachments !== undefined || blocks !== undefined || text !== undefined, "At least one of text, blocks, or attachments must be provided.");
239
+ export const SLACK_CURSOR_INPUT_SCHEMA = z.object({
240
+ /** Opaque cursor returned by the previous page. */
241
+ cursor: z.string().min(1).optional(),
242
+ /** Maximum number of results requested from Slack. */
243
+ limit: z.number().int().min(1).max(200).optional(),
244
+ });
245
+ export const SLACK_PROVIDER_RESPONSE_METADATA_SCHEMA = z
246
+ .object({
247
+ next_cursor: z.string().optional(),
248
+ })
249
+ .optional();
250
+ export const SLACK_PROVIDER_TOPIC_SCHEMA = z.object({
251
+ creator: z.string().optional(),
252
+ last_set: z.number().int().nonnegative().optional(),
253
+ value: z.string(),
254
+ });
255
+ export const SLACK_PROVIDER_CONVERSATION_SCHEMA = z.looseObject({
256
+ created: z.number().int().nonnegative().optional(),
257
+ creator: z.string().optional(),
258
+ id: z.string(),
259
+ is_archived: z.boolean().optional(),
260
+ is_general: z.boolean().optional(),
261
+ is_im: z.boolean().optional(),
262
+ is_member: z.boolean().optional(),
263
+ is_mpim: z.boolean().optional(),
264
+ is_private: z.boolean().optional(),
265
+ is_shared: z.boolean().optional(),
266
+ name: z.string().optional(),
267
+ name_normalized: z.string().optional(),
268
+ num_members: z.number().int().nonnegative().optional(),
269
+ purpose: SLACK_PROVIDER_TOPIC_SCHEMA.optional(),
270
+ topic: SLACK_PROVIDER_TOPIC_SCHEMA.optional(),
271
+ user: z.string().optional(),
272
+ });
273
+ export const SLACK_PROVIDER_MEMBER_PROFILE_SCHEMA = z.looseObject({
274
+ display_name: z.string().optional(),
275
+ email: z.string().optional(),
276
+ first_name: z.string().optional(),
277
+ image_192: z.string().optional(),
278
+ image_512: z.string().optional(),
279
+ image_72: z.string().optional(),
280
+ last_name: z.string().optional(),
281
+ pronouns: z.string().optional(),
282
+ real_name: z.string().optional(),
283
+ status_emoji: z.string().optional(),
284
+ status_expiration: z.number().int().nonnegative().optional(),
285
+ status_text: z.string().optional(),
286
+ title: z.string().optional(),
287
+ });
288
+ export const SLACK_PROVIDER_MEMBER_SCHEMA = z.looseObject({
289
+ deleted: z.boolean().optional(),
290
+ id: z.string(),
291
+ is_admin: z.boolean().optional(),
292
+ is_app_user: z.boolean().optional(),
293
+ is_bot: z.boolean().optional(),
294
+ is_owner: z.boolean().optional(),
295
+ is_restricted: z.boolean().optional(),
296
+ is_ultra_restricted: z.boolean().optional(),
297
+ name: z.string().optional(),
298
+ profile: SLACK_PROVIDER_MEMBER_PROFILE_SCHEMA.prefault({}),
299
+ team_id: z.string().optional(),
300
+ tz: z.string().optional(),
301
+ tz_label: z.string().optional(),
302
+ tz_offset: z.number().int().optional(),
303
+ updated: z.number().int().nonnegative().optional(),
304
+ });
305
+ export const SLACK_PROVIDER_REACTION_SCHEMA = z.object({
306
+ count: z.number().int().nonnegative(),
307
+ name: z.string(),
308
+ users: z.string().array().optional(),
309
+ });
310
+ export const SLACK_PROVIDER_MESSAGE_SCHEMA = z
311
+ .looseObject({
312
+ app_id: z.string().optional(),
313
+ attachments: SLACK_JSON_OBJECT_SCHEMA.array().optional(),
314
+ blocks: SLACK_BLOCKS_SCHEMA.optional(),
315
+ bot_id: z.string().optional(),
316
+ files: SLACK_JSON_OBJECT_SCHEMA.array().optional(),
317
+ parent_user_id: z.string().optional(),
318
+ reactions: SLACK_PROVIDER_REACTION_SCHEMA.array().optional(),
319
+ reply_count: z.number().int().nonnegative().optional(),
320
+ subtype: z.string().optional(),
321
+ text: z.string().prefault(""),
322
+ thread_ts: z.string().optional(),
323
+ ts: z.string(),
324
+ type: z.string().prefault("message"),
325
+ user: z.string().optional(),
326
+ })
327
+ .catchall(z.json());
328
+ const SLACK_PROVIDER_MESSAGE_EVENT_SCHEMA = SLACK_PROVIDER_MESSAGE_SCHEMA.extend({
329
+ channel: z.string(),
330
+ channel_type: z.string().optional(),
331
+ event_ts: z.string(),
332
+ });
333
+ export const SLACK_MESSAGE_EVENT_SCHEMA = SLACK_MESSAGE_SCHEMA.extend({
334
+ /** Slack conversation containing the message. */
335
+ conversationId: z.string(),
336
+ /** Provider conversation category such as `channel`, `group`, or `im`. */
337
+ conversationType: z.string().optional(),
338
+ /** Original provider event. */
339
+ event: SLACK_PROVIDER_MESSAGE_EVENT_SCHEMA,
340
+ /** Slack timestamp identifying when the event occurred. */
341
+ eventTimestamp: z.string(),
342
+ /** Slack workspace in which the event occurred. */
343
+ workspaceId: z.string(),
344
+ });
345
+ export const SLACK_APP_MENTION_EVENT_SCHEMA = SLACK_MESSAGE_EVENT_SCHEMA.extend({
346
+ event: SLACK_PROVIDER_MESSAGE_EVENT_SCHEMA.extend({
347
+ type: z.literal("app_mention"),
348
+ }),
349
+ type: z.literal("app_mention"),
350
+ });
351
+ export const SLACK_MESSAGE_POSTED_EVENT_SCHEMA = SLACK_MESSAGE_EVENT_SCHEMA.extend({
352
+ event: SLACK_PROVIDER_MESSAGE_EVENT_SCHEMA.extend({
353
+ type: z.literal("message"),
354
+ }),
355
+ type: z.literal("message"),
356
+ });
357
+ const SLACK_PROVIDER_REACTION_ITEM_SCHEMA = z.discriminatedUnion("type", [
358
+ z.looseObject({
359
+ channel: z.string(),
360
+ channel_type: z.string().optional(),
361
+ ts: z.string(),
362
+ type: z.literal("message"),
363
+ }),
364
+ z.looseObject({
365
+ file: z.string(),
366
+ type: z.literal("file"),
367
+ }),
368
+ z.looseObject({
369
+ file: z.string(),
370
+ file_comment: z.string(),
371
+ type: z.literal("file_comment"),
372
+ }),
373
+ ]);
374
+ const SLACK_PROVIDER_REACTION_EVENT_SCHEMA = z.looseObject({
375
+ event_ts: z.string(),
376
+ item: SLACK_PROVIDER_REACTION_ITEM_SCHEMA,
377
+ item_user: z.string().optional(),
378
+ reaction: z.string(),
379
+ user: z.string(),
380
+ });
381
+ export const SLACK_PROVIDER_FILE_SCHEMA = z.looseObject({
382
+ channels: z.string().array().optional(),
383
+ created: z.number().int().nonnegative().optional(),
384
+ filetype: z.string().optional(),
385
+ id: z.string(),
386
+ mimetype: z.string().optional(),
387
+ name: z.string().optional(),
388
+ permalink: z.string().optional(),
389
+ size: z.number().int().nonnegative().optional(),
390
+ title: z.string().optional(),
391
+ url_private: z.string().optional(),
392
+ user: z.string().optional(),
393
+ });
394
+ /**
395
+ * Normalizes Slack cursor metadata.
396
+ *
397
+ * @param metadata - Provider-native cursor metadata.
398
+ */
399
+ export function toSlackResponseMetadata(metadata) {
400
+ return {
401
+ ...(metadata?.next_cursor && { nextCursor: metadata.next_cursor }),
402
+ };
403
+ }
404
+ /**
405
+ * Normalizes a Slack topic or purpose object.
406
+ *
407
+ * @param topic - Provider-native topic fields.
408
+ */
409
+ export function toSlackTopic(topic) {
410
+ return {
411
+ creatorId: topic.creator,
412
+ lastSetAt: topic.last_set,
413
+ value: topic.value,
414
+ };
415
+ }
416
+ /**
417
+ * Normalizes a Slack conversation.
418
+ *
419
+ * @param conversation - Provider-native conversation fields.
420
+ */
421
+ export function toSlackConversation(conversation) {
422
+ return {
423
+ createdAt: conversation.created,
424
+ creatorId: conversation.creator,
425
+ id: conversation.id,
426
+ isArchived: conversation.is_archived,
427
+ isDirectMessage: conversation.is_im,
428
+ isGeneral: conversation.is_general,
429
+ isGroupDirectMessage: conversation.is_mpim,
430
+ isMember: conversation.is_member,
431
+ isPrivate: conversation.is_private,
432
+ isShared: conversation.is_shared,
433
+ memberCount: conversation.num_members,
434
+ name: conversation.name,
435
+ normalizedName: conversation.name_normalized,
436
+ purpose: conversation.purpose
437
+ ? toSlackTopic(conversation.purpose)
438
+ : undefined,
439
+ topic: conversation.topic ? toSlackTopic(conversation.topic) : undefined,
440
+ userId: conversation.user,
441
+ };
442
+ }
443
+ /**
444
+ * Normalizes a Slack workspace member.
445
+ *
446
+ * @param member - Provider-native member fields.
447
+ */
448
+ export function toSlackMember(member) {
449
+ return {
450
+ deleted: member.deleted,
451
+ id: member.id,
452
+ isAdmin: member.is_admin,
453
+ isAppUser: member.is_app_user,
454
+ isBot: member.is_bot,
455
+ isOwner: member.is_owner,
456
+ isRestricted: member.is_restricted,
457
+ isUltraRestricted: member.is_ultra_restricted,
458
+ name: member.name,
459
+ profile: {
460
+ displayName: member.profile.display_name,
461
+ email: member.profile.email,
462
+ firstName: member.profile.first_name,
463
+ image192: member.profile.image_192,
464
+ image512: member.profile.image_512,
465
+ image72: member.profile.image_72,
466
+ lastName: member.profile.last_name,
467
+ pronouns: member.profile.pronouns,
468
+ realName: member.profile.real_name,
469
+ statusEmoji: member.profile.status_emoji,
470
+ statusExpiration: member.profile.status_expiration,
471
+ statusText: member.profile.status_text,
472
+ title: member.profile.title,
473
+ },
474
+ timeZone: member.tz,
475
+ timeZoneLabel: member.tz_label,
476
+ timeZoneOffset: member.tz_offset,
477
+ updatedAt: member.updated,
478
+ workspaceId: member.team_id,
479
+ };
480
+ }
481
+ /**
482
+ * Normalizes a Slack message.
483
+ *
484
+ * @param message - Provider-native message fields.
485
+ */
486
+ export function toSlackMessage(message) {
487
+ return {
488
+ appId: message.app_id,
489
+ attachments: message.attachments,
490
+ blocks: message.blocks,
491
+ botId: message.bot_id,
492
+ files: message.files,
493
+ parentUserId: message.parent_user_id,
494
+ reactions: message.reactions?.map((reaction) => ({
495
+ count: reaction.count,
496
+ name: reaction.name,
497
+ userIds: reaction.users ?? [],
498
+ })),
499
+ replyCount: message.reply_count,
500
+ subtype: message.subtype,
501
+ text: message.text,
502
+ threadTimestamp: message.thread_ts,
503
+ timestamp: message.ts,
504
+ type: message.type,
505
+ userId: message.user,
506
+ };
507
+ }
508
+ /**
509
+ * Normalizes a message-shaped Slack Events API payload.
510
+ *
511
+ * @param event - Provider-native inner event.
512
+ * @param workspaceId - Slack workspace from the outer event envelope.
513
+ */
514
+ export function normalizeSlackMessageEvent(event, workspaceId) {
515
+ const parsedEvent = SLACK_PROVIDER_MESSAGE_EVENT_SCHEMA.parse(event);
516
+ return SLACK_MESSAGE_EVENT_SCHEMA.parse({
517
+ ...toSlackMessage(parsedEvent),
518
+ conversationId: parsedEvent.channel,
519
+ conversationType: parsedEvent.channel_type,
520
+ event: parsedEvent,
521
+ eventTimestamp: parsedEvent.event_ts,
522
+ workspaceId,
523
+ });
524
+ }
525
+ /**
526
+ * Normalizes a reaction-shaped Slack Events API payload.
527
+ *
528
+ * @param event - Provider-native inner event.
529
+ * @param workspaceId - Slack workspace from the outer event envelope.
530
+ */
531
+ export function normalizeSlackReactionEvent(event, workspaceId) {
532
+ const parsedEvent = SLACK_PROVIDER_REACTION_EVENT_SCHEMA.parse(event);
533
+ // Keep the discriminated provider-to-public item mapping readable as a unit.
534
+ const item = (() => {
535
+ switch (parsedEvent.item.type) {
536
+ case "message":
537
+ return {
538
+ conversationId: parsedEvent.item.channel,
539
+ conversationType: parsedEvent.item.channel_type,
540
+ messageTimestamp: parsedEvent.item.ts,
541
+ type: "message",
542
+ };
543
+ case "file":
544
+ return { fileId: parsedEvent.item.file, type: "file" };
545
+ case "file_comment":
546
+ return {
547
+ fileCommentId: parsedEvent.item.file_comment,
548
+ fileId: parsedEvent.item.file,
549
+ type: "fileComment",
550
+ };
551
+ }
552
+ })();
553
+ return SLACK_REACTION_EVENT_SCHEMA.parse({
554
+ eventTimestamp: parsedEvent.event_ts,
555
+ item,
556
+ itemUserId: parsedEvent.item_user,
557
+ reaction: parsedEvent.reaction,
558
+ userId: parsedEvent.user,
559
+ workspaceId,
560
+ });
561
+ }
562
+ /**
563
+ * Normalizes a Slack file.
564
+ *
565
+ * @param file - Provider-native file fields.
566
+ */
567
+ export function toSlackFile(file) {
568
+ return {
569
+ channelIds: file.channels,
570
+ createdAt: file.created,
571
+ fileType: file.filetype,
572
+ id: file.id,
573
+ mimeType: file.mimetype,
574
+ name: file.name,
575
+ permalink: file.permalink,
576
+ size: file.size,
577
+ title: file.title,
578
+ urlPrivate: file.url_private,
579
+ userId: file.user,
580
+ };
581
+ }
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ /** Options accepted by the authenticated Teams Graph request helper. */
3
+ export interface TeamsGraphRequestOptions {
4
+ /** JSON-serializable request body. */
5
+ body?: unknown;
6
+ /** Additional HTTP headers. */
7
+ headers?: RequestInit["headers"];
8
+ /** HTTP method. */
9
+ method?: string;
10
+ }
11
+ /**
12
+ * Creates a small authenticated Microsoft Graph client for Teams APIs.
13
+ *
14
+ * The raw `fetch` method is an escape hatch for Graph operations not yet
15
+ * represented by a built-in action.
16
+ *
17
+ * @param secret - Refreshed Microsoft OAuth integration secret.
18
+ */
19
+ export declare function getTeamsGraphApi(secret: Record<string, unknown>): {
20
+ /** Performs an authenticated request and returns the raw Response. */
21
+ fetch: (path: string, init?: RequestInit) => Promise<Response>;
22
+ /** Performs an authenticated request and returns its untrusted JSON value. */
23
+ request: (path: string, options?: TeamsGraphRequestOptions) => Promise<unknown>;
24
+ };
25
+ /**
26
+ * Reads Graph collection pages until the requested limit is reached.
27
+ *
28
+ * @param request - Authenticated Graph JSON request function.
29
+ * @param path - Initial relative Graph path.
30
+ * @param itemSchema - Schema for one collection item.
31
+ * @param limit - Maximum total items.
32
+ */
33
+ export declare function listTeamsGraphCollection<T>(request: (path: string) => Promise<unknown>, path: string, itemSchema: z.ZodType<T>, limit: number): Promise<T[]>;