Skip to content

Commit

Permalink
Add new list_id type. Make generation script throw an exception if it…
Browse files Browse the repository at this point in the history
… finds an unfamiliar parameter type. Update generated list functions with new list_id type.
  • Loading branch information
Filip Maj committed Sep 6, 2024
1 parent 794c175 commit 6b3e08a
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 19 deletions.
2 changes: 2 additions & 0 deletions src/schema/slack/functions/_scripts/generate
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ echo "Formatting Slack function files..."
deno fmt --quiet ../*.ts
echo "Linting Slack function files..."
deno lint --quiet ../*.ts
echo "Type-checking Slack function files..."
deno check --quiet ../*.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ const propertyToTypeScript = (
property: FunctionProperty,
): string => {
const typescript = [];
const sdkType = schemaTypeMap[property.type];
if (!sdkType) {
throw new Error(`Unrecognized type "${property.type}"! Maybe a new automation platform type was recently introduced? If so, add it to one of the type files under src/schema.`);
}
typescript.push(
`type: ${schemaTypeMap[property.type]}`,
`type: ${sdkType}`,
);
if (property.description) {
typescript.push(`description: ${sanitize(property.description)}`);
Expand Down
3 changes: 1 addition & 2 deletions src/schema/slack/functions/_scripts/src/templates/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import SlackTypes from "../../../../schema_types.ts";
import { InternalSlackTypes } from "../../../../types/custom/mod.ts";
import { AllowedTypeValue, AllowedTypeValueObject } from "./types.ts";
import { isCustomType } from "../../../../../../types/mod.ts";
import { isArrayFunctionProperty } from "../utils.ts";
import { isObjectFunctionProperty } from "../utils.ts";
import { isArrayFunctionProperty, isObjectFunctionProperty } from "../utils.ts";

export function autogeneratedComment(includeDate?: boolean): string {
const dateString = includeDate ? ` on ${new Date().toDateString()}` : "";
Expand Down
4 changes: 2 additions & 2 deletions src/schema/slack/functions/copy_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default DefineFunction({
input_parameters: {
properties: {
list_id: {
type: undefined,
type: SlackTypes.list_id,
description: "Search all lists",
title: "Select a list",
},
Expand Down Expand Up @@ -55,7 +55,7 @@ export default DefineFunction({
title: "Link",
},
list_id_value: {
type: undefined,
type: SlackTypes.list_id,
description: "List title",
title: "List title",
},
Expand Down
4 changes: 2 additions & 2 deletions src/schema/slack/functions/copy_list_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Deno.test("CopyList generates valid FunctionManifest", () => {
input_parameters: {
properties: {
list_id: {
type: undefined,
type: SlackTypes.list_id,
description: "Search all lists",
title: "Select a list",
},
Expand Down Expand Up @@ -63,7 +63,7 @@ Deno.test("CopyList generates valid FunctionManifest", () => {
title: "Link",
},
list_id_value: {
type: undefined,
type: SlackTypes.list_id,
description: "List title",
title: "List title",
},
Expand Down
3 changes: 2 additions & 1 deletion src/schema/slack/functions/delete_list_record.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** 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/delete_list_record",
Expand All @@ -9,7 +10,7 @@ export default DefineFunction({
input_parameters: {
properties: {
list_id: {
type: undefined,
type: SlackTypes.list_id,
description: "Select a list",
title: "Select a list",
},
Expand Down
3 changes: 2 additions & 1 deletion src/schema/slack/functions/delete_list_record_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { assertEquals, 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 DeleteListRecord from "./delete_list_record.ts";

Deno.test("DeleteListRecord generates valid FunctionManifest", () => {
Expand All @@ -16,7 +17,7 @@ Deno.test("DeleteListRecord generates valid FunctionManifest", () => {
input_parameters: {
properties: {
list_id: {
type: undefined,
type: SlackTypes.list_id,
description: "Select a list",
title: "Select a list",
},
Expand Down
3 changes: 2 additions & 1 deletion src/schema/slack/functions/list_add_record.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** 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/list_add_record",
Expand All @@ -10,7 +11,7 @@ export default DefineFunction({
input_parameters: {
properties: {
list_id: {
type: undefined,
type: SlackTypes.list_id,
description: "Search all lists",
title: "Select a list",
},
Expand Down
3 changes: 2 additions & 1 deletion src/schema/slack/functions/list_add_record_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
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 ListAddRecord from "./list_add_record.ts";

Deno.test("ListAddRecord generates valid FunctionManifest", () => {
Expand All @@ -21,7 +22,7 @@ Deno.test("ListAddRecord generates valid FunctionManifest", () => {
input_parameters: {
properties: {
list_id: {
type: undefined,
type: SlackTypes.list_id,
description: "Search all lists",
title: "Select a list",
},
Expand Down
2 changes: 1 addition & 1 deletion src/schema/slack/functions/lists_activity_feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default DefineFunction({
title: "User who updated the list item",
},
list_id: {
type: undefined,
type: SlackTypes.list_id,
description: "Select a list",
title: "Select a list",
},
Expand Down
2 changes: 1 addition & 1 deletion src/schema/slack/functions/lists_activity_feed_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Deno.test("ListsActivityFeed generates valid FunctionManifest", () => {
title: "User who updated the list item",
},
list_id: {
type: undefined,
type: SlackTypes.list_id,
description: "Select a list",
title: "Select a list",
},
Expand Down
4 changes: 2 additions & 2 deletions src/schema/slack/functions/share_list_users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default DefineFunction({
input_parameters: {
properties: {
file_id: {
type: undefined,
type: SlackTypes.list_id,
description: "Search all list",
title: "Select a List",
},
Expand All @@ -37,7 +37,7 @@ export default DefineFunction({
output_parameters: {
properties: {
file_id: {
type: undefined,
type: SlackTypes.list_id,
description: "List title",
title: "List title",
},
Expand Down
4 changes: 2 additions & 2 deletions src/schema/slack/functions/share_list_users_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Deno.test("ShareListUsers generates valid FunctionManifest", () => {
input_parameters: {
properties: {
file_id: {
type: undefined,
type: SlackTypes.list_id,
description: "Search all list",
title: "Select a List",
},
Expand All @@ -48,7 +48,7 @@ Deno.test("ShareListUsers generates valid FunctionManifest", () => {
output_parameters: {
properties: {
file_id: {
type: undefined,
type: SlackTypes.list_id,
description: "List title",
title: "List title",
},
Expand Down
3 changes: 2 additions & 1 deletion src/schema/slack/functions/update_list_record.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** 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/update_list_record",
Expand All @@ -9,7 +10,7 @@ export default DefineFunction({
input_parameters: {
properties: {
list_id: {
type: undefined,
type: SlackTypes.list_id,
description: "Select a list",
title: "Select a list",
},
Expand Down
3 changes: 2 additions & 1 deletion src/schema/slack/functions/update_list_record_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
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 UpdateListRecord from "./update_list_record.ts";

Deno.test("UpdateListRecord generates valid FunctionManifest", () => {
Expand All @@ -20,7 +21,7 @@ Deno.test("UpdateListRecord generates valid FunctionManifest", () => {
input_parameters: {
properties: {
list_id: {
type: undefined,
type: SlackTypes.list_id,
description: "Select a list",
title: "Select a list",
},
Expand Down
1 change: 1 addition & 0 deletions src/schema/slack/types/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const SlackPrimitiveTypes = {
date: "slack#/types/date",
expanded_rich_text: "slack#/types/expanded_rich_text",
file_id: "slack#/types/file_id",
list_id: "slack#/types/list_id",
message_ts: "slack#/types/message_ts",
oauth2: "slack#/types/credential/oauth2",
rich_text: "slack#/types/rich_text",
Expand Down

0 comments on commit 6b3e08a

Please sign in to comment.