@spooled/sdk 1.0.32 → 1.0.34
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-CfLL1w6Y.d.cts → index-CYEamGDj.d.cts} +48 -3
- package/dist/{index-CfLL1w6Y.d.ts → index-CYEamGDj.d.ts} +48 -3
- package/dist/index.cjs +87 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -8
- package/dist/index.d.ts +18 -8
- package/dist/index.js +87 -72
- package/dist/index.js.map +1 -1
- package/dist/worker/index.cjs +8 -4
- 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 +8 -4
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
- package/proto/spooled.proto +13 -0
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-CYEamGDj.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-CYEamGDj.cjs';
|
|
3
3
|
import * as protoLoader from '@grpc/proto-loader';
|
|
4
4
|
import { ServiceClientConstructor } from '@grpc/grpc-js';
|
|
5
5
|
|
|
@@ -31,7 +31,6 @@ declare class WebSocketRealtimeClient {
|
|
|
31
31
|
*/
|
|
32
32
|
private authFailure;
|
|
33
33
|
private subscriptions;
|
|
34
|
-
private pendingCommands;
|
|
35
34
|
private eventHandlers;
|
|
36
35
|
private allEventsHandlers;
|
|
37
36
|
private stateChangeHandlers;
|
|
@@ -53,11 +52,17 @@ declare class WebSocketRealtimeClient {
|
|
|
53
52
|
*/
|
|
54
53
|
disconnect(): void;
|
|
55
54
|
/**
|
|
56
|
-
* Subscribe to events matching a filter
|
|
55
|
+
* Subscribe to events matching a filter.
|
|
56
|
+
*
|
|
57
|
+
* The server applies filtering itself and sends no acknowledgement, so this
|
|
58
|
+
* resolves as soon as the command has been written to the socket. The filter
|
|
59
|
+
* is tracked locally so it is replayed automatically on reconnect.
|
|
57
60
|
*/
|
|
58
61
|
subscribe(filter: SubscriptionFilter): Promise<void>;
|
|
59
62
|
/**
|
|
60
|
-
* Unsubscribe from events matching a filter
|
|
63
|
+
* Unsubscribe from events matching a filter.
|
|
64
|
+
*
|
|
65
|
+
* Fire-and-forget, like {@link subscribe} — the server sends no ack.
|
|
61
66
|
*/
|
|
62
67
|
unsubscribe(filter: SubscriptionFilter): Promise<void>;
|
|
63
68
|
/**
|
|
@@ -79,14 +84,19 @@ declare class WebSocketRealtimeClient {
|
|
|
79
84
|
private buildWsUrl;
|
|
80
85
|
private setState;
|
|
81
86
|
private handleMessage;
|
|
82
|
-
private handleCommandResponse;
|
|
83
87
|
private handleDisconnect;
|
|
84
88
|
private scheduleReconnect;
|
|
85
89
|
private resubscribeAll;
|
|
90
|
+
/**
|
|
91
|
+
* Send a subscribe/unsubscribe command to the server.
|
|
92
|
+
*
|
|
93
|
+
* The backend `ClientCommand` shape is `{ cmd, queue, job_id }` and it sends
|
|
94
|
+
* no acknowledgement, so this is fire-and-forget — it writes to the socket
|
|
95
|
+
* and returns. The `SubscriptionFilter`'s `workerId`/`scheduleId` have no
|
|
96
|
+
* server-side equivalent and are ignored.
|
|
97
|
+
*/
|
|
86
98
|
private sendCommand;
|
|
87
|
-
private clearPendingCommands;
|
|
88
99
|
private filterToId;
|
|
89
|
-
private generateRequestId;
|
|
90
100
|
}
|
|
91
101
|
|
|
92
102
|
/**
|
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-CYEamGDj.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-CYEamGDj.js';
|
|
3
3
|
import * as protoLoader from '@grpc/proto-loader';
|
|
4
4
|
import { ServiceClientConstructor } from '@grpc/grpc-js';
|
|
5
5
|
|
|
@@ -31,7 +31,6 @@ declare class WebSocketRealtimeClient {
|
|
|
31
31
|
*/
|
|
32
32
|
private authFailure;
|
|
33
33
|
private subscriptions;
|
|
34
|
-
private pendingCommands;
|
|
35
34
|
private eventHandlers;
|
|
36
35
|
private allEventsHandlers;
|
|
37
36
|
private stateChangeHandlers;
|
|
@@ -53,11 +52,17 @@ declare class WebSocketRealtimeClient {
|
|
|
53
52
|
*/
|
|
54
53
|
disconnect(): void;
|
|
55
54
|
/**
|
|
56
|
-
* Subscribe to events matching a filter
|
|
55
|
+
* Subscribe to events matching a filter.
|
|
56
|
+
*
|
|
57
|
+
* The server applies filtering itself and sends no acknowledgement, so this
|
|
58
|
+
* resolves as soon as the command has been written to the socket. The filter
|
|
59
|
+
* is tracked locally so it is replayed automatically on reconnect.
|
|
57
60
|
*/
|
|
58
61
|
subscribe(filter: SubscriptionFilter): Promise<void>;
|
|
59
62
|
/**
|
|
60
|
-
* Unsubscribe from events matching a filter
|
|
63
|
+
* Unsubscribe from events matching a filter.
|
|
64
|
+
*
|
|
65
|
+
* Fire-and-forget, like {@link subscribe} — the server sends no ack.
|
|
61
66
|
*/
|
|
62
67
|
unsubscribe(filter: SubscriptionFilter): Promise<void>;
|
|
63
68
|
/**
|
|
@@ -79,14 +84,19 @@ declare class WebSocketRealtimeClient {
|
|
|
79
84
|
private buildWsUrl;
|
|
80
85
|
private setState;
|
|
81
86
|
private handleMessage;
|
|
82
|
-
private handleCommandResponse;
|
|
83
87
|
private handleDisconnect;
|
|
84
88
|
private scheduleReconnect;
|
|
85
89
|
private resubscribeAll;
|
|
90
|
+
/**
|
|
91
|
+
* Send a subscribe/unsubscribe command to the server.
|
|
92
|
+
*
|
|
93
|
+
* The backend `ClientCommand` shape is `{ cmd, queue, job_id }` and it sends
|
|
94
|
+
* no acknowledgement, so this is fire-and-forget — it writes to the socket
|
|
95
|
+
* and returns. The `SubscriptionFilter`'s `workerId`/`scheduleId` have no
|
|
96
|
+
* server-side equivalent and are ignored.
|
|
97
|
+
*/
|
|
86
98
|
private sendCommand;
|
|
87
|
-
private clearPendingCommands;
|
|
88
99
|
private filterToId;
|
|
89
|
-
private generateRequestId;
|
|
90
100
|
}
|
|
91
101
|
|
|
92
102
|
/**
|
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.33",
|
|
29
29
|
autoRefreshToken: true
|
|
30
30
|
};
|
|
31
|
-
var SDK_VERSION = "1.0.
|
|
31
|
+
var SDK_VERSION = "1.0.33";
|
|
32
32
|
var API_VERSION = "v1";
|
|
33
33
|
var API_BASE_PATH = `/api/${API_VERSION}`;
|
|
34
34
|
function normalizeCredential(value) {
|
|
@@ -303,22 +303,33 @@ function parseRateLimitHeaders(headers) {
|
|
|
303
303
|
}
|
|
304
304
|
return info;
|
|
305
305
|
}
|
|
306
|
+
var MAX_RAW_ERROR_BODY_CHARS = 500;
|
|
306
307
|
async function parseErrorBody(response) {
|
|
307
308
|
const contentType = response.headers.get("Content-Type") || "";
|
|
308
|
-
|
|
309
|
+
let raw;
|
|
310
|
+
try {
|
|
311
|
+
raw = await response.text();
|
|
312
|
+
} catch {
|
|
309
313
|
return null;
|
|
310
314
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
315
|
+
if (contentType.includes("application/json")) {
|
|
316
|
+
try {
|
|
317
|
+
const body = JSON.parse(raw);
|
|
318
|
+
if (typeof body === "object" && body !== null) {
|
|
319
|
+
const message = (body.message ?? body.error) || response.statusText;
|
|
320
|
+
return {
|
|
321
|
+
code: body.code || "UNKNOWN_ERROR",
|
|
322
|
+
message,
|
|
323
|
+
details: body.details
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
} catch {
|
|
320
327
|
}
|
|
321
|
-
}
|
|
328
|
+
}
|
|
329
|
+
const trimmed = raw.trim();
|
|
330
|
+
if (trimmed) {
|
|
331
|
+
const message = trimmed.length > MAX_RAW_ERROR_BODY_CHARS ? `${trimmed.slice(0, MAX_RAW_ERROR_BODY_CHARS)}\u2026` : trimmed;
|
|
332
|
+
return { code: "UNKNOWN_ERROR", message };
|
|
322
333
|
}
|
|
323
334
|
return null;
|
|
324
335
|
}
|
|
@@ -1824,6 +1835,24 @@ var WebhookIngestionResource = class {
|
|
|
1824
1835
|
}
|
|
1825
1836
|
};
|
|
1826
1837
|
|
|
1838
|
+
// src/realtime/event-map.ts
|
|
1839
|
+
var BACKEND_EVENT_TYPE_MAP = {
|
|
1840
|
+
JobStatusChange: "job.status_changed",
|
|
1841
|
+
JobCreated: "job.created",
|
|
1842
|
+
JobCompleted: "job.completed",
|
|
1843
|
+
JobFailed: "job.failed",
|
|
1844
|
+
QueueStats: "queue.stats",
|
|
1845
|
+
WorkerHeartbeat: "worker.heartbeat",
|
|
1846
|
+
WorkerRegistered: "worker.registered",
|
|
1847
|
+
WorkerDeregistered: "worker.deregistered",
|
|
1848
|
+
SystemHealth: "system.health",
|
|
1849
|
+
Ping: "ping",
|
|
1850
|
+
Error: "error"
|
|
1851
|
+
};
|
|
1852
|
+
function mapEventType(type) {
|
|
1853
|
+
return BACKEND_EVENT_TYPE_MAP[type] ?? type;
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1827
1856
|
// src/realtime/websocket.ts
|
|
1828
1857
|
var WebSocketRealtimeClient = class {
|
|
1829
1858
|
options;
|
|
@@ -1839,7 +1868,6 @@ var WebSocketRealtimeClient = class {
|
|
|
1839
1868
|
*/
|
|
1840
1869
|
authFailure = false;
|
|
1841
1870
|
subscriptions = /* @__PURE__ */ new Map();
|
|
1842
|
-
pendingCommands = /* @__PURE__ */ new Map();
|
|
1843
1871
|
// Event handlers
|
|
1844
1872
|
eventHandlers = /* @__PURE__ */ new Map();
|
|
1845
1873
|
allEventsHandlers = /* @__PURE__ */ new Set();
|
|
@@ -1944,10 +1972,13 @@ var WebSocketRealtimeClient = class {
|
|
|
1944
1972
|
}
|
|
1945
1973
|
this.setState("disconnected");
|
|
1946
1974
|
this.subscriptions.clear();
|
|
1947
|
-
this.clearPendingCommands();
|
|
1948
1975
|
}
|
|
1949
1976
|
/**
|
|
1950
|
-
* Subscribe to events matching a filter
|
|
1977
|
+
* Subscribe to events matching a filter.
|
|
1978
|
+
*
|
|
1979
|
+
* The server applies filtering itself and sends no acknowledgement, so this
|
|
1980
|
+
* resolves as soon as the command has been written to the socket. The filter
|
|
1981
|
+
* is tracked locally so it is replayed automatically on reconnect.
|
|
1951
1982
|
*/
|
|
1952
1983
|
async subscribe(filter) {
|
|
1953
1984
|
const filterId = this.filterToId(filter);
|
|
@@ -1956,11 +1987,13 @@ var WebSocketRealtimeClient = class {
|
|
|
1956
1987
|
}
|
|
1957
1988
|
this.subscriptions.set(filterId, filter);
|
|
1958
1989
|
if (this.state === "connected") {
|
|
1959
|
-
|
|
1990
|
+
this.sendCommand("Subscribe", filter);
|
|
1960
1991
|
}
|
|
1961
1992
|
}
|
|
1962
1993
|
/**
|
|
1963
|
-
* Unsubscribe from events matching a filter
|
|
1994
|
+
* Unsubscribe from events matching a filter.
|
|
1995
|
+
*
|
|
1996
|
+
* Fire-and-forget, like {@link subscribe} — the server sends no ack.
|
|
1964
1997
|
*/
|
|
1965
1998
|
async unsubscribe(filter) {
|
|
1966
1999
|
const filterId = this.filterToId(filter);
|
|
@@ -1969,7 +2002,7 @@ var WebSocketRealtimeClient = class {
|
|
|
1969
2002
|
}
|
|
1970
2003
|
this.subscriptions.delete(filterId);
|
|
1971
2004
|
if (this.state === "connected") {
|
|
1972
|
-
|
|
2005
|
+
this.sendCommand("Unsubscribe", filter);
|
|
1973
2006
|
}
|
|
1974
2007
|
}
|
|
1975
2008
|
/**
|
|
@@ -2022,13 +2055,11 @@ var WebSocketRealtimeClient = class {
|
|
|
2022
2055
|
handleMessage(data) {
|
|
2023
2056
|
try {
|
|
2024
2057
|
const message = convertResponse(JSON.parse(data));
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
return;
|
|
2028
|
-
}
|
|
2058
|
+
const eventType = mapEventType(String(message.type));
|
|
2059
|
+
message.type = eventType;
|
|
2029
2060
|
const event = message;
|
|
2030
|
-
this.options.debug(`Received event: ${
|
|
2031
|
-
const handlers = this.eventHandlers.get(
|
|
2061
|
+
this.options.debug(`Received event: ${eventType}`, event);
|
|
2062
|
+
const handlers = this.eventHandlers.get(eventType);
|
|
2032
2063
|
if (handlers) {
|
|
2033
2064
|
const eventData = event.data;
|
|
2034
2065
|
handlers.forEach((handler) => {
|
|
@@ -2050,25 +2081,8 @@ var WebSocketRealtimeClient = class {
|
|
|
2050
2081
|
this.options.debug("Failed to parse message", { data, error });
|
|
2051
2082
|
}
|
|
2052
2083
|
}
|
|
2053
|
-
handleCommandResponse(response) {
|
|
2054
|
-
if (!response.requestId) {
|
|
2055
|
-
return;
|
|
2056
|
-
}
|
|
2057
|
-
const pending = this.pendingCommands.get(response.requestId);
|
|
2058
|
-
if (!pending) {
|
|
2059
|
-
return;
|
|
2060
|
-
}
|
|
2061
|
-
clearTimeout(pending.timeout);
|
|
2062
|
-
this.pendingCommands.delete(response.requestId);
|
|
2063
|
-
if (response.type === "error") {
|
|
2064
|
-
pending.reject(new Error(response.error || "Unknown error"));
|
|
2065
|
-
} else {
|
|
2066
|
-
pending.resolve();
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
2084
|
handleDisconnect() {
|
|
2070
2085
|
this.ws = null;
|
|
2071
|
-
this.clearPendingCommands();
|
|
2072
2086
|
if (this.options.autoReconnect && this.reconnectAttempts < this.options.maxReconnectAttempts) {
|
|
2073
2087
|
this.scheduleReconnect();
|
|
2074
2088
|
} else {
|
|
@@ -2092,43 +2106,37 @@ var WebSocketRealtimeClient = class {
|
|
|
2092
2106
|
}
|
|
2093
2107
|
}, delay);
|
|
2094
2108
|
}
|
|
2095
|
-
|
|
2109
|
+
resubscribeAll() {
|
|
2096
2110
|
for (const filter of this.subscriptions.values()) {
|
|
2097
2111
|
try {
|
|
2098
|
-
|
|
2112
|
+
this.sendCommand("Subscribe", filter);
|
|
2099
2113
|
} catch (error) {
|
|
2100
2114
|
this.options.debug("Failed to resubscribe", { filter, error });
|
|
2101
2115
|
}
|
|
2102
2116
|
}
|
|
2103
2117
|
}
|
|
2104
|
-
|
|
2118
|
+
/**
|
|
2119
|
+
* Send a subscribe/unsubscribe command to the server.
|
|
2120
|
+
*
|
|
2121
|
+
* The backend `ClientCommand` shape is `{ cmd, queue, job_id }` and it sends
|
|
2122
|
+
* no acknowledgement, so this is fire-and-forget — it writes to the socket
|
|
2123
|
+
* and returns. The `SubscriptionFilter`'s `workerId`/`scheduleId` have no
|
|
2124
|
+
* server-side equivalent and are ignored.
|
|
2125
|
+
*/
|
|
2126
|
+
sendCommand(cmd, filter) {
|
|
2105
2127
|
if (!this.ws || this.state !== "connected") {
|
|
2106
2128
|
throw new Error("WebSocket not connected");
|
|
2107
2129
|
}
|
|
2108
|
-
const
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
}, 1e4);
|
|
2115
|
-
this.pendingCommands.set(requestId, { resolve, reject, timeout });
|
|
2116
|
-
this.ws.send(JSON.stringify(fullCommand));
|
|
2117
|
-
});
|
|
2118
|
-
}
|
|
2119
|
-
clearPendingCommands() {
|
|
2120
|
-
for (const pending of this.pendingCommands.values()) {
|
|
2121
|
-
clearTimeout(pending.timeout);
|
|
2122
|
-
pending.reject(new Error("Connection closed"));
|
|
2123
|
-
}
|
|
2124
|
-
this.pendingCommands.clear();
|
|
2130
|
+
const command = {
|
|
2131
|
+
cmd,
|
|
2132
|
+
queue: filter.queueName,
|
|
2133
|
+
job_id: filter.jobId
|
|
2134
|
+
};
|
|
2135
|
+
this.ws.send(JSON.stringify(command));
|
|
2125
2136
|
}
|
|
2126
2137
|
filterToId(filter) {
|
|
2127
2138
|
return JSON.stringify(filter);
|
|
2128
2139
|
}
|
|
2129
|
-
generateRequestId() {
|
|
2130
|
-
return `req_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
|
|
2131
|
-
}
|
|
2132
2140
|
};
|
|
2133
2141
|
function redactToken(url) {
|
|
2134
2142
|
return url.replace(/([?&](?:token|api_key)=)[^&]*/gi, "$1***");
|
|
@@ -2327,9 +2335,12 @@ var SseRealtimeClient = class {
|
|
|
2327
2335
|
}
|
|
2328
2336
|
handleMessage(data) {
|
|
2329
2337
|
try {
|
|
2330
|
-
const
|
|
2331
|
-
|
|
2332
|
-
|
|
2338
|
+
const parsed = convertResponse(JSON.parse(data));
|
|
2339
|
+
const eventType = mapEventType(String(parsed.type));
|
|
2340
|
+
parsed.type = eventType;
|
|
2341
|
+
const event = parsed;
|
|
2342
|
+
this.options.debug(`Received SSE event: ${eventType}`, event);
|
|
2343
|
+
const handlers = this.eventHandlers.get(eventType);
|
|
2333
2344
|
if (handlers) {
|
|
2334
2345
|
const eventData = event.data;
|
|
2335
2346
|
handlers.forEach((handler) => {
|
|
@@ -3253,7 +3264,7 @@ var SpooledWorker = class {
|
|
|
3253
3264
|
...DEFAULT_OPTIONS,
|
|
3254
3265
|
hostname: hostname(),
|
|
3255
3266
|
workerType: "nodejs",
|
|
3256
|
-
version: "1.0.
|
|
3267
|
+
version: "1.0.34",
|
|
3257
3268
|
metadata: {},
|
|
3258
3269
|
...options
|
|
3259
3270
|
};
|
|
@@ -3498,7 +3509,8 @@ var SpooledWorker = class {
|
|
|
3498
3509
|
try {
|
|
3499
3510
|
await this.client.jobs.complete(job.id, {
|
|
3500
3511
|
workerId: this.workerId,
|
|
3501
|
-
result
|
|
3512
|
+
result,
|
|
3513
|
+
...job.leaseId !== void 0 && { leaseId: job.leaseId }
|
|
3502
3514
|
});
|
|
3503
3515
|
this.emit("job:completed", {
|
|
3504
3516
|
jobId: job.id,
|
|
@@ -3515,7 +3527,8 @@ var SpooledWorker = class {
|
|
|
3515
3527
|
try {
|
|
3516
3528
|
await this.client.jobs.fail(job.id, {
|
|
3517
3529
|
workerId: this.workerId,
|
|
3518
|
-
error: errorMessage
|
|
3530
|
+
error: errorMessage,
|
|
3531
|
+
...job.leaseId !== void 0 && { leaseId: job.leaseId }
|
|
3519
3532
|
});
|
|
3520
3533
|
this.emit("job:failed", {
|
|
3521
3534
|
jobId: job.id,
|
|
@@ -3536,10 +3549,12 @@ var SpooledWorker = class {
|
|
|
3536
3549
|
}
|
|
3537
3550
|
async sendJobHeartbeat(jobId) {
|
|
3538
3551
|
if (!this.workerId) return;
|
|
3552
|
+
const leaseId = this.activeJobs.get(jobId)?.job.leaseId;
|
|
3539
3553
|
try {
|
|
3540
3554
|
await this.client.jobs.heartbeat(jobId, {
|
|
3541
3555
|
workerId: this.workerId,
|
|
3542
|
-
leaseDurationSecs: this.options.leaseDuration
|
|
3556
|
+
leaseDurationSecs: this.options.leaseDuration,
|
|
3557
|
+
...leaseId !== void 0 && { leaseId }
|
|
3543
3558
|
});
|
|
3544
3559
|
} catch (error) {
|
|
3545
3560
|
this.debug(`Job heartbeat failed for ${jobId}`, error);
|