@hatchet-dev/typescript-sdk 1.24.3 → 1.26.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/package.json +8 -7
- package/protoc/google/protobuf/any.d.ts +133 -0
- package/protoc/google/protobuf/any.js +112 -0
- package/protoc/google/rpc/status.d.ts +45 -0
- package/protoc/google/rpc/status.js +102 -0
- package/protoc/v1/workflows.d.ts +21 -0
- package/protoc/v1/workflows.js +231 -1
- package/util/errors/bulk-trigger-idempotency-collision-error.d.ts +6 -0
- package/util/errors/bulk-trigger-idempotency-collision-error.js +13 -0
- package/util/errors/idempotency-collision-error.d.ts +5 -0
- package/util/errors/idempotency-collision-error.js +16 -0
- package/util/retrier.d.ts +1 -1
- package/util/retrier.js +4 -1
- package/v1/client/admin.js +125 -9
- package/v1/client/worker/worker-internal.d.ts +5 -0
- package/v1/client/worker/worker-internal.js +25 -2
- package/v1/declaration.d.ts +8 -3
- package/v1/examples/bulk_operations/cancel.d.ts +1 -0
- package/v1/examples/bulk_operations/cancel.js +52 -0
- package/v1/examples/concurrency_cancel_in_progress/workflow.js +2 -0
- package/v1/examples/concurrency_cancel_newest/workflow.js +2 -0
- package/v1/examples/dag_match_condition/complex-workflow.js +15 -0
- package/v1/examples/e2e-worker.js +30 -27
- package/v1/examples/idempotency/run.d.ts +1 -0
- package/v1/examples/idempotency/run.js +37 -0
- package/v1/examples/idempotency/workflow.d.ts +10 -0
- package/v1/examples/idempotency/workflow.js +39 -0
- package/v1/examples/slot_cost/workflow.d.ts +2 -0
- package/v1/examples/slot_cost/workflow.js +29 -0
- package/v1/examples/timeout/worker.js +2 -0
- package/v1/index.d.ts +2 -0
- package/v1/index.js +5 -1
- package/v1/task.d.ts +35 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const data_contracts_1 = require("../../../clients/rest/generated/data-contracts");
|
|
13
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
// > Setup
|
|
18
|
+
const workflows = yield hatchet_client_1.hatchet.workflows.list();
|
|
19
|
+
if (!((_a = workflows.rows) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
20
|
+
throw new Error('no workflows found');
|
|
21
|
+
}
|
|
22
|
+
const [workflow] = workflows.rows;
|
|
23
|
+
// !!
|
|
24
|
+
// > List runs
|
|
25
|
+
const workflowRuns = yield hatchet_client_1.hatchet.runs.list({
|
|
26
|
+
workflowNames: [workflow.name],
|
|
27
|
+
});
|
|
28
|
+
// !!
|
|
29
|
+
// > Cancel by run ids
|
|
30
|
+
const runIds = (_c = (_b = workflowRuns.rows) === null || _b === void 0 ? void 0 : _b.map((run) => run.metadata.id)) !== null && _c !== void 0 ? _c : [];
|
|
31
|
+
// to replay runs by their ids, use `hatchet.runs.replay` instead
|
|
32
|
+
yield hatchet_client_1.hatchet.runs.cancel({ ids: runIds });
|
|
33
|
+
// !!
|
|
34
|
+
// > Cancel by filters
|
|
35
|
+
// to replay runs matching filters, use `hatchet.runs.replay` instead
|
|
36
|
+
yield hatchet_client_1.hatchet.runs.cancel({
|
|
37
|
+
filters: {
|
|
38
|
+
since: new Date(Date.now() - 24 * 60 * 60 * 1000),
|
|
39
|
+
until: new Date(),
|
|
40
|
+
statuses: [data_contracts_1.V1TaskStatus.RUNNING],
|
|
41
|
+
workflowNames: [workflow.name],
|
|
42
|
+
additionalMetadata: { key: 'value' },
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
// !!
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (require.main === module) {
|
|
49
|
+
main()
|
|
50
|
+
.catch(console.error)
|
|
51
|
+
.finally(() => process.exit(0));
|
|
52
|
+
}
|
|
@@ -16,6 +16,7 @@ exports.concurrencyCancelInProgressWorkflow = void 0;
|
|
|
16
16
|
const sleep_1 = __importDefault(require("../../../util/sleep"));
|
|
17
17
|
const v1_1 = require("../..");
|
|
18
18
|
const hatchet_client_1 = require("../hatchet-client");
|
|
19
|
+
// > Cancel In Progress
|
|
19
20
|
exports.concurrencyCancelInProgressWorkflow = hatchet_client_1.hatchet.workflow({
|
|
20
21
|
name: 'concurrencycancelinprogress',
|
|
21
22
|
concurrency: {
|
|
@@ -24,6 +25,7 @@ exports.concurrencyCancelInProgressWorkflow = hatchet_client_1.hatchet.workflow(
|
|
|
24
25
|
limitStrategy: v1_1.ConcurrencyLimitStrategy.CANCEL_IN_PROGRESS,
|
|
25
26
|
},
|
|
26
27
|
});
|
|
28
|
+
// !!
|
|
27
29
|
const step1 = exports.concurrencyCancelInProgressWorkflow.task({
|
|
28
30
|
name: 'step1',
|
|
29
31
|
fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -16,6 +16,7 @@ exports.concurrencyCancelNewestWorkflow = void 0;
|
|
|
16
16
|
const sleep_1 = __importDefault(require("../../../util/sleep"));
|
|
17
17
|
const v1_1 = require("../..");
|
|
18
18
|
const hatchet_client_1 = require("../hatchet-client");
|
|
19
|
+
// > Cancel Newest
|
|
19
20
|
exports.concurrencyCancelNewestWorkflow = hatchet_client_1.hatchet.workflow({
|
|
20
21
|
name: 'concurrencycancelnewest',
|
|
21
22
|
concurrency: {
|
|
@@ -24,6 +25,7 @@ exports.concurrencyCancelNewestWorkflow = hatchet_client_1.hatchet.workflow({
|
|
|
24
25
|
limitStrategy: v1_1.ConcurrencyLimitStrategy.CANCEL_NEWEST,
|
|
25
26
|
},
|
|
26
27
|
});
|
|
28
|
+
// !!
|
|
27
29
|
const step1 = exports.concurrencyCancelNewestWorkflow.task({
|
|
28
30
|
name: 'step1',
|
|
29
31
|
fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -87,6 +87,21 @@ const waitForEvent = exports.taskConditionWorkflow.task({
|
|
|
87
87
|
},
|
|
88
88
|
});
|
|
89
89
|
// !!
|
|
90
|
+
// > Add multiple or groups
|
|
91
|
+
exports.taskConditionWorkflow.task({
|
|
92
|
+
name: 'waitForOrGroups',
|
|
93
|
+
parents: [start],
|
|
94
|
+
waitFor: [
|
|
95
|
+
(0, conditions_1.Or)(new parent_condition_1.ParentCondition(start, 'output.randomNumber > 50'), new conditions_1.SleepCondition('30s')),
|
|
96
|
+
(0, conditions_1.Or)(new parent_condition_1.ParentCondition(start, 'output.randomNumber > 50'), new conditions_1.UserEventCondition('payment:processed', 'true')),
|
|
97
|
+
],
|
|
98
|
+
fn: () => {
|
|
99
|
+
return {
|
|
100
|
+
randomNumber: Math.floor(Math.random() * 100) + 1,
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
// !!
|
|
90
105
|
// > Add sum
|
|
91
106
|
exports.taskConditionWorkflow.task({
|
|
92
107
|
name: 'sum',
|
|
@@ -32,17 +32,18 @@ const workflow_11 = require("./durable_sleep/workflow");
|
|
|
32
32
|
const workflow_12 = require("./logger/workflow");
|
|
33
33
|
const workflow_13 = require("./non_retryable/workflow");
|
|
34
34
|
const workflow_14 = require("./on_failure/workflow");
|
|
35
|
-
const workflow_15 = require("./
|
|
36
|
-
const workflow_16 = require("./
|
|
37
|
-
const workflow_17 = require("./
|
|
35
|
+
const workflow_15 = require("./idempotency/workflow");
|
|
36
|
+
const workflow_16 = require("./on_event/workflow");
|
|
37
|
+
const workflow_17 = require("./return_exceptions/workflow");
|
|
38
|
+
const workflow_18 = require("./run_details/workflow");
|
|
38
39
|
const e2e_workflows_1 = require("./simple/e2e-workflows");
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
40
|
+
const workflow_19 = require("./streaming/workflow");
|
|
41
|
+
const workflow_20 = require("./timeout/workflow");
|
|
42
|
+
const workflow_21 = require("./webhooks/workflow");
|
|
43
|
+
const workflow_22 = require("./child_index/workflow");
|
|
44
|
+
const workflow_23 = require("./support_agent/workflow");
|
|
45
|
+
const workflow_24 = require("./welcome_email/workflow");
|
|
46
|
+
const workflow_25 = require("./pdf_pipeline/workflow");
|
|
46
47
|
const workflows = [
|
|
47
48
|
workflow_1.bulkChild,
|
|
48
49
|
workflow_1.bulkParentWorkflow,
|
|
@@ -86,25 +87,27 @@ const workflows = [
|
|
|
86
87
|
(0, workflow_12.createLoggingWorkflow)(hatchet_client_1.hatchet),
|
|
87
88
|
workflow_13.nonRetryableWorkflow,
|
|
88
89
|
workflow_14.failureWorkflow,
|
|
89
|
-
workflow_15.
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
workflow_15.idempotentTask,
|
|
91
|
+
workflow_15.idempotentTaskShortWindow,
|
|
92
|
+
workflow_16.lower,
|
|
93
|
+
workflow_17.returnExceptionsTask,
|
|
94
|
+
workflow_18.runDetailTestWorkflow,
|
|
92
95
|
e2e_workflows_1.helloWorld,
|
|
93
96
|
e2e_workflows_1.helloWorldDurable,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
workflow_19.streamingTask,
|
|
98
|
+
workflow_20.timeoutTask,
|
|
99
|
+
workflow_20.refreshTimeoutTask,
|
|
100
|
+
workflow_21.webhookWorkflow,
|
|
101
|
+
workflow_22.childIndexChild,
|
|
102
|
+
workflow_22.childIndexParent,
|
|
103
|
+
workflow_22.scenarioTask,
|
|
104
|
+
workflow_22.orchestratorTask,
|
|
105
|
+
workflow_23.supportAgent,
|
|
106
|
+
workflow_23.triageTicket,
|
|
107
|
+
workflow_23.generateReply,
|
|
108
|
+
workflow_23.escalateTicket,
|
|
109
|
+
workflow_24.welcomeEmail,
|
|
110
|
+
workflow_25.pdfPipeline,
|
|
108
111
|
];
|
|
109
112
|
function main() {
|
|
110
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const v1_1 = require("../..");
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
// > trigger
|
|
17
|
+
const ref1 = yield workflow_1.idempotentTask.runNoWait({ id: '123' });
|
|
18
|
+
let runId2;
|
|
19
|
+
try {
|
|
20
|
+
const ref2 = yield workflow_1.idempotentTask.runNoWait({ id: '123' });
|
|
21
|
+
runId2 = yield ref2.getWorkflowRunId();
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
if (e instanceof v1_1.IdempotencyCollisionError) {
|
|
25
|
+
console.log(`Run with external ID ${e.existingRunExternalId} already exists for this idempotency key`);
|
|
26
|
+
runId2 = e.existingRunExternalId;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const res1 = yield ref1.result();
|
|
33
|
+
console.log(`Result: ${JSON.stringify(res1)}, run ID: ${runId2}`);
|
|
34
|
+
// !!
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const EVENT_KEY = "ts-e2e:idempotency-example";
|
|
2
|
+
export type IdempotencyInput = {
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const idempotentTask: import("../..").TaskWorkflowDeclaration<IdempotencyInput, {
|
|
6
|
+
result: string;
|
|
7
|
+
}, {}, {}, {}, {}>;
|
|
8
|
+
export declare const idempotentTaskShortWindow: import("../..").TaskWorkflowDeclaration<IdempotencyInput, {
|
|
9
|
+
result: string;
|
|
10
|
+
}, {}, {}, {}, {}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.idempotentTaskShortWindow = exports.idempotentTask = exports.EVENT_KEY = void 0;
|
|
13
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
14
|
+
exports.EVENT_KEY = 'ts-e2e:idempotency-example';
|
|
15
|
+
// > idempotency
|
|
16
|
+
exports.idempotentTask = hatchet_client_1.hatchet.task({
|
|
17
|
+
name: 'ts-e2e-idempotent-task',
|
|
18
|
+
idempotency: {
|
|
19
|
+
strategy: 'ttl',
|
|
20
|
+
expression: 'input.id',
|
|
21
|
+
ttlMs: 60000,
|
|
22
|
+
},
|
|
23
|
+
onEvents: [exports.EVENT_KEY],
|
|
24
|
+
fn: (input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
return { result: `Hello, world from task ${input.id}` };
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
// !!
|
|
29
|
+
exports.idempotentTaskShortWindow = hatchet_client_1.hatchet.task({
|
|
30
|
+
name: 'ts-e2e-idempotent-task-short-window',
|
|
31
|
+
idempotency: {
|
|
32
|
+
strategy: 'ttl',
|
|
33
|
+
expression: 'input.id',
|
|
34
|
+
ttlMs: 2000,
|
|
35
|
+
},
|
|
36
|
+
fn: (input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
return { result: `Hello, world from task ${input.id}` };
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.weenie = exports.omega = void 0;
|
|
13
|
+
// > Slot cost
|
|
14
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
15
|
+
exports.omega = hatchet_client_1.hatchet.task({
|
|
16
|
+
name: 'omega',
|
|
17
|
+
slotCost: 5,
|
|
18
|
+
fn: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
console.log('heavy work');
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
exports.weenie = hatchet_client_1.hatchet.task({
|
|
23
|
+
name: 'weenie',
|
|
24
|
+
slotCost: 1,
|
|
25
|
+
fn: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
console.log('light work');
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
// !!
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const hatchet_client_1 = require("../hatchet-client");
|
|
13
13
|
const workflow_1 = require("./workflow");
|
|
14
|
+
// > Slots
|
|
14
15
|
function main() {
|
|
15
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
const worker = yield hatchet_client_1.hatchet.worker('timeout-worker', {
|
|
@@ -20,6 +21,7 @@ function main() {
|
|
|
20
21
|
yield worker.start();
|
|
21
22
|
});
|
|
22
23
|
}
|
|
24
|
+
// !!
|
|
23
25
|
if (require.main === module) {
|
|
24
26
|
main();
|
|
25
27
|
}
|
package/v1/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export * from './slot-types';
|
|
|
12
12
|
export * from '../legacy/legacy-transformer';
|
|
13
13
|
export { NonDeterminismError } from '../util/errors/non-determinism-error';
|
|
14
14
|
export { EvictionNotSupportedError } from '../util/errors/eviction-not-supported-error';
|
|
15
|
+
export { IdempotencyCollisionError } from '../util/errors/idempotency-collision-error';
|
|
16
|
+
export { BulkTriggerIdempotencyCollisionError } from '../util/errors/bulk-trigger-idempotency-collision-error';
|
|
15
17
|
export { EvictionPolicy, DEFAULT_DURABLE_TASK_EVICTION_POLICY, } from './client/worker/eviction/eviction-policy';
|
|
16
18
|
export { DurableEvictionConfig } from './client/worker/eviction/eviction-manager';
|
|
17
19
|
export { MinEngineVersion, supportsEviction } from './client/worker/engine-version';
|
package/v1/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.supportsEviction = exports.MinEngineVersion = exports.DEFAULT_DURABLE_TASK_EVICTION_POLICY = exports.EvictionNotSupportedError = exports.NonDeterminismError = void 0;
|
|
17
|
+
exports.supportsEviction = exports.MinEngineVersion = exports.DEFAULT_DURABLE_TASK_EVICTION_POLICY = exports.BulkTriggerIdempotencyCollisionError = exports.IdempotencyCollisionError = exports.EvictionNotSupportedError = exports.NonDeterminismError = void 0;
|
|
18
18
|
__exportStar(require("./client/client"), exports);
|
|
19
19
|
__exportStar(require("./client/features"), exports);
|
|
20
20
|
__exportStar(require("./client/worker/worker"), exports);
|
|
@@ -30,6 +30,10 @@ var non_determinism_error_1 = require("../util/errors/non-determinism-error");
|
|
|
30
30
|
Object.defineProperty(exports, "NonDeterminismError", { enumerable: true, get: function () { return non_determinism_error_1.NonDeterminismError; } });
|
|
31
31
|
var eviction_not_supported_error_1 = require("../util/errors/eviction-not-supported-error");
|
|
32
32
|
Object.defineProperty(exports, "EvictionNotSupportedError", { enumerable: true, get: function () { return eviction_not_supported_error_1.EvictionNotSupportedError; } });
|
|
33
|
+
var idempotency_collision_error_1 = require("../util/errors/idempotency-collision-error");
|
|
34
|
+
Object.defineProperty(exports, "IdempotencyCollisionError", { enumerable: true, get: function () { return idempotency_collision_error_1.IdempotencyCollisionError; } });
|
|
35
|
+
var bulk_trigger_idempotency_collision_error_1 = require("../util/errors/bulk-trigger-idempotency-collision-error");
|
|
36
|
+
Object.defineProperty(exports, "BulkTriggerIdempotencyCollisionError", { enumerable: true, get: function () { return bulk_trigger_idempotency_collision_error_1.BulkTriggerIdempotencyCollisionError; } });
|
|
33
37
|
var eviction_policy_1 = require("./client/worker/eviction/eviction-policy");
|
|
34
38
|
Object.defineProperty(exports, "DEFAULT_DURABLE_TASK_EVICTION_POLICY", { enumerable: true, get: function () { return eviction_policy_1.DEFAULT_DURABLE_TASK_EVICTION_POLICY; } });
|
|
35
39
|
var engine_version_1 = require("./client/worker/engine-version");
|
package/v1/task.d.ts
CHANGED
|
@@ -36,6 +36,30 @@ export type Concurrency = {
|
|
|
36
36
|
* @deprecated use Concurrency instead
|
|
37
37
|
*/
|
|
38
38
|
export type TaskConcurrency = Concurrency;
|
|
39
|
+
/**
|
|
40
|
+
* Base type for idempotency configurations.
|
|
41
|
+
*/
|
|
42
|
+
export type BaseIdempotencyConfig = {
|
|
43
|
+
/**
|
|
44
|
+
* CEL expression to create an idempotency key from input and metadata.
|
|
45
|
+
* @example "input.id" // use the 'id' field from input as the key
|
|
46
|
+
*/
|
|
47
|
+
expression: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* TTL-based idempotency: prevents duplicate runs within a sliding time window.
|
|
51
|
+
*/
|
|
52
|
+
export type TTLBasedIdempotencyConfig = BaseIdempotencyConfig & {
|
|
53
|
+
strategy: 'ttl';
|
|
54
|
+
/**
|
|
55
|
+
* How long the idempotency key should live (in milliseconds).
|
|
56
|
+
*/
|
|
57
|
+
ttlMs: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Union of all supported idempotency configurations.
|
|
61
|
+
*/
|
|
62
|
+
export type IdempotencyConfig = TTLBasedIdempotencyConfig;
|
|
39
63
|
export declare class NonRetryableError extends Error {
|
|
40
64
|
constructor(message?: string);
|
|
41
65
|
}
|
|
@@ -120,6 +144,16 @@ export type CreateBaseTaskOpts<I extends InputType = UnknownInputType, O extends
|
|
|
120
144
|
* (optional) the concurrency options for the task
|
|
121
145
|
*/
|
|
122
146
|
concurrency?: Concurrency | Concurrency[];
|
|
147
|
+
/**
|
|
148
|
+
* (optional) the number of default worker slots this task consumes.
|
|
149
|
+
*
|
|
150
|
+
* A worker has a fixed number of slots (default 100), and a normal task consumes one. Set slotCost
|
|
151
|
+
* higher for a task that needs more memory or CPU, so a worker runs fewer of them at once. A single
|
|
152
|
+
* worker must have that many free slots to run it. Not available on durable tasks.
|
|
153
|
+
*
|
|
154
|
+
* default: 1
|
|
155
|
+
*/
|
|
156
|
+
slotCost?: number;
|
|
123
157
|
/** @internal */
|
|
124
158
|
slotRequests?: Record<string, number>;
|
|
125
159
|
};
|
|
@@ -187,7 +221,7 @@ export type CreateWorkflowTaskOpts<I extends InputType = UnknownInputType, O ext
|
|
|
187
221
|
* @template I The input type for the task function.
|
|
188
222
|
* @template O The return type of the task function (can be inferred from the return value of fn).
|
|
189
223
|
*/
|
|
190
|
-
export type CreateWorkflowDurableTaskOpts<I extends InputType = UnknownInputType, O extends OutputType = void, C extends DurableTaskFn<I, O> = DurableTaskFn<I, O>> = CreateWorkflowTaskOpts<I, O, C> & {
|
|
224
|
+
export type CreateWorkflowDurableTaskOpts<I extends InputType = UnknownInputType, O extends OutputType = void, C extends DurableTaskFn<I, O> = DurableTaskFn<I, O>> = Omit<CreateWorkflowTaskOpts<I, O, C>, 'slotCost'> & {
|
|
191
225
|
/**
|
|
192
226
|
* Eviction policy for the durable task. Controls TTL-based eviction and capacity-based eviction.
|
|
193
227
|
* Defaults to the built-in eviction policy when omitted or `undefined`.
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.26.0";
|
package/version.js
CHANGED