Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
Update triggers to use typed types and context data (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-zijdemans-vipps authored Sep 28, 2023
1 parent bff36c5 commit edf57c9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions import_map.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"imports": {
"deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.2.0/",
"deno-slack-api/": "https://deno.land/x/[email protected].1/",
"deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.3.0/",
"deno-slack-api/": "https://deno.land/x/[email protected].2/",
"mock-fetch/": "https://deno.land/x/[email protected]/"
}
}
7 changes: 4 additions & 3 deletions triggers/display_leaderboard_trigger.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { Trigger } from "deno-slack-sdk/types.ts";
import { TriggerContextData, TriggerTypes } from "deno-slack-api/mod.ts";
import DisplayLeaderboardWorkflow from "../workflows/display_leaderboard_workflow.ts";

const DisplayLeaderboardTrigger: Trigger<
typeof DisplayLeaderboardWorkflow.definition
> = {
type: "shortcut",
type: TriggerTypes.Shortcut,
name: "Display the leaderboard",
description: "Show stats for the team and individual runners",
workflow: `#/workflows/${DisplayLeaderboardWorkflow.definition.callback_id}`,
inputs: {
interactivity: {
value: "{{data.interactivity}}",
value: TriggerContextData.Shortcut.interactivity,
},
channel: {
value: "{{data.channel_id}}",
value: TriggerContextData.Shortcut.channel_id,
},
},
};
Expand Down
7 changes: 4 additions & 3 deletions triggers/display_weekly_stats.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { Trigger } from "deno-slack-sdk/types.ts";
import { TriggerContextData, TriggerTypes } from "deno-slack-api/mod.ts";
import DisplayLeaderboardWorkflow from "../workflows/display_leaderboard_workflow.ts";

const DisplayWeeklyStats: Trigger<
typeof DisplayLeaderboardWorkflow.definition
> = {
type: "scheduled",
type: TriggerTypes.Scheduled,
name: "Display weekly stats",
description: "Display weekly running stats on a schedule",
workflow: `#/workflows/${DisplayLeaderboardWorkflow.definition.callback_id}`,
inputs: {
interactivity: {
value: "{{data.interactivity}}",
value: TriggerContextData.Shortcut.interactivity,
},
channel: {
value: "{{data.channel_id}}",
value: TriggerContextData.Shortcut.channel_id,
},
},
schedule: {
Expand Down
9 changes: 5 additions & 4 deletions triggers/log_run_trigger.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { Trigger } from "deno-slack-sdk/types.ts";
import { TriggerContextData, TriggerTypes } from "deno-slack-api/mod.ts";
import LogRunWorkflow from "../workflows/log_run_workflow.ts";

const LogRunTrigger: Trigger<typeof LogRunWorkflow.definition> = {
type: "shortcut",
type: TriggerTypes.Shortcut,
name: "Log a run",
description: "Save the details of a recent run",
workflow: `#/workflows/${LogRunWorkflow.definition.callback_id}`,
inputs: {
interactivity: {
value: "{{data.interactivity}}",
value: TriggerContextData.Shortcut.interactivity,
},
channel: {
value: "{{data.channel_id}}",
value: TriggerContextData.Shortcut.channel_id,
},
user_id: {
value: "{{data.user_id}}",
value: TriggerContextData.Shortcut.user_id,
},
},
};
Expand Down

0 comments on commit edf57c9

Please sign in to comment.