@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.
- package/clients/dispatcher/dispatcher-client.d.ts +6 -1
- package/clients/dispatcher/dispatcher-client.js +14 -0
- package/clients/rest/generated/Api.d.ts +2 -0
- package/clients/rest/generated/data-contracts.d.ts +2 -0
- package/clients/rest/generated/data-contracts.js +2 -0
- package/package.json +1 -1
- package/protoc/dispatcher/dispatcher.d.ts +67 -0
- package/protoc/dispatcher/dispatcher.js +495 -3
- package/protoc/events/events.js +1 -1
- package/protoc/google/protobuf/any.js +1 -1
- package/protoc/google/protobuf/timestamp.js +1 -1
- package/protoc/google/rpc/status.js +1 -1
- package/protoc/v1/dispatcher.js +1 -1
- package/protoc/v1/shared/condition.js +1 -1
- package/protoc/v1/shared/trigger.js +1 -1
- package/protoc/v1/workflows.d.ts +24 -7
- package/protoc/v1/workflows.js +218 -40
- package/protoc/workflows/workflows.js +1 -1
- package/util/workflow-run-ref.js +23 -9
- package/v1/client/client.d.ts +26 -1
- package/v1/client/client.js +6 -0
- package/v1/client/worker/context.js +23 -3
- package/v1/client/worker/worker-internal.d.ts +22 -1
- package/v1/client/worker/worker-internal.js +167 -2
- package/v1/declaration.d.ts +62 -2
- package/v1/declaration.js +56 -0
- package/v1/examples/batch_assign/workflow.d.ts +62 -0
- package/v1/examples/batch_assign/workflow.js +161 -0
- package/v1/examples/e2e-worker.js +35 -21
- package/v1/task.d.ts +50 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -37,13 +37,14 @@ const workflow_16 = require("./on_event/workflow");
|
|
|
37
37
|
const workflow_17 = require("./return_exceptions/workflow");
|
|
38
38
|
const workflow_18 = require("./run_details/workflow");
|
|
39
39
|
const e2e_workflows_1 = require("./simple/e2e-workflows");
|
|
40
|
-
const workflow_19 = require("./
|
|
41
|
-
const workflow_20 = require("./
|
|
42
|
-
const workflow_21 = require("./
|
|
43
|
-
const workflow_22 = require("./
|
|
44
|
-
const workflow_23 = require("./
|
|
45
|
-
const workflow_24 = require("./
|
|
46
|
-
const workflow_25 = require("./
|
|
40
|
+
const workflow_19 = require("./batch_assign/workflow");
|
|
41
|
+
const workflow_20 = require("./streaming/workflow");
|
|
42
|
+
const workflow_21 = require("./timeout/workflow");
|
|
43
|
+
const workflow_22 = require("./webhooks/workflow");
|
|
44
|
+
const workflow_23 = require("./child_index/workflow");
|
|
45
|
+
const workflow_24 = require("./support_agent/workflow");
|
|
46
|
+
const workflow_25 = require("./welcome_email/workflow");
|
|
47
|
+
const workflow_26 = require("./pdf_pipeline/workflow");
|
|
47
48
|
const workflows = [
|
|
48
49
|
workflow_1.bulkChild,
|
|
49
50
|
workflow_1.bulkParentWorkflow,
|
|
@@ -94,20 +95,33 @@ const workflows = [
|
|
|
94
95
|
workflow_18.runDetailTestWorkflow,
|
|
95
96
|
e2e_workflows_1.helloWorld,
|
|
96
97
|
e2e_workflows_1.helloWorldDurable,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
98
|
+
workflow_20.streamingTask,
|
|
99
|
+
workflow_21.timeoutTask,
|
|
100
|
+
workflow_21.refreshTimeoutTask,
|
|
101
|
+
workflow_22.webhookWorkflow,
|
|
102
|
+
workflow_23.childIndexChild,
|
|
103
|
+
workflow_23.childIndexParent,
|
|
104
|
+
workflow_23.scenarioTask,
|
|
105
|
+
workflow_23.orchestratorTask,
|
|
106
|
+
workflow_24.supportAgent,
|
|
107
|
+
workflow_24.triageTicket,
|
|
108
|
+
workflow_24.generateReply,
|
|
109
|
+
workflow_24.escalateTicket,
|
|
110
|
+
workflow_25.welcomeEmail,
|
|
111
|
+
workflow_26.pdfPipeline,
|
|
112
|
+
workflow_19.batchSimple,
|
|
113
|
+
workflow_19.batchKeyed,
|
|
114
|
+
workflow_19.batchKeyedFailable,
|
|
115
|
+
workflow_19.batchKeyedInterval,
|
|
116
|
+
workflow_19.batchLarge,
|
|
117
|
+
workflow_19.batchSingle,
|
|
118
|
+
workflow_19.batchOrdered,
|
|
119
|
+
workflow_19.batchBroadcast,
|
|
120
|
+
workflow_19.batchCancel,
|
|
121
|
+
workflow_19.child,
|
|
122
|
+
workflow_19.childBatch,
|
|
123
|
+
workflow_19.batchChildSpawn,
|
|
124
|
+
workflow_19.batchChildBatchSpawn,
|
|
111
125
|
];
|
|
112
126
|
function main() {
|
|
113
127
|
return __awaiter(this, void 0, void 0, function* () {
|
package/v1/task.d.ts
CHANGED
|
@@ -77,6 +77,48 @@ export declare class NonRetryableError extends Error {
|
|
|
77
77
|
}
|
|
78
78
|
export type TaskFn<I extends InputType = UnknownInputType, O extends OutputType = void, C = Context<I>> = (input: I, ctx: C) => O | Promise<O>;
|
|
79
79
|
export type DurableTaskFn<I extends InputType = UnknownInputType, O extends OutputType = void> = TaskFn<I, O, DurableContext<I>>;
|
|
80
|
+
/**
|
|
81
|
+
* Configures a task as a batch task: concurrent runs are buffered and dispatched together
|
|
82
|
+
* as a single execution once maxSize is reached, maxInterval elapses, or (if groupKey is
|
|
83
|
+
* set) once groupMaxRuns concurrent batches per group are exceeded.
|
|
84
|
+
*
|
|
85
|
+
* Preview: batch tasks are in beta and may change in future releases.
|
|
86
|
+
*/
|
|
87
|
+
export type BatchTaskConfig = {
|
|
88
|
+
/**
|
|
89
|
+
* Maximum number of items buffered before the batch is flushed. Must be positive.
|
|
90
|
+
*/
|
|
91
|
+
maxSize: number;
|
|
92
|
+
/**
|
|
93
|
+
* (optional) maximum time to wait before flushing a partially-filled batch.
|
|
94
|
+
* go duration format (e.g., "1s", "5m", "1h").
|
|
95
|
+
*/
|
|
96
|
+
maxInterval?: Duration;
|
|
97
|
+
/**
|
|
98
|
+
* (optional) CEL expression evaluated against each item's input to partition items into
|
|
99
|
+
* independent batches, e.g. "input.group". When unset, all items buffered for the task
|
|
100
|
+
* share a single batch.
|
|
101
|
+
*/
|
|
102
|
+
groupKey?: string;
|
|
103
|
+
/**
|
|
104
|
+
* (optional) maximum number of concurrent batches per group.
|
|
105
|
+
*/
|
|
106
|
+
groupMaxRuns?: number;
|
|
107
|
+
/**
|
|
108
|
+
* (optional) when true, the handler returns a single value that is broadcast as the
|
|
109
|
+
* result to every member of the batch, instead of a Record keyed by batch member id.
|
|
110
|
+
*
|
|
111
|
+
* default: false
|
|
112
|
+
*/
|
|
113
|
+
broadcastOutput?: boolean;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* The function signature for a batch task's handler. `input` maps each buffered run's
|
|
117
|
+
* task-run external id (its "batch member id") to that run's input. Unless
|
|
118
|
+
* `batch.broadcastOutput` is set, the handler must return a Record with the exact same
|
|
119
|
+
* key set, mapping each id to that run's output.
|
|
120
|
+
*/
|
|
121
|
+
export type BatchTaskFn<I extends InputType = UnknownInputType, O extends OutputType = void> = (input: Record<string, I>, ctx: Context<Record<string, I>>) => O | Promise<O>;
|
|
80
122
|
/**
|
|
81
123
|
* Options for creating a hatchet task which is an atomic unit of work in a workflow.
|
|
82
124
|
* @template I The input type for the task function.
|
|
@@ -168,6 +210,13 @@ export type CreateBaseTaskOpts<I extends InputType = UnknownInputType, O extends
|
|
|
168
210
|
slotCost?: number;
|
|
169
211
|
/** @internal */
|
|
170
212
|
slotRequests?: Record<string, number>;
|
|
213
|
+
/**
|
|
214
|
+
* (optional) configures this task as a batch task. Not available on durable tasks.
|
|
215
|
+
* retries is always forced to 0 when batch is set.
|
|
216
|
+
*
|
|
217
|
+
* Preview: batch tasks are in beta and may change in future releases.
|
|
218
|
+
*/
|
|
219
|
+
batch?: BatchTaskConfig;
|
|
171
220
|
};
|
|
172
221
|
export type CreateWorkflowTaskOpts<I extends InputType = UnknownInputType, O extends OutputType = void, C extends TaskFn<I, O> | DurableTaskFn<I, O> = TaskFn<I, O>> = CreateBaseTaskOpts<I, O, C> & {
|
|
173
222
|
/**
|
|
@@ -233,7 +282,7 @@ export type CreateWorkflowTaskOpts<I extends InputType = UnknownInputType, O ext
|
|
|
233
282
|
* @template I The input type for the task function.
|
|
234
283
|
* @template O The return type of the task function (can be inferred from the return value of fn).
|
|
235
284
|
*/
|
|
236
|
-
export type CreateWorkflowDurableTaskOpts<I extends InputType = UnknownInputType, O extends OutputType = void, C extends DurableTaskFn<I, O> = DurableTaskFn<I, O>> = Omit<CreateWorkflowTaskOpts<I, O, C>, 'slotCost'> & {
|
|
285
|
+
export type CreateWorkflowDurableTaskOpts<I extends InputType = UnknownInputType, O extends OutputType = void, C extends DurableTaskFn<I, O> = DurableTaskFn<I, O>> = Omit<CreateWorkflowTaskOpts<I, O, C>, 'slotCost' | 'batch'> & {
|
|
237
286
|
/**
|
|
238
287
|
* Eviction policy for the durable task. Controls TTL-based eviction and capacity-based eviction.
|
|
239
288
|
* Defaults to the built-in eviction policy when omitted or `undefined`.
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.28.0";
|
package/version.js
CHANGED