@automate.ax/integration-contracts 0.95.4 → 0.97.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/close/schemas.d.ts +1 -1
- package/dist/close/schemas.js +1 -1
- package/dist/slack/event-schemas.d.ts +42126 -0
- package/dist/slack/event-schemas.js +714 -0
- package/dist/slack/index.d.ts +22401 -25
- package/dist/slack/index.js +78 -5
- package/dist/slack/schemas.d.ts +85 -291
- package/dist/slack/schemas.js +68 -185
- package/package.json +2 -2
- package/src/close/schemas.ts +1 -1
- package/src/slack/event-schemas.ts +792 -0
- package/src/slack/index.ts +100 -8
- package/src/slack/schemas.ts +71 -216
package/src/slack/index.ts
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import * as z from "zod"
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
SLACK_APP_MENTION_CALLBACK_EVENT_SCHEMA,
|
|
4
|
+
SLACK_CHANNEL_CREATED_EVENT_SCHEMA,
|
|
5
|
+
SLACK_CHANNEL_MEMBER_JOINED_EVENT_SCHEMA,
|
|
6
|
+
SLACK_CHANNEL_MEMBER_LEFT_EVENT_SCHEMA,
|
|
7
|
+
SLACK_CHANNEL_RENAMED_EVENT_SCHEMA,
|
|
8
|
+
SLACK_CHANNEL_SHARED_EVENT_SCHEMA,
|
|
9
|
+
SLACK_CHANNEL_UNSHARED_EVENT_SCHEMA,
|
|
10
|
+
SLACK_EVENT_SCHEMA,
|
|
11
|
+
SLACK_FILE_CREATED_EVENT_SCHEMA,
|
|
12
|
+
SLACK_FILE_DELETED_EVENT_SCHEMA,
|
|
13
|
+
SLACK_FILE_SHARED_EVENT_SCHEMA,
|
|
14
|
+
SLACK_MESSAGE_CHANGED_EVENT_SCHEMA,
|
|
15
|
+
SLACK_MESSAGE_DELETED_EVENT_SCHEMA,
|
|
16
|
+
SLACK_MESSAGE_POSTED_CALLBACK_EVENT_SCHEMA,
|
|
17
|
+
SLACK_PIN_ADDED_EVENT_SCHEMA,
|
|
18
|
+
SLACK_PIN_REMOVED_EVENT_SCHEMA,
|
|
19
|
+
SLACK_REACTION_ADDED_CALLBACK_EVENT_SCHEMA,
|
|
20
|
+
SLACK_REACTION_CALLBACK_EVENT_SCHEMA,
|
|
21
|
+
SLACK_REACTION_REMOVED_CALLBACK_EVENT_SCHEMA,
|
|
22
|
+
SLACK_THREAD_REPLY_POSTED_EVENT_SCHEMA,
|
|
23
|
+
SLACK_WORKSPACE_MEMBER_CHANGED_EVENT_SCHEMA,
|
|
24
|
+
SLACK_WORKSPACE_MEMBER_JOINED_EVENT_SCHEMA,
|
|
25
|
+
} from "./event-schemas"
|
|
7
26
|
|
|
27
|
+
export * from "./event-schemas"
|
|
8
28
|
export * from "./schemas"
|
|
9
29
|
|
|
10
30
|
export const SLACK_TRIGGER_CONFIG_SCHEMA = z.object({})
|
|
@@ -12,18 +32,90 @@ export const SLACK_TRIGGER_CONFIG_SCHEMA = z.object({})
|
|
|
12
32
|
export const slackTriggerContracts = {
|
|
13
33
|
"slack.app.mentioned": {
|
|
14
34
|
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
15
|
-
eventSchema:
|
|
35
|
+
eventSchema: SLACK_APP_MENTION_CALLBACK_EVENT_SCHEMA,
|
|
36
|
+
},
|
|
37
|
+
"slack.channel.created": {
|
|
38
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
39
|
+
eventSchema: SLACK_CHANNEL_CREATED_EVENT_SCHEMA,
|
|
40
|
+
},
|
|
41
|
+
"slack.channel.member.joined": {
|
|
42
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
43
|
+
eventSchema: SLACK_CHANNEL_MEMBER_JOINED_EVENT_SCHEMA,
|
|
44
|
+
},
|
|
45
|
+
"slack.channel.member.left": {
|
|
46
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
47
|
+
eventSchema: SLACK_CHANNEL_MEMBER_LEFT_EVENT_SCHEMA,
|
|
48
|
+
},
|
|
49
|
+
"slack.channel.renamed": {
|
|
50
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
51
|
+
eventSchema: SLACK_CHANNEL_RENAMED_EVENT_SCHEMA,
|
|
52
|
+
},
|
|
53
|
+
"slack.channel.shared": {
|
|
54
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
55
|
+
eventSchema: SLACK_CHANNEL_SHARED_EVENT_SCHEMA,
|
|
56
|
+
},
|
|
57
|
+
"slack.channel.unshared": {
|
|
58
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
59
|
+
eventSchema: SLACK_CHANNEL_UNSHARED_EVENT_SCHEMA,
|
|
60
|
+
},
|
|
61
|
+
"slack.event.received": {
|
|
62
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
63
|
+
eventSchema: SLACK_EVENT_SCHEMA,
|
|
64
|
+
},
|
|
65
|
+
"slack.file.created": {
|
|
66
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
67
|
+
eventSchema: SLACK_FILE_CREATED_EVENT_SCHEMA,
|
|
68
|
+
},
|
|
69
|
+
"slack.file.deleted": {
|
|
70
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
71
|
+
eventSchema: SLACK_FILE_DELETED_EVENT_SCHEMA,
|
|
72
|
+
},
|
|
73
|
+
"slack.file.shared": {
|
|
74
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
75
|
+
eventSchema: SLACK_FILE_SHARED_EVENT_SCHEMA,
|
|
76
|
+
},
|
|
77
|
+
"slack.message.changed": {
|
|
78
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
79
|
+
eventSchema: SLACK_MESSAGE_CHANGED_EVENT_SCHEMA,
|
|
80
|
+
},
|
|
81
|
+
"slack.message.deleted": {
|
|
82
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
83
|
+
eventSchema: SLACK_MESSAGE_DELETED_EVENT_SCHEMA,
|
|
16
84
|
},
|
|
17
85
|
"slack.message.posted": {
|
|
18
86
|
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
19
|
-
eventSchema:
|
|
87
|
+
eventSchema: SLACK_MESSAGE_POSTED_CALLBACK_EVENT_SCHEMA,
|
|
88
|
+
},
|
|
89
|
+
"slack.pin.added": {
|
|
90
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
91
|
+
eventSchema: SLACK_PIN_ADDED_EVENT_SCHEMA,
|
|
92
|
+
},
|
|
93
|
+
"slack.pin.removed": {
|
|
94
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
95
|
+
eventSchema: SLACK_PIN_REMOVED_EVENT_SCHEMA,
|
|
20
96
|
},
|
|
21
97
|
"slack.reaction.added": {
|
|
22
98
|
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
23
|
-
eventSchema:
|
|
99
|
+
eventSchema: SLACK_REACTION_ADDED_CALLBACK_EVENT_SCHEMA,
|
|
100
|
+
},
|
|
101
|
+
"slack.reaction.event": {
|
|
102
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
103
|
+
eventSchema: SLACK_REACTION_CALLBACK_EVENT_SCHEMA,
|
|
24
104
|
},
|
|
25
105
|
"slack.reaction.removed": {
|
|
26
106
|
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
27
|
-
eventSchema:
|
|
107
|
+
eventSchema: SLACK_REACTION_REMOVED_CALLBACK_EVENT_SCHEMA,
|
|
108
|
+
},
|
|
109
|
+
"slack.thread.reply.posted": {
|
|
110
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
111
|
+
eventSchema: SLACK_THREAD_REPLY_POSTED_EVENT_SCHEMA,
|
|
112
|
+
},
|
|
113
|
+
"slack.workspace.member.changed": {
|
|
114
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
115
|
+
eventSchema: SLACK_WORKSPACE_MEMBER_CHANGED_EVENT_SCHEMA,
|
|
116
|
+
},
|
|
117
|
+
"slack.workspace.member.joined": {
|
|
118
|
+
configSchema: SLACK_TRIGGER_CONFIG_SCHEMA,
|
|
119
|
+
eventSchema: SLACK_WORKSPACE_MEMBER_JOINED_EVENT_SCHEMA,
|
|
28
120
|
},
|
|
29
121
|
} as const
|
package/src/slack/schemas.ts
CHANGED
|
@@ -196,8 +196,8 @@ export const SLACK_MESSAGE_SCHEMA = z.object({
|
|
|
196
196
|
/** Message subtype supplied by Slack. */
|
|
197
197
|
subtype: z.string().optional(),
|
|
198
198
|
|
|
199
|
-
/** Plain-text message content or accessibility fallback. */
|
|
200
|
-
text: z.string(),
|
|
199
|
+
/** Plain-text message content or accessibility fallback, when supplied. */
|
|
200
|
+
text: z.string().optional(),
|
|
201
201
|
|
|
202
202
|
/** Parent message timestamp when this message belongs to a thread. */
|
|
203
203
|
threadTimestamp: z.string().optional(),
|
|
@@ -217,8 +217,8 @@ export const SLACK_REACTION_ITEM_SCHEMA = z.discriminatedUnion("type", [
|
|
|
217
217
|
/** Slack conversation containing the reacted-to message. */
|
|
218
218
|
conversationId: z.string(),
|
|
219
219
|
|
|
220
|
-
/** Provider conversation category
|
|
221
|
-
conversationType: z.
|
|
220
|
+
/** Provider conversation category. */
|
|
221
|
+
conversationType: z.enum(["channel", "group", "im", "mpim"]).optional(),
|
|
222
222
|
|
|
223
223
|
/** Timestamp identifying the reacted-to message. */
|
|
224
224
|
messageTimestamp: z.string(),
|
|
@@ -242,26 +242,6 @@ export const SLACK_REACTION_ITEM_SCHEMA = z.discriminatedUnion("type", [
|
|
|
242
242
|
}),
|
|
243
243
|
])
|
|
244
244
|
|
|
245
|
-
export const SLACK_REACTION_EVENT_SCHEMA = z.object({
|
|
246
|
-
/** Slack timestamp identifying when the event occurred. */
|
|
247
|
-
eventTimestamp: z.string(),
|
|
248
|
-
|
|
249
|
-
/** Reacted-to Slack item. */
|
|
250
|
-
item: SLACK_REACTION_ITEM_SCHEMA,
|
|
251
|
-
|
|
252
|
-
/** Author of the reacted-to item, when Slack can identify one. */
|
|
253
|
-
itemUserId: z.string().optional(),
|
|
254
|
-
|
|
255
|
-
/** Emoji name without surrounding colons. */
|
|
256
|
-
reaction: z.string(),
|
|
257
|
-
|
|
258
|
-
/** Slack user who added or removed the reaction. */
|
|
259
|
-
userId: z.string(),
|
|
260
|
-
|
|
261
|
-
/** Slack workspace in which the event occurred. */
|
|
262
|
-
workspaceId: z.string(),
|
|
263
|
-
})
|
|
264
|
-
|
|
265
245
|
export const SLACK_FILE_SCHEMA = z.object({
|
|
266
246
|
/** Channels in which the file is shared. */
|
|
267
247
|
channelIds: z.string().array().optional(),
|
|
@@ -279,7 +259,7 @@ export const SLACK_FILE_SCHEMA = z.object({
|
|
|
279
259
|
mimeType: z.string().optional(),
|
|
280
260
|
|
|
281
261
|
/** Original filename. */
|
|
282
|
-
name: z.string().optional(),
|
|
262
|
+
name: z.string().nullable().optional(),
|
|
283
263
|
|
|
284
264
|
/** Slack permalink for the file. */
|
|
285
265
|
permalink: z.string().optional(),
|
|
@@ -382,39 +362,45 @@ export const SLACK_PROVIDER_CONVERSATION_SCHEMA = z.looseObject({
|
|
|
382
362
|
user: z.string().optional(),
|
|
383
363
|
})
|
|
384
364
|
|
|
385
|
-
export const SLACK_PROVIDER_MEMBER_PROFILE_SCHEMA = z
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
365
|
+
export const SLACK_PROVIDER_MEMBER_PROFILE_SCHEMA = z
|
|
366
|
+
.object({
|
|
367
|
+
display_name: z.string().nullable().optional(),
|
|
368
|
+
email: z.string().nullable().optional(),
|
|
369
|
+
first_name: z.string().nullable().optional(),
|
|
370
|
+
image_192: z.string().nullable().optional(),
|
|
371
|
+
image_512: z.string().nullable().optional(),
|
|
372
|
+
image_72: z.string().nullable().optional(),
|
|
373
|
+
last_name: z.string().nullable().optional(),
|
|
374
|
+
pronouns: z.string().nullable().optional(),
|
|
375
|
+
real_name: z.string().nullable().optional(),
|
|
376
|
+
status_emoji: z.string().nullable().optional(),
|
|
377
|
+
status_expiration: z.number().int().nonnegative().nullable().optional(),
|
|
378
|
+
status_text: z.string().nullable().optional(),
|
|
379
|
+
title: z.string().nullable().optional(),
|
|
380
|
+
})
|
|
381
|
+
.catchall(z.json())
|
|
400
382
|
|
|
401
|
-
export const SLACK_PROVIDER_MEMBER_SCHEMA = z
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
383
|
+
export const SLACK_PROVIDER_MEMBER_SCHEMA = z
|
|
384
|
+
.object({
|
|
385
|
+
deleted: z.boolean().nullable().optional(),
|
|
386
|
+
id: z.string(),
|
|
387
|
+
is_admin: z.boolean().nullable().optional(),
|
|
388
|
+
is_app_user: z.boolean().nullable().optional(),
|
|
389
|
+
is_bot: z.boolean().nullable().optional(),
|
|
390
|
+
is_owner: z.boolean().nullable().optional(),
|
|
391
|
+
is_restricted: z.boolean().nullable().optional(),
|
|
392
|
+
is_ultra_restricted: z.boolean().nullable().optional(),
|
|
393
|
+
name: z.string().nullable().optional(),
|
|
394
|
+
profile: SLACK_PROVIDER_MEMBER_PROFILE_SCHEMA.nullish().transform(
|
|
395
|
+
(profile) => profile ?? {},
|
|
396
|
+
),
|
|
397
|
+
team_id: z.string().nullable().optional(),
|
|
398
|
+
tz: z.string().nullable().optional(),
|
|
399
|
+
tz_label: z.string().nullable().optional(),
|
|
400
|
+
tz_offset: z.number().int().nullable().optional(),
|
|
401
|
+
updated: z.number().int().nonnegative().nullable().optional(),
|
|
402
|
+
})
|
|
403
|
+
.catchall(z.json())
|
|
418
404
|
|
|
419
405
|
export const SLACK_PROVIDER_REACTION_SCHEMA = z.object({
|
|
420
406
|
count: z.number().int().nonnegative(),
|
|
@@ -433,7 +419,7 @@ export const SLACK_PROVIDER_MESSAGE_SCHEMA = z
|
|
|
433
419
|
reactions: SLACK_PROVIDER_REACTION_SCHEMA.array().optional(),
|
|
434
420
|
reply_count: z.number().int().nonnegative().optional(),
|
|
435
421
|
subtype: z.string().optional(),
|
|
436
|
-
text: z.string().
|
|
422
|
+
text: z.string().optional(),
|
|
437
423
|
thread_ts: z.string().optional(),
|
|
438
424
|
ts: z.string(),
|
|
439
425
|
type: z.string().prefault("message"),
|
|
@@ -441,80 +427,13 @@ export const SLACK_PROVIDER_MESSAGE_SCHEMA = z
|
|
|
441
427
|
})
|
|
442
428
|
.catchall(z.json())
|
|
443
429
|
|
|
444
|
-
const SLACK_PROVIDER_MESSAGE_EVENT_SCHEMA =
|
|
445
|
-
SLACK_PROVIDER_MESSAGE_SCHEMA.extend({
|
|
446
|
-
channel: z.string(),
|
|
447
|
-
channel_type: z.string().optional(),
|
|
448
|
-
event_ts: z.string(),
|
|
449
|
-
})
|
|
450
|
-
|
|
451
|
-
export const SLACK_MESSAGE_EVENT_SCHEMA = SLACK_MESSAGE_SCHEMA.extend({
|
|
452
|
-
/** Slack conversation containing the message. */
|
|
453
|
-
conversationId: z.string(),
|
|
454
|
-
|
|
455
|
-
/** Provider conversation category such as `channel`, `group`, or `im`. */
|
|
456
|
-
conversationType: z.string().optional(),
|
|
457
|
-
|
|
458
|
-
/** Original provider event. */
|
|
459
|
-
event: SLACK_PROVIDER_MESSAGE_EVENT_SCHEMA,
|
|
460
|
-
|
|
461
|
-
/** Slack timestamp identifying when the event occurred. */
|
|
462
|
-
eventTimestamp: z.string(),
|
|
463
|
-
|
|
464
|
-
/** Slack workspace in which the event occurred. */
|
|
465
|
-
workspaceId: z.string(),
|
|
466
|
-
})
|
|
467
|
-
|
|
468
|
-
export const SLACK_APP_MENTION_EVENT_SCHEMA = SLACK_MESSAGE_EVENT_SCHEMA.extend(
|
|
469
|
-
{
|
|
470
|
-
event: SLACK_PROVIDER_MESSAGE_EVENT_SCHEMA.extend({
|
|
471
|
-
type: z.literal("app_mention"),
|
|
472
|
-
}),
|
|
473
|
-
type: z.literal("app_mention"),
|
|
474
|
-
},
|
|
475
|
-
)
|
|
476
|
-
|
|
477
|
-
export const SLACK_MESSAGE_POSTED_EVENT_SCHEMA =
|
|
478
|
-
SLACK_MESSAGE_EVENT_SCHEMA.extend({
|
|
479
|
-
event: SLACK_PROVIDER_MESSAGE_EVENT_SCHEMA.extend({
|
|
480
|
-
type: z.literal("message"),
|
|
481
|
-
}),
|
|
482
|
-
type: z.literal("message"),
|
|
483
|
-
})
|
|
484
|
-
|
|
485
|
-
const SLACK_PROVIDER_REACTION_ITEM_SCHEMA = z.discriminatedUnion("type", [
|
|
486
|
-
z.looseObject({
|
|
487
|
-
channel: z.string(),
|
|
488
|
-
channel_type: z.string().optional(),
|
|
489
|
-
ts: z.string(),
|
|
490
|
-
type: z.literal("message"),
|
|
491
|
-
}),
|
|
492
|
-
z.looseObject({
|
|
493
|
-
file: z.string(),
|
|
494
|
-
type: z.literal("file"),
|
|
495
|
-
}),
|
|
496
|
-
z.looseObject({
|
|
497
|
-
file: z.string(),
|
|
498
|
-
file_comment: z.string(),
|
|
499
|
-
type: z.literal("file_comment"),
|
|
500
|
-
}),
|
|
501
|
-
])
|
|
502
|
-
|
|
503
|
-
const SLACK_PROVIDER_REACTION_EVENT_SCHEMA = z.looseObject({
|
|
504
|
-
event_ts: z.string(),
|
|
505
|
-
item: SLACK_PROVIDER_REACTION_ITEM_SCHEMA,
|
|
506
|
-
item_user: z.string().optional(),
|
|
507
|
-
reaction: z.string(),
|
|
508
|
-
user: z.string(),
|
|
509
|
-
})
|
|
510
|
-
|
|
511
430
|
export const SLACK_PROVIDER_FILE_SCHEMA = z.looseObject({
|
|
512
431
|
channels: z.string().array().optional(),
|
|
513
432
|
created: z.number().int().nonnegative().optional(),
|
|
514
433
|
filetype: z.string().optional(),
|
|
515
434
|
id: z.string(),
|
|
516
435
|
mimetype: z.string().optional(),
|
|
517
|
-
name: z.string().optional(),
|
|
436
|
+
name: z.string().nullable().optional(),
|
|
518
437
|
permalink: z.string().optional(),
|
|
519
438
|
size: z.number().int().nonnegative().optional(),
|
|
520
439
|
title: z.string().optional(),
|
|
@@ -589,35 +508,35 @@ export function toSlackMember(
|
|
|
589
508
|
member: z.output<typeof SLACK_PROVIDER_MEMBER_SCHEMA>,
|
|
590
509
|
) {
|
|
591
510
|
return {
|
|
592
|
-
deleted: member.deleted,
|
|
511
|
+
deleted: member.deleted ?? undefined,
|
|
593
512
|
id: member.id,
|
|
594
|
-
isAdmin: member.is_admin,
|
|
595
|
-
isAppUser: member.is_app_user,
|
|
596
|
-
isBot: member.is_bot,
|
|
597
|
-
isOwner: member.is_owner,
|
|
598
|
-
isRestricted: member.is_restricted,
|
|
599
|
-
isUltraRestricted: member.is_ultra_restricted,
|
|
600
|
-
name: member.name,
|
|
513
|
+
isAdmin: member.is_admin ?? undefined,
|
|
514
|
+
isAppUser: member.is_app_user ?? undefined,
|
|
515
|
+
isBot: member.is_bot ?? undefined,
|
|
516
|
+
isOwner: member.is_owner ?? undefined,
|
|
517
|
+
isRestricted: member.is_restricted ?? undefined,
|
|
518
|
+
isUltraRestricted: member.is_ultra_restricted ?? undefined,
|
|
519
|
+
name: member.name ?? undefined,
|
|
601
520
|
profile: {
|
|
602
|
-
displayName: member.profile.display_name,
|
|
603
|
-
email: member.profile.email,
|
|
604
|
-
firstName: member.profile.first_name,
|
|
605
|
-
image192: member.profile.image_192,
|
|
606
|
-
image512: member.profile.image_512,
|
|
607
|
-
image72: member.profile.image_72,
|
|
608
|
-
lastName: member.profile.last_name,
|
|
609
|
-
pronouns: member.profile.pronouns,
|
|
610
|
-
realName: member.profile.real_name,
|
|
611
|
-
statusEmoji: member.profile.status_emoji,
|
|
612
|
-
statusExpiration: member.profile.status_expiration,
|
|
613
|
-
statusText: member.profile.status_text,
|
|
614
|
-
title: member.profile.title,
|
|
521
|
+
displayName: member.profile.display_name ?? undefined,
|
|
522
|
+
email: member.profile.email ?? undefined,
|
|
523
|
+
firstName: member.profile.first_name ?? undefined,
|
|
524
|
+
image192: member.profile.image_192 ?? undefined,
|
|
525
|
+
image512: member.profile.image_512 ?? undefined,
|
|
526
|
+
image72: member.profile.image_72 ?? undefined,
|
|
527
|
+
lastName: member.profile.last_name ?? undefined,
|
|
528
|
+
pronouns: member.profile.pronouns ?? undefined,
|
|
529
|
+
realName: member.profile.real_name ?? undefined,
|
|
530
|
+
statusEmoji: member.profile.status_emoji ?? undefined,
|
|
531
|
+
statusExpiration: member.profile.status_expiration ?? undefined,
|
|
532
|
+
statusText: member.profile.status_text ?? undefined,
|
|
533
|
+
title: member.profile.title ?? undefined,
|
|
615
534
|
},
|
|
616
|
-
timeZone: member.tz,
|
|
617
|
-
timeZoneLabel: member.tz_label,
|
|
618
|
-
timeZoneOffset: member.tz_offset,
|
|
619
|
-
updatedAt: member.updated,
|
|
620
|
-
workspaceId: member.team_id,
|
|
535
|
+
timeZone: member.tz ?? undefined,
|
|
536
|
+
timeZoneLabel: member.tz_label ?? undefined,
|
|
537
|
+
timeZoneOffset: member.tz_offset ?? undefined,
|
|
538
|
+
updatedAt: member.updated ?? undefined,
|
|
539
|
+
workspaceId: member.team_id ?? undefined,
|
|
621
540
|
}
|
|
622
541
|
}
|
|
623
542
|
|
|
@@ -651,70 +570,6 @@ export function toSlackMessage(
|
|
|
651
570
|
}
|
|
652
571
|
}
|
|
653
572
|
|
|
654
|
-
/**
|
|
655
|
-
* Normalizes a message-shaped Slack Events API payload.
|
|
656
|
-
*
|
|
657
|
-
* @param event - Provider-native inner event.
|
|
658
|
-
* @param workspaceId - Slack workspace from the outer event envelope.
|
|
659
|
-
*/
|
|
660
|
-
export function normalizeSlackMessageEvent(
|
|
661
|
-
event: unknown,
|
|
662
|
-
workspaceId: string,
|
|
663
|
-
) {
|
|
664
|
-
const parsedEvent = SLACK_PROVIDER_MESSAGE_EVENT_SCHEMA.parse(event)
|
|
665
|
-
|
|
666
|
-
return SLACK_MESSAGE_EVENT_SCHEMA.parse({
|
|
667
|
-
...toSlackMessage(parsedEvent),
|
|
668
|
-
conversationId: parsedEvent.channel,
|
|
669
|
-
conversationType: parsedEvent.channel_type,
|
|
670
|
-
event: parsedEvent,
|
|
671
|
-
eventTimestamp: parsedEvent.event_ts,
|
|
672
|
-
workspaceId,
|
|
673
|
-
})
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
/**
|
|
677
|
-
* Normalizes a reaction-shaped Slack Events API payload.
|
|
678
|
-
*
|
|
679
|
-
* @param event - Provider-native inner event.
|
|
680
|
-
* @param workspaceId - Slack workspace from the outer event envelope.
|
|
681
|
-
*/
|
|
682
|
-
export function normalizeSlackReactionEvent(
|
|
683
|
-
event: unknown,
|
|
684
|
-
workspaceId: string,
|
|
685
|
-
) {
|
|
686
|
-
const parsedEvent = SLACK_PROVIDER_REACTION_EVENT_SCHEMA.parse(event)
|
|
687
|
-
// Keep the discriminated provider-to-public item mapping readable as a unit.
|
|
688
|
-
const item = (() => {
|
|
689
|
-
switch (parsedEvent.item.type) {
|
|
690
|
-
case "message":
|
|
691
|
-
return {
|
|
692
|
-
conversationId: parsedEvent.item.channel,
|
|
693
|
-
conversationType: parsedEvent.item.channel_type,
|
|
694
|
-
messageTimestamp: parsedEvent.item.ts,
|
|
695
|
-
type: "message" as const,
|
|
696
|
-
}
|
|
697
|
-
case "file":
|
|
698
|
-
return { fileId: parsedEvent.item.file, type: "file" as const }
|
|
699
|
-
case "file_comment":
|
|
700
|
-
return {
|
|
701
|
-
fileCommentId: parsedEvent.item.file_comment,
|
|
702
|
-
fileId: parsedEvent.item.file,
|
|
703
|
-
type: "fileComment" as const,
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
})()
|
|
707
|
-
|
|
708
|
-
return SLACK_REACTION_EVENT_SCHEMA.parse({
|
|
709
|
-
eventTimestamp: parsedEvent.event_ts,
|
|
710
|
-
item,
|
|
711
|
-
itemUserId: parsedEvent.item_user,
|
|
712
|
-
reaction: parsedEvent.reaction,
|
|
713
|
-
userId: parsedEvent.user,
|
|
714
|
-
workspaceId,
|
|
715
|
-
})
|
|
716
|
-
}
|
|
717
|
-
|
|
718
573
|
/**
|
|
719
574
|
* Normalizes a Slack file.
|
|
720
575
|
*
|