Skip to content

Commit

Permalink
Built in function updates:
Browse files Browse the repository at this point in the history
- updated some property titles
- create-channel built in now accepts an optional team id (fixes #267)
- added new Add Bookmark builtin
- openform now accepts an on_submit_function_config input
  • Loading branch information
Filip Maj committed Jun 6, 2024
1 parent 5a4140f commit fb5e6a4
Show file tree
Hide file tree
Showing 29 changed files with 237 additions and 62 deletions.
50 changes: 50 additions & 0 deletions src/schema/slack/functions/add_bookmark.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/** 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_bookmark",
source_file: "",
title: "Add a bookmark",
input_parameters: {
properties: {
channel_id: {
type: SlackTypes.channel_id,
description: "Search all channels",
title: "Select a channel",
},
name: {
type: SchemaTypes.string,
description: "Enter the bookmark name",
title: "Bookmark name",
},
link: {
type: SchemaTypes.string,
description: "https://docs.acme.com",
title: "Bookmark Link",
},
},
required: ["channel_id", "name", "link"],
},
output_parameters: {
properties: {
channel_id: {
type: SlackTypes.channel_id,
description: "Channel",
title: "Channel",
},
bookmark_name: {
type: SchemaTypes.string,
description: "Bookmark name",
title: "Bookmark name",
},
bookmark_link: {
type: SchemaTypes.string,
description: "Bookmark link",
title: "Bookmark link",
},
},
required: ["channel_id", "bookmark_name", "bookmark_link"],
},
});
102 changes: 102 additions & 0 deletions src/schema/slack/functions/add_bookmark_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/** 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 AddBookmark from "./add_bookmark.ts";

Deno.test("AddBookmark generates valid FunctionManifest", () => {
assertEquals(
AddBookmark.definition.callback_id,
"slack#/functions/add_bookmark",
);
const expected: ManifestFunctionSchema = {
source_file: "",
title: "Add a bookmark",
input_parameters: {
properties: {
channel_id: {
type: SlackTypes.channel_id,
description: "Search all channels",
title: "Select a channel",
},
name: {
type: SchemaTypes.string,
description: "Enter the bookmark name",
title: "Bookmark name",
},
link: {
type: SchemaTypes.string,
description: "https://docs.acme.com",
title: "Bookmark Link",
},
},
required: ["channel_id", "name", "link"],
},
output_parameters: {
properties: {
channel_id: {
type: SlackTypes.channel_id,
description: "Channel",
title: "Channel",
},
bookmark_name: {
type: SchemaTypes.string,
description: "Bookmark name",
title: "Bookmark name",
},
bookmark_link: {
type: SchemaTypes.string,
description: "Bookmark link",
title: "Bookmark link",
},
},
required: ["channel_id", "bookmark_name", "bookmark_link"],
},
};
const actual = AddBookmark.export();

assertNotStrictEquals(actual, expected);
});

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

assertEquals(actual.function_id, "slack#/functions/add_bookmark");
assertEquals(actual.inputs, {
channel_id: "test",
name: "test",
link: "test",
});
});

Deno.test("All outputs of Slack function AddBookmark should exist", () => {
const testWorkflow = DefineWorkflow({
callback_id: "test_AddBookmark_slack_function",
title: "Test AddBookmark",
description: "This is a generated test to test AddBookmark",
});
const step = testWorkflow.addStep(AddBookmark, {
channel_id: "test",
name: "test",
link: "test",
});
assertExists(step.outputs.channel_id);
assertExists(step.outputs.bookmark_name);
assertExists(step.outputs.bookmark_link);
});
7 changes: 3 additions & 4 deletions src/schema/slack/functions/canvas_copy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/** 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({
Expand All @@ -11,7 +10,7 @@ export default DefineFunction({
input_parameters: {
properties: {
canvas_id: {
type: SlackPrimitiveTypes.canvas_id,
type: SlackTypes.canvas_id,
description: "Search all canvases",
title: "Select a canvas",
},
Expand All @@ -23,7 +22,7 @@ export default DefineFunction({
owner_id: {
type: SlackTypes.user_id,
description: "Person",
title: "Owner",
title: "Canvas owner",
},
placeholder_values: {
type: SchemaTypes.object,
Expand All @@ -36,7 +35,7 @@ export default DefineFunction({
output_parameters: {
properties: {
canvas_id: {
type: SlackPrimitiveTypes.canvas_id,
type: SlackTypes.canvas_id,
description: "Canvas link",
title: "Canvas link",
},
Expand Down
10 changes: 4 additions & 6 deletions src/schema/slack/functions/canvas_copy_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ 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", () => {
Expand All @@ -23,7 +21,7 @@ Deno.test("CanvasCopy generates valid FunctionManifest", () => {
input_parameters: {
properties: {
canvas_id: {
type: SlackPrimitiveTypes.canvas_id,
type: SlackTypes.canvas_id,
description: "Search all canvases",
title: "Select a canvas",
},
Expand All @@ -34,8 +32,8 @@ Deno.test("CanvasCopy generates valid FunctionManifest", () => {
},
owner_id: {
type: SlackTypes.user_id,
description: "Canvas owner id",
title: "Owner",
description: "Person",
title: "Canvas owner",
},
placeholder_values: {
type: SchemaTypes.object,
Expand All @@ -48,7 +46,7 @@ Deno.test("CanvasCopy generates valid FunctionManifest", () => {
output_parameters: {
properties: {
canvas_id: {
type: SlackPrimitiveTypes.canvas_id,
type: SlackTypes.canvas_id,
description: "Canvas link",
title: "Canvas link",
},
Expand Down
9 changes: 4 additions & 5 deletions src/schema/slack/functions/canvas_create.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/** 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({
Expand All @@ -21,17 +20,17 @@ export default DefineFunction({
title: "Type of creation",
},
canvas_template_id: {
type: SlackPrimitiveTypes.canvas_template_id,
type: SlackTypes.canvas_template_id,
description: "Select an option",
title: "Select a canvas template",
},
owner_id: {
type: SlackTypes.user_id,
description: "Person",
title: "Owner",
title: "Canvas owner",
},
content: {
type: SlackPrimitiveTypes.expanded_rich_text,
type: SlackTypes.expanded_rich_text,
description: "Add content to the canvas",
title: "Add content",
},
Expand All @@ -46,7 +45,7 @@ export default DefineFunction({
output_parameters: {
properties: {
canvas_id: {
type: SlackPrimitiveTypes.canvas_id,
type: SlackTypes.canvas_id,
description: "Canvas link",
title: "Canvas link",
},
Expand Down
7 changes: 3 additions & 4 deletions src/schema/slack/functions/canvas_create_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ 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", () => {
Expand All @@ -32,7 +31,7 @@ Deno.test("CanvasCreate generates valid FunctionManifest", () => {
title: "Type of creation",
},
canvas_template_id: {
type: SlackPrimitiveTypes.canvas_template_id,
type: SlackTypes.canvas_template_id,
description: "Select an option",
title: "Select a canvas template",
},
Expand All @@ -42,7 +41,7 @@ Deno.test("CanvasCreate generates valid FunctionManifest", () => {
title: "Canvas owner",
},
content: {
type: SlackPrimitiveTypes.expanded_rich_text,
type: SlackTypes.expanded_rich_text,
description: "Add content to the canvas",
title: "Add content",
},
Expand All @@ -57,7 +56,7 @@ Deno.test("CanvasCreate generates valid FunctionManifest", () => {
output_parameters: {
properties: {
canvas_id: {
type: SlackPrimitiveTypes.canvas_id,
type: SlackTypes.canvas_id,
description: "Canvas link",
title: "Canvas link",
},
Expand Down
7 changes: 3 additions & 4 deletions src/schema/slack/functions/canvas_update_content.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/** 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({
Expand All @@ -21,7 +20,7 @@ export default DefineFunction({
title: "Select a channel",
},
canvas_id: {
type: SlackPrimitiveTypes.canvas_id,
type: SlackTypes.canvas_id,
description: "Search standalone canvases",
title: "Select a canvas",
},
Expand All @@ -36,7 +35,7 @@ export default DefineFunction({
title: "How do you want to update?",
},
content: {
type: SlackPrimitiveTypes.expanded_rich_text,
type: SlackTypes.expanded_rich_text,
description: "Add content to the canvas",
title: "Content",
},
Expand All @@ -46,7 +45,7 @@ export default DefineFunction({
output_parameters: {
properties: {
canvas_id: {
type: SlackPrimitiveTypes.canvas_id,
type: SlackTypes.canvas_id,
description: "Canvas link",
title: "Canvas link",
},
Expand Down
7 changes: 3 additions & 4 deletions src/schema/slack/functions/canvas_update_content_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ 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", () => {
Expand All @@ -32,7 +31,7 @@ Deno.test("CanvasUpdateContent generates valid FunctionManifest", () => {
title: "Select a channel",
},
canvas_id: {
type: SlackPrimitiveTypes.canvas_id,
type: SlackTypes.canvas_id,
description: "Search standalone canvases",
title: "Select a canvas",
},
Expand All @@ -47,7 +46,7 @@ Deno.test("CanvasUpdateContent generates valid FunctionManifest", () => {
title: "How do you want to update?",
},
content: {
type: SlackPrimitiveTypes.expanded_rich_text,
type: SlackTypes.expanded_rich_text,
description: "Add content to the canvas",
title: "Content",
},
Expand All @@ -57,7 +56,7 @@ Deno.test("CanvasUpdateContent generates valid FunctionManifest", () => {
output_parameters: {
properties: {
canvas_id: {
type: SlackPrimitiveTypes.canvas_id,
type: SlackTypes.canvas_id,
description: "Canvas link",
title: "Canvas link",
},
Expand Down
Loading

0 comments on commit fb5e6a4

Please sign in to comment.