@spooled/sdk 1.0.31 → 1.0.33
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-CfLL1w6Y.d.cts → index-QIsnz4Bc.d.cts} +23 -3
- package/dist/{index-CfLL1w6Y.d.ts → index-QIsnz4Bc.d.ts} +23 -3
- package/dist/index.cjs +90 -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 +90 -72
- 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-QIsnz4Bc.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-QIsnz4Bc.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-QIsnz4Bc.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-QIsnz4Bc.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,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.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
|
+
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,
|
|
@@ -296,22 +303,33 @@ function parseRateLimitHeaders(headers) {
|
|
|
296
303
|
}
|
|
297
304
|
return info;
|
|
298
305
|
}
|
|
306
|
+
var MAX_RAW_ERROR_BODY_CHARS = 500;
|
|
299
307
|
async function parseErrorBody(response) {
|
|
300
308
|
const contentType = response.headers.get("Content-Type") || "";
|
|
301
|
-
|
|
309
|
+
let raw;
|
|
310
|
+
try {
|
|
311
|
+
raw = await response.text();
|
|
312
|
+
} catch {
|
|
302
313
|
return null;
|
|
303
314
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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 {
|
|
313
327
|
}
|
|
314
|
-
}
|
|
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 };
|
|
315
333
|
}
|
|
316
334
|
return null;
|
|
317
335
|
}
|
|
@@ -1817,6 +1835,24 @@ var WebhookIngestionResource = class {
|
|
|
1817
1835
|
}
|
|
1818
1836
|
};
|
|
1819
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
|
+
|
|
1820
1856
|
// src/realtime/websocket.ts
|
|
1821
1857
|
var WebSocketRealtimeClient = class {
|
|
1822
1858
|
options;
|
|
@@ -1832,7 +1868,6 @@ var WebSocketRealtimeClient = class {
|
|
|
1832
1868
|
*/
|
|
1833
1869
|
authFailure = false;
|
|
1834
1870
|
subscriptions = /* @__PURE__ */ new Map();
|
|
1835
|
-
pendingCommands = /* @__PURE__ */ new Map();
|
|
1836
1871
|
// Event handlers
|
|
1837
1872
|
eventHandlers = /* @__PURE__ */ new Map();
|
|
1838
1873
|
allEventsHandlers = /* @__PURE__ */ new Set();
|
|
@@ -1937,10 +1972,13 @@ var WebSocketRealtimeClient = class {
|
|
|
1937
1972
|
}
|
|
1938
1973
|
this.setState("disconnected");
|
|
1939
1974
|
this.subscriptions.clear();
|
|
1940
|
-
this.clearPendingCommands();
|
|
1941
1975
|
}
|
|
1942
1976
|
/**
|
|
1943
|
-
* 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.
|
|
1944
1982
|
*/
|
|
1945
1983
|
async subscribe(filter) {
|
|
1946
1984
|
const filterId = this.filterToId(filter);
|
|
@@ -1949,11 +1987,13 @@ var WebSocketRealtimeClient = class {
|
|
|
1949
1987
|
}
|
|
1950
1988
|
this.subscriptions.set(filterId, filter);
|
|
1951
1989
|
if (this.state === "connected") {
|
|
1952
|
-
|
|
1990
|
+
this.sendCommand("Subscribe", filter);
|
|
1953
1991
|
}
|
|
1954
1992
|
}
|
|
1955
1993
|
/**
|
|
1956
|
-
* 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.
|
|
1957
1997
|
*/
|
|
1958
1998
|
async unsubscribe(filter) {
|
|
1959
1999
|
const filterId = this.filterToId(filter);
|
|
@@ -1962,7 +2002,7 @@ var WebSocketRealtimeClient = class {
|
|
|
1962
2002
|
}
|
|
1963
2003
|
this.subscriptions.delete(filterId);
|
|
1964
2004
|
if (this.state === "connected") {
|
|
1965
|
-
|
|
2005
|
+
this.sendCommand("Unsubscribe", filter);
|
|
1966
2006
|
}
|
|
1967
2007
|
}
|
|
1968
2008
|
/**
|
|
@@ -2015,13 +2055,11 @@ var WebSocketRealtimeClient = class {
|
|
|
2015
2055
|
handleMessage(data) {
|
|
2016
2056
|
try {
|
|
2017
2057
|
const message = convertResponse(JSON.parse(data));
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
return;
|
|
2021
|
-
}
|
|
2058
|
+
const eventType = mapEventType(String(message.type));
|
|
2059
|
+
message.type = eventType;
|
|
2022
2060
|
const event = message;
|
|
2023
|
-
this.options.debug(`Received event: ${
|
|
2024
|
-
const handlers = this.eventHandlers.get(
|
|
2061
|
+
this.options.debug(`Received event: ${eventType}`, event);
|
|
2062
|
+
const handlers = this.eventHandlers.get(eventType);
|
|
2025
2063
|
if (handlers) {
|
|
2026
2064
|
const eventData = event.data;
|
|
2027
2065
|
handlers.forEach((handler) => {
|
|
@@ -2043,25 +2081,8 @@ var WebSocketRealtimeClient = class {
|
|
|
2043
2081
|
this.options.debug("Failed to parse message", { data, error });
|
|
2044
2082
|
}
|
|
2045
2083
|
}
|
|
2046
|
-
handleCommandResponse(response) {
|
|
2047
|
-
if (!response.requestId) {
|
|
2048
|
-
return;
|
|
2049
|
-
}
|
|
2050
|
-
const pending = this.pendingCommands.get(response.requestId);
|
|
2051
|
-
if (!pending) {
|
|
2052
|
-
return;
|
|
2053
|
-
}
|
|
2054
|
-
clearTimeout(pending.timeout);
|
|
2055
|
-
this.pendingCommands.delete(response.requestId);
|
|
2056
|
-
if (response.type === "error") {
|
|
2057
|
-
pending.reject(new Error(response.error || "Unknown error"));
|
|
2058
|
-
} else {
|
|
2059
|
-
pending.resolve();
|
|
2060
|
-
}
|
|
2061
|
-
}
|
|
2062
2084
|
handleDisconnect() {
|
|
2063
2085
|
this.ws = null;
|
|
2064
|
-
this.clearPendingCommands();
|
|
2065
2086
|
if (this.options.autoReconnect && this.reconnectAttempts < this.options.maxReconnectAttempts) {
|
|
2066
2087
|
this.scheduleReconnect();
|
|
2067
2088
|
} else {
|
|
@@ -2085,43 +2106,37 @@ var WebSocketRealtimeClient = class {
|
|
|
2085
2106
|
}
|
|
2086
2107
|
}, delay);
|
|
2087
2108
|
}
|
|
2088
|
-
|
|
2109
|
+
resubscribeAll() {
|
|
2089
2110
|
for (const filter of this.subscriptions.values()) {
|
|
2090
2111
|
try {
|
|
2091
|
-
|
|
2112
|
+
this.sendCommand("Subscribe", filter);
|
|
2092
2113
|
} catch (error) {
|
|
2093
2114
|
this.options.debug("Failed to resubscribe", { filter, error });
|
|
2094
2115
|
}
|
|
2095
2116
|
}
|
|
2096
2117
|
}
|
|
2097
|
-
|
|
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) {
|
|
2098
2127
|
if (!this.ws || this.state !== "connected") {
|
|
2099
2128
|
throw new Error("WebSocket not connected");
|
|
2100
2129
|
}
|
|
2101
|
-
const
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
}, 1e4);
|
|
2108
|
-
this.pendingCommands.set(requestId, { resolve, reject, timeout });
|
|
2109
|
-
this.ws.send(JSON.stringify(fullCommand));
|
|
2110
|
-
});
|
|
2111
|
-
}
|
|
2112
|
-
clearPendingCommands() {
|
|
2113
|
-
for (const pending of this.pendingCommands.values()) {
|
|
2114
|
-
clearTimeout(pending.timeout);
|
|
2115
|
-
pending.reject(new Error("Connection closed"));
|
|
2116
|
-
}
|
|
2117
|
-
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));
|
|
2118
2136
|
}
|
|
2119
2137
|
filterToId(filter) {
|
|
2120
2138
|
return JSON.stringify(filter);
|
|
2121
2139
|
}
|
|
2122
|
-
generateRequestId() {
|
|
2123
|
-
return `req_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
|
|
2124
|
-
}
|
|
2125
2140
|
};
|
|
2126
2141
|
function redactToken(url) {
|
|
2127
2142
|
return url.replace(/([?&](?:token|api_key)=)[^&]*/gi, "$1***");
|
|
@@ -2320,9 +2335,12 @@ var SseRealtimeClient = class {
|
|
|
2320
2335
|
}
|
|
2321
2336
|
handleMessage(data) {
|
|
2322
2337
|
try {
|
|
2323
|
-
const
|
|
2324
|
-
|
|
2325
|
-
|
|
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);
|
|
2326
2344
|
if (handlers) {
|
|
2327
2345
|
const eventData = event.data;
|
|
2328
2346
|
handlers.forEach((handler) => {
|