From e23ba7ddb8eef573691fa2463ee6dd9a3d362f20 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Fri, 6 Sep 2024 10:39:44 -0400 Subject: [PATCH 1/4] feat: Add builtins for Add/Remove Reactions and many List-related functions, too. also updates instructions for how to generate built-in function definitions using updated `functions.list` API endpoint --- src/schema/slack/functions/_scripts/README.md | 20 +-- src/schema/slack/functions/add_reaction.ts | 26 ++++ .../slack/functions/add_reaction_test.ts | 50 ++++++++ src/schema/slack/functions/copy_list.ts | 65 ++++++++++ src/schema/slack/functions/copy_list_test.ts | 117 ++++++++++++++++++ .../slack/functions/delete_list_record.ts | 25 ++++ .../functions/delete_list_record_test.ts | 49 ++++++++ src/schema/slack/functions/list_add_record.ts | 40 ++++++ .../slack/functions/list_add_record_test.ts | 82 ++++++++++++ .../slack/functions/lists_activity_feed.ts | 41 ++++++ .../functions/lists_activity_feed_test.ts | 75 +++++++++++ src/schema/slack/functions/mod.ts | 18 ++- src/schema/slack/functions/remove_reaction.ts | 26 ++++ .../slack/functions/remove_reaction_test.ts | 53 ++++++++ .../slack/functions/share_list_users.ts | 47 +++++++ .../slack/functions/share_list_users_test.ts | 97 +++++++++++++++ .../slack/functions/update_list_record.ts | 39 ++++++ .../functions/update_list_record_test.ts | 83 +++++++++++++ 18 files changed, 938 insertions(+), 15 deletions(-) create mode 100644 src/schema/slack/functions/add_reaction.ts create mode 100644 src/schema/slack/functions/add_reaction_test.ts create mode 100644 src/schema/slack/functions/copy_list.ts create mode 100644 src/schema/slack/functions/copy_list_test.ts create mode 100644 src/schema/slack/functions/delete_list_record.ts create mode 100644 src/schema/slack/functions/delete_list_record_test.ts create mode 100644 src/schema/slack/functions/list_add_record.ts create mode 100644 src/schema/slack/functions/list_add_record_test.ts create mode 100644 src/schema/slack/functions/lists_activity_feed.ts create mode 100644 src/schema/slack/functions/lists_activity_feed_test.ts create mode 100644 src/schema/slack/functions/remove_reaction.ts create mode 100644 src/schema/slack/functions/remove_reaction_test.ts create mode 100644 src/schema/slack/functions/share_list_users.ts create mode 100644 src/schema/slack/functions/share_list_users_test.ts create mode 100644 src/schema/slack/functions/update_list_record.ts create mode 100644 src/schema/slack/functions/update_list_record_test.ts diff --git a/src/schema/slack/functions/_scripts/README.md b/src/schema/slack/functions/_scripts/README.md index dd244620..837ce6a7 100644 --- a/src/schema/slack/functions/_scripts/README.md +++ b/src/schema/slack/functions/_scripts/README.md @@ -10,21 +10,13 @@ corresponding test, the tests must be removed manually. ## Instructions -1. First, you'll need to grab the response from `functions.categories.list` API +1. First, you'll need to grab the response from `functions.list` API method tester: - -- Choose a session token from a public production enterprise grid workspace that - is NOT enrolled in the `hermes_next` toggle. Recommend using the Slack DevRel - production enterprise grid token. -- Pass the `category_type=builtins_categories` parameter to this API. -- Now for the super annoying part: for each builtin category, you will need to - manually call _another_ API and assemble a functions list yourself: - - Grab the response from `functions.categories.steps.list` API method tester, - using the same session token as earlier in this step, passing each - `category_id` retrieved earlier into this API call. - - Copy the `functions` array elements from each response into a fresh - `{"functions":[]}` array in `functions.json`, slowly building up a list of - all builtin functions. + - Choose a session token from a public production enterprise grid workspace that + is NOT enrolled in any beta toggles. Recommend using the Slack DevRel + production enterprise grid token. + - Use `builtins` as the value for the `function_type` parameter to this API. + - Copy the response into a `functions.json` file in this directory. 2. With this `_scripts` directory as your working directory, run the generate script: diff --git a/src/schema/slack/functions/add_reaction.ts b/src/schema/slack/functions/add_reaction.ts new file mode 100644 index 00000000..31f088b8 --- /dev/null +++ b/src/schema/slack/functions/add_reaction.ts @@ -0,0 +1,26 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { DefineFunction } from "../../../functions/mod.ts"; +import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; + +export default DefineFunction({ + callback_id: "slack#/functions/add_reaction", + source_file: "", + title: "Add a reaction to a message", + input_parameters: { + properties: { + message_context: { + type: SlackTypes.message_context, + description: "Select a message to react to", + title: "Select a message to react to", + }, + emoji: { + type: SchemaTypes.string, + description: "Reaction (emoji) name", + title: "Emoji", + }, + }, + required: ["message_context", "emoji"], + }, + output_parameters: { properties: {}, required: [] }, +}); diff --git a/src/schema/slack/functions/add_reaction_test.ts b/src/schema/slack/functions/add_reaction_test.ts new file mode 100644 index 00000000..9de1eff1 --- /dev/null +++ b/src/schema/slack/functions/add_reaction_test.ts @@ -0,0 +1,50 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { assertEquals, assertNotStrictEquals } from "../../../dev_deps.ts"; +import { DefineWorkflow } from "../../../workflows/mod.ts"; +import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts"; +import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; +import AddReaction from "./add_reaction.ts"; + +Deno.test("AddReaction generates valid FunctionManifest", () => { + assertEquals( + AddReaction.definition.callback_id, + "slack#/functions/add_reaction", + ); + const expected: ManifestFunctionSchema = { + source_file: "", + title: "Add a reaction to a message", + input_parameters: { + properties: { + message_context: { + type: SlackTypes.message_context, + description: "Select a message to react to", + title: "Select a message to react to", + }, + emoji: { + type: SchemaTypes.string, + description: "Reaction (emoji) name", + title: "Emoji", + }, + }, + required: ["message_context", "emoji"], + }, + output_parameters: { properties: {}, required: [] }, + }; + const actual = AddReaction.export(); + + assertNotStrictEquals(actual, expected); +}); + +Deno.test("AddReaction can be used as a Slack function in a workflow step", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_AddReaction_slack_function", + title: "Test AddReaction", + description: "This is a generated test to test AddReaction", + }); + testWorkflow.addStep(AddReaction, { message_context: "test", emoji: "test" }); + const actual = testWorkflow.steps[0].export(); + + assertEquals(actual.function_id, "slack#/functions/add_reaction"); + assertEquals(actual.inputs, { message_context: "test", emoji: "test" }); +}); diff --git a/src/schema/slack/functions/copy_list.ts b/src/schema/slack/functions/copy_list.ts new file mode 100644 index 00000000..d486ca9a --- /dev/null +++ b/src/schema/slack/functions/copy_list.ts @@ -0,0 +1,65 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { DefineFunction } from "../../../functions/mod.ts"; +import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; + +export default DefineFunction({ + callback_id: "slack#/functions/copy_list", + source_file: "", + title: "Copy a list", + input_parameters: { + properties: { + list_id: { + type: undefined, + description: "Search all lists", + title: "Select a list", + }, + owner_id: { + type: SlackTypes.user_id, + description: "List owner id", + title: "Owner", + }, + name: { + type: SchemaTypes.string, + description: "Name of the list", + title: "Name", + }, + description: { + type: SchemaTypes.string, + description: "Description of the list", + title: "Description", + }, + emoji: { + type: SchemaTypes.string, + description: "Emoji for the list", + title: "Emoji", + }, + include_copied_list_records: { + type: SchemaTypes.boolean, + description: "Include records from the copied list", + title: "Copy records", + }, + }, + required: ["list_id", "owner_id", "name", "include_copied_list_records"], + }, + output_parameters: { + properties: { + list_id: { + type: SchemaTypes.string, + description: "List ID", + title: "List ID", + }, + link: { + type: SchemaTypes.string, + description: "Link for the list", + title: "Link", + }, + list_id_value: { + type: undefined, + description: "List title", + title: "List title", + }, + }, + required: [], + }, +}); diff --git a/src/schema/slack/functions/copy_list_test.ts b/src/schema/slack/functions/copy_list_test.ts new file mode 100644 index 00000000..d53ed1e5 --- /dev/null +++ b/src/schema/slack/functions/copy_list_test.ts @@ -0,0 +1,117 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { + assertEquals, + assertExists, + assertNotStrictEquals, +} from "../../../dev_deps.ts"; +import { DefineWorkflow } from "../../../workflows/mod.ts"; +import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts"; +import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; +import CopyList from "./copy_list.ts"; + +Deno.test("CopyList generates valid FunctionManifest", () => { + assertEquals(CopyList.definition.callback_id, "slack#/functions/copy_list"); + const expected: ManifestFunctionSchema = { + source_file: "", + title: "Copy a list", + input_parameters: { + properties: { + list_id: { + type: undefined, + description: "Search all lists", + title: "Select a list", + }, + owner_id: { + type: SlackTypes.user_id, + description: "List owner id", + title: "Owner", + }, + name: { + type: SchemaTypes.string, + description: "Name of the list", + title: "Name", + }, + description: { + type: SchemaTypes.string, + description: "Description of the list", + title: "Description", + }, + emoji: { + type: SchemaTypes.string, + description: "Emoji for the list", + title: "Emoji", + }, + include_copied_list_records: { + type: SchemaTypes.boolean, + description: "Include records from the copied list", + title: "Copy records", + }, + }, + required: ["list_id", "owner_id", "name", "include_copied_list_records"], + }, + output_parameters: { + properties: { + list_id: { + type: SchemaTypes.string, + description: "List ID", + title: "List ID", + }, + link: { + type: SchemaTypes.string, + description: "Link for the list", + title: "Link", + }, + list_id_value: { + type: undefined, + description: "List title", + title: "List title", + }, + }, + required: [], + }, + }; + const actual = CopyList.export(); + + assertNotStrictEquals(actual, expected); +}); + +Deno.test("CopyList can be used as a Slack function in a workflow step", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_CopyList_slack_function", + title: "Test CopyList", + description: "This is a generated test to test CopyList", + }); + testWorkflow.addStep(CopyList, { + list_id: "test", + owner_id: "test", + name: "test", + include_copied_list_records: "test", + }); + const actual = testWorkflow.steps[0].export(); + + assertEquals(actual.function_id, "slack#/functions/copy_list"); + assertEquals(actual.inputs, { + list_id: "test", + owner_id: "test", + name: "test", + include_copied_list_records: "test", + }); +}); + +Deno.test("All outputs of Slack function CopyList should exist", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_CopyList_slack_function", + title: "Test CopyList", + description: "This is a generated test to test CopyList", + }); + const step = testWorkflow.addStep(CopyList, { + list_id: "test", + owner_id: "test", + name: "test", + include_copied_list_records: "test", + }); + assertExists(step.outputs.list_id); + assertExists(step.outputs.link); + assertExists(step.outputs.list_id_value); +}); diff --git a/src/schema/slack/functions/delete_list_record.ts b/src/schema/slack/functions/delete_list_record.ts new file mode 100644 index 00000000..2684d965 --- /dev/null +++ b/src/schema/slack/functions/delete_list_record.ts @@ -0,0 +1,25 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { DefineFunction } from "../../../functions/mod.ts"; +import SchemaTypes from "../../schema_types.ts"; + +export default DefineFunction({ + callback_id: "slack#/functions/delete_list_record", + source_file: "", + title: "Delete a list item", + input_parameters: { + properties: { + list_id: { + type: undefined, + description: "Select a list", + title: "Select a list", + }, + record_id: { + type: SchemaTypes.string, + description: "Item ID", + title: "Item ID", + }, + }, + required: ["list_id"], + }, + output_parameters: { properties: {}, required: [] }, +}); diff --git a/src/schema/slack/functions/delete_list_record_test.ts b/src/schema/slack/functions/delete_list_record_test.ts new file mode 100644 index 00000000..7eebbbef --- /dev/null +++ b/src/schema/slack/functions/delete_list_record_test.ts @@ -0,0 +1,49 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { assertEquals, assertNotStrictEquals } from "../../../dev_deps.ts"; +import { DefineWorkflow } from "../../../workflows/mod.ts"; +import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts"; +import SchemaTypes from "../../schema_types.ts"; +import DeleteListRecord from "./delete_list_record.ts"; + +Deno.test("DeleteListRecord generates valid FunctionManifest", () => { + assertEquals( + DeleteListRecord.definition.callback_id, + "slack#/functions/delete_list_record", + ); + const expected: ManifestFunctionSchema = { + source_file: "", + title: "Delete a list item", + input_parameters: { + properties: { + list_id: { + type: undefined, + description: "Select a list", + title: "Select a list", + }, + record_id: { + type: SchemaTypes.string, + description: "Item ID", + title: "Item ID", + }, + }, + required: ["list_id"], + }, + output_parameters: { properties: {}, required: [] }, + }; + const actual = DeleteListRecord.export(); + + assertNotStrictEquals(actual, expected); +}); + +Deno.test("DeleteListRecord can be used as a Slack function in a workflow step", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_DeleteListRecord_slack_function", + title: "Test DeleteListRecord", + description: "This is a generated test to test DeleteListRecord", + }); + testWorkflow.addStep(DeleteListRecord, { list_id: "test" }); + const actual = testWorkflow.steps[0].export(); + + assertEquals(actual.function_id, "slack#/functions/delete_list_record"); + assertEquals(actual.inputs, { list_id: "test" }); +}); diff --git a/src/schema/slack/functions/list_add_record.ts b/src/schema/slack/functions/list_add_record.ts new file mode 100644 index 00000000..39849cb5 --- /dev/null +++ b/src/schema/slack/functions/list_add_record.ts @@ -0,0 +1,40 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { DefineFunction } from "../../../functions/mod.ts"; +import SchemaTypes from "../../schema_types.ts"; + +export default DefineFunction({ + callback_id: "slack#/functions/list_add_record", + source_file: "", + title: "Add an item to a list", + description: "Add an item to a given list", + input_parameters: { + properties: { + list_id: { + type: undefined, + description: "Search all lists", + title: "Select a list", + }, + columns: { + type: SchemaTypes.object, + description: "Enter the data for each field", + title: "Fields", + }, + }, + required: ["list_id", "columns"], + }, + output_parameters: { + properties: { + record_id: { + type: SchemaTypes.string, + description: "The item ID of the new item", + title: "Item ID", + }, + record_url: { + type: SchemaTypes.string, + description: "The URL of the new item", + title: "Item URL", + }, + }, + required: ["record_id", "record_url"], + }, +}); diff --git a/src/schema/slack/functions/list_add_record_test.ts b/src/schema/slack/functions/list_add_record_test.ts new file mode 100644 index 00000000..49a85592 --- /dev/null +++ b/src/schema/slack/functions/list_add_record_test.ts @@ -0,0 +1,82 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { + assertEquals, + assertExists, + assertNotStrictEquals, +} from "../../../dev_deps.ts"; +import { DefineWorkflow } from "../../../workflows/mod.ts"; +import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts"; +import SchemaTypes from "../../schema_types.ts"; +import ListAddRecord from "./list_add_record.ts"; + +Deno.test("ListAddRecord generates valid FunctionManifest", () => { + assertEquals( + ListAddRecord.definition.callback_id, + "slack#/functions/list_add_record", + ); + const expected: ManifestFunctionSchema = { + source_file: "", + title: "Add an item to a list", + description: "Add an item to a given list", + input_parameters: { + properties: { + list_id: { + type: undefined, + description: "Search all lists", + title: "Select a list", + }, + columns: { + type: SchemaTypes.object, + description: "Enter the data for each field", + title: "Fields", + }, + }, + required: ["list_id", "columns"], + }, + output_parameters: { + properties: { + record_id: { + type: SchemaTypes.string, + description: "The item ID of the new item", + title: "Item ID", + }, + record_url: { + type: SchemaTypes.string, + description: "The URL of the new item", + title: "Item URL", + }, + }, + required: ["record_id", "record_url"], + }, + }; + const actual = ListAddRecord.export(); + + assertNotStrictEquals(actual, expected); +}); + +Deno.test("ListAddRecord can be used as a Slack function in a workflow step", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_ListAddRecord_slack_function", + title: "Test ListAddRecord", + description: "This is a generated test to test ListAddRecord", + }); + testWorkflow.addStep(ListAddRecord, { list_id: "test", columns: "test" }); + const actual = testWorkflow.steps[0].export(); + + assertEquals(actual.function_id, "slack#/functions/list_add_record"); + assertEquals(actual.inputs, { list_id: "test", columns: "test" }); +}); + +Deno.test("All outputs of Slack function ListAddRecord should exist", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_ListAddRecord_slack_function", + title: "Test ListAddRecord", + description: "This is a generated test to test ListAddRecord", + }); + const step = testWorkflow.addStep(ListAddRecord, { + list_id: "test", + columns: "test", + }); + assertExists(step.outputs.record_id); + assertExists(step.outputs.record_url); +}); diff --git a/src/schema/slack/functions/lists_activity_feed.ts b/src/schema/slack/functions/lists_activity_feed.ts new file mode 100644 index 00000000..9411000c --- /dev/null +++ b/src/schema/slack/functions/lists_activity_feed.ts @@ -0,0 +1,41 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { DefineFunction } from "../../../functions/mod.ts"; +import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; + +export default DefineFunction({ + callback_id: "slack#/functions/lists_activity_feed", + source_file: "", + title: "Send notification to activity feed", + input_parameters: { + properties: { + user_id: { + type: SlackTypes.user_id, + description: "Select a user", + title: "Select a user", + }, + updated_by_user_id: { + type: SlackTypes.user_id, + description: "User who updated the list item", + title: "User who updated the list item", + }, + list_id: { + type: undefined, + description: "Select a list", + title: "Select a list", + }, + record_id: { + type: SchemaTypes.string, + description: "Item ID", + title: "Item ID", + }, + columns: { + type: SchemaTypes.string, + description: "Field IDs", + title: "Field IDs", + }, + }, + required: ["user_id", "list_id", "record_id", "columns"], + }, + output_parameters: { properties: {}, required: [] }, +}); diff --git a/src/schema/slack/functions/lists_activity_feed_test.ts b/src/schema/slack/functions/lists_activity_feed_test.ts new file mode 100644 index 00000000..4b54740a --- /dev/null +++ b/src/schema/slack/functions/lists_activity_feed_test.ts @@ -0,0 +1,75 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { assertEquals, assertNotStrictEquals } from "../../../dev_deps.ts"; +import { DefineWorkflow } from "../../../workflows/mod.ts"; +import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts"; +import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; +import ListsActivityFeed from "./lists_activity_feed.ts"; + +Deno.test("ListsActivityFeed generates valid FunctionManifest", () => { + assertEquals( + ListsActivityFeed.definition.callback_id, + "slack#/functions/lists_activity_feed", + ); + const expected: ManifestFunctionSchema = { + source_file: "", + title: "Send notification to activity feed", + input_parameters: { + properties: { + user_id: { + type: SlackTypes.user_id, + description: "Select a user", + title: "Select a user", + }, + updated_by_user_id: { + type: SlackTypes.user_id, + description: "User who updated the list item", + title: "User who updated the list item", + }, + list_id: { + type: undefined, + description: "Select a list", + title: "Select a list", + }, + record_id: { + type: SchemaTypes.string, + description: "Item ID", + title: "Item ID", + }, + columns: { + type: SchemaTypes.string, + description: "Field IDs", + title: "Field IDs", + }, + }, + required: ["user_id", "list_id", "record_id", "columns"], + }, + output_parameters: { properties: {}, required: [] }, + }; + const actual = ListsActivityFeed.export(); + + assertNotStrictEquals(actual, expected); +}); + +Deno.test("ListsActivityFeed can be used as a Slack function in a workflow step", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_ListsActivityFeed_slack_function", + title: "Test ListsActivityFeed", + description: "This is a generated test to test ListsActivityFeed", + }); + testWorkflow.addStep(ListsActivityFeed, { + user_id: "test", + list_id: "test", + record_id: "test", + columns: "test", + }); + const actual = testWorkflow.steps[0].export(); + + assertEquals(actual.function_id, "slack#/functions/lists_activity_feed"); + assertEquals(actual.inputs, { + user_id: "test", + list_id: "test", + record_id: "test", + columns: "test", + }); +}); diff --git a/src/schema/slack/functions/mod.ts b/src/schema/slack/functions/mod.ts index 420f096d..06193d1d 100644 --- a/src/schema/slack/functions/mod.ts +++ b/src/schema/slack/functions/mod.ts @@ -1,17 +1,23 @@ -/** This file was autogenerated on Fri Jun 07 2024. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +/** This file was autogenerated on Fri Sep 06 2024. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ import AddBookmark from "./add_bookmark.ts"; import AddPin from "./add_pin.ts"; +import AddReaction from "./add_reaction.ts"; import AddUserToUsergroup from "./add_user_to_usergroup.ts"; import ArchiveChannel from "./archive_channel.ts"; import CanvasCopy from "./canvas_copy.ts"; import CanvasCreate from "./canvas_create.ts"; import CanvasUpdateContent from "./canvas_update_content.ts"; import ChannelCanvasCreate from "./channel_canvas_create.ts"; +import CopyList from "./copy_list.ts"; import CreateChannel from "./create_channel.ts"; import CreateUsergroup from "./create_usergroup.ts"; import Delay from "./delay.ts"; +import DeleteListRecord from "./delete_list_record.ts"; import InviteUserToChannel from "./invite_user_to_channel.ts"; +import ListAddRecord from "./list_add_record.ts"; +import ListsActivityFeed from "./lists_activity_feed.ts"; import OpenForm from "./open_form.ts"; +import RemoveReaction from "./remove_reaction.ts"; import RemoveUserFromUsergroup from "./remove_user_from_usergroup.ts"; import ReplyInThread from "./reply_in_thread.ts"; import SendDm from "./send_dm.ts"; @@ -19,22 +25,30 @@ import SendEphemeralMessage from "./send_ephemeral_message.ts"; import SendMessage from "./send_message.ts"; import ShareCanvas from "./share_canvas.ts"; import ShareCanvasInThread from "./share_canvas_in_thread.ts"; +import ShareListUsers from "./share_list_users.ts"; import UpdateChannelTopic from "./update_channel_topic.ts"; +import UpdateListRecord from "./update_list_record.ts"; const SlackFunctions = { AddBookmark, AddPin, + AddReaction, AddUserToUsergroup, ArchiveChannel, CanvasCopy, CanvasCreate, CanvasUpdateContent, ChannelCanvasCreate, + CopyList, CreateChannel, CreateUsergroup, Delay, + DeleteListRecord, InviteUserToChannel, + ListAddRecord, + ListsActivityFeed, OpenForm, + RemoveReaction, RemoveUserFromUsergroup, ReplyInThread, SendDm, @@ -42,7 +56,9 @@ const SlackFunctions = { SendMessage, ShareCanvas, ShareCanvasInThread, + ShareListUsers, UpdateChannelTopic, + UpdateListRecord, } as const; export default SlackFunctions; diff --git a/src/schema/slack/functions/remove_reaction.ts b/src/schema/slack/functions/remove_reaction.ts new file mode 100644 index 00000000..75b5a35d --- /dev/null +++ b/src/schema/slack/functions/remove_reaction.ts @@ -0,0 +1,26 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { DefineFunction } from "../../../functions/mod.ts"; +import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; + +export default DefineFunction({ + callback_id: "slack#/functions/remove_reaction", + source_file: "", + title: "Remove a reaction from a message", + input_parameters: { + properties: { + message_context: { + type: SlackTypes.message_context, + description: "Select a message to unreact from", + title: "Select a message to unreact from", + }, + emoji: { + type: SchemaTypes.string, + description: "Reaction (emoji) name", + title: "Emoji", + }, + }, + required: ["message_context", "emoji"], + }, + output_parameters: { properties: {}, required: [] }, +}); diff --git a/src/schema/slack/functions/remove_reaction_test.ts b/src/schema/slack/functions/remove_reaction_test.ts new file mode 100644 index 00000000..aed35e0f --- /dev/null +++ b/src/schema/slack/functions/remove_reaction_test.ts @@ -0,0 +1,53 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { assertEquals, assertNotStrictEquals } from "../../../dev_deps.ts"; +import { DefineWorkflow } from "../../../workflows/mod.ts"; +import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts"; +import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; +import RemoveReaction from "./remove_reaction.ts"; + +Deno.test("RemoveReaction generates valid FunctionManifest", () => { + assertEquals( + RemoveReaction.definition.callback_id, + "slack#/functions/remove_reaction", + ); + const expected: ManifestFunctionSchema = { + source_file: "", + title: "Remove a reaction from a message", + input_parameters: { + properties: { + message_context: { + type: SlackTypes.message_context, + description: "Select a message to unreact from", + title: "Select a message to unreact from", + }, + emoji: { + type: SchemaTypes.string, + description: "Reaction (emoji) name", + title: "Emoji", + }, + }, + required: ["message_context", "emoji"], + }, + output_parameters: { properties: {}, required: [] }, + }; + const actual = RemoveReaction.export(); + + assertNotStrictEquals(actual, expected); +}); + +Deno.test("RemoveReaction can be used as a Slack function in a workflow step", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_RemoveReaction_slack_function", + title: "Test RemoveReaction", + description: "This is a generated test to test RemoveReaction", + }); + testWorkflow.addStep(RemoveReaction, { + message_context: "test", + emoji: "test", + }); + const actual = testWorkflow.steps[0].export(); + + assertEquals(actual.function_id, "slack#/functions/remove_reaction"); + assertEquals(actual.inputs, { message_context: "test", emoji: "test" }); +}); diff --git a/src/schema/slack/functions/share_list_users.ts b/src/schema/slack/functions/share_list_users.ts new file mode 100644 index 00000000..4dec017a --- /dev/null +++ b/src/schema/slack/functions/share_list_users.ts @@ -0,0 +1,47 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { DefineFunction } from "../../../functions/mod.ts"; +import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; + +export default DefineFunction({ + callback_id: "slack#/functions/share_list_users", + source_file: "", + title: "Share a list with people", + description: "Share a list with users", + input_parameters: { + properties: { + file_id: { + type: undefined, + description: "Search all list", + title: "Select a List", + }, + user_ids: { + type: SchemaTypes.array, + description: "Search all people", + title: "Select member(s)", + items: { type: SlackTypes.user_id }, + }, + user_access_level: { + type: SchemaTypes.string, + description: "Selects an access level for sharing", + title: "Select access level", + }, + message: { + type: SlackTypes.rich_text, + description: "Add a message", + title: "Add a message", + }, + }, + required: ["file_id", "user_ids", "user_access_level"], + }, + output_parameters: { + properties: { + file_id: { + type: undefined, + description: "List title", + title: "List title", + }, + }, + required: [], + }, +}); diff --git a/src/schema/slack/functions/share_list_users_test.ts b/src/schema/slack/functions/share_list_users_test.ts new file mode 100644 index 00000000..f0d0a5ad --- /dev/null +++ b/src/schema/slack/functions/share_list_users_test.ts @@ -0,0 +1,97 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { + assertEquals, + assertExists, + assertNotStrictEquals, +} from "../../../dev_deps.ts"; +import { DefineWorkflow } from "../../../workflows/mod.ts"; +import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts"; +import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; +import ShareListUsers from "./share_list_users.ts"; + +Deno.test("ShareListUsers generates valid FunctionManifest", () => { + assertEquals( + ShareListUsers.definition.callback_id, + "slack#/functions/share_list_users", + ); + const expected: ManifestFunctionSchema = { + source_file: "", + title: "Share a list with people", + description: "Share a list with users", + input_parameters: { + properties: { + file_id: { + type: undefined, + description: "Search all list", + title: "Select a List", + }, + user_ids: { + type: SchemaTypes.array, + description: "Search all people", + title: "Select member(s)", + items: { type: SlackTypes.user_id }, + }, + user_access_level: { + type: SchemaTypes.string, + description: "Selects an access level for sharing", + title: "Select access level", + }, + message: { + type: SlackTypes.rich_text, + description: "Add a message", + title: "Add a message", + }, + }, + required: ["file_id", "user_ids", "user_access_level"], + }, + output_parameters: { + properties: { + file_id: { + type: undefined, + description: "List title", + title: "List title", + }, + }, + required: [], + }, + }; + const actual = ShareListUsers.export(); + + assertNotStrictEquals(actual, expected); +}); + +Deno.test("ShareListUsers can be used as a Slack function in a workflow step", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_ShareListUsers_slack_function", + title: "Test ShareListUsers", + description: "This is a generated test to test ShareListUsers", + }); + testWorkflow.addStep(ShareListUsers, { + file_id: "test", + user_ids: "test", + user_access_level: "test", + }); + const actual = testWorkflow.steps[0].export(); + + assertEquals(actual.function_id, "slack#/functions/share_list_users"); + assertEquals(actual.inputs, { + file_id: "test", + user_ids: "test", + user_access_level: "test", + }); +}); + +Deno.test("All outputs of Slack function ShareListUsers should exist", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_ShareListUsers_slack_function", + title: "Test ShareListUsers", + description: "This is a generated test to test ShareListUsers", + }); + const step = testWorkflow.addStep(ShareListUsers, { + file_id: "test", + user_ids: "test", + user_access_level: "test", + }); + assertExists(step.outputs.file_id); +}); diff --git a/src/schema/slack/functions/update_list_record.ts b/src/schema/slack/functions/update_list_record.ts new file mode 100644 index 00000000..950efc1f --- /dev/null +++ b/src/schema/slack/functions/update_list_record.ts @@ -0,0 +1,39 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { DefineFunction } from "../../../functions/mod.ts"; +import SchemaTypes from "../../schema_types.ts"; + +export default DefineFunction({ + callback_id: "slack#/functions/update_list_record", + source_file: "", + title: "Update a list item", + input_parameters: { + properties: { + list_id: { + type: undefined, + description: "Select a list", + title: "Select a list", + }, + record_id: { + type: SchemaTypes.string, + description: "Item ID", + title: "Item ID", + }, + updated_columns: { + type: SchemaTypes.object, + description: "Enter the data for fields", + title: "Updated fields", + }, + }, + required: ["list_id", "updated_columns"], + }, + output_parameters: { + properties: { + field_values: { + type: SchemaTypes.object, + description: "Updated values of the item", + title: "Item", + }, + }, + required: [], + }, +}); diff --git a/src/schema/slack/functions/update_list_record_test.ts b/src/schema/slack/functions/update_list_record_test.ts new file mode 100644 index 00000000..73555ea8 --- /dev/null +++ b/src/schema/slack/functions/update_list_record_test.ts @@ -0,0 +1,83 @@ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import { + assertEquals, + assertExists, + assertNotStrictEquals, +} from "../../../dev_deps.ts"; +import { DefineWorkflow } from "../../../workflows/mod.ts"; +import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts"; +import SchemaTypes from "../../schema_types.ts"; +import UpdateListRecord from "./update_list_record.ts"; + +Deno.test("UpdateListRecord generates valid FunctionManifest", () => { + assertEquals( + UpdateListRecord.definition.callback_id, + "slack#/functions/update_list_record", + ); + const expected: ManifestFunctionSchema = { + source_file: "", + title: "Update a list item", + input_parameters: { + properties: { + list_id: { + type: undefined, + description: "Select a list", + title: "Select a list", + }, + record_id: { + type: SchemaTypes.string, + description: "Item ID", + title: "Item ID", + }, + updated_columns: { + type: SchemaTypes.object, + description: "Enter the data for fields", + title: "Updated fields", + }, + }, + required: ["list_id", "updated_columns"], + }, + output_parameters: { + properties: { + field_values: { + type: SchemaTypes.object, + description: "Updated values of the item", + title: "Item", + }, + }, + required: [], + }, + }; + const actual = UpdateListRecord.export(); + + assertNotStrictEquals(actual, expected); +}); + +Deno.test("UpdateListRecord can be used as a Slack function in a workflow step", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_UpdateListRecord_slack_function", + title: "Test UpdateListRecord", + description: "This is a generated test to test UpdateListRecord", + }); + testWorkflow.addStep(UpdateListRecord, { + list_id: "test", + updated_columns: "test", + }); + const actual = testWorkflow.steps[0].export(); + + assertEquals(actual.function_id, "slack#/functions/update_list_record"); + assertEquals(actual.inputs, { list_id: "test", updated_columns: "test" }); +}); + +Deno.test("All outputs of Slack function UpdateListRecord should exist", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_UpdateListRecord_slack_function", + title: "Test UpdateListRecord", + description: "This is a generated test to test UpdateListRecord", + }); + const step = testWorkflow.addStep(UpdateListRecord, { + list_id: "test", + updated_columns: "test", + }); + assertExists(step.outputs.field_values); +}); From 794c175b8fe88e79e31fa448ddbdafcd7e398de0 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Fri, 6 Sep 2024 10:42:36 -0400 Subject: [PATCH 2/4] deno fmt --- src/schema/slack/functions/_scripts/README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/schema/slack/functions/_scripts/README.md b/src/schema/slack/functions/_scripts/README.md index 837ce6a7..ba993baa 100644 --- a/src/schema/slack/functions/_scripts/README.md +++ b/src/schema/slack/functions/_scripts/README.md @@ -10,13 +10,14 @@ corresponding test, the tests must be removed manually. ## Instructions -1. First, you'll need to grab the response from `functions.list` API - method tester: - - Choose a session token from a public production enterprise grid workspace that - is NOT enrolled in any beta toggles. Recommend using the Slack DevRel - production enterprise grid token. - - Use `builtins` as the value for the `function_type` parameter to this API. - - Copy the response into a `functions.json` file in this directory. +1. First, you'll need to grab the response from `functions.list` API method + tester: + +- Choose a session token from a public production enterprise grid workspace that + is NOT enrolled in any beta toggles. Recommend using the Slack DevRel + production enterprise grid token. +- Use `builtins` as the value for the `function_type` parameter to this API. +- Copy the response into a `functions.json` file in this directory. 2. With this `_scripts` directory as your working directory, run the generate script: From 6b3e08a5ee2afd2d100d74db4dec3c04f01910fc Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Fri, 6 Sep 2024 15:03:14 -0400 Subject: [PATCH 3/4] Add new list_id type. Make generation script throw an exception if it finds an unfamiliar parameter type. Update generated list functions with new list_id type. --- src/schema/slack/functions/_scripts/generate | 2 ++ .../functions/_scripts/src/templates/template_function.ts | 6 +++++- src/schema/slack/functions/_scripts/src/templates/utils.ts | 3 +-- src/schema/slack/functions/copy_list.ts | 4 ++-- src/schema/slack/functions/copy_list_test.ts | 4 ++-- src/schema/slack/functions/delete_list_record.ts | 3 ++- src/schema/slack/functions/delete_list_record_test.ts | 3 ++- src/schema/slack/functions/list_add_record.ts | 3 ++- src/schema/slack/functions/list_add_record_test.ts | 3 ++- src/schema/slack/functions/lists_activity_feed.ts | 2 +- src/schema/slack/functions/lists_activity_feed_test.ts | 2 +- src/schema/slack/functions/share_list_users.ts | 4 ++-- src/schema/slack/functions/share_list_users_test.ts | 4 ++-- src/schema/slack/functions/update_list_record.ts | 3 ++- src/schema/slack/functions/update_list_record_test.ts | 3 ++- src/schema/slack/types/mod.ts | 1 + 16 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/schema/slack/functions/_scripts/generate b/src/schema/slack/functions/_scripts/generate index f9d2e3ca..db977b40 100755 --- a/src/schema/slack/functions/_scripts/generate +++ b/src/schema/slack/functions/_scripts/generate @@ -21,3 +21,5 @@ echo "Formatting Slack function files..." deno fmt --quiet ../*.ts echo "Linting Slack function files..." deno lint --quiet ../*.ts +echo "Type-checking Slack function files..." +deno check --quiet ../*.ts diff --git a/src/schema/slack/functions/_scripts/src/templates/template_function.ts b/src/schema/slack/functions/_scripts/src/templates/template_function.ts index 760bc686..2354d56b 100644 --- a/src/schema/slack/functions/_scripts/src/templates/template_function.ts +++ b/src/schema/slack/functions/_scripts/src/templates/template_function.ts @@ -73,8 +73,12 @@ const propertyToTypeScript = ( property: FunctionProperty, ): string => { const typescript = []; + const sdkType = schemaTypeMap[property.type]; + if (!sdkType) { + throw new Error(`Unrecognized type "${property.type}"! Maybe a new automation platform type was recently introduced? If so, add it to one of the type files under src/schema.`); + } typescript.push( - `type: ${schemaTypeMap[property.type]}`, + `type: ${sdkType}`, ); if (property.description) { typescript.push(`description: ${sanitize(property.description)}`); diff --git a/src/schema/slack/functions/_scripts/src/templates/utils.ts b/src/schema/slack/functions/_scripts/src/templates/utils.ts index 968e5277..ae6255a1 100644 --- a/src/schema/slack/functions/_scripts/src/templates/utils.ts +++ b/src/schema/slack/functions/_scripts/src/templates/utils.ts @@ -5,8 +5,7 @@ import SlackTypes from "../../../../schema_types.ts"; import { InternalSlackTypes } from "../../../../types/custom/mod.ts"; import { AllowedTypeValue, AllowedTypeValueObject } from "./types.ts"; import { isCustomType } from "../../../../../../types/mod.ts"; -import { isArrayFunctionProperty } from "../utils.ts"; -import { isObjectFunctionProperty } from "../utils.ts"; +import { isArrayFunctionProperty, isObjectFunctionProperty } from "../utils.ts"; export function autogeneratedComment(includeDate?: boolean): string { const dateString = includeDate ? ` on ${new Date().toDateString()}` : ""; diff --git a/src/schema/slack/functions/copy_list.ts b/src/schema/slack/functions/copy_list.ts index d486ca9a..149eaf30 100644 --- a/src/schema/slack/functions/copy_list.ts +++ b/src/schema/slack/functions/copy_list.ts @@ -10,7 +10,7 @@ export default DefineFunction({ input_parameters: { properties: { list_id: { - type: undefined, + type: SlackTypes.list_id, description: "Search all lists", title: "Select a list", }, @@ -55,7 +55,7 @@ export default DefineFunction({ title: "Link", }, list_id_value: { - type: undefined, + type: SlackTypes.list_id, description: "List title", title: "List title", }, diff --git a/src/schema/slack/functions/copy_list_test.ts b/src/schema/slack/functions/copy_list_test.ts index d53ed1e5..ff2140bd 100644 --- a/src/schema/slack/functions/copy_list_test.ts +++ b/src/schema/slack/functions/copy_list_test.ts @@ -18,7 +18,7 @@ Deno.test("CopyList generates valid FunctionManifest", () => { input_parameters: { properties: { list_id: { - type: undefined, + type: SlackTypes.list_id, description: "Search all lists", title: "Select a list", }, @@ -63,7 +63,7 @@ Deno.test("CopyList generates valid FunctionManifest", () => { title: "Link", }, list_id_value: { - type: undefined, + type: SlackTypes.list_id, description: "List title", title: "List title", }, diff --git a/src/schema/slack/functions/delete_list_record.ts b/src/schema/slack/functions/delete_list_record.ts index 2684d965..36efc383 100644 --- a/src/schema/slack/functions/delete_list_record.ts +++ b/src/schema/slack/functions/delete_list_record.ts @@ -1,6 +1,7 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ import { DefineFunction } from "../../../functions/mod.ts"; import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; export default DefineFunction({ callback_id: "slack#/functions/delete_list_record", @@ -9,7 +10,7 @@ export default DefineFunction({ input_parameters: { properties: { list_id: { - type: undefined, + type: SlackTypes.list_id, description: "Select a list", title: "Select a list", }, diff --git a/src/schema/slack/functions/delete_list_record_test.ts b/src/schema/slack/functions/delete_list_record_test.ts index 7eebbbef..1416dd46 100644 --- a/src/schema/slack/functions/delete_list_record_test.ts +++ b/src/schema/slack/functions/delete_list_record_test.ts @@ -3,6 +3,7 @@ import { assertEquals, assertNotStrictEquals } from "../../../dev_deps.ts"; import { DefineWorkflow } from "../../../workflows/mod.ts"; import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts"; import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; import DeleteListRecord from "./delete_list_record.ts"; Deno.test("DeleteListRecord generates valid FunctionManifest", () => { @@ -16,7 +17,7 @@ Deno.test("DeleteListRecord generates valid FunctionManifest", () => { input_parameters: { properties: { list_id: { - type: undefined, + type: SlackTypes.list_id, description: "Select a list", title: "Select a list", }, diff --git a/src/schema/slack/functions/list_add_record.ts b/src/schema/slack/functions/list_add_record.ts index 39849cb5..6d91d50c 100644 --- a/src/schema/slack/functions/list_add_record.ts +++ b/src/schema/slack/functions/list_add_record.ts @@ -1,6 +1,7 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ import { DefineFunction } from "../../../functions/mod.ts"; import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; export default DefineFunction({ callback_id: "slack#/functions/list_add_record", @@ -10,7 +11,7 @@ export default DefineFunction({ input_parameters: { properties: { list_id: { - type: undefined, + type: SlackTypes.list_id, description: "Search all lists", title: "Select a list", }, diff --git a/src/schema/slack/functions/list_add_record_test.ts b/src/schema/slack/functions/list_add_record_test.ts index 49a85592..0983cf7e 100644 --- a/src/schema/slack/functions/list_add_record_test.ts +++ b/src/schema/slack/functions/list_add_record_test.ts @@ -7,6 +7,7 @@ import { import { DefineWorkflow } from "../../../workflows/mod.ts"; import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts"; import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; import ListAddRecord from "./list_add_record.ts"; Deno.test("ListAddRecord generates valid FunctionManifest", () => { @@ -21,7 +22,7 @@ Deno.test("ListAddRecord generates valid FunctionManifest", () => { input_parameters: { properties: { list_id: { - type: undefined, + type: SlackTypes.list_id, description: "Search all lists", title: "Select a list", }, diff --git a/src/schema/slack/functions/lists_activity_feed.ts b/src/schema/slack/functions/lists_activity_feed.ts index 9411000c..fe2c1e04 100644 --- a/src/schema/slack/functions/lists_activity_feed.ts +++ b/src/schema/slack/functions/lists_activity_feed.ts @@ -20,7 +20,7 @@ export default DefineFunction({ title: "User who updated the list item", }, list_id: { - type: undefined, + type: SlackTypes.list_id, description: "Select a list", title: "Select a list", }, diff --git a/src/schema/slack/functions/lists_activity_feed_test.ts b/src/schema/slack/functions/lists_activity_feed_test.ts index 4b54740a..82194728 100644 --- a/src/schema/slack/functions/lists_activity_feed_test.ts +++ b/src/schema/slack/functions/lists_activity_feed_test.ts @@ -27,7 +27,7 @@ Deno.test("ListsActivityFeed generates valid FunctionManifest", () => { title: "User who updated the list item", }, list_id: { - type: undefined, + type: SlackTypes.list_id, description: "Select a list", title: "Select a list", }, diff --git a/src/schema/slack/functions/share_list_users.ts b/src/schema/slack/functions/share_list_users.ts index 4dec017a..57fb0ea1 100644 --- a/src/schema/slack/functions/share_list_users.ts +++ b/src/schema/slack/functions/share_list_users.ts @@ -11,7 +11,7 @@ export default DefineFunction({ input_parameters: { properties: { file_id: { - type: undefined, + type: SlackTypes.list_id, description: "Search all list", title: "Select a List", }, @@ -37,7 +37,7 @@ export default DefineFunction({ output_parameters: { properties: { file_id: { - type: undefined, + type: SlackTypes.list_id, description: "List title", title: "List title", }, diff --git a/src/schema/slack/functions/share_list_users_test.ts b/src/schema/slack/functions/share_list_users_test.ts index f0d0a5ad..8e8f86fd 100644 --- a/src/schema/slack/functions/share_list_users_test.ts +++ b/src/schema/slack/functions/share_list_users_test.ts @@ -22,7 +22,7 @@ Deno.test("ShareListUsers generates valid FunctionManifest", () => { input_parameters: { properties: { file_id: { - type: undefined, + type: SlackTypes.list_id, description: "Search all list", title: "Select a List", }, @@ -48,7 +48,7 @@ Deno.test("ShareListUsers generates valid FunctionManifest", () => { output_parameters: { properties: { file_id: { - type: undefined, + type: SlackTypes.list_id, description: "List title", title: "List title", }, diff --git a/src/schema/slack/functions/update_list_record.ts b/src/schema/slack/functions/update_list_record.ts index 950efc1f..e8f078b2 100644 --- a/src/schema/slack/functions/update_list_record.ts +++ b/src/schema/slack/functions/update_list_record.ts @@ -1,6 +1,7 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ import { DefineFunction } from "../../../functions/mod.ts"; import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; export default DefineFunction({ callback_id: "slack#/functions/update_list_record", @@ -9,7 +10,7 @@ export default DefineFunction({ input_parameters: { properties: { list_id: { - type: undefined, + type: SlackTypes.list_id, description: "Select a list", title: "Select a list", }, diff --git a/src/schema/slack/functions/update_list_record_test.ts b/src/schema/slack/functions/update_list_record_test.ts index 73555ea8..2ddc4e97 100644 --- a/src/schema/slack/functions/update_list_record_test.ts +++ b/src/schema/slack/functions/update_list_record_test.ts @@ -7,6 +7,7 @@ import { import { DefineWorkflow } from "../../../workflows/mod.ts"; import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts"; import SchemaTypes from "../../schema_types.ts"; +import SlackTypes from "../schema_types.ts"; import UpdateListRecord from "./update_list_record.ts"; Deno.test("UpdateListRecord generates valid FunctionManifest", () => { @@ -20,7 +21,7 @@ Deno.test("UpdateListRecord generates valid FunctionManifest", () => { input_parameters: { properties: { list_id: { - type: undefined, + type: SlackTypes.list_id, description: "Select a list", title: "Select a list", }, diff --git a/src/schema/slack/types/mod.ts b/src/schema/slack/types/mod.ts index 80495399..dd7086d6 100644 --- a/src/schema/slack/types/mod.ts +++ b/src/schema/slack/types/mod.ts @@ -6,6 +6,7 @@ const SlackPrimitiveTypes = { date: "slack#/types/date", expanded_rich_text: "slack#/types/expanded_rich_text", file_id: "slack#/types/file_id", + list_id: "slack#/types/list_id", message_ts: "slack#/types/message_ts", oauth2: "slack#/types/credential/oauth2", rich_text: "slack#/types/rich_text", From 74e6d9ebba4307311e7f062dc3fd920f965b1908 Mon Sep 17 00:00:00 2001 From: Filip Maj Date: Fri, 6 Sep 2024 15:04:07 -0400 Subject: [PATCH 4/4] deno fmt --- .../functions/_scripts/src/templates/template_function.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/schema/slack/functions/_scripts/src/templates/template_function.ts b/src/schema/slack/functions/_scripts/src/templates/template_function.ts index 2354d56b..ccc1f00a 100644 --- a/src/schema/slack/functions/_scripts/src/templates/template_function.ts +++ b/src/schema/slack/functions/_scripts/src/templates/template_function.ts @@ -75,7 +75,9 @@ const propertyToTypeScript = ( const typescript = []; const sdkType = schemaTypeMap[property.type]; if (!sdkType) { - throw new Error(`Unrecognized type "${property.type}"! Maybe a new automation platform type was recently introduced? If so, add it to one of the type files under src/schema.`); + throw new Error( + `Unrecognized type "${property.type}"! Maybe a new automation platform type was recently introduced? If so, add it to one of the type files under src/schema.`, + ); } typescript.push( `type: ${sdkType}`,