@hatchet-dev/typescript-sdk 0.13.0 → 0.13.1

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.
@@ -11,12 +11,17 @@ export declare enum LogLevel {
11
11
  export interface PushEventOptions {
12
12
  additionalMetadata?: Record<string, string>;
13
13
  }
14
+ export interface EventWithMetadata<T> {
15
+ payload: T;
16
+ additionalMetadata?: Record<string, any>;
17
+ }
14
18
  export declare class EventClient {
15
19
  config: ClientConfig;
16
20
  client: EventsServiceClient;
17
21
  logger: Logger;
18
22
  constructor(config: ClientConfig, channel: Channel, factory: ClientFactory);
19
23
  push<T>(type: string, input: T, options?: PushEventOptions): Promise<import("../../protoc/events/events").Event>;
24
+ bulkPush<T>(type: string, inputs: EventWithMetadata<T>[], options?: PushEventOptions): Promise<import("../../protoc/events/events").Events>;
20
25
  putLog(stepRunId: string, log: string, level?: LogLevel): void;
21
26
  putStream(stepRunId: string, data: string | Uint8Array): void;
22
27
  }
@@ -51,6 +51,37 @@ class EventClient {
51
51
  throw new hatchet_error_1.default(e.message);
52
52
  }
53
53
  }
54
+ bulkPush(type, inputs, options = {}) {
55
+ var _a;
56
+ const namespacedType = `${(_a = this.config.namespace) !== null && _a !== void 0 ? _a : ''}${type}`;
57
+ const events = inputs.map((input) => {
58
+ return {
59
+ key: namespacedType,
60
+ payload: JSON.stringify(input.payload),
61
+ eventTimestamp: new Date(),
62
+ additionalMetadata: (() => {
63
+ if (input.additionalMetadata) {
64
+ return JSON.stringify(input.additionalMetadata);
65
+ }
66
+ if (options.additionalMetadata) {
67
+ return JSON.stringify(options.additionalMetadata);
68
+ }
69
+ return undefined;
70
+ })(),
71
+ };
72
+ });
73
+ const req = {
74
+ events,
75
+ };
76
+ try {
77
+ const e = this.client.bulkPush(req);
78
+ this.logger.info(`Bulk events pushed for type: ${namespacedType}`);
79
+ return e;
80
+ }
81
+ catch (e) {
82
+ throw new hatchet_error_1.default(e.message);
83
+ }
84
+ }
54
85
  putLog(stepRunId, log, level) {
55
86
  const createdAt = new Date();
56
87
  (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () {
@@ -1,4 +1,4 @@
1
- import { AcceptInviteRequest, APIErrors, APIMeta, CreateAPITokenRequest, CreateAPITokenResponse, CreateEventRequest, CreateSNSIntegrationRequest, CreateTenantAlertEmailGroupRequest, CreateTenantInviteRequest, CreateTenantRequest, Event, EventData, EventKey, EventKeyList, EventList, EventOrderByDirection, EventOrderByField, EventSearch, ListAPIMetaIntegration, ListAPITokensResponse, ListSlackWebhooks, ListSNSIntegrations, LogLineLevelField, LogLineList, LogLineOrderByDirection, LogLineOrderByField, LogLineSearch, RejectInviteRequest, ReplayEventRequest, RerunStepRunRequest, SNSIntegration, StepRun, StepRunArchiveList, StepRunEventList, Tenant, TenantAlertEmailGroup, TenantAlertEmailGroupList, TenantAlertingSettings, TenantInvite, TenantInviteList, TenantMember, TenantMemberList, TenantQueueMetrics, TenantResourcePolicy, TriggerWorkflowRunRequest, UpdateTenantAlertEmailGroupRequest, UpdateTenantInviteRequest, UpdateTenantRequest, User, UserChangePasswordRequest, UserLoginRequest, UserRegisterRequest, UserTenantMembershipsList, WebhookWorkerCreated, WebhookWorkerCreateRequest, WebhookWorkerListResponse, Worker, WorkerList, Workflow, WorkflowID, WorkflowList, WorkflowMetrics, WorkflowRun, WorkflowRunList, WorkflowRunsCancelRequest, WorkflowRunsMetrics, WorkflowRunStatus, WorkflowRunStatusList, WorkflowVersion, WorkflowVersionDefinition } from './data-contracts';
1
+ import { AcceptInviteRequest, APIErrors, APIMeta, BulkCreateEventRequest, BulkCreateEventResponse, CancelEventRequest, CreateAPITokenRequest, CreateAPITokenResponse, CreateEventRequest, CreateSNSIntegrationRequest, CreateTenantAlertEmailGroupRequest, CreateTenantInviteRequest, CreateTenantRequest, Event, EventData, EventKey, EventKeyList, EventList, EventOrderByDirection, EventOrderByField, EventSearch, ListAPIMetaIntegration, ListAPITokensResponse, ListSlackWebhooks, ListSNSIntegrations, LogLineLevelField, LogLineList, LogLineOrderByDirection, LogLineOrderByField, LogLineSearch, RejectInviteRequest, ReplayEventRequest, ReplayWorkflowRunsRequest, ReplayWorkflowRunsResponse, RerunStepRunRequest, SNSIntegration, StepRun, StepRunArchiveList, StepRunEventList, Tenant, TenantAlertEmailGroup, TenantAlertEmailGroupList, TenantAlertingSettings, TenantInvite, TenantInviteList, TenantMember, TenantMemberList, TenantQueueMetrics, TenantResourcePolicy, TriggerWorkflowRunRequest, UpdateTenantAlertEmailGroupRequest, UpdateTenantInviteRequest, UpdateTenantRequest, UpdateWorkerRequest, User, UserChangePasswordRequest, UserLoginRequest, UserRegisterRequest, UserTenantMembershipsList, WebhookWorkerCreated, WebhookWorkerCreateRequest, WebhookWorkerListResponse, WebhookWorkerRequestListResponse, Worker, WorkerList, Workflow, WorkflowID, WorkflowKindList, WorkflowList, WorkflowMetrics, WorkflowRun, WorkflowRunList, WorkflowRunOrderByDirection, WorkflowRunOrderByField, WorkflowRunsCancelRequest, WorkflowRunShape, WorkflowRunsMetrics, WorkflowRunStatus, WorkflowRunStatusList, 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
  /**
@@ -453,6 +453,8 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
453
453
  * @example ["key1:value1","key2:value2"]
454
454
  */
455
455
  additionalMetadata?: string[];
456
+ /** A list of event ids to filter by */
457
+ eventIds?: string[];
456
458
  }, params?: RequestParams) => Promise<import("axios").AxiosResponse<EventList, any>>;
457
459
  /**
458
460
  * @description Creates a new event.
@@ -464,6 +466,16 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
464
466
  * @secure
465
467
  */
466
468
  eventCreate: (tenant: string, data: CreateEventRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<Event, any>>;
469
+ /**
470
+ * @description Bulk creates new events.
471
+ *
472
+ * @tags Event
473
+ * @name EventCreateBulk
474
+ * @summary Bulk Create events
475
+ * @request POST:/api/v1/tenants/{tenant}/events/bulk
476
+ * @secure
477
+ */
478
+ eventCreateBulk: (tenant: string, data: BulkCreateEventRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<BulkCreateEventResponse, any>>;
467
479
  /**
468
480
  * @description Replays a list of events.
469
481
  *
@@ -474,6 +486,18 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
474
486
  * @secure
475
487
  */
476
488
  eventUpdateReplay: (tenant: string, data: ReplayEventRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<EventList, any>>;
489
+ /**
490
+ * @description Cancels all runs for a list of events.
491
+ *
492
+ * @tags Event
493
+ * @name EventUpdateCancel
494
+ * @summary Replay events
495
+ * @request POST:/api/v1/tenants/{tenant}/events/cancel
496
+ * @secure
497
+ */
498
+ eventUpdateCancel: (tenant: string, data: CancelEventRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<{
499
+ workflowRunIds?: string[];
500
+ }, any>>;
477
501
  /**
478
502
  * @description Gets a list of tenant members
479
503
  *
@@ -494,6 +518,16 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
494
518
  * @secure
495
519
  */
496
520
  tenantMemberDelete: (tenant: string, member: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<TenantMember, any>>;
521
+ /**
522
+ * @description Get an event.
523
+ *
524
+ * @tags Event
525
+ * @name EventGet
526
+ * @summary Get event data
527
+ * @request GET:/api/v1/events/{event}
528
+ * @secure
529
+ */
530
+ eventGet: (event: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<Event, any>>;
497
531
  /**
498
532
  * @description Get the data for an event.
499
533
  *
@@ -592,24 +626,6 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
592
626
  */
593
627
  version?: string;
594
628
  }, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkflowRun, any>>;
595
- /**
596
- * @description Get a workflow version definition for a tenant
597
- *
598
- * @tags Workflow
599
- * @name WorkflowVersionGetDefinition
600
- * @summary Get workflow version definition
601
- * @request GET:/api/v1/workflows/{workflow}/versions/definition
602
- * @secure
603
- */
604
- workflowVersionGetDefinition: (workflow: string, query?: {
605
- /**
606
- * The workflow version. If not supplied, the latest version is fetched.
607
- * @format uuid
608
- * @minLength 36
609
- * @maxLength 36
610
- */
611
- version?: string;
612
- }, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkflowVersionDefinition, any>>;
613
629
  /**
614
630
  * @description Get the metrics for a workflow version
615
631
  *
@@ -675,6 +691,22 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
675
691
  */
676
692
  limit?: number;
677
693
  }, params?: RequestParams) => Promise<import("axios").AxiosResponse<StepRunEventList, any>>;
694
+ /**
695
+ * @description List events for all step runs for a workflow run
696
+ *
697
+ * @tags Step Run
698
+ * @name WorkflowRunListStepRunEvents
699
+ * @summary List events for all step runs for a workflow run
700
+ * @request GET:/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}/step-run-events
701
+ * @secure
702
+ */
703
+ workflowRunListStepRunEvents: (tenant: string, workflowRun: string, query?: {
704
+ /**
705
+ * Last ID of the last event
706
+ * @format int32
707
+ */
708
+ lastId?: number;
709
+ }, params?: RequestParams) => Promise<import("axios").AxiosResponse<StepRunEventList, any>>;
678
710
  /**
679
711
  * @description List archives for a step run
680
712
  *
@@ -696,6 +728,16 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
696
728
  */
697
729
  limit?: number;
698
730
  }, params?: RequestParams) => Promise<import("axios").AxiosResponse<StepRunArchiveList, any>>;
731
+ /**
732
+ * @description Get a count of the workers available for workflow
733
+ *
734
+ * @tags Workflow
735
+ * @name WorkflowGetWorkersCount
736
+ * @summary Get workflow worker count
737
+ * @request GET:/api/v1/tenants/{tenant}/workflows/{workflow}/worker-count
738
+ * @secure
739
+ */
740
+ workflowGetWorkersCount: (tenant: string, workflow: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkflowWorkersCount, any>>;
699
741
  /**
700
742
  * @description Get all workflow runs for a tenant
701
743
  *
@@ -746,12 +788,40 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
746
788
  parentStepRunId?: string;
747
789
  /** A list of workflow run statuses to filter by */
748
790
  statuses?: WorkflowRunStatusList;
791
+ /** A list of workflow kinds to filter by */
792
+ kinds?: WorkflowKindList;
749
793
  /**
750
794
  * A list of metadata key value pairs to filter by
751
795
  * @example ["key1:value1","key2:value2"]
752
796
  */
753
797
  additionalMetadata?: string[];
798
+ /**
799
+ * The time after the workflow run was created
800
+ * @format date-time
801
+ * @example "2021-01-01T00:00:00Z"
802
+ */
803
+ createdAfter?: string;
804
+ /**
805
+ * The time before the workflow run was created
806
+ * @format date-time
807
+ * @example "2021-01-01T00:00:00Z"
808
+ */
809
+ createdBefore?: string;
810
+ /** The order by field */
811
+ orderByField?: WorkflowRunOrderByField;
812
+ /** The order by direction */
813
+ orderByDirection?: WorkflowRunOrderByDirection;
754
814
  }, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkflowRunList, any>>;
815
+ /**
816
+ * @description Replays a list of workflow runs.
817
+ *
818
+ * @tags Workflow Run
819
+ * @name WorkflowRunUpdateReplay
820
+ * @summary Replay workflow runs
821
+ * @request POST:/api/v1/tenants/{tenant}/workflow-runs/replay
822
+ * @secure
823
+ */
824
+ workflowRunUpdateReplay: (tenant: string, data: ReplayWorkflowRunsRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<ReplayWorkflowRunsResponse, any>>;
755
825
  /**
756
826
  * @description Get a summary of workflow run metrics for a tenant
757
827
  *
@@ -795,6 +865,18 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
795
865
  * @example ["key1:value1","key2:value2"]
796
866
  */
797
867
  additionalMetadata?: string[];
868
+ /**
869
+ * The time after the workflow run was created
870
+ * @format date-time
871
+ * @example "2021-01-01T00:00:00Z"
872
+ */
873
+ createdAfter?: string;
874
+ /**
875
+ * The time before the workflow run was created
876
+ * @format date-time
877
+ * @example "2021-01-01T00:00:00Z"
878
+ */
879
+ createdBefore?: string;
798
880
  }, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkflowRunsMetrics, any>>;
799
881
  /**
800
882
  * @description Get a workflow run for a tenant
@@ -806,6 +888,16 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
806
888
  * @secure
807
889
  */
808
890
  workflowRunGet: (tenant: string, workflowRun: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkflowRun, any>>;
891
+ /**
892
+ * @description Get a workflow run for a tenant
893
+ *
894
+ * @tags Workflow
895
+ * @name WorkflowRunGetShape
896
+ * @summary Get workflow run
897
+ * @request GET:/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}/shape
898
+ * @secure
899
+ */
900
+ workflowRunGetShape: (tenant: string, workflowRun: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkflowRunShape, any>>;
809
901
  /**
810
902
  * @description Get a step run by id
811
903
  *
@@ -856,6 +948,16 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
856
948
  * @secure
857
949
  */
858
950
  workerList: (tenant: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkerList, any>>;
951
+ /**
952
+ * @description Update a worker
953
+ *
954
+ * @tags Worker
955
+ * @name WorkerUpdate
956
+ * @summary Update worker
957
+ * @request PATCH:/api/v1/workers/{worker}
958
+ * @secure
959
+ */
960
+ workerUpdate: (worker: string, data: UpdateWorkerRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<Worker, any>>;
859
961
  /**
860
962
  * @description Get a worker
861
963
  *
@@ -893,4 +995,23 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
893
995
  * @secure
894
996
  */
895
997
  webhookDelete: (webhook: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any>>;
998
+ /**
999
+ * @description Lists all requests for a webhook
1000
+ *
1001
+ * @name WebhookRequestsList
1002
+ * @summary List webhook requests
1003
+ * @request GET:/api/v1/webhook-workers/{webhook}/requests
1004
+ * @secure
1005
+ */
1006
+ webhookRequestsList: (webhook: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<WebhookWorkerRequestListResponse, any>>;
1007
+ /**
1008
+ * @description Get the input for a workflow run.
1009
+ *
1010
+ * @tags Workflow Run
1011
+ * @name WorkflowRunGetInput
1012
+ * @summary Get workflow run input
1013
+ * @request GET:/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}/input
1014
+ * @secure
1015
+ */
1016
+ workflowRunGetInput: (tenant: string, workflowRun: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<Record<string, any>, any>>;
896
1017
  }
@@ -442,6 +442,16 @@ class Api extends http_client_1.HttpClient {
442
442
  * @secure
443
443
  */
444
444
  this.eventCreate = (tenant, data, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/events`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
445
+ /**
446
+ * @description Bulk creates new events.
447
+ *
448
+ * @tags Event
449
+ * @name EventCreateBulk
450
+ * @summary Bulk Create events
451
+ * @request POST:/api/v1/tenants/{tenant}/events/bulk
452
+ * @secure
453
+ */
454
+ this.eventCreateBulk = (tenant, data, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/events/bulk`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
445
455
  /**
446
456
  * @description Replays a list of events.
447
457
  *
@@ -452,6 +462,16 @@ class Api extends http_client_1.HttpClient {
452
462
  * @secure
453
463
  */
454
464
  this.eventUpdateReplay = (tenant, data, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/events/replay`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
465
+ /**
466
+ * @description Cancels all runs for a list of events.
467
+ *
468
+ * @tags Event
469
+ * @name EventUpdateCancel
470
+ * @summary Replay events
471
+ * @request POST:/api/v1/tenants/{tenant}/events/cancel
472
+ * @secure
473
+ */
474
+ this.eventUpdateCancel = (tenant, data, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/events/cancel`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
455
475
  /**
456
476
  * @description Gets a list of tenant members
457
477
  *
@@ -472,6 +492,16 @@ class Api extends http_client_1.HttpClient {
472
492
  * @secure
473
493
  */
474
494
  this.tenantMemberDelete = (tenant, member, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/members/${member}`, method: 'DELETE', secure: true, format: 'json' }, params));
495
+ /**
496
+ * @description Get an event.
497
+ *
498
+ * @tags Event
499
+ * @name EventGet
500
+ * @summary Get event data
501
+ * @request GET:/api/v1/events/{event}
502
+ * @secure
503
+ */
504
+ this.eventGet = (event, params = {}) => this.request(Object.assign({ path: `/api/v1/events/${event}`, method: 'GET', secure: true, format: 'json' }, params));
475
505
  /**
476
506
  * @description Get the data for an event.
477
507
  *
@@ -552,16 +582,6 @@ class Api extends http_client_1.HttpClient {
552
582
  * @secure
553
583
  */
554
584
  this.workflowRunCreate = (workflow, data, query, params = {}) => this.request(Object.assign({ path: `/api/v1/workflows/${workflow}/trigger`, method: 'POST', query: query, body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
555
- /**
556
- * @description Get a workflow version definition for a tenant
557
- *
558
- * @tags Workflow
559
- * @name WorkflowVersionGetDefinition
560
- * @summary Get workflow version definition
561
- * @request GET:/api/v1/workflows/{workflow}/versions/definition
562
- * @secure
563
- */
564
- this.workflowVersionGetDefinition = (workflow, query, params = {}) => this.request(Object.assign({ path: `/api/v1/workflows/${workflow}/versions/definition`, method: 'GET', query: query, secure: true, format: 'json' }, params));
565
585
  /**
566
586
  * @description Get the metrics for a workflow version
567
587
  *
@@ -592,6 +612,16 @@ class Api extends http_client_1.HttpClient {
592
612
  * @secure
593
613
  */
594
614
  this.stepRunListEvents = (stepRun, query, params = {}) => this.request(Object.assign({ path: `/api/v1/step-runs/${stepRun}/events`, method: 'GET', query: query, secure: true, format: 'json' }, params));
615
+ /**
616
+ * @description List events for all step runs for a workflow run
617
+ *
618
+ * @tags Step Run
619
+ * @name WorkflowRunListStepRunEvents
620
+ * @summary List events for all step runs for a workflow run
621
+ * @request GET:/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}/step-run-events
622
+ * @secure
623
+ */
624
+ this.workflowRunListStepRunEvents = (tenant, workflowRun, query, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflow-runs/${workflowRun}/step-run-events`, method: 'GET', query: query, secure: true, format: 'json' }, params));
595
625
  /**
596
626
  * @description List archives for a step run
597
627
  *
@@ -602,6 +632,16 @@ class Api extends http_client_1.HttpClient {
602
632
  * @secure
603
633
  */
604
634
  this.stepRunListArchives = (stepRun, query, params = {}) => this.request(Object.assign({ path: `/api/v1/step-runs/${stepRun}/archives`, method: 'GET', query: query, secure: true, format: 'json' }, params));
635
+ /**
636
+ * @description Get a count of the workers available for workflow
637
+ *
638
+ * @tags Workflow
639
+ * @name WorkflowGetWorkersCount
640
+ * @summary Get workflow worker count
641
+ * @request GET:/api/v1/tenants/{tenant}/workflows/{workflow}/worker-count
642
+ * @secure
643
+ */
644
+ this.workflowGetWorkersCount = (tenant, workflow, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflows/${workflow}/worker-count`, method: 'GET', secure: true, format: 'json' }, params));
605
645
  /**
606
646
  * @description Get all workflow runs for a tenant
607
647
  *
@@ -612,6 +652,16 @@ class Api extends http_client_1.HttpClient {
612
652
  * @secure
613
653
  */
614
654
  this.workflowRunList = (tenant, query, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflows/runs`, method: 'GET', query: query, secure: true, format: 'json' }, params));
655
+ /**
656
+ * @description Replays a list of workflow runs.
657
+ *
658
+ * @tags Workflow Run
659
+ * @name WorkflowRunUpdateReplay
660
+ * @summary Replay workflow runs
661
+ * @request POST:/api/v1/tenants/{tenant}/workflow-runs/replay
662
+ * @secure
663
+ */
664
+ this.workflowRunUpdateReplay = (tenant, data, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflow-runs/replay`, method: 'POST', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
615
665
  /**
616
666
  * @description Get a summary of workflow run metrics for a tenant
617
667
  *
@@ -632,6 +682,16 @@ class Api extends http_client_1.HttpClient {
632
682
  * @secure
633
683
  */
634
684
  this.workflowRunGet = (tenant, workflowRun, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflow-runs/${workflowRun}`, method: 'GET', secure: true, format: 'json' }, params));
685
+ /**
686
+ * @description Get a workflow run for a tenant
687
+ *
688
+ * @tags Workflow
689
+ * @name WorkflowRunGetShape
690
+ * @summary Get workflow run
691
+ * @request GET:/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}/shape
692
+ * @secure
693
+ */
694
+ this.workflowRunGetShape = (tenant, workflowRun, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflow-runs/${workflowRun}/shape`, method: 'GET', secure: true, format: 'json' }, params));
635
695
  /**
636
696
  * @description Get a step run by id
637
697
  *
@@ -682,6 +742,16 @@ class Api extends http_client_1.HttpClient {
682
742
  * @secure
683
743
  */
684
744
  this.workerList = (tenant, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/worker`, method: 'GET', secure: true, format: 'json' }, params));
745
+ /**
746
+ * @description Update a worker
747
+ *
748
+ * @tags Worker
749
+ * @name WorkerUpdate
750
+ * @summary Update worker
751
+ * @request PATCH:/api/v1/workers/{worker}
752
+ * @secure
753
+ */
754
+ this.workerUpdate = (worker, data, params = {}) => this.request(Object.assign({ path: `/api/v1/workers/${worker}`, method: 'PATCH', body: data, secure: true, type: http_client_1.ContentType.Json, format: 'json' }, params));
685
755
  /**
686
756
  * @description Get a worker
687
757
  *
@@ -719,6 +789,25 @@ class Api extends http_client_1.HttpClient {
719
789
  * @secure
720
790
  */
721
791
  this.webhookDelete = (webhook, params = {}) => this.request(Object.assign({ path: `/api/v1/webhook-workers/${webhook}`, method: 'DELETE', secure: true }, params));
792
+ /**
793
+ * @description Lists all requests for a webhook
794
+ *
795
+ * @name WebhookRequestsList
796
+ * @summary List webhook requests
797
+ * @request GET:/api/v1/webhook-workers/{webhook}/requests
798
+ * @secure
799
+ */
800
+ this.webhookRequestsList = (webhook, params = {}) => this.request(Object.assign({ path: `/api/v1/webhook-workers/${webhook}/requests`, method: 'GET', secure: true, format: 'json' }, params));
801
+ /**
802
+ * @description Get the input for a workflow run.
803
+ *
804
+ * @tags Workflow Run
805
+ * @name WorkflowRunGetInput
806
+ * @summary Get workflow run input
807
+ * @request GET:/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}/input
808
+ * @secure
809
+ */
810
+ this.workflowRunGetInput = (tenant, workflowRun, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflow-runs/${workflowRun}/input`, method: 'GET', secure: true, format: 'json' }, params));
722
811
  }
723
812
  }
724
813
  exports.Api = Api;
@@ -106,8 +106,7 @@ export interface PaginationResponse {
106
106
  export interface APIResourceMeta {
107
107
  /**
108
108
  * the id of this resource, in UUID format
109
- * @format uuid
110
- * @minLength 36
109
+ * @minLength 0
111
110
  * @maxLength 36
112
111
  * @example "bb214807-246e-43a5-a25d-41761d1cff9e"
113
112
  */
@@ -383,6 +382,14 @@ export interface CreateEventRequest {
383
382
  /** Additional metadata for the event. */
384
383
  additionalMetadata?: object;
385
384
  }
385
+ export interface BulkCreateEventRequest {
386
+ events: CreateEventRequest[];
387
+ }
388
+ export interface BulkCreateEventResponse {
389
+ metadata: APIResourceMeta;
390
+ /** The events. */
391
+ events: Event[];
392
+ }
386
393
  export interface EventWorkflowRunSummary {
387
394
  /**
388
395
  * The number of pending runs.
@@ -433,6 +440,9 @@ export interface EventList {
433
440
  export interface ReplayEventRequest {
434
441
  eventIds: string[];
435
442
  }
443
+ export interface CancelEventRequest {
444
+ eventIds: string[];
445
+ }
436
446
  export interface Workflow {
437
447
  metadata: APIResourceMeta;
438
448
  /** The name of the workflow. */
@@ -442,7 +452,6 @@ export interface Workflow {
442
452
  versions?: WorkflowVersionMeta[];
443
453
  /** The tags of the workflow. */
444
454
  tags?: WorkflowTag[];
445
- lastRun?: WorkflowRun;
446
455
  /** The jobs of the workflow. */
447
456
  jobs?: Job[];
448
457
  }
@@ -473,6 +482,13 @@ export interface WorkflowVersion {
473
482
  /** @format int32 */
474
483
  order: number;
475
484
  workflowId: string;
485
+ /** The sticky strategy of the workflow. */
486
+ sticky?: string;
487
+ /**
488
+ * The default priority of the workflow.
489
+ * @format int32
490
+ */
491
+ defaultPriority?: number;
476
492
  workflow?: Workflow;
477
493
  concurrency?: WorkflowConcurrency;
478
494
  triggers?: WorkflowTriggers;
@@ -532,6 +548,11 @@ export interface Step {
532
548
  children?: string[];
533
549
  parents?: string[];
534
550
  }
551
+ export interface WorkflowWorkersCount {
552
+ freeSlotCount?: number;
553
+ maxSlotCount?: number;
554
+ workflowRunId?: string;
555
+ }
535
556
  export interface WorkflowRun {
536
557
  metadata: APIResourceMeta;
537
558
  tenantId: string;
@@ -547,6 +568,42 @@ export interface WorkflowRun {
547
568
  startedAt?: string;
548
569
  /** @format date-time */
549
570
  finishedAt?: string;
571
+ /** @example 1000 */
572
+ duration?: number;
573
+ /**
574
+ * @format uuid
575
+ * @minLength 36
576
+ * @maxLength 36
577
+ * @example "bb214807-246e-43a5-a25d-41761d1cff9e"
578
+ */
579
+ parentId?: string;
580
+ /**
581
+ * @format uuid
582
+ * @minLength 36
583
+ * @maxLength 36
584
+ * @example "bb214807-246e-43a5-a25d-41761d1cff9e"
585
+ */
586
+ parentStepRunId?: string;
587
+ additionalMetadata?: Record<string, any>;
588
+ }
589
+ export interface WorkflowRunShape {
590
+ metadata: APIResourceMeta;
591
+ tenantId: string;
592
+ workflowId?: string;
593
+ workflowVersionId: string;
594
+ workflowVersion?: WorkflowVersion;
595
+ status: WorkflowRunStatus;
596
+ displayName?: string;
597
+ jobRuns?: JobRun[];
598
+ triggeredBy: WorkflowRunTriggeredBy;
599
+ input?: Record<string, any>;
600
+ error?: string;
601
+ /** @format date-time */
602
+ startedAt?: string;
603
+ /** @format date-time */
604
+ finishedAt?: string;
605
+ /** @example 1000 */
606
+ duration?: number;
550
607
  /**
551
608
  * @format uuid
552
609
  * @minLength 36
@@ -563,10 +620,27 @@ export interface WorkflowRun {
563
620
  parentStepRunId?: string;
564
621
  additionalMetadata?: Record<string, any>;
565
622
  }
623
+ export interface ReplayWorkflowRunsRequest {
624
+ /** @maxLength 500 */
625
+ workflowRunIds: string[];
626
+ }
627
+ export interface ReplayWorkflowRunsResponse {
628
+ workflowRuns: WorkflowRun[];
629
+ }
566
630
  export interface WorkflowRunList {
567
631
  rows?: WorkflowRun[];
568
632
  pagination?: PaginationResponse;
569
633
  }
634
+ export declare enum WorkflowRunOrderByField {
635
+ CreatedAt = "createdAt",
636
+ StartedAt = "startedAt",
637
+ FinishedAt = "finishedAt",
638
+ Duration = "duration"
639
+ }
640
+ export declare enum WorkflowRunOrderByDirection {
641
+ ASC = "ASC",
642
+ DESC = "DESC"
643
+ }
570
644
  export interface WorkflowRunsMetrics {
571
645
  counts?: WorkflowRunsMetricsCounts;
572
646
  }
@@ -586,6 +660,12 @@ export declare enum WorkflowRunStatus {
586
660
  QUEUED = "QUEUED"
587
661
  }
588
662
  export type WorkflowRunStatusList = WorkflowRunStatus[];
663
+ export declare enum WorkflowKind {
664
+ FUNCTION = "FUNCTION",
665
+ DURABLE = "DURABLE",
666
+ DAG = "DAG"
667
+ }
668
+ export type WorkflowKindList = WorkflowKind[];
589
669
  export interface WorkflowRunsCancelRequest {
590
670
  workflowRunIds: string[];
591
671
  }
@@ -603,7 +683,8 @@ export declare enum StepRunStatus {
603
683
  RUNNING = "RUNNING",
604
684
  SUCCEEDED = "SUCCEEDED",
605
685
  FAILED = "FAILED",
606
- CANCELLED = "CANCELLED"
686
+ CANCELLED = "CANCELLED",
687
+ CANCELLING = "CANCELLING"
607
688
  }
608
689
  export interface JobRun {
609
690
  metadata: APIResourceMeta;
@@ -629,9 +710,8 @@ export interface JobRun {
629
710
  }
630
711
  export interface WorkflowRunTriggeredBy {
631
712
  metadata: APIResourceMeta;
632
- parentId: string;
713
+ parentWorkflowRunId?: string;
633
714
  eventId?: string;
634
- event?: Event;
635
715
  cronParentId?: string;
636
716
  cronSchedule?: string;
637
717
  }
@@ -642,7 +722,7 @@ export interface StepRun {
642
722
  jobRun?: JobRun;
643
723
  stepId: string;
644
724
  step?: Step;
645
- children?: string[];
725
+ childWorkflowsCount?: number;
646
726
  parents?: string[];
647
727
  childWorkflowRuns?: string[];
648
728
  workerId?: string;
@@ -682,7 +762,9 @@ export declare enum StepRunEventReason {
682
762
  REASSIGNED = "REASSIGNED",
683
763
  TIMED_OUT = "TIMED_OUT",
684
764
  SLOT_RELEASED = "SLOT_RELEASED",
685
- RETRIED_BY_USER = "RETRIED_BY_USER"
765
+ RETRIED_BY_USER = "RETRIED_BY_USER",
766
+ WORKFLOW_RUN_GROUP_KEY_SUCCEEDED = "WORKFLOW_RUN_GROUP_KEY_SUCCEEDED",
767
+ WORKFLOW_RUN_GROUP_KEY_FAILED = "WORKFLOW_RUN_GROUP_KEY_FAILED"
686
768
  }
687
769
  export declare enum StepRunEventSeverity {
688
770
  INFO = "INFO",
@@ -695,7 +777,8 @@ export interface StepRunEvent {
695
777
  timeFirstSeen: string;
696
778
  /** @format date-time */
697
779
  timeLastSeen: string;
698
- stepRunId: string;
780
+ stepRunId?: string;
781
+ workflowRunId?: string;
699
782
  reason: StepRunEventReason;
700
783
  severity: StepRunEventSeverity;
701
784
  message: string;
@@ -714,6 +797,7 @@ export interface StepRunArchive {
714
797
  /** @format date-time */
715
798
  startedAt?: string;
716
799
  error?: string;
800
+ retryCount: number;
717
801
  /** @format date-time */
718
802
  createdAt: string;
719
803
  startedAtEpoch?: number;
@@ -737,10 +821,50 @@ export interface WorkerList {
737
821
  pagination?: PaginationResponse;
738
822
  rows?: Worker[];
739
823
  }
824
+ export interface SemaphoreSlots {
825
+ /**
826
+ * The step run id.
827
+ * @format uuid
828
+ */
829
+ stepRunId: string;
830
+ /** The action id. */
831
+ actionId: string;
832
+ /**
833
+ * The time this slot was started.
834
+ * @format date-time
835
+ */
836
+ startedAt?: string;
837
+ /**
838
+ * The time this slot will timeout.
839
+ * @format date-time
840
+ */
841
+ timeoutAt?: string;
842
+ /**
843
+ * The workflow run id.
844
+ * @format uuid
845
+ */
846
+ workflowRunId: string;
847
+ status: StepRunStatus;
848
+ }
849
+ export interface RecentStepRuns {
850
+ metadata: APIResourceMeta;
851
+ /** The action id. */
852
+ actionId: string;
853
+ status: StepRunStatus;
854
+ /** @format date-time */
855
+ startedAt?: string;
856
+ /** @format date-time */
857
+ finishedAt?: string;
858
+ /** @format date-time */
859
+ cancelledAt?: string;
860
+ /** @format uuid */
861
+ workflowRunId: string;
862
+ }
740
863
  export interface Worker {
741
864
  metadata: APIResourceMeta;
742
865
  /** The name of the worker. */
743
866
  name: string;
867
+ type: 'SELFHOSTED' | 'MANAGED' | 'WEBHOOK';
744
868
  /**
745
869
  * The time this worker last sent a heartbeat.
746
870
  * @format date-time
@@ -755,10 +879,12 @@ export interface Worker {
755
879
  lastListenerEstablished?: string;
756
880
  /** The actions this worker can perform. */
757
881
  actions?: string[];
758
- /** The recent step runs for this worker. */
759
- recentStepRuns?: StepRun[];
882
+ /** The semaphore slot state for the worker. */
883
+ slots?: SemaphoreSlots[];
884
+ /** The recent step runs for the worker. */
885
+ recentStepRuns?: RecentStepRuns[];
760
886
  /** The status of the worker. */
761
- status?: 'ACTIVE' | 'INACTIVE';
887
+ status?: 'ACTIVE' | 'INACTIVE' | 'PAUSED';
762
888
  /** The maximum number of runs this worker can execute concurrently. */
763
889
  maxRuns?: number;
764
890
  /** The number of runs this worker can execute concurrently. */
@@ -771,6 +897,26 @@ export interface Worker {
771
897
  * @example "bb214807-246e-43a5-a25d-41761d1cff9e"
772
898
  */
773
899
  dispatcherId?: string;
900
+ /** The current label state of the worker. */
901
+ labels?: WorkerLabel[];
902
+ /** The webhook URL for the worker. */
903
+ webhookUrl?: string;
904
+ /**
905
+ * The webhook ID for the worker.
906
+ * @format uuid
907
+ */
908
+ webhookId?: string;
909
+ }
910
+ export interface WorkerLabel {
911
+ metadata: APIResourceMeta;
912
+ /** The key of the label. */
913
+ key: string;
914
+ /** The value of the label. */
915
+ value?: string;
916
+ }
917
+ export interface UpdateWorkerRequest {
918
+ /** Whether the worker is paused and cannot accept new runs. */
919
+ isPaused?: boolean;
774
920
  }
775
921
  export interface APIToken {
776
922
  metadata: APIResourceMeta;
@@ -791,6 +937,8 @@ export interface CreateAPITokenRequest {
791
937
  * @maxLength 255
792
938
  */
793
939
  name: string;
940
+ /** The duration for which the token is valid. */
941
+ expiresIn?: string;
794
942
  }
795
943
  export interface CreateAPITokenResponse {
796
944
  /** The API token. */
@@ -918,6 +1066,26 @@ export interface WebhookWorker {
918
1066
  /** The webhook url. */
919
1067
  url: string;
920
1068
  }
1069
+ export declare enum WebhookWorkerRequestMethod {
1070
+ GET = "GET",
1071
+ POST = "POST",
1072
+ PUT = "PUT"
1073
+ }
1074
+ export interface WebhookWorkerRequest {
1075
+ /**
1076
+ * The date and time the request was created.
1077
+ * @format date-time
1078
+ */
1079
+ created_at: string;
1080
+ /** The HTTP method used for the request. */
1081
+ method: WebhookWorkerRequestMethod;
1082
+ /** The HTTP status code of the response. */
1083
+ statusCode: number;
1084
+ }
1085
+ export interface WebhookWorkerRequestListResponse {
1086
+ /** The list of webhook requests. */
1087
+ requests?: WebhookWorkerRequest[];
1088
+ }
921
1089
  export interface WebhookWorkerCreated {
922
1090
  metadata: APIResourceMeta;
923
1091
  /** The name of the webhook worker. */
@@ -10,7 +10,7 @@
10
10
  * ---------------------------------------------------------------
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.LogLineOrderByDirection = exports.LogLineOrderByField = exports.LogLineLevel = exports.PullRequestState = exports.StepRunEventSeverity = exports.StepRunEventReason = exports.StepRunStatus = exports.JobRunStatus = exports.WorkflowRunStatus = exports.EventOrderByDirection = exports.EventOrderByField = exports.TenantResource = exports.TenantMemberRole = void 0;
13
+ exports.WebhookWorkerRequestMethod = exports.LogLineOrderByDirection = exports.LogLineOrderByField = exports.LogLineLevel = exports.PullRequestState = exports.StepRunEventSeverity = exports.StepRunEventReason = exports.StepRunStatus = exports.JobRunStatus = exports.WorkflowKind = exports.WorkflowRunStatus = exports.WorkflowRunOrderByDirection = exports.WorkflowRunOrderByField = exports.EventOrderByDirection = exports.EventOrderByField = exports.TenantResource = exports.TenantMemberRole = void 0;
14
14
  var TenantMemberRole;
15
15
  (function (TenantMemberRole) {
16
16
  TenantMemberRole["OWNER"] = "OWNER";
@@ -34,6 +34,18 @@ var EventOrderByDirection;
34
34
  EventOrderByDirection["Asc"] = "asc";
35
35
  EventOrderByDirection["Desc"] = "desc";
36
36
  })(EventOrderByDirection || (exports.EventOrderByDirection = EventOrderByDirection = {}));
37
+ var WorkflowRunOrderByField;
38
+ (function (WorkflowRunOrderByField) {
39
+ WorkflowRunOrderByField["CreatedAt"] = "createdAt";
40
+ WorkflowRunOrderByField["StartedAt"] = "startedAt";
41
+ WorkflowRunOrderByField["FinishedAt"] = "finishedAt";
42
+ WorkflowRunOrderByField["Duration"] = "duration";
43
+ })(WorkflowRunOrderByField || (exports.WorkflowRunOrderByField = WorkflowRunOrderByField = {}));
44
+ var WorkflowRunOrderByDirection;
45
+ (function (WorkflowRunOrderByDirection) {
46
+ WorkflowRunOrderByDirection["ASC"] = "ASC";
47
+ WorkflowRunOrderByDirection["DESC"] = "DESC";
48
+ })(WorkflowRunOrderByDirection || (exports.WorkflowRunOrderByDirection = WorkflowRunOrderByDirection = {}));
37
49
  var WorkflowRunStatus;
38
50
  (function (WorkflowRunStatus) {
39
51
  WorkflowRunStatus["PENDING"] = "PENDING";
@@ -43,6 +55,12 @@ var WorkflowRunStatus;
43
55
  WorkflowRunStatus["CANCELLED"] = "CANCELLED";
44
56
  WorkflowRunStatus["QUEUED"] = "QUEUED";
45
57
  })(WorkflowRunStatus || (exports.WorkflowRunStatus = WorkflowRunStatus = {}));
58
+ var WorkflowKind;
59
+ (function (WorkflowKind) {
60
+ WorkflowKind["FUNCTION"] = "FUNCTION";
61
+ WorkflowKind["DURABLE"] = "DURABLE";
62
+ WorkflowKind["DAG"] = "DAG";
63
+ })(WorkflowKind || (exports.WorkflowKind = WorkflowKind = {}));
46
64
  var JobRunStatus;
47
65
  (function (JobRunStatus) {
48
66
  JobRunStatus["PENDING"] = "PENDING";
@@ -60,6 +78,7 @@ var StepRunStatus;
60
78
  StepRunStatus["SUCCEEDED"] = "SUCCEEDED";
61
79
  StepRunStatus["FAILED"] = "FAILED";
62
80
  StepRunStatus["CANCELLED"] = "CANCELLED";
81
+ StepRunStatus["CANCELLING"] = "CANCELLING";
63
82
  })(StepRunStatus || (exports.StepRunStatus = StepRunStatus = {}));
64
83
  var StepRunEventReason;
65
84
  (function (StepRunEventReason) {
@@ -77,6 +96,8 @@ var StepRunEventReason;
77
96
  StepRunEventReason["TIMED_OUT"] = "TIMED_OUT";
78
97
  StepRunEventReason["SLOT_RELEASED"] = "SLOT_RELEASED";
79
98
  StepRunEventReason["RETRIED_BY_USER"] = "RETRIED_BY_USER";
99
+ StepRunEventReason["WORKFLOW_RUN_GROUP_KEY_SUCCEEDED"] = "WORKFLOW_RUN_GROUP_KEY_SUCCEEDED";
100
+ StepRunEventReason["WORKFLOW_RUN_GROUP_KEY_FAILED"] = "WORKFLOW_RUN_GROUP_KEY_FAILED";
80
101
  })(StepRunEventReason || (exports.StepRunEventReason = StepRunEventReason = {}));
81
102
  var StepRunEventSeverity;
82
103
  (function (StepRunEventSeverity) {
@@ -105,3 +126,9 @@ var LogLineOrderByDirection;
105
126
  LogLineOrderByDirection["Asc"] = "asc";
106
127
  LogLineOrderByDirection["Desc"] = "desc";
107
128
  })(LogLineOrderByDirection || (exports.LogLineOrderByDirection = LogLineOrderByDirection = {}));
129
+ var WebhookWorkerRequestMethod;
130
+ (function (WebhookWorkerRequestMethod) {
131
+ WebhookWorkerRequestMethod["GET"] = "GET";
132
+ WebhookWorkerRequestMethod["POST"] = "POST";
133
+ WebhookWorkerRequestMethod["PUT"] = "PUT";
134
+ })(WebhookWorkerRequestMethod || (exports.WebhookWorkerRequestMethod = WebhookWorkerRequestMethod = {}));
@@ -63,7 +63,7 @@ class HttpClient {
63
63
  if (type === ContentType.Text && body && body !== null && typeof body !== 'string') {
64
64
  body = JSON.stringify(body);
65
65
  }
66
- return this.instance.request(Object.assign(Object.assign({}, requestParams), { headers: Object.assign(Object.assign({}, (requestParams.headers || {})), (type && type !== ContentType.FormData ? { 'Content-Type': type } : {})), params: query, responseType: responseFormat, data: body, url: path }));
66
+ return this.instance.request(Object.assign(Object.assign({}, requestParams), { headers: Object.assign(Object.assign({}, (requestParams.headers || {})), (type ? { 'Content-Type': type } : {})), params: query, responseType: responseFormat, data: body, url: path }));
67
67
  });
68
68
  this.instance = axios_1.default.create(Object.assign(Object.assign({}, axiosConfig), { baseURL: axiosConfig.baseURL || '' }));
69
69
  this.secure = secure;
@@ -85,6 +85,9 @@ class HttpClient {
85
85
  }
86
86
  }
87
87
  createFormData(input) {
88
+ if (input instanceof FormData) {
89
+ return input;
90
+ }
88
91
  return Object.keys(input || {}).reduce((formData, key) => {
89
92
  const property = input[key];
90
93
  const propertyContent = property instanceof Array ? property : [property];
@@ -5,6 +5,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const sdk_1 = __importDefault(require("../sdk"));
7
7
  const hatchet = sdk_1.default.init();
8
+ // Push a single event (example)
8
9
  hatchet.event.push('user:create', {
9
10
  test: 'test',
10
11
  });
12
+ // Example events to be pushed in bulk
13
+ const events = [
14
+ {
15
+ payload: { test: 'test1' },
16
+ additionalMetadata: { user_id: 'user1', source: 'test' },
17
+ },
18
+ {
19
+ payload: { test: 'test2' },
20
+ additionalMetadata: { user_id: 'user2', source: 'test' },
21
+ },
22
+ {
23
+ payload: { test: 'test3' },
24
+ additionalMetadata: { user_id: 'user3', source: 'test' },
25
+ },
26
+ ];
27
+ // Bulk push the events and compare the keys
28
+ hatchet.event
29
+ .bulkPush('user:create:bulk', events)
30
+ .then((result) => {
31
+ const returnedEvents = result.events;
32
+ const keysMatch = returnedEvents.every((returnedEvent) => {
33
+ const expectedKey = `user:create:bulk`;
34
+ return returnedEvent.key === expectedKey;
35
+ });
36
+ if (keysMatch) {
37
+ // eslint-disable-next-line no-console
38
+ console.log('All keys match the original events.');
39
+ }
40
+ else {
41
+ // eslint-disable-next-line no-console
42
+ console.log('Mismatch found between original events and returned events.');
43
+ }
44
+ })
45
+ .catch((error) => {
46
+ // eslint-disable-next-line no-console
47
+ console.error('Error during bulk push:', error);
48
+ });
@@ -14,9 +14,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const sdk_1 = __importDefault(require("../sdk"));
16
16
  const hatchet = sdk_1.default.init();
17
- const sleep = (ms) => new Promise((resolve) => {
18
- setTimeout(resolve, ms);
19
- });
20
17
  const parentWorkflow = {
21
18
  id: 'parent-workflow',
22
19
  description: 'simple example for spawning child workflows',
@@ -26,16 +23,19 @@ const parentWorkflow = {
26
23
  steps: [
27
24
  {
28
25
  name: 'parent-spawn',
29
- timeout: '10s',
26
+ timeout: '70s',
30
27
  run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
31
- ctx.putStream('spawning children');
32
- const promises = Array.from({ length: 7 }, (_, i) => ctx
28
+ const promises = Array.from({ length: 3 }, (_, i) => ctx
33
29
  .spawnWorkflow('child-workflow', { input: `child-input-${i}` }, { additionalMetadata: { childKey: 'childValue' } })
34
- .result());
30
+ .result()
31
+ .then((result) => {
32
+ ctx.log('spawned workflow result:');
33
+ return result;
34
+ }));
35
35
  const results = yield Promise.all(promises);
36
36
  console.log('spawned workflow results:', results);
37
37
  console.log('number of spawned workflows:', results.length);
38
- return { spawned: results };
38
+ return { spawned: 'x' };
39
39
  }),
40
40
  },
41
41
  ],
@@ -44,25 +44,46 @@ const childWorkflow = {
44
44
  id: 'child-workflow',
45
45
  description: 'simple example for spawning child workflows',
46
46
  on: {
47
- event: 'fanout:create',
47
+ event: 'child:create',
48
48
  },
49
49
  steps: [
50
50
  {
51
51
  name: 'child-work',
52
52
  run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
53
53
  const { input } = ctx.workflowInput();
54
- ctx.putStream('child running...');
55
- yield sleep(10);
54
+ // throw new Error('child error');
55
+ return { 'child-output': 'sm' };
56
+ }),
57
+ },
58
+ {
59
+ name: 'child-work2',
60
+ run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
61
+ const { input } = ctx.workflowInput();
62
+ // Perform CPU-bound work
56
63
  // throw new Error('child error');
57
64
  console.log('child workflow input:', input);
58
- return { 'child-output': 'results' };
65
+ // Generate a large amount of garbage data
66
+ const garbageData = Array.from({ length: 1e6 / 3.5 }, (_, i) => `garbage-${i}`).join(',');
67
+ console.log('Generated garbage data:', `${garbageData.slice(0, 100)}...`); // Print a snippet of the garbage data
68
+ return { 'child-output': garbageData };
69
+ }),
70
+ },
71
+ {
72
+ name: 'child-work3',
73
+ parents: ['child-work'],
74
+ run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
75
+ const { input } = ctx.workflowInput();
76
+ // throw new Error('child error');
77
+ const garbageData = Array.from({ length: 1e6 / 3.5 }, (_, i) => `garbage-${i}`).join(',');
78
+ console.log('Generated garbage data:', `${garbageData.slice(0, 100)}...`); // Print a snippet of the garbage data
79
+ return { 'child-output': garbageData };
59
80
  }),
60
81
  },
61
82
  ],
62
83
  };
63
84
  function main() {
64
85
  return __awaiter(this, void 0, void 0, function* () {
65
- const worker = yield hatchet.worker('fanout-worker');
86
+ const worker = yield hatchet.worker('fanout-worker', { maxRuns: 1000 });
66
87
  yield worker.registerWorkflow(parentWorkflow);
67
88
  yield worker.registerWorkflow(childWorkflow);
68
89
  worker.start();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -15,6 +15,9 @@ export interface Event {
15
15
  /** the payload for the event */
16
16
  additionalMetadata?: string | undefined;
17
17
  }
18
+ export interface Events {
19
+ events: Event[];
20
+ }
18
21
  export interface PutLogRequest {
19
22
  /** the step run id for the request */
20
23
  stepRunId: string;
@@ -41,6 +44,9 @@ export interface PutStreamEventRequest {
41
44
  }
42
45
  export interface PutStreamEventResponse {
43
46
  }
47
+ export interface BulkPushEventRequest {
48
+ events: PushEventRequest[];
49
+ }
44
50
  export interface PushEventRequest {
45
51
  /** the key for the event */
46
52
  key: string;
@@ -56,10 +62,12 @@ export interface ReplayEventRequest {
56
62
  eventId: string;
57
63
  }
58
64
  export declare const Event: MessageFns<Event>;
65
+ export declare const Events: MessageFns<Events>;
59
66
  export declare const PutLogRequest: MessageFns<PutLogRequest>;
60
67
  export declare const PutLogResponse: MessageFns<PutLogResponse>;
61
68
  export declare const PutStreamEventRequest: MessageFns<PutStreamEventRequest>;
62
69
  export declare const PutStreamEventResponse: MessageFns<PutStreamEventResponse>;
70
+ export declare const BulkPushEventRequest: MessageFns<BulkPushEventRequest>;
63
71
  export declare const PushEventRequest: MessageFns<PushEventRequest>;
64
72
  export declare const ReplayEventRequest: MessageFns<ReplayEventRequest>;
65
73
  export type EventsServiceDefinition = typeof EventsServiceDefinition;
@@ -75,6 +83,14 @@ export declare const EventsServiceDefinition: {
75
83
  readonly responseStream: false;
76
84
  readonly options: {};
77
85
  };
86
+ readonly bulkPush: {
87
+ readonly name: "BulkPush";
88
+ readonly requestType: MessageFns<BulkPushEventRequest>;
89
+ readonly requestStream: false;
90
+ readonly responseType: MessageFns<Events>;
91
+ readonly responseStream: false;
92
+ readonly options: {};
93
+ };
78
94
  readonly replaySingleEvent: {
79
95
  readonly name: "ReplaySingleEvent";
80
96
  readonly requestType: MessageFns<ReplayEventRequest>;
@@ -103,12 +119,14 @@ export declare const EventsServiceDefinition: {
103
119
  };
104
120
  export interface EventsServiceImplementation<CallContextExt = {}> {
105
121
  push(request: PushEventRequest, context: CallContext & CallContextExt): Promise<DeepPartial<Event>>;
122
+ bulkPush(request: BulkPushEventRequest, context: CallContext & CallContextExt): Promise<DeepPartial<Events>>;
106
123
  replaySingleEvent(request: ReplayEventRequest, context: CallContext & CallContextExt): Promise<DeepPartial<Event>>;
107
124
  putLog(request: PutLogRequest, context: CallContext & CallContextExt): Promise<DeepPartial<PutLogResponse>>;
108
125
  putStreamEvent(request: PutStreamEventRequest, context: CallContext & CallContextExt): Promise<DeepPartial<PutStreamEventResponse>>;
109
126
  }
110
127
  export interface EventsServiceClient<CallOptionsExt = {}> {
111
128
  push(request: DeepPartial<PushEventRequest>, options?: CallOptions & CallOptionsExt): Promise<Event>;
129
+ bulkPush(request: DeepPartial<BulkPushEventRequest>, options?: CallOptions & CallOptionsExt): Promise<Events>;
112
130
  replaySingleEvent(request: DeepPartial<ReplayEventRequest>, options?: CallOptions & CallOptionsExt): Promise<Event>;
113
131
  putLog(request: DeepPartial<PutLogRequest>, options?: CallOptions & CallOptionsExt): Promise<PutLogResponse>;
114
132
  putStreamEvent(request: DeepPartial<PutStreamEventRequest>, options?: CallOptions & CallOptionsExt): Promise<PutStreamEventResponse>;
@@ -5,7 +5,7 @@
5
5
  // protoc v3.19.1
6
6
  // source: events/events.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.EventsServiceDefinition = exports.ReplayEventRequest = exports.PushEventRequest = exports.PutStreamEventResponse = exports.PutStreamEventRequest = exports.PutLogResponse = exports.PutLogRequest = exports.Event = exports.protobufPackage = void 0;
8
+ exports.EventsServiceDefinition = exports.ReplayEventRequest = exports.PushEventRequest = exports.BulkPushEventRequest = exports.PutStreamEventResponse = exports.PutStreamEventRequest = exports.PutLogResponse = exports.PutLogRequest = exports.Events = exports.Event = exports.protobufPackage = void 0;
9
9
  /* eslint-disable */
10
10
  const wire_1 = require("@bufbuild/protobuf/wire");
11
11
  const timestamp_1 = require("../google/protobuf/timestamp");
@@ -144,6 +144,62 @@ exports.Event = {
144
144
  return message;
145
145
  },
146
146
  };
147
+ function createBaseEvents() {
148
+ return { events: [] };
149
+ }
150
+ exports.Events = {
151
+ encode(message, writer = new wire_1.BinaryWriter()) {
152
+ for (const v of message.events) {
153
+ exports.Event.encode(v, writer.uint32(10).fork()).join();
154
+ }
155
+ return writer;
156
+ },
157
+ decode(input, length) {
158
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
159
+ let end = length === undefined ? reader.len : reader.pos + length;
160
+ const message = createBaseEvents();
161
+ while (reader.pos < end) {
162
+ const tag = reader.uint32();
163
+ switch (tag >>> 3) {
164
+ case 1:
165
+ if (tag !== 10) {
166
+ break;
167
+ }
168
+ message.events.push(exports.Event.decode(reader, reader.uint32()));
169
+ continue;
170
+ }
171
+ if ((tag & 7) === 4 || tag === 0) {
172
+ break;
173
+ }
174
+ reader.skip(tag & 7);
175
+ }
176
+ return message;
177
+ },
178
+ fromJSON(object) {
179
+ return {
180
+ events: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.events)
181
+ ? object.events.map((e) => exports.Event.fromJSON(e))
182
+ : [],
183
+ };
184
+ },
185
+ toJSON(message) {
186
+ var _a;
187
+ const obj = {};
188
+ if ((_a = message.events) === null || _a === void 0 ? void 0 : _a.length) {
189
+ obj.events = message.events.map((e) => exports.Event.toJSON(e));
190
+ }
191
+ return obj;
192
+ },
193
+ create(base) {
194
+ return exports.Events.fromPartial(base !== null && base !== void 0 ? base : {});
195
+ },
196
+ fromPartial(object) {
197
+ var _a;
198
+ const message = createBaseEvents();
199
+ message.events = ((_a = object.events) === null || _a === void 0 ? void 0 : _a.map((e) => exports.Event.fromPartial(e))) || [];
200
+ return message;
201
+ },
202
+ };
147
203
  function createBasePutLogRequest() {
148
204
  return { stepRunId: '', createdAt: undefined, message: '', level: undefined, metadata: '' };
149
205
  }
@@ -422,6 +478,62 @@ exports.PutStreamEventResponse = {
422
478
  return message;
423
479
  },
424
480
  };
481
+ function createBaseBulkPushEventRequest() {
482
+ return { events: [] };
483
+ }
484
+ exports.BulkPushEventRequest = {
485
+ encode(message, writer = new wire_1.BinaryWriter()) {
486
+ for (const v of message.events) {
487
+ exports.PushEventRequest.encode(v, writer.uint32(10).fork()).join();
488
+ }
489
+ return writer;
490
+ },
491
+ decode(input, length) {
492
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
493
+ let end = length === undefined ? reader.len : reader.pos + length;
494
+ const message = createBaseBulkPushEventRequest();
495
+ while (reader.pos < end) {
496
+ const tag = reader.uint32();
497
+ switch (tag >>> 3) {
498
+ case 1:
499
+ if (tag !== 10) {
500
+ break;
501
+ }
502
+ message.events.push(exports.PushEventRequest.decode(reader, reader.uint32()));
503
+ continue;
504
+ }
505
+ if ((tag & 7) === 4 || tag === 0) {
506
+ break;
507
+ }
508
+ reader.skip(tag & 7);
509
+ }
510
+ return message;
511
+ },
512
+ fromJSON(object) {
513
+ return {
514
+ events: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.events)
515
+ ? object.events.map((e) => exports.PushEventRequest.fromJSON(e))
516
+ : [],
517
+ };
518
+ },
519
+ toJSON(message) {
520
+ var _a;
521
+ const obj = {};
522
+ if ((_a = message.events) === null || _a === void 0 ? void 0 : _a.length) {
523
+ obj.events = message.events.map((e) => exports.PushEventRequest.toJSON(e));
524
+ }
525
+ return obj;
526
+ },
527
+ create(base) {
528
+ return exports.BulkPushEventRequest.fromPartial(base !== null && base !== void 0 ? base : {});
529
+ },
530
+ fromPartial(object) {
531
+ var _a;
532
+ const message = createBaseBulkPushEventRequest();
533
+ message.events = ((_a = object.events) === null || _a === void 0 ? void 0 : _a.map((e) => exports.PushEventRequest.fromPartial(e))) || [];
534
+ return message;
535
+ },
536
+ };
425
537
  function createBasePushEventRequest() {
426
538
  return { key: '', payload: '', eventTimestamp: undefined, additionalMetadata: undefined };
427
539
  }
@@ -584,6 +696,14 @@ exports.EventsServiceDefinition = {
584
696
  responseStream: false,
585
697
  options: {},
586
698
  },
699
+ bulkPush: {
700
+ name: 'BulkPush',
701
+ requestType: exports.BulkPushEventRequest,
702
+ requestStream: false,
703
+ responseType: exports.Events,
704
+ responseStream: false,
705
+ options: {},
706
+ },
587
707
  replaySingleEvent: {
588
708
  name: 'ReplaySingleEvent',
589
709
  requestType: exports.ReplayEventRequest,
@@ -73,16 +73,39 @@ class WorkflowRunRef {
73
73
  return new Promise((resolve, reject) => {
74
74
  (() => __awaiter(this, void 0, void 0, function* () {
75
75
  var _a, e_1, _b, _c;
76
+ var _d, _e;
76
77
  try {
77
- for (var _d = true, _e = __asyncValues(streamable.stream()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
78
- _c = _f.value;
79
- _d = false;
78
+ for (var _f = true, _g = __asyncValues(streamable.stream()), _h; _h = yield _g.next(), _a = _h.done, !_a; _f = true) {
79
+ _c = _h.value;
80
+ _f = false;
80
81
  const event = _c;
81
82
  if (event.eventType === dispatcher_1.WorkflowRunEventType.WORKFLOW_RUN_EVENT_TYPE_FINISHED) {
82
83
  if (event.results.some((r) => !!r.error)) {
83
84
  reject(event.results);
84
85
  return;
85
86
  }
87
+ if (event.results.length === 0) {
88
+ const data = yield this.client.api.workflowRunGetShape(this.client.config.tenant_id, event.workflowRunId);
89
+ const mostRecentJobRun = (_d = data.data.jobRuns) === null || _d === void 0 ? void 0 : _d[0];
90
+ if (!mostRecentJobRun) {
91
+ reject(new Error('No job runs found'));
92
+ return;
93
+ }
94
+ const outputs = {};
95
+ (_e = mostRecentJobRun.stepRuns) === null || _e === void 0 ? void 0 : _e.forEach((stepRun) => {
96
+ var _a, _b;
97
+ const readable = (_b = (_a = mostRecentJobRun.job) === null || _a === void 0 ? void 0 : _a.steps) === null || _b === void 0 ? void 0 : _b.find((step) => step.metadata.id === stepRun.stepId);
98
+ const readableStepName = `${readable === null || readable === void 0 ? void 0 : readable.readableId}`;
99
+ try {
100
+ outputs[readableStepName] = JSON.parse(stepRun.output || '{}');
101
+ }
102
+ catch (error) {
103
+ outputs[readableStepName] = stepRun.output;
104
+ }
105
+ });
106
+ resolve(outputs);
107
+ return;
108
+ }
86
109
  const result = event.results.reduce((acc, r) => (Object.assign(Object.assign({}, acc), { [r.stepReadableId]: JSON.parse(r.output || '{}') })), {});
87
110
  resolve(result);
88
111
  return;
@@ -92,7 +115,7 @@ class WorkflowRunRef {
92
115
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
93
116
  finally {
94
117
  try {
95
- if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
118
+ if (!_f && !_a && (_b = _g.return)) yield _b.call(_g);
96
119
  }
97
120
  finally { if (e_1) throw e_1.error; }
98
121
  }