Skip to content

Commit 498e379

Browse files
committed
fix ci
1 parent d884c03 commit 498e379

18 files changed

Lines changed: 105 additions & 115 deletions

File tree

packages/core/src/v3/apiClient/core.ts

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ import { SemanticInternalAttributes } from "../semanticInternalAttributes.js";
1313
import type { TriggerTracer } from "../tracer.js";
1414
import { randomUUID } from "../utils/crypto.js";
1515
import { accessoryAttributes } from "../utils/styleAttributes.js";
16-
import type {
17-
AnyZodSchema,
18-
inferZodSchemaOutput,
19-
} from "../types/schemas.js";
16+
import type { AnyZodSchema, inferZodSchemaOutput } from "../types/schemas.js";
2017
import type {
2118
CursorPageParams,
2219
CursorPageResponse,
@@ -106,21 +103,22 @@ export function zodfetchCursorPage<TItemSchema extends AnyZodSchema>(
106103
query.set("page[before]", params.before);
107104
}
108105

109-
const cursorPageSchema = "_zod" in schema
110-
? z.object({
111-
data: z.array(schema as any),
112-
pagination: z.object({
113-
next: z.string().optional(),
114-
previous: z.string().optional(),
115-
}),
116-
})
117-
: z3.object({
118-
data: z3.array(schema as any),
119-
pagination: z3.object({
120-
next: z3.string().optional(),
121-
previous: z3.string().optional(),
122-
}),
123-
});
106+
const cursorPageSchema =
107+
"_zod" in schema
108+
? z.object({
109+
data: z.array(schema as any),
110+
pagination: z.object({
111+
next: z.string().optional(),
112+
previous: z.string().optional(),
113+
}),
114+
})
115+
: z3.object({
116+
data: z3.array(schema as any),
117+
pagination: z3.object({
118+
next: z3.string().optional(),
119+
previous: z3.string().optional(),
120+
}),
121+
});
124122

125123
const $url = new URL(url);
126124
$url.search = query.toString();
@@ -147,23 +145,24 @@ export function zodfetchOffsetLimitPage<TItemSchema extends AnyZodSchema>(
147145
query.set("page", String(params.page));
148146
}
149147

150-
const offsetLimitPageSchema = "_zod" in schema
151-
? z.object({
152-
data: z.array(schema as any),
153-
pagination: z.object({
154-
currentPage: z.coerce.number(),
155-
totalPages: z.coerce.number(),
156-
count: z.coerce.number(),
157-
}),
158-
})
159-
: z3.object({
160-
data: z3.array(schema as any),
161-
pagination: z3.object({
162-
currentPage: z3.coerce.number(),
163-
totalPages: z3.coerce.number(),
164-
count: z3.coerce.number(),
165-
}),
166-
});
148+
const offsetLimitPageSchema =
149+
"_zod" in schema
150+
? z.object({
151+
data: z.array(schema as any),
152+
pagination: z.object({
153+
currentPage: z.coerce.number(),
154+
totalPages: z.coerce.number(),
155+
count: z.coerce.number(),
156+
}),
157+
})
158+
: z3.object({
159+
data: z3.array(schema as any),
160+
pagination: z3.object({
161+
currentPage: z3.coerce.number(),
162+
totalPages: z3.coerce.number(),
163+
count: z3.coerce.number(),
164+
}),
165+
});
167166

168167
const $url = new URL(url);
169168
$url.search = query.toString();
@@ -670,8 +669,7 @@ function injectRequestIdempotencyKey(
670669
};
671670
}
672671

673-
export type ZodFetchSSEMessageValueSchema<TSchema extends AnyZodSchema = AnyZodSchema> =
674-
TSchema;
672+
export type ZodFetchSSEMessageValueSchema<TSchema extends AnyZodSchema = AnyZodSchema> = TSchema;
675673

