@hatchet-dev/typescript-sdk 1.33.1 → 1.34.0-alpha.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.
Files changed (64) hide show
  1. package/clients/admin/admin-client.d.ts +6 -1
  2. package/clients/admin/admin-client.js +13 -4
  3. package/clients/admin/rpc.d.ts +13 -0
  4. package/clients/admin/rpc.js +23 -0
  5. package/clients/event/event-client.d.ts +2 -1
  6. package/clients/event/event-client.js +6 -3
  7. package/clients/event/rpc.d.ts +7 -0
  8. package/clients/event/rpc.js +13 -0
  9. package/clients/rest/generated/data-contracts.d.ts +2 -0
  10. package/clients/transport/grpc-target.d.ts +19 -0
  11. package/clients/transport/grpc-target.js +85 -0
  12. package/clients/transport/index.d.ts +4 -0
  13. package/clients/transport/index.js +15 -0
  14. package/clients/transport/message-bridge.d.ts +32 -0
  15. package/clients/transport/message-bridge.js +20 -0
  16. package/clients/transport/node-transport.d.ts +50 -0
  17. package/clients/transport/node-transport.js +123 -0
  18. package/clients/transport/transport.d.ts +14 -0
  19. package/clients/transport/transport.js +24 -0
  20. package/clients/transport/ts-proto-client.d.ts +41 -0
  21. package/clients/transport/ts-proto-client.js +143 -0
  22. package/core/index.d.ts +9 -0
  23. package/core/index.js +12 -0
  24. package/dist/check-exports.mjs +171 -0
  25. package/legacy/legacy-client.d.ts +4 -0
  26. package/legacy/legacy-client.js +5 -3
  27. package/legacy/legacy-transformer.d.ts +2 -1
  28. package/legacy/legacy-transformer.js +11 -0
  29. package/legacy/workflow.d.ts +1 -1
  30. package/legacy/workflow.js +1 -1
  31. package/package.json +95 -2
  32. package/protoc/dispatcher/dispatcher.d.ts +2 -0
  33. package/protoc/dispatcher/dispatcher.js +21 -1
  34. package/protoc-es/dispatcher/dispatcher_pb.d.ts +1357 -0
  35. package/protoc-es/dispatcher/dispatcher_pb.js +371 -0
  36. package/protoc-es/events/events_pb.d.ts +294 -0
  37. package/protoc-es/events/events_pb.js +61 -0
  38. package/protoc-es/google/rpc/status_pb.d.ts +48 -0
  39. package/protoc-es/google/rpc/status_pb.js +27 -0
  40. package/protoc-es/v1/dispatcher_pb.d.ts +676 -0
  41. package/protoc-es/v1/dispatcher_pb.js +155 -0
  42. package/protoc-es/v1/shared/condition_pb.d.ts +166 -0
  43. package/protoc-es/v1/shared/condition_pb.js +68 -0
  44. package/protoc-es/v1/shared/trigger_pb.d.ts +160 -0
  45. package/protoc-es/v1/shared/trigger_pb.js +55 -0
  46. package/protoc-es/v1/workflows_pb.d.ts +995 -0
  47. package/protoc-es/v1/workflows_pb.js +280 -0
  48. package/protoc-es/workflows/workflows_pb.d.ts +715 -0
  49. package/protoc-es/workflows/workflows_pb.js +216 -0
  50. package/scripts/check-exports.mjs +171 -0
  51. package/step.js +0 -2
  52. package/util/grpc-error.d.ts +3 -1
  53. package/util/grpc-error.js +13 -4
  54. package/util/v0-deprecation-warning.d.ts +6 -13
  55. package/util/v0-deprecation-warning.js +6 -13
  56. package/v1/client/admin.d.ts +2 -1
  57. package/v1/client/admin.js +34 -114
  58. package/v1/client/client.d.ts +1 -0
  59. package/v1/client/client.js +8 -5
  60. package/v1/client/features/schedules.d.ts +1 -1
  61. package/v1/examples/concurrency-rr/workflow.js +4 -4
  62. package/version.d.ts +1 -1
  63. package/version.js +1 -1
  64. package/workflow.js +0 -2
