@hatchet-dev/typescript-sdk 1.27.0 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { Channel, ClientFactory } from 'nice-grpc';
2
- import { DispatcherClient as PbDispatcherClient, StepActionEvent, GroupKeyActionEvent, OverridesData, DeepPartial, WorkerLabels as PbWorkerAffinityConfig, RuntimeInfo } from '../../protoc/dispatcher';
2
+ import { DispatcherClient as PbDispatcherClient, StepActionEvent, BatchActionEvent, GroupKeyActionEvent, OverridesData, DeepPartial, WorkerLabels as PbWorkerAffinityConfig, RuntimeInfo } from '../../protoc/dispatcher';
3
3
  import { ClientConfig } from '../hatchet-client/client-config';
4
4
  import { Logger } from '../../util/logger';
5
5
  import { SlotConfig } from '../../v1/slot-types';
@@ -37,6 +37,11 @@ export declare class DispatcherClient {
37
37
  */
38
38
  getVersion(): Promise<string>;
39
39
  sendStepActionEvent(in_: StepActionEventInput): Promise<import("../../protoc/dispatcher").ActionEventResponse>;
40
+ /**
41
+ * Reports a lifecycle event (STARTED, COMPLETED, or FAILED) covering one or more
42
+ * members of a batch task's execution.
43
+ */
44
+ sendBatchActionEvent(in_: BatchActionEvent): Promise<import("../../protoc/dispatcher").ActionEventResponse>;
40
45
  sendGroupKeyActionEvent(in_: GroupKeyActionEvent): Promise<import("../../protoc/dispatcher").ActionEventResponse>;
41
46
  putOverridesData(in_: DeepPartial<OverridesData>): Promise<void | import("../../protoc/dispatcher").OverridesDataResponse>;
42
47
  refreshTimeout(incrementTimeoutBy: string, taskRunExternalId: string): Promise<import("../../protoc/dispatcher").RefreshTimeoutResponse>;
@@ -83,6 +83,20 @@ class DispatcherClient {
83
83
  }
84
84
  });
85
85
  }
