Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Share Canvas in thread to the deno sdk #311

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This label changed in the built in

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
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);
});
Loading