Skip to content

Commit a58ecb7

Browse files
committed
extract shared code
1 parent 5b09b9f commit a58ecb7

3 files changed

Lines changed: 32 additions & 64 deletions

File tree

apps/sim/tools/slack/get_canvas.ts

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,8 @@
1-
import type {
2-
SlackCanvasFile,
3-
SlackGetCanvasParams,
4-
SlackGetCanvasResponse,
5-
} from '@/tools/slack/types'
1+
import type { SlackGetCanvasParams, SlackGetCanvasResponse } from '@/tools/slack/types'
62
import { CANVAS_FILE_OUTPUT_PROPERTIES } from '@/tools/slack/types'
3+
import { mapCanvasFile } from '@/tools/slack/utils'
74
import type { ToolConfig } from '@/tools/types'
85

9-
const mapCanvasFile = (file: SlackCanvasFile): SlackCanvasFile => ({
10-
id: file.id,
11-
created: file.created ?? null,
12-
timestamp: file.timestamp ?? null,
13-
name: file.name ?? null,
14-
title: file.title ?? null,
15-
mimetype: file.mimetype ?? null,
16-
filetype: file.filetype ?? null,
17-
pretty_type: file.pretty_type ?? null,
18-
user: file.user ?? null,
19-
editable: file.editable ?? null,
20-
size: file.size ?? null,
21-
mode: file.mode ?? null,
22-
is_external: file.is_external ?? null,
23-
is_public: file.is_public ?? null,
24-
url_private: file.url_private ?? null,
25-
url_private_download: file.url_private_download ?? null,
26-
permalink: file.permalink ?? null,
27-
channels: file.channels ?? [],
28-
groups: file.groups ?? [],
29-
ims: file.ims ?? [],
30-
canvas_readtime: file.canvas_readtime ?? null,
31-
is_channel_space: file.is_channel_space ?? null,
32-
linked_channel_id: file.linked_channel_id ?? null,
33-
canvas_creator_id: file.canvas_creator_id ?? null,
34-
})
35-
366
export const slackGetCanvasTool: ToolConfig<SlackGetCanvasParams, SlackGetCanvasResponse> = {
377
id: 'slack_get_canvas',
388
name: 'Slack Get Canvas Info',

apps/sim/tools/slack/list_canvases.ts

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,8 @@
1-
import type {
2-
SlackCanvasFile,
3-
SlackListCanvasesParams,
4-
SlackListCanvasesResponse,
5-
} from '@/tools/slack/types'
1+
import type { SlackListCanvasesParams, SlackListCanvasesResponse } from '@/tools/slack/types'
62
import { CANVAS_FILE_OUTPUT_PROPERTIES, CANVAS_PAGING_OUTPUT_PROPERTIES } from '@/tools/slack/types'
3+
import { mapCanvasFile } from '@/tools/slack/utils'
74
import type { ToolConfig } from '@/tools/types'
85

9-
const mapCanvasFile = (file: SlackCanvasFile): SlackCanvasFile => ({
10-
id: file.id,
11-
created: file.created ?? null,
12-
timestamp: file.timestamp ?? null,
13-
name: file.name ?? null,
14-
title: file.title ?? null,
15-
mimetype: file.mimetype ?? null,
16-
filetype: file.filetype ?? null,
17-
pretty_type: file.pretty_type ?? null,
18-
user: file.user ?? null,
19-
editable: file.editable ?? null,
20-
size: file.size ?? null,
21-
mode: file.mode ?? null,
22-
is_external: file.is_external ?? null,
23-
is_public: file.is_public ?? null,
24-
url_private: file.url_private ?? null,
25-
url_private_download: file.url_private_download ?? null,
26-
permalink: file.permalink ?? null,
27-
channels: file.channels ?? [],
28-
groups: file.groups ?? [],
29-
ims: file.ims ?? [],
30-
canvas_readtime: file.canvas_readtime ?? null,
31-
is_channel_space: file.is_channel_space ?? null,
32-
linked_channel_id: file.linked_channel_id ?? null,
33-
canvas_creator_id: file.canvas_creator_id ?? null,
34-
})
35-
366
export const slackListCanvasesTool: ToolConfig<SlackListCanvasesParams, SlackListCanvasesResponse> =
377
{
388
id: 'slack_list_canvases',

apps/sim/tools/slack/utils.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { SlackCanvasFile } from '@/tools/slack/types'
2+
3+
export const mapCanvasFile = (file: SlackCanvasFile): SlackCanvasFile => ({
4+
id: file.id,
5+
created: file.created ?? null,
6+
timestamp: file.timestamp ?? null,
7+
name: file.name ?? null,
8+
title: file.title ?? null,
9+
mimetype: file.mimetype ?? null,
10+
filetype: file.filetype ?? null,
11+
pretty_type: file.pretty_type ?? null,
12+
user: file.user ?? null,
13+
editable: file.editable ?? null,
14+
size: file.size ?? null,
15+
mode: file.mode ?? null,
16+
is_external: file.is_external ?? null,
17+
is_public: file.is_public ?? null,
18+
url_private: file.url_private ?? null,
19+
url_private_download: file.url_private_download ?? null,
20+
permalink: file.permalink ?? null,
21+
channels: file.channels ?? [],
22+
groups: file.groups ?? [],
23+
ims: file.ims ?? [],
24+
canvas_readtime: file.canvas_readtime ?? null,
25+
is_channel_space: file.is_channel_space ?? null,
26+
linked_channel_id: file.linked_channel_id ?? null,
27+
canvas_creator_id: file.canvas_creator_id ?? null,
28+
})

0 commit comments

Comments
 (0)