-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.ts
More file actions
65 lines (52 loc) · 1.98 KB
/
Copy pathbasic.ts
File metadata and controls
65 lines (52 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { JokelboardClient, RevisionConflictError } from '@jokelboard/typescript';
const client = new JokelboardClient({ token: process.env.JOKELBOARD_TOKEN! });
const BOARD_ID = 'board-abc123';
// List all boards
const boards = await client.listBoards();
console.log(boards.map(b => b.name));
// Fetch a board
const board = await client.getBoard(BOARD_ID);
const firstList = board.data.lists[0];
// Create a card
const card = await client.createCard(BOARD_ID, firstList.id, 'Fix login redirect', {
categoryId: 'P1',
description: 'Users on mobile are sent to the wrong domain.',
labels: [{ name: 'bug', color: '#ff5e5e' }],
});
console.log(`Created card: ${card.ticket} (${card.id})`);
// Set custom field values
await client.updateCard(BOARD_ID, card.id, {
fieldValues: { 'owner-team': 'platform', 'discord-id': '1234567890' },
});
// Add a comment
await client.addComment(BOARD_ID, card.id, 'Assigned to the platform team.');
// Move to another list
const doneList = board.data.lists.find(l => l.title === 'Done');
if (doneList) {
await client.moveCard(BOARD_ID, card.id, doneList.id);
}
// Get the shareable link
const link = await client.getCardLink(BOARD_ID, card.id);
console.log(`Card URL: ${link.url}`);
// Vault (soft-delete) and restore
await client.vaultCard(BOARD_ID, card.id);
await client.restoreCard(BOARD_ID, card.id, { toListId: firstList.id });
// Handle revision conflicts
try {
await client.updateCard(BOARD_ID, card.id, { title: 'Updated title', revision: 0 });
} catch (err) {
if (err instanceof RevisionConflictError) {
const fresh = await client.getBoard(BOARD_ID);
await client.updateCard(BOARD_ID, card.id, {
title: 'Updated title',
revision: fresh.revision,
});
}
}
// Plugin API
const pluginBoard = await client.plugin.getBoard(BOARD_ID);
const firstCard = pluginBoard.lists[0]?.cards[0];
const firstItem = firstCard?.checklist?.items[0];
if (firstItem?.id) {
await client.plugin.toggleChecklistItem(BOARD_ID, firstCard.id, firstItem.id);
}