@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.
- package/LICENSE +21 -0
- package/README.md +27 -2
- package/dist/collections.d.ts +572 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +479 -0
- package/dist/export-contract.d.ts +52 -0
- package/dist/export-contract.d.ts.map +1 -0
- package/dist/export-contract.js +17 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/letter.d.ts +13 -0
- package/dist/letter.d.ts.map +1 -0
- package/dist/letter.js +1 -0
- package/dist/library.d.ts +60 -0
- package/dist/library.d.ts.map +1 -0
- package/dist/library.js +118 -0
- package/dist/locale.d.ts +11 -0
- package/dist/locale.d.ts.map +1 -0
- package/dist/locale.js +6 -0
- package/dist/resume-dates.d.ts +122 -0
- package/dist/resume-dates.d.ts.map +1 -0
- package/dist/resume-dates.js +185 -0
- package/dist/resume.d.ts +271 -0
- package/dist/resume.d.ts.map +1 -0
- package/dist/resume.js +367 -0
- package/dist/template.d.ts +2049 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +2050 -0
- package/package.json +51 -3
- package/src/collections.ts +595 -0
- package/src/export-contract.ts +64 -0
- package/src/index.ts +8 -0
- package/src/letter.ts +12 -0
- package/src/library.ts +179 -0
- package/src/locale.ts +8 -0
- package/src/resume-dates.ts +252 -0
- package/src/resume.ts +410 -0
- package/src/template.ts +2360 -0
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@resumekit/schema",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Zod schemas for a structured resume, the resumekit template catalog, and the presentation overlay a candidate's edits are recorded in.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"resume",
|
|
7
|
+
"cv",
|
|
8
|
+
"schema",
|
|
9
|
+
"zod",
|
|
10
|
+
"templates"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Starlin Gil Cruz",
|
|
14
|
+
"homepage": "https://github.com/rocketbyte/resumekit/tree/main/packages/schema#readme",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/rocketbyte/resumekit.git",
|
|
18
|
+
"directory": "packages/schema"
|
|
19
|
+
},
|
|
20
|
+
"bugs": "https://github.com/rocketbyte/resumekit/issues",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"src/**/*.ts",
|
|
26
|
+
"!src/**/*.spec.ts",
|
|
27
|
+
"!dist/*.tsbuildinfo"
|
|
28
|
+
],
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"zod": "^4.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"zod": "^4.4.3"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20.19"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "rm -rf dist && tsc -b tsconfig.lib.json",
|
|
50
|
+
"typecheck": "tsc -b tsconfig.spec.json",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"check:package": "rm -rf out-tsc/pack && pnpm pack --pack-destination out-tsc/pack >/dev/null && publint --strict --pack pnpm && attw out-tsc/pack/*.tgz --profile esm-only"
|
|
53
|
+
}
|
|
6
54
|
}
|
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { isPresentDate } from './resume-dates.js';
|
|
3
|
+
import {
|
|
4
|
+
CustomEntrySchema,
|
|
5
|
+
CustomSectionSchema,
|
|
6
|
+
DescribedEntrySchema,
|
|
7
|
+
EducationSchema,
|
|
8
|
+
ExperienceSchema,
|
|
9
|
+
LanguageLevelSchema,
|
|
10
|
+
LanguageSchema,
|
|
11
|
+
LinkSchema,
|
|
12
|
+
ResumeObjectSchema,
|
|
13
|
+
SkillGroupSchema,
|
|
14
|
+
type ResumeObject,
|
|
15
|
+
} from './resume.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Every repeatable location in a résumé, declared as data.
|
|
19
|
+
*
|
|
20
|
+
* The table exists so that "may the candidate add one of these?" is answered in
|
|
21
|
+
* ONE place, by a field, rather than by each surface remembering. A control that
|
|
22
|
+
* has to know the professional summary is singular is a control that can forget;
|
|
23
|
+
* `arity: 'one'` cannot.
|
|
24
|
+
*
|
|
25
|
+
* Framework-free, in the manner of `TEMPLATES` and `PLANS`: no component, no
|
|
26
|
+
* React import, and no knowledge of which template draws it.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/** How many items a location holds. `one` is what suppresses an add control. */
|
|
30
|
+
export type Arity = 'one' | 'many';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* What an item is drawn as, which is the only thing a template needs to supply.
|
|
34
|
+
*
|
|
35
|
+
* `entry` is a block with fields of its own; `bullet` is a line in a list;
|
|
36
|
+
* `inline` is a comma-run inside a line; `field` is a single value with no list
|
|
37
|
+
* around it; `section` is a heading with entries under it.
|
|
38
|
+
*/
|
|
39
|
+
export type CollectionShape =
|
|
40
|
+
'field' | 'entry' | 'bullet' | 'inline' | 'section';
|
|
41
|
+
|
|
42
|
+
export interface CollectionDef {
|
|
43
|
+
/**
|
|
44
|
+
* Where the location lives, with `*` standing for an index the caller
|
|
45
|
+
* supplies — `experience.*.bullets` is one collection, not one per role.
|
|
46
|
+
*/
|
|
47
|
+
readonly path: string;
|
|
48
|
+
readonly arity: Arity;
|
|
49
|
+
readonly shape: CollectionShape;
|
|
50
|
+
/** Whether the candidate may change the order of what is here. */
|
|
51
|
+
readonly reorderable: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* How few items may remain. Removing below it is refused and explained —
|
|
54
|
+
* an experience entry with no bullets is a heading with nothing under it.
|
|
55
|
+
*/
|
|
56
|
+
readonly min: number;
|
|
57
|
+
/**
|
|
58
|
+
* A blank item. NEVER a populated one: what a minted entry carries is
|
|
59
|
+
* guidance, and guidance is not a value. See {@link PLACEHOLDERS}.
|
|
60
|
+
*/
|
|
61
|
+
readonly mint: () => unknown;
|
|
62
|
+
/** The item's own schema, for validating an addition before it is applied. */
|
|
63
|
+
readonly item: z.ZodTypeAny;
|
|
64
|
+
/**
|
|
65
|
+
* What to call one of these to a candidate.
|
|
66
|
+
*
|
|
67
|
+
* Data rather than a prop at every call site, so "a bullet", "a role" and "a
|
|
68
|
+
* skills group" are named once and every control, label and refusal reads the
|
|
69
|
+
* same word — including the refusal for a minimum, which used to be a
|
|
70
|
+
* bullet-specific constant in a bullet-specific component.
|
|
71
|
+
*/
|
|
72
|
+
readonly noun: string;
|
|
73
|
+
/**
|
|
74
|
+
* What the SECTION is called, for a control that has to say where it is
|
|
75
|
+
* acting — "Experience · Role 2" tells a candidate which of two roles and
|
|
76
|
+
* which of six sections in one line.
|
|
77
|
+
*/
|
|
78
|
+
readonly label: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The guidance a minted item shows in each of its fields.
|
|
83
|
+
*
|
|
84
|
+
* Keyed by the field's own name so a template needs no table of its own. These
|
|
85
|
+
* strings reach `EditableText`'s `placeholder` prop, which has been documented
|
|
86
|
+
* as "never saved" since the editor was written — they are what the candidate
|
|
87
|
+
* reads in an empty field, and they are never stored, exported or extractable.
|
|
88
|
+
*/
|
|
89
|
+
export const PLACEHOLDERS: Record<string, string> = {
|
|
90
|
+
/*
|
|
91
|
+
* The header's own fields, which had none — and a field with no guidance is
|
|
92
|
+
* a field a candidate cannot see is missing. A résumé whose writer produced
|
|
93
|
+
* no phone number rendered no phone number, and there was nothing on the page
|
|
94
|
+
* to say one belonged there or to click on to add it.
|
|
95
|
+
*/
|
|
96
|
+
location: 'City, Country',
|
|
97
|
+
email: 'you@example.com',
|
|
98
|
+
phone: 'Phone number',
|
|
99
|
+
company: 'Employer',
|
|
100
|
+
title: 'Your role',
|
|
101
|
+
start: 'YYYY-MM',
|
|
102
|
+
end: 'YYYY-MM or Present',
|
|
103
|
+
school: 'Institution',
|
|
104
|
+
degree: 'Degree',
|
|
105
|
+
field: 'Field of study',
|
|
106
|
+
category: 'Skill group, e.g. Languages',
|
|
107
|
+
heading: 'Section heading',
|
|
108
|
+
detail: 'Organisation or date range',
|
|
109
|
+
bullet: 'What you did, and what changed because of it.',
|
|
110
|
+
item: 'Keyword',
|
|
111
|
+
certification: 'Certification name',
|
|
112
|
+
label: 'Link text',
|
|
113
|
+
url: 'https://',
|
|
114
|
+
/*
|
|
115
|
+
* The two fields a résumé can be missing entirely, and therefore the two a
|
|
116
|
+
* candidate starting from scratch could not reach.
|
|
117
|
+
*
|
|
118
|
+
* A template omits a section it has no data for, so an empty `summary`
|
|
119
|
+
* rendered NOTHING — no heading, no field, nowhere to click — on a document
|
|
120
|
+
* whose whole purpose was to be typed into. The section renders while the
|
|
121
|
+
* document is being authored now, and this is what stands in it.
|
|
122
|
+
*
|
|
123
|
+
* Guidance, never an EXAMPLE. A specimen sentence in a field is something a
|
|
124
|
+
* candidate edits around rather than replaces, and the half they leave is a
|
|
125
|
+
* claim about their career that they did not make. These say what belongs
|
|
126
|
+
* there and nothing about whose career it is.
|
|
127
|
+
*/
|
|
128
|
+
summary:
|
|
129
|
+
'Two or three lines: what you do, how long, and what you are best at.',
|
|
130
|
+
headline: 'The role you are applying for.',
|
|
131
|
+
/*
|
|
132
|
+
* The LIST fields, guided by what the whole list is and how it is separated.
|
|
133
|
+
*
|
|
134
|
+
* Named for the field rather than for one of its items, because that is what
|
|
135
|
+
* the candidate is looking at: an inline list is one run of text, and the
|
|
136
|
+
* comma is the whole of how a second skill is added to it. A group added to
|
|
137
|
+
* Harvard's skills rendered as a category, a colon, and then nothing at all —
|
|
138
|
+
* an empty span with no width — so there was no way to see that the skills
|
|
139
|
+
* went there, and nothing to click on to type them.
|
|
140
|
+
*/
|
|
141
|
+
items: 'Skills, separated by commas',
|
|
142
|
+
certifications: 'Certifications, separated by commas',
|
|
143
|
+
/*
|
|
144
|
+
* The supporting sections' fields.
|
|
145
|
+
*
|
|
146
|
+
* Keyed per SECTION rather than by the bare field name, because `title` is
|
|
147
|
+
* already the experience entry's and means "Your role" there. An achievement
|
|
148
|
+
* guided as a job title would be worse than unguided. `DescribedEntries` looks
|
|
149
|
+
* up its own pair from the section id it is given, so no template carries a
|
|
150
|
+
* table for this.
|
|
151
|
+
*/
|
|
152
|
+
achievement_title: 'What you achieved',
|
|
153
|
+
achievement_description:
|
|
154
|
+
'One or two lines: what you did, and what it changed.',
|
|
155
|
+
course_title: 'Course or qualification',
|
|
156
|
+
course_description: 'One or two lines: what it covered, and who ran it.',
|
|
157
|
+
passion_title: 'An interest',
|
|
158
|
+
passion_description: 'One or two lines on what draws you to it.',
|
|
159
|
+
/* Keyed `language`, not `name`: `blank-document.spec.tsx` asserts that no
|
|
160
|
+
guidance string appears as document text, and "Language" is a substring
|
|
161
|
+
of the "Languages" heading right above the field. */
|
|
162
|
+
language: 'e.g. Spanish',
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/** A blank experience entry: every field empty, every field guided. */
|
|
166
|
+
const mintExperience = () => ({
|
|
167
|
+
company: '',
|
|
168
|
+
title: '',
|
|
169
|
+
location: '',
|
|
170
|
+
start: '',
|
|
171
|
+
end: '',
|
|
172
|
+
bullets: [''],
|
|
173
|
+
tech: [],
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const mintEducation = () => ({
|
|
177
|
+
school: '',
|
|
178
|
+
degree: '',
|
|
179
|
+
field: '',
|
|
180
|
+
location: '',
|
|
181
|
+
start: '',
|
|
182
|
+
end: '',
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const mintSkillGroup = () => ({ category: '', items: [''] });
|
|
186
|
+
|
|
187
|
+
const mintCustomEntry = () => ({ title: '', bullets: [''] });
|
|
188
|
+
|
|
189
|
+
const mintCustomSection = () => ({ heading: '', entries: [mintCustomEntry()] });
|
|
190
|
+
|
|
191
|
+
const mintLink = () => ({ label: '', url: '' });
|
|
192
|
+
|
|
193
|
+
/** A blank achievement, course or passion: a title and a paragraph, both empty. */
|
|
194
|
+
const mintDescribedEntry = () => ({ title: '', description: '' });
|
|
195
|
+
|
|
196
|
+
/*
|
|
197
|
+
* A blank language: no name, and NO LEVEL.
|
|
198
|
+
*
|
|
199
|
+
* Minting a level would mint a claim. `native` is not a neutral default — it is
|
|
200
|
+
* a statement about the candidate's fluency that the candidate has not made,
|
|
201
|
+
* and `collections.spec.ts` holds every mint to "guidance, never content" for
|
|
202
|
+
* exactly this reason. So the empty string is the unchosen state, the draft
|
|
203
|
+
* schema below is what tolerates it, and a template draws no meter until a
|
|
204
|
+
* level exists.
|
|
205
|
+
*/
|
|
206
|
+
const mintLanguage = () => ({ name: '', level: '' });
|
|
207
|
+
|
|
208
|
+
const mintString = () => '';
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Draft-tolerant item schemas.
|
|
212
|
+
*
|
|
213
|
+
* The writer's schemas require every text field to be non-empty, and that is
|
|
214
|
+
* right for the writer: a role with no employer is a role the model failed to
|
|
215
|
+
* ground. A MINTED entry is the opposite case — it is empty because the
|
|
216
|
+
* candidate has not typed yet, and refusing it would mean an added entry could
|
|
217
|
+
* not appear until it was already complete.
|
|
218
|
+
*
|
|
219
|
+
* `z.infer` of `z.string().min(1)` and of `z.string()` is the same type, so
|
|
220
|
+
* these are structurally identical to the strict schemas and nothing downstream
|
|
221
|
+
* changes shape. Only the runtime check differs.
|
|
222
|
+
*/
|
|
223
|
+
export const DraftExperienceSchema = ExperienceSchema.extend({
|
|
224
|
+
company: z.string(),
|
|
225
|
+
title: z.string(),
|
|
226
|
+
start: z.string(),
|
|
227
|
+
end: z.string(),
|
|
228
|
+
bullets: z.array(z.string()),
|
|
229
|
+
tech: z.array(z.string()).default([]),
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
export const DraftEducationSchema = EducationSchema.extend({
|
|
233
|
+
school: z.string(),
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
export const DraftSkillGroupSchema = SkillGroupSchema.extend({
|
|
237
|
+
category: z.string(),
|
|
238
|
+
items: z.array(z.string()),
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
export const DraftCustomEntrySchema = CustomEntrySchema.extend({
|
|
242
|
+
title: z.string(),
|
|
243
|
+
bullets: z.array(z.string()).default([]),
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
export const DraftCustomSectionSchema = CustomSectionSchema.extend({
|
|
247
|
+
heading: z.string(),
|
|
248
|
+
entries: z.array(DraftCustomEntrySchema).default([]),
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* A link whose address has not been typed yet.
|
|
253
|
+
*
|
|
254
|
+
* `LinkSchema` requires a non-empty `url`, and that is right for the writer: a
|
|
255
|
+
* link with no address is not a link. It was also the ONE item schema a minted
|
|
256
|
+
* item could not satisfy — every other collection already had a draft schema
|
|
257
|
+
* for exactly this — and the failure was silent in both places that read it.
|
|
258
|
+
* `collectionOrder` skips an append whose entry does not parse, and `applyEdits`
|
|
259
|
+
* skips it again, so pressing "Add links" appended an edit that nothing would
|
|
260
|
+
* ever draw. The candidate pressed a control and the document did not change.
|
|
261
|
+
*
|
|
262
|
+
* `collections.spec.ts` now asserts the general rule rather than this instance:
|
|
263
|
+
* what a collection mints, its own schema accepts.
|
|
264
|
+
*/
|
|
265
|
+
export const DraftLinkSchema = LinkSchema.extend({
|
|
266
|
+
url: z.string(),
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
/** A minted achievement, course or passion, before either field is typed. */
|
|
270
|
+
export const DraftDescribedEntrySchema = DescribedEntrySchema.extend({
|
|
271
|
+
title: z.string(),
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* A minted language, before either field is chosen.
|
|
276
|
+
*
|
|
277
|
+
* `level` widens to the enum OR the empty string, which is the unchosen state —
|
|
278
|
+
* not a sixth level. Nothing renders a meter for it, and the stored schema still
|
|
279
|
+
* refuses it, so an empty level cannot reach a saved résumé.
|
|
280
|
+
*/
|
|
281
|
+
export const DraftLanguageSchema = LanguageSchema.extend({
|
|
282
|
+
name: z.string(),
|
|
283
|
+
level: z.union([LanguageLevelSchema, z.literal('')]),
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The résumé AS DRAWN: the writer's shape, tolerating the empty fields of an
|
|
288
|
+
* entry the candidate has added and not yet filled in.
|
|
289
|
+
*
|
|
290
|
+
* Distinct from `ResumeObjectSchema`, which stays exactly as strict as it was —
|
|
291
|
+
* it is embedded in `TailoredResumeSchema` and is therefore the writer's
|
|
292
|
+
* contract. Relaxing that to make room for a draft would let the model's own
|
|
293
|
+
* output degrade silently, which is the opposite of what this is for.
|
|
294
|
+
*/
|
|
295
|
+
export const PresentedResumeSchema = ResumeObjectSchema.extend({
|
|
296
|
+
links: z.array(DraftLinkSchema).default([]),
|
|
297
|
+
experience: z.array(DraftExperienceSchema),
|
|
298
|
+
education: z.array(DraftEducationSchema).default([]),
|
|
299
|
+
skills: z.array(DraftSkillGroupSchema).default([]),
|
|
300
|
+
certifications: z.array(z.string()).default([]),
|
|
301
|
+
achievements: z.array(DraftDescribedEntrySchema).default([]),
|
|
302
|
+
courses: z.array(DraftDescribedEntrySchema).default([]),
|
|
303
|
+
passions: z.array(DraftDescribedEntrySchema).default([]),
|
|
304
|
+
languages: z.array(DraftLanguageSchema).default([]),
|
|
305
|
+
custom_sections: z.array(DraftCustomSectionSchema).default([]),
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The résumé a document draws.
|
|
310
|
+
*
|
|
311
|
+
* Structurally identical to {@link ResumeObject} — `.min(1)` constrains values,
|
|
312
|
+
* not types — so every template, serializer and renderer takes it unchanged.
|
|
313
|
+
* The alias exists to name the runtime difference at the places that care.
|
|
314
|
+
*/
|
|
315
|
+
export type PresentedResume = ResumeObject;
|
|
316
|
+
|
|
317
|
+
export const COLLECTIONS = {
|
|
318
|
+
summary: {
|
|
319
|
+
path: 'summary',
|
|
320
|
+
noun: 'summary',
|
|
321
|
+
label: 'Summary',
|
|
322
|
+
arity: 'one',
|
|
323
|
+
shape: 'field',
|
|
324
|
+
reorderable: false,
|
|
325
|
+
min: 1,
|
|
326
|
+
mint: mintString,
|
|
327
|
+
item: z.string(),
|
|
328
|
+
},
|
|
329
|
+
links: {
|
|
330
|
+
path: 'links',
|
|
331
|
+
noun: 'link',
|
|
332
|
+
label: 'Links',
|
|
333
|
+
arity: 'many',
|
|
334
|
+
shape: 'inline',
|
|
335
|
+
reorderable: true,
|
|
336
|
+
min: 0,
|
|
337
|
+
mint: mintLink,
|
|
338
|
+
item: DraftLinkSchema,
|
|
339
|
+
},
|
|
340
|
+
experience: {
|
|
341
|
+
path: 'experience',
|
|
342
|
+
noun: 'role',
|
|
343
|
+
label: 'Experience',
|
|
344
|
+
arity: 'many',
|
|
345
|
+
shape: 'entry',
|
|
346
|
+
reorderable: true,
|
|
347
|
+
min: 0,
|
|
348
|
+
mint: mintExperience,
|
|
349
|
+
item: DraftExperienceSchema,
|
|
350
|
+
},
|
|
351
|
+
experience_bullets: {
|
|
352
|
+
path: 'experience.*.bullets',
|
|
353
|
+
noun: 'bullet',
|
|
354
|
+
label: 'Experience',
|
|
355
|
+
arity: 'many',
|
|
356
|
+
shape: 'bullet',
|
|
357
|
+
reorderable: true,
|
|
358
|
+
// An entry with no bullets is a heading with nothing under it — the rule
|
|
359
|
+
// #29 wrote into `EditableBulletList`, now stated where every list reads it.
|
|
360
|
+
min: 1,
|
|
361
|
+
mint: mintString,
|
|
362
|
+
item: z.string(),
|
|
363
|
+
},
|
|
364
|
+
education: {
|
|
365
|
+
path: 'education',
|
|
366
|
+
noun: 'qualification',
|
|
367
|
+
label: 'Education',
|
|
368
|
+
arity: 'many',
|
|
369
|
+
shape: 'entry',
|
|
370
|
+
reorderable: true,
|
|
371
|
+
min: 0,
|
|
372
|
+
mint: mintEducation,
|
|
373
|
+
item: DraftEducationSchema,
|
|
374
|
+
},
|
|
375
|
+
skills: {
|
|
376
|
+
path: 'skills',
|
|
377
|
+
noun: 'skills group',
|
|
378
|
+
label: 'Skills',
|
|
379
|
+
arity: 'many',
|
|
380
|
+
shape: 'entry',
|
|
381
|
+
reorderable: true,
|
|
382
|
+
min: 0,
|
|
383
|
+
mint: mintSkillGroup,
|
|
384
|
+
item: DraftSkillGroupSchema,
|
|
385
|
+
},
|
|
386
|
+
skill_items: {
|
|
387
|
+
path: 'skills.*.items',
|
|
388
|
+
noun: 'skill',
|
|
389
|
+
label: 'Skills',
|
|
390
|
+
arity: 'many',
|
|
391
|
+
shape: 'inline',
|
|
392
|
+
reorderable: true,
|
|
393
|
+
min: 1,
|
|
394
|
+
mint: mintString,
|
|
395
|
+
item: z.string(),
|
|
396
|
+
},
|
|
397
|
+
certifications: {
|
|
398
|
+
path: 'certifications',
|
|
399
|
+
noun: 'certification',
|
|
400
|
+
label: 'Certifications',
|
|
401
|
+
arity: 'many',
|
|
402
|
+
shape: 'inline',
|
|
403
|
+
reorderable: true,
|
|
404
|
+
min: 0,
|
|
405
|
+
mint: mintString,
|
|
406
|
+
item: z.string(),
|
|
407
|
+
},
|
|
408
|
+
achievements: {
|
|
409
|
+
path: 'achievements',
|
|
410
|
+
noun: 'achievement',
|
|
411
|
+
label: 'Achievements',
|
|
412
|
+
arity: 'many',
|
|
413
|
+
shape: 'entry',
|
|
414
|
+
reorderable: true,
|
|
415
|
+
min: 0,
|
|
416
|
+
mint: mintDescribedEntry,
|
|
417
|
+
item: DraftDescribedEntrySchema,
|
|
418
|
+
},
|
|
419
|
+
courses: {
|
|
420
|
+
path: 'courses',
|
|
421
|
+
noun: 'course',
|
|
422
|
+
label: 'Courses',
|
|
423
|
+
arity: 'many',
|
|
424
|
+
shape: 'entry',
|
|
425
|
+
reorderable: true,
|
|
426
|
+
min: 0,
|
|
427
|
+
mint: mintDescribedEntry,
|
|
428
|
+
item: DraftDescribedEntrySchema,
|
|
429
|
+
},
|
|
430
|
+
passions: {
|
|
431
|
+
path: 'passions',
|
|
432
|
+
noun: 'interest',
|
|
433
|
+
label: 'Passions',
|
|
434
|
+
arity: 'many',
|
|
435
|
+
shape: 'entry',
|
|
436
|
+
reorderable: true,
|
|
437
|
+
min: 0,
|
|
438
|
+
mint: mintDescribedEntry,
|
|
439
|
+
item: DraftDescribedEntrySchema,
|
|
440
|
+
},
|
|
441
|
+
languages: {
|
|
442
|
+
path: 'languages',
|
|
443
|
+
noun: 'language',
|
|
444
|
+
label: 'Languages',
|
|
445
|
+
arity: 'many',
|
|
446
|
+
shape: 'entry',
|
|
447
|
+
reorderable: true,
|
|
448
|
+
min: 0,
|
|
449
|
+
mint: mintLanguage,
|
|
450
|
+
item: DraftLanguageSchema,
|
|
451
|
+
},
|
|
452
|
+
custom_sections: {
|
|
453
|
+
path: 'custom_sections',
|
|
454
|
+
noun: 'section',
|
|
455
|
+
label: 'Sections',
|
|
456
|
+
arity: 'many',
|
|
457
|
+
shape: 'section',
|
|
458
|
+
reorderable: true,
|
|
459
|
+
min: 0,
|
|
460
|
+
mint: mintCustomSection,
|
|
461
|
+
item: DraftCustomSectionSchema,
|
|
462
|
+
},
|
|
463
|
+
custom_entries: {
|
|
464
|
+
path: 'custom_sections.*.entries',
|
|
465
|
+
noun: 'entry',
|
|
466
|
+
label: 'Section',
|
|
467
|
+
arity: 'many',
|
|
468
|
+
shape: 'entry',
|
|
469
|
+
reorderable: true,
|
|
470
|
+
min: 1,
|
|
471
|
+
mint: mintCustomEntry,
|
|
472
|
+
item: DraftCustomEntrySchema,
|
|
473
|
+
},
|
|
474
|
+
custom_bullets: {
|
|
475
|
+
path: 'custom_sections.*.entries.*.bullets',
|
|
476
|
+
noun: 'bullet',
|
|
477
|
+
label: 'Section',
|
|
478
|
+
arity: 'many',
|
|
479
|
+
shape: 'bullet',
|
|
480
|
+
reorderable: true,
|
|
481
|
+
min: 0,
|
|
482
|
+
mint: mintString,
|
|
483
|
+
item: z.string(),
|
|
484
|
+
},
|
|
485
|
+
} as const satisfies Record<string, CollectionDef>;
|
|
486
|
+
|
|
487
|
+
export type CollectionId = keyof typeof COLLECTIONS;
|
|
488
|
+
export const CollectionIdSchema = z.enum(
|
|
489
|
+
Object.keys(COLLECTIONS) as [CollectionId, ...CollectionId[]],
|
|
490
|
+
);
|
|
491
|
+
|
|
492
|
+
/** Whether anything can be added here. The one place the question is answered. */
|
|
493
|
+
export function canAddTo(id: CollectionId): boolean {
|
|
494
|
+
return COLLECTIONS[id].arity === 'many';
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* The collections that live at the résumé's top level, which are the ones an
|
|
499
|
+
* `append` edit can name.
|
|
500
|
+
*
|
|
501
|
+
* A nested collection (`experience.*.bullets`, a custom section's entries) is
|
|
502
|
+
* reached through the entry that owns it, and its content is stored with that
|
|
503
|
+
* entry — so appending to one is not a separate operation on the overlay.
|
|
504
|
+
*/
|
|
505
|
+
export const TOP_LEVEL_COLLECTIONS = Object.entries(COLLECTIONS)
|
|
506
|
+
.filter(([, def]) => def.arity === 'many' && !def.path.includes('*'))
|
|
507
|
+
.map(([id]) => id as CollectionId);
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Resolve a collection's path for a particular set of indices.
|
|
511
|
+
*
|
|
512
|
+
* `experience.*.bullets` with `[2]` is `experience.2.bullets`. Supplying the
|
|
513
|
+
* wrong number of indices is a programming error, not a data one, so it throws.
|
|
514
|
+
*/
|
|
515
|
+
export function collectionPath(
|
|
516
|
+
id: CollectionId,
|
|
517
|
+
indices: readonly number[] = [],
|
|
518
|
+
): string {
|
|
519
|
+
const template = COLLECTIONS[id].path;
|
|
520
|
+
let used = 0;
|
|
521
|
+
const resolved = template
|
|
522
|
+
.split('.')
|
|
523
|
+
.map((segment) => {
|
|
524
|
+
if (segment !== '*') return segment;
|
|
525
|
+
const index = indices[used++];
|
|
526
|
+
if (index === undefined) {
|
|
527
|
+
throw new Error(
|
|
528
|
+
`${id} needs ${template.split('*').length - 1} indices`,
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
return String(index);
|
|
532
|
+
})
|
|
533
|
+
.join('.');
|
|
534
|
+
if (used !== indices.length) {
|
|
535
|
+
throw new Error(`${id} takes ${used} indices, given ${indices.length}`);
|
|
536
|
+
}
|
|
537
|
+
return resolved;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Whether an item holds nothing the candidate typed.
|
|
542
|
+
*
|
|
543
|
+
* This is what makes a placeholder an absence rather than a value: an entry
|
|
544
|
+
* every field of which is still empty has no content, so it is omitted from the
|
|
545
|
+
* export rather than shipped as guidance somebody will read as a claim.
|
|
546
|
+
*
|
|
547
|
+
* Recursive over arrays and objects, and blind to which collection it is
|
|
548
|
+
* looking at, because "unfilled" is the same question everywhere.
|
|
549
|
+
*/
|
|
550
|
+
export function isUnfilled(value: unknown): boolean {
|
|
551
|
+
if (typeof value === 'string') return value.trim().length === 0;
|
|
552
|
+
if (Array.isArray(value)) return value.every(isUnfilled);
|
|
553
|
+
if (value !== null && typeof value === 'object') {
|
|
554
|
+
return (
|
|
555
|
+
Object.entries(value as Record<string, unknown>)
|
|
556
|
+
// `id` and `author` are bookkeeping the candidate never types.
|
|
557
|
+
.filter(([key]) => key !== 'id' && key !== 'author')
|
|
558
|
+
.every(([, v]) => isUnfilled(v))
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
// A number or a boolean is a value; nothing in a résumé is either today.
|
|
562
|
+
return value === undefined || value === null;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Which experience entries are out of reverse-chronological order.
|
|
567
|
+
*
|
|
568
|
+
* The knowledge base requires reverse chronological, so a free reorder lets a
|
|
569
|
+
* candidate produce a résumé the product's own rulebook calls wrong. Returning
|
|
570
|
+
* the offending positions rather than a boolean is deliberate: this is shown to
|
|
571
|
+
* the candidate as a cost, never used to refuse the ordering.
|
|
572
|
+
*
|
|
573
|
+
* `Present` sorts above every date. An unparseable date is not an offence —
|
|
574
|
+
* the candidate is mid-typing, and a warning about a half-typed date is noise.
|
|
575
|
+
*/
|
|
576
|
+
export function chronologyWarnings(resume: PresentedResume): number[] {
|
|
577
|
+
const rank = (end: string): number | null => {
|
|
578
|
+
const value = end.trim();
|
|
579
|
+
if (value.length === 0) return null;
|
|
580
|
+
if (isPresentDate(value)) return Number.POSITIVE_INFINITY;
|
|
581
|
+
const match = /^(\d{4})(?:-(\d{2}))?/.exec(value);
|
|
582
|
+
if (!match) return null;
|
|
583
|
+
return Number(match[1]) * 12 + (match[2] ? Number(match[2]) : 0);
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
const out: number[] = [];
|
|
587
|
+
let previous: number | null = null;
|
|
588
|
+
resume.experience.forEach((role, index) => {
|
|
589
|
+
const current = rank(role.end);
|
|
590
|
+
if (current === null) return;
|
|
591
|
+
if (previous !== null && current > previous) out.push(index);
|
|
592
|
+
previous = current;
|
|
593
|
+
});
|
|
594
|
+
return out;
|
|
595
|
+
}
|