Skip to content

Commit 9d88bca

Browse files
committed
improve zod v3 compat
1 parent c81650d commit 9d88bca

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎packages/core/src/v3/schemas/api.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export type IdempotencyKeyOptionsSchema = z.infer<typeof IdempotencyKeyOptionsSc
272272
// with PrismaClientValidationError. Accept the intent and stringify here.
273273
const ConcurrencyKeySchema = z.union([z.string(), z.number()]).transform((value) => String(value));
274274

275-
const ExternalDeploymentId = z.preprocess((value) => {
275+
const ExternalDeploymentId: z.ZodType<string | undefined> = z.preprocess((value) => {
276276
if (typeof value !== "string") {
277277
return value;
278278
}

‎packages/core/src/v3/schemas/webhookConfig.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { z } from "zod/v4";
2+
import { discriminatedUnion } from "../utils/zod.js";
23

3-
// Ingress webhook verification config. Kept in a LEAF module (imports only `z`) so it
4-
// can be consumed by resources.ts / schemas.ts without dragging in the alert-webhook
4+
// Ingress webhook verification config. Kept in a LEAF module (imports only `z` and
5+
// the Zod compatibility helper) so it can be consumed by resources.ts / schemas.ts without dragging in the alert-webhook
56
// `Webhook` union in webhooks.ts, which imports api.js (RunStatus). resources.ts is
67
// imported by api.ts, so a resources -> webhooks -> api edge would be a module-init cycle.
78

@@ -24,7 +25,7 @@ export type WebhookIdempotencyField = z.infer<typeof WebhookIdempotencyField>;
2425
// Where a scalar value comes from. Used for the timestamp and for signing-string template vars.
2526
// "signatureField" reads a field parsed out of the signature header (e.g. Stripe `t`).
2627
// "url" is the inbound request URL (e.g. Square signs `{url}{body}`). "constant" is a literal.
27-
export const WebhookValueSource = z.discriminatedUnion("from", [
28+
export const WebhookValueSource = discriminatedUnion("from", [
2829
z.object({ from: z.literal("header"), name: z.string() }),
2930
z.object({ from: z.literal("signatureField"), field: z.string() }),
3031
z.object({ from: z.literal("body"), path: z.string() }),
@@ -133,7 +134,7 @@ export const WebhookUrlSecretConfig = z.object({
133134
});
134135
export type WebhookUrlSecretConfig = z.infer<typeof WebhookUrlSecretConfig>;
135136

136-
export const WebhookVerifierConfig = z.discriminatedUnion("scheme", [
137+
export const WebhookVerifierConfig = discriminatedUnion("scheme", [
137138
WebhookHmacConfig,
138139
WebhookSharedSecretConfig,
139140
WebhookUrlSecretConfig,
@@ -152,7 +153,7 @@ export const WebhookHandshakeConfig = z.object({
152153
export type WebhookHandshakeConfig = z.infer<typeof WebhookHandshakeConfig>;
153154

154155
// ── Verifier artifact: data-only tagged union stored on WebhookEndpoint.verifierArtifact ──
155-
export const WebhookVerifierArtifact = z.discriminatedUnion("kind", [
156+
export const WebhookVerifierArtifact = discriminatedUnion("kind", [
156157
z.object({
157158
kind: z.literal("config"),
158159
config: WebhookVerifierConfig,
@@ -173,7 +174,7 @@ export type WebhookVerifierArtifact = z.infer<typeof WebhookVerifierArtifact>;
173174
// session: keyTemplate resolves the externalId, deliverAs selects the mode. "action" (chat.event)
174175
// carries actionType → the onAction envelope's action.type; "message" (channels) carries connectorId
175176
// → the run resolves the connector's inbound() mapper and runs a turn.
176-
export const WebhookRoutingTarget = z.discriminatedUnion("type", [
177+
export const WebhookRoutingTarget = discriminatedUnion("type", [
177178
z.object({ type: z.literal("task"), taskId: z.string() }),
178179
z.object({
179180
type: z.literal("session"),

0 commit comments

Comments
 (0)