Skip to content

Commit 571f100

Browse files
committed
fix required vs partial
1 parent bd0ceb8 commit 571f100

File tree

7 files changed

+32
-29
lines changed

7 files changed

+32
-29
lines changed

src/command/render/pandoc.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ import {
202202
BrandFontFile,
203203
BrandFontGoogle,
204204
} from "../../resources/types/schema-types.ts";
205+
import { Zod } from "../../resources/types/zod/schema-types.ts";
205206
import { kFieldCategories } from "../../project/types/website/listing/website-listing-shared.ts";
206207
import { isWindows } from "../../deno_ral/platform.ts";
207208
import { appendToCombinedLuaProfile } from "../../core/performance/perfetto-utils.ts";
@@ -1480,7 +1481,7 @@ async function resolveExtras(
14801481
// deno-lint-ignore no-explicit-any
14811482
const source: string = (_font as any).source ?? "google";
14821483
if (source === "file") {
1483-
const font = _font as BrandFontFile;
1484+
const font = Zod.BrandFontFile.parse(_font);
14841485
for (const file of font.files || []) {
14851486
const path = typeof file === "object" ? file.path : file;
14861487
fontdirs.add(dirname(join(brand.brandDir, path)));

src/core/schema/zod-types-from-schema.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,13 +407,15 @@ ${zodObject}
407407
baseObj = `${baseObj}.passthrough()`;
408408
}
409409
if (Array.isArray(required)) {
410-
baseObj = `${baseObj}.partial({${
410+
baseObj = `${baseObj}.required({${
411411
required.map((key: string) => {
412412
return `${key}: true`;
413413
}).join(", ")
414414
}})`;
415415
} else if (required === undefined) {
416416
baseObj = `${baseObj}.partial()`;
417+
} else if (required === "all") {
418+
baseObj = `${baseObj}.required()`;
417419
}
418420
if (obj.additionalProperties) {
419421
baseObj = `z.record(${

src/resources/editor/tools/vs-code.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24332,12 +24332,12 @@ var require_yaml_intelligence_resources = __commonJS({
2433224332
mermaid: "%%"
2433324333
},
2433424334
"handlers/mermaid/schema.yml": {
24335-
_internalId: 195566,
24335+
_internalId: 195562,
2433624336
type: "object",
2433724337
description: "be an object",
2433824338
properties: {
2433924339
"mermaid-format": {
24340-
_internalId: 195558,
24340+
_internalId: 195554,
2434124341
type: "enum",
2434224342
enum: [
2434324343
"png",
@@ -24353,7 +24353,7 @@ var require_yaml_intelligence_resources = __commonJS({
2435324353
exhaustiveCompletions: true
2435424354
},
2435524355
theme: {
24356-
_internalId: 195565,
24356+
_internalId: 195561,
2435724357
type: "anyOf",
2435824358
anyOf: [
2435924359
{

src/resources/editor/tools/yaml/web-worker.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/resources/editor/tools/yaml/yaml-intelligence-resources.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17304,12 +17304,12 @@
1730417304
"mermaid": "%%"
1730517305
},
1730617306
"handlers/mermaid/schema.yml": {
17307-
"_internalId": 195566,
17307+
"_internalId": 195562,
1730817308
"type": "object",
1730917309
"description": "be an object",
1731017310
"properties": {
1731117311
"mermaid-format": {
17312-
"_internalId": 195558,
17312+
"_internalId": 195554,
1731317313
"type": "enum",
1731417314
"enum": [
1731517315
"png",
@@ -17325,7 +17325,7 @@
1732517325
"exhaustiveCompletions": true
1732617326
},
1732717327
"theme": {
17328-
"_internalId": 195565,
17328+
"_internalId": 195561,
1732917329
"type": "anyOf",
1733017330
"anyOf": [
1733117331
{

src/resources/types/schema-schema-types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// This file is automatically generated by `quarto build-js`! Do not edit.",
1+
// This file is automatically generated by `quarto dev-call build-artifacts`! Do not edit.",
22
//
3-
// If you find yourself trying to rebuild types and `quarto build-js` won't run because
3+
// If you find yourself trying to rebuild types and `quarto dev-call build-artifacts` won't run because
44
// of bad type definitions, run the following:
55
// $ cd $QUARTO_ROOT
66
// $ ./package/dist/bin/tools/deno run --importmap=./src/import_map.json --allow-all ./package/src/common/create-schema-types.ts ./src/resources

src/resources/types/zod/schema-types.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export type JsonObject = { [key: string]: unknown };
2424

2525
export const ZodDate = z.union([
2626
z.string(),
27-
z.object({ value: z.string(), format: z.string() }).passthrough().partial({
27+
z.object({ value: z.string(), format: z.string() }).passthrough().required({
2828
value: true,
2929
}),
3030
]);
@@ -40,7 +40,7 @@ export const ZodPandocFormatOutputFile = z.union([z.string(), z.literal(null)]);
4040
export const ZodPandocFormatFilters = z.array(
4141
z.union([
4242
z.string(),
43-
z.object({ type: z.string(), path: z.string() }).passthrough().partial({
43+
z.object({ type: z.string(), path: z.string() }).passthrough().required({
4444
path: true,
4545
}),
4646
z.object({
@@ -56,7 +56,7 @@ export const ZodPandocFormatFilters = z.array(
5656
"post-render",
5757
] as const,
5858
),
59-
}).passthrough().partial({ path: true, at: true }),
59+
}).passthrough().required({ path: true, at: true }),
6060
z.object({ type: z.enum(["citeproc"] as const) }).strict(),
6161
]),
6262
);
@@ -133,7 +133,7 @@ export const ZodGiscusConfiguration = z.object({
133133
}).strict().partial(),
134134
]),
135135
language: z.string(),
136-
}).strict().partial({ repo: true });
136+
}).strict().required({ repo: true });
137137

138138
export const ZodDocumentCommentsConfiguration = z.union([
139139
z.literal(false),
@@ -143,7 +143,7 @@ export const ZodDocumentCommentsConfiguration = z.union([
143143
label: z.string(),
144144
theme: z.string(),
145145
"issue-term": z.string(),
146-
}).strict().partial({ repo: true }),
146+
}).strict().required({ repo: true }),
147147
giscus: z.lazy(() => ZodGiscusConfiguration),
148148
hypothesis: z.union([
149149
z.boolean(),
@@ -169,7 +169,7 @@ export const ZodDocumentCommentsConfiguration = z.union([
169169
z.array(z.string()),
170170
]),
171171
icon: z.string(),
172-
}).passthrough().partial({
172+
}).passthrough().required({
173173
apiUrl: true,
174174
authority: true,
175175
grantToken: true,
@@ -189,7 +189,7 @@ export const ZodDocumentCommentsConfiguration = z.union([
189189
userid: z.string(),
190190
displayName: z.string(),
191191
}).passthrough().partial(),
192-
}).passthrough().partial({ user: true }),
192+
}).passthrough().required({ user: true }),
193193
requestConfigFromFrame: z.object({
194194
origin: z.string(),
195195
ancestorLevel: z.number(),
@@ -232,7 +232,7 @@ export const ZodProjectServe = z.object({
232232
args: z.string(),
233233
env: z.object({}).passthrough().partial(),
234234
ready: z.string(),
235-
}).strict().partial({ cmd: true, ready: true });
235+
}).strict().required({ cmd: true, ready: true });
236236

237237
export const ZodPublish = z.object({
238238
netlify: z.array(z.lazy(() => ZodPublishRecord)),
@@ -650,7 +650,7 @@ export const ZodChapterItem = z.union([
650650
z.object({
651651
part: z.string(),
652652
chapters: z.array(z.lazy(() => ZodNavigationItem)),
653-
}).passthrough().partial({ part: true }),
653+
}).passthrough().required({ part: true }),
654654
]);
655655

656656
export const ZodChapterList = z.array(z.lazy(() => ZodChapterItem));
@@ -662,7 +662,7 @@ export const ZodOtherLinks = z.array(
662662
icon: z.string(),
663663
rel: z.string(),
664664
target: z.string(),
665-
}).passthrough().partial({ text: true, href: true }),
665+
}).passthrough().required({ text: true, href: true }),
666666
);
667667

668668
export const ZodCrossrefLabelsSchema = z.string();
@@ -756,7 +756,7 @@ export const ZodWebsiteAbout = z.object({
756756
"image-width": z.string(),
757757
"image-shape": z.enum(["rectangle", "round", "rounded"] as const),
758758
links: z.array(z.lazy(() => ZodNavigationItem)),
759-
}).strict().partial({ template: true });
759+
}).strict().required({ template: true });
760760

761761
export const ZodWebsiteListing = z.object({
762762
id: z.string(),
@@ -1224,7 +1224,7 @@ export const ZodSemver = z.string().regex(
12241224

12251225
export const ZodQuartoDate = z.union([
12261226
z.string(),
1227-
z.object({ format: z.string(), value: z.string() }).strict().partial({
1227+
z.object({ format: z.string(), value: z.string() }).strict().required({
12281228
value: true,
12291229
}),
12301230
]);
@@ -1248,7 +1248,7 @@ export const ZodNotebookViewSchema = z.object({
12481248
title: z.union([z.string(), z.boolean()]),
12491249
url: z.string(),
12501250
"download-url": z.string(),
1251-
}).passthrough().partial({ notebook: true });
1251+
}).passthrough().required({ notebook: true });
12521252

12531253
export const ZodCodeLinksSchema = z.union([
12541254
z.boolean(),
@@ -1317,7 +1317,7 @@ export const ZodBrandStringLightDark = z.union([
13171317
export const ZodBrandLogoExplicitResource = z.object({
13181318
path: z.string(),
13191319
alt: z.string(),
1320-
}).strict().partial({ path: true });
1320+
}).strict().required({ path: true });
13211321

13221322
export const ZodBrandLogoResource = z.union([
13231323
z.string(),
@@ -1564,10 +1564,10 @@ export const ZodBrandFontFile = z.object({
15641564
path: z.string(),
15651565
weight: z.lazy(() => ZodBrandFontWeight),
15661566
style: z.lazy(() => ZodBrandFontStyle),
1567-
}).passthrough().partial({ path: true }),
1567+
}).passthrough().required({ path: true }),
15681568
]),
15691569
),
1570-
}).strict().partial({ files: true, family: true, source: true });
1570+
}).strict().required({ files: true, family: true, source: true });
15711571

15721572
export const ZodBrandFontFamily = z.string();
15731573

0 commit comments

Comments
 (0)