mirror of
https://github.com/morluto/rea.git
synced 2026-11-30 02:17:09 +00:00
perf(contracts): simplify inspectWebPageInputSchema to single strictObject (#13832)
Closes #13831
This commit is contained in:
1 parent
d1a9a67664
commit
9514e63d2a
1 file changed
+5
-15
@@ -230,9 +230,9 @@ const inspectWebPageInputFacts = {
|
||||
include_storage_fingerprints: z.boolean().default(false),
|
||||
} as const;
|
||||
|
||||
const inspectWebPageWithoutSourceSchema = z.strictObject({
|
||||
const inspectWebPageShapeSchema = z.strictObject({
|
||||
...inspectWebPageInputFacts,
|
||||
include_script_sources: z.literal(false).optional().default(false),
|
||||
include_script_sources: z.boolean().default(false),
|
||||
});
|
||||
|
||||
const inspectWebPageWithSourceShapeSchema = z.strictObject({
|
||||
@@ -240,9 +240,7 @@ const inspectWebPageWithSourceShapeSchema = z.strictObject({
|
||||
include_script_sources: z.literal(true).default(true),
|
||||
});
|
||||
|
||||
type InspectWebPageShape =
|
||||
| z.output<typeof inspectWebPageWithoutSourceSchema>
|
||||
| z.output<typeof inspectWebPageWithSourceShapeSchema>;
|
||||
type InspectWebPageShape = z.output<typeof inspectWebPageShapeSchema>;
|
||||
|
||||
const refineInspectWebPageInput = (
|
||||
input: InspectWebPageShape,
|
||||
@@ -261,16 +259,8 @@ export const inspectWebPageWithSourceInputSchema =
|
||||
inspectWebPageWithSourceShapeSchema.superRefine(refineInspectWebPageInput);
|
||||
|
||||
/** Caller-visible schema for one passive inspection. */
|
||||
export const inspectWebPageInputSchema = z.discriminatedUnion(
|
||||
"include_script_sources",
|
||||
[
|
||||
inspectWebPageWithoutSourceSchema.superRefine(refineInspectWebPageInput),
|
||||
inspectWebPageWithSourceShapeSchema
|
||||
.extend({
|
||||
include_script_sources: z.literal(true),
|
||||
})
|
||||
.superRefine(refineInspectWebPageInput),
|
||||
],
|
||||
export const inspectWebPageInputSchema = inspectWebPageShapeSchema.superRefine(
|
||||
refineInspectWebPageInput,
|
||||
);
|
||||
|
||||
export type ListBrowserTargetsInput = z.infer<
|
||||
|
||||
Reference in new issue
Block a user