@hatchet-dev/typescript-sdk 1.10.4-alpha.0 → 1.10.4
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/rest/generated/Api.d.ts +31 -1
- package/clients/rest/generated/Api.js +30 -0
- package/clients/rest/generated/data-contracts.d.ts +67 -0
- package/package.json +1 -1
- package/step.js +3 -0
- package/v1/client/features/schedules.d.ts +37 -1
- package/v1/client/features/schedules.js +67 -1
- package/v1/client/worker/worker.js +1 -2
- package/v1/examples/simple/schedule.js +15 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -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, TaskStats, Tenant, TenantAlertEmailGroup, TenantAlertEmailGroupList, TenantAlertingSettings, TenantInvite, TenantInviteList, TenantMember, TenantMemberList, TenantQueueMetrics, TenantResourcePolicy, TenantStepRunQueueMetrics, TriggerWorkflowRunRequest, UpdateCronWorkflowTriggerRequest, UpdateTenantAlertEmailGroupRequest, UpdateTenantInviteRequest, UpdateTenantMemberRequest, 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, V1UpdateWebhookRequest, V1Webhook, V1WebhookList, V1WebhookSourceName, V1WorkflowRunDetails, V1WorkflowRunDisplayNameList, V1WorkflowRunExternalIdList, 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, ScheduledWorkflowsBulkDeleteRequest, ScheduledWorkflowsBulkDeleteResponse, ScheduledWorkflowsBulkUpdateRequest, ScheduledWorkflowsBulkUpdateResponse, ScheduledWorkflowsList, ScheduledWorkflowsOrderByField, ScheduleWorkflowRunRequest, SNSIntegration, StepRun, StepRunArchiveList, StepRunEventList, TaskStats, Tenant, TenantAlertEmailGroup, TenantAlertEmailGroupList, TenantAlertingSettings, TenantInvite, TenantInviteList, TenantMember, TenantMemberList, TenantQueueMetrics, TenantResourcePolicy, TenantStepRunQueueMetrics, TriggerWorkflowRunRequest, UpdateCronWorkflowTriggerRequest, UpdateScheduledWorkflowRunRequest, UpdateTenantAlertEmailGroupRequest, UpdateTenantInviteRequest, UpdateTenantMemberRequest, 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, V1UpdateWebhookRequest, V1Webhook, V1WebhookList, V1WebhookSourceName, V1WorkflowRunDetails, V1WorkflowRunDisplayNameList, V1WorkflowRunExternalIdList, 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
|
/**
|
|
@@ -1243,6 +1243,36 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
|
|
|
1243
1243
|
* @secure
|
|
1244
1244
|
*/
|
|
1245
1245
|
workflowScheduledDelete: (tenant: string, scheduledWorkflowRun: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any, {}>>;
|
|
1246
|
+
/**
|
|
1247
|
+
* @description Update (reschedule) a scheduled workflow run for a tenant
|
|
1248
|
+
*
|
|
1249
|
+
* @tags Workflow
|
|
1250
|
+
* @name WorkflowScheduledUpdate
|
|
1251
|
+
* @summary Update scheduled workflow run
|
|
1252
|
+
* @request PATCH:/api/v1/tenants/{tenant}/workflows/scheduled/{scheduled-workflow-run}
|
|
1253
|
+
* @secure
|
|
1254
|
+
*/
|
|
1255
|
+
workflowScheduledUpdate: (tenant: string, scheduledWorkflowRun: string, data: UpdateScheduledWorkflowRunRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<ScheduledWorkflows, any, {}>>;
|
|
1256
|
+
/**
|
|
1257
|
+
* @description Bulk delete scheduled workflow runs for a tenant
|
|
1258
|
+
*
|
|
1259
|
+
* @tags Workflow
|
|
1260
|
+
* @name WorkflowScheduledBulkDelete
|
|
1261
|
+
* @summary Bulk delete scheduled workflow runs
|
|
1262
|
+
* @request POST:/api/v1/tenants/{tenant}/workflows/scheduled/bulk-delete
|
|
1263
|
+
* @secure
|
|
1264
|
+
*/
|
|
1265
|
+
workflowScheduledBulkDelete: (tenant: string, data: ScheduledWorkflowsBulkDeleteRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<ScheduledWorkflowsBulkDeleteResponse, any, {}>>;
|
|
1266
|
+
/**
|
|
1267
|
+
* @description Bulk update (reschedule) scheduled workflow runs for a tenant
|
|
1268
|
+
*
|
|
1269
|
+
* @tags Workflow
|
|
1270
|
+
* @name WorkflowScheduledBulkUpdate
|
|
1271
|
+
* @summary Bulk update scheduled workflow runs
|
|
1272
|
+
* @request POST:/api/v1/tenants/{tenant}/workflows/scheduled/bulk-update
|
|
1273
|
+
* @secure
|
|
1274
|
+
*/
|
|
1275
|
+
workflowScheduledBulkUpdate: (tenant: string, data: ScheduledWorkflowsBulkUpdateRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<ScheduledWorkflowsBulkUpdateResponse, any, {}>>;
|
|
1246
1276
|
/**
|
|
1247
1277
|
* @description Create a new cron job workflow trigger for a tenant
|
|
1248
1278
|
*
|
|
@@ -909,6 +909,36 @@ class Api extends http_client_1.HttpClient {
|
|
|
909
909
|
* @secure
|
|
910
910
|
*/
|
|
911
911
|
this.workflowScheduledDelete = (tenant, scheduledWorkflowRun, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflows/scheduled/${scheduledWorkflowRun}`, method: 'DELETE', secure: true }, params));
|
|
912
|
+
/**
|
|
913
|
+
* @description Update (reschedule) a scheduled workflow run for a tenant
|
|
914
|
+
*
|
|
915
|
+
* @tags Workflow
|
|
916
|
+
* @name WorkflowScheduledUpdate
|
|
917
|
+
* @summary Update scheduled workflow run
|
|
918
|
+
* @request PATCH:/api/v1/tenants/{tenant}/workflows/scheduled/{scheduled-workflow-run}
|
|
919
|
+
* @secure
|
|
920
|
+
*/
|
|
921
|
+
this.workflowScheduledUpdate = (tenant, scheduledWorkflowRun, data, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflows/scheduled/${scheduledWorkflowRun}`, method: 'PATCH', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
|
|
922
|
+
/**
|
|
923
|
+
* @description Bulk delete scheduled workflow runs for a tenant
|
|
924
|
+
*
|
|
925
|
+
* @tags Workflow
|
|
926
|
+
* @name WorkflowScheduledBulkDelete
|
|
927
|
+
* @summary Bulk delete scheduled workflow runs
|
|
928
|
+
* @request POST:/api/v1/tenants/{tenant}/workflows/scheduled/bulk-delete
|
|
929
|
+
* @secure
|
|
930
|
+
*/
|
|
931
|
+
this.workflowScheduledBulkDelete = (tenant, data, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflows/scheduled/bulk-delete`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
|
|
932
|
+
/**
|
|
933
|
+
* @description Bulk update (reschedule) scheduled workflow runs for a tenant
|
|
934
|
+
*
|
|
935
|
+
* @tags Workflow
|
|
936
|
+
* @name WorkflowScheduledBulkUpdate
|
|
937
|
+
* @summary Bulk update scheduled workflow runs
|
|
938
|
+
* @request POST:/api/v1/tenants/{tenant}/workflows/scheduled/bulk-update
|
|
939
|
+
* @secure
|
|
940
|
+
*/
|
|
941
|
+
this.workflowScheduledBulkUpdate = (tenant, data, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflows/scheduled/bulk-update`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
|
|
912
942
|
/**
|
|
913
943
|
* @description Create a new cron job workflow trigger for a tenant
|
|
914
944
|
*
|
|
@@ -887,6 +887,73 @@ export interface ScheduledWorkflowsList {
|
|
|
887
887
|
rows?: ScheduledWorkflows[];
|
|
888
888
|
pagination?: PaginationResponse;
|
|
889
889
|
}
|
|
890
|
+
export interface UpdateScheduledWorkflowRunRequest {
|
|
891
|
+
/** @format date-time */
|
|
892
|
+
triggerAt: string;
|
|
893
|
+
}
|
|
894
|
+
export interface ScheduledWorkflowsBulkDeleteFilter {
|
|
895
|
+
/**
|
|
896
|
+
* @format uuid
|
|
897
|
+
* @minLength 36
|
|
898
|
+
* @maxLength 36
|
|
899
|
+
*/
|
|
900
|
+
workflowId?: string;
|
|
901
|
+
/**
|
|
902
|
+
* @format uuid
|
|
903
|
+
* @minLength 36
|
|
904
|
+
* @maxLength 36
|
|
905
|
+
*/
|
|
906
|
+
parentWorkflowRunId?: string;
|
|
907
|
+
/**
|
|
908
|
+
* @format uuid
|
|
909
|
+
* @minLength 36
|
|
910
|
+
* @maxLength 36
|
|
911
|
+
*/
|
|
912
|
+
parentStepRunId?: string;
|
|
913
|
+
/**
|
|
914
|
+
* A list of metadata key value pairs to filter by
|
|
915
|
+
* @example ["key1:value1","key2:value2"]
|
|
916
|
+
*/
|
|
917
|
+
additionalMetadata?: string[];
|
|
918
|
+
/** A list of scheduled run statuses to filter by */
|
|
919
|
+
statuses?: ScheduledRunStatus[];
|
|
920
|
+
}
|
|
921
|
+
export interface ScheduledWorkflowsBulkDeleteRequest {
|
|
922
|
+
/** @maxItems 500 */
|
|
923
|
+
scheduledWorkflowRunIds?: string[];
|
|
924
|
+
filter?: ScheduledWorkflowsBulkDeleteFilter;
|
|
925
|
+
}
|
|
926
|
+
export interface ScheduledWorkflowsBulkError {
|
|
927
|
+
/**
|
|
928
|
+
* @format uuid
|
|
929
|
+
* @minLength 36
|
|
930
|
+
* @maxLength 36
|
|
931
|
+
*/
|
|
932
|
+
id?: string;
|
|
933
|
+
error: string;
|
|
934
|
+
}
|
|
935
|
+
export interface ScheduledWorkflowsBulkDeleteResponse {
|
|
936
|
+
deletedIds: string[];
|
|
937
|
+
errors: ScheduledWorkflowsBulkError[];
|
|
938
|
+
}
|
|
939
|
+
export interface ScheduledWorkflowsBulkUpdateItem {
|
|
940
|
+
/**
|
|
941
|
+
* @format uuid
|
|
942
|
+
* @minLength 36
|
|
943
|
+
* @maxLength 36
|
|
944
|
+
*/
|
|
945
|
+
id: string;
|
|
946
|
+
/** @format date-time */
|
|
947
|
+
triggerAt: string;
|
|
948
|
+
}
|
|
949
|
+
export interface ScheduledWorkflowsBulkUpdateRequest {
|
|
950
|
+
/** @maxItems 500 */
|
|
951
|
+
updates: ScheduledWorkflowsBulkUpdateItem[];
|
|
952
|
+
}
|
|
953
|
+
export interface ScheduledWorkflowsBulkUpdateResponse {
|
|
954
|
+
updatedIds: string[];
|
|
955
|
+
errors: ScheduledWorkflowsBulkError[];
|
|
956
|
+
}
|
|
890
957
|
export declare enum ScheduledWorkflowsOrderByField {
|
|
891
958
|
TriggerAt = "triggerAt",
|
|
892
959
|
CreatedAt = "createdAt"
|
package/package.json
CHANGED
package/step.js
CHANGED
|
@@ -632,6 +632,9 @@ function mapRateLimit(limits) {
|
|
|
632
632
|
if (keyExpression !== undefined && limitExpression === undefined) {
|
|
633
633
|
throw new Error('CEL based keys requires limit to be set');
|
|
634
634
|
}
|
|
635
|
+
if (limitExpression === undefined) {
|
|
636
|
+
limitExpression = `-1`;
|
|
637
|
+
}
|
|
635
638
|
return {
|
|
636
639
|
key,
|
|
637
640
|
keyExpr: keyExpression,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScheduledWorkflows, ScheduledWorkflowsList } from '../../../clients/rest/generated/data-contracts';
|
|
1
|
+
import { ScheduledWorkflows, ScheduledWorkflowsBulkDeleteFilter, ScheduledWorkflowsBulkDeleteResponse, ScheduledWorkflowsBulkUpdateResponse, ScheduledWorkflowsList } from '../../../clients/rest/generated/data-contracts';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { Workflow } from '../../../workflow';
|
|
4
4
|
import { BaseWorkflowDeclaration, WorkflowDefinition } from '../..';
|
|
@@ -27,6 +27,17 @@ export declare const CreateScheduledRunTriggerSchema: z.ZodObject<{
|
|
|
27
27
|
* Type representing the input for creating a Cron.
|
|
28
28
|
*/
|
|
29
29
|
export type CreateScheduledRunInput = z.infer<typeof CreateScheduledRunTriggerSchema>;
|
|
30
|
+
/**
|
|
31
|
+
* Schema for updating (rescheduling) a Scheduled Run Trigger.
|
|
32
|
+
*/
|
|
33
|
+
export declare const UpdateScheduledRunTriggerSchema: z.ZodObject<{
|
|
34
|
+
triggerAt: z.ZodDate;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
triggerAt: Date;
|
|
37
|
+
}, {
|
|
38
|
+
triggerAt: Date;
|
|
39
|
+
}>;
|
|
40
|
+
export type UpdateScheduledRunInput = z.infer<typeof UpdateScheduledRunTriggerSchema>;
|
|
30
41
|
/**
|
|
31
42
|
* Client for managing Scheduled Runs.
|
|
32
43
|
*/
|
|
@@ -50,6 +61,13 @@ export declare class ScheduleClient {
|
|
|
50
61
|
* @throws Will throw an error if the input is invalid or the API call fails.
|
|
51
62
|
*/
|
|
52
63
|
create(workflow: string | Workflow, cron: CreateScheduledRunInput): Promise<ScheduledWorkflows>;
|
|
64
|
+
/**
|
|
65
|
+
* Updates (reschedules) an existing Scheduled Run.
|
|
66
|
+
* @param scheduledRun - The Scheduled Run ID as a string or ScheduledWorkflows object.
|
|
67
|
+
* @param update - The update payload (currently only triggerAt).
|
|
68
|
+
* @returns A promise that resolves to the updated ScheduledWorkflows object.
|
|
69
|
+
*/
|
|
70
|
+
update(scheduledRun: string | ScheduledWorkflows, update: UpdateScheduledRunInput): Promise<ScheduledWorkflows>;
|
|
53
71
|
/**
|
|
54
72
|
* Deletes an existing Scheduled Run.
|
|
55
73
|
* @param scheduledRun - The Scheduled Run ID as a string or ScheduledWorkflows object.
|
|
@@ -70,4 +88,22 @@ export declare class ScheduleClient {
|
|
|
70
88
|
* @returns A promise that resolves to the ScheduledWorkflows object.
|
|
71
89
|
*/
|
|
72
90
|
get(scheduledRun: string | ScheduledWorkflows): Promise<ScheduledWorkflows>;
|
|
91
|
+
/**
|
|
92
|
+
* Bulk deletes scheduled runs (by explicit IDs and/or a filter).
|
|
93
|
+
* @param opts - Either `scheduledRuns` (ids/objects) and/or a server-side filter.
|
|
94
|
+
* @returns A promise that resolves to deleted ids + per-id errors.
|
|
95
|
+
*/
|
|
96
|
+
bulkDelete(opts: {
|
|
97
|
+
scheduledRuns?: Array<string | ScheduledWorkflows>;
|
|
98
|
+
filter?: ScheduledWorkflowsBulkDeleteFilter;
|
|
99
|
+
}): Promise<ScheduledWorkflowsBulkDeleteResponse>;
|
|
100
|
+
/**
|
|
101
|
+
* Bulk updates (reschedules) scheduled runs.
|
|
102
|
+
* @param updates - List of id/object + new triggerAt.
|
|
103
|
+
* @returns A promise that resolves to updated ids + per-id errors.
|
|
104
|
+
*/
|
|
105
|
+
bulkUpdate(updates: Array<{
|
|
106
|
+
scheduledRun: string | ScheduledWorkflows;
|
|
107
|
+
triggerAt: Date | string;
|
|
108
|
+
}>): Promise<ScheduledWorkflowsBulkUpdateResponse>;
|
|
73
109
|
}
|
|
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.ScheduleClient = exports.CreateScheduledRunTriggerSchema = void 0;
|
|
23
|
+
exports.ScheduleClient = exports.UpdateScheduledRunTriggerSchema = exports.CreateScheduledRunTriggerSchema = void 0;
|
|
24
24
|
const zod_1 = require("zod");
|
|
25
25
|
const axios_1 = require("axios");
|
|
26
26
|
const uuid_1 = require("../../../util/uuid");
|
|
@@ -35,6 +35,12 @@ exports.CreateScheduledRunTriggerSchema = zod_1.z.object({
|
|
|
35
35
|
additionalMetadata: zod_1.z.record(zod_1.z.string()).optional(),
|
|
36
36
|
priority: zod_1.z.number().optional(),
|
|
37
37
|
});
|
|
38
|
+
/**
|
|
39
|
+
* Schema for updating (rescheduling) a Scheduled Run Trigger.
|
|
40
|
+
*/
|
|
41
|
+
exports.UpdateScheduledRunTriggerSchema = zod_1.z.object({
|
|
42
|
+
triggerAt: zod_1.z.coerce.date(),
|
|
43
|
+
});
|
|
38
44
|
/**
|
|
39
45
|
* Client for managing Scheduled Runs.
|
|
40
46
|
*/
|
|
@@ -90,6 +96,34 @@ class ScheduleClient {
|
|
|
90
96
|
}
|
|
91
97
|
});
|
|
92
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Updates (reschedules) an existing Scheduled Run.
|
|
101
|
+
* @param scheduledRun - The Scheduled Run ID as a string or ScheduledWorkflows object.
|
|
102
|
+
* @param update - The update payload (currently only triggerAt).
|
|
103
|
+
* @returns A promise that resolves to the updated ScheduledWorkflows object.
|
|
104
|
+
*/
|
|
105
|
+
update(scheduledRun, update) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
var _a;
|
|
108
|
+
const scheduledRunId = this.getScheduledRunId(scheduledRun);
|
|
109
|
+
try {
|
|
110
|
+
const parsed = exports.UpdateScheduledRunTriggerSchema.parse(update);
|
|
111
|
+
const response = yield this.api.workflowScheduledUpdate(this.tenantId, scheduledRunId, {
|
|
112
|
+
triggerAt: parsed.triggerAt.toISOString(),
|
|
113
|
+
});
|
|
114
|
+
return response.data;
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
if (err instanceof zod_1.z.ZodError) {
|
|
118
|
+
throw new Error(`Invalid update input: ${err.message}`);
|
|
119
|
+
}
|
|
120
|
+
if (err instanceof axios_1.AxiosError) {
|
|
121
|
+
throw new Error(JSON.stringify((_a = err.response) === null || _a === void 0 ? void 0 : _a.data.errors));
|
|
122
|
+
}
|
|
123
|
+
throw err;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
93
127
|
/**
|
|
94
128
|
* Deletes an existing Scheduled Run.
|
|
95
129
|
* @param scheduledRun - The Scheduled Run ID as a string or ScheduledWorkflows object.
|
|
@@ -129,5 +163,37 @@ class ScheduleClient {
|
|
|
129
163
|
return response.data;
|
|
130
164
|
});
|
|
131
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Bulk deletes scheduled runs (by explicit IDs and/or a filter).
|
|
168
|
+
* @param opts - Either `scheduledRuns` (ids/objects) and/or a server-side filter.
|
|
169
|
+
* @returns A promise that resolves to deleted ids + per-id errors.
|
|
170
|
+
*/
|
|
171
|
+
bulkDelete(opts) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
var _a;
|
|
174
|
+
const scheduledWorkflowRunIds = (_a = opts.scheduledRuns) === null || _a === void 0 ? void 0 : _a.map((r) => this.getScheduledRunId(r));
|
|
175
|
+
const response = yield this.api.workflowScheduledBulkDelete(this.tenantId, {
|
|
176
|
+
scheduledWorkflowRunIds,
|
|
177
|
+
filter: opts.filter,
|
|
178
|
+
});
|
|
179
|
+
return response.data;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Bulk updates (reschedules) scheduled runs.
|
|
184
|
+
* @param updates - List of id/object + new triggerAt.
|
|
185
|
+
* @returns A promise that resolves to updated ids + per-id errors.
|
|
186
|
+
*/
|
|
187
|
+
bulkUpdate(updates) {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
const response = yield this.api.workflowScheduledBulkUpdate(this.tenantId, {
|
|
190
|
+
updates: updates.map((u) => ({
|
|
191
|
+
id: this.getScheduledRunId(u.scheduledRun),
|
|
192
|
+
triggerAt: new Date(u.triggerAt).toISOString(),
|
|
193
|
+
})),
|
|
194
|
+
});
|
|
195
|
+
return response.data;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
132
198
|
}
|
|
133
199
|
exports.ScheduleClient = ScheduleClient;
|
|
@@ -50,8 +50,7 @@ class Worker {
|
|
|
50
50
|
*/
|
|
51
51
|
registerWorkflows(workflows) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
const
|
|
54
|
-
for (const wf of shuffled) {
|
|
53
|
+
for (const wf of workflows || []) {
|
|
55
54
|
if (wf instanceof declaration_1.BaseWorkflowDeclaration) {
|
|
56
55
|
// TODO check if tenant is V1
|
|
57
56
|
yield this.nonDurable.registerWorkflowV1(wf);
|
|
@@ -25,6 +25,11 @@ function main() {
|
|
|
25
25
|
const scheduledRunId = scheduled.metadata.id;
|
|
26
26
|
console.log(scheduledRunId);
|
|
27
27
|
// !!
|
|
28
|
+
// > Reschedule a Scheduled Run
|
|
29
|
+
yield hatchet_client_1.hatchet.scheduled.update(scheduledRunId, {
|
|
30
|
+
triggerAt: new Date(Date.now() + 60 * 60 * 1000),
|
|
31
|
+
});
|
|
32
|
+
// !!
|
|
28
33
|
// > Delete a Scheduled Run
|
|
29
34
|
yield hatchet_client_1.hatchet.scheduled.delete(scheduled);
|
|
30
35
|
// !!
|
|
@@ -34,6 +39,16 @@ function main() {
|
|
|
34
39
|
});
|
|
35
40
|
console.log(scheduledRuns);
|
|
36
41
|
// !!
|
|
42
|
+
// > Bulk Delete Scheduled Runs
|
|
43
|
+
yield hatchet_client_1.hatchet.scheduled.bulkDelete({
|
|
44
|
+
scheduledRuns: [scheduledRunId],
|
|
45
|
+
});
|
|
46
|
+
// !!
|
|
47
|
+
// > Bulk Reschedule Scheduled Runs
|
|
48
|
+
yield hatchet_client_1.hatchet.scheduled.bulkUpdate([
|
|
49
|
+
{ scheduledRun: scheduledRunId, triggerAt: new Date(Date.now() + 2 * 60 * 60 * 1000) },
|
|
50
|
+
]);
|
|
51
|
+
// !!
|
|
37
52
|
});
|
|
38
53
|
}
|
|
39
54
|
if (require.main === module) {
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.10.4
|
|
1
|
+
export declare const HATCHET_VERSION = "1.10.4";
|
package/version.js
CHANGED