diff --git a/deno.jsonc b/deno.jsonc index 022637bf..f5146f69 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,35 +1,29 @@ { "$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json", "fmt": { - "files": { - "include": [ - "src", - "tests", - "docs", - "README.md", - "scripts", - ".github/maintainers_guide.md", - ".github/CONTRIBUTING.md" - ], - "exclude": ["src/schema/slack/functions/_scripts/functions.json"] - }, - "options": { - "semiColons": true, - "indentWidth": 2, - "lineWidth": 80, - "proseWrap": "always", - "singleQuote": false, - "useTabs": false - } + "include": [ + "src", + "tests", + "docs", + "README.md", + "scripts", + ".github/maintainers_guide.md", + ".github/CONTRIBUTING.md" + ], + "exclude": ["src/schema/slack/functions/_scripts/functions.json"] + "semiColons": true, + "indentWidth": 2, + "lineWidth": 80, + "proseWrap": "always", + "singleQuote": false, + "useTabs": false }, "lint": { - "files": { - "include": ["src", "tests", "scripts"], - "exclude": [ - "src/schema/slack/functions/_scripts/functions.json", - "**/*.md" - ] - } + "include": ["src", "tests", "scripts"], + "exclude": [ + "src/schema/slack/functions/_scripts/functions.json", + "**/*.md" + ] }, "tasks": { "test": "deno fmt --check && deno lint && deno bundle src/mod.ts && deno test --allow-read --allow-run --parallel src/ tests/", diff --git a/src/schema/slack/functions/_scripts/README.md b/src/schema/slack/functions/_scripts/README.md index 7329af72..dd244620 100644 --- a/src/schema/slack/functions/_scripts/README.md +++ b/src/schema/slack/functions/_scripts/README.md @@ -10,8 +10,21 @@ corresponding test, the tests must be removed manually. ## Instructions -1. First, you'll need to grab a payload from `functions.list` and place the - response in a `functions.json` file inside of this `_scripts` directory. +1. First, you'll need to grab the response from `functions.categories.list` API + method tester: + +- Choose a session token from a public production enterprise grid workspace that + is NOT enrolled in the `hermes_next` toggle. Recommend using the Slack DevRel + production enterprise grid token. +- Pass the `category_type=builtins_categories` parameter to this API. +- Now for the super annoying part: for each builtin category, you will need to + manually call _another_ API and assemble a functions list yourself: + - Grab the response from `functions.categories.steps.list` API method tester, + using the same session token as earlier in this step, passing each + `category_id` retrieved earlier into this API call. + - Copy the `functions` array elements from each response into a fresh + `{"functions":[]}` array in `functions.json`, slowly building up a list of + all builtin functions. 2. With this `_scripts` directory as your working directory, run the generate script: @@ -20,30 +33,6 @@ corresponding test, the tests must be removed manually. > ./generate ``` -3. This will output something like the following: - - ```txt - Cleaning folder directory - Generating code & tests for Slack function: add_pin - Generating code & tests for Slack function: add_user_to_usergroup - Generating code & tests for Slack function: archive_channel - Generating code & tests for Slack function: create_channel - Generating code & tests for Slack function: create_usergroup - Generating code & tests for Slack function: delay - Generating code & tests for Slack function: invite_user_to_channel - Generating code & tests for Slack function: open_form - Generating code & tests for Slack function: remove_user_from_usergroup - Generating code & tests for Slack function: reply_in_thread - Generating code & tests for Slack function: send_dm - Generating code & tests for Slack function: send_ephemeral_message - Generating code & tests for Slack function: send_message - Generating code & tests for Slack function: update_channel_topic - Generated 14 Slack functions with their unit tests - Updated functions module export - Formatting Slack function files... - Linting Slack function files... - ``` - If it completes without any linter errors, you should be good to go, with new, formatted and linted TypeScript files for all of the Slack functions included in your `functions.json` payload. If there are any unexpected linting issues, you diff --git a/src/schema/slack/functions/_scripts/src/templates/template_function.ts b/src/schema/slack/functions/_scripts/src/templates/template_function.ts index 0b43d376..760bc686 100644 --- a/src/schema/slack/functions/_scripts/src/templates/template_function.ts +++ b/src/schema/slack/functions/_scripts/src/templates/template_function.ts @@ -17,6 +17,40 @@ import { } from "./utils.ts"; import { AllowedTypeValue, AllowedTypeValueObject } from "./types.ts"; +type AllowedHiddenParamsMap = Record< + string, + Record<"input" | "output", string[]> +>; +// Oops we accidentally exposed hidden parameters. That's ok, we'll keep them public for now. +export const allowedHiddenParams: AllowedHiddenParamsMap = { + "open_form": { + input: [], + output: ["interactivity"], + }, + "reply_in_thread": { + input: ["files"], + output: ["action", "interactivity"], + }, + "send_dm": { + input: ["files"], + output: [ + "action", + "interactivity", + "timestamp_started", + "timestamp_completed", + ], + }, + "send_message": { + input: ["files"], + output: [ + "action", + "interactivity", + "timestamp_started", + "timestamp_completed", + ], + }, +}; + const typeMap: Record = { SchemaTypes, SlackTypes: SlackSchemaTypes, @@ -76,12 +110,15 @@ const propertiesToTypeScript = ( }; const manifestParametersToTypeScript = ( + allowedHiddenParams: string[], functionParameters: FunctionParameter[], ) => { const typescript: string[] = []; typescript.push( `properties: {${ - functionParameters.map((parameter) => + functionParameters.filter((p) => + allowedHiddenParams.includes(p.name) || !p.is_hidden + ).map((parameter) => `${parameter.name}: ${propertyToTypeScript(parameter)}` ).join(",\n") }}`, @@ -97,6 +134,7 @@ const manifestParametersToTypeScript = ( }; export function manifestFunctionFieldsToTypeScript( + allowedParamsMap: AllowedHiddenParamsMap, functionRecord: FunctionRecord, ) { const typescript: string[] = []; @@ -111,14 +149,22 @@ export function manifestFunctionFieldsToTypeScript( `description: ${sanitize(functionRecord.description)}`, ); } + const allowedHiddenParams = allowedParamsMap[functionRecord.callback_id] || + { input: [], output: [] }; typescript.push( `input_parameters: ${ - manifestParametersToTypeScript(functionRecord.input_parameters) + manifestParametersToTypeScript( + allowedHiddenParams.input, + functionRecord.input_parameters, + ) }`, ); typescript.push( `output_parameters: ${ - manifestParametersToTypeScript(functionRecord.output_parameters) + manifestParametersToTypeScript( + allowedHiddenParams.output, + functionRecord.output_parameters, + ) }`, ); return typescript.join(",\n"); @@ -131,7 +177,9 @@ const defineFunctionInputToTypeScript = ( typescript.push( `callback_id: ${sanitize(getSlackCallbackId(functionRecord))}`, ); - typescript.push(manifestFunctionFieldsToTypeScript(functionRecord)); + typescript.push( + manifestFunctionFieldsToTypeScript(allowedHiddenParams, functionRecord), + ); return `{${typescript.join(",\n")}}`; }; diff --git a/src/schema/slack/functions/_scripts/src/templates/test_template.ts b/src/schema/slack/functions/_scripts/src/templates/test_template.ts index fbd69bce..6e3e2a07 100644 --- a/src/schema/slack/functions/_scripts/src/templates/test_template.ts +++ b/src/schema/slack/functions/_scripts/src/templates/test_template.ts @@ -6,12 +6,17 @@ import { renderTypeImports, } from "./utils.ts"; import { FunctionParameter, FunctionRecord } from "../types.ts"; -import { manifestFunctionFieldsToTypeScript } from "./template_function.ts"; +import { + allowedHiddenParams, + manifestFunctionFieldsToTypeScript, +} from "./template_function.ts"; export const manifestFunctionToTypeScript = ( functionRecord: FunctionRecord, ) => { - return `{${manifestFunctionFieldsToTypeScript(functionRecord)}}`; + return `{${ + manifestFunctionFieldsToTypeScript(allowedHiddenParams, functionRecord) + }}`; }; const renderFunctionManifestTest = ( diff --git a/src/schema/slack/functions/_scripts/src/types.ts b/src/schema/slack/functions/_scripts/src/types.ts index 50373ed1..06745f70 100644 --- a/src/schema/slack/functions/_scripts/src/types.ts +++ b/src/schema/slack/functions/_scripts/src/types.ts @@ -26,6 +26,7 @@ export type FunctionProperties = { export type FunctionParameter = FunctionProperty & { name: string; is_required?: boolean; + is_hidden?: boolean; }; export type FunctionRecord = { diff --git a/src/schema/slack/functions/add_bookmark.ts b/src/schema/slack/functions/add_bookmark.ts new file mode 100644 index 00000000..d828649e --- /dev/null +++ b/src/schema/slack/functions/add_bookmark.ts @@ -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"], + }, +}); diff --git a/src/schema/slack/functions/add_bookmark_test.ts b/src/schema/slack/functions/add_bookmark_test.ts new file mode 100644 index 00000000..932782f9 --- /dev/null +++ b/src/schema/slack/functions/add_bookmark_test.ts @@ -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); +}); diff --git a/src/schema/slack/functions/canvas_copy.ts b/src/schema/slack/functions/canvas_copy.ts index ba2518f0..b4472024 100644 --- a/src/schema/slack/functions/canvas_copy.ts +++ b/src/schema/slack/functions/canvas_copy.ts @@ -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({ @@ -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", }, @@ -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, @@ -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", }, diff --git a/src/schema/slack/functions/canvas_copy_test.ts b/src/schema/slack/functions/canvas_copy_test.ts index 49402fe0..79df3bdb 100644 --- a/src/schema/slack/functions/canvas_copy_test.ts +++ b/src/schema/slack/functions/canvas_copy_test.ts @@ -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", () => { @@ -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", }, @@ -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, @@ -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", }, diff --git a/src/schema/slack/functions/canvas_create.ts b/src/schema/slack/functions/canvas_create.ts index 33ded67f..eed305a9 100644 --- a/src/schema/slack/functions/canvas_create.ts +++ b/src/schema/slack/functions/canvas_create.ts @@ -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({ @@ -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", }, @@ -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", }, diff --git a/src/schema/slack/functions/canvas_create_test.ts b/src/schema/slack/functions/canvas_create_test.ts index 0eada188..c33cc925 100644 --- a/src/schema/slack/functions/canvas_create_test.ts +++ b/src/schema/slack/functions/canvas_create_test.ts @@ -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", () => { @@ -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", }, @@ -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", }, @@ -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", }, diff --git a/src/schema/slack/functions/canvas_update_content.ts b/src/schema/slack/functions/canvas_update_content.ts index 3fc8b324..ae4f97e4 100644 --- a/src/schema/slack/functions/canvas_update_content.ts +++ b/src/schema/slack/functions/canvas_update_content.ts @@ -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({ @@ -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", }, @@ -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", }, @@ -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", }, diff --git a/src/schema/slack/functions/canvas_update_content_test.ts b/src/schema/slack/functions/canvas_update_content_test.ts index 52470fe4..63d679a7 100644 --- a/src/schema/slack/functions/canvas_update_content_test.ts +++ b/src/schema/slack/functions/canvas_update_content_test.ts @@ -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", () => { @@ -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", }, @@ -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", }, @@ -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", }, diff --git a/src/schema/slack/functions/channel_canvas_create.ts b/src/schema/slack/functions/channel_canvas_create.ts index 0afe27da..3b4b44b0 100644 --- a/src/schema/slack/functions/channel_canvas_create.ts +++ b/src/schema/slack/functions/channel_canvas_create.ts @@ -2,7 +2,6 @@ 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", @@ -21,12 +20,12 @@ 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", }, content: { - type: SlackPrimitiveTypes.expanded_rich_text, + type: SlackTypes.expanded_rich_text, description: "Add content to the canvas", title: "Add content", }, @@ -41,7 +40,7 @@ export default DefineFunction({ output_parameters: { properties: { canvas_id: { - type: SlackPrimitiveTypes.canvas_id, + type: SlackTypes.canvas_id, description: "Canvas link", title: "Canvas link", }, diff --git a/src/schema/slack/functions/channel_canvas_create_test.ts b/src/schema/slack/functions/channel_canvas_create_test.ts index b494e9b7..6074d45c 100644 --- a/src/schema/slack/functions/channel_canvas_create_test.ts +++ b/src/schema/slack/functions/channel_canvas_create_test.ts @@ -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 ChannelCanvasCreate from "./channel_canvas_create.ts"; Deno.test("ChannelCanvasCreate generates valid FunctionManifest", () => { @@ -32,12 +31,12 @@ Deno.test("ChannelCanvasCreate 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", }, content: { - type: SlackPrimitiveTypes.expanded_rich_text, + type: SlackTypes.expanded_rich_text, description: "Add content to the canvas", title: "Add content", }, @@ -52,7 +51,7 @@ Deno.test("ChannelCanvasCreate generates valid FunctionManifest", () => { output_parameters: { properties: { canvas_id: { - type: SlackPrimitiveTypes.canvas_id, + type: SlackTypes.canvas_id, description: "Canvas link", title: "Canvas link", }, diff --git a/src/schema/slack/functions/create_channel.ts b/src/schema/slack/functions/create_channel.ts index 4a9e4b49..b643aa63 100644 --- a/src/schema/slack/functions/create_channel.ts +++ b/src/schema/slack/functions/create_channel.ts @@ -9,6 +9,11 @@ export default DefineFunction({ title: "Create a channel", input_parameters: { properties: { + team_id: { + type: SlackTypes.team_id, + description: "Search all workspaces", + title: "Select a workspace", + }, channel_name: { type: SchemaTypes.string, description: "Enter a channel name", diff --git a/src/schema/slack/functions/create_channel_test.ts b/src/schema/slack/functions/create_channel_test.ts index c0bc524e..9634d6c8 100644 --- a/src/schema/slack/functions/create_channel_test.ts +++ b/src/schema/slack/functions/create_channel_test.ts @@ -20,6 +20,11 @@ Deno.test("CreateChannel generates valid FunctionManifest", () => { title: "Create a channel", input_parameters: { properties: { + team_id: { + type: SlackTypes.team_id, + description: "Search all workspaces", + title: "Select a workspace", + }, channel_name: { type: SchemaTypes.string, description: "Enter a channel name", diff --git a/src/schema/slack/functions/create_usergroup.ts b/src/schema/slack/functions/create_usergroup.ts index 70fd7c6b..73a40e0d 100644 --- a/src/schema/slack/functions/create_usergroup.ts +++ b/src/schema/slack/functions/create_usergroup.ts @@ -10,6 +10,11 @@ export default DefineFunction({ description: "Additional permissions might be required", input_parameters: { properties: { + team_id: { + type: SlackTypes.team_id, + description: "Search all teams", + title: "Select a team", + }, usergroup_handle: { type: SchemaTypes.string, description: "Ex: accounts-team", @@ -17,7 +22,7 @@ export default DefineFunction({ }, usergroup_name: { type: SchemaTypes.string, - description: "Ex. Accounts Team", + description: "Ex: Accounts Team", title: "Display name", }, }, diff --git a/src/schema/slack/functions/create_usergroup_test.ts b/src/schema/slack/functions/create_usergroup_test.ts index cf1ec5a8..d9f20ccf 100644 --- a/src/schema/slack/functions/create_usergroup_test.ts +++ b/src/schema/slack/functions/create_usergroup_test.ts @@ -21,6 +21,11 @@ Deno.test("CreateUsergroup generates valid FunctionManifest", () => { description: "Additional permissions might be required", input_parameters: { properties: { + team_id: { + type: SlackTypes.team_id, + description: "Search all teams", + title: "Select a team", + }, usergroup_handle: { type: SchemaTypes.string, description: "Ex: accounts-team", @@ -28,7 +33,7 @@ Deno.test("CreateUsergroup generates valid FunctionManifest", () => { }, usergroup_name: { type: SchemaTypes.string, - description: "Ex. Accounts Team", + description: "Ex: Accounts Team", title: "Display name", }, }, diff --git a/src/schema/slack/functions/delay.ts b/src/schema/slack/functions/delay.ts index b4581ef1..f254eec3 100644 --- a/src/schema/slack/functions/delay.ts +++ b/src/schema/slack/functions/delay.ts @@ -12,7 +12,7 @@ export default DefineFunction({ minutes_to_delay: { type: SchemaTypes.integer, description: "Enter number of minutes", - title: "Delay for this many minutes", + title: "Delay", }, }, required: ["minutes_to_delay"], diff --git a/src/schema/slack/functions/delay_test.ts b/src/schema/slack/functions/delay_test.ts index 264c1ef5..c2ab0497 100644 --- a/src/schema/slack/functions/delay_test.ts +++ b/src/schema/slack/functions/delay_test.ts @@ -16,7 +16,7 @@ Deno.test("Delay generates valid FunctionManifest", () => { minutes_to_delay: { type: SchemaTypes.integer, description: "Enter number of minutes", - title: "Delay for this many minutes", + title: "Delay", }, }, required: ["minutes_to_delay"], diff --git a/src/schema/slack/functions/invite_user_to_channel.ts b/src/schema/slack/functions/invite_user_to_channel.ts index 55684e6c..cf44ff95 100644 --- a/src/schema/slack/functions/invite_user_to_channel.ts +++ b/src/schema/slack/functions/invite_user_to_channel.ts @@ -1,4 +1,4 @@ -/** This file was autogenerated on Wed Mar 20 2024. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +/** 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"; @@ -20,7 +20,7 @@ export default DefineFunction({ user_ids: { type: SchemaTypes.array, description: "Search all people", - title: "Select members", + title: "Select member(s)", items: { type: SlackTypes.user_id }, }, usergroup_ids: { diff --git a/src/schema/slack/functions/invite_user_to_channel_test.ts b/src/schema/slack/functions/invite_user_to_channel_test.ts index b1a35447..fe7aab1e 100644 --- a/src/schema/slack/functions/invite_user_to_channel_test.ts +++ b/src/schema/slack/functions/invite_user_to_channel_test.ts @@ -1,4 +1,4 @@ -/** This file was autogenerated on Wed Mar 20 2024. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +/** This file was autogenerated. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ import { assertEquals, assertExists, @@ -31,7 +31,7 @@ Deno.test("InviteUserToChannel generates valid FunctionManifest", () => { user_ids: { type: SchemaTypes.array, description: "Search all people", - title: "Select members", + title: "Select member(s)", items: { type: SlackTypes.user_id }, }, usergroup_ids: { diff --git a/src/schema/slack/functions/mod.ts b/src/schema/slack/functions/mod.ts index f9d4d42f..420f096d 100644 --- a/src/schema/slack/functions/mod.ts +++ b/src/schema/slack/functions/mod.ts @@ -1,4 +1,5 @@ -/** This file was autogenerated on Thu Feb 08 2024. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +/** This file was autogenerated on Fri Jun 07 2024. Follow the steps in src/schema/slack/functions/_scripts/README.md to rebuild **/ +import AddBookmark from "./add_bookmark.ts"; import AddPin from "./add_pin.ts"; import AddUserToUsergroup from "./add_user_to_usergroup.ts"; import ArchiveChannel from "./archive_channel.ts"; @@ -21,6 +22,7 @@ import ShareCanvasInThread from "./share_canvas_in_thread.ts"; import UpdateChannelTopic from "./update_channel_topic.ts"; const SlackFunctions = { + AddBookmark, AddPin, AddUserToUsergroup, ArchiveChannel, diff --git a/src/schema/slack/functions/send_dm.ts b/src/schema/slack/functions/send_dm.ts index 585ab818..7dff980f 100644 --- a/src/schema/slack/functions/send_dm.ts +++ b/src/schema/slack/functions/send_dm.ts @@ -37,8 +37,8 @@ export default DefineFunction({ properties: { message_timestamp: { type: SlackTypes.timestamp, - description: "Message time stamp", - title: "Message time stamp", + description: "Message timestamp", + title: "Message timestamp", }, message_link: { type: SchemaTypes.string, diff --git a/src/schema/slack/functions/send_dm_test.ts b/src/schema/slack/functions/send_dm_test.ts index eaa536e2..a9a1edac 100644 --- a/src/schema/slack/functions/send_dm_test.ts +++ b/src/schema/slack/functions/send_dm_test.ts @@ -45,8 +45,8 @@ Deno.test("SendDm generates valid FunctionManifest", () => { properties: { message_timestamp: { type: SlackTypes.timestamp, - description: "Message time stamp", - title: "Message time stamp", + description: "Message timestamp", + title: "Message timestamp", }, message_link: { type: SchemaTypes.string, diff --git a/src/schema/slack/functions/send_ephemeral_message.ts b/src/schema/slack/functions/send_ephemeral_message.ts index 44d64071..13563d28 100644 --- a/src/schema/slack/functions/send_ephemeral_message.ts +++ b/src/schema/slack/functions/send_ephemeral_message.ts @@ -39,8 +39,8 @@ export default DefineFunction({ properties: { message_ts: { type: SlackTypes.message_ts, - description: "Message time stamp", - title: "Message time stamp", + description: "Message timestamp", + title: "Message timestamp", }, }, required: ["message_ts"], diff --git a/src/schema/slack/functions/send_ephemeral_message_test.ts b/src/schema/slack/functions/send_ephemeral_message_test.ts index 0ae0f741..06c791e8 100644 --- a/src/schema/slack/functions/send_ephemeral_message_test.ts +++ b/src/schema/slack/functions/send_ephemeral_message_test.ts @@ -50,8 +50,8 @@ Deno.test("SendEphemeralMessage generates valid FunctionManifest", () => { properties: { message_ts: { type: SlackTypes.message_ts, - description: "Message time stamp", - title: "Message time stamp", + description: "Message timestamp", + title: "Message timestamp", }, }, required: ["message_ts"], diff --git a/src/schema/slack/functions/send_message.ts b/src/schema/slack/functions/send_message.ts index 7becb038..a9275049 100644 --- a/src/schema/slack/functions/send_message.ts +++ b/src/schema/slack/functions/send_message.ts @@ -49,8 +49,8 @@ export default DefineFunction({ properties: { message_timestamp: { type: SlackTypes.timestamp, - description: "Message time stamp", - title: "Message time stamp", + description: "Message timestamp", + title: "Message timestamp", }, message_link: { type: SchemaTypes.string, diff --git a/src/schema/slack/functions/send_message_test.ts b/src/schema/slack/functions/send_message_test.ts index e4c2943a..e2ff6532 100644 --- a/src/schema/slack/functions/send_message_test.ts +++ b/src/schema/slack/functions/send_message_test.ts @@ -60,8 +60,8 @@ Deno.test("SendMessage generates valid FunctionManifest", () => { properties: { message_timestamp: { type: SlackTypes.timestamp, - description: "Message time stamp", - title: "Message time stamp", + description: "Message timestamp", + title: "Message timestamp", }, message_link: { type: SchemaTypes.string, diff --git a/src/schema/slack/functions/share_canvas.ts b/src/schema/slack/functions/share_canvas.ts index b474761c..09f7133f 100644 --- a/src/schema/slack/functions/share_canvas.ts +++ b/src/schema/slack/functions/share_canvas.ts @@ -2,7 +2,6 @@ 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", @@ -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", }, @@ -43,7 +42,7 @@ export default DefineFunction({ output_parameters: { properties: { canvas_id: { - type: SlackPrimitiveTypes.canvas_id, + type: SlackTypes.canvas_id, description: "Canvas link", title: "Canvas link", }, diff --git a/src/schema/slack/functions/share_canvas_test.ts b/src/schema/slack/functions/share_canvas_test.ts index 323587b9..6f2f066c 100644 --- a/src/schema/slack/functions/share_canvas_test.ts +++ b/src/schema/slack/functions/share_canvas_test.ts @@ -7,7 +7,6 @@ import { 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"; @@ -22,7 +21,7 @@ Deno.test("ShareCanvas generates valid FunctionManifest", () => { input_parameters: { properties: { canvas_id: { - type: SlackPrimitiveTypes.canvas_id, + type: SlackTypes.canvas_id, description: "Search all canvases", title: "Select a canvas", }, @@ -54,7 +53,7 @@ Deno.test("ShareCanvas generates valid FunctionManifest", () => { output_parameters: { properties: { canvas_id: { - type: SlackPrimitiveTypes.canvas_id, + type: SlackTypes.canvas_id, description: "Canvas link", title: "Canvas link", }, diff --git a/src/schema/slack/types/mod.ts b/src/schema/slack/types/mod.ts index 85d3c031..80495399 100644 --- a/src/schema/slack/types/mod.ts +++ b/src/schema/slack/types/mod.ts @@ -1,17 +1,18 @@ const SlackPrimitiveTypes = { - user_id: "slack#/types/user_id", + blocks: "slack#/types/blocks", + canvas_id: "slack#/types/canvas_id", + canvas_template_id: "slack#/types/canvas_template_id", channel_id: "slack#/types/channel_id", - usergroup_id: "slack#/types/usergroup_id", date: "slack#/types/date", - 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", + message_ts: "slack#/types/message_ts", + oauth2: "slack#/types/credential/oauth2", + rich_text: "slack#/types/rich_text", + team_id: "slack#/types/team_id", + timestamp: "slack#/types/timestamp", + user_id: "slack#/types/user_id", + usergroup_id: "slack#/types/usergroup_id", } as const; export type ValidSlackPrimitiveTypes =