@singi-labs/sifa-sdk 0.19.93 → 0.19.95

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.
@@ -1,83 +1,9 @@
1
- import { z } from 'zod';
1
+ import { E as ExportContact } from '../export-contact-D_krcTBH.js';
2
+ export { a as EXPORT_CONTACT_LIMITS, b as ExportContactDraft, e as exportContactSchema, l as looksLikeEmail, n as normalizeExportContact, p as pickExportContact } from '../export-contact-D_krcTBH.js';
2
3
  import { L as LocationValue, J as ProfileLocation, d as ProfilePosition, f as ProfileEducation, P as ProfileSkill, e as ProfileCertification, i as ProfileProject, j as ProfilePublication, N as ProfileVolunteering, g as ProfileHonor, h as ProfileLanguage, p as ExternalAccount, M as ProfilePresentation, B as ProfileCourse } from '../index-BEAuoL6l.js';
4
+ import { z } from 'zod';
3
5
  import '../verification-providers-DeyGqaoC.js';
4
6
 
5
- /**
6
- * Private contact and personal details for exports: email, phone, postal
7
- * address, driver's license, right to work and nationality.
8
- *
9
- * Sifa never stores these and never writes them to the owner's PDS, where they
10
- * would be public. The owner types them on the export page, the browser keeps
11
- * them, and they go only into the files the owner downloads. This module holds
12
- * the shape, the limits and the pick rule, so the export page and the server
13
- * that builds a funder CV agree on them.
14
- */
15
-
16
- /** Longest value accepted per field. 254 is the longest valid email address. */
17
- declare const EXPORT_CONTACT_LIMITS: {
18
- readonly email: 254;
19
- readonly phone: 40;
20
- readonly address: 500;
21
- readonly driversLicense: 60;
22
- readonly rightToWork: 200;
23
- readonly nationality: 100;
24
- };
25
- /** The contact details that go into an export. Absent keys are left out. */
26
- interface ExportContact {
27
- readonly email?: string;
28
- readonly phone?: string;
29
- /** Free text; lines are separated by `\n`. */
30
- readonly address?: string;
31
- /** License categories, e.g. "B, BE". */
32
- readonly driversLicense?: string;
33
- /** e.g. "EU citizen, no sponsorship needed". */
34
- readonly rightToWork?: string;
35
- readonly nationality?: string;
36
- }
37
- /** What the owner has typed, plus which fields they chose to include. */
38
- interface ExportContactDraft {
39
- readonly email?: string;
40
- readonly phone?: string;
41
- readonly address?: string;
42
- readonly driversLicense?: string;
43
- readonly rightToWork?: string;
44
- readonly nationality?: string;
45
- readonly includeEmail?: boolean;
46
- readonly includePhone?: boolean;
47
- readonly includeAddress?: boolean;
48
- readonly includeDriversLicense?: boolean;
49
- readonly includeRightToWork?: boolean;
50
- readonly includeNationality?: boolean;
51
- }
52
- /**
53
- * Validates a picked contact. Only lengths are checked: phone numbers and
54
- * addresses vary too much between countries, and a wrong-looking email is a
55
- * warning for the owner, not a reason to refuse the export.
56
- */
57
- declare const exportContactSchema: z.ZodObject<{
58
- email: z.ZodOptional<z.ZodString>;
59
- phone: z.ZodOptional<z.ZodString>;
60
- address: z.ZodOptional<z.ZodString>;
61
- driversLicense: z.ZodOptional<z.ZodString>;
62
- rightToWork: z.ZodOptional<z.ZodString>;
63
- nationality: z.ZodOptional<z.ZodString>;
64
- }, z.core.$strict>;
65
- /**
66
- * The fields to put in an export: the included ones that are not blank, run
67
- * through {@link normalizeExportContact}.
68
- */
69
- declare function pickExportContact(draft: ExportContactDraft): ExportContact;
70
- /**
71
- * Drops blank fields and tidies the rest. Every field but the address becomes
72
- * one line with single spaces. An address keeps its line breaks but loses blank lines and the
73
- * spaces around each line. Each field is cut at its {@link EXPORT_CONTACT_LIMITS}
74
- * length. The emitters call this too, so a caller that skips
75
- * {@link pickExportContact} and the schema gets the same bounded output.
76
- */
77
- declare function normalizeExportContact(contact: ExportContact): ExportContact;
78
- /** A loose shape check for a non-blocking "check this address" hint. */
79
- declare function looksLikeEmail(value: string): boolean;
80
-
81
7
  /**
82
8
  * JSON Resume v1.0.0 emitter for a Sifa profile.
83
9
  *
@@ -514,4 +440,4 @@ type FunderCvDocument = NihFunderCv | ErcFunderCv;
514
440
  */
515
441
  declare function profileToFunderCv(profile: FunderCvProfileInput, selection: FunderCvSelection, options?: FunderCvOptions): FunderCvDocument;
516
442
 
