Skip to content

1.0.0

Compare
Choose a tag to compare
@selfcontained selfcontained released this 30 Aug 02:15
· 99 commits to main since this release
f6b5a15

1.0.0

First major version release ๐ŸŽ‰

This release includes a few exciting new bits, as well as a couple breaking changes.

Breaking Changes

  • The type FunctionHandler is no longer exported, as it was deprecated in favor of the SlackFunctionHandler type. Alternatively, you can also update to use the SlackFunction helper also included in this release, and described below.
  • DefineType() no longer accepts callback_id as a property, which has been deprecated in favor of name. If you're using callback_id still, you can safely change it to name.
  • The options.client_secret_env_key property has been removed from DefineOAuth2Provider() in favor of using the add-secret command of the slack cli. If you were setting this previously, you can remove it, and use slack add-secret instead to provide the value.

Message metadata event schemas

You can define schemas for your Message metadata events via a new DefineEvent() function. This will both provide validation that metadata posted matches the defined event schema, as well as provide discoverability in the future.

export const MyEvent = DefineEvent({
  name: "my_event",
  type: Schema.types.object,
  properties: {
    id: { type: Schema.types.string },
    summary: { type: Schema.types.string },
  },
  required: ["id", "summary"],
});

export default Manifest({
  ...,
  events: [MyEvent], 
});

Easier function handlers with SlackFunction()

Now that functions can do quite a few things, like action and view handlers, we wanted to provide a simplified API for defining both the main function handler, as well as any additional optional handlers for interactivity, or a new unhandledEvent handler, which will get called for any events your function receives that aren't otherwise handled.

import { SlackFunction, DefineFunction } from "deno-slack-sdk/mod.ts";

export const ReverseString = DefineFunction({
  //... function definition
});

export default SlackFunction(ReverseString, async ({ inputs }) => {
  // ... main function handler
}).addBlockActionsHandler(
  "approve_request",
  async ({ inputs }) => {
    // ... block_actions handler
  },
).addViewClosedHandler(
  "approval_modal",
  async ({ view, inputs }) => {
    // ... view_closed handler
  },
).addViewSubmissionHandler(
  "approval_modal",
  async ({ view, inputs }) => {
    // ... view_submission handler
  },
).addUnhandledEventHandler(({ body }) => {
  console.log("unhandled event handler");
});

A more exhaustive set of the PRs included in this release

New Contributors

Full Changelog: 0.2.0...1.0.0