86
+ /**
87
+ * Reports a lifecycle event (STARTED, COMPLETED, or FAILED) covering one or more
88
+ * members of a batch task's execution.
89
+ */
90
+ sendBatchActionEvent(in_) {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ try {
93
+ return yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () { return this.client.sendBatchActionEvent(in_); }), this.logger);
94
+ }
95
+ catch (e) {
96
+ throw (0, hatchet_error_1.toHatchetError)(e);
97
+ }
98
+ });
99
+ }
86
100
  sendGroupKeyActionEvent(in_) {
87
101
  return __awaiter(this, void 0, void 0, function* () {
88
102
  try {
@@ -1958,6 +1958,8 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
1958
1958
  limit?: number;
1959
1959
  /** Filter by worker status */
1960
1960
  statuses?: WorkerStatus[];
1961
+ /** Filter by worker labels */
1962
+ labels?: string[];
1961
1963
  }, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkerList, any, {}>>;
1962
1964
  /**
1963
1965
  * @description Update a worker
@@ -281,6 +281,8 @@ export declare enum V1TaskEventType {
281
281
  CREATED = "CREATED",
282
282
  QUEUED = "QUEUED",
283
283
  SKIPPED = "SKIPPED",
284
+ WAITING_FOR_BATCH = "WAITING_FOR_BATCH",
285
+ BATCH_FLUSHED = "BATCH_FLUSHED",
284
286
  COULD_NOT_SEND_TO_WORKER = "COULD_NOT_SEND_TO_WORKER",
285
287
  DURABLE_EVICTED = "DURABLE_EVICTED",
286
288
  DURABLE_RESTORING = "DURABLE_RESTORING"
@@ -342,6 +342,8 @@ var V1TaskEventType;
342
342
  V1TaskEventType["CREATED"] = "CREATED";
343
343
  V1TaskEventType["QUEUED"] = "QUEUED";
344
344
  V1TaskEventType["SKIPPED"] = "SKIPPED";
345
+ V1TaskEventType["WAITING_FOR_BATCH"] = "WAITING_FOR_BATCH";
346
+ V1TaskEventType["BATCH_FLUSHED"] = "BATCH_FLUSHED";
345
347
  V1TaskEventType["COULD_NOT_SEND_TO_WORKER"] = "COULD_NOT_SEND_TO_WORKER";
346
348
  V1TaskEventType["DURABLE_EVICTED"] = "DURABLE_EVICTED";
347
349
  V1TaskEventType["DURABLE_RESTORING"] = "DURABLE_RESTORING";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "1.27.0",
3
+ "version": "1.28.0",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -15,6 +15,7 @@ export declare enum ActionType {
15
15
  START_STEP_RUN = 0,
16
16
  CANCEL_STEP_RUN = 1,
17
17
  START_GET_GROUP_KEY = 2,
18
+ START_BATCH = 3,
18
19
  UNRECOGNIZED = -1
19
20
  }
20
21
  export declare function actionTypeFromJSON(object: any): ActionType;
@@ -34,6 +35,7 @@ export declare enum StepActionEventType {
34
35
  STEP_EVENT_TYPE_COMPLETED = 2,
35
36
  STEP_EVENT_TYPE_FAILED = 3,
36
37
  STEP_EVENT_TYPE_ACKNOWLEDGED = 4,
38
+ STEP_EVENT_TYPE_CANCELLED = 5,
37
39
  UNRECOGNIZED = -1
38
40
  }
39
41
  export declare function stepActionEventTypeFromJSON(object: any): StepActionEventType;
@@ -182,6 +184,21 @@ export interface AssignedAction {
182
184
  triggeringEventExternalId?: string | undefined;
183
185
  /** (optional) the key of the event that triggered this workflow run (if any) */
184
186
  triggeringEventKey?: string | undefined;
187
+ /** (optional) the batch identifier if this task is part of a batch */
188
+ batchId?: string | undefined;
189
+ /** (optional) the total number of tasks in the batch */
190
+ batchSize?: number | undefined;
191
+ /** (optional) the index of the task within the batch */
192
+ batchIndex?: number | undefined;
193
+ /** (optional) payload for starting a batch execution */
194
+ batchStartPayload?: BatchStartPayload | undefined;
195
+ /** (optional) the partition key used for batching */
196
+ batchKey?: string | undefined;
197
+ }
198
+ export interface BatchStartPayload {
199
+ triggerReason: string;
200
+ triggerTime: Date | undefined;
201
+ expectedSize: number;
185
202
  }
186
203
  export interface WorkerListenRequest {
187
204
  /** the id of the worker */
@@ -234,6 +251,31 @@ export interface StepActionEvent {
234
251
  /** a flag indicating if the task should _not_ be retried */
235
252
  shouldNotRetry?: boolean | undefined;
236
253
  }
254
+ export interface BatchActionEventItem {
255
+ /** the task external run id */
256
+ taskRunExternalId: string;
257
+ /** the event payload (e.g. serialized error for FAILED; unused for STARTED/CANCELLED) */
258
+ eventPayload: string;
259
+ /** the retry count (falls back to the task's current retry count if unset) */
260
+ retryCount?: number | undefined;
261
+ /** a flag indicating if the task should _not_ be retried (FAILED only) */
262
+ shouldNotRetry?: boolean | undefined;
263
+ }
264
+ export interface BatchActionEvent {
265
+ /** the id of the worker */
266
+ workerId: string;
267
+ /** the id of the job (shared across all items in the batch) */
268
+ jobId: string;
269
+ /** the action id (shared across all items in the batch) */
270
+ actionId: string;
271
+ /** (optional) the batch identifier, for observability */
272
+ batchId?: string | undefined;
273
+ eventTimestamp: Date | undefined;
274
+ /** the task event type -- applies uniformly to every item in this batch */
275
+ eventType: StepActionEventType;
276
+ /** the items in this batch */
277
+ items: BatchActionEventItem[];
278
+ }
237
279
  export interface ActionEventResponse {
238
280
  /** the tenant id */
239
281
  tenantId: string;
@@ -341,11 +383,14 @@ export declare const UpsertWorkerLabelsRequest: MessageFns<UpsertWorkerLabelsReq
341
383
  export declare const UpsertWorkerLabelsRequest_LabelsEntry: MessageFns<UpsertWorkerLabelsRequest_LabelsEntry>;
342
384
  export declare const UpsertWorkerLabelsResponse: MessageFns<UpsertWorkerLabelsResponse>;
343
385
  export declare const AssignedAction: MessageFns<AssignedAction>;
386
+ export declare const BatchStartPayload: MessageFns<BatchStartPayload>;
344
387
  export declare const WorkerListenRequest: MessageFns<WorkerListenRequest>;
345
388
  export declare const WorkerUnsubscribeRequest: MessageFns<WorkerUnsubscribeRequest>;
346
389
  export declare const WorkerUnsubscribeResponse: MessageFns<WorkerUnsubscribeResponse>;
347
390
  export declare const GroupKeyActionEvent: MessageFns<GroupKeyActionEvent>;
348
391
  export declare const StepActionEvent: MessageFns<StepActionEvent>;
392
+ export declare const BatchActionEventItem: MessageFns<BatchActionEventItem>;
393
+ export declare const BatchActionEvent: MessageFns<BatchActionEvent>;
349
394
  export declare const ActionEventResponse: MessageFns<ActionEventResponse>;
350
395
  export declare const SubscribeToWorkflowEventsRequest: MessageFns<SubscribeToWorkflowEventsRequest>;
351
396
  export declare const SubscribeToWorkflowRunsRequest: MessageFns<SubscribeToWorkflowRunsRequest>;
@@ -430,6 +475,18 @@ export declare const DispatcherDefinition: {
430
475
  readonly responseStream: false;
431
476
  readonly options: {};
432
477
  };
478
+ /**
479
+ * SendBatchActionEvent reports a single lifecycle event (STARTED, FAILED, or CANCELLED)
480
+ * for every task in a batch in one call, instead of one SendStepActionEvent call per task.
481
+ */
482
+ readonly sendBatchActionEvent: {
483
+ readonly name: "SendBatchActionEvent";
484
+ readonly requestType: typeof BatchActionEvent;
485
+ readonly requestStream: false;
486
+ readonly responseType: typeof ActionEventResponse;
487
+ readonly responseStream: false;
488
+ readonly options: {};
489
+ };
433
490
  readonly sendGroupKeyActionEvent: {
434
491
  readonly name: "SendGroupKeyActionEvent";
435
492
  readonly requestType: typeof GroupKeyActionEvent;
@@ -514,6 +571,11 @@ export interface DispatcherServiceImplementation<CallContextExt = {}> {
514
571
  subscribeToWorkflowEvents(request: SubscribeToWorkflowEventsRequest, context: CallContext & CallContextExt): ServerStreamingMethodResult<DeepPartial<WorkflowEvent>>;
515
572
  subscribeToWorkflowRuns(request: AsyncIterable<SubscribeToWorkflowRunsRequest>, context: CallContext & CallContextExt): ServerStreamingMethodResult<DeepPartial<WorkflowRunEvent>>;
516
573
  sendStepActionEvent(request: StepActionEvent, context: CallContext & CallContextExt): Promise<DeepPartial<ActionEventResponse>>;
574
+ /**
575
+ * SendBatchActionEvent reports a single lifecycle event (STARTED, FAILED, or CANCELLED)
576
+ * for every task in a batch in one call, instead of one SendStepActionEvent call per task.
577
+ */
578
+ sendBatchActionEvent(request: BatchActionEvent, context: CallContext & CallContextExt): Promise<DeepPartial<ActionEventResponse>>;
517
579
  sendGroupKeyActionEvent(request: GroupKeyActionEvent, context: CallContext & CallContextExt): Promise<DeepPartial<ActionEventResponse>>;
518
580
  putOverridesData(request: OverridesData, context: CallContext & CallContextExt): Promise<DeepPartial<OverridesDataResponse>>;
519
581
  unsubscribe(request: WorkerUnsubscribeRequest, context: CallContext & CallContextExt): Promise<DeepPartial<WorkerUnsubscribeResponse>>;
@@ -541,6 +603,11 @@ export interface DispatcherClient<CallOptionsExt = {}> {
541
603
  subscribeToWorkflowEvents(request: DeepPartial<SubscribeToWorkflowEventsRequest>, options?: CallOptions & CallOptionsExt): AsyncIterable<WorkflowEvent>;
542
604
  subscribeToWorkflowRuns(request: AsyncIterable<DeepPartial<SubscribeToWorkflowRunsRequest>>, options?: CallOptions & CallOptionsExt): AsyncIterable<WorkflowRunEvent>;
543
605
  sendStepActionEvent(request: DeepPartial<StepActionEvent>, options?: CallOptions & CallOptionsExt): Promise<ActionEventResponse>;
606
+ /**
607
+ * SendBatchActionEvent reports a single lifecycle event (STARTED, FAILED, or CANCELLED)
608
+ * for every task in a batch in one call, instead of one SendStepActionEvent call per task.
609
+ */
610
+ sendBatchActionEvent(request: DeepPartial<BatchActionEvent>, options?: CallOptions & CallOptionsExt): Promise<ActionEventResponse>;
544
611
  sendGroupKeyActionEvent(request: DeepPartial<GroupKeyActionEvent>, options?: CallOptions & CallOptionsExt): Promise<ActionEventResponse>;
545
612
  putOverridesData(request: DeepPartial<OverridesData>, options?: CallOptions & CallOptionsExt): Promise<OverridesDataResponse>;
546
613
  unsubscribe(request: DeepPartial<WorkerUnsubscribeRequest>, options?: CallOptions & CallOptionsExt): Promise<WorkerUnsubscribeResponse>;