Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update slack functions with new type #237

Merged
merged 2 commits into from
Nov 2, 2023

Conversation

WilliamBergamin
Copy link
Contributor

@WilliamBergamin WilliamBergamin commented Nov 2, 2023

Summary

This PR introduces the new slack type slack#/types/file_id and update the slack functions to use this new type.

Had to also modify he generation script to improve the robustness of the generated tests

testing

  1. Add https://raw.githubusercontent.com/slackapi/deno-slack-sdk/type_file_id_with_builtins/src/ as the value of deno-slack-sdk/ in the import_map.json of a project
  2. Build a workflow that uses the new feature example
import { DefineWorkflow, Schema } from "deno-slack-sdk/mod.ts";

const ImageWorkflow = DefineWorkflow({
  callback_id: "post_image",
  title: "Workflow to post an image",
  description: "A workflow that post an image in the channel it is invoked",
  input_parameters: {
    properties: {
      interactivity: {
        type: Schema.slack.types.interactivity
      },
      channel: {
        type: Schema.slack.types.channel_id,
      },
    },
    required: ["channel", "interactivity"],
  },
});

const getImageStep = ImageWorkflow.addStep(
  Schema.slack.functions.OpenForm,
  {
    title: "Submit this form",
    interactivity: ImageWorkflow.inputs.interactivity,
    fields:{
      elements: [{
        title: "Enter a file",
        name: "image",
        type: Schema.types.array,
        maxItems: 1,
        items: {
          type: Schema.slack.types.file_id,
        },
      }],
      required: ["image"],
    }
  },
);

ImageWorkflow.addStep(Schema.slack.functions.SendMessage, {
  channel_id: ImageWorkflow.inputs.channel,
  message: "cool image bro",
  files: getImageStep.outputs.fields.image
});

export default ImageWorkflow;
  1. Everything should run as expected

Special notes

Ensure your app has the files:read scope, since this is required for the feature and logged error is cryptic

Requirements

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've ran deno task test after making the changes.

@WilliamBergamin WilliamBergamin added the semver:minor requires a minor version number bump label Nov 2, 2023
@WilliamBergamin WilliamBergamin self-assigned this Nov 2, 2023
@WilliamBergamin WilliamBergamin requested a review from a team as a code owner November 2, 2023 16:09
Copy link

codecov bot commented Nov 2, 2023

Codecov Report

Merging #237 (d3a96fc) into main (288a284) will increase coverage by 0.09%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #237      +/-   ##
==========================================
+ Coverage   97.97%   98.07%   +0.09%     
==========================================
  Files          58       58              
  Lines        2177     2280     +103     
  Branches      137      137              
==========================================
+ Hits         2133     2236     +103     
  Misses         42       42              
  Partials        2        2              
Files Coverage Δ
src/dev_deps.ts 100.00% <100.00%> (ø)
src/schema/slack/functions/add_pin.ts 100.00% <100.00%> (ø)
...rc/schema/slack/functions/add_user_to_usergroup.ts 100.00% <100.00%> (ø)
src/schema/slack/functions/archive_channel.ts 100.00% <ø> (ø)
src/schema/slack/functions/create_channel.ts 100.00% <ø> (ø)
src/schema/slack/functions/create_usergroup.ts 100.00% <100.00%> (ø)
src/schema/slack/functions/delay.ts 100.00% <100.00%> (ø)
...c/schema/slack/functions/invite_user_to_channel.ts 100.00% <100.00%> (ø)
src/schema/slack/functions/mod.ts 100.00% <100.00%> (ø)
src/schema/slack/functions/open_form.ts 100.00% <100.00%> (ø)
... and 7 more

... and 5 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@filmaj filmaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beauty! The new file ID works well in SendDM, SendMessage and ReplyInThread built-ins.

@WilliamBergamin WilliamBergamin merged commit e165fd6 into main Nov 2, 2023
10 checks passed
@WilliamBergamin WilliamBergamin deleted the type_file_id_with_builtins branch November 2, 2023 18:42
@WilliamBergamin WilliamBergamin restored the type_file_id_with_builtins branch November 9, 2023 19:38
WilliamBergamin added a commit that referenced this pull request Nov 9, 2023
WilliamBergamin added a commit that referenced this pull request Nov 9, 2023
@WilliamBergamin WilliamBergamin mentioned this pull request Nov 9, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:minor requires a minor version number bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants