Skip to content

Commit

Permalink
Add Share Canvas In Thread built-in function (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelamsili authored May 3, 2024
1 parent 199861e commit c6b5344
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/schema/slack/functions/canvas_copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default DefineFunction({
},
owner_id: {
type: SlackTypes.user_id,
description: "Canvas owner id",
description: "Person",
title: "Owner",
},
placeholder_values: {
Expand Down
2 changes: 1 addition & 1 deletion src/schema/slack/functions/canvas_create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default DefineFunction({
owner_id: {
type: SlackTypes.user_id,
description: "Person",
title: "Canvas owner",
title: "Owner",
},
content: {
type: SlackPrimitiveTypes.expanded_rich_text,
Expand Down
2 changes: 2 additions & 0 deletions src/schema/slack/functions/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ 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 ShareCanvasInThread from "./share_canvas_in_thread.ts";
import UpdateChannelTopic from "./update_channel_topic.ts";

const SlackFunctions = {
Expand All @@ -38,6 +39,7 @@ const SlackFunctions = {
SendEphemeralMessage,
SendMessage,
ShareCanvas,
ShareCanvasInThread,
UpdateChannelTopic,
} as const;

Expand Down
55 changes: 55 additions & 0 deletions src/schema/slack/functions/share_canvas_in_thread.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/** 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_canvas_in_thread",
source_file: "",
title: "Share canvas in thread",
input_parameters: {
properties: {
canvas_id: {
type: SlackTypes.canvas_id,
description: "Search all canvases",
title: "Select a canvas",
},
message_context: {
type: SlackTypes.message_context,
description: "Select a message to reply to",
title: "Select a message to reply to",
},
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",
},
reply_broadcast: {
type: SchemaTypes.boolean,
description: "Also send to conversation",
title: "Also send to conversation",
},
},
required: ["canvas_id", "message_context", "access_level"],
},
output_parameters: {
properties: {
canvas_id: {
type: SlackTypes.canvas_id,
description: "Canvas link",
title: "Canvas link",
},
message_context: {
type: SlackTypes.message_context,
description: "Reference to the message sent",
title: "Reference to the message sent",
},
},
required: [],
},
});
106 changes: 106 additions & 0 deletions src/schema/slack/functions/share_canvas_in_thread_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/** 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 ShareCanvasInThread from "./share_canvas_in_thread.ts";

Deno.test("ShareCanvasInThread generates valid FunctionManifest", () => {
assertEquals(
ShareCanvasInThread.definition.callback_id,
"slack#/functions/share_canvas_in_thread",
);
const expected: ManifestFunctionSchema = {
source_file: "",
title: "Share canvas in thread",
input_parameters: {
properties: {
canvas_id: {
type: SlackTypes.canvas_id,
description: "Search all canvases",
title: "Select a canvas",
},
message_context: {
type: SlackTypes.message_context,
description: "Select a message to reply to",
title: "Select a message to reply to",
},
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",
},
reply_broadcast: {
type: SchemaTypes.boolean,
description: "Also send to conversation",
title: "Also send to conversation",
},
},
required: ["canvas_id", "message_context", "access_level"],
},
output_parameters: {
properties: {
canvas_id: {
type: SlackTypes.canvas_id,
description: "Canvas link",
title: "Canvas link",
},
message_context: {
type: SlackTypes.message_context,
description: "Reference to the message sent",
title: "Reference to the message sent",
},
},
required: [],
},
};
const actual = ShareCanvasInThread.export();

assertNotStrictEquals(actual, expected);
});

Deno.test("ShareCanvasInThread can be used as a Slack function in a workflow step", () => {
const testWorkflow = DefineWorkflow({
callback_id: "test_ShareCanvasInThread_slack_function",
title: "Test ShareCanvasInThread",
description: "This is a generated test to test ShareCanvasInThread",
});
testWorkflow.addStep(ShareCanvasInThread, {
canvas_id: "test",
message_context: "test",
access_level: "test",
});
const actual = testWorkflow.steps[0].export();

assertEquals(actual.function_id, "slack#/functions/share_canvas_in_thread");
assertEquals(actual.inputs, {
canvas_id: "test",
message_context: "test",
access_level: "test",
});
});

Deno.test("All outputs of Slack function ShareCanvasInThread should exist", () => {
const testWorkflow = DefineWorkflow({
callback_id: "test_ShareCanvasInThread_slack_function",
title: "Test ShareCanvasInThread",
description: "This is a generated test to test ShareCanvasInThread",
});
const step = testWorkflow.addStep(ShareCanvasInThread, {
canvas_id: "test",
message_context: "test",
access_level: "test",
});
assertExists(step.outputs.canvas_id);
assertExists(step.outputs.message_context);
});

0 comments on commit c6b5344

Please sign in to comment.