@hatchet-dev/typescript-sdk 0.13.0 → 0.14.0
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/event/event-client.d.ts +5 -0
- package/clients/event/event-client.js +31 -0
- package/clients/rest/generated/Api.d.ts +189 -19
- package/clients/rest/generated/Api.js +119 -10
- package/clients/rest/generated/data-contracts.d.ts +218 -12
- package/clients/rest/generated/data-contracts.js +39 -1
- package/clients/rest/generated/http-client.js +4 -1
- package/clients/worker/worker.js +4 -4
- package/examples/example-event.js +38 -0
- package/examples/fanout-worker.js +34 -13
- package/examples/rate-limit/worker.js +17 -2
- package/package.json +1 -1
- package/protoc/events/events.d.ts +18 -0
- package/protoc/events/events.js +121 -1
- package/protoc/workflows/workflows.d.ts +10 -2
- package/protoc/workflows/workflows.js +71 -6
- package/step.d.ts +50 -17
- package/step.js +72 -2
- package/util/workflow-run-ref.js +27 -4
- package/workflow.d.ts +114 -38
|
@@ -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
|
-
* @
|
|
110
|
-
* @minLength 36
|
|
109
|
+
* @minLength 0
|
|
111
110
|
* @maxLength 36
|
|
112
111
|
* @example "bb214807-246e-43a5-a25d-41761d1cff9e"
|
|
113
112
|
*/
|
|
@@ -315,6 +314,7 @@ export interface TenantQueueMetrics {
|
|
|
315
314
|
/** The total queue metrics. */
|
|
316
315
|
total?: QueueMetrics;
|
|
317
316
|
workflow?: Record<string, QueueMetrics>;
|
|
317
|
+
queues?: Record<string, number>;
|
|
318
318
|
}
|
|
319
319
|
export interface AcceptInviteRequest {
|
|
320
320
|
/**
|
|
@@ -383,6 +383,14 @@ export interface CreateEventRequest {
|
|
|
383
383
|
/** Additional metadata for the event. */
|
|
384
384
|
additionalMetadata?: object;
|
|
385
385
|
}
|
|
386
|
+
export interface BulkCreateEventRequest {
|
|
387
|
+
events: CreateEventRequest[];
|
|
388
|
+
}
|
|
389
|
+
export interface BulkCreateEventResponse {
|
|
390
|
+
metadata: APIResourceMeta;
|
|
391
|
+
/** The events. */
|
|
392
|
+
events: Event[];
|
|
393
|
+
}
|
|
386
394
|
export interface EventWorkflowRunSummary {
|
|
387
395
|
/**
|
|
388
396
|
* The number of pending runs.
|
|
@@ -430,22 +438,61 @@ export interface EventList {
|
|
|
430
438
|
pagination?: PaginationResponse;
|
|
431
439
|
rows?: Event[];
|
|
432
440
|
}
|
|
441
|
+
export interface RateLimit {
|
|
442
|
+
/** The key for the rate limit. */
|
|
443
|
+
key: string;
|
|
444
|
+
/** The ID of the tenant associated with this rate limit. */
|
|
445
|
+
tenantId: string;
|
|
446
|
+
/** The maximum number of requests allowed within the window. */
|
|
447
|
+
limitValue: number;
|
|
448
|
+
/** The current number of requests made within the window. */
|
|
449
|
+
value: number;
|
|
450
|
+
/** The window of time in which the limitValue is enforced. */
|
|
451
|
+
window: string;
|
|
452
|
+
/**
|
|
453
|
+
* The last time the rate limit was refilled.
|
|
454
|
+
* @format date-time
|
|
455
|
+
* @example "2022-12-13T20:06:48.888Z"
|
|
456
|
+
*/
|
|
457
|
+
lastRefill: string;
|
|
458
|
+
}
|
|
459
|
+
export interface RateLimitList {
|
|
460
|
+
pagination?: PaginationResponse;
|
|
461
|
+
rows?: RateLimit[];
|
|
462
|
+
}
|
|
463
|
+
export declare enum RateLimitOrderByField {
|
|
464
|
+
Key = "key",
|
|
465
|
+
Value = "value",
|
|
466
|
+
LimitValue = "limitValue"
|
|
467
|
+
}
|
|
468
|
+
export declare enum RateLimitOrderByDirection {
|
|
469
|
+
Asc = "asc",
|
|
470
|
+
Desc = "desc"
|
|
471
|
+
}
|
|
433
472
|
export interface ReplayEventRequest {
|
|
434
473
|
eventIds: string[];
|
|
435
474
|
}
|
|
475
|
+
export interface CancelEventRequest {
|
|
476
|
+
eventIds: string[];
|
|
477
|
+
}
|
|
436
478
|
export interface Workflow {
|
|
437
479
|
metadata: APIResourceMeta;
|
|
438
480
|
/** The name of the workflow. */
|
|
439
481
|
name: string;
|
|
440
482
|
/** The description of the workflow. */
|
|
441
483
|
description?: string;
|
|
484
|
+
/** Whether the workflow is paused. */
|
|
485
|
+
isPaused?: boolean;
|
|
442
486
|
versions?: WorkflowVersionMeta[];
|
|
443
487
|
/** The tags of the workflow. */
|
|
444
488
|
tags?: WorkflowTag[];
|
|
445
|
-
lastRun?: WorkflowRun;
|
|
446
489
|
/** The jobs of the workflow. */
|
|
447
490
|
jobs?: Job[];
|
|
448
491
|
}
|
|
492
|
+
export interface WorkflowUpdateRequest {
|
|
493
|
+
/** Whether the workflow is paused. */
|
|
494
|
+
isPaused?: boolean;
|
|
495
|
+
}
|
|
449
496
|
export interface WorkflowConcurrency {
|
|
450
497
|
/**
|
|
451
498
|
* The maximum number of concurrent workflow runs.
|
|
@@ -473,6 +520,13 @@ export interface WorkflowVersion {
|
|
|
473
520
|
/** @format int32 */
|
|
474
521
|
order: number;
|
|
475
522
|
workflowId: string;
|
|
523
|
+
/** The sticky strategy of the workflow. */
|
|
524
|
+
sticky?: string;
|
|
525
|
+
/**
|
|
526
|
+
* The default priority of the workflow.
|
|
527
|
+
* @format int32
|
|
528
|
+
*/
|
|
529
|
+
defaultPriority?: number;
|
|
476
530
|
workflow?: Workflow;
|
|
477
531
|
concurrency?: WorkflowConcurrency;
|
|
478
532
|
triggers?: WorkflowTriggers;
|
|
@@ -532,6 +586,11 @@ export interface Step {
|
|
|
532
586
|
children?: string[];
|
|
533
587
|
parents?: string[];
|
|
534
588
|
}
|
|
589
|
+
export interface WorkflowWorkersCount {
|
|
590
|
+
freeSlotCount?: number;
|
|
591
|
+
maxSlotCount?: number;
|
|
592
|
+
workflowRunId?: string;
|
|
593
|
+
}
|
|
535
594
|
export interface WorkflowRun {
|
|
536
595
|
metadata: APIResourceMeta;
|
|
537
596
|
tenantId: string;
|
|
@@ -547,6 +606,8 @@ export interface WorkflowRun {
|
|
|
547
606
|
startedAt?: string;
|
|
548
607
|
/** @format date-time */
|
|
549
608
|
finishedAt?: string;
|
|
609
|
+
/** @example 1000 */
|
|
610
|
+
duration?: number;
|
|
550
611
|
/**
|
|
551
612
|
* @format uuid
|
|
552
613
|
* @minLength 36
|
|
@@ -563,10 +624,61 @@ export interface WorkflowRun {
|
|
|
563
624
|
parentStepRunId?: string;
|
|
564
625
|
additionalMetadata?: Record<string, any>;
|
|
565
626
|
}
|
|
627
|
+
export interface WorkflowRunShape {
|
|
628
|
+
metadata: APIResourceMeta;
|
|
629
|
+
tenantId: string;
|
|
630
|
+
workflowId?: string;
|
|
631
|
+
workflowVersionId: string;
|
|
632
|
+
workflowVersion?: WorkflowVersion;
|
|
633
|
+
status: WorkflowRunStatus;
|
|
634
|
+
displayName?: string;
|
|
635
|
+
jobRuns?: JobRun[];
|
|
636
|
+
triggeredBy: WorkflowRunTriggeredBy;
|
|
637
|
+
input?: Record<string, any>;
|
|
638
|
+
error?: string;
|
|
639
|
+
/** @format date-time */
|
|
640
|
+
startedAt?: string;
|
|
641
|
+
/** @format date-time */
|
|
642
|
+
finishedAt?: string;
|
|
643
|
+
/** @example 1000 */
|
|
644
|
+
duration?: number;
|
|
645
|
+
/**
|
|
646
|
+
* @format uuid
|
|
647
|
+
* @minLength 36
|
|
648
|
+
* @maxLength 36
|
|
649
|
+
* @example "bb214807-246e-43a5-a25d-41761d1cff9e"
|
|
650
|
+
*/
|
|
651
|
+
parentId?: string;
|
|
652
|
+
/**
|
|
653
|
+
* @format uuid
|
|
654
|
+
* @minLength 36
|
|
655
|
+
* @maxLength 36
|
|
656
|
+
* @example "bb214807-246e-43a5-a25d-41761d1cff9e"
|
|
657
|
+
*/
|
|
658
|
+
parentStepRunId?: string;
|
|
659
|
+
additionalMetadata?: Record<string, any>;
|
|
660
|
+
}
|
|
661
|
+
export interface ReplayWorkflowRunsRequest {
|
|
662
|
+
/** @maxLength 500 */
|
|
663
|
+
workflowRunIds: string[];
|
|
664
|
+
}
|
|
665
|
+
export interface ReplayWorkflowRunsResponse {
|
|
666
|
+
workflowRuns: WorkflowRun[];
|
|
667
|
+
}
|
|
566
668
|
export interface WorkflowRunList {
|
|
567
669
|
rows?: WorkflowRun[];
|
|
568
670
|
pagination?: PaginationResponse;
|
|
569
671
|
}
|
|
672
|
+
export declare enum WorkflowRunOrderByField {
|
|
673
|
+
CreatedAt = "createdAt",
|
|
674
|
+
StartedAt = "startedAt",
|
|
675
|
+
FinishedAt = "finishedAt",
|
|
676
|
+
Duration = "duration"
|
|
677
|
+
}
|
|
678
|
+
export declare enum WorkflowRunOrderByDirection {
|
|
679
|
+
ASC = "ASC",
|
|
680
|
+
DESC = "DESC"
|
|
681
|
+
}
|
|
570
682
|
export interface WorkflowRunsMetrics {
|
|
571
683
|
counts?: WorkflowRunsMetricsCounts;
|
|
572
684
|
}
|
|
@@ -586,6 +698,12 @@ export declare enum WorkflowRunStatus {
|
|
|
586
698
|
QUEUED = "QUEUED"
|
|
587
699
|
}
|
|
588
700
|
export type WorkflowRunStatusList = WorkflowRunStatus[];
|
|
701
|
+
export declare enum WorkflowKind {
|
|
702
|
+
FUNCTION = "FUNCTION",
|
|
703
|
+
DURABLE = "DURABLE",
|
|
704
|
+
DAG = "DAG"
|
|
705
|
+
}
|
|
706
|
+
export type WorkflowKindList = WorkflowKind[];
|
|
589
707
|
export interface WorkflowRunsCancelRequest {
|
|
590
708
|
workflowRunIds: string[];
|
|
591
709
|
}
|
|
@@ -603,7 +721,8 @@ export declare enum StepRunStatus {
|
|
|
603
721
|
RUNNING = "RUNNING",
|
|
604
722
|
SUCCEEDED = "SUCCEEDED",
|
|
605
723
|
FAILED = "FAILED",
|
|
606
|
-
CANCELLED = "CANCELLED"
|
|
724
|
+
CANCELLED = "CANCELLED",
|
|
725
|
+
CANCELLING = "CANCELLING"
|
|
607
726
|
}
|
|
608
727
|
export interface JobRun {
|
|
609
728
|
metadata: APIResourceMeta;
|
|
@@ -629,9 +748,8 @@ export interface JobRun {
|
|
|
629
748
|
}
|
|
630
749
|
export interface WorkflowRunTriggeredBy {
|
|
631
750
|
metadata: APIResourceMeta;
|
|
632
|
-
|
|
751
|
+
parentWorkflowRunId?: string;
|
|
633
752
|
eventId?: string;
|
|
634
|
-
event?: Event;
|
|
635
753
|
cronParentId?: string;
|
|
636
754
|
cronSchedule?: string;
|
|
637
755
|
}
|
|
@@ -642,7 +760,7 @@ export interface StepRun {
|
|
|
642
760
|
jobRun?: JobRun;
|
|
643
761
|
stepId: string;
|
|
644
762
|
step?: Step;
|
|
645
|
-
|
|
763
|
+
childWorkflowsCount?: number;
|
|
646
764
|
parents?: string[];
|
|
647
765
|
childWorkflowRuns?: string[];
|
|
648
766
|
workerId?: string;
|
|
@@ -682,7 +800,9 @@ export declare enum StepRunEventReason {
|
|
|
682
800
|
REASSIGNED = "REASSIGNED",
|
|
683
801
|
TIMED_OUT = "TIMED_OUT",
|
|
684
802
|
SLOT_RELEASED = "SLOT_RELEASED",
|
|
685
|
-
RETRIED_BY_USER = "RETRIED_BY_USER"
|
|
803
|
+
RETRIED_BY_USER = "RETRIED_BY_USER",
|
|
804
|
+
WORKFLOW_RUN_GROUP_KEY_SUCCEEDED = "WORKFLOW_RUN_GROUP_KEY_SUCCEEDED",
|
|
805
|
+
WORKFLOW_RUN_GROUP_KEY_FAILED = "WORKFLOW_RUN_GROUP_KEY_FAILED"
|
|
686
806
|
}
|
|
687
807
|
export declare enum StepRunEventSeverity {
|
|
688
808
|
INFO = "INFO",
|
|
@@ -695,7 +815,8 @@ export interface StepRunEvent {
|
|
|
695
815
|
timeFirstSeen: string;
|
|
696
816
|
/** @format date-time */
|
|
697
817
|
timeLastSeen: string;
|
|
698
|
-
stepRunId
|
|
818
|
+
stepRunId?: string;
|
|
819
|
+
workflowRunId?: string;
|
|
699
820
|
reason: StepRunEventReason;
|
|
700
821
|
severity: StepRunEventSeverity;
|
|
701
822
|
message: string;
|
|
@@ -714,6 +835,7 @@ export interface StepRunArchive {
|
|
|
714
835
|
/** @format date-time */
|
|
715
836
|
startedAt?: string;
|
|
716
837
|
error?: string;
|
|
838
|
+
retryCount: number;
|
|
717
839
|
/** @format date-time */
|
|
718
840
|
createdAt: string;
|
|
719
841
|
startedAtEpoch?: number;
|
|
@@ -737,10 +859,50 @@ export interface WorkerList {
|
|
|
737
859
|
pagination?: PaginationResponse;
|
|
738
860
|
rows?: Worker[];
|
|
739
861
|
}
|
|
862
|
+
export interface SemaphoreSlots {
|
|
863
|
+
/**
|
|
864
|
+
* The step run id.
|
|
865
|
+
* @format uuid
|
|
866
|
+
*/
|
|
867
|
+
stepRunId: string;
|
|
868
|
+
/** The action id. */
|
|
869
|
+
actionId: string;
|
|
870
|
+
/**
|
|
871
|
+
* The time this slot was started.
|
|
872
|
+
* @format date-time
|
|
873
|
+
*/
|
|
874
|
+
startedAt?: string;
|
|
875
|
+
/**
|
|
876
|
+
* The time this slot will timeout.
|
|
877
|
+
* @format date-time
|
|
878
|
+
*/
|
|
879
|
+
timeoutAt?: string;
|
|
880
|
+
/**
|
|
881
|
+
* The workflow run id.
|
|
882
|
+
* @format uuid
|
|
883
|
+
*/
|
|
884
|
+
workflowRunId: string;
|
|
885
|
+
status: StepRunStatus;
|
|
886
|
+
}
|
|
887
|
+
export interface RecentStepRuns {
|
|
888
|
+
metadata: APIResourceMeta;
|
|
889
|
+
/** The action id. */
|
|
890
|
+
actionId: string;
|
|
891
|
+
status: StepRunStatus;
|
|
892
|
+
/** @format date-time */
|
|
893
|
+
startedAt?: string;
|
|
894
|
+
/** @format date-time */
|
|
895
|
+
finishedAt?: string;
|
|
896
|
+
/** @format date-time */
|
|
897
|
+
cancelledAt?: string;
|
|
898
|
+
/** @format uuid */
|
|
899
|
+
workflowRunId: string;
|
|
900
|
+
}
|
|
740
901
|
export interface Worker {
|
|
741
902
|
metadata: APIResourceMeta;
|
|
742
903
|
/** The name of the worker. */
|
|
743
904
|
name: string;
|
|
905
|
+
type: 'SELFHOSTED' | 'MANAGED' | 'WEBHOOK';
|
|
744
906
|
/**
|
|
745
907
|
* The time this worker last sent a heartbeat.
|
|
746
908
|
* @format date-time
|
|
@@ -755,10 +917,12 @@ export interface Worker {
|
|
|
755
917
|
lastListenerEstablished?: string;
|
|
756
918
|
/** The actions this worker can perform. */
|
|
757
919
|
actions?: string[];
|
|
758
|
-
/** The
|
|
759
|
-
|
|
920
|
+
/** The semaphore slot state for the worker. */
|
|
921
|
+
slots?: SemaphoreSlots[];
|
|
922
|
+
/** The recent step runs for the worker. */
|
|
923
|
+
recentStepRuns?: RecentStepRuns[];
|
|
760
924
|
/** The status of the worker. */
|
|
761
|
-
status?: 'ACTIVE' | 'INACTIVE';
|
|
925
|
+
status?: 'ACTIVE' | 'INACTIVE' | 'PAUSED';
|
|
762
926
|
/** The maximum number of runs this worker can execute concurrently. */
|
|
763
927
|
maxRuns?: number;
|
|
764
928
|
/** The number of runs this worker can execute concurrently. */
|
|
@@ -771,6 +935,26 @@ export interface Worker {
|
|
|
771
935
|
* @example "bb214807-246e-43a5-a25d-41761d1cff9e"
|
|
772
936
|
*/
|
|
773
937
|
dispatcherId?: string;
|
|
938
|
+
/** The current label state of the worker. */
|
|
939
|
+
labels?: WorkerLabel[];
|
|
940
|
+
/** The webhook URL for the worker. */
|
|
941
|
+
webhookUrl?: string;
|
|
942
|
+
/**
|
|
943
|
+
* The webhook ID for the worker.
|
|
944
|
+
* @format uuid
|
|
945
|
+
*/
|
|
946
|
+
webhookId?: string;
|
|
947
|
+
}
|
|
948
|
+
export interface WorkerLabel {
|
|
949
|
+
metadata: APIResourceMeta;
|
|
950
|
+
/** The key of the label. */
|
|
951
|
+
key: string;
|
|
952
|
+
/** The value of the label. */
|
|
953
|
+
value?: string;
|
|
954
|
+
}
|
|
955
|
+
export interface UpdateWorkerRequest {
|
|
956
|
+
/** Whether the worker is paused and cannot accept new runs. */
|
|
957
|
+
isPaused?: boolean;
|
|
774
958
|
}
|
|
775
959
|
export interface APIToken {
|
|
776
960
|
metadata: APIResourceMeta;
|
|
@@ -791,6 +975,8 @@ export interface CreateAPITokenRequest {
|
|
|
791
975
|
* @maxLength 255
|
|
792
976
|
*/
|
|
793
977
|
name: string;
|
|
978
|
+
/** The duration for which the token is valid. */
|
|
979
|
+
expiresIn?: string;
|
|
794
980
|
}
|
|
795
981
|
export interface CreateAPITokenResponse {
|
|
796
982
|
/** The API token. */
|
|
@@ -918,6 +1104,26 @@ export interface WebhookWorker {
|
|
|
918
1104
|
/** The webhook url. */
|
|
919
1105
|
url: string;
|
|
920
1106
|
}
|
|
1107
|
+
export declare enum WebhookWorkerRequestMethod {
|
|
1108
|
+
GET = "GET",
|
|
1109
|
+
POST = "POST",
|
|
1110
|
+
PUT = "PUT"
|
|
1111
|
+
}
|
|
1112
|
+
export interface WebhookWorkerRequest {
|
|
1113
|
+
/**
|
|
1114
|
+
* The date and time the request was created.
|
|
1115
|
+
* @format date-time
|
|
1116
|
+
*/
|
|
1117
|
+
created_at: string;
|
|
1118
|
+
/** The HTTP method used for the request. */
|
|
1119
|
+
method: WebhookWorkerRequestMethod;
|
|
1120
|
+
/** The HTTP status code of the response. */
|
|
1121
|
+
statusCode: number;
|
|
1122
|
+
}
|
|
1123
|
+
export interface WebhookWorkerRequestListResponse {
|
|
1124
|
+
/** The list of webhook requests. */
|
|
1125
|
+
requests?: WebhookWorkerRequest[];
|
|
1126
|
+
}
|
|
921
1127
|
export interface WebhookWorkerCreated {
|
|
922
1128
|
metadata: APIResourceMeta;
|
|
923
1129
|
/** 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.RateLimitOrderByDirection = exports.RateLimitOrderByField = 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,29 @@ var EventOrderByDirection;
|
|
|
34
34
|
EventOrderByDirection["Asc"] = "asc";
|
|
35
35
|
EventOrderByDirection["Desc"] = "desc";
|
|
36
36
|
})(EventOrderByDirection || (exports.EventOrderByDirection = EventOrderByDirection = {}));
|
|
37
|
+
var RateLimitOrderByField;
|
|
38
|
+
(function (RateLimitOrderByField) {
|
|
39
|
+
RateLimitOrderByField["Key"] = "key";
|
|
40
|
+
RateLimitOrderByField["Value"] = "value";
|
|
41
|
+
RateLimitOrderByField["LimitValue"] = "limitValue";
|
|
42
|
+
})(RateLimitOrderByField || (exports.RateLimitOrderByField = RateLimitOrderByField = {}));
|
|
43
|
+
var RateLimitOrderByDirection;
|
|
44
|
+
(function (RateLimitOrderByDirection) {
|
|
45
|
+
RateLimitOrderByDirection["Asc"] = "asc";
|
|
46
|
+
RateLimitOrderByDirection["Desc"] = "desc";
|
|
47
|
+
})(RateLimitOrderByDirection || (exports.RateLimitOrderByDirection = RateLimitOrderByDirection = {}));
|
|
48
|
+
var WorkflowRunOrderByField;
|
|
49
|
+
(function (WorkflowRunOrderByField) {
|
|
50
|
+
WorkflowRunOrderByField["CreatedAt"] = "createdAt";
|
|
51
|
+
WorkflowRunOrderByField["StartedAt"] = "startedAt";
|
|
52
|
+
WorkflowRunOrderByField["FinishedAt"] = "finishedAt";
|
|
53
|
+
WorkflowRunOrderByField["Duration"] = "duration";
|
|
54
|
+
})(WorkflowRunOrderByField || (exports.WorkflowRunOrderByField = WorkflowRunOrderByField = {}));
|
|
55
|
+
var WorkflowRunOrderByDirection;
|
|
56
|
+
(function (WorkflowRunOrderByDirection) {
|
|
57
|
+
WorkflowRunOrderByDirection["ASC"] = "ASC";
|
|
58
|
+
WorkflowRunOrderByDirection["DESC"] = "DESC";
|
|
59
|
+
})(WorkflowRunOrderByDirection || (exports.WorkflowRunOrderByDirection = WorkflowRunOrderByDirection = {}));
|
|
37
60
|
var WorkflowRunStatus;
|
|
38
61
|
(function (WorkflowRunStatus) {
|
|
39
62
|
WorkflowRunStatus["PENDING"] = "PENDING";
|
|
@@ -43,6 +66,12 @@ var WorkflowRunStatus;
|
|
|
43
66
|
WorkflowRunStatus["CANCELLED"] = "CANCELLED";
|
|
44
67
|
WorkflowRunStatus["QUEUED"] = "QUEUED";
|
|
45
68
|
})(WorkflowRunStatus || (exports.WorkflowRunStatus = WorkflowRunStatus = {}));
|
|
69
|
+
var WorkflowKind;
|
|
70
|
+
(function (WorkflowKind) {
|
|
71
|
+
WorkflowKind["FUNCTION"] = "FUNCTION";
|
|
72
|
+
WorkflowKind["DURABLE"] = "DURABLE";
|
|
73
|
+
WorkflowKind["DAG"] = "DAG";
|
|
74
|
+
})(WorkflowKind || (exports.WorkflowKind = WorkflowKind = {}));
|
|
46
75
|
var JobRunStatus;
|
|
47
76
|
(function (JobRunStatus) {
|
|
48
77
|
JobRunStatus["PENDING"] = "PENDING";
|
|
@@ -60,6 +89,7 @@ var StepRunStatus;
|
|
|
60
89
|
StepRunStatus["SUCCEEDED"] = "SUCCEEDED";
|
|
61
90
|
StepRunStatus["FAILED"] = "FAILED";
|
|
62
91
|
StepRunStatus["CANCELLED"] = "CANCELLED";
|
|
92
|
+
StepRunStatus["CANCELLING"] = "CANCELLING";
|
|
63
93
|
})(StepRunStatus || (exports.StepRunStatus = StepRunStatus = {}));
|
|
64
94
|
var StepRunEventReason;
|
|
65
95
|
(function (StepRunEventReason) {
|
|
@@ -77,6 +107,8 @@ var StepRunEventReason;
|
|
|
77
107
|
StepRunEventReason["TIMED_OUT"] = "TIMED_OUT";
|
|
78
108
|
StepRunEventReason["SLOT_RELEASED"] = "SLOT_RELEASED";
|
|
79
109
|
StepRunEventReason["RETRIED_BY_USER"] = "RETRIED_BY_USER";
|
|
110
|
+
StepRunEventReason["WORKFLOW_RUN_GROUP_KEY_SUCCEEDED"] = "WORKFLOW_RUN_GROUP_KEY_SUCCEEDED";
|
|
111
|
+
StepRunEventReason["WORKFLOW_RUN_GROUP_KEY_FAILED"] = "WORKFLOW_RUN_GROUP_KEY_FAILED";
|
|
80
112
|
})(StepRunEventReason || (exports.StepRunEventReason = StepRunEventReason = {}));
|
|
81
113
|
var StepRunEventSeverity;
|
|
82
114
|
(function (StepRunEventSeverity) {
|
|
@@ -105,3 +137,9 @@ var LogLineOrderByDirection;
|
|
|
105
137
|
LogLineOrderByDirection["Asc"] = "asc";
|
|
106
138
|
LogLineOrderByDirection["Desc"] = "desc";
|
|
107
139
|
})(LogLineOrderByDirection || (exports.LogLineOrderByDirection = LogLineOrderByDirection = {}));
|
|
140
|
+
var WebhookWorkerRequestMethod;
|
|
141
|
+
(function (WebhookWorkerRequestMethod) {
|
|
142
|
+
WebhookWorkerRequestMethod["GET"] = "GET";
|
|
143
|
+
WebhookWorkerRequestMethod["POST"] = "POST";
|
|
144
|
+
WebhookWorkerRequestMethod["PUT"] = "PUT";
|
|
145
|
+
})(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
|
|
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];
|
package/clients/worker/worker.js
CHANGED
|
@@ -83,7 +83,7 @@ class Worker {
|
|
|
83
83
|
}
|
|
84
84
|
registerWorkflow(initWorkflow) {
|
|
85
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
var _a, _b, _c
|
|
86
|
+
var _a, _b, _c;
|
|
87
87
|
const workflow = Object.assign(Object.assign({}, initWorkflow), { id: this.client.config.namespace + initWorkflow.id });
|
|
88
88
|
try {
|
|
89
89
|
if (((_a = workflow.concurrency) === null || _a === void 0 ? void 0 : _a.key) && workflow.concurrency.expression) {
|
|
@@ -112,7 +112,7 @@ class Worker {
|
|
|
112
112
|
parents: [],
|
|
113
113
|
userData: '{}',
|
|
114
114
|
retries: workflow.onFailure.retries || 0,
|
|
115
|
-
rateLimits: (
|
|
115
|
+
rateLimits: (0, step_1.mapRateLimit)(workflow.onFailure.rate_limits),
|
|
116
116
|
workerLabels: {}, // no worker labels for on failure steps
|
|
117
117
|
},
|
|
118
118
|
],
|
|
@@ -136,7 +136,7 @@ class Worker {
|
|
|
136
136
|
name: workflow.id,
|
|
137
137
|
description: workflow.description,
|
|
138
138
|
steps: workflow.steps.map((step) => {
|
|
139
|
-
var _a
|
|
139
|
+
var _a;
|
|
140
140
|
return ({
|
|
141
141
|
readableId: step.name,
|
|
142
142
|
action: `${workflow.id}:${step.name}`,
|
|
@@ -145,7 +145,7 @@ class Worker {
|
|
|
145
145
|
parents: (_a = step.parents) !== null && _a !== void 0 ? _a : [],
|
|
146
146
|
userData: '{}',
|
|
147
147
|
retries: step.retries || 0,
|
|
148
|
-
rateLimits: (
|
|
148
|
+
rateLimits: (0, step_1.mapRateLimit)(step.rate_limits),
|
|
149
149
|
workerLabels: toPbWorkerLabel(step.worker_labels),
|
|
150
150
|
});
|
|
151
151
|
}),
|
|
@@ -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: '
|
|
26
|
+
timeout: '70s',
|
|
30
27
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
|
|
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:
|
|
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: '
|
|
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
|
-
|
|
55
|
-
|
|
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
|
-
|
|
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();
|
|
@@ -23,10 +23,25 @@ const workflow = {
|
|
|
23
23
|
},
|
|
24
24
|
steps: [
|
|
25
25
|
{
|
|
26
|
-
name: '
|
|
26
|
+
name: 'dynamic',
|
|
27
|
+
rate_limits: [
|
|
28
|
+
{
|
|
29
|
+
dynamicKey: 'input.group',
|
|
30
|
+
units: 1,
|
|
31
|
+
limit: 10,
|
|
32
|
+
duration: workflows_1.RateLimitDuration.DAY,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
console.log('starting step1 with the following input and a dynamic rate limit', ctx.workflowInput());
|
|
37
|
+
return { step1: 'step1 results!' };
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'static',
|
|
27
42
|
rate_limits: [{ key: 'test-limit', units: 1 }],
|
|
28
43
|
run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
-
console.log('starting step1 with the following input', ctx.workflowInput());
|
|
44
|
+
console.log('starting step1 with the following input and a static rate limit', ctx.workflowInput());
|
|
30
45
|
return { step1: 'step1 results!' };
|
|
31
46
|
}),
|
|
32
47
|
},
|