-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new Canvas built in functions to the deno-sdk (#273)
- Loading branch information
1 parent
9de72ce
commit 8563f41
Showing
13 changed files
with
762 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"], | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"], | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"], | ||
}, | ||
}); |
Oops, something went wrong.