517
- export { EXPORT_CONTACT_LIMITS, type ErcContribution, type ErcEducation, type ErcFunderCv, type ErcFunderCvPerson, type ErcRecognition, type ExportContact, type ExportContactDraft, FUNDER_CV_FORMATS, FUNDER_CV_GROUPS, FUNDER_CV_ITEM_KINDS, type FunderCvAppointment, type FunderCvCandidate, type FunderCvCitation, type FunderCvDocument, type FunderCvFormat, type FunderCvGroupName, type FunderCvGroupSpec, type FunderCvHonor, type FunderCvItemKind, type FunderCvOptions, type FunderCvPerson, type FunderCvProfileInput, type FunderCvSelection, type JsonResume, type JsonResumeAward, type JsonResumeBasics, type JsonResumeCertificate, type JsonResumeEducation, type JsonResumeLanguage, type JsonResumeLocation, type JsonResumeMeta, type JsonResumeOptions, type JsonResumeProfileInput, type JsonResumeProfileLink, type JsonResumeProject, type JsonResumePublication, type JsonResumeSkill, type JsonResumeVolunteer, type JsonResumeWork, type NihEducation, type NihFunderCv, type Sanitizer, defaultFunderCvSelection, exportContactSchema, findUnknownFunderCvItems, funderCvItemId, funderCvSelectionSchema, listFunderCvCandidates, looksLikeEmail, normalizeExportContact, pickExportContact, profileToFunderCv, profileToJsonResume, toResumeDate };
443
+ export { type ErcContribution, type ErcEducation, type ErcFunderCv, type ErcFunderCvPerson, type ErcRecognition, ExportContact, FUNDER_CV_FORMATS, FUNDER_CV_GROUPS, FUNDER_CV_ITEM_KINDS, type FunderCvAppointment, type FunderCvCandidate, type FunderCvCitation, type FunderCvDocument, type FunderCvFormat, type FunderCvGroupName, type FunderCvGroupSpec, type FunderCvHonor, type FunderCvItemKind, type FunderCvOptions, type FunderCvPerson, type FunderCvProfileInput, type FunderCvSelection, type JsonResume, type JsonResumeAward, type JsonResumeBasics, type JsonResumeCertificate, type JsonResumeEducation, type JsonResumeLanguage, type JsonResumeLocation, type JsonResumeMeta, type JsonResumeOptions, type JsonResumeProfileInput, type JsonResumeProfileLink, type JsonResumeProject, type JsonResumePublication, type JsonResumeSkill, type JsonResumeVolunteer, type JsonResumeWork, type NihEducation, type NihFunderCv, type Sanitizer, defaultFunderCvSelection, findUnknownFunderCvItems, funderCvItemId, funderCvSelectionSchema, listFunderCvCandidates, profileToFunderCv, profileToJsonResume, toResumeDate };
@@ -58,6 +58,13 @@ function mapLocation(profile, s) {
58
58
  ];
59
59
  return candidates.find((c) => Object.keys(c).length > 0);
60
60
  }
