@spooled/sdk 1.0.29 → 1.0.31
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/{index-CZorNMoD.d.cts → index-CfLL1w6Y.d.cts} +49 -12
- package/dist/{index-CZorNMoD.d.ts → index-CfLL1w6Y.d.ts} +49 -12
- package/dist/index.cjs +134 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +134 -25
- package/dist/index.js.map +1 -1
- package/dist/worker/index.d.cts +1 -1
- package/dist/worker/index.d.ts +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 CheckSlugResponse, G as CircuitBreaker, H as CircuitBreakerConfig, I as CircuitState, J as ClaimJobsParams, K as ClaimJobsResult, L as ClaimedJob, M as CompleteJobParams, N as CreateApiKeyParams, O as CreateApiKeyResponse, P as CreateBillingPortalParams, Q as CreateBillingPortalResponse, T as CreateJobParams, U as CreateJobResult, V as CreateOrganizationParams, W as CreateOrganizationResponse, X as CreateOutgoingWebhookParams, Y as CreateScheduleParams, Z as CreateScheduleResponse, _ as CreateWorkflowParams, $ as CreateWorkflowResponse, a0 as CurrentUserResponse, a1 as DEFAULT_CONFIG, a2 as DashboardData, a3 as DashboardResource, a4 as DashboardWorkerSummary, a5 as DebugFn, a6 as DependencyMode, a7 as FailJobParams, a8 as GrpcClientOptions, a9 as GrpcCompleteJobParams, aa as GrpcCompleteJobResponse, ab as GrpcCompleteRequest, ac as GrpcCompleteResponse, ad as GrpcDequeueJobParams, ae as GrpcDequeueJobResponse, af as GrpcDequeueRequest, ag as GrpcDequeueResponse, ah as GrpcDeregisterRequest, ai as GrpcDeregisterResponse, aj as GrpcEnqueueJobParams, ak as GrpcEnqueueJobResponse, al as GrpcEnqueueRequest, am as GrpcEnqueueResponse, an as GrpcErrorResponse, ao as GrpcFailJobParams, ap as GrpcFailJobResponse, aq as GrpcFailRequest, ar as GrpcFailResponse, as as GrpcGetJobRequest, at as GrpcGetJobResponse, au as GrpcGetQueueStatsRequest, av as GrpcGetQueueStatsResponse, aw as GrpcGetQueueStatsResponse_Legacy, ax as GrpcHeartbeatParams, ay as GrpcHeartbeatRequest, az as GrpcHeartbeatResponse, aA as GrpcHeartbeatResponse_Legacy, aB as GrpcJob, aC as GrpcJobStatus, aD as GrpcJobStatusNumber, aE as GrpcProcessRequest, aF as GrpcProcessResponse, aG as GrpcQueueOperations, aH as GrpcRegisterWorkerParams, aI as GrpcRegisterWorkerRequest, aJ as GrpcRegisterWorkerResponse, aK as GrpcRegisterWorkerResponse_Legacy, aL as GrpcRenewLeaseParams, aM as GrpcRenewLeaseRequest, aN as GrpcRenewLeaseResponse, aO as GrpcRenewLeaseResponse_Legacy, aP as GrpcStreamJobsRequest, aQ as GrpcTimestamp, aR as GrpcWorkerOperations, aS as HealthResource, aT as HealthResponse, aU as HeartbeatEvent, aV as HeartbeatJobParams, aW as HttpClient, aX as IngestCustomWebhookParams, aY as IngestGitHubWebhookOptions, aZ as IngestStripeWebhookOptions, a_ as InitialApiKey, a$ as Job, b0 as JobCompletedEvent, b1 as JobContext, b2 as JobCreatedEvent, b3 as JobFailedEvent, b4 as JobHandler, b5 as JobProgressEvent, b6 as JobResult, b7 as JobStartedEvent, b8 as JobStats, b9 as JobStatus, ba as JobStatusChangedEvent, bb as JobStream, bc as JobSummary, bd as JobSummaryStats, be as JobWithDependencies, bf as JobsResource, bg as JsonArray, bh as JsonObject, bi as JsonPrimitive, bj as JsonValue, bk as ListDlqParams, bl as ListJobsParams, bm as ListParams, bn as ListSchedulesParams, bo as ListWorkflowsParams, bp as LoginParams, bq as LoginResponse, br as MetricsResource, bs as Organization, bt as OrganizationMember, bu as OrganizationSummary, bv as OrganizationUsage, bw as OrganizationsResource, bx as OutgoingWebhook, by as OutgoingWebhookDelivery, bz as PaginatedResponse, bA as PaginationParams, bB as PauseQueueResponse, bC as PlanCount, bD as PlanLimits, bE as PlanTier, bF as ProcessJobsStream, bG as PurgeDlqParams, bH as PurgeDlqResponse, bI as QueueConfig, bJ as QueueConfigSummary, bK as QueuePausedEvent, bL as QueueResumedEvent, bM as QueueStats, bN as QueueSummary, bO as QueuesResource, bP as RealtimeEventData, bQ as RecentActivity, bR as RefreshTokenParams, bS as RefreshTokenResponse, bT as RegisterWorkerParams, bU as RegisterWorkerResponse, bV as ResolvedConfig, bW as ResourceUsage, bX as ResumeQueueResponse, bY as RetryDlqParams, bZ as RetryDlqResponse, b_ as SDK_VERSION, b$ as Schedule, c0 as ScheduleRun, c1 as ScheduleRunStatus, c2 as ScheduleTriggeredEvent, c3 as SchedulesResource, c4 as SpooledClient, c5 as SpooledClientConfig, c6 as SpooledGrpcClient, c7 as SpooledRealtime, c8 as SpooledRealtimeOptions, c9 as SpooledWorker, ca as SpooledWorkerOptions, cb as StreamOptions, cc as SystemInfo, cd as TestWebhookResponse, ce as TriggerScheduleResponse, cf as UpdateApiKeyParams, cg as UpdateOrganizationParams, ch as UpdateOutgoingWebhookParams, ci as UpdateQueueConfigParams, cj as UpdateScheduleParams, ck as UsageItem, cl as UsageWarning, cm as ValidateTokenParams, cn as ValidateTokenResponse, co as WebhookDeliveryStatus, cp as WebhookEventType, cq as WebhookIngestionResource, cr as WebhookTokenResponse, cs as WebhooksResource, ct as Worker, cu as WorkerDeregisteredEvent, cv as WorkerEvent, cw as WorkerEventData, cx as WorkerHeartbeatParams, cy as WorkerRegisteredEvent, cz as WorkerState, cA as WorkerStatus, cB as WorkerSummary, cC as WorkersResource, cD as Workflow, cE as WorkflowJob, cF as WorkflowJobDefinition, cG as WorkflowJobStatus, cH as WorkflowResponse, cI as WorkflowStatus, cJ as WorkflowsResource, cK as asyncIterableFromStream, cL as createCircuitBreaker, cM as createClient, cN as createHttpClient, cO as createJobStream, cP as createPaginatedResponse, cQ as createProcessJobsStream, cR as dateToTimestamp, cS as resolveConfig, cT as timestampToDate, cU as validateConfig } from './index-
|
|
1
|
+
import { R as RealtimeConnectionOptions, C as ConnectionState, S as SubscriptionFilter, a as RealtimeEventType, b as RealtimeEvent, c as RetryConfig } from './index-CfLL1w6Y.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 CheckSlugResponse, G as CircuitBreaker, H as CircuitBreakerConfig, I as CircuitState, J as ClaimJobsParams, K as ClaimJobsResult, L as ClaimedJob, M as CompleteJobParams, N as CreateApiKeyParams, O as CreateApiKeyResponse, P as CreateBillingPortalParams, Q as CreateBillingPortalResponse, T as CreateJobParams, U as CreateJobResult, V as CreateOrganizationParams, W as CreateOrganizationResponse, X as CreateOutgoingWebhookParams, Y as CreateScheduleParams, Z as CreateScheduleResponse, _ as CreateWorkflowParams, $ as CreateWorkflowResponse, a0 as CurrentUserResponse, a1 as DEFAULT_CONFIG, a2 as DashboardData, a3 as DashboardResource, a4 as DashboardWorkerSummary, a5 as DebugFn, a6 as DependencyMode, a7 as FailJobParams, a8 as GrpcClientOptions, a9 as GrpcCompleteJobParams, aa as GrpcCompleteJobResponse, ab as GrpcCompleteRequest, ac as GrpcCompleteResponse, ad as GrpcDequeueJobParams, ae as GrpcDequeueJobResponse, af as GrpcDequeueRequest, ag as GrpcDequeueResponse, ah as GrpcDeregisterRequest, ai as GrpcDeregisterResponse, aj as GrpcEnqueueJobParams, ak as GrpcEnqueueJobResponse, al as GrpcEnqueueRequest, am as GrpcEnqueueResponse, an as GrpcErrorResponse, ao as GrpcFailJobParams, ap as GrpcFailJobResponse, aq as GrpcFailRequest, ar as GrpcFailResponse, as as GrpcGetJobRequest, at as GrpcGetJobResponse, au as GrpcGetQueueStatsRequest, av as GrpcGetQueueStatsResponse, aw as GrpcGetQueueStatsResponse_Legacy, ax as GrpcHeartbeatParams, ay as GrpcHeartbeatRequest, az as GrpcHeartbeatResponse, aA as GrpcHeartbeatResponse_Legacy, aB as GrpcJob, aC as GrpcJobStatus, aD as GrpcJobStatusNumber, aE as GrpcProcessRequest, aF as GrpcProcessResponse, aG as GrpcQueueOperations, aH as GrpcRegisterWorkerParams, aI as GrpcRegisterWorkerRequest, aJ as GrpcRegisterWorkerResponse, aK as GrpcRegisterWorkerResponse_Legacy, aL as GrpcRenewLeaseParams, aM as GrpcRenewLeaseRequest, aN as GrpcRenewLeaseResponse, aO as GrpcRenewLeaseResponse_Legacy, aP as GrpcStreamJobsRequest, aQ as GrpcTimestamp, aR as GrpcWorkerOperations, aS as HealthResource, aT as HealthResponse, aU as HeartbeatEvent, aV as HeartbeatJobParams, aW as HttpClient, aX as IngestCustomWebhookParams, aY as IngestGitHubWebhookOptions, aZ as IngestStripeWebhookOptions, a_ as InitialApiKey, a$ as Job, b0 as JobCompletedEvent, b1 as JobContext, b2 as JobCreatedEvent, b3 as JobFailedEvent, b4 as JobHandler, b5 as JobProgressEvent, b6 as JobResult, b7 as JobStartedEvent, b8 as JobStats, b9 as JobStatus, ba as JobStatusChangedEvent, bb as JobStream, bc as JobSummary, bd as JobSummaryStats, be as JobWithDependencies, bf as JobsResource, bg as JsonArray, bh as JsonObject, bi as JsonPrimitive, bj as JsonValue, bk as ListDlqParams, bl as ListJobsParams, bm as ListParams, bn as ListSchedulesParams, bo as ListWorkflowsParams, bp as LoginParams, bq as LoginResponse, br as MetricsResource, bs as Organization, bt as OrganizationMember, bu as OrganizationSummary, bv as OrganizationUsage, bw as OrganizationsResource, bx as OutgoingWebhook, by as OutgoingWebhookDelivery, bz as PaginatedResponse, bA as PaginationParams, bB as PauseQueueResponse, bC as PlanCount, bD as PlanLimits, bE as PlanTier, bF as ProcessJobsStream, bG as PurgeDlqParams, bH as PurgeDlqResponse, bI as QueueConfig, bJ as QueueConfigSummary, bK as QueuePausedEvent, bL as QueueResumedEvent, bM as QueueStats, bN as QueueSummary, bO as QueuesResource, bP as RealtimeEventData, bQ as RecentActivity, bR as RefreshTokenParams, bS as RefreshTokenResponse, bT as RegisterWorkerParams, bU as RegisterWorkerResponse, bV as ResolvedConfig, bW as ResourceUsage, bX as ResumeQueueResponse, bY as RetryDlqParams, bZ as RetryDlqResponse, b_ as SDK_VERSION, b$ as Schedule, c0 as ScheduleRun, c1 as ScheduleRunStatus, c2 as ScheduleTriggeredEvent, c3 as SchedulesResource, c4 as SpooledClient, c5 as SpooledClientConfig, c6 as SpooledGrpcClient, c7 as SpooledRealtime, c8 as SpooledRealtimeOptions, c9 as SpooledWorker, ca as SpooledWorkerOptions, cb as StreamOptions, cc as SystemInfo, cd as TestWebhookResponse, ce as TriggerScheduleResponse, cf as UpdateApiKeyParams, cg as UpdateOrganizationParams, ch as UpdateOutgoingWebhookParams, ci as UpdateQueueConfigParams, cj as UpdateScheduleParams, ck as UsageItem, cl as UsageWarning, cm as ValidateTokenParams, cn as ValidateTokenResponse, co as WebhookDeliveryStatus, cp as WebhookEventType, cq as WebhookIngestionResource, cr as WebhookTokenResponse, cs as WebhooksResource, ct as Worker, cu as WorkerDeregisteredEvent, cv as WorkerEvent, cw as WorkerEventData, cx as WorkerHeartbeatParams, cy as WorkerRegisteredEvent, cz as WorkerState, cA as WorkerStatus, cB as WorkerSummary, cC as WorkersResource, cD as Workflow, cE as WorkflowJob, cF as WorkflowJobDefinition, cG as WorkflowJobStatus, cH as WorkflowResponse, cI as WorkflowStatus, cJ as WorkflowsResource, cK as asyncIterableFromStream, cL as createCircuitBreaker, cM as createClient, cN as createHttpClient, cO as createJobStream, cP as createPaginatedResponse, cQ as createProcessJobsStream, cR as dateToTimestamp, cS as resolveConfig, cT as timestampToDate, cU as validateConfig } from './index-CfLL1w6Y.cjs';
|
|
3
3
|
import * as protoLoader from '@grpc/proto-loader';
|
|
4
4
|
import { ServiceClientConstructor } from '@grpc/grpc-js';
|
|
5
5
|
|
|
@@ -24,6 +24,12 @@ declare class WebSocketRealtimeClient {
|
|
|
24
24
|
private state;
|
|
25
25
|
private reconnectAttempts;
|
|
26
26
|
private reconnectTimer;
|
|
27
|
+
/**
|
|
28
|
+
* Set when the server rejected our token on the upgrade (e.g. HTTP 401/403).
|
|
29
|
+
* The next (re)connect uses it to force the token provider to mint a fresh
|
|
30
|
+
* JWT instead of replaying the rejected one (which would loop forever).
|
|
31
|
+
*/
|
|
32
|
+
private authFailure;
|
|
27
33
|
private subscriptions;
|
|
28
34
|
private pendingCommands;
|
|
29
35
|
private eventHandlers;
|
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 CheckSlugResponse, G as CircuitBreaker, H as CircuitBreakerConfig, I as CircuitState, J as ClaimJobsParams, K as ClaimJobsResult, L as ClaimedJob, M as CompleteJobParams, N as CreateApiKeyParams, O as CreateApiKeyResponse, P as CreateBillingPortalParams, Q as CreateBillingPortalResponse, T as CreateJobParams, U as CreateJobResult, V as CreateOrganizationParams, W as CreateOrganizationResponse, X as CreateOutgoingWebhookParams, Y as CreateScheduleParams, Z as CreateScheduleResponse, _ as CreateWorkflowParams, $ as CreateWorkflowResponse, a0 as CurrentUserResponse, a1 as DEFAULT_CONFIG, a2 as DashboardData, a3 as DashboardResource, a4 as DashboardWorkerSummary, a5 as DebugFn, a6 as DependencyMode, a7 as FailJobParams, a8 as GrpcClientOptions, a9 as GrpcCompleteJobParams, aa as GrpcCompleteJobResponse, ab as GrpcCompleteRequest, ac as GrpcCompleteResponse, ad as GrpcDequeueJobParams, ae as GrpcDequeueJobResponse, af as GrpcDequeueRequest, ag as GrpcDequeueResponse, ah as GrpcDeregisterRequest, ai as GrpcDeregisterResponse, aj as GrpcEnqueueJobParams, ak as GrpcEnqueueJobResponse, al as GrpcEnqueueRequest, am as GrpcEnqueueResponse, an as GrpcErrorResponse, ao as GrpcFailJobParams, ap as GrpcFailJobResponse, aq as GrpcFailRequest, ar as GrpcFailResponse, as as GrpcGetJobRequest, at as GrpcGetJobResponse, au as GrpcGetQueueStatsRequest, av as GrpcGetQueueStatsResponse, aw as GrpcGetQueueStatsResponse_Legacy, ax as GrpcHeartbeatParams, ay as GrpcHeartbeatRequest, az as GrpcHeartbeatResponse, aA as GrpcHeartbeatResponse_Legacy, aB as GrpcJob, aC as GrpcJobStatus, aD as GrpcJobStatusNumber, aE as GrpcProcessRequest, aF as GrpcProcessResponse, aG as GrpcQueueOperations, aH as GrpcRegisterWorkerParams, aI as GrpcRegisterWorkerRequest, aJ as GrpcRegisterWorkerResponse, aK as GrpcRegisterWorkerResponse_Legacy, aL as GrpcRenewLeaseParams, aM as GrpcRenewLeaseRequest, aN as GrpcRenewLeaseResponse, aO as GrpcRenewLeaseResponse_Legacy, aP as GrpcStreamJobsRequest, aQ as GrpcTimestamp, aR as GrpcWorkerOperations, aS as HealthResource, aT as HealthResponse, aU as HeartbeatEvent, aV as HeartbeatJobParams, aW as HttpClient, aX as IngestCustomWebhookParams, aY as IngestGitHubWebhookOptions, aZ as IngestStripeWebhookOptions, a_ as InitialApiKey, a$ as Job, b0 as JobCompletedEvent, b1 as JobContext, b2 as JobCreatedEvent, b3 as JobFailedEvent, b4 as JobHandler, b5 as JobProgressEvent, b6 as JobResult, b7 as JobStartedEvent, b8 as JobStats, b9 as JobStatus, ba as JobStatusChangedEvent, bb as JobStream, bc as JobSummary, bd as JobSummaryStats, be as JobWithDependencies, bf as JobsResource, bg as JsonArray, bh as JsonObject, bi as JsonPrimitive, bj as JsonValue, bk as ListDlqParams, bl as ListJobsParams, bm as ListParams, bn as ListSchedulesParams, bo as ListWorkflowsParams, bp as LoginParams, bq as LoginResponse, br as MetricsResource, bs as Organization, bt as OrganizationMember, bu as OrganizationSummary, bv as OrganizationUsage, bw as OrganizationsResource, bx as OutgoingWebhook, by as OutgoingWebhookDelivery, bz as PaginatedResponse, bA as PaginationParams, bB as PauseQueueResponse, bC as PlanCount, bD as PlanLimits, bE as PlanTier, bF as ProcessJobsStream, bG as PurgeDlqParams, bH as PurgeDlqResponse, bI as QueueConfig, bJ as QueueConfigSummary, bK as QueuePausedEvent, bL as QueueResumedEvent, bM as QueueStats, bN as QueueSummary, bO as QueuesResource, bP as RealtimeEventData, bQ as RecentActivity, bR as RefreshTokenParams, bS as RefreshTokenResponse, bT as RegisterWorkerParams, bU as RegisterWorkerResponse, bV as ResolvedConfig, bW as ResourceUsage, bX as ResumeQueueResponse, bY as RetryDlqParams, bZ as RetryDlqResponse, b_ as SDK_VERSION, b$ as Schedule, c0 as ScheduleRun, c1 as ScheduleRunStatus, c2 as ScheduleTriggeredEvent, c3 as SchedulesResource, c4 as SpooledClient, c5 as SpooledClientConfig, c6 as SpooledGrpcClient, c7 as SpooledRealtime, c8 as SpooledRealtimeOptions, c9 as SpooledWorker, ca as SpooledWorkerOptions, cb as StreamOptions, cc as SystemInfo, cd as TestWebhookResponse, ce as TriggerScheduleResponse, cf as UpdateApiKeyParams, cg as UpdateOrganizationParams, ch as UpdateOutgoingWebhookParams, ci as UpdateQueueConfigParams, cj as UpdateScheduleParams, ck as UsageItem, cl as UsageWarning, cm as ValidateTokenParams, cn as ValidateTokenResponse, co as WebhookDeliveryStatus, cp as WebhookEventType, cq as WebhookIngestionResource, cr as WebhookTokenResponse, cs as WebhooksResource, ct as Worker, cu as WorkerDeregisteredEvent, cv as WorkerEvent, cw as WorkerEventData, cx as WorkerHeartbeatParams, cy as WorkerRegisteredEvent, cz as WorkerState, cA as WorkerStatus, cB as WorkerSummary, cC as WorkersResource, cD as Workflow, cE as WorkflowJob, cF as WorkflowJobDefinition, cG as WorkflowJobStatus, cH as WorkflowResponse, cI as WorkflowStatus, cJ as WorkflowsResource, cK as asyncIterableFromStream, cL as createCircuitBreaker, cM as createClient, cN as createHttpClient, cO as createJobStream, cP as createPaginatedResponse, cQ as createProcessJobsStream, cR as dateToTimestamp, cS as resolveConfig, cT as timestampToDate, cU as validateConfig } from './index-
|
|
1
|
+
import { R as RealtimeConnectionOptions, C as ConnectionState, S as SubscriptionFilter, a as RealtimeEventType, b as RealtimeEvent, c as RetryConfig } from './index-CfLL1w6Y.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 CheckSlugResponse, G as CircuitBreaker, H as CircuitBreakerConfig, I as CircuitState, J as ClaimJobsParams, K as ClaimJobsResult, L as ClaimedJob, M as CompleteJobParams, N as CreateApiKeyParams, O as CreateApiKeyResponse, P as CreateBillingPortalParams, Q as CreateBillingPortalResponse, T as CreateJobParams, U as CreateJobResult, V as CreateOrganizationParams, W as CreateOrganizationResponse, X as CreateOutgoingWebhookParams, Y as CreateScheduleParams, Z as CreateScheduleResponse, _ as CreateWorkflowParams, $ as CreateWorkflowResponse, a0 as CurrentUserResponse, a1 as DEFAULT_CONFIG, a2 as DashboardData, a3 as DashboardResource, a4 as DashboardWorkerSummary, a5 as DebugFn, a6 as DependencyMode, a7 as FailJobParams, a8 as GrpcClientOptions, a9 as GrpcCompleteJobParams, aa as GrpcCompleteJobResponse, ab as GrpcCompleteRequest, ac as GrpcCompleteResponse, ad as GrpcDequeueJobParams, ae as GrpcDequeueJobResponse, af as GrpcDequeueRequest, ag as GrpcDequeueResponse, ah as GrpcDeregisterRequest, ai as GrpcDeregisterResponse, aj as GrpcEnqueueJobParams, ak as GrpcEnqueueJobResponse, al as GrpcEnqueueRequest, am as GrpcEnqueueResponse, an as GrpcErrorResponse, ao as GrpcFailJobParams, ap as GrpcFailJobResponse, aq as GrpcFailRequest, ar as GrpcFailResponse, as as GrpcGetJobRequest, at as GrpcGetJobResponse, au as GrpcGetQueueStatsRequest, av as GrpcGetQueueStatsResponse, aw as GrpcGetQueueStatsResponse_Legacy, ax as GrpcHeartbeatParams, ay as GrpcHeartbeatRequest, az as GrpcHeartbeatResponse, aA as GrpcHeartbeatResponse_Legacy, aB as GrpcJob, aC as GrpcJobStatus, aD as GrpcJobStatusNumber, aE as GrpcProcessRequest, aF as GrpcProcessResponse, aG as GrpcQueueOperations, aH as GrpcRegisterWorkerParams, aI as GrpcRegisterWorkerRequest, aJ as GrpcRegisterWorkerResponse, aK as GrpcRegisterWorkerResponse_Legacy, aL as GrpcRenewLeaseParams, aM as GrpcRenewLeaseRequest, aN as GrpcRenewLeaseResponse, aO as GrpcRenewLeaseResponse_Legacy, aP as GrpcStreamJobsRequest, aQ as GrpcTimestamp, aR as GrpcWorkerOperations, aS as HealthResource, aT as HealthResponse, aU as HeartbeatEvent, aV as HeartbeatJobParams, aW as HttpClient, aX as IngestCustomWebhookParams, aY as IngestGitHubWebhookOptions, aZ as IngestStripeWebhookOptions, a_ as InitialApiKey, a$ as Job, b0 as JobCompletedEvent, b1 as JobContext, b2 as JobCreatedEvent, b3 as JobFailedEvent, b4 as JobHandler, b5 as JobProgressEvent, b6 as JobResult, b7 as JobStartedEvent, b8 as JobStats, b9 as JobStatus, ba as JobStatusChangedEvent, bb as JobStream, bc as JobSummary, bd as JobSummaryStats, be as JobWithDependencies, bf as JobsResource, bg as JsonArray, bh as JsonObject, bi as JsonPrimitive, bj as JsonValue, bk as ListDlqParams, bl as ListJobsParams, bm as ListParams, bn as ListSchedulesParams, bo as ListWorkflowsParams, bp as LoginParams, bq as LoginResponse, br as MetricsResource, bs as Organization, bt as OrganizationMember, bu as OrganizationSummary, bv as OrganizationUsage, bw as OrganizationsResource, bx as OutgoingWebhook, by as OutgoingWebhookDelivery, bz as PaginatedResponse, bA as PaginationParams, bB as PauseQueueResponse, bC as PlanCount, bD as PlanLimits, bE as PlanTier, bF as ProcessJobsStream, bG as PurgeDlqParams, bH as PurgeDlqResponse, bI as QueueConfig, bJ as QueueConfigSummary, bK as QueuePausedEvent, bL as QueueResumedEvent, bM as QueueStats, bN as QueueSummary, bO as QueuesResource, bP as RealtimeEventData, bQ as RecentActivity, bR as RefreshTokenParams, bS as RefreshTokenResponse, bT as RegisterWorkerParams, bU as RegisterWorkerResponse, bV as ResolvedConfig, bW as ResourceUsage, bX as ResumeQueueResponse, bY as RetryDlqParams, bZ as RetryDlqResponse, b_ as SDK_VERSION, b$ as Schedule, c0 as ScheduleRun, c1 as ScheduleRunStatus, c2 as ScheduleTriggeredEvent, c3 as SchedulesResource, c4 as SpooledClient, c5 as SpooledClientConfig, c6 as SpooledGrpcClient, c7 as SpooledRealtime, c8 as SpooledRealtimeOptions, c9 as SpooledWorker, ca as SpooledWorkerOptions, cb as StreamOptions, cc as SystemInfo, cd as TestWebhookResponse, ce as TriggerScheduleResponse, cf as UpdateApiKeyParams, cg as UpdateOrganizationParams, ch as UpdateOutgoingWebhookParams, ci as UpdateQueueConfigParams, cj as UpdateScheduleParams, ck as UsageItem, cl as UsageWarning, cm as ValidateTokenParams, cn as ValidateTokenResponse, co as WebhookDeliveryStatus, cp as WebhookEventType, cq as WebhookIngestionResource, cr as WebhookTokenResponse, cs as WebhooksResource, ct as Worker, cu as WorkerDeregisteredEvent, cv as WorkerEvent, cw as WorkerEventData, cx as WorkerHeartbeatParams, cy as WorkerRegisteredEvent, cz as WorkerState, cA as WorkerStatus, cB as WorkerSummary, cC as WorkersResource, cD as Workflow, cE as WorkflowJob, cF as WorkflowJobDefinition, cG as WorkflowJobStatus, cH as WorkflowResponse, cI as WorkflowStatus, cJ as WorkflowsResource, cK as asyncIterableFromStream, cL as createCircuitBreaker, cM as createClient, cN as createHttpClient, cO as createJobStream, cP as createPaginatedResponse, cQ as createProcessJobsStream, cR as dateToTimestamp, cS as resolveConfig, cT as timestampToDate, cU as validateConfig } from './index-CfLL1w6Y.js';
|
|
3
3
|
import * as protoLoader from '@grpc/proto-loader';
|
|
4
4
|
import { ServiceClientConstructor } from '@grpc/grpc-js';
|
|
5
5
|
|
|
@@ -24,6 +24,12 @@ declare class WebSocketRealtimeClient {
|
|
|
24
24
|
private state;
|
|
25
25
|
private reconnectAttempts;
|
|
26
26
|
private reconnectTimer;
|
|
27
|
+
/**
|
|
28
|
+
* Set when the server rejected our token on the upgrade (e.g. HTTP 401/403).
|
|
29
|
+
* The next (re)connect uses it to force the token provider to mint a fresh
|
|
30
|
+
* JWT instead of replaying the rejected one (which would loop forever).
|
|
31
|
+
*/
|
|
32
|
+
private authFailure;
|
|
27
33
|
private subscriptions;
|
|
28
34
|
private pendingCommands;
|
|
29
35
|
private eventHandlers;
|
package/dist/index.js
CHANGED
|
@@ -25,10 +25,10 @@ var DEFAULT_CONFIG = {
|
|
|
25
25
|
successThreshold: 3,
|
|
26
26
|
timeout: 3e4
|
|
27
27
|
},
|
|
28
|
-
userAgent: "@spooled/sdk-nodejs/1.0.
|
|
28
|
+
userAgent: "@spooled/sdk-nodejs/1.0.31",
|
|
29
29
|
autoRefreshToken: true
|
|
30
30
|
};
|
|
31
|
-
var SDK_VERSION = "1.0.
|
|
31
|
+
var SDK_VERSION = "1.0.31";
|
|
32
32
|
var API_VERSION = "v1";
|
|
33
33
|
var API_BASE_PATH = `/api/${API_VERSION}`;
|
|
34
34
|
function resolveConfig(options) {
|
|
@@ -1825,6 +1825,12 @@ var WebSocketRealtimeClient = class {
|
|
|
1825
1825
|
state = "disconnected";
|
|
1826
1826
|
reconnectAttempts = 0;
|
|
1827
1827
|
reconnectTimer = null;
|
|
1828
|
+
/**
|
|
1829
|
+
* Set when the server rejected our token on the upgrade (e.g. HTTP 401/403).
|
|
1830
|
+
* The next (re)connect uses it to force the token provider to mint a fresh
|
|
1831
|
+
* JWT instead of replaying the rejected one (which would loop forever).
|
|
1832
|
+
*/
|
|
1833
|
+
authFailure = false;
|
|
1828
1834
|
subscriptions = /* @__PURE__ */ new Map();
|
|
1829
1835
|
pendingCommands = /* @__PURE__ */ new Map();
|
|
1830
1836
|
// Event handlers
|
|
@@ -1833,16 +1839,16 @@ var WebSocketRealtimeClient = class {
|
|
|
1833
1839
|
stateChangeHandlers = /* @__PURE__ */ new Set();
|
|
1834
1840
|
constructor(options) {
|
|
1835
1841
|
this.options = {
|
|
1836
|
-
autoReconnect: true,
|
|
1837
|
-
maxReconnectAttempts: 10,
|
|
1838
|
-
reconnectDelay: 1e3,
|
|
1839
|
-
maxReconnectDelay: 3e4,
|
|
1840
|
-
debug: () => {
|
|
1841
|
-
},
|
|
1842
1842
|
...options,
|
|
1843
|
+
autoReconnect: options.autoReconnect ?? true,
|
|
1844
|
+
maxReconnectAttempts: options.maxReconnectAttempts ?? 10,
|
|
1845
|
+
reconnectDelay: options.reconnectDelay ?? 1e3,
|
|
1846
|
+
maxReconnectDelay: options.maxReconnectDelay ?? 3e4,
|
|
1843
1847
|
// Always resolve to a provider so reconnects can mint a fresh JWT.
|
|
1844
1848
|
// Falls back to the static token when no provider is supplied.
|
|
1845
|
-
tokenProvider: options.tokenProvider ?? (async () => options.token)
|
|
1849
|
+
tokenProvider: options.tokenProvider ?? (async () => options.token),
|
|
1850
|
+
debug: options.debug ?? (() => {
|
|
1851
|
+
})
|
|
1846
1852
|
};
|
|
1847
1853
|
}
|
|
1848
1854
|
/**
|
|
@@ -1906,6 +1912,9 @@ var WebSocketRealtimeClient = class {
|
|
|
1906
1912
|
};
|
|
1907
1913
|
this.ws.onerror = (event) => {
|
|
1908
1914
|
this.options.debug("WebSocket error", event);
|
|
1915
|
+
if (isAuthFailureEvent(event)) {
|
|
1916
|
+
this.authFailure = true;
|
|
1917
|
+
}
|
|
1909
1918
|
};
|
|
1910
1919
|
} catch (error) {
|
|
1911
1920
|
this.setState("disconnected");
|
|
@@ -1992,7 +2001,9 @@ var WebSocketRealtimeClient = class {
|
|
|
1992
2001
|
// Private methods
|
|
1993
2002
|
async buildWsUrl() {
|
|
1994
2003
|
const wsBase = this.options.wsUrl;
|
|
1995
|
-
const
|
|
2004
|
+
const forceRefresh = this.authFailure;
|
|
2005
|
+
this.authFailure = false;
|
|
2006
|
+
const token = await this.options.tokenProvider(forceRefresh);
|
|
1996
2007
|
return `${wsBase}/api/v1/ws?token=${encodeURIComponent(token)}`;
|
|
1997
2008
|
}
|
|
1998
2009
|
setState(state) {
|
|
@@ -2115,6 +2126,17 @@ var WebSocketRealtimeClient = class {
|
|
|
2115
2126
|
function redactToken(url) {
|
|
2116
2127
|
return url.replace(/([?&](?:token|api_key)=)[^&]*/gi, "$1***");
|
|
2117
2128
|
}
|
|
2129
|
+
function isAuthFailureEvent(event) {
|
|
2130
|
+
if (!event) {
|
|
2131
|
+
return false;
|
|
2132
|
+
}
|
|
2133
|
+
const status = event.status ?? event.statusCode ?? event.error?.status;
|
|
2134
|
+
if (status === 401 || status === 403) {
|
|
2135
|
+
return true;
|
|
2136
|
+
}
|
|
2137
|
+
const text = String(event.message ?? event.error?.message ?? event.reason ?? "");
|
|
2138
|
+
return /\b(401|403)\b/.test(text);
|
|
2139
|
+
}
|
|
2118
2140
|
|
|
2119
2141
|
// src/realtime/sse.ts
|
|
2120
2142
|
var SseRealtimeClient = class {
|
|
@@ -2131,16 +2153,22 @@ var SseRealtimeClient = class {
|
|
|
2131
2153
|
stateChangeHandlers = /* @__PURE__ */ new Set();
|
|
2132
2154
|
constructor(options) {
|
|
2133
2155
|
this.options = {
|
|
2134
|
-
autoReconnect: true,
|
|
2135
|
-
maxReconnectAttempts: 10,
|
|
2136
|
-
reconnectDelay: 1e3,
|
|
2137
|
-
maxReconnectDelay: 3e4,
|
|
2138
|
-
debug: () => {
|
|
2139
|
-
},
|
|
2140
2156
|
...options,
|
|
2157
|
+
autoReconnect: options.autoReconnect ?? true,
|
|
2158
|
+
maxReconnectAttempts: options.maxReconnectAttempts ?? 10,
|
|
2159
|
+
reconnectDelay: options.reconnectDelay ?? 1e3,
|
|
2160
|
+
maxReconnectDelay: options.maxReconnectDelay ?? 3e4,
|
|
2141
2161
|
// Always resolve to a provider so reconnects can mint a fresh token.
|
|
2142
2162
|
// Falls back to the static token when no provider is supplied.
|
|
2143
|
-
tokenProvider: options.tokenProvider ?? (async () => options.token)
|
|
2163
|
+
tokenProvider: options.tokenProvider ?? (async () => options.token),
|
|
2164
|
+
// Coalesce debug to a no-op AFTER the spread. A caller that omits debug
|
|
2165
|
+
// still passes `debug: undefined` explicitly (e.g. via SpooledRealtime),
|
|
2166
|
+
// and spreading that would overwrite a pre-spread default with undefined,
|
|
2167
|
+
// making connect() call `this.options.debug(...)` on undefined and throw
|
|
2168
|
+
// "this.options.debug is not a function". Guarding here keeps it callable
|
|
2169
|
+
// regardless of what the caller passes.
|
|
2170
|
+
debug: options.debug ?? (() => {
|
|
2171
|
+
})
|
|
2144
2172
|
};
|
|
2145
2173
|
}
|
|
2146
2174
|
/**
|
|
@@ -2847,6 +2875,18 @@ var SpooledClient = class _SpooledClient {
|
|
|
2847
2875
|
/** Token refresh state */
|
|
2848
2876
|
refreshPromise = null;
|
|
2849
2877
|
tokenExpiresAt = null;
|
|
2878
|
+
/**
|
|
2879
|
+
* Cached JWT for realtime connections (API-key auth path).
|
|
2880
|
+
*
|
|
2881
|
+
* The realtime layer requests a token on every (re)connect. Minting a brand
|
|
2882
|
+
* new JWT via POST /auth/login each time trips the login rate limit (429)
|
|
2883
|
+
* under a reconnect storm, after which realtime can never recover. We cache
|
|
2884
|
+
* the token here — at the client level, shared across reconnects — and reuse
|
|
2885
|
+
* it until it nears expiry.
|
|
2886
|
+
*/
|
|
2887
|
+
cachedJwt = null;
|
|
2888
|
+
/** Deduplicates concurrent logins (e.g. WS + SSE reconnecting together). */
|
|
2889
|
+
jwtLoginPromise = null;
|
|
2850
2890
|
constructor(options) {
|
|
2851
2891
|
this.config = resolveConfig(options);
|
|
2852
2892
|
validateConfig(this.config);
|
|
@@ -2934,31 +2974,72 @@ var SpooledClient = class _SpooledClient {
|
|
|
2934
2974
|
baseUrl: this.config.baseUrl,
|
|
2935
2975
|
wsUrl: this.config.wsUrl,
|
|
2936
2976
|
token,
|
|
2937
|
-
// Provider
|
|
2938
|
-
//
|
|
2939
|
-
|
|
2977
|
+
// Provider the realtime layer calls on every (re)connect. It returns a
|
|
2978
|
+
// cached JWT and only re-logs-in when the token is absent, near expiry,
|
|
2979
|
+
// or the transport asks to force a refresh (e.g. after a 401 upgrade).
|
|
2980
|
+
tokenProvider: (forceRefresh) => this.getJwtToken(forceRefresh),
|
|
2940
2981
|
...options,
|
|
2941
|
-
|
|
2982
|
+
// Only forward debug when the client actually has a logger, so we never
|
|
2983
|
+
// hand the realtime layer an explicit `debug: undefined`. The WS/SSE
|
|
2984
|
+
// constructors also guard against this, but keeping the undefined out of
|
|
2985
|
+
// the option object makes the intent clear at the call site.
|
|
2986
|
+
...this.config.debug ? { debug: this.config.debug } : {}
|
|
2942
2987
|
});
|
|
2943
2988
|
}
|
|
2944
2989
|
/**
|
|
2945
|
-
* Get or acquire a JWT token for realtime connections
|
|
2990
|
+
* Get or acquire a JWT token for realtime connections.
|
|
2991
|
+
*
|
|
2992
|
+
* The realtime layer calls this on every (re)connect. We cache the JWT and
|
|
2993
|
+
* reuse it until it nears expiry so a reconnect storm doesn't hammer
|
|
2994
|
+
* /auth/login and trip its rate limit. A fresh login happens only when the
|
|
2995
|
+
* cached token is absent, within ~60s of its `exp`, or a refresh is forced.
|
|
2996
|
+
*
|
|
2997
|
+
* @param forceRefresh Bypass the cache and mint a new token. Set by the
|
|
2998
|
+
* transport when the server rejected the current token (e.g. a 401 on the
|
|
2999
|
+
* WebSocket upgrade), so a stale/revoked token is replaced without waiting
|
|
3000
|
+
* for it to expire.
|
|
2946
3001
|
*/
|
|
2947
|
-
async getJwtToken() {
|
|
3002
|
+
async getJwtToken(forceRefresh = false) {
|
|
2948
3003
|
if (this.config.accessToken) {
|
|
2949
|
-
if (this.shouldRefreshToken()) {
|
|
3004
|
+
if (forceRefresh || this.shouldRefreshToken()) {
|
|
2950
3005
|
return this.refreshAccessToken();
|
|
2951
3006
|
}
|
|
2952
3007
|
return this.config.accessToken;
|
|
2953
3008
|
}
|
|
2954
3009
|
if (this.config.apiKey) {
|
|
3010
|
+
if (forceRefresh) {
|
|
3011
|
+
this.cachedJwt = null;
|
|
3012
|
+
}
|
|
3013
|
+
if (this.cachedJwt && !isJwtNearExpiry(this.cachedJwt)) {
|
|
3014
|
+
return this.cachedJwt;
|
|
3015
|
+
}
|
|
3016
|
+
return this.loginForJwt();
|
|
3017
|
+
}
|
|
3018
|
+
throw new AuthenticationError("No authentication method available for realtime connection");
|
|
3019
|
+
}
|
|
3020
|
+
/**
|
|
3021
|
+
* Exchange the API key for a JWT via /auth/login and cache the result.
|
|
3022
|
+
*
|
|
3023
|
+
* Concurrent callers share a single in-flight login so a burst of reconnects
|
|
3024
|
+
* (e.g. WebSocket and SSE at once) issues just one request.
|
|
3025
|
+
*/
|
|
3026
|
+
async loginForJwt() {
|
|
3027
|
+
if (this.jwtLoginPromise) {
|
|
3028
|
+
return this.jwtLoginPromise;
|
|
3029
|
+
}
|
|
3030
|
+
this.jwtLoginPromise = (async () => {
|
|
2955
3031
|
const response = await this.auth.login({ apiKey: this.config.apiKey });
|
|
2956
3032
|
this.http.setAuthToken(response.accessToken);
|
|
2957
3033
|
this.tokenExpiresAt = Date.now() + response.expiresIn * 1e3;
|
|
2958
3034
|
this.config.refreshToken = response.refreshToken;
|
|
3035
|
+
this.cachedJwt = response.accessToken;
|
|
2959
3036
|
return response.accessToken;
|
|
3037
|
+
})();
|
|
3038
|
+
try {
|
|
3039
|
+
return await this.jwtLoginPromise;
|
|
3040
|
+
} finally {
|
|
3041
|
+
this.jwtLoginPromise = null;
|
|
2960
3042
|
}
|
|
2961
|
-
throw new AuthenticationError("No authentication method available for realtime connection");
|
|
2962
3043
|
}
|
|
2963
3044
|
/**
|
|
2964
3045
|
* Check if token should be refreshed
|
|
@@ -3059,6 +3140,34 @@ var SpooledClient = class _SpooledClient {
|
|
|
3059
3140
|
function createClient(options) {
|
|
3060
3141
|
return new SpooledClient(options);
|
|
3061
3142
|
}
|
|
3143
|
+
function decodeJwtExp(token) {
|
|
3144
|
+
const parts = token.split(".");
|
|
3145
|
+
if (parts.length < 2) {
|
|
3146
|
+
return null;
|
|
3147
|
+
}
|
|
3148
|
+
try {
|
|
3149
|
+
const payload = JSON.parse(base64UrlDecode(parts[1]));
|
|
3150
|
+
return typeof payload.exp === "number" ? payload.exp : null;
|
|
3151
|
+
} catch {
|
|
3152
|
+
return null;
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
function isJwtNearExpiry(token, skewMs = 6e4) {
|
|
3156
|
+
const exp = decodeJwtExp(token);
|
|
3157
|
+
if (exp === null) {
|
|
3158
|
+
return true;
|
|
3159
|
+
}
|
|
3160
|
+
return Date.now() >= exp * 1e3 - skewMs;
|
|
3161
|
+
}
|
|
3162
|
+
function base64UrlDecode(segment) {
|
|
3163
|
+
const b64 = segment.replace(/-/g, "+").replace(/_/g, "/");
|
|
3164
|
+
if (typeof globalThis.Buffer !== "undefined") {
|
|
3165
|
+
return globalThis.Buffer.from(b64, "base64").toString("utf8");
|
|
3166
|
+
}
|
|
3167
|
+
const binary = globalThis.atob(b64);
|
|
3168
|
+
const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
|
3169
|
+
return new globalThis.TextDecoder().decode(bytes);
|
|
3170
|
+
}
|
|
3062
3171
|
|
|
3063
3172
|
// src/types/common.ts
|
|
3064
3173
|
function createPaginatedResponse(items, limit, offset = 0, total) {
|