@webhooks-cc/sdk 1.2.0 → 1.2.1
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.
- package/dist/{chunk-7IMPSHQY.mjs → chunk-NSGVJJSF.mjs} +7 -2
- package/dist/{diff-DbTsOT_n.d.mts → diff-kGWh0pPP.d.mts} +17 -2
- package/dist/{diff-DbTsOT_n.d.ts → diff-kGWh0pPP.d.ts} +17 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -3
- package/dist/index.mjs +14 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +1 -1
|
@@ -26,11 +26,16 @@ var TimeoutError = class extends WebhooksCCError {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
var RateLimitError = class extends WebhooksCCError {
|
|
29
|
-
constructor(retryAfter) {
|
|
30
|
-
const message = retryAfter ? `Rate limited, retry after ${retryAfter}s` : "Rate limited";
|
|
29
|
+
constructor(retryAfter, meta) {
|
|
30
|
+
const message = retryAfter !== void 0 ? `Rate limited, retry after ${retryAfter}s` : "Rate limited";
|
|
31
31
|
super(429, message);
|
|
32
32
|
this.name = "RateLimitError";
|
|
33
33
|
this.retryAfter = retryAfter;
|
|
34
|
+
if (meta) {
|
|
35
|
+
this.limit = meta.limit;
|
|
36
|
+
this.remaining = meta.remaining;
|
|
37
|
+
this.reset = meta.reset;
|
|
38
|
+
}
|
|
34
39
|
}
|
|
35
40
|
};
|
|
36
41
|
|
|
@@ -488,11 +488,26 @@ declare class NotFoundError extends WebhooksCCError {
|
|
|
488
488
|
declare class TimeoutError extends WebhooksCCError {
|
|
489
489
|
constructor(timeoutMs: number);
|
|
490
490
|
}
|
|
491
|
+
/** Rate limit metadata from X-RateLimit-* response headers. */
|
|
492
|
+
interface RateLimitMeta {
|
|
493
|
+
/** Maximum number of requests allowed in the current window. */
|
|
494
|
+
limit: number;
|
|
495
|
+
/** Number of requests remaining in the current window. */
|
|
496
|
+
remaining: number;
|
|
497
|
+
/** Unix epoch timestamp (seconds) when the rate limit window resets. */
|
|
498
|
+
reset: number;
|
|
499
|
+
}
|
|
491
500
|
/** Thrown when the API returns 429 Too Many Requests. */
|
|
492
501
|
declare class RateLimitError extends WebhooksCCError {
|
|
493
502
|
/** Seconds until the rate limit resets, if provided by the server. */
|
|
494
503
|
readonly retryAfter?: number;
|
|
495
|
-
|
|
504
|
+
/** Maximum number of requests allowed in the current window. */
|
|
505
|
+
readonly limit?: number;
|
|
506
|
+
/** Number of requests remaining in the current window. */
|
|
507
|
+
readonly remaining?: number;
|
|
508
|
+
/** Unix epoch timestamp (seconds) when the rate limit window resets. */
|
|
509
|
+
readonly reset?: number;
|
|
510
|
+
constructor(retryAfter?: number, meta?: RateLimitMeta);
|
|
496
511
|
}
|
|
497
512
|
|
|
498
513
|
interface FlowClient {
|
|
@@ -711,4 +726,4 @@ type ComparableRequest = Pick<Request, "method" | "path" | "headers" | "body"> &
|
|
|
711
726
|
*/
|
|
712
727
|
declare function diffRequests(left: ComparableRequest | SearchResult, right: ComparableRequest | SearchResult, options?: DiffRequestsOptions): DiffResult;
|
|
713
728
|
|
|
714
|
-
export {
|
|
729
|
+
export { WebhookFlowBuilder as $, ApiError as A, type BodyDiff as B, type ClearRequestsOptions as C, type DiffRequestsOptions as D, type Endpoint as E, type FormBodyValue as F, type TemplateProviderInfo as G, type HarExport as H, type TextBodyDiff as I, type JsonBodyDiff as J, TimeoutError as K, type ListPaginatedRequestsOptions as L, type MockResponse as M, NotFoundError as N, type OperationDescription as O, type ParsedBody as P, type UpdateEndpointOptions as Q, type Request as R, type SearchResult as S, type TeamShare as T, UnauthorizedError as U, type VerifySignatureOptions as V, type UsageInfo as W, type ValueDifference as X, type VerifyProvider as Y, type WaitForAllOptions as Z, type WaitForOptions as _, type ParsedFormBody as a, type WebhookFlowResult as a0, type WebhookFlowVerifyOptions as a1, WebhooksCC as a2, WebhooksCCError as a3, diffRequests as a4, type SignatureVerificationResult as b, type ClientHooks as c, type ClientOptions as d, type CreateEndpointOptions as e, type CurlExport as f, type DiffResult as g, type ErrorHookInfo as h, type ExportRequestsOptions as i, type HeaderDiff as j, type ListRequestsOptions as k, type PaginatedResult as l, RateLimitError as m, type RateLimitMeta as n, type RequestDifferences as o, type RequestHookInfo as p, type RequestsExport as q, type ResponseHookInfo as r, type RetryOptions as s, type SDKDescription as t, type SearchFilters as u, type SendOptions as v, type SendTemplateOptions as w, type SendToOptions as x, type SubscribeOptions as y, type TemplateProvider as z };
|
|
@@ -488,11 +488,26 @@ declare class NotFoundError extends WebhooksCCError {
|
|
|
488
488
|
declare class TimeoutError extends WebhooksCCError {
|
|
489
489
|
constructor(timeoutMs: number);
|
|
490
490
|
}
|
|
491
|
+
/** Rate limit metadata from X-RateLimit-* response headers. */
|
|
492
|
+
interface RateLimitMeta {
|
|
493
|
+
/** Maximum number of requests allowed in the current window. */
|
|
494
|
+
limit: number;
|
|
495
|
+
/** Number of requests remaining in the current window. */
|
|
496
|
+
remaining: number;
|
|
497
|
+
/** Unix epoch timestamp (seconds) when the rate limit window resets. */
|
|
498
|
+
reset: number;
|
|
499
|
+
}
|
|
491
500
|
/** Thrown when the API returns 429 Too Many Requests. */
|
|
492
501
|
declare class RateLimitError extends WebhooksCCError {
|
|
493
502
|
/** Seconds until the rate limit resets, if provided by the server. */
|
|
494
503
|
readonly retryAfter?: number;
|
|
495
|
-
|
|
504
|
+
/** Maximum number of requests allowed in the current window. */
|
|
505
|
+
readonly limit?: number;
|
|
506
|
+
/** Number of requests remaining in the current window. */
|
|
507
|
+
readonly remaining?: number;
|
|
508
|
+
/** Unix epoch timestamp (seconds) when the rate limit window resets. */
|
|
509
|
+
readonly reset?: number;
|
|
510
|
+
constructor(retryAfter?: number, meta?: RateLimitMeta);
|
|
496
511
|
}
|
|
497
512
|
|
|
498
513
|
interface FlowClient {
|
|
@@ -711,4 +726,4 @@ type ComparableRequest = Pick<Request, "method" | "path" | "headers" | "body"> &
|
|
|
711
726
|
*/
|
|
712
727
|
declare function diffRequests(left: ComparableRequest | SearchResult, right: ComparableRequest | SearchResult, options?: DiffRequestsOptions): DiffResult;
|
|
713
728
|
|
|
714
|
-
export {
|
|
729
|
+
export { WebhookFlowBuilder as $, ApiError as A, type BodyDiff as B, type ClearRequestsOptions as C, type DiffRequestsOptions as D, type Endpoint as E, type FormBodyValue as F, type TemplateProviderInfo as G, type HarExport as H, type TextBodyDiff as I, type JsonBodyDiff as J, TimeoutError as K, type ListPaginatedRequestsOptions as L, type MockResponse as M, NotFoundError as N, type OperationDescription as O, type ParsedBody as P, type UpdateEndpointOptions as Q, type Request as R, type SearchResult as S, type TeamShare as T, UnauthorizedError as U, type VerifySignatureOptions as V, type UsageInfo as W, type ValueDifference as X, type VerifyProvider as Y, type WaitForAllOptions as Z, type WaitForOptions as _, type ParsedFormBody as a, type WebhookFlowResult as a0, type WebhookFlowVerifyOptions as a1, WebhooksCC as a2, WebhooksCCError as a3, diffRequests as a4, type SignatureVerificationResult as b, type ClientHooks as c, type ClientOptions as d, type CreateEndpointOptions as e, type CurlExport as f, type DiffResult as g, type ErrorHookInfo as h, type ExportRequestsOptions as i, type HeaderDiff as j, type ListRequestsOptions as k, type PaginatedResult as l, RateLimitError as m, type RateLimitMeta as n, type RequestDifferences as o, type RequestHookInfo as p, type RequestsExport as q, type ResponseHookInfo as r, type RetryOptions as s, type SDKDescription as t, type SearchFilters as u, type SendOptions as v, type SendTemplateOptions as w, type SendToOptions as x, type SubscribeOptions as y, type TemplateProvider as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as Request, P as ParsedBody, a as ParsedFormBody, S as SearchResult, V as VerifySignatureOptions, b as SignatureVerificationResult } from './diff-
|
|
2
|
-
export { A as ApiError, B as BodyDiff, C as ClearRequestsOptions, c as ClientHooks, d as ClientOptions, e as CreateEndpointOptions, f as CurlExport, D as DiffRequestsOptions, g as DiffResult, E as Endpoint, h as ErrorHookInfo, i as ExportRequestsOptions, F as FormBodyValue, H as HarExport, j as HeaderDiff, J as JsonBodyDiff, L as ListPaginatedRequestsOptions, k as ListRequestsOptions, M as MockResponse, N as NotFoundError, O as OperationDescription, l as PaginatedResult, m as RateLimitError, n as
|
|
1
|
+
import { R as Request, P as ParsedBody, a as ParsedFormBody, S as SearchResult, V as VerifySignatureOptions, b as SignatureVerificationResult } from './diff-kGWh0pPP.mjs';
|
|
2
|
+
export { A as ApiError, B as BodyDiff, C as ClearRequestsOptions, c as ClientHooks, d as ClientOptions, e as CreateEndpointOptions, f as CurlExport, D as DiffRequestsOptions, g as DiffResult, E as Endpoint, h as ErrorHookInfo, i as ExportRequestsOptions, F as FormBodyValue, H as HarExport, j as HeaderDiff, J as JsonBodyDiff, L as ListPaginatedRequestsOptions, k as ListRequestsOptions, M as MockResponse, N as NotFoundError, O as OperationDescription, l as PaginatedResult, m as RateLimitError, n as RateLimitMeta, o as RequestDifferences, p as RequestHookInfo, q as RequestsExport, r as ResponseHookInfo, s as RetryOptions, t as SDKDescription, u as SearchFilters, v as SendOptions, w as SendTemplateOptions, x as SendToOptions, y as SubscribeOptions, T as TeamShare, z as TemplateProvider, G as TemplateProviderInfo, I as TextBodyDiff, K as TimeoutError, U as UnauthorizedError, Q as UpdateEndpointOptions, W as UsageInfo, X as ValueDifference, Y as VerifyProvider, Z as WaitForAllOptions, _ as WaitForOptions, $ as WebhookFlowBuilder, a0 as WebhookFlowResult, a1 as WebhookFlowVerifyOptions, a2 as WebhooksCC, a3 as WebhooksCCError, a4 as diffRequests } from './diff-kGWh0pPP.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Safely parse a JSON request body.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as Request, P as ParsedBody, a as ParsedFormBody, S as SearchResult, V as VerifySignatureOptions, b as SignatureVerificationResult } from './diff-
|
|
2
|
-
export { A as ApiError, B as BodyDiff, C as ClearRequestsOptions, c as ClientHooks, d as ClientOptions, e as CreateEndpointOptions, f as CurlExport, D as DiffRequestsOptions, g as DiffResult, E as Endpoint, h as ErrorHookInfo, i as ExportRequestsOptions, F as FormBodyValue, H as HarExport, j as HeaderDiff, J as JsonBodyDiff, L as ListPaginatedRequestsOptions, k as ListRequestsOptions, M as MockResponse, N as NotFoundError, O as OperationDescription, l as PaginatedResult, m as RateLimitError, n as
|
|
1
|
+
import { R as Request, P as ParsedBody, a as ParsedFormBody, S as SearchResult, V as VerifySignatureOptions, b as SignatureVerificationResult } from './diff-kGWh0pPP.js';
|
|
2
|
+
export { A as ApiError, B as BodyDiff, C as ClearRequestsOptions, c as ClientHooks, d as ClientOptions, e as CreateEndpointOptions, f as CurlExport, D as DiffRequestsOptions, g as DiffResult, E as Endpoint, h as ErrorHookInfo, i as ExportRequestsOptions, F as FormBodyValue, H as HarExport, j as HeaderDiff, J as JsonBodyDiff, L as ListPaginatedRequestsOptions, k as ListRequestsOptions, M as MockResponse, N as NotFoundError, O as OperationDescription, l as PaginatedResult, m as RateLimitError, n as RateLimitMeta, o as RequestDifferences, p as RequestHookInfo, q as RequestsExport, r as ResponseHookInfo, s as RetryOptions, t as SDKDescription, u as SearchFilters, v as SendOptions, w as SendTemplateOptions, x as SendToOptions, y as SubscribeOptions, T as TeamShare, z as TemplateProvider, G as TemplateProviderInfo, I as TextBodyDiff, K as TimeoutError, U as UnauthorizedError, Q as UpdateEndpointOptions, W as UsageInfo, X as ValueDifference, Y as VerifyProvider, Z as WaitForAllOptions, _ as WaitForOptions, $ as WebhookFlowBuilder, a0 as WebhookFlowResult, a1 as WebhookFlowVerifyOptions, a2 as WebhooksCC, a3 as WebhooksCCError, a4 as diffRequests } from './diff-kGWh0pPP.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Safely parse a JSON request body.
|
package/dist/index.js
CHANGED
|
@@ -103,11 +103,16 @@ var TimeoutError = class extends WebhooksCCError {
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
var RateLimitError = class extends WebhooksCCError {
|
|
106
|
-
constructor(retryAfter) {
|
|
107
|
-
const message = retryAfter ? `Rate limited, retry after ${retryAfter}s` : "Rate limited";
|
|
106
|
+
constructor(retryAfter, meta) {
|
|
107
|
+
const message = retryAfter !== void 0 ? `Rate limited, retry after ${retryAfter}s` : "Rate limited";
|
|
108
108
|
super(429, message);
|
|
109
109
|
this.name = "RateLimitError";
|
|
110
110
|
this.retryAfter = retryAfter;
|
|
111
|
+
if (meta) {
|
|
112
|
+
this.limit = meta.limit;
|
|
113
|
+
this.remaining = meta.remaining;
|
|
114
|
+
this.reset = meta.reset;
|
|
115
|
+
}
|
|
111
116
|
}
|
|
112
117
|
};
|
|
113
118
|
|
|
@@ -2238,7 +2243,19 @@ function mapStatusToError(status, message, response) {
|
|
|
2238
2243
|
const parsed = parseInt(retryAfterHeader, 10);
|
|
2239
2244
|
retryAfter = Number.isNaN(parsed) ? void 0 : parsed;
|
|
2240
2245
|
}
|
|
2241
|
-
|
|
2246
|
+
const limitHeader = response.headers.get("x-ratelimit-limit");
|
|
2247
|
+
const remainingHeader = response.headers.get("x-ratelimit-remaining");
|
|
2248
|
+
const resetHeader = response.headers.get("x-ratelimit-reset");
|
|
2249
|
+
let meta;
|
|
2250
|
+
if (limitHeader !== null && remainingHeader !== null && resetHeader !== null) {
|
|
2251
|
+
const limit = parseInt(limitHeader, 10);
|
|
2252
|
+
const remaining = parseInt(remainingHeader, 10);
|
|
2253
|
+
const reset = parseInt(resetHeader, 10);
|
|
2254
|
+
if (!Number.isNaN(limit) && !Number.isNaN(remaining) && !Number.isNaN(reset) && limit >= 0 && remaining >= 0 && reset >= 0) {
|
|
2255
|
+
meta = { limit, remaining, reset };
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
return new RateLimitError(retryAfter, meta);
|
|
2242
2259
|
}
|
|
2243
2260
|
default:
|
|
2244
2261
|
return new WebhooksCCError(status, message);
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
WebhooksCCError,
|
|
7
7
|
diffRequests,
|
|
8
8
|
parseDuration
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NSGVJJSF.mjs";
|
|
10
10
|
|
|
11
11
|
// src/sse.ts
|
|
12
12
|
async function* parseSSE(stream) {
|
|
@@ -2097,7 +2097,19 @@ function mapStatusToError(status, message, response) {
|
|
|
2097
2097
|
const parsed = parseInt(retryAfterHeader, 10);
|
|
2098
2098
|
retryAfter = Number.isNaN(parsed) ? void 0 : parsed;
|
|
2099
2099
|
}
|
|
2100
|
-
|
|
2100
|
+
const limitHeader = response.headers.get("x-ratelimit-limit");
|
|
2101
|
+
const remainingHeader = response.headers.get("x-ratelimit-remaining");
|
|
2102
|
+
const resetHeader = response.headers.get("x-ratelimit-reset");
|
|
2103
|
+
let meta;
|
|
2104
|
+
if (limitHeader !== null && remainingHeader !== null && resetHeader !== null) {
|
|
2105
|
+
const limit = parseInt(limitHeader, 10);
|
|
2106
|
+
const remaining = parseInt(remainingHeader, 10);
|
|
2107
|
+
const reset = parseInt(resetHeader, 10);
|
|
2108
|
+
if (!Number.isNaN(limit) && !Number.isNaN(remaining) && !Number.isNaN(reset) && limit >= 0 && remaining >= 0 && reset >= 0) {
|
|
2109
|
+
meta = { limit, remaining, reset };
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
return new RateLimitError(retryAfter, meta);
|
|
2101
2113
|
}
|
|
2102
2114
|
default:
|
|
2103
2115
|
return new WebhooksCCError(status, message);
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as DiffResult, e as CreateEndpointOptions, R as Request,
|
|
1
|
+
import { g as DiffResult, e as CreateEndpointOptions, R as Request, a2 as WebhooksCC, E as Endpoint } from './diff-kGWh0pPP.mjs';
|
|
2
2
|
|
|
3
3
|
type TestingClient = Pick<WebhooksCC, "endpoints" | "requests">;
|
|
4
4
|
interface AssertRequestExpectation {
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as DiffResult, e as CreateEndpointOptions, R as Request,
|
|
1
|
+
import { g as DiffResult, e as CreateEndpointOptions, R as Request, a2 as WebhooksCC, E as Endpoint } from './diff-kGWh0pPP.js';
|
|
2
2
|
|
|
3
3
|
type TestingClient = Pick<WebhooksCC, "endpoints" | "requests">;
|
|
4
4
|
interface AssertRequestExpectation {
|
package/dist/testing.mjs
CHANGED