@spooled/sdk 1.2.1 → 1.4.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 +119 -18
- package/dist/{index-CWVI9LRo.d.cts → index-DzTC8ld3.d.cts} +741 -134
- package/dist/{index-CWVI9LRo.d.ts → index-DzTC8ld3.d.ts} +741 -134
- package/dist/index.cjs +758 -304
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -151
- package/dist/index.d.ts +9 -151
- package/dist/index.js +757 -305
- 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 +4 -3
- package/proto/spooled.proto +19 -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
|
|
1
|
+
import { R as RealtimeConnectionOptions, C as ConnectionState, S as SubscriptionFilter, a as RealtimeEventType, b as RealtimeEvent, c as RetryConfig } from './index-DzTC8ld3.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 ApiErrorBody, u as ApiKeySummary, v as ApiKeysResource, w as AuthResource, x as AuthenticationError, y as AuthorizationError, B as BatchJobStatus, z as BillingResource, D as BillingStatus, E as BoostPriorityResponse, F as BulkEnqueueParams, G as BulkEnqueueResponse, H as BulkJobItem, I as CheckEmailResponse, J as CheckSlugResponse, K as CircuitBreaker, L as CircuitBreakerConfig, M as CircuitBreakerOpenError, N as CircuitBreakerOptions, O as CircuitState, P as CircuitStateChange, Q as ClaimJobsParams, T as ClaimJobsResult, U as ClaimedJob, V as CompleteJobParams, W as ConflictError, X as CreateApiKeyParams, Y as CreateApiKeyResponse, Z as CreateBillingPortalParams, _ as CreateBillingPortalResponse, $ as CreateJobParams, a0 as CreateJobResult, a1 as CreateOrganizationParams, a2 as CreateOrganizationResponse, a3 as CreateOutgoingWebhookParams, a4 as CreateScheduleParams, a5 as CreateScheduleResponse, a6 as CreateWorkflowParams, a7 as CreateWorkflowResponse, a8 as CurrentUserResponse, a9 as DEFAULT_CONFIG, aa as DashboardData, ab as DashboardResource, ac as DashboardWorkerSummary, ad as DebugFn, ae as DeleteQueueOptions, af as DependencyInfo, ag as DependencyMode, ah as FailJobParams, ai as GrpcClientOptions, aj as GrpcCompleteJobParams, ak as GrpcCompleteJobResponse, al as GrpcCompleteRequest, am as GrpcCompleteResponse, an as GrpcDequeueJobParams, ao as GrpcDequeueJobResponse, ap as GrpcDequeueRequest, aq as GrpcDequeueResponse, ar as GrpcDeregisterRequest, as as GrpcDeregisterResponse, at as GrpcEnqueueJobParams, au as GrpcEnqueueJobResponse, av as GrpcEnqueueRequest, aw as GrpcEnqueueResponse, ax as GrpcErrorResponse, ay as GrpcFailJobParams, az as GrpcFailJobResponse, aA as GrpcFailRequest, aB as GrpcFailResponse, aC as GrpcGetJobRequest, aD as GrpcGetJobResponse, aE as GrpcGetQueueStatsRequest, aF as GrpcGetQueueStatsResponse, aG as GrpcGetQueueStatsResponse_Legacy, aH as GrpcHeartbeatParams, aI as GrpcHeartbeatRequest, aJ as GrpcHeartbeatResponse, aK as GrpcHeartbeatResponse_Legacy, aL as GrpcJob, aM as GrpcJobStatus, aN as GrpcJobStatusNumber, aO as GrpcProcessRequest, aP as GrpcProcessResponse, aQ as GrpcQueueOperations, aR as GrpcRegisterWorkerParams, aS as GrpcRegisterWorkerRequest, aT as GrpcRegisterWorkerResponse, aU as GrpcRegisterWorkerResponse_Legacy, aV as GrpcRenewLeaseParams, aW as GrpcRenewLeaseRequest, aX as GrpcRenewLeaseResponse, aY as GrpcRenewLeaseResponse_Legacy, aZ as GrpcStreamJobsRequest, a_ as GrpcTimestamp, a$ as GrpcWorkerOperations, b0 as HealthResource, b1 as HealthResponse, b2 as HeartbeatEvent, b3 as HeartbeatJobParams, b4 as HttpClient, b5 as InboundDeliveryStatus, b6 as InboundWebhookDelivery, b7 as IngestCustomWebhookParams, b8 as IngestCustomWebhookResponse, b9 as IngestGitHubWebhookOptions, ba as IngestStripeWebhookOptions, bb as InitialApiKey, bc as Job, bd as JobCompletedEvent, be as JobContext, bf as JobCreatedEvent, bg as JobFailedEvent, bh as JobHandler, bi as JobHistoryEvent, bj as JobHistoryEventType, bk as JobHistoryParams, bl as JobProgressEvent, bm as JobResult, bn as JobSearchParams, bo as JobStartedEvent, bp as JobStats, bq as JobStatus, br as JobStatusChangedEvent, bs as JobStream, bt as JobSummary, bu as JobSummaryStats, bv as JobWithDependencies, bw as JobsResource, bx as JsonArray, by as JsonObject, bz as JsonPrimitive, bA as JsonValue, bB as ListDlqParams, bC as ListInboundDeliveriesParams, bD as ListJobsParams, bE as ListPage, bF as ListParams, bG as ListSchedulesParams, bH as ListWorkflowsParams, bI as LoginParams, bJ as LoginResponse, bK as MetricsResource, bL as NetworkError, bM as NotFoundError, bN as Organization, bO as OrganizationMember, bP as OrganizationSummary, bQ as OrganizationUsage, bR as OrganizationsResource, bS as OutgoingWebhook, bT as OutgoingWebhookDelivery, bU as PaginatedResponse, bV as PaginationParams, bW as PauseQueueResponse, bX as PayloadTooLargeError, bY as PlanCount, bZ as PlanLimits, b_ as PlanTier, b$ as ProcessJobsStream, c0 as PurgeDlqParams, c1 as PurgeDlqResponse, c2 as QueueConfig, c3 as QueueConfigSummary, c4 as QueuePausedEvent, c5 as QueueResumedEvent, c6 as QueueStats, c7 as QueueSummary, c8 as QueuesResource, c9 as RateLimitError, ca as RateLimitInfo, cb as RealtimeEventData, cc as RecentActivity, cd as RefreshTokenParams, ce as RefreshTokenResponse, cf as RegisterWorkerParams, cg as RegisterWorkerResponse, ch as ResolvedConfig, ci as ResourceUsage, cj as ResumeQueueResponse, ck as RetryDlqParams, cl as RetryDlqResponse, cm as SDK_VERSION, cn as Schedule, co as ScheduleRun, cp as ScheduleRunStatus, cq as ScheduleTriggeredEvent, cr as SchedulesResource, cs as ServerError, ct as SpooledClient, cu as SpooledClientConfig, cv as SpooledError, cw as SpooledGrpcClient, cx as SpooledRealtime, cy as SpooledRealtimeOptions, cz as SpooledWorker, cA as SpooledWorkerOptions, cB as StartEmailLoginResponse, cC as StreamOptions, cD as SystemInfo, cE as TestWebhookResponse, cF as TimeoutError, cG as TokenClaims, cH as TriggerScheduleResponse, cI as UnsupportedOperationError, cJ as UpdateApiKeyParams, cK as UpdateOrganizationParams, cL as UpdateOutgoingWebhookParams, cM as UpdateQueueConfigParams, cN as UpdateScheduleParams, cO as UsageItem, cP as UsageWarning, cQ as ValidateTokenParams, cR as ValidateTokenResponse, cS as ValidationError, cT as WebhookDeliveryStatus, cU as WebhookEventType, cV as WebhookFormat, cW as WebhookIngestionResource, cX as WebhookTokenResponse, cY as WebhooksResource, cZ as Worker, c_ as WorkerDeregisteredEvent, c$ as WorkerEvent, d0 as WorkerEventData, d1 as WorkerHeartbeatParams, d2 as WorkerRegisteredEvent, d3 as WorkerState, d4 as WorkerStatus, d5 as WorkerSummary, d6 as WorkersResource, d7 as Workflow, d8 as WorkflowJob, d9 as WorkflowJobDefinition, da as WorkflowJobStatus, db as WorkflowResponse, dc as WorkflowStatus, dd as WorkflowsResource, de as asyncIterableFromStream, df as createCircuitBreaker, dg as createClient, dh as createErrorFromResponse, di as createHttpClient, dj as createJobStream, dk as createPaginatedResponse, dl as createProcessJobsStream, dm as dateToTimestamp, dn as isCircuitBreakerFailure, dp as isRetryableError, dq as isSpooledError, dr as parseRateLimitHeaders, ds as resolveConfig, dt as timestampToDate, du as validateConfig } from './index-DzTC8ld3.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;
|
|
@@ -165,154 +171,6 @@ declare class SseRealtimeClient {
|
|
|
165
171
|
private scheduleReconnect;
|
|
166
172
|
}
|
|
167
173
|
|
|
168
|
-
/**
|
|
169
|
-
* Custom Error Classes
|
|
170
|
-
*
|
|
171
|
-
* Provides a hierarchy of error types for the Spooled SDK.
|
|
172
|
-
*/
|
|
173
|
-
/** Error response body from the API */
|
|
174
|
-
interface ApiErrorBody {
|
|
175
|
-
code: string;
|
|
176
|
-
message: string;
|
|
177
|
-
details?: Record<string, unknown>;
|
|
178
|
-
}
|
|
179
|
-
/** Rate limit information parsed from headers */
|
|
180
|
-
interface RateLimitInfo {
|
|
181
|
-
/** Maximum requests per window */
|
|
182
|
-
limit?: number;
|
|
183
|
-
/** Remaining requests in current window */
|
|
184
|
-
remaining?: number;
|
|
185
|
-
/** Unix timestamp when the window resets */
|
|
186
|
-
reset?: Date;
|
|
187
|
-
/** Seconds to wait before retrying */
|
|
188
|
-
retryAfter?: number;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Base error class for all Spooled SDK errors
|
|
192
|
-
*/
|
|
193
|
-
declare class SpooledError extends Error {
|
|
194
|
-
/** HTTP status code (if applicable) */
|
|
195
|
-
readonly statusCode: number;
|
|
196
|
-
/** Error code from API response */
|
|
197
|
-
readonly code: string;
|
|
198
|
-
/** Additional error details */
|
|
199
|
-
readonly details?: Record<string, unknown>;
|
|
200
|
-
/** Request ID for debugging */
|
|
201
|
-
readonly requestId?: string;
|
|
202
|
-
/** Original cause of the error */
|
|
203
|
-
readonly cause?: Error;
|
|
204
|
-
constructor(message: string, statusCode?: number, code?: string, details?: Record<string, unknown>, requestId?: string, cause?: Error);
|
|
205
|
-
/** Whether this error is retryable */
|
|
206
|
-
isRetryable(): boolean;
|
|
207
|
-
/** Convert to plain object for logging */
|
|
208
|
-
toJSON(): Record<string, unknown>;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Authentication error (401)
|
|
212
|
-
* Thrown when authentication fails (invalid/expired token or API key)
|
|
213
|
-
*/
|
|
214
|
-
declare class AuthenticationError extends SpooledError {
|
|
215
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Authorization error (403)
|
|
219
|
-
* Thrown when the authenticated user lacks permission
|
|
220
|
-
*/
|
|
221
|
-
declare class AuthorizationError extends SpooledError {
|
|
222
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Not found error (404)
|
|
226
|
-
* Thrown when a requested resource doesn't exist
|
|
227
|
-
*/
|
|
228
|
-
declare class NotFoundError extends SpooledError {
|
|
229
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Conflict error (409)
|
|
233
|
-
* Thrown when there's a conflict (e.g., duplicate resource)
|
|
234
|
-
*/
|
|
235
|
-
declare class ConflictError extends SpooledError {
|
|
236
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Validation error (400)
|
|
240
|
-
* Thrown when request validation fails
|
|
241
|
-
*/
|
|
242
|
-
declare class ValidationError extends SpooledError {
|
|
243
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Payload too large error (413)
|
|
247
|
-
* Thrown when request body exceeds size limit
|
|
248
|
-
*/
|
|
249
|
-
declare class PayloadTooLargeError extends SpooledError {
|
|
250
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Rate limit error (429)
|
|
254
|
-
* Thrown when rate limit is exceeded
|
|
255
|
-
*/
|
|
256
|
-
declare class RateLimitError extends SpooledError {
|
|
257
|
-
/** Rate limit information */
|
|
258
|
-
readonly rateLimitInfo: RateLimitInfo;
|
|
259
|
-
constructor(message?: string, code?: string, rateLimitInfo?: RateLimitInfo, details?: Record<string, unknown>, requestId?: string);
|
|
260
|
-
isRetryable(): boolean;
|
|
261
|
-
/** Get the number of seconds to wait before retrying */
|
|
262
|
-
getRetryAfter(): number;
|
|
263
|
-
toJSON(): Record<string, unknown>;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Server error (5xx)
|
|
267
|
-
* Thrown when the server encounters an error
|
|
268
|
-
*/
|
|
269
|
-
declare class ServerError extends SpooledError {
|
|
270
|
-
constructor(message?: string, statusCode?: number, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
271
|
-
isRetryable(): boolean;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Network error
|
|
275
|
-
* Thrown when a network request fails (no response received)
|
|
276
|
-
*/
|
|
277
|
-
declare class NetworkError extends SpooledError {
|
|
278
|
-
constructor(message?: string, cause?: Error);
|
|
279
|
-
isRetryable(): boolean;
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Timeout error
|
|
283
|
-
* Thrown when a request times out
|
|
284
|
-
*/
|
|
285
|
-
declare class TimeoutError extends SpooledError {
|
|
286
|
-
/** Timeout duration in milliseconds */
|
|
287
|
-
readonly timeoutMs: number;
|
|
288
|
-
constructor(message?: string, timeoutMs?: number);
|
|
289
|
-
isRetryable(): boolean;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Circuit breaker open error
|
|
293
|
-
* Thrown when the circuit breaker is open and rejecting requests
|
|
294
|
-
*/
|
|
295
|
-
declare class CircuitBreakerOpenError extends SpooledError {
|
|
296
|
-
constructor(message?: string);
|
|
297
|
-
isRetryable(): boolean;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Parse rate limit headers from a Response
|
|
301
|
-
*/
|
|
302
|
-
declare function parseRateLimitHeaders(headers: Headers): RateLimitInfo;
|
|
303
|
-
/**
|
|
304
|
-
* Create an appropriate error from an HTTP response
|
|
305
|
-
*/
|
|
306
|
-
declare function createErrorFromResponse(response: Response): Promise<SpooledError>;
|
|
307
|
-
/**
|
|
308
|
-
* Check if an error is a SpooledError instance
|
|
309
|
-
*/
|
|
310
|
-
declare function isSpooledError(error: unknown): error is SpooledError;
|
|
311
|
-
/**
|
|
312
|
-
* Check if an error is retryable
|
|
313
|
-
*/
|
|
314
|
-
declare function isRetryableError(error: unknown): boolean;
|
|
315
|
-
|
|
316
174
|
/**
|
|
317
175
|
* Proto Loader Utility
|
|
318
176
|
*
|
|
@@ -456,4 +314,4 @@ declare function convertResponse<T>(body: T): T;
|
|
|
456
314
|
*/
|
|
457
315
|
declare function convertQueryParams(params: Record<string, string | number | boolean | undefined>): Record<string, string>;
|
|
458
316
|
|
|
459
|
-
export {
|
|
317
|
+
export { ConnectionState, PROTO_LOADER_OPTIONS, RealtimeConnectionOptions, RealtimeEvent, RealtimeEventType, RetryConfig, type SpooledProtoDefinition, SseRealtimeClient, SubscriptionFilter, WebSocketRealtimeClient, calculateDelay, camelToSnake, clearProtoCache, convertQueryParams, convertRequest, convertResponse, createRetryWrapper, getProtoPath, loadProtoDefinition, loadProtoDefinitionAsync, 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
|
|
1
|
+
import { R as RealtimeConnectionOptions, C as ConnectionState, S as SubscriptionFilter, a as RealtimeEventType, b as RealtimeEvent, c as RetryConfig } from './index-DzTC8ld3.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 ApiErrorBody, u as ApiKeySummary, v as ApiKeysResource, w as AuthResource, x as AuthenticationError, y as AuthorizationError, B as BatchJobStatus, z as BillingResource, D as BillingStatus, E as BoostPriorityResponse, F as BulkEnqueueParams, G as BulkEnqueueResponse, H as BulkJobItem, I as CheckEmailResponse, J as CheckSlugResponse, K as CircuitBreaker, L as CircuitBreakerConfig, M as CircuitBreakerOpenError, N as CircuitBreakerOptions, O as CircuitState, P as CircuitStateChange, Q as ClaimJobsParams, T as ClaimJobsResult, U as ClaimedJob, V as CompleteJobParams, W as ConflictError, X as CreateApiKeyParams, Y as CreateApiKeyResponse, Z as CreateBillingPortalParams, _ as CreateBillingPortalResponse, $ as CreateJobParams, a0 as CreateJobResult, a1 as CreateOrganizationParams, a2 as CreateOrganizationResponse, a3 as CreateOutgoingWebhookParams, a4 as CreateScheduleParams, a5 as CreateScheduleResponse, a6 as CreateWorkflowParams, a7 as CreateWorkflowResponse, a8 as CurrentUserResponse, a9 as DEFAULT_CONFIG, aa as DashboardData, ab as DashboardResource, ac as DashboardWorkerSummary, ad as DebugFn, ae as DeleteQueueOptions, af as DependencyInfo, ag as DependencyMode, ah as FailJobParams, ai as GrpcClientOptions, aj as GrpcCompleteJobParams, ak as GrpcCompleteJobResponse, al as GrpcCompleteRequest, am as GrpcCompleteResponse, an as GrpcDequeueJobParams, ao as GrpcDequeueJobResponse, ap as GrpcDequeueRequest, aq as GrpcDequeueResponse, ar as GrpcDeregisterRequest, as as GrpcDeregisterResponse, at as GrpcEnqueueJobParams, au as GrpcEnqueueJobResponse, av as GrpcEnqueueRequest, aw as GrpcEnqueueResponse, ax as GrpcErrorResponse, ay as GrpcFailJobParams, az as GrpcFailJobResponse, aA as GrpcFailRequest, aB as GrpcFailResponse, aC as GrpcGetJobRequest, aD as GrpcGetJobResponse, aE as GrpcGetQueueStatsRequest, aF as GrpcGetQueueStatsResponse, aG as GrpcGetQueueStatsResponse_Legacy, aH as GrpcHeartbeatParams, aI as GrpcHeartbeatRequest, aJ as GrpcHeartbeatResponse, aK as GrpcHeartbeatResponse_Legacy, aL as GrpcJob, aM as GrpcJobStatus, aN as GrpcJobStatusNumber, aO as GrpcProcessRequest, aP as GrpcProcessResponse, aQ as GrpcQueueOperations, aR as GrpcRegisterWorkerParams, aS as GrpcRegisterWorkerRequest, aT as GrpcRegisterWorkerResponse, aU as GrpcRegisterWorkerResponse_Legacy, aV as GrpcRenewLeaseParams, aW as GrpcRenewLeaseRequest, aX as GrpcRenewLeaseResponse, aY as GrpcRenewLeaseResponse_Legacy, aZ as GrpcStreamJobsRequest, a_ as GrpcTimestamp, a$ as GrpcWorkerOperations, b0 as HealthResource, b1 as HealthResponse, b2 as HeartbeatEvent, b3 as HeartbeatJobParams, b4 as HttpClient, b5 as InboundDeliveryStatus, b6 as InboundWebhookDelivery, b7 as IngestCustomWebhookParams, b8 as IngestCustomWebhookResponse, b9 as IngestGitHubWebhookOptions, ba as IngestStripeWebhookOptions, bb as InitialApiKey, bc as Job, bd as JobCompletedEvent, be as JobContext, bf as JobCreatedEvent, bg as JobFailedEvent, bh as JobHandler, bi as JobHistoryEvent, bj as JobHistoryEventType, bk as JobHistoryParams, bl as JobProgressEvent, bm as JobResult, bn as JobSearchParams, bo as JobStartedEvent, bp as JobStats, bq as JobStatus, br as JobStatusChangedEvent, bs as JobStream, bt as JobSummary, bu as JobSummaryStats, bv as JobWithDependencies, bw as JobsResource, bx as JsonArray, by as JsonObject, bz as JsonPrimitive, bA as JsonValue, bB as ListDlqParams, bC as ListInboundDeliveriesParams, bD as ListJobsParams, bE as ListPage, bF as ListParams, bG as ListSchedulesParams, bH as ListWorkflowsParams, bI as LoginParams, bJ as LoginResponse, bK as MetricsResource, bL as NetworkError, bM as NotFoundError, bN as Organization, bO as OrganizationMember, bP as OrganizationSummary, bQ as OrganizationUsage, bR as OrganizationsResource, bS as OutgoingWebhook, bT as OutgoingWebhookDelivery, bU as PaginatedResponse, bV as PaginationParams, bW as PauseQueueResponse, bX as PayloadTooLargeError, bY as PlanCount, bZ as PlanLimits, b_ as PlanTier, b$ as ProcessJobsStream, c0 as PurgeDlqParams, c1 as PurgeDlqResponse, c2 as QueueConfig, c3 as QueueConfigSummary, c4 as QueuePausedEvent, c5 as QueueResumedEvent, c6 as QueueStats, c7 as QueueSummary, c8 as QueuesResource, c9 as RateLimitError, ca as RateLimitInfo, cb as RealtimeEventData, cc as RecentActivity, cd as RefreshTokenParams, ce as RefreshTokenResponse, cf as RegisterWorkerParams, cg as RegisterWorkerResponse, ch as ResolvedConfig, ci as ResourceUsage, cj as ResumeQueueResponse, ck as RetryDlqParams, cl as RetryDlqResponse, cm as SDK_VERSION, cn as Schedule, co as ScheduleRun, cp as ScheduleRunStatus, cq as ScheduleTriggeredEvent, cr as SchedulesResource, cs as ServerError, ct as SpooledClient, cu as SpooledClientConfig, cv as SpooledError, cw as SpooledGrpcClient, cx as SpooledRealtime, cy as SpooledRealtimeOptions, cz as SpooledWorker, cA as SpooledWorkerOptions, cB as StartEmailLoginResponse, cC as StreamOptions, cD as SystemInfo, cE as TestWebhookResponse, cF as TimeoutError, cG as TokenClaims, cH as TriggerScheduleResponse, cI as UnsupportedOperationError, cJ as UpdateApiKeyParams, cK as UpdateOrganizationParams, cL as UpdateOutgoingWebhookParams, cM as UpdateQueueConfigParams, cN as UpdateScheduleParams, cO as UsageItem, cP as UsageWarning, cQ as ValidateTokenParams, cR as ValidateTokenResponse, cS as ValidationError, cT as WebhookDeliveryStatus, cU as WebhookEventType, cV as WebhookFormat, cW as WebhookIngestionResource, cX as WebhookTokenResponse, cY as WebhooksResource, cZ as Worker, c_ as WorkerDeregisteredEvent, c$ as WorkerEvent, d0 as WorkerEventData, d1 as WorkerHeartbeatParams, d2 as WorkerRegisteredEvent, d3 as WorkerState, d4 as WorkerStatus, d5 as WorkerSummary, d6 as WorkersResource, d7 as Workflow, d8 as WorkflowJob, d9 as WorkflowJobDefinition, da as WorkflowJobStatus, db as WorkflowResponse, dc as WorkflowStatus, dd as WorkflowsResource, de as asyncIterableFromStream, df as createCircuitBreaker, dg as createClient, dh as createErrorFromResponse, di as createHttpClient, dj as createJobStream, dk as createPaginatedResponse, dl as createProcessJobsStream, dm as dateToTimestamp, dn as isCircuitBreakerFailure, dp as isRetryableError, dq as isSpooledError, dr as parseRateLimitHeaders, ds as resolveConfig, dt as timestampToDate, du as validateConfig } from './index-DzTC8ld3.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;
|
|
@@ -165,154 +171,6 @@ declare class SseRealtimeClient {
|
|
|
165
171
|
private scheduleReconnect;
|
|
166
172
|
}
|
|
167
173
|
|
|
168
|
-
/**
|
|
169
|
-
* Custom Error Classes
|
|
170
|
-
*
|
|
171
|
-
* Provides a hierarchy of error types for the Spooled SDK.
|
|
172
|
-
*/
|
|
173
|
-
/** Error response body from the API */
|
|
174
|
-
interface ApiErrorBody {
|
|
175
|
-
code: string;
|
|
176
|
-
message: string;
|
|
177
|
-
details?: Record<string, unknown>;
|
|
178
|
-
}
|
|
179
|
-
/** Rate limit information parsed from headers */
|
|
180
|
-
interface RateLimitInfo {
|
|
181
|
-
/** Maximum requests per window */
|
|
182
|
-
limit?: number;
|
|
183
|
-
/** Remaining requests in current window */
|
|
184
|
-
remaining?: number;
|
|
185
|
-
/** Unix timestamp when the window resets */
|
|
186
|
-
reset?: Date;
|
|
187
|
-
/** Seconds to wait before retrying */
|
|
188
|
-
retryAfter?: number;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Base error class for all Spooled SDK errors
|
|
192
|
-
*/
|
|
193
|
-
declare class SpooledError extends Error {
|
|
194
|
-
/** HTTP status code (if applicable) */
|
|
195
|
-
readonly statusCode: number;
|
|
196
|
-
/** Error code from API response */
|
|
197
|
-
readonly code: string;
|
|
198
|
-
/** Additional error details */
|
|
199
|
-
readonly details?: Record<string, unknown>;
|
|
200
|
-
/** Request ID for debugging */
|
|
201
|
-
readonly requestId?: string;
|
|
202
|
-
/** Original cause of the error */
|
|
203
|
-
readonly cause?: Error;
|
|
204
|
-
constructor(message: string, statusCode?: number, code?: string, details?: Record<string, unknown>, requestId?: string, cause?: Error);
|
|
205
|
-
/** Whether this error is retryable */
|
|
206
|
-
isRetryable(): boolean;
|
|
207
|
-
/** Convert to plain object for logging */
|
|
208
|
-
toJSON(): Record<string, unknown>;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Authentication error (401)
|
|
212
|
-
* Thrown when authentication fails (invalid/expired token or API key)
|
|
213
|
-
*/
|
|
214
|
-
declare class AuthenticationError extends SpooledError {
|
|
215
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Authorization error (403)
|
|
219
|
-
* Thrown when the authenticated user lacks permission
|
|
220
|
-
*/
|
|
221
|
-
declare class AuthorizationError extends SpooledError {
|
|
222
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Not found error (404)
|
|
226
|
-
* Thrown when a requested resource doesn't exist
|
|
227
|
-
*/
|
|
228
|
-
declare class NotFoundError extends SpooledError {
|
|
229
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Conflict error (409)
|
|
233
|
-
* Thrown when there's a conflict (e.g., duplicate resource)
|
|
234
|
-
*/
|
|
235
|
-
declare class ConflictError extends SpooledError {
|
|
236
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Validation error (400)
|
|
240
|
-
* Thrown when request validation fails
|
|
241
|
-
*/
|
|
242
|
-
declare class ValidationError extends SpooledError {
|
|
243
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Payload too large error (413)
|
|
247
|
-
* Thrown when request body exceeds size limit
|
|
248
|
-
*/
|
|
249
|
-
declare class PayloadTooLargeError extends SpooledError {
|
|
250
|
-
constructor(message?: string, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Rate limit error (429)
|
|
254
|
-
* Thrown when rate limit is exceeded
|
|
255
|
-
*/
|
|
256
|
-
declare class RateLimitError extends SpooledError {
|
|
257
|
-
/** Rate limit information */
|
|
258
|
-
readonly rateLimitInfo: RateLimitInfo;
|
|
259
|
-
constructor(message?: string, code?: string, rateLimitInfo?: RateLimitInfo, details?: Record<string, unknown>, requestId?: string);
|
|
260
|
-
isRetryable(): boolean;
|
|
261
|
-
/** Get the number of seconds to wait before retrying */
|
|
262
|
-
getRetryAfter(): number;
|
|
263
|
-
toJSON(): Record<string, unknown>;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Server error (5xx)
|
|
267
|
-
* Thrown when the server encounters an error
|
|
268
|
-
*/
|
|
269
|
-
declare class ServerError extends SpooledError {
|
|
270
|
-
constructor(message?: string, statusCode?: number, code?: string, details?: Record<string, unknown>, requestId?: string);
|
|
271
|
-
isRetryable(): boolean;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Network error
|
|
275
|
-
* Thrown when a network request fails (no response received)
|
|
276
|
-
*/
|
|
277
|
-
declare class NetworkError extends SpooledError {
|
|
278
|
-
constructor(message?: string, cause?: Error);
|
|
279
|
-
isRetryable(): boolean;
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Timeout error
|
|
283
|
-
* Thrown when a request times out
|
|
284
|
-
*/
|
|
285
|
-
declare class TimeoutError extends SpooledError {
|
|
286
|
-
/** Timeout duration in milliseconds */
|
|
287
|
-
readonly timeoutMs: number;
|
|
288
|
-
constructor(message?: string, timeoutMs?: number);
|
|
289
|
-
isRetryable(): boolean;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Circuit breaker open error
|
|
293
|
-
* Thrown when the circuit breaker is open and rejecting requests
|
|
294
|
-
*/
|
|
295
|
-
declare class CircuitBreakerOpenError extends SpooledError {
|
|
296
|
-
constructor(message?: string);
|
|
297
|
-
isRetryable(): boolean;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Parse rate limit headers from a Response
|
|
301
|
-
*/
|
|
302
|
-
declare function parseRateLimitHeaders(headers: Headers): RateLimitInfo;
|
|
303
|
-
/**
|
|
304
|
-
* Create an appropriate error from an HTTP response
|
|
305
|
-
*/
|
|
306
|
-
declare function createErrorFromResponse(response: Response): Promise<SpooledError>;
|
|
307
|
-
/**
|
|
308
|
-
* Check if an error is a SpooledError instance
|
|
309
|
-
*/
|
|
310
|
-
declare function isSpooledError(error: unknown): error is SpooledError;
|
|
311
|
-
/**
|
|
312
|
-
* Check if an error is retryable
|
|
313
|
-
*/
|
|
314
|
-
declare function isRetryableError(error: unknown): boolean;
|
|
315
|
-
|
|
316
174
|
/**
|
|
317
175
|
* Proto Loader Utility
|
|
318
176
|
*
|
|
@@ -456,4 +314,4 @@ declare function convertResponse<T>(body: T): T;
|
|
|
456
314
|
*/
|
|
457
315
|
declare function convertQueryParams(params: Record<string, string | number | boolean | undefined>): Record<string, string>;
|
|
458
316
|
|
|
459
|
-
export {
|
|
317
|
+
export { ConnectionState, PROTO_LOADER_OPTIONS, RealtimeConnectionOptions, RealtimeEvent, RealtimeEventType, RetryConfig, type SpooledProtoDefinition, SseRealtimeClient, SubscriptionFilter, WebSocketRealtimeClient, calculateDelay, camelToSnake, clearProtoCache, convertQueryParams, convertRequest, convertResponse, createRetryWrapper, getProtoPath, loadProtoDefinition, loadProtoDefinitionAsync, shouldRetry, sleep, snakeToCamel, toCamelCase, toSnakeCase, withRetry };
|