@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/dist/slack/schemas.js
CHANGED
|
@@ -134,8 +134,8 @@ export const SLACK_MESSAGE_SCHEMA = z.object({
|
|
|
134
134
|
replyCount: z.number().int().nonnegative().optional(),
|
|
135
135
|
/** Message subtype supplied by Slack. */
|
|
136
136
|
subtype: z.string().optional(),
|
|
137
|
-
/** Plain-text message content or accessibility fallback. */
|
|
138
|
-
text: z.string(),
|
|
137
|
+
/** Plain-text message content or accessibility fallback, when supplied. */
|
|
138
|
+
text: z.string().optional(),
|
|
139
139
|
/** Parent message timestamp when this message belongs to a thread. */
|
|
140
140
|
threadTimestamp: z.string().optional(),
|
|
141
141
|
/** Stable Slack message timestamp. */
|
|
@@ -149,8 +149,8 @@ export const SLACK_REACTION_ITEM_SCHEMA = z.discriminatedUnion("type", [
|
|
|
149
149
|
z.object({
|
|
150
150
|
/** Slack conversation containing the reacted-to message. */
|
|
151
151
|
conversationId: z.string(),
|
|
152
|
-
/** Provider conversation category
|
|
153
|
-
conversationType: z.
|
|
152
|
+
/** Provider conversation category. */
|
|
153
|
+
conversationType: z.enum(["channel", "group", "im", "mpim"]).optional(),
|
|
154
154
|
/** Timestamp identifying the reacted-to message. */
|
|
155
155
|
messageTimestamp: z.string(),
|
|
156
156
|
type: z.literal("message"),
|
|
@@ -168,20 +168,6 @@ export const SLACK_REACTION_ITEM_SCHEMA = z.discriminatedUnion("type", [
|
|
|
168
168
|
type: z.literal("fileComment"),
|
|
169
169
|
}),
|
|
170
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
171
|
export const SLACK_FILE_SCHEMA = z.object({
|
|
186
172
|
/** Channels in which the file is shared. */
|
|
187
173
|
channelIds: z.string().array().optional(),
|
|
@@ -194,7 +180,7 @@ export const SLACK_FILE_SCHEMA = z.object({
|
|
|
194
180
|
/** MIME media type reported by Slack. */
|
|
195
181
|
mimeType: z.string().optional(),
|
|
196
182
|
/** Original filename. */
|
|
197
|
-
name: z.string().optional(),
|
|
183
|
+
name: z.string().nullable().optional(),
|
|
198
184
|
/** Slack permalink for the file. */
|
|
199
185
|
permalink: z.string().optional(),
|
|
200
186
|
/** File size in bytes. */
|
|
@@ -270,38 +256,42 @@ export const SLACK_PROVIDER_CONVERSATION_SCHEMA = z.looseObject({
|
|
|
270
256
|
topic: SLACK_PROVIDER_TOPIC_SCHEMA.optional(),
|
|
271
257
|
user: z.string().optional(),
|
|
272
258
|
});
|
|
273
|
-
export const SLACK_PROVIDER_MEMBER_PROFILE_SCHEMA = z
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
259
|
+
export const SLACK_PROVIDER_MEMBER_PROFILE_SCHEMA = z
|
|
260
|
+
.object({
|
|
261
|
+
display_name: z.string().nullable().optional(),
|
|
262
|
+
email: z.string().nullable().optional(),
|
|
263
|
+
first_name: z.string().nullable().optional(),
|
|
264
|
+
image_192: z.string().nullable().optional(),
|
|
265
|
+
image_512: z.string().nullable().optional(),
|
|
266
|
+
image_72: z.string().nullable().optional(),
|
|
267
|
+
last_name: z.string().nullable().optional(),
|
|
268
|
+
pronouns: z.string().nullable().optional(),
|
|
269
|
+
real_name: z.string().nullable().optional(),
|
|
270
|
+
status_emoji: z.string().nullable().optional(),
|
|
271
|
+
status_expiration: z.number().int().nonnegative().nullable().optional(),
|
|
272
|
+
status_text: z.string().nullable().optional(),
|
|
273
|
+
title: z.string().nullable().optional(),
|
|
274
|
+
})
|
|
275
|
+
.catchall(z.json());
|
|
276
|
+
export const SLACK_PROVIDER_MEMBER_SCHEMA = z
|
|
277
|
+
.object({
|
|
278
|
+
deleted: z.boolean().nullable().optional(),
|
|
290
279
|
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.
|
|
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
|
-
})
|
|
280
|
+
is_admin: z.boolean().nullable().optional(),
|
|
281
|
+
is_app_user: z.boolean().nullable().optional(),
|
|
282
|
+
is_bot: z.boolean().nullable().optional(),
|
|
283
|
+
is_owner: z.boolean().nullable().optional(),
|
|
284
|
+
is_restricted: z.boolean().nullable().optional(),
|
|
285
|
+
is_ultra_restricted: z.boolean().nullable().optional(),
|
|
286
|
+
name: z.string().nullable().optional(),
|
|
287
|
+
profile: SLACK_PROVIDER_MEMBER_PROFILE_SCHEMA.nullish().transform((profile) => profile ?? {}),
|
|
288
|
+
team_id: z.string().nullable().optional(),
|
|
289
|
+
tz: z.string().nullable().optional(),
|
|
290
|
+
tz_label: z.string().nullable().optional(),
|
|
291
|
+
tz_offset: z.number().int().nullable().optional(),
|
|
292
|
+
updated: z.number().int().nonnegative().nullable().optional(),
|
|
293
|
+
})
|
|
294
|
+
.catchall(z.json());
|
|
305
295
|
export const SLACK_PROVIDER_REACTION_SCHEMA = z.object({
|
|
306
296
|
count: z.number().int().nonnegative(),
|
|
307
297
|
name: z.string(),
|
|
@@ -318,73 +308,20 @@ export const SLACK_PROVIDER_MESSAGE_SCHEMA = z
|
|
|
318
308
|
reactions: SLACK_PROVIDER_REACTION_SCHEMA.array().optional(),
|
|
319
309
|
reply_count: z.number().int().nonnegative().optional(),
|
|
320
310
|
subtype: z.string().optional(),
|
|
321
|
-
text: z.string().
|
|
311
|
+
text: z.string().optional(),
|
|
322
312
|
thread_ts: z.string().optional(),
|
|
323
313
|
ts: z.string(),
|
|
324
314
|
type: z.string().prefault("message"),
|
|
325
315
|
user: z.string().optional(),
|
|
326
316
|
})
|
|
327
317
|
.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
318
|
export const SLACK_PROVIDER_FILE_SCHEMA = z.looseObject({
|
|
382
319
|
channels: z.string().array().optional(),
|
|
383
320
|
created: z.number().int().nonnegative().optional(),
|
|
384
321
|
filetype: z.string().optional(),
|
|
385
322
|
id: z.string(),
|
|
386
323
|
mimetype: z.string().optional(),
|
|
387
|
-
name: z.string().optional(),
|
|
324
|
+
name: z.string().nullable().optional(),
|
|
388
325
|
permalink: z.string().optional(),
|
|
389
326
|
size: z.number().int().nonnegative().optional(),
|
|
390
327
|
title: z.string().optional(),
|
|
@@ -447,35 +384,35 @@ export function toSlackConversation(conversation) {
|
|
|
447
384
|
*/
|
|
448
385
|
export function toSlackMember(member) {
|
|
449
386
|
return {
|
|
450
|
-
deleted: member.deleted,
|
|
387
|
+
deleted: member.deleted ?? undefined,
|
|
451
388
|
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,
|
|
389
|
+
isAdmin: member.is_admin ?? undefined,
|
|
390
|
+
isAppUser: member.is_app_user ?? undefined,
|
|
391
|
+
isBot: member.is_bot ?? undefined,
|
|
392
|
+
isOwner: member.is_owner ?? undefined,
|
|
393
|
+
isRestricted: member.is_restricted ?? undefined,
|
|
394
|
+
isUltraRestricted: member.is_ultra_restricted ?? undefined,
|
|
395
|
+
name: member.name ?? undefined,
|
|
459
396
|
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,
|
|
397
|
+
displayName: member.profile.display_name ?? undefined,
|
|
398
|
+
email: member.profile.email ?? undefined,
|
|
399
|
+
firstName: member.profile.first_name ?? undefined,
|
|
400
|
+
image192: member.profile.image_192 ?? undefined,
|
|
401
|
+
image512: member.profile.image_512 ?? undefined,
|
|
402
|
+
image72: member.profile.image_72 ?? undefined,
|
|
403
|
+
lastName: member.profile.last_name ?? undefined,
|
|
404
|
+
pronouns: member.profile.pronouns ?? undefined,
|
|
405
|
+
realName: member.profile.real_name ?? undefined,
|
|
406
|
+
statusEmoji: member.profile.status_emoji ?? undefined,
|
|
407
|
+
statusExpiration: member.profile.status_expiration ?? undefined,
|
|
408
|
+
statusText: member.profile.status_text ?? undefined,
|
|
409
|
+
title: member.profile.title ?? undefined,
|
|
473
410
|
},
|
|
474
|
-
timeZone: member.tz,
|
|
475
|
-
timeZoneLabel: member.tz_label,
|
|
476
|
-
timeZoneOffset: member.tz_offset,
|
|
477
|
-
updatedAt: member.updated,
|
|
478
|
-
workspaceId: member.team_id,
|
|
411
|
+
timeZone: member.tz ?? undefined,
|
|
412
|
+
timeZoneLabel: member.tz_label ?? undefined,
|
|
413
|
+
timeZoneOffset: member.tz_offset ?? undefined,
|
|
414
|
+
updatedAt: member.updated ?? undefined,
|
|
415
|
+
workspaceId: member.team_id ?? undefined,
|
|
479
416
|
};
|
|
480
417
|
}
|
|
481
418
|
/**
|
|
@@ -505,60 +442,6 @@ export function toSlackMessage(message) {
|
|
|
505
442
|
userId: message.user,
|
|
506
443
|
};
|
|
507
444
|
}
|
|
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
445
|
/**
|
|
563
446
|
* Normalizes a Slack file.
|
|
564
447
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automate.ax/integration-contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.97.0",
|
|
4
4
|
"description": "Shared integration payload contracts and provider primitives for Automate.ax.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@automate.ax/codec": "0.
|
|
51
|
+
"@automate.ax/codec": "0.97.0",
|
|
52
52
|
"@cfworker/json-schema": "^4.1.1",
|
|
53
53
|
"@googleapis/calendar": "^15.0.0",
|
|
54
54
|
"@googleapis/forms": "^6.0.1",
|
package/src/close/schemas.ts
CHANGED
|
@@ -892,7 +892,7 @@ export const CLOSE_SEQUENCE_SCHEMA = z.object({
|
|
|
892
892
|
.optional(),
|
|
893
893
|
timezone: z.string(),
|
|
894
894
|
updatedAt: DATE_SCHEMA,
|
|
895
|
-
updatedById: z.string(),
|
|
895
|
+
updatedById: z.string().nullable(),
|
|
896
896
|
})
|
|
897
897
|
|
|
898
898
|
export const CLOSE_SEQUENCE_SUBSCRIPTION_SCHEMA = z.object({
|