@spooled/sdk 1.2.1 → 1.3.0
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/README.md +42 -12
- package/dist/{index-CWVI9LRo.d.cts → index-BVWKEr6p.d.cts} +178 -45
- package/dist/{index-CWVI9LRo.d.ts → index-BVWKEr6p.d.ts} +178 -45
- package/dist/index.cjs +422 -184
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -8
- package/dist/index.d.ts +49 -8
- package/dist/index.js +422 -185
- package/dist/index.js.map +1 -1
- package/dist/worker/index.cjs +164 -45
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.d.cts +1 -1
- package/dist/worker/index.d.ts +1 -1
- package/dist/worker/index.js +164 -45
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RealtimeConnectionOptions, C as ConnectionState, S as SubscriptionFilter, a as RealtimeEventType, b as RealtimeEvent, c as RetryConfig } from './index-
|
|
2
|
-
export { A as API_VERSION, d as AddDependenciesParams, e as AddDependenciesResponse, f as AdminApiKeyResponse, g as AdminCreateApiKeyParams, h as AdminCreateOrganizationParams, i as AdminCreateOrganizationResponse, j as AdminDeleteOrganizationParams, k as AdminListOrganizationsParams, l as AdminOrganizationDetail, m as AdminOrganizationList, n as AdminOrganizationSummary, o as AdminPlanLimits, p as AdminPlatformStats, q as AdminResource, r as AdminUpdateOrganizationParams, s as AdminUsageStats, t as ApiKeySummary, u as ApiKeysResource, v as AuthResource, B as BatchJobStatus, w as BillingResource, x as BillingStatus, y as BoostPriorityResponse, z as BulkEnqueueParams, D as BulkEnqueueResponse, E as BulkJobItem, F as CheckEmailResponse, G as CheckSlugResponse, H as CircuitBreaker, I as CircuitBreakerConfig, J as CircuitState, K as ClaimJobsParams, L as ClaimJobsResult, M as ClaimedJob, N as CompleteJobParams, O as CreateApiKeyParams, P as CreateApiKeyResponse, Q as CreateBillingPortalParams, T as CreateBillingPortalResponse, U as CreateJobParams, V as CreateJobResult, W as CreateOrganizationParams, X as CreateOrganizationResponse, Y as CreateOutgoingWebhookParams, Z as CreateScheduleParams, _ as CreateScheduleResponse, $ as CreateWorkflowParams, a0 as CreateWorkflowResponse, a1 as CurrentUserResponse, a2 as DEFAULT_CONFIG, a3 as DashboardData, a4 as DashboardResource, a5 as DashboardWorkerSummary, a6 as DebugFn, a7 as
|
|
1
|
+
import { R as RealtimeConnectionOptions, C as ConnectionState, S as SubscriptionFilter, a as RealtimeEventType, b as RealtimeEvent, c as RetryConfig } from './index-BVWKEr6p.cjs';
|
|
2
|
+
export { A as API_VERSION, d as AddDependenciesParams, e as AddDependenciesResponse, f as AdminApiKeyResponse, g as AdminCreateApiKeyParams, h as AdminCreateOrganizationParams, i as AdminCreateOrganizationResponse, j as AdminDeleteOrganizationParams, k as AdminListOrganizationsParams, l as AdminOrganizationDetail, m as AdminOrganizationList, n as AdminOrganizationSummary, o as AdminPlanLimits, p as AdminPlatformStats, q as AdminResource, r as AdminUpdateOrganizationParams, s as AdminUsageStats, t as ApiKeySummary, u as ApiKeysResource, v as AuthResource, B as BatchJobStatus, w as BillingResource, x as BillingStatus, y as BoostPriorityResponse, z as BulkEnqueueParams, D as BulkEnqueueResponse, E as BulkJobItem, F as CheckEmailResponse, G as CheckSlugResponse, H as CircuitBreaker, I as CircuitBreakerConfig, J as CircuitState, K as ClaimJobsParams, L as ClaimJobsResult, M as ClaimedJob, N as CompleteJobParams, O as CreateApiKeyParams, P as CreateApiKeyResponse, Q as CreateBillingPortalParams, T as CreateBillingPortalResponse, U as CreateJobParams, V as CreateJobResult, W as CreateOrganizationParams, X as CreateOrganizationResponse, Y as CreateOutgoingWebhookParams, Z as CreateScheduleParams, _ as CreateScheduleResponse, $ as CreateWorkflowParams, a0 as CreateWorkflowResponse, a1 as CurrentUserResponse, a2 as DEFAULT_CONFIG, a3 as DashboardData, a4 as DashboardResource, a5 as DashboardWorkerSummary, a6 as DebugFn, a7 as DeleteQueueOptions, a8 as DependencyInfo, a9 as DependencyMode, aa as FailJobParams, ab as GrpcClientOptions, ac as GrpcCompleteJobParams, ad as GrpcCompleteJobResponse, ae as GrpcCompleteRequest, af as GrpcCompleteResponse, ag as GrpcDequeueJobParams, ah as GrpcDequeueJobResponse, ai as GrpcDequeueRequest, aj as GrpcDequeueResponse, ak as GrpcDeregisterRequest, al as GrpcDeregisterResponse, am as GrpcEnqueueJobParams, an as GrpcEnqueueJobResponse, ao as GrpcEnqueueRequest, ap as GrpcEnqueueResponse, aq as GrpcErrorResponse, ar as GrpcFailJobParams, as as GrpcFailJobResponse, at as GrpcFailRequest, au as GrpcFailResponse, av as GrpcGetJobRequest, aw as GrpcGetJobResponse, ax as GrpcGetQueueStatsRequest, ay as GrpcGetQueueStatsResponse, az as GrpcGetQueueStatsResponse_Legacy, aA as GrpcHeartbeatParams, aB as GrpcHeartbeatRequest, aC as GrpcHeartbeatResponse, aD as GrpcHeartbeatResponse_Legacy, aE as GrpcJob, aF as GrpcJobStatus, aG as GrpcJobStatusNumber, aH as GrpcProcessRequest, aI as GrpcProcessResponse, aJ as GrpcQueueOperations, aK as GrpcRegisterWorkerParams, aL as GrpcRegisterWorkerRequest, aM as GrpcRegisterWorkerResponse, aN as GrpcRegisterWorkerResponse_Legacy, aO as GrpcRenewLeaseParams, aP as GrpcRenewLeaseRequest, aQ as GrpcRenewLeaseResponse, aR as GrpcRenewLeaseResponse_Legacy, aS as GrpcStreamJobsRequest, aT as GrpcTimestamp, aU as GrpcWorkerOperations, aV as HealthResource, aW as HealthResponse, aX as HeartbeatEvent, aY as HeartbeatJobParams, aZ as HttpClient, a_ as IngestCustomWebhookParams, a$ as IngestCustomWebhookResponse, b0 as IngestGitHubWebhookOptions, b1 as IngestStripeWebhookOptions, b2 as InitialApiKey, b3 as Job, b4 as JobCompletedEvent, b5 as JobContext, b6 as JobCreatedEvent, b7 as JobFailedEvent, b8 as JobHandler, b9 as JobProgressEvent, ba as JobResult, bb as JobStartedEvent, bc as JobStats, bd as JobStatus, be as JobStatusChangedEvent, bf as JobStream, bg as JobSummary, bh as JobSummaryStats, bi as JobWithDependencies, bj as JobsResource, bk as JsonArray, bl as JsonObject, bm as JsonPrimitive, bn as JsonValue, bo as ListDlqParams, bp as ListJobsParams, bq as ListParams, br as ListSchedulesParams, bs as ListWorkflowsParams, bt as LoginParams, bu as LoginResponse, bv as MetricsResource, bw as Organization, bx as OrganizationMember, by as OrganizationSummary, bz as OrganizationUsage, bA as OrganizationsResource, bB as OutgoingWebhook, bC as OutgoingWebhookDelivery, bD as PaginatedResponse, bE as PaginationParams, bF as PauseQueueResponse, bG as PlanCount, bH as PlanLimits, bI as PlanTier, bJ as ProcessJobsStream, bK as PurgeDlqParams, bL as PurgeDlqResponse, bM as QueueConfig, bN as QueueConfigSummary, bO as QueuePausedEvent, bP as QueueResumedEvent, bQ as QueueStats, bR as QueueSummary, bS as QueuesResource, bT as RealtimeEventData, bU as RecentActivity, bV as RefreshTokenParams, bW as RefreshTokenResponse, bX as RegisterWorkerParams, bY as RegisterWorkerResponse, bZ as ResolvedConfig, b_ as ResourceUsage, b$ as ResumeQueueResponse, c0 as RetryDlqParams, c1 as RetryDlqResponse, c2 as SDK_VERSION, c3 as Schedule, c4 as ScheduleRun, c5 as ScheduleRunStatus, c6 as ScheduleTriggeredEvent, c7 as SchedulesResource, c8 as SpooledClient, c9 as SpooledClientConfig, ca as SpooledGrpcClient, cb as SpooledRealtime, cc as SpooledRealtimeOptions, cd as SpooledWorker, ce as SpooledWorkerOptions, cf as StartEmailLoginResponse, cg as StreamOptions, ch as SystemInfo, ci as TestWebhookResponse, cj as TokenClaims, ck as TriggerScheduleResponse, cl as UpdateApiKeyParams, cm as UpdateOrganizationParams, cn as UpdateOutgoingWebhookParams, co as UpdateQueueConfigParams, cp as UpdateScheduleParams, cq as UsageItem, cr as UsageWarning, cs as ValidateTokenParams, ct as ValidateTokenResponse, cu as WebhookDeliveryStatus, cv as WebhookEventType, cw as WebhookIngestionResource, cx as WebhookTokenResponse, cy as WebhooksResource, cz as Worker, cA as WorkerDeregisteredEvent, cB as WorkerEvent, cC as WorkerEventData, cD as WorkerHeartbeatParams, cE as WorkerRegisteredEvent, cF as WorkerState, cG as WorkerStatus, cH as WorkerSummary, cI as WorkersResource, cJ as Workflow, cK as WorkflowJob, cL as WorkflowJobDefinition, cM as WorkflowJobStatus, cN as WorkflowResponse, cO as WorkflowStatus, cP as WorkflowsResource, cQ as asyncIterableFromStream, cR as createCircuitBreaker, cS as createClient, cT as createHttpClient, cU as createJobStream, cV as createPaginatedResponse, cW as createProcessJobsStream, cX as dateToTimestamp, cY as resolveConfig, cZ as timestampToDate, c_ as validateConfig } from './index-BVWKEr6p.cjs';
|
|
3
3
|
import * as protoLoader from '@grpc/proto-loader';
|
|
4
4
|
import { ServiceClientConstructor } from '@grpc/grpc-js';
|
|
5
5
|
|
|
@@ -122,6 +122,12 @@ declare class SseRealtimeClient {
|
|
|
122
122
|
private reconnectAttempts;
|
|
123
123
|
private reconnectTimer;
|
|
124
124
|
private filter;
|
|
125
|
+
/** When the current connection opened (for the stable-connection check). */
|
|
126
|
+
private connectedAt;
|
|
127
|
+
/** The server finished this stream on purpose (terminal job); do not reconnect. */
|
|
128
|
+
private streamEnded;
|
|
129
|
+
/** The server rejected our token; mint a fresh one for the next connect. */
|
|
130
|
+
private forceTokenRefresh;
|
|
125
131
|
private eventHandlers;
|
|
126
132
|
private allEventsHandlers;
|
|
127
133
|
private stateChangeHandlers;
|
|
@@ -202,7 +208,13 @@ declare class SpooledError extends Error {
|
|
|
202
208
|
/** Original cause of the error */
|
|
203
209
|
readonly cause?: Error;
|
|
204
210
|
constructor(message: string, statusCode?: number, code?: string, details?: Record<string, unknown>, requestId?: string, cause?: Error);
|
|
205
|
-
/**
|
|
211
|
+
/**
|
|
212
|
+
* Whether this error is retryable.
|
|
213
|
+
*
|
|
214
|
+
* Only 408 (Request Timeout) is retryable among the plain 4xx statuses: the
|
|
215
|
+
* server gave up waiting for the request, so it never ran. Subclasses
|
|
216
|
+
* override this (5xx, network, timeout, rate limit).
|
|
217
|
+
*/
|
|
206
218
|
isRetryable(): boolean;
|
|
207
219
|
/** Convert to plain object for logging */
|
|
208
220
|
toJSON(): Record<string, unknown>;
|
|
@@ -236,11 +248,15 @@ declare class ConflictError extends SpooledError {
|
|
|
236
248
|
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
237
249
|
}
|
|
238
250
|
/**
|
|
239
|
-
* Validation error (400)
|
|
240
|
-
* Thrown when request validation fails
|
|
251
|
+
* Validation error (400 or 422)
|
|
252
|
+
* Thrown when request validation fails.
|
|
253
|
+
*
|
|
254
|
+
* The API answers a field-rule failure (length, range) with 400 but a missing
|
|
255
|
+
* or mistyped JSON field with 422; both are the caller's request being invalid,
|
|
256
|
+
* so both surface as this class. `statusCode` tells them apart.
|
|
241
257
|
*/
|
|
242
258
|
declare class ValidationError extends SpooledError {
|
|
243
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
259
|
+
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string, statusCode?: 400 | 422);
|
|
244
260
|
}
|
|
245
261
|
/**
|
|
246
262
|
* Payload too large error (413)
|
|
@@ -251,12 +267,26 @@ declare class PayloadTooLargeError extends SpooledError {
|
|
|
251
267
|
}
|
|
252
268
|
/**
|
|
253
269
|
* Rate limit error (429)
|
|
254
|
-
* Thrown when rate limit is exceeded
|
|
270
|
+
* Thrown when rate limit is exceeded, or a plan quota is (see `isQuota`)
|
|
255
271
|
*/
|
|
256
272
|
declare class RateLimitError extends SpooledError {
|
|
257
273
|
/** Rate limit information */
|
|
258
274
|
readonly rateLimitInfo: RateLimitInfo;
|
|
259
275
|
constructor(message?: string, code?: string, rateLimitInfo?: RateLimitInfo, details?: Record<string, unknown>, requestId?: string);
|
|
276
|
+
/**
|
|
277
|
+
* True when this 429 is a plan quota or limit (daily job cap, active jobs,
|
|
278
|
+
* queue/worker/webhook caps) rather than per-second rate limiting.
|
|
279
|
+
*
|
|
280
|
+
* A quota does not clear for minutes or hours, so retrying it only blocks the
|
|
281
|
+
* caller for the whole backoff and, via the circuit breaker, takes every
|
|
282
|
+
* other call on the client down with it. It is never retried and never
|
|
283
|
+
* counted as a circuit breaker failure.
|
|
284
|
+
*
|
|
285
|
+
* Detection: the `QUOTA_EXCEEDED` code, or, for older plan-limit paths that
|
|
286
|
+
* answer with plain text wrapped as `RATE_LIMIT_EXCEEDED`, a "... limit
|
|
287
|
+
* reached" message that carries no `Retry-After`.
|
|
288
|
+
*/
|
|
289
|
+
get isQuota(): boolean;
|
|
260
290
|
isRetryable(): boolean;
|
|
261
291
|
/** Get the number of seconds to wait before retrying */
|
|
262
292
|
getRetryAfter(): number;
|
|
@@ -296,6 +326,17 @@ declare class CircuitBreakerOpenError extends SpooledError {
|
|
|
296
326
|
constructor(message?: string);
|
|
297
327
|
isRetryable(): boolean;
|
|
298
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Unsupported operation error
|
|
331
|
+
* Thrown by SDK methods whose route the Spooled API does not provide (or
|
|
332
|
+
* always rejects). It is raised before any network call, so code that still
|
|
333
|
+
* calls such a method fails loudly with an explanation instead of a 404.
|
|
334
|
+
*/
|
|
335
|
+
declare class UnsupportedOperationError extends SpooledError {
|
|
336
|
+
/** The SDK method that is not supported, e.g. `ingest.github` */
|
|
337
|
+
readonly operation: string;
|
|
338
|
+
constructor(operation: string, reason: string);
|
|
339
|
+
}
|
|
299
340
|
/**
|
|
300
341
|
* Parse rate limit headers from a Response
|
|
301
342
|
*/
|
|
@@ -456,4 +497,4 @@ declare function convertResponse<T>(body: T): T;
|
|
|
456
497
|
*/
|
|
457
498
|
declare function convertQueryParams(params: Record<string, string | number | boolean | undefined>): Record<string, string>;
|
|
458
499
|
|
|
459
|
-
export { type ApiErrorBody, AuthenticationError, AuthorizationError, CircuitBreakerOpenError, ConflictError, ConnectionState, NetworkError, NotFoundError, PROTO_LOADER_OPTIONS, PayloadTooLargeError, RateLimitError, type RateLimitInfo, RealtimeConnectionOptions, RealtimeEvent, RealtimeEventType, RetryConfig, ServerError, SpooledError, type SpooledProtoDefinition, SseRealtimeClient, SubscriptionFilter, TimeoutError, ValidationError, WebSocketRealtimeClient, calculateDelay, camelToSnake, clearProtoCache, convertQueryParams, convertRequest, convertResponse, createErrorFromResponse, createRetryWrapper, getProtoPath, isRetryableError, isSpooledError, loadProtoDefinition, loadProtoDefinitionAsync, parseRateLimitHeaders, shouldRetry, sleep, snakeToCamel, toCamelCase, toSnakeCase, withRetry };
|
|
500
|
+
export { type ApiErrorBody, AuthenticationError, AuthorizationError, CircuitBreakerOpenError, ConflictError, ConnectionState, NetworkError, NotFoundError, PROTO_LOADER_OPTIONS, PayloadTooLargeError, RateLimitError, type RateLimitInfo, RealtimeConnectionOptions, RealtimeEvent, RealtimeEventType, RetryConfig, ServerError, SpooledError, type SpooledProtoDefinition, SseRealtimeClient, SubscriptionFilter, TimeoutError, UnsupportedOperationError, ValidationError, WebSocketRealtimeClient, calculateDelay, camelToSnake, clearProtoCache, convertQueryParams, convertRequest, convertResponse, createErrorFromResponse, createRetryWrapper, getProtoPath, isRetryableError, isSpooledError, loadProtoDefinition, loadProtoDefinitionAsync, parseRateLimitHeaders, shouldRetry, sleep, snakeToCamel, toCamelCase, toSnakeCase, withRetry };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RealtimeConnectionOptions, C as ConnectionState, S as SubscriptionFilter, a as RealtimeEventType, b as RealtimeEvent, c as RetryConfig } from './index-
|
|
2
|
-
export { A as API_VERSION, d as AddDependenciesParams, e as AddDependenciesResponse, f as AdminApiKeyResponse, g as AdminCreateApiKeyParams, h as AdminCreateOrganizationParams, i as AdminCreateOrganizationResponse, j as AdminDeleteOrganizationParams, k as AdminListOrganizationsParams, l as AdminOrganizationDetail, m as AdminOrganizationList, n as AdminOrganizationSummary, o as AdminPlanLimits, p as AdminPlatformStats, q as AdminResource, r as AdminUpdateOrganizationParams, s as AdminUsageStats, t as ApiKeySummary, u as ApiKeysResource, v as AuthResource, B as BatchJobStatus, w as BillingResource, x as BillingStatus, y as BoostPriorityResponse, z as BulkEnqueueParams, D as BulkEnqueueResponse, E as BulkJobItem, F as CheckEmailResponse, G as CheckSlugResponse, H as CircuitBreaker, I as CircuitBreakerConfig, J as CircuitState, K as ClaimJobsParams, L as ClaimJobsResult, M as ClaimedJob, N as CompleteJobParams, O as CreateApiKeyParams, P as CreateApiKeyResponse, Q as CreateBillingPortalParams, T as CreateBillingPortalResponse, U as CreateJobParams, V as CreateJobResult, W as CreateOrganizationParams, X as CreateOrganizationResponse, Y as CreateOutgoingWebhookParams, Z as CreateScheduleParams, _ as CreateScheduleResponse, $ as CreateWorkflowParams, a0 as CreateWorkflowResponse, a1 as CurrentUserResponse, a2 as DEFAULT_CONFIG, a3 as DashboardData, a4 as DashboardResource, a5 as DashboardWorkerSummary, a6 as DebugFn, a7 as
|
|
1
|
+
import { R as RealtimeConnectionOptions, C as ConnectionState, S as SubscriptionFilter, a as RealtimeEventType, b as RealtimeEvent, c as RetryConfig } from './index-BVWKEr6p.js';
|
|
2
|
+
export { A as API_VERSION, d as AddDependenciesParams, e as AddDependenciesResponse, f as AdminApiKeyResponse, g as AdminCreateApiKeyParams, h as AdminCreateOrganizationParams, i as AdminCreateOrganizationResponse, j as AdminDeleteOrganizationParams, k as AdminListOrganizationsParams, l as AdminOrganizationDetail, m as AdminOrganizationList, n as AdminOrganizationSummary, o as AdminPlanLimits, p as AdminPlatformStats, q as AdminResource, r as AdminUpdateOrganizationParams, s as AdminUsageStats, t as ApiKeySummary, u as ApiKeysResource, v as AuthResource, B as BatchJobStatus, w as BillingResource, x as BillingStatus, y as BoostPriorityResponse, z as BulkEnqueueParams, D as BulkEnqueueResponse, E as BulkJobItem, F as CheckEmailResponse, G as CheckSlugResponse, H as CircuitBreaker, I as CircuitBreakerConfig, J as CircuitState, K as ClaimJobsParams, L as ClaimJobsResult, M as ClaimedJob, N as CompleteJobParams, O as CreateApiKeyParams, P as CreateApiKeyResponse, Q as CreateBillingPortalParams, T as CreateBillingPortalResponse, U as CreateJobParams, V as CreateJobResult, W as CreateOrganizationParams, X as CreateOrganizationResponse, Y as CreateOutgoingWebhookParams, Z as CreateScheduleParams, _ as CreateScheduleResponse, $ as CreateWorkflowParams, a0 as CreateWorkflowResponse, a1 as CurrentUserResponse, a2 as DEFAULT_CONFIG, a3 as DashboardData, a4 as DashboardResource, a5 as DashboardWorkerSummary, a6 as DebugFn, a7 as DeleteQueueOptions, a8 as DependencyInfo, a9 as DependencyMode, aa as FailJobParams, ab as GrpcClientOptions, ac as GrpcCompleteJobParams, ad as GrpcCompleteJobResponse, ae as GrpcCompleteRequest, af as GrpcCompleteResponse, ag as GrpcDequeueJobParams, ah as GrpcDequeueJobResponse, ai as GrpcDequeueRequest, aj as GrpcDequeueResponse, ak as GrpcDeregisterRequest, al as GrpcDeregisterResponse, am as GrpcEnqueueJobParams, an as GrpcEnqueueJobResponse, ao as GrpcEnqueueRequest, ap as GrpcEnqueueResponse, aq as GrpcErrorResponse, ar as GrpcFailJobParams, as as GrpcFailJobResponse, at as GrpcFailRequest, au as GrpcFailResponse, av as GrpcGetJobRequest, aw as GrpcGetJobResponse, ax as GrpcGetQueueStatsRequest, ay as GrpcGetQueueStatsResponse, az as GrpcGetQueueStatsResponse_Legacy, aA as GrpcHeartbeatParams, aB as GrpcHeartbeatRequest, aC as GrpcHeartbeatResponse, aD as GrpcHeartbeatResponse_Legacy, aE as GrpcJob, aF as GrpcJobStatus, aG as GrpcJobStatusNumber, aH as GrpcProcessRequest, aI as GrpcProcessResponse, aJ as GrpcQueueOperations, aK as GrpcRegisterWorkerParams, aL as GrpcRegisterWorkerRequest, aM as GrpcRegisterWorkerResponse, aN as GrpcRegisterWorkerResponse_Legacy, aO as GrpcRenewLeaseParams, aP as GrpcRenewLeaseRequest, aQ as GrpcRenewLeaseResponse, aR as GrpcRenewLeaseResponse_Legacy, aS as GrpcStreamJobsRequest, aT as GrpcTimestamp, aU as GrpcWorkerOperations, aV as HealthResource, aW as HealthResponse, aX as HeartbeatEvent, aY as HeartbeatJobParams, aZ as HttpClient, a_ as IngestCustomWebhookParams, a$ as IngestCustomWebhookResponse, b0 as IngestGitHubWebhookOptions, b1 as IngestStripeWebhookOptions, b2 as InitialApiKey, b3 as Job, b4 as JobCompletedEvent, b5 as JobContext, b6 as JobCreatedEvent, b7 as JobFailedEvent, b8 as JobHandler, b9 as JobProgressEvent, ba as JobResult, bb as JobStartedEvent, bc as JobStats, bd as JobStatus, be as JobStatusChangedEvent, bf as JobStream, bg as JobSummary, bh as JobSummaryStats, bi as JobWithDependencies, bj as JobsResource, bk as JsonArray, bl as JsonObject, bm as JsonPrimitive, bn as JsonValue, bo as ListDlqParams, bp as ListJobsParams, bq as ListParams, br as ListSchedulesParams, bs as ListWorkflowsParams, bt as LoginParams, bu as LoginResponse, bv as MetricsResource, bw as Organization, bx as OrganizationMember, by as OrganizationSummary, bz as OrganizationUsage, bA as OrganizationsResource, bB as OutgoingWebhook, bC as OutgoingWebhookDelivery, bD as PaginatedResponse, bE as PaginationParams, bF as PauseQueueResponse, bG as PlanCount, bH as PlanLimits, bI as PlanTier, bJ as ProcessJobsStream, bK as PurgeDlqParams, bL as PurgeDlqResponse, bM as QueueConfig, bN as QueueConfigSummary, bO as QueuePausedEvent, bP as QueueResumedEvent, bQ as QueueStats, bR as QueueSummary, bS as QueuesResource, bT as RealtimeEventData, bU as RecentActivity, bV as RefreshTokenParams, bW as RefreshTokenResponse, bX as RegisterWorkerParams, bY as RegisterWorkerResponse, bZ as ResolvedConfig, b_ as ResourceUsage, b$ as ResumeQueueResponse, c0 as RetryDlqParams, c1 as RetryDlqResponse, c2 as SDK_VERSION, c3 as Schedule, c4 as ScheduleRun, c5 as ScheduleRunStatus, c6 as ScheduleTriggeredEvent, c7 as SchedulesResource, c8 as SpooledClient, c9 as SpooledClientConfig, ca as SpooledGrpcClient, cb as SpooledRealtime, cc as SpooledRealtimeOptions, cd as SpooledWorker, ce as SpooledWorkerOptions, cf as StartEmailLoginResponse, cg as StreamOptions, ch as SystemInfo, ci as TestWebhookResponse, cj as TokenClaims, ck as TriggerScheduleResponse, cl as UpdateApiKeyParams, cm as UpdateOrganizationParams, cn as UpdateOutgoingWebhookParams, co as UpdateQueueConfigParams, cp as UpdateScheduleParams, cq as UsageItem, cr as UsageWarning, cs as ValidateTokenParams, ct as ValidateTokenResponse, cu as WebhookDeliveryStatus, cv as WebhookEventType, cw as WebhookIngestionResource, cx as WebhookTokenResponse, cy as WebhooksResource, cz as Worker, cA as WorkerDeregisteredEvent, cB as WorkerEvent, cC as WorkerEventData, cD as WorkerHeartbeatParams, cE as WorkerRegisteredEvent, cF as WorkerState, cG as WorkerStatus, cH as WorkerSummary, cI as WorkersResource, cJ as Workflow, cK as WorkflowJob, cL as WorkflowJobDefinition, cM as WorkflowJobStatus, cN as WorkflowResponse, cO as WorkflowStatus, cP as WorkflowsResource, cQ as asyncIterableFromStream, cR as createCircuitBreaker, cS as createClient, cT as createHttpClient, cU as createJobStream, cV as createPaginatedResponse, cW as createProcessJobsStream, cX as dateToTimestamp, cY as resolveConfig, cZ as timestampToDate, c_ as validateConfig } from './index-BVWKEr6p.js';
|
|
3
3
|
import * as protoLoader from '@grpc/proto-loader';
|
|
4
4
|
import { ServiceClientConstructor } from '@grpc/grpc-js';
|
|
5
5
|
|
|
@@ -122,6 +122,12 @@ declare class SseRealtimeClient {
|
|
|
122
122
|
private reconnectAttempts;
|
|
123
123
|
private reconnectTimer;
|
|
124
124
|
private filter;
|
|
125
|
+
/** When the current connection opened (for the stable-connection check). */
|
|
126
|
+
private connectedAt;
|
|
127
|
+
/** The server finished this stream on purpose (terminal job); do not reconnect. */
|
|
128
|
+
private streamEnded;
|
|
129
|
+
/** The server rejected our token; mint a fresh one for the next connect. */
|
|
130
|
+
private forceTokenRefresh;
|
|
125
131
|
private eventHandlers;
|
|
126
132
|
private allEventsHandlers;
|
|
127
133
|
private stateChangeHandlers;
|
|
@@ -202,7 +208,13 @@ declare class SpooledError extends Error {
|
|
|
202
208
|
/** Original cause of the error */
|
|
203
209
|
readonly cause?: Error;
|
|
204
210
|
constructor(message: string, statusCode?: number, code?: string, details?: Record<string, unknown>, requestId?: string, cause?: Error);
|
|
205
|
-
/**
|
|
211
|
+
/**
|
|
212
|
+
* Whether this error is retryable.
|
|
213
|
+
*
|
|
214
|
+
* Only 408 (Request Timeout) is retryable among the plain 4xx statuses: the
|
|
215
|
+
* server gave up waiting for the request, so it never ran. Subclasses
|
|
216
|
+
* override this (5xx, network, timeout, rate limit).
|
|
217
|
+
*/
|
|
206
218
|
isRetryable(): boolean;
|
|
207
219
|
/** Convert to plain object for logging */
|
|
208
220
|
toJSON(): Record<string, unknown>;
|
|
@@ -236,11 +248,15 @@ declare class ConflictError extends SpooledError {
|
|
|
236
248
|
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
237
249
|
}
|
|
238
250
|
/**
|
|
239
|
-
* Validation error (400)
|
|
240
|
-
* Thrown when request validation fails
|
|
251
|
+
* Validation error (400 or 422)
|
|
252
|
+
* Thrown when request validation fails.
|
|
253
|
+
*
|
|
254
|
+
* The API answers a field-rule failure (length, range) with 400 but a missing
|
|
255
|
+
* or mistyped JSON field with 422; both are the caller's request being invalid,
|
|
256
|
+
* so both surface as this class. `statusCode` tells them apart.
|
|
241
257
|
*/
|
|
242
258
|
declare class ValidationError extends SpooledError {
|
|
243
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
259
|
+
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string, statusCode?: 400 | 422);
|
|
244
260
|
}
|
|
245
261
|
/**
|
|
246
262
|
* Payload too large error (413)
|
|
@@ -251,12 +267,26 @@ declare class PayloadTooLargeError extends SpooledError {
|
|
|
251
267
|
}
|
|
252
268
|
/**
|
|
253
269
|
* Rate limit error (429)
|
|
254
|
-
* Thrown when rate limit is exceeded
|
|
270
|
+
* Thrown when rate limit is exceeded, or a plan quota is (see `isQuota`)
|
|
255
271
|
*/
|
|
256
272
|
declare class RateLimitError extends SpooledError {
|
|
257
273
|
/** Rate limit information */
|
|
258
274
|
readonly rateLimitInfo: RateLimitInfo;
|
|
259
275
|
constructor(message?: string, code?: string, rateLimitInfo?: RateLimitInfo, details?: Record<string, unknown>, requestId?: string);
|
|
276
|
+
/**
|
|
277
|
+
* True when this 429 is a plan quota or limit (daily job cap, active jobs,
|
|
278
|
+
* queue/worker/webhook caps) rather than per-second rate limiting.
|
|
279
|
+
*
|
|
280
|
+
* A quota does not clear for minutes or hours, so retrying it only blocks the
|
|
281
|
+
* caller for the whole backoff and, via the circuit breaker, takes every
|
|
282
|
+
* other call on the client down with it. It is never retried and never
|
|
283
|
+
* counted as a circuit breaker failure.
|
|
284
|
+
*
|
|
285
|
+
* Detection: the `QUOTA_EXCEEDED` code, or, for older plan-limit paths that
|
|
286
|
+
* answer with plain text wrapped as `RATE_LIMIT_EXCEEDED`, a "... limit
|
|
287
|
+
* reached" message that carries no `Retry-After`.
|
|
288
|
+
*/
|
|
289
|
+
get isQuota(): boolean;
|
|
260
290
|
isRetryable(): boolean;
|
|
261
291
|
/** Get the number of seconds to wait before retrying */
|
|
262
292
|
getRetryAfter(): number;
|
|
@@ -296,6 +326,17 @@ declare class CircuitBreakerOpenError extends SpooledError {
|
|
|
296
326
|
constructor(message?: string);
|
|
297
327
|
isRetryable(): boolean;
|
|
298
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Unsupported operation error
|
|
331
|
+
* Thrown by SDK methods whose route the Spooled API does not provide (or
|
|
332
|
+
* always rejects). It is raised before any network call, so code that still
|
|
333
|
+
* calls such a method fails loudly with an explanation instead of a 404.
|
|
334
|
+
*/
|
|
335
|
+
declare class UnsupportedOperationError extends SpooledError {
|
|
336
|
+
/** The SDK method that is not supported, e.g. `ingest.github` */
|
|
337
|
+
readonly operation: string;
|
|
338
|
+
constructor(operation: string, reason: string);
|
|
339
|
+
}
|
|
299
340
|
/**
|
|
300
341
|
* Parse rate limit headers from a Response
|
|
301
342
|
*/
|
|
@@ -456,4 +497,4 @@ declare function convertResponse<T>(body: T): T;
|
|
|
456
497
|
*/
|
|
457
498
|
declare function convertQueryParams(params: Record<string, string | number | boolean | undefined>): Record<string, string>;
|
|
458
499
|
|
|
459
|
-
export { type ApiErrorBody, AuthenticationError, AuthorizationError, CircuitBreakerOpenError, ConflictError, ConnectionState, NetworkError, NotFoundError, PROTO_LOADER_OPTIONS, PayloadTooLargeError, RateLimitError, type RateLimitInfo, RealtimeConnectionOptions, RealtimeEvent, RealtimeEventType, RetryConfig, ServerError, SpooledError, type SpooledProtoDefinition, SseRealtimeClient, SubscriptionFilter, TimeoutError, ValidationError, WebSocketRealtimeClient, calculateDelay, camelToSnake, clearProtoCache, convertQueryParams, convertRequest, convertResponse, createErrorFromResponse, createRetryWrapper, getProtoPath, isRetryableError, isSpooledError, loadProtoDefinition, loadProtoDefinitionAsync, parseRateLimitHeaders, shouldRetry, sleep, snakeToCamel, toCamelCase, toSnakeCase, withRetry };
|
|
500
|
+
export { type ApiErrorBody, AuthenticationError, AuthorizationError, CircuitBreakerOpenError, ConflictError, ConnectionState, NetworkError, NotFoundError, PROTO_LOADER_OPTIONS, PayloadTooLargeError, RateLimitError, type RateLimitInfo, RealtimeConnectionOptions, RealtimeEvent, RealtimeEventType, RetryConfig, ServerError, SpooledError, type SpooledProtoDefinition, SseRealtimeClient, SubscriptionFilter, TimeoutError, UnsupportedOperationError, ValidationError, WebSocketRealtimeClient, calculateDelay, camelToSnake, clearProtoCache, convertQueryParams, convertRequest, convertResponse, createErrorFromResponse, createRetryWrapper, getProtoPath, isRetryableError, isSpooledError, loadProtoDefinition, loadProtoDefinitionAsync, parseRateLimitHeaders, shouldRetry, sleep, snakeToCamel, toCamelCase, toSnakeCase, withRetry };
|