@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.
- package/dist/airtable/api.d.ts +19 -0
- package/dist/airtable/api.js +44 -0
- package/dist/airtable/index.d.ts +353 -0
- package/dist/airtable/index.js +32 -0
- package/dist/airtable/schemas.d.ts +716 -0
- package/dist/airtable/schemas.js +184 -0
- package/dist/asana/api.d.ts +70 -0
- package/dist/asana/api.js +119 -0
- package/dist/asana/index.d.ts +384 -0
- package/dist/asana/index.js +38 -0
- package/dist/asana/schemas.d.ts +1060 -0
- package/dist/asana/schemas.js +512 -0
- package/dist/brevo/api.d.ts +31 -0
- package/dist/brevo/api.js +64 -0
- package/dist/brevo/index.d.ts +822 -0
- package/dist/brevo/index.js +51 -0
- package/dist/brevo/schemas.d.ts +1217 -0
- package/dist/brevo/schemas.js +332 -0
- package/dist/github/index.d.ts +37 -0
- package/dist/github/index.js +106 -0
- package/dist/github/schemas.d.ts +8014 -0
- package/dist/github/schemas.js +113 -0
- package/dist/gmail/gmail.d.ts +172 -0
- package/dist/gmail/gmail.js +405 -0
- package/dist/gmail/index.d.ts +262 -0
- package/dist/gmail/index.js +23 -0
- package/dist/gmail/schemas.d.ts +444 -0
- package/dist/gmail/schemas.js +242 -0
- package/dist/google-calendar/event-schemas.d.ts +117 -0
- package/dist/google-calendar/event-schemas.js +13 -0
- package/dist/google-calendar/google-calendar.d.ts +147 -0
- package/dist/google-calendar/google-calendar.js +583 -0
- package/dist/google-calendar/index.d.ts +365 -0
- package/dist/google-calendar/index.js +24 -0
- package/dist/google-calendar/schemas.d.ts +592 -0
- package/dist/google-calendar/schemas.js +379 -0
- package/dist/google-forms/event-schemas.d.ts +105 -0
- package/dist/google-forms/event-schemas.js +20 -0
- package/dist/google-forms/google-forms.d.ts +243 -0
- package/dist/google-forms/google-forms.js +581 -0
- package/dist/google-forms/index.d.ts +141 -0
- package/dist/google-forms/index.js +20 -0
- package/dist/google-forms/schemas.d.ts +618 -0
- package/dist/google-forms/schemas.js +383 -0
- package/dist/linear/api.d.ts +63 -0
- package/dist/linear/api.js +88 -0
- package/dist/linear/index.d.ts +1338 -0
- package/dist/linear/index.js +55 -0
- package/dist/linear/schemas.d.ts +1795 -0
- package/dist/linear/schemas.js +760 -0
- package/dist/outlook/graph.d.ts +34 -0
- package/dist/outlook/graph.js +98 -0
- package/dist/outlook/index.d.ts +115 -0
- package/dist/outlook/index.js +11 -0
- package/dist/outlook/schemas.d.ts +529 -0
- package/dist/outlook/schemas.js +312 -0
- package/dist/resend/index.d.ts +707 -0
- package/dist/resend/index.js +54 -0
- package/dist/resend/schemas.d.ts +1033 -0
- package/dist/resend/schemas.js +377 -0
- package/dist/slack/index.d.ts +151 -0
- package/dist/slack/index.js +22 -0
- package/dist/slack/schemas.d.ts +641 -0
- package/dist/slack/schemas.js +581 -0
- package/dist/teams/graph.d.ts +33 -0
- package/dist/teams/graph.js +95 -0
- package/dist/teams/index.d.ts +164 -0
- package/dist/teams/index.js +21 -0
- package/dist/teams/schemas.d.ts +675 -0
- package/dist/teams/schemas.js +365 -0
- package/dist/trello/api.d.ts +69 -0
- package/dist/trello/api.js +140 -0
- package/dist/trello/event-schemas.d.ts +1101 -0
- package/dist/trello/event-schemas.js +233 -0
- package/dist/trello/index.d.ts +721 -0
- package/dist/trello/index.js +35 -0
- package/dist/trello/schemas.d.ts +283 -0
- package/dist/trello/schemas.js +401 -0
- package/dist/triggers.d.ts +26 -0
- package/dist/triggers.js +33 -0
- package/dist/vercel/index.d.ts +1065 -0
- package/dist/vercel/index.js +114 -0
- package/dist/vercel/schemas.d.ts +1518 -0
- package/dist/vercel/schemas.js +335 -0
- package/dist/whatsapp/api.d.ts +62 -0
- package/dist/whatsapp/api.js +121 -0
- package/dist/whatsapp/index.d.ts +614 -0
- package/dist/whatsapp/index.js +35 -0
- package/dist/whatsapp/schemas.d.ts +926 -0
- package/dist/whatsapp/schemas.js +326 -0
- package/package.json +169 -0
- package/src/airtable/api.ts +66 -0
- package/src/airtable/index.ts +41 -0
- package/src/airtable/schemas.ts +231 -0
- package/src/asana/api.ts +171 -0
- package/src/asana/index.ts +49 -0
- package/src/asana/schemas.ts +655 -0
- package/src/brevo/api.ts +89 -0
- package/src/brevo/index.ts +66 -0
- package/src/brevo/schemas.ts +449 -0
- package/src/github/index.ts +217 -0
- package/src/github/schemas.ts +435 -0
- package/src/gmail/gmail.ts +577 -0
- package/src/gmail/index.ts +26 -0
- package/src/gmail/schemas.ts +327 -0
- package/src/google-calendar/event-schemas.ts +16 -0
- package/src/google-calendar/google-calendar.ts +727 -0
- package/src/google-calendar/index.ts +27 -0
- package/src/google-calendar/schemas.ts +529 -0
- package/src/google-forms/event-schemas.ts +26 -0
- package/src/google-forms/google-forms.ts +683 -0
- package/src/google-forms/index.ts +23 -0
- package/src/google-forms/schemas.ts +499 -0
- package/src/linear/api.ts +141 -0
- package/src/linear/index.ts +71 -0
- package/src/linear/schemas.ts +1060 -0
- package/src/outlook/graph.ts +132 -0
- package/src/outlook/index.ts +14 -0
- package/src/outlook/schemas.ts +388 -0
- package/src/resend/index.ts +70 -0
- package/src/resend/schemas.ts +462 -0
- package/src/slack/index.ts +29 -0
- package/src/slack/schemas.ts +737 -0
- package/src/teams/graph.ts +130 -0
- package/src/teams/index.ts +27 -0
- package/src/teams/schemas.ts +463 -0
- package/src/trello/api.ts +190 -0
- package/src/trello/event-schemas.ts +290 -0
- package/src/trello/index.ts +45 -0
- package/src/trello/schemas.ts +507 -0
- package/src/triggers.ts +68 -0
- package/src/vercel/index.ts +147 -0
- package/src/vercel/schemas.ts +594 -0
- package/src/whatsapp/api.ts +171 -0
- package/src/whatsapp/index.ts +46 -0
- package/src/whatsapp/schemas.ts +341 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const OPTIONAL_DATE_SCHEMA = z
|
|
3
|
+
.union([
|
|
4
|
+
z.date(),
|
|
5
|
+
z.iso.datetime({ offset: true }).transform((value) => new Date(value)),
|
|
6
|
+
])
|
|
7
|
+
.nullish()
|
|
8
|
+
.transform((value) => value ?? undefined);
|
|
9
|
+
const OPTIONAL_STRING_SCHEMA = z
|
|
10
|
+
.string()
|
|
11
|
+
.nullish()
|
|
12
|
+
.transform((value) => value ?? undefined);
|
|
13
|
+
export const TEAMS_TEAM_SCHEMA = z.object({
|
|
14
|
+
/** Whether the team is archived. */
|
|
15
|
+
isArchived: z.boolean().prefault(false),
|
|
16
|
+
/** Team classification assigned by the organization. */
|
|
17
|
+
classification: OPTIONAL_STRING_SCHEMA,
|
|
18
|
+
/** Team description. */
|
|
19
|
+
description: OPTIONAL_STRING_SCHEMA,
|
|
20
|
+
/** Human-readable team name. */
|
|
21
|
+
displayName: z.string(),
|
|
22
|
+
/** Opaque Microsoft team identifier. */
|
|
23
|
+
teamId: z.string(),
|
|
24
|
+
/** Team specialization, when configured. */
|
|
25
|
+
specialization: OPTIONAL_STRING_SCHEMA,
|
|
26
|
+
/** Team visibility. */
|
|
27
|
+
visibility: z
|
|
28
|
+
.enum(["private", "public", "hiddenMembership", "unknownFutureValue"])
|
|
29
|
+
.nullish()
|
|
30
|
+
.transform((value) => value ?? undefined),
|
|
31
|
+
/** Microsoft Teams web URL. */
|
|
32
|
+
webUrl: OPTIONAL_STRING_SCHEMA,
|
|
33
|
+
});
|
|
34
|
+
export const GRAPH_TEAM_SCHEMA = z
|
|
35
|
+
.looseObject({
|
|
36
|
+
classification: z.string().nullish(),
|
|
37
|
+
description: z.string().nullish(),
|
|
38
|
+
displayName: z.string(),
|
|
39
|
+
id: z.string(),
|
|
40
|
+
isArchived: z.boolean().optional(),
|
|
41
|
+
specialization: z.string().nullish(),
|
|
42
|
+
visibility: z
|
|
43
|
+
.enum(["private", "public", "hiddenMembership", "unknownFutureValue"])
|
|
44
|
+
.nullish(),
|
|
45
|
+
webUrl: z.string().nullish(),
|
|
46
|
+
})
|
|
47
|
+
.transform((team) => TEAMS_TEAM_SCHEMA.parse({ ...team, teamId: team.id }));
|
|
48
|
+
export const TEAMS_CHANNEL_SCHEMA = z.object({
|
|
49
|
+
/** Time the channel was created. */
|
|
50
|
+
createdAt: OPTIONAL_DATE_SCHEMA,
|
|
51
|
+
/** Channel description. */
|
|
52
|
+
description: OPTIONAL_STRING_SCHEMA,
|
|
53
|
+
/** Human-readable channel name. */
|
|
54
|
+
displayName: z.string(),
|
|
55
|
+
/** Email address assigned to the channel. */
|
|
56
|
+
email: OPTIONAL_STRING_SCHEMA,
|
|
57
|
+
/** Opaque Microsoft channel identifier. */
|
|
58
|
+
channelId: z.string(),
|
|
59
|
+
/** Whether the channel is archived. */
|
|
60
|
+
isArchived: z.boolean().prefault(false),
|
|
61
|
+
/** Standard, private, or shared membership model. */
|
|
62
|
+
membershipType: z
|
|
63
|
+
.enum(["standard", "private", "shared", "unknownFutureValue"])
|
|
64
|
+
.nullish()
|
|
65
|
+
.transform((value) => value ?? undefined),
|
|
66
|
+
/** Microsoft Teams web URL. */
|
|
67
|
+
webUrl: OPTIONAL_STRING_SCHEMA,
|
|
68
|
+
});
|
|
69
|
+
export const GRAPH_CHANNEL_SCHEMA = z
|
|
70
|
+
.looseObject({
|
|
71
|
+
createdDateTime: z.string().nullish(),
|
|
72
|
+
description: z.string().nullish(),
|
|
73
|
+
displayName: z.string(),
|
|
74
|
+
email: z.string().nullish(),
|
|
75
|
+
id: z.string(),
|
|
76
|
+
isArchived: z.boolean().optional(),
|
|
77
|
+
membershipType: z
|
|
78
|
+
.enum(["standard", "private", "shared", "unknownFutureValue"])
|
|
79
|
+
.nullish(),
|
|
80
|
+
webUrl: z.string().nullish(),
|
|
81
|
+
})
|
|
82
|
+
.transform((channel) => TEAMS_CHANNEL_SCHEMA.parse({
|
|
83
|
+
...channel,
|
|
84
|
+
channelId: channel.id,
|
|
85
|
+
createdAt: channel.createdDateTime,
|
|
86
|
+
}));
|
|
87
|
+
export const TEAMS_MEMBER_SCHEMA = z.object({
|
|
88
|
+
/** Member display name. */
|
|
89
|
+
displayName: OPTIONAL_STRING_SCHEMA,
|
|
90
|
+
/** Member email address, when Graph exposes it. */
|
|
91
|
+
email: OPTIONAL_STRING_SCHEMA,
|
|
92
|
+
/** Opaque conversation membership identifier. */
|
|
93
|
+
memberId: z.string(),
|
|
94
|
+
/** Membership roles such as `owner`. */
|
|
95
|
+
roles: z.string().array().prefault([]),
|
|
96
|
+
/** Microsoft Entra tenant identifier. */
|
|
97
|
+
tenantId: OPTIONAL_STRING_SCHEMA,
|
|
98
|
+
/** Microsoft Entra user identifier, when the member is a user. */
|
|
99
|
+
userId: OPTIONAL_STRING_SCHEMA,
|
|
100
|
+
/** Earliest history visible to this member. */
|
|
101
|
+
visibleHistoryStartAt: OPTIONAL_DATE_SCHEMA,
|
|
102
|
+
});
|
|
103
|
+
export const GRAPH_MEMBER_SCHEMA = z
|
|
104
|
+
.looseObject({
|
|
105
|
+
displayName: z.string().nullish(),
|
|
106
|
+
email: z.string().nullish(),
|
|
107
|
+
id: z.string(),
|
|
108
|
+
roles: z.string().array().optional(),
|
|
109
|
+
tenantId: z.string().nullish(),
|
|
110
|
+
userId: z.string().nullish(),
|
|
111
|
+
visibleHistoryStartDateTime: z.string().nullish(),
|
|
112
|
+
})
|
|
113
|
+
.transform((member) => TEAMS_MEMBER_SCHEMA.parse({
|
|
114
|
+
...member,
|
|
115
|
+
memberId: member.id,
|
|
116
|
+
visibleHistoryStartAt: member.visibleHistoryStartDateTime,
|
|
117
|
+
}));
|
|
118
|
+
export const TEAMS_CHAT_SCHEMA = z.object({
|
|
119
|
+
/** Chat kind. */
|
|
120
|
+
chatType: z.enum(["oneOnOne", "group", "meeting", "unknownFutureValue"]),
|
|
121
|
+
/** Time the chat was created. */
|
|
122
|
+
createdAt: OPTIONAL_DATE_SCHEMA,
|
|
123
|
+
/** Opaque Microsoft chat identifier. */
|
|
124
|
+
chatId: z.string(),
|
|
125
|
+
/** Time the chat was last updated. */
|
|
126
|
+
updatedAt: OPTIONAL_DATE_SCHEMA,
|
|
127
|
+
/** Microsoft Entra tenant identifier. */
|
|
128
|
+
tenantId: OPTIONAL_STRING_SCHEMA,
|
|
129
|
+
/** Optional group-chat or meeting topic. */
|
|
130
|
+
topic: OPTIONAL_STRING_SCHEMA,
|
|
131
|
+
/** Microsoft Teams web URL. */
|
|
132
|
+
webUrl: OPTIONAL_STRING_SCHEMA,
|
|
133
|
+
});
|
|
134
|
+
export const GRAPH_CHAT_SCHEMA = z
|
|
135
|
+
.looseObject({
|
|
136
|
+
chatType: z.enum(["oneOnOne", "group", "meeting", "unknownFutureValue"]),
|
|
137
|
+
createdDateTime: z.string().nullish(),
|
|
138
|
+
id: z.string(),
|
|
139
|
+
lastUpdatedDateTime: z.string().nullish(),
|
|
140
|
+
tenantId: z.string().nullish(),
|
|
141
|
+
topic: z.string().nullish(),
|
|
142
|
+
webUrl: z.string().nullish(),
|
|
143
|
+
})
|
|
144
|
+
.transform((chat) => TEAMS_CHAT_SCHEMA.parse({
|
|
145
|
+
...chat,
|
|
146
|
+
chatId: chat.id,
|
|
147
|
+
createdAt: chat.createdDateTime,
|
|
148
|
+
updatedAt: chat.lastUpdatedDateTime,
|
|
149
|
+
}));
|
|
150
|
+
export const TEAMS_MESSAGE_BODY_SCHEMA = z.object({
|
|
151
|
+
/** Message content. */
|
|
152
|
+
content: z.string(),
|
|
153
|
+
/** Plain text or HTML content type. */
|
|
154
|
+
contentType: z.enum(["text", "html"]),
|
|
155
|
+
});
|
|
156
|
+
const TEAMS_MESSAGE_FROM_SCHEMA = z.object({
|
|
157
|
+
/** Application identifier, when sent by an app. */
|
|
158
|
+
applicationId: OPTIONAL_STRING_SCHEMA,
|
|
159
|
+
/** Device identifier, when sent by a device. */
|
|
160
|
+
deviceId: OPTIONAL_STRING_SCHEMA,
|
|
161
|
+
/** Display name supplied by Teams. */
|
|
162
|
+
displayName: OPTIONAL_STRING_SCHEMA,
|
|
163
|
+
/** Microsoft Entra user identifier, when sent by a user. */
|
|
164
|
+
userId: OPTIONAL_STRING_SCHEMA,
|
|
165
|
+
});
|
|
166
|
+
const TEAMS_MESSAGE_ATTACHMENT_SCHEMA = z.object({
|
|
167
|
+
/** Provider attachment identifier. */
|
|
168
|
+
attachmentId: z.string(),
|
|
169
|
+
/** Attachment content or card JSON. */
|
|
170
|
+
content: OPTIONAL_STRING_SCHEMA,
|
|
171
|
+
/** MIME media type or Teams card type. */
|
|
172
|
+
contentType: z.string(),
|
|
173
|
+
/** Display name. */
|
|
174
|
+
name: OPTIONAL_STRING_SCHEMA,
|
|
175
|
+
/** External content URL. */
|
|
176
|
+
contentUrl: OPTIONAL_STRING_SCHEMA,
|
|
177
|
+
});
|
|
178
|
+
const TEAMS_MESSAGE_MENTION_SCHEMA = z.object({
|
|
179
|
+
/** Mention identifier corresponding to the HTML `<at>` token. */
|
|
180
|
+
mentionId: z.number().int(),
|
|
181
|
+
/** Text displayed for the mention. */
|
|
182
|
+
mentionText: z.string(),
|
|
183
|
+
/** Mentioned conversation identity. */
|
|
184
|
+
mentioned: TEAMS_MESSAGE_FROM_SCHEMA,
|
|
185
|
+
});
|
|
186
|
+
const TEAMS_MESSAGE_REACTION_SCHEMA = z.object({
|
|
187
|
+
/** Reaction name such as `like` or `heart`. */
|
|
188
|
+
reactionType: z.string(),
|
|
189
|
+
/** Time the reaction was created. */
|
|
190
|
+
createdAt: OPTIONAL_DATE_SCHEMA,
|
|
191
|
+
/** Identity that created the reaction. */
|
|
192
|
+
user: TEAMS_MESSAGE_FROM_SCHEMA,
|
|
193
|
+
});
|
|
194
|
+
export const TEAMS_CHAT_MESSAGE_SCHEMA = z.object({
|
|
195
|
+
/** Attachments and cards associated with the message. */
|
|
196
|
+
attachments: TEAMS_MESSAGE_ATTACHMENT_SCHEMA.array().prefault([]),
|
|
197
|
+
/** Message body. */
|
|
198
|
+
body: TEAMS_MESSAGE_BODY_SCHEMA,
|
|
199
|
+
/** Time the message was created. */
|
|
200
|
+
createdAt: OPTIONAL_DATE_SCHEMA,
|
|
201
|
+
/** Time the message was soft-deleted. */
|
|
202
|
+
deletedAt: OPTIONAL_DATE_SCHEMA,
|
|
203
|
+
/** Graph concurrency token. */
|
|
204
|
+
etag: OPTIONAL_STRING_SCHEMA,
|
|
205
|
+
/** Sender identity. */
|
|
206
|
+
from: TEAMS_MESSAGE_FROM_SCHEMA.nullish().transform((value) => value ?? undefined),
|
|
207
|
+
/** Message importance. */
|
|
208
|
+
importance: z
|
|
209
|
+
.enum(["normal", "high", "urgent", "unknownFutureValue"])
|
|
210
|
+
.prefault("normal"),
|
|
211
|
+
/** Message locale. */
|
|
212
|
+
locale: OPTIONAL_STRING_SCHEMA,
|
|
213
|
+
/** Opaque Teams message identifier. */
|
|
214
|
+
messageId: z.string(),
|
|
215
|
+
/** Message kind. */
|
|
216
|
+
messageType: z.string(),
|
|
217
|
+
/** Structured mentions embedded in the body. */
|
|
218
|
+
mentions: TEAMS_MESSAGE_MENTION_SCHEMA.array().prefault([]),
|
|
219
|
+
/** Reactions currently applied to the message. */
|
|
220
|
+
reactions: TEAMS_MESSAGE_REACTION_SCHEMA.array().prefault([]),
|
|
221
|
+
/** Parent channel message identifier for a reply. */
|
|
222
|
+
replyToId: OPTIONAL_STRING_SCHEMA,
|
|
223
|
+
/** Subject, commonly present on channel announcements. */
|
|
224
|
+
subject: OPTIONAL_STRING_SCHEMA,
|
|
225
|
+
/** Provider-generated summary. */
|
|
226
|
+
summary: OPTIONAL_STRING_SCHEMA,
|
|
227
|
+
/** Time the message was last modified. */
|
|
228
|
+
updatedAt: OPTIONAL_DATE_SCHEMA,
|
|
229
|
+
/** Microsoft Teams web URL. */
|
|
230
|
+
webUrl: OPTIONAL_STRING_SCHEMA,
|
|
231
|
+
});
|
|
232
|
+
const GRAPH_IDENTITY_SCHEMA = z
|
|
233
|
+
.looseObject({
|
|
234
|
+
id: z.string().nullish(),
|
|
235
|
+
displayName: z.string().nullish(),
|
|
236
|
+
})
|
|
237
|
+
.optional();
|
|
238
|
+
export const GRAPH_CHAT_MESSAGE_SCHEMA = z
|
|
239
|
+
.looseObject({
|
|
240
|
+
attachments: z
|
|
241
|
+
.looseObject({
|
|
242
|
+
content: z.string().nullish(),
|
|
243
|
+
contentType: z.string(),
|
|
244
|
+
contentUrl: z.string().nullish(),
|
|
245
|
+
id: z.string(),
|
|
246
|
+
name: z.string().nullish(),
|
|
247
|
+
})
|
|
248
|
+
.array()
|
|
249
|
+
.optional(),
|
|
250
|
+
body: z.object({
|
|
251
|
+
content: z.string(),
|
|
252
|
+
contentType: z.enum(["text", "html"]),
|
|
253
|
+
}),
|
|
254
|
+
createdDateTime: z.string().nullish(),
|
|
255
|
+
deletedDateTime: z.string().nullish(),
|
|
256
|
+
etag: z.string().nullish(),
|
|
257
|
+
from: z
|
|
258
|
+
.looseObject({
|
|
259
|
+
application: GRAPH_IDENTITY_SCHEMA,
|
|
260
|
+
device: GRAPH_IDENTITY_SCHEMA,
|
|
261
|
+
user: GRAPH_IDENTITY_SCHEMA,
|
|
262
|
+
})
|
|
263
|
+
.nullish(),
|
|
264
|
+
id: z.string(),
|
|
265
|
+
importance: z
|
|
266
|
+
.enum(["normal", "high", "urgent", "unknownFutureValue"])
|
|
267
|
+
.optional(),
|
|
268
|
+
lastModifiedDateTime: z.string().nullish(),
|
|
269
|
+
locale: z.string().nullish(),
|
|
270
|
+
mentions: z
|
|
271
|
+
.looseObject({
|
|
272
|
+
id: z.number().int(),
|
|
273
|
+
mentionText: z.string(),
|
|
274
|
+
mentioned: z.looseObject({
|
|
275
|
+
application: GRAPH_IDENTITY_SCHEMA,
|
|
276
|
+
device: GRAPH_IDENTITY_SCHEMA,
|
|
277
|
+
user: GRAPH_IDENTITY_SCHEMA,
|
|
278
|
+
}),
|
|
279
|
+
})
|
|
280
|
+
.array()
|
|
281
|
+
.optional(),
|
|
282
|
+
messageType: z.string(),
|
|
283
|
+
reactions: z
|
|
284
|
+
.looseObject({
|
|
285
|
+
createdDateTime: z.string().nullish(),
|
|
286
|
+
reactionType: z.string(),
|
|
287
|
+
user: z.looseObject({
|
|
288
|
+
application: GRAPH_IDENTITY_SCHEMA,
|
|
289
|
+
device: GRAPH_IDENTITY_SCHEMA,
|
|
290
|
+
user: GRAPH_IDENTITY_SCHEMA,
|
|
291
|
+
}),
|
|
292
|
+
})
|
|
293
|
+
.array()
|
|
294
|
+
.optional(),
|
|
295
|
+
replyToId: z.string().nullish(),
|
|
296
|
+
subject: z.string().nullish(),
|
|
297
|
+
summary: z.string().nullish(),
|
|
298
|
+
webUrl: z.string().nullish(),
|
|
299
|
+
})
|
|
300
|
+
.transform((message) => TEAMS_CHAT_MESSAGE_SCHEMA.parse({
|
|
301
|
+
attachments: message.attachments?.map((attachment) => ({
|
|
302
|
+
attachmentId: attachment.id,
|
|
303
|
+
content: attachment.content,
|
|
304
|
+
contentType: attachment.contentType,
|
|
305
|
+
contentUrl: attachment.contentUrl,
|
|
306
|
+
name: attachment.name,
|
|
307
|
+
})),
|
|
308
|
+
body: message.body,
|
|
309
|
+
createdAt: message.createdDateTime,
|
|
310
|
+
deletedAt: message.deletedDateTime,
|
|
311
|
+
etag: message.etag,
|
|
312
|
+
from: graphIdentitySet(message.from),
|
|
313
|
+
importance: message.importance,
|
|
314
|
+
locale: message.locale,
|
|
315
|
+
mentions: message.mentions?.map((mention) => ({
|
|
316
|
+
mentionId: mention.id,
|
|
317
|
+
mentioned: graphIdentitySet(mention.mentioned),
|
|
318
|
+
mentionText: mention.mentionText,
|
|
319
|
+
})),
|
|
320
|
+
messageId: message.id,
|
|
321
|
+
messageType: message.messageType,
|
|
322
|
+
reactions: message.reactions?.map((reaction) => ({
|
|
323
|
+
createdAt: reaction.createdDateTime,
|
|
324
|
+
reactionType: reaction.reactionType,
|
|
325
|
+
user: graphIdentitySet(reaction.user),
|
|
326
|
+
})),
|
|
327
|
+
replyToId: message.replyToId,
|
|
328
|
+
subject: message.subject,
|
|
329
|
+
summary: message.summary,
|
|
330
|
+
updatedAt: message.lastModifiedDateTime,
|
|
331
|
+
webUrl: message.webUrl,
|
|
332
|
+
}));
|
|
333
|
+
/**
|
|
334
|
+
* Normalizes an untrusted Microsoft Graph chat-message payload.
|
|
335
|
+
*
|
|
336
|
+
* @param payload - Provider chat-message payload.
|
|
337
|
+
*/
|
|
338
|
+
export function normalizeTeamsChatMessage(payload) {
|
|
339
|
+
return GRAPH_CHAT_MESSAGE_SCHEMA.parse(payload);
|
|
340
|
+
}
|
|
341
|
+
export const TEAMS_CHANNEL_MESSAGE_POSTED_EVENT_SCHEMA = TEAMS_CHAT_MESSAGE_SCHEMA.extend({
|
|
342
|
+
/** Channel containing the posted message. */
|
|
343
|
+
channelId: z.string(),
|
|
344
|
+
/** Team containing the posted message. */
|
|
345
|
+
teamId: z.string(),
|
|
346
|
+
});
|
|
347
|
+
export const TEAMS_CHAT_MESSAGE_POSTED_EVENT_SCHEMA = TEAMS_CHAT_MESSAGE_SCHEMA.extend({
|
|
348
|
+
/** Chat containing the posted message. */
|
|
349
|
+
chatId: z.string(),
|
|
350
|
+
});
|
|
351
|
+
/**
|
|
352
|
+
* Flattens Graph's user/application/device identity-set union.
|
|
353
|
+
*
|
|
354
|
+
* @param identitySet - Provider identity set.
|
|
355
|
+
*/
|
|
356
|
+
function graphIdentitySet(identitySet) {
|
|
357
|
+
return {
|
|
358
|
+
applicationId: identitySet?.application?.id,
|
|
359
|
+
deviceId: identitySet?.device?.id,
|
|
360
|
+
displayName: identitySet?.user?.displayName ??
|
|
361
|
+
identitySet?.application?.displayName ??
|
|
362
|
+
identitySet?.device?.displayName,
|
|
363
|
+
userId: identitySet?.user?.id,
|
|
364
|
+
};
|
|
365
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Scalar value serialized into one Trello query parameter. */
|
|
3
|
+
type TrelloQueryValue = boolean | number | string | undefined;
|
|
4
|
+
/** Options for one authenticated Trello REST request. */
|
|
5
|
+
export interface TrelloRequestOptions<TSchema extends z.ZodType> {
|
|
6
|
+
/** JSON request body for endpoints that accept one. */
|
|
7
|
+
body?: unknown;
|
|
8
|
+
/** HTTP verb. Defaults to `GET`. */
|
|
9
|
+
method?: "DELETE" | "GET" | "POST" | "PUT";
|
|
10
|
+
/** Query parameters appended to the request URL. */
|
|
11
|
+
query?: Record<string, TrelloQueryValue>;
|
|
12
|
+
/** Schema that validates and types the successful response. */
|
|
13
|
+
responseSchema: TSchema;
|
|
14
|
+
}
|
|
15
|
+
/** Authenticated raw Trello REST helper. */
|
|
16
|
+
export interface TrelloApi {
|
|
17
|
+
/**
|
|
18
|
+
* Calls any Trello REST endpoint and validates its successful response.
|
|
19
|
+
*
|
|
20
|
+
* @param path - Relative path below Trello's `/1` API root.
|
|
21
|
+
* @param options - Request data and successful response schema.
|
|
22
|
+
*/
|
|
23
|
+
request<TSchema extends z.ZodType>(path: string, options: TrelloRequestOptions<TSchema>): Promise<z.output<TSchema>>;
|
|
24
|
+
}
|
|
25
|
+
/** Structured Trello REST request error. */
|
|
26
|
+
export declare class TrelloApiError extends Error {
|
|
27
|
+
/** Provider error body, when Trello returned text. */
|
|
28
|
+
readonly providerMessage?: string;
|
|
29
|
+
/** Retry delay from Trello's `Retry-After` header, in seconds. */
|
|
30
|
+
readonly retryAfter?: number;
|
|
31
|
+
/** HTTP status returned by Trello. */
|
|
32
|
+
readonly status: number;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a structured Trello API error.
|
|
35
|
+
*
|
|
36
|
+
* @param options - Provider and transport error details.
|
|
37
|
+
* @param options.providerMessage - Provider error body.
|
|
38
|
+
* @param options.retryAfter - Retry delay in seconds.
|
|
39
|
+
* @param options.status - HTTP response status.
|
|
40
|
+
*/
|
|
41
|
+
constructor(options: {
|
|
42
|
+
providerMessage?: string;
|
|
43
|
+
retryAfter?: number;
|
|
44
|
+
status: number;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates a raw authenticated Trello REST helper.
|
|
49
|
+
*
|
|
50
|
+
* Use this escape hatch for provider endpoints that do not yet have a packaged
|
|
51
|
+
* action. Trello authenticates requests with the integration API key and user
|
|
52
|
+
* token, and the caller supplies a response schema for boundary validation.
|
|
53
|
+
*
|
|
54
|
+
* @param secret - Resolved Trello integration secret.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getTrelloApi(secret: Record<string, unknown>): TrelloApi;
|
|
57
|
+
/**
|
|
58
|
+
* Accepts a raw card ID, short link, or standard Trello card URL.
|
|
59
|
+
*
|
|
60
|
+
* @param card - Card reference to normalize.
|
|
61
|
+
*/
|
|
62
|
+
export declare function normalizeTrelloCardId(card: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* Accepts a raw board ID, short link, or standard Trello board URL.
|
|
65
|
+
*
|
|
66
|
+
* @param board - Board reference to normalize.
|
|
67
|
+
*/
|
|
68
|
+
export declare function normalizeTrelloBoardId(board: string): string;
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const TRELLO_API_BASE_URL = "https://api.trello.com/1/";
|
|
3
|
+
const TRELLO_API_ORIGIN = new URL(TRELLO_API_BASE_URL).origin;
|
|
4
|
+
const TRELLO_SECRET_SCHEMA = z.object({
|
|
5
|
+
apiKey: z.string().min(1),
|
|
6
|
+
token: z.string().min(1),
|
|
7
|
+
});
|
|
8
|
+
const TRELLO_ERROR_SCHEMA = z.looseObject({
|
|
9
|
+
message: z.string().optional(),
|
|
10
|
+
});
|
|
11
|
+
/** Structured Trello REST request error. */
|
|
12
|
+
export class TrelloApiError extends Error {
|
|
13
|
+
/** Provider error body, when Trello returned text. */
|
|
14
|
+
providerMessage;
|
|
15
|
+
/** Retry delay from Trello's `Retry-After` header, in seconds. */
|
|
16
|
+
retryAfter;
|
|
17
|
+
/** HTTP status returned by Trello. */
|
|
18
|
+
status;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a structured Trello API error.
|
|
21
|
+
*
|
|
22
|
+
* @param options - Provider and transport error details.
|
|
23
|
+
* @param options.providerMessage - Provider error body.
|
|
24
|
+
* @param options.retryAfter - Retry delay in seconds.
|
|
25
|
+
* @param options.status - HTTP response status.
|
|
26
|
+
*/
|
|
27
|
+
constructor(options) {
|
|
28
|
+
super(options.providerMessage
|
|
29
|
+
? `Trello API error (${options.status}): ${options.providerMessage}`
|
|
30
|
+
: `Trello API request failed with status ${options.status}.`);
|
|
31
|
+
this.name = "TrelloApiError";
|
|
32
|
+
this.providerMessage = options.providerMessage;
|
|
33
|
+
this.retryAfter = options.retryAfter;
|
|
34
|
+
this.status = options.status;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates a raw authenticated Trello REST helper.
|
|
39
|
+
*
|
|
40
|
+
* Use this escape hatch for provider endpoints that do not yet have a packaged
|
|
41
|
+
* action. Trello authenticates requests with the integration API key and user
|
|
42
|
+
* token, and the caller supplies a response schema for boundary validation.
|
|
43
|
+
*
|
|
44
|
+
* @param secret - Resolved Trello integration secret.
|
|
45
|
+
*/
|
|
46
|
+
export function getTrelloApi(secret) {
|
|
47
|
+
const { apiKey, token } = TRELLO_SECRET_SCHEMA.parse(secret);
|
|
48
|
+
return {
|
|
49
|
+
request: async (path, options) => {
|
|
50
|
+
const url = new URL(path.replace(/^\//, ""), TRELLO_API_BASE_URL);
|
|
51
|
+
if (url.origin !== TRELLO_API_ORIGIN) {
|
|
52
|
+
throw new Error("Trello API paths must use the Trello API origin.");
|
|
53
|
+
}
|
|
54
|
+
for (const [name, value] of Object.entries(options.query ?? {})) {
|
|
55
|
+
if (value !== undefined)
|
|
56
|
+
url.searchParams.set(name, String(value));
|
|
57
|
+
}
|
|
58
|
+
url.searchParams.set("key", apiKey);
|
|
59
|
+
url.searchParams.set("token", token);
|
|
60
|
+
const headers = new Headers({ Accept: "application/json" });
|
|
61
|
+
if (options.body !== undefined)
|
|
62
|
+
headers.set("Content-Type", "application/json");
|
|
63
|
+
const response = await fetch(url, {
|
|
64
|
+
body: options.body === undefined ? undefined : JSON.stringify(options.body),
|
|
65
|
+
headers,
|
|
66
|
+
method: options.method ?? "GET",
|
|
67
|
+
});
|
|
68
|
+
if (!response.ok) {
|
|
69
|
+
const responseText = await response.text();
|
|
70
|
+
const error = TRELLO_ERROR_SCHEMA.safeParse(parseJson(responseText));
|
|
71
|
+
throw new TrelloApiError({
|
|
72
|
+
providerMessage: error.success && error.data.message
|
|
73
|
+
? error.data.message
|
|
74
|
+
: responseText || undefined,
|
|
75
|
+
retryAfter: parseRetryAfter(response.headers.get("Retry-After")),
|
|
76
|
+
status: response.status,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return options.responseSchema.parse(await response.json());
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Accepts a raw card ID, short link, or standard Trello card URL.
|
|
85
|
+
*
|
|
86
|
+
* @param card - Card reference to normalize.
|
|
87
|
+
*/
|
|
88
|
+
export function normalizeTrelloCardId(card) {
|
|
89
|
+
return normalizeTrelloUrlReference(card, "c");
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Accepts a raw board ID, short link, or standard Trello board URL.
|
|
93
|
+
*
|
|
94
|
+
* @param board - Board reference to normalize.
|
|
95
|
+
*/
|
|
96
|
+
export function normalizeTrelloBoardId(board) {
|
|
97
|
+
return normalizeTrelloUrlReference(board, "b");
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Extracts a Trello short link from one recognized provider URL.
|
|
101
|
+
*
|
|
102
|
+
* @param value - Raw resource reference.
|
|
103
|
+
* @param resource - Expected Trello URL resource segment.
|
|
104
|
+
*/
|
|
105
|
+
function normalizeTrelloUrlReference(value, resource) {
|
|
106
|
+
const trimmed = value.trim();
|
|
107
|
+
if (!URL.canParse(trimmed))
|
|
108
|
+
return trimmed;
|
|
109
|
+
const url = new URL(trimmed);
|
|
110
|
+
if (url.hostname !== "trello.com" && url.hostname !== "www.trello.com") {
|
|
111
|
+
return trimmed;
|
|
112
|
+
}
|
|
113
|
+
const parts = url.pathname.split("/").filter(Boolean);
|
|
114
|
+
const resourceIndex = parts.indexOf(resource);
|
|
115
|
+
return resourceIndex === -1 ? trimmed : (parts[resourceIndex + 1] ?? trimmed);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Parses an optional provider JSON error body without masking the HTTP error.
|
|
119
|
+
*
|
|
120
|
+
* @param value - Raw provider response text.
|
|
121
|
+
*/
|
|
122
|
+
function parseJson(value) {
|
|
123
|
+
try {
|
|
124
|
+
return JSON.parse(value);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Parses Trello's integer retry delay header.
|
|
132
|
+
*
|
|
133
|
+
* @param value - Raw `Retry-After` header.
|
|
134
|
+
*/
|
|
135
|
+
function parseRetryAfter(value) {
|
|
136
|
+
if (value === null)
|
|
137
|
+
return undefined;
|
|
138
|
+
const seconds = Number(value);
|
|
139
|
+
return Number.isFinite(seconds) ? seconds : undefined;
|
|
140
|
+
}
|