61
+ function link(value, s) {
62
+ const t = value?.replace(/\s+/g, "");
63
+ if (!t) return void 0;
64
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(t)) return URL.canParse(t) ? s(t) : void 0;
65
+ const withScheme = `https://${t}`;
66
+ return /^[^\s/]+\.[^\s/]+/.test(t) && URL.canParse(withScheme) ? s(withScheme) : void 0;
67
+ }
61
68
  function text(value, s) {
62
69
  const trimmed = value?.trim();
63
70
  return trimmed ? s(trimmed) : void 0;
@@ -75,7 +82,7 @@ function profileToJsonResume(profile, options = {}) {
75
82
  (account) => compact({
76
83
  network: s(account.platform),
77
84
  username: text(account.label, s),
78
- url: text(account.url, s)
85
+ url: link(account.url, s)
79
86
  })
80
87
  );
81
88
  const basics = compact({
@@ -84,7 +91,7 @@ function profileToJsonResume(profile, options = {}) {
84
91
  image: text(profile.avatar, s),
85
92
  email: text(contact.email, s),
86
93
  phone: text(contact.phone, s),
87
- url: text(profile.website, s) ?? canonical,
94
+ url: link(profile.website, s) ?? canonical,
88
95
  summary: text(profile.about, s),
89
96
  location: withAddress(mapLocation(profile, s), text(contact.address, s)),
90
97
  ...section("profiles", profiles)
@@ -131,7 +138,7 @@ function profileToJsonResume(profile, options = {}) {
131
138
  // `issuingOrg` is the deprecated read-view alias for `authority`; records
132
139
  // indexed before the rename carry only the alias.
133
140
  issuer: orgName(cert.entityName, cert.authority ?? cert.issuingOrg, s),
134
- url: text(cert.credentialUrl, s)
141
+ url: link(cert.credentialUrl, s)
135
142
  })
136
143
  );
137
144
  const publications = sortPublications(filterHidden(profile.publications)).map(
@@ -139,7 +146,7 @@ function profileToJsonResume(profile, options = {}) {
139
146
  name: s(publication.title),
140
147
  publisher: text(publication.publisher, s),
141
148
  releaseDate: toResumeDate(publication.date),
142
- url: text(publication.url, s),
149
+ url: link(publication.url, s),
143
150
  summary: text(publication.description, s)
144
151
  })
145
152
  );
@@ -154,7 +161,7 @@ function profileToJsonResume(profile, options = {}) {
154
161
  (project) => compact({
155
162
  name: s(project.name),
156
163
  description: text(project.description, s),
157
- url: text(project.url, s),
164
+ url: link(project.url, s),
158
165
  startDate: toResumeDate(project.startDate),
159
166
  endDate: toResumeDate(project.endDate)
160
167
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resume/json-resume.ts"],"sourcesContent":["/**\n * JSON Resume v1.0.0 emitter for a Sifa profile.\n *\n * https://jsonresume.org/schema/\n *\n * One pure function, no fetching, no DOM, no framework -- the same shape as the\n * JSON-LD emitter next door, and for the same reason: sifa.id, page.sifa.id and\n * any future consumer should emit one document from one implementation.\n *\n * Why this format earns its place: it is the lingua franca of CV tooling, so\n * emitting it hands a user every JSON Resume theme, and the Typst CV templates\n * on Typst Universe, without Sifa writing a renderer for any of them.\n *\n * Fields Sifa holds that JSON Resume has no slot for -- endorsements,\n * confirmations, involvement, investments, presentations, courses -- are\n * dropped rather than smuggled into a nearby field. The loss is documented for\n * the user at the point of download.\n */\n\nimport { parseLocationString } from '../format/location-utils.js';\nimport { formatStructuredName } from '../format/pds-utils.js';\nimport { filterHidden } from '../profile/section-model.js';\nimport {\n sortCertifications,\n sortEducation,\n sortHonors,\n sortLanguages,\n sortPositions,\n sortProjects,\n sortPublications,\n} from '../profile/section-sorts.js';\nimport { sortByActiveDateRange } from '../profile/range-sort.js';\nimport type {\n ExternalAccount,\n LanguageProficiency,\n LocationValue,\n ProfileCertification,\n ProfileEducation,\n ProfileHonor,\n ProfileLanguage,\n ProfileLocation,\n ProfilePosition,\n ProfileProject,\n ProfilePublication,\n ProfileSkill,\n ProfileVolunteering,\n} from '../types/index.js';\nimport { normaliseBaseUrl, profileUrl } from '../jsonld/url.js';\nimport { normalizeExportContact, type ExportContact } from './export-contact.js';\n\nexport type Sanitizer = (input: string) => string;\n\nexport interface JsonResumeOptions {\n /** Canonical origin for the profile URL. Defaults to `https://sifa.id`. */\n readonly baseUrl?: string;\n /** Applied to every user-authored string. Defaults to identity. */\n readonly sanitize?: Sanitizer;\n /**\n * Absolute URL of the profile this resume describes. Defaults to\n * `${baseUrl}/p/${handle}`. A personal site served from a custom domain is\n * not at that path.\n */\n readonly canonicalUrl?: string;\n /**\n * Email, phone and postal address to print. Sifa holds none of these; the\n * owner types them on the export page. Without it the resume has no\n * `email`, `phone` or `location.address`. Personal details in the same object\n * (driver's license, right to work, nationality) are left out: JSON Resume\n * has no field for them, and strict consumers such as altacv refuse a file\n * with an unknown key.\n */\n readonly contact?: ExportContact;\n}\n\n/**\n * The subset of `Profile` this emitter reads. Deliberately structural rather\n * than the full `Profile`, so a caller holding a partially hydrated profile --\n * or a test -- does not have to invent forty unrelated fields.\n */\nexport interface JsonResumeProfileInput {\n readonly handle: string;\n readonly displayName?: string;\n readonly givenName?: string;\n readonly familyName?: string;\n readonly avatar?: string;\n readonly headline?: string;\n readonly about?: string;\n readonly website?: string;\n /**\n * The structured location. The profile API sends a display string here\n * instead; the emitter then reads the primary entry of `locations`.\n */\n readonly location?: LocationValue | string | null;\n readonly locations?: ProfileLocation[];\n readonly positions?: ProfilePosition[];\n readonly education?: ProfileEducation[];\n readonly skills?: ProfileSkill[];\n readonly certifications?: ProfileCertification[];\n readonly projects?: ProfileProject[];\n readonly publications?: ProfilePublication[];\n readonly volunteering?: ProfileVolunteering[];\n readonly honors?: ProfileHonor[];\n readonly languages?: ProfileLanguage[];\n readonly externalAccounts?: ExternalAccount[];\n}\n\nexport interface JsonResumeLocation {\n /** Street address; lines are separated by `\\n`, as the schema asks. */\n readonly address?: string;\n readonly city?: string;\n readonly region?: string;\n readonly countryCode?: string;\n readonly postalCode?: string;\n}\n\nexport interface JsonResumeProfileLink {\n readonly network: string;\n readonly username?: string;\n readonly url?: string;\n}\n\nexport interface JsonResumeBasics {\n readonly name: string;\n readonly label?: string;\n readonly image?: string;\n readonly url?: string;\n readonly email?: string;\n readonly phone?: string;\n readonly summary?: string;\n readonly location?: JsonResumeLocation;\n readonly profiles?: JsonResumeProfileLink[];\n}\n\nexport interface JsonResumeWork {\n readonly name?: string;\n readonly position: string;\n readonly summary?: string;\n readonly startDate?: string;\n readonly endDate?: string;\n}\n\nexport interface JsonResumeVolunteer {\n /**\n * Omitted when the record carries no organization name at all. Emitting an\n * empty string would render as a blank organization line in a CV template.\n */\n readonly organization?: string;\n readonly position?: string;\n readonly summary?: string;\n readonly startDate?: string;\n readonly endDate?: string;\n}\n\nexport interface JsonResumeEducation {\n /** Omitted when the record carries no institution name. See volunteer. */\n readonly institution?: string;\n readonly area?: string;\n readonly studyType?: string;\n readonly startDate?: string;\n readonly endDate?: string;\n}\n\nexport interface JsonResumeAward {\n readonly title: string;\n readonly date?: string;\n readonly awarder?: string;\n readonly summary?: string;\n}\n\nexport interface JsonResumeCertificate {\n readonly name: string;\n readonly date?: string;\n readonly issuer?: string;\n readonly url?: string;\n}\n\nexport interface JsonResumePublication {\n readonly name: string;\n readonly publisher?: string;\n readonly releaseDate?: string;\n readonly url?: string;\n readonly summary?: string;\n}\n\nexport interface JsonResumeSkill {\n readonly name: string;\n}\n\nexport interface JsonResumeLanguage {\n readonly language: string;\n readonly fluency?: string;\n}\n\nexport interface JsonResumeProject {\n readonly name: string;\n readonly description?: string;\n readonly url?: string;\n readonly startDate?: string;\n readonly endDate?: string;\n}\n\nexport interface JsonResumeMeta {\n readonly canonical: string;\n readonly version: string;\n readonly lastModified?: string;\n}\n\nexport interface JsonResume {\n readonly basics?: JsonResumeBasics;\n readonly work?: JsonResumeWork[];\n readonly volunteer?: JsonResumeVolunteer[];\n readonly education?: JsonResumeEducation[];\n readonly awards?: JsonResumeAward[];\n readonly certificates?: JsonResumeCertificate[];\n readonly publications?: JsonResumePublication[];\n readonly skills?: JsonResumeSkill[];\n readonly languages?: JsonResumeLanguage[];\n readonly projects?: JsonResumeProject[];\n readonly meta?: JsonResumeMeta;\n}\n\n/** Schema version this emitter targets, as JSON Resume writes it in `meta`. */\nconst SCHEMA_VERSION = 'v1.0.0';\n\n/**\n * A date JSON Resume will accept: `YYYY`, `YYYY-MM` or `YYYY-MM-DD`. Sifa\n * stores RFC 3339 for some fields, and a full timestamp pasted into a CV\n * template renders as `2020-03-04T00:00:00.000Z` on the page.\n */\nconst RESUME_DATE_RE = /^(\\d{4})(-\\d{2})?(-\\d{2})?/;\n\nexport function toResumeDate(value: string | undefined): string | undefined {\n const trimmed = value?.trim();\n if (!trimmed) return undefined;\n const match = RESUME_DATE_RE.exec(trimmed);\n return match ? match[0] : undefined;\n}\n\n/**\n * JSON Resume's `fluency` is free text, so these are display labels rather\n * than a mapped vocabulary. Kept in one place so export and a future import\n * agree on the spelling.\n */\nconst FLUENCY_LABELS: Record<LanguageProficiency, string> = {\n elementary: 'Elementary',\n limited_working: 'Limited working',\n professional_working: 'Professional working',\n full_professional: 'Full professional',\n native: 'Native or bilingual',\n};\n\nconst identity: Sanitizer = (input) => input;\n\n/** Drops keys whose value is undefined, so the document carries no empty slots. */\nfunction compact<T extends object>(value: T): T {\n return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined)) as T;\n}\n\n/** Adds the owner's street address to the profile's location. */\nfunction withAddress(\n location: JsonResumeLocation | undefined,\n address: string | undefined,\n): JsonResumeLocation | undefined {\n return address ? { address, ...location } : location;\n}\n\n/** Omits the key entirely when the mapped list came out empty. */\nfunction section<K extends string, T>(key: K, items: T[]): Record<K, T[]> | undefined {\n return items.length > 0 ? ({ [key]: items } as Record<K, T[]>) : undefined;\n}\n\n/**\n * The first of these that yields anything: the structured `location` object;\n * the primary entry of `locations` (or the first entry when none is marked\n * primary), which is what the profile API sends; a display-string `location`,\n * split into city and region. JSON Resume has no field for a country name, so a\n * country-only location maps to nothing.\n */\nfunction mapLocation(\n profile: Pick<JsonResumeProfileInput, 'location' | 'locations'>,\n s: Sanitizer,\n): JsonResumeLocation | undefined {\n const fromValue = (location: LocationValue | null | undefined) =>\n location\n ? compact<JsonResumeLocation>({\n city: text(location.locality || location.city, s),\n region: text(location.region, s),\n countryCode: text(location.countryCode, s),\n postalCode: text(location.postalCode, s),\n })\n : {};\n const entry = profile.locations?.find((l) => l.isPrimary) ?? profile.locations?.[0];\n const candidates: JsonResumeLocation[] = [\n typeof profile.location === 'object' ? fromValue(profile.location) : {},\n entry\n ? compact<JsonResumeLocation>({\n city: text((entry.locationLocality || entry.locationCity) ?? undefined, s),\n region: text(entry.locationRegion ?? undefined, s),\n countryCode: text(entry.countryCode ?? undefined, s),\n })\n : {},\n typeof profile.location === 'string' ? fromValue(parseLocationString(profile.location)) : {},\n ];\n return candidates.find((c) => Object.keys(c).length > 0);\n}\n\n/** Trimmed, sanitised, and undefined when there is nothing left. */\nfunction text(value: string | undefined, s: Sanitizer): string | undefined {\n const trimmed = value?.trim();\n return trimmed ? s(trimmed) : undefined;\n}\n\n/**\n * The name to print for a linked organization. `entityName` is the AppView's\n * resolved current name and wins when present, matching how the profile itself\n * renders these.\n */\nfunction orgName(\n entityName: string | undefined,\n stored: string | undefined,\n s: Sanitizer,\n): string | undefined {\n return text(entityName, s) ?? text(stored, s);\n}\n\n/**\n * Build a JSON Resume v1.0.0 document from a Sifa profile.\n *\n * Hidden records are dropped. Keys are omitted rather than emitted empty, so a\n * profile with no publications produces a document with no `publications` key\n * instead of one a reader has to interpret.\n */\nexport function profileToJsonResume(\n profile: JsonResumeProfileInput,\n options: JsonResumeOptions = {},\n): JsonResume {\n const s = options.sanitize ?? identity;\n const baseUrl = normaliseBaseUrl(options.baseUrl);\n const canonical = options.canonicalUrl ?? profileUrl(baseUrl, profile.handle);\n const contact = normalizeExportContact(options.contact ?? {});\n\n const name =\n formatStructuredName(profile.givenName, profile.familyName) ??\n text(profile.displayName, s) ??\n profile.handle;\n\n const profiles = filterHidden(profile.externalAccounts).map((account) =>\n compact<JsonResumeProfileLink>({\n network: s(account.platform),\n username: text(account.label, s),\n url: text(account.url, s),\n }),\n );\n\n const basics = compact<JsonResumeBasics>({\n name,\n label: text(profile.headline, s),\n image: text(profile.avatar, s),\n email: text(contact.email, s),\n phone: text(contact.phone, s),\n url: text(profile.website, s) ?? canonical,\n summary: text(profile.about, s),\n location: withAddress(mapLocation(profile, s), text(contact.address, s)),\n ...section('profiles', profiles),\n });\n\n // Same order as the profile page and the other exports: newest first.\n const work = sortPositions(filterHidden(profile.positions)).map((position) =>\n compact<JsonResumeWork>({\n name: orgName(position.entityName, position.company, s),\n position: s(position.title),\n summary: text(position.description, s),\n startDate: toResumeDate(position.startedAt),\n endDate: toResumeDate(position.endedAt),\n }),\n );\n\n const volunteer = sortByActiveDateRange(filterHidden(profile.volunteering)).map((entry) =>\n compact<JsonResumeVolunteer>({\n organization: orgName(entry.entityName, entry.organization, s),\n position: text(entry.role, s),\n summary: text(entry.description, s),\n startDate: toResumeDate(entry.startDate),\n endDate: toResumeDate(entry.endDate),\n }),\n );\n\n const education = sortEducation(filterHidden(profile.education)).map((entry) =>\n compact<JsonResumeEducation>({\n institution: orgName(entry.entityName, entry.institution, s),\n area: text(entry.fieldOfStudy, s),\n studyType: text(entry.degree, s),\n startDate: toResumeDate(entry.startedAt),\n endDate: toResumeDate(entry.endedAt),\n }),\n );\n\n const awards = sortHonors(filterHidden(profile.honors)).map((honor) =>\n compact<JsonResumeAward>({\n title: s(honor.title),\n date: toResumeDate(honor.date),\n awarder: orgName(honor.entityName, honor.issuer, s),\n summary: text(honor.description, s),\n }),\n );\n\n const certificates = sortCertifications(filterHidden(profile.certifications)).map((cert) =>\n compact<JsonResumeCertificate>({\n name: s(cert.name),\n date: toResumeDate(cert.issueDate),\n // `issuingOrg` is the deprecated read-view alias for `authority`; records\n // indexed before the rename carry only the alias.\n issuer: orgName(cert.entityName, cert.authority ?? cert.issuingOrg, s),\n url: text(cert.credentialUrl, s),\n }),\n );\n\n const publications = sortPublications(filterHidden(profile.publications)).map((publication) =>\n compact<JsonResumePublication>({\n name: s(publication.title),\n publisher: text(publication.publisher, s),\n releaseDate: toResumeDate(publication.date),\n url: text(publication.url, s),\n summary: text(publication.description, s),\n }),\n );\n\n // One entry per skill rather than JSON Resume's grouped shape: Sifa stores one\n // record per skill, and keeping the two symmetric is what makes a round-trip\n // through a third-party editor safe. Category and endorsement counts have no\n // JSON Resume slot and are dropped. Skill records carry no `hidden` flag, so\n // there is nothing to filter here.\n const skills = (profile.skills ?? []).map((skill) => ({ name: s(skill.name) }));\n\n const languages = sortLanguages(filterHidden(profile.languages)).map((language) =>\n compact<JsonResumeLanguage>({\n language: s(language.language),\n fluency: language.proficiency ? FLUENCY_LABELS[language.proficiency] : undefined,\n }),\n );\n\n const projects = sortProjects(filterHidden(profile.projects)).map((project) =>\n compact<JsonResumeProject>({\n name: s(project.name),\n description: text(project.description, s),\n url: text(project.url, s),\n startDate: toResumeDate(project.startDate),\n endDate: toResumeDate(project.endDate),\n }),\n );\n\n return {\n basics,\n ...section('work', work),\n ...section('volunteer', volunteer),\n ...section('education', education),\n ...section('awards', awards),\n ...section('certificates', certificates),\n ...section('publications', publications),\n ...section('skills', skills),\n ...section('languages', languages),\n ...section('projects', projects),\n meta: { canonical, version: SCHEMA_VERSION },\n };\n}\n"],"mappings":";AAmBA,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AAgBtC,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,8BAAkD;AA8K3D,IAAM,iBAAiB;AAOvB,IAAM,iBAAiB;AAEhB,SAAS,aAAa,OAA+C;AAC1E,QAAM,UAAU,OAAO,KAAK;AAC5B,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,QAAQ,eAAe,KAAK,OAAO;AACzC,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC5B;AAOA,IAA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,CAAC;AAAA,MACxC,KAAK,KAAK,QAAQ,KAAK,CAAC;AAAA,MACxB,WAAW,aAAa,QAAQ,SAAS;AAAA,MACzC,SAAS,aAAa,QAAQ,OAAO;AAAA,IACvC,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL;AAAA,IACA,GAAG,QAAQ,QAAQ,IAAI;AAAA,IACvB,GAAG,QAAQ,aAAa,SAAS;AAAA,IACjC,GAAG,QAAQ,aAAa,SAAS;AAAA,IACjC,GAAG,QAAQ,UAAU,MAAM;AAAA,IAC3B,GAAG,QAAQ,gBAAgB,YAAY;AAAA,IACvC,GAAG,QAAQ,gBAAgB,YAAY;AAAA,IACvC,GAAG,QAAQ,UAAU,MAAM;AAAA,IAC3B,GAAG,QAAQ,aAAa,SAAS;AAAA,IACjC,GAAG,QAAQ,YAAY,QAAQ;AAAA,IAC/B,MAAM,EAAE,WAAW,SAAS,eAAe;AAAA,EAC7C;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/resume/json-resume.ts"],"sourcesContent":["/**\n * JSON Resume v1.0.0 emitter for a Sifa profile.\n *\n * https://jsonresume.org/schema/\n *\n * One pure function, no fetching, no DOM, no framework -- the same shape as the\n * JSON-LD emitter next door, and for the same reason: sifa.id, page.sifa.id and\n * any future consumer should emit one document from one implementation.\n *\n * Why this format earns its place: it is the lingua franca of CV tooling, so\n * emitting it hands a user every JSON Resume theme, and the Typst CV templates\n * on Typst Universe, without Sifa writing a renderer for any of them.\n *\n * Fields Sifa holds that JSON Resume has no slot for -- endorsements,\n * confirmations, involvement, investments, presentations, courses -- are\n * dropped rather than smuggled into a nearby field. The loss is documented for\n * the user at the point of download.\n */\n\nimport { parseLocationString } from '../format/location-utils.js';\nimport { formatStructuredName } from '../format/pds-utils.js';\nimport { filterHidden } from '../profile/section-model.js';\nimport {\n sortCertifications,\n sortEducation,\n sortHonors,\n sortLanguages,\n sortPositions,\n sortProjects,\n sortPublications,\n} from '../profile/section-sorts.js';\nimport { sortByActiveDateRange } from '../profile/range-sort.js';\nimport type {\n ExternalAccount,\n LanguageProficiency,\n LocationValue,\n ProfileCertification,\n ProfileEducation,\n ProfileHonor,\n ProfileLanguage,\n ProfileLocation,\n ProfilePosition,\n ProfileProject,\n ProfilePublication,\n ProfileSkill,\n ProfileVolunteering,\n} from '../types/index.js';\nimport { normaliseBaseUrl, profileUrl } from '../jsonld/url.js';\nimport { normalizeExportContact, type ExportContact } from './export-contact.js';\n\nexport type Sanitizer = (input: string) => string;\n\nexport interface JsonResumeOptions {\n /** Canonical origin for the profile URL. Defaults to `https://sifa.id`. */\n readonly baseUrl?: string;\n /** Applied to every user-authored string. Defaults to identity. */\n readonly sanitize?: Sanitizer;\n /**\n * Absolute URL of the profile this resume describes. Defaults to\n * `${baseUrl}/p/${handle}`. A personal site served from a custom domain is\n * not at that path.\n */\n readonly canonicalUrl?: string;\n /**\n * Email, phone and postal address to print. Sifa holds none of these; the\n * owner types them on the export page. Without it the resume has no\n * `email`, `phone` or `location.address`. Personal details in the same object\n * (driver's license, right to work, nationality) are left out: JSON Resume\n * has no field for them, and strict consumers such as altacv refuse a file\n * with an unknown key.\n */\n readonly contact?: ExportContact;\n}\n\n/**\n * The subset of `Profile` this emitter reads. Deliberately structural rather\n * than the full `Profile`, so a caller holding a partially hydrated profile --\n * or a test -- does not have to invent forty unrelated fields.\n */\nexport interface JsonResumeProfileInput {\n readonly handle: string;\n readonly displayName?: string;\n readonly givenName?: string;\n readonly familyName?: string;\n readonly avatar?: string;\n readonly headline?: string;\n readonly about?: string;\n readonly website?: string;\n /**\n * The structured location. The profile API sends a display string here\n * instead; the emitter then reads the primary entry of `locations`.\n */\n readonly location?: LocationValue | string | null;\n readonly locations?: ProfileLocation[];\n readonly positions?: ProfilePosition[];\n readonly education?: ProfileEducation[];\n readonly skills?: ProfileSkill[];\n readonly certifications?: ProfileCertification[];\n readonly projects?: ProfileProject[];\n readonly publications?: ProfilePublication[];\n readonly volunteering?: ProfileVolunteering[];\n readonly honors?: ProfileHonor[];\n readonly languages?: ProfileLanguage[];\n readonly externalAccounts?: ExternalAccount[];\n}\n\nexport interface JsonResumeLocation {\n /** Street address; lines are separated by `\\n`, as the schema asks. */\n readonly address?: string;\n readonly city?: string;\n readonly region?: string;\n readonly countryCode?: string;\n readonly postalCode?: string;\n}\n\nexport interface JsonResumeProfileLink {\n readonly network: string;\n readonly username?: string;\n readonly url?: string;\n}\n\nexport interface JsonResumeBasics {\n readonly name: string;\n readonly label?: string;\n readonly image?: string;\n readonly url?: string;\n readonly email?: string;\n readonly phone?: string;\n readonly summary?: string;\n readonly location?: JsonResumeLocation;\n readonly profiles?: JsonResumeProfileLink[];\n}\n\nexport interface JsonResumeWork {\n readonly name?: string;\n readonly position: string;\n readonly summary?: string;\n readonly startDate?: string;\n readonly endDate?: string;\n}\n\nexport interface JsonResumeVolunteer {\n /**\n * Omitted when the record carries no organization name at all. Emitting an\n * empty string would render as a blank organization line in a CV template.\n */\n readonly organization?: string;\n readonly position?: string;\n readonly summary?: string;\n readonly startDate?: string;\n readonly endDate?: string;\n}\n\nexport interface JsonResumeEducation {\n /** Omitted when the record carries no institution name. See volunteer. */\n readonly institution?: string;\n readonly area?: string;\n readonly studyType?: string;\n readonly startDate?: string;\n readonly endDate?: string;\n}\n\nexport interface JsonResumeAward {\n readonly title: string;\n readonly date?: string;\n readonly awarder?: string;\n readonly summary?: string;\n}\n\nexport interface JsonResumeCertificate {\n readonly name: string;\n readonly date?: string;\n readonly issuer?: string;\n readonly url?: string;\n}\n\nexport interface JsonResumePublication {\n readonly name: string;\n readonly publisher?: string;\n readonly releaseDate?: string;\n readonly url?: string;\n readonly summary?: string;\n}\n\nexport interface JsonResumeSkill {\n readonly name: string;\n}\n\nexport interface JsonResumeLanguage {\n readonly language: string;\n readonly fluency?: string;\n}\n\nexport interface JsonResumeProject {\n readonly name: string;\n readonly description?: string;\n readonly url?: string;\n readonly startDate?: string;\n readonly endDate?: string;\n}\n\nexport interface JsonResumeMeta {\n readonly canonical: string;\n readonly version: string;\n readonly lastModified?: string;\n}\n\nexport interface JsonResume {\n readonly basics?: JsonResumeBasics;\n readonly work?: JsonResumeWork[];\n readonly volunteer?: JsonResumeVolunteer[];\n readonly education?: JsonResumeEducation[];\n readonly awards?: JsonResumeAward[];\n readonly certificates?: JsonResumeCertificate[];\n readonly publications?: JsonResumePublication[];\n readonly skills?: JsonResumeSkill[];\n readonly languages?: JsonResumeLanguage[];\n readonly projects?: JsonResumeProject[];\n readonly meta?: JsonResumeMeta;\n}\n\n/** Schema version this emitter targets, as JSON Resume writes it in `meta`. */\nconst SCHEMA_VERSION = 'v1.0.0';\n\n/**\n * A date JSON Resume will accept: `YYYY`, `YYYY-MM` or `YYYY-MM-DD`. Sifa\n * stores RFC 3339 for some fields, and a full timestamp pasted into a CV\n * template renders as `2020-03-04T00:00:00.000Z` on the page.\n */\nconst RESUME_DATE_RE = /^(\\d{4})(-\\d{2})?(-\\d{2})?/;\n\nexport function toResumeDate(value: string | undefined): string | undefined {\n const trimmed = value?.trim();\n if (!trimmed) return undefined;\n const match = RESUME_DATE_RE.exec(trimmed);\n return match ? match[0] : undefined;\n}\n\n/**\n * JSON Resume's `fluency` is free text, so these are display labels rather\n * than a mapped vocabulary. Kept in one place so export and a future import\n * agree on the spelling.\n */\nconst FLUENCY_LABELS: Record<LanguageProficiency, string> = {\n elementary: 'Elementary',\n limited_working: 'Limited working',\n professional_working: 'Professional working',\n full_professional: 'Full professional',\n native: 'Native or bilingual',\n};\n\nconst identity: Sanitizer = (input) => input;\n\n/** Drops keys whose value is undefined, so the document carries no empty slots. */\nfunction compact<T extends object>(value: T): T {\n return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined)) as T;\n}\n\n/** Adds the owner's street address to the profile's location. */\nfunction withAddress(\n location: JsonResumeLocation | undefined,\n address: string | undefined,\n): JsonResumeLocation | undefined {\n return address ? { address, ...location } : location;\n}\n\n/** Omits the key entirely when the mapped list came out empty. */\nfunction section<K extends string, T>(key: K, items: T[]): Record<K, T[]> | undefined {\n return items.length > 0 ? ({ [key]: items } as Record<K, T[]>) : undefined;\n}\n\n/**\n * The first of these that yields anything: the structured `location` object;\n * the primary entry of `locations` (or the first entry when none is marked\n * primary), which is what the profile API sends; a display-string `location`,\n * split into city and region. JSON Resume has no field for a country name, so a\n * country-only location maps to nothing.\n */\nfunction mapLocation(\n profile: Pick<JsonResumeProfileInput, 'location' | 'locations'>,\n s: Sanitizer,\n): JsonResumeLocation | undefined {\n const fromValue = (location: LocationValue | null | undefined) =>\n location\n ? compact<JsonResumeLocation>({\n city: text(location.locality || location.city, s),\n region: text(location.region, s),\n countryCode: text(location.countryCode, s),\n postalCode: text(location.postalCode, s),\n })\n : {};\n const entry = profile.locations?.find((l) => l.isPrimary) ?? profile.locations?.[0];\n const candidates: JsonResumeLocation[] = [\n typeof profile.location === 'object' ? fromValue(profile.location) : {},\n entry\n ? compact<JsonResumeLocation>({\n city: text((entry.locationLocality || entry.locationCity) ?? undefined, s),\n region: text(entry.locationRegion ?? undefined, s),\n countryCode: text(entry.countryCode ?? undefined, s),\n })\n : {},\n typeof profile.location === 'string' ? fromValue(parseLocationString(profile.location)) : {},\n ];\n return candidates.find((c) => Object.keys(c).length > 0);\n}\n\n/**\n * A link field as a valid URI. A bare domain (\"example.com\") gets `https://`;\n * anything else that does not parse is left out. JSON Resume declares these as\n * URIs, and strict consumers such as altacv refuse the whole file otherwise.\n */\nfunction link(value: string | undefined, s: Sanitizer): string | undefined {\n // No whitespace belongs in a link; a pasted space made altacv refuse a real\n // ORCID URL that the URL parser itself accepts.\n const t = value?.replace(/\\s+/g, '');\n if (!t) return undefined;\n // Checked before sanitizing, so the sanitizer still sees every value.\n if (/^[a-z][a-z0-9+.-]*:\\/\\//i.test(t)) return URL.canParse(t) ? s(t) : undefined;\n const withScheme = `https://${t}`;\n return /^[^\\s/]+\\.[^\\s/]+/.test(t) && URL.canParse(withScheme) ? s(withScheme) : undefined;\n}\n\n/** Trimmed, sanitised, and undefined when there is nothing left. */\nfunction text(value: string | undefined, s: Sanitizer): string | undefined {\n const trimmed = value?.trim();\n return trimmed ? s(trimmed) : undefined;\n}\n\n/**\n * The name to print for a linked organization. `entityName` is the AppView's\n * resolved current name and wins when present, matching how the profile itself\n * renders these.\n */\nfunction orgName(\n entityName: string | undefined,\n stored: string | undefined,\n s: Sanitizer,\n): string | undefined {\n return text(entityName, s) ?? text(stored, s);\n}\n\n/**\n * Build a JSON Resume v1.0.0 document from a Sifa profile.\n *\n * Hidden records are dropped. Keys are omitted rather than emitted empty, so a\n * profile with no publications produces a document with no `publications` key\n * instead of one a reader has to interpret.\n */\nexport function profileToJsonResume(\n profile: JsonResumeProfileInput,\n options: JsonResumeOptions = {},\n): JsonResume {\n const s = options.sanitize ?? identity;\n const baseUrl = normaliseBaseUrl(options.baseUrl);\n const canonical = options.canonicalUrl ?? profileUrl(baseUrl, profile.handle);\n const contact = normalizeExportContact(options.contact ?? {});\n\n const name =\n formatStructuredName(profile.givenName, profile.familyName) ??\n text(profile.displayName, s) ??\n profile.handle;\n\n const profiles = filterHidden(profile.externalAccounts).map((account) =>\n compact<JsonResumeProfileLink>({\n network: s(account.platform),\n username: text(account.label, s),\n url: link(account.url, s),\n }),\n );\n\n const basics = compact<JsonResumeBasics>({\n name,\n label: text(profile.headline, s),\n image: text(profile.avatar, s),\n email: text(contact.email, s),\n phone: text(contact.phone, s),\n url: link(profile.website, s) ?? canonical,\n summary: text(profile.about, s),\n location: withAddress(mapLocation(profile, s), text(contact.address, s)),\n ...section('profiles', profiles),\n });\n\n // Same order as the profile page and the other exports: newest first.\n const work = sortPositions(filterHidden(profile.positions)).map((position) =>\n compact<JsonResumeWork>({\n name: orgName(position.entityName, position.company, s),\n position: s(position.title),\n summary: text(position.description, s),\n startDate: toResumeDate(position.startedAt),\n endDate: toResumeDate(position.endedAt),\n }),\n );\n\n const volunteer = sortByActiveDateRange(filterHidden(profile.volunteering)).map((entry) =>\n compact<JsonResumeVolunteer>({\n organization: orgName(entry.entityName, entry.organization, s),\n position: text(entry.role, s),\n summary: text(entry.description, s),\n startDate: toResumeDate(entry.startDate),\n endDate: toResumeDate(entry.endDate),\n }),\n );\n\n const education = sortEducation(filterHidden(profile.education)).map((entry) =>\n compact<JsonResumeEducation>({\n institution: orgName(entry.entityName, entry.institution, s),\n area: text(entry.fieldOfStudy, s),\n studyType: text(entry.degree, s),\n startDate: toResumeDate(entry.startedAt),\n endDate: toResumeDate(entry.endedAt),\n }),\n );\n\n const awards = sortHonors(filterHidden(profile.honors)).map((honor) =>\n compact<JsonResumeAward>({\n title: s(honor.title),\n date: toResumeDate(honor.date),\n awarder: orgName(honor.entityName, honor.issuer, s),\n summary: text(honor.description, s),\n }),\n );\n\n const certificates = sortCertifications(filterHidden(profile.certifications)).map((cert) =>\n compact<JsonResumeCertificate>({\n name: s(cert.name),\n date: toResumeDate(cert.issueDate),\n // `issuingOrg` is the deprecated read-view alias for `authority`; records\n // indexed before the rename carry only the alias.\n issuer: orgName(cert.entityName, cert.authority ?? cert.issuingOrg, s),\n url: link(cert.credentialUrl, s),\n }),\n );\n\n const publications = sortPublications(filterHidden(profile.publications)).map((publication) =>\n compact<JsonResumePublication>({\n name: s(publication.title),\n publisher: text(publication.publisher, s),\n releaseDate: toResumeDate(publication.date),\n url: link(publication.url, s),\n summary: text(publication.description, s),\n }),\n );\n\n // One entry per skill rather than JSON Resume's grouped shape: Sifa stores one\n // record per skill, and keeping the two symmetric is what makes a round-trip\n // through a third-party editor safe. Category and endorsement counts have no\n // JSON Resume slot and are dropped. Skill records carry no `hidden` flag, so\n // there is nothing to filter here.\n const skills = (profile.skills ?? []).map((skill) => ({ name: s(skill.name) }));\n\n const languages = sortLanguages(filterHidden(profile.languages)).map((language) =>\n compact<JsonResumeLanguage>({\n language: s(language.language),\n fluency: language.proficiency ? FLUENCY_LABELS[language.proficiency] : undefined,\n }),\n );\n\n const projects = sortProjects(filterHidden(profile.projects)).map((project) =>\n compact<JsonResumeProject>({\n name: s(project.name),\n description: text(project.description, s),\n url: link(project.url, s),\n startDate: toResumeDate(project.startDate),\n endDate: toResumeDate(project.endDate),\n }),\n );\n\n return {\n basics,\n ...section('work', work),\n ...section('volunteer', volunteer),\n ...section('education', education),\n ...section('awards', awards),\n ...section('certificates', certificates),\n ...section('publications', publications),\n ...section('skills', skills),\n ...section('languages', languages),\n ...section('projects', projects),\n meta: { canonical, version: SCHEMA_VERSION },\n };\n}\n"],"mappings":";AAmBA,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AAgBtC,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,8BAAkD;AA8K3D,IAAM,iBAAiB;AAOvB,IAAM,iBAAiB;AAEhB,SAAS,aAAa,OAA+C;AAC1E,QAAM,UAAU,OAAO,KAAK;AAC5B,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,QAAQ,eAAe,KAAK,OAAO;AACzC,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC5B;AAOA,IAAM,iBAAsD;AAAA,EAC1D,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB,QAAQ;AACV;AAEA,IAAM,WAAsB,CAAC,UAAU;AAGvC,SAAS,QAA0B,OAAa;AAC9C,SAAO,OAAO,YAAY,OAAO,QAAQ,KAAK,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,MAAM,MAAS,CAAC;AACpF;AAGA,SAAS,YACP,UACA,SACgC;AAChC,SAAO,UAAU,EAAE,SAAS,GAAG,SAAS,IAAI;AAC9C;AAGA,SAAS,QAA6B,KAAQ,OAAwC;AACpF,SAAO,MAAM,SAAS,IAAK,EAAE,CAAC,GAAG,GAAG,MAAM,IAAuB;AACnE;AASA,SAAS,YACP,SACA,GACgC;AAChC,Q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