@hatchet-dev/typescript-sdk 0.1.25 → 0.1.27
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/action-listener.d.ts +1 -0
- package/clients/dispatcher/action-listener.js +5 -0
- package/clients/listener/listener-client.d.ts +4 -1
- package/clients/listener/listener-client.js +27 -12
- package/clients/rest/generated/Api.d.ts +32 -1
- package/clients/rest/generated/Api.js +29 -0
- package/clients/rest/generated/data-contracts.d.ts +13 -1
- package/clients/worker/worker.d.ts +1 -1
- package/clients/worker/worker.js +12 -6
- package/package.json +13 -7
- package/step.d.ts +1 -1
|
@@ -25,6 +25,7 @@ export declare class ActionListener {
|
|
|
25
25
|
retries: number;
|
|
26
26
|
retryInterval: number;
|
|
27
27
|
retryCount: number;
|
|
28
|
+
done: boolean;
|
|
28
29
|
constructor(client: DispatcherClient, workerId: string, retryInterval?: number, retryCount?: number);
|
|
29
30
|
actions: () => AsyncGenerator<Action, void, unknown>;
|
|
30
31
|
incrementRetries(): Promise<void>;
|
|
@@ -45,10 +45,14 @@ class ActionListener {
|
|
|
45
45
|
this.retries = 0;
|
|
46
46
|
this.retryInterval = DEFAULT_ACTION_LISTENER_RETRY_INTERVAL;
|
|
47
47
|
this.retryCount = DEFAULT_ACTION_LISTENER_RETRY_COUNT;
|
|
48
|
+
this.done = false;
|
|
48
49
|
this.actions = () => (function gen(client) {
|
|
49
50
|
return __asyncGenerator(this, arguments, function* gen_1() {
|
|
50
51
|
var _a, e_1, _b, _c;
|
|
51
52
|
while (true) {
|
|
53
|
+
if (client.done) {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
52
56
|
try {
|
|
53
57
|
try {
|
|
54
58
|
for (var _d = true, _e = (e_1 = void 0, __asyncValues(yield __await(client.getListenClient()))), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
|
|
@@ -121,6 +125,7 @@ class ActionListener {
|
|
|
121
125
|
}
|
|
122
126
|
unregister() {
|
|
123
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
this.done = true;
|
|
124
129
|
try {
|
|
125
130
|
return this.client.unsubscribe({
|
|
126
131
|
workerId: this.workerId,
|
|
@@ -18,6 +18,9 @@ export declare class ListenerClient {
|
|
|
18
18
|
client: PbDispatcherClient;
|
|
19
19
|
logger: Logger;
|
|
20
20
|
constructor(config: ClientConfig, channel: Channel, factory: ClientFactory);
|
|
21
|
-
|
|
21
|
+
stream(workflowRunId: string): AsyncGenerator<{
|
|
22
|
+
type: StepRunEventType;
|
|
23
|
+
payload: string;
|
|
24
|
+
}, void, unknown>;
|
|
22
25
|
retrySubscribe(workflowRunId: string): Promise<AsyncIterable<import("../../protoc/dispatcher").WorkflowEvent>>;
|
|
23
26
|
}
|
|
@@ -15,6 +15,19 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
15
15
|
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
16
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
17
|
};
|
|
18
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
19
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
20
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
21
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
22
|
+
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
23
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
24
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
25
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
26
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
27
|
+
function fulfill(value) { resume("next", value); }
|
|
28
|
+
function reject(value) { resume("throw", value); }
|
|
29
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
30
|
+
};
|
|
18
31
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
32
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
33
|
};
|
|
@@ -42,15 +55,15 @@ class ListenerClient {
|
|
|
42
55
|
this.client = factory.create(dispatcher_1.DispatcherDefinition, channel);
|
|
43
56
|
this.logger = new logger_1.Logger(`Listener`, config.log_level);
|
|
44
57
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
stream(workflowRunId) {
|
|
59
|
+
return __asyncGenerator(this, arguments, function* stream_1() {
|
|
60
|
+
var _a, e_1, _b, _c;
|
|
48
61
|
let listener = this.client.subscribeToWorkflowEvents({
|
|
49
62
|
workflowRunId,
|
|
50
63
|
});
|
|
51
64
|
try {
|
|
52
65
|
try {
|
|
53
|
-
for (var _d = true, listener_1 = __asyncValues(listener), listener_1_1; listener_1_1 = yield listener_1.next(), _a = listener_1_1.done, !_a; _d = true) {
|
|
66
|
+
for (var _d = true, listener_1 = __asyncValues(listener), listener_1_1; listener_1_1 = yield __await(listener_1.next()), _a = listener_1_1.done, !_a; _d = true) {
|
|
54
67
|
_c = listener_1_1.value;
|
|
55
68
|
_d = false;
|
|
56
69
|
const workflowEvent = _c;
|
|
@@ -72,28 +85,30 @@ class ListenerClient {
|
|
|
72
85
|
eventType = StepRunEventType.STEP_RUN_EVENT_TYPE_TIMED_OUT;
|
|
73
86
|
break;
|
|
74
87
|
default:
|
|
75
|
-
|
|
88
|
+
// no nothing
|
|
89
|
+
}
|
|
90
|
+
if (eventType) {
|
|
91
|
+
yield yield __await({
|
|
92
|
+
type: eventType,
|
|
93
|
+
payload: workflowEvent.eventPayload,
|
|
94
|
+
});
|
|
76
95
|
}
|
|
77
|
-
yield handler({
|
|
78
|
-
type: eventType,
|
|
79
|
-
payload: workflowEvent.eventPayload,
|
|
80
|
-
});
|
|
81
96
|
}
|
|
82
97
|
}
|
|
83
98
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
84
99
|
finally {
|
|
85
100
|
try {
|
|
86
|
-
if (!_d && !_a && (_b = listener_1.return)) yield _b.call(listener_1);
|
|
101
|
+
if (!_d && !_a && (_b = listener_1.return)) yield __await(_b.call(listener_1));
|
|
87
102
|
}
|
|
88
103
|
finally { if (e_1) throw e_1.error; }
|
|
89
104
|
}
|
|
90
105
|
}
|
|
91
106
|
catch (e) {
|
|
92
107
|
if (e.code === nice_grpc_1.Status.CANCELLED) {
|
|
93
|
-
return;
|
|
108
|
+
return yield __await(void 0);
|
|
94
109
|
}
|
|
95
110
|
if (e.code === nice_grpc_1.Status.UNAVAILABLE) {
|
|
96
|
-
listener = yield this.retrySubscribe(workflowRunId);
|
|
111
|
+
listener = yield __await(this.retrySubscribe(workflowRunId));
|
|
97
112
|
}
|
|
98
113
|
}
|
|
99
114
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APIMeta, AcceptInviteRequest, CreateAPITokenRequest, CreateAPITokenResponse, CreatePullRequestFromStepRun, CreateTenantInviteRequest, CreateTenantRequest, EventData, EventKey, EventKeyList, EventList, EventOrderByDirection, EventOrderByField, EventSearch, GetStepRunDiffResponse, LinkGithubRepositoryRequest, ListAPIMetaIntegration, ListAPITokensResponse, ListGithubAppInstallationsResponse, ListGithubBranchesResponse, ListGithubReposResponse, ListPullRequestsResponse, LogLineLevelField, LogLineList, LogLineOrderByDirection, LogLineOrderByField, LogLineSearch, PullRequestState, RejectInviteRequest, ReplayEventRequest, RerunStepRunRequest, StepRun, Tenant, TenantInvite, TenantInviteList, TenantMemberList, TriggerWorkflowRunRequest, UpdateTenantInviteRequest, User, UserLoginRequest, UserRegisterRequest, UserTenantMembershipsList, Worker, WorkerList, Workflow, WorkflowID, WorkflowList, WorkflowRun, WorkflowRunList, WorkflowVersion, WorkflowVersionDefinition } from './data-contracts';
|
|
1
|
+
import { APIMeta, AcceptInviteRequest, CreateAPITokenRequest, CreateAPITokenResponse, CreatePullRequestFromStepRun, CreateTenantInviteRequest, CreateTenantRequest, EventData, EventKey, EventKeyList, EventList, EventOrderByDirection, EventOrderByField, EventSearch, GetStepRunDiffResponse, LinkGithubRepositoryRequest, ListAPIMetaIntegration, ListAPITokensResponse, ListGithubAppInstallationsResponse, ListGithubBranchesResponse, ListGithubReposResponse, ListPullRequestsResponse, LogLineLevelField, LogLineList, LogLineOrderByDirection, LogLineOrderByField, LogLineSearch, PullRequestState, RejectInviteRequest, ReplayEventRequest, RerunStepRunRequest, StepRun, Tenant, TenantInvite, TenantInviteList, TenantMemberList, TriggerWorkflowRunRequest, UpdateTenantInviteRequest, User, UserLoginRequest, UserRegisterRequest, UserTenantMembershipsList, Worker, WorkerList, Workflow, WorkflowID, WorkflowList, WorkflowRun, WorkflowRunList, WorkflowRunStatusList, WorkflowVersion, WorkflowVersionDefinition } from './data-contracts';
|
|
2
2
|
import { HttpClient, RequestParams } from './http-client';
|
|
3
3
|
export declare class Api<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
|
|
4
4
|
/**
|
|
@@ -103,6 +103,15 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
|
|
|
103
103
|
* @request POST:/api/v1/github/webhook/{webhook}
|
|
104
104
|
*/
|
|
105
105
|
githubUpdateTenantWebhook: (webhook: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any>>;
|
|
106
|
+
/**
|
|
107
|
+
* @description SNS event
|
|
108
|
+
*
|
|
109
|
+
* @tags Github
|
|
110
|
+
* @name SnsUpdate
|
|
111
|
+
* @summary Github app tenant webhook
|
|
112
|
+
* @request POST:/api/v1/sns/{tenant}/{event}
|
|
113
|
+
*/
|
|
114
|
+
snsUpdate: (tenant: string, event: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any>>;
|
|
106
115
|
/**
|
|
107
116
|
* @description Gets the current user
|
|
108
117
|
*
|
|
@@ -274,6 +283,8 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
|
|
|
274
283
|
keys?: EventKey[];
|
|
275
284
|
/** A list of workflow IDs to filter by */
|
|
276
285
|
workflows?: WorkflowID[];
|
|
286
|
+
/** A list of workflow run statuses to filter by */
|
|
287
|
+
statuses?: WorkflowRunStatusList;
|
|
277
288
|
/** The search query to filter for */
|
|
278
289
|
search?: EventSearch;
|
|
279
290
|
/** What to order by */
|
|
@@ -341,6 +352,16 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
|
|
|
341
352
|
* @secure
|
|
342
353
|
*/
|
|
343
354
|
workflowGet: (workflow: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<Workflow, any>>;
|
|
355
|
+
/**
|
|
356
|
+
* @description Delete a workflow for a tenant
|
|
357
|
+
*
|
|
358
|
+
* @tags Workflow
|
|
359
|
+
* @name WorkflowDelete
|
|
360
|
+
* @summary Delete workflow
|
|
361
|
+
* @request DELETE:/api/v1/workflows/{workflow}
|
|
362
|
+
* @secure
|
|
363
|
+
*/
|
|
364
|
+
workflowDelete: (workflow: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any>>;
|
|
344
365
|
/**
|
|
345
366
|
* @description Get a workflow version for a tenant
|
|
346
367
|
*
|
|
@@ -532,6 +553,16 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
|
|
|
532
553
|
* @secure
|
|
533
554
|
*/
|
|
534
555
|
stepRunUpdateRerun: (tenant: string, stepRun: string, data: RerunStepRunRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<StepRun, any>>;
|
|
556
|
+
/**
|
|
557
|
+
* @description Get the schema for a step run
|
|
558
|
+
*
|
|
559
|
+
* @tags Step Run
|
|
560
|
+
* @name StepRunGetSchema
|
|
561
|
+
* @summary Get step run schema
|
|
562
|
+
* @request GET:/api/v1/tenants/{tenant}/step-runs/{step-run}/schema
|
|
563
|
+
* @secure
|
|
564
|
+
*/
|
|
565
|
+
stepRunGetSchema: (tenant: string, stepRun: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<object, any>>;
|
|
535
566
|
/**
|
|
536
567
|
* @description Get all workers for a tenant
|
|
537
568
|
*
|
|
@@ -117,6 +117,15 @@ class Api extends http_client_1.HttpClient {
|
|
|
117
117
|
* @request POST:/api/v1/github/webhook/{webhook}
|
|
118
118
|
*/
|
|
119
119
|
this.githubUpdateTenantWebhook = (webhook, params = {}) => this.request(Object.assign({ path: `/api/v1/github/webhook/${webhook}`, method: 'POST' }, params));
|
|
120
|
+
/**
|
|
121
|
+
* @description SNS event
|
|
122
|
+
*
|
|
123
|
+
* @tags Github
|
|
124
|
+
* @name SnsUpdate
|
|
125
|
+
* @summary Github app tenant webhook
|
|
126
|
+
* @request POST:/api/v1/sns/{tenant}/{event}
|
|
127
|
+
*/
|
|
128
|
+
this.snsUpdate = (tenant, event, params = {}) => this.request(Object.assign({ path: `/api/v1/sns/${tenant}/${event}`, method: 'POST' }, params));
|
|
120
129
|
/**
|
|
121
130
|
* @description Gets the current user
|
|
122
131
|
*
|
|
@@ -334,6 +343,16 @@ class Api extends http_client_1.HttpClient {
|
|
|
334
343
|
* @secure
|
|
335
344
|
*/
|
|
336
345
|
this.workflowGet = (workflow, params = {}) => this.request(Object.assign({ path: `/api/v1/workflows/${workflow}`, method: 'GET', secure: true, format: 'json' }, params));
|
|
346
|
+
/**
|
|
347
|
+
* @description Delete a workflow for a tenant
|
|
348
|
+
*
|
|
349
|
+
* @tags Workflow
|
|
350
|
+
* @name WorkflowDelete
|
|
351
|
+
* @summary Delete workflow
|
|
352
|
+
* @request DELETE:/api/v1/workflows/{workflow}
|
|
353
|
+
* @secure
|
|
354
|
+
*/
|
|
355
|
+
this.workflowDelete = (workflow, params = {}) => this.request(Object.assign({ path: `/api/v1/workflows/${workflow}`, method: 'DELETE', secure: true }, params));
|
|
337
356
|
/**
|
|
338
357
|
* @description Get a workflow version for a tenant
|
|
339
358
|
*
|
|
@@ -454,6 +473,16 @@ class Api extends http_client_1.HttpClient {
|
|
|
454
473
|
* @secure
|
|
455
474
|
*/
|
|
456
475
|
this.stepRunUpdateRerun = (tenant, stepRun, data, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/step-runs/${stepRun}/rerun`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
|
|
476
|
+
/**
|
|
477
|
+
* @description Get the schema for a step run
|
|
478
|
+
*
|
|
479
|
+
* @tags Step Run
|
|
480
|
+
* @name StepRunGetSchema
|
|
481
|
+
* @summary Get step run schema
|
|
482
|
+
* @request GET:/api/v1/tenants/{tenant}/step-runs/{step-run}/schema
|
|
483
|
+
* @secure
|
|
484
|
+
*/
|
|
485
|
+
this.stepRunGetSchema = (tenant, stepRun, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/step-runs/${stepRun}/schema`, method: 'GET', secure: true, format: 'json' }, params));
|
|
457
486
|
/**
|
|
458
487
|
* @description Get all workers for a tenant
|
|
459
488
|
*
|
|
@@ -287,6 +287,17 @@ export interface Workflow {
|
|
|
287
287
|
jobs?: Job[];
|
|
288
288
|
deployment?: WorkflowDeploymentConfig;
|
|
289
289
|
}
|
|
290
|
+
export interface WorkflowConcurrency {
|
|
291
|
+
/**
|
|
292
|
+
* The maximum number of concurrent workflow runs.
|
|
293
|
+
* @format int32
|
|
294
|
+
*/
|
|
295
|
+
maxRuns: number;
|
|
296
|
+
/** The strategy to use when the concurrency limit is reached. */
|
|
297
|
+
limitStrategy: 'CANCEL_IN_PROGRESS' | 'DROP_NEWEST' | 'QUEUE_NEWEST' | 'GROUP_ROUND_ROBIN';
|
|
298
|
+
/** An action which gets the concurrency group for the WorkflowRun. */
|
|
299
|
+
getConcurrencyGroup: string;
|
|
300
|
+
}
|
|
290
301
|
export interface WorkflowDeploymentConfig {
|
|
291
302
|
metadata: APIResourceMeta;
|
|
292
303
|
/** The repository name. */
|
|
@@ -320,6 +331,7 @@ export interface WorkflowVersion {
|
|
|
320
331
|
order: number;
|
|
321
332
|
workflowId: string;
|
|
322
333
|
workflow?: Workflow;
|
|
334
|
+
concurrency?: WorkflowConcurrency;
|
|
323
335
|
triggers?: WorkflowTriggers;
|
|
324
336
|
jobs?: Job[];
|
|
325
337
|
}
|
|
@@ -403,6 +415,7 @@ export declare enum WorkflowRunStatus {
|
|
|
403
415
|
FAILED = "FAILED",
|
|
404
416
|
CANCELLED = "CANCELLED"
|
|
405
417
|
}
|
|
418
|
+
export type WorkflowRunStatusList = WorkflowRunStatus[];
|
|
406
419
|
export declare enum JobRunStatus {
|
|
407
420
|
PENDING = "PENDING",
|
|
408
421
|
RUNNING = "RUNNING",
|
|
@@ -480,7 +493,6 @@ export interface StepRun {
|
|
|
480
493
|
cancelledAtEpoch?: number;
|
|
481
494
|
cancelledReason?: string;
|
|
482
495
|
cancelledError?: string;
|
|
483
|
-
inputSchema?: string;
|
|
484
496
|
}
|
|
485
497
|
export interface WorkerList {
|
|
486
498
|
pagination?: PaginationResponse;
|
|
@@ -30,6 +30,6 @@ export declare class Worker {
|
|
|
30
30
|
getGroupKeyActionEvent(action: Action, eventType: GroupKeyActionEventType, payload?: any): GroupKeyActionEvent;
|
|
31
31
|
handleCancelStepRun(action: Action): void;
|
|
32
32
|
stop(): Promise<void>;
|
|
33
|
-
exitGracefully(): Promise<void>;
|
|
33
|
+
exitGracefully(handleKill: boolean): Promise<void>;
|
|
34
34
|
start(): Promise<void>;
|
|
35
35
|
}
|
package/clients/worker/worker.js
CHANGED
|
@@ -35,8 +35,8 @@ class Worker {
|
|
|
35
35
|
this.name = options.name;
|
|
36
36
|
this.action_registry = {};
|
|
37
37
|
this.maxRuns = options.maxRuns;
|
|
38
|
-
process.on('SIGTERM', () => this.exitGracefully());
|
|
39
|
-
process.on('SIGINT', () => this.exitGracefully());
|
|
38
|
+
process.on('SIGTERM', () => this.exitGracefully(true));
|
|
39
|
+
process.on('SIGINT', () => this.exitGracefully(true));
|
|
40
40
|
this.killing = false;
|
|
41
41
|
this.handle_kill = options.handleKill === undefined ? true : options.handleKill;
|
|
42
42
|
this.logger = new logger_1.Logger(`Worker/${this.name}`, this.client.config.log_level);
|
|
@@ -245,16 +245,16 @@ class Worker {
|
|
|
245
245
|
}
|
|
246
246
|
stop() {
|
|
247
247
|
return __awaiter(this, void 0, void 0, function* () {
|
|
248
|
-
yield this.exitGracefully();
|
|
248
|
+
yield this.exitGracefully(false);
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
|
-
exitGracefully() {
|
|
251
|
+
exitGracefully(handleKill) {
|
|
252
252
|
var _a;
|
|
253
253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
254
254
|
this.killing = true;
|
|
255
255
|
this.logger.info('Starting to exit...');
|
|
256
256
|
try {
|
|
257
|
-
(_a = this.listener) === null || _a === void 0 ? void 0 : _a.unregister();
|
|
257
|
+
yield ((_a = this.listener) === null || _a === void 0 ? void 0 : _a.unregister());
|
|
258
258
|
}
|
|
259
259
|
catch (e) {
|
|
260
260
|
this.logger.error(`Could not unregister listener: ${e.message}`);
|
|
@@ -262,7 +262,8 @@ class Worker {
|
|
|
262
262
|
this.logger.info('Gracefully exiting hatchet worker, running tasks will attempt to finish...');
|
|
263
263
|
// attempt to wait for futures to finish
|
|
264
264
|
yield Promise.all(Object.values(this.futures).map(({ promise }) => promise));
|
|
265
|
-
|
|
265
|
+
this.logger.info('Successfully finished pending tasks.');
|
|
266
|
+
if (handleKill) {
|
|
266
267
|
this.logger.info('Exiting hatchet worker...');
|
|
267
268
|
process.exit(0);
|
|
268
269
|
}
|
|
@@ -309,6 +310,11 @@ class Worker {
|
|
|
309
310
|
}
|
|
310
311
|
}
|
|
311
312
|
catch (e) {
|
|
313
|
+
// TODO TEMP this needs to be handled better
|
|
314
|
+
if (this.killing) {
|
|
315
|
+
this.logger.info(`Exiting worker, ignoring error: ${e.message}`);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
312
318
|
this.logger.error(`Could not run worker: ${e.message}`);
|
|
313
319
|
throw new hatchet_error_1.default(`Could not run worker: ${e.message}`);
|
|
314
320
|
}
|
package/package.json
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hatchet-dev/typescript-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"description": "Background task orchestration & visibility for developers",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"*",
|
|
9
9
|
"!**/*.test.js",
|
|
10
|
-
"!**/*.test.d.ts"
|
|
10
|
+
"!**/*.test.d.ts",
|
|
11
|
+
"!**/*.e2e.js",
|
|
12
|
+
"!**/*.e2e.d.ts"
|
|
11
13
|
],
|
|
12
14
|
"repository": {
|
|
13
15
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/hatchet-dev/hatchet.git"
|
|
16
|
+
"url": "https://github.com/hatchet-dev/hatchet-typescript.git"
|
|
15
17
|
},
|
|
16
18
|
"scripts": {
|
|
17
19
|
"build": "echo 'build hatchet sdk with `npn run tsc:build` to ensure it is not build during the publish step' && exit 0",
|
|
18
20
|
"prepare": "npm run build",
|
|
19
21
|
"tsc:build": "tsc && resolve-tspaths",
|
|
20
|
-
"test": "jest",
|
|
21
|
-
"test:
|
|
22
|
-
"
|
|
22
|
+
"test:unit": "jest --testMatch='**/*.test.ts'",
|
|
23
|
+
"test:e2e": "jest --testMatch='**/*.e2e.ts'",
|
|
24
|
+
"test:unit:watch": "jest --testMatch='**/*.test.ts' --watch",
|
|
25
|
+
"generate": "pnpm run '/generate-.*/'",
|
|
26
|
+
"generate-api": "npx --yes swagger-cli bundle ./hatchet/api-contracts/openapi/openapi.yaml --outfile openapi.yaml --type yaml && npx swagger-typescript-api -p openapi.yaml -o src/clients/rest/generated -n hatchet.ts --modular --axios",
|
|
27
|
+
"generate-protoc": "./generate-protoc.sh",
|
|
23
28
|
"lint:check": "npm run eslint:check && npm run prettier:check",
|
|
24
29
|
"lint:fix": "npm run eslint:fix && npm run prettier:fix",
|
|
25
30
|
"eslint:check": "eslint \"{hatchet,tests}/**/*.{ts,tsx,js}\"",
|
|
@@ -28,6 +33,7 @@
|
|
|
28
33
|
"prettier:fix": "prettier \"hatchet/**/*.{ts,tsx}\" --write",
|
|
29
34
|
"exec": "npx dotenv -- ts-node -r tsconfig-paths/register --project tsconfig.json",
|
|
30
35
|
"example:event": "npm run exec -- ./examples/example-event.ts",
|
|
36
|
+
"example:event-listen": "npm run exec -- ./examples/example-event-with-results.ts",
|
|
31
37
|
"worker:simple": "npm run exec -- ./examples/simple-worker.ts",
|
|
32
38
|
"manual:trigger": "npm run exec -- ./examples/manual-trigger.ts",
|
|
33
39
|
"worker:dag": "npm run exec -- ./examples/dag-worker.ts",
|
|
@@ -86,4 +92,4 @@
|
|
|
86
92
|
"yaml": "^2.3.4",
|
|
87
93
|
"zod": "^3.22.4"
|
|
88
94
|
}
|
|
89
|
-
}
|
|
95
|
+
}
|
package/step.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare const CreateStepSchema: z.ZodObject<{
|
|
|
21
21
|
}>;
|
|
22
22
|
type JSONPrimitive = string | number | boolean | null | Array<JSONPrimitive>;
|
|
23
23
|
export type NextStep = {
|
|
24
|
-
[key: string]: NextStep | JSONPrimitive
|
|
24
|
+
[key: string]: NextStep | JSONPrimitive | Array<NextStep>;
|
|
25
25
|
};
|
|
26
26
|
interface ContextData<T, K> {
|
|
27
27
|
input: T;
|