From 9105487385b1e42fbdf5c879ca02a48836af9a73 Mon Sep 17 00:00:00 2001 From: Fil Maj Date: Thu, 1 Aug 2024 20:02:07 +0000 Subject: [PATCH] feat: add `event_timestamp` to all trigger event data objects (#109) * feat: add `event_timestamp` to all trigger event data objects. * linting * all_trigger_data -> base_trigger_data --- .../workflows/triggers/event-data/app_mentioned.ts | 3 +++ .../workflows/triggers/event-data/channel_archived.ts | 3 +++ .../workflows/triggers/event-data/channel_created.ts | 3 +++ .../workflows/triggers/event-data/channel_deleted.ts | 3 +++ .../workflows/triggers/event-data/channel_renamed.ts | 3 +++ .../workflows/triggers/event-data/channel_shared.ts | 3 +++ .../workflows/triggers/event-data/channel_unarchived.ts | 3 +++ .../workflows/triggers/event-data/channel_unshared.ts | 3 +++ .../triggers/event-data/common-objects/all_triggers.ts | 6 ++++++ .../workflows/triggers/event-data/dnd_updated.ts | 3 +++ .../workflows/triggers/event-data/emoji_changed.ts | 3 +++ .../triggers/event-data/message_metadata_posted.ts | 3 +++ .../workflows/triggers/event-data/message_posted.ts | 3 +++ .../workflows/triggers/event-data/pin_added.ts | 3 +++ .../workflows/triggers/event-data/pin_removed.ts | 3 +++ .../workflows/triggers/event-data/reaction_added.ts | 3 +++ .../workflows/triggers/event-data/reaction_removed.ts | 3 +++ .../triggers/event-data/shared_channel_invite_accepted.ts | 2 ++ .../triggers/event-data/shared_channel_invite_approved.ts | 2 ++ .../triggers/event-data/shared_channel_invite_declined.ts | 2 ++ .../triggers/event-data/shared_channel_invite_received.ts | 2 ++ .../workflows/triggers/event-data/user_joined_channel.ts | 3 +++ .../workflows/triggers/event-data/user_joined_team.ts | 3 +++ .../workflows/triggers/event-data/user_left_channel.ts | 3 +++ src/typed-method-types/workflows/triggers/scheduled-data.ts | 3 +++ src/typed-method-types/workflows/triggers/shortcut-data.ts | 3 +++ 26 files changed, 77 insertions(+) create mode 100644 src/typed-method-types/workflows/triggers/event-data/common-objects/all_triggers.ts diff --git a/src/typed-method-types/workflows/triggers/event-data/app_mentioned.ts b/src/typed-method-types/workflows/triggers/event-data/app_mentioned.ts index c96a81b..c9d2a2a 100644 --- a/src/typed-method-types/workflows/triggers/event-data/app_mentioned.ts +++ b/src/typed-method-types/workflows/triggers/event-data/app_mentioned.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const AppMentioned = { + ...base_trigger_data, /** * A unique identifier for the app being mentioned. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/channel_archived.ts b/src/typed-method-types/workflows/triggers/event-data/channel_archived.ts index 0570c87..a525a2c 100644 --- a/src/typed-method-types/workflows/triggers/event-data/channel_archived.ts +++ b/src/typed-method-types/workflows/triggers/event-data/channel_archived.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const ChannelArchived = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} that was archived. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/channel_created.ts b/src/typed-method-types/workflows/triggers/event-data/channel_created.ts index a0548e0..f8dce43 100644 --- a/src/typed-method-types/workflows/triggers/event-data/channel_created.ts +++ b/src/typed-method-types/workflows/triggers/event-data/channel_created.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const ChannelCreated = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} that was created. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/channel_deleted.ts b/src/typed-method-types/workflows/triggers/event-data/channel_deleted.ts index 0ca781d..2496ab2 100644 --- a/src/typed-method-types/workflows/triggers/event-data/channel_deleted.ts +++ b/src/typed-method-types/workflows/triggers/event-data/channel_deleted.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const ChannelDeleted = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} that was deleted. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/channel_renamed.ts b/src/typed-method-types/workflows/triggers/event-data/channel_renamed.ts index 9b28633..21f6014 100644 --- a/src/typed-method-types/workflows/triggers/event-data/channel_renamed.ts +++ b/src/typed-method-types/workflows/triggers/event-data/channel_renamed.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const ChannelRenamed = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} that was renamed. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/channel_shared.ts b/src/typed-method-types/workflows/triggers/event-data/channel_shared.ts index ab3d547..afb92fc 100644 --- a/src/typed-method-types/workflows/triggers/event-data/channel_shared.ts +++ b/src/typed-method-types/workflows/triggers/event-data/channel_shared.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const ChannelShared = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} that was shared. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/channel_unarchived.ts b/src/typed-method-types/workflows/triggers/event-data/channel_unarchived.ts index 5ba2749..c624721 100644 --- a/src/typed-method-types/workflows/triggers/event-data/channel_unarchived.ts +++ b/src/typed-method-types/workflows/triggers/event-data/channel_unarchived.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const ChannelUnarchived = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} that was unarchived. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/channel_unshared.ts b/src/typed-method-types/workflows/triggers/event-data/channel_unshared.ts index 0091243..b3b35f5 100644 --- a/src/typed-method-types/workflows/triggers/event-data/channel_unshared.ts +++ b/src/typed-method-types/workflows/triggers/event-data/channel_unshared.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const ChannelUnshared = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} that was unshared. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/common-objects/all_triggers.ts b/src/typed-method-types/workflows/triggers/event-data/common-objects/all_triggers.ts new file mode 100644 index 0000000..ce9ef1c --- /dev/null +++ b/src/typed-method-types/workflows/triggers/event-data/common-objects/all_triggers.ts @@ -0,0 +1,6 @@ +export default { + /** + * A {@link https://api.slack.com/automation/types#timestamp timestamp} when the trigger was invoked. + */ + event_timestamp: "{{event_timestamp}}", +} as const; diff --git a/src/typed-method-types/workflows/triggers/event-data/dnd_updated.ts b/src/typed-method-types/workflows/triggers/event-data/dnd_updated.ts index ed101e9..2b0c2f4 100644 --- a/src/typed-method-types/workflows/triggers/event-data/dnd_updated.ts +++ b/src/typed-method-types/workflows/triggers/event-data/dnd_updated.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + const DndStatus = { + ...base_trigger_data, /** * Whether Do Not Disturb is enabled or not. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/emoji_changed.ts b/src/typed-method-types/workflows/triggers/event-data/emoji_changed.ts index c2f1f5f..49ea05b 100644 --- a/src/typed-method-types/workflows/triggers/event-data/emoji_changed.ts +++ b/src/typed-method-types/workflows/triggers/event-data/emoji_changed.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const EmojiChanged = { + ...base_trigger_data, /** * The event type being invoked. At runtime will always be "slack#/events/emoji_changed". */ diff --git a/src/typed-method-types/workflows/triggers/event-data/message_metadata_posted.ts b/src/typed-method-types/workflows/triggers/event-data/message_metadata_posted.ts index 0945349..50d51f3 100644 --- a/src/typed-method-types/workflows/triggers/event-data/message_metadata_posted.ts +++ b/src/typed-method-types/workflows/triggers/event-data/message_metadata_posted.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const MessageMetadataPosted = { + ...base_trigger_data, /** * A unique identifier for the app that posted metadata. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/message_posted.ts b/src/typed-method-types/workflows/triggers/event-data/message_posted.ts index 92e9f6f..8a962a6 100644 --- a/src/typed-method-types/workflows/triggers/event-data/message_posted.ts +++ b/src/typed-method-types/workflows/triggers/event-data/message_posted.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const MessagePosted = { + ...base_trigger_data, /** * A unique identifier for the app that posted the message. Only available when message is posted by an app. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/pin_added.ts b/src/typed-method-types/workflows/triggers/event-data/pin_added.ts index df5d16e..a99af0e 100644 --- a/src/typed-method-types/workflows/triggers/event-data/pin_added.ts +++ b/src/typed-method-types/workflows/triggers/event-data/pin_added.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const PinAdded = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} where the message was pinned. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/pin_removed.ts b/src/typed-method-types/workflows/triggers/event-data/pin_removed.ts index 9c49565..85ae858 100644 --- a/src/typed-method-types/workflows/triggers/event-data/pin_removed.ts +++ b/src/typed-method-types/workflows/triggers/event-data/pin_removed.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const PinRemoved = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} where the message was unpinned. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/reaction_added.ts b/src/typed-method-types/workflows/triggers/event-data/reaction_added.ts index 5719139..dad1d90 100644 --- a/src/typed-method-types/workflows/triggers/event-data/reaction_added.ts +++ b/src/typed-method-types/workflows/triggers/event-data/reaction_added.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const ReactionAdded = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} where the emoji reaction was added to. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/reaction_removed.ts b/src/typed-method-types/workflows/triggers/event-data/reaction_removed.ts index 6382d5b..c694d1d 100644 --- a/src/typed-method-types/workflows/triggers/event-data/reaction_removed.ts +++ b/src/typed-method-types/workflows/triggers/event-data/reaction_removed.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const ReactionRemoved = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} where the emoji reaction was removed from. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_accepted.ts b/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_accepted.ts index e12ea98..4fc32d4 100644 --- a/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_accepted.ts +++ b/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_accepted.ts @@ -1,4 +1,5 @@ import { Invite } from "./common-objects/shared_channel_invite.ts"; +import base_trigger_data from "./common-objects/all_triggers.ts"; const AcceptingUser = { /** @@ -37,6 +38,7 @@ Object.defineProperty(AcceptingUser, "toJSON", { }); export const SharedChannelInviteAccepted = { + ...base_trigger_data, /** * Object containing details for the invitee. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_approved.ts b/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_approved.ts index 5524e77..13414f6 100644 --- a/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_approved.ts +++ b/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_approved.ts @@ -1,4 +1,5 @@ import { Invite } from "./common-objects/shared_channel_invite.ts"; +import base_trigger_data from "./common-objects/all_triggers.ts"; const ApprovingUser = { /** @@ -37,6 +38,7 @@ Object.defineProperty(ApprovingUser, "toJSON", { }); export const SharedChannelInviteApproved = { + ...base_trigger_data, /** * A unique identifier for the team or workspace issuing the approval. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_declined.ts b/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_declined.ts index a32d1dc..d59e67e 100644 --- a/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_declined.ts +++ b/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_declined.ts @@ -1,4 +1,5 @@ import { Invite } from "./common-objects/shared_channel_invite.ts"; +import base_trigger_data from "./common-objects/all_triggers.ts"; const DecliningUser = { /** @@ -37,6 +38,7 @@ Object.defineProperty(DecliningUser, "toJSON", { }); export const SharedChannelInviteDeclined = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} being shared. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_received.ts b/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_received.ts index 0557bf3..530b4fb 100644 --- a/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_received.ts +++ b/src/typed-method-types/workflows/triggers/event-data/shared_channel_invite_received.ts @@ -1,6 +1,8 @@ import { Invite } from "./common-objects/shared_channel_invite.ts"; +import base_trigger_data from "./common-objects/all_triggers.ts"; export const SharedChannelInviteReceived = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} being shared. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/user_joined_channel.ts b/src/typed-method-types/workflows/triggers/event-data/user_joined_channel.ts index 19edce9..25cf785 100644 --- a/src/typed-method-types/workflows/triggers/event-data/user_joined_channel.ts +++ b/src/typed-method-types/workflows/triggers/event-data/user_joined_channel.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const UserJoinedChannel = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} that was joined. */ diff --git a/src/typed-method-types/workflows/triggers/event-data/user_joined_team.ts b/src/typed-method-types/workflows/triggers/event-data/user_joined_team.ts index 650f5e4..a8784eb 100644 --- a/src/typed-method-types/workflows/triggers/event-data/user_joined_team.ts +++ b/src/typed-method-types/workflows/triggers/event-data/user_joined_team.ts @@ -1,3 +1,5 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + const User = { /** * The display name of the user who joined, as they chose upon registering to the workspace. @@ -33,6 +35,7 @@ const User = { Object.defineProperty(User, "toJSON", { value: () => "{{data.user}}" }); export const UserJoinedTeam = { + ...base_trigger_data, /** * The event type being invoked. At runtime will always be "slack#/events/user_joined_channel". */ diff --git a/src/typed-method-types/workflows/triggers/event-data/user_left_channel.ts b/src/typed-method-types/workflows/triggers/event-data/user_left_channel.ts index b916d87..644479d 100644 --- a/src/typed-method-types/workflows/triggers/event-data/user_left_channel.ts +++ b/src/typed-method-types/workflows/triggers/event-data/user_left_channel.ts @@ -1,4 +1,7 @@ +import base_trigger_data from "./common-objects/all_triggers.ts"; + export const UserLeftChannel = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#channelid Slack channel} that was left. */ diff --git a/src/typed-method-types/workflows/triggers/scheduled-data.ts b/src/typed-method-types/workflows/triggers/scheduled-data.ts index 7663d4b..2cfa1f1 100644 --- a/src/typed-method-types/workflows/triggers/scheduled-data.ts +++ b/src/typed-method-types/workflows/triggers/scheduled-data.ts @@ -1,7 +1,10 @@ +import base_trigger_data from "./event-data/common-objects/all_triggers.ts"; + /** * Scheduled-trigger-specific input values that contain information about the scheduled trigger. */ export const ScheduledTriggerContextData = { + ...base_trigger_data, /** * A unique identifier for the {@link https://api.slack.com/automation/types#userid Slack user} who created the trigger. */ diff --git a/src/typed-method-types/workflows/triggers/shortcut-data.ts b/src/typed-method-types/workflows/triggers/shortcut-data.ts index eb08a54..d5d143d 100644 --- a/src/typed-method-types/workflows/triggers/shortcut-data.ts +++ b/src/typed-method-types/workflows/triggers/shortcut-data.ts @@ -1,3 +1,5 @@ +import base_trigger_data from "./event-data/common-objects/all_triggers.ts"; + const Interactor = { /** * A unique identifier for the {@link https://api.slack.com/automation/types#userid Slack user} who invoked the trigger. @@ -32,6 +34,7 @@ Object.defineProperty(Interactivity, "toJSON", { * Link-trigger-specific input values that contain information about the link trigger. */ export const ShortcutTriggerContextData = { + ...base_trigger_data, /** * A unique identifier for the action that invoked the trigger. Only available when trigger is invoked from a {@link https://api.slack.com/automation/triggers/link#workflow_buttons Workflow button}! */