@hatchet-dev/typescript-sdk 0.1.18 → 0.1.20

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.
@@ -99,45 +99,45 @@ class Worker {
99
99
  }
100
100
  handleStartStepRun(action) {
101
101
  const { actionId } = action;
102
- const context = new step_1.Context(action);
103
- this.contexts[action.stepRunId] = context;
104
- const step = this.action_registry[actionId];
105
- if (!step) {
106
- this.logger.error(`Could not find step '${actionId}'`);
107
- return;
108
- }
109
- const run = () => __awaiter(this, void 0, void 0, function* () {
110
- return step(context);
111
- });
112
- const success = (result) => {
113
- this.logger.info(`Step run ${action.stepRunId} succeeded`);
114
- try {
115
- // Send the action event to the dispatcher
116
- const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, result);
117
- this.client.dispatcher.sendStepActionEvent(event);
118
- // delete the run from the futures
119
- delete this.futures[action.stepRunId];
120
- }
121
- catch (e) {
122
- this.logger.error(`Could not send action event: ${e.message}`);
123
- }
124
- };
125
- const failure = (error) => {
126
- this.logger.error(`Step run ${action.stepRunId} failed: ${error.message}`);
127
- try {
128
- // Send the action event to the dispatcher
129
- const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, error);
130
- this.client.dispatcher.sendStepActionEvent(event);
131
- // delete the run from the futures
132
- delete this.futures[action.stepRunId];
133
- }
134
- catch (e) {
135
- this.logger.error(`Could not send action event: ${e.message}`);
136
- }
137
- };
138
- const future = new hatchet_promise_1.default(run().then(success).catch(failure));
139
- this.futures[action.stepRunId] = future;
140
102
  try {
103
+ const context = new step_1.Context(action);
104
+ this.contexts[action.stepRunId] = context;
105
+ const step = this.action_registry[actionId];
106
+ if (!step) {
107
+ this.logger.error(`Could not find step '${actionId}'`);
108
+ return;
109
+ }
110
+ const run = () => __awaiter(this, void 0, void 0, function* () {
111
+ return step(context);
112
+ });
113
+ const success = (result) => {
114
+ this.logger.info(`Step run ${action.stepRunId} succeeded`);
115
+ try {
116
+ // Send the action event to the dispatcher
117
+ const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, result);
118
+ this.client.dispatcher.sendStepActionEvent(event);
119
+ // delete the run from the futures
120
+ delete this.futures[action.stepRunId];
121
+ }
122
+ catch (e) {
123
+ this.logger.error(`Could not send action event: ${e.message}`);
124
+ }
125
+ };
126
+ const failure = (error) => {
127
+ this.logger.error(`Step run ${action.stepRunId} failed: ${error.message}`);
128
+ try {
129
+ // Send the action event to the dispatcher
130
+ const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, error);
131
+ this.client.dispatcher.sendStepActionEvent(event);
132
+ // delete the run from the futures
133
+ delete this.futures[action.stepRunId];
134
+ }
135
+ catch (e) {
136
+ this.logger.error(`Could not send action event: ${e.message}`);
137
+ }
138
+ };
139
+ const future = new hatchet_promise_1.default(run().then(success).catch(failure));
140
+ this.futures[action.stepRunId] = future;
141
141
  // Send the action event to the dispatcher
142
142
  const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_STARTED);
143
143
  this.client.dispatcher.sendStepActionEvent(event);
@@ -148,47 +148,47 @@ class Worker {
148
148
  }
149
149
  handleStartGroupKeyRun(action) {
150
150
  const { actionId } = action;
151
- const context = new step_1.Context(action);
152
- const key = action.getGroupKeyRunId;
153
- this.contexts[key] = context;
154
- this.logger.debug(`Starting group key run ${key}`);
155
- const step = this.action_registry[actionId];
156
- if (!step) {
157
- this.logger.error(`Could not find step '${actionId}'`);
158
- return;
159
- }
160
- const run = () => __awaiter(this, void 0, void 0, function* () {
161
- return step(context);
162
- });
163
- const success = (result) => {
164
- this.logger.info(`Step run ${action.stepRunId} succeeded`);
165
- try {
166
- // Send the action event to the dispatcher
167
- const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_COMPLETED, result);
168
- this.client.dispatcher.sendGroupKeyActionEvent(event);
169
- // delete the run from the futures
170
- delete this.futures[key];
171
- }
172
- catch (e) {
173
- this.logger.error(`Could not send action event: ${e.message}`);
174
- }
175
- };
176
- const failure = (error) => {
177
- this.logger.error(`Step run ${key} failed: ${error.message}`);
178
- try {
179
- // Send the action event to the dispatcher
180
- const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_FAILED, error);
181
- this.client.dispatcher.sendGroupKeyActionEvent(event);
182
- // delete the run from the futures
183
- delete this.futures[key];
184
- }
185
- catch (e) {
186
- this.logger.error(`Could not send action event: ${e.message}`);
187
- }
188
- };
189
- const future = new hatchet_promise_1.default(run().then(success).catch(failure));
190
- this.futures[action.getGroupKeyRunId] = future;
191
151
  try {
152
+ const context = new step_1.Context(action);
153
+ const key = action.getGroupKeyRunId;
154
+ this.contexts[key] = context;
155
+ this.logger.debug(`Starting group key run ${key}`);
156
+ const step = this.action_registry[actionId];
157
+ if (!step) {
158
+ this.logger.error(`Could not find step '${actionId}'`);
159
+ return;
160
+ }
161
+ const run = () => __awaiter(this, void 0, void 0, function* () {
162
+ return step(context);
163
+ });
164
+ const success = (result) => {
165
+ this.logger.info(`Step run ${action.stepRunId} succeeded`);
166
+ try {
167
+ // Send the action event to the dispatcher
168
+ const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_COMPLETED, result);
169
+ this.client.dispatcher.sendGroupKeyActionEvent(event);
170
+ // delete the run from the futures
171
+ delete this.futures[key];
172
+ }
173
+ catch (e) {
174
+ this.logger.error(`Could not send action event: ${e.message}`);
175
+ }
176
+ };
177
+ const failure = (error) => {
178
+ this.logger.error(`Step run ${key} failed: ${error.message}`);
179
+ try {
180
+ // Send the action event to the dispatcher
181
+ const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_FAILED, error);
182
+ this.client.dispatcher.sendGroupKeyActionEvent(event);
183
+ // delete the run from the futures
184
+ delete this.futures[key];
185
+ }
186
+ catch (e) {
187
+ this.logger.error(`Could not send action event: ${e.message}`);
188
+ }
189
+ };
190
+ const future = new hatchet_promise_1.default(run().then(success).catch(failure));
191
+ this.futures[action.getGroupKeyRunId] = future;
192
192
  // Send the action event to the dispatcher
193
193
  const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_STARTED);
194
194
  this.client.dispatcher.sendStepActionEvent(event);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/step.d.ts CHANGED
@@ -16,8 +16,9 @@ export declare const CreateStepSchema: z.ZodObject<{
16
16
  timeout?: string | undefined;
17
17
  retries?: number | undefined;
18
18
  }>;
19
+ type JSONPrimitive = string | number | boolean | null;
19
20
  export type NextStep = {
20
- [key: string]: string;
21
+ [key: string]: NextStep | JSONPrimitive;
21
22
  };
22
23
  interface ContextData<T, K> {
23
24
  input: T;