@hatchet-dev/typescript-sdk 1.3.1 → 1.3.2
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/package.json +1 -1
- package/protoc/workflows/workflows.d.ts +1 -1
- package/protoc/workflows/workflows.js +5 -5
- package/v1/client/worker.d.ts +2 -2
- package/v1/client/worker.js +7 -6
- package/v1/examples/concurrency-rr/workflow.d.ts +1 -0
- package/v1/examples/concurrency-rr/workflow.js +27 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/package.json
CHANGED
|
@@ -196,7 +196,7 @@ export interface ScheduleWorkflowRequest {
|
|
|
196
196
|
/** (optional) the additional metadata for the workflow */
|
|
197
197
|
additionalMetadata?: string | undefined;
|
|
198
198
|
/** (optional) the priority of the workflow */
|
|
199
|
-
priority
|
|
199
|
+
priority?: number | undefined;
|
|
200
200
|
}
|
|
201
201
|
/** ScheduledWorkflow represents a scheduled workflow. */
|
|
202
202
|
export interface ScheduledWorkflow {
|
|
@@ -1409,7 +1409,7 @@ function createBaseScheduleWorkflowRequest() {
|
|
|
1409
1409
|
childIndex: undefined,
|
|
1410
1410
|
childKey: undefined,
|
|
1411
1411
|
additionalMetadata: undefined,
|
|
1412
|
-
priority:
|
|
1412
|
+
priority: undefined,
|
|
1413
1413
|
};
|
|
1414
1414
|
}
|
|
1415
1415
|
exports.ScheduleWorkflowRequest = {
|
|
@@ -1438,7 +1438,7 @@ exports.ScheduleWorkflowRequest = {
|
|
|
1438
1438
|
if (message.additionalMetadata !== undefined) {
|
|
1439
1439
|
writer.uint32(66).string(message.additionalMetadata);
|
|
1440
1440
|
}
|
|
1441
|
-
if (message.priority !==
|
|
1441
|
+
if (message.priority !== undefined) {
|
|
1442
1442
|
writer.uint32(72).int32(message.priority);
|
|
1443
1443
|
}
|
|
1444
1444
|
return writer;
|
|
@@ -1537,7 +1537,7 @@ exports.ScheduleWorkflowRequest = {
|
|
|
1537
1537
|
additionalMetadata: isSet(object.additionalMetadata)
|
|
1538
1538
|
? globalThis.String(object.additionalMetadata)
|
|
1539
1539
|
: undefined,
|
|
1540
|
-
priority: isSet(object.priority) ? globalThis.Number(object.priority) :
|
|
1540
|
+
priority: isSet(object.priority) ? globalThis.Number(object.priority) : undefined,
|
|
1541
1541
|
};
|
|
1542
1542
|
},
|
|
1543
1543
|
toJSON(message) {
|
|
@@ -1567,7 +1567,7 @@ exports.ScheduleWorkflowRequest = {
|
|
|
1567
1567
|
if (message.additionalMetadata !== undefined) {
|
|
1568
1568
|
obj.additionalMetadata = message.additionalMetadata;
|
|
1569
1569
|
}
|
|
1570
|
-
if (message.priority !==
|
|
1570
|
+
if (message.priority !== undefined) {
|
|
1571
1571
|
obj.priority = Math.round(message.priority);
|
|
1572
1572
|
}
|
|
1573
1573
|
return obj;
|
|
@@ -1586,7 +1586,7 @@ exports.ScheduleWorkflowRequest = {
|
|
|
1586
1586
|
message.childIndex = (_f = object.childIndex) !== null && _f !== void 0 ? _f : undefined;
|
|
1587
1587
|
message.childKey = (_g = object.childKey) !== null && _g !== void 0 ? _g : undefined;
|
|
1588
1588
|
message.additionalMetadata = (_h = object.additionalMetadata) !== null && _h !== void 0 ? _h : undefined;
|
|
1589
|
-
message.priority = (_j = object.priority) !== null && _j !== void 0 ? _j :
|
|
1589
|
+
message.priority = (_j = object.priority) !== null && _j !== void 0 ? _j : undefined;
|
|
1590
1590
|
return message;
|
|
1591
1591
|
},
|
|
1592
1592
|
};
|
package/v1/client/worker.d.ts
CHANGED
|
@@ -51,14 +51,14 @@ export declare class Worker {
|
|
|
51
51
|
* @param workflows - Array of workflows to register
|
|
52
52
|
* @returns Array of registered workflow promises
|
|
53
53
|
*/
|
|
54
|
-
registerWorkflows(workflows?: Array<BaseWorkflowDeclaration<any, any> | V0Workflow>): Promise<void
|
|
54
|
+
registerWorkflows(workflows?: Array<BaseWorkflowDeclaration<any, any> | V0Workflow>): Promise<void>;
|
|
55
55
|
/**
|
|
56
56
|
* Registers a single workflow with the worker
|
|
57
57
|
* @param workflow - The workflow to register
|
|
58
58
|
* @returns A promise that resolves when the workflow is registered
|
|
59
59
|
* @deprecated use registerWorkflows instead
|
|
60
60
|
*/
|
|
61
|
-
registerWorkflow(workflow: BaseWorkflowDeclaration<any, any> | V0Workflow): Promise<void
|
|
61
|
+
registerWorkflow(workflow: BaseWorkflowDeclaration<any, any> | V0Workflow): Promise<void>;
|
|
62
62
|
/**
|
|
63
63
|
* Starts the worker
|
|
64
64
|
* @returns Promise that resolves when the worker is stopped or killed
|
package/v1/client/worker.js
CHANGED
|
@@ -48,21 +48,22 @@ class Worker {
|
|
|
48
48
|
*/
|
|
49
49
|
registerWorkflows(workflows) {
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
|
|
51
|
+
for (const wf of workflows || []) {
|
|
52
52
|
if (wf instanceof declaration_1.BaseWorkflowDeclaration) {
|
|
53
53
|
// TODO check if tenant is V1
|
|
54
|
-
|
|
54
|
+
yield this.nonDurable.registerWorkflowV1(wf);
|
|
55
55
|
if (wf.definition._durableTasks.length > 0) {
|
|
56
56
|
if (!this.durable) {
|
|
57
57
|
this.durable = yield this._v0.worker(`${this.name}-durable`, Object.assign(Object.assign({}, this.config), { maxRuns: this.config.durableSlots || DEFAULT_DURABLE_SLOTS }));
|
|
58
58
|
}
|
|
59
59
|
this.durable.registerDurableActionsV1(wf.definition);
|
|
60
60
|
}
|
|
61
|
-
return register;
|
|
62
61
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
else {
|
|
63
|
+
// fallback to v0 client for backwards compatibility
|
|
64
|
+
yield this.nonDurable.registerWorkflow(wf);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
/**
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.simpleConcurrency = void 0;
|
|
12
|
+
exports.multipleConcurrencyKeys = exports.simpleConcurrency = void 0;
|
|
13
13
|
const workflow_1 = require("../../../workflow");
|
|
14
14
|
const hatchet_client_1 = require("../hatchet-client");
|
|
15
15
|
const sleep = (ms) => new Promise((resolve) => {
|
|
@@ -34,3 +34,29 @@ exports.simpleConcurrency.task({
|
|
|
34
34
|
};
|
|
35
35
|
}),
|
|
36
36
|
});
|
|
37
|
+
// ❓ Multiple Concurrency Keys
|
|
38
|
+
exports.multipleConcurrencyKeys = hatchet_client_1.hatchet.workflow({
|
|
39
|
+
name: 'simple-concurrency',
|
|
40
|
+
concurrency: [
|
|
41
|
+
{
|
|
42
|
+
maxRuns: 1,
|
|
43
|
+
limitStrategy: workflow_1.ConcurrencyLimitStrategy.GROUP_ROUND_ROBIN,
|
|
44
|
+
expression: 'input.Tier',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
maxRuns: 1,
|
|
48
|
+
limitStrategy: workflow_1.ConcurrencyLimitStrategy.GROUP_ROUND_ROBIN,
|
|
49
|
+
expression: 'input.Account',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
// !!
|
|
54
|
+
exports.multipleConcurrencyKeys.task({
|
|
55
|
+
name: 'to-lower',
|
|
56
|
+
fn: (input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
yield sleep(Math.floor(Math.random() * (1000 - 200 + 1)) + 200);
|
|
58
|
+
return {
|
|
59
|
+
TransformedMessage: input.Message.toLowerCase(),
|
|
60
|
+
};
|
|
61
|
+
}),
|
|
62
|
+
});
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.3.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.3.2";
|
package/version.js
CHANGED