From 514c51a9e1a0b80fdd18a50a0332b75e454acc10 Mon Sep 17 00:00:00 2001 From: Rafael Amsili Date: Thu, 8 Feb 2024 12:15:55 -0800 Subject: [PATCH] Add new Canvas built in functions to the deno-sdk --- src/functions/types.ts | 4 + src/schema/slack/functions/canvas_copy.ts | 46 ++++++++ .../slack/functions/canvas_copy_test.ts | 97 +++++++++++++++++ src/schema/slack/functions/canvas_create.ts | 56 ++++++++++ .../slack/functions/canvas_create_test.ts | 97 +++++++++++++++++ .../slack/functions/canvas_update_content.ts | 56 ++++++++++ .../functions/canvas_update_content_test.ts | 100 ++++++++++++++++++ .../slack/functions/channel_canvas_create.ts | 51 +++++++++ .../functions/channel_canvas_create_test.ts | 91 ++++++++++++++++ src/schema/slack/functions/mod.ts | 12 ++- src/schema/slack/functions/share_canvas.ts | 53 ++++++++++ .../slack/functions/share_canvas_test.ts | 97 +++++++++++++++++ src/schema/slack/types/mod.ts | 3 + 13 files changed, 762 insertions(+), 1 deletion(-) create mode 100644 src/schema/slack/functions/canvas_copy.ts create mode 100644 src/schema/slack/functions/canvas_copy_test.ts create mode 100644 src/schema/slack/functions/canvas_create.ts create mode 100644 src/schema/slack/functions/canvas_create_test.ts create mode 100644 src/schema/slack/functions/canvas_update_content.ts create mode 100644 src/schema/slack/functions/canvas_update_content_test.ts create mode 100644 src/schema/slack/functions/channel_canvas_create.ts create mode 100644 src/schema/slack/functions/channel_canvas_create_test.ts create mode 100644 src/schema/slack/functions/share_canvas.ts create mode 100644 src/schema/slack/functions/share_canvas_test.ts diff --git a/src/functions/types.ts b/src/functions/types.ts index f766c1ca..86d762cb 100644 --- a/src/functions/types.ts +++ b/src/functions/types.ts @@ -77,6 +77,8 @@ type FunctionInputRuntimeType< | typeof SlackSchemaTypes.user_id | typeof SlackSchemaTypes.usergroup_id | typeof SlackSchemaTypes.channel_id + | typeof SlackSchemaTypes.canvas_id + | typeof SlackSchemaTypes.canvas_template_id | typeof SlackSchemaTypes.date | typeof SlackSchemaTypes.message_ts ? string : Param["type"] extends @@ -96,6 +98,8 @@ type FunctionInputRuntimeType< : UnknownRuntimeType : Param["type"] extends typeof SlackSchemaTypes.rich_text ? UnknownRuntimeType + : Param["type"] extends typeof SlackSchemaTypes.expanded_rich_text + ? UnknownRuntimeType : UnknownRuntimeType; // deno-lint-ignore no-explicit-any diff --git a/src/schema/slack/functions/canvas_copy.ts b/src/schema/slack/functions/canvas_copy.ts new file mode 100644 index 00000000..aeb21496 --- /dev/null +++ b/src/schema/slack/functions/canvas_copy.ts @@ -0,0 +1,46 @@ +/** 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 { SlackPrimitiveTypes } from "../../slack/types/mod.ts"; +import SlackTypes from "../schema_types.ts"; + +export default DefineFunction({ + callback_id: "slack#/functions/canvas_copy", + source_file: "", + title: "Copy a canvas", + input_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Search all canvases", + title: "Select a canvas", + }, + title: { + type: SchemaTypes.string, + description: "Enter a canvas name", + title: "Canvas name", + }, + owner_id: { + type: SlackTypes.user_id, + description: "Canvas owner id", + title: "Owner", + }, + placeholder_values: { + type: SchemaTypes.object, + description: "Variables", + title: "Variables", + }, + }, + required: ["canvas_id", "title", "owner_id"], + }, + output_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Canvas link", + title: "Canvas link", + }, + }, + required: ["canvas_id"], + }, +}); diff --git a/src/schema/slack/functions/canvas_copy_test.ts b/src/schema/slack/functions/canvas_copy_test.ts new file mode 100644 index 00000000..49402fe0 --- /dev/null +++ b/src/schema/slack/functions/canvas_copy_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 { SlackPrimitiveTypes } from "../../slack/types/mod.ts"; + +import CanvasCopy from "./canvas_copy.ts"; + +Deno.test("CanvasCopy generates valid FunctionManifest", () => { + assertEquals( + CanvasCopy.definition.callback_id, + "slack#/functions/canvas_copy", + ); + const expected: ManifestFunctionSchema = { + source_file: "", + title: "Copy a canvas", + input_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Search all canvases", + title: "Select a canvas", + }, + title: { + type: SchemaTypes.string, + description: "Enter a canvas name", + title: "Canvas name", + }, + owner_id: { + type: SlackTypes.user_id, + description: "Canvas owner id", + title: "Owner", + }, + placeholder_values: { + type: SchemaTypes.object, + description: "Variables", + title: "Variables", + }, + }, + required: ["canvas_id", "title", "owner_id"], + }, + output_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Canvas link", + title: "Canvas link", + }, + }, + required: ["canvas_id"], + }, + }; + const actual = CanvasCopy.export(); + + assertNotStrictEquals(actual, expected); +}); + +Deno.test("CanvasCopy can be used as a Slack function in a workflow step", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_CanvasCopy_slack_function", + title: "Test CanvasCopy", + description: "This is a generated test to test CanvasCopy", + }); + testWorkflow.addStep(CanvasCopy, { + canvas_id: "test", + title: "test", + owner_id: "test", + }); + const actual = testWorkflow.steps[0].export(); + + assertEquals(actual.function_id, "slack#/functions/canvas_copy"); + assertEquals(actual.inputs, { + canvas_id: "test", + title: "test", + owner_id: "test", + }); +}); + +Deno.test("All outputs of Slack function CanvasCopy should exist", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_CanvasCopy_slack_function", + title: "Test CanvasCopy", + description: "This is a generated test to test CanvasCopy", + }); + const step = testWorkflow.addStep(CanvasCopy, { + canvas_id: "test", + title: "test", + owner_id: "test", + }); + assertExists(step.outputs.canvas_id); +}); diff --git a/src/schema/slack/functions/canvas_create.ts b/src/schema/slack/functions/canvas_create.ts new file mode 100644 index 00000000..e6331555 --- /dev/null +++ b/src/schema/slack/functions/canvas_create.ts @@ -0,0 +1,56 @@ +/** 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 { SlackPrimitiveTypes } from "../../slack/types/mod.ts"; +import SlackTypes from "../schema_types.ts"; + +export default DefineFunction({ + callback_id: "slack#/functions/canvas_create", + source_file: "", + title: "Create a canvas", + input_parameters: { + properties: { + title: { + type: SchemaTypes.string, + description: "Enter a canvas name", + title: "Canvas name", + }, + canvas_create_type: { + type: SchemaTypes.string, + description: "Type of creation", + title: "Type of creation", + }, + canvas_template_id: { + type: SlackPrimitiveTypes.canvas_template_id, + description: "Select an option", + title: "Select a canvas template", + }, + owner_id: { + type: SlackTypes.user_id, + description: "Person", + title: "Canvas owner", + }, + content: { + type: SlackPrimitiveTypes.expanded_rich_text, + description: "Add content to the canvas", + title: "Add content", + }, + placeholder_values: { + type: SchemaTypes.object, + description: "Variables", + title: "Variables", + }, + }, + required: ["title", "owner_id"], + }, + output_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Canvas link", + title: "Canvas link", + }, + }, + required: ["canvas_id"], + }, +}); diff --git a/src/schema/slack/functions/canvas_create_test.ts b/src/schema/slack/functions/canvas_create_test.ts new file mode 100644 index 00000000..0eada188 --- /dev/null +++ b/src/schema/slack/functions/canvas_create_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 { SlackPrimitiveTypes } from "../../slack/types/mod.ts"; +import CanvasCreate from "./canvas_create.ts"; + +Deno.test("CanvasCreate generates valid FunctionManifest", () => { + assertEquals( + CanvasCreate.definition.callback_id, + "slack#/functions/canvas_create", + ); + const expected: ManifestFunctionSchema = { + source_file: "", + title: "Create a canvas", + input_parameters: { + properties: { + title: { + type: SchemaTypes.string, + description: "Enter a canvas name", + title: "Canvas name", + }, + canvas_create_type: { + type: SchemaTypes.string, + description: "Type of creation", + title: "Type of creation", + }, + canvas_template_id: { + type: SlackPrimitiveTypes.canvas_template_id, + description: "Select an option", + title: "Select a canvas template", + }, + owner_id: { + type: SlackTypes.user_id, + description: "Person", + title: "Canvas owner", + }, + content: { + type: SlackPrimitiveTypes.expanded_rich_text, + description: "Add content to the canvas", + title: "Add content", + }, + placeholder_values: { + type: SchemaTypes.object, + description: "Variables", + title: "Variables", + }, + }, + required: ["title", "owner_id"], + }, + output_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Canvas link", + title: "Canvas link", + }, + }, + required: ["canvas_id"], + }, + }; + const actual = CanvasCreate.export(); + + assertNotStrictEquals(actual, expected); +}); + +Deno.test("CanvasCreate can be used as a Slack function in a workflow step", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_CanvasCreate_slack_function", + title: "Test CanvasCreate", + description: "This is a generated test to test CanvasCreate", + }); + testWorkflow.addStep(CanvasCreate, { title: "test", owner_id: "test" }); + const actual = testWorkflow.steps[0].export(); + + assertEquals(actual.function_id, "slack#/functions/canvas_create"); + assertEquals(actual.inputs, { title: "test", owner_id: "test" }); +}); + +Deno.test("All outputs of Slack function CanvasCreate should exist", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_CanvasCreate_slack_function", + title: "Test CanvasCreate", + description: "This is a generated test to test CanvasCreate", + }); + const step = testWorkflow.addStep(CanvasCreate, { + title: "test", + owner_id: "test", + }); + assertExists(step.outputs.canvas_id); +}); diff --git a/src/schema/slack/functions/canvas_update_content.ts b/src/schema/slack/functions/canvas_update_content.ts new file mode 100644 index 00000000..3fc8b324 --- /dev/null +++ b/src/schema/slack/functions/canvas_update_content.ts @@ -0,0 +1,56 @@ +/** 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 { SlackPrimitiveTypes } from "../../slack/types/mod.ts"; +import SlackTypes from "../schema_types.ts"; + +export default DefineFunction({ + callback_id: "slack#/functions/canvas_update_content", + source_file: "", + title: "Update a canvas", + input_parameters: { + properties: { + canvas_update_type: { + type: SchemaTypes.string, + description: "Type of update", + title: "Type of update", + }, + channel_id: { + type: SlackTypes.channel_id, + description: "Channel name", + title: "Select a channel", + }, + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Search standalone canvases", + title: "Select a canvas", + }, + section_id: { + type: SchemaTypes.string, + description: "Select an option", + title: "Choose which section to update", + }, + action: { + type: SchemaTypes.string, + description: "Select an option", + title: "How do you want to update?", + }, + content: { + type: SlackPrimitiveTypes.expanded_rich_text, + description: "Add content to the canvas", + title: "Content", + }, + }, + required: ["action", "content"], + }, + output_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Canvas link", + title: "Canvas link", + }, + }, + required: ["canvas_id"], + }, +}); diff --git a/src/schema/slack/functions/canvas_update_content_test.ts b/src/schema/slack/functions/canvas_update_content_test.ts new file mode 100644 index 00000000..52470fe4 --- /dev/null +++ b/src/schema/slack/functions/canvas_update_content_test.ts @@ -0,0 +1,100 @@ +/** 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 { SlackPrimitiveTypes } from "../../slack/types/mod.ts"; +import CanvasUpdateContent from "./canvas_update_content.ts"; + +Deno.test("CanvasUpdateContent generates valid FunctionManifest", () => { + assertEquals( + CanvasUpdateContent.definition.callback_id, + "slack#/functions/canvas_update_content", + ); + const expected: ManifestFunctionSchema = { + source_file: "", + title: "Update a canvas", + input_parameters: { + properties: { + canvas_update_type: { + type: SchemaTypes.string, + description: "Type of update", + title: "Type of update", + }, + channel_id: { + type: SlackTypes.channel_id, + description: "Channel name", + title: "Select a channel", + }, + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Search standalone canvases", + title: "Select a canvas", + }, + section_id: { + type: SchemaTypes.string, + description: "Select an option", + title: "Choose which section to update", + }, + action: { + type: SchemaTypes.string, + description: "Select an option", + title: "How do you want to update?", + }, + content: { + type: SlackPrimitiveTypes.expanded_rich_text, + description: "Add content to the canvas", + title: "Content", + }, + }, + required: ["action", "content"], + }, + output_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Canvas link", + title: "Canvas link", + }, + }, + required: ["canvas_id"], + }, + }; + const actual = CanvasUpdateContent.export(); + + assertNotStrictEquals(actual, expected); +}); + +Deno.test("CanvasUpdateContent can be used as a Slack function in a workflow step", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_CanvasUpdateContent_slack_function", + title: "Test CanvasUpdateContent", + description: "This is a generated test to test CanvasUpdateContent", + }); + testWorkflow.addStep(CanvasUpdateContent, { + action: "test", + content: "test", + }); + const actual = testWorkflow.steps[0].export(); + + assertEquals(actual.function_id, "slack#/functions/canvas_update_content"); + assertEquals(actual.inputs, { action: "test", content: "test" }); +}); + +Deno.test("All outputs of Slack function CanvasUpdateContent should exist", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_CanvasUpdateContent_slack_function", + title: "Test CanvasUpdateContent", + description: "This is a generated test to test CanvasUpdateContent", + }); + const step = testWorkflow.addStep(CanvasUpdateContent, { + action: "test", + content: "test", + }); + assertExists(step.outputs.canvas_id); +}); diff --git a/src/schema/slack/functions/channel_canvas_create.ts b/src/schema/slack/functions/channel_canvas_create.ts new file mode 100644 index 00000000..0afe27da --- /dev/null +++ b/src/schema/slack/functions/channel_canvas_create.ts @@ -0,0 +1,51 @@ +/** 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"; +import { SlackPrimitiveTypes } from "../../slack/types/mod.ts"; + +export default DefineFunction({ + callback_id: "slack#/functions/channel_canvas_create", + source_file: "", + title: "Create channel canvas", + input_parameters: { + properties: { + channel_id: { + type: SlackTypes.channel_id, + description: "Channel name", + title: "Select a channel", + }, + canvas_create_type: { + type: SchemaTypes.string, + description: "Type of creation", + title: "Type of creation", + }, + canvas_template_id: { + type: SlackPrimitiveTypes.canvas_template_id, + description: "Select an option", + title: "Select a canvas template", + }, + content: { + type: SlackPrimitiveTypes.expanded_rich_text, + description: "Add content to the canvas", + title: "Add content", + }, + placeholder_values: { + type: SchemaTypes.object, + description: "Variables", + title: "Variables", + }, + }, + required: ["channel_id"], + }, + output_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Canvas link", + title: "Canvas link", + }, + }, + required: ["canvas_id"], + }, +}); diff --git a/src/schema/slack/functions/channel_canvas_create_test.ts b/src/schema/slack/functions/channel_canvas_create_test.ts new file mode 100644 index 00000000..b494e9b7 --- /dev/null +++ b/src/schema/slack/functions/channel_canvas_create_test.ts @@ -0,0 +1,91 @@ +/** 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 { SlackPrimitiveTypes } from "../../slack/types/mod.ts"; +import ChannelCanvasCreate from "./channel_canvas_create.ts"; + +Deno.test("ChannelCanvasCreate generates valid FunctionManifest", () => { + assertEquals( + ChannelCanvasCreate.definition.callback_id, + "slack#/functions/channel_canvas_create", + ); + const expected: ManifestFunctionSchema = { + source_file: "", + title: "Create channel canvas", + input_parameters: { + properties: { + channel_id: { + type: SlackTypes.channel_id, + description: "Channel name", + title: "Select a channel", + }, + canvas_create_type: { + type: SchemaTypes.string, + description: "Type of creation", + title: "Type of creation", + }, + canvas_template_id: { + type: SlackPrimitiveTypes.canvas_template_id, + description: "Select an option", + title: "Select a canvas template", + }, + content: { + type: SlackPrimitiveTypes.expanded_rich_text, + description: "Add content to the canvas", + title: "Add content", + }, + placeholder_values: { + type: SchemaTypes.object, + description: "Variables", + title: "Variables", + }, + }, + required: ["channel_id"], + }, + output_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Canvas link", + title: "Canvas link", + }, + }, + required: ["canvas_id"], + }, + }; + const actual = ChannelCanvasCreate.export(); + + assertNotStrictEquals(actual, expected); +}); + +Deno.test("ChannelCanvasCreate can be used as a Slack function in a workflow step", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_ChannelCanvasCreate_slack_function", + title: "Test ChannelCanvasCreate", + description: "This is a generated test to test ChannelCanvasCreate", + }); + testWorkflow.addStep(ChannelCanvasCreate, { channel_id: "test" }); + const actual = testWorkflow.steps[0].export(); + + assertEquals(actual.function_id, "slack#/functions/channel_canvas_create"); + assertEquals(actual.inputs, { channel_id: "test" }); +}); + +Deno.test("All outputs of Slack function ChannelCanvasCreate should exist", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_ChannelCanvasCreate_slack_function", + title: "Test ChannelCanvasCreate", + description: "This is a generated test to test ChannelCanvasCreate", + }); + const step = testWorkflow.addStep(ChannelCanvasCreate, { + channel_id: "test", + }); + assertExists(step.outputs.canvas_id); +}); diff --git a/src/schema/slack/functions/mod.ts b/src/schema/slack/functions/mod.ts index ceb864d8..575fcee0 100644 --- a/src/schema/slack/functions/mod.ts +++ b/src/schema/slack/functions/mod.ts @@ -1,7 +1,11 @@ -/** This file was autogenerated on Thu Nov 02 2023. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +/** This file was autogenerated on Thu Feb 08 2024. 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"; +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 CreateChannel from "./create_channel.ts"; import CreateUsergroup from "./create_usergroup.ts"; import Delay from "./delay.ts"; @@ -12,12 +16,17 @@ import ReplyInThread from "./reply_in_thread.ts"; import SendDm from "./send_dm.ts"; import SendEphemeralMessage from "./send_ephemeral_message.ts"; import SendMessage from "./send_message.ts"; +import ShareCanvas from "./share_canvas.ts"; import UpdateChannelTopic from "./update_channel_topic.ts"; const SlackFunctions = { AddPin, AddUserToUsergroup, ArchiveChannel, + CanvasCopy, + CanvasCreate, + CanvasUpdateContent, + ChannelCanvasCreate, CreateChannel, CreateUsergroup, Delay, @@ -28,6 +37,7 @@ const SlackFunctions = { SendDm, SendEphemeralMessage, SendMessage, + ShareCanvas, UpdateChannelTopic, } as const; diff --git a/src/schema/slack/functions/share_canvas.ts b/src/schema/slack/functions/share_canvas.ts new file mode 100644 index 00000000..b474761c --- /dev/null +++ b/src/schema/slack/functions/share_canvas.ts @@ -0,0 +1,53 @@ +/** 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"; +import { SlackPrimitiveTypes } from "../../slack/types/mod.ts"; + +export default DefineFunction({ + callback_id: "slack#/functions/share_canvas", + source_file: "", + title: "Share a canvas", + input_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Search all canvases", + title: "Select a canvas", + }, + channel_ids: { + type: SchemaTypes.array, + description: "Select channels", + title: "Select channels", + items: { type: SlackTypes.channel_id }, + }, + user_ids: { + type: SchemaTypes.array, + description: "Search users", + title: "Select people", + items: { type: SlackTypes.user_id }, + }, + access_level: { + type: SchemaTypes.string, + description: "Select an option", + title: "Select access level", + }, + message: { + type: SlackTypes.rich_text, + description: "Add a message", + title: "Add a message", + }, + }, + required: ["canvas_id", "access_level"], + }, + output_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Canvas link", + title: "Canvas link", + }, + }, + required: [], + }, +}); diff --git a/src/schema/slack/functions/share_canvas_test.ts b/src/schema/slack/functions/share_canvas_test.ts new file mode 100644 index 00000000..323587b9 --- /dev/null +++ b/src/schema/slack/functions/share_canvas_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 { SlackPrimitiveTypes } from "../../slack/types/mod.ts"; +import SlackTypes from "../schema_types.ts"; +import ShareCanvas from "./share_canvas.ts"; + +Deno.test("ShareCanvas generates valid FunctionManifest", () => { + assertEquals( + ShareCanvas.definition.callback_id, + "slack#/functions/share_canvas", + ); + const expected: ManifestFunctionSchema = { + source_file: "", + title: "Share a canvas", + input_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Search all canvases", + title: "Select a canvas", + }, + channel_ids: { + type: SchemaTypes.array, + description: "Select channels", + title: "Select channels", + items: { type: SlackTypes.channel_id }, + }, + user_ids: { + type: SchemaTypes.array, + description: "Search users", + title: "Select people", + items: { type: SlackTypes.user_id }, + }, + access_level: { + type: SchemaTypes.string, + description: "Select an option", + title: "Select access level", + }, + message: { + type: SlackTypes.rich_text, + description: "Add a message", + title: "Add a message", + }, + }, + required: ["canvas_id", "access_level"], + }, + output_parameters: { + properties: { + canvas_id: { + type: SlackPrimitiveTypes.canvas_id, + description: "Canvas link", + title: "Canvas link", + }, + }, + required: [], + }, + }; + const actual = ShareCanvas.export(); + + assertNotStrictEquals(actual, expected); +}); + +Deno.test("ShareCanvas can be used as a Slack function in a workflow step", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_ShareCanvas_slack_function", + title: "Test ShareCanvas", + description: "This is a generated test to test ShareCanvas", + }); + testWorkflow.addStep(ShareCanvas, { + canvas_id: "test", + access_level: "test", + }); + const actual = testWorkflow.steps[0].export(); + + assertEquals(actual.function_id, "slack#/functions/share_canvas"); + assertEquals(actual.inputs, { canvas_id: "test", access_level: "test" }); +}); + +Deno.test("All outputs of Slack function ShareCanvas should exist", () => { + const testWorkflow = DefineWorkflow({ + callback_id: "test_ShareCanvas_slack_function", + title: "Test ShareCanvas", + description: "This is a generated test to test ShareCanvas", + }); + const step = testWorkflow.addStep(ShareCanvas, { + canvas_id: "test", + access_level: "test", + }); + assertExists(step.outputs.canvas_id); +}); diff --git a/src/schema/slack/types/mod.ts b/src/schema/slack/types/mod.ts index b0be5b48..85d3c031 100644 --- a/src/schema/slack/types/mod.ts +++ b/src/schema/slack/types/mod.ts @@ -6,9 +6,12 @@ const SlackPrimitiveTypes = { timestamp: "slack#/types/timestamp", blocks: "slack#/types/blocks", oauth2: "slack#/types/credential/oauth2", + expanded_rich_text: "slack#/types/expanded_rich_text", rich_text: "slack#/types/rich_text", message_ts: "slack#/types/message_ts", file_id: "slack#/types/file_id", + canvas_id: "slack#/types/canvas_id", + canvas_template_id: "slack#/types/canvas_template_id", } as const; export type ValidSlackPrimitiveTypes =