@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,28 @@
1
+ {
2
+ "name": "@dereekb/trello/nestjs",
3
+ "version": "13.11.14",
4
+ "peerDependencies": {
5
+ "@dereekb/nestjs": "13.11.14",
6
+ "@dereekb/rxjs": "13.11.14",
7
+ "@dereekb/trello": "13.11.14",
8
+ "@dereekb/util": "13.11.14",
9
+ "@nestjs/common": "^11.1.19",
10
+ "@nestjs/config": "^4.0.4",
11
+ "express": "^5.2.1"
12
+ },
13
+ "devDependencies": {
14
+ "@nestjs/testing": "^11.1.19"
15
+ },
16
+ "exports": {
17
+ "./package.json": "./package.json",
18
+ ".": {
19
+ "module": "./index.esm.js",
20
+ "types": "./index.d.ts",
21
+ "import": "./index.cjs.mjs",
22
+ "default": "./index.cjs.js"
23
+ }
24
+ },
25
+ "module": "./index.esm.js",
26
+ "main": "./index.cjs.js",
27
+ "types": "./index.d.ts"
28
+ }
@@ -0,0 +1 @@
1
+ export * from './lib';
@@ -0,0 +1,2 @@
1
+ export * from './trello';
2
+ export * from './webhook';
@@ -0,0 +1,3 @@
1
+ export * from './trello.api';
2
+ export * from './trello.config';
3
+ export * from './trello.module';
@@ -0,0 +1,36 @@
1
+ import { type Trello, type TrelloContext } from '@dereekb/trello';
2
+ import { TrelloServiceConfig } from './trello.config';
3
+ export declare class TrelloApi {
4
+ readonly config: TrelloServiceConfig;
5
+ readonly trello: Trello;
6
+ get trelloContext(): TrelloContext;
7
+ get trelloRateLimiter(): import("@dereekb/util").ResetPeriodPromiseRateLimiter;
8
+ constructor(config: TrelloServiceConfig);
9
+ get getBoard(): import("@dereekb/trello").GetBoardFunction;
10
+ get createBoard(): import("@dereekb/trello").CreateBoardFunction;
11
+ get updateBoard(): import("@dereekb/trello").UpdateBoardFunction;
12
+ get deleteBoard(): import("@dereekb/trello").DeleteBoardFunction;
13
+ get listBoardLists(): import("@dereekb/trello").ListBoardListsFunction;
14
+ get listBoardCards(): import("@dereekb/trello").ListBoardCardsFunction;
15
+ get listBoardMembers(): import("@dereekb/trello").ListBoardMembersFunction;
16
+ get listBoardLabels(): import("@dereekb/trello").ListBoardLabelsFunction;
17
+ get getList(): import("@dereekb/trello").GetListFunction;
18
+ get createList(): import("@dereekb/trello").CreateListFunction;
19
+ get updateList(): import("@dereekb/trello").UpdateListFunction;
20
+ get listCardsInList(): import("@dereekb/trello").ListCardsInListFunction;
21
+ get getCard(): import("@dereekb/trello").GetCardFunction;
22
+ get createCard(): import("@dereekb/trello").CreateCardFunction;
23
+ get updateCard(): import("@dereekb/trello").UpdateCardFunction;
24
+ get deleteCard(): import("@dereekb/trello").DeleteCardFunction;
25
+ get addCommentToCard(): import("@dereekb/trello").AddCommentToCardFunction;
26
+ get addMemberToCard(): import("@dereekb/trello").AddMemberToCardFunction;
27
+ get addLabelToCard(): import("@dereekb/trello").AddLabelToCardFunction;
28
+ get listCardActions(): import("@dereekb/trello").ListCardActionsFunction;
29
+ get getMember(): import("@dereekb/trello").GetMemberFunction;
30
+ get getMe(): import("@dereekb/trello").GetMeFunction;
31
+ get createWebhook(): import("@dereekb/trello").CreateWebhookFunction;
32
+ get getWebhook(): import("@dereekb/trello").GetWebhookFunction;
33
+ get updateWebhook(): import("@dereekb/trello").UpdateWebhookFunction;
34
+ get deleteWebhook(): import("@dereekb/trello").DeleteWebhookFunction;
35
+ get listWebhooksForToken(): import("@dereekb/trello").ListWebhooksForTokenFunction;
36
+ }
@@ -0,0 +1,12 @@
1
+ import { type TrelloConfig, type TrelloFactoryConfig } from '@dereekb/trello';
2
+ export declare const TRELLO_API_KEY_ENV_VAR = "TRELLO_API_KEY";
3
+ export declare const TRELLO_API_TOKEN_ENV_VAR = "TRELLO_API_TOKEN";
4
+ export type TrelloServiceApiConfig = TrelloConfig;
5
+ /**
6
+ * Configuration for TrelloApi.
7
+ */
8
+ export declare abstract class TrelloServiceConfig {
9
+ readonly trello: TrelloServiceApiConfig;
10
+ readonly factoryConfig?: TrelloFactoryConfig;
11
+ static assertValidConfig(config: TrelloServiceConfig): void;
12
+ }
@@ -0,0 +1,21 @@
1
+ import { type ModuleMetadata } from '@nestjs/common';
2
+ import { ConfigService } from '@nestjs/config';
3
+ import { TrelloServiceConfig } from './trello.config';
4
+ /**
5
+ * Default factory function for creating TrelloServiceConfig from ConfigService.
6
+ *
7
+ * Reads `TRELLO_API_KEY` and `TRELLO_API_TOKEN` from the environment.
8
+ *
9
+ * @param configService The NestJS ConfigService.
10
+ * @returns A validated TrelloServiceConfig.
11
+ */
12
+ export declare function trelloServiceConfigFactory(configService: ConfigService): TrelloServiceConfig;
13
+ export interface ProvideAppTrelloMetadataConfig extends Pick<ModuleMetadata, 'imports' | 'exports' | 'providers'> {
14
+ }
15
+ /**
16
+ * Convenience function used to generate ModuleMetadata for an app's TrelloModule.
17
+ *
18
+ * @param config Optional additional module metadata overrides.
19
+ * @returns Module metadata for the Trello module.
20
+ */
21
+ export declare function appTrelloModuleMetadata(config?: ProvideAppTrelloMetadataConfig): ModuleMetadata;
@@ -0,0 +1,7 @@
1
+ export * from './webhook.trello';
2
+ export * from './webhook.trello.config';
3
+ export * from './webhook.trello.controller';
4
+ export * from './webhook.trello.module';
5
+ export * from './webhook.trello.service';
6
+ export * from './webhook.trello.type';
7
+ export * from './webhook.trello.verify';
@@ -0,0 +1,22 @@
1
+ import { type TrelloAppSecret } from '@dereekb/trello';
2
+ export declare const TRELLO_APP_SECRET_ENV_VAR = "TRELLO_APP_SECRET";
3
+ export declare const TRELLO_WEBHOOK_CALLBACK_URL_ENV_VAR = "TRELLO_WEBHOOK_CALLBACK_URL";
4
+ export interface TrelloWebhookConfig {
5
+ /**
6
+ * The Trello app secret used to verify webhook signatures.
7
+ */
8
+ readonly appSecret: TrelloAppSecret;
9
+ /**
10
+ * The exact callback URL configured for the registered webhook.
11
+ *
12
+ * Must match the URL Trello was given on registration — the HMAC is computed over `rawBody + callbackUrl`.
13
+ */
14
+ readonly callbackUrl: string;
15
+ }
16
+ /**
17
+ * Configuration for {@link TrelloWebhookService}.
18
+ */
19
+ export declare abstract class TrelloWebhookServiceConfig {
20
+ readonly webhookConfig: TrelloWebhookConfig;
21
+ static assertValidConfig(config: TrelloWebhookServiceConfig): void;
22
+ }
@@ -0,0 +1,12 @@
1
+ import { type RawBodyBuffer } from '@dereekb/nestjs';
2
+ import { type Request } from 'express';
3
+ import { TrelloWebhookService } from './webhook.trello.service';
4
+ export declare class TrelloWebhookController {
5
+ readonly trelloWebhookService: TrelloWebhookService;
6
+ constructor(trelloWebhookService: TrelloWebhookService);
7
+ /**
8
+ * Endpoint Trello pings with HEAD during webhook registration. Must return 200.
9
+ */
10
+ handleTrelloWebhookHead(): void;
11
+ handleTrelloWebhook(req: Request, rawBody: RawBodyBuffer): Promise<void>;
12
+ }
@@ -0,0 +1,50 @@
1
+ import { type Handler, type HandlerBindAccessor, type HandlerMappedSetFunction } from '@dereekb/util';
2
+ import { type TrelloWebhookActionType, type TrelloWebhookAddMemberToCardActionData, type TrelloWebhookBoardActionData, type TrelloWebhookCardActionData, type TrelloWebhookCommentCardActionData, type TrelloWebhookEvent, type UntypedTrelloWebhookEvent } from './webhook.trello.type';
3
+ /**
4
+ * Action type emitted when a new card is created.
5
+ */
6
+ export declare const TRELLO_WEBHOOK_CREATE_CARD_ACTION_TYPE = "createCard";
7
+ /**
8
+ * Action type emitted when a card is updated.
9
+ */
10
+ export declare const TRELLO_WEBHOOK_UPDATE_CARD_ACTION_TYPE = "updateCard";
11
+ /**
12
+ * Action type emitted when a card is deleted.
13
+ */
14
+ export declare const TRELLO_WEBHOOK_DELETE_CARD_ACTION_TYPE = "deleteCard";
15
+ /**
16
+ * Action type emitted when a comment is added to a card.
17
+ */
18
+ export declare const TRELLO_WEBHOOK_COMMENT_CARD_ACTION_TYPE = "commentCard";
19
+ /**
20
+ * Action type emitted when a member is added to a card.
21
+ */
22
+ export declare const TRELLO_WEBHOOK_ADD_MEMBER_TO_CARD_ACTION_TYPE = "addMemberToCard";
23
+ /**
24
+ * Action type emitted when a member is removed from a card.
25
+ */
26
+ export declare const TRELLO_WEBHOOK_REMOVE_MEMBER_FROM_CARD_ACTION_TYPE = "removeMemberFromCard";
27
+ /**
28
+ * Action type emitted when a board is updated.
29
+ */
30
+ export declare const TRELLO_WEBHOOK_UPDATE_BOARD_ACTION_TYPE = "updateBoard";
31
+ /**
32
+ * Re-narrows an UntypedTrelloWebhookEvent's payload to the given action data type.
33
+ *
34
+ * @param event The untyped event.
35
+ * @returns A typed view over the same event.
36
+ */
37
+ export declare function trelloWebhookEvent<D>(event: UntypedTrelloWebhookEvent): TrelloWebhookEvent<D>;
38
+ export type TrelloEventHandler = Handler<UntypedTrelloWebhookEvent, TrelloWebhookActionType>;
39
+ export declare const trelloEventHandlerFactory: import("@dereekb/util").HandlerFactory<UntypedTrelloWebhookEvent, string, boolean>;
40
+ export type TrelloHandlerMappedSetFunction<D> = HandlerMappedSetFunction<TrelloWebhookEvent<D>>;
41
+ export interface TrelloEventHandlerConfigurer extends HandlerBindAccessor<UntypedTrelloWebhookEvent, TrelloWebhookActionType> {
42
+ handleCreateCard: TrelloHandlerMappedSetFunction<TrelloWebhookCardActionData>;
43
+ handleUpdateCard: TrelloHandlerMappedSetFunction<TrelloWebhookCardActionData>;
44
+ handleDeleteCard: TrelloHandlerMappedSetFunction<TrelloWebhookCardActionData>;
45
+ handleCommentCard: TrelloHandlerMappedSetFunction<TrelloWebhookCommentCardActionData>;
46
+ handleAddMemberToCard: TrelloHandlerMappedSetFunction<TrelloWebhookAddMemberToCardActionData>;
47
+ handleRemoveMemberFromCard: TrelloHandlerMappedSetFunction<TrelloWebhookAddMemberToCardActionData>;
48
+ handleUpdateBoard: TrelloHandlerMappedSetFunction<TrelloWebhookBoardActionData>;
49
+ }
50
+ export declare const trelloEventHandlerConfigurerFactory: import("@dereekb/util").HandlerConfigurerFactory<TrelloEventHandlerConfigurer, UntypedTrelloWebhookEvent, string, boolean>;
@@ -0,0 +1,13 @@
1
+ import { ConfigService } from '@nestjs/config';
2
+ import { TrelloWebhookServiceConfig } from './webhook.trello.config';
3
+ /**
4
+ * Factory function that creates TrelloWebhookServiceConfig from NestJS ConfigService.
5
+ *
6
+ * Reads `TRELLO_APP_SECRET` and `TRELLO_WEBHOOK_CALLBACK_URL` from the environment.
7
+ *
8
+ * @param configService The NestJS ConfigService.
9
+ * @returns A validated TrelloWebhookServiceConfig.
10
+ */
11
+ export declare function trelloWebhookServiceConfigFactory(configService: ConfigService): TrelloWebhookServiceConfig;
12
+ export declare class TrelloWebhookModule {
13
+ }
@@ -0,0 +1,24 @@
1
+ import { type Handler } from '@dereekb/util';
2
+ import { type Request } from 'express';
3
+ import { TrelloWebhookServiceConfig } from './webhook.trello.config';
4
+ import { type UntypedTrelloWebhookEvent } from './webhook.trello.type';
5
+ export interface UpdateForTrelloWebhookResponse {
6
+ readonly valid: boolean;
7
+ readonly handled: boolean;
8
+ readonly event?: UntypedTrelloWebhookEvent;
9
+ }
10
+ /**
11
+ * Service that processes Trello webhook events.
12
+ *
13
+ * Verifies the signature, then dispatches verified events through a {@link Handler}
14
+ * configured via {@link TrelloEventHandlerConfigurer}.
15
+ */
16
+ export declare class TrelloWebhookService {
17
+ private readonly logger;
18
+ private readonly _verifier;
19
+ readonly handler: Handler<UntypedTrelloWebhookEvent>;
20
+ readonly configure: import("@dereekb/util").HandlerConfigurer<import("./webhook.trello").TrelloEventHandlerConfigurer, UntypedTrelloWebhookEvent, string, boolean>;
21
+ constructor(config: TrelloWebhookServiceConfig);
22
+ updateForWebhook(req: Request, rawBody: Buffer): Promise<UpdateForTrelloWebhookResponse>;
23
+ updateForTrelloEvent(event: UntypedTrelloWebhookEvent): Promise<boolean>;
24
+ }
@@ -0,0 +1,85 @@
1
+ import { type TrelloBoardId, type TrelloCardId, type TrelloId, type TrelloListId, type TrelloMemberId, type TrelloOrganizationId, type TrelloWebhookId } from '@dereekb/trello';
2
+ /**
3
+ * Trello webhook action type, e.g. `createCard`, `updateCard`, `addMemberToCard`.
4
+ *
5
+ * The full set is large; consult the API reference for the active list.
6
+ *
7
+ * @see https://developer.atlassian.com/cloud/trello/guides/rest-api/object-definitions/#action-types
8
+ */
9
+ export type TrelloWebhookActionType = string;
10
+ /**
11
+ * The minimal shape of a Trello webhook action.
12
+ */
13
+ export interface TrelloWebhookAction<D = unknown> {
14
+ readonly id: TrelloId;
15
+ readonly type: TrelloWebhookActionType;
16
+ readonly date: string;
17
+ readonly idMemberCreator: TrelloMemberId;
18
+ readonly data: D;
19
+ }
20
+ /**
21
+ * Trello webhook model — the object the webhook is subscribed to.
22
+ *
23
+ * The shape varies depending on the model type (board, card, list, member, etc.).
24
+ */
25
+ export interface TrelloWebhookModel {
26
+ readonly id: TrelloId;
27
+ readonly [key: string]: unknown;
28
+ }
29
+ /**
30
+ * Webhook configuration object included in the POST body.
31
+ */
32
+ export interface TrelloWebhookEventWebhook {
33
+ readonly id: TrelloWebhookId;
34
+ readonly idModel: TrelloId;
35
+ readonly callbackURL: string;
36
+ readonly description: string;
37
+ readonly active: boolean;
38
+ }
39
+ /**
40
+ * Trello webhook POST body shape.
41
+ *
42
+ * @see https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/#receiving-webhook-events
43
+ */
44
+ export interface TrelloWebhookEvent<D = unknown> {
45
+ readonly action: TrelloWebhookAction<D>;
46
+ readonly model: TrelloWebhookModel;
47
+ readonly webhook: TrelloWebhookEventWebhook;
48
+ }
49
+ export type UntypedTrelloWebhookEvent = TrelloWebhookEvent<unknown>;
50
+ export interface TrelloWebhookCardActionData {
51
+ readonly card: {
52
+ readonly id: TrelloCardId;
53
+ readonly name?: string;
54
+ readonly idShort?: number;
55
+ };
56
+ readonly board: {
57
+ readonly id: TrelloBoardId;
58
+ readonly name?: string;
59
+ };
60
+ readonly list?: {
61
+ readonly id: TrelloListId;
62
+ readonly name?: string;
63
+ };
64
+ readonly old?: Record<string, unknown>;
65
+ }
66
+ export interface TrelloWebhookCommentCardActionData extends TrelloWebhookCardActionData {
67
+ readonly text: string;
68
+ }
69
+ export interface TrelloWebhookAddMemberToCardActionData extends TrelloWebhookCardActionData {
70
+ readonly idMember: TrelloMemberId;
71
+ readonly member: {
72
+ readonly id: TrelloMemberId;
73
+ readonly name?: string;
74
+ };
75
+ }
76
+ export interface TrelloWebhookBoardActionData {
77
+ readonly board: {
78
+ readonly id: TrelloBoardId;
79
+ readonly name?: string;
80
+ };
81
+ readonly organization?: {
82
+ readonly id: TrelloOrganizationId;
83
+ readonly name?: string;
84
+ };
85
+ }
@@ -0,0 +1,46 @@
1
+ import { type Request } from 'express';
2
+ import { type TrelloAppSecret } from '@dereekb/trello';
3
+ import { type UntypedTrelloWebhookEvent } from './webhook.trello.type';
4
+ export interface TrelloWebhookEventVerificationResult {
5
+ readonly valid: boolean;
6
+ /**
7
+ * Parsed event, only present on successful verification.
8
+ */
9
+ readonly event?: UntypedTrelloWebhookEvent;
10
+ }
11
+ /**
12
+ * Function that verifies a Trello webhook event.
13
+ */
14
+ export type TrelloWebhookEventVerifier = (req: Request, rawBody: Buffer) => TrelloWebhookEventVerificationResult;
15
+ export interface TrelloWebhookEventVerifierConfig {
16
+ /**
17
+ * App secret from the Power-Up admin page, used to verify the `X-Trello-Webhook` header.
18
+ */
19
+ readonly appSecret: TrelloAppSecret;
20
+ /**
21
+ * The exact callback URL configured for this webhook subscription.
22
+ *
23
+ * Trello signs the HMAC over `rawBody + callbackURL`, so the URL must match exactly (including scheme + path).
24
+ */
25
+ readonly callbackUrl: string;
26
+ }
27
+ /**
28
+ * Computes the expected `X-Trello-Webhook` value for the given body + callback URL.
29
+ *
30
+ * Exported for testability.
31
+ *
32
+ * @param appSecret The Trello app secret.
33
+ * @param rawBody The raw request body bytes.
34
+ * @param callbackUrl The exact callback URL configured for this webhook.
35
+ * @returns The expected base64 signature value.
36
+ */
37
+ export declare function trelloWebhookExpectedSignature(appSecret: TrelloAppSecret, rawBody: Buffer, callbackUrl: string): string;
38
+ /**
39
+ * Verifies a Trello webhook event header.
40
+ *
41
+ * @see https://developer.atlassian.com/cloud/trello/guides/rest-api/webhooks/#webhook-signatures
42
+ *
43
+ * @param config The verifier configuration.
44
+ * @returns A function that verifies a Trello webhook event.
45
+ */
46
+ export declare function trelloWebhookEventVerifier(config: TrelloWebhookEventVerifierConfig): TrelloWebhookEventVerifier;
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@dereekb/trello",
3
+ "version": "13.11.14",
4
+ "exports": {
5
+ "./nestjs": {
6
+ "module": "./nestjs/index.esm.js",
7
+ "types": "./nestjs/index.d.ts",
8
+ "import": "./nestjs/index.cjs.mjs",
9
+ "default": "./nestjs/index.cjs.js"
10
+ },
11
+ "./package.json": "./package.json",
12
+ ".": {
13
+ "module": "./index.esm.js",
14
+ "types": "./index.d.ts",
15
+ "import": "./index.cjs.mjs",
16
+ "default": "./index.cjs.js"
17
+ }
18
+ },
19
+ "peerDependencies": {
20
+ "@dereekb/nestjs": "13.11.14",
21
+ "@dereekb/rxjs": "13.11.14",
22
+ "@dereekb/util": "13.11.14",
23
+ "@nestjs/common": "^11.1.19",
24
+ "@nestjs/config": "^4.0.4",
25
+ "express": "^5.2.1",
26
+ "make-error": "^1.3.6"
27
+ },
28
+ "devDependencies": {
29
+ "@nestjs/testing": "^11.1.19"
30
+ },
31
+ "module": "./index.esm.js",
32
+ "main": "./index.cjs.js",
33
+ "types": "./index.d.ts"
34
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './lib';
@@ -0,0 +1,7 @@
1
+ export * from './shared';
2
+ export * from './trello';
3
+ export * from './trello.api.page';
4
+ export * from './trello.config';
5
+ export * from './trello.error.api';
6
+ export * from './trello.limit';
7
+ export * from './trello.type';
@@ -0,0 +1 @@
1
+ export * from './trello.type';
@@ -0,0 +1,23 @@
1
+ import { type ISO8601DateString, type Maybe } from '@dereekb/util';
2
+ /**
3
+ * RGB hex color string for label colors (no preset name).
4
+ */
5
+ export type TrelloHexColor = string;
6
+ /**
7
+ * One of the canonical Trello label colors. Pass `null` to clear a label color.
8
+ */
9
+ export type TrelloLabelColor = 'yellow' | 'purple' | 'blue' | 'red' | 'green' | 'orange' | 'black' | 'sky' | 'pink' | 'lime';
10
+ /**
11
+ * Common `pos` value used by lists, cards, and labels.
12
+ *
13
+ * Either a number, or the string `top` or `bottom`.
14
+ */
15
+ export type TrelloPosition = number | 'top' | 'bottom';
16
+ /**
17
+ * ISO date string used by Trello timestamps.
18
+ */
19
+ export type TrelloDateString = ISO8601DateString;
20
+ /**
21
+ * Maybe a date string, since Trello often returns null/undefined for unset dates.
22
+ */
23
+ export type TrelloMaybeDateString = Maybe<TrelloDateString>;
@@ -0,0 +1,11 @@
1
+ export * from './trello.factory';
2
+ export * from './trello.api.board';
3
+ export * from './trello.api.board.type';
4
+ export * from './trello.api.list';
5
+ export * from './trello.api.list.type';
6
+ export * from './trello.api.card';
7
+ export * from './trello.api.card.type';
8
+ export * from './trello.api.member';
9
+ export * from './trello.api.member.type';
10
+ export * from './trello.api.webhook';
11
+ export * from './trello.api.webhook.type';
@@ -0,0 +1,103 @@
1
+ import { type TrelloContext } from './trello.factory';
2
+ import { type TrelloBoardId, type TrelloMemberId } from '../trello.type';
3
+ import { type CreateBoardBody, type TrelloBoard, type UpdateBoardBody } from './trello.api.board.type';
4
+ import { type TrelloList } from './trello.api.list.type';
5
+ import { type TrelloCard, type TrelloLabel } from './trello.api.card.type';
6
+ import { type TrelloMember } from './trello.api.member.type';
7
+ export interface GetBoardInput {
8
+ readonly boardId: TrelloBoardId;
9
+ }
10
+ export type GetBoardFunction = (input: GetBoardInput) => Promise<TrelloBoard>;
11
+ /**
12
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-get
13
+ *
14
+ * @param context The Trello API context.
15
+ * @returns A function that retrieves a board by id.
16
+ */
17
+ export declare function getBoard(context: TrelloContext): GetBoardFunction;
18
+ export type CreateBoardFunction = (input: CreateBoardBody) => Promise<TrelloBoard>;
19
+ /**
20
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-post
21
+ *
22
+ * @param context The Trello API context.
23
+ * @returns A function that creates a new board.
24
+ */
25
+ export declare function createBoard(context: TrelloContext): CreateBoardFunction;
26
+ export interface UpdateBoardInput extends UpdateBoardBody {
27
+ readonly boardId: TrelloBoardId;
28
+ }
29
+ export type UpdateBoardFunction = (input: UpdateBoardInput) => Promise<TrelloBoard>;
30
+ /**
31
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-put
32
+ *
33
+ * @param context The Trello API context.
34
+ * @returns A function that updates an existing board.
35
+ */
36
+ export declare function updateBoard(context: TrelloContext): UpdateBoardFunction;
37
+ export type DeleteBoardFunction = (input: GetBoardInput) => Promise<void>;
38
+ /**
39
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-delete
40
+ *
41
+ * @param context The Trello API context.
42
+ * @returns A function that deletes a board.
43
+ */
44
+ export declare function deleteBoard(context: TrelloContext): DeleteBoardFunction;
45
+ export interface ListBoardListsInput {
46
+ readonly boardId: TrelloBoardId;
47
+ /**
48
+ * Whether to include all lists, only open, or only closed.
49
+ *
50
+ * Defaults to `open`.
51
+ */
52
+ readonly filter?: 'all' | 'closed' | 'none' | 'open';
53
+ }
54
+ export type ListBoardListsFunction = (input: ListBoardListsInput) => Promise<ReadonlyArray<TrelloList>>;
55
+ /**
56
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-lists-get
57
+ *
58
+ * @param context The Trello API context.
59
+ * @returns A function that lists all lists on a board.
60
+ */
61
+ export declare function listBoardLists(context: TrelloContext): ListBoardListsFunction;
62
+ export interface ListBoardCardsInput {
63
+ readonly boardId: TrelloBoardId;
64
+ readonly filter?: 'all' | 'closed' | 'none' | 'open' | 'visible';
65
+ }
66
+ export type ListBoardCardsFunction = (input: ListBoardCardsInput) => Promise<ReadonlyArray<TrelloCard>>;
67
+ /**
68
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-cards-get
69
+ *
70
+ * @param context The Trello API context.
71
+ * @returns A function that lists all cards on a board.
72
+ */
73
+ export declare function listBoardCards(context: TrelloContext): ListBoardCardsFunction;
74
+ export interface ListBoardLabelsInput {
75
+ readonly boardId: TrelloBoardId;
76
+ /**
77
+ * Maximum number of labels to return. Defaults to 50 server-side; max is 1000.
78
+ */
79
+ readonly limit?: number;
80
+ }
81
+ export type ListBoardLabelsFunction = (input: ListBoardLabelsInput) => Promise<ReadonlyArray<TrelloLabel>>;
82
+ /**
83
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-labels-get
84
+ *
85
+ * @param context The Trello API context.
86
+ * @returns A function that lists every label defined on a board.
87
+ */
88
+ export declare function listBoardLabels(context: TrelloContext): ListBoardLabelsFunction;
89
+ export interface ListBoardMembersInput {
90
+ readonly boardId: TrelloBoardId;
91
+ /**
92
+ * Optional member id filter. Pass to list a specific board member.
93
+ */
94
+ readonly memberId?: TrelloMemberId;
95
+ }
96
+ export type ListBoardMembersFunction = (input: ListBoardMembersInput) => Promise<ReadonlyArray<TrelloMember>>;
97
+ /**
98
+ * https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-members-get
99
+ *
100
+ * @param context The Trello API context.
101
+ * @returns A function that lists all members of a board.
102
+ */
103
+ export declare function listBoardMembers(context: TrelloContext): ListBoardMembersFunction;
@@ -0,0 +1,75 @@
1
+ import { type Maybe } from '@dereekb/util';
2
+ import { type TrelloBoardId, type TrelloOrganizationId } from '../trello.type';
3
+ import { type TrelloMaybeDateString } from '../shared/trello.type';
4
+ /**
5
+ * Trello board.
6
+ *
7
+ * Only the most commonly-used fields are typed. Use `fields=all` and a custom cast when more are required.
8
+ *
9
+ * @see https://developer.atlassian.com/cloud/trello/rest/api-group-boards/#api-boards-id-get
10
+ */
11
+ export interface TrelloBoard {
12
+ readonly id: TrelloBoardId;
13
+ readonly name: string;
14
+ readonly desc: string;
15
+ readonly closed: boolean;
16
+ readonly idOrganization: Maybe<TrelloOrganizationId>;
17
+ readonly url: string;
18
+ readonly shortUrl: string;
19
+ readonly pinned?: boolean;
20
+ readonly starred?: boolean;
21
+ readonly subscribed?: boolean;
22
+ readonly dateLastActivity: TrelloMaybeDateString;
23
+ readonly dateLastView?: TrelloMaybeDateString;
24
+ }
25
+ /**
26
+ * Permission level for a Trello board.
27
+ */
28
+ export type TrelloBoardPermissionLevel = 'private' | 'org' | 'public';
29
+ /**
30
+ * Background preset name. Custom backgrounds use ids returned by the API.
31
+ */
32
+ export type TrelloBoardBackground = 'blue' | 'orange' | 'green' | 'red' | 'purple' | 'pink' | 'lime' | 'sky' | 'grey' | string;
33
+ export interface CreateBoardBody {
34
+ /**
35
+ * The new board's name. Required. 1-16384 characters.
36
+ */
37
+ readonly name: string;
38
+ /**
39
+ * Optional board description.
40
+ */
41
+ readonly desc?: string;
42
+ /**
43
+ * Determines whether to use the default set of lists for the board (To Do, Doing, Done).
44
+ *
45
+ * Defaults to true.
46
+ */
47
+ readonly defaultLists?: boolean;
48
+ /**
49
+ * Determines whether to use the default set of labels for the board.
50
+ *
51
+ * Defaults to true.
52
+ */
53
+ readonly defaultLabels?: boolean;
54
+ /**
55
+ * The id of the organization the board should belong to.
56
+ */
57
+ readonly idOrganization?: TrelloOrganizationId;
58
+ /**
59
+ * The permission level. Defaults to private.
60
+ */
61
+ readonly prefs_permissionLevel?: TrelloBoardPermissionLevel;
62
+ /**
63
+ * Background of the board.
64
+ */
65
+ readonly prefs_background?: TrelloBoardBackground;
66
+ }
67
+ export interface UpdateBoardBody {
68
+ readonly name?: string;
69
+ readonly desc?: string;
70
+ readonly closed?: boolean;
71
+ readonly subscribed?: boolean;
72
+ readonly idOrganization?: TrelloOrganizationId;
73
+ readonly 'prefs/permissionLevel'?: TrelloBoardPermissionLevel;
74
+ readonly 'prefs/background'?: TrelloBoardBackground;
75
+ }