From fef25e8ed209652e069533dc0c93e63a05d01ad4 Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Tue, 14 Nov 2023 10:46:21 -0500 Subject: [PATCH] Type file id with builtins (#241) * Add new type and update builtins * Improve robustness of generated tests --- src/dev_deps.ts | 1 + .../_scripts/src/templates/test_template.ts | 6 +-- src/schema/slack/functions/add_pin.ts | 7 ++- src/schema/slack/functions/add_pin_test.ts | 11 ++-- .../slack/functions/add_user_to_usergroup.ts | 4 +- .../functions/add_user_to_usergroup_test.ts | 12 +++-- src/schema/slack/functions/archive_channel.ts | 1 - .../slack/functions/archive_channel_test.ts | 9 ++-- src/schema/slack/functions/create_channel.ts | 1 - .../slack/functions/create_channel_test.ts | 9 ++-- .../slack/functions/create_usergroup.ts | 2 +- .../slack/functions/create_usergroup_test.ts | 10 ++-- src/schema/slack/functions/delay.ts | 4 +- src/schema/slack/functions/delay_test.ts | 8 +-- .../slack/functions/invite_user_to_channel.ts | 4 +- .../functions/invite_user_to_channel_test.ts | 12 +++-- src/schema/slack/functions/mod.ts | 2 +- src/schema/slack/functions/open_form.ts | 27 ++++++++-- src/schema/slack/functions/open_form_test.ts | 38 +++++++++++-- .../functions/remove_user_from_usergroup.ts | 4 +- .../remove_user_from_usergroup_test.ts | 12 +++-- src/schema/slack/functions/reply_in_thread.ts | 41 ++++++++++++-- .../slack/functions/reply_in_thread_test.ts | 53 +++++++++++++++++-- src/schema/slack/functions/send_dm.ts | 27 ++++++++-- src/schema/slack/functions/send_dm_test.ts | 37 +++++++++++-- .../slack/functions/send_ephemeral_message.ts | 5 +- .../functions/send_ephemeral_message_test.ts | 15 +++--- src/schema/slack/functions/send_message.ts | 27 ++++++++-- .../slack/functions/send_message_test.ts | 37 +++++++++++-- .../slack/functions/update_channel_topic.ts | 4 +- .../functions/update_channel_topic_test.ts | 12 +++-- src/schema/slack/types/mod.ts | 1 + 32 files changed, 347 insertions(+), 96 deletions(-) diff --git a/src/dev_deps.ts b/src/dev_deps.ts index 8823642b..16496106 100644 --- a/src/dev_deps.ts +++ b/src/dev_deps.ts @@ -4,6 +4,7 @@ export { assertInstanceOf, AssertionError, assertMatch, + assertNotStrictEquals, assertRejects, assertStrictEquals, assertStringIncludes, diff --git a/src/schema/slack/functions/_scripts/src/templates/test_template.ts b/src/schema/slack/functions/_scripts/src/templates/test_template.ts index 831f253f..fbd69bce 100644 --- a/src/schema/slack/functions/_scripts/src/templates/test_template.ts +++ b/src/schema/slack/functions/_scripts/src/templates/test_template.ts @@ -33,7 +33,7 @@ const renderFunctionManifestTest = ( ); typescript.push(`const actual = ${functionName}.export();`); typescript.push(""); - typescript.push(`assertEquals(actual, expected);`); + typescript.push(`assertNotStrictEquals(actual, expected);`); return `() => {${typescript.join("\n")}}`; }; @@ -114,7 +114,7 @@ export function SlackTestFunctionTemplate( const typescript: string[] = []; typescript.push(autogeneratedComment()); typescript.push( - `import { assertEquals } from "../../../dev_deps.ts";`, + `import { assertEquals, assertNotStrictEquals } from "../../../dev_deps.ts";`, ); typescript.push( `import { DefineWorkflow } from "../../../workflows/mod.ts";`, @@ -142,7 +142,7 @@ export function SlackTestFunctionTemplate( } typescript[1] = - `import { assertEquals, assertExists } from "../../../dev_deps.ts";`; + `import { assertEquals, assertNotStrictEquals, assertExists } from "../../../dev_deps.ts";`; typescript.push(""); typescript.push( `Deno.test("All outputs of Slack function ${functionName} should exist", ${ diff --git a/src/schema/slack/functions/add_pin.ts b/src/schema/slack/functions/add_pin.ts index 4e7c714c..2b48f36c 100644 --- a/src/schema/slack/functions/add_pin.ts +++ b/src/schema/slack/functions/add_pin.ts @@ -6,8 +6,7 @@ import SlackTypes from "../schema_types.ts"; export default DefineFunction({ callback_id: "slack#/functions/add_pin", source_file: "", - title: "Pin to channel", - description: "Pin a message to a channel", + title: "Pin a message", input_parameters: { properties: { channel_id: { @@ -17,8 +16,8 @@ export default DefineFunction({ }, message: { type: SchemaTypes.string, - description: "Enter a message URL or message timestamp", - title: "Message URL or message timestamp", + description: "Enter a message link or message timestamp", + title: "Message link or message timestamp", }, }, required: ["channel_id", "message"], diff --git a/src/schema/slack/functions/add_pin_test.ts b/src/schema/slack/functions/add_pin_test.ts index c08c58d8..9674c7a1 100644 --- a/src/schema/slack/functions/add_pin_test.ts +++ b/src/schema/slack/functions/add_pin_test.ts @@ -1,5 +1,5 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals } from "../../../dev_deps.ts"; +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"; @@ -10,8 +10,7 @@ Deno.test("AddPin generates valid FunctionManifest", () => { assertEquals(AddPin.definition.callback_id, "slack#/functions/add_pin"); const expected: ManifestFunctionSchema = { source_file: "", - title: "Pin to channel", - description: "Pin a message to a channel", + title: "Pin a message", input_parameters: { properties: { channel_id: { @@ -21,8 +20,8 @@ Deno.test("AddPin generates valid FunctionManifest", () => { }, message: { type: SchemaTypes.string, - description: "Enter a message URL or message timestamp", - title: "Message URL or message timestamp", + description: "Enter a message link or message timestamp", + title: "Message link or message timestamp", }, }, required: ["channel_id", "message"], @@ -31,7 +30,7 @@ Deno.test("AddPin generates valid FunctionManifest", () => { }; const actual = AddPin.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("AddPin can be used as a Slack function in a workflow step", () => { diff --git a/src/schema/slack/functions/add_user_to_usergroup.ts b/src/schema/slack/functions/add_user_to_usergroup.ts index 5218e908..5d572852 100644 --- a/src/schema/slack/functions/add_user_to_usergroup.ts +++ b/src/schema/slack/functions/add_user_to_usergroup.ts @@ -6,8 +6,8 @@ import SlackTypes from "../schema_types.ts"; export default DefineFunction({ callback_id: "slack#/functions/add_user_to_usergroup", source_file: "", - title: "Add to user group", - description: "Add someone to a user group.", + title: "Add people to a user group", + description: "Additional permissions might be required", input_parameters: { properties: { usergroup_id: { diff --git a/src/schema/slack/functions/add_user_to_usergroup_test.ts b/src/schema/slack/functions/add_user_to_usergroup_test.ts index d4a2e02c..6d190a39 100644 --- a/src/schema/slack/functions/add_user_to_usergroup_test.ts +++ b/src/schema/slack/functions/add_user_to_usergroup_test.ts @@ -1,5 +1,9 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals, assertExists } from "../../../dev_deps.ts"; +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"; @@ -13,8 +17,8 @@ Deno.test("AddUserToUsergroup generates valid FunctionManifest", () => { ); const expected: ManifestFunctionSchema = { source_file: "", - title: "Add to user group", - description: "Add someone to a user group.", + title: "Add people to a user group", + description: "Additional permissions might be required", input_parameters: { properties: { usergroup_id: { @@ -44,7 +48,7 @@ Deno.test("AddUserToUsergroup generates valid FunctionManifest", () => { }; const actual = AddUserToUsergroup.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("AddUserToUsergroup can be used as a Slack function in a workflow step", () => { diff --git a/src/schema/slack/functions/archive_channel.ts b/src/schema/slack/functions/archive_channel.ts index d47dadd3..89edbd25 100644 --- a/src/schema/slack/functions/archive_channel.ts +++ b/src/schema/slack/functions/archive_channel.ts @@ -6,7 +6,6 @@ export default DefineFunction({ callback_id: "slack#/functions/archive_channel", source_file: "", title: "Archive a channel", - description: "Archive a Slack channel", input_parameters: { properties: { channel_id: { diff --git a/src/schema/slack/functions/archive_channel_test.ts b/src/schema/slack/functions/archive_channel_test.ts index 5da9663a..9d4fbc92 100644 --- a/src/schema/slack/functions/archive_channel_test.ts +++ b/src/schema/slack/functions/archive_channel_test.ts @@ -1,5 +1,9 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals, assertExists } from "../../../dev_deps.ts"; +import { + assertEquals, + assertExists, + assertNotStrictEquals, +} from "../../../dev_deps.ts"; import { DefineWorkflow } from "../../../workflows/mod.ts"; import { ManifestFunctionSchema } from "../../../manifest/manifest_schema.ts"; import SlackTypes from "../schema_types.ts"; @@ -13,7 +17,6 @@ Deno.test("ArchiveChannel generates valid FunctionManifest", () => { const expected: ManifestFunctionSchema = { source_file: "", title: "Archive a channel", - description: "Archive a Slack channel", input_parameters: { properties: { channel_id: { @@ -37,7 +40,7 @@ Deno.test("ArchiveChannel generates valid FunctionManifest", () => { }; const actual = ArchiveChannel.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("ArchiveChannel can be used as a Slack function in a workflow step", () => { diff --git a/src/schema/slack/functions/create_channel.ts b/src/schema/slack/functions/create_channel.ts index b876e81d..4a9e4b49 100644 --- a/src/schema/slack/functions/create_channel.ts +++ b/src/schema/slack/functions/create_channel.ts @@ -7,7 +7,6 @@ export default DefineFunction({ callback_id: "slack#/functions/create_channel", source_file: "", title: "Create a channel", - description: "Create a Slack channel", input_parameters: { properties: { channel_name: { diff --git a/src/schema/slack/functions/create_channel_test.ts b/src/schema/slack/functions/create_channel_test.ts index 8709f2b1..c0bc524e 100644 --- a/src/schema/slack/functions/create_channel_test.ts +++ b/src/schema/slack/functions/create_channel_test.ts @@ -1,5 +1,9 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals, assertExists } from "../../../dev_deps.ts"; +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"; @@ -14,7 +18,6 @@ Deno.test("CreateChannel generates valid FunctionManifest", () => { const expected: ManifestFunctionSchema = { source_file: "", title: "Create a channel", - description: "Create a Slack channel", input_parameters: { properties: { channel_name: { @@ -55,7 +58,7 @@ Deno.test("CreateChannel generates valid FunctionManifest", () => { }; const actual = CreateChannel.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("CreateChannel can be used as a Slack function in a workflow step", () => { diff --git a/src/schema/slack/functions/create_usergroup.ts b/src/schema/slack/functions/create_usergroup.ts index 382fd9b1..70fd7c6b 100644 --- a/src/schema/slack/functions/create_usergroup.ts +++ b/src/schema/slack/functions/create_usergroup.ts @@ -7,7 +7,7 @@ export default DefineFunction({ callback_id: "slack#/functions/create_usergroup", source_file: "", title: "Create a user group", - description: "Create a Slack user group", + description: "Additional permissions might be required", input_parameters: { properties: { usergroup_handle: { diff --git a/src/schema/slack/functions/create_usergroup_test.ts b/src/schema/slack/functions/create_usergroup_test.ts index b4cb2926..cf1ec5a8 100644 --- a/src/schema/slack/functions/create_usergroup_test.ts +++ b/src/schema/slack/functions/create_usergroup_test.ts @@ -1,5 +1,9 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals, assertExists } from "../../../dev_deps.ts"; +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"; @@ -14,7 +18,7 @@ Deno.test("CreateUsergroup generates valid FunctionManifest", () => { const expected: ManifestFunctionSchema = { source_file: "", title: "Create a user group", - description: "Create a Slack user group", + description: "Additional permissions might be required", input_parameters: { properties: { usergroup_handle: { @@ -43,7 +47,7 @@ Deno.test("CreateUsergroup generates valid FunctionManifest", () => { }; const actual = CreateUsergroup.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("CreateUsergroup can be used as a Slack function in a workflow step", () => { diff --git a/src/schema/slack/functions/delay.ts b/src/schema/slack/functions/delay.ts index 5f6c63fb..b4581ef1 100644 --- a/src/schema/slack/functions/delay.ts +++ b/src/schema/slack/functions/delay.ts @@ -5,8 +5,8 @@ import SchemaTypes from "../../schema_types.ts"; export default DefineFunction({ callback_id: "slack#/functions/delay", source_file: "", - title: "Delay", - description: "Pause the workflow for a set amount of time", + title: "Delay this workflow", + description: "Pauses the workflow at this step", input_parameters: { properties: { minutes_to_delay: { diff --git a/src/schema/slack/functions/delay_test.ts b/src/schema/slack/functions/delay_test.ts index e6fd5c50..264c1ef5 100644 --- a/src/schema/slack/functions/delay_test.ts +++ b/src/schema/slack/functions/delay_test.ts @@ -1,5 +1,5 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals } from "../../../dev_deps.ts"; +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"; @@ -9,8 +9,8 @@ Deno.test("Delay generates valid FunctionManifest", () => { assertEquals(Delay.definition.callback_id, "slack#/functions/delay"); const expected: ManifestFunctionSchema = { source_file: "", - title: "Delay", - description: "Pause the workflow for a set amount of time", + title: "Delay this workflow", + description: "Pauses the workflow at this step", input_parameters: { properties: { minutes_to_delay: { @@ -25,7 +25,7 @@ Deno.test("Delay generates valid FunctionManifest", () => { }; const actual = Delay.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("Delay can be used as a Slack function in a workflow step", () => { diff --git a/src/schema/slack/functions/invite_user_to_channel.ts b/src/schema/slack/functions/invite_user_to_channel.ts index cde840f3..5c048940 100644 --- a/src/schema/slack/functions/invite_user_to_channel.ts +++ b/src/schema/slack/functions/invite_user_to_channel.ts @@ -6,9 +6,9 @@ import SlackTypes from "../schema_types.ts"; export default DefineFunction({ callback_id: "slack#/functions/invite_user_to_channel", source_file: "", - title: "Invite to channel", + title: "Add people to a channel", description: - "Invite someone to a channel. This will only work if this workflow created the channel.", + "You or the people using the workflow must have permission to invite others to the channel", input_parameters: { properties: { channel_ids: { diff --git a/src/schema/slack/functions/invite_user_to_channel_test.ts b/src/schema/slack/functions/invite_user_to_channel_test.ts index 6c7a4951..86d05de0 100644 --- a/src/schema/slack/functions/invite_user_to_channel_test.ts +++ b/src/schema/slack/functions/invite_user_to_channel_test.ts @@ -1,5 +1,9 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals, assertExists } from "../../../dev_deps.ts"; +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"; @@ -13,9 +17,9 @@ Deno.test("InviteUserToChannel generates valid FunctionManifest", () => { ); const expected: ManifestFunctionSchema = { source_file: "", - title: "Invite to channel", + title: "Add people to a channel", description: - "Invite someone to a channel. This will only work if this workflow created the channel.", + "You or the people using the workflow must have permission to invite others to the channel", input_parameters: { properties: { channel_ids: { @@ -47,7 +51,7 @@ Deno.test("InviteUserToChannel generates valid FunctionManifest", () => { }; const actual = InviteUserToChannel.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("InviteUserToChannel can be used as a Slack function in a workflow step", () => { diff --git a/src/schema/slack/functions/mod.ts b/src/schema/slack/functions/mod.ts index 6cd4c1ed..ceb864d8 100644 --- a/src/schema/slack/functions/mod.ts +++ b/src/schema/slack/functions/mod.ts @@ -1,4 +1,4 @@ -/** This file was autogenerated on Thu Sep 07 2023. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +/** This file was autogenerated on Thu Nov 02 2023. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ import AddPin from "./add_pin.ts"; import AddUserToUsergroup from "./add_user_to_usergroup.ts"; import ArchiveChannel from "./archive_channel.ts"; diff --git a/src/schema/slack/functions/open_form.ts b/src/schema/slack/functions/open_form.ts index afd8824f..3a119cf0 100644 --- a/src/schema/slack/functions/open_form.ts +++ b/src/schema/slack/functions/open_form.ts @@ -7,8 +7,8 @@ import { InternalSlackTypes } from "../types/custom/mod.ts"; export default DefineFunction({ callback_id: "slack#/functions/open_form", source_file: "", - title: "Open a form", - description: "Opens a form for the user", + title: "Collect info in a form", + description: "Uses a form to collect information", input_parameters: { properties: { title: { @@ -52,7 +52,28 @@ export default DefineFunction({ description: "Context about the form submit action interactive event", title: "interactivity", }, + submit_user: { + type: SlackTypes.user_id, + description: "Person who submitted the form", + title: "Person who submitted the form", + }, + timestamp_started: { + type: SlackTypes.timestamp, + description: "Time when step started", + title: "Time when step started", + }, + timestamp_completed: { + type: SlackTypes.timestamp, + description: "Time when step ended", + title: "Time when step ended", + }, }, - required: ["fields", "interactivity"], + required: [ + "fields", + "interactivity", + "submit_user", + "timestamp_started", + "timestamp_completed", + ], }, }); diff --git a/src/schema/slack/functions/open_form_test.ts b/src/schema/slack/functions/open_form_test.ts index 2f27b565..e4ecebe3 100644 --- a/src/schema/slack/functions/open_form_test.ts +++ b/src/schema/slack/functions/open_form_test.ts @@ -1,5 +1,9 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals, assertExists } from "../../../dev_deps.ts"; +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"; @@ -11,8 +15,8 @@ Deno.test("OpenForm generates valid FunctionManifest", () => { assertEquals(OpenForm.definition.callback_id, "slack#/functions/open_form"); const expected: ManifestFunctionSchema = { source_file: "", - title: "Open a form", - description: "Opens a form for the user", + title: "Collect info in a form", + description: "Uses a form to collect information", input_parameters: { properties: { title: { @@ -56,13 +60,34 @@ Deno.test("OpenForm generates valid FunctionManifest", () => { description: "Context about the form submit action interactive event", title: "interactivity", }, + submit_user: { + type: SlackTypes.user_id, + description: "Person who submitted the form", + title: "Person who submitted the form", + }, + timestamp_started: { + type: SlackTypes.timestamp, + description: "Time when step started", + title: "Time when step started", + }, + timestamp_completed: { + type: SlackTypes.timestamp, + description: "Time when step ended", + title: "Time when step ended", + }, }, - required: ["fields", "interactivity"], + required: [ + "fields", + "interactivity", + "submit_user", + "timestamp_started", + "timestamp_completed", + ], }, }; const actual = OpenForm.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("OpenForm can be used as a Slack function in a workflow step", () => { @@ -99,4 +124,7 @@ Deno.test("All outputs of Slack function OpenForm should exist", () => { }); assertExists(step.outputs.fields); assertExists(step.outputs.interactivity); + assertExists(step.outputs.submit_user); + assertExists(step.outputs.timestamp_started); + assertExists(step.outputs.timestamp_completed); }); diff --git a/src/schema/slack/functions/remove_user_from_usergroup.ts b/src/schema/slack/functions/remove_user_from_usergroup.ts index 9891ee0c..8167b466 100644 --- a/src/schema/slack/functions/remove_user_from_usergroup.ts +++ b/src/schema/slack/functions/remove_user_from_usergroup.ts @@ -6,8 +6,8 @@ import SlackTypes from "../schema_types.ts"; export default DefineFunction({ callback_id: "slack#/functions/remove_user_from_usergroup", source_file: "", - title: "Remove from a user group", - description: "Remove someone from a user group", + title: "Remove someone from a user group", + description: "Additional permissions might be required", input_parameters: { properties: { usergroup_id: { diff --git a/src/schema/slack/functions/remove_user_from_usergroup_test.ts b/src/schema/slack/functions/remove_user_from_usergroup_test.ts index ffefa4f0..e66c38b6 100644 --- a/src/schema/slack/functions/remove_user_from_usergroup_test.ts +++ b/src/schema/slack/functions/remove_user_from_usergroup_test.ts @@ -1,5 +1,9 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals, assertExists } from "../../../dev_deps.ts"; +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"; @@ -13,8 +17,8 @@ Deno.test("RemoveUserFromUsergroup generates valid FunctionManifest", () => { ); const expected: ManifestFunctionSchema = { source_file: "", - title: "Remove from a user group", - description: "Remove someone from a user group", + title: "Remove someone from a user group", + description: "Additional permissions might be required", input_parameters: { properties: { usergroup_id: { @@ -44,7 +48,7 @@ Deno.test("RemoveUserFromUsergroup generates valid FunctionManifest", () => { }; const actual = RemoveUserFromUsergroup.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("RemoveUserFromUsergroup can be used as a Slack function in a workflow step", () => { diff --git a/src/schema/slack/functions/reply_in_thread.ts b/src/schema/slack/functions/reply_in_thread.ts index 887f6b89..b4afefc0 100644 --- a/src/schema/slack/functions/reply_in_thread.ts +++ b/src/schema/slack/functions/reply_in_thread.ts @@ -6,8 +6,7 @@ import SlackTypes from "../schema_types.ts"; export default DefineFunction({ callback_id: "slack#/functions/reply_in_thread", source_file: "", - title: "Reply in thread", - description: "Send a message in a thread", + title: "Reply to a message in thread", input_parameters: { properties: { message_context: { @@ -37,6 +36,17 @@ export default DefineFunction({ additionalProperties: true, required: ["event_type", "event_payload"], }, + interactive_blocks: { + type: SlackTypes.blocks, + description: "Button(s) to send with the message", + title: "Button(s) to send with the message", + }, + files: { + type: SchemaTypes.array, + description: "File(s) to attach to the message", + title: "File(s) to attach to the message", + items: { type: SlackTypes.file_id }, + }, }, required: ["message_context", "message"], }, @@ -52,7 +62,32 @@ export default DefineFunction({ description: "Message link", title: "Message link", }, + action: { + type: SchemaTypes.object, + description: "Button interactivity data", + title: "Button interactivity data", + }, + interactivity: { + type: SlackTypes.interactivity, + description: "Interactivity context", + title: "interactivity", + }, + timestamp_started: { + type: SlackTypes.timestamp, + description: "Time when step started", + title: "Time when step started", + }, + timestamp_completed: { + type: SlackTypes.timestamp, + description: "Time when step ended", + title: "Time when step ended", + }, }, - required: ["message_context", "message_link"], + required: [ + "message_context", + "message_link", + "timestamp_started", + "timestamp_completed", + ], }, }); diff --git a/src/schema/slack/functions/reply_in_thread_test.ts b/src/schema/slack/functions/reply_in_thread_test.ts index 7997a166..ebe70ba8 100644 --- a/src/schema/slack/functions/reply_in_thread_test.ts +++ b/src/schema/slack/functions/reply_in_thread_test.ts @@ -1,5 +1,9 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals, assertExists } from "../../../dev_deps.ts"; +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"; @@ -13,8 +17,7 @@ Deno.test("ReplyInThread generates valid FunctionManifest", () => { ); const expected: ManifestFunctionSchema = { source_file: "", - title: "Reply in thread", - description: "Send a message in a thread", + title: "Reply to a message in thread", input_parameters: { properties: { message_context: { @@ -44,6 +47,17 @@ Deno.test("ReplyInThread generates valid FunctionManifest", () => { additionalProperties: true, required: ["event_type", "event_payload"], }, + interactive_blocks: { + type: SlackTypes.blocks, + description: "Button(s) to send with the message", + title: "Button(s) to send with the message", + }, + files: { + type: SchemaTypes.array, + description: "File(s) to attach to the message", + title: "File(s) to attach to the message", + items: { type: SlackTypes.file_id }, + }, }, required: ["message_context", "message"], }, @@ -59,13 +73,38 @@ Deno.test("ReplyInThread generates valid FunctionManifest", () => { description: "Message link", title: "Message link", }, + action: { + type: SchemaTypes.object, + description: "Button interactivity data", + title: "Button interactivity data", + }, + interactivity: { + type: SlackTypes.interactivity, + description: "Interactivity context", + title: "interactivity", + }, + timestamp_started: { + type: SlackTypes.timestamp, + description: "Time when step started", + title: "Time when step started", + }, + timestamp_completed: { + type: SlackTypes.timestamp, + description: "Time when step ended", + title: "Time when step ended", + }, }, - required: ["message_context", "message_link"], + required: [ + "message_context", + "message_link", + "timestamp_started", + "timestamp_completed", + ], }, }; const actual = ReplyInThread.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("ReplyInThread can be used as a Slack function in a workflow step", () => { @@ -96,4 +135,8 @@ Deno.test("All outputs of Slack function ReplyInThread should exist", () => { }); assertExists(step.outputs.message_context); assertExists(step.outputs.message_link); + assertExists(step.outputs.action); + assertExists(step.outputs.interactivity); + assertExists(step.outputs.timestamp_started); + assertExists(step.outputs.timestamp_completed); }); diff --git a/src/schema/slack/functions/send_dm.ts b/src/schema/slack/functions/send_dm.ts index d2ae2326..585ab818 100644 --- a/src/schema/slack/functions/send_dm.ts +++ b/src/schema/slack/functions/send_dm.ts @@ -6,8 +6,7 @@ import SlackTypes from "../schema_types.ts"; export default DefineFunction({ callback_id: "slack#/functions/send_dm", source_file: "", - title: "Send a direct message", - description: "Send a direct message to someone", + title: "Send a message to a person", input_parameters: { properties: { user_id: { @@ -25,6 +24,12 @@ export default DefineFunction({ description: "Button(s) to send with the message", title: "Button(s) to send with the message", }, + files: { + type: SchemaTypes.array, + description: "File(s) to attach to the message", + title: "File(s) to attach to the message", + items: { type: SlackTypes.file_id }, + }, }, required: ["user_id", "message"], }, @@ -55,7 +60,23 @@ export default DefineFunction({ description: "Reference to the message sent", title: "Reference to the message sent", }, + timestamp_started: { + type: SlackTypes.timestamp, + description: "Time when step started", + title: "Time when step started", + }, + timestamp_completed: { + type: SlackTypes.timestamp, + description: "Time when step ended", + title: "Time when step ended", + }, }, - required: ["message_timestamp", "message_link", "message_context"], + required: [ + "message_timestamp", + "message_link", + "message_context", + "timestamp_started", + "timestamp_completed", + ], }, }); diff --git a/src/schema/slack/functions/send_dm_test.ts b/src/schema/slack/functions/send_dm_test.ts index e65a72be..eaa536e2 100644 --- a/src/schema/slack/functions/send_dm_test.ts +++ b/src/schema/slack/functions/send_dm_test.ts @@ -1,5 +1,9 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals, assertExists } from "../../../dev_deps.ts"; +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"; @@ -10,8 +14,7 @@ Deno.test("SendDm generates valid FunctionManifest", () => { assertEquals(SendDm.definition.callback_id, "slack#/functions/send_dm"); const expected: ManifestFunctionSchema = { source_file: "", - title: "Send a direct message", - description: "Send a direct message to someone", + title: "Send a message to a person", input_parameters: { properties: { user_id: { @@ -29,6 +32,12 @@ Deno.test("SendDm generates valid FunctionManifest", () => { description: "Button(s) to send with the message", title: "Button(s) to send with the message", }, + files: { + type: SchemaTypes.array, + description: "File(s) to attach to the message", + title: "File(s) to attach to the message", + items: { type: SlackTypes.file_id }, + }, }, required: ["user_id", "message"], }, @@ -59,13 +68,29 @@ Deno.test("SendDm generates valid FunctionManifest", () => { description: "Reference to the message sent", title: "Reference to the message sent", }, + timestamp_started: { + type: SlackTypes.timestamp, + description: "Time when step started", + title: "Time when step started", + }, + timestamp_completed: { + type: SlackTypes.timestamp, + description: "Time when step ended", + title: "Time when step ended", + }, }, - required: ["message_timestamp", "message_link", "message_context"], + required: [ + "message_timestamp", + "message_link", + "message_context", + "timestamp_started", + "timestamp_completed", + ], }, }; const actual = SendDm.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("SendDm can be used as a Slack function in a workflow step", () => { @@ -96,4 +121,6 @@ Deno.test("All outputs of Slack function SendDm should exist", () => { assertExists(step.outputs.action); assertExists(step.outputs.interactivity); assertExists(step.outputs.message_context); + assertExists(step.outputs.timestamp_started); + assertExists(step.outputs.timestamp_completed); }); diff --git a/src/schema/slack/functions/send_ephemeral_message.ts b/src/schema/slack/functions/send_ephemeral_message.ts index 12ffe02e..44d64071 100644 --- a/src/schema/slack/functions/send_ephemeral_message.ts +++ b/src/schema/slack/functions/send_ephemeral_message.ts @@ -6,8 +6,9 @@ import SlackTypes from "../schema_types.ts"; export default DefineFunction({ callback_id: "slack#/functions/send_ephemeral_message", source_file: "", - title: "Send an ephemeral message", - description: "Send a private message to someone in a channel", + title: 'Send an "only visible to you" message', + description: + "Send a temporary message to someone in a channel that only they can see", input_parameters: { properties: { channel_id: { diff --git a/src/schema/slack/functions/send_ephemeral_message_test.ts b/src/schema/slack/functions/send_ephemeral_message_test.ts index a33d46f7..0ae0f741 100644 --- a/src/schema/slack/functions/send_ephemeral_message_test.ts +++ b/src/schema/slack/functions/send_ephemeral_message_test.ts @@ -1,5 +1,9 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals, assertExists } from "../../../dev_deps.ts"; +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"; @@ -13,8 +17,9 @@ Deno.test("SendEphemeralMessage generates valid FunctionManifest", () => { ); const expected: ManifestFunctionSchema = { source_file: "", - title: "Send an ephemeral message", - description: "Send a private message to someone in a channel", + title: 'Send an "only visible to you" message', + description: + "Send a temporary message to someone in a channel that only they can see", input_parameters: { properties: { channel_id: { @@ -32,7 +37,6 @@ Deno.test("SendEphemeralMessage generates valid FunctionManifest", () => { description: "Add a message", title: "Add a message", }, - // thread_ts will be removed, maybe, in a future change. ask @shapirone if in doubt thread_ts: { type: SchemaTypes.string, description: @@ -44,7 +48,6 @@ Deno.test("SendEphemeralMessage generates valid FunctionManifest", () => { }, output_parameters: { properties: { - // message_ts will be renamed message_timestamp.. soon. ask @shapirone for more info message_ts: { type: SlackTypes.message_ts, description: "Message time stamp", @@ -56,7 +59,7 @@ Deno.test("SendEphemeralMessage generates valid FunctionManifest", () => { }; const actual = SendEphemeralMessage.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("SendEphemeralMessage can be used as a Slack function in a workflow step", () => { diff --git a/src/schema/slack/functions/send_message.ts b/src/schema/slack/functions/send_message.ts index 6e883511..7becb038 100644 --- a/src/schema/slack/functions/send_message.ts +++ b/src/schema/slack/functions/send_message.ts @@ -6,8 +6,7 @@ import SlackTypes from "../schema_types.ts"; export default DefineFunction({ callback_id: "slack#/functions/send_message", source_file: "", - title: "Send a message to channel", - description: "Send a message to channel", + title: "Send a message to a channel", input_parameters: { properties: { channel_id: { @@ -37,6 +36,12 @@ export default DefineFunction({ description: "Button(s) to send with the message", title: "Button(s) to send with the message", }, + files: { + type: SchemaTypes.array, + description: "File(s) to attach to the message", + title: "File(s) to attach to the message", + items: { type: SlackTypes.file_id }, + }, }, required: ["channel_id", "message"], }, @@ -67,7 +72,23 @@ export default DefineFunction({ description: "Reference to the message sent", title: "Reference to the message sent", }, + timestamp_started: { + type: SlackTypes.timestamp, + description: "Time when step started", + title: "Time when step started", + }, + timestamp_completed: { + type: SlackTypes.timestamp, + description: "Time when step ended", + title: "Time when step ended", + }, }, - required: ["message_timestamp", "message_link", "message_context"], + required: [ + "message_timestamp", + "message_link", + "message_context", + "timestamp_started", + "timestamp_completed", + ], }, }); diff --git a/src/schema/slack/functions/send_message_test.ts b/src/schema/slack/functions/send_message_test.ts index 968cffc3..e4c2943a 100644 --- a/src/schema/slack/functions/send_message_test.ts +++ b/src/schema/slack/functions/send_message_test.ts @@ -1,5 +1,9 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals, assertExists } from "../../../dev_deps.ts"; +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"; @@ -13,8 +17,7 @@ Deno.test("SendMessage generates valid FunctionManifest", () => { ); const expected: ManifestFunctionSchema = { source_file: "", - title: "Send a message to channel", - description: "Send a message to channel", + title: "Send a message to a channel", input_parameters: { properties: { channel_id: { @@ -44,6 +47,12 @@ Deno.test("SendMessage generates valid FunctionManifest", () => { description: "Button(s) to send with the message", title: "Button(s) to send with the message", }, + files: { + type: SchemaTypes.array, + description: "File(s) to attach to the message", + title: "File(s) to attach to the message", + items: { type: SlackTypes.file_id }, + }, }, required: ["channel_id", "message"], }, @@ -74,13 +83,29 @@ Deno.test("SendMessage generates valid FunctionManifest", () => { description: "Reference to the message sent", title: "Reference to the message sent", }, + timestamp_started: { + type: SlackTypes.timestamp, + description: "Time when step started", + title: "Time when step started", + }, + timestamp_completed: { + type: SlackTypes.timestamp, + description: "Time when step ended", + title: "Time when step ended", + }, }, - required: ["message_timestamp", "message_link", "message_context"], + required: [ + "message_timestamp", + "message_link", + "message_context", + "timestamp_started", + "timestamp_completed", + ], }, }; const actual = SendMessage.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("SendMessage can be used as a Slack function in a workflow step", () => { @@ -111,4 +136,6 @@ Deno.test("All outputs of Slack function SendMessage should exist", () => { assertExists(step.outputs.action); assertExists(step.outputs.interactivity); assertExists(step.outputs.message_context); + assertExists(step.outputs.timestamp_started); + assertExists(step.outputs.timestamp_completed); }); diff --git a/src/schema/slack/functions/update_channel_topic.ts b/src/schema/slack/functions/update_channel_topic.ts index 76f05ff2..35c3cb0c 100644 --- a/src/schema/slack/functions/update_channel_topic.ts +++ b/src/schema/slack/functions/update_channel_topic.ts @@ -6,9 +6,9 @@ import SlackTypes from "../schema_types.ts"; export default DefineFunction({ callback_id: "slack#/functions/update_channel_topic", source_file: "", - title: "Update channel topic", + title: "Update the channel topic", description: - "Update the topic of a specific channel. This will work only if this workflow created the channel.", + "You or the people using the workflow must be members of the channel", input_parameters: { properties: { channel_id: { diff --git a/src/schema/slack/functions/update_channel_topic_test.ts b/src/schema/slack/functions/update_channel_topic_test.ts index 3cf4981e..824c833a 100644 --- a/src/schema/slack/functions/update_channel_topic_test.ts +++ b/src/schema/slack/functions/update_channel_topic_test.ts @@ -1,5 +1,9 @@ /** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ -import { assertEquals, assertExists } from "../../../dev_deps.ts"; +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"; @@ -13,9 +17,9 @@ Deno.test("UpdateChannelTopic generates valid FunctionManifest", () => { ); const expected: ManifestFunctionSchema = { source_file: "", - title: "Update channel topic", + title: "Update the channel topic", description: - "Update the topic of a specific channel. This will work only if this workflow created the channel.", + "You or the people using the workflow must be members of the channel", input_parameters: { properties: { channel_id: { @@ -44,7 +48,7 @@ Deno.test("UpdateChannelTopic generates valid FunctionManifest", () => { }; const actual = UpdateChannelTopic.export(); - assertEquals(actual, expected); + assertNotStrictEquals(actual, expected); }); Deno.test("UpdateChannelTopic can be used as a Slack function in a workflow step", () => { diff --git a/src/schema/slack/types/mod.ts b/src/schema/slack/types/mod.ts index b5a7061c..b0be5b48 100644 --- a/src/schema/slack/types/mod.ts +++ b/src/schema/slack/types/mod.ts @@ -8,6 +8,7 @@ const SlackPrimitiveTypes = { oauth2: "slack#/types/credential/oauth2", rich_text: "slack#/types/rich_text", message_ts: "slack#/types/message_ts", + file_id: "slack#/types/file_id", } as const; export type ValidSlackPrimitiveTypes =