@@ -0,0 +1,143 @@
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.createTsProtoClient = createTsProtoClient;
13
+ exports.toConnectCallOptions = toConnectCallOptions;
14
+ exports.metadataToHeaders = metadataToHeaders;
15
+ exports.headersToMetadata = headersToMetadata;
16
+ const connect_1 = require("@connectrpc/connect");
17
+ const abort_controller_x_1 = require("abort-controller-x");
18
+ const nice_grpc_common_1 = require("nice-grpc-common");
19
+ const message_bridge_1 = require("./message-bridge");
20
+ /**
21
+ * Builds the client a `ts-proto` service definition describes, with every method served by a
22
+ * Connect client for the matching protobuf-es service on `transport`. The result has the exact
23
+ * surface `nice-grpc`'s `ClientFactory.create(definition, channel)` produced: every RPC of the
24
+ * service as `(request, options?) => Promise<response>` with the SDK's `ts-proto` message types,
25
+ * so a caller holding one of the public client properties sees no difference.
26
+ *
27
+ * Both bindings are generated from the same proto, so a method's client name is the same in
28
+ * each and the protobuf-es descriptor can be looked up by it.
29
+ */
30
+ function createTsProtoClient(definition, service, transport) {
31
+ const connectClient = (0, connect_1.createClient)(service, transport);
32
+ const client = {};
33
+ for (const [key, method] of Object.entries(definition.methods)) {
34
+ const desc = service.method[key];
35
+ if (!desc) {
36
+ throw new Error(`${definition.fullName}.${method.name} has no protobuf-es descriptor; regenerate src/protoc-es`);
37
+ }
38
+ if (method.requestStream || method.responseStream) {
39
+ client[key] = () => {
40
+ throw new Error(`${definition.fullName}.${method.name} is a streaming RPC, which the unary transport does not serve`);
41
+ };
42
+ continue;
43
+ }
44
+ const requestCodec = method.requestType;
45
+ const responseCodec = method.responseType;
46
+ client[key] = (request, options) => unaryCall(() => connectClient[key]((0, message_bridge_1.toProtobufEs)(desc.input, requestCodec, request), toConnectCallOptions(options)), responseCodec, desc.output, options);
47
+ }
48
+ return client;
49
+ }
50
+ /**
51
+ * Runs one unary call with `nice-grpc`'s cancellation and deadline semantics: a signal that
52
+ * is already aborted rejects before anything is sent, an abort during the call rejects with the
53
+ * signal's reason (an `AbortError`) rather than the transport's cancellation error, and a
54
+ * deadline that has already passed rejects with `DEADLINE_EXCEEDED` without sending.
55
+ */
56
+ function unaryCall(send, responseCodec, responseSchema, options) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const signal = options === null || options === void 0 ? void 0 : options.signal;
59
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
60
+ throw abortReason(signal);
61
+ }
62
+ if ((options === null || options === void 0 ? void 0 : options.deadline) !== undefined && remainingMs(options.deadline) <= 0) {
63
+ throw new connect_1.ConnectError('the operation timed out', connect_1.Code.DeadlineExceeded);
64
+ }
65
+ let response;
66
+ try {
67
+ response = yield send();
68
+ }
69
+ catch (e) {
70
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
71
+ throw abortReason(signal);
72
+ }
73
+ throw e;
74
+ }
75
+ return (0, message_bridge_1.fromProtobufEs)(responseCodec, responseSchema, response);
76
+ });
77
+ }
78
+ function abortReason(signal) {
79
+ var _a;
80
+ return (_a = signal.reason) !== null && _a !== void 0 ? _a : new abort_controller_x_1.AbortError();
81
+ }
82
+ function remainingMs(deadline) {
83
+ const at = deadline instanceof Date ? deadline.getTime() : deadline;
84
+ return at - Date.now();
85
+ }
86
+ /**
87
+ * Translates `nice-grpc` call options to Connect's: the signal passes through, an absolute
88
+ * deadline becomes the remaining time, request metadata becomes headers and the header and
89
+ * trailer callbacks receive `Metadata` built from the response headers.
90
+ */
91
+ function toConnectCallOptions(options) {
92
+ if (!options) {
93
+ return undefined;
94
+ }
95
+ const { signal, deadline, metadata, onHeader, onTrailer } = options;
96
+ const connect = {};
97
+ if (signal) {
98
+ connect.signal = signal;
99
+ }
100
+ if (deadline !== undefined) {
101
+ connect.timeoutMs = Math.max(1, remainingMs(deadline));
102
+ }
103
+ if (metadata) {
104
+ connect.headers = metadataToHeaders(metadata);
105
+ }
106
+ if (onHeader) {
107
+ connect.onHeader = (headers) => onHeader(headersToMetadata(headers));
108
+ }
109
+ if (onTrailer) {
110
+ connect.onTrailer = (headers) => onTrailer(headersToMetadata(headers));
111
+ }
112
+ return connect;
113
+ }
114
+ /**
115
+ * gRPC metadata as HTTP headers: binary values (keys ending in `-bin`) are base64 encoded,
116
+ * which is how they travel on the wire in every gRPC implementation.
117
+ */
118
+ function metadataToHeaders(metadata) {
119
+ const headers = new Headers();
120
+ for (const [key, values] of metadata) {
121
+ for (const value of values) {
122
+ headers.append(key, typeof value === 'string' ? value : Buffer.from(value).toString('base64'));
123
+ }
124
+ }
125
+ return headers;
126
+ }
127
+ /**
128
+ * Response headers as gRPC metadata, the inverse of `metadataToHeaders`. `Headers` joins
129
+ * repeated values with a comma, so a binary header is split back into its values before each
130
+ * is decoded.
131
+ */
132
+ function headersToMetadata(headers) {
133
+ const metadata = (0, nice_grpc_common_1.Metadata)();
134
+ headers.forEach((value, key) => {
135
+ if (key.endsWith('-bin')) {
136
+ metadata.set(key, value.split(',').map((part) => new Uint8Array(Buffer.from(part.trim(), 'base64'))));
137
+ }
138
+ else {
139
+ metadata.set(key, value);
140
+ }
141
+ });
142
+ return metadata;
143
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The core entry point: the application client for runtimes without gRPC, built on the
3
+ * Connect transport seam. The entry resolves today so that `@hatchet-dev/typescript-sdk/core`
4
+ * is a stable import path; the client it exports is added on top.
5
+ *
6
+ * @module Core
7
+ */
8
+ /** Bumped whenever the surface exported from this entry changes incompatibly. */
9
+ export declare const CORE_ENTRY_VERSION = 0;
package/core/index.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /**
3
+ * The core entry point: the application client for runtimes without gRPC, built on the
4
+ * Connect transport seam. The entry resolves today so that `@hatchet-dev/typescript-sdk/core`
5
+ * is a stable import path; the client it exports is added on top.
6
+ *
7
+ * @module Core
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.CORE_ENTRY_VERSION = void 0;
11
+ /** Bumped whenever the surface exported from this entry changes incompatibly. */
12
+ exports.CORE_ENTRY_VERSION = 0;
@@ -0,0 +1,171 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable no-console */
3
+ // Verifies the package's `exports` map against the built `dist/`: every documented import
4
+ // path resolves from both a native ESM module and a CommonJS module, every directory that
5
+ // ships an `index.js` has an explicit entry (a wildcard cannot map a bare directory to its
6
+ // index), every entry's target exists, and a TypeScript consumer compiles against the
7
+ // declarations, including an explicit `.d.ts` import path.
8
+ //
9
+ // The published package root is `dist/` (`publish:ci` copies package.json there and publishes
10
+ // from it), so the map is checked from a scratch package whose node_modules links to `dist/`.
11
+ // Run after `pnpm run tsc:build` (the `check:exports` script does both).
12
+ import { spawnSync } from 'node:child_process';
13
+ import { createRequire } from 'node:module';
14
+ import {
15
+ cpSync,
16
+ existsSync,
17
+ mkdirSync,
18
+ mkdtempSync,
19
+ readFileSync,
20
+ readdirSync,
21
+ rmSync,
22
+ symlinkSync,
23
+ writeFileSync,
24
+ } from 'node:fs';
25
+ import { tmpdir } from 'node:os';
26
+ import { dirname, join, resolve } from 'node:path';
27
+ import { fileURLToPath, pathToFileURL } from 'node:url';
28
+
29
+ const PACKAGE = '@hatchet-dev/typescript-sdk';
30
+
31
+ // Import paths users and the serverless package rely on, with and without the `.js` suffix.
32
+ const DOCUMENTED_SUBPATHS = [
33
+ '.',
34
+ './v1',
35
+ './edge',
36
+ './edge/index.js',
37
+ './core',
38
+ './clients/hatchet-client',
39
+ './v1/client/client.js',
40
+ './protoc/dispatcher/dispatcher',
41
+ ];
42
+
43
+ // Type-only imports a consumer's TypeScript may use: the explicit declaration-file path a
44
+ // `types` condition cannot produce on its own (`./*` would append `.d.ts` twice), next to the
45
+ // bare, `.js`-suffixed and directory-entry forms.
46
+ const TYPE_CONSUMER = [
47
+ "import type { ClientConfig } from '@hatchet-dev/typescript-sdk/clients/hatchet-client/client-config.d.ts';",
48
+ "import type { HatchetClient } from '@hatchet-dev/typescript-sdk/v1';",
49
+ "import type { AdminClient } from '@hatchet-dev/typescript-sdk/v1/client/admin';",
50
+ "import type { EventClient } from '@hatchet-dev/typescript-sdk/clients/event/event-client.js';",
51
+ 'export type Consumer = [ClientConfig, HatchetClient, AdminClient, EventClient];',
52
+ '',
53
+ ].join('\n');
54
+ const TYPE_RESOLUTIONS = ['node16', 'bundler'];
55
+
56
+ const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
57
+ const dist = join(root, 'dist');
58
+ const tsc = join(root, 'node_modules', 'typescript', 'bin', 'tsc');
59
+
60
+ if (!existsSync(join(dist, 'index.js'))) {
61
+ console.error(`dist is not built: ${dist}/index.js is missing. Run \`pnpm run tsc:build\` first.`);
62
+ process.exit(1);
63
+ }
64
+
65
+ const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
66
+ const exportsMap = pkg.exports ?? {};
67
+ const explicitSubpaths = Object.keys(exportsMap).filter((k) => !k.includes('*'));
68
+ const failures = [];
69
+
70
+ function indexDirectories(dir, prefix = '.') {
71
+ const out = [];
72
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
73
+ if (!entry.isDirectory()) continue;
74
+ const sub = `${prefix}/${entry.name}`;
75
+ if (existsSync(join(dir, entry.name, 'index.js'))) out.push(sub);
76
+ out.push(...indexDirectories(join(dir, entry.name), sub));
77
+ }
78
+ return out;
79
+ }
80
+
81
+ for (const sub of indexDirectories(dist)) {
82
+ if (!(sub in exportsMap)) {
83
+ failures.push(`${sub} ships an index.js but has no explicit "exports" entry`);
84
+ }
85
+ }
86
+
87
+ for (const sub of explicitSubpaths) {
88
+ const target = exportsMap[sub];
89
+ const files = typeof target === 'string' ? [target] : Object.values(target);
90
+ for (const file of files) {
91
+ if (file !== './package.json' && !existsSync(join(dist, file))) {
92
+ failures.push(`"${sub}" target ${file} does not exist in dist`);
93
+ }
94
+ }
95
+ }
96
+
97
+ const scratch = mkdtempSync(join(tmpdir(), 'hatchet-check-exports-'));
98
+ try {
99
+ // The published layout: package.json next to the build output, reached through node_modules.
100
+ cpSync(join(root, 'package.json'), join(dist, 'package.json'));
101
+ mkdirSync(join(scratch, 'node_modules', '@hatchet-dev'), { recursive: true });
102
+ symlinkSync(dist, join(scratch, 'node_modules', '@hatchet-dev', 'typescript-sdk'), 'dir');
103
+
104
+ const esmDir = join(scratch, 'esm');
105
+ const cjsDir = join(scratch, 'cjs');
106
+ mkdirSync(esmDir);
107
+ mkdirSync(cjsDir);
108
+ writeFileSync(join(esmDir, 'package.json'), '{ "type": "module" }\n');
109
+ writeFileSync(join(cjsDir, 'package.json'), '{ "type": "commonjs" }\n');
110
+ const cjsRequire = createRequire(join(cjsDir, 'probe.js'));
111
+
112
+ const subpaths = [...new Set([...DOCUMENTED_SUBPATHS, ...explicitSubpaths])];
113
+ for (const [i, sub] of subpaths.entries()) {
114
+ const specifier = sub === '.' ? PACKAGE : `${PACKAGE}/${sub.slice(2)}`;
115
+
116
+ const probe = join(esmDir, `probe-${i}.mjs`);
117
+ const attributes = sub === './package.json' ? ' with { type: "json" }' : '';
118
+ writeFileSync(probe, `import ${JSON.stringify(specifier)}${attributes};\n`);
119
+ try {
120
+ await import(pathToFileURL(probe).href);
121
+ } catch (e) {
122
+ failures.push(`ESM import of ${specifier} failed: ${e.message}`);
123
+ }
124
+
125
+ try {
126
+ cjsRequire(specifier);
127
+ } catch (e) {
128
+ failures.push(`CJS require of ${specifier} failed: ${e.message}`);
129
+ }
130
+ }
131
+
132
+ const typesDir = join(scratch, 'types');
133
+ mkdirSync(typesDir);
134
+ writeFileSync(join(typesDir, 'consumer.ts'), TYPE_CONSUMER);
135
+ for (const moduleResolution of TYPE_RESOLUTIONS) {
136
+ const tsconfig = join(typesDir, `tsconfig.${moduleResolution}.json`);
137
+ writeFileSync(
138
+ tsconfig,
139
+ JSON.stringify({
140
+ compilerOptions: {
141
+ target: 'ES2022',
142
+ module: moduleResolution === 'bundler' ? 'ESNext' : moduleResolution,
143
+ moduleResolution,
144
+ strict: true,
145
+ noEmit: true,
146
+ skipLibCheck: true,
147
+ types: [],
148
+ },
149
+ files: ['consumer.ts'],
150
+ })
151
+ );
152
+ const result = spawnSync(process.execPath, [tsc, '-p', tsconfig], { encoding: 'utf8' });
153
+ if (result.status !== 0) {
154
+ failures.push(
155
+ `type consumer (moduleResolution ${moduleResolution}) failed:\n${result.stdout}${result.stderr}`
156
+ );
157
+ }
158
+ }
159
+ } finally {
160
+ rmSync(scratch, { recursive: true, force: true });
161
+ }
162
+
163
+ if (failures.length) {
164
+ console.error('exports map check failed:');
165
+ for (const f of failures) console.error(` ${f}`);
166
+ process.exit(1);
167
+ }
168
+
169
+ console.log(
170
+ `exports map resolves ${DOCUMENTED_SUBPATHS.length} documented and ${explicitSubpaths.length} explicit subpaths from ESM and CJS, and a type consumer compiles under ${TYPE_RESOLUTIONS.join(' and ')}`
171
+ );
@@ -9,9 +9,13 @@ import { ClientConfig } from '../clients/hatchet-client/client-config';
9
9
  import { RunListenerClient } from '../clients/listeners/run-listener/child-listener-client';
