@spooled/sdk 1.0.30 → 1.0.32
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 +10 -6
- package/dist/{index-Dv2jBkfc.d.cts → index-CfLL1w6Y.d.cts} +44 -11
- package/dist/{index-Dv2jBkfc.d.ts → index-CfLL1w6Y.d.ts} +44 -11
- package/dist/index.cjs +120 -14
- 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 +120 -14
- 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,12 +25,19 @@ 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
|
+
function normalizeCredential(value) {
|
|
35
|
+
if (value === void 0) {
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
const trimmed = value.trim();
|
|
39
|
+
return trimmed === "" ? void 0 : trimmed;
|
|
40
|
+
}
|
|
34
41
|
function resolveConfig(options) {
|
|
35
42
|
let debugFn = null;
|
|
36
43
|
if (options.debug === true) {
|
|
@@ -60,10 +67,10 @@ function resolveConfig(options) {
|
|
|
60
67
|
const derivedWsUrl = baseUrl.replace(/^http/, "ws");
|
|
61
68
|
const wsUrl = options.wsUrl ?? derivedWsUrl;
|
|
62
69
|
return {
|
|
63
|
-
apiKey: options.apiKey,
|
|
64
|
-
accessToken: options.accessToken,
|
|
65
|
-
refreshToken: options.refreshToken,
|
|
66
|
-
adminKey: options.adminKey,
|
|
70
|
+
apiKey: normalizeCredential(options.apiKey),
|
|
71
|
+
accessToken: normalizeCredential(options.accessToken),
|
|
72
|
+
refreshToken: normalizeCredential(options.refreshToken),
|
|
73
|
+
adminKey: normalizeCredential(options.adminKey),
|
|
67
74
|
baseUrl,
|
|
68
75
|
wsUrl,
|
|
69
76
|
grpcAddress: options.grpcAddress ?? DEFAULT_CONFIG.grpcAddress,
|
|
@@ -1825,6 +1832,12 @@ var WebSocketRealtimeClient = class {
|
|
|
1825
1832
|
state = "disconnected";
|
|
1826
1833
|
reconnectAttempts = 0;
|
|
1827
1834
|
reconnectTimer = null;
|
|
1835
|
+
/**
|
|
1836
|
+
* Set when the server rejected our token on the upgrade (e.g. HTTP 401/403).
|
|
1837
|
+
* The next (re)connect uses it to force the token provider to mint a fresh
|
|
1838
|
+
* JWT instead of replaying the rejected one (which would loop forever).
|
|
1839
|
+
*/
|
|
1840
|
+
authFailure = false;
|
|
1828
1841
|
subscriptions = /* @__PURE__ */ new Map();
|
|
1829
1842
|
pendingCommands = /* @__PURE__ */ new Map();
|
|
1830
1843
|
// Event handlers
|
|
@@ -1906,6 +1919,9 @@ var WebSocketRealtimeClient = class {
|
|
|
1906
1919
|
};
|
|
1907
1920
|
this.ws.onerror = (event) => {
|
|
1908
1921
|
this.options.debug("WebSocket error", event);
|
|
1922
|
+
if (isAuthFailureEvent(event)) {
|
|
1923
|
+
this.authFailure = true;
|
|
1924
|
+
}
|
|
1909
1925
|
};
|
|
1910
1926
|
} catch (error) {
|
|
1911
1927
|
this.setState("disconnected");
|
|
@@ -1992,7 +2008,9 @@ var WebSocketRealtimeClient = class {
|
|
|
1992
2008
|
// Private methods
|
|
1993
2009
|
async buildWsUrl() {
|
|
1994
2010
|
const wsBase = this.options.wsUrl;
|
|
1995
|
-
const
|
|
2011
|
+
const forceRefresh = this.authFailure;
|
|
2012
|
+
this.authFailure = false;
|
|
2013
|
+
const token = await this.options.tokenProvider(forceRefresh);
|
|
1996
2014
|
return `${wsBase}/api/v1/ws?token=${encodeURIComponent(token)}`;
|
|
1997
2015
|
}
|
|
1998
2016
|
setState(state) {
|
|
@@ -2115,6 +2133,17 @@ var WebSocketRealtimeClient = class {
|
|
|
2115
2133
|
function redactToken(url) {
|
|
2116
2134
|
return url.replace(/([?&](?:token|api_key)=)[^&]*/gi, "$1***");
|
|
2117
2135
|
}
|
|
2136
|
+
function isAuthFailureEvent(event) {
|
|
2137
|
+
if (!event) {
|
|
2138
|
+
return false;
|
|
2139
|
+
}
|
|
2140
|
+
const status = event.status ?? event.statusCode ?? event.error?.status;
|
|
2141
|
+
if (status === 401 || status === 403) {
|
|
2142
|
+
return true;
|
|
2143
|
+
}
|
|
2144
|
+
const text = String(event.message ?? event.error?.message ?? event.reason ?? "");
|
|
2145
|
+
return /\b(401|403)\b/.test(text);
|
|
2146
|
+
}
|
|
2118
2147
|
|
|
2119
2148
|
// src/realtime/sse.ts
|
|
2120
2149
|
var SseRealtimeClient = class {
|
|
@@ -2853,6 +2882,18 @@ var SpooledClient = class _SpooledClient {
|
|
|
2853
2882
|
/** Token refresh state */
|
|
2854
2883
|
refreshPromise = null;
|
|
2855
2884
|
tokenExpiresAt = null;
|
|
2885
|
+
/**
|
|
2886
|
+
* Cached JWT for realtime connections (API-key auth path).
|
|
2887
|
+
*
|
|
2888
|
+
* The realtime layer requests a token on every (re)connect. Minting a brand
|
|
2889
|
+
* new JWT via POST /auth/login each time trips the login rate limit (429)
|
|
2890
|
+
* under a reconnect storm, after which realtime can never recover. We cache
|
|
2891
|
+
* the token here — at the client level, shared across reconnects — and reuse
|
|
2892
|
+
* it until it nears expiry.
|
|
2893
|
+
*/
|
|
2894
|
+
cachedJwt = null;
|
|
2895
|
+
/** Deduplicates concurrent logins (e.g. WS + SSE reconnecting together). */
|
|
2896
|
+
jwtLoginPromise = null;
|
|
2856
2897
|
constructor(options) {
|
|
2857
2898
|
this.config = resolveConfig(options);
|
|
2858
2899
|
validateConfig(this.config);
|
|
@@ -2940,9 +2981,10 @@ var SpooledClient = class _SpooledClient {
|
|
|
2940
2981
|
baseUrl: this.config.baseUrl,
|
|
2941
2982
|
wsUrl: this.config.wsUrl,
|
|
2942
2983
|
token,
|
|
2943
|
-
// Provider
|
|
2944
|
-
//
|
|
2945
|
-
|
|
2984
|
+
// Provider the realtime layer calls on every (re)connect. It returns a
|
|
2985
|
+
// cached JWT and only re-logs-in when the token is absent, near expiry,
|
|
2986
|
+
// or the transport asks to force a refresh (e.g. after a 401 upgrade).
|
|
2987
|
+
tokenProvider: (forceRefresh) => this.getJwtToken(forceRefresh),
|
|
2946
2988
|
...options,
|
|
2947
2989
|
// Only forward debug when the client actually has a logger, so we never
|
|
2948
2990
|
// hand the realtime layer an explicit `debug: undefined`. The WS/SSE
|
|
@@ -2952,23 +2994,59 @@ var SpooledClient = class _SpooledClient {
|
|
|
2952
2994
|
});
|
|
2953
2995
|
}
|
|
2954
2996
|
/**
|
|
2955
|
-
* Get or acquire a JWT token for realtime connections
|
|
2997
|
+
* Get or acquire a JWT token for realtime connections.
|
|
2998
|
+
*
|
|
2999
|
+
* The realtime layer calls this on every (re)connect. We cache the JWT and
|
|
3000
|
+
* reuse it until it nears expiry so a reconnect storm doesn't hammer
|
|
3001
|
+
* /auth/login and trip its rate limit. A fresh login happens only when the
|
|
3002
|
+
* cached token is absent, within ~60s of its `exp`, or a refresh is forced.
|
|
3003
|
+
*
|
|
3004
|
+
* @param forceRefresh Bypass the cache and mint a new token. Set by the
|
|
3005
|
+
* transport when the server rejected the current token (e.g. a 401 on the
|
|
3006
|
+
* WebSocket upgrade), so a stale/revoked token is replaced without waiting
|
|
3007
|
+
* for it to expire.
|
|
2956
3008
|
*/
|
|
2957
|
-
async getJwtToken() {
|
|
3009
|
+
async getJwtToken(forceRefresh = false) {
|
|
2958
3010
|
if (this.config.accessToken) {
|
|
2959
|
-
if (this.shouldRefreshToken()) {
|
|
3011
|
+
if (forceRefresh || this.shouldRefreshToken()) {
|
|
2960
3012
|
return this.refreshAccessToken();
|
|
2961
3013
|
}
|
|
2962
3014
|
return this.config.accessToken;
|
|
2963
3015
|
}
|
|
2964
3016
|
if (this.config.apiKey) {
|
|
3017
|
+
if (forceRefresh) {
|
|
3018
|
+
this.cachedJwt = null;
|
|
3019
|
+
}
|
|
3020
|
+
if (this.cachedJwt && !isJwtNearExpiry(this.cachedJwt)) {
|
|
3021
|
+
return this.cachedJwt;
|
|
3022
|
+
}
|
|
3023
|
+
return this.loginForJwt();
|
|
3024
|
+
}
|
|
3025
|
+
throw new AuthenticationError("No authentication method available for realtime connection");
|
|
3026
|
+
}
|
|
3027
|
+
/**
|
|
3028
|
+
* Exchange the API key for a JWT via /auth/login and cache the result.
|
|
3029
|
+
*
|
|
3030
|
+
* Concurrent callers share a single in-flight login so a burst of reconnects
|
|
3031
|
+
* (e.g. WebSocket and SSE at once) issues just one request.
|
|
3032
|
+
*/
|
|
3033
|
+
async loginForJwt() {
|
|
3034
|
+
if (this.jwtLoginPromise) {
|
|
3035
|
+
return this.jwtLoginPromise;
|
|
3036
|
+
}
|
|
3037
|
+
this.jwtLoginPromise = (async () => {
|
|
2965
3038
|
const response = await this.auth.login({ apiKey: this.config.apiKey });
|
|
2966
3039
|
this.http.setAuthToken(response.accessToken);
|
|
2967
3040
|
this.tokenExpiresAt = Date.now() + response.expiresIn * 1e3;
|
|
2968
3041
|
this.config.refreshToken = response.refreshToken;
|
|
3042
|
+
this.cachedJwt = response.accessToken;
|
|
2969
3043
|
return response.accessToken;
|
|
3044
|
+
})();
|
|
3045
|
+
try {
|
|
3046
|
+
return await this.jwtLoginPromise;
|
|
3047
|
+
} finally {
|
|
3048
|
+
this.jwtLoginPromise = null;
|
|
2970
3049
|
}
|
|
2971
|
-
throw new AuthenticationError("No authentication method available for realtime connection");
|
|
2972
3050
|
}
|
|
2973
3051
|
/**
|
|
2974
3052
|
* Check if token should be refreshed
|
|
@@ -3069,6 +3147,34 @@ var SpooledClient = class _SpooledClient {
|
|
|
3069
3147
|
function createClient(options) {
|
|
3070
3148
|
return new SpooledClient(options);
|
|
3071
3149
|
}
|
|
3150
|
+
function decodeJwtExp(token) {
|
|
3151
|
+
const parts = token.split(".");
|
|
3152
|
+
if (parts.length < 2) {
|
|
3153
|
+
return null;
|
|
3154
|
+
}
|
|
3155
|
+
try {
|
|
3156
|
+
const payload = JSON.parse(base64UrlDecode(parts[1]));
|
|
3157
|
+
return typeof payload.exp === "number" ? payload.exp : null;
|
|
3158
|
+
} catch {
|
|
3159
|
+
return null;
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
function isJwtNearExpiry(token, skewMs = 6e4) {
|
|
3163
|
+
const exp = decodeJwtExp(token);
|
|
3164
|
+
if (exp === null) {
|
|
3165
|
+
return true;
|
|
3166
|
+
}
|
|
3167
|
+
return Date.now() >= exp * 1e3 - skewMs;
|
|
3168
|
+
}
|
|
3169
|
+
function base64UrlDecode(segment) {
|
|
3170
|
+
const b64 = segment.replace(/-/g, "+").replace(/_/g, "/");
|
|
3171
|
+
if (typeof globalThis.Buffer !== "undefined") {
|
|
3172
|
+
return globalThis.Buffer.from(b64, "base64").toString("utf8");
|
|
3173
|
+
}
|
|
3174
|
+
const binary = globalThis.atob(b64);
|
|
3175
|
+
const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
|
3176
|
+
return new globalThis.TextDecoder().decode(bytes);
|
|
3177
|
+
}
|
|
3072
3178
|
|
|
3073
3179
|
// src/types/common.ts
|
|
3074
3180
|
function createPaginatedResponse(items, limit, offset = 0, total) {
|