@hatchet-dev/typescript-sdk 1.25.0 → 1.26.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/dispatcher/action-listener.d.ts +1 -0
- package/clients/dispatcher/action-listener.js +5 -0
- package/clients/rest/generated/Api.d.ts +77 -3
- package/clients/rest/generated/Api.js +42 -2
- package/clients/rest/generated/data-contracts.d.ts +126 -2
- package/clients/rest/generated/data-contracts.js +26 -1
- package/opentelemetry/instrumentor.js +2 -1
- package/package.json +3 -3
- 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/context.d.ts +8 -1
- package/v1/client/worker/context.js +11 -1
- package/v1/client/worker/worker-internal.js +6 -0
- package/v1/declaration.d.ts +6 -1
- 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/index.d.ts +2 -0
- package/v1/index.js +5 -1
- package/v1/task.d.ts +24 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -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
|
+
});
|
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
|
}
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.26.1";
|
package/version.js
CHANGED