@hatchet-dev/typescript-sdk 1.10.5 → 1.10.7
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/package.json +4 -3
- package/protoc/v1/workflows.d.ts +60 -0
- package/protoc/v1/workflows.js +458 -2
- package/v1/client/worker/worker-internal.js +20 -5
- package/v1/declaration.d.ts +9 -1
- package/v1/declaration.js +2 -1
- package/v1/examples/simple/worker.js +2 -1
- package/v1/examples/simple/zod.d.ts +15 -0
- package/v1/examples/simple/zod.js +63 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hatchet-dev/typescript-sdk",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.7",
|
|
4
4
|
"description": "Background task orchestration & visibility for developers",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -62,10 +62,11 @@
|
|
|
62
62
|
"nice-grpc": "^2.1.12",
|
|
63
63
|
"nice-grpc-common": "^2.0.2",
|
|
64
64
|
"protobufjs": "^7.4.0",
|
|
65
|
-
"qs": "^6.14.
|
|
65
|
+
"qs": "^6.14.1",
|
|
66
66
|
"semver": "^7.7.1",
|
|
67
67
|
"yaml": "^2.7.1",
|
|
68
|
-
"zod": "^3.24.2"
|
|
68
|
+
"zod": "^3.24.2",
|
|
69
|
+
"zod-to-json-schema": "^3.24.1"
|
|
69
70
|
},
|
|
70
71
|
"optionalDependencies": {
|
|
71
72
|
"prom-client": "^15.1.3"
|
package/protoc/v1/workflows.d.ts
CHANGED
|
@@ -21,6 +21,16 @@ export declare enum RateLimitDuration {
|
|
|
21
21
|
}
|
|
22
22
|
export declare function rateLimitDurationFromJSON(object: any): RateLimitDuration;
|
|
23
23
|
export declare function rateLimitDurationToJSON(object: RateLimitDuration): string;
|
|
24
|
+
export declare enum RunStatus {
|
|
25
|
+
QUEUED = 0,
|
|
26
|
+
RUNNING = 1,
|
|
27
|
+
COMPLETED = 2,
|
|
28
|
+
FAILED = 3,
|
|
29
|
+
CANCELLED = 4,
|
|
30
|
+
UNRECOGNIZED = -1
|
|
31
|
+
}
|
|
32
|
+
export declare function runStatusFromJSON(object: any): RunStatus;
|
|
33
|
+
export declare function runStatusToJSON(object: RunStatus): string;
|
|
24
34
|
export declare enum ConcurrencyLimitStrategy {
|
|
25
35
|
CANCEL_IN_PROGRESS = 0,
|
|
26
36
|
/** DROP_NEWEST - deprecated */
|
|
@@ -104,6 +114,8 @@ export interface CreateWorkflowVersionRequest {
|
|
|
104
114
|
concurrencyArr: Concurrency[];
|
|
105
115
|
/** (optional) the default filters for the workflow */
|
|
106
116
|
defaultFilters: DefaultFilter[];
|
|
117
|
+
/** (optional) the JSON schema for the workflow input */
|
|
118
|
+
inputJsonSchema?: Uint8Array | undefined;
|
|
107
119
|
}
|
|
108
120
|
export interface DefaultFilter {
|
|
109
121
|
/** (required) the CEL expression for the filter */
|
|
@@ -197,6 +209,40 @@ export interface CreateWorkflowVersionResponse {
|
|
|
197
209
|
id: string;
|
|
198
210
|
workflowId: string;
|
|
199
211
|
}
|
|
212
|
+
export interface GetRunDetailsRequest {
|
|
213
|
+
/** (required) the external id (uuid) of the workflow run */
|
|
214
|
+
externalId: string;
|
|
215
|
+
}
|
|
216
|
+
export interface TaskRunDetail {
|
|
217
|
+
/** the external id (uuid) of the task run */
|
|
218
|
+
externalId: string;
|
|
219
|
+
/** the status of the task run */
|
|
220
|
+
status: RunStatus;
|
|
221
|
+
/** (optional) error message from the task run, if any */
|
|
222
|
+
error?: string | undefined;
|
|
223
|
+
/** (optional) the output payload for the task run */
|
|
224
|
+
output?: Uint8Array | undefined;
|
|
225
|
+
/** the readable id of the task */
|
|
226
|
+
readableId: string;
|
|
227
|
+
}
|
|
228
|
+
export interface GetRunDetailsResponse {
|
|
229
|
+
/** the input payload for the workflow run */
|
|
230
|
+
input: Uint8Array;
|
|
231
|
+
/** the status of the workflow run */
|
|
232
|
+
status: RunStatus;
|
|
233
|
+
/** map of task run external ids to their details */
|
|
234
|
+
taskRuns: {
|
|
235
|
+
[key: string]: TaskRunDetail;
|
|
236
|
+
};
|
|
237
|
+
/** indicates if the workflow run is done */
|
|
238
|
+
done: boolean;
|
|
239
|
+
/** (optional) additional metadata for the workflow run */
|
|
240
|
+
additionalMetadata: Uint8Array;
|
|
241
|
+
}
|
|
242
|
+
export interface GetRunDetailsResponse_TaskRunsEntry {
|
|
243
|
+
key: string;
|
|
244
|
+
value: TaskRunDetail | undefined;
|
|
245
|
+
}
|
|
200
246
|
export declare const CancelTasksRequest: MessageFns<CancelTasksRequest>;
|
|
201
247
|
export declare const ReplayTasksRequest: MessageFns<ReplayTasksRequest>;
|
|
202
248
|
export declare const TasksFilter: MessageFns<TasksFilter>;
|
|
@@ -212,6 +258,10 @@ export declare const CreateTaskOpts: MessageFns<CreateTaskOpts>;
|
|
|
212
258
|
export declare const CreateTaskOpts_WorkerLabelsEntry: MessageFns<CreateTaskOpts_WorkerLabelsEntry>;
|
|
213
259
|
export declare const CreateTaskRateLimit: MessageFns<CreateTaskRateLimit>;
|
|
214
260
|
export declare const CreateWorkflowVersionResponse: MessageFns<CreateWorkflowVersionResponse>;
|
|
261
|
+
export declare const GetRunDetailsRequest: MessageFns<GetRunDetailsRequest>;
|
|
262
|
+
export declare const TaskRunDetail: MessageFns<TaskRunDetail>;
|
|
263
|
+
export declare const GetRunDetailsResponse: MessageFns<GetRunDetailsResponse>;
|
|
264
|
+
export declare const GetRunDetailsResponse_TaskRunsEntry: MessageFns<GetRunDetailsResponse_TaskRunsEntry>;
|
|
215
265
|
/** AdminService represents a set of RPCs for admin management of tasks, workflows, etc. */
|
|
216
266
|
export type AdminServiceDefinition = typeof AdminServiceDefinition;
|
|
217
267
|
export declare const AdminServiceDefinition: {
|
|
@@ -250,6 +300,14 @@ export declare const AdminServiceDefinition: {
|
|
|
250
300
|
readonly responseStream: false;
|
|
251
301
|
readonly options: {};
|
|
252
302
|
};
|
|
303
|
+
readonly getRunDetails: {
|
|
304
|
+
readonly name: "GetRunDetails";
|
|
305
|
+
readonly requestType: MessageFns<GetRunDetailsRequest>;
|
|
306
|
+
readonly requestStream: false;
|
|
307
|
+
readonly responseType: MessageFns<GetRunDetailsResponse>;
|
|
308
|
+
readonly responseStream: false;
|
|
309
|
+
readonly options: {};
|
|
310
|
+
};
|
|
253
311
|
};
|
|
254
312
|
};
|
|
255
313
|
export interface AdminServiceImplementation<CallContextExt = {}> {
|
|
@@ -257,12 +315,14 @@ export interface AdminServiceImplementation<CallContextExt = {}> {
|
|
|
257
315
|
cancelTasks(request: CancelTasksRequest, context: CallContext & CallContextExt): Promise<DeepPartial<CancelTasksResponse>>;
|
|
258
316
|
replayTasks(request: ReplayTasksRequest, context: CallContext & CallContextExt): Promise<DeepPartial<ReplayTasksResponse>>;
|
|
259
317
|
triggerWorkflowRun(request: TriggerWorkflowRunRequest, context: CallContext & CallContextExt): Promise<DeepPartial<TriggerWorkflowRunResponse>>;
|
|
318
|
+
getRunDetails(request: GetRunDetailsRequest, context: CallContext & CallContextExt): Promise<DeepPartial<GetRunDetailsResponse>>;
|
|
260
319
|
}
|
|
261
320
|
export interface AdminServiceClient<CallOptionsExt = {}> {
|
|
262
321
|
putWorkflow(request: DeepPartial<CreateWorkflowVersionRequest>, options?: CallOptions & CallOptionsExt): Promise<CreateWorkflowVersionResponse>;
|
|
263
322
|
cancelTasks(request: DeepPartial<CancelTasksRequest>, options?: CallOptions & CallOptionsExt): Promise<CancelTasksResponse>;
|
|
264
323
|
replayTasks(request: DeepPartial<ReplayTasksRequest>, options?: CallOptions & CallOptionsExt): Promise<ReplayTasksResponse>;
|
|
265
324
|
triggerWorkflowRun(request: DeepPartial<TriggerWorkflowRunRequest>, options?: CallOptions & CallOptionsExt): Promise<TriggerWorkflowRunResponse>;
|
|
325
|
+
getRunDetails(request: DeepPartial<GetRunDetailsRequest>, options?: CallOptions & CallOptionsExt): Promise<GetRunDetailsResponse>;
|
|
266
326
|
}
|
|
267
327
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
268
328
|
export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
package/protoc/v1/workflows.js
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
// protoc v3.19.1
|
|
6
6
|
// source: v1/workflows.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.AdminServiceDefinition = exports.CreateWorkflowVersionResponse = exports.CreateTaskRateLimit = exports.CreateTaskOpts_WorkerLabelsEntry = exports.CreateTaskOpts = exports.DesiredWorkerLabels = exports.Concurrency = exports.DefaultFilter = exports.CreateWorkflowVersionRequest = exports.TriggerWorkflowRunResponse = exports.TriggerWorkflowRunRequest = exports.ReplayTasksResponse = exports.CancelTasksResponse = exports.TasksFilter = exports.ReplayTasksRequest = exports.CancelTasksRequest = exports.WorkerLabelComparator = exports.ConcurrencyLimitStrategy = exports.RateLimitDuration = exports.StickyStrategy = exports.protobufPackage = void 0;
|
|
8
|
+
exports.AdminServiceDefinition = exports.GetRunDetailsResponse_TaskRunsEntry = exports.GetRunDetailsResponse = exports.TaskRunDetail = exports.GetRunDetailsRequest = exports.CreateWorkflowVersionResponse = exports.CreateTaskRateLimit = exports.CreateTaskOpts_WorkerLabelsEntry = exports.CreateTaskOpts = exports.DesiredWorkerLabels = exports.Concurrency = exports.DefaultFilter = exports.CreateWorkflowVersionRequest = exports.TriggerWorkflowRunResponse = exports.TriggerWorkflowRunRequest = exports.ReplayTasksResponse = exports.CancelTasksResponse = exports.TasksFilter = exports.ReplayTasksRequest = exports.CancelTasksRequest = exports.WorkerLabelComparator = exports.ConcurrencyLimitStrategy = exports.RunStatus = exports.RateLimitDuration = exports.StickyStrategy = exports.protobufPackage = void 0;
|
|
9
9
|
exports.stickyStrategyFromJSON = stickyStrategyFromJSON;
|
|
10
10
|
exports.stickyStrategyToJSON = stickyStrategyToJSON;
|
|
11
11
|
exports.rateLimitDurationFromJSON = rateLimitDurationFromJSON;
|
|
12
12
|
exports.rateLimitDurationToJSON = rateLimitDurationToJSON;
|
|
13
|
+
exports.runStatusFromJSON = runStatusFromJSON;
|
|
14
|
+
exports.runStatusToJSON = runStatusToJSON;
|
|
13
15
|
exports.concurrencyLimitStrategyFromJSON = concurrencyLimitStrategyFromJSON;
|
|
14
16
|
exports.concurrencyLimitStrategyToJSON = concurrencyLimitStrategyToJSON;
|
|
15
17
|
exports.workerLabelComparatorFromJSON = workerLabelComparatorFromJSON;
|
|
@@ -111,6 +113,55 @@ function rateLimitDurationToJSON(object) {
|
|
|
111
113
|
return 'UNRECOGNIZED';
|
|
112
114
|
}
|
|
113
115
|
}
|
|
116
|
+
var RunStatus;
|
|
117
|
+
(function (RunStatus) {
|
|
118
|
+
RunStatus[RunStatus["QUEUED"] = 0] = "QUEUED";
|
|
119
|
+
RunStatus[RunStatus["RUNNING"] = 1] = "RUNNING";
|
|
120
|
+
RunStatus[RunStatus["COMPLETED"] = 2] = "COMPLETED";
|
|
121
|
+
RunStatus[RunStatus["FAILED"] = 3] = "FAILED";
|
|
122
|
+
RunStatus[RunStatus["CANCELLED"] = 4] = "CANCELLED";
|
|
123
|
+
RunStatus[RunStatus["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
124
|
+
})(RunStatus || (exports.RunStatus = RunStatus = {}));
|
|
125
|
+
function runStatusFromJSON(object) {
|
|
126
|
+
switch (object) {
|
|
127
|
+
case 0:
|
|
128
|
+
case 'QUEUED':
|
|
129
|
+
return RunStatus.QUEUED;
|
|
130
|
+
case 1:
|
|
131
|
+
case 'RUNNING':
|
|
132
|
+
return RunStatus.RUNNING;
|
|
133
|
+
case 2:
|
|
134
|
+
case 'COMPLETED':
|
|
135
|
+
return RunStatus.COMPLETED;
|
|
136
|
+
case 3:
|
|
137
|
+
case 'FAILED':
|
|
138
|
+
return RunStatus.FAILED;
|
|
139
|
+
case 4:
|
|
140
|
+
case 'CANCELLED':
|
|
141
|
+
return RunStatus.CANCELLED;
|
|
142
|
+
case -1:
|
|
143
|
+
case 'UNRECOGNIZED':
|
|
144
|
+
default:
|
|
145
|
+
return RunStatus.UNRECOGNIZED;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function runStatusToJSON(object) {
|
|
149
|
+
switch (object) {
|
|
150
|
+
case RunStatus.QUEUED:
|
|
151
|
+
return 'QUEUED';
|
|
152
|
+
case RunStatus.RUNNING:
|
|
153
|
+
return 'RUNNING';
|
|
154
|
+
case RunStatus.COMPLETED:
|
|
155
|
+
return 'COMPLETED';
|
|
156
|
+
case RunStatus.FAILED:
|
|
157
|
+
return 'FAILED';
|
|
158
|
+
case RunStatus.CANCELLED:
|
|
159
|
+
return 'CANCELLED';
|
|
160
|
+
case RunStatus.UNRECOGNIZED:
|
|
161
|
+
default:
|
|
162
|
+
return 'UNRECOGNIZED';
|
|
163
|
+
}
|
|
164
|
+
}
|
|
114
165
|
var ConcurrencyLimitStrategy;
|
|
115
166
|
(function (ConcurrencyLimitStrategy) {
|
|
116
167
|
ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["CANCEL_IN_PROGRESS"] = 0] = "CANCEL_IN_PROGRESS";
|
|
@@ -781,6 +832,7 @@ function createBaseCreateWorkflowVersionRequest() {
|
|
|
781
832
|
defaultPriority: undefined,
|
|
782
833
|
concurrencyArr: [],
|
|
783
834
|
defaultFilters: [],
|
|
835
|
+
inputJsonSchema: undefined,
|
|
784
836
|
};
|
|
785
837
|
}
|
|
786
838
|
exports.CreateWorkflowVersionRequest = {
|
|
@@ -824,6 +876,9 @@ exports.CreateWorkflowVersionRequest = {
|
|
|
824
876
|
for (const v of message.defaultFilters) {
|
|
825
877
|
exports.DefaultFilter.encode(v, writer.uint32(106).fork()).join();
|
|
826
878
|
}
|
|
879
|
+
if (message.inputJsonSchema !== undefined) {
|
|
880
|
+
writer.uint32(114).bytes(message.inputJsonSchema);
|
|
881
|
+
}
|
|
827
882
|
return writer;
|
|
828
883
|
},
|
|
829
884
|
decode(input, length) {
|
|
@@ -924,6 +979,13 @@ exports.CreateWorkflowVersionRequest = {
|
|
|
924
979
|
message.defaultFilters.push(exports.DefaultFilter.decode(reader, reader.uint32()));
|
|
925
980
|
continue;
|
|
926
981
|
}
|
|
982
|
+
case 14: {
|
|
983
|
+
if (tag !== 114) {
|
|
984
|
+
break;
|
|
985
|
+
}
|
|
986
|
+
message.inputJsonSchema = reader.bytes();
|
|
987
|
+
continue;
|
|
988
|
+
}
|
|
927
989
|
}
|
|
928
990
|
if ((tag & 7) === 4 || tag === 0) {
|
|
929
991
|
break;
|
|
@@ -961,6 +1023,9 @@ exports.CreateWorkflowVersionRequest = {
|
|
|
961
1023
|
defaultFilters: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.defaultFilters)
|
|
962
1024
|
? object.defaultFilters.map((e) => exports.DefaultFilter.fromJSON(e))
|
|
963
1025
|
: [],
|
|
1026
|
+
inputJsonSchema: isSet(object.inputJsonSchema)
|
|
1027
|
+
? bytesFromBase64(object.inputJsonSchema)
|
|
1028
|
+
: undefined,
|
|
964
1029
|
};
|
|
965
1030
|
},
|
|
966
1031
|
toJSON(message) {
|
|
@@ -1005,13 +1070,16 @@ exports.CreateWorkflowVersionRequest = {
|
|
|
1005
1070
|
if ((_e = message.defaultFilters) === null || _e === void 0 ? void 0 : _e.length) {
|
|
1006
1071
|
obj.defaultFilters = message.defaultFilters.map((e) => exports.DefaultFilter.toJSON(e));
|
|
1007
1072
|
}
|
|
1073
|
+
if (message.inputJsonSchema !== undefined) {
|
|
1074
|
+
obj.inputJsonSchema = base64FromBytes(message.inputJsonSchema);
|
|
1075
|
+
}
|
|
1008
1076
|
return obj;
|
|
1009
1077
|
},
|
|
1010
1078
|
create(base) {
|
|
1011
1079
|
return exports.CreateWorkflowVersionRequest.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
1012
1080
|
},
|
|
1013
1081
|
fromPartial(object) {
|
|
1014
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1082
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1015
1083
|
const message = createBaseCreateWorkflowVersionRequest();
|
|
1016
1084
|
message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
|
|
1017
1085
|
message.description = (_b = object.description) !== null && _b !== void 0 ? _b : '';
|
|
@@ -1032,6 +1100,7 @@ exports.CreateWorkflowVersionRequest = {
|
|
|
1032
1100
|
message.defaultPriority = (_j = object.defaultPriority) !== null && _j !== void 0 ? _j : undefined;
|
|
1033
1101
|
message.concurrencyArr = ((_k = object.concurrencyArr) === null || _k === void 0 ? void 0 : _k.map((e) => exports.Concurrency.fromPartial(e))) || [];
|
|
1034
1102
|
message.defaultFilters = ((_l = object.defaultFilters) === null || _l === void 0 ? void 0 : _l.map((e) => exports.DefaultFilter.fromPartial(e))) || [];
|
|
1103
|
+
message.inputJsonSchema = (_m = object.inputJsonSchema) !== null && _m !== void 0 ? _m : undefined;
|
|
1035
1104
|
return message;
|
|
1036
1105
|
},
|
|
1037
1106
|
};
|
|
@@ -1889,6 +1958,385 @@ exports.CreateWorkflowVersionResponse = {
|
|
|
1889
1958
|
return message;
|
|
1890
1959
|
},
|
|
1891
1960
|
};
|
|
1961
|
+
function createBaseGetRunDetailsRequest() {
|
|
1962
|
+
return { externalId: '' };
|
|
1963
|
+
}
|
|
1964
|
+
exports.GetRunDetailsRequest = {
|
|
1965
|
+
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
1966
|
+
if (message.externalId !== '') {
|
|
1967
|
+
writer.uint32(10).string(message.externalId);
|
|
1968
|
+
}
|
|
1969
|
+
return writer;
|
|
1970
|
+
},
|
|
1971
|
+
decode(input, length) {
|
|
1972
|
+
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
1973
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
1974
|
+
const message = createBaseGetRunDetailsRequest();
|
|
1975
|
+
while (reader.pos < end) {
|
|
1976
|
+
const tag = reader.uint32();
|
|
1977
|
+
switch (tag >>> 3) {
|
|
1978
|
+
case 1: {
|
|
1979
|
+
if (tag !== 10) {
|
|
1980
|
+
break;
|
|
1981
|
+
}
|
|
1982
|
+
message.externalId = reader.string();
|
|
1983
|
+
continue;
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1987
|
+
break;
|
|
1988
|
+
}
|
|
1989
|
+
reader.skip(tag & 7);
|
|
1990
|
+
}
|
|
1991
|
+
return message;
|
|
1992
|
+
},
|
|
1993
|
+
fromJSON(object) {
|
|
1994
|
+
return { externalId: isSet(object.externalId) ? globalThis.String(object.externalId) : '' };
|
|
1995
|
+
},
|
|
1996
|
+
toJSON(message) {
|
|
1997
|
+
const obj = {};
|
|
1998
|
+
if (message.externalId !== '') {
|
|
1999
|
+
obj.externalId = message.externalId;
|
|
2000
|
+
}
|
|
2001
|
+
return obj;
|
|
2002
|
+
},
|
|
2003
|
+
create(base) {
|
|
2004
|
+
return exports.GetRunDetailsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
2005
|
+
},
|
|
2006
|
+
fromPartial(object) {
|
|
2007
|
+
var _a;
|
|
2008
|
+
const message = createBaseGetRunDetailsRequest();
|
|
2009
|
+
message.externalId = (_a = object.externalId) !== null && _a !== void 0 ? _a : '';
|
|
2010
|
+
return message;
|
|
2011
|
+
},
|
|
2012
|
+
};
|
|
2013
|
+
function createBaseTaskRunDetail() {
|
|
2014
|
+
return { externalId: '', status: 0, error: undefined, output: undefined, readableId: '' };
|
|
2015
|
+
}
|
|
2016
|
+
exports.TaskRunDetail = {
|
|
2017
|
+
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
2018
|
+
if (message.externalId !== '') {
|
|
2019
|
+
writer.uint32(10).string(message.externalId);
|
|
2020
|
+
}
|
|
2021
|
+
if (message.status !== 0) {
|
|
2022
|
+
writer.uint32(16).int32(message.status);
|
|
2023
|
+
}
|
|
2024
|
+
if (message.error !== undefined) {
|
|
2025
|
+
writer.uint32(26).string(message.error);
|
|
2026
|
+
}
|
|
2027
|
+
if (message.output !== undefined) {
|
|
2028
|
+
writer.uint32(34).bytes(message.output);
|
|
2029
|
+
}
|
|
2030
|
+
if (message.readableId !== '') {
|
|
2031
|
+
writer.uint32(42).string(message.readableId);
|
|
2032
|
+
}
|
|
2033
|
+
return writer;
|
|
2034
|
+
},
|
|
2035
|
+
decode(input, length) {
|
|
2036
|
+
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
2037
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
2038
|
+
const message = createBaseTaskRunDetail();
|
|
2039
|
+
while (reader.pos < end) {
|
|
2040
|
+
const tag = reader.uint32();
|
|
2041
|
+
switch (tag >>> 3) {
|
|
2042
|
+
case 1: {
|
|
2043
|
+
if (tag !== 10) {
|
|
2044
|
+
break;
|
|
2045
|
+
}
|
|
2046
|
+
message.externalId = reader.string();
|
|
2047
|
+
continue;
|
|
2048
|
+
}
|
|
2049
|
+
case 2: {
|
|
2050
|
+
if (tag !== 16) {
|
|
2051
|
+
break;
|
|
2052
|
+
}
|
|
2053
|
+
message.status = reader.int32();
|
|
2054
|
+
continue;
|
|
2055
|
+
}
|
|
2056
|
+
case 3: {
|
|
2057
|
+
if (tag !== 26) {
|
|
2058
|
+
break;
|
|
2059
|
+
}
|
|
2060
|
+
message.error = reader.string();
|
|
2061
|
+
continue;
|
|
2062
|
+
}
|
|
2063
|
+
case 4: {
|
|
2064
|
+
if (tag !== 34) {
|
|
2065
|
+
break;
|
|
2066
|
+
}
|
|
2067
|
+
message.output = reader.bytes();
|
|
2068
|
+
continue;
|
|
2069
|
+
}
|
|
2070
|
+
case 5: {
|
|
2071
|
+
if (tag !== 42) {
|
|
2072
|
+
break;
|
|
2073
|
+
}
|
|
2074
|
+
message.readableId = reader.string();
|
|
2075
|
+
continue;
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
2079
|
+
break;
|
|
2080
|
+
}
|
|
2081
|
+
reader.skip(tag & 7);
|
|
2082
|
+
}
|
|
2083
|
+
return message;
|
|
2084
|
+
},
|
|
2085
|
+
fromJSON(object) {
|
|
2086
|
+
return {
|
|
2087
|
+
externalId: isSet(object.externalId) ? globalThis.String(object.externalId) : '',
|
|
2088
|
+
status: isSet(object.status) ? runStatusFromJSON(object.status) : 0,
|
|
2089
|
+
error: isSet(object.error) ? globalThis.String(object.error) : undefined,
|
|
2090
|
+
output: isSet(object.output) ? bytesFromBase64(object.output) : undefined,
|
|
2091
|
+
readableId: isSet(object.readableId) ? globalThis.String(object.readableId) : '',
|
|
2092
|
+
};
|
|
2093
|
+
},
|
|
2094
|
+
toJSON(message) {
|
|
2095
|
+
const obj = {};
|
|
2096
|
+
if (message.externalId !== '') {
|
|
2097
|
+
obj.externalId = message.externalId;
|
|
2098
|
+
}
|
|
2099
|
+
if (message.status !== 0) {
|
|
2100
|
+
obj.status = runStatusToJSON(message.status);
|
|
2101
|
+
}
|
|
2102
|
+
if (message.error !== undefined) {
|
|
2103
|
+
obj.error = message.error;
|
|
2104
|
+
}
|
|
2105
|
+
if (message.output !== undefined) {
|
|
2106
|
+
obj.output = base64FromBytes(message.output);
|
|
2107
|
+
}
|
|
2108
|
+
if (message.readableId !== '') {
|
|
2109
|
+
obj.readableId = message.readableId;
|
|
2110
|
+
}
|
|
2111
|
+
return obj;
|
|
2112
|
+
},
|
|
2113
|
+
create(base) {
|
|
2114
|
+
return exports.TaskRunDetail.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
2115
|
+
},
|
|
2116
|
+
fromPartial(object) {
|
|
2117
|
+
var _a, _b, _c, _d, _e;
|
|
2118
|
+
const message = createBaseTaskRunDetail();
|
|
2119
|
+
message.externalId = (_a = object.externalId) !== null && _a !== void 0 ? _a : '';
|
|
2120
|
+
message.status = (_b = object.status) !== null && _b !== void 0 ? _b : 0;
|
|
2121
|
+
message.error = (_c = object.error) !== null && _c !== void 0 ? _c : undefined;
|
|
2122
|
+
message.output = (_d = object.output) !== null && _d !== void 0 ? _d : undefined;
|
|
2123
|
+
message.readableId = (_e = object.readableId) !== null && _e !== void 0 ? _e : '';
|
|
2124
|
+
return message;
|
|
2125
|
+
},
|
|
2126
|
+
};
|
|
2127
|
+
function createBaseGetRunDetailsResponse() {
|
|
2128
|
+
return {
|
|
2129
|
+
input: new Uint8Array(0),
|
|
2130
|
+
status: 0,
|
|
2131
|
+
taskRuns: {},
|
|
2132
|
+
done: false,
|
|
2133
|
+
additionalMetadata: new Uint8Array(0),
|
|
2134
|
+
};
|
|
2135
|
+
}
|
|
2136
|
+
exports.GetRunDetailsResponse = {
|
|
2137
|
+
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
2138
|
+
if (message.input.length !== 0) {
|
|
2139
|
+
writer.uint32(10).bytes(message.input);
|
|
2140
|
+
}
|
|
2141
|
+
if (message.status !== 0) {
|
|
2142
|
+
writer.uint32(16).int32(message.status);
|
|
2143
|
+
}
|
|
2144
|
+
Object.entries(message.taskRuns).forEach(([key, value]) => {
|
|
2145
|
+
exports.GetRunDetailsResponse_TaskRunsEntry.encode({ key: key, value }, writer.uint32(26).fork()).join();
|
|
2146
|
+
});
|
|
2147
|
+
if (message.done !== false) {
|
|
2148
|
+
writer.uint32(32).bool(message.done);
|
|
2149
|
+
}
|
|
2150
|
+
if (message.additionalMetadata.length !== 0) {
|
|
2151
|
+
writer.uint32(42).bytes(message.additionalMetadata);
|
|
2152
|
+
}
|
|
2153
|
+
return writer;
|
|
2154
|
+
},
|
|
2155
|
+
decode(input, length) {
|
|
2156
|
+
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
2157
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
2158
|
+
const message = createBaseGetRunDetailsResponse();
|
|
2159
|
+
while (reader.pos < end) {
|
|
2160
|
+
const tag = reader.uint32();
|
|
2161
|
+
switch (tag >>> 3) {
|
|
2162
|
+
case 1: {
|
|
2163
|
+
if (tag !== 10) {
|
|
2164
|
+
break;
|
|
2165
|
+
}
|
|
2166
|
+
message.input = reader.bytes();
|
|
2167
|
+
continue;
|
|
2168
|
+
}
|
|
2169
|
+
case 2: {
|
|
2170
|
+
if (tag !== 16) {
|
|
2171
|
+
break;
|
|
2172
|
+
}
|
|
2173
|
+
message.status = reader.int32();
|
|
2174
|
+
continue;
|
|
2175
|
+
}
|
|
2176
|
+
case 3: {
|
|
2177
|
+
if (tag !== 26) {
|
|
2178
|
+
break;
|
|
2179
|
+
}
|
|
2180
|
+
const entry3 = exports.GetRunDetailsResponse_TaskRunsEntry.decode(reader, reader.uint32());
|
|
2181
|
+
if (entry3.value !== undefined) {
|
|
2182
|
+
message.taskRuns[entry3.key] = entry3.value;
|
|
2183
|
+
}
|
|
2184
|
+
continue;
|
|
2185
|
+
}
|
|
2186
|
+
case 4: {
|
|
2187
|
+
if (tag !== 32) {
|
|
2188
|
+
break;
|
|
2189
|
+
}
|
|
2190
|
+
message.done = reader.bool();
|
|
2191
|
+
continue;
|
|
2192
|
+
}
|
|
2193
|
+
case 5: {
|
|
2194
|
+
if (tag !== 42) {
|
|
2195
|
+
break;
|
|
2196
|
+
}
|
|
2197
|
+
message.additionalMetadata = reader.bytes();
|
|
2198
|
+
continue;
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
2202
|
+
break;
|
|
2203
|
+
}
|
|
2204
|
+
reader.skip(tag & 7);
|
|
2205
|
+
}
|
|
2206
|
+
return message;
|
|
2207
|
+
},
|
|
2208
|
+
fromJSON(object) {
|
|
2209
|
+
return {
|
|
2210
|
+
input: isSet(object.input) ? bytesFromBase64(object.input) : new Uint8Array(0),
|
|
2211
|
+
status: isSet(object.status) ? runStatusFromJSON(object.status) : 0,
|
|
2212
|
+
taskRuns: isObject(object.taskRuns)
|
|
2213
|
+
? Object.entries(object.taskRuns).reduce((acc, [key, value]) => {
|
|
2214
|
+
acc[key] = exports.TaskRunDetail.fromJSON(value);
|
|
2215
|
+
return acc;
|
|
2216
|
+
}, {})
|
|
2217
|
+
: {},
|
|
2218
|
+
done: isSet(object.done) ? globalThis.Boolean(object.done) : false,
|
|
2219
|
+
additionalMetadata: isSet(object.additionalMetadata)
|
|
2220
|
+
? bytesFromBase64(object.additionalMetadata)
|
|
2221
|
+
: new Uint8Array(0),
|
|
2222
|
+
};
|
|
2223
|
+
},
|
|
2224
|
+
toJSON(message) {
|
|
2225
|
+
const obj = {};
|
|
2226
|
+
if (message.input.length !== 0) {
|
|
2227
|
+
obj.input = base64FromBytes(message.input);
|
|
2228
|
+
}
|
|
2229
|
+
if (message.status !== 0) {
|
|
2230
|
+
obj.status = runStatusToJSON(message.status);
|
|
2231
|
+
}
|
|
2232
|
+
if (message.taskRuns) {
|
|
2233
|
+
const entries = Object.entries(message.taskRuns);
|
|
2234
|
+
if (entries.length > 0) {
|
|
2235
|
+
obj.taskRuns = {};
|
|
2236
|
+
entries.forEach(([k, v]) => {
|
|
2237
|
+
obj.taskRuns[k] = exports.TaskRunDetail.toJSON(v);
|
|
2238
|
+
});
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
if (message.done !== false) {
|
|
2242
|
+
obj.done = message.done;
|
|
2243
|
+
}
|
|
2244
|
+
if (message.additionalMetadata.length !== 0) {
|
|
2245
|
+
obj.additionalMetadata = base64FromBytes(message.additionalMetadata);
|
|
2246
|
+
}
|
|
2247
|
+
return obj;
|
|
2248
|
+
},
|
|
2249
|
+
create(base) {
|
|
2250
|
+
return exports.GetRunDetailsResponse.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
2251
|
+
},
|
|
2252
|
+
fromPartial(object) {
|
|
2253
|
+
var _a, _b, _c, _d, _e;
|
|
2254
|
+
const message = createBaseGetRunDetailsResponse();
|
|
2255
|
+
message.input = (_a = object.input) !== null && _a !== void 0 ? _a : new Uint8Array(0);
|
|
2256
|
+
message.status = (_b = object.status) !== null && _b !== void 0 ? _b : 0;
|
|
2257
|
+
message.taskRuns = Object.entries((_c = object.taskRuns) !== null && _c !== void 0 ? _c : {}).reduce((acc, [key, value]) => {
|
|
2258
|
+
if (value !== undefined) {
|
|
2259
|
+
acc[key] = exports.TaskRunDetail.fromPartial(value);
|
|
2260
|
+
}
|
|
2261
|
+
return acc;
|
|
2262
|
+
}, {});
|
|
2263
|
+
message.done = (_d = object.done) !== null && _d !== void 0 ? _d : false;
|
|
2264
|
+
message.additionalMetadata = (_e = object.additionalMetadata) !== null && _e !== void 0 ? _e : new Uint8Array(0);
|
|
2265
|
+
return message;
|
|
2266
|
+
},
|
|
2267
|
+
};
|
|
2268
|
+
function createBaseGetRunDetailsResponse_TaskRunsEntry() {
|
|
2269
|
+
return { key: '', value: undefined };
|
|
2270
|
+
}
|
|
2271
|
+
exports.GetRunDetailsResponse_TaskRunsEntry = {
|
|
2272
|
+
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
2273
|
+
if (message.key !== '') {
|
|
2274
|
+
writer.uint32(10).string(message.key);
|
|
2275
|
+
}
|
|
2276
|
+
if (message.value !== undefined) {
|
|
2277
|
+
exports.TaskRunDetail.encode(message.value, writer.uint32(18).fork()).join();
|
|
2278
|
+
}
|
|
2279
|
+
return writer;
|
|
2280
|
+
},
|
|
2281
|
+
decode(input, length) {
|
|
2282
|
+
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
2283
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
2284
|
+
const message = createBaseGetRunDetailsResponse_TaskRunsEntry();
|
|
2285
|
+
while (reader.pos < end) {
|
|
2286
|
+
const tag = reader.uint32();
|
|
2287
|
+
switch (tag >>> 3) {
|
|
2288
|
+
case 1: {
|
|
2289
|
+
if (tag !== 10) {
|
|
2290
|
+
break;
|
|
2291
|
+
}
|
|
2292
|
+
message.key = reader.string();
|
|
2293
|
+
continue;
|
|
2294
|
+
}
|
|
2295
|
+
case 2: {
|
|
2296
|
+
if (tag !== 18) {
|
|
2297
|
+
break;
|
|
2298
|
+
}
|
|
2299
|
+
message.value = exports.TaskRunDetail.decode(reader, reader.uint32());
|
|
2300
|
+
continue;
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
2304
|
+
break;
|
|
2305
|
+
}
|
|
2306
|
+
reader.skip(tag & 7);
|
|
2307
|
+
}
|
|
2308
|
+
return message;
|
|
2309
|
+
},
|
|
2310
|
+
fromJSON(object) {
|
|
2311
|
+
return {
|
|
2312
|
+
key: isSet(object.key) ? globalThis.String(object.key) : '',
|
|
2313
|
+
value: isSet(object.value) ? exports.TaskRunDetail.fromJSON(object.value) : undefined,
|
|
2314
|
+
};
|
|
2315
|
+
},
|
|
2316
|
+
toJSON(message) {
|
|
2317
|
+
const obj = {};
|
|
2318
|
+
if (message.key !== '') {
|
|
2319
|
+
obj.key = message.key;
|
|
2320
|
+
}
|
|
2321
|
+
if (message.value !== undefined) {
|
|
2322
|
+
obj.value = exports.TaskRunDetail.toJSON(message.value);
|
|
2323
|
+
}
|
|
2324
|
+
return obj;
|
|
2325
|
+
},
|
|
2326
|
+
create(base) {
|
|
2327
|
+
return exports.GetRunDetailsResponse_TaskRunsEntry.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
2328
|
+
},
|
|
2329
|
+
fromPartial(object) {
|
|
2330
|
+
var _a;
|
|
2331
|
+
const message = createBaseGetRunDetailsResponse_TaskRunsEntry();
|
|
2332
|
+
message.key = (_a = object.key) !== null && _a !== void 0 ? _a : '';
|
|
2333
|
+
message.value =
|
|
2334
|
+
object.value !== undefined && object.value !== null
|
|
2335
|
+
? exports.TaskRunDetail.fromPartial(object.value)
|
|
2336
|
+
: undefined;
|
|
2337
|
+
return message;
|
|
2338
|
+
},
|
|
2339
|
+
};
|
|
1892
2340
|
exports.AdminServiceDefinition = {
|
|
1893
2341
|
name: 'AdminService',
|
|
1894
2342
|
fullName: 'v1.AdminService',
|
|
@@ -1925,6 +2373,14 @@ exports.AdminServiceDefinition = {
|
|
|
1925
2373
|
responseStream: false,
|
|
1926
2374
|
options: {},
|
|
1927
2375
|
},
|
|
2376
|
+
getRunDetails: {
|
|
2377
|
+
name: 'GetRunDetails',
|
|
2378
|
+
requestType: exports.GetRunDetailsRequest,
|
|
2379
|
+
requestStream: false,
|
|
2380
|
+
responseType: exports.GetRunDetailsResponse,
|
|
2381
|
+
responseStream: false,
|
|
2382
|
+
options: {},
|
|
2383
|
+
},
|
|
1928
2384
|
},
|
|
1929
2385
|
};
|
|
1930
2386
|
function bytesFromBase64(b64) {
|
|
@@ -28,6 +28,7 @@ const hatchet_promise_1 = __importDefault(require("../../../util/hatchet-promise
|
|
|
28
28
|
const workflows_1 = require("../../../protoc/workflows");
|
|
29
29
|
const task_1 = require("../../task");
|
|
30
30
|
const transformer_1 = require("../../conditions/transformer");
|
|
31
|
+
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
31
32
|
const step_1 = require("../../../step");
|
|
32
33
|
const apply_namespace_1 = require("../../../util/apply-namespace");
|
|
33
34
|
const context_1 = require("./context");
|
|
@@ -244,6 +245,13 @@ class V1Worker {
|
|
|
244
245
|
];
|
|
245
246
|
const concurrencyArr = Array.isArray(concurrency) ? concurrency : [];
|
|
246
247
|
const concurrencySolo = !Array.isArray(concurrency) ? concurrency : undefined;
|
|
248
|
+
// Convert Zod schema to JSON Schema if provided
|
|
249
|
+
let inputJsonSchema;
|
|
250
|
+
if (workflow.inputValidator) {
|
|
251
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
252
|
+
const jsonSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(workflow.inputValidator);
|
|
253
|
+
inputJsonSchema = new TextEncoder().encode(JSON.stringify(jsonSchema));
|
|
254
|
+
}
|
|
247
255
|
const registeredWorkflow = this.client._v0.admin.putWorkflowV1({
|
|
248
256
|
name: workflow.name,
|
|
249
257
|
description: workflow.description || '',
|
|
@@ -254,6 +262,7 @@ class V1Worker {
|
|
|
254
262
|
concurrencyArr,
|
|
255
263
|
onFailureTask,
|
|
256
264
|
defaultPriority: workflow.defaultPriority,
|
|
265
|
+
inputJsonSchema,
|
|
257
266
|
tasks: [...workflow._tasks, ...workflow._durableTasks].map((task) => {
|
|
258
267
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
259
268
|
return ({
|
|
@@ -410,8 +419,11 @@ class V1Worker {
|
|
|
410
419
|
return step(context);
|
|
411
420
|
});
|
|
412
421
|
const success = (result) => __awaiter(this, void 0, void 0, function* () {
|
|
413
|
-
this.logger.info(`Step run ${action.stepRunId} succeeded`);
|
|
414
422
|
try {
|
|
423
|
+
if (context.cancelled) {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
this.logger.info(`Step run ${action.stepRunId} succeeded`);
|
|
415
427
|
// Send the action event to the dispatcher
|
|
416
428
|
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, false, result || null, action.retryCount);
|
|
417
429
|
yield this.client._v0.dispatcher.sendStepActionEvent(event);
|
|
@@ -435,12 +447,15 @@ class V1Worker {
|
|
|
435
447
|
}
|
|
436
448
|
});
|
|
437
449
|
const failure = (error) => __awaiter(this, void 0, void 0, function* () {
|
|
438
|
-
this.logger.error(`Step run ${action.stepRunId} failed: ${error.message}`);
|
|
439
|
-
if (error.stack) {
|
|
440
|
-
this.logger.error(error.stack);
|
|
441
|
-
}
|
|
442
450
|
const shouldNotRetry = error instanceof task_1.NonRetryableError;
|
|
443
451
|
try {
|
|
452
|
+
if (context.cancelled) {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
this.logger.error(`Step run ${action.stepRunId} failed: ${error.message}`);
|
|
456
|
+
if (error.stack) {
|
|
457
|
+
this.logger.error(error.stack);
|
|
458
|
+
}
|
|
444
459
|
// Send the action event to the dispatcher
|
|
445
460
|
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, shouldNotRetry, {
|
|
446
461
|
message: error === null || error === void 0 ? void 0 : error.message,
|
package/v1/declaration.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import WorkflowRunRef from '../util/workflow-run-ref';
|
|
2
2
|
import { CronWorkflows, ScheduledWorkflows, V1CreateFilterRequest } from '../clients/rest/generated/data-contracts';
|
|
3
3
|
import { Workflow as WorkflowV0 } from '../workflow';
|
|
4
|
+
import { z } from 'zod';
|
|
4
5
|
import { IHatchetClient } from './client/client.interface';
|
|
5
6
|
import { CreateWorkflowTaskOpts, CreateOnFailureTaskOpts, TaskFn, CreateWorkflowDurableTaskOpts, CreateBaseTaskOpts, CreateOnSuccessTaskOpts, Concurrency, DurableTaskFn } from './task';
|
|
6
7
|
import { Duration } from './client/duration';
|
|
@@ -90,6 +91,12 @@ export type CreateBaseWorkflowOpts = {
|
|
|
90
91
|
*/
|
|
91
92
|
defaultPriority?: Priority;
|
|
92
93
|
defaultFilters?: DefaultFilter[];
|
|
94
|
+
/**
|
|
95
|
+
* (optional) Zod schema for the workflow input.
|
|
96
|
+
* When provided, a JSON Schema is generated and sent to the Hatchet backend, which
|
|
97
|
+
* can be used on the dashboard for autocomplete.
|
|
98
|
+
*/
|
|
99
|
+
inputValidator?: z.ZodType<any>;
|
|
93
100
|
};
|
|
94
101
|
export type CreateTaskWorkflowOpts<I extends InputType = UnknownInputType, O extends OutputType = void> = CreateBaseWorkflowOpts & CreateBaseTaskOpts<I, O, TaskFn<I, O>>;
|
|
95
102
|
export type CreateDurableTaskWorkflowOpts<I extends InputType = UnknownInputType, O extends OutputType = void> = CreateBaseWorkflowOpts & CreateBaseTaskOpts<I, O, DurableTaskFn<I, O>>;
|
|
@@ -363,7 +370,8 @@ export declare function CreateTaskWorkflow<Fn extends (input: I, ctx?: any) => O
|
|
|
363
370
|
* Creates a new workflow instance.
|
|
364
371
|
* @template I The input type for the workflow.
|
|
365
372
|
* @template O The return type of the workflow.
|
|
366
|
-
* @param options The options for creating the workflow.
|
|
373
|
+
* @param options The options for creating the workflow. Optionally include a Zod schema
|
|
374
|
+
* via the `input` field to generate a JSON Schema for the backend.
|
|
367
375
|
* @param client Optional Hatchet client instance.
|
|
368
376
|
* @returns A new Workflow instance.
|
|
369
377
|
*/
|
package/v1/declaration.js
CHANGED
|
@@ -360,7 +360,8 @@ function CreateTaskWorkflow(options, client) {
|
|
|
360
360
|
* Creates a new workflow instance.
|
|
361
361
|
* @template I The input type for the workflow.
|
|
362
362
|
* @template O The return type of the workflow.
|
|
363
|
-
* @param options The options for creating the workflow.
|
|
363
|
+
* @param options The options for creating the workflow. Optionally include a Zod schema
|
|
364
|
+
* via the `input` field to generate a JSON Schema for the backend.
|
|
364
365
|
* @param client Optional Hatchet client instance.
|
|
365
366
|
* @returns A new Workflow instance.
|
|
366
367
|
*/
|
|
@@ -13,11 +13,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
const hatchet_client_1 = require("../hatchet-client");
|
|
14
14
|
const workflow_1 = require("./workflow");
|
|
15
15
|
const workflow_with_child_1 = require("./workflow-with-child");
|
|
16
|
+
const zod_1 = require("./zod");
|
|
16
17
|
function main() {
|
|
17
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
19
|
const worker = yield hatchet_client_1.hatchet.worker('simple-worker', {
|
|
19
20
|
// 👀 Declare the workflows that the worker can execute
|
|
20
|
-
workflows: [workflow_1.simple, workflow_with_child_1.parent, workflow_with_child_1.child],
|
|
21
|
+
workflows: [workflow_1.simple, zod_1.simpleWithZod, workflow_with_child_1.parent, workflow_with_child_1.child],
|
|
21
22
|
// 👀 Declare the number of concurrent task runs the worker can accept
|
|
22
23
|
slots: 100,
|
|
23
24
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
declare const SimpleInputSchema: z.ZodObject<{
|
|
3
|
+
Message: z.ZodString;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
Message: string;
|
|
6
|
+
}, {
|
|
7
|
+
Message: string;
|
|
8
|
+
}>;
|
|
9
|
+
export type SimpleInputWithZod = z.infer<typeof SimpleInputSchema>;
|
|
10
|
+
export declare const simpleWithZod: import("../..").TaskWorkflowDeclaration<{
|
|
11
|
+
Message: string;
|
|
12
|
+
}, {
|
|
13
|
+
TransformedMessage: string;
|
|
14
|
+
}>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.simpleWithZod = void 0;
|
|
46
|
+
// > Declaring a Task
|
|
47
|
+
const z = __importStar(require("zod"));
|
|
48
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
49
|
+
const SimpleInputSchema = z.object({
|
|
50
|
+
Message: z.string(),
|
|
51
|
+
});
|
|
52
|
+
exports.simpleWithZod = hatchet_client_1.hatchet.task({
|
|
53
|
+
name: 'simple-with-zod',
|
|
54
|
+
retries: 3,
|
|
55
|
+
fn: (input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
return {
|
|
57
|
+
TransformedMessage: input.Message.toLowerCase(),
|
|
58
|
+
};
|
|
59
|
+
}),
|
|
60
|
+
inputValidator: SimpleInputSchema,
|
|
61
|
+
});
|
|
62
|
+
// !!
|
|
63
|
+
// see ./worker.ts and ./run.ts for how to run the workflow
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.10.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.10.7";
|
package/version.js
CHANGED