10
10
  import { Api } from '../clients/rest/generated/Api';
11
11
  import { DurableListenerClient } from '../clients/listeners/durable-listener/durable-listener-client';
12
+ import { type Transport } from '../clients/transport';
12
13
  export interface HatchetClientOptions {
13
14
  config_path?: string;
15
+ /** Credentials for the streaming gRPC channel. Unary calls derive their TLS settings from `tls_config`. */
14
16
  credentials?: ChannelCredentials;
17
+ /** The transport unary calls go over; defaults to the Node gRPC transport built from the config. */
18
+ transport?: Transport;
15
19
  }
16
20
  export declare class LegacyHatchetClient {
17
21
  config: ClientConfig;
@@ -16,11 +16,12 @@ const client_config_1 = require("../clients/hatchet-client/client-config");
16
16
  const child_listener_client_1 = require("../clients/listeners/run-listener/child-listener-client");
17
17
  const rest_1 = __importDefault(require("../clients/rest"));
18
18
  const durable_listener_client_1 = require("../clients/listeners/durable-listener/durable-listener-client");
19
+ const transport_1 = require("../clients/transport");
19
20
  class LegacyHatchetClient {
20
21
  constructor(config, options, axiosOpts, runs, listener, event, dispatcher, logger, durableListener) {
21
22
  // Initializes a new Client instance.
22
23
  // Loads config in the following order: config param > yaml file > env vars
23
- var _a;
24
+ var _a, _b;
24
25
  this.runs = runs;
25
26
  const loaded = config_loader_1.ConfigLoader.loadClientConfig(config, {
26
27
  path: options === null || options === void 0 ? void 0 : options.config_path,
@@ -42,18 +43,19 @@ class LegacyHatchetClient {
42
43
  this.credentials =
43
44
  (_a = options === null || options === void 0 ? void 0 : options.credentials) !== null && _a !== void 0 ? _a : config_loader_1.ConfigLoader.createCredentials(this.config.tls_config);
44
45
  const clientFactory = (0, nice_grpc_1.createClientFactory)().use((0, grpc_helpers_1.addTokenMiddleware)(this.config.token));
46
+ const transport = (_b = options === null || options === void 0 ? void 0 : options.transport) !== null && _b !== void 0 ? _b : (0, transport_1.createNodeTransport)(this.config);
45
47
  this.tenantId = this.config.tenant_id;
46
48
  this.api = (0, rest_1.default)(this.config.api_url, this.config.token, axiosOpts);
47
49
  this.event =
48
50
  event ||
49
- new event_client_1.EventClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory, this.api);
51
+ new event_client_1.EventClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory, this.api, transport);
50
52
  this.dispatcher =
51
53
  dispatcher ||
52
54
  new dispatcher_client_1.DispatcherClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory);
53
55
  this.listener =
54
56
  listener ||
55
57
  new child_listener_client_1.RunListenerClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory, this.api);
56
- this.admin = new admin_client_1.AdminClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory, this.api, this.tenantId, this.listener, this.runs);
58
+ this.admin = new admin_client_1.AdminClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory, this.api, this.tenantId, this.listener, this.runs, transport);
57
59
  this.durableListener =
