@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,77 @@
1
+ import { type Maybe } from '@dereekb/util';
2
+ import { type ConfiguredFetch, type FetchRequestFactoryError, FetchResponseError } from '@dereekb/util/fetch';
3
+ import { BaseError } from 'make-error';
4
+ /**
5
+ * Raw error body shape returned by the Trello API.
6
+ *
7
+ * Trello commonly returns a plain text body (e.g. "invalid token") rather than JSON.
8
+ * This shape captures both the parsed JSON case and the text fallback.
9
+ */
10
+ export interface TrelloServerErrorData {
11
+ /**
12
+ * Status code of the underlying HTTP response.
13
+ */
14
+ readonly status: number;
15
+ /**
16
+ * Raw response body as text. Always present.
17
+ */
18
+ readonly bodyText: string;
19
+ /**
20
+ * Parsed JSON body when the response had a JSON content type.
21
+ */
22
+ readonly bodyJson?: unknown;
23
+ }
24
+ /**
25
+ * Base Trello server error.
26
+ */
27
+ export declare class TrelloServerError extends BaseError {
28
+ readonly data: TrelloServerErrorData;
29
+ constructor(message: string, data: TrelloServerErrorData);
30
+ get status(): number;
31
+ }
32
+ /**
33
+ * Trello server error that retains the originating fetch response.
34
+ */
35
+ export declare class TrelloServerFetchResponseError extends TrelloServerError {
36
+ readonly responseError: FetchResponseError;
37
+ constructor(message: string, data: TrelloServerErrorData, responseError: FetchResponseError);
38
+ }
39
+ /**
40
+ * Trello returned 401 — typically a revoked or otherwise invalid token.
41
+ *
42
+ * @see https://developer.atlassian.com/cloud/trello/guides/rest-api/authorization/
43
+ */
44
+ export declare class TrelloInvalidTokenError extends TrelloServerFetchResponseError {
45
+ }
46
+ /**
47
+ * Trello returned 429 — too many requests.
48
+ */
49
+ export declare class TrelloTooManyRequestsError extends TrelloServerFetchResponseError {
50
+ get retryAfter(): Maybe<number>;
51
+ }
52
+ export type LogTrelloServerErrorFunction = (error: FetchRequestFactoryError | TrelloServerError) => void;
53
+ /**
54
+ * Creates a logTrelloServerErrorFunction that logs the error to console.
55
+ *
56
+ * @param trelloApiNamePrefix Prefix to use when logging.
57
+ * @returns A function that logs Trello server errors to the console.
58
+ * @__NO_SIDE_EFFECTS__
59
+ */
60
+ export declare function logTrelloServerErrorFunction(trelloApiNamePrefix: string): LogTrelloServerErrorFunction;
61
+ export declare const logTrelloErrorToConsole: LogTrelloServerErrorFunction;
62
+ /**
63
+ * Parses a FetchResponseError into a typed Trello API error.
64
+ *
65
+ * @param responseError The fetch response error to parse.
66
+ * @returns A typed Trello error, or undefined if the response could not be parsed.
67
+ */
68
+ export declare function parseTrelloApiError(responseError: FetchResponseError): Promise<Maybe<TrelloServerFetchResponseError>>;
69
+ /**
70
+ * Wraps a ConfiguredFetch to translate FetchResponseError into typed Trello errors.
71
+ *
72
+ * @param fetch The fetch to wrap.
73
+ * @param logError Optional logger.
74
+ * @returns A ConfiguredFetch that throws typed Trello errors for known error responses.
75
+ * @__NO_SIDE_EFFECTS__
76
+ */
77
+ export declare function handleTrelloErrorFetch(fetch: ConfiguredFetch, logError?: LogTrelloServerErrorFunction): ConfiguredFetch;
@@ -0,0 +1,40 @@
1
+ import { type Maybe, type Milliseconds, type ResetPeriodPromiseRateLimiter } from '@dereekb/util';
2
+ import { type RateLimitedFetchHandler } from '@dereekb/util/fetch';
3
+ /**
4
+ * Documented per-token rate limit: 100 requests per 10 seconds.
5
+ *
6
+ * @see https://developer.atlassian.com/cloud/trello/guides/rest-api/rate-limits/
7
+ */
8
+ export declare const DEFAULT_TRELLO_API_RATE_LIMIT = 100;
9
+ /**
10
+ * Reset period for the per-token rate limit (10 seconds).
11
+ */
12
+ export declare const DEFAULT_TRELLO_API_RATE_LIMIT_RESET_PERIOD: Milliseconds;
13
+ export interface TrelloRateLimiterRef {
14
+ readonly trelloRateLimiter: ResetPeriodPromiseRateLimiter;
15
+ }
16
+ export interface TrelloRateLimitedFetchHandlerConfig {
17
+ /**
18
+ * Maximum number of requests allowed per reset period.
19
+ *
20
+ * Defaults to DEFAULT_TRELLO_API_RATE_LIMIT.
21
+ */
22
+ readonly maxRateLimit?: number;
23
+ /**
24
+ * Reset period for the rate limiter, in milliseconds.
25
+ *
26
+ * Defaults to DEFAULT_TRELLO_API_RATE_LIMIT_RESET_PERIOD.
27
+ */
28
+ readonly resetPeriod?: Milliseconds;
29
+ }
30
+ export type TrelloRateLimitedFetchHandler = RateLimitedFetchHandler<ResetPeriodPromiseRateLimiter>;
31
+ /**
32
+ * Creates a rate-limited fetch handler configured for the Trello API.
33
+ *
34
+ * Backs off after 429 responses and respects the documented per-token rate limit.
35
+ *
36
+ * @param config Optional configuration for rate limiting behavior.
37
+ * @returns A configured rate-limited fetch handler.
38
+ * @__NO_SIDE_EFFECTS__
39
+ */
40
+ export declare function trelloRateLimitedFetchHandler(config?: Maybe<TrelloRateLimitedFetchHandlerConfig>): TrelloRateLimitedFetchHandler;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * 24-character hex id used for boards, lists, cards, members, webhooks, etc.
3
+ */
4
+ export type TrelloId = string;
5
+ export type TrelloBoardId = TrelloId;
6
+ export type TrelloListId = TrelloId;
7
+ export type TrelloCardId = TrelloId;
8
+ export type TrelloMemberId = TrelloId;
9
+ export type TrelloLabelId = TrelloId;
10
+ export type TrelloActionId = TrelloId;
11
+ export type TrelloChecklistId = TrelloId;
12
+ export type TrelloWebhookId = TrelloId;
13
+ export type TrelloOrganizationId = TrelloId;
14
+ export type TrelloEnterpriseId = TrelloId;
15
+ /**
16
+ * Trello API key, exposed publicly as part of Power-Up configuration.
17
+ */
18
+ export type TrelloApiKey = string;
19
+ /**
20
+ * Trello user API token granted via the OAuth1 or `/1/authorize` flow.
21
+ *
22
+ * Treat as a secret — token grants the same access the user has consented to.
23
+ */
24
+ export type TrelloApiToken = string;
25
+ /**
26
+ * Application secret used to sign webhook requests for verification.
27
+ *
28
+ * Found on the same Power-Up admin page as the API key.
29
+ */
30
+ export type TrelloAppSecret = string;
31
+ /**
32
+ * Trello username (the slug portion of a profile URL).
33
+ */
34
+ export type TrelloUsername = string;
35
+ /**
36
+ * Trello API URL (versioned).
37
+ */
38
+ export declare const TRELLO_API_URL = "https://api.trello.com/1";
39
+ export type TrelloApiUrl = typeof TRELLO_API_URL;