@frogbotai/piece-trello 0.22.0 → 0.24.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.
- package/README.md +41 -0
- package/dist/actions.d.ts +233 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +176 -0
- package/dist/actions.js.map +1 -0
- package/dist/client.d.ts +37 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +55 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +7 -0
- package/dist/config.js.map +1 -0
- package/dist/files.d.ts +10 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +50 -0
- package/dist/files.js.map +1 -0
- package/dist/index.d.ts +656 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -38
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +18 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +20 -0
- package/dist/options.js.map +1 -0
- package/dist/schemas.d.ts +20 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +24 -0
- package/dist/schemas.js.map +1 -0
- package/dist/triggers.d.ts +138 -0
- package/dist/triggers.d.ts.map +1 -0
- package/dist/triggers.js +104 -0
- package/dist/triggers.js.map +1 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# `@frogbotai/piece-trello`
|
|
2
|
+
|
|
3
|
+
Manage Trello cards and attachments, make authenticated API calls, and react to card events.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createTrello } from '@frogbotai/piece-trello';
|
|
9
|
+
|
|
10
|
+
export const trello = createTrello({
|
|
11
|
+
auth: {
|
|
12
|
+
username: process.env.TRELLO_API_KEY!,
|
|
13
|
+
password: process.env.TRELLO_TOKEN!,
|
|
14
|
+
applicationSecret: process.env.TRELLO_APPLICATION_SECRET!,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Create an application at [Trello's Power-Up administration page](https://trello.com/power-ups/admin), then copy its API key and application secret. Generate and authorize a token from the API Key page. The API key and token authenticate API requests; the application secret verifies webhook deliveries.
|
|
20
|
+
|
|
21
|
+
## Actions
|
|
22
|
+
|
|
23
|
+
| Upstream action slug | Previous wrapper export | Native action | Notes |
|
|
24
|
+
| ------------------------ | ----------------------- | ---------------------- | ---------------------------------- |
|
|
25
|
+
| `create_card` | `createCard` | `createCard` | |
|
|
26
|
+
| `get_card` | `getCard` | `getCard` | |
|
|
27
|
+
| `update_card` | `updateCard` | `updateCard` | |
|
|
28
|
+
| `delete_card` | `deleteCard` | `deleteCard` | |
|
|
29
|
+
| `get_card_attachments` | `getCardAttachments` | `listCardAttachments` | Uses collection naming. |
|
|
30
|
+
| `add_card_attachment` | `addCardAttachment` | `addCardAttachment` | Uploads from FrogBot files. |
|
|
31
|
+
| `get_card_attachment` | `getCardAttachment` | `getCardAttachment` | |
|
|
32
|
+
| `delete_card_attachment` | `deleteCardAttachment` | `deleteCardAttachment` | |
|
|
33
|
+
| `custom_api_call` | `customApiCall` | `customApiCall` | Auth is added as query parameters. |
|
|
34
|
+
|
|
35
|
+
## Triggers
|
|
36
|
+
|
|
37
|
+
| Upstream trigger slug | Native trigger | Type | Notes |
|
|
38
|
+
| --------------------- | ----------------- | --------- | --------------------------------------- |
|
|
39
|
+
| `new_card` | `cardCreated` | `webhook` | Board or optional list scope. |
|
|
40
|
+
| `card_moved_to_list` | `cardMovedToList` | `webhook` | Registers against the destination list. |
|
|
41
|
+
| `deadline` | `cardDeadline` | `polling` | Polls every five minutes. |
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { type PieceRunArgs } from 'frogbot/pieces';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { Trello } from './client.js';
|
|
4
|
+
import { boardOptions, labelOptions, listOptions } from './options.js';
|
|
5
|
+
type Args<T> = PieceRunArgs<T, Record<string, never>, Trello>;
|
|
6
|
+
export declare const createCard: {
|
|
7
|
+
slug: string;
|
|
8
|
+
description: string;
|
|
9
|
+
input: z.ZodObject<{
|
|
10
|
+
boardId: z.ZodString;
|
|
11
|
+
listId: z.ZodString;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
description: z.ZodOptional<z.ZodString>;
|
|
14
|
+
position: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
top: "top";
|
|
16
|
+
bottom: "bottom";
|
|
17
|
+
}>>;
|
|
18
|
+
labelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
output: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
desc: z.ZodOptional<z.ZodString>;
|
|
24
|
+
idBoard: z.ZodOptional<z.ZodString>;
|
|
25
|
+
idList: z.ZodOptional<z.ZodString>;
|
|
26
|
+
due: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
+
dueComplete: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
dateLastActivity: z.ZodOptional<z.ZodString>;
|
|
29
|
+
url: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$loose>;
|
|
31
|
+
idempotent: boolean;
|
|
32
|
+
options: {
|
|
33
|
+
boardId: typeof boardOptions;
|
|
34
|
+
listId: typeof listOptions;
|
|
35
|
+
labelIds: typeof labelOptions;
|
|
36
|
+
};
|
|
37
|
+
run({ client, input, }: Args<{
|
|
38
|
+
boardId: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
labelIds?: string[];
|
|
41
|
+
listId: string;
|
|
42
|
+
name: string;
|
|
43
|
+
position?: "bottom" | "top";
|
|
44
|
+
}>): Promise<unknown>;
|
|
45
|
+
};
|
|
46
|
+
export declare const getCard: {
|
|
47
|
+
slug: string;
|
|
48
|
+
description: string;
|
|
49
|
+
input: z.ZodObject<{
|
|
50
|
+
cardId: z.ZodString;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
output: z.ZodObject<{
|
|
53
|
+
id: z.ZodString;
|
|
54
|
+
name: z.ZodString;
|
|
55
|
+
desc: z.ZodOptional<z.ZodString>;
|
|
56
|
+
idBoard: z.ZodOptional<z.ZodString>;
|
|
57
|
+
idList: z.ZodOptional<z.ZodString>;
|
|
58
|
+
due: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
dueComplete: z.ZodOptional<z.ZodBoolean>;
|
|
60
|
+
dateLastActivity: z.ZodOptional<z.ZodString>;
|
|
61
|
+
url: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, z.core.$loose>;
|
|
63
|
+
idempotent: boolean;
|
|
64
|
+
run({ client, input }: Args<{
|
|
65
|
+
cardId: string;
|
|
66
|
+
}>): Promise<Record<string, unknown>>;
|
|
67
|
+
};
|
|
68
|
+
export declare const updateCard: {
|
|
69
|
+
slug: string;
|
|
70
|
+
description: string;
|
|
71
|
+
input: z.ZodObject<{
|
|
72
|
+
cardId: z.ZodString;
|
|
73
|
+
boardId: z.ZodOptional<z.ZodString>;
|
|
74
|
+
listId: z.ZodOptional<z.ZodString>;
|
|
75
|
+
name: z.ZodOptional<z.ZodString>;
|
|
76
|
+
description: z.ZodOptional<z.ZodString>;
|
|
77
|
+
position: z.ZodOptional<z.ZodEnum<{
|
|
78
|
+
top: "top";
|
|
79
|
+
bottom: "bottom";
|
|
80
|
+
}>>;
|
|
81
|
+
labelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
82
|
+
archived: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
due: z.ZodOptional<z.ZodString>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
output: z.ZodObject<{
|
|
86
|
+
id: z.ZodString;
|
|
87
|
+
name: z.ZodString;
|
|
88
|
+
desc: z.ZodOptional<z.ZodString>;
|
|
89
|
+
idBoard: z.ZodOptional<z.ZodString>;
|
|
90
|
+
idList: z.ZodOptional<z.ZodString>;
|
|
91
|
+
due: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
92
|
+
dueComplete: z.ZodOptional<z.ZodBoolean>;
|
|
93
|
+
dateLastActivity: z.ZodOptional<z.ZodString>;
|
|
94
|
+
url: z.ZodOptional<z.ZodString>;
|
|
95
|
+
}, z.core.$loose>;
|
|
96
|
+
idempotent: boolean;
|
|
97
|
+
options: {
|
|
98
|
+
boardId: typeof boardOptions;
|
|
99
|
+
listId: typeof listOptions;
|
|
100
|
+
labelIds: typeof labelOptions;
|
|
101
|
+
};
|
|
102
|
+
run({ client, input }: Args<Record<string, unknown> & {
|
|
103
|
+
cardId: string;
|
|
104
|
+
}>): Promise<unknown>;
|
|
105
|
+
};
|
|
106
|
+
export declare const deleteCard: {
|
|
107
|
+
slug: string;
|
|
108
|
+
description: string;
|
|
109
|
+
input: z.ZodObject<{
|
|
110
|
+
cardId: z.ZodString;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
output: z.ZodObject<{}, z.core.$loose>;
|
|
113
|
+
idempotent: boolean;
|
|
114
|
+
run({ client, input }: Args<{
|
|
115
|
+
cardId: string;
|
|
116
|
+
}>): Promise<unknown>;
|
|
117
|
+
};
|
|
118
|
+
export declare const listCardAttachments: {
|
|
119
|
+
slug: string;
|
|
120
|
+
description: string;
|
|
121
|
+
input: z.ZodObject<{
|
|
122
|
+
cardId: z.ZodString;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
output: z.ZodArray<z.ZodObject<{
|
|
125
|
+
id: z.ZodString;
|
|
126
|
+
name: z.ZodString;
|
|
127
|
+
url: z.ZodString;
|
|
128
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.core.$loose>>;
|
|
130
|
+
idempotent: boolean;
|
|
131
|
+
run({ client, input }: Args<{
|
|
132
|
+
cardId: string;
|
|
133
|
+
}>): Promise<unknown>;
|
|
134
|
+
};
|
|
135
|
+
export declare const addCardAttachment: {
|
|
136
|
+
slug: string;
|
|
137
|
+
description: string;
|
|
138
|
+
input: z.ZodObject<{
|
|
139
|
+
cardId: z.ZodString;
|
|
140
|
+
attachment: z.ZodObject<{
|
|
141
|
+
fileId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
142
|
+
name: z.ZodOptional<z.ZodString>;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
name: z.ZodOptional<z.ZodString>;
|
|
145
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
146
|
+
setCover: z.ZodOptional<z.ZodBoolean>;
|
|
147
|
+
}, z.core.$strip>;
|
|
148
|
+
output: z.ZodObject<{
|
|
149
|
+
id: z.ZodString;
|
|
150
|
+
name: z.ZodString;
|
|
151
|
+
url: z.ZodString;
|
|
152
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
153
|
+
}, z.core.$loose>;
|
|
154
|
+
idempotent: boolean;
|
|
155
|
+
run({ client, input, req, }: Args<{
|
|
156
|
+
attachment: {
|
|
157
|
+
fileId: number | string;
|
|
158
|
+
name?: string;
|
|
159
|
+
};
|
|
160
|
+
cardId: string;
|
|
161
|
+
mimeType?: string;
|
|
162
|
+
name?: string;
|
|
163
|
+
setCover?: boolean;
|
|
164
|
+
}>): Promise<unknown>;
|
|
165
|
+
};
|
|
166
|
+
export declare const getCardAttachment: {
|
|
167
|
+
slug: string;
|
|
168
|
+
description: string;
|
|
169
|
+
input: z.ZodObject<{
|
|
170
|
+
cardId: z.ZodString;
|
|
171
|
+
attachmentId: z.ZodString;
|
|
172
|
+
}, z.core.$strip>;
|
|
173
|
+
output: z.ZodObject<{
|
|
174
|
+
id: z.ZodString;
|
|
175
|
+
name: z.ZodString;
|
|
176
|
+
url: z.ZodString;
|
|
177
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
178
|
+
}, z.core.$loose>;
|
|
179
|
+
idempotent: boolean;
|
|
180
|
+
run({ client, input }: Args<{
|
|
181
|
+
attachmentId: string;
|
|
182
|
+
cardId: string;
|
|
183
|
+
}>): Promise<unknown>;
|
|
184
|
+
};
|
|
185
|
+
export declare const deleteCardAttachment: {
|
|
186
|
+
slug: string;
|
|
187
|
+
description: string;
|
|
188
|
+
input: z.ZodObject<{
|
|
189
|
+
cardId: z.ZodString;
|
|
190
|
+
attachmentId: z.ZodString;
|
|
191
|
+
}, z.core.$strip>;
|
|
192
|
+
output: z.ZodObject<{}, z.core.$loose>;
|
|
193
|
+
idempotent: boolean;
|
|
194
|
+
run({ client, input }: Args<{
|
|
195
|
+
attachmentId: string;
|
|
196
|
+
cardId: string;
|
|
197
|
+
}>): Promise<unknown>;
|
|
198
|
+
};
|
|
199
|
+
declare const customInput: z.ZodObject<{
|
|
200
|
+
method: z.ZodEnum<{
|
|
201
|
+
POST: "POST";
|
|
202
|
+
DELETE: "DELETE";
|
|
203
|
+
GET: "GET";
|
|
204
|
+
PUT: "PUT";
|
|
205
|
+
PATCH: "PATCH";
|
|
206
|
+
}>;
|
|
207
|
+
path: z.ZodString;
|
|
208
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
209
|
+
query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
210
|
+
body: z.ZodOptional<z.ZodJSONSchema>;
|
|
211
|
+
}, z.core.$strip>;
|
|
212
|
+
export declare const customApiCall: {
|
|
213
|
+
slug: string;
|
|
214
|
+
description: string;
|
|
215
|
+
input: z.ZodObject<{
|
|
216
|
+
method: z.ZodEnum<{
|
|
217
|
+
POST: "POST";
|
|
218
|
+
DELETE: "DELETE";
|
|
219
|
+
GET: "GET";
|
|
220
|
+
PUT: "PUT";
|
|
221
|
+
PATCH: "PATCH";
|
|
222
|
+
}>;
|
|
223
|
+
path: z.ZodString;
|
|
224
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
225
|
+
query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
226
|
+
body: z.ZodOptional<z.ZodJSONSchema>;
|
|
227
|
+
}, z.core.$strip>;
|
|
228
|
+
output: z.ZodJSONSchema;
|
|
229
|
+
idempotent: boolean;
|
|
230
|
+
run({ client, input }: Args<z.output<typeof customInput>>): Promise<unknown>;
|
|
231
|
+
};
|
|
232
|
+
export {};
|
|
233
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGvE,KAAK,IAAI,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;AAO9D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAiBlB,IAAI,CAAC;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;KAC7B,CAAC;CAaH,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;2BAMW,IAAI,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAGtD,CAAC;AAEF,eAAO,MAAM,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 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { loadAttachment } from './files.js';
|
|
3
|
+
import { boardOptions, labelOptions, listOptions } from './options.js';
|
|
4
|
+
import { attachmentOutput, cardOutput, emptyOutput } from './schemas.js';
|
|
5
|
+
const cardIdInput = z.object({ cardId: z.string().min(1).meta({ label: 'Card ID' }) });
|
|
6
|
+
const attachmentIdInput = cardIdInput.extend({
|
|
7
|
+
attachmentId: z.string().min(1).meta({ label: 'Attachment ID' }),
|
|
8
|
+
});
|
|
9
|
+
export const createCard = {
|
|
10
|
+
slug: 'createCard',
|
|
11
|
+
description: 'Create a Trello card.',
|
|
12
|
+
input: z.object({
|
|
13
|
+
boardId: z.string().min(1).meta({ label: 'Board' }),
|
|
14
|
+
listId: z.string().min(1).meta({ label: 'List' }),
|
|
15
|
+
name: z.string().min(1).meta({ label: 'Task name' }),
|
|
16
|
+
description: z.string().optional().meta({ label: 'Task description' }),
|
|
17
|
+
position: z.enum(['top', 'bottom']).optional(),
|
|
18
|
+
labelIds: z.array(z.string()).optional().meta({ label: 'Labels' }),
|
|
19
|
+
}),
|
|
20
|
+
output: cardOutput,
|
|
21
|
+
idempotent: false,
|
|
22
|
+
options: { boardId: boardOptions, listId: listOptions, labelIds: labelOptions },
|
|
23
|
+
async run({ client, input, }) {
|
|
24
|
+
return client.request('cards', {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers: { 'Content-Type': 'application/json' },
|
|
27
|
+
body: JSON.stringify({
|
|
28
|
+
name: input.name,
|
|
29
|
+
desc: input.description,
|
|
30
|
+
pos: input.position,
|
|
31
|
+
idLabels: input.labelIds,
|
|
32
|
+
}),
|
|
33
|
+
query: { idList: input.listId },
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
export const getCard = {
|
|
38
|
+
slug: 'getCard',
|
|
39
|
+
description: 'Get a Trello card by ID.',
|
|
40
|
+
input: cardIdInput,
|
|
41
|
+
output: cardOutput,
|
|
42
|
+
idempotent: true,
|
|
43
|
+
async run({ client, input }) {
|
|
44
|
+
return client.getCard(input.cardId);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
export const updateCard = {
|
|
48
|
+
slug: 'updateCard',
|
|
49
|
+
description: 'Update a Trello card.',
|
|
50
|
+
input: z.object({
|
|
51
|
+
cardId: z.string().min(1),
|
|
52
|
+
boardId: z.string().optional(),
|
|
53
|
+
listId: z.string().optional(),
|
|
54
|
+
name: z.string().optional(),
|
|
55
|
+
description: z.string().optional(),
|
|
56
|
+
position: z.enum(['top', 'bottom']).optional(),
|
|
57
|
+
labelIds: z.array(z.string()).optional(),
|
|
58
|
+
archived: z.boolean().optional(),
|
|
59
|
+
due: z.string().datetime().optional(),
|
|
60
|
+
}),
|
|
61
|
+
output: cardOutput,
|
|
62
|
+
idempotent: true,
|
|
63
|
+
options: { boardId: boardOptions, listId: listOptions, labelIds: labelOptions },
|
|
64
|
+
async run({ client, input }) {
|
|
65
|
+
return client.request(`cards/${input.cardId}`, {
|
|
66
|
+
method: 'PUT',
|
|
67
|
+
headers: { 'Content-Type': 'application/json' },
|
|
68
|
+
body: JSON.stringify({
|
|
69
|
+
name: input.name,
|
|
70
|
+
desc: input.description,
|
|
71
|
+
idList: input.listId,
|
|
72
|
+
pos: input.position,
|
|
73
|
+
idLabels: input.labelIds,
|
|
74
|
+
closed: input.archived,
|
|
75
|
+
due: input.due,
|
|
76
|
+
}),
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
export const deleteCard = {
|
|
81
|
+
slug: 'deleteCard',
|
|
82
|
+
description: 'Permanently delete a Trello card.',
|
|
83
|
+
input: cardIdInput,
|
|
84
|
+
output: emptyOutput,
|
|
85
|
+
idempotent: false,
|
|
86
|
+
async run({ client, input }) {
|
|
87
|
+
return client.request(`cards/${input.cardId}`, { method: 'DELETE' });
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
export const listCardAttachments = {
|
|
91
|
+
slug: 'listCardAttachments',
|
|
92
|
+
description: 'List attachments on a Trello card.',
|
|
93
|
+
input: cardIdInput,
|
|
94
|
+
output: z.array(attachmentOutput),
|
|
95
|
+
idempotent: true,
|
|
96
|
+
async run({ client, input }) {
|
|
97
|
+
return client.request(`cards/${input.cardId}/attachments`);
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
export const addCardAttachment = {
|
|
101
|
+
slug: 'addCardAttachment',
|
|
102
|
+
description: 'Upload an attachment to a Trello card.',
|
|
103
|
+
input: cardIdInput.extend({
|
|
104
|
+
attachment: z.object({
|
|
105
|
+
fileId: z.union([z.string(), z.number()]),
|
|
106
|
+
name: z.string().optional(),
|
|
107
|
+
}),
|
|
108
|
+
name: z.string().optional(),
|
|
109
|
+
mimeType: z.string().optional(),
|
|
110
|
+
setCover: z.boolean().optional(),
|
|
111
|
+
}),
|
|
112
|
+
output: attachmentOutput,
|
|
113
|
+
idempotent: false,
|
|
114
|
+
async run({ client, input, req, }) {
|
|
115
|
+
const attachment = await loadAttachment(req, input.attachment);
|
|
116
|
+
const form = new FormData();
|
|
117
|
+
form.append('file', attachment.data, attachment.name);
|
|
118
|
+
return client.request(`cards/${input.cardId}/attachments`, {
|
|
119
|
+
method: 'POST',
|
|
120
|
+
body: form,
|
|
121
|
+
query: {
|
|
122
|
+
mimeType: input.mimeType ?? attachment.type,
|
|
123
|
+
name: input.name,
|
|
124
|
+
setCover: input.setCover,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
export const getCardAttachment = {
|
|
130
|
+
slug: 'getCardAttachment',
|
|
131
|
+
description: 'Get one attachment from a Trello card.',
|
|
132
|
+
input: attachmentIdInput,
|
|
133
|
+
output: attachmentOutput,
|
|
134
|
+
idempotent: true,
|
|
135
|
+
async run({ client, input }) {
|
|
136
|
+
return client.request(`cards/${input.cardId}/attachments/${input.attachmentId}`);
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
export const deleteCardAttachment = {
|
|
140
|
+
slug: 'deleteCardAttachment',
|
|
141
|
+
description: 'Permanently delete an attachment from a Trello card.',
|
|
142
|
+
input: attachmentIdInput,
|
|
143
|
+
output: emptyOutput,
|
|
144
|
+
idempotent: false,
|
|
145
|
+
async run({ client, input }) {
|
|
146
|
+
return client.request(`cards/${input.cardId}/attachments/${input.attachmentId}`, {
|
|
147
|
+
method: 'DELETE',
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
const customInput = z.object({
|
|
152
|
+
method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']),
|
|
153
|
+
path: z.string().startsWith('/'),
|
|
154
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
155
|
+
query: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
|
|
156
|
+
body: z.json().optional(),
|
|
157
|
+
});
|
|
158
|
+
export const customApiCall = {
|
|
159
|
+
slug: 'customApiCall',
|
|
160
|
+
description: 'Make an authenticated Trello API call.',
|
|
161
|
+
input: customInput,
|
|
162
|
+
output: z.json(),
|
|
163
|
+
idempotent: false,
|
|
164
|
+
async run({ client, input }) {
|
|
165
|
+
return client.request(input.path, {
|
|
166
|
+
method: input.method,
|
|
167
|
+
headers: {
|
|
168
|
+
...input.headers,
|
|
169
|
+
...(input.body === undefined ? {} : { 'Content-Type': 'application/json' }),
|
|
170
|
+
},
|
|
171
|
+
body: input.body === undefined ? undefined : JSON.stringify(input.body),
|
|
172
|
+
query: input.query,
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE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;IACjB,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAsC;QAC7D,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE;YAChC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,OAAO,EAAE;gBACP,GAAG,KAAK,CAAC,OAAO;gBAChB,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;aAC5E;YACD,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;YACvE,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
type Query = Record<string, boolean | number | string | undefined>;
|
|
2
|
+
export type TrelloWebhook = {
|
|
3
|
+
callbackURL: string;
|
|
4
|
+
id: string;
|
|
5
|
+
idModel: string;
|
|
6
|
+
};
|
|
7
|
+
export type Trello = ReturnType<typeof createTrelloClient>;
|
|
8
|
+
export declare function createTrelloClient({ auth }: {
|
|
9
|
+
auth: unknown;
|
|
10
|
+
}): {
|
|
11
|
+
request: <T>(path: string, init?: RequestInit & {
|
|
12
|
+
query?: Query;
|
|
13
|
+
}) => Promise<T>;
|
|
14
|
+
verifyWebhook(body: Buffer, signature: string | null, webhookUrl: string): boolean;
|
|
15
|
+
listAll<T extends {
|
|
16
|
+
id: string;
|
|
17
|
+
}>(path: string): Promise<T[]>;
|
|
18
|
+
getCard: (cardId: string) => Promise<Record<string, unknown>>;
|
|
19
|
+
listBoards: () => Promise<{
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
}[]>;
|
|
23
|
+
listLists: (boardId: string) => Promise<{
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
}[]>;
|
|
27
|
+
listLabels: (boardId: string) => Promise<{
|
|
28
|
+
color: string;
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
}[]>;
|
|
32
|
+
listWebhooks: () => Promise<TrelloWebhook[]>;
|
|
33
|
+
createWebhook: (idModel: string, callbackURL: string) => Promise<TrelloWebhook>;
|
|
34
|
+
deleteWebhook: (id: string) => Promise<unknown>;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;AAEnE,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE3D,wBAAgB,kBAAkB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE;cAGrC,CAAC,QAAQ,MAAM,SAAQ,WAAW,GAAG;QAAE,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE,KAAQ,OAAO,CAAC,CAAC,CAAC;wBAsBzE,MAAM,aAAa,MAAM,GAAG,IAAI,cAAc,MAAM;YAW1D,CAAC,SAAS;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,QAAQ,MAAM;sBAclC,MAAM;;YACc,MAAM;cAAQ,MAAM;;yBACrC,MAAM;YACL,MAAM;cAAQ,MAAM;;0BACpB,MAAM;eACH,MAAM;YAAM,MAAM;cAAQ,MAAM;;;6BAEhC,MAAM,eAAe,MAAM;wBAKhC,MAAM;EAE7B"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { trelloAuth } from './config.js';
|
|
3
|
+
export function createTrelloClient({ auth }) {
|
|
4
|
+
const credential = trelloAuth.parse(auth);
|
|
5
|
+
async function request(path, init = {}) {
|
|
6
|
+
const url = new URL(`https://api.trello.com/1/${path.replace(/^\//, '')}`);
|
|
7
|
+
url.searchParams.set('key', credential.username);
|
|
8
|
+
url.searchParams.set('token', credential.password);
|
|
9
|
+
Object.entries(init.query ?? {}).forEach(([key, value]) => {
|
|
10
|
+
if (value !== undefined)
|
|
11
|
+
url.searchParams.set(key, String(value));
|
|
12
|
+
});
|
|
13
|
+
const response = await fetch(url, init);
|
|
14
|
+
const text = await response.text();
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
throw new Error(`Trello request failed (${response.status}): ${text || response.statusText}`);
|
|
17
|
+
}
|
|
18
|
+
return (text ? JSON.parse(text) : {});
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
request,
|
|
22
|
+
verifyWebhook(body, signature, webhookUrl) {
|
|
23
|
+
if (!signature || !/^[A-Za-z\d+/]{27}=$/.test(signature))
|
|
24
|
+
return false;
|
|
25
|
+
const expected = createHmac('sha1', credential.applicationSecret)
|
|
26
|
+
.update(body)
|
|
27
|
+
.update(webhookUrl)
|
|
28
|
+
.digest();
|
|
29
|
+
const actual = Buffer.from(signature, 'base64');
|
|
30
|
+
return actual.length === expected.length && timingSafeEqual(actual, expected);
|
|
31
|
+
},
|
|
32
|
+
async listAll(path) {
|
|
33
|
+
const items = [];
|
|
34
|
+
let before;
|
|
35
|
+
while (true) {
|
|
36
|
+
const page = await request(path, { query: { limit: 1000, before } });
|
|
37
|
+
items.push(...page);
|
|
38
|
+
if (page.length < 1000)
|
|
39
|
+
return items;
|
|
40
|
+
before = page.at(-1)?.id;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
getCard: (cardId) => request(`cards/${cardId}`),
|
|
44
|
+
listBoards: () => request('members/me/boards'),
|
|
45
|
+
listLists: (boardId) => request(`boards/${boardId}/lists`),
|
|
46
|
+
listLabels: (boardId) => request(`boards/${boardId}/labels`),
|
|
47
|
+
listWebhooks: () => request(`tokens/${credential.password}/webhooks`),
|
|
48
|
+
createWebhook: (idModel, callbackURL) => request('webhooks', {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
query: { callbackURL, idModel },
|
|
51
|
+
}),
|
|
52
|
+
deleteWebhook: (id) => request(`webhooks/${id}`, { method: 'DELETE' }),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAYzC,MAAM,UAAU,kBAAkB,CAAC,EAAE,IAAI,EAAqB;IAC5D,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE1C,KAAK,UAAU,OAAO,CAAI,IAAY,EAAE,OAAwC,EAAE;QAChF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,4BAA4B,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QAE3E,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;QACjD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;QAEnD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,C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ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,UAAU;;;;iBAIrB,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const trelloAuth = z.object({
|
|
3
|
+
username: z.string().min(1).meta({ label: 'API key', secret: true }),
|
|
4
|
+
password: z.string().min(1).meta({ label: 'Token', secret: true }),
|
|
5
|
+
applicationSecret: z.string().min(1).meta({ label: 'Application secret', secret: true }),
|
|
6
|
+
});
|
|
7
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACpE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAClE,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;CACzF,CAAC,CAAC"}
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FrogbotRequest } from 'frogbot';
|
|
2
|
+
export declare function loadAttachment(req: FrogbotRequest, value: {
|
|
3
|
+
fileId: number | string;
|
|
4
|
+
name?: string;
|
|
5
|
+
}): Promise<{
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
data: Blob;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAsB,cAAc,CAClC,GAAG,EAAE,cAAc,EACnB,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;;;;GA8DlD"}
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export async function loadAttachment(req, value) {
|
|
2
|
+
const collection = req.frogbot.config.files?.slug;
|
|
3
|
+
if (!collection) {
|
|
4
|
+
throw new Error('[frogbot] Trello attachments require the files collection to be configured.');
|
|
5
|
+
}
|
|
6
|
+
const doc = await req.frogbot.findByID({
|
|
7
|
+
collection,
|
|
8
|
+
id: value.fileId,
|
|
9
|
+
depth: 0,
|
|
10
|
+
req,
|
|
11
|
+
overrideAccess: false,
|
|
12
|
+
});
|
|
13
|
+
const fileUrl = doc.url;
|
|
14
|
+
if (typeof fileUrl !== 'string') {
|
|
15
|
+
throw new Error(`[frogbot] File '${value.fileId}' is unavailable.`);
|
|
16
|
+
}
|
|
17
|
+
const config = await req.frogbot.config._internal.payloadConfig;
|
|
18
|
+
const baseUrl = config.serverURL || req.url;
|
|
19
|
+
if (typeof baseUrl !== 'string') {
|
|
20
|
+
throw new Error(`[frogbot] File '${value.fileId}' is unavailable.`);
|
|
21
|
+
}
|
|
22
|
+
const url = new URL(fileUrl, baseUrl);
|
|
23
|
+
const base = new URL(baseUrl);
|
|
24
|
+
const headers = new Headers();
|
|
25
|
+
if (url.origin !== base.origin) {
|
|
26
|
+
throw new Error(`[frogbot] File '${value.fileId}' has an invalid URL.`);
|
|
27
|
+
}
|
|
28
|
+
for (const name of ['authorization', 'cookie']) {
|
|
29
|
+
const header = req.headers.get(name);
|
|
30
|
+
if (header)
|
|
31
|
+
headers.set(name, header);
|
|
32
|
+
}
|
|
33
|
+
const response = await fetch(url, {
|
|
34
|
+
headers,
|
|
35
|
+
redirect: 'error',
|
|
36
|
+
signal: req.signal ?? undefined,
|
|
37
|
+
});
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
throw new Error(`[frogbot] File '${value.fileId}' is unavailable (${response.status}).`);
|
|
40
|
+
}
|
|
41
|
+
const filename = typeof doc.filename === 'string' ? doc.filename : undefined;
|
|
42
|
+
const name = typeof doc.name === 'string' ? doc.name : undefined;
|
|
43
|
+
const mimeType = typeof doc.mimeType === 'string' ? doc.mimeType : undefined;
|
|
44
|
+
return {
|
|
45
|
+
name: value.name ?? filename ?? name ?? 'attachment',
|
|
46
|
+
type: mimeType ?? 'application/octet-stream',
|
|
47
|
+
data: await response.blob(),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=files.js.map
|