@hatchet-dev/typescript-sdk 1.29.2 → 1.29.3
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/util/config-loader/config-loader.js +1 -1
- package/v1/examples/e2e-worker.js +22 -19
- package/v1/examples/subscribe_to_stream/worker.d.ts +1 -0
- package/v1/examples/subscribe_to_stream/worker.js +25 -0
- package/v1/examples/subscribe_to_stream/workflow.d.ts +5 -0
- package/v1/examples/subscribe_to_stream/workflow.js +49 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/package.json
CHANGED
|
@@ -59,7 +59,7 @@ class ConfigLoader {
|
|
|
59
59
|
port: parseInt(this.env('HATCHET_CLIENT_WORKER_HEALTHCHECK_PORT') || '8001', 10),
|
|
60
60
|
};
|
|
61
61
|
if (!token) {
|
|
62
|
-
throw new Error('
|
|
62
|
+
throw new Error('API token is required. Set it via the HATCHET_CLIENT_TOKEN environment variable. For local development, you can run Hatchet embedded via HatchetEmbeddedClient.init() (imported from @hatchet-dev/typescript-sdk/v1/embedded). More docs here: https://docs.hatchet.run/v1/embedded');
|
|
63
63
|
}
|
|
64
64
|
let grpcBroadcastAddress;
|
|
65
65
|
let apiUrl;
|
|
@@ -39,12 +39,13 @@ const workflow_18 = require("./run_details/workflow");
|
|
|
39
39
|
const e2e_workflows_1 = require("./simple/e2e-workflows");
|
|
40
40
|
const workflow_19 = require("./batch_assign/workflow");
|
|
41
41
|
const workflow_20 = require("./streaming/workflow");
|
|
42
|
-
const workflow_21 = require("./
|
|
43
|
-
const workflow_22 = require("./
|
|
44
|
-
const workflow_23 = require("./
|
|
45
|
-
const workflow_24 = require("./
|
|
46
|
-
const workflow_25 = require("./
|
|
47
|
-
const workflow_26 = require("./
|
|
42
|
+
const workflow_21 = require("./subscribe_to_stream/workflow");
|
|
43
|
+
const workflow_22 = require("./timeout/workflow");
|
|
44
|
+
const workflow_23 = require("./webhooks/workflow");
|
|
45
|
+
const workflow_24 = require("./child_index/workflow");
|
|
46
|
+
const workflow_25 = require("./support_agent/workflow");
|
|
47
|
+
const workflow_26 = require("./welcome_email/workflow");
|
|
48
|
+
const workflow_27 = require("./pdf_pipeline/workflow");
|
|
48
49
|
const workflows = [
|
|
49
50
|
workflow_1.bulkChild,
|
|
50
51
|
workflow_1.bulkParentWorkflow,
|
|
@@ -96,19 +97,21 @@ const workflows = [
|
|
|
96
97
|
e2e_workflows_1.helloWorld,
|
|
97
98
|
e2e_workflows_1.helloWorldDurable,
|
|
98
99
|
workflow_20.streamingTask,
|
|
99
|
-
workflow_21.
|
|
100
|
-
workflow_21.
|
|
101
|
-
workflow_22.
|
|
102
|
-
|
|
103
|
-
workflow_23.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
workflow_24.
|
|
107
|
-
workflow_24.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
workflow_25.
|
|
111
|
-
|
|
100
|
+
workflow_21.dagStream,
|
|
101
|
+
workflow_21.longStream,
|
|
102
|
+
workflow_22.timeoutTask,
|
|
103
|
+
workflow_22.refreshTimeoutTask,
|
|
104
|
+
workflow_23.webhookWorkflow,
|
|
105
|
+
workflow_24.childIndexChild,
|
|
106
|
+
workflow_24.childIndexParent,
|
|
107
|
+
workflow_24.scenarioTask,
|
|
108
|
+
workflow_24.orchestratorTask,
|
|
109
|
+
workflow_25.supportAgent,
|
|
110
|
+
workflow_25.triageTicket,
|
|
111
|
+
workflow_25.generateReply,
|
|
112
|
+
workflow_25.escalateTicket,
|
|
113
|
+
workflow_26.welcomeEmail,
|
|
114
|
+
workflow_27.pdfPipeline,
|
|
112
115
|
workflow_19.batchSimple,
|
|
113
116
|
workflow_19.batchKeyed,
|
|
114
117
|
workflow_19.batchKeyedFailable,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
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 hatchet_client_1 = require("../hatchet-client");
|
|
13
|
+
const workflow_1 = require("./workflow");
|
|
14
|
+
function main() {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const worker = yield hatchet_client_1.hatchet.worker('subscribe-stream-worker', {
|
|
17
|
+
workflows: [workflow_1.longStream, workflow_1.dagStream],
|
|
18
|
+
slots: 8,
|
|
19
|
+
});
|
|
20
|
+
yield worker.start();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (require.main === module) {
|
|
24
|
+
main();
|
|
25
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const STREAM_CHUNKS: string[];
|
|
2
|
+
export declare const PRE_STREAM_SLEEP_MS = 2000;
|
|
3
|
+
export declare const INTER_CHUNK_MS = 50;
|
|
4
|
+
export declare const longStream: import("../..").TaskWorkflowDeclaration<import("../..").UnknownInputType, void, {}, {}, {}, {}>;
|
|
5
|
+
export declare const dagStream: import("../..").WorkflowDeclaration<import("../..").UnknownInputType, {}, {}>;
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
exports.dagStream = exports.longStream = exports.INTER_CHUNK_MS = exports.PRE_STREAM_SLEEP_MS = exports.STREAM_CHUNKS = void 0;
|
|
16
|
+
const sleep_1 = __importDefault(require("../../../util/sleep"));
|
|
17
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
18
|
+
exports.STREAM_CHUNKS = Array.from({ length: 20 }, (_, i) => `c${String(i).padStart(2, '0')}|`);
|
|
19
|
+
exports.PRE_STREAM_SLEEP_MS = 2000;
|
|
20
|
+
exports.INTER_CHUNK_MS = 50;
|
|
21
|
+
exports.longStream = hatchet_client_1.hatchet.task({
|
|
22
|
+
name: 'subscribe-stream-long',
|
|
23
|
+
fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
yield (0, sleep_1.default)(exports.PRE_STREAM_SLEEP_MS);
|
|
25
|
+
for (const chunk of exports.STREAM_CHUNKS) {
|
|
26
|
+
yield ctx.putStream(chunk);
|
|
27
|
+
yield (0, sleep_1.default)(exports.INTER_CHUNK_MS);
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
// An onFailure handler makes the run a DAG. DAG QUEUED->RUNNING used to be
|
|
32
|
+
// published as workflow-run-finished, which hung up stream subscribers as
|
|
33
|
+
// soon as the run started.
|
|
34
|
+
exports.dagStream = hatchet_client_1.hatchet.workflow({
|
|
35
|
+
name: 'subscribe-stream-dag',
|
|
36
|
+
});
|
|
37
|
+
exports.dagStream.task({
|
|
38
|
+
name: 'subscribe-stream-dag',
|
|
39
|
+
fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
yield (0, sleep_1.default)(exports.PRE_STREAM_SLEEP_MS);
|
|
41
|
+
for (const chunk of exports.STREAM_CHUNKS) {
|
|
42
|
+
yield ctx.putStream(chunk);
|
|
43
|
+
}
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
exports.dagStream.onFailure({
|
|
47
|
+
name: 'subscribe-stream-dag-on-failure',
|
|
48
|
+
fn: () => __awaiter(void 0, void 0, void 0, function* () { }),
|
|
49
|
+
});
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.29.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.29.3";
|
package/version.js
CHANGED