Skip to content

Commit 286faba

Browse files
committed
updates
1 parent cff7109 commit 286faba

File tree

8 files changed

+80
-20
lines changed

8 files changed

+80
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"prettier-plugin-jsdoc": "^1.3.2",
4646
"rollup": "^4.40.0",
4747
"tslib": "^2.8.1",
48-
"typedoc": "^0.28.2",
48+
"typedoc": "^0.28.3",
4949
"typescript": "^5.8.3",
5050
"typescript-eslint": "^8.30.1",
5151
"vitest": "^3.1.1"

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api/boards.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Client, Request } from '~/interfaces';
22
import { boardSchema, Board, CreateBoard } from '~/schemas/api/boards';
3-
import { TrelloId } from '~/schemas/common';
3+
import { customFieldsSchema, TrelloId } from '~/schemas/common';
44
import { Members } from './members';
55

66
export class Boards {
@@ -21,18 +21,10 @@ export class Boards {
2121
return this.client.sendRequest<T, never>(request, boardSchema);
2222
}
2323

24-
// async list() {
25-
// const request: Request = {
26-
// url: '/members/me/'
27-
// };
28-
//
29-
// return this.client.sendRequest(request);
30-
// }
31-
3224
async getAll() {
3325
const boardsId = await this.membersClient.getBoards('me');
3426

35-
const boards: Board[] = [];
27+
const boards: Board[] = [];
3628

3729
for (const { id } of boardsId) {
3830
const board = await this.get(id);
@@ -54,5 +46,22 @@ export class Boards {
5446
return this.client.sendRequest(request, boardSchema);
5547
}
5648

57-
// async delete(boardId) {}
49+
async delete(boardId: TrelloId) {
50+
const request: Request = {
51+
url: `/boards/${boardId}`,
52+
method: 'DELETE',
53+
};
54+
55+
return this.client.sendRequest(request);
56+
}
57+
58+
/** Get the Custom Field Definitions that exist on a board. */
59+
async getCustomFields(boardId: TrelloId) {
60+
const request: Request = {
61+
url: `/boards/${boardId}/customFields`,
62+
method: 'GET',
63+
}
64+
65+
return this.client.sendRequest(request, customFieldsSchema);
66+
}
5867
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { z } from 'zod';
2+
import { trelloIdSchema } from './trelloIdSchema';
3+
import { colorSchema } from '~/schemas/common/colorSchema';
4+
5+
const baseCustomFieldSchema = z.object({
6+
id: trelloIdSchema,
7+
idModel: z.string(),
8+
modelType: z.enum(['card', 'board', 'member']),
9+
fieldGroup: z.string(),
10+
name: z.string(),
11+
pos: z.number(),
12+
type: z.string(),
13+
isSuggestedField: z.boolean(),
14+
display: z.object({
15+
cardFront: z.boolean(),
16+
}).strict(),
17+
}).strict();
18+
19+
export const customFieldSchema = z.discriminatedUnion('type', [
20+
baseCustomFieldSchema.extend({
21+
type: z.literal('date'),
22+
}),
23+
baseCustomFieldSchema.extend({
24+
type: z.literal('list'),
25+
options: z.array(z.object({
26+
id: trelloIdSchema,
27+
idCustomField: trelloIdSchema,
28+
value: z.object({
29+
text: z.string(),
30+
}).strict(),
31+
color: z.union([colorSchema, z.literal('none')]),
32+
pos: z.number(),
33+
}).strict())
34+
}),
35+
]);
36+
37+
export type CustomField = z.infer<typeof customFieldSchema>;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { z } from 'zod';
2+
import { customFieldSchema } from '~/schemas/common/customFieldSchema';
3+
4+
export const customFieldsSchema = z.array(customFieldSchema);
5+
6+
export type CustomFields = z.infer<typeof customFieldSchema>;

src/schemas/common/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export * from './backgroundScaledImageSchema';
22
export * from './colorSchema';
3+
export * from './customFieldSchema';
4+
export * from './customFieldsSchema';
35
export * from './hexColorSchema';
46
export * from './prefsSchema';
57
export * from './trelloIdSchema';

src/schemas/common/prefsSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const prefsSchema = z
1111
backgroundBrightness: z.enum(['light', 'dark']),
1212
backgroundColor: hexColorSchema.nullable(),
1313
backgroundDarkColor: hexColorSchema.nullable(),
14-
backgroundDarkImage: z.unknown().nullable(),
14+
backgroundDarkImage: z.string().url().nullable(),
1515
backgroundImage: z.string().url().nullable(),
1616
backgroundImageScaled: z.array(backgroundScaledImageSchema).nullable(),
1717
backgroundTile: z.boolean(),

tests/integration/api/boards.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ describe('Boards Service Integration Tests', () => {
1919
expect(board.name).toBe(mockBoardInput.name);
2020
});
2121

22-
it('should successfully get all boards', async () => {
22+
it.skip('should successfully get all boards', async () => {
2323
const boards = await trelloClient.boards.getAll();
2424

2525
console.log(boards);
2626
});
2727

28-
it.skip('should successfully delete a board', async () => {
28+
it('should successfully get custom fields', async () => {
29+
const customFields = await trelloClient.boards.getCustomFields('639cdbf9f5557e00df01180d'); // todo
30+
31+
console.log(customFields);
32+
})
2933

34+
it.skip('should successfully delete a board', async () => {
35+
await trelloClient.boards.delete(board!.id);
3036
})
3137
});

0 commit comments

Comments
 (0)