terse-types 0.0.28 → 0.0.30
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/json-schema/terse-types.schema.json +346 -1517
- package/dist/types.d.ts +12 -4
- package/dist/types.js +11 -2
- package/package.json +1 -1
- package/dist/BillingErrors.d.ts +0 -20
- package/dist/BillingErrors.js +0 -39
- package/dist/BillingSchemas.d.ts +0 -72
- package/dist/BillingSchemas.js +0 -59
- package/dist/SandboxTypes.d.ts +0 -15
- package/dist/SandboxTypes.js +0 -1
- package/dist/TriggerEventPresenters.d.ts +0 -3
- package/dist/TriggerEventPresenters.js +0 -238
- package/dist/TriggerEvents.d.ts +0 -4054
- package/dist/TriggerEvents.js +0 -437
package/dist/TriggerEvents.js
DELETED
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { GitHubEventType, WorkOSEventType, gitHubEventTypeSchema, gmailEventTypeSchema, linearEventTypeSchema, slackEventTypeSchema, workOSEventTypeSchema } from "./Configs.js";
|
|
3
|
-
import { IntegrationType, integrationTypeEnum } from "./Integrations.js";
|
|
4
|
-
import { SlackChannelType } from "./SlackTypes.js";
|
|
5
|
-
import { debugTrigger as debugTriggerWithPresenter, formatTriggerForAgent as formatTriggerForAgentWithPresenter } from "./TriggerPresenters.js";
|
|
6
|
-
const providerTriggerTypeSchema = z.union([slackEventTypeSchema, gitHubEventTypeSchema, linearEventTypeSchema, gmailEventTypeSchema, workOSEventTypeSchema]);
|
|
7
|
-
const TriggerHeaderSchema = z.object({
|
|
8
|
-
integrationType: integrationTypeEnum,
|
|
9
|
-
eventType: providerTriggerTypeSchema
|
|
10
|
-
});
|
|
11
|
-
const slackTriggerBaseSchema = TriggerHeaderSchema.extend({
|
|
12
|
-
integrationType: z.literal(IntegrationType.SLACK),
|
|
13
|
-
eventType: slackEventTypeSchema,
|
|
14
|
-
channelId: z.string(),
|
|
15
|
-
channelName: z.string().nullable(),
|
|
16
|
-
userId: z.string(),
|
|
17
|
-
userName: z.string().nullable(),
|
|
18
|
-
text: z.string(),
|
|
19
|
-
timestamp: z.string(),
|
|
20
|
-
// Keep both names during migration; `threadTs` is the target shared field.
|
|
21
|
-
threadTs: z.string().nullable().optional(),
|
|
22
|
-
threadTimestamp: z.string().nullable(),
|
|
23
|
-
teamId: z.string(),
|
|
24
|
-
permalink: z.string().nullable(),
|
|
25
|
-
channelType: z.enum(SlackChannelType).nullable(),
|
|
26
|
-
blocks: z.array(z.unknown()).nullable(),
|
|
27
|
-
attachments: z.array(z.unknown()).nullable(),
|
|
28
|
-
files: z.array(z.unknown()).nullable()
|
|
29
|
-
});
|
|
30
|
-
export const slackMessageTriggerSchema = slackTriggerBaseSchema.extend({
|
|
31
|
-
eventType: z.literal("message")
|
|
32
|
-
});
|
|
33
|
-
export const slackAppMentionTriggerSchema = slackTriggerBaseSchema.extend({
|
|
34
|
-
eventType: z.literal("app_mention")
|
|
35
|
-
});
|
|
36
|
-
export const slackReactionAddedTriggerSchema = slackTriggerBaseSchema.extend({
|
|
37
|
-
eventType: z.literal("reaction_added"),
|
|
38
|
-
reaction: z.string(),
|
|
39
|
-
itemType: z.string().nullable(),
|
|
40
|
-
itemUserId: z.string().nullable(),
|
|
41
|
-
itemChannelId: z.string().nullable(),
|
|
42
|
-
itemTimestamp: z.string().nullable()
|
|
43
|
-
});
|
|
44
|
-
export const slackTriggerSchema = z.discriminatedUnion("eventType", [slackMessageTriggerSchema, slackAppMentionTriggerSchema, slackReactionAddedTriggerSchema]);
|
|
45
|
-
// Github Event Data
|
|
46
|
-
export const fileDiffSchema = z.object({
|
|
47
|
-
filename: z.string(),
|
|
48
|
-
diff: z.string()
|
|
49
|
-
});
|
|
50
|
-
export const commitSchema = z.object({
|
|
51
|
-
sha: z.string(),
|
|
52
|
-
// Keep both names during migration; `message` is the target shared field.
|
|
53
|
-
message: z.string().optional(),
|
|
54
|
-
name: z.string(),
|
|
55
|
-
fileDiffs: z.array(fileDiffSchema)
|
|
56
|
-
});
|
|
57
|
-
export const pullRequestUserSchema = z.object({
|
|
58
|
-
login: z.string(),
|
|
59
|
-
email: z.string().optional()
|
|
60
|
-
});
|
|
61
|
-
export const pullRequestRefSchema = z.object({
|
|
62
|
-
ref: z.string(),
|
|
63
|
-
sha: z.string()
|
|
64
|
-
});
|
|
65
|
-
export const pullRequestSchema = z.object({
|
|
66
|
-
id: z.string(),
|
|
67
|
-
number: z.number(),
|
|
68
|
-
title: z.string(),
|
|
69
|
-
body: z.string().optional(),
|
|
70
|
-
state: z.enum(["open", "closed"]),
|
|
71
|
-
merged: z.boolean(),
|
|
72
|
-
head: pullRequestRefSchema,
|
|
73
|
-
base: pullRequestRefSchema,
|
|
74
|
-
// Keep both names during migration; `author` is the target shared field.
|
|
75
|
-
user: pullRequestUserSchema,
|
|
76
|
-
author: pullRequestUserSchema.optional(),
|
|
77
|
-
url: z.string().optional()
|
|
78
|
-
});
|
|
79
|
-
export const githubRepositorySchema = z.object({
|
|
80
|
-
id: z.number(),
|
|
81
|
-
name: z.string(),
|
|
82
|
-
owner: z.string(),
|
|
83
|
-
defaultBranch: z.string()
|
|
84
|
-
});
|
|
85
|
-
export const senderSchema = z.object({
|
|
86
|
-
login: z.string(),
|
|
87
|
-
email: z.string().optional()
|
|
88
|
-
});
|
|
89
|
-
const GithubTriggerBaseSchema = z.object({
|
|
90
|
-
integrationType: z.literal(IntegrationType.GITHUB),
|
|
91
|
-
username: z.string(),
|
|
92
|
-
installationId: z.number(),
|
|
93
|
-
repositoryName: z.string(),
|
|
94
|
-
repository: githubRepositorySchema,
|
|
95
|
-
sender: senderSchema
|
|
96
|
-
});
|
|
97
|
-
export const GithubPushTriggerSchema = GithubTriggerBaseSchema.extend({
|
|
98
|
-
eventType: z.literal(GitHubEventType.PUSH),
|
|
99
|
-
branch: z.string(),
|
|
100
|
-
commits: z.array(commitSchema),
|
|
101
|
-
pullRequest: z.undefined().optional()
|
|
102
|
-
});
|
|
103
|
-
const GithubPRTriggerBaseSchema = GithubTriggerBaseSchema.extend({
|
|
104
|
-
pullRequest: pullRequestSchema,
|
|
105
|
-
branch: z.string().optional(),
|
|
106
|
-
commits: z.array(commitSchema)
|
|
107
|
-
});
|
|
108
|
-
export const GithubPROpenedTriggerSchema = GithubPRTriggerBaseSchema.extend({
|
|
109
|
-
eventType: z.literal(GitHubEventType.PR_OPENED)
|
|
110
|
-
});
|
|
111
|
-
export const GithubPRSynchronizedTriggerSchema = GithubPRTriggerBaseSchema.extend({
|
|
112
|
-
eventType: z.literal(GitHubEventType.PR_SYNCHRONIZE)
|
|
113
|
-
});
|
|
114
|
-
export const GithubPRClosedTriggerSchema = GithubPRTriggerBaseSchema.extend({
|
|
115
|
-
eventType: z.literal(GitHubEventType.PR_CLOSED)
|
|
116
|
-
});
|
|
117
|
-
export const GithubPRMergedTriggerSchema = GithubPRTriggerBaseSchema.extend({
|
|
118
|
-
eventType: z.literal(GitHubEventType.PR_MERGED)
|
|
119
|
-
});
|
|
120
|
-
export const GithubPRTriggerSchema = z.discriminatedUnion("eventType", [GithubPROpenedTriggerSchema, GithubPRSynchronizedTriggerSchema, GithubPRClosedTriggerSchema, GithubPRMergedTriggerSchema]);
|
|
121
|
-
export const GithubTriggerSchema = z.discriminatedUnion("eventType", [
|
|
122
|
-
GithubPushTriggerSchema,
|
|
123
|
-
GithubPROpenedTriggerSchema,
|
|
124
|
-
GithubPRSynchronizedTriggerSchema,
|
|
125
|
-
GithubPRClosedTriggerSchema,
|
|
126
|
-
GithubPRMergedTriggerSchema
|
|
127
|
-
]);
|
|
128
|
-
export const GmailParsedAttachmentSchema = z.object({
|
|
129
|
-
attachmentId: z.string(),
|
|
130
|
-
filename: z.string(),
|
|
131
|
-
mimeType: z.string(),
|
|
132
|
-
contentId: z.string().optional(),
|
|
133
|
-
isInline: z.boolean()
|
|
134
|
-
});
|
|
135
|
-
const gmailMessagePayloadSchema = z.object({
|
|
136
|
-
id: z.string(),
|
|
137
|
-
threadId: z.string(),
|
|
138
|
-
subject: z.string(),
|
|
139
|
-
from: z.string(),
|
|
140
|
-
to: z.string(),
|
|
141
|
-
date: z.string(),
|
|
142
|
-
internalDate: z.string(),
|
|
143
|
-
messageId: z.string(),
|
|
144
|
-
body: z.string(),
|
|
145
|
-
snippet: z.string(),
|
|
146
|
-
labelIds: z.array(z.string()),
|
|
147
|
-
attachments: z.array(GmailParsedAttachmentSchema).optional()
|
|
148
|
-
});
|
|
149
|
-
export const LinearWebhookActionSchema = z.enum(["create", "update", "remove"]);
|
|
150
|
-
export const LinearWebhookTypeSchema = z.union([z.literal("Issue"), z.literal("Comment"), z.literal("Project"), z.string()]);
|
|
151
|
-
export const LinearWebhookActorSchema = z.object({
|
|
152
|
-
id: z.string(),
|
|
153
|
-
name: z.string(),
|
|
154
|
-
email: z.string(),
|
|
155
|
-
url: z.string(),
|
|
156
|
-
type: z.string()
|
|
157
|
-
});
|
|
158
|
-
export const LinearWebhookStateSchema = z.object({
|
|
159
|
-
id: z.string(),
|
|
160
|
-
color: z.string(),
|
|
161
|
-
name: z.string(),
|
|
162
|
-
type: z.string()
|
|
163
|
-
});
|
|
164
|
-
export const LinearWebhookTeamSchema = z.object({
|
|
165
|
-
id: z.string(),
|
|
166
|
-
key: z.string(),
|
|
167
|
-
name: z.string()
|
|
168
|
-
});
|
|
169
|
-
export const LinearWebhookAssigneeSchema = z.object({
|
|
170
|
-
id: z.string(),
|
|
171
|
-
name: z.string()
|
|
172
|
-
});
|
|
173
|
-
export const LinearWebhookDataSchema = z.object({
|
|
174
|
-
id: z.string(),
|
|
175
|
-
createdAt: z.string(),
|
|
176
|
-
updatedAt: z.string(),
|
|
177
|
-
number: z.number(),
|
|
178
|
-
title: z.string(),
|
|
179
|
-
priority: z.number(),
|
|
180
|
-
sortOrder: z.number(),
|
|
181
|
-
prioritySortOrder: z.number(),
|
|
182
|
-
slaType: z.string(),
|
|
183
|
-
addedToTeamAt: z.string(),
|
|
184
|
-
trashed: z.boolean(),
|
|
185
|
-
labelIds: z.array(z.string()),
|
|
186
|
-
teamId: z.string(),
|
|
187
|
-
previousIdentifiers: z.array(z.string()),
|
|
188
|
-
stateId: z.string(),
|
|
189
|
-
reactionData: z.array(z.any()),
|
|
190
|
-
priorityLabel: z.string(),
|
|
191
|
-
botActor: z.string().optional(),
|
|
192
|
-
identifier: z.string(),
|
|
193
|
-
url: z.string(),
|
|
194
|
-
subscriberIds: z.array(z.string()),
|
|
195
|
-
state: LinearWebhookStateSchema,
|
|
196
|
-
team: LinearWebhookTeamSchema,
|
|
197
|
-
labels: z.array(z.any()),
|
|
198
|
-
description: z.string().optional(),
|
|
199
|
-
descriptionData: z.string().optional(),
|
|
200
|
-
assignee: LinearWebhookAssigneeSchema.optional()
|
|
201
|
-
});
|
|
202
|
-
export const LinearWebhookCommentDataSchema = z
|
|
203
|
-
.object({
|
|
204
|
-
id: z.string(),
|
|
205
|
-
body: z.string().optional(),
|
|
206
|
-
issueId: z.string().optional()
|
|
207
|
-
})
|
|
208
|
-
.passthrough();
|
|
209
|
-
export const linearWebhookPayloadSchema = z.object({
|
|
210
|
-
action: LinearWebhookActionSchema,
|
|
211
|
-
actor: LinearWebhookActorSchema,
|
|
212
|
-
createdAt: z.string(),
|
|
213
|
-
data: LinearWebhookDataSchema,
|
|
214
|
-
type: LinearWebhookTypeSchema,
|
|
215
|
-
url: z.string().optional(),
|
|
216
|
-
organizationId: z.string(),
|
|
217
|
-
webhookTimestamp: z.number(),
|
|
218
|
-
webhookId: z.string()
|
|
219
|
-
});
|
|
220
|
-
export const WorkOSWebhookDataSchema = z.record(z.string(), z.any());
|
|
221
|
-
export const workOSWebhookPayloadSchema = z.object({
|
|
222
|
-
id: z.string(),
|
|
223
|
-
event: z.string(),
|
|
224
|
-
data: WorkOSWebhookDataSchema,
|
|
225
|
-
created_at: z.string()
|
|
226
|
-
});
|
|
227
|
-
// MARK: Canonical Trigger Events
|
|
228
|
-
export const webhookTriggerTypeSchema = z.literal("webhook");
|
|
229
|
-
export const cronTriggerTypeSchema = z.literal("cron");
|
|
230
|
-
export const manualSampleTriggerTypeSchema = z.literal("manual_sample");
|
|
231
|
-
export const TriggerTypeSchema = z.union([
|
|
232
|
-
slackEventTypeSchema,
|
|
233
|
-
gitHubEventTypeSchema,
|
|
234
|
-
linearEventTypeSchema,
|
|
235
|
-
gmailEventTypeSchema,
|
|
236
|
-
workOSEventTypeSchema,
|
|
237
|
-
webhookTriggerTypeSchema,
|
|
238
|
-
cronTriggerTypeSchema,
|
|
239
|
-
manualSampleTriggerTypeSchema
|
|
240
|
-
]);
|
|
241
|
-
export const baseTriggerSchema = z.object({
|
|
242
|
-
integrationType: integrationTypeEnum,
|
|
243
|
-
eventType: TriggerTypeSchema
|
|
244
|
-
});
|
|
245
|
-
export const gmailTriggerSchema = baseTriggerSchema
|
|
246
|
-
.extend({
|
|
247
|
-
integrationType: z.literal(IntegrationType.GMAIL),
|
|
248
|
-
eventType: gmailEventTypeSchema
|
|
249
|
-
})
|
|
250
|
-
.merge(gmailMessagePayloadSchema);
|
|
251
|
-
const linearTriggerBaseSchema = z.object({
|
|
252
|
-
integrationType: z.literal(IntegrationType.LINEAR),
|
|
253
|
-
action: LinearWebhookActionSchema,
|
|
254
|
-
actor: LinearWebhookActorSchema,
|
|
255
|
-
createdAt: z.string(),
|
|
256
|
-
url: z.string().optional(),
|
|
257
|
-
organizationId: z.string(),
|
|
258
|
-
webhookTimestamp: z.number(),
|
|
259
|
-
webhookId: z.string()
|
|
260
|
-
});
|
|
261
|
-
export const linearIssueCreatedTriggerSchema = linearTriggerBaseSchema.extend({
|
|
262
|
-
eventType: z.literal("issue.created"),
|
|
263
|
-
action: z.literal("create"),
|
|
264
|
-
type: z.literal("Issue"),
|
|
265
|
-
data: LinearWebhookDataSchema
|
|
266
|
-
});
|
|
267
|
-
export const linearIssueUpdatedTriggerSchema = linearTriggerBaseSchema.extend({
|
|
268
|
-
eventType: z.literal("issue.updated"),
|
|
269
|
-
action: z.literal("update"),
|
|
270
|
-
type: z.literal("Issue"),
|
|
271
|
-
data: LinearWebhookDataSchema
|
|
272
|
-
});
|
|
273
|
-
export const linearCommentCreatedTriggerSchema = linearTriggerBaseSchema.extend({
|
|
274
|
-
eventType: z.literal("comment.created"),
|
|
275
|
-
action: z.literal("create"),
|
|
276
|
-
type: z.literal("Comment"),
|
|
277
|
-
data: LinearWebhookCommentDataSchema
|
|
278
|
-
});
|
|
279
|
-
export const linearTriggerSchema = z.discriminatedUnion("eventType", [linearIssueCreatedTriggerSchema, linearIssueUpdatedTriggerSchema, linearCommentCreatedTriggerSchema]);
|
|
280
|
-
export const workOSTriggerUserSchema = z.object({
|
|
281
|
-
id: z.string(),
|
|
282
|
-
email: z.string(),
|
|
283
|
-
firstName: z.string().optional(),
|
|
284
|
-
lastName: z.string().optional(),
|
|
285
|
-
emailVerified: z.boolean(),
|
|
286
|
-
profilePictureUrl: z.string().optional()
|
|
287
|
-
});
|
|
288
|
-
export const workOSTriggerMembershipSchema = z.object({
|
|
289
|
-
id: z.string(),
|
|
290
|
-
userId: z.string(),
|
|
291
|
-
organizationId: z.string(),
|
|
292
|
-
role: z.object({
|
|
293
|
-
slug: z.string()
|
|
294
|
-
}),
|
|
295
|
-
status: z.string()
|
|
296
|
-
});
|
|
297
|
-
export const workOSTriggerInvitationSchema = z.object({
|
|
298
|
-
id: z.string(),
|
|
299
|
-
email: z.string(),
|
|
300
|
-
organizationId: z.string(),
|
|
301
|
-
inviterEmail: z.string().optional(),
|
|
302
|
-
state: z.string(),
|
|
303
|
-
acceptedAt: z.string().optional()
|
|
304
|
-
});
|
|
305
|
-
export const workOSTriggerOrganizationSchema = z.object({
|
|
306
|
-
id: z.string(),
|
|
307
|
-
name: z.string()
|
|
308
|
-
});
|
|
309
|
-
const workOSTriggerBaseSchema = baseTriggerSchema.extend({
|
|
310
|
-
integrationType: z.literal(IntegrationType.WORKOS),
|
|
311
|
-
eventType: workOSEventTypeSchema,
|
|
312
|
-
eventId: z.string(),
|
|
313
|
-
createdAt: z.string()
|
|
314
|
-
});
|
|
315
|
-
export const workOSUserCreatedTriggerSchema = workOSTriggerBaseSchema.extend({
|
|
316
|
-
eventType: z.literal(WorkOSEventType.USER_CREATED),
|
|
317
|
-
user: workOSTriggerUserSchema
|
|
318
|
-
});
|
|
319
|
-
export const workOSUserUpdatedTriggerSchema = workOSTriggerBaseSchema.extend({
|
|
320
|
-
eventType: z.literal(WorkOSEventType.USER_UPDATED),
|
|
321
|
-
user: workOSTriggerUserSchema
|
|
322
|
-
});
|
|
323
|
-
export const workOSUserDeletedTriggerSchema = workOSTriggerBaseSchema.extend({
|
|
324
|
-
eventType: z.literal(WorkOSEventType.USER_DELETED),
|
|
325
|
-
user: workOSTriggerUserSchema
|
|
326
|
-
});
|
|
327
|
-
export const workOSUserTriggerSchema = z.discriminatedUnion("eventType", [workOSUserCreatedTriggerSchema, workOSUserUpdatedTriggerSchema, workOSUserDeletedTriggerSchema]);
|
|
328
|
-
export const workOSOrganizationMembershipCreatedTriggerSchema = workOSTriggerBaseSchema.extend({
|
|
329
|
-
eventType: z.literal(WorkOSEventType.ORGANIZATION_MEMBERSHIP_CREATED),
|
|
330
|
-
membership: workOSTriggerMembershipSchema
|
|
331
|
-
});
|
|
332
|
-
export const workOSOrganizationMembershipUpdatedTriggerSchema = workOSTriggerBaseSchema.extend({
|
|
333
|
-
eventType: z.literal(WorkOSEventType.ORGANIZATION_MEMBERSHIP_UPDATED),
|
|
334
|
-
membership: workOSTriggerMembershipSchema
|
|
335
|
-
});
|
|
336
|
-
export const workOSOrganizationMembershipDeletedTriggerSchema = workOSTriggerBaseSchema.extend({
|
|
337
|
-
eventType: z.literal(WorkOSEventType.ORGANIZATION_MEMBERSHIP_DELETED),
|
|
338
|
-
membership: workOSTriggerMembershipSchema
|
|
339
|
-
});
|
|
340
|
-
export const workOSMembershipTriggerSchema = z.discriminatedUnion("eventType", [
|
|
341
|
-
workOSOrganizationMembershipCreatedTriggerSchema,
|
|
342
|
-
workOSOrganizationMembershipUpdatedTriggerSchema,
|
|
343
|
-
workOSOrganizationMembershipDeletedTriggerSchema
|
|
344
|
-
]);
|
|
345
|
-
export const workOSInvitationCreatedTriggerSchema = workOSTriggerBaseSchema.extend({
|
|
346
|
-
eventType: z.literal(WorkOSEventType.INVITATION_CREATED),
|
|
347
|
-
invitation: workOSTriggerInvitationSchema,
|
|
348
|
-
user: workOSTriggerUserSchema.optional()
|
|
349
|
-
});
|
|
350
|
-
export const workOSInvitationAcceptedTriggerSchema = workOSTriggerBaseSchema.extend({
|
|
351
|
-
eventType: z.literal(WorkOSEventType.INVITATION_ACCEPTED),
|
|
352
|
-
invitation: workOSTriggerInvitationSchema,
|
|
353
|
-
user: workOSTriggerUserSchema.optional()
|
|
354
|
-
});
|
|
355
|
-
export const workOSInvitationResentTriggerSchema = workOSTriggerBaseSchema.extend({
|
|
356
|
-
eventType: z.literal(WorkOSEventType.INVITATION_RESENT),
|
|
357
|
-
invitation: workOSTriggerInvitationSchema,
|
|
358
|
-
user: workOSTriggerUserSchema.optional()
|
|
359
|
-
});
|
|
360
|
-
export const workOSInvitationRevokedTriggerSchema = workOSTriggerBaseSchema.extend({
|
|
361
|
-
eventType: z.literal(WorkOSEventType.INVITATION_REVOKED),
|
|
362
|
-
invitation: workOSTriggerInvitationSchema,
|
|
363
|
-
user: workOSTriggerUserSchema.optional()
|
|
364
|
-
});
|
|
365
|
-
export const workOSInvitationTriggerSchema = z.discriminatedUnion("eventType", [
|
|
366
|
-
workOSInvitationCreatedTriggerSchema,
|
|
367
|
-
workOSInvitationAcceptedTriggerSchema,
|
|
368
|
-
workOSInvitationResentTriggerSchema,
|
|
369
|
-
workOSInvitationRevokedTriggerSchema
|
|
370
|
-
]);
|
|
371
|
-
export const workOSOrganizationTriggerSchema = workOSTriggerBaseSchema.extend({
|
|
372
|
-
eventType: z.literal(WorkOSEventType.ORGANIZATION_CREATED),
|
|
373
|
-
organization: workOSTriggerOrganizationSchema
|
|
374
|
-
});
|
|
375
|
-
export const workOSTriggerSchema = z.discriminatedUnion("eventType", [
|
|
376
|
-
workOSUserCreatedTriggerSchema,
|
|
377
|
-
workOSUserUpdatedTriggerSchema,
|
|
378
|
-
workOSUserDeletedTriggerSchema,
|
|
379
|
-
workOSOrganizationMembershipCreatedTriggerSchema,
|
|
380
|
-
workOSOrganizationMembershipUpdatedTriggerSchema,
|
|
381
|
-
workOSOrganizationMembershipDeletedTriggerSchema,
|
|
382
|
-
workOSInvitationCreatedTriggerSchema,
|
|
383
|
-
workOSInvitationAcceptedTriggerSchema,
|
|
384
|
-
workOSInvitationResentTriggerSchema,
|
|
385
|
-
workOSInvitationRevokedTriggerSchema,
|
|
386
|
-
workOSOrganizationTriggerSchema
|
|
387
|
-
]);
|
|
388
|
-
export const webhookTriggerSchema = baseTriggerSchema.extend({
|
|
389
|
-
integrationType: z.literal(IntegrationType.WEBHOOK),
|
|
390
|
-
eventType: webhookTriggerTypeSchema,
|
|
391
|
-
body: z.record(z.string(), z.unknown()),
|
|
392
|
-
headers: z.record(z.string(), z.string()),
|
|
393
|
-
method: z.string()
|
|
394
|
-
});
|
|
395
|
-
export const cronTriggerSchema = baseTriggerSchema.extend({
|
|
396
|
-
integrationType: z.literal(IntegrationType.CRON_JOB),
|
|
397
|
-
eventType: cronTriggerTypeSchema,
|
|
398
|
-
inputId: z.string(),
|
|
399
|
-
isManualTrigger: z.boolean().optional(),
|
|
400
|
-
manualContext: z.string().optional()
|
|
401
|
-
});
|
|
402
|
-
export const manualSampleTriggerSchema = baseTriggerSchema.extend({
|
|
403
|
-
eventType: manualSampleTriggerTypeSchema
|
|
404
|
-
});
|
|
405
|
-
export const TriggerSchema = z.union([
|
|
406
|
-
slackTriggerSchema,
|
|
407
|
-
GithubTriggerSchema,
|
|
408
|
-
gmailTriggerSchema,
|
|
409
|
-
linearTriggerSchema,
|
|
410
|
-
workOSTriggerSchema,
|
|
411
|
-
webhookTriggerSchema,
|
|
412
|
-
cronTriggerSchema,
|
|
413
|
-
manualSampleTriggerSchema
|
|
414
|
-
]);
|
|
415
|
-
export function parseTrigger(value) {
|
|
416
|
-
return TriggerSchema.parse(value);
|
|
417
|
-
}
|
|
418
|
-
export function createManualTrigger(params = {}) {
|
|
419
|
-
return parseTrigger({
|
|
420
|
-
integrationType: params.integrationType ?? IntegrationType.TERSE,
|
|
421
|
-
eventType: "manual_sample"
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
export function formatTriggerForAgent(event) {
|
|
425
|
-
return formatTriggerForAgentWithPresenter(event);
|
|
426
|
-
}
|
|
427
|
-
export function debugTrigger(event) {
|
|
428
|
-
return debugTriggerWithPresenter(event);
|
|
429
|
-
}
|
|
430
|
-
export const TriggerArraySchema = z.array(TriggerSchema);
|
|
431
|
-
export const serializedEventSchema = z.object({
|
|
432
|
-
integrationType: integrationTypeEnum,
|
|
433
|
-
eventType: TriggerTypeSchema,
|
|
434
|
-
formattedContent: z.string(),
|
|
435
|
-
debugLog: z.string(),
|
|
436
|
-
data: TriggerSchema
|
|
437
|
-
});
|