@hatchet-dev/typescript-sdk 1.11.0 → 1.12.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.
- package/clients/admin/admin-client.d.ts +38 -0
- package/clients/admin/admin-client.js +19 -6
- package/clients/dispatcher/action-listener.d.ts +6 -2
- package/clients/dispatcher/action-listener.js +2 -2
- package/clients/dispatcher/dispatcher-client.d.ts +22 -3
- package/clients/dispatcher/dispatcher-client.js +41 -4
- package/clients/event/event-client.d.ts +2 -2
- package/clients/event/event-client.js +4 -4
- package/clients/hatchet-client/hatchet-logger.js +2 -2
- package/clients/rest/generated/Api.d.ts +9 -1
- package/clients/rest/generated/data-contracts.d.ts +44 -8
- package/clients/rest/generated/data-contracts.js +13 -2
- package/clients/worker/worker.js +11 -11
- package/examples/webhooks.d.ts +1 -0
- package/examples/webhooks.js +45 -0
- package/package.json +1 -1
- package/protoc/dispatcher/dispatcher.d.ts +70 -25
- package/protoc/dispatcher/dispatcher.js +323 -97
- package/protoc/events/events.d.ts +4 -4
- package/protoc/events/events.js +20 -16
- package/protoc/v1/workflows.d.ts +18 -7
- package/protoc/v1/workflows.js +122 -2
- package/protoc/workflows/workflows.d.ts +22 -22
- package/protoc/workflows/workflows.js +18 -18
- package/step.d.ts +6 -0
- package/step.js +27 -19
- package/util/workflow-run-ref.js +1 -1
- package/v1/client/admin.d.ts +30 -0
- package/v1/client/admin.js +21 -6
- package/v1/client/client.d.ts +8 -1
- package/v1/client/client.js +13 -2
- package/v1/client/features/runs.d.ts +9 -1
- package/v1/client/features/runs.js +4 -2
- package/v1/client/features/webhooks.d.ts +28 -0
- package/v1/client/features/webhooks.js +97 -0
- package/v1/client/worker/context.d.ts +6 -0
- package/v1/client/worker/context.js +30 -22
- package/v1/client/worker/deprecated/deprecation.d.ts +44 -0
- package/v1/client/worker/deprecated/deprecation.js +95 -0
- package/v1/client/worker/deprecated/index.d.ts +4 -0
- package/v1/client/worker/deprecated/index.js +15 -0
- package/v1/client/worker/deprecated/legacy-registration.d.ts +18 -0
- package/v1/client/worker/deprecated/legacy-registration.js +35 -0
- package/v1/client/worker/deprecated/legacy-v1-worker.d.ts +15 -0
- package/v1/client/worker/deprecated/legacy-v1-worker.js +39 -0
- package/v1/client/worker/deprecated/legacy-worker.d.ts +41 -0
- package/v1/client/worker/deprecated/legacy-worker.js +148 -0
- package/v1/client/worker/slot-utils.d.ts +21 -0
- package/v1/client/worker/slot-utils.js +73 -0
- package/v1/client/worker/worker-internal.d.ts +16 -5
- package/v1/client/worker/worker-internal.js +54 -37
- package/v1/client/worker/worker.d.ts +12 -15
- package/v1/client/worker/worker.js +45 -49
- package/v1/declaration.js +1 -1
- package/v1/index.d.ts +1 -0
- package/v1/index.js +1 -0
- package/v1/parent-run-context-vars.d.ts +4 -1
- package/v1/parent-run-context-vars.js +1 -0
- package/v1/slot-types.d.ts +5 -0
- package/v1/slot-types.js +9 -0
- package/v1/task.d.ts +2 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/workflow.d.ts +2 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const sdk_1 = __importDefault(require("../sdk"));
|
|
16
|
+
const data_contracts_1 = require("../clients/rest/generated/data-contracts");
|
|
17
|
+
const hatchet = sdk_1.default.init();
|
|
18
|
+
function main() {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var _a, _b, _c, _d;
|
|
21
|
+
const webhookName = `example-webhook-${Date.now()}`;
|
|
22
|
+
const namespace = (_b = (_a = hatchet.config) === null || _a === void 0 ? void 0 : _a.namespace) !== null && _b !== void 0 ? _b : 'default';
|
|
23
|
+
const webhook = yield hatchet.webhooks.create({
|
|
24
|
+
sourceName: data_contracts_1.V1WebhookSourceName.GENERIC,
|
|
25
|
+
name: webhookName,
|
|
26
|
+
eventKeyExpression: `'${namespace}/webhook:' + input.type`,
|
|
27
|
+
scopeExpression: 'input.customer_id',
|
|
28
|
+
staticPayload: { customer_id: 'cust-123', environment: 'production' },
|
|
29
|
+
auth: { username: 'test_user', password: 'test_password' },
|
|
30
|
+
});
|
|
31
|
+
console.log('Created webhook:', webhook.name, webhook.scopeExpression, webhook.staticPayload);
|
|
32
|
+
const one = yield hatchet.webhooks.get(webhook.name);
|
|
33
|
+
console.log('Get webhook:', one.name);
|
|
34
|
+
yield hatchet.webhooks.update(webhook.name, {
|
|
35
|
+
scopeExpression: 'input.environment',
|
|
36
|
+
});
|
|
37
|
+
const updated = yield hatchet.webhooks.get(webhook.name);
|
|
38
|
+
console.log('Updated scope expression:', updated.scopeExpression);
|
|
39
|
+
const list = yield hatchet.webhooks.list({ limit: 10, offset: 0 });
|
|
40
|
+
console.log('List webhooks:', (_d = (_c = list.rows) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0);
|
|
41
|
+
yield hatchet.webhooks.delete(webhook.name);
|
|
42
|
+
console.log('Deleted example webhook');
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
main();
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ export declare enum SDKS {
|
|
|
6
6
|
GO = 1,
|
|
7
7
|
PYTHON = 2,
|
|
8
8
|
TYPESCRIPT = 3,
|
|
9
|
+
RUBY = 4,
|
|
9
10
|
UNRECOGNIZED = -1
|
|
10
11
|
}
|
|
11
12
|
export declare function sDKSFromJSON(object: any): SDKS;
|
|
@@ -82,8 +83,11 @@ export interface WorkerRegisterRequest {
|
|
|
82
83
|
actions: string[];
|
|
83
84
|
/** (optional) the services for this worker */
|
|
84
85
|
services: string[];
|
|
85
|
-
/**
|
|
86
|
-
|
|
86
|
+
/**
|
|
87
|
+
* (optional) the number of default slots this worker can handle
|
|
88
|
+
* deprecated: use slot_config instead
|
|
89
|
+
*/
|
|
90
|
+
slots?: number | undefined;
|
|
87
91
|
/** (optional) worker labels (i.e. state or other metadata) */
|
|
88
92
|
labels: {
|
|
89
93
|
[key: string]: WorkerLabels;
|
|
@@ -92,11 +96,19 @@ export interface WorkerRegisterRequest {
|
|
|
92
96
|
webhookId?: string | undefined;
|
|
93
97
|
/** (optional) information regarding the runtime environment of the worker */
|
|
94
98
|
runtimeInfo?: RuntimeInfo | undefined;
|
|
99
|
+
/** (optional) slot config for this worker (slot_type -> units) */
|
|
100
|
+
slotConfig: {
|
|
101
|
+
[key: string]: number;
|
|
102
|
+
};
|
|
95
103
|
}
|
|
96
104
|
export interface WorkerRegisterRequest_LabelsEntry {
|
|
97
105
|
key: string;
|
|
98
106
|
value: WorkerLabels | undefined;
|
|
99
107
|
}
|
|
108
|
+
export interface WorkerRegisterRequest_SlotConfigEntry {
|
|
109
|
+
key: string;
|
|
110
|
+
value: number;
|
|
111
|
+
}
|
|
100
112
|
export interface WorkerRegisterResponse {
|
|
101
113
|
/** the tenant id */
|
|
102
114
|
tenantId: string;
|
|
@@ -136,18 +148,18 @@ export interface AssignedAction {
|
|
|
136
148
|
jobName: string;
|
|
137
149
|
/** the job run id */
|
|
138
150
|
jobRunId: string;
|
|
139
|
-
/** the
|
|
140
|
-
|
|
141
|
-
/** the
|
|
142
|
-
|
|
151
|
+
/** the task id */
|
|
152
|
+
taskId: string;
|
|
153
|
+
/** the task external run id */
|
|
154
|
+
taskRunExternalId: string;
|
|
143
155
|
/** the action id */
|
|
144
156
|
actionId: string;
|
|
145
157
|
/** the action type */
|
|
146
158
|
actionType: ActionType;
|
|
147
159
|
/** the action payload */
|
|
148
160
|
actionPayload: string;
|
|
149
|
-
/** the
|
|
150
|
-
|
|
161
|
+
/** the task name */
|
|
162
|
+
taskName: string;
|
|
151
163
|
/** the count number of the retry attempt */
|
|
152
164
|
retryCount: number;
|
|
153
165
|
/** (optional) additional metadata set on the workflow */
|
|
@@ -188,7 +200,7 @@ export interface GroupKeyActionEvent {
|
|
|
188
200
|
/** the action id */
|
|
189
201
|
actionId: string;
|
|
190
202
|
eventTimestamp: Date | undefined;
|
|
191
|
-
/** the
|
|
203
|
+
/** the task event type */
|
|
192
204
|
eventType: GroupKeyActionEventType;
|
|
193
205
|
/** the event payload */
|
|
194
206
|
eventPayload: string;
|
|
@@ -200,14 +212,14 @@ export interface StepActionEvent {
|
|
|
200
212
|
jobId: string;
|
|
201
213
|
/** the job run id */
|
|
202
214
|
jobRunId: string;
|
|
203
|
-
/** the id of the
|
|
204
|
-
|
|
205
|
-
/** the
|
|
206
|
-
|
|
215
|
+
/** the id of the task */
|
|
216
|
+
taskId: string;
|
|
217
|
+
/** the task external run id */
|
|
218
|
+
taskRunExternalId: string;
|
|
207
219
|
/** the action id */
|
|
208
220
|
actionId: string;
|
|
209
221
|
eventTimestamp: Date | undefined;
|
|
210
|
-
/** the
|
|
222
|
+
/** the task event type */
|
|
211
223
|
eventType: StepActionEventType;
|
|
212
224
|
/** the event payload */
|
|
213
225
|
eventPayload: string;
|
|
@@ -248,9 +260,9 @@ export interface WorkflowEvent {
|
|
|
248
260
|
* will hang up the connection but clients might want to case
|
|
249
261
|
*/
|
|
250
262
|
hangup: boolean;
|
|
251
|
-
/** (optional) the max number of retries this
|
|
252
|
-
|
|
253
|
-
/** (optional) the retry count of this
|
|
263
|
+
/** (optional) the max number of retries this task can handle */
|
|
264
|
+
taskRetries?: number | undefined;
|
|
265
|
+
/** (optional) the retry count of this task */
|
|
254
266
|
retryCount?: number | undefined;
|
|
255
267
|
eventIndex?: number | undefined;
|
|
256
268
|
}
|
|
@@ -262,15 +274,15 @@ export interface WorkflowRunEvent {
|
|
|
262
274
|
results: StepRunResult[];
|
|
263
275
|
}
|
|
264
276
|
export interface StepRunResult {
|
|
265
|
-
|
|
266
|
-
|
|
277
|
+
taskRunExternalId: string;
|
|
278
|
+
taskName: string;
|
|
267
279
|
jobRunId: string;
|
|
268
280
|
error?: string | undefined;
|
|
269
281
|
output?: string | undefined;
|
|
270
282
|
}
|
|
271
283
|
export interface OverridesData {
|
|
272
|
-
/** the
|
|
273
|
-
|
|
284
|
+
/** the task run id */
|
|
285
|
+
taskRunExternalId: string;
|
|
274
286
|
/** the path of the data to set */
|
|
275
287
|
path: string;
|
|
276
288
|
/** the value to set */
|
|
@@ -289,23 +301,29 @@ export interface HeartbeatRequest {
|
|
|
289
301
|
export interface HeartbeatResponse {
|
|
290
302
|
}
|
|
291
303
|
export interface RefreshTimeoutRequest {
|
|
292
|
-
/** the id of the
|
|
293
|
-
|
|
304
|
+
/** the id of the task run to release */
|
|
305
|
+
taskRunExternalId: string;
|
|
294
306
|
incrementTimeoutBy: string;
|
|
295
307
|
}
|
|
296
308
|
export interface RefreshTimeoutResponse {
|
|
297
309
|
timeoutAt: Date | undefined;
|
|
298
310
|
}
|
|
299
311
|
export interface ReleaseSlotRequest {
|
|
300
|
-
/** the id of the
|
|
301
|
-
|
|
312
|
+
/** the id of the task run to release */
|
|
313
|
+
taskRunExternalId: string;
|
|
302
314
|
}
|
|
303
315
|
export interface ReleaseSlotResponse {
|
|
304
316
|
}
|
|
317
|
+
export interface GetVersionRequest {
|
|
318
|
+
}
|
|
319
|
+
export interface GetVersionResponse {
|
|
320
|
+
version: string;
|
|
321
|
+
}
|
|
305
322
|
export declare const WorkerLabels: MessageFns<WorkerLabels>;
|
|
306
323
|
export declare const RuntimeInfo: MessageFns<RuntimeInfo>;
|
|
307
324
|
export declare const WorkerRegisterRequest: MessageFns<WorkerRegisterRequest>;
|
|
308
325
|
export declare const WorkerRegisterRequest_LabelsEntry: MessageFns<WorkerRegisterRequest_LabelsEntry>;
|
|
326
|
+
export declare const WorkerRegisterRequest_SlotConfigEntry: MessageFns<WorkerRegisterRequest_SlotConfigEntry>;
|
|
309
327
|
export declare const WorkerRegisterResponse: MessageFns<WorkerRegisterResponse>;
|
|
310
328
|
export declare const UpsertWorkerLabelsRequest: MessageFns<UpsertWorkerLabelsRequest>;
|
|
311
329
|
export declare const UpsertWorkerLabelsRequest_LabelsEntry: MessageFns<UpsertWorkerLabelsRequest_LabelsEntry>;
|
|
@@ -330,6 +348,8 @@ export declare const RefreshTimeoutRequest: MessageFns<RefreshTimeoutRequest>;
|
|
|
330
348
|
export declare const RefreshTimeoutResponse: MessageFns<RefreshTimeoutResponse>;
|
|
331
349
|
export declare const ReleaseSlotRequest: MessageFns<ReleaseSlotRequest>;
|
|
332
350
|
export declare const ReleaseSlotResponse: MessageFns<ReleaseSlotResponse>;
|
|
351
|
+
export declare const GetVersionRequest: MessageFns<GetVersionRequest>;
|
|
352
|
+
export declare const GetVersionResponse: MessageFns<GetVersionResponse>;
|
|
333
353
|
export type DispatcherDefinition = typeof DispatcherDefinition;
|
|
334
354
|
export declare const DispatcherDefinition: {
|
|
335
355
|
readonly name: "Dispatcher";
|
|
@@ -444,6 +464,19 @@ export declare const DispatcherDefinition: {
|
|
|
444
464
|
readonly responseStream: false;
|
|
445
465
|
readonly options: {};
|
|
446
466
|
};
|
|
467
|
+
/**
|
|
468
|
+
* GetVersion returns the dispatcher protocol version as a simple integer.
|
|
469
|
+
* SDKs use this to determine feature support (e.g. slot_config registration).
|
|
470
|
+
* Old engines that do not implement this RPC will return UNIMPLEMENTED.
|
|
471
|
+
*/
|
|
472
|
+
readonly getVersion: {
|
|
473
|
+
readonly name: "GetVersion";
|
|
474
|
+
readonly requestType: MessageFns<GetVersionRequest>;
|
|
475
|
+
readonly requestStream: false;
|
|
476
|
+
readonly responseType: MessageFns<GetVersionResponse>;
|
|
477
|
+
readonly responseStream: false;
|
|
478
|
+
readonly options: {};
|
|
479
|
+
};
|
|
447
480
|
};
|
|
448
481
|
};
|
|
449
482
|
export interface DispatcherServiceImplementation<CallContextExt = {}> {
|
|
@@ -465,6 +498,12 @@ export interface DispatcherServiceImplementation<CallContextExt = {}> {
|
|
|
465
498
|
refreshTimeout(request: RefreshTimeoutRequest, context: CallContext & CallContextExt): Promise<DeepPartial<RefreshTimeoutResponse>>;
|
|
466
499
|
releaseSlot(request: ReleaseSlotRequest, context: CallContext & CallContextExt): Promise<DeepPartial<ReleaseSlotResponse>>;
|
|
467
500
|
upsertWorkerLabels(request: UpsertWorkerLabelsRequest, context: CallContext & CallContextExt): Promise<DeepPartial<UpsertWorkerLabelsResponse>>;
|
|
501
|
+
/**
|
|
502
|
+
* GetVersion returns the dispatcher protocol version as a simple integer.
|
|
503
|
+
* SDKs use this to determine feature support (e.g. slot_config registration).
|
|
504
|
+
* Old engines that do not implement this RPC will return UNIMPLEMENTED.
|
|
505
|
+
*/
|
|
506
|
+
getVersion(request: GetVersionRequest, context: CallContext & CallContextExt): Promise<DeepPartial<GetVersionResponse>>;
|
|
468
507
|
}
|
|
469
508
|
export interface DispatcherClient<CallOptionsExt = {}> {
|
|
470
509
|
register(request: DeepPartial<WorkerRegisterRequest>, options?: CallOptions & CallOptionsExt): Promise<WorkerRegisterResponse>;
|
|
@@ -485,6 +524,12 @@ export interface DispatcherClient<CallOptionsExt = {}> {
|
|
|
485
524
|
refreshTimeout(request: DeepPartial<RefreshTimeoutRequest>, options?: CallOptions & CallOptionsExt): Promise<RefreshTimeoutResponse>;
|
|
486
525
|
releaseSlot(request: DeepPartial<ReleaseSlotRequest>, options?: CallOptions & CallOptionsExt): Promise<ReleaseSlotResponse>;
|
|
487
526
|
upsertWorkerLabels(request: DeepPartial<UpsertWorkerLabelsRequest>, options?: CallOptions & CallOptionsExt): Promise<UpsertWorkerLabelsResponse>;
|
|
527
|
+
/**
|
|
528
|
+
* GetVersion returns the dispatcher protocol version as a simple integer.
|
|
529
|
+
* SDKs use this to determine feature support (e.g. slot_config registration).
|
|
530
|
+
* Old engines that do not implement this RPC will return UNIMPLEMENTED.
|
|
531
|
+
*/
|
|
532
|
+
getVersion(request: DeepPartial<GetVersionRequest>, options?: CallOptions & CallOptionsExt): Promise<GetVersionResponse>;
|
|
488
533
|
}
|
|
489
534
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
490
535
|
export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|