@hatchet-dev/typescript-sdk 1.21.2 → 1.22.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/clients/hatchet-client/client-config.d.ts +27 -133
- package/clients/hatchet-client/client-config.js +24 -24
- package/legacy/legacy-client.js +2 -2
- package/legacy/step.d.ts +22 -121
- package/legacy/step.js +7 -4
- package/legacy/workflow.d.ts +46 -420
- package/legacy/workflow.js +5 -5
- package/package.json +12 -6
- package/util/config-loader/config-loader.js +2 -2
- package/util/uuid.js +2 -2
- package/v1/agent/claude.d.ts +17 -0
- package/v1/agent/claude.js +83 -0
- package/v1/agent/openai.d.ts +4 -0
- package/v1/agent/openai.js +83 -0
- package/v1/client/client.js +2 -2
- package/v1/client/features/crons.d.ts +3 -15
- package/v1/client/features/crons.js +8 -8
- package/v1/client/features/schedules.d.ts +6 -20
- package/v1/client/features/schedules.js +10 -10
- package/v1/client/worker/context.d.ts +1 -1
- package/v1/client/worker/worker-internal.js +2 -2
- package/v1/declaration.d.ts +18 -1
- package/v1/declaration.js +10 -0
- package/v1/examples/agent/agent-claude.d.ts +1 -0
- package/v1/examples/agent/agent-claude.js +68 -0
- package/v1/examples/agent/agent-openai.d.ts +1 -0
- package/v1/examples/agent/agent-openai.js +72 -0
- package/v1/examples/agent/worker.d.ts +1 -0
- package/v1/examples/agent/worker.js +24 -0
- package/v1/examples/agent/workflow.d.ts +26 -0
- package/v1/examples/agent/workflow.js +48 -0
- package/v1/examples/durable/workflow.d.ts +6 -2
- package/v1/examples/durable/workflow.js +9 -6
- package/v1/examples/durable_eviction/workflow.js +6 -0
- package/v1/examples/e2e-worker.js +7 -0
- package/v1/examples/simple/run.js +5 -0
- package/v1/examples/simple/zod.d.ts +2 -6
- package/v1/examples/simple/zod.js +1 -1
- package/v1/examples/support_agent/run.d.ts +1 -0
- package/v1/examples/support_agent/run.js +42 -0
- package/v1/examples/support_agent/workflow.d.ts +43 -0
- package/v1/examples/support_agent/workflow.js +140 -0
- package/v1/examples/welcome_email/run.d.ts +1 -0
- package/v1/examples/welcome_email/run.js +40 -0
- package/v1/examples/welcome_email/workflow.d.ts +11 -0
- package/v1/examples/welcome_email/workflow.js +52 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -1,168 +1,62 @@
|
|
|
1
1
|
import { ChannelCredentials } from 'nice-grpc';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
3
|
import type { Context } from '../../v1/client/worker/context';
|
|
4
4
|
import { Logger, LogLevel } from '../../util/logger';
|
|
5
5
|
declare const ClientTLSConfigSchema: z.ZodObject<{
|
|
6
|
-
tls_strategy: z.ZodOptional<z.ZodEnum<
|
|
6
|
+
tls_strategy: z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
tls: "tls";
|
|
8
|
+
mtls: "mtls";
|
|
9
|
+
none: "none";
|
|
10
|
+
}>>;
|
|
7
11
|
cert_file: z.ZodOptional<z.ZodString>;
|
|
8
12
|
ca_file: z.ZodOptional<z.ZodString>;
|
|
9
13
|
key_file: z.ZodOptional<z.ZodString>;
|
|
10
14
|
server_name: z.ZodOptional<z.ZodString>;
|
|
11
|
-
},
|
|
12
|
-
tls_strategy?: "tls" | "mtls" | "none" | undefined;
|
|
13
|
-
cert_file?: string | undefined;
|
|
14
|
-
ca_file?: string | undefined;
|
|
15
|
-
key_file?: string | undefined;
|
|
16
|
-
server_name?: string | undefined;
|
|
17
|
-
}, {
|
|
18
|
-
tls_strategy?: "tls" | "mtls" | "none" | undefined;
|
|
19
|
-
cert_file?: string | undefined;
|
|
20
|
-
ca_file?: string | undefined;
|
|
21
|
-
key_file?: string | undefined;
|
|
22
|
-
server_name?: string | undefined;
|
|
23
|
-
}>;
|
|
15
|
+
}, z.core.$strip>;
|
|
24
16
|
export declare const OpenTelemetryConfigSchema: z.ZodObject<{
|
|
25
|
-
|
|
26
|
-
* List of attribute keys to exclude from spans.
|
|
27
|
-
* Useful for filtering sensitive or verbose data like payloads.
|
|
28
|
-
*/
|
|
29
|
-
excludedAttributes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
30
|
-
/**
|
|
31
|
-
* If true, includes the task name in the span name for task run spans.
|
|
32
|
-
* e.g., "hatchet.start_step_run.my_task" instead of "hatchet.start_step_run"
|
|
33
|
-
*/
|
|
17
|
+
excludedAttributes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
34
18
|
includeTaskNameInSpanName: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
35
|
-
},
|
|
36
|
-
excludedAttributes: string[];
|
|
37
|
-
includeTaskNameInSpanName: boolean;
|
|
38
|
-
}, {
|
|
39
|
-
excludedAttributes?: string[] | undefined;
|
|
40
|
-
includeTaskNameInSpanName?: boolean | undefined;
|
|
41
|
-
}>;
|
|
19
|
+
}, z.core.$strip>;
|
|
42
20
|
export type OpenTelemetryConfig = z.infer<typeof OpenTelemetryConfigSchema>;
|
|
43
21
|
export declare const ClientConfigSchema: z.ZodObject<{
|
|
44
22
|
token: z.ZodString;
|
|
45
23
|
tls_config: z.ZodObject<{
|
|
46
|
-
tls_strategy: z.ZodOptional<z.ZodEnum<
|
|
24
|
+
tls_strategy: z.ZodOptional<z.ZodEnum<{
|
|
25
|
+
tls: "tls";
|
|
26
|
+
mtls: "mtls";
|
|
27
|
+
none: "none";
|
|
28
|
+
}>>;
|
|
47
29
|
cert_file: z.ZodOptional<z.ZodString>;
|
|
48
30
|
ca_file: z.ZodOptional<z.ZodString>;
|
|
49
31
|
key_file: z.ZodOptional<z.ZodString>;
|
|
50
32
|
server_name: z.ZodOptional<z.ZodString>;
|
|
51
|
-
},
|
|
52
|
-
tls_strategy?: "tls" | "mtls" | "none" | undefined;
|
|
53
|
-
cert_file?: string | undefined;
|
|
54
|
-
ca_file?: string | undefined;
|
|
55
|
-
key_file?: string | undefined;
|
|
56
|
-
server_name?: string | undefined;
|
|
57
|
-
}, {
|
|
58
|
-
tls_strategy?: "tls" | "mtls" | "none" | undefined;
|
|
59
|
-
cert_file?: string | undefined;
|
|
60
|
-
ca_file?: string | undefined;
|
|
61
|
-
key_file?: string | undefined;
|
|
62
|
-
server_name?: string | undefined;
|
|
63
|
-
}>;
|
|
33
|
+
}, z.core.$strip>;
|
|
64
34
|
healthcheck: z.ZodOptional<z.ZodObject<{
|
|
65
35
|
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
66
36
|
port: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
67
|
-
},
|
|
68
|
-
port: number;
|
|
69
|
-
enabled: boolean;
|
|
70
|
-
}, {
|
|
71
|
-
port?: number | undefined;
|
|
72
|
-
enabled?: boolean | undefined;
|
|
73
|
-
}>>;
|
|
37
|
+
}, z.core.$strip>>;
|
|
74
38
|
host_port: z.ZodString;
|
|
75
39
|
api_url: z.ZodString;
|
|
76
|
-
log_level: z.ZodOptional<z.ZodEnum<
|
|
40
|
+
log_level: z.ZodOptional<z.ZodEnum<{
|
|
41
|
+
OFF: "OFF";
|
|
42
|
+
DEBUG: "DEBUG";
|
|
43
|
+
INFO: "INFO";
|
|
44
|
+
WARN: "WARN";
|
|
45
|
+
ERROR: "ERROR";
|
|
46
|
+
}>>;
|
|
77
47
|
tenant_id: z.ZodString;
|
|
78
48
|
namespace: z.ZodOptional<z.ZodString>;
|
|
79
49
|
otel: z.ZodOptional<z.ZodObject<{
|
|
80
|
-
|
|
81
|
-
* List of attribute keys to exclude from spans.
|
|
82
|
-
* Useful for filtering sensitive or verbose data like payloads.
|
|
83
|
-
*/
|
|
84
|
-
excludedAttributes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
85
|
-
/**
|
|
86
|
-
* If true, includes the task name in the span name for task run spans.
|
|
87
|
-
* e.g., "hatchet.start_step_run.my_task" instead of "hatchet.start_step_run"
|
|
88
|
-
*/
|
|
50
|
+
excludedAttributes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
89
51
|
includeTaskNameInSpanName: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
90
|
-
},
|
|
91
|
-
excludedAttributes: string[];
|
|
92
|
-
includeTaskNameInSpanName: boolean;
|
|
93
|
-
}, {
|
|
94
|
-
excludedAttributes?: string[] | undefined;
|
|
95
|
-
includeTaskNameInSpanName?: boolean | undefined;
|
|
96
|
-
}>>;
|
|
52
|
+
}, z.core.$strip>>;
|
|
97
53
|
middleware: z.ZodOptional<z.ZodObject<{
|
|
98
54
|
before: z.ZodOptional<z.ZodAny>;
|
|
99
55
|
after: z.ZodOptional<z.ZodAny>;
|
|
100
|
-
},
|
|
101
|
-
before?: any;
|
|
102
|
-
after?: any;
|
|
103
|
-
}, {
|
|
104
|
-
before?: any;
|
|
105
|
-
after?: any;
|
|
106
|
-
}>>;
|
|
56
|
+
}, z.core.$strip>>;
|
|
107
57
|
cancellation_grace_period: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
108
58
|
cancellation_warning_threshold: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
109
|
-
},
|
|
110
|
-
token: string;
|
|
111
|
-
tls_config: {
|
|
112
|
-
tls_strategy?: "tls" | "mtls" | "none" | undefined;
|
|
113
|
-
cert_file?: string | undefined;
|
|
114
|
-
ca_file?: string | undefined;
|
|
115
|
-
key_file?: string | undefined;
|
|
116
|
-
server_name?: string | undefined;
|
|
117
|
-
};
|
|
118
|
-
host_port: string;
|
|
119
|
-
api_url: string;
|
|
120
|
-
tenant_id: string;
|
|
121
|
-
cancellation_grace_period: number;
|
|
122
|
-
cancellation_warning_threshold: number;
|
|
123
|
-
healthcheck?: {
|
|
124
|
-
port: number;
|
|
125
|
-
enabled: boolean;
|
|
126
|
-
} | undefined;
|
|
127
|
-
log_level?: "OFF" | "DEBUG" | "INFO" | "WARN" | "ERROR" | undefined;
|
|
128
|
-
namespace?: string | undefined;
|
|
129
|
-
otel?: {
|
|
130
|
-
excludedAttributes: string[];
|
|
131
|
-
includeTaskNameInSpanName: boolean;
|
|
132
|
-
} | undefined;
|
|
133
|
-
middleware?: {
|
|
134
|
-
before?: any;
|
|
135
|
-
after?: any;
|
|
136
|
-
} | undefined;
|
|
137
|
-
}, {
|
|
138
|
-
token: string;
|
|
139
|
-
tls_config: {
|
|
140
|
-
tls_strategy?: "tls" | "mtls" | "none" | undefined;
|
|
141
|
-
cert_file?: string | undefined;
|
|
142
|
-
ca_file?: string | undefined;
|
|
143
|
-
key_file?: string | undefined;
|
|
144
|
-
server_name?: string | undefined;
|
|
145
|
-
};
|
|
146
|
-
host_port: string;
|
|
147
|
-
api_url: string;
|
|
148
|
-
tenant_id: string;
|
|
149
|
-
healthcheck?: {
|
|
150
|
-
port?: number | undefined;
|
|
151
|
-
enabled?: boolean | undefined;
|
|
152
|
-
} | undefined;
|
|
153
|
-
log_level?: "OFF" | "DEBUG" | "INFO" | "WARN" | "ERROR" | undefined;
|
|
154
|
-
namespace?: string | undefined;
|
|
155
|
-
otel?: {
|
|
156
|
-
excludedAttributes?: string[] | undefined;
|
|
157
|
-
includeTaskNameInSpanName?: boolean | undefined;
|
|
158
|
-
} | undefined;
|
|
159
|
-
middleware?: {
|
|
160
|
-
before?: any;
|
|
161
|
-
after?: any;
|
|
162
|
-
} | undefined;
|
|
163
|
-
cancellation_grace_period?: number | undefined;
|
|
164
|
-
cancellation_warning_threshold?: number | undefined;
|
|
165
|
-
}>;
|
|
59
|
+
}, z.core.$strip>;
|
|
166
60
|
export type LogConstructor = (context: string, logLevel?: LogLevel) => Logger;
|
|
167
61
|
/**
|
|
168
62
|
* A middleware function that runs before every task invocation.
|
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ClientConfigSchema = exports.OpenTelemetryConfigSchema = void 0;
|
|
4
|
-
const
|
|
5
|
-
const ClientTLSConfigSchema =
|
|
6
|
-
tls_strategy:
|
|
7
|
-
cert_file:
|
|
8
|
-
ca_file:
|
|
9
|
-
key_file:
|
|
10
|
-
server_name:
|
|
4
|
+
const v4_1 = require("zod/v4");
|
|
5
|
+
const ClientTLSConfigSchema = v4_1.z.object({
|
|
6
|
+
tls_strategy: v4_1.z.enum(['tls', 'mtls', 'none']).optional(),
|
|
7
|
+
cert_file: v4_1.z.string().optional(),
|
|
8
|
+
ca_file: v4_1.z.string().optional(),
|
|
9
|
+
key_file: v4_1.z.string().optional(),
|
|
10
|
+
server_name: v4_1.z.string().optional(),
|
|
11
11
|
});
|
|
12
|
-
const HealthcheckConfigSchema =
|
|
13
|
-
enabled:
|
|
14
|
-
port:
|
|
12
|
+
const HealthcheckConfigSchema = v4_1.z.object({
|
|
13
|
+
enabled: v4_1.z.boolean().optional().default(false),
|
|
14
|
+
port: v4_1.z.number().optional().default(8001),
|
|
15
15
|
});
|
|
16
|
-
exports.OpenTelemetryConfigSchema =
|
|
16
|
+
exports.OpenTelemetryConfigSchema = v4_1.z.object({
|
|
17
17
|
/**
|
|
18
18
|
* List of attribute keys to exclude from spans.
|
|
19
19
|
* Useful for filtering sensitive or verbose data like payloads.
|
|
20
20
|
*/
|
|
21
|
-
excludedAttributes:
|
|
21
|
+
excludedAttributes: v4_1.z.array(v4_1.z.string()).optional().default([]),
|
|
22
22
|
/**
|
|
23
23
|
* If true, includes the task name in the span name for task run spans.
|
|
24
24
|
* e.g., "hatchet.start_step_run.my_task" instead of "hatchet.start_step_run"
|
|
25
25
|
*/
|
|
26
|
-
includeTaskNameInSpanName:
|
|
26
|
+
includeTaskNameInSpanName: v4_1.z.boolean().optional().default(false),
|
|
27
27
|
});
|
|
28
|
-
const TaskMiddlewareSchema =
|
|
28
|
+
const TaskMiddlewareSchema = v4_1.z
|
|
29
29
|
.object({
|
|
30
|
-
before:
|
|
31
|
-
after:
|
|
30
|
+
before: v4_1.z.any().optional(),
|
|
31
|
+
after: v4_1.z.any().optional(),
|
|
32
32
|
})
|
|
33
33
|
.optional();
|
|
34
|
-
const DurationMsSchema =
|
|
35
|
-
exports.ClientConfigSchema =
|
|
36
|
-
token:
|
|
34
|
+
const DurationMsSchema = v4_1.z.number().int().nonnegative().finite();
|
|
35
|
+
exports.ClientConfigSchema = v4_1.z.object({
|
|
36
|
+
token: v4_1.z.string(),
|
|
37
37
|
tls_config: ClientTLSConfigSchema,
|
|
38
38
|
healthcheck: HealthcheckConfigSchema.optional(),
|
|
39
|
-
host_port:
|
|
40
|
-
api_url:
|
|
41
|
-
log_level:
|
|
42
|
-
tenant_id:
|
|
43
|
-
namespace:
|
|
39
|
+
host_port: v4_1.z.string(),
|
|
40
|
+
api_url: v4_1.z.string(),
|
|
41
|
+
log_level: v4_1.z.enum(['OFF', 'DEBUG', 'INFO', 'WARN', 'ERROR']).optional(),
|
|
42
|
+
tenant_id: v4_1.z.string(),
|
|
43
|
+
namespace: v4_1.z.string().optional(),
|
|
44
44
|
otel: exports.OpenTelemetryConfigSchema.optional(),
|
|
45
45
|
middleware: TaskMiddlewareSchema,
|
|
46
46
|
cancellation_grace_period: DurationMsSchema.optional().default(1000),
|
package/legacy/legacy-client.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.LegacyHatchetClient = void 0;
|
|
7
|
-
const
|
|
7
|
+
const v4_1 = require("zod/v4");
|
|
8
8
|
const config_loader_1 = require("../util/config-loader");
|
|
9
9
|
const event_client_1 = require("../clients/event/event-client");
|
|
10
10
|
const dispatcher_client_1 = require("../clients/dispatcher/dispatcher-client");
|
|
@@ -34,7 +34,7 @@ class LegacyHatchetClient {
|
|
|
34
34
|
this.config = Object.assign(Object.assign({}, valid), { logger: logConstructor });
|
|
35
35
|
}
|
|
36
36
|
catch (e) {
|
|
37
|
-
if (e instanceof
|
|
37
|
+
if (e instanceof v4_1.z.ZodError) {
|
|
38
38
|
throw new Error(`Invalid client config: ${e.message}`, { cause: e });
|
|
39
39
|
}
|
|
40
40
|
throw e;
|
package/legacy/step.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as z from 'zod';
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
2
|
import { JsonObject } from '@bufbuild/protobuf';
|
|
3
3
|
import { Workflow } from './workflow';
|
|
4
4
|
import { Action } from '../clients/dispatcher/action-listener';
|
|
@@ -7,7 +7,8 @@ import { Logger } from '../util/logger';
|
|
|
7
7
|
import WorkflowRunRef from '../util/workflow-run-ref';
|
|
8
8
|
import { WorkerLabels } from '../clients/dispatcher/dispatcher-client';
|
|
9
9
|
import { CreateStepRateLimit, RateLimitDuration } from '../protoc/workflows';
|
|
10
|
-
import { CreateWorkflowTaskOpts, Priority
|
|
10
|
+
import { CreateWorkflowTaskOpts, Priority } from '../v1';
|
|
11
|
+
import { WorkerLabelComparator } from '../v1/task';
|
|
11
12
|
import { RunOpts, TaskWorkflowDeclaration, BaseWorkflowDeclaration as WorkflowV1 } from '../v1/declaration';
|
|
12
13
|
import { Conditions } from '../v1/conditions';
|
|
13
14
|
import { Duration } from '../v1/client/duration';
|
|
@@ -18,140 +19,40 @@ export declare const CreateRateLimitSchema: z.ZodObject<{
|
|
|
18
19
|
key: z.ZodOptional<z.ZodString>;
|
|
19
20
|
staticKey: z.ZodOptional<z.ZodString>;
|
|
20
21
|
dynamicKey: z.ZodOptional<z.ZodString>;
|
|
21
|
-
units: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
|
|
22
|
-
limit: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
23
|
-
duration: z.ZodOptional<z.
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
duration?: RateLimitDuration | undefined;
|
|
28
|
-
limit?: string | number | undefined;
|
|
29
|
-
staticKey?: string | undefined;
|
|
30
|
-
dynamicKey?: string | undefined;
|
|
31
|
-
}, {
|
|
32
|
-
units: string | number;
|
|
33
|
-
key?: string | undefined;
|
|
34
|
-
duration?: RateLimitDuration | undefined;
|
|
35
|
-
limit?: string | number | undefined;
|
|
36
|
-
staticKey?: string | undefined;
|
|
37
|
-
dynamicKey?: string | undefined;
|
|
38
|
-
}>;
|
|
39
|
-
export declare const DesiredWorkerLabelSchema: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodObject<{
|
|
40
|
-
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
22
|
+
units: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
23
|
+
limit: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
24
|
+
duration: z.ZodOptional<z.ZodEnum<typeof RateLimitDuration>>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export declare const DesiredWorkerLabelSchema: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodObject<{
|
|
27
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
41
28
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
42
29
|
weight: z.ZodOptional<z.ZodNumber>;
|
|
43
|
-
comparator: z.ZodOptional<z.
|
|
44
|
-
},
|
|
45
|
-
value: string | number;
|
|
46
|
-
required?: boolean | undefined;
|
|
47
|
-
comparator?: WorkerLabelComparator | undefined;
|
|
48
|
-
weight?: number | undefined;
|
|
49
|
-
}, {
|
|
50
|
-
value: string | number;
|
|
51
|
-
required?: boolean | undefined;
|
|
52
|
-
comparator?: WorkerLabelComparator | undefined;
|
|
53
|
-
weight?: number | undefined;
|
|
54
|
-
}>]>>;
|
|
30
|
+
comparator: z.ZodOptional<z.ZodEnum<typeof WorkerLabelComparator>>;
|
|
31
|
+
}, z.core.$strip>]>>;
|
|
55
32
|
export declare const CreateStepSchema: z.ZodObject<{
|
|
56
33
|
name: z.ZodString;
|
|
57
|
-
parents: z.ZodOptional<z.ZodArray<z.ZodString
|
|
34
|
+
parents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
58
35
|
timeout: z.ZodOptional<z.ZodString>;
|
|
59
36
|
retries: z.ZodOptional<z.ZodNumber>;
|
|
60
37
|
rate_limits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
61
38
|
key: z.ZodOptional<z.ZodString>;
|
|
62
39
|
staticKey: z.ZodOptional<z.ZodString>;
|
|
63
40
|
dynamicKey: z.ZodOptional<z.ZodString>;
|
|
64
|
-
units: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
|
|
65
|
-
limit: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
66
|
-
duration: z.ZodOptional<z.
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
duration?: RateLimitDuration | undefined;
|
|
71
|
-
limit?: string | number | undefined;
|
|
72
|
-
staticKey?: string | undefined;
|
|
73
|
-
dynamicKey?: string | undefined;
|
|
74
|
-
}, {
|
|
75
|
-
units: string | number;
|
|
76
|
-
key?: string | undefined;
|
|
77
|
-
duration?: RateLimitDuration | undefined;
|
|
78
|
-
limit?: string | number | undefined;
|
|
79
|
-
staticKey?: string | undefined;
|
|
80
|
-
dynamicKey?: string | undefined;
|
|
81
|
-
}>, "many">>;
|
|
82
|
-
worker_labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodLazy<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodObject<{
|
|
83
|
-
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
41
|
+
units: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
42
|
+
limit: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
43
|
+
duration: z.ZodOptional<z.ZodEnum<typeof RateLimitDuration>>;
|
|
44
|
+
}, z.core.$strip>>>;
|
|
45
|
+
worker_labels: z.ZodOptional<z.ZodRecord<z.ZodAny, z.ZodLazy<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodObject<{
|
|
46
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
84
47
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
85
48
|
weight: z.ZodOptional<z.ZodNumber>;
|
|
86
|
-
comparator: z.ZodOptional<z.
|
|
87
|
-
},
|
|
88
|
-
value: string | number;
|
|
89
|
-
required?: boolean | undefined;
|
|
90
|
-
comparator?: WorkerLabelComparator | undefined;
|
|
91
|
-
weight?: number | undefined;
|
|
92
|
-
}, {
|
|
93
|
-
value: string | number;
|
|
94
|
-
required?: boolean | undefined;
|
|
95
|
-
comparator?: WorkerLabelComparator | undefined;
|
|
96
|
-
weight?: number | undefined;
|
|
97
|
-
}>]>>>>>;
|
|
49
|
+
comparator: z.ZodOptional<z.ZodEnum<typeof WorkerLabelComparator>>;
|
|
50
|
+
}, z.core.$strip>]>>>>>;
|
|
98
51
|
backoff: z.ZodOptional<z.ZodObject<{
|
|
99
52
|
factor: z.ZodOptional<z.ZodNumber>;
|
|
100
53
|
maxSeconds: z.ZodOptional<z.ZodNumber>;
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
maxSeconds?: number | undefined;
|
|
104
|
-
}, {
|
|
105
|
-
factor?: number | undefined;
|
|
106
|
-
maxSeconds?: number | undefined;
|
|
107
|
-
}>>;
|
|
108
|
-
}, "strip", z.ZodTypeAny, {
|
|
109
|
-
name: string;
|
|
110
|
-
timeout?: string | undefined;
|
|
111
|
-
parents?: string[] | undefined;
|
|
112
|
-
retries?: number | undefined;
|
|
113
|
-
backoff?: {
|
|
114
|
-
factor?: number | undefined;
|
|
115
|
-
maxSeconds?: number | undefined;
|
|
116
|
-
} | undefined;
|
|
117
|
-
rate_limits?: {
|
|
118
|
-
units: string | number;
|
|
119
|
-
key?: string | undefined;
|
|
120
|
-
duration?: RateLimitDuration | undefined;
|
|
121
|
-
limit?: string | number | undefined;
|
|
122
|
-
staticKey?: string | undefined;
|
|
123
|
-
dynamicKey?: string | undefined;
|
|
124
|
-
}[] | undefined;
|
|
125
|
-
worker_labels?: Record<string, string | number | {
|
|
126
|
-
value: string | number;
|
|
127
|
-
required?: boolean | undefined;
|
|
128
|
-
comparator?: WorkerLabelComparator | undefined;
|
|
129
|
-
weight?: number | undefined;
|
|
130
|
-
} | undefined> | undefined;
|
|
131
|
-
}, {
|
|
132
|
-
name: string;
|
|
133
|
-
timeout?: string | undefined;
|
|
134
|
-
parents?: string[] | undefined;
|
|
135
|
-
retries?: number | undefined;
|
|
136
|
-
backoff?: {
|
|
137
|
-
factor?: number | undefined;
|
|
138
|
-
maxSeconds?: number | undefined;
|
|
139
|
-
} | undefined;
|
|
140
|
-
rate_limits?: {
|
|
141
|
-
units: string | number;
|
|
142
|
-
key?: string | undefined;
|
|
143
|
-
duration?: RateLimitDuration | undefined;
|
|
144
|
-
limit?: string | number | undefined;
|
|
145
|
-
staticKey?: string | undefined;
|
|
146
|
-
dynamicKey?: string | undefined;
|
|
147
|
-
}[] | undefined;
|
|
148
|
-
worker_labels?: Record<string, string | number | {
|
|
149
|
-
value: string | number;
|
|
150
|
-
required?: boolean | undefined;
|
|
151
|
-
comparator?: WorkerLabelComparator | undefined;
|
|
152
|
-
weight?: number | undefined;
|
|
153
|
-
} | undefined> | undefined;
|
|
154
|
-
}>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
}, z.core.$strip>;
|
|
155
56
|
export type NextStep = {
|
|
156
57
|
[key: string]: JsonValue;
|
|
157
58
|
};
|
package/legacy/step.js
CHANGED
|
@@ -48,10 +48,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
48
48
|
exports.V0DurableContext = exports.V0Context = exports.V0ContextWorker = exports.CreateStepSchema = exports.DesiredWorkerLabelSchema = exports.CreateRateLimitSchema = void 0;
|
|
49
49
|
exports.mapRateLimit = mapRateLimit;
|
|
50
50
|
const hatchet_error_1 = __importDefault(require("../util/errors/hatchet-error"));
|
|
51
|
-
const z = __importStar(require("zod"));
|
|
51
|
+
const z = __importStar(require("zod/v4"));
|
|
52
52
|
const parse_1 = require("../util/parse");
|
|
53
53
|
const workflows_1 = require("../protoc/workflows");
|
|
54
54
|
const v1_1 = require("../v1");
|
|
55
|
+
const task_1 = require("../v1/task");
|
|
55
56
|
const declaration_1 = require("../v1/declaration");
|
|
56
57
|
const conditions_1 = require("../v1/conditions");
|
|
57
58
|
const condition_1 = require("../protoc/v1/shared/condition");
|
|
@@ -64,7 +65,7 @@ exports.CreateRateLimitSchema = z.object({
|
|
|
64
65
|
dynamicKey: z.string().optional(),
|
|
65
66
|
units: z.union([z.number().min(0), z.string()]),
|
|
66
67
|
limit: z.union([z.number().min(1), z.string()]).optional(),
|
|
67
|
-
duration: z.
|
|
68
|
+
duration: z.enum(workflows_1.RateLimitDuration).optional(),
|
|
68
69
|
});
|
|
69
70
|
exports.DesiredWorkerLabelSchema = z
|
|
70
71
|
.union([
|
|
@@ -77,7 +78,7 @@ exports.DesiredWorkerLabelSchema = z
|
|
|
77
78
|
// (optional) comparator for the label
|
|
78
79
|
// if not provided, the default is EQUAL
|
|
79
80
|
// desired COMPARATOR actual (i.e. desired > actual for GREATER_THAN)
|
|
80
|
-
comparator: z.
|
|
81
|
+
comparator: z.enum(task_1.WorkerLabelComparator).optional(),
|
|
81
82
|
}),
|
|
82
83
|
])
|
|
83
84
|
.optional();
|
|
@@ -87,7 +88,9 @@ exports.CreateStepSchema = z.object({
|
|
|
87
88
|
timeout: z.string().optional(),
|
|
88
89
|
retries: z.number().optional(),
|
|
89
90
|
rate_limits: z.array(exports.CreateRateLimitSchema).optional(),
|
|
90
|
-
worker_labels: z
|
|
91
|
+
worker_labels: z
|
|
92
|
+
.record(z.any(), z.lazy(() => exports.DesiredWorkerLabelSchema))
|
|
93
|
+
.optional(),
|
|
91
94
|
backoff: z
|
|
92
95
|
.object({
|
|
93
96
|
factor: z.number().optional(),
|