@dereekb/trello 13.11.14

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 (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +6 -0
  3. package/index.cjs.default.js +1 -0
  4. package/index.cjs.js +1629 -0
  5. package/index.cjs.mjs +2 -0
  6. package/index.d.ts +1 -0
  7. package/index.esm.js +1583 -0
  8. package/nestjs/index.cjs.default.js +1 -0
  9. package/nestjs/index.cjs.js +1127 -0
  10. package/nestjs/index.cjs.mjs +2 -0
  11. package/nestjs/index.d.ts +1 -0
  12. package/nestjs/index.esm.js +1105 -0
  13. package/nestjs/package.json +28 -0
  14. package/nestjs/src/index.d.ts +1 -0
  15. package/nestjs/src/lib/index.d.ts +2 -0
  16. package/nestjs/src/lib/trello/index.d.ts +3 -0
  17. package/nestjs/src/lib/trello/trello.api.d.ts +36 -0
  18. package/nestjs/src/lib/trello/trello.config.d.ts +12 -0
  19. package/nestjs/src/lib/trello/trello.module.d.ts +21 -0
  20. package/nestjs/src/lib/webhook/index.d.ts +7 -0
  21. package/nestjs/src/lib/webhook/webhook.trello.config.d.ts +22 -0
  22. package/nestjs/src/lib/webhook/webhook.trello.controller.d.ts +12 -0
  23. package/nestjs/src/lib/webhook/webhook.trello.d.ts +50 -0
  24. package/nestjs/src/lib/webhook/webhook.trello.module.d.ts +13 -0
  25. package/nestjs/src/lib/webhook/webhook.trello.service.d.ts +24 -0
  26. package/nestjs/src/lib/webhook/webhook.trello.type.d.ts +85 -0
  27. package/nestjs/src/lib/webhook/webhook.trello.verify.d.ts +46 -0
  28. package/package.json +34 -0
  29. package/src/index.d.ts +1 -0
  30. package/src/lib/index.d.ts +7 -0
  31. package/src/lib/shared/index.d.ts +1 -0
  32. package/src/lib/shared/trello.type.d.ts +23 -0
  33. package/src/lib/trello/index.d.ts +11 -0
  34. package/src/lib/trello/trello.api.board.d.ts +103 -0
  35. package/src/lib/trello/trello.api.board.type.d.ts +75 -0
  36. package/src/lib/trello/trello.api.card.d.ts +116 -0
  37. package/src/lib/trello/trello.api.card.type.d.ts +141 -0
  38. package/src/lib/trello/trello.api.list.d.ts +46 -0
  39. package/src/lib/trello/trello.api.list.type.d.ts +40 -0
  40. package/src/lib/trello/trello.api.member.d.ts +25 -0
  41. package/src/lib/trello/trello.api.member.type.d.ts +20 -0
  42. package/src/lib/trello/trello.api.webhook.d.ts +57 -0
  43. package/src/lib/trello/trello.api.webhook.type.d.ts +41 -0
  44. package/src/lib/trello/trello.factory.d.ts +54 -0
  45. package/src/lib/trello.api.page.d.ts +92 -0
  46. package/src/lib/trello.config.d.ts +20 -0
  47. package/src/lib/trello.error.api.d.ts +77 -0
  48. package/src/lib/trello.limit.d.ts +40 -0
  49. package/src/lib/trello.type.d.ts +39 -0
@@ -0,0 +1,116 @@
1
+ import { type TrelloContext } from './trello.factory';
2
+ import { type TrelloCardId, type TrelloLabelId, type TrelloMemberId } from '../trello.type';
3
+ import { type CreateCardBody, type TrelloAction, type TrelloCard, type TrelloCommentCardAction, type UpdateCardBody } from './trello.api.card.type';
4
+ export interface GetCardInput {
5
+ readonly cardId: TrelloCardId;
6
+ }
7
+ export type GetCardFunction = (input: GetCardInput) => Promise<TrelloCard>;
8
+ /**
9
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-get
10
+ *
11
+ * @param context The Trello API context.
12
+ * @returns A function that retrieves a card by id.
13
+ */
14
+ export declare function getCard(context: TrelloContext): GetCardFunction;
15
+ export type CreateCardFunction = (input: CreateCardBody) => Promise<TrelloCard>;
16
+ /**
17
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-post
18
+ *
19
+ * @param context The Trello API context.
20
+ * @returns A function that creates a card on a list.
21
+ */
22
+ export declare function createCard(context: TrelloContext): CreateCardFunction;
23
+ export interface UpdateCardInput extends UpdateCardBody {
24
+ readonly cardId: TrelloCardId;
25
+ }
26
+ export type UpdateCardFunction = (input: UpdateCardInput) => Promise<TrelloCard>;
27
+ /**
28
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-put
29
+ *
30
+ * @param context The Trello API context.
31
+ * @returns A function that updates an existing card.
32
+ */
33
+ export declare function updateCard(context: TrelloContext): UpdateCardFunction;
34
+ export type DeleteCardFunction = (input: GetCardInput) => Promise<void>;
35
+ /**
36
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-delete
37
+ *
38
+ * @param context The Trello API context.
39
+ * @returns A function that deletes a card.
40
+ */
41
+ export declare function deleteCard(context: TrelloContext): DeleteCardFunction;
42
+ /**
43
+ * Known Trello action type. Trello supports many more (40+) — pass any string for filters not enumerated here.
44
+ *
45
+ * @see https://developer.atlassian.com/cloud/trello/guides/rest-api/action-types/
46
+ */
47
+ export type TrelloActionType = 'commentCard' | 'updateCard' | 'createCard' | 'deleteCard' | 'addMemberToCard' | 'removeMemberFromCard' | 'addAttachmentToCard' | 'deleteAttachmentFromCard' | 'addChecklistToCard' | 'removeChecklistFromCard' | 'updateCheckItemStateOnCard' | 'addLabelToCard' | 'removeLabelFromCard' | string;
48
+ export interface ListCardActionsInput {
49
+ readonly cardId: TrelloCardId;
50
+ /**
51
+ * Comma-separated list of action types to include, or `all`. Defaults to `commentCard,updateCard:idList` server-side.
52
+ */
53
+ readonly filter?: TrelloActionType;
54
+ /**
55
+ * Maximum number of actions to return. Defaults to 50 server-side; max is 1000.
56
+ */
57
+ readonly limit?: number;
58
+ /**
59
+ * Cursor: return actions before this action id (older).
60
+ */
61
+ readonly before?: string;
62
+ /**
63
+ * Cursor: return actions since this action id (newer).
64
+ */
65
+ readonly since?: string;
66
+ }
67
+ export type ListCardActionsFunction = <D = unknown>(input: ListCardActionsInput) => Promise<ReadonlyArray<TrelloAction<D>>>;
68
+ /**
69
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-actions-get
70
+ *
71
+ * Comments are returned as actions with `type === 'commentCard'`; pass `filter: 'commentCard'` and the generic
72
+ * type parameter `TrelloCommentCardActionData` to get a comment-typed result.
73
+ *
74
+ * @param context The Trello API context.
75
+ * @returns A function that lists actions on a card.
76
+ */
77
+ export declare function listCardActions(context: TrelloContext): ListCardActionsFunction;
78
+ export interface AddCommentToCardInput {
79
+ readonly cardId: TrelloCardId;
80
+ /**
81
+ * Comment text (1-16384 characters).
82
+ */
83
+ readonly text: string;
84
+ }
85
+ export type AddCommentToCardFunction = (input: AddCommentToCardInput) => Promise<TrelloCommentCardAction>;
86
+ /**
87
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-actions-comments-post
88
+ *
89
+ * @param context The Trello API context.
90
+ * @returns A function that adds a comment to a card.
91
+ */
92
+ export declare function addCommentToCard(context: TrelloContext): AddCommentToCardFunction;
93
+ export interface AddMemberToCardInput {
94
+ readonly cardId: TrelloCardId;
95
+ readonly memberId: TrelloMemberId;
96
+ }
97
+ export type AddMemberToCardFunction = (input: AddMemberToCardInput) => Promise<ReadonlyArray<TrelloMemberId>>;
98
+ /**
99
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-idmembers-post
100
+ *
101
+ * @param context The Trello API context.
102
+ * @returns A function that adds a member to a card.
103
+ */
104
+ export declare function addMemberToCard(context: TrelloContext): AddMemberToCardFunction;
105
+ export interface AddLabelToCardInput {
106
+ readonly cardId: TrelloCardId;
107
+ readonly labelId: TrelloLabelId;
108
+ }
109
+ export type AddLabelToCardFunction = (input: AddLabelToCardInput) => Promise<ReadonlyArray<TrelloLabelId>>;
110
+ /**
111
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-idlabels-post
112
+ *
113
+ * @param context The Trello API context.
114
+ * @returns A function that adds an existing label to a card.
115
+ */
116
+ export declare function addLabelToCard(context: TrelloContext): AddLabelToCardFunction;
@@ -0,0 +1,141 @@
1
+ import { type Maybe } from '@dereekb/util';
2
+ import { type TrelloActionId, type TrelloBoardId, type TrelloCardId, type TrelloChecklistId, type TrelloLabelId, type TrelloListId, type TrelloMemberId } from '../trello.type';
3
+ import { type TrelloLabelColor, type TrelloMaybeDateString, type TrelloPosition } from '../shared/trello.type';
4
+ import { type TrelloMember } from './trello.api.member.type';
5
+ /**
6
+ * Trello label.
7
+ */
8
+ export interface TrelloLabel {
9
+ readonly id: TrelloLabelId;
10
+ readonly idBoard: TrelloBoardId;
11
+ readonly name: string;
12
+ readonly color: Maybe<TrelloLabelColor>;
13
+ }
14
+ /**
15
+ * Card `badges` summary block. Trello populates ~12 fields here; only the
16
+ * most commonly-read ones are typed. Cast for additional fields.
17
+ *
18
+ * @see https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-get
19
+ */
20
+ export interface TrelloCardBadges {
21
+ readonly attachments?: number;
22
+ readonly comments?: number;
23
+ readonly checkItems?: number;
24
+ readonly checkItemsChecked?: number;
25
+ readonly description?: boolean;
26
+ readonly subscribed?: boolean;
27
+ readonly votes?: number;
28
+ }
29
+ /**
30
+ * Trello card.
31
+ *
32
+ * Only the most commonly-used fields are typed. Use `fields=all` and a custom cast when more are required.
33
+ *
34
+ * @see https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-get
35
+ */
36
+ export interface TrelloCard {
37
+ readonly id: TrelloCardId;
38
+ readonly name: string;
39
+ readonly desc: string;
40
+ readonly closed: boolean;
41
+ readonly idBoard: TrelloBoardId;
42
+ readonly idList: TrelloListId;
43
+ readonly idMembers: ReadonlyArray<TrelloMemberId>;
44
+ readonly idLabels: ReadonlyArray<TrelloLabelId>;
45
+ readonly idChecklists: ReadonlyArray<TrelloChecklistId>;
46
+ readonly labels: ReadonlyArray<TrelloLabel>;
47
+ readonly pos: number;
48
+ readonly due: TrelloMaybeDateString;
49
+ readonly dueComplete: boolean;
50
+ readonly start: TrelloMaybeDateString;
51
+ readonly url: string;
52
+ readonly shortUrl: string;
53
+ readonly shortLink: string;
54
+ readonly dateLastActivity: TrelloMaybeDateString;
55
+ readonly badges?: TrelloCardBadges;
56
+ readonly subscribed?: boolean;
57
+ }
58
+ export interface CreateCardBody {
59
+ /**
60
+ * The id of the list the card should be created on. Required.
61
+ */
62
+ readonly idList: TrelloListId;
63
+ /**
64
+ * Card name (1-16384 characters).
65
+ */
66
+ readonly name?: string;
67
+ /**
68
+ * Card description.
69
+ */
70
+ readonly desc?: string;
71
+ /**
72
+ * Position on the list.
73
+ */
74
+ readonly pos?: TrelloPosition;
75
+ /**
76
+ * Optional comma-separated list of label ids.
77
+ */
78
+ readonly idLabels?: ReadonlyArray<TrelloLabelId>;
79
+ /**
80
+ * Optional comma-separated list of member ids.
81
+ */
82
+ readonly idMembers?: ReadonlyArray<TrelloMemberId>;
83
+ /**
84
+ * Optional due date as an ISO date string.
85
+ */
86
+ readonly due?: TrelloMaybeDateString;
87
+ /**
88
+ * Optional start date as an ISO date string.
89
+ */
90
+ readonly start?: TrelloMaybeDateString;
91
+ }
92
+ export interface UpdateCardBody {
93
+ readonly name?: string;
94
+ readonly desc?: string;
95
+ readonly closed?: boolean;
96
+ readonly idList?: TrelloListId;
97
+ readonly idBoard?: TrelloBoardId;
98
+ readonly idLabels?: ReadonlyArray<TrelloLabelId>;
99
+ readonly idMembers?: ReadonlyArray<TrelloMemberId>;
100
+ readonly due?: TrelloMaybeDateString;
101
+ readonly dueComplete?: boolean;
102
+ readonly start?: TrelloMaybeDateString;
103
+ readonly pos?: TrelloPosition;
104
+ readonly subscribed?: boolean;
105
+ }
106
+ /**
107
+ * A Trello action (i.e. an immutable activity log entry).
108
+ *
109
+ * Comments are surfaced as actions with `type === 'commentCard'`.
110
+ *
111
+ * @see https://developer.atlassian.com/cloud/trello/rest/api-group-actions/
112
+ */
113
+ export interface TrelloAction<D = unknown> {
114
+ readonly id: TrelloActionId;
115
+ readonly idMemberCreator: TrelloMemberId;
116
+ readonly type: string;
117
+ readonly date: string;
118
+ readonly data: D;
119
+ /**
120
+ * Member who created the action. Populated when the request includes
121
+ * `member=true` (the default). Omitted otherwise.
122
+ */
123
+ readonly memberCreator?: TrelloMember;
124
+ }
125
+ export interface TrelloCommentCardActionData {
126
+ readonly text: string;
127
+ readonly card: {
128
+ readonly id: TrelloCardId;
129
+ readonly idShort?: number;
130
+ readonly name?: string;
131
+ };
132
+ readonly board: {
133
+ readonly id: TrelloBoardId;
134
+ readonly name?: string;
135
+ };
136
+ readonly list?: {
137
+ readonly id: TrelloListId;
138
+ readonly name?: string;
139
+ };
140
+ }
141
+ export type TrelloCommentCardAction = TrelloAction<TrelloCommentCardActionData>;
@@ -0,0 +1,46 @@
1
+ import { type TrelloContext } from './trello.factory';
2
+ import { type TrelloListId } from '../trello.type';
3
+ import { type CreateListBody, type TrelloList, type UpdateListBody } from './trello.api.list.type';
4
+ import { type TrelloCard } from './trello.api.card.type';
5
+ export interface GetListInput {
6
+ readonly listId: TrelloListId;
7
+ }
8
+ export type GetListFunction = (input: GetListInput) => Promise<TrelloList>;
9
+ /**
10
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-lists/#api-lists-id-get
11
+ *
12
+ * @param context The Trello API context.
13
+ * @returns A function that retrieves a list by id.
14
+ */
15
+ export declare function getList(context: TrelloContext): GetListFunction;
16
+ export type CreateListFunction = (input: CreateListBody) => Promise<TrelloList>;
17
+ /**
18
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-lists/#api-lists-post
19
+ *
20
+ * @param context The Trello API context.
21
+ * @returns A function that creates a new list on a board.
22
+ */
23
+ export declare function createList(context: TrelloContext): CreateListFunction;
24
+ export interface UpdateListInput extends UpdateListBody {
25
+ readonly listId: TrelloListId;
26
+ }
27
+ export type UpdateListFunction = (input: UpdateListInput) => Promise<TrelloList>;
28
+ /**
29
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-lists/#api-lists-id-put
30
+ *
31
+ * @param context The Trello API context.
32
+ * @returns A function that updates an existing list.
33
+ */
34
+ export declare function updateList(context: TrelloContext): UpdateListFunction;
35
+ export interface ListCardsInListInput {
36
+ readonly listId: TrelloListId;
37
+ readonly filter?: 'all' | 'closed' | 'none' | 'open';
38
+ }
39
+ export type ListCardsInListFunction = (input: ListCardsInListInput) => Promise<ReadonlyArray<TrelloCard>>;
40
+ /**
41
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-lists/#api-lists-id-cards-get
42
+ *
43
+ * @param context The Trello API context.
44
+ * @returns A function that lists all cards on a list.
45
+ */
46
+ export declare function listCardsInList(context: TrelloContext): ListCardsInListFunction;
@@ -0,0 +1,40 @@
1
+ import { type TrelloBoardId, type TrelloListId } from '../trello.type';
2
+ import { type TrelloPosition } from '../shared/trello.type';
3
+ /**
4
+ * Trello list.
5
+ *
6
+ * @see https://developer.atlassian.com/cloud/trello/rest/api-group-lists/#api-lists-id-get
7
+ */
8
+ export interface TrelloList {
9
+ readonly id: TrelloListId;
10
+ readonly name: string;
11
+ readonly closed: boolean;
12
+ readonly idBoard: TrelloBoardId;
13
+ readonly pos: number;
14
+ readonly subscribed?: boolean;
15
+ }
16
+ export interface CreateListBody {
17
+ /**
18
+ * Name of the list (1-16384 characters).
19
+ */
20
+ readonly name: string;
21
+ /**
22
+ * The id of the board the list belongs to. Required.
23
+ */
24
+ readonly idBoard: TrelloBoardId;
25
+ /**
26
+ * The id of the list to copy from. Cannot be used with `idBoard`.
27
+ */
28
+ readonly idListSource?: TrelloListId;
29
+ /**
30
+ * Position of the list (top, bottom, or a positive number).
31
+ */
32
+ readonly pos?: TrelloPosition;
33
+ }
34
+ export interface UpdateListBody {
35
+ readonly name?: string;
36
+ readonly closed?: boolean;
37
+ readonly idBoard?: TrelloBoardId;
38
+ readonly pos?: TrelloPosition;
39
+ readonly subscribed?: boolean;
40
+ }
@@ -0,0 +1,25 @@
1
+ import { type TrelloContext } from './trello.factory';
2
+ import { type TrelloMemberId } from '../trello.type';
3
+ import { type TrelloMember } from './trello.api.member.type';
4
+ export interface GetMemberInput {
5
+ /**
6
+ * Member id, username, or the literal `me` (the authenticated user).
7
+ */
8
+ readonly memberId: TrelloMemberId | 'me' | string;
9
+ }
10
+ export type GetMemberFunction = (input: GetMemberInput) => Promise<TrelloMember>;
11
+ /**
12
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-members/#api-members-id-get
13
+ *
14
+ * @param context The Trello API context.
15
+ * @returns A function that retrieves a member by id (or `me`).
16
+ */
17
+ export declare function getMember(context: TrelloContext): GetMemberFunction;
18
+ export type GetMeFunction = () => Promise<TrelloMember>;
19
+ /**
20
+ * Convenience wrapper around `getMember({ memberId: 'me' })`.
21
+ *
22
+ * @param context The Trello API context.
23
+ * @returns A function that retrieves the authenticated user.
24
+ */
25
+ export declare function getMe(context: TrelloContext): GetMeFunction;
@@ -0,0 +1,20 @@
1
+ import { type EmailAddress, type Maybe } from '@dereekb/util';
2
+ import { type TrelloBoardId, type TrelloMemberId, type TrelloOrganizationId, type TrelloUsername } from '../trello.type';
3
+ /**
4
+ * Trello member.
5
+ *
6
+ * @see https://developer.atlassian.com/cloud/trello/rest/api-group-members/#api-members-id-get
7
+ */
8
+ export interface TrelloMember {
9
+ readonly id: TrelloMemberId;
10
+ readonly username: TrelloUsername;
11
+ readonly fullName: string;
12
+ readonly initials: string;
13
+ readonly avatarUrl: Maybe<string>;
14
+ /**
15
+ * Email is only returned for the requesting user, and only when the token has the `account` scope.
16
+ */
17
+ readonly email?: Maybe<EmailAddress>;
18
+ readonly idBoards?: ReadonlyArray<TrelloBoardId>;
19
+ readonly idOrganizations?: ReadonlyArray<TrelloOrganizationId>;
20
+ }
@@ -0,0 +1,57 @@
1
+ import { type TrelloContext } from './trello.factory';
2
+ import { type TrelloApiToken, type TrelloWebhookId } from '../trello.type';
3
+ import { type CreateWebhookBody, type TrelloWebhook, type UpdateWebhookBody } from './trello.api.webhook.type';
4
+ export type CreateWebhookFunction = (input: CreateWebhookBody) => Promise<TrelloWebhook>;
5
+ /**
6
+ * Trello validates the callback URL with a HEAD request before creation. The endpoint MUST return 200.
7
+ *
8
+ * https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/#creating-a-webhook
9
+ *
10
+ * @param context The Trello API context.
11
+ * @returns A function that registers a new webhook.
12
+ */
13
+ export declare function createWebhook(context: TrelloContext): CreateWebhookFunction;
14
+ export interface GetWebhookInput {
15
+ readonly webhookId: TrelloWebhookId;
16
+ }
17
+ export type GetWebhookFunction = (input: GetWebhookInput) => Promise<TrelloWebhook>;
18
+ /**
19
+ * https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/#retrieving-a-webhook
20
+ *
21
+ * @param context The Trello API context.
22
+ * @returns A function that retrieves a webhook by id.
23
+ */
24
+ export declare function getWebhook(context: TrelloContext): GetWebhookFunction;
25
+ export interface UpdateWebhookInput extends UpdateWebhookBody {
26
+ readonly webhookId: TrelloWebhookId;
27
+ }
28
+ export type UpdateWebhookFunction = (input: UpdateWebhookInput) => Promise<TrelloWebhook>;
29
+ /**
30
+ * https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/#updating-a-webhook
31
+ *
32
+ * @param context The Trello API context.
33
+ * @returns A function that updates an existing webhook.
34
+ */
35
+ export declare function updateWebhook(context: TrelloContext): UpdateWebhookFunction;
36
+ export type DeleteWebhookFunction = (input: GetWebhookInput) => Promise<void>;
37
+ /**
38
+ * https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/#deleting-a-webhook
39
+ *
40
+ * @param context The Trello API context.
41
+ * @returns A function that deletes a webhook.
42
+ */
43
+ export declare function deleteWebhook(context: TrelloContext): DeleteWebhookFunction;
44
+ export interface ListWebhooksForTokenInput {
45
+ /**
46
+ * Optional override for the token whose webhooks to list. Defaults to the context's configured token.
47
+ */
48
+ readonly apiToken?: TrelloApiToken;
49
+ }
50
+ export type ListWebhooksForTokenFunction = (input?: ListWebhooksForTokenInput) => Promise<ReadonlyArray<TrelloWebhook>>;
51
+ /**
52
+ * https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/
53
+ *
54
+ * @param context The Trello API context.
55
+ * @returns A function that lists all webhooks registered for a token.
56
+ */
57
+ export declare function listWebhooksForToken(context: TrelloContext): ListWebhooksForTokenFunction;
@@ -0,0 +1,41 @@
1
+ import { type Maybe } from '@dereekb/util';
2
+ import { type TrelloId, type TrelloWebhookId } from '../trello.type';
3
+ /**
4
+ * Trello webhook registration.
5
+ *
6
+ * @see https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/
7
+ */
8
+ export interface TrelloWebhook {
9
+ readonly id: TrelloWebhookId;
10
+ readonly idModel: TrelloId;
11
+ readonly callbackURL: string;
12
+ readonly description: string;
13
+ readonly active: boolean;
14
+ readonly consecutiveFailures?: number;
15
+ readonly firstConsecutiveFailDate?: Maybe<string>;
16
+ }
17
+ export interface CreateWebhookBody {
18
+ /**
19
+ * The id of the model (board, card, member, list, etc.) to subscribe to.
20
+ */
21
+ readonly idModel: TrelloId;
22
+ /**
23
+ * The URL Trello will POST to when an event occurs.
24
+ *
25
+ * Trello validates this URL with a HEAD request before creation. It must respond with 200.
26
+ */
27
+ readonly callbackURL: string;
28
+ /**
29
+ * Optional human-readable description.
30
+ */
31
+ readonly description?: string;
32
+ /**
33
+ * Whether the webhook is active. Defaults to true.
34
+ */
35
+ readonly active?: boolean;
36
+ }
37
+ export interface UpdateWebhookBody {
38
+ readonly callbackURL?: string;
39
+ readonly description?: string;
40
+ readonly active?: boolean;
41
+ }
@@ -0,0 +1,54 @@
1
+ import { type ConfiguredFetch, type FetchJsonFunction } from '@dereekb/util/fetch';
2
+ import { type Maybe, type ResetPeriodPromiseRateLimiter } from '@dereekb/util';
3
+ import { type LogTrelloServerErrorFunction } from '../trello.error.api';
4
+ import { type TrelloRateLimitedFetchHandlerConfig } from '../trello.limit';
5
+ import { type TrelloConfig } from '../trello.config';
6
+ /**
7
+ * A Trello context used for making authenticated requests to the Trello REST API.
8
+ */
9
+ export interface TrelloContext {
10
+ /**
11
+ * Configured fetch that handles auth, rate limiting, and error normalization.
12
+ */
13
+ readonly fetch: ConfiguredFetch;
14
+ /**
15
+ * Convenience fetchJson wrapper.
16
+ */
17
+ readonly fetchJson: FetchJsonFunction;
18
+ /**
19
+ * The configuration this context was created with.
20
+ */
21
+ readonly config: TrelloConfig;
22
+ /**
23
+ * The underlying rate limiter used by the configured fetch.
24
+ */
25
+ readonly trelloRateLimiter: ResetPeriodPromiseRateLimiter;
26
+ }
27
+ export interface TrelloContextRef {
28
+ readonly trelloContext: TrelloContext;
29
+ }
30
+ /**
31
+ * A Trello API instance wrapping a {@link TrelloContext}.
32
+ */
33
+ export type Trello = TrelloContextRef;
34
+ export interface TrelloFactoryConfig {
35
+ /**
36
+ * Optional rate limiter configuration override.
37
+ */
38
+ readonly rateLimiterConfig?: Maybe<TrelloRateLimitedFetchHandlerConfig>;
39
+ /**
40
+ * Optional custom error logger.
41
+ */
42
+ readonly logTrelloServerErrorFunction?: LogTrelloServerErrorFunction;
43
+ }
44
+ export type TrelloFactory = (config: TrelloConfig) => Trello;
45
+ /**
46
+ * Builds a Trello API factory.
47
+ *
48
+ * Auth uses Trello's `Authorization: OAuth oauth_consumer_key=..., oauth_token=...` header form so credentials never appear in URLs or logs.
49
+ *
50
+ * @param factoryConfig Factory-level configuration shared across created Trello instances.
51
+ * @returns A factory function that creates a configured Trello API instance.
52
+ * @__NO_SIDE_EFFECTS__
53
+ */
54
+ export declare function trelloFactory(factoryConfig?: TrelloFactoryConfig): TrelloFactory;
@@ -0,0 +1,92 @@
1
+ import { type Maybe } from '@dereekb/util';
2
+ import { type FetchPageFactory, type FetchPageFactoryConfigDefaults } from '@dereekb/util/fetch';
3
+ import { type TrelloActionId, type TrelloId } from './trello.type';
4
+ /**
5
+ * Maximum allowed `limit` value for most Trello collection endpoints.
6
+ *
7
+ * @see https://developer.atlassian.com/cloud/trello/rest/
8
+ */
9
+ export declare const TRELLO_MAX_PAGE_LIMIT = 1000;
10
+ /**
11
+ * Filter shape for Trello cursor-style pagination using action IDs.
12
+ *
13
+ * Trello collection endpoints typically accept `before`/`since` filters that take an item id
14
+ * (often an action id or card id) and return items older/newer than that cursor.
15
+ */
16
+ export interface TrelloCursorPageFilter {
17
+ /**
18
+ * Returns items before this id (older).
19
+ */
20
+ readonly before?: TrelloId;
21
+ /**
22
+ * Returns items since this id (newer).
23
+ */
24
+ readonly since?: TrelloId;
25
+ /**
26
+ * Maximum number of items to return. Defaults vary per endpoint; max is typically 1000.
27
+ */
28
+ readonly limit?: number;
29
+ }
30
+ /**
31
+ * A Trello collection endpoint typically returns a bare JSON array.
32
+ *
33
+ * This type captures pagination metadata around such a response.
34
+ */
35
+ export interface TrelloPageResult<T> {
36
+ /**
37
+ * The page data.
38
+ */
39
+ readonly data: ReadonlyArray<T>;
40
+ /**
41
+ * Maximum items requested for this page (echoed from input).
42
+ */
43
+ readonly limit: number;
44
+ /**
45
+ * Cursor that can be used as `before` to fetch the next (older) page.
46
+ *
47
+ * Undefined when this page has fewer items than the requested limit.
48
+ */
49
+ readonly nextBefore?: TrelloId;
50
+ }
51
+ /**
52
+ * Reads the id of the last item in a Trello page response, for use as the next page's `before` cursor.
53
+ */
54
+ export type TrelloPageItemIdReader<T> = (item: T) => TrelloId;
55
+ /**
56
+ * Default reader that pulls `id` off the item. Works for most Trello resource types.
57
+ *
58
+ * @param item The page item whose id to read.
59
+ * @returns The item's id.
60
+ */
61
+ export declare const defaultTrelloPageItemIdReader: <T extends {
62
+ readonly id: TrelloId;
63
+ }>(item: T) => TrelloId;
64
+ /**
65
+ * Reader that pulls the action id off a Trello action item.
66
+ *
67
+ * @param item The action page item whose id to read.
68
+ * @returns The item's action id.
69
+ */
70
+ export declare const trelloActionIdReader: <T extends {
71
+ readonly id: TrelloActionId;
72
+ }>(item: T) => TrelloActionId;
73
+ /**
74
+ * Wraps a raw Trello collection fetch into a {@link TrelloPageResult}.
75
+ *
76
+ * @param input The page filter that was used.
77
+ * @param data The raw page items.
78
+ * @param idReader Function to read the id from the last item.
79
+ * @returns A page result with the data and a cursor for the next page.
80
+ * @__NO_SIDE_EFFECTS__
81
+ */
82
+ export declare function buildTrelloPageResult<T>(input: TrelloCursorPageFilter, data: ReadonlyArray<T>, idReader: TrelloPageItemIdReader<T>): TrelloPageResult<T>;
83
+ export type TrelloFetchPageFetchFunction<I extends TrelloCursorPageFilter, R extends TrelloPageResult<unknown>> = (input: I) => Promise<R>;
84
+ /**
85
+ * Creates a FetchPageFactory using the input TrelloFetchPageFetchFunction.
86
+ *
87
+ * @param fetch Function that fetches a single page of results from the Trello API.
88
+ * @param defaults Optional default pagination configuration.
89
+ * @returns A configured FetchPageFactory that handles Trello's cursor-based pagination using `before`.
90
+ * @__NO_SIDE_EFFECTS__
91
+ */
92
+ export declare function trelloFetchPageFactory<I extends TrelloCursorPageFilter, R extends TrelloPageResult<unknown>>(fetch: TrelloFetchPageFetchFunction<I, R>, defaults?: Maybe<FetchPageFactoryConfigDefaults>): FetchPageFactory<I, R>;
@@ -0,0 +1,20 @@
1
+ import { type TrelloApiKey, type TrelloApiToken, type TrelloApiUrl } from './trello.type';
2
+ /**
3
+ * Configuration for a TrelloContext.
4
+ */
5
+ export interface TrelloConfig {
6
+ /**
7
+ * Trello API key. Created at https://trello.com/power-ups/admin.
8
+ *
9
+ * Note that the API key alone does not grant access to user data.
10
+ */
11
+ readonly apiKey: TrelloApiKey;
12
+ /**
13
+ * Trello user API token. Required for all authenticated requests.
14
+ */
15
+ readonly apiToken: TrelloApiToken;
16
+ /**
17
+ * Optional custom API base URL. Defaults to https://api.trello.com/1.
18
+ */
19
+ readonly apiUrl?: TrelloApiUrl | string;
20
+ }