@zapier/trello-connector 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +93 -0
  2. package/NOTICE +8 -0
  3. package/README.md +135 -2
  4. package/SKILL.md +139 -0
  5. package/cli.js +71 -0
  6. package/cli.ts +5 -0
  7. package/connections.ts +26 -0
  8. package/dist/cli.js +4 -0
  9. package/dist/index.js +2654 -0
  10. package/index.ts +145 -0
  11. package/package.json +59 -4
  12. package/preflight.sh +157 -0
  13. package/references/trello-api-gotchas.md +81 -0
  14. package/scripts/.gitkeep +0 -0
  15. package/scripts/addCardAttachment.ts +107 -0
  16. package/scripts/addCardLabel.ts +93 -0
  17. package/scripts/addCardMember.ts +93 -0
  18. package/scripts/addChecklistItem.ts +98 -0
  19. package/scripts/addMemberToBoard.ts +57 -0
  20. package/scripts/archiveCard.ts +67 -0
  21. package/scripts/closeBoard.ts +62 -0
  22. package/scripts/completeChecklistItem.ts +56 -0
  23. package/scripts/copyBoard.ts +81 -0
  24. package/scripts/createBoard.ts +72 -0
  25. package/scripts/createCard.ts +266 -0
  26. package/scripts/createChecklist.ts +50 -0
  27. package/scripts/createComment.ts +71 -0
  28. package/scripts/createLabel.ts +72 -0
  29. package/scripts/createList.ts +100 -0
  30. package/scripts/deleteChecklist.ts +38 -0
  31. package/scripts/findBoard.ts +62 -0
  32. package/scripts/findChecklist.ts +51 -0
  33. package/scripts/findChecklistItem.ts +49 -0
  34. package/scripts/findLabel.ts +54 -0
  35. package/scripts/findList.ts +55 -0
  36. package/scripts/findOrganizationMember.ts +59 -0
  37. package/scripts/getAction.ts +58 -0
  38. package/scripts/getBoard.ts +52 -0
  39. package/scripts/getCard.ts +79 -0
  40. package/scripts/getChecklist.ts +45 -0
  41. package/scripts/getChecklistItem.ts +48 -0
  42. package/scripts/getCurrentMember.ts +52 -0
  43. package/scripts/getLabel.ts +46 -0
  44. package/scripts/getList.ts +47 -0
  45. package/scripts/getMember.ts +52 -0
  46. package/scripts/getOrganization.ts +46 -0
  47. package/scripts/listBoardMembers.ts +58 -0
  48. package/scripts/listBoards.ts +78 -0
  49. package/scripts/listCardAttachments.ts +55 -0
  50. package/scripts/listCards.ts +129 -0
  51. package/scripts/listCustomFields.ts +62 -0
  52. package/scripts/listLabels.ts +52 -0
  53. package/scripts/listLists.ts +61 -0
  54. package/scripts/listOrganizations.ts +50 -0
  55. package/scripts/moveCard.ts +68 -0
  56. package/scripts/removeCardLabel.ts +43 -0
  57. package/scripts/searchCards.ts +153 -0
  58. package/scripts/updateCard.ts +184 -0
  59. package/tsup.config.ts +63 -0
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+ import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
3
+ import { z } from "zod";
4
+
5
+ import { connectionResolvers } from "../connections.ts";
6
+ import { nameContains, TRELLO_BASE, trelloError } from "../lib/trello.ts";
7
+
8
+ const inputSchema = z
9
+ .object({ id: z.string().describe("24-char hex card id."), name: z.string() })
10
+ .strict();
11
+ const itemSchema = z.array(
12
+ z.object({
13
+ id: z
14
+ .string()
15
+ .regex(new RegExp("^[0-9a-fA-F]{24}$"))
16
+ .describe("Trello object id (24 hex chars)."),
17
+ name: z.string(),
18
+ idCard: z.string().nullable().optional(),
19
+ }),
20
+ );
21
+ const outputSchema = z.object({ items: itemSchema });
22
+
23
+ const definition = defineTool({
24
+ name: "findChecklist",
25
+ title: "Find Checklist",
26
+ description:
27
+ "Find checklists on a card whose name contains the search string.",
28
+ inputSchema,
29
+ outputSchema,
30
+ annotations: {
31
+ readOnlyHint: true,
32
+ destructiveHint: false,
33
+ idempotentHint: true,
34
+ openWorldHint: true,
35
+ },
36
+ connection: "trello",
37
+ run: async (input, ctx) => {
38
+ const url = `${TRELLO_BASE}/cards/${encodeURIComponent(input.id)}/checklists`;
39
+ const res = await ctx.fetch(url, { method: "GET" });
40
+ if (!res.ok) await trelloError("findChecklist", res);
41
+ const checklists = (await res.json()) as Array<{ name?: string }>;
42
+ const items = (Array.isArray(checklists) ? checklists : []).filter((cl) =>
43
+ nameContains(cl.name ?? "", input.name),
44
+ );
45
+ return { items };
46
+ },
47
+ });
48
+
49
+ export default definition;
50
+
51
+ await handleIfScriptMain(import.meta, definition, { connectionResolvers });
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
3
+ import { z } from "zod";
4
+
5
+ import { connectionResolvers } from "../connections.ts";
6
+ import { nameContains, TRELLO_BASE, trelloError } from "../lib/trello.ts";
7
+
8
+ const inputSchema = z.object({ id: z.string(), name: z.string() }).strict();
9
+ const itemSchema = z.array(
10
+ z.object({
11
+ id: z
12
+ .string()
13
+ .regex(new RegExp("^[0-9a-fA-F]{24}$"))
14
+ .describe("Trello object id (24 hex chars)."),
15
+ name: z.string(),
16
+ state: z.enum(["complete", "incomplete"]),
17
+ idChecklist: z.string().nullable().optional(),
18
+ }),
19
+ );
20
+ const outputSchema = z.object({ items: itemSchema });
21
+
22
+ const definition = defineTool({
23
+ name: "findChecklistItem",
24
+ title: "Find Checklist Item",
25
+ description: "Find checklist items whose name contains the search string.",
26
+ inputSchema,
27
+ outputSchema,
28
+ annotations: {
29
+ readOnlyHint: true,
30
+ destructiveHint: false,
31
+ idempotentHint: true,
32
+ openWorldHint: true,
33
+ },
34
+ connection: "trello",
35
+ run: async (input, ctx) => {
36
+ const url = `${TRELLO_BASE}/checklists/${encodeURIComponent(input.id)}/checkItems`;
37
+ const res = await ctx.fetch(url, { method: "GET" });
38
+ if (!res.ok) await trelloError("findChecklistItem", res);
39
+ const checkItems = (await res.json()) as Array<{ name?: string }>;
40
+ const items = (Array.isArray(checkItems) ? checkItems : []).filter((item) =>
41
+ nameContains(item.name ?? "", input.name),
42
+ );
43
+ return { items };
44
+ },
45
+ });
46
+
47
+ export default definition;
48
+
49
+ await handleIfScriptMain(import.meta, definition, { connectionResolvers });
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
3
+ import { z } from "zod";
4
+
5
+ import { connectionResolvers } from "../connections.ts";
6
+ import { nameContains, TRELLO_BASE, trelloError } from "../lib/trello.ts";
7
+
8
+ const inputSchema = z
9
+ .object({
10
+ id: z.string().describe("24-char hex board id."),
11
+ name: z.string(),
12
+ })
13
+ .strict();
14
+ const itemSchema = z.array(
15
+ z.object({
16
+ id: z
17
+ .string()
18
+ .regex(new RegExp("^[0-9a-fA-F]{24}$"))
19
+ .describe("Trello object id (24 hex chars)."),
20
+ idBoard: z.string(),
21
+ name: z.string().nullable().optional(),
22
+ color: z.string().nullable().optional(),
23
+ }),
24
+ );
25
+ const outputSchema = z.object({ items: itemSchema });
26
+
27
+ const definition = defineTool({
28
+ name: "findLabel",
29
+ title: "Find Label",
30
+ description: "Find labels on a board whose name contains the search string.",
31
+ inputSchema,
32
+ outputSchema,
33
+ annotations: {
34
+ readOnlyHint: true,
35
+ destructiveHint: false,
36
+ idempotentHint: true,
37
+ openWorldHint: true,
38
+ },
39
+ connection: "trello",
40
+ run: async (input, ctx) => {
41
+ const url = `${TRELLO_BASE}/boards/${encodeURIComponent(input.id)}/labels`;
42
+ const res = await ctx.fetch(url, { method: "GET" });
43
+ if (!res.ok) await trelloError("findLabel", res);
44
+ const labels = (await res.json()) as Array<{ name?: string | null }>;
45
+ const items = (Array.isArray(labels) ? labels : []).filter((label) =>
46
+ nameContains(label.name ?? "", input.name),
47
+ );
48
+ return { items };
49
+ },
50
+ });
51
+
52
+ export default definition;
53
+
54
+ await handleIfScriptMain(import.meta, definition, { connectionResolvers });
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
3
+ import { z } from "zod";
4
+
5
+ import { connectionResolvers } from "../connections.ts";
6
+ import { nameContains, TRELLO_BASE, trelloError } from "../lib/trello.ts";
7
+
8
+ const inputSchema = z
9
+ .object({
10
+ id: z.string().describe("24-char hex board id."),
11
+ name: z.string(),
12
+ })
13
+ .strict();
14
+ const itemSchema = z.array(
15
+ z.object({
16
+ id: z
17
+ .string()
18
+ .regex(new RegExp("^[0-9a-fA-F]{24}$"))
19
+ .describe("Trello object id (24 hex chars)."),
20
+ name: z.string(),
21
+ closed: z.boolean().nullable().optional(),
22
+ idBoard: z.string(),
23
+ pos: z.number().nullable().optional(),
24
+ }),
25
+ );
26
+ const outputSchema = z.object({ items: itemSchema });
27
+
28
+ const definition = defineTool({
29
+ name: "findList",
30
+ title: "Find List",
31
+ description: "Find lists on a board whose name contains the search string.",
32
+ inputSchema,
33
+ outputSchema,
34
+ annotations: {
35
+ readOnlyHint: true,
36
+ destructiveHint: false,
37
+ idempotentHint: true,
38
+ openWorldHint: true,
39
+ },
40
+ connection: "trello",
41
+ run: async (input, ctx) => {
42
+ const url = `${TRELLO_BASE}/boards/${encodeURIComponent(input.id)}/lists`;
43
+ const res = await ctx.fetch(url, { method: "GET" });
44
+ if (!res.ok) await trelloError("findList", res);
45
+ const lists = (await res.json()) as Array<{ name?: string }>;
46
+ const items = (Array.isArray(lists) ? lists : []).filter((list) =>
47
+ nameContains(list.name ?? "", input.name),
48
+ );
49
+ return { items };
50
+ },
51
+ });
52
+
53
+ export default definition;
54
+
55
+ await handleIfScriptMain(import.meta, definition, { connectionResolvers });
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+ import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
3
+ import { z } from "zod";
4
+
5
+ import { connectionResolvers } from "../connections.ts";
6
+ import { TRELLO_BASE, trelloError } from "../lib/trello.ts";
7
+
8
+ const inputSchema = z
9
+ .object({ query: z.string(), organizationId: z.string().optional() })
10
+ .strict();
11
+ const itemSchema = z.array(
12
+ z.object({
13
+ id: z
14
+ .string()
15
+ .regex(new RegExp("^[0-9a-fA-F]{24}$"))
16
+ .describe("Trello object id (24 hex chars)."),
17
+ username: z.string(),
18
+ fullName: z.string().nullable().optional(),
19
+ initials: z.string().nullable().optional(),
20
+ avatarUrl: z.string().nullable().optional(),
21
+ email: z
22
+ .string()
23
+ .nullable()
24
+ .describe("Present only when token has account read scope.")
25
+ .optional(),
26
+ }),
27
+ );
28
+ const outputSchema = z.object({ items: itemSchema });
29
+
30
+ const definition = defineTool({
31
+ name: "findOrganizationMember",
32
+ title: "Find Organization Member",
33
+ description: "Find members via GET /search/members/.",
34
+ inputSchema,
35
+ outputSchema,
36
+ annotations: {
37
+ readOnlyHint: true,
38
+ destructiveHint: false,
39
+ idempotentHint: true,
40
+ openWorldHint: true,
41
+ },
42
+ connection: "trello",
43
+ run: async (input, ctx) => {
44
+ const url = new URL(`${TRELLO_BASE}/search/members/`);
45
+ url.searchParams.set("query", input.query);
46
+ url.searchParams.set("limit", "20");
47
+ if (input.organizationId !== undefined) {
48
+ url.searchParams.set("idOrganization", input.organizationId);
49
+ }
50
+ const res = await ctx.fetch(url.toString(), { method: "GET" });
51
+ if (!res.ok) await trelloError("findOrganizationMember", res);
52
+ const data = await res.json();
53
+ return { items: Array.isArray(data) ? data : [] };
54
+ },
55
+ });
56
+
57
+ export default definition;
58
+
59
+ await handleIfScriptMain(import.meta, definition, { connectionResolvers });
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+ import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
3
+ import { z } from "zod";
4
+
5
+ import { connectionResolvers } from "../connections.ts";
6
+
7
+ const inputSchema = z.object({ id: z.string() }).strict();
8
+ const outputSchema = z.object({
9
+ id: z
10
+ .string()
11
+ .regex(new RegExp("^[0-9a-fA-F]{24}$"))
12
+ .describe("Trello object id (24 hex chars)."),
13
+ type: z.string(),
14
+ date: z.string().datetime({ offset: true }),
15
+ data: z
16
+ .object({
17
+ text: z.string().nullable().optional(),
18
+ card: z
19
+ .object({
20
+ id: z.string().nullable().optional(),
21
+ name: z.string().nullable().optional(),
22
+ })
23
+ .nullable()
24
+ .optional(),
25
+ })
26
+ .nullable()
27
+ .optional(),
28
+ });
29
+
30
+ const definition = defineTool({
31
+ name: "getAction",
32
+ title: "Get Action",
33
+ description: "Get an action (activity) by id, including comments.",
34
+ inputSchema,
35
+ outputSchema,
36
+ annotations: {
37
+ readOnlyHint: true,
38
+ destructiveHint: false,
39
+ idempotentHint: true,
40
+ openWorldHint: true,
41
+ },
42
+ connection: "trello",
43
+ run: async (input, ctx) => {
44
+ const url = `https://api.trello.com/1/actions/${encodeURIComponent(input.id)}`;
45
+ const res = await ctx.fetch(url, {
46
+ method: "GET",
47
+ });
48
+ if (!res.ok) {
49
+ const errBody = await res.text();
50
+ throw new Error(`Trello getAction ${res.status}: ${errBody}`);
51
+ }
52
+ return res.json();
53
+ },
54
+ });
55
+
56
+ export default definition;
57
+
58
+ await handleIfScriptMain(import.meta, definition, { connectionResolvers });
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
3
+ import { z } from "zod";
4
+
5
+ import { connectionResolvers } from "../connections.ts";
6
+
7
+ const inputSchema = z
8
+ .object({ id: z.string().describe("24-char hex board id.") })
9
+ .strict();
10
+ const outputSchema = z.object({
11
+ id: z
12
+ .string()
13
+ .regex(new RegExp("^[0-9a-fA-F]{24}$"))
14
+ .describe("Trello object id (24 hex chars)."),
15
+ name: z.string(),
16
+ desc: z.string().nullable().optional(),
17
+ closed: z.boolean().nullable().optional(),
18
+ idOrganization: z.string().nullable().optional(),
19
+ url: z.string().nullable().optional(),
20
+ shortUrl: z.string().nullable().optional(),
21
+ dateLastActivity: z.string().datetime({ offset: true }).nullable().optional(),
22
+ });
23
+
24
+ const definition = defineTool({
25
+ name: "getBoard",
26
+ title: "Get Board",
27
+ description: "Get a board by id.",
28
+ inputSchema,
29
+ outputSchema,
30
+ annotations: {
31
+ readOnlyHint: true,
32
+ destructiveHint: false,
33
+ idempotentHint: true,
34
+ openWorldHint: true,
35
+ },
36
+ connection: "trello",
37
+ run: async (input, ctx) => {
38
+ const url = `https://api.trello.com/1/boards/${encodeURIComponent(input.id)}`;
39
+ const res = await ctx.fetch(url, {
40
+ method: "GET",
41
+ });
42
+ if (!res.ok) {
43
+ const errBody = await res.text();
44
+ throw new Error(`Trello getBoard ${res.status}: ${errBody}`);
45
+ }
46
+ return res.json();
47
+ },
48
+ });
49
+
50
+ export default definition;
51
+
52
+ await handleIfScriptMain(import.meta, definition, { connectionResolvers });
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+ import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
3
+ import { z } from "zod";
4
+
5
+ import { connectionResolvers } from "../connections.ts";
6
+
7
+ const inputSchema = z
8
+ .object({ id: z.string().describe("24-char hex card id.") })
9
+ .strict();
10
+ const outputSchema = z.object({
11
+ id: z
12
+ .string()
13
+ .regex(new RegExp("^[0-9a-fA-F]{24}$"))
14
+ .describe("Trello object id (24 hex chars)."),
15
+ name: z.string(),
16
+ desc: z.string().nullable().optional(),
17
+ closed: z.boolean().nullable().optional(),
18
+ idBoard: z.string(),
19
+ idList: z.string(),
20
+ idShort: z.number().int().nullable().optional(),
21
+ shortLink: z.string().nullable().optional(),
22
+ shortUrl: z.string().nullable().optional(),
23
+ url: z.string().nullable().optional(),
24
+ due: z.union([z.string().datetime({ offset: true }), z.null()]).optional(),
25
+ dueComplete: z.boolean().nullable().optional(),
26
+ dateLastActivity: z.string().datetime({ offset: true }).nullable().optional(),
27
+ idLabels: z.array(z.string()).nullable().optional(),
28
+ idMembers: z.array(z.string()).nullable().optional(),
29
+ labels: z
30
+ .array(
31
+ z.object({
32
+ id: z
33
+ .string()
34
+ .regex(new RegExp("^[0-9a-fA-F]{24}$"))
35
+ .describe("Trello object id (24 hex chars)."),
36
+ idBoard: z.string(),
37
+ name: z.string().nullable().optional(),
38
+ color: z.string().nullable().optional(),
39
+ }),
40
+ )
41
+ .nullable()
42
+ .optional(),
43
+ pos: z.number().nullable().optional(),
44
+ customFields: z
45
+ .record(z.string(), z.any())
46
+ .nullable()
47
+ .describe("Custom field values keyed by field name when requested.")
48
+ .optional(),
49
+ });
50
+
51
+ const definition = defineTool({
52
+ name: "getCard",
53
+ title: "Get Card",
54
+ description: "Get a card by id.",
55
+ inputSchema,
56
+ outputSchema,
57
+ annotations: {
58
+ readOnlyHint: true,
59
+ destructiveHint: false,
60
+ idempotentHint: true,
61
+ openWorldHint: true,
62
+ },
63
+ connection: "trello",
64
+ run: async (input, ctx) => {
65
+ const url = `https://api.trello.com/1/cards/${encodeURIComponent(input.id)}`;
66
+ const res = await ctx.fetch(url, {
67
+ method: "GET",
68
+ });
69
+ if (!res.ok) {
70
+ const errBody = await res.text();
71
+ throw new Error(`Trello getCard ${res.status}: ${errBody}`);
72
+ }
73
+ return res.json();
74
+ },
75
+ });
76
+
77
+ export default definition;
78
+
79
+ await handleIfScriptMain(import.meta, definition, { connectionResolvers });
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
3
+ import { z } from "zod";
4
+
5
+ import { connectionResolvers } from "../connections.ts";
6
+
7
+ const inputSchema = z.object({ id: z.string() }).strict();
8
+ const outputSchema = z.object({
9
+ id: z
10
+ .string()
11
+ .regex(new RegExp("^[0-9a-fA-F]{24}$"))
12
+ .describe("Trello object id (24 hex chars)."),
13
+ name: z.string(),
14
+ idCard: z.string().nullable().optional(),
15
+ });
16
+
17
+ const definition = defineTool({
18
+ name: "getChecklist",
19
+ title: "Get Checklist",
20
+ description: "Get a checklist by id.",
21
+ inputSchema,
22
+ outputSchema,
23
+ annotations: {
24
+ readOnlyHint: true,
25
+ destructiveHint: false,
26
+ idempotentHint: true,
27
+ openWorldHint: true,
28
+ },
29
+ connection: "trello",
30
+ run: async (input, ctx) => {
31
+ const url = `https://api.trello.com/1/checklists/${encodeURIComponent(input.id)}`;
32
+ const res = await ctx.fetch(url, {
33
+ method: "GET",
34
+ });
35
+ if (!res.ok) {
36
+ const errBody = await res.text();
37
+ throw new Error(`Trello getChecklist ${res.status}: ${errBody}`);
38
+ }
39
+ return res.json();
40
+ },
41
+ });
42
+
43
+ export default definition;
44
+
45
+ await handleIfScriptMain(import.meta, definition, { connectionResolvers });
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
3
+ import { z } from "zod";
4
+
5
+ import { connectionResolvers } from "../connections.ts";
6
+
7
+ const inputSchema = z
8
+ .object({ id: z.string(), idCheckItem: z.string() })
9
+ .strict();
10
+ const outputSchema = z.object({
11
+ id: z
12
+ .string()
13
+ .regex(new RegExp("^[0-9a-fA-F]{24}$"))
14
+ .describe("Trello object id (24 hex chars)."),
15
+ name: z.string(),
16
+ state: z.enum(["complete", "incomplete"]),
17
+ idChecklist: z.string().nullable().optional(),
18
+ });
19
+
20
+ const definition = defineTool({
21
+ name: "getChecklistItem",
22
+ title: "Get Checklist Item",
23
+ description: "Get a checklist item by id.",
24
+ inputSchema,
25
+ outputSchema,
26
+ annotations: {
27
+ readOnlyHint: true,
28
+ destructiveHint: false,
29
+ idempotentHint: true,
30
+ openWorldHint: true,
31
+ },
32
+ connection: "trello",
33
+ run: async (input, ctx) => {
34
+ const url = `https://api.trello.com/1/checklists/${encodeURIComponent(input.id)}/checkItems/${encodeURIComponent(input.idCheckItem)}`;
35
+ const res = await ctx.fetch(url, {
36
+ method: "GET",
37
+ });
38
+ if (!res.ok) {
39
+ const errBody = await res.text();
40
+ throw new Error(`Trello getChecklistItem ${res.status}: ${errBody}`);
41
+ }
42
+ return res.json();
43
+ },
44
+ });
45
+
46
+ export default definition;
47
+
48
+ await handleIfScriptMain(import.meta, definition, { connectionResolvers });
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
3
+ import { z } from "zod";
4
+
5
+ import { connectionResolvers } from "../connections.ts";
6
+
7
+ const inputSchema = z.object({}).strict();
8
+ const outputSchema = z.object({
9
+ id: z
10
+ .string()
11
+ .regex(new RegExp("^[0-9a-fA-F]{24}$"))
12
+ .describe("Trello object id (24 hex chars)."),
13
+ username: z.string(),
14
+ fullName: z.string().nullable().optional(),
15
+ initials: z.string().nullable().optional(),
16
+ avatarUrl: z.string().nullable().optional(),
17
+ email: z
18
+ .string()
19
+ .nullable()
20
+ .describe("Present only when token has account read scope.")
21
+ .optional(),
22
+ });
23
+
24
+ const definition = defineTool({
25
+ name: "getCurrentMember",
26
+ title: "Get Current Member",
27
+ description: "Get the authenticated member (identity resolver).",
28
+ inputSchema,
29
+ outputSchema,
30
+ annotations: {
31
+ readOnlyHint: true,
32
+ destructiveHint: false,
33
+ idempotentHint: true,
34
+ openWorldHint: true,
35
+ },
36
+ connection: "trello",
37
+ run: async (_input, ctx) => {
38
+ const url = `https://api.trello.com/1/members/me`;
39
+ const res = await ctx.fetch(url, {
40
+ method: "GET",
41
+ });
42
+ if (!res.ok) {
43
+ const errBody = await res.text();
44
+ throw new Error(`Trello getCurrentMember ${res.status}: ${errBody}`);
45
+ }
46
+ return res.json();
47
+ },
48
+ });
49
+
50
+ export default definition;
51
+
52
+ await handleIfScriptMain(import.meta, definition, { connectionResolvers });
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
3
+ import { z } from "zod";
4
+
5
+ import { connectionResolvers } from "../connections.ts";
6
+
7
+ const inputSchema = z.object({ id: z.string() }).strict();
8
+ const outputSchema = z.object({
9
+ id: z
10
+ .string()
11
+ .regex(new RegExp("^[0-9a-fA-F]{24}$"))
12
+ .describe("Trello object id (24 hex chars)."),
13
+ idBoard: z.string(),
14
+ name: z.string().nullable().optional(),
15
+ color: z.string().nullable().optional(),
16
+ });
17
+
18
+ const definition = defineTool({
19
+ name: "getLabel",
20
+ title: "Get Label",
21
+ description: "Get a label by id.",
22
+ inputSchema,
23
+ outputSchema,
24
+ annotations: {
25
+ readOnlyHint: true,
26
+ destructiveHint: false,
27
+ idempotentHint: true,
28
+ openWorldHint: true,
29
+ },
30
+ connection: "trello",
31
+ run: async (input, ctx) => {
32
+ const url = `https://api.trello.com/1/labels/${encodeURIComponent(input.id)}`;
33
+ const res = await ctx.fetch(url, {
34
+ method: "GET",
35
+ });
36
+ if (!res.ok) {
37
+ const errBody = await res.text();
38
+ throw new Error(`Trello getLabel ${res.status}: ${errBody}`);
39
+ }
40
+ return res.json();
41
+ },
42
+ });
43
+
44
+ export default definition;
45
+
46
+ await handleIfScriptMain(import.meta, definition, { connectionResolvers });