@resumekit/schema 0.0.0-stage → 0.2.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.
@@ -0,0 +1,271 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Contact details. EVERY field is optional on purpose: text extraction routinely
4
+ * loses the email (it lives in a PDF header, a hyperlink, or a graphic). A
5
+ * required field with no honest source would force the writer to invent one —
6
+ * violating the product's defining constraint — or to fail validation on every
7
+ * repair attempt at full model cost. Absent details are the renderer's problem,
8
+ * not a reason to fabricate. See `llm-cost-optimization`.
9
+ */
10
+ export declare const ContactSchema: z.ZodObject<{
11
+ email: z.ZodOptional<z.ZodString>;
12
+ phone: z.ZodOptional<z.ZodString>;
13
+ location: z.ZodOptional<z.ZodString>;
14
+ }, z.core.$strip>;
15
+ export type Contact = z.infer<typeof ContactSchema>;
16
+ export declare const LinkSchema: z.ZodObject<{
17
+ label: z.ZodOptional<z.ZodString>;
18
+ url: z.ZodString;
19
+ }, z.core.$strip>;
20
+ export type Link = z.infer<typeof LinkSchema>;
21
+ /**
22
+ * Whether a string may be used as a link target in a document.
23
+ *
24
+ * PARSED, never prefix-matched. `startsWith('http')` is defeated by
25
+ * `javascript:` with an embedded tab or newline (the URL parser strips those
26
+ * before determining the scheme, so the string and the parsed scheme disagree),
27
+ * by unusual casing, and by percent-encoding. Asking the parser what the scheme
28
+ * actually is and then checking that against the allowlist has no such gap.
29
+ *
30
+ * A relative address (`github.com/me`) is REFUSED rather than silently promoted
31
+ * to `https://`. Guessing the scheme is inventing intent, and the surface that
32
+ * collected the value is the right place to say "start with https://".
33
+ */
34
+ export declare function isSafeLinkTarget(value: string): boolean;
35
+ /**
36
+ * A validated link target.
37
+ *
38
+ * Refused loudly: a caller gets a parse error it can report, rather than a
39
+ * quietly dropped value that leaves a word looking linked and doing nothing.
40
+ */
41
+ export declare const LinkTargetSchema: z.ZodString;
42
+ /**
43
+ * Who put a piece of the document there.
44
+ *
45
+ * An enum of one today, and deliberately an enum: the product's guarantee is
46
+ * that the WRITER never states what it cannot ground, and that stays checkable
47
+ * only while writer output and candidate typing remain distinguishable to every
48
+ * later reader. Stored rather than inferred — see `editor-structural-authoring`,
49
+ * decision 2.
50
+ */
51
+ export declare const CONTENT_AUTHORS: readonly ["candidate"];
52
+ export declare const ContentAuthorSchema: z.ZodEnum<{
53
+ candidate: "candidate";
54
+ }>;
55
+ export type ContentAuthor = z.infer<typeof ContentAuthorSchema>;
56
+ /**
57
+ * One entry in a candidate-authored section.
58
+ *
59
+ * Deliberately the same shape as the entries the templates already draw — a
60
+ * title, an optional qualifier line, and bullets — so a custom section renders
61
+ * through each template's existing section machinery rather than needing a
62
+ * layout of its own. A section carries content; it never carries a layout.
63
+ */
64
+ export declare const CustomEntrySchema: z.ZodObject<{
65
+ title: z.ZodString;
66
+ detail: z.ZodOptional<z.ZodString>;
67
+ bullets: z.ZodDefault<z.ZodArray<z.ZodString>>;
68
+ }, z.core.$strip>;
69
+ export type CustomEntry = z.infer<typeof CustomEntrySchema>;
70
+ /**
71
+ * A section the schema has no concept of — Projects, Volunteering, Awards.
72
+ *
73
+ * `id` is minted when the section is created and is what the overlay addresses,
74
+ * so the section survives the writer producing a different résumé underneath it.
75
+ * `author` is what keeps the never-invent claim checkable once one document
76
+ * contains both writer output and candidate typing.
77
+ */
78
+ export declare const CustomSectionSchema: z.ZodObject<{
79
+ id: z.ZodString;
80
+ heading: z.ZodString;
81
+ entries: z.ZodDefault<z.ZodArray<z.ZodObject<{
82
+ title: z.ZodString;
83
+ detail: z.ZodOptional<z.ZodString>;
84
+ bullets: z.ZodDefault<z.ZodArray<z.ZodString>>;
85
+ }, z.core.$strip>>>;
86
+ author: z.ZodEnum<{
87
+ candidate: "candidate";
88
+ }>;
89
+ }, z.core.$strip>;
90
+ export type CustomSection = z.infer<typeof CustomSectionSchema>;
91
+ /**
92
+ * A title with a short paragraph under it — an achievement, a course, a passion.
93
+ *
94
+ * The shape is taken from the references rather than guessed. Every one of the
95
+ * thirteen sets an achievement as a bold or accented title with a paragraph
96
+ * beneath it; not one sets it as bullets. `description` is therefore a single
97
+ * `string` and not a `string[]`, so the record cannot express a list no template
98
+ * draws — the same discipline {@link SkillGroupSchema} applies when it refuses
99
+ * prose.
100
+ *
101
+ * ONE schema for three sections because they share a shape, and three FIELDS
102
+ * rather than one tagged list because they do not share a place on the page: a
103
+ * template resolves where a section sits from the field it is reading, not from
104
+ * a discriminator it has to match. Keying behaviour off a string is the mistake
105
+ * `isLanguages` made, and it is not repeated here.
106
+ */
107
+ export declare const DescribedEntrySchema: z.ZodObject<{
108
+ title: z.ZodString;
109
+ description: z.ZodString;
110
+ }, z.core.$strip>;
111
+ export type DescribedEntry = z.infer<typeof DescribedEntrySchema>;
112
+ /**
113
+ * How well the candidate speaks a language.
114
+ *
115
+ * FIVE values, because the meter five of the references draw has five steps.
116
+ * That correspondence is the whole reason a meter is allowed to exist here at
117
+ * all: `docs/template-contract.md` refuses a proficiency meter whose
118
+ * proportions nothing recorded, and this one renders one step per stored enum
119
+ * value rather than a percentage somebody chose. A sixth level would break the
120
+ * correspondence and force that rule to be re-decided — stated here so it is
121
+ * decided knowingly rather than discovered.
122
+ *
123
+ * There is no zero: a language the candidate does not speak is not on the
124
+ * résumé.
125
+ */
126
+ export declare const LANGUAGE_LEVELS: readonly ["native", "fluent", "advanced", "intermediate", "beginner"];
127
+ export declare const LanguageLevelSchema: z.ZodEnum<{
128
+ native: "native";
129
+ fluent: "fluent";
130
+ advanced: "advanced";
131
+ intermediate: "intermediate";
132
+ beginner: "beginner";
133
+ }>;
134
+ export type LanguageLevel = z.infer<typeof LanguageLevelSchema>;
135
+ export declare const LanguageSchema: z.ZodObject<{
136
+ name: z.ZodString;
137
+ level: z.ZodEnum<{
138
+ native: "native";
139
+ fluent: "fluent";
140
+ advanced: "advanced";
141
+ intermediate: "intermediate";
142
+ beginner: "beginner";
143
+ }>;
144
+ }, z.core.$strip>;
145
+ export type Language = z.infer<typeof LanguageSchema>;
146
+ /** A flat keyword list grouped by type (no rating bars / years-per-skill). */
147
+ export declare const SkillGroupSchema: z.ZodObject<{
148
+ category: z.ZodString;
149
+ items: z.ZodArray<z.ZodString>;
150
+ }, z.core.$strip>;
151
+ export type SkillGroup = z.infer<typeof SkillGroupSchema>;
152
+ export declare const ExperienceSchema: z.ZodObject<{
153
+ company: z.ZodString;
154
+ title: z.ZodString;
155
+ location: z.ZodOptional<z.ZodString>;
156
+ start: z.ZodString;
157
+ end: z.ZodString;
158
+ bullets: z.ZodArray<z.ZodString>;
159
+ tech: z.ZodDefault<z.ZodArray<z.ZodString>>;
160
+ }, z.core.$strip>;
161
+ export type Experience = z.infer<typeof ExperienceSchema>;
162
+ export declare const EducationSchema: z.ZodObject<{
163
+ school: z.ZodString;
164
+ degree: z.ZodOptional<z.ZodString>;
165
+ field: z.ZodOptional<z.ZodString>;
166
+ location: z.ZodOptional<z.ZodString>;
167
+ start: z.ZodOptional<z.ZodString>;
168
+ end: z.ZodOptional<z.ZodString>;
169
+ }, z.core.$strip>;
170
+ export type Education = z.infer<typeof EducationSchema>;
171
+ /**
172
+ * The structured resume — NOT a text blob — so a template can render it without
173
+ * re-parsing free text, and "same resume, different template" is a data operation.
174
+ *
175
+ * @pii This object is dense personal data. See {@link PersonalData} and README.
176
+ */
177
+ export declare const ResumeObjectSchema: z.ZodObject<{
178
+ name: z.ZodString;
179
+ contact: z.ZodObject<{
180
+ email: z.ZodOptional<z.ZodString>;
181
+ phone: z.ZodOptional<z.ZodString>;
182
+ location: z.ZodOptional<z.ZodString>;
183
+ }, z.core.$strip>;
184
+ links: z.ZodDefault<z.ZodArray<z.ZodObject<{
185
+ label: z.ZodOptional<z.ZodString>;
186
+ url: z.ZodString;
187
+ }, z.core.$strip>>>;
188
+ headline: z.ZodOptional<z.ZodString>;
189
+ summary: z.ZodString;
190
+ skills: z.ZodDefault<z.ZodArray<z.ZodObject<{
191
+ category: z.ZodString;
192
+ items: z.ZodArray<z.ZodString>;
193
+ }, z.core.$strip>>>;
194
+ experience: z.ZodArray<z.ZodObject<{
195
+ company: z.ZodString;
196
+ title: z.ZodString;
197
+ location: z.ZodOptional<z.ZodString>;
198
+ start: z.ZodString;
199
+ end: z.ZodString;
200
+ bullets: z.ZodArray<z.ZodString>;
201
+ tech: z.ZodDefault<z.ZodArray<z.ZodString>>;
202
+ }, z.core.$strip>>;
203
+ education: z.ZodDefault<z.ZodArray<z.ZodObject<{
204
+ school: z.ZodString;
205
+ degree: z.ZodOptional<z.ZodString>;
206
+ field: z.ZodOptional<z.ZodString>;
207
+ location: z.ZodOptional<z.ZodString>;
208
+ start: z.ZodOptional<z.ZodString>;
209
+ end: z.ZodOptional<z.ZodString>;
210
+ }, z.core.$strip>>>;
211
+ certifications: z.ZodDefault<z.ZodArray<z.ZodString>>;
212
+ achievements: z.ZodDefault<z.ZodArray<z.ZodObject<{
213
+ title: z.ZodString;
214
+ description: z.ZodString;
215
+ }, z.core.$strip>>>;
216
+ courses: z.ZodDefault<z.ZodArray<z.ZodObject<{
217
+ title: z.ZodString;
218
+ description: z.ZodString;
219
+ }, z.core.$strip>>>;
220
+ passions: z.ZodDefault<z.ZodArray<z.ZodObject<{
221
+ title: z.ZodString;
222
+ description: z.ZodString;
223
+ }, z.core.$strip>>>;
224
+ languages: z.ZodDefault<z.ZodArray<z.ZodObject<{
225
+ name: z.ZodString;
226
+ level: z.ZodEnum<{
227
+ native: "native";
228
+ fluent: "fluent";
229
+ advanced: "advanced";
230
+ intermediate: "intermediate";
231
+ beginner: "beginner";
232
+ }>;
233
+ }, z.core.$strip>>>;
234
+ section_headings: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
235
+ custom_sections: z.ZodDefault<z.ZodArray<z.ZodObject<{
236
+ id: z.ZodString;
237
+ heading: z.ZodString;
238
+ entries: z.ZodDefault<z.ZodArray<z.ZodObject<{
239
+ title: z.ZodString;
240
+ detail: z.ZodOptional<z.ZodString>;
241
+ bullets: z.ZodDefault<z.ZodArray<z.ZodString>>;
242
+ }, z.core.$strip>>>;
243
+ author: z.ZodEnum<{
244
+ candidate: "candidate";
245
+ }>;
246
+ }, z.core.$strip>>>;
247
+ }, z.core.$strip>;
248
+ export type ResumeObject = z.infer<typeof ResumeObjectSchema>;
249
+ /**
250
+ * The résumé fields the writer cannot express.
251
+ *
252
+ * One list, used by `TailoredResumeSchema` to omit them and by
253
+ * {@link asResumeObject} to put them back, so the two can never disagree about
254
+ * which fields are candidate-only.
255
+ */
256
+ export declare const CANDIDATE_ONLY_FIELDS: readonly ["custom_sections", "section_headings", "achievements", "courses", "passions", "languages"];
257
+ export type CandidateOnlyField = (typeof CANDIDATE_ONLY_FIELDS)[number];
258
+ /**
259
+ * A writer résumé widened to a full {@link ResumeObject}.
260
+ *
261
+ * `TailoredResumeSchema` omits every {@link CANDIDATE_ONLY_FIELDS} member so the
262
+ * model cannot express a section it did not ground. Everything that RENDERS a
263
+ * résumé takes the full object, so the two meet here: a writer résumé has none
264
+ * of them, and saying that once beats each caller spreading five empty arrays
265
+ * and hoping they stay the right defaults.
266
+ *
267
+ * The parameter is typed by the same list, so a sixth candidate-only field is a
268
+ * type error here until it is handled rather than a silently missing default.
269
+ */
270
+ export declare function asResumeObject(written: Omit<ResumeObject, CandidateOnlyField>): ResumeObject;
271
+ //# sourceMappingURL=resume.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resume.d.ts","sourceRoot":"","sources":["../src/resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;;;;iBAgBxB,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,eAAO,MAAM,UAAU;;;iBAGrB,CAAC;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAsB9C;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAWvD;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aAKgC,CAAC;AAE9D;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,wBAAyB,CAAC;AACtD,eAAO,MAAM,mBAAmB;;EAA0B,CAAC;AAC3D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;;;;iBAO5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;iBAK9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB;;;iBAO/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,uEAMlB,CAAC;AACX,eAAO,MAAM,mBAAmB;;;;;;EAA0B,CAAC;AAC3D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,cAAc;;;;;;;;;iBAGzB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB;;;iBAU3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,gBAAgB;;;;;;;;iBA0C3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,eAAe;;;;;;;iBAmB1B,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiF7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,sGAOxB,CAAC;AACX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,kBAAkB,CAAC,GAC9C,YAAY,CAUd"}
package/dist/resume.js ADDED
@@ -0,0 +1,367 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Contact details. EVERY field is optional on purpose: text extraction routinely
4
+ * loses the email (it lives in a PDF header, a hyperlink, or a graphic). A
5
+ * required field with no honest source would force the writer to invent one —
6
+ * violating the product's defining constraint — or to fail validation on every
7
+ * repair attempt at full model cost. Absent details are the renderer's problem,
8
+ * not a reason to fabricate. See `llm-cost-optimization`.
9
+ */
10
+ export const ContactSchema = z.object({
11
+ email: z
12
+ .string()
13
+ .optional()
14
+ .describe('Email exactly as it appears in the source resume. Omit if the resume ' +
15
+ 'does not contain one — never invent or guess an address.'),
16
+ phone: z
17
+ .string()
18
+ .optional()
19
+ .describe('Phone as written in the source resume.'),
20
+ location: z
21
+ .string()
22
+ .optional()
23
+ .describe("Location as written, e.g. 'Berlin, DE'."),
24
+ });
25
+ export const LinkSchema = z.object({
26
+ label: z.string().optional().describe("Display label, e.g. 'GitHub'."),
27
+ url: z.string().min(1).describe('The URL as written in the source resume.'),
28
+ });
29
+ /**
30
+ * The only schemes a document's link may use.
31
+ *
32
+ * A résumé is exported to PDF and HTML, mailed to strangers, and reopened in
33
+ * readers this product does not control. A `javascript:` or `data:` target in
34
+ * that document is a script-injection vector rather than a formatting mistake,
35
+ * so the allowlist is a security boundary and lives in the domain where every
36
+ * surface inherits it.
37
+ */
38
+ const SAFE_LINK_SCHEMES = ['http:', 'https:'];
39
+ /**
40
+ * A ceiling on a stored target.
41
+ *
42
+ * Not a correctness rule — it is the de-facto address-bar limit, and it stops a
43
+ * pasted megabyte of `data:` payload becoming part of a document that is
44
+ * synced, versioned and re-parsed on every render.
45
+ */
46
+ const MAX_LINK_LENGTH = 2048;
47
+ /**
48
+ * Whether a string may be used as a link target in a document.
49
+ *
50
+ * PARSED, never prefix-matched. `startsWith('http')` is defeated by
51
+ * `javascript:` with an embedded tab or newline (the URL parser strips those
52
+ * before determining the scheme, so the string and the parsed scheme disagree),
53
+ * by unusual casing, and by percent-encoding. Asking the parser what the scheme
54
+ * actually is and then checking that against the allowlist has no such gap.
55
+ *
56
+ * A relative address (`github.com/me`) is REFUSED rather than silently promoted
57
+ * to `https://`. Guessing the scheme is inventing intent, and the surface that
58
+ * collected the value is the right place to say "start with https://".
59
+ */
60
+ export function isSafeLinkTarget(value) {
61
+ const trimmed = value.trim();
62
+ if (trimmed.length === 0 || trimmed.length > MAX_LINK_LENGTH)
63
+ return false;
64
+ let parsed;
65
+ try {
66
+ parsed = new URL(trimmed);
67
+ }
68
+ catch {
69
+ // No scheme, or unparseable. Either way it is not something to link to.
70
+ return false;
71
+ }
72
+ return SAFE_LINK_SCHEMES.includes(parsed.protocol);
73
+ }
74
+ /**
75
+ * A validated link target.
76
+ *
77
+ * Refused loudly: a caller gets a parse error it can report, rather than a
78
+ * quietly dropped value that leaves a word looking linked and doing nothing.
79
+ */
80
+ export const LinkTargetSchema = z
81
+ .string()
82
+ .refine(isSafeLinkTarget, {
83
+ message: 'A link must be an http:// or https:// address.',
84
+ })
85
+ .describe('An absolute http(s) address a field points at.');
86
+ /**
87
+ * Who put a piece of the document there.
88
+ *
89
+ * An enum of one today, and deliberately an enum: the product's guarantee is
90
+ * that the WRITER never states what it cannot ground, and that stays checkable
91
+ * only while writer output and candidate typing remain distinguishable to every
92
+ * later reader. Stored rather than inferred — see `editor-structural-authoring`,
93
+ * decision 2.
94
+ */
95
+ export const CONTENT_AUTHORS = ['candidate'];
96
+ export const ContentAuthorSchema = z.enum(CONTENT_AUTHORS);
97
+ /**
98
+ * One entry in a candidate-authored section.
99
+ *
100
+ * Deliberately the same shape as the entries the templates already draw — a
101
+ * title, an optional qualifier line, and bullets — so a custom section renders
102
+ * through each template's existing section machinery rather than needing a
103
+ * layout of its own. A section carries content; it never carries a layout.
104
+ */
105
+ export const CustomEntrySchema = z.object({
106
+ title: z.string().min(1).describe('The entry’s headline, e.g. a project.'),
107
+ detail: z
108
+ .string()
109
+ .optional()
110
+ .describe('Qualifier line, e.g. an organisation or a date range.'),
111
+ bullets: z.array(z.string().min(1)).default([]),
112
+ });
113
+ /**
114
+ * A section the schema has no concept of — Projects, Volunteering, Awards.
115
+ *
116
+ * `id` is minted when the section is created and is what the overlay addresses,
117
+ * so the section survives the writer producing a different résumé underneath it.
118
+ * `author` is what keeps the never-invent claim checkable once one document
119
+ * contains both writer output and candidate typing.
120
+ */
121
+ export const CustomSectionSchema = z.object({
122
+ id: z.string().min(1),
123
+ heading: z.string().min(1).describe("Section heading, e.g. 'Volunteering'."),
124
+ entries: z.array(CustomEntrySchema).default([]),
125
+ author: ContentAuthorSchema,
126
+ });
127
+ /**
128
+ * A title with a short paragraph under it — an achievement, a course, a passion.
129
+ *
130
+ * The shape is taken from the references rather than guessed. Every one of the
131
+ * thirteen sets an achievement as a bold or accented title with a paragraph
132
+ * beneath it; not one sets it as bullets. `description` is therefore a single
133
+ * `string` and not a `string[]`, so the record cannot express a list no template
134
+ * draws — the same discipline {@link SkillGroupSchema} applies when it refuses
135
+ * prose.
136
+ *
137
+ * ONE schema for three sections because they share a shape, and three FIELDS
138
+ * rather than one tagged list because they do not share a place on the page: a
139
+ * template resolves where a section sits from the field it is reading, not from
140
+ * a discriminator it has to match. Keying behaviour off a string is the mistake
141
+ * `isLanguages` made, and it is not repeated here.
142
+ */
143
+ export const DescribedEntrySchema = z.object({
144
+ title: z.string().min(1).describe('The entry’s headline, e.g. an award.'),
145
+ description: z
146
+ .string()
147
+ .describe('One short paragraph. Never a list — no template draws bullets here.'),
148
+ });
149
+ /**
150
+ * How well the candidate speaks a language.
151
+ *
152
+ * FIVE values, because the meter five of the references draw has five steps.
153
+ * That correspondence is the whole reason a meter is allowed to exist here at
154
+ * all: `docs/template-contract.md` refuses a proficiency meter whose
155
+ * proportions nothing recorded, and this one renders one step per stored enum
156
+ * value rather than a percentage somebody chose. A sixth level would break the
157
+ * correspondence and force that rule to be re-decided — stated here so it is
158
+ * decided knowingly rather than discovered.
159
+ *
160
+ * There is no zero: a language the candidate does not speak is not on the
161
+ * résumé.
162
+ */
163
+ export const LANGUAGE_LEVELS = [
164
+ 'native',
165
+ 'fluent',
166
+ 'advanced',
167
+ 'intermediate',
168
+ 'beginner',
169
+ ];
170
+ export const LanguageLevelSchema = z.enum(LANGUAGE_LEVELS);
171
+ export const LanguageSchema = z.object({
172
+ name: z.string().min(1).describe("A language, e.g. 'Spanish'."),
173
+ level: LanguageLevelSchema.describe('How well the candidate speaks it.'),
174
+ });
175
+ /** A flat keyword list grouped by type (no rating bars / years-per-skill). */
176
+ export const SkillGroupSchema = z.object({
177
+ category: z
178
+ .string()
179
+ .min(1)
180
+ .describe("Group name, e.g. 'Languages', 'Cloud & Infra'."),
181
+ items: z
182
+ .array(z.string().min(1))
183
+ .describe('Flat keyword list. No rating bars, no years-per-skill, no prose.'),
184
+ });
185
+ export const ExperienceSchema = z.object({
186
+ company: z
187
+ .string()
188
+ .min(1)
189
+ .describe('Employer name exactly as in the resume.'),
190
+ title: z.string().min(1).describe('Job title exactly as in the resume.'),
191
+ /*
192
+ * Where the job was, which the résumé had nowhere to put.
193
+ *
194
+ * The same gap `Education.location` closed, in the sibling entry: Harvard has
195
+ * drawn an empty slot beside the employer since it was written, so every
196
+ * résumé printed a blank there and no candidate could type into it. A real
197
+ * résumé states it — `Doral Health & Wellness New York, NY` — and a recruiter
198
+ * filtering by place is reading exactly this line.
199
+ *
200
+ * Optional, because remote roles and plenty of résumés state none, and
201
+ * inventing a city is worse than omitting one.
202
+ */
203
+ location: z
204
+ .string()
205
+ .optional()
206
+ .describe("Where the job was, e.g. 'New York, NY'. Omit if not stated."),
207
+ start: z
208
+ .string()
209
+ .min(1)
210
+ .describe("Start date as 'YYYY-MM', e.g. '2021-03'. Never empty."),
211
+ end: z
212
+ .string()
213
+ .min(1)
214
+ .describe("End date as 'YYYY-MM', or exactly 'Present' for a current role. Never empty."),
215
+ bullets: z
216
+ .array(z.string().min(1))
217
+ .describe('Each bullet: action verb + what you did + tool + quantified outcome. ' +
218
+ "No 'responsible for'."),
219
+ tech: z
220
+ .array(z.string().min(1))
221
+ .default([])
222
+ .describe('Technologies used in this role, as ATS keyword strings.'),
223
+ });
224
+ export const EducationSchema = z.object({
225
+ school: z.string().min(1).describe('Institution name as in the resume.'),
226
+ degree: z.string().optional().describe("e.g. 'BSc'."),
227
+ field: z.string().optional().describe("e.g. 'Computer Science'."),
228
+ /*
229
+ * Where the institution is, which the résumé had nowhere to put.
230
+ *
231
+ * Every template draws a slot beside the school for it — Harvard has carried
232
+ * an empty `__where` since it was written — and the record it was drawn from
233
+ * could not hold one, so it printed blank on every résumé and no candidate
234
+ * could type it in. Optional, because plenty of qualifications are stated
235
+ * without a city and inventing one is worse than omitting it.
236
+ */
237
+ location: z
238
+ .string()
239
+ .optional()
240
+ .describe("Where the institution is, e.g. 'Madrid, Spain'."),
241
+ start: z.string().optional().describe("'YYYY' or 'YYYY-MM'."),
242
+ end: z.string().optional().describe("'YYYY', 'YYYY-MM', or 'Present'."),
243
+ });
244
+ /**
245
+ * The structured resume — NOT a text blob — so a template can render it without
246
+ * re-parsing free text, and "same resume, different template" is a data operation.
247
+ *
248
+ * @pii This object is dense personal data. See {@link PersonalData} and README.
249
+ */
250
+ export const ResumeObjectSchema = z.object({
251
+ name: z.string().min(1).describe("The candidate's full name."),
252
+ contact: ContactSchema,
253
+ links: z.array(LinkSchema).default([]),
254
+ headline: z
255
+ .string()
256
+ .optional()
257
+ .describe('One line mirroring the target job title.'),
258
+ summary: z
259
+ .string()
260
+ .describe('Short paragraph proving the target title. Grounded only in the source ' +
261
+ "resume and the candidate's answers."),
262
+ skills: z.array(SkillGroupSchema).default([]),
263
+ experience: z
264
+ .array(ExperienceSchema)
265
+ .describe('Reverse chronological — most recent role first.'),
266
+ education: z.array(EducationSchema).default([]),
267
+ certifications: z.array(z.string().min(1)).default([]),
268
+ /*
269
+ * The four sections every reference draws and the record could not hold.
270
+ *
271
+ * Achievements is in all thirteen references, usually directly under the
272
+ * summary or at the top of the rail; Courses is in ten, Passions in six,
273
+ * Languages in five. Until they existed here, seventeen templates each had
274
+ * four holes a stylesheet could not fill, because there was nowhere for a
275
+ * candidate to type the content.
276
+ *
277
+ * DEFAULTED EMPTY, so every résumé stored before these fields existed parses
278
+ * unchanged and nothing is migrated.
279
+ *
280
+ * DELIBERATELY ABSENT from `TailoredResumeSchema`, on the same terms as
281
+ * `custom_sections` below: a section the pipeline cannot express is a section
282
+ * the pipeline cannot invent, so every entry here is known to be the
283
+ * candidate's own. It also keeps the JSON Schema sent to the provider
284
+ * byte-identical, so the fields cost no tokens.
285
+ */
286
+ achievements: z.array(DescribedEntrySchema).default([]),
287
+ courses: z.array(DescribedEntrySchema).default([]),
288
+ passions: z.array(DescribedEntrySchema).default([]),
289
+ /*
290
+ * Read from here rather than from whichever skills group a candidate happened
291
+ * to name "Languages", which is how every template found them before this
292
+ * field existed. That stopgap had no level, so no meter; no section id, so no
293
+ * adjustable gap; and it rendered nothing at all for the candidate who had not
294
+ * guessed the magic category name.
295
+ */
296
+ languages: z.array(LanguageSchema).default([]),
297
+ /*
298
+ * What each section is CALLED, where the candidate renamed it.
299
+ *
300
+ * Keyed by `ResumeSectionId`, and absent for every section the candidate left
301
+ * alone — so the template's own heading is the default and nothing is stored
302
+ * until somebody types. A custom section has carried an editable `heading`
303
+ * since it was introduced; this is the same capability for the sections the
304
+ * schema names, which a candidate could read on the page and not change.
305
+ *
306
+ * The VALUE type is a loose `Record<string, string>` rather than a record
307
+ * keyed by the enum, deliberately. A rename arrives as an ordinary `set` edit
308
+ * on `section_headings.<id>`, and an overlay is data at rest that outlives the
309
+ * code that wrote it — so an edit naming a section this build no longer has
310
+ * would make the whole résumé fail to parse, and `presentedResume` would fall
311
+ * back to the writer's copy and silently discard every OTHER edit with it. A
312
+ * key nothing reads costs nothing; a résumé that will not open costs the
313
+ * candidate their work. The same reasoning `applyPresentation` gives for
314
+ * skipping a stale path rather than throwing.
315
+ */
316
+ section_headings: z.record(z.string(), z.string()).default({}),
317
+ /*
318
+ * Sections the candidate added, which this schema has no other concept of.
319
+ *
320
+ * Defaulted empty, so every résumé written before this field existed parses
321
+ * unchanged and nothing is migrated. Rendered after the sections a template
322
+ * knows, in declaration order.
323
+ *
324
+ * DELIBERATELY ABSENT from the schema the writer produces (`TailoredResume`):
325
+ * a section the pipeline cannot express is a section the pipeline cannot
326
+ * invent, so a custom section can only ever have come from a candidate.
327
+ */
328
+ custom_sections: z.array(CustomSectionSchema).default([]),
329
+ });
330
+ /**
331
+ * The résumé fields the writer cannot express.
332
+ *
333
+ * One list, used by `TailoredResumeSchema` to omit them and by
334
+ * {@link asResumeObject} to put them back, so the two can never disagree about
335
+ * which fields are candidate-only.
336
+ */
337
+ export const CANDIDATE_ONLY_FIELDS = [
338
+ 'custom_sections',
339
+ 'section_headings',
340
+ 'achievements',
341
+ 'courses',
342
+ 'passions',
343
+ 'languages',
344
+ ];
345
+ /**
346
+ * A writer résumé widened to a full {@link ResumeObject}.
347
+ *
348
+ * `TailoredResumeSchema` omits every {@link CANDIDATE_ONLY_FIELDS} member so the
349
+ * model cannot express a section it did not ground. Everything that RENDERS a
350
+ * résumé takes the full object, so the two meet here: a writer résumé has none
351
+ * of them, and saying that once beats each caller spreading five empty arrays
352
+ * and hoping they stay the right defaults.
353
+ *
354
+ * The parameter is typed by the same list, so a sixth candidate-only field is a
355
+ * type error here until it is handled rather than a silently missing default.
356
+ */
357
+ export function asResumeObject(written) {
358
+ return {
359
+ ...written,
360
+ custom_sections: [],
361
+ section_headings: {},
362
+ achievements: [],
363
+ courses: [],
364
+ passions: [],
365
+ languages: [],
366
+ };
367
+ }