@hatchet-dev/typescript-sdk 1.33.2 → 1.34.0-alpha.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/admin/admin-client.d.ts +6 -1
- package/clients/admin/admin-client.js +9 -4
- package/clients/admin/rpc.d.ts +13 -0
- package/clients/admin/rpc.js +23 -0
- package/clients/event/event-client.d.ts +2 -1
- package/clients/event/event-client.js +6 -3
- package/clients/event/rpc.d.ts +7 -0
- package/clients/event/rpc.js +13 -0
- package/clients/rest/generated/data-contracts.d.ts +2 -0
- package/clients/transport/grpc-target.d.ts +19 -0
- package/clients/transport/grpc-target.js +85 -0
- package/clients/transport/index.d.ts +4 -0
- package/clients/transport/index.js +15 -0
- package/clients/transport/message-bridge.d.ts +32 -0
- package/clients/transport/message-bridge.js +20 -0
- package/clients/transport/node-transport.d.ts +50 -0
- package/clients/transport/node-transport.js +123 -0
- package/clients/transport/transport.d.ts +14 -0
- package/clients/transport/transport.js +24 -0
- package/clients/transport/ts-proto-client.d.ts +41 -0
- package/clients/transport/ts-proto-client.js +143 -0
- package/core/index.d.ts +9 -0
- package/core/index.js +12 -0
- package/dist/check-exports.mjs +171 -0
- package/legacy/legacy-client.d.ts +4 -0
- package/legacy/legacy-client.js +5 -3
- package/package.json +95 -2
- package/protoc-es/dispatcher/dispatcher_pb.d.ts +1357 -0
- package/protoc-es/dispatcher/dispatcher_pb.js +371 -0
- package/protoc-es/events/events_pb.d.ts +294 -0
- package/protoc-es/events/events_pb.js +61 -0
- package/protoc-es/google/rpc/status_pb.d.ts +48 -0
- package/protoc-es/google/rpc/status_pb.js +27 -0
- package/protoc-es/v1/dispatcher_pb.d.ts +676 -0
- package/protoc-es/v1/dispatcher_pb.js +155 -0
- package/protoc-es/v1/shared/condition_pb.d.ts +166 -0
- package/protoc-es/v1/shared/condition_pb.js +68 -0
- package/protoc-es/v1/shared/trigger_pb.d.ts +160 -0
- package/protoc-es/v1/shared/trigger_pb.js +55 -0
- package/protoc-es/v1/workflows_pb.d.ts +995 -0
- package/protoc-es/v1/workflows_pb.js +280 -0
- package/protoc-es/workflows/workflows_pb.d.ts +715 -0
- package/protoc-es/workflows/workflows_pb.js +216 -0
- package/scripts/check-exports.mjs +171 -0
- package/util/grpc-error.d.ts +3 -1
- package/util/grpc-error.js +13 -4
- package/v1/client/admin.d.ts +2 -1
- package/v1/client/admin.js +34 -114
- package/v1/client/client.d.ts +1 -0
- package/v1/client/client.js +8 -5
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @generated by protoc-gen-es v2.15.0 with parameter "target=ts"
|
|
3
|
+
// @generated from file workflows/workflows.proto (syntax proto3)
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WorkflowService = exports.RateLimitDurationSchema = exports.RateLimitDuration = exports.ConcurrencyLimitStrategySchema = exports.ConcurrencyLimitStrategy = exports.WorkflowKindSchema = exports.WorkflowKind = exports.StickyStrategySchema = exports.StickyStrategy = exports.PutRateLimitResponseSchema = exports.PutRateLimitRequestSchema = exports.TriggerWorkflowResponseSchema = exports.BulkTriggerWorkflowResponseSchema = exports.BulkTriggerWorkflowRequestSchema = exports.WorkflowTriggerCronRefSchema = exports.WorkflowTriggerEventRefSchema = exports.WorkflowVersionSchema = exports.ScheduledWorkflowSchema = exports.ScheduleWorkflowRequestSchema = exports.ListWorkflowsRequestSchema = exports.CreateStepRateLimitSchema = exports.CreateWorkflowStepOptsSchema = exports.CreateWorkflowJobOptsSchema = exports.WorkflowConcurrencyOptsSchema = exports.CreateWorkflowVersionOptsSchema = exports.PutWorkflowRequestSchema = exports.file_workflows_workflows = void 0;
|
|
7
|
+
const codegenv2_1 = require("@bufbuild/protobuf/codegenv2");
|
|
8
|
+
const wkt_1 = require("@bufbuild/protobuf/wkt");
|
|
9
|
+
const trigger_pb_1 = require("../v1/shared/trigger_pb");
|
|
10
|
+
/**
|
|
11
|
+
* Describes the file workflows/workflows.proto.
|
|
12
|
+
*/
|
|
13
|
+
exports.file_workflows_workflows = (0, codegenv2_1.fileDesc)("Chl3b3JrZmxvd3Mvd29ya2Zsb3dzLnByb3RvIj4KElB1dFdvcmtmbG93UmVxdWVzdBIoCgRvcHRzGAEgASgLMhouQ3JlYXRlV29ya2Zsb3dWZXJzaW9uT3B0cyK/BAoZQ3JlYXRlV29ya2Zsb3dWZXJzaW9uT3B0cxIMCgRuYW1lGAEgASgJEhMKC2Rlc2NyaXB0aW9uGAIgASgJEg8KB3ZlcnNpb24YAyABKAkSFgoOZXZlbnRfdHJpZ2dlcnMYBCADKAkSFQoNY3Jvbl90cmlnZ2VycxgFIAMoCRI2ChJzY2hlZHVsZWRfdHJpZ2dlcnMYBiADKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wEiQKBGpvYnMYByADKAsyFi5DcmVhdGVXb3JrZmxvd0pvYk9wdHMSLQoLY29uY3VycmVuY3kYCCABKAsyGC5Xb3JrZmxvd0NvbmN1cnJlbmN5T3B0cxIdChBzY2hlZHVsZV90aW1lb3V0GAkgASgJSACIAQESFwoKY3Jvbl9pbnB1dBgKIAEoCUgBiAEBEjMKDm9uX2ZhaWx1cmVfam9iGAsgASgLMhYuQ3JlYXRlV29ya2Zsb3dKb2JPcHRzSAKIAQESJAoGc3RpY2t5GAwgASgOMg8uU3RpY2t5U3RyYXRlZ3lIA4gBARIgCgRraW5kGA0gASgOMg0uV29ya2Zsb3dLaW5kSASIAQESHQoQZGVmYXVsdF9wcmlvcml0eRgOIAEoBUgFiAEBQhMKEV9zY2hlZHVsZV90aW1lb3V0Qg0KC19jcm9uX2lucHV0QhEKD19vbl9mYWlsdXJlX2pvYkIJCgdfc3RpY2t5QgcKBV9raW5kQhMKEV9kZWZhdWx0X3ByaW9yaXR5ItABChdXb3JrZmxvd0NvbmN1cnJlbmN5T3B0cxITCgZhY3Rpb24Y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WUVBUhAGMt8CCg9Xb3JrZmxvd1NlcnZpY2USNAoLUHV0V29ya2Zsb3cSEy5QdXRXb3JrZmxvd1JlcXVlc3QaEC5Xb3JrZmxvd1ZlcnNpb24SPgoQU2NoZWR1bGVXb3JrZmxvdxIYLlNjaGVkdWxlV29ya2Zsb3dSZXF1ZXN0GhAuV29ya2Zsb3dWZXJzaW9uEkcKD1RyaWdnZXJXb3JrZmxvdxIaLnYxLlRyaWdnZXJXb3JrZmxvd1JlcXVlc3QaGC5UcmlnZ2VyV29ya2Zsb3dSZXNwb25zZRJQChNCdWxrVHJpZ2dlcldvcmtmbG93EhsuQnVsa1RyaWdnZXJXb3JrZmxvd1JlcXVlc3QaHC5CdWxrVHJpZ2dlcldvcmtmbG93UmVzcG9uc2USOwoMUHV0UmF0ZUxpbWl0EhQuUHV0UmF0ZUxpbWl0UmVxdWVzdBoVLlB1dFJhdGVMaW1pdFJlc3BvbnNlQkJaQGdpdGh1Yi5jb20vaGF0Y2hldC1kZXYvaGF0Y2hldC9pbnRlcm5hbC9zZXJ2aWNlcy9hZG1pbi9jb250cmFjdHNiBnByb3RvMw", [wkt_1.file_google_protobuf_timestamp, trigger_pb_1.file_v1_shared_trigger]);
|
|
14
|
+
/**
|
|
15
|
+
* Describes the message PutWorkflowRequest.
|
|
16
|
+
* Use `create(PutWorkflowRequestSchema)` to create a new message.
|
|
17
|
+
*/
|
|
18
|
+
exports.PutWorkflowRequestSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 0);
|
|
19
|
+
/**
|
|
20
|
+
* Describes the message CreateWorkflowVersionOpts.
|
|
21
|
+
* Use `create(CreateWorkflowVersionOptsSchema)` to create a new message.
|
|
22
|
+
*/
|
|
23
|
+
exports.CreateWorkflowVersionOptsSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 1);
|
|
24
|
+
/**
|
|
25
|
+
* Describes the message WorkflowConcurrencyOpts.
|
|
26
|
+
* Use `create(WorkflowConcurrencyOptsSchema)` to create a new message.
|
|
27
|
+
*/
|
|
28
|
+
exports.WorkflowConcurrencyOptsSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 2);
|
|
29
|
+
/**
|
|
30
|
+
* Describes the message CreateWorkflowJobOpts.
|
|
31
|
+
* Use `create(CreateWorkflowJobOptsSchema)` to create a new message.
|
|
32
|
+
*/
|
|
33
|
+
exports.CreateWorkflowJobOptsSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 3);
|
|
34
|
+
/**
|
|
35
|
+
* Describes the message CreateWorkflowStepOpts.
|
|
36
|
+
* Use `create(CreateWorkflowStepOptsSchema)` to create a new message.
|
|
37
|
+
*/
|
|
38
|
+
exports.CreateWorkflowStepOptsSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 4);
|
|
39
|
+
/**
|
|
40
|
+
* Describes the message CreateStepRateLimit.
|
|
41
|
+
* Use `create(CreateStepRateLimitSchema)` to create a new message.
|
|
42
|
+
*/
|
|
43
|
+
exports.CreateStepRateLimitSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 5);
|
|
44
|
+
/**
|
|
45
|
+
* Describes the message ListWorkflowsRequest.
|
|
46
|
+
* Use `create(ListWorkflowsRequestSchema)` to create a new message.
|
|
47
|
+
*/
|
|
48
|
+
exports.ListWorkflowsRequestSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 6);
|
|
49
|
+
/**
|
|
50
|
+
* Describes the message ScheduleWorkflowRequest.
|
|
51
|
+
* Use `create(ScheduleWorkflowRequestSchema)` to create a new message.
|
|
52
|
+
*/
|
|
53
|
+
exports.ScheduleWorkflowRequestSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 7);
|
|
54
|
+
/**
|
|
55
|
+
* Describes the message ScheduledWorkflow.
|
|
56
|
+
* Use `create(ScheduledWorkflowSchema)` to create a new message.
|
|
57
|
+
*/
|
|
58
|
+
exports.ScheduledWorkflowSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 8);
|
|
59
|
+
/**
|
|
60
|
+
* Describes the message WorkflowVersion.
|
|
61
|
+
* Use `create(WorkflowVersionSchema)` to create a new message.
|
|
62
|
+
*/
|
|
63
|
+
exports.WorkflowVersionSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 9);
|
|
64
|
+
/**
|
|
65
|
+
* Describes the message WorkflowTriggerEventRef.
|
|
66
|
+
* Use `create(WorkflowTriggerEventRefSchema)` to create a new message.
|
|
67
|
+
*/
|
|
68
|
+
exports.WorkflowTriggerEventRefSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 10);
|
|
69
|
+
/**
|
|
70
|
+
* Describes the message WorkflowTriggerCronRef.
|
|
71
|
+
* Use `create(WorkflowTriggerCronRefSchema)` to create a new message.
|
|
72
|
+
*/
|
|
73
|
+
exports.WorkflowTriggerCronRefSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 11);
|
|
74
|
+
/**
|
|
75
|
+
* Describes the message BulkTriggerWorkflowRequest.
|
|
76
|
+
* Use `create(BulkTriggerWorkflowRequestSchema)` to create a new message.
|
|
77
|
+
*/
|
|
78
|
+
exports.BulkTriggerWorkflowRequestSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 12);
|
|
79
|
+
/**
|
|
80
|
+
* Describes the message BulkTriggerWorkflowResponse.
|
|
81
|
+
* Use `create(BulkTriggerWorkflowResponseSchema)` to create a new message.
|
|
82
|
+
*/
|
|
83
|
+
exports.BulkTriggerWorkflowResponseSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 13);
|
|
84
|
+
/**
|
|
85
|
+
* Describes the message TriggerWorkflowResponse.
|
|
86
|
+
* Use `create(TriggerWorkflowResponseSchema)` to create a new message.
|
|
87
|
+
*/
|
|
88
|
+
exports.TriggerWorkflowResponseSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 14);
|
|
89
|
+
/**
|
|
90
|
+
* Describes the message PutRateLimitRequest.
|
|
91
|
+
* Use `create(PutRateLimitRequestSchema)` to create a new message.
|
|
92
|
+
*/
|
|
93
|
+
exports.PutRateLimitRequestSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 15);
|
|
94
|
+
/**
|
|
95
|
+
* Describes the message PutRateLimitResponse.
|
|
96
|
+
* Use `create(PutRateLimitResponseSchema)` to create a new message.
|
|
97
|
+
*/
|
|
98
|
+
exports.PutRateLimitResponseSchema = (0, codegenv2_1.messageDesc)(exports.file_workflows_workflows, 16);
|
|
99
|
+
/**
|
|
100
|
+
* @generated from enum StickyStrategy
|
|
101
|
+
*/
|
|
102
|
+
var StickyStrategy;
|
|
103
|
+
(function (StickyStrategy) {
|
|
104
|
+
/**
|
|
105
|
+
* @generated from enum value: SOFT = 0;
|
|
106
|
+
*/
|
|
107
|
+
StickyStrategy[StickyStrategy["SOFT"] = 0] = "SOFT";
|
|
108
|
+
/**
|
|
109
|
+
* @generated from enum value: HARD = 1;
|
|
110
|
+
*/
|
|
111
|
+
StickyStrategy[StickyStrategy["HARD"] = 1] = "HARD";
|
|
112
|
+
})(StickyStrategy || (exports.StickyStrategy = StickyStrategy = {}));
|
|
113
|
+
/**
|
|
114
|
+
* Describes the enum StickyStrategy.
|
|
115
|
+
*/
|
|
116
|
+
exports.StickyStrategySchema = (0, codegenv2_1.enumDesc)(exports.file_workflows_workflows, 0);
|
|
117
|
+
/**
|
|
118
|
+
* @generated from enum WorkflowKind
|
|
119
|
+
*/
|
|
120
|
+
var WorkflowKind;
|
|
121
|
+
(function (WorkflowKind) {
|
|
122
|
+
/**
|
|
123
|
+
* @generated from enum value: FUNCTION = 0;
|
|
124
|
+
*/
|
|
125
|
+
WorkflowKind[WorkflowKind["FUNCTION"] = 0] = "FUNCTION";
|
|
126
|
+
/**
|
|
127
|
+
* @generated from enum value: DURABLE = 1;
|
|
128
|
+
*/
|
|
129
|
+
WorkflowKind[WorkflowKind["DURABLE"] = 1] = "DURABLE";
|
|
130
|
+
/**
|
|
131
|
+
* @generated from enum value: DAG = 2;
|
|
132
|
+
*/
|
|
133
|
+
WorkflowKind[WorkflowKind["DAG"] = 2] = "DAG";
|
|
134
|
+
})(WorkflowKind || (exports.WorkflowKind = WorkflowKind = {}));
|
|
135
|
+
/**
|
|
136
|
+
* Describes the enum WorkflowKind.
|
|
137
|
+
*/
|
|
138
|
+
exports.WorkflowKindSchema = (0, codegenv2_1.enumDesc)(exports.file_workflows_workflows, 1);
|
|
139
|
+
/**
|
|
140
|
+
* @generated from enum ConcurrencyLimitStrategy
|
|
141
|
+
*/
|
|
142
|
+
var ConcurrencyLimitStrategy;
|
|
143
|
+
(function (ConcurrencyLimitStrategy) {
|
|
144
|
+
/**
|
|
145
|
+
* @generated from enum value: CANCEL_IN_PROGRESS = 0;
|
|
146
|
+
*/
|
|
147
|
+
ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["CANCEL_IN_PROGRESS"] = 0] = "CANCEL_IN_PROGRESS";
|
|
148
|
+
/**
|
|
149
|
+
* deprecated
|
|
150
|
+
*
|
|
151
|
+
* @generated from enum value: DROP_NEWEST = 1;
|
|
152
|
+
*/
|
|
153
|
+
ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["DROP_NEWEST"] = 1] = "DROP_NEWEST";
|
|
154
|
+
/**
|
|
155
|
+
* deprecated
|
|
156
|
+
*
|
|
157
|
+
* @generated from enum value: QUEUE_NEWEST = 2;
|
|
158
|
+
*/
|
|
159
|
+
ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["QUEUE_NEWEST"] = 2] = "QUEUE_NEWEST";
|
|
160
|
+
/**
|
|
161
|
+
* @generated from enum value: GROUP_ROUND_ROBIN = 3;
|
|
162
|
+
*/
|
|
163
|
+
ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["GROUP_ROUND_ROBIN"] = 3] = "GROUP_ROUND_ROBIN";
|
|
164
|
+
/**
|
|
165
|
+
* @generated from enum value: CANCEL_NEWEST = 4;
|
|
166
|
+
*/
|
|
167
|
+
ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["CANCEL_NEWEST"] = 4] = "CANCEL_NEWEST";
|
|
168
|
+
})(ConcurrencyLimitStrategy || (exports.ConcurrencyLimitStrategy = ConcurrencyLimitStrategy = {}));
|
|
169
|
+
/**
|
|
170
|
+
* Describes the enum ConcurrencyLimitStrategy.
|
|
171
|
+
*/
|
|
172
|
+
exports.ConcurrencyLimitStrategySchema = (0, codegenv2_1.enumDesc)(exports.file_workflows_workflows, 2);
|
|
173
|
+
/**
|
|
174
|
+
* @generated from enum RateLimitDuration
|
|
175
|
+
*/
|
|
176
|
+
var RateLimitDuration;
|
|
177
|
+
(function (RateLimitDuration) {
|
|
178
|
+
/**
|
|
179
|
+
* @generated from enum value: SECOND = 0;
|
|
180
|
+
*/
|
|
181
|
+
RateLimitDuration[RateLimitDuration["SECOND"] = 0] = "SECOND";
|
|
182
|
+
/**
|
|
183
|
+
* @generated from enum value: MINUTE = 1;
|
|
184
|
+
*/
|
|
185
|
+
RateLimitDuration[RateLimitDuration["MINUTE"] = 1] = "MINUTE";
|
|
186
|
+
/**
|
|
187
|
+
* @generated from enum value: HOUR = 2;
|
|
188
|
+
*/
|
|
189
|
+
RateLimitDuration[RateLimitDuration["HOUR"] = 2] = "HOUR";
|
|
190
|
+
/**
|
|
191
|
+
* @generated from enum value: DAY = 3;
|
|
192
|
+
*/
|
|
193
|
+
RateLimitDuration[RateLimitDuration["DAY"] = 3] = "DAY";
|
|
194
|
+
/**
|
|
195
|
+
* @generated from enum value: WEEK = 4;
|
|
196
|
+
*/
|
|
197
|
+
RateLimitDuration[RateLimitDuration["WEEK"] = 4] = "WEEK";
|
|
198
|
+
/**
|
|
199
|
+
* @generated from enum value: MONTH = 5;
|
|
200
|
+
*/
|
|
201
|
+
RateLimitDuration[RateLimitDuration["MONTH"] = 5] = "MONTH";
|
|
202
|
+
/**
|
|
203
|
+
* @generated from enum value: YEAR = 6;
|
|
204
|
+
*/
|
|
205
|
+
RateLimitDuration[RateLimitDuration["YEAR"] = 6] = "YEAR";
|
|
206
|
+
})(RateLimitDuration || (exports.RateLimitDuration = RateLimitDuration = {}));
|
|
207
|
+
/**
|
|
208
|
+
* Describes the enum RateLimitDuration.
|
|
209
|
+
*/
|
|
210
|
+
exports.RateLimitDurationSchema = (0, codegenv2_1.enumDesc)(exports.file_workflows_workflows, 3);
|
|
211
|
+
/**
|
|
212
|
+
* WorkflowService represents a set of RPCs for managing workflows.
|
|
213
|
+
*
|
|
214
|
+
* @generated from service WorkflowService
|
|
215
|
+
*/
|
|
216
|
+
exports.WorkflowService = (0, codegenv2_1.serviceDesc)(exports.file_workflows_workflows, 0);
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
// Verifies the package's `exports` map against the built `dist/`: every documented import
|
|
4
|
+
// path resolves from both a native ESM module and a CommonJS module, every directory that
|
|
5
|
+
// ships an `index.js` has an explicit entry (a wildcard cannot map a bare directory to its
|
|
6
|
+
// index), every entry's target exists, and a TypeScript consumer compiles against the
|
|
7
|
+
// declarations, including an explicit `.d.ts` import path.
|
|
8
|
+
//
|
|
9
|
+
// The published package root is `dist/` (`publish:ci` copies package.json there and publishes
|
|
10
|
+
// from it), so the map is checked from a scratch package whose node_modules links to `dist/`.
|
|
11
|
+
// Run after `pnpm run tsc:build` (the `check:exports` script does both).
|
|
12
|
+
import { spawnSync } from 'node:child_process';
|
|
13
|
+
import { createRequire } from 'node:module';
|
|
14
|
+
import {
|
|
15
|
+
cpSync,
|
|
16
|
+
existsSync,
|
|
17
|
+
mkdirSync,
|
|
18
|
+
mkdtempSync,
|
|
19
|
+
readFileSync,
|
|
20
|
+
readdirSync,
|
|
21
|
+
rmSync,
|
|
22
|
+
symlinkSync,
|
|
23
|
+
writeFileSync,
|
|
24
|
+
} from 'node:fs';
|
|
25
|
+
import { tmpdir } from 'node:os';
|
|
26
|
+
import { dirname, join, resolve } from 'node:path';
|
|
27
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
28
|
+
|
|
29
|
+
const PACKAGE = '@hatchet-dev/typescript-sdk';
|
|
30
|
+
|
|
31
|
+
// Import paths users and the serverless package rely on, with and without the `.js` suffix.
|
|
32
|
+
const DOCUMENTED_SUBPATHS = [
|
|
33
|
+
'.',
|
|
34
|
+
'./v1',
|
|
35
|
+
'./edge',
|
|
36
|
+
'./edge/index.js',
|
|
37
|
+
'./core',
|
|
38
|
+
'./clients/hatchet-client',
|
|
39
|
+
'./v1/client/client.js',
|
|
40
|
+
'./protoc/dispatcher/dispatcher',
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
// Type-only imports a consumer's TypeScript may use: the explicit declaration-file path a
|
|
44
|
+
// `types` condition cannot produce on its own (`./*` would append `.d.ts` twice), next to the
|
|
45
|
+
// bare, `.js`-suffixed and directory-entry forms.
|
|
46
|
+
const TYPE_CONSUMER = [
|
|
47
|
+
"import type { ClientConfig } from '@hatchet-dev/typescript-sdk/clients/hatchet-client/client-config.d.ts';",
|
|
48
|
+
"import type { HatchetClient } from '@hatchet-dev/typescript-sdk/v1';",
|
|
49
|
+
"import type { AdminClient } from '@hatchet-dev/typescript-sdk/v1/client/admin';",
|
|
50
|
+
"import type { EventClient } from '@hatchet-dev/typescript-sdk/clients/event/event-client.js';",
|
|
51
|
+
'export type Consumer = [ClientConfig, HatchetClient, AdminClient, EventClient];',
|
|
52
|
+
'',
|
|
53
|
+
].join('\n');
|
|
54
|
+
const TYPE_RESOLUTIONS = ['node16', 'bundler'];
|
|
55
|
+
|
|
56
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
57
|
+
const dist = join(root, 'dist');
|
|
58
|
+
const tsc = join(root, 'node_modules', 'typescript', 'bin', 'tsc');
|
|
59
|
+
|
|
60
|
+
if (!existsSync(join(dist, 'index.js'))) {
|
|
61
|
+
console.error(`dist is not built: ${dist}/index.js is missing. Run \`pnpm run tsc:build\` first.`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
|
|
66
|
+
const exportsMap = pkg.exports ?? {};
|
|
67
|
+
const explicitSubpaths = Object.keys(exportsMap).filter((k) => !k.includes('*'));
|
|
68
|
+
const failures = [];
|
|
69
|
+
|
|
70
|
+
function indexDirectories(dir, prefix = '.') {
|
|
71
|
+
const out = [];
|
|
72
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
73
|
+
if (!entry.isDirectory()) continue;
|
|
74
|
+
const sub = `${prefix}/${entry.name}`;
|
|
75
|
+
if (existsSync(join(dir, entry.name, 'index.js'))) out.push(sub);
|
|
76
|
+
out.push(...indexDirectories(join(dir, entry.name), sub));
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
for (const sub of indexDirectories(dist)) {
|
|
82
|
+
if (!(sub in exportsMap)) {
|
|
83
|
+
failures.push(`${sub} ships an index.js but has no explicit "exports" entry`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
for (const sub of explicitSubpaths) {
|
|
88
|
+
const target = exportsMap[sub];
|
|
89
|
+
const files = typeof target === 'string' ? [target] : Object.values(target);
|
|
90
|
+
for (const file of files) {
|
|
91
|
+
if (file !== './package.json' && !existsSync(join(dist, file))) {
|
|
92
|
+
failures.push(`"${sub}" target ${file} does not exist in dist`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const scratch = mkdtempSync(join(tmpdir(), 'hatchet-check-exports-'));
|
|
98
|
+
try {
|
|
99
|
+
// The published layout: package.json next to the build output, reached through node_modules.
|
|
100
|
+
cpSync(join(root, 'package.json'), join(dist, 'package.json'));
|
|
101
|
+
mkdirSync(join(scratch, 'node_modules', '@hatchet-dev'), { recursive: true });
|
|
102
|
+
symlinkSync(dist, join(scratch, 'node_modules', '@hatchet-dev', 'typescript-sdk'), 'dir');
|
|
103
|
+
|
|
104
|
+
const esmDir = join(scratch, 'esm');
|
|
105
|
+
const cjsDir = join(scratch, 'cjs');
|
|
106
|
+
mkdirSync(esmDir);
|
|
107
|
+
mkdirSync(cjsDir);
|
|
108
|
+
writeFileSync(join(esmDir, 'package.json'), '{ "type": "module" }\n');
|
|
109
|
+
writeFileSync(join(cjsDir, 'package.json'), '{ "type": "commonjs" }\n');
|
|
110
|
+
const cjsRequire = createRequire(join(cjsDir, 'probe.js'));
|
|
111
|
+
|
|
112
|
+
const subpaths = [...new Set([...DOCUMENTED_SUBPATHS, ...explicitSubpaths])];
|
|
113
|
+
for (const [i, sub] of subpaths.entries()) {
|
|
114
|
+
const specifier = sub === '.' ? PACKAGE : `${PACKAGE}/${sub.slice(2)}`;
|
|
115
|
+
|
|
116
|
+
const probe = join(esmDir, `probe-${i}.mjs`);
|
|
117
|
+
const attributes = sub === './package.json' ? ' with { type: "json" }' : '';
|
|
118
|
+
writeFileSync(probe, `import ${JSON.stringify(specifier)}${attributes};\n`);
|
|
119
|
+
try {
|
|
120
|
+
await import(pathToFileURL(probe).href);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
failures.push(`ESM import of ${specifier} failed: ${e.message}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
cjsRequire(specifier);
|
|
127
|
+
} catch (e) {
|
|
128
|
+
failures.push(`CJS require of ${specifier} failed: ${e.message}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const typesDir = join(scratch, 'types');
|
|
133
|
+
mkdirSync(typesDir);
|
|
134
|
+
writeFileSync(join(typesDir, 'consumer.ts'), TYPE_CONSUMER);
|
|
135
|
+
for (const moduleResolution of TYPE_RESOLUTIONS) {
|
|
136
|
+
const tsconfig = join(typesDir, `tsconfig.${moduleResolution}.json`);
|
|
137
|
+
writeFileSync(
|
|
138
|
+
tsconfig,
|
|
139
|
+
JSON.stringify({
|
|
140
|
+
compilerOptions: {
|
|
141
|
+
target: 'ES2022',
|
|
142
|
+
module: moduleResolution === 'bundler' ? 'ESNext' : moduleResolution,
|
|
143
|
+
moduleResolution,
|
|
144
|
+
strict: true,
|
|
145
|
+
noEmit: true,
|
|
146
|
+
skipLibCheck: true,
|
|
147
|
+
types: [],
|
|
148
|
+
},
|
|
149
|
+
files: ['consumer.ts'],
|
|
150
|
+
})
|
|
151
|
+
);
|
|
152
|
+
const result = spawnSync(process.execPath, [tsc, '-p', tsconfig], { encoding: 'utf8' });
|
|
153
|
+
if (result.status !== 0) {
|
|
154
|
+
failures.push(
|
|
155
|
+
`type consumer (moduleResolution ${moduleResolution}) failed:\n${result.stdout}${result.stderr}`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
} finally {
|
|
160
|
+
rmSync(scratch, { recursive: true, force: true });
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (failures.length) {
|
|
164
|
+
console.error('exports map check failed:');
|
|
165
|
+
for (const f of failures) console.error(` ${f}`);
|
|
166
|
+
process.exit(1);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
console.log(
|
|
170
|
+
`exports map resolves ${DOCUMENTED_SUBPATHS.length} documented and ${explicitSubpaths.length} explicit subpaths from ESM and CJS, and a type consumer compiles under ${TYPE_RESOLUTIONS.join(' and ')}`
|
|
171
|
+
);
|
package/util/grpc-error.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export declare function isTimeoutOrAbortError(e: unknown): boolean;
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function getGrpcErrorCode(e: unknown): number | undefined;
|
|
19
19
|
/**
|
|
20
|
-
* Returns the gRPC
|
|
20
|
+
* Returns the gRPC status message from an unknown value (e.g. from a catch block): the
|
|
21
|
+
* `details` string of a `nice-grpc` or `@grpc/grpc-js` error, or the `rawMessage` of a
|
|
22
|
+
* `ConnectError`, which carries the same server-provided text without the code prefix.
|
|
21
23
|
*/
|
|
22
24
|
export declare function getGrpcErrorDetails(e: unknown): string | undefined;
|
package/util/grpc-error.js
CHANGED
|
@@ -35,12 +35,21 @@ function getGrpcErrorCode(e) {
|
|
|
35
35
|
return undefined;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* Returns the gRPC
|
|
38
|
+
* Returns the gRPC status message from an unknown value (e.g. from a catch block): the
|
|
39
|
+
* `details` string of a `nice-grpc` or `@grpc/grpc-js` error, or the `rawMessage` of a
|
|
40
|
+
* `ConnectError`, which carries the same server-provided text without the code prefix.
|
|
39
41
|
*/
|
|
40
42
|
function getGrpcErrorDetails(e) {
|
|
41
|
-
if (e != null && typeof e === 'object'
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
if (e != null && typeof e === 'object') {
|
|
44
|
+
if ('rawMessage' in e) {
|
|
45
|
+
const { rawMessage } = e;
|
|
46
|
+
if (typeof rawMessage === 'string')
|
|
47
|
+
return rawMessage;
|
|
48
|
+
}
|
|
49
|
+
if ('details' in e) {
|
|
50
|
+
const { details } = e;
|
|
51
|
+
return typeof details === 'string' ? details : undefined;
|
|
52
|
+
}
|
|
44
53
|
}
|
|
45
54
|
return undefined;
|
|
46
55
|
}
|
package/v1/client/admin.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { RunListenerClient } from '../../clients/listeners/run-listener/child-li
|
|
|
5
5
|
import { Api } from '../../clients/rest/generated/Api';
|
|
6
6
|
import { WorkflowServiceClient } from '../../protoc/workflows';
|
|
7
7
|
import { AdminServiceClient, CreateWorkflowVersionRequest } from '../../protoc/v1/workflows';
|
|
8
|
+
import { type Transport } from '../../clients/transport';
|
|
8
9
|
import { Logger } from '../../util/logger';
|
|
9
10
|
type DesiredWorkerLabelOpt = {
|
|
10
11
|
value: string | number;
|
|
@@ -40,7 +41,7 @@ export declare class AdminClient {
|
|
|
40
41
|
listenerClient: RunListenerClient;
|
|
41
42
|
runs: RunsClient;
|
|
42
43
|
logger: Logger;
|
|
43
|
-
constructor(config: ClientConfig, api: Api, runs: RunsClient);
|
|
44
|
+
constructor(config: ClientConfig, api: Api, runs: RunsClient, transport?: Transport);
|
|
44
45
|
/**
|
|
45
46
|
* Creates a new workflow or updates an existing workflow via the v1 admin service.
|
|
46
47
|
* @param workflow a workflow definition to create
|
package/v1/client/admin.js
CHANGED
|
@@ -28,95 +28,36 @@ const hatchet_error_1 = __importDefault(require("../../util/errors/hatchet-error
|
|
|
28
28
|
const idempotency_collision_error_1 = require("../../util/errors/idempotency-collision-error");
|
|
29
29
|
const bulk_trigger_idempotency_collision_error_1 = require("../../util/errors/bulk-trigger-idempotency-collision-error");
|
|
30
30
|
const workflow_run_ref_1 = __importDefault(require("../../util/workflow-run-ref"));
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const nice_grpc_common_1 = require("nice-grpc-common");
|
|
31
|
+
const connect_1 = require("@connectrpc/connect");
|
|
32
|
+
const workflows_pb_1 = require("../../protoc-es/v1/workflows_pb");
|
|
33
|
+
const nice_grpc_1 = require("nice-grpc");
|
|
35
34
|
const grpc_helpers_1 = require("../../util/grpc-helpers");
|
|
35
|
+
const config_loader_1 = require("../../util/config-loader");
|
|
36
36
|
const child_listener_client_1 = require("../../clients/listeners/run-listener/child-listener-client");
|
|
37
|
-
const
|
|
38
|
-
const
|
|
37
|
+
const workflows_1 = require("../../protoc/workflows");
|
|
38
|
+
const rpc_1 = require("../../clients/admin/rpc");
|
|
39
|
+
const transport_1 = require("../../clients/transport");
|
|
39
40
|
const retrier_1 = require("../../util/retrier");
|
|
40
41
|
const batch_1 = require("../../util/batch");
|
|
41
42
|
const apply_namespace_1 = require("../../util/apply-namespace");
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* The engine answers a trigger whose idempotency key is already taken with `ALREADY_EXISTS`
|
|
45
|
+
* and attaches the collision details to the status. The Connect client decodes those details
|
|
46
|
+
* from the trailer, so the error carries everything needed to build the SDK's collision errors.
|
|
47
|
+
*/
|
|
48
|
+
function isAlreadyExists(e) {
|
|
49
|
+
return e instanceof connect_1.ConnectError && e.code === connect_1.Code.AlreadyExists;
|
|
44
50
|
}
|
|
45
|
-
function
|
|
51
|
+
function extractExistingRunId(e) {
|
|
46
52
|
var _a;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (!binData)
|
|
50
|
-
return '';
|
|
51
|
-
const status = status_1.Status.decode(binData instanceof Buffer ? binData : Buffer.from(binData));
|
|
52
|
-
for (const detail of status.details) {
|
|
53
|
-
if (detail.typeUrl.includes('IdempotencyCollisionError')) {
|
|
54
|
-
return (_a = workflows_1.IdempotencyCollisionError.decode(detail.value).existingRunExternalId) !== null && _a !== void 0 ? _a : '';
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch (_b) {
|
|
59
|
-
// ignore decoding errors
|
|
60
|
-
}
|
|
61
|
-
return '';
|
|
53
|
+
const [detail] = e.findDetails(workflows_pb_1.IdempotencyCollisionErrorSchema);
|
|
54
|
+
return (_a = detail === null || detail === void 0 ? void 0 : detail.existingRunExternalId) !== null && _a !== void 0 ? _a : '';
|
|
62
55
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
function decodeBulkTriggerCollision(status) {
|
|
67
|
-
for (const detail of status.details) {
|
|
68
|
-
if (detail.typeUrl.includes('BulkTriggerIdempotencyCollisionError')) {
|
|
69
|
-
const proto = workflows_1.BulkTriggerIdempotencyCollisionError.decode(detail.value);
|
|
70
|
-
return new bulk_trigger_idempotency_collision_error_1.BulkTriggerIdempotencyCollisionError(proto.successfulWorkflowRunExternalIds, proto.collisions.map((c) => new idempotency_collision_error_1.IdempotencyCollisionError(c.existingRunExternalId)));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
function extractBulkTriggerCollisionFromGrpcError(e) {
|
|
76
|
-
try {
|
|
77
|
-
const [binData] = e.metadata.get('grpc-status-details-bin');
|
|
78
|
-
if (!binData)
|
|
79
|
-
return null;
|
|
80
|
-
const status = status_1.Status.decode(binData instanceof Buffer ? binData : Buffer.from(binData));
|
|
81
|
-
return decodeBulkTriggerCollision(status);
|
|
82
|
-
}
|
|
83
|
-
catch (_a) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function extractBulkTriggerCollisionFromNiceGrpcMetadata(metadata) {
|
|
88
|
-
if (!metadata)
|
|
89
|
-
return null;
|
|
90
|
-
try {
|
|
91
|
-
const binData = metadata.get('grpc-status-details-bin');
|
|
92
|
-
if (!binData)
|
|
93
|
-
return null;
|
|
94
|
-
const status = status_1.Status.decode(binData);
|
|
95
|
-
return decodeBulkTriggerCollision(status);
|
|
96
|
-
}
|
|
97
|
-
catch (_a) {
|
|
56
|
+
function extractBulkTriggerCollision(e) {
|
|
57
|
+
const [detail] = e.findDetails(workflows_pb_1.BulkTriggerIdempotencyCollisionErrorSchema);
|
|
58
|
+
if (!detail)
|
|
98
59
|
return null;
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
function extractRunIdFromNiceGrpcMetadata(metadata) {
|
|
102
|
-
var _a;
|
|
103
|
-
if (!metadata)
|
|
104
|
-
return '';
|
|
105
|
-
try {
|
|
106
|
-
const binData = metadata.get('grpc-status-details-bin');
|
|
107
|
-
if (!binData)
|
|
108
|
-
return '';
|
|
109
|
-
const status = status_1.Status.decode(binData);
|
|
110
|
-
for (const detail of status.details) {
|
|
111
|
-
if (detail.typeUrl.includes('IdempotencyCollisionError')) {
|
|
112
|
-
return (_a = workflows_1.IdempotencyCollisionError.decode(detail.value).existingRunExternalId) !== null && _a !== void 0 ? _a : '';
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
catch (_b) {
|
|
117
|
-
// ignore decoding errors
|
|
118
|
-
}
|
|
119
|
-
return '';
|
|
60
|
+
return new bulk_trigger_idempotency_collision_error_1.BulkTriggerIdempotencyCollisionError(detail.successfulWorkflowRunExternalIds, detail.collisions.map((c) => new idempotency_collision_error_1.IdempotencyCollisionError(c.existingRunExternalId)));
|
|
120
61
|
}
|
|
121
62
|
function convertDesiredWorkerLabels(labels) {
|
|
122
63
|
return Object.fromEntries(Object.entries(labels).map(([key, label]) => [
|
|
@@ -131,12 +72,14 @@ function convertDesiredWorkerLabels(labels) {
|
|
|
131
72
|
]));
|
|
132
73
|
}
|
|
133
74
|
class AdminClient {
|
|
134
|
-
constructor(config, api, runs) {
|
|
75
|
+
constructor(config, api, runs, transport = (0, transport_1.createNodeTransport)(config)) {
|
|
135
76
|
this.config = config;
|
|
136
77
|
this.logger = config.logger(`Admin`, config.log_level);
|
|
137
|
-
|
|
138
|
-
this.
|
|
139
|
-
|
|
78
|
+
this.workflowsGrpc = (0, rpc_1.createWorkflowsRpc)(transport);
|
|
79
|
+
this.adminGrpc = (0, rpc_1.createV1AdminRpc)(transport);
|
|
80
|
+
// The run listener streams, which stay on the nice-grpc channel.
|
|
81
|
+
const channel = (0, grpc_helpers_1.channelFactory)(config, config_loader_1.ConfigLoader.createCredentials(config.tls_config));
|
|
82
|
+
const factory = (0, nice_grpc_1.createClientFactory)().use((0, grpc_helpers_1.addTokenMiddleware)(config.token));
|
|
140
83
|
this.listenerClient = new child_listener_client_1.RunListenerClient(config, channel, factory, api);
|
|
141
84
|
this.runs = runs;
|
|
142
85
|
}
|
|
@@ -167,7 +110,6 @@ class AdminClient {
|
|
|
167
110
|
*/
|
|
168
111
|
runWorkflow(workflowName, input, options) {
|
|
169
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
-
let trailerMetadata;
|
|
171
113
|
try {
|
|
172
114
|
const computedName = (0, apply_namespace_1.applyNamespace)(workflowName, this.config.namespace).toLowerCase();
|
|
173
115
|
const inputStr = JSON.stringify(input);
|
|
@@ -178,24 +120,15 @@ class AdminClient {
|
|
|
178
120
|
parentTaskRunExternalId: parentTaskRunExternalId !== null && parentTaskRunExternalId !== void 0 ? parentTaskRunExternalId : parentStepRunId, additionalMetadata: additionalMetadata ? JSON.stringify(additionalMetadata) : undefined, priority: opts.priority, desiredWorkerLabels: desiredWorkerLabels
|
|
179
121
|
? convertDesiredWorkerLabels(desiredWorkerLabels)
|
|
180
122
|
: {} });
|
|
181
|
-
const resp = yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
return this.workflowsGrpc.triggerWorkflow(request, {
|
|
183
|
-
onTrailer: (trailer) => {
|
|
184
|
-
trailerMetadata = trailer;
|
|
185
|
-
},
|
|
186
|
-
});
|
|
187
|
-
}), this.logger, Object.assign(Object.assign({}, this.config.retrier), { shouldRetry: (e) => !isNiceGrpcAlreadyExists(e) }));
|
|
123
|
+
const resp = yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () { return this.workflowsGrpc.triggerWorkflow(request); }), this.logger, Object.assign(Object.assign({}, this.config.retrier), { shouldRetry: (e) => !isAlreadyExists(e) }));
|
|
188
124
|
const id = resp.workflowRunId;
|
|
189
125
|
const ref = new workflow_run_ref_1.default(id, this.listenerClient, this.runs, options === null || options === void 0 ? void 0 : options.parentId, options === null || options === void 0 ? void 0 : options._standaloneTaskName);
|
|
190
126
|
yield ref.getWorkflowRunId();
|
|
191
127
|
return ref;
|
|
192
128
|
}
|
|
193
129
|
catch (e) {
|
|
194
|
-
if (
|
|
195
|
-
throw new idempotency_collision_error_1.IdempotencyCollisionError(
|
|
196
|
-
}
|
|
197
|
-
if (isNiceGrpcAlreadyExists(e)) {
|
|
198
|
-
throw new idempotency_collision_error_1.IdempotencyCollisionError(extractRunIdFromNiceGrpcMetadata(trailerMetadata));
|
|
130
|
+
if (isAlreadyExists(e)) {
|
|
131
|
+
throw new idempotency_collision_error_1.IdempotencyCollisionError(extractExistingRunId(e));
|
|
199
132
|
}
|
|
200
133
|
throw new hatchet_error_1.default(e instanceof Error ? e.message : String(e));
|
|
201
134
|
}
|
|
@@ -227,23 +160,15 @@ class AdminClient {
|
|
|
227
160
|
});
|
|
228
161
|
const batches = (0, batch_1.batch)(workflowRequests, batchSize, (_a = this.config.grpc_max_send_message_length) !== null && _a !== void 0 ? _a : 4 * 1024 * 1024);
|
|
229
162
|
this.logger.debug(`batching ${batches.length} batches`);
|
|
230
|
-
let bulkTrailerMetadata;
|
|
231
163
|
try {
|
|
232
164
|
const results = [];
|
|
233
165
|
// for loop to ensure serial execution of batches
|
|
234
166
|
for (const { payloads, originalIndices, batchIndex } of batches) {
|
|
235
|
-
const request =
|
|
167
|
+
const request = workflows_1.BulkTriggerWorkflowRequest.create({
|
|
236
168
|
workflows: payloads,
|
|
237
169
|
});
|
|
238
170
|
// Call the bulk trigger workflow method for this batch
|
|
239
|
-
const bulkTriggerWorkflowResponse = yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () {
|
|
240
|
-
return this.workflowsGrpc.bulkTriggerWorkflow(request, {
|
|
241
|
-
onTrailer: (trailer) => {
|
|
242
|
-
bulkTrailerMetadata = trailer;
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
}), this.logger, Object.assign(Object.assign({}, this.config.retrier), { shouldRetry: (e) => !isNiceGrpcAlreadyExists(e) &&
|
|
246
|
-
!(isGrpcServiceError(e) && e.code === grpc_js_1.status.ALREADY_EXISTS) }));
|
|
171
|
+
const bulkTriggerWorkflowResponse = yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () { return this.workflowsGrpc.bulkTriggerWorkflow(request); }), this.logger, Object.assign(Object.assign({}, this.config.retrier), { shouldRetry: (e) => !isAlreadyExists(e) }));
|
|
247
172
|
this.logger.debug(`batch ${batchIndex + 1} of ${batches.length}`);
|
|
248
173
|
// Map the results back to their original indices
|
|
249
174
|
const batchResults = bulkTriggerWorkflowResponse.workflowRunIds.map((resp, index) => {
|
|
@@ -256,13 +181,8 @@ class AdminClient {
|
|
|
256
181
|
return results;
|
|
257
182
|
}
|
|
258
183
|
catch (e) {
|
|
259
|
-
if (
|
|
260
|
-
const collision =
|
|
261
|
-
if (collision)
|
|
262
|
-
throw collision;
|
|
263
|
-
}
|
|
264
|
-
if (isNiceGrpcAlreadyExists(e)) {
|
|
265
|
-
const collision = extractBulkTriggerCollisionFromNiceGrpcMetadata(bulkTrailerMetadata);
|
|
184
|
+
if (isAlreadyExists(e)) {
|
|
185
|
+
const collision = extractBulkTriggerCollision(e);
|
|
266
186
|
if (collision)
|
|
267
187
|
throw collision;
|
|
268
188
|
}
|