676674
export interface ZodFetchSSEMessageCatalogSchema {
677675
[key: string]: AnyZodSchema;

packages/core/src/v3/apiClient/stream.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import type {
2-
AnyZodSchema,
3-
inferZodSchemaOutput,
4-
} from "../types/schemas.js";
1+
import type { AnyZodSchema, inferZodSchemaOutput } from "../types/schemas.js";
52
import {
63
type Offset,
74
FetchError,

packages/core/src/v3/errors.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { TaskMetadataFailedToParseData } from "./schemas/messages.js";
88
import { links } from "./links.js";
99
import type { ExceptionEventProperties } from "./schemas/openTelemetry.js";
1010
import { assertExhaustive } from "../utils.js";
11+
import type { ZodIssueLike } from "./types/schemas.js";
1112

1213
/**
1314
* If you throw this, it will get converted into an INTERNAL_ERROR
@@ -484,7 +485,7 @@ function correctStackTraceLine(line: string, projectDir?: string, isDev?: boolea
484485
return line.trim();
485486
}
486487

487-
export function groupTaskMetadataIssuesByTask(tasks: any, issues: z.ZodIssue[]) {
488+
export function groupTaskMetadataIssuesByTask(tasks: any, issues: ReadonlyArray<ZodIssueLike>) {
488489
return issues.reduce(
489490
(acc, issue) => {
490491
if (issue.path.length === 0) {
@@ -553,7 +554,7 @@ export class UncaughtExceptionError extends Error {
553554

554555
export class TaskMetadataParseError extends Error {
555556
constructor(
556-
public readonly zodIssues: z.ZodIssue[],
557+
public readonly zodIssues: ReadonlyArray<ZodIssueLike>,
557558
public readonly tasks: any
558559
) {
559560
super(`Failed to parse task metadata`);

packages/core/src/v3/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export {
8585
type AnySchemaParseFn,
8686
type AnyZodSchema,
8787
type SchemaParseFn,
88+
type ZodErrorLike,
89+
type ZodIssueLike,
8890
type inferSchemaOut,
8991
type inferZodSchemaInput,
9092
type inferZodSchemaOutput,

packages/core/src/v3/runEngineWorker/supervisor/http.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ import { wrapZodFetch, type ApiResult, type ZodFetchOptions } from "../../zodfet
2727
import { createHeaders } from "../util.js";
2828
import { WORKER_HEADERS } from "../consts.js";
2929
import { SimpleStructuredLogger } from "../../utils/structuredLogger.js";
30-
import type {
31-
AnyZodSchema,
32-
inferZodSchemaOutput,
33-
} from "../../types/schemas.js";
30+
import type { AnyZodSchema, inferZodSchemaOutput } from "../../types/schemas.js";
3431

3532
type SupervisorHttpClientOptions = SupervisorClientCommonOptions;
3633

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

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,20 +1304,19 @@ const BulkActionSelectionRequestBody = {
13041304
};
13051305

13061306
export const CreateBulkActionRequestBody = discriminatedUnion("action", [
1307-
z.object({
1308-
action: z.literal("cancel"),
1309-
targetRegion: z.never().optional(),
1310-
...BulkActionSelectionRequestBody,
1311-
}),
1312-
z.object({
1313-
action: z.literal("replay"),
1314-
targetRegion: z.string().optional(),
1315-
...BulkActionSelectionRequestBody,
1316-
}),
1317-
])
1318-
.refine((body) => (body.filter ? 1 : 0) + (body.runIds ? 1 : 0) === 1, {
1319-
message: "Exactly one of filter or runIds must be provided",
1320-
});
1307+
z.object({
1308+
action: z.literal("cancel"),
1309+
targetRegion: z.never().optional(),
1310+
...BulkActionSelectionRequestBody,
1311+
}),
1312+
z.object({
1313+
action: z.literal("replay"),
1314+
targetRegion: z.string().optional(),
1315+
...BulkActionSelectionRequestBody,
1316+
}),
1317+
]).refine((body) => (body.filter ? 1 : 0) + (body.runIds ? 1 : 0) === 1, {
1318+
message: "Exactly one of filter or runIds must be provided",
1319+
});
13211320

13221321
export type CreateBulkActionRequestBody = z.infer<typeof CreateBulkActionRequestBody>;
13231322

@@ -1391,10 +1390,9 @@ export const ImportEnvironmentVariablesRequestBody = z.object({
13911390
// When omitted, variables default to non-secret (the DB default is false).
13921391
isSecret: z.boolean().optional(),
13931392
source: discriminatedUnion("type", [
1394-
z.object({ type: z.literal("user"), userId: z.string() }),
1395-
z.object({ type: z.literal("integration"), integration: z.string() }),
1396-
])
1397-
.optional(),
1393+
z.object({ type: z.literal("user"), userId: z.string() }),
1394+
z.object({ type: z.literal("integration"), integration: z.string() }),
1395+
]).optional(),
13981396
});
13991397

14001398
export type ImportEnvironmentVariablesRequestBody = z.infer<

packages/core/src/v3/schemas/messages.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { TaskRunExecution, TaskRunExecutionResult } from "./common.js";
44
import { RunEngineVersionSchema, TaskRunExecutionMetrics } from "./schemas.js";
55
import { CompletedWaitpoint } from "./runEngine.js";
66
import { DebugLogPropertiesInput } from "../runEngineWorker/supervisor/schemas.js";
7+
import type { ZodIssueLike } from "../types/schemas.js";
78

89
export const ServerBackgroundWorker = z.object({
910
id: z.string(),
@@ -27,7 +28,7 @@ export const UncaughtExceptionMessage = z.object({
2728
export const TaskMetadataFailedToParseData = z.object({
2829
version: z.literal("v1").default("v1"),
2930
tasks: z.unknown(),
30-
zodIssues: z.custom<z.ZodIssue[]>((v) => {
31+
zodIssues: z.custom<ReadonlyArray<ZodIssueLike>>((v) => {
3132
return Array.isArray(v) && v.every((issue) => typeof issue === "object" && "message" in issue);
3233
}),
3334
});

packages/core/src/v3/serverOnly/httpServer.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import { HttpReply, getJsonBody } from "../apps/http.js";
55
import type { Registry } from "prom-client";
66
import { Histogram, Counter } from "prom-client";
77
import { tryCatch } from "../../utils.js";
8-
import type {
9-
AnyZodSchema,
10-
inferZodSchemaOutput,
11-
} from "../types/schemas.js";
8+
import type { AnyZodSchema, inferZodSchemaOutput } from "../types/schemas.js";
129

1310
const logger = new SimpleStructuredLogger("http-server");
1411

packages/core/src/v3/types/schemas.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { describe, expect, expectTypeOf, it } from "vitest";
22
import { z as z3 } from "zod/v3";
33
import { z as z4 } from "zod/v4";
44
import { getSchemaParseFn, isSchemaZodEsque } from "./schemas.js";
5-
import {
6-
convertToolParametersToSchema,
7-
type inferToolParameters,
8-
} from "./tools.js";
5+
import { convertToolParametersToSchema, type inferToolParameters } from "./tools.js";
96

107
describe("Zod schema compatibility", () => {
118
it("detects and parses Zod 3 schemas", async () => {

packages/core/src/v3/types/schemas.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,25 @@ export type SchemaZodEsque<TInput, TParsedInput> = {
33
_output: TParsedInput;
44
parse: (input: unknown) => TParsedInput;
55
parseAsync: (input: unknown) => Promise<TParsedInput>;
6-
safeParse: (input: unknown) =>
7-
| { success: true; data: TParsedInput }
8-
| { success: false; error: any };
6+
safeParse: (
7+
input: unknown
8+
) => { success: true; data: TParsedInput } | { success: false; error: any };
99
};
1010

1111
export type AnyZodSchema = SchemaZodEsque<any, any>;
1212
export type inferZodSchemaInput<TSchema extends AnyZodSchema> = TSchema["_input"];
1313
export type inferZodSchemaOutput<TSchema extends AnyZodSchema> = TSchema["_output"];
1414

15+
export type ZodIssueLike = {
16+
message: string;
17+
path: ReadonlyArray<PropertyKey>;
18+
};
19+
20+
export type ZodErrorLike = {
21+
message: string;
22+
issues: ReadonlyArray<ZodIssueLike>;
23+
};
24+
1525
export function isSchemaZodEsque<TInput, TParsedInput>(
1626
schema: unknown
1727
): schema is SchemaZodEsque<TInput, TParsedInput> {

0 commit comments

Comments
 (0)