58
60
  durableListener ||
59
61
  new durable_listener_client_1.DurableListenerClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory);
@@ -6,7 +6,8 @@ export type { Workflow as LegacyWorkflow } from './workflow';
6
6
  */
7
7
  export declare function isLegacyWorkflow(workflow: unknown): workflow is Workflow;
8
8
  /**
9
- * Emits a deprecation warning for legacy workflow usage.
9
+ * Warns once per process that a v0 workflow is in use: the banner for the terminal and a
10
+ * DeprecationWarning with a stable code that Node's warning flags and handlers can filter.
10
11
  */
11
12
  export declare function warnLegacyWorkflow(): void;
12
13
  /**
@@ -6,6 +6,7 @@ exports.transformLegacyWorkflow = transformLegacyWorkflow;
6
6
  exports.normalizeWorkflow = normalizeWorkflow;
7
7
  exports.normalizeWorkflows = normalizeWorkflows;
8
8
  exports.getWorkflowName = getWorkflowName;
9
+ const v0_deprecation_warning_1 = require("../util/v0-deprecation-warning");
9
10
  const step_1 = require("./step");
10
11
  const declaration_1 = require("../v1/declaration");
11
12
  const LEGACY_WORKFLOW_WARNING = [
@@ -34,8 +35,18 @@ function isLegacyWorkflow(workflow) {
34
35
  /**
35
36
  * Emits a deprecation warning for legacy workflow usage.
36
37
  */
