@hatchet-dev/typescript-sdk 1.9.3 → 1.9.5
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 +16 -0
- package/clients/rest/generated/Api.d.ts +67 -1
- package/clients/rest/generated/Api.js +48 -0
- package/clients/rest/generated/data-contracts.d.ts +68 -0
- package/clients/rest/generated/data-contracts.js +13 -1
- package/examples/byo-logger.js +6 -6
- package/package.json +3 -3
- package/v1/client/worker/worker-internal.js +6 -2
- package/v1/declaration.d.ts +1 -1
- package/v1/examples/affinity/affinity-workers.d.ts +1 -0
- package/v1/examples/affinity/affinity-workers.js +87 -0
- package/v1/examples/logging/byo-logger.d.ts +1 -0
- package/v1/examples/logging/byo-logger.js +73 -0
- package/v1/examples/logging/logger.d.ts +1 -0
- package/v1/examples/logging/logger.js +46 -0
- package/v1/examples/with_timeouts/workflow.js +0 -1
- package/v1/task.d.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -23,6 +23,7 @@ export declare class ActionListener {
|
|
|
23
23
|
done: boolean;
|
|
24
24
|
listenStrategy: ListenStrategy;
|
|
25
25
|
heartbeat: Heartbeat;
|
|
26
|
+
abortController?: AbortController;
|
|
26
27
|
constructor(client: DispatcherClient, workerId: string, retryInterval?: number, retryCount?: number);
|
|
27
28
|
actions: () => AsyncGenerator<Action, void, unknown>;
|
|
28
29
|
setListenStrategy(strategy: ListenStrategy): Promise<void>;
|
|
@@ -36,6 +36,7 @@ exports.ActionListener = void 0;
|
|
|
36
36
|
exports.createActionKey = createActionKey;
|
|
37
37
|
const dispatcher_1 = require("../../protoc/dispatcher");
|
|
38
38
|
const nice_grpc_1 = require("nice-grpc");
|
|
39
|
+
const abort_controller_x_1 = require("abort-controller-x");
|
|
39
40
|
const sleep_1 = __importDefault(require("../../util/sleep"));
|
|
40
41
|
const hatchet_error_1 = __importDefault(require("../../util/errors/hatchet-error"));
|
|
41
42
|
const heartbeat_controller_1 = require("./heartbeat/heartbeat-controller");
|
|
@@ -96,6 +97,11 @@ class ActionListener {
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
catch (e) {
|
|
100
|
+
// If the stream was aborted (e.g., during worker shutdown), exit gracefully
|
|
101
|
+
if ((0, abort_controller_x_1.isAbortError)(e)) {
|
|
102
|
+
client.logger.info('Listener aborted, exiting generator');
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
99
105
|
client.logger.info('Listener error');
|
|
100
106
|
// if this is a HatchetError, we should throw this error
|
|
101
107
|
if (e instanceof hatchet_error_1.default) {
|
|
@@ -157,15 +163,21 @@ class ActionListener {
|
|
|
157
163
|
yield (0, sleep_1.default)(DEFAULT_ACTION_LISTENER_RETRY_INTERVAL);
|
|
158
164
|
}
|
|
159
165
|
try {
|
|
166
|
+
// Create a new AbortController for this connection
|
|
167
|
+
this.abortController = new AbortController();
|
|
160
168
|
if (this.listenStrategy === ListenStrategy.LISTEN_STRATEGY_V1) {
|
|
161
169
|
const result = this.client.listen({
|
|
162
170
|
workerId: this.workerId,
|
|
171
|
+
}, {
|
|
172
|
+
signal: this.abortController.signal,
|
|
163
173
|
});
|
|
164
174
|
this.logger.green('Connection established using LISTEN_STRATEGY_V1');
|
|
165
175
|
return result;
|
|
166
176
|
}
|
|
167
177
|
const res = this.client.listenV2({
|
|
168
178
|
workerId: this.workerId,
|
|
179
|
+
}, {
|
|
180
|
+
signal: this.abortController.signal,
|
|
169
181
|
});
|
|
170
182
|
yield this.heartbeat.start();
|
|
171
183
|
this.logger.green('Connection established using LISTEN_STRATEGY_V2');
|
|
@@ -187,6 +199,10 @@ class ActionListener {
|
|
|
187
199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
188
200
|
this.done = true;
|
|
189
201
|
this.heartbeat.stop();
|
|
202
|
+
// Abort the gRPC stream to immediately cancel the generator
|
|
203
|
+
if (this.abortController) {
|
|
204
|
+
this.abortController.abort('Worker stopping');
|
|
205
|
+
}
|
|
190
206
|
try {
|
|
191
207
|
return yield this.client.unsubscribe({
|
|
192
208
|
workerId: this.workerId,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AcceptInviteRequest, APIErrors, APIMeta, BulkCreateEventRequest, BulkCreateEventResponse, CancelEventRequest, CreateAPITokenRequest, CreateAPITokenResponse, CreateCronWorkflowTriggerRequest, CreateEventRequest, CreateSNSIntegrationRequest, CreateTenantAlertEmailGroupRequest, CreateTenantInviteRequest, CreateTenantRequest, CronWorkflows, CronWorkflowsList, CronWorkflowsOrderByField, Event, EventData, EventKey, EventKeyList, EventList, EventOrderByDirection, EventOrderByField, EventSearch, ListAPIMetaIntegration, ListAPITokensResponse, ListSlackWebhooks, ListSNSIntegrations, LogLineLevelField, LogLineList, LogLineOrderByDirection, LogLineOrderByField, LogLineSearch, RateLimitList, RateLimitOrderByDirection, RateLimitOrderByField, RejectInviteRequest, ReplayEventRequest, ReplayWorkflowRunsRequest, ReplayWorkflowRunsResponse, RerunStepRunRequest, ScheduledRunStatus, ScheduledWorkflows, ScheduledWorkflowsList, ScheduledWorkflowsOrderByField, ScheduleWorkflowRunRequest, SNSIntegration, StepRun, StepRunArchiveList, StepRunEventList, Tenant, TenantAlertEmailGroup, TenantAlertEmailGroupList, TenantAlertingSettings, TenantInvite, TenantInviteList, TenantMember, TenantMemberList, TenantQueueMetrics, TenantResourcePolicy, TenantStepRunQueueMetrics, TriggerWorkflowRunRequest, UpdateTenantAlertEmailGroupRequest, UpdateTenantInviteRequest, UpdateTenantRequest, UpdateWorkerRequest, User, UserChangePasswordRequest, UserLoginRequest, UserRegisterRequest, UserTenantMembershipsList, V1CancelledTasks, V1CancelTaskRequest, V1CELDebugRequest, V1CELDebugResponse, V1CreateFilterRequest, V1DagChildren, V1EventList, V1Filter, V1FilterList, V1LogLineList, V1ReplayedTasks, V1ReplayTaskRequest, V1TaskEventList, V1TaskPointMetrics, V1TaskRunMetrics, V1TaskStatus, V1TaskSummary, V1TaskSummaryList, V1TaskTimingList, V1TriggerWorkflowRunRequest, V1UpdateFilterRequest, V1WorkflowRunDetails, V1WorkflowRunDisplayNameList, WebhookWorkerCreated, WebhookWorkerCreateRequest, WebhookWorkerListResponse, WebhookWorkerRequestListResponse, Worker, WorkerList, Workflow, WorkflowID, WorkflowKindList, WorkflowList, WorkflowMetrics, WorkflowRun, WorkflowRunList, WorkflowRunOrderByDirection, WorkflowRunOrderByField, WorkflowRunsCancelRequest, WorkflowRunShape, WorkflowRunsMetrics, WorkflowRunStatus, WorkflowRunStatusList, WorkflowUpdateRequest, WorkflowVersion, WorkflowWorkersCount } from './data-contracts';
|
|
1
|
+
import { AcceptInviteRequest, APIErrors, APIMeta, BulkCreateEventRequest, BulkCreateEventResponse, CancelEventRequest, CreateAPITokenRequest, CreateAPITokenResponse, CreateCronWorkflowTriggerRequest, CreateEventRequest, CreateSNSIntegrationRequest, CreateTenantAlertEmailGroupRequest, CreateTenantInviteRequest, CreateTenantRequest, CronWorkflows, CronWorkflowsList, CronWorkflowsOrderByField, Event, EventData, EventKey, EventKeyList, EventList, EventOrderByDirection, EventOrderByField, EventSearch, ListAPIMetaIntegration, ListAPITokensResponse, ListSlackWebhooks, ListSNSIntegrations, LogLineLevelField, LogLineList, LogLineOrderByDirection, LogLineOrderByField, LogLineSearch, RateLimitList, RateLimitOrderByDirection, RateLimitOrderByField, RejectInviteRequest, ReplayEventRequest, ReplayWorkflowRunsRequest, ReplayWorkflowRunsResponse, RerunStepRunRequest, ScheduledRunStatus, ScheduledWorkflows, ScheduledWorkflowsList, ScheduledWorkflowsOrderByField, ScheduleWorkflowRunRequest, SNSIntegration, StepRun, StepRunArchiveList, StepRunEventList, Tenant, TenantAlertEmailGroup, TenantAlertEmailGroupList, TenantAlertingSettings, TenantInvite, TenantInviteList, TenantMember, TenantMemberList, TenantQueueMetrics, TenantResourcePolicy, TenantStepRunQueueMetrics, TriggerWorkflowRunRequest, UpdateTenantAlertEmailGroupRequest, UpdateTenantInviteRequest, UpdateTenantRequest, UpdateWorkerRequest, User, UserChangePasswordRequest, UserLoginRequest, UserRegisterRequest, UserTenantMembershipsList, V1CancelledTasks, V1CancelTaskRequest, V1CELDebugRequest, V1CELDebugResponse, V1CreateFilterRequest, V1CreateWebhookRequest, V1DagChildren, V1EventList, V1Filter, V1FilterList, V1LogLineList, V1ReplayedTasks, V1ReplayTaskRequest, V1TaskEventList, V1TaskPointMetrics, V1TaskRunMetrics, V1TaskStatus, V1TaskSummary, V1TaskSummaryList, V1TaskTimingList, V1TriggerWorkflowRunRequest, V1UpdateFilterRequest, V1Webhook, V1WebhookList, V1WebhookSourceName, V1WorkflowRunDetails, V1WorkflowRunDisplayNameList, WebhookWorkerCreated, WebhookWorkerCreateRequest, WebhookWorkerListResponse, WebhookWorkerRequestListResponse, Worker, WorkerList, Workflow, WorkflowID, WorkflowKindList, WorkflowList, WorkflowMetrics, WorkflowRun, WorkflowRunList, WorkflowRunOrderByDirection, WorkflowRunOrderByField, WorkflowRunsCancelRequest, WorkflowRunShape, WorkflowRunsMetrics, WorkflowRunStatus, WorkflowRunStatusList, WorkflowUpdateRequest, WorkflowVersion, WorkflowWorkersCount } from './data-contracts';
|
|
2
2
|
import { HttpClient, RequestParams } from './http-client';
|
|
3
3
|
export declare class Api<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
|
|
4
4
|
/**
|
|
@@ -403,6 +403,72 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
|
|
|
403
403
|
* @secure
|
|
404
404
|
*/
|
|
405
405
|
v1FilterUpdate: (tenant: string, v1Filter: string, data: V1UpdateFilterRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1Filter, any>>;
|
|
406
|
+
/**
|
|
407
|
+
* @description Lists all webhook for a tenant.
|
|
408
|
+
*
|
|
409
|
+
* @tags Webhook
|
|
410
|
+
* @name V1WebhookList
|
|
411
|
+
* @summary List webhooks
|
|
412
|
+
* @request GET:/api/v1/stable/tenants/{tenant}/webhooks
|
|
413
|
+
* @secure
|
|
414
|
+
*/
|
|
415
|
+
v1WebhookList: (tenant: string, query?: {
|
|
416
|
+
/**
|
|
417
|
+
* The number to skip
|
|
418
|
+
* @format int64
|
|
419
|
+
*/
|
|
420
|
+
offset?: number;
|
|
421
|
+
/**
|
|
422
|
+
* The number to limit by
|
|
423
|
+
* @format int64
|
|
424
|
+
*/
|
|
425
|
+
limit?: number;
|
|
426
|
+
/** The source names to filter by */
|
|
427
|
+
sourceNames?: V1WebhookSourceName[];
|
|
428
|
+
/** The webhook names to filter by */
|
|
429
|
+
webhookNames?: string[];
|
|
430
|
+
}, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1WebhookList, any>>;
|
|
431
|
+
/**
|
|
432
|
+
* @description Create a new webhook
|
|
433
|
+
*
|
|
434
|
+
* @tags Webhook
|
|
435
|
+
* @name V1WebhookCreate
|
|
436
|
+
* @summary Create a webhook
|
|
437
|
+
* @request POST:/api/v1/stable/tenants/{tenant}/webhooks
|
|
438
|
+
* @secure
|
|
439
|
+
*/
|
|
440
|
+
v1WebhookCreate: (tenant: string, data: V1CreateWebhookRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1Webhook, any>>;
|
|
441
|
+
/**
|
|
442
|
+
* @description Get a webhook by its name
|
|
443
|
+
*
|
|
444
|
+
* @tags Webhook
|
|
445
|
+
* @name V1WebhookGet
|
|
446
|
+
* @summary Get a webhook
|
|
447
|
+
* @request GET:/api/v1/stable/tenants/{tenant}/webhooks/{v1-webhook}
|
|
448
|
+
* @secure
|
|
449
|
+
*/
|
|
450
|
+
v1WebhookGet: (tenant: string, v1Webhook: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1Webhook, any>>;
|
|
451
|
+
/**
|
|
452
|
+
* @description Delete a webhook
|
|
453
|
+
*
|
|
454
|
+
* @tags Webhook
|
|
455
|
+
* @name V1WebhookDelete
|
|
456
|
+
* @request DELETE:/api/v1/stable/tenants/{tenant}/webhooks/{v1-webhook}
|
|
457
|
+
* @secure
|
|
458
|
+
*/
|
|
459
|
+
v1WebhookDelete: (tenant: string, v1Webhook: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<V1Webhook, any>>;
|
|
460
|
+
/**
|
|
461
|
+
* @description Post an incoming webhook message
|
|
462
|
+
*
|
|
463
|
+
* @tags Webhook
|
|
464
|
+
* @name V1WebhookReceive
|
|
465
|
+
* @summary Post a webhook message
|
|
466
|
+
* @request POST:/api/v1/stable/tenants/{tenant}/webhooks/{v1-webhook}
|
|
467
|
+
*/
|
|
468
|
+
v1WebhookReceive: (tenant: string, v1Webhook: string, data?: any, params?: RequestParams) => Promise<import("axios").AxiosResponse<{
|
|
469
|
+
/** @example "OK" */
|
|
470
|
+
message?: string;
|
|
471
|
+
}, any>>;
|
|
406
472
|
/**
|
|
407
473
|
* @description Evaluate a CEL expression against provided input data.
|
|
408
474
|
*
|
|
@@ -234,6 +234,54 @@ class Api extends http_client_1.HttpClient {
|
|
|
234
234
|
* @secure
|
|
235
235
|
*/
|
|
236
236
|
this.v1FilterUpdate = (tenant, v1Filter, data, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/filters/${v1Filter}`, method: 'PATCH', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
|
|
237
|
+
/**
|
|
238
|
+
* @description Lists all webhook for a tenant.
|
|
239
|
+
*
|
|
240
|
+
* @tags Webhook
|
|
241
|
+
* @name V1WebhookList
|
|
242
|
+
* @summary List webhooks
|
|
243
|
+
* @request GET:/api/v1/stable/tenants/{tenant}/webhooks
|
|
244
|
+
* @secure
|
|
245
|
+
*/
|
|
246
|
+
this.v1WebhookList = (tenant, query, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/webhooks`, method: 'GET', query: query, secure: true, format: 'json' }, params));
|
|
247
|
+
/**
|
|
248
|
+
* @description Create a new webhook
|
|
249
|
+
*
|
|
250
|
+
* @tags Webhook
|
|
251
|
+
* @name V1WebhookCreate
|
|
252
|
+
* @summary Create a webhook
|
|
253
|
+
* @request POST:/api/v1/stable/tenants/{tenant}/webhooks
|
|
254
|
+
* @secure
|
|
255
|
+
*/
|
|
256
|
+
this.v1WebhookCreate = (tenant, data, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/webhooks`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
|
|
257
|
+
/**
|
|
258
|
+
* @description Get a webhook by its name
|
|
259
|
+
*
|
|
260
|
+
* @tags Webhook
|
|
261
|
+
* @name V1WebhookGet
|
|
262
|
+
* @summary Get a webhook
|
|
263
|
+
* @request GET:/api/v1/stable/tenants/{tenant}/webhooks/{v1-webhook}
|
|
264
|
+
* @secure
|
|
265
|
+
*/
|
|
266
|
+
this.v1WebhookGet = (tenant, v1Webhook, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/webhooks/${v1Webhook}`, method: 'GET', secure: true, format: 'json' }, params));
|
|
267
|
+
/**
|
|
268
|
+
* @description Delete a webhook
|
|
269
|
+
*
|
|
270
|
+
* @tags Webhook
|
|
271
|
+
* @name V1WebhookDelete
|
|
272
|
+
* @request DELETE:/api/v1/stable/tenants/{tenant}/webhooks/{v1-webhook}
|
|
273
|
+
* @secure
|
|
274
|
+
*/
|
|
275
|
+
this.v1WebhookDelete = (tenant, v1Webhook, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/webhooks/${v1Webhook}`, method: 'DELETE', secure: true, format: 'json' }, params));
|
|
276
|
+
/**
|
|
277
|
+
* @description Post an incoming webhook message
|
|
278
|
+
*
|
|
279
|
+
* @tags Webhook
|
|
280
|
+
* @name V1WebhookReceive
|
|
281
|
+
* @summary Post a webhook message
|
|
282
|
+
* @request POST:/api/v1/stable/tenants/{tenant}/webhooks/{v1-webhook}
|
|
283
|
+
*/
|
|
284
|
+
this.v1WebhookReceive = (tenant, v1Webhook, data, params = {}) => this.request(Object.assign({ path: `/api/v1/stable/tenants/${tenant}/webhooks/${v1Webhook}`, method: 'POST', body: data, format: 'json' }, params));
|
|
237
285
|
/**
|
|
238
286
|
* @description Evaluate a CEL expression against provided input data.
|
|
239
287
|
*
|
|
@@ -531,6 +531,8 @@ export interface V1EventList {
|
|
|
531
531
|
*/
|
|
532
532
|
filterId?: string;
|
|
533
533
|
}[];
|
|
534
|
+
/** The name of the webhook that triggered this event, if applicable. */
|
|
535
|
+
triggeringWebhookName?: string;
|
|
534
536
|
}[];
|
|
535
537
|
}
|
|
536
538
|
export interface V1FilterList {
|
|
@@ -555,6 +557,33 @@ export interface V1Filter {
|
|
|
555
557
|
/** Additional payload data associated with the filter */
|
|
556
558
|
payload: object;
|
|
557
559
|
}
|
|
560
|
+
export interface V1WebhookList {
|
|
561
|
+
pagination?: PaginationResponse;
|
|
562
|
+
rows?: V1Webhook[];
|
|
563
|
+
}
|
|
564
|
+
export interface V1Webhook {
|
|
565
|
+
metadata: APIResourceMeta;
|
|
566
|
+
/** The ID of the tenant associated with this webhook. */
|
|
567
|
+
tenantId: string;
|
|
568
|
+
/** The name of the webhook */
|
|
569
|
+
name: string;
|
|
570
|
+
/** The name of the source for this webhook */
|
|
571
|
+
sourceName: V1WebhookSourceName;
|
|
572
|
+
/** The CEL expression to use for the event key. This is used to create the event key from the webhook payload. */
|
|
573
|
+
eventKeyExpression: string;
|
|
574
|
+
/** The type of authentication to use for the webhook */
|
|
575
|
+
authType: V1WebhookAuthType;
|
|
576
|
+
}
|
|
577
|
+
export declare enum V1WebhookSourceName {
|
|
578
|
+
GENERIC = "GENERIC",
|
|
579
|
+
GITHUB = "GITHUB",
|
|
580
|
+
STRIPE = "STRIPE"
|
|
581
|
+
}
|
|
582
|
+
export declare enum V1WebhookAuthType {
|
|
583
|
+
BASIC = "BASIC",
|
|
584
|
+
API_KEY = "API_KEY",
|
|
585
|
+
HMAC = "HMAC"
|
|
586
|
+
}
|
|
558
587
|
export interface RateLimit {
|
|
559
588
|
/** The key for the rate limit. */
|
|
560
589
|
key: string;
|
|
@@ -1761,6 +1790,45 @@ export interface V1CreateFilterRequest {
|
|
|
1761
1790
|
/** The payload for the filter */
|
|
1762
1791
|
payload?: object;
|
|
1763
1792
|
}
|
|
1793
|
+
export type V1CreateWebhookRequest = ({
|
|
1794
|
+
/** The name of the source for this webhook */
|
|
1795
|
+
sourceName: V1WebhookSourceName;
|
|
1796
|
+
/** The name of the webhook */
|
|
1797
|
+
name: string;
|
|
1798
|
+
/** The CEL expression to use for the event key. This is used to create the event key from the webhook payload. */
|
|
1799
|
+
eventKeyExpression: string;
|
|
1800
|
+
} & {
|
|
1801
|
+
/** The type of authentication to use for the webhook */
|
|
1802
|
+
authType: 'BASIC';
|
|
1803
|
+
auth: {
|
|
1804
|
+
/** The username for basic auth */
|
|
1805
|
+
username: string;
|
|
1806
|
+
/** The password for basic auth */
|
|
1807
|
+
password: string;
|
|
1808
|
+
};
|
|
1809
|
+
}) | {
|
|
1810
|
+
/** The type of authentication to use for the webhook */
|
|
1811
|
+
authType: 'API_KEY';
|
|
1812
|
+
auth: {
|
|
1813
|
+
/** The name of the header to use for the API key */
|
|
1814
|
+
headerName: string;
|
|
1815
|
+
/** The API key to use for authentication */
|
|
1816
|
+
apiKey: string;
|
|
1817
|
+
};
|
|
1818
|
+
} | {
|
|
1819
|
+
/** The type of authentication to use for the webhook */
|
|
1820
|
+
authType: 'HMAC';
|
|
1821
|
+
auth: {
|
|
1822
|
+
/** The HMAC algorithm to use for the webhook */
|
|
1823
|
+
algorithm: 'SHA1' | 'SHA256' | 'SHA512' | 'MD5';
|
|
1824
|
+
/** The encoding to use for the HMAC signature */
|
|
1825
|
+
encoding: 'HEX' | 'BASE64' | 'BASE64URL';
|
|
1826
|
+
/** The name of the header to use for the HMAC signature */
|
|
1827
|
+
signatureHeaderName: string;
|
|
1828
|
+
/** The secret key used to sign the HMAC signature */
|
|
1829
|
+
signingSecret: string;
|
|
1830
|
+
};
|
|
1831
|
+
};
|
|
1764
1832
|
export interface V1UpdateFilterRequest {
|
|
1765
1833
|
/** The expression for the filter */
|
|
1766
1834
|
expression?: string;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* ---------------------------------------------------------------
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.V1CELDebugResponseStatus = exports.V1LogLineLevel = exports.V1TaskRunStatus = exports.V1TaskStatus = exports.WebhookWorkerRequestMethod = exports.LogLineOrderByDirection = exports.LogLineOrderByField = exports.LogLineLevel = exports.PullRequestState = exports.WorkerRuntimeSDKs = exports.StepRunEventSeverity = exports.StepRunEventReason = exports.StepRunStatus = exports.JobRunStatus = exports.WorkflowKind = exports.WorkflowRunStatus = exports.WorkflowRunOrderByDirection = exports.WorkflowRunOrderByField = exports.CronWorkflowsOrderByField = exports.ScheduledRunStatus = exports.ScheduledWorkflowsOrderByField = exports.RateLimitOrderByDirection = exports.RateLimitOrderByField = exports.EventOrderByDirection = exports.EventOrderByField = exports.TenantResource = exports.TenantMemberRole = void 0;
|
|
14
|
+
exports.V1CELDebugResponseStatus = exports.V1LogLineLevel = exports.V1TaskRunStatus = exports.V1TaskStatus = exports.WebhookWorkerRequestMethod = exports.LogLineOrderByDirection = exports.LogLineOrderByField = exports.LogLineLevel = exports.PullRequestState = exports.WorkerRuntimeSDKs = exports.StepRunEventSeverity = exports.StepRunEventReason = exports.StepRunStatus = exports.JobRunStatus = exports.WorkflowKind = exports.WorkflowRunStatus = exports.WorkflowRunOrderByDirection = exports.WorkflowRunOrderByField = exports.CronWorkflowsOrderByField = exports.ScheduledRunStatus = exports.ScheduledWorkflowsOrderByField = exports.RateLimitOrderByDirection = exports.RateLimitOrderByField = exports.V1WebhookAuthType = exports.V1WebhookSourceName = exports.EventOrderByDirection = exports.EventOrderByField = exports.TenantResource = exports.TenantMemberRole = void 0;
|
|
15
15
|
var TenantMemberRole;
|
|
16
16
|
(function (TenantMemberRole) {
|
|
17
17
|
TenantMemberRole["OWNER"] = "OWNER";
|
|
@@ -37,6 +37,18 @@ var EventOrderByDirection;
|
|
|
37
37
|
EventOrderByDirection["Asc"] = "asc";
|
|
38
38
|
EventOrderByDirection["Desc"] = "desc";
|
|
39
39
|
})(EventOrderByDirection || (exports.EventOrderByDirection = EventOrderByDirection = {}));
|
|
40
|
+
var V1WebhookSourceName;
|
|
41
|
+
(function (V1WebhookSourceName) {
|
|
42
|
+
V1WebhookSourceName["GENERIC"] = "GENERIC";
|
|
43
|
+
V1WebhookSourceName["GITHUB"] = "GITHUB";
|
|
44
|
+
V1WebhookSourceName["STRIPE"] = "STRIPE";
|
|
45
|
+
})(V1WebhookSourceName || (exports.V1WebhookSourceName = V1WebhookSourceName = {}));
|
|
46
|
+
var V1WebhookAuthType;
|
|
47
|
+
(function (V1WebhookAuthType) {
|
|
48
|
+
V1WebhookAuthType["BASIC"] = "BASIC";
|
|
49
|
+
V1WebhookAuthType["API_KEY"] = "API_KEY";
|
|
50
|
+
V1WebhookAuthType["HMAC"] = "HMAC";
|
|
51
|
+
})(V1WebhookAuthType || (exports.V1WebhookAuthType = V1WebhookAuthType = {}));
|
|
40
52
|
var RateLimitOrderByField;
|
|
41
53
|
(function (RateLimitOrderByField) {
|
|
42
54
|
RateLimitOrderByField["Key"] = "key";
|
package/examples/byo-logger.js
CHANGED
|
@@ -23,25 +23,25 @@ class PinoLogger {
|
|
|
23
23
|
this.context = context;
|
|
24
24
|
}
|
|
25
25
|
debug(message, extra) {
|
|
26
|
-
logger.debug(
|
|
26
|
+
logger.debug(extra, message);
|
|
27
27
|
}
|
|
28
28
|
info(message, extra) {
|
|
29
|
-
logger.info(
|
|
29
|
+
logger.info(extra, message);
|
|
30
30
|
}
|
|
31
31
|
green(message, extra) {
|
|
32
|
-
logger.info(`%c${message}
|
|
32
|
+
logger.info(extra, `%c${message}`);
|
|
33
33
|
}
|
|
34
34
|
warn(message, error, extra) {
|
|
35
|
-
logger.warn(`${message} ${error}
|
|
35
|
+
logger.warn(extra, `${message} ${error}`);
|
|
36
36
|
}
|
|
37
37
|
error(message, error, extra) {
|
|
38
|
-
logger.error(`${message} ${error}
|
|
38
|
+
logger.error(extra, `${message} ${error}`);
|
|
39
39
|
}
|
|
40
40
|
// optional util method
|
|
41
41
|
util(key, message, extra) {
|
|
42
42
|
// for example you may want to expose a trace method
|
|
43
43
|
if (key === 'trace') {
|
|
44
|
-
logger.info('trace'
|
|
44
|
+
logger.info(extra, 'trace');
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hatchet-dev/typescript-sdk",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.5",
|
|
4
4
|
"description": "Background task orchestration & visibility for developers",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"grpc-tools": "^1.13.0",
|
|
68
68
|
"jest": "^29.7.0",
|
|
69
69
|
"jest-tsd": "^0.2.2",
|
|
70
|
-
"pino": "^9.
|
|
70
|
+
"pino": "^9.8.0",
|
|
71
71
|
"prettier": "^3.5.3",
|
|
72
72
|
"resolve-tspaths": "^0.8.23",
|
|
73
73
|
"ts-jest": "^29.3.1",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@bufbuild/protobuf": "^2.2.5",
|
|
82
82
|
"@types/qs": "^6.9.18",
|
|
83
83
|
"abort-controller-x": "^0.4.3",
|
|
84
|
-
"axios": "^1.
|
|
84
|
+
"axios": "^1.11.0",
|
|
85
85
|
"long": "^5.3.1",
|
|
86
86
|
"nice-grpc": "^2.1.12",
|
|
87
87
|
"nice-grpc-common": "^2.0.2",
|
|
@@ -92,14 +92,18 @@ class V1Worker {
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
registerDurableActionsV1(workflow) {
|
|
95
|
-
const newActions = workflow._durableTasks
|
|
95
|
+
const newActions = workflow._durableTasks
|
|
96
|
+
.filter((task) => !!task.fn)
|
|
97
|
+
.reduce((acc, task) => {
|
|
96
98
|
acc[`${(0, apply_namespace_1.applyNamespace)(workflow.name, this.client.config.namespace).toLowerCase()}:${task.name.toLowerCase()}`] = (ctx) => task.fn(ctx.input, ctx);
|
|
97
99
|
return acc;
|
|
98
100
|
}, {});
|
|
99
101
|
this.action_registry = Object.assign(Object.assign({}, this.action_registry), newActions);
|
|
100
102
|
}
|
|
101
103
|
registerActionsV1(workflow) {
|
|
102
|
-
const newActions = workflow._tasks
|
|
104
|
+
const newActions = workflow._tasks
|
|
105
|
+
.filter((task) => !!task.fn)
|
|
106
|
+
.reduce((acc, task) => {
|
|
103
107
|
acc[`${workflow.name}:${task.name.toLowerCase()}`] = (ctx) => task.fn(ctx.input, ctx);
|
|
104
108
|
return acc;
|
|
105
109
|
}, {});
|
package/v1/declaration.d.ts
CHANGED
|
@@ -295,7 +295,7 @@ export declare class WorkflowDeclaration<I extends InputType = UnknownInputType,
|
|
|
295
295
|
*/
|
|
296
296
|
task<Name extends string, Fn extends Name extends keyof O ? (input: I, ctx: Context<I>) => O[Name] extends OutputType ? O[Name] | Promise<O[Name]> : void : (input: I, ctx: Context<I>) => void, FnReturn = ReturnType<Fn> extends Promise<infer P> ? P : ReturnType<Fn>, TO extends OutputType = Name extends keyof O ? O[Name] extends OutputType ? O[Name] : never : FnReturn extends OutputType ? FnReturn : never>(options: (Omit<CreateWorkflowTaskOpts<I, TO>, 'fn'> & {
|
|
297
297
|
name: Name;
|
|
298
|
-
fn
|
|
298
|
+
fn?: Fn;
|
|
299
299
|
}) | TaskWorkflowDeclaration<I, TO>): CreateWorkflowTaskOpts<I, TO>;
|
|
300
300
|
/**
|
|
301
301
|
* Adds an onFailure task to the workflow.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const workflows_1 = require("../../../protoc/workflows");
|
|
13
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
14
|
+
// > AffinityWorkflow
|
|
15
|
+
const workflow = hatchet_client_1.hatchet.workflow({
|
|
16
|
+
name: 'affinity-workflow',
|
|
17
|
+
description: 'test',
|
|
18
|
+
});
|
|
19
|
+
workflow.task({
|
|
20
|
+
name: 'step1',
|
|
21
|
+
fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
const results = [];
|
|
23
|
+
// eslint-disable-next-line no-plusplus
|
|
24
|
+
for (let i = 0; i < 50; i++) {
|
|
25
|
+
const result = yield ctx.spawnWorkflow(childWorkflow.id, {});
|
|
26
|
+
results.push(result.output);
|
|
27
|
+
}
|
|
28
|
+
console.log('Spawned 50 child workflows');
|
|
29
|
+
console.log('Results:', yield Promise.all(results));
|
|
30
|
+
return { step1: 'step1 results!' };
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
// !!
|
|
34
|
+
const childWorkflow = hatchet_client_1.hatchet.workflow({
|
|
35
|
+
name: 'child-affinity-workflow',
|
|
36
|
+
description: 'test',
|
|
37
|
+
});
|
|
38
|
+
childWorkflow.task({
|
|
39
|
+
name: 'child-step1',
|
|
40
|
+
desiredWorkerLabels: {
|
|
41
|
+
model: {
|
|
42
|
+
value: 'xyz',
|
|
43
|
+
required: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
fn: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
return { childStep1: 'childStep1 results!' };
|
|
48
|
+
}),
|
|
49
|
+
});
|
|
50
|
+
childWorkflow.task({
|
|
51
|
+
name: 'child-step2',
|
|
52
|
+
desiredWorkerLabels: {
|
|
53
|
+
memory: {
|
|
54
|
+
value: 512,
|
|
55
|
+
required: true,
|
|
56
|
+
comparator: workflows_1.WorkerLabelComparator.LESS_THAN,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
fn: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
return { childStep2: 'childStep2 results!' };
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
function main() {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
// > AffinityWorker
|
|
66
|
+
const worker1 = yield hatchet_client_1.hatchet.worker('affinity-worker-1', {
|
|
67
|
+
labels: {
|
|
68
|
+
model: 'abc',
|
|
69
|
+
memory: 1024,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
// !!
|
|
73
|
+
yield worker1.registerWorkflow(workflow);
|
|
74
|
+
yield worker1.registerWorkflow(childWorkflow);
|
|
75
|
+
worker1.start();
|
|
76
|
+
const worker2 = yield hatchet_client_1.hatchet.worker('affinity-worker-2', {
|
|
77
|
+
labels: {
|
|
78
|
+
model: 'xyz',
|
|
79
|
+
memory: 512,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
yield worker2.registerWorkflow(workflow);
|
|
83
|
+
yield worker2.registerWorkflow(childWorkflow);
|
|
84
|
+
worker2.start();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
16
|
+
const pino_1 = __importDefault(require("pino"));
|
|
17
|
+
const sdk_1 = __importDefault(require("../../../sdk"));
|
|
18
|
+
// > Create Pino logger
|
|
19
|
+
const logger = (0, pino_1.default)();
|
|
20
|
+
class PinoLogger {
|
|
21
|
+
constructor(context, logLevel = 'DEBUG') {
|
|
22
|
+
this.logLevel = logLevel;
|
|
23
|
+
this.context = context;
|
|
24
|
+
}
|
|
25
|
+
debug(message, extra) {
|
|
26
|
+
logger.debug(extra, message);
|
|
27
|
+
}
|
|
28
|
+
info(message, extra) {
|
|
29
|
+
logger.info(extra, message);
|
|
30
|
+
}
|
|
31
|
+
green(message, extra) {
|
|
32
|
+
logger.info(extra, `%c${message}`);
|
|
33
|
+
}
|
|
34
|
+
warn(message, error, extra) {
|
|
35
|
+
logger.warn(extra, `${message} ${error}`);
|
|
36
|
+
}
|
|
37
|
+
error(message, error, extra) {
|
|
38
|
+
logger.error(extra, `${message} ${error}`);
|
|
39
|
+
}
|
|
40
|
+
// optional util method
|
|
41
|
+
util(key, message, extra) {
|
|
42
|
+
// for example you may want to expose a trace method
|
|
43
|
+
if (key === 'trace') {
|
|
44
|
+
logger.info(extra, 'trace');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const hatchet = sdk_1.default.init({
|
|
49
|
+
log_level: 'DEBUG',
|
|
50
|
+
logger: (ctx, level) => new PinoLogger(ctx, level),
|
|
51
|
+
});
|
|
52
|
+
// !!
|
|
53
|
+
// > Use the logger
|
|
54
|
+
const workflow = hatchet.task({
|
|
55
|
+
name: 'byo-logger-example',
|
|
56
|
+
fn: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
// eslint-disable-next-line no-plusplus
|
|
58
|
+
for (let i = 0; i < 5; i++) {
|
|
59
|
+
logger.info(`log message ${i}`);
|
|
60
|
+
}
|
|
61
|
+
return { step1: 'completed step run' };
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
// !!
|
|
65
|
+
function main() {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const worker = yield hatchet.worker('byo-logger-worker', {
|
|
68
|
+
workflows: [workflow],
|
|
69
|
+
});
|
|
70
|
+
worker.start();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
13
|
+
const sleep = (ms) => new Promise((resolve) => {
|
|
14
|
+
setTimeout(resolve, ms);
|
|
15
|
+
});
|
|
16
|
+
// > Logger
|
|
17
|
+
const workflow = hatchet_client_1.hatchet.workflow({
|
|
18
|
+
name: 'logger-example',
|
|
19
|
+
description: 'test',
|
|
20
|
+
on: {
|
|
21
|
+
event: 'user:create',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
workflow.task({
|
|
25
|
+
name: 'logger-step1',
|
|
26
|
+
fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
// log in a for loop
|
|
28
|
+
// eslint-disable-next-line no-plusplus
|
|
29
|
+
for (let i = 0; i < 10; i++) {
|
|
30
|
+
ctx.logger.info(`log message ${i}`);
|
|
31
|
+
yield sleep(200);
|
|
32
|
+
}
|
|
33
|
+
return { step1: 'completed step run' };
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
// !!
|
|
37
|
+
function main() {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const worker = yield hatchet_client_1.hatchet.worker('logger-worker', {
|
|
40
|
+
slots: 1,
|
|
41
|
+
workflows: [workflow],
|
|
42
|
+
});
|
|
43
|
+
yield worker.start();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
main();
|
|
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.refreshTimeout = exports.withTimeouts = void 0;
|
|
16
|
-
// > Declaring a Task
|
|
17
16
|
const sleep_1 = __importDefault(require("../../../util/sleep"));
|
|
18
17
|
const hatchet_client_1 = require("../hatchet-client");
|
|
19
18
|
// > Execution Timeout
|
package/v1/task.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export type CreateBaseTaskOpts<I extends InputType = UnknownInputType, O extends
|
|
|
55
55
|
* @param ctx The execution context for the task.
|
|
56
56
|
* @returns The result of the task execution.
|
|
57
57
|
*/
|
|
58
|
-
fn
|
|
58
|
+
fn?: C;
|
|
59
59
|
/**
|
|
60
60
|
* @deprecated use executionTimeout instead
|
|
61
61
|
*/
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.9.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.9.5";
|
package/version.js
CHANGED