38
+ let warnedLegacyWorkflow = false;
39
+ /**
40
+ * Warns once per process that a v0 workflow is in use: the banner for the terminal and a
41
+ * DeprecationWarning with a stable code that Node's warning flags and handlers can filter.
42
+ */
37
43
  function warnLegacyWorkflow() {
44
+ if (warnedLegacyWorkflow) {
45
+ return;
46
+ }
47
+ warnedLegacyWorkflow = true;
38
48
  console.warn(LEGACY_WORKFLOW_WARNING);
49
+ (0, v0_deprecation_warning_1.emitV0RemovedWarning)('workflow');
39
50
  }
40
51
  /**
41
52
  * Transforms a legacy v0 Workflow into a v1 WorkflowDeclaration.
@@ -1,5 +1,5 @@
1
1
  import * as z from 'zod/v4';
2
- import { CreateStep } from '../step';
2
+ import { CreateStep } from './step';
3
3
  import { ConcurrencyLimitStrategy as PbConcurrencyLimitStrategy, StickyStrategy as PbStickyStrategy } from '../protoc/v1/workflows';
4
4
  declare const StepsSchema: z.ZodArray<z.ZodObject<{
5
5
  name: z.ZodString;
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.CreateWorkflowSchema = exports.StickyStrategy = exports.HatchetTimeoutSchema = exports.WorkflowConcurrency = exports.ConcurrencyLimitStrategy = void 0;
37
37
  const z = __importStar(require("zod/v4"));
38
- const step_1 = require("../step");
38
+ const step_1 = require("./step");
39
39
  const workflows_1 = require("../protoc/v1/workflows");
40
40
  const CronConfigSchema = z.object({
41
41
  cron: z.string(),
package/package.json CHANGED
@@ -1,11 +1,99 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "1.33.1",
3
+ "version": "1.34.0-alpha.0",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },
7
7
  "description": "Background task orchestration & visibility for developers",
8
8
  "types": "index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./index.d.ts",
12
+ "default": "./index.js"
13
+ },
14
+ "./v1": {
15
+ "types": "./v1/index.d.ts",
16
+ "default": "./v1/index.js"
17
+ },
18
+ "./edge": {
19
+ "types": "./edge/index.d.ts",
20
+ "default": "./edge/index.js"
21
+ },
22
+ "./core": {
23
+ "types": "./core/index.d.ts",
24
+ "default": "./core/index.js"
25
+ },
26
+ "./clients/admin": {
27
+ "types": "./clients/admin/index.d.ts",
28
+ "default": "./clients/admin/index.js"
29
+ },
30
+ "./clients/hatchet-client": {
31
+ "types": "./clients/hatchet-client/index.d.ts",
32
+ "default": "./clients/hatchet-client/index.js"
33
+ },
34
+ "./clients/rest": {
35
+ "types": "./clients/rest/index.d.ts",
36
+ "default": "./clients/rest/index.js"
37
+ },
38
+ "./clients/transport": {
39
+ "types": "./clients/transport/index.d.ts",
40
+ "default": "./clients/transport/index.js"
41
+ },
42
+ "./opentelemetry": {
43
+ "types": "./opentelemetry/index.d.ts",
44
+ "default": "./opentelemetry/index.js"
45
+ },
46
+ "./protoc/dispatcher": {
47
+ "types": "./protoc/dispatcher/index.d.ts",
48
+ "default": "./protoc/dispatcher/index.js"
49
+ },
50
+ "./protoc/events": {
51
+ "types": "./protoc/events/index.d.ts",
52
+ "default": "./protoc/events/index.js"
53
+ },
54
+ "./protoc/workflows": {
55
+ "types": "./protoc/workflows/index.d.ts",
56
+ "default": "./protoc/workflows/index.js"
57
+ },
58
+ "./util/config-loader": {
59
+ "types": "./util/config-loader/index.d.ts",
60
+ "default": "./util/config-loader/index.js"
61
+ },
62
+ "./util/logger": {
63
+ "types": "./util/logger/index.d.ts",
64
+ "default": "./util/logger/index.js"
65
+ },
66
+ "./v1/client/features": {
67
+ "types": "./v1/client/features/index.d.ts",
68
+ "default": "./v1/client/features/index.js"
69
+ },
70
+ "./v1/client/worker/deprecated": {
71
+ "types": "./v1/client/worker/deprecated/index.d.ts",
72
+ "default": "./v1/client/worker/deprecated/index.js"
73
+ },
74
+ "./v1/client/worker/eviction": {
75
+ "types": "./v1/client/worker/eviction/index.d.ts",
76
+ "default": "./v1/client/worker/eviction/index.js"
77
+ },
78
+ "./v1/conditions": {
79
+ "types": "./v1/conditions/index.d.ts",
80
+ "default": "./v1/conditions/index.js"
81
+ },
82
+ "./package.json": "./package.json",
83
+ "./*.d.ts": "./*.d.ts",
84
+ "./*.js": {
85
+ "types": "./*.d.ts",
86
+ "default": "./*.js"
87
+ },
88
+ "./*/index": {
89
+ "types": "./*/index.d.ts",
90
+ "default": "./*/index.js"
91
+ },
92
+ "./*": {
93
+ "types": "./*.d.ts",
94
+ "default": "./*.js"
95
+ }
96
+ },
9
97
  "files": [
10
98
  "*",
11
99
  "!**/*.test.js",
@@ -38,6 +126,7 @@
38
126
  "devDependencies": {
39
127
  "@anthropic-ai/claude-agent-sdk": "^0.3.148",
40
128
  "@aws-sdk/client-s3": "^3.1042.0",
129
+ "@bufbuild/protoc-gen-es": "^2.15.0",
41
130
  "@eslint/js": "^10.0.1",
42
131
  "@grpc/grpc-js": "^1.14.3",
43
132
  "@modelcontextprotocol/sdk": "^1.29.0",
@@ -77,7 +166,9 @@
77
166
  "typescript-eslint": "^8.56.1"
78
167
  },
79
168
  "dependencies": {
80
- "@bufbuild/protobuf": "^2.11.0",
169
+ "@bufbuild/protobuf": "^2.15.0",
170
+ "@connectrpc/connect": "~2.1.2",
171
+ "@connectrpc/connect-node": "~2.1.2",
81
172
  "@types/qs": "^6.15.0",
82
173
  "abort-controller-x": "^0.5.0",
83
174
  "axios": "^1.15.2",
@@ -145,11 +236,13 @@
145
236
  "tsc:build": "pnpm run dump-version && tsc && resolve-tspaths",
146
237
  "test:unit": "jest --testMatch='**/*.test.ts'",
147
238
  "check:edge": "pnpm run tsc:build && node scripts/check-edge-entry.mjs",
239
+ "check:exports": "pnpm run tsc:build && node scripts/check-exports.mjs",
148
240
  "test:e2e": "jest --config jest.e2e.config.ts --silent --forceExit --runInBand",
149
241
  "test:unit:watch": "jest --testMatch='**/*.test.ts' --watch",
150
242
  "generate": "pnpm run '/generate-.*/'",
151
243
  "generate-api": "npx swagger-typescript-api@13.2.7 generate -p ../../bin/oas/openapi.yaml -o ./src/clients/rest/generated -n hatchet.ts --modular --axios",
152
244
  "generate-protoc": "./generate-protoc.sh",
245
+ "generate-protoc-es": "./generate-protoc-es.sh",
153
246
  "lint:check": "pnpm run eslint:check && pnpm run prettier:check",
154
247
  "lint:fix": "pnpm run eslint:fix && pnpm run prettier:fix",
155
248
  "eslint:check": "eslint \"{src,tests}/**/*.{ts,tsx,js}\"",
@@ -194,6 +194,8 @@ export interface AssignedAction {
194
194
  batchStartPayload?: BatchStartPayload | undefined;
195
195
  /** (optional) the partition key used for batching */
196
196
  batchKey?: string | undefined;
197
+ /** (optional) inserted_at of the assigned task. The DAG operator uses this to prune durable log partitions. */
198
+ taskInsertedAt?: Date | undefined;
197
199
  }
198
200
  export interface BatchStartPayload {
199
201
  triggerReason: string;
@@ -1281,6 +1281,7 @@ function createBaseAssignedAction() {
1281
1281
  batchIndex: undefined,
1282
1282
  batchStartPayload: undefined,
1283
1283
  batchKey: undefined,
1284
+ taskInsertedAt: undefined,
1284
1285
  };
1285
1286
  }
1286
1287
  exports.AssignedAction = {
@@ -1369,6 +1370,9 @@ exports.AssignedAction = {
1369
1370
  if (message.batchKey !== undefined) {
1370
1371
  writer.uint32(226).string(message.batchKey);
1371
1372
  }
1373
+ if (message.taskInsertedAt !== undefined) {
1374
+ timestamp_1.Timestamp.encode(toTimestamp(message.taskInsertedAt), writer.uint32(234).fork()).join();
1375
+ }
1372
1376
  return writer;
1373
1377
  },
1374
1378
  decode(input, length) {
@@ -1574,6 +1578,13 @@ exports.AssignedAction = {
1574
1578
  message.batchKey = reader.string();
1575
1579
  continue;
1576
1580
  }
1581
+ case 29: {
1582
+ if (tag !== 234) {
1583
+ break;
1584
+ }
1585
+ message.taskInsertedAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
1586
+ continue;
1587
+ }
1577
1588
  }
1578
1589
  if ((tag & 7) === 4 || tag === 0) {
1579
1590
  break;
@@ -1702,6 +1713,11 @@ exports.AssignedAction = {
1702
1713
  ? exports.BatchStartPayload.fromJSON(object.batchStartPayload)
1703
1714
  : undefined,
1704
1715
  batchKey: isSet(object.batchKey) ? globalThis.String(object.batchKey) : undefined,
1716
+ taskInsertedAt: isSet(object.taskInsertedAt)
1717
+ ? fromJsonTimestamp(object.taskInsertedAt)
1718
+ : isSet(object.task_inserted_at)
1719
+ ? fromJsonTimestamp(object.task_inserted_at)
1720
+ : undefined,
1705
1721
  };
1706
1722
  },
1707
1723
  toJSON(message) {
@@ -1790,13 +1806,16 @@ exports.AssignedAction = {
1790
1806
  if (message.batchKey !== undefined) {
1791
1807
  obj.batchKey = message.batchKey;
1792
1808
  }
1809
+ if (message.taskInsertedAt !== undefined) {
1810
+ obj.taskInsertedAt = message.taskInsertedAt.toISOString();
1811
+ }
1793
1812
  return obj;
1794
1813
  },
1795
1814
  create(base) {
1796
1815
  return exports.AssignedAction.fromPartial(base !== null && base !== void 0 ? base : {});
1797
1816
  },
1798
1817
  fromPartial(object) {
1799
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
1818
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
1800
1819
  const message = createBaseAssignedAction();
1801
1820
  message.tenantId = (_a = object.tenantId) !== null && _a !== void 0 ? _a : '';
1802
1821
  message.workflowRunId = (_b = object.workflowRunId) !== null && _b !== void 0 ? _b : '';
@@ -1829,6 +1848,7 @@ exports.AssignedAction = {
1829
1848
  ? exports.BatchStartPayload.fromPartial(object.batchStartPayload)
1830
1849
  : undefined;
1831
1850
  message.batchKey = (_2 = object.batchKey) !== null && _2 !== void 0 ? _2 : undefined;
1851
+ message.taskInsertedAt = (_3 = object.taskInsertedAt) !== null && _3 !== void 0 ? _3 : undefined;
1832
1852
  return message;
1833
1853
  },
1834
1854
  };