@singi-labs/sifa-sdk 0.19.112 → 0.20.1
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/dist/badge/index.cjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/{network-map-CrkLq2Gz.d.ts → network-map-2OKh3wSB.d.ts} +2 -2
- package/dist/{network-map-BwM-Wvxt.d.cts → network-map-DJonNOl0.d.cts} +2 -2
- package/dist/{profile-summary-TkVxvll4.d.cts → profile-summary-BCOKt3qS.d.cts} +1 -1
- package/dist/{profile-summary-CwJymH9d.d.ts → profile-summary-DF8-evvA.d.ts} +1 -1
- package/dist/query/client.js +2 -1
- package/dist/query/client.js.map +1 -1
- package/dist/query/fetchers/index.cjs +2 -1
- package/dist/query/fetchers/index.cjs.map +1 -1
- package/dist/query/fetchers/index.d.cts +5 -5
- package/dist/query/fetchers/index.d.ts +5 -5
- package/dist/query/fetchers/org.js.map +1 -1
- package/dist/query/hooks/index.cjs +2 -1
- package/dist/query/hooks/index.cjs.map +1 -1
- package/dist/query/hooks/index.d.cts +3 -3
- package/dist/query/hooks/index.d.ts +3 -3
- package/dist/query/index.cjs +2 -1
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +8 -8
- package/dist/query/index.d.ts +8 -8
- package/dist/resume/index.cjs +148 -24
- package/dist/resume/index.cjs.map +1 -1
- package/dist/resume/index.d.cts +20 -5
- package/dist/resume/index.d.ts +20 -5
- package/dist/resume/json-resume.js +67 -5
- package/dist/resume/json-resume.js.map +1 -1
- package/dist/{types-CQA_vO39.d.ts → types-CkomzDlY.d.ts} +11 -2
- package/dist/{types-DMTHqi2m.d.cts → types-JydVIhN5.d.cts} +11 -2
- package/dist/{use-user-settings-1zgi6qwl.d.ts → use-user-settings-CrS3ZXoW.d.ts} +2 -2
- package/dist/{use-user-settings-BmuAd8D4.d.cts → use-user-settings-YIv1C3qN.d.cts} +2 -2
- package/dist/{user-settings-Btvrox4G.d.ts → user-settings-Bvafly0r.d.ts} +3 -2
- package/dist/{user-settings-D4vdBf0A.d.cts → user-settings-DWq91Gj-.d.cts} +3 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/resume/export-contact.ts","../../src/format/location-utils.ts","../../src/format/pds-utils.ts","../../src/profile/section-model.ts","../../src/format/sort-by-date.ts","../../src/profile/range-sort.ts","../../src/format/compare-text.ts","../../src/profile/language-sort.ts","../../src/profile/section-sorts.ts","../../src/jsonld/url.ts","../../src/resume/json-resume.ts","../../src/taxonomy/course-role.ts","../../src/resume/funder-cv.ts"],"names":["z","text","compact"],"mappings":";;;;;AAcO,IAAM,qBAAA,GAAwB;AAAA,EACnC,KAAA,EAAO,GAAA;AAAA,EACP,KAAA,EAAO,EAAA;AAAA,EACP,OAAA,EAAS,GAAA;AAAA,EACT,cAAA,EAAgB,EAAA;AAAA,EAChB,WAAA,EAAa,GAAA;AAAA,EACb,WAAA,EAAa;AACf;AAoCO,IAAM,mBAAA,GAAsBA,MAAE,YAAA,CAAa;AAAA,EAChD,KAAA,EAAOA,MAAE,MAAA,EAAO,CAAE,IAAI,qBAAA,CAAsB,KAAK,EAAE,QAAA,EAAS;AAAA,EAC5D,KAAA,EAAOA,MAAE,MAAA,EAAO,CAAE,IAAI,qBAAA,CAAsB,KAAK,EAAE,QAAA,EAAS;AAAA,EAC5D,OAAA,EAASA,MAAE,MAAA,EAAO,CAAE,IAAI,qBAAA,CAAsB,OAAO,EAAE,QAAA,EAAS;AAAA,EAChE,cAAA,EAAgBA,MAAE,MAAA,EAAO,CAAE,IAAI,qBAAA,CAAsB,cAAc,EAAE,QAAA,EAAS;AAAA,EAC9E,WAAA,EAAaA,MAAE,MAAA,EAAO,CAAE,IAAI,qBAAA,CAAsB,WAAW,EAAE,QAAA,EAAS;AAAA,EACxE,WAAA,EAAaA,MAAE,MA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A,EAAU,GAAG,OAAO,CAAA;AAAA,IAChD,OAAA,EAAS,IAAA;AAAA,IACT,YAAA,EAAc;AAAA,GAChB;AACF","file":"index.cjs","sourcesContent":["/**\n * Private contact and personal details for exports: email, phone, postal\n * address, driver's license, right to work and nationality.\n *\n * Sifa never stores these and never writes them to the owner's PDS, where they\n * would be public. The owner types them on the export page, the browser keeps\n * them, and they go only into the files the owner downloads. This module holds\n * the shape, the limits and the pick rule, so the export page and the server\n * that builds a funder CV agree on them.\n */\n\nimport { z } from 'zod';\n\n/** Longest value accepted per field. 254 is the longest valid email address. */\nexport const EXPORT_CONTACT_LIMITS = {\n email: 254,\n phone: 40,\n address: 500,\n driversLicense: 60,\n rightToWork: 200,\n nationality: 100,\n} as const;\n\n/** The contact details that go into an export. Absent keys are left out. */\nexport interface ExportContact {\n readonly email?: string;\n readonly phone?: string;\n /** Free text; lines are separated by `\\n`. */\n readonly address?: string;\n /** License categories, e.g. \"B, BE\". */\n readonly driversLicense?: string;\n /** e.g. \"EU citizen, no sponsorship needed\". */\n readonly rightToWork?: string;\n readonly nationality?: string;\n}\n\n/** What the owner has typed, plus which fields they chose to include. */\nexport interface ExportContactDraft {\n readonly email?: string;\n readonly phone?: string;\n readonly address?: string;\n readonly driversLicense?: string;\n readonly rightToWork?: string;\n readonly nationality?: string;\n readonly includeEmail?: boolean;\n readonly includePhone?: boolean;\n readonly includeAddress?: boolean;\n readonly includeDriversLicense?: boolean;\n readonly includeRightToWork?: boolean;\n readonly includeNationality?: boolean;\n}\n\n/**\n * Validates a picked contact. Only lengths are checked: phone numbers and\n * addresses vary too much between countries, and a wrong-looking email is a\n * warning for the owner, not a reason to refuse the export.\n */\nexport const exportContactSchema = z.strictObject({\n email: z.string().max(EXPORT_CONTACT_LIMITS.email).optional(),\n phone: z.string().max(EXPORT_CONTACT_LIMITS.phone).optional(),\n address: z.string().max(EXPORT_CONTACT_LIMITS.address).optional(),\n driversLicense: z.string().max(EXPORT_CONTACT_LIMITS.driversLicense).optional(),\n rightToWork: z.string().max(EXPORT_CONTACT_LIMITS.rightToWork).optional(),\n nationality: z.string().max(EXPORT_CONTACT_LIMITS.nationality).optional(),\n});\n\n/**\n * The fields to put in an export: the included ones that are not blank, run\n * through {@link normalizeExportContact}.\n */\nexport function pickExportContact(draft: ExportContactDraft): ExportContact {\n return normalizeExportContact({\n email: draft.includeEmail ? draft.email : undefined,\n phone: draft.includePhone ? draft.phone : undefined,\n address: draft.includeAddress ? draft.address : undefined,\n driversLicense: draft.includeDriversLicense ? draft.driversLicense : undefined,\n rightToWork: draft.includeRightToWork ? draft.rightToWork : undefined,\n nationality: draft.includeNationality ? draft.nationality : undefined,\n });\n}\n\n/**\n * Drops blank fields and tidies the rest. Every field but the address becomes\n * one line with single spaces. An address keeps its line breaks but loses blank lines and the\n * spaces around each line. Each field is cut at its {@link EXPORT_CONTACT_LIMITS}\n * length. The emitters call this too, so a caller that skips\n * {@link pickExportContact} and the schema gets the same bounded output.\n */\nexport function normalizeExportContact(contact: ExportContact): ExportContact {\n const email = cap(oneLine(contact.email), EXPORT_CONTACT_LIMITS.email);\n const phone = cap(oneLine(contact.phone), EXPORT_CONTACT_LIMITS.phone);\n const address = cap(lines(contact.address), EXPORT_CONTACT_LIMITS.address);\n const driversLicense = cap(oneLine(contact.driversLicense), EXPORT_CONTACT_LIMITS.driversLicense);\n const rightToWork = cap(oneLine(contact.rightToWork), EXPORT_CONTACT_LIMITS.rightToWork);\n const nationality = cap(oneLine(contact.nationality), EXPORT_CONTACT_LIMITS.nationality);\n return {\n ...(email ? { email } : {}),\n ...(phone ? { phone } : {}),\n ...(address ? { address } : {}),\n ...(driversLicense ? { driversLicense } : {}),\n ...(rightToWork ? { rightToWork } : {}),\n ...(nationality ? { nationality } : {}),\n };\n}\n\n/** A loose shape check for a non-blocking \"check this address\" hint. */\nexport function looksLikeEmail(value: string): boolean {\n const trimmed = value.trim();\n if (/\\s/.test(trimmed)) return false;\n const parts = trimmed.split('@');\n if (parts.length !== 2) return false;\n const [local, domain] = parts as [string, string];\n const dot = domain.lastIndexOf('.');\n return local.length > 0 && dot > 0 && dot < domain.length - 1;\n}\n\nfunction cap(value: string | undefined, max: number): string | undefined {\n if (value === undefined) return undefined;\n let cut = value.slice(0, max);\n // Never leave half of a surrogate pair (an emoji, say) at the cut.\n if (/[\\uD800-\\uDBFF]$/.test(cut)) cut = cut.slice(0, -1);\n return cut.trimEnd();\n}\n\nfunction oneLine(value: string | undefined): string | undefined {\n const collapsed = value?.replace(/\\s+/g, ' ').trim();\n return collapsed ? collapsed : undefined;\n}\n\nfunction lines(value: string | undefined): string | undefined {\n const kept = (value ?? '')\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .filter(Boolean);\n return kept.length > 0 ? kept.join('\\n') : undefined;\n}\n","import type { LocationValue } from '../types/index.js';\n\n/**\n * Format a LocationValue for display.\n *\n * Prefers `locality` (the community.lexicon.location.address field) and\n * falls back to the legacy `city` slot so values produced before the\n * sifa-api alias migration still render correctly during the additive\n * transition window.\n */\nexport function formatLocation(loc: LocationValue | null | undefined): string {\n if (!loc) return '';\n const locality = loc.locality ?? loc.city;\n const parts = [locality, loc.region, loc.country].filter(Boolean);\n if (loc.postalCode && !locality) {\n return `${loc.postalCode}, ${loc.country}`;\n }\n return parts.join(', ');\n}\n\n/** Parse a display string back into a LocationValue (best-effort for legacy data) */\nexport function parseLocationString(str: string): LocationValue | null {\n if (!str.trim()) return null;\n const parts = str\n .split(',')\n .map((p) => p.trim())\n .filter(Boolean);\n if (parts.length >= 3) {\n return {\n city: parts[0],\n region: parts[1],\n country: parts[parts.length - 1]!,\n };\n }\n if (parts.length === 2) {\n return {\n city: parts[0],\n country: parts[1]!,\n };\n }\n return { country: parts[0]! };\n}\n\n/** Convert ISO 3166-1 alpha-2 country code to flag emoji */\nexport function countryCodeToFlag(code: string | undefined): string {\n if (!code || code.length !== 2) return '';\n const upper = code.toUpperCase();\n const a = upper.codePointAt(0);\n const b = upper.codePointAt(1);\n if (a === undefined || b === undefined) return '';\n return String.fromCodePoint(a - 0x41 + 0x1f1e6, b - 0x41 + 0x1f1e6);\n}\n","import type { PdsProviderInfo } from '../types/index.js';\n\nexport interface PdsProvider {\n name: string;\n profileUrl: string;\n host?: string;\n}\n\nconst BSKY_PROFILE_BASE = 'https://bsky.app/profile/';\n\nconst PDS_PROVIDERS: { suffix: string; name: string }[] = [\n { suffix: '.bsky.social', name: 'bluesky' },\n { suffix: '.blacksky.app', name: 'blacksky' },\n { suffix: '.eurosky.social', name: 'eurosky' },\n { suffix: '.northsky.social', name: 'northsky' },\n];\n\nconst KNOWN_PROVIDER_NAMES = new Set(PDS_PROVIDERS.map((p) => p.name));\n\nconst ICON_ONLY_PROVIDERS = new Set(['selfhosted-social', 'selfhosted']);\n\nexport function pdsProviderFromApi(\n apiProvider: PdsProviderInfo | null | undefined,\n handle: string,\n): PdsProvider | null {\n if (!apiProvider) return null;\n if (ICON_ONLY_PROVIDERS.has(apiProvider.name)) {\n return { name: apiProvider.name, profileUrl: '', host: apiProvider.host };\n }\n if (!KNOWN_PROVIDER_NAMES.has(apiProvider.name)) return null;\n return {\n name: apiProvider.name,\n profileUrl: `${BSKY_PROFILE_BASE}${handle}`,\n host: apiProvider.host,\n };\n}\n\nexport function getHandleStem(handle: string): string {\n const lower = handle.toLowerCase();\n for (const provider of PDS_PROVIDERS) {\n if (lower.endsWith(provider.suffix) && lower.length > provider.suffix.length) {\n return handle.slice(0, -provider.suffix.length);\n }\n }\n return handle;\n}\n\nexport function getDisplayLabel(displayName: string | undefined, handle: string): string {\n if (displayName) return displayName;\n return getHandleStem(handle);\n}\n\n/**\n * Combine optional structured name fields (`id.sifa.profile.self.givenName`,\n * `familyName`) into a single string in Schema.org `Person` order — given\n * before family. Returns `undefined` when both are absent so callers can\n * fall back to `displayName`. Whitespace-only inputs are treated as absent.\n * Does not impose cultural ordering: users whose preferred presentation\n * differs (e.g. Eastern name order) should set `displayName` accordingly,\n * which this helper deliberately does not consult.\n */\nexport function formatStructuredName(\n givenName: string | undefined,\n familyName: string | undefined,\n): string | undefined {\n const given = givenName?.trim();\n const family = familyName?.trim();\n if (given && family) return `${given} ${family}`;\n return given || family || undefined;\n}\n\nconst PDS_DISPLAY_NAMES: Record<string, string> = {\n bluesky: 'Bluesky',\n blacksky: 'BlackSky',\n eurosky: 'EuroSky',\n northsky: 'NorthSky',\n 'selfhosted-social': 'Self-hosted',\n selfhosted: 'Self-hosted',\n};\n\nexport function getPdsDisplayName(providerName: string): string {\n return PDS_DISPLAY_NAMES[providerName] ?? providerName;\n}\n\nexport function detectPdsProvider(handle: string): PdsProvider | null {\n const lower = handle.toLowerCase();\n for (const provider of PDS_PROVIDERS) {\n if (lower.endsWith(provider.suffix)) {\n return {\n name: provider.name,\n profileUrl: `${BSKY_PROFILE_BASE}${handle}`,\n };\n }\n }\n return null;\n}\n","/**\n * Shared, single-source-of-truth model for which profile sections render, in\n * what order, their nav grouping, and which items a given viewer may see.\n *\n * Every Sifa profile surface builds on this: the HTML profile page, the\n * Markdown / DOCX / print exports, and the standalone personal-site renderer.\n * Adding a section to {@link ALL_SECTIONS} makes it appear everywhere (the\n * exports drive presence + order from here, and {@link SECTION_LABELS} is an\n * exhaustive `Record<SectionId, string>`, so a new id is a compile error until\n * it has a label).\n *\n * The per-section sorts live in `./section-sorts.js`, built on the same SDK\n * date extractors the HTML section components use, so the surfaces cannot\n * diverge on ordering.\n */\n\nimport type { Profile } from '../types/index.js';\n\n/**\n * Side-nav groups, in display order. Each labels a contiguous run of sections\n * in {@link ALL_SECTIONS}. `labelKey` resolves against the consumer's `sections`\n * i18n namespace.\n */\nexport const SECTION_GROUPS = [\n { id: 'overview', labelKey: 'groupOverview' },\n { id: 'experience', labelKey: 'groupExperience' },\n { id: 'qualifications', labelKey: 'groupQualifications' },\n { id: 'more', labelKey: 'groupMore' },\n] as const;\n\nexport type SectionGroupId = (typeof SECTION_GROUPS)[number]['id'];\n\n/**\n * Profile body sections in render + nav order (evidence-first): identity and\n * activity lead, then living work (career, projects, talks, publications, then\n * skills), then the formal record (credentials, education, courses), then the\n * rest. `ns` selects the consumer's i18n namespace for `labelKey`; `group`\n * ties the section to a {@link SECTION_GROUPS} header.\n */\nexport const ALL_SECTIONS = [\n { id: 'about', labelKey: 'about', ns: 'profile' as const, group: 'overview' as const },\n { id: 'career', labelKey: 'career', ns: 'sections' as const, group: 'experience' as const },\n { id: 'projects', labelKey: 'projects', ns: 'sections' as const, group: 'experience' as const },\n {\n id: 'presentations',\n labelKey: 'talksAndSessions',\n ns: 'sections' as const,\n group: 'experience' as const,\n },\n {\n id: 'publications',\n labelKey: 'publications',\n ns: 'sections' as const,\n group: 'experience' as const,\n },\n { id: 'skills', labelKey: 'skills', ns: 'sections' as const, group: 'experience' as const },\n {\n id: 'credentials',\n labelKey: 'credentials',\n ns: 'sections' as const,\n group: 'qualifications' as const,\n },\n {\n id: 'education',\n labelKey: 'education',\n ns: 'sections' as const,\n group: 'qualifications' as const,\n },\n { id: 'courses', labelKey: 'courses', ns: 'sections' as const, group: 'qualifications' as const },\n { id: 'awards', labelKey: 'awards', ns: 'sections' as const, group: 'more' as const },\n { id: 'involvement', labelKey: 'involvement', ns: 'sections' as const, group: 'more' as const },\n // Its own section rather than a group under involvement: that record is about\n // work contributed, this one about capital deployed.\n { id: 'investments', labelKey: 'investments', ns: 'sections' as const, group: 'more' as const },\n { id: 'languages', labelKey: 'languages', ns: 'sections' as const, group: 'more' as const },\n {\n id: 'other-profiles',\n labelKey: 'otherProfiles',\n ns: 'sections' as const,\n group: 'more' as const,\n },\n] as const;\n\n/** Every profile section id, in canonical render order. */\nexport type SectionId = (typeof ALL_SECTIONS)[number]['id'];\n\n/**\n * Whether a section has content a visitor can see (used to hide empty nav\n * entries and sections for visitors). Items the owner hid do not count: a\n * section whose only entries are hidden renders nothing for a visitor, so it\n * must not get a nav entry either.\n */\nexport function isSectionPopulated(profile: Profile, id: string): boolean {\n const hasVisible = <T extends { hidden?: boolean }>(items: T[] | undefined): boolean =>\n filterHidden(items).length > 0;\n switch (id) {\n case 'about':\n // Text fields, not hideable items. Without a headline the summary shows\n // in the identity card instead, so the About section stays out of it.\n return Boolean(profile.about && profile.headline);\n case 'career':\n return hasVisible(profile.positions);\n case 'education':\n return hasVisible(profile.education);\n case 'courses':\n return hasVisible(profile.courses);\n case 'skills':\n // Skills have no owner-hide flag (`ProfileSkill` carries no `hidden`).\n return Boolean(profile.skills?.length);\n case 'projects':\n return hasVisible(profile.projects);\n case 'credentials':\n return hasVisible(profile.certifications);\n case 'publications':\n return hasVisible(profile.publications);\n case 'presentations':\n return hasVisible(profile.presentations) || hasVisible(profile.presentationDeliveries);\n case 'involvement':\n return hasVisible(profile.involvement);\n case 'investments':\n return hasVisible(profile.investments);\n case 'awards':\n return hasVisible(profile.honors);\n case 'languages':\n return hasVisible(profile.languages);\n case 'other-profiles':\n return hasVisible(profile.externalAccounts);\n default:\n return false;\n }\n}\n\n/**\n * The section ids a given viewer should see, in {@link ALL_SECTIONS} order.\n * Owners see every section; visitors only see populated ones.\n */\nexport function getVisibleSectionIds(profile: Profile, isOwnProfile: boolean): SectionId[] {\n return ALL_SECTIONS.map((s) => s.id).filter(\n (id) => isOwnProfile || isSectionPopulated(profile, id),\n );\n}\n\n/** Drop items the owner has hidden from visitors. */\nexport function filterHidden<T extends { hidden?: boolean }>(items: T[] | undefined): T[] {\n return (items ?? []).filter((i) => !i.hidden);\n}\n\n/**\n * Items visible to a given viewer: owners see their own hidden items, visitors\n * do not. Shared by every export format (markdown, docx, print) and the public\n * `.md` route so the hidden rule lives in one place.\n */\nexport function visibleItems<T extends { hidden?: boolean }>(\n items: T[] | undefined,\n isOwnProfile: boolean,\n): T[] {\n return isOwnProfile ? (items ?? []) : filterHidden(items);\n}\n\n/**\n * English heading text for each section, keyed by {@link SectionId} (e.g.\n * `other-profiles` renders as \"Links\"). Exhaustive `Record<SectionId, string>`:\n * adding a section to {@link ALL_SECTIONS} without a label here is a compile\n * error, so a section can never silently render without (or with a stale)\n * heading. Consumers with i18n resolve their own localized labels via\n * `labelKey`; this is the canonical English fallback used by the exports.\n */\nexport const SECTION_LABELS: Record<SectionId, string> = {\n about: 'About',\n career: 'Career',\n skills: 'Skills',\n projects: 'Projects',\n presentations: 'Talks & sessions',\n publications: 'Publications',\n credentials: 'Credentials',\n education: 'Education',\n courses: 'Courses',\n awards: 'Awards',\n involvement: 'Involvement',\n investments: 'Investments',\n languages: 'Languages',\n 'other-profiles': 'Links',\n};\n","/**\n * Sort profile section items from newest to oldest.\n *\n * Rules:\n * - Items with no end date (ongoing/current) sort to the top.\n * - Primary sort: end date descending (newest first).\n * - Secondary sort: start date descending (newest first).\n * - Items with no dates sort to the bottom.\n *\n * Date strings are ISO-ish (\"2024\", \"2024-03\", \"2024-03-15\") and\n * lexicographic comparison works correctly for them.\n */\n\ninterface DateRange {\n startDate?: string;\n endDate?: string;\n current?: boolean;\n}\n\ntype DateExtractor<T> = (item: T) => DateRange;\n\nconst FAR_FUTURE = '9999-12-31';\nconst FAR_PAST = '0000-01-01';\n\nexport function sortByDateDesc<T>(items: T[], extract: DateExtractor<T>): T[] {\n return [...items].sort((a, b) => {\n const da = extract(a);\n const db = extract(b);\n\n const endA = da.current ? FAR_FUTURE : (da.endDate ?? '');\n const endB = db.current ? FAR_FUTURE : (db.endDate ?? '');\n\n // Items with any date beat items with no dates at all\n const hasDateA = endA || da.startDate;\n const hasDateB = endB || db.startDate;\n if (hasDateA && !hasDateB) return -1;\n if (!hasDateA && hasDateB) return 1;\n\n // Primary: end date descending\n if (endA !== endB) return endB.localeCompare(endA);\n\n // Secondary: start date descending\n const startA = da.startDate ?? FAR_PAST;\n const startB = db.startDate ?? FAR_PAST;\n return startB.localeCompare(startA);\n });\n}\n\n/**\n * Convenience extractor for items that use `startDate` / `endDate` fields directly.\n * Used by volunteering, projects, and other sections that still use startDate/endDate.\n */\nexport function dateRangeExtractor<\n T extends { startDate?: string; endDate?: string; current?: boolean },\n>(item: T): DateRange {\n return { startDate: item.startDate, endDate: item.endDate, current: item.current };\n}\n\n/**\n * Extractor for lexicon-aligned items that use `startedAt` / `endedAt` fields.\n * Used by positions and education (current derived from !endedAt).\n */\nexport function lexiconDateExtractor<T extends { startedAt?: string; endedAt?: string }>(\n item: T,\n): DateRange {\n return { startDate: item.startedAt, endDate: item.endedAt, current: !item.endedAt };\n}\n\n/**\n * Convenience extractor for items with a single `date` field.\n */\nexport function singleDateExtractor<T extends { date?: string }>(item: T): DateRange {\n return { endDate: item.date };\n}\n\n/**\n * Extractor for certifications which use `issueDate` / `expiryDate`.\n */\nexport function certDateExtractor<T extends { issueDate?: string; expiryDate?: string }>(\n item: T,\n): DateRange {\n return { startDate: item.issueDate, endDate: item.expiryDate ?? item.issueDate };\n}\n","import { sortByDateDesc } from '../format/sort-by-date.js';\n\nconst hasValue = (date?: string) => !!date;\n\n/**\n * Sort items by date range, floating ongoing entries (startDate present, endDate\n * absent) to the top. Items with no dates sink to the bottom.\n *\n * Used by sections whose lexicons have no explicit `current` flag -- ongoing is\n * implicit from a missing endDate. Without this wrapper, the shared\n * `dateRangeExtractor` reads `item.current` (always undefined for these items)\n * and sinks ongoing entries below completed ones.\n *\n * Sections using lexicon-aligned `startedAt`/`endedAt` fields (positions,\n * education) should use `lexiconDateExtractor` instead -- that extractor already\n * derives `current` correctly.\n */\nexport function sortByActiveDateRange<T extends { startDate?: string; endDate?: string }>(\n items: T[],\n): T[] {\n return sortByDateDesc(items, (p) => ({\n startDate: p.startDate,\n endDate: p.endDate,\n current: !hasValue(p.endDate) && hasValue(p.startDate),\n }));\n}\n","const COLLATOR = new Intl.Collator('en');\n\n/**\n * Compare two display strings for sorting, with a fixed collation locale.\n *\n * A bare `a.localeCompare(b)` follows the runtime's default locale, which is\n * the server's on the server and the visitor's on the client. Mixed-script\n * lists (Latin and Cyrillic skill names, for example) then sort differently on\n * each side, and React discards the server HTML as a hydration mismatch. Use\n * this for every name sort whose output is rendered.\n */\nexport function compareText(a: string, b: string): number {\n return COLLATOR.compare(a, b);\n}\n","import { compareText } from '../format/compare-text.js';\n\nconst PROFICIENCY_RANK: Record<string, number> = {\n native: 5,\n full_professional: 4,\n professional_working: 3,\n limited_working: 2,\n elementary: 1,\n};\n\nfunction rank(proficiency: string | undefined): number {\n if (!proficiency) return 0;\n return PROFICIENCY_RANK[proficiency] ?? 0;\n}\n\n/** Sort languages by proficiency (native first), then alphabetically within a rank. */\nexport function sortLanguagesByProficiency<T extends { language?: string; proficiency?: string }>(\n items: T[],\n): T[] {\n return [...items].sort((a, b) => {\n const diff = rank(b.proficiency) - rank(a.proficiency);\n if (diff !== 0) return diff;\n return compareText(a.language ?? '', b.language ?? '');\n });\n}\n","/**\n * Per-section item sorts, shared by every profile surface so ordering can't\n * diverge between the HTML page and the Markdown / DOCX / print exports and the\n * standalone personal-site renderer. Thin wrappers over the SDK date extractors\n * plus the range/language sorts in this directory.\n */\n\nimport type {\n ProfilePosition,\n ProfileEducation,\n ProfileProject,\n ProfilePublication,\n ProfileCertification,\n ProfileHonor,\n ProfileLanguage,\n} from '../types/index.js';\nimport {\n sortByDateDesc,\n lexiconDateExtractor,\n singleDateExtractor,\n certDateExtractor,\n} from '../format/sort-by-date.js';\nimport { sortByActiveDateRange } from './range-sort.js';\nimport { sortLanguagesByProficiency } from './language-sort.js';\n\n/**\n * Move a `primary && !endedAt` position to the top, matching the HTML career\n * section, so the current primary role always leads.\n */\nexport function hoistPrimary(positions: ProfilePosition[]): ProfilePosition[] {\n const idx = positions.findIndex((p) => p.primary && !p.endedAt);\n if (idx <= 0) return positions;\n const primary = positions[idx]!;\n return [primary, ...positions.slice(0, idx), ...positions.slice(idx + 1)];\n}\n\nexport const sortPositions = (items: ProfilePosition[]): ProfilePosition[] =>\n hoistPrimary(sortByDateDesc(items, lexiconDateExtractor));\n\nexport const sortEducation = (items: ProfileEducation[]): ProfileEducation[] =>\n sortByDateDesc(items, lexiconDateExtractor);\n\nexport const sortProjects = (items: ProfileProject[]): ProfileProject[] =>\n sortByActiveDateRange(items);\n\nexport const sortPublications = (items: ProfilePublication[]): ProfilePublication[] =>\n sortByDateDesc(items, singleDateExtractor);\n\nexport const sortCertifications = (items: ProfileCertification[]): ProfileCertification[] =>\n sortByDateDesc(items, certDateExtractor);\n\nexport const sortHonors = (items: ProfileHonor[]): ProfileHonor[] =>\n sortByDateDesc(items, singleDateExtractor);\n\nexport const sortLanguages = (items: ProfileLanguage[]): ProfileLanguage[] =>\n sortLanguagesByProficiency(items);\n","/** Shared URL helpers for the JSON-LD emitters. */\n\nexport const DEFAULT_BASE_URL = 'https://sifa.id';\n\n/**\n * Drop trailing slashes from a caller-supplied base URL.\n *\n * Written as a scan rather than `replace(/\\/+$/, '')` on purpose: the regex\n * form is a polynomial-backtracking hazard on input the library does not\n * control (CodeQL js/polynomial-redos). This runs in linear time.\n */\nexport function normaliseBaseUrl(baseUrl: string | undefined): string {\n const value = baseUrl ?? DEFAULT_BASE_URL;\n let end = value.length;\n while (end > 0 && value.charCodeAt(end - 1) === 0x2f) end -= 1;\n return value.slice(0, end);\n}\n\nexport function profileUrl(baseUrl: string, handle: string): string {\n return `${baseUrl}/p/${handle}`;\n}\n","/**\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 /** Expiry date. Not in the JSON Resume schema, which allows extra fields. */\n readonly endDate?: 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 endDate: toResumeDate(cert.expiryDate),\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","/**\n * Course-role taxonomy. Mirrors `id.sifa.defs#courseRole.knownValues` from\n * sifa-lexicons. A course record without a role is a course the user took;\n * taught and assisted courses render under the \"Teaching\" heading.\n */\n\nexport interface CourseRoleOption {\n value: string;\n label: string;\n}\n\nexport const COURSE_ROLE_TAKEN = 'id.sifa.defs#courseTaken';\nexport const COURSE_ROLE_TAUGHT = 'id.sifa.defs#courseTaught';\nexport const COURSE_ROLE_TEACHING_ASSISTANT = 'id.sifa.defs#courseTeachingAssistant';\n\nexport const COURSE_ROLE_OPTIONS: CourseRoleOption[] = [\n { value: COURSE_ROLE_TAKEN, label: 'Student' },\n { value: COURSE_ROLE_TAUGHT, label: 'Instructor' },\n { value: COURSE_ROLE_TEACHING_ASSISTANT, label: 'Teaching assistant' },\n];\n\nexport const COURSE_ROLE_LABELS: Record<string, string> = Object.fromEntries(\n COURSE_ROLE_OPTIONS.map((o) => [o.value, o.label]),\n);\n\n/**\n * Resolve the label for a course-role token. An unknown token resolves to\n * `undefined` rather than the raw value, so a token a client has not learned\n * never shows up as a raw `id.sifa.defs#...` string.\n */\nexport function getCourseRoleLabel(value: string | undefined | null): string | undefined {\n if (!value) return undefined;\n return COURSE_ROLE_LABELS[value];\n}\n\nconst TEACHING_ROLES = new Set([COURSE_ROLE_TAUGHT, COURSE_ROLE_TEACHING_ASSISTANT]);\n\n/**\n * Whether a course is one the user taught or assisted with. An absent, taken,\n * or unknown role counts as taken, so a record is never dropped from the\n * profile when a client meets a token it has not learned.\n */\nexport function isTeachingCourse(course: { role?: string | null }): boolean {\n return !!course.role && TEACHING_ROLES.has(course.role);\n}\n\n/** Split courses into the ones taken and the ones taught or assisted, keeping order. */\nexport function splitCoursesByRole<T extends { role?: string | null }>(\n courses: readonly T[],\n): { taken: T[]; teaching: T[] } {\n const taken: T[] = [];\n const teaching: T[] = [];\n for (const c of courses) (isTeachingCourse(c) ? teaching : taken).push(c);\n return { taken, teaching };\n}\n","/**\n * Funder-format CV documents: the NIH Biographical Sketch (Common Form plus\n * NIH Supplement) and the ERC Part B1 \"Curriculum vitae and Track Record\".\n *\n * A pure mapper from a Sifa profile and the owner's pick of items to a plain\n * JSON document a typesetter lays out. Like the JSON Resume emitter next door,\n * nothing here fetches or renders.\n *\n * Funders cap how many items a CV may list. The caps live in\n * `FUNDER_CV_GROUPS`, so the export page that offers the choice and the server\n * that enforces it read one number. Sections a funder asks for that Sifa holds\n * no records for (a personal statement, contributions to science, career\n * breaks) are emitted as `null` or empty, for the template to show as a\n * placeholder the applicant fills in.\n */\n\nimport { z } from 'zod';\n\nimport { formatLocation } from '../format/location-utils.js';\nimport { formatStructuredName } from '../format/pds-utils.js';\nimport { filterHidden } from '../profile/section-model.js';\nimport { isTeachingCourse } from '../taxonomy/course-role.js';\nimport type {\n ExternalAccount,\n ProfileCourse,\n ProfileEducation,\n ProfileHonor,\n ProfilePosition,\n ProfilePresentation,\n ProfilePublication,\n ProfileVolunteering,\n} from '../types/index.js';\nimport { normalizeExportContact, type ExportContact } from './export-contact.js';\nimport { toResumeDate } from './json-resume.js';\n\nexport const FUNDER_CV_FORMATS = ['nih', 'erc'] as const;\nexport type FunderCvFormat = (typeof FUNDER_CV_FORMATS)[number];\n\nexport const FUNDER_CV_ITEM_KINDS = ['publication', 'presentation', 'honor'] as const;\nexport type FunderCvItemKind = (typeof FUNDER_CV_ITEM_KINDS)[number];\n\nexport interface FunderCvGroupSpec {\n readonly kinds: readonly FunderCvItemKind[];\n /** Most items the funder's form takes for this group. */\n readonly max: number;\n}\n\n/**\n * The pickable groups per format, with the funder's item limits.\n *\n * - NIH Common Form \"Products\": up to 5 closely related to the proposed\n * project and up to 5 other significant products. Publications, conference\n * papers and presentations all count. NIH Supplement \"Honors\": up to 15.\n * - ERC Part B1 \"Research achievements\": up to ten research outputs. \"Peer\n * recognition\" is \"selected examples\" with no number; 15 is Sifa's own cap,\n * to keep the section inside the 4-page limit.\n */\nexport const FUNDER_CV_GROUPS = {\n nih: {\n related: { kinds: ['publication', 'presentation'], max: 5 },\n other: { kinds: ['publication', 'presentation'], max: 5 },\n honors: { kinds: ['honor'], max: 15 },\n },\n erc: {\n outputs: { kinds: ['publication'], max: 10 },\n recognition: { kinds: ['honor', 'presentation'], max: 15 },\n },\n} as const satisfies Record<FunderCvFormat, Record<string, FunderCvGroupSpec>>;\n\nexport type FunderCvGroupName<F extends FunderCvFormat> = keyof (typeof FUNDER_CV_GROUPS)[F] &\n string;\n\n/** A picked item: `<kind>:<rkey>`, e.g. `publication:3kxyz`. */\nexport function funderCvItemId(kind: FunderCvItemKind, rkey: string): string {\n return `${kind}:${rkey}`;\n}\n\n/**\n * Record key syntax (atproto: 1-512 of A-Z a-z 0-9 . - _ : ~), plus `/`:\n * publications from Standard.site are keyed by their AT URI (`std-at://...`).\n */\nconst ITEM_ID_RE = /^(publication|presentation|honor):[A-Za-z0-9._~:/-]{1,512}$/;\n\nfunction kindOf(id: string): FunderCvItemKind | undefined {\n const kind = id.slice(0, id.indexOf(':'));\n return (FUNDER_CV_ITEM_KINDS as readonly string[]).includes(kind)\n ? (kind as FunderCvItemKind)\n : undefined;\n}\n\nfunction groupSchema(spec: FunderCvGroupSpec) {\n return z\n .array(\n z\n .string()\n .regex(ITEM_ID_RE)\n .refine((id) => spec.kinds.includes(kindOf(id) as FunderCvItemKind), {\n message: `Only ${spec.kinds.join(', ')} items fit here`,\n }),\n )\n .max(spec.max)\n .default([]);\n}\n\nfunction noRepeats(lists: readonly string[][]): boolean {\n const all = lists.flat();\n return new Set(all).size === all.length;\n}\n\nconst nihSelectionSchema = z\n .object({\n format: z.literal('nih'),\n related: groupSchema(FUNDER_CV_GROUPS.nih.related),\n other: groupSchema(FUNDER_CV_GROUPS.nih.other),\n honors: groupSchema(FUNDER_CV_GROUPS.nih.honors),\n })\n .refine((s) => noRepeats([s.related, s.other, s.honors]), {\n message: 'An item can be listed once',\n });\n\nconst ercSelectionSchema = z\n .object({\n format: z.literal('erc'),\n outputs: groupSchema(FUNDER_CV_GROUPS.erc.outputs),\n recognition: groupSchema(FUNDER_CV_GROUPS.erc.recognition),\n })\n .refine((s) => noRepeats([s.outputs, s.recognition]), {\n message: 'An item can be listed once',\n });\n\n/**\n * The owner's pick for one format. Enforces the shape and the funder's limits;\n * whether each id is one of the owner's own visible records is a separate\n * check against the profile, `findUnknownFunderCvItems`.\n */\nexport const funderCvSelectionSchema = z.discriminatedUnion('format', [\n nihSelectionSchema,\n ercSelectionSchema,\n]);\n\nexport type FunderCvSelection = z.infer<typeof funderCvSelectionSchema>;\n\n/** The subset of `Profile` the funder mapper reads. */\nexport interface FunderCvProfileInput {\n readonly handle: string;\n readonly displayName?: string;\n readonly givenName?: string;\n readonly familyName?: string;\n readonly headline?: string;\n readonly website?: string;\n readonly positions?: ProfilePosition[];\n readonly education?: ProfileEducation[];\n readonly publications?: ProfilePublication[];\n readonly presentations?: ProfilePresentation[];\n readonly honors?: ProfileHonor[];\n readonly courses?: ProfileCourse[];\n readonly volunteering?: ProfileVolunteering[];\n readonly externalAccounts?: ExternalAccount[];\n}\n\nexport interface FunderCvCandidate {\n readonly id: string;\n readonly kind: FunderCvItemKind;\n readonly title: string;\n /** `YYYY`, `YYYY-MM` or `YYYY-MM-DD`; absent when the record has no date. */\n readonly date?: string;\n}\n\n/** The most recent visible delivery of a talk, which dates it. */\nfunction latestDeliveryRecord(presentation: ProfilePresentation) {\n const dateOf = (d: { date?: string | null }) => toResumeDate(d.date ?? undefined) ?? '';\n return [...filterHidden(presentation.deliveries)]\n .sort((a, b) => dateOf(a).localeCompare(dateOf(b)))\n .at(-1);\n}\n\nfunction latestDelivery(presentation: ProfilePresentation): string | undefined {\n return toResumeDate(latestDeliveryRecord(presentation)?.date ?? undefined);\n}\n\nfunction candidatesOf(profile: FunderCvProfileInput, kind: FunderCvItemKind): FunderCvCandidate[] {\n switch (kind) {\n case 'publication':\n return filterHidden(profile.publications).map((p) => ({\n id: funderCvItemId(kind, p.rkey),\n kind,\n title: p.title,\n date: toResumeDate(p.date),\n }));\n case 'presentation':\n return filterHidden(profile.presentations).map((p) => ({\n id: funderCvItemId(kind, p.rkey),\n kind,\n title: p.title,\n date: latestDelivery(p),\n }));\n case 'honor':\n return filterHidden(profile.honors).map((h) => ({\n id: funderCvItemId(kind, h.rkey),\n kind,\n title: h.title,\n date: toResumeDate(h.date),\n }));\n }\n}\n\n/**\n * The owner's visible items of the given kinds, most recent first. Undated\n * items go last, in profile order. The sort is stable, so equal dates keep\n * profile order too.\n */\nexport function listFunderCvCandidates(\n profile: FunderCvProfileInput,\n kinds: readonly FunderCvItemKind[],\n): FunderCvCandidate[] {\n const all = kinds.flatMap((kind) => candidatesOf(profile, kind));\n return all.sort((a, b) => {\n if (a.date && b.date) return b.date.localeCompare(a.date);\n if (a.date) return -1;\n if (b.date) return 1;\n return 0;\n });\n}\n\n/**\n * What the export page pre-ticks: the most recent publications up to each\n * limit (for NIH, the first five as closely related and the next five as\n * other), and the most recent honors. Talks are offered but not pre-ticked.\n */\nexport function defaultFunderCvSelection(\n profile: FunderCvProfileInput,\n format: FunderCvFormat,\n): FunderCvSelection {\n const publications = listFunderCvCandidates(profile, ['publication']).map((c) => c.id);\n const honors = listFunderCvCandidates(profile, ['honor']).map((c) => c.id);\n if (format === 'nih') {\n const { related, other } = FUNDER_CV_GROUPS.nih;\n return {\n format,\n related: publications.slice(0, related.max),\n other: publications.slice(related.max, related.max + other.max),\n honors: honors.slice(0, FUNDER_CV_GROUPS.nih.honors.max),\n };\n }\n return {\n format,\n outputs: publications.slice(0, FUNDER_CV_GROUPS.erc.outputs.max),\n recognition: honors.slice(0, FUNDER_CV_GROUPS.erc.recognition.max),\n };\n}\n\nfunction selectedIds(selection: FunderCvSelection): string[] {\n return selection.format === 'nih'\n ? [...selection.related, ...selection.other, ...selection.honors]\n : [...selection.outputs, ...selection.recognition];\n}\n\n/**\n * Ids in the selection that are not visible records on this profile. The\n * profile is the owner's own, so an empty result means every pick is theirs.\n */\nexport function findUnknownFunderCvItems(\n profile: FunderCvProfileInput,\n selection: FunderCvSelection,\n): string[] {\n const known = new Set(listFunderCvCandidates(profile, FUNDER_CV_ITEM_KINDS).map((c) => c.id));\n return selectedIds(selection).filter((id) => !known.has(id));\n}\n\n// ---------------------------------------------------------------------------\n// Document shapes\n// ---------------------------------------------------------------------------\n\nexport interface FunderCvPerson {\n /** Full name as the profile shows it; the handle when there is no name. */\n readonly name: string;\n readonly givenName?: string;\n readonly familyName?: string;\n /** Bare ORCID iD, e.g. `0000-0002-1825-0097`. */\n readonly orcid?: string;\n readonly website?: string;\n}\n\n/**\n * The ERC person, with the contact and personal details the owner typed for\n * this export. The NIH Biographical Sketch has no such block, so only ERC carries them.\n */\nexport interface ErcFunderCvPerson extends FunderCvPerson {\n readonly email?: string;\n readonly phone?: string;\n /** Lines are separated by `\\n`. */\n readonly address?: string;\n readonly driversLicense?: string;\n readonly rightToWork?: string;\n readonly nationality?: string;\n}\n\nexport interface FunderCvOptions {\n /**\n * Contact details the owner typed for this export. Sifa stores none of\n * them. Used for ERC only.\n */\n readonly contact?: ExportContact;\n}\n\n/** One product or research output, ready to cite. */\nexport interface FunderCvCitation {\n readonly kind: 'publication' | 'presentation';\n readonly title: string;\n /** Authors in record order, comma separated. For a talk, the speaker. */\n readonly authors?: string;\n /** Journal, publisher or event. */\n readonly venue?: string;\n /** Year. */\n readonly date?: string;\n readonly doi?: string;\n readonly url?: string;\n}\n\nexport interface FunderCvHonor {\n readonly year?: string;\n readonly title: string;\n readonly organization?: string;\n}\n\nexport interface NihEducation {\n readonly organization: string;\n readonly location?: string;\n readonly degree?: string;\n /** Start date, `MM/YYYY` or `YYYY`. */\n readonly start?: string;\n /** Receipt date, `MM/YYYY` or `YYYY`. */\n readonly end?: string;\n readonly field?: string;\n}\n\nexport interface FunderCvAppointment {\n /** `YYYY`. */\n readonly start?: string;\n /** `YYYY`, or null for a current appointment. */\n readonly end: string | null;\n readonly title: string;\n readonly organization?: string;\n readonly location?: string;\n}\n\n/** NIH Biographical Sketch: Common Form plus NIH Supplement. */\nexport interface NihFunderCv {\n readonly format: 'nih';\n readonly person: FunderCvPerson;\n readonly positionTitle?: string;\n /** Primary organization: the current position's. */\n readonly organization?: string;\n readonly location?: string;\n readonly education: NihEducation[];\n readonly appointments: FunderCvAppointment[];\n readonly products: { readonly related: FunderCvCitation[]; readonly other: FunderCvCitation[] };\n readonly honors: FunderCvHonor[];\n /** Supplement \"Personal Statement\". Sifa holds no record for it. */\n readonly personalStatement: string | null;\n /** Supplement \"Contributions to Science\". Sifa holds no record for them. */\n readonly contributions: string[];\n}\n\nexport interface ErcEducation {\n /** Receipt date, `MM/YYYY` or `YYYY`. */\n readonly date?: string;\n readonly degree?: string;\n readonly field?: string;\n readonly institution: string;\n}\n\nexport interface ErcRecognition {\n readonly kind: 'honor' | 'presentation';\n readonly year?: string;\n readonly title: string;\n /** Awarding body, or the event a talk was given at. */\n readonly organization?: string;\n}\n\nexport interface ErcContribution {\n readonly kind: 'teaching' | 'service';\n readonly start?: string;\n readonly end: string | null;\n readonly title: string;\n readonly organization?: string;\n}\n\n/** ERC Part B1, section \"Curriculum vitae and Track Record\". */\nexport interface ErcFunderCv {\n readonly format: 'erc';\n readonly person: ErcFunderCvPerson;\n readonly education: ErcEducation[];\n readonly currentPositions: FunderCvAppointment[];\n readonly previousPositions: FunderCvAppointment[];\n readonly outputs: FunderCvCitation[];\n readonly recognition: ErcRecognition[];\n readonly communityContributions: ErcContribution[];\n /** Proposal acronym for the page header. Not a profile fact. */\n readonly acronym: string | null;\n /** \"Career breaks, diverse career paths and major life events\". */\n readonly careerBreaks: string | null;\n}\n\nexport type FunderCvDocument = NihFunderCv | ErcFunderCv;\n\n// ---------------------------------------------------------------------------\n// Mapping\n// ---------------------------------------------------------------------------\n\nfunction text(value: string | null | undefined): string | undefined {\n const trimmed = value?.trim();\n return trimmed ? trimmed : undefined;\n}\n\nfunction compact<T extends object>(value: T): T {\n return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined)) as T;\n}\n\nfunction year(value: string | null | undefined): string | undefined {\n return toResumeDate(value ?? undefined)?.slice(0, 4);\n}\n\n/** `MM/YYYY` when the month is known, else `YYYY`. */\nfunction monthYear(value: string | null | undefined): string | undefined {\n const date = toResumeDate(value ?? undefined);\n if (!date) return undefined;\n return date.length >= 7 ? `${date.slice(5, 7)}/${date.slice(0, 4)}` : date;\n}\n\n/** Newest start first; undated entries last, in profile order. */\nfunction byStartDesc<T>(items: T[], start: (item: T) => string | undefined): T[] {\n return [...items].sort((a, b) => {\n const da = toResumeDate(start(a));\n const db = toResumeDate(start(b));\n if (da && db) return db.localeCompare(da);\n if (da) return -1;\n if (db) return 1;\n return 0;\n });\n}\n\nconst ORCID_RE = /\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]/;\n\nfunction orcidOf(accounts: ExternalAccount[] | undefined): string | undefined {\n const account = filterHidden(accounts).find((a) => a.platform.toLowerCase() === 'orcid');\n return account ? ORCID_RE.exec(account.url)?.[0] : undefined;\n}\n\nfunction personOf(profile: FunderCvProfileInput): FunderCvPerson {\n return compact<FunderCvPerson>({\n name:\n formatStructuredName(profile.givenName, profile.familyName) ??\n text(profile.displayName) ??\n profile.handle,\n givenName: text(profile.givenName),\n familyName: text(profile.familyName),\n orcid: orcidOf(profile.externalAccounts),\n website: text(profile.website),\n });\n}\n\nfunction appointment(position: ProfilePosition): FunderCvAppointment {\n return compact<FunderCvAppointment>({\n start: year(position.startedAt),\n end: year(position.endedAt) ?? null,\n title: position.title,\n organization: text(position.entityName) ?? text(position.company),\n location: text(formatLocation(position.location)),\n });\n}\n\n/** The current position to name on the form: the flagged primary, else the newest. */\nfunction currentPosition(positions: ProfilePosition[]): ProfilePosition | undefined {\n const current = byStartDesc(\n positions.filter((p) => !text(p.endedAt)),\n (p) => p.startedAt,\n );\n return current.find((p) => p.primary) ?? current[0];\n}\n\nfunction lookup(profile: FunderCvProfileInput) {\n const publications = new Map(filterHidden(profile.publications).map((p) => [p.rkey, p]));\n const presentations = new Map(filterHidden(profile.presentations).map((p) => [p.rkey, p]));\n const honors = new Map(filterHidden(profile.honors).map((h) => [h.rkey, h]));\n const split = (id: string) => {\n const at = id.indexOf(':');\n return { kind: id.slice(0, at), rkey: id.slice(at + 1) };\n };\n return { publications, presentations, honors, split };\n}\n\nfunction citations(\n ids: readonly string[],\n profile: FunderCvProfileInput,\n person: FunderCvPerson,\n): FunderCvCitation[] {\n const { publications, presentations, split } = lookup(profile);\n return ids.flatMap((id): FunderCvCitation[] => {\n const { kind, rkey } = split(id);\n if (kind === 'publication') {\n const p = publications.get(rkey);\n if (!p) return [];\n const authors = (p.contributors ?? []).map((c) => c.name.trim()).filter(Boolean);\n return [\n compact<FunderCvCitation>({\n kind: 'publication',\n title: p.title,\n authors: authors.length > 0 ? authors.join(', ') : undefined,\n venue: text(p.publisher),\n date: year(p.date),\n doi: text(p.doi),\n url: text(p.url),\n }),\n ];\n }\n if (kind === 'presentation') {\n const talk = presentations.get(rkey);\n if (!talk) return [];\n const delivery = latestDeliveryRecord(talk);\n return [\n compact<FunderCvCitation>({\n kind: 'presentation',\n title: talk.title,\n authors: person.name,\n venue: text(delivery?.eventName),\n date: year(delivery?.date),\n url: text(talk.links?.[0]?.uri),\n }),\n ];\n }\n return [];\n });\n}\n\nfunction honorsOf(ids: readonly string[], profile: FunderCvProfileInput): FunderCvHonor[] {\n const { honors, split } = lookup(profile);\n return ids.flatMap((id) => {\n const { kind, rkey } = split(id);\n const h = kind === 'honor' ? honors.get(rkey) : undefined;\n if (!h) return [];\n return [\n compact<FunderCvHonor>({\n year: year(h.date),\n title: h.title,\n organization: text(h.entityName) ?? text(h.issuer),\n }),\n ];\n });\n}\n\n/**\n * Build the funder document from the profile and the owner's selection.\n *\n * Hidden records never appear. Selected ids that match no visible record are\n * skipped; callers that must refuse them check `findUnknownFunderCvItems`\n * first. Selected items keep the order they were picked in.\n */\nexport function profileToFunderCv(\n profile: FunderCvProfileInput,\n selection: FunderCvSelection,\n options: FunderCvOptions = {},\n): FunderCvDocument {\n const person = personOf(profile);\n const positions = filterHidden(profile.positions);\n const education = byStartDesc(filterHidden(profile.education), (e) => e.startedAt);\n\n if (selection.format === 'nih') {\n const current = currentPosition(positions);\n return compact<NihFunderCv>({\n format: 'nih',\n person,\n positionTitle: text(current?.title),\n organization: current ? appointment(current).organization : undefined,\n location: text(formatLocation(current?.location)),\n education: education.map((e) =>\n compact<NihEducation>({\n organization: text(e.entityName) ?? e.institution,\n degree: text(e.degree),\n start: monthYear(e.startedAt),\n end: monthYear(e.endedAt),\n field: text(e.fieldOfStudy),\n }),\n ),\n appointments: byStartDesc(positions, (p) => p.startedAt).map(appointment),\n products: {\n related: citations(selection.related, profile, person),\n other: citations(selection.other, profile, person),\n },\n honors: honorsOf(selection.honors, profile),\n personalStatement: null,\n contributions: [],\n });\n }\n\n const appointments = byStartDesc(positions, (p) => p.startedAt);\n const { presentations, split } = lookup(profile);\n\n const recognition = selection.recognition.flatMap((id): ErcRecognition[] => {\n const { kind, rkey } = split(id);\n if (kind === 'honor') {\n const [honor] = honorsOf([id], profile);\n return honor ? [{ kind: 'honor', ...honor }] : [];\n }\n const talk = kind === 'presentation' ? presentations.get(rkey) : undefined;\n if (!talk) return [];\n const delivery = latestDeliveryRecord(talk);\n return [\n compact<ErcRecognition>({\n kind: 'presentation',\n year: year(delivery?.date),\n title: talk.title,\n organization: text(delivery?.eventName),\n }),\n ];\n });\n\n const teaching = filterHidden(profile.courses)\n .filter(isTeachingCourse)\n .map((c) =>\n compact<ErcContribution>({\n kind: 'teaching',\n start: year(c.startedAt),\n end: year(c.endedAt) ?? null,\n title: c.name,\n organization: text(c.entityName) ?? text(c.institution),\n }),\n );\n const service = filterHidden(profile.volunteering).map((v) =>\n compact<ErcContribution>({\n kind: 'service',\n start: year(v.startDate),\n end: year(v.endDate) ?? null,\n title: text(v.role) ?? text(v.entityName) ?? v.organization,\n organization: text(v.entityName) ?? text(v.organization),\n }),\n );\n\n return {\n format: 'erc',\n person: { ...person, ...normalizeExportContact(options.contact ?? {}) },\n education: education.map((e) =>\n compact<ErcEducation>({\n date: monthYear(e.endedAt) ?? monthYear(e.startedAt),\n degree: text(e.degree),\n field: text(e.fieldOfStudy),\n institution: text(e.entityName) ?? e.institution,\n }),\n ),\n currentPositions: appointments.filter((p) => !text(p.endedAt)).map(appointment),\n previousPositions: appointments.filter((p) => !!text(p.endedAt)).map(appointment),\n outputs: citations(selection.outputs, profile, person),\n recognition,\n communityContributions: [...teaching, ...service],\n acronym: null,\n careerBreaks: null,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/resume/export-contact.ts","../../src/format/location-utils.ts","../../src/format/pds-utils.ts","../../src/profile/section-model.ts","../../src/format/sort-by-date.ts","../../src/profile/range-sort.ts","../../src/format/compare-text.ts","../../src/profile/language-sort.ts","../../src/profile/section-sorts.ts","../../src/taxonomy/course-role.ts","../../src/taxonomy/involvement-kind.ts","../../src/taxonomy/skill-categories.ts","../../src/taxonomy/skill-grouping.ts","../../src/jsonld/url.ts","../../src/resume/json-resume.ts","../../src/resume/funder-cv.ts"],"names":["z","text","compact"],"mappings":";;;;;AAcO,IAAM,qBAAA,GAAwB;AAAA,EACnC,KAAA,EAAO,GAAA;AAAA,EACP,KAAA,EAAO,EAAA;AAAA,EACP,OAAA,EAAS,GAAA;AAAA,EACT,cAAA,EAAgB,EAAA;AA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KAAAA,CAAK,CAAA,CAAE,OAAO,CAAC,CAAA,CAAE,GAAA,CAAI,WAAW,CAAA;AAAA,IAC9E,iBAAA,EAAmB,YAAA,CAAa,MAAA,CAAO,CAAC,CAAA,KAAM,CAAC,CAACA,KAAAA,CAAK,CAAA,CAAE,OAAO,CAAC,CAAA,CAAE,IAAI,WAAW,CAAA;AAAA,IAChF,OAAA,EAAS,SAAA,CAAU,SAAA,CAAU,OAAA,EAAS,SAAS,MAAM,CAAA;AAAA,IACrD,WAAA;AAAA,IACA,sBAAA,EAAwB,CAAC,GAAG,QAAA,EAAU,GAAG,OAAO,CAAA;AAAA,IAChD,OAAA,EAAS,IAAA;AAAA,IACT,YAAA,EAAc;AAAA,GAChB;AACF","file":"index.cjs","sourcesContent":["/**\n * Private contact and personal details for exports: email, phone, postal\n * address, driver's license, right to work and nationality.\n *\n * Sifa never stores these and never writes them to the owner's PDS, where they\n * would be public. The owner types them on the export page, the browser keeps\n * them, and they go only into the files the owner downloads. This module holds\n * the shape, the limits and the pick rule, so the export page and the server\n * that builds a funder CV agree on them.\n */\n\nimport { z } from 'zod';\n\n/** Longest value accepted per field. 254 is the longest valid email address. */\nexport const EXPORT_CONTACT_LIMITS = {\n email: 254,\n phone: 40,\n address: 500,\n driversLicense: 60,\n rightToWork: 200,\n nationality: 100,\n} as const;\n\n/** The contact details that go into an export. Absent keys are left out. */\nexport interface ExportContact {\n readonly email?: string;\n readonly phone?: string;\n /** Free text; lines are separated by `\\n`. */\n readonly address?: string;\n /** License categories, e.g. \"B, BE\". */\n readonly driversLicense?: string;\n /** e.g. \"EU citizen, no sponsorship needed\". */\n readonly rightToWork?: string;\n readonly nationality?: string;\n}\n\n/** What the owner has typed, plus which fields they chose to include. */\nexport interface ExportContactDraft {\n readonly email?: string;\n readonly phone?: string;\n readonly address?: string;\n readonly driversLicense?: string;\n readonly rightToWork?: string;\n readonly nationality?: string;\n readonly includeEmail?: boolean;\n readonly includePhone?: boolean;\n readonly includeAddress?: boolean;\n readonly includeDriversLicense?: boolean;\n readonly includeRightToWork?: boolean;\n readonly includeNationality?: boolean;\n}\n\n/**\n * Validates a picked contact. Only lengths are checked: phone numbers and\n * addresses vary too much between countries, and a wrong-looking email is a\n * warning for the owner, not a reason to refuse the export.\n */\nexport const exportContactSchema = z.strictObject({\n email: z.string().max(EXPORT_CONTACT_LIMITS.email).optional(),\n phone: z.string().max(EXPORT_CONTACT_LIMITS.phone).optional(),\n address: z.string().max(EXPORT_CONTACT_LIMITS.address).optional(),\n driversLicense: z.string().max(EXPORT_CONTACT_LIMITS.driversLicense).optional(),\n rightToWork: z.string().max(EXPORT_CONTACT_LIMITS.rightToWork).optional(),\n nationality: z.string().max(EXPORT_CONTACT_LIMITS.nationality).optional(),\n});\n\n/**\n * The fields to put in an export: the included ones that are not blank, run\n * through {@link normalizeExportContact}.\n */\nexport function pickExportContact(draft: ExportContactDraft): ExportContact {\n return normalizeExportContact({\n email: draft.includeEmail ? draft.email : undefined,\n phone: draft.includePhone ? draft.phone : undefined,\n address: draft.includeAddress ? draft.address : undefined,\n driversLicense: draft.includeDriversLicense ? draft.driversLicense : undefined,\n rightToWork: draft.includeRightToWork ? draft.rightToWork : undefined,\n nationality: draft.includeNationality ? draft.nationality : undefined,\n });\n}\n\n/**\n * Drops blank fields and tidies the rest. Every field but the address becomes\n * one line with single spaces. An address keeps its line breaks but loses blank lines and the\n * spaces around each line. Each field is cut at its {@link EXPORT_CONTACT_LIMITS}\n * length. The emitters call this too, so a caller that skips\n * {@link pickExportContact} and the schema gets the same bounded output.\n */\nexport function normalizeExportContact(contact: ExportContact): ExportContact {\n const email = cap(oneLine(contact.email), EXPORT_CONTACT_LIMITS.email);\n const phone = cap(oneLine(contact.phone), EXPORT_CONTACT_LIMITS.phone);\n const address = cap(lines(contact.address), EXPORT_CONTACT_LIMITS.address);\n const driversLicense = cap(oneLine(contact.driversLicense), EXPORT_CONTACT_LIMITS.driversLicense);\n const rightToWork = cap(oneLine(contact.rightToWork), EXPORT_CONTACT_LIMITS.rightToWork);\n const nationality = cap(oneLine(contact.nationality), EXPORT_CONTACT_LIMITS.nationality);\n return {\n ...(email ? { email } : {}),\n ...(phone ? { phone } : {}),\n ...(address ? { address } : {}),\n ...(driversLicense ? { driversLicense } : {}),\n ...(rightToWork ? { rightToWork } : {}),\n ...(nationality ? { nationality } : {}),\n };\n}\n\n/** A loose shape check for a non-blocking \"check this address\" hint. */\nexport function looksLikeEmail(value: string): boolean {\n const trimmed = value.trim();\n if (/\\s/.test(trimmed)) return false;\n const parts = trimmed.split('@');\n if (parts.length !== 2) return false;\n const [local, domain] = parts as [string, string];\n const dot = domain.lastIndexOf('.');\n return local.length > 0 && dot > 0 && dot < domain.length - 1;\n}\n\nfunction cap(value: string | undefined, max: number): string | undefined {\n if (value === undefined) return undefined;\n let cut = value.slice(0, max);\n // Never leave half of a surrogate pair (an emoji, say) at the cut.\n if (/[\\uD800-\\uDBFF]$/.test(cut)) cut = cut.slice(0, -1);\n return cut.trimEnd();\n}\n\nfunction oneLine(value: string | undefined): string | undefined {\n const collapsed = value?.replace(/\\s+/g, ' ').trim();\n return collapsed ? collapsed : undefined;\n}\n\nfunction lines(value: string | undefined): string | undefined {\n const kept = (value ?? '')\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .filter(Boolean);\n return kept.length > 0 ? kept.join('\\n') : undefined;\n}\n","import type { LocationValue } from '../types/index.js';\n\n/**\n * Format a LocationValue for display.\n *\n * Prefers `locality` (the community.lexicon.location.address field) and\n * falls back to the legacy `city` slot so values produced before the\n * sifa-api alias migration still render correctly during the additive\n * transition window.\n */\nexport function formatLocation(loc: LocationValue | null | undefined): string {\n if (!loc) return '';\n const locality = loc.locality ?? loc.city;\n const parts = [locality, loc.region, loc.country].filter(Boolean);\n if (loc.postalCode && !locality) {\n return `${loc.postalCode}, ${loc.country}`;\n }\n return parts.join(', ');\n}\n\n/** Parse a display string back into a LocationValue (best-effort for legacy data) */\nexport function parseLocationString(str: string): LocationValue | null {\n if (!str.trim()) return null;\n const parts = str\n .split(',')\n .map((p) => p.trim())\n .filter(Boolean);\n if (parts.length >= 3) {\n return {\n city: parts[0],\n region: parts[1],\n country: parts[parts.length - 1]!,\n };\n }\n if (parts.length === 2) {\n return {\n city: parts[0],\n country: parts[1]!,\n };\n }\n return { country: parts[0]! };\n}\n\n/** Convert ISO 3166-1 alpha-2 country code to flag emoji */\nexport function countryCodeToFlag(code: string | undefined): string {\n if (!code || code.length !== 2) return '';\n const upper = code.toUpperCase();\n const a = upper.codePointAt(0);\n const b = upper.codePointAt(1);\n if (a === undefined || b === undefined) return '';\n return String.fromCodePoint(a - 0x41 + 0x1f1e6, b - 0x41 + 0x1f1e6);\n}\n","import type { PdsProviderInfo } from '../types/index.js';\n\nexport interface PdsProvider {\n name: string;\n profileUrl: string;\n host?: string;\n}\n\nconst BSKY_PROFILE_BASE = 'https://bsky.app/profile/';\n\nconst PDS_PROVIDERS: { suffix: string; name: string }[] = [\n { suffix: '.bsky.social', name: 'bluesky' },\n { suffix: '.blacksky.app', name: 'blacksky' },\n { suffix: '.eurosky.social', name: 'eurosky' },\n { suffix: '.northsky.social', name: 'northsky' },\n];\n\nconst KNOWN_PROVIDER_NAMES = new Set(PDS_PROVIDERS.map((p) => p.name));\n\nconst ICON_ONLY_PROVIDERS = new Set(['selfhosted-social', 'selfhosted']);\n\nexport function pdsProviderFromApi(\n apiProvider: PdsProviderInfo | null | undefined,\n handle: string,\n): PdsProvider | null {\n if (!apiProvider) return null;\n if (ICON_ONLY_PROVIDERS.has(apiProvider.name)) {\n return { name: apiProvider.name, profileUrl: '', host: apiProvider.host };\n }\n if (!KNOWN_PROVIDER_NAMES.has(apiProvider.name)) return null;\n return {\n name: apiProvider.name,\n profileUrl: `${BSKY_PROFILE_BASE}${handle}`,\n host: apiProvider.host,\n };\n}\n\nexport function getHandleStem(handle: string): string {\n const lower = handle.toLowerCase();\n for (const provider of PDS_PROVIDERS) {\n if (lower.endsWith(provider.suffix) && lower.length > provider.suffix.length) {\n return handle.slice(0, -provider.suffix.length);\n }\n }\n return handle;\n}\n\nexport function getDisplayLabel(displayName: string | undefined, handle: string): string {\n if (displayName) return displayName;\n return getHandleStem(handle);\n}\n\n/**\n * Combine optional structured name fields (`id.sifa.profile.self.givenName`,\n * `familyName`) into a single string in Schema.org `Person` order — given\n * before family. Returns `undefined` when both are absent so callers can\n * fall back to `displayName`. Whitespace-only inputs are treated as absent.\n * Does not impose cultural ordering: users whose preferred presentation\n * differs (e.g. Eastern name order) should set `displayName` accordingly,\n * which this helper deliberately does not consult.\n */\nexport function formatStructuredName(\n givenName: string | undefined,\n familyName: string | undefined,\n): string | undefined {\n const given = givenName?.trim();\n const family = familyName?.trim();\n if (given && family) return `${given} ${family}`;\n return given || family || undefined;\n}\n\nconst PDS_DISPLAY_NAMES: Record<string, string> = {\n bluesky: 'Bluesky',\n blacksky: 'BlackSky',\n eurosky: 'EuroSky',\n northsky: 'NorthSky',\n 'selfhosted-social': 'Self-hosted',\n selfhosted: 'Self-hosted',\n};\n\nexport function getPdsDisplayName(providerName: string): string {\n return PDS_DISPLAY_NAMES[providerName] ?? providerName;\n}\n\nexport function detectPdsProvider(handle: string): PdsProvider | null {\n const lower = handle.toLowerCase();\n for (const provider of PDS_PROVIDERS) {\n if (lower.endsWith(provider.suffix)) {\n return {\n name: provider.name,\n profileUrl: `${BSKY_PROFILE_BASE}${handle}`,\n };\n }\n }\n return null;\n}\n","/**\n * Shared, single-source-of-truth model for which profile sections render, in\n * what order, their nav grouping, and which items a given viewer may see.\n *\n * Every Sifa profile surface builds on this: the HTML profile page, the\n * Markdown / DOCX / print exports, and the standalone personal-site renderer.\n * Adding a section to {@link ALL_SECTIONS} makes it appear everywhere (the\n * exports drive presence + order from here, and {@link SECTION_LABELS} is an\n * exhaustive `Record<SectionId, string>`, so a new id is a compile error until\n * it has a label).\n *\n * The per-section sorts live in `./section-sorts.js`, built on the same SDK\n * date extractors the HTML section components use, so the surfaces cannot\n * diverge on ordering.\n */\n\nimport type { Profile } from '../types/index.js';\n\n/**\n * Side-nav groups, in display order. Each labels a contiguous run of sections\n * in {@link ALL_SECTIONS}. `labelKey` resolves against the consumer's `sections`\n * i18n namespace.\n */\nexport const SECTION_GROUPS = [\n { id: 'overview', labelKey: 'groupOverview' },\n { id: 'experience', labelKey: 'groupExperience' },\n { id: 'qualifications', labelKey: 'groupQualifications' },\n { id: 'more', labelKey: 'groupMore' },\n] as const;\n\nexport type SectionGroupId = (typeof SECTION_GROUPS)[number]['id'];\n\n/**\n * Profile body sections in render + nav order (evidence-first): identity and\n * activity lead, then living work (career, projects, talks, publications, then\n * skills), then the formal record (credentials, education, courses), then the\n * rest. `ns` selects the consumer's i18n namespace for `labelKey`; `group`\n * ties the section to a {@link SECTION_GROUPS} header.\n */\nexport const ALL_SECTIONS = [\n { id: 'about', labelKey: 'about', ns: 'profile' as const, group: 'overview' as const },\n { id: 'career', labelKey: 'career', ns: 'sections' as const, group: 'experience' as const },\n { id: 'projects', labelKey: 'projects', ns: 'sections' as const, group: 'experience' as const },\n {\n id: 'presentations',\n labelKey: 'talksAndSessions',\n ns: 'sections' as const,\n group: 'experience' as const,\n },\n {\n id: 'publications',\n labelKey: 'publications',\n ns: 'sections' as const,\n group: 'experience' as const,\n },\n { id: 'skills', labelKey: 'skills', ns: 'sections' as const, group: 'experience' as const },\n {\n id: 'credentials',\n labelKey: 'credentials',\n ns: 'sections' as const,\n group: 'qualifications' as const,\n },\n {\n id: 'education',\n labelKey: 'education',\n ns: 'sections' as const,\n group: 'qualifications' as const,\n },\n { id: 'courses', labelKey: 'courses', ns: 'sections' as const, group: 'qualifications' as const },\n { id: 'awards', labelKey: 'awards', ns: 'sections' as const, group: 'more' as const },\n { id: 'involvement', labelKey: 'involvement', ns: 'sections' as const, group: 'more' as const },\n // Its own section rather than a group under involvement: that record is about\n // work contributed, this one about capital deployed.\n { id: 'investments', labelKey: 'investments', ns: 'sections' as const, group: 'more' as const },\n { id: 'languages', labelKey: 'languages', ns: 'sections' as const, group: 'more' as const },\n {\n id: 'other-profiles',\n labelKey: 'otherProfiles',\n ns: 'sections' as const,\n group: 'more' as const,\n },\n] as const;\n\n/** Every profile section id, in canonical render order. */\nexport type SectionId = (typeof ALL_SECTIONS)[number]['id'];\n\n/**\n * Whether a section has content a visitor can see (used to hide empty nav\n * entries and sections for visitors). Items the owner hid do not count: a\n * section whose only entries are hidden renders nothing for a visitor, so it\n * must not get a nav entry either.\n */\nexport function isSectionPopulated(profile: Profile, id: string): boolean {\n const hasVisible = <T extends { hidden?: boolean }>(items: T[] | undefined): boolean =>\n filterHidden(items).length > 0;\n switch (id) {\n case 'about':\n // Text fields, not hideable items. Without a headline the summary shows\n // in the identity card instead, so the About section stays out of it.\n return Boolean(profile.about && profile.headline);\n case 'career':\n return hasVisible(profile.positions);\n case 'education':\n return hasVisible(profile.education);\n case 'courses':\n return hasVisible(profile.courses);\n case 'skills':\n // Skills have no owner-hide flag (`ProfileSkill` carries no `hidden`).\n return Boolean(profile.skills?.length);\n case 'projects':\n return hasVisible(profile.projects);\n case 'credentials':\n return hasVisible(profile.certifications);\n case 'publications':\n return hasVisible(profile.publications);\n case 'presentations':\n return hasVisible(profile.presentations) || hasVisible(profile.presentationDeliveries);\n case 'involvement':\n return hasVisible(profile.involvement);\n case 'investments':\n return hasVisible(profile.investments);\n case 'awards':\n return hasVisible(profile.honors);\n case 'languages':\n return hasVisible(profile.languages);\n case 'other-profiles':\n return hasVisible(profile.externalAccounts);\n default:\n return false;\n }\n}\n\n/**\n * The section ids a given viewer should see, in {@link ALL_SECTIONS} order.\n * Owners see every section; visitors only see populated ones.\n */\nexport function getVisibleSectionIds(profile: Profile, isOwnProfile: boolean): SectionId[] {\n return ALL_SECTIONS.map((s) => s.id).filter(\n (id) => isOwnProfile || isSectionPopulated(profile, id),\n );\n}\n\n/** Drop items the owner has hidden from visitors. */\nexport function filterHidden<T extends { hidden?: boolean }>(items: T[] | undefined): T[] {\n return (items ?? []).filter((i) => !i.hidden);\n}\n\n/**\n * Items visible to a given viewer: owners see their own hidden items, visitors\n * do not. Shared by every export format (markdown, docx, print) and the public\n * `.md` route so the hidden rule lives in one place.\n */\nexport function visibleItems<T extends { hidden?: boolean }>(\n items: T[] | undefined,\n isOwnProfile: boolean,\n): T[] {\n return isOwnProfile ? (items ?? []) : filterHidden(items);\n}\n\n/**\n * English heading text for each section, keyed by {@link SectionId} (e.g.\n * `other-profiles` renders as \"Links\"). Exhaustive `Record<SectionId, string>`:\n * adding a section to {@link ALL_SECTIONS} without a label here is a compile\n * error, so a section can never silently render without (or with a stale)\n * heading. Consumers with i18n resolve their own localized labels via\n * `labelKey`; this is the canonical English fallback used by the exports.\n */\nexport const SECTION_LABELS: Record<SectionId, string> = {\n about: 'About',\n career: 'Career',\n skills: 'Skills',\n projects: 'Projects',\n presentations: 'Talks & sessions',\n publications: 'Publications',\n credentials: 'Credentials',\n education: 'Education',\n courses: 'Courses',\n awards: 'Awards',\n involvement: 'Involvement',\n investments: 'Investments',\n languages: 'Languages',\n 'other-profiles': 'Links',\n};\n","/**\n * Sort profile section items from newest to oldest.\n *\n * Rules:\n * - Items with no end date (ongoing/current) sort to the top.\n * - Primary sort: end date descending (newest first).\n * - Secondary sort: start date descending (newest first).\n * - Items with no dates sort to the bottom.\n *\n * Date strings are ISO-ish (\"2024\", \"2024-03\", \"2024-03-15\") and\n * lexicographic comparison works correctly for them.\n */\n\ninterface DateRange {\n startDate?: string;\n endDate?: string;\n current?: boolean;\n}\n\ntype DateExtractor<T> = (item: T) => DateRange;\n\nconst FAR_FUTURE = '9999-12-31';\nconst FAR_PAST = '0000-01-01';\n\nexport function sortByDateDesc<T>(items: T[], extract: DateExtractor<T>): T[] {\n return [...items].sort((a, b) => {\n const da = extract(a);\n const db = extract(b);\n\n const endA = da.current ? FAR_FUTURE : (da.endDate ?? '');\n const endB = db.current ? FAR_FUTURE : (db.endDate ?? '');\n\n // Items with any date beat items with no dates at all\n const hasDateA = endA || da.startDate;\n const hasDateB = endB || db.startDate;\n if (hasDateA && !hasDateB) return -1;\n if (!hasDateA && hasDateB) return 1;\n\n // Primary: end date descending\n if (endA !== endB) return endB.localeCompare(endA);\n\n // Secondary: start date descending\n const startA = da.startDate ?? FAR_PAST;\n const startB = db.startDate ?? FAR_PAST;\n return startB.localeCompare(startA);\n });\n}\n\n/**\n * Convenience extractor for items that use `startDate` / `endDate` fields directly.\n * Used by volunteering, projects, and other sections that still use startDate/endDate.\n */\nexport function dateRangeExtractor<\n T extends { startDate?: string; endDate?: string; current?: boolean },\n>(item: T): DateRange {\n return { startDate: item.startDate, endDate: item.endDate, current: item.current };\n}\n\n/**\n * Extractor for lexicon-aligned items that use `startedAt` / `endedAt` fields.\n * Used by positions and education (current derived from !endedAt).\n */\nexport function lexiconDateExtractor<T extends { startedAt?: string; endedAt?: string }>(\n item: T,\n): DateRange {\n return { startDate: item.startedAt, endDate: item.endedAt, current: !item.endedAt };\n}\n\n/**\n * Convenience extractor for items with a single `date` field.\n */\nexport function singleDateExtractor<T extends { date?: string }>(item: T): DateRange {\n return { endDate: item.date };\n}\n\n/**\n * Extractor for certifications which use `issueDate` / `expiryDate`.\n */\nexport function certDateExtractor<T extends { issueDate?: string; expiryDate?: string }>(\n item: T,\n): DateRange {\n return { startDate: item.issueDate, endDate: item.expiryDate ?? item.issueDate };\n}\n","import { sortByDateDesc } from '../format/sort-by-date.js';\n\nconst hasValue = (date?: string) => !!date;\n\n/**\n * Sort items by date range, floating ongoing entries (startDate present, endDate\n * absent) to the top. Items with no dates sink to the bottom.\n *\n * Used by sections whose lexicons have no explicit `current` flag -- ongoing is\n * implicit from a missing endDate. Without this wrapper, the shared\n * `dateRangeExtractor` reads `item.current` (always undefined for these items)\n * and sinks ongoing entries below completed ones.\n *\n * Sections using lexicon-aligned `startedAt`/`endedAt` fields (positions,\n * education) should use `lexiconDateExtractor` instead -- that extractor already\n * derives `current` correctly.\n */\nexport function sortByActiveDateRange<T extends { startDate?: string; endDate?: string }>(\n items: T[],\n): T[] {\n return sortByDateDesc(items, (p) => ({\n startDate: p.startDate,\n endDate: p.endDate,\n current: !hasValue(p.endDate) && hasValue(p.startDate),\n }));\n}\n","const COLLATOR = new Intl.Collator('en');\n\n/**\n * Compare two display strings for sorting, with a fixed collation locale.\n *\n * A bare `a.localeCompare(b)` follows the runtime's default locale, which is\n * the server's on the server and the visitor's on the client. Mixed-script\n * lists (Latin and Cyrillic skill names, for example) then sort differently on\n * each side, and React discards the server HTML as a hydration mismatch. Use\n * this for every name sort whose output is rendered.\n */\nexport function compareText(a: string, b: string): number {\n return COLLATOR.compare(a, b);\n}\n","import { compareText } from '../format/compare-text.js';\n\nconst PROFICIENCY_RANK: Record<string, number> = {\n native: 5,\n full_professional: 4,\n professional_working: 3,\n limited_working: 2,\n elementary: 1,\n};\n\nfunction rank(proficiency: string | undefined): number {\n if (!proficiency) return 0;\n return PROFICIENCY_RANK[proficiency] ?? 0;\n}\n\n/** Sort languages by proficiency (native first), then alphabetically within a rank. */\nexport function sortLanguagesByProficiency<T extends { language?: string; proficiency?: string }>(\n items: T[],\n): T[] {\n return [...items].sort((a, b) => {\n const diff = rank(b.proficiency) - rank(a.proficiency);\n if (diff !== 0) return diff;\n return compareText(a.language ?? '', b.language ?? '');\n });\n}\n","/**\n * Per-section item sorts, shared by every profile surface so ordering can't\n * diverge between the HTML page and the Markdown / DOCX / print exports and the\n * standalone personal-site renderer. Thin wrappers over the SDK date extractors\n * plus the range/language sorts in this directory.\n */\n\nimport type {\n ProfilePosition,\n ProfileEducation,\n ProfileProject,\n ProfilePublication,\n ProfileCertification,\n ProfileHonor,\n ProfileLanguage,\n} from '../types/index.js';\nimport {\n sortByDateDesc,\n lexiconDateExtractor,\n singleDateExtractor,\n certDateExtractor,\n} from '../format/sort-by-date.js';\nimport { sortByActiveDateRange } from './range-sort.js';\nimport { sortLanguagesByProficiency } from './language-sort.js';\n\n/**\n * Move a `primary && !endedAt` position to the top, matching the HTML career\n * section, so the current primary role always leads.\n */\nexport function hoistPrimary(positions: ProfilePosition[]): ProfilePosition[] {\n const idx = positions.findIndex((p) => p.primary && !p.endedAt);\n if (idx <= 0) return positions;\n const primary = positions[idx]!;\n return [primary, ...positions.slice(0, idx), ...positions.slice(idx + 1)];\n}\n\nexport const sortPositions = (items: ProfilePosition[]): ProfilePosition[] =>\n hoistPrimary(sortByDateDesc(items, lexiconDateExtractor));\n\nexport const sortEducation = (items: ProfileEducation[]): ProfileEducation[] =>\n sortByDateDesc(items, lexiconDateExtractor);\n\nexport const sortProjects = (items: ProfileProject[]): ProfileProject[] =>\n sortByActiveDateRange(items);\n\nexport const sortPublications = (items: ProfilePublication[]): ProfilePublication[] =>\n sortByDateDesc(items, singleDateExtractor);\n\nexport const sortCertifications = (items: ProfileCertification[]): ProfileCertification[] =>\n sortByDateDesc(items, certDateExtractor);\n\nexport const sortHonors = (items: ProfileHonor[]): ProfileHonor[] =>\n sortByDateDesc(items, singleDateExtractor);\n\nexport const sortLanguages = (items: ProfileLanguage[]): ProfileLanguage[] =>\n sortLanguagesByProficiency(items);\n","/**\n * Course-role taxonomy. Mirrors `id.sifa.defs#courseRole.knownValues` from\n * sifa-lexicons. A course record without a role is a course the user took;\n * taught and assisted courses render under the \"Teaching\" heading.\n */\n\nexport interface CourseRoleOption {\n value: string;\n label: string;\n}\n\nexport const COURSE_ROLE_TAKEN = 'id.sifa.defs#courseTaken';\nexport const COURSE_ROLE_TAUGHT = 'id.sifa.defs#courseTaught';\nexport const COURSE_ROLE_TEACHING_ASSISTANT = 'id.sifa.defs#courseTeachingAssistant';\n\nexport const COURSE_ROLE_OPTIONS: CourseRoleOption[] = [\n { value: COURSE_ROLE_TAKEN, label: 'Student' },\n { value: COURSE_ROLE_TAUGHT, label: 'Instructor' },\n { value: COURSE_ROLE_TEACHING_ASSISTANT, label: 'Teaching assistant' },\n];\n\nexport const COURSE_ROLE_LABELS: Record<string, string> = Object.fromEntries(\n COURSE_ROLE_OPTIONS.map((o) => [o.value, o.label]),\n);\n\n/**\n * Resolve the label for a course-role token. An unknown token resolves to\n * `undefined` rather than the raw value, so a token a client has not learned\n * never shows up as a raw `id.sifa.defs#...` string.\n */\nexport function getCourseRoleLabel(value: string | undefined | null): string | undefined {\n if (!value) return undefined;\n return COURSE_ROLE_LABELS[value];\n}\n\nconst TEACHING_ROLES = new Set([COURSE_ROLE_TAUGHT, COURSE_ROLE_TEACHING_ASSISTANT]);\n\n/**\n * Whether a course is one the user taught or assisted with. An absent, taken,\n * or unknown role counts as taken, so a record is never dropped from the\n * profile when a client meets a token it has not learned.\n */\nexport function isTeachingCourse(course: { role?: string | null }): boolean {\n return !!course.role && TEACHING_ROLES.has(course.role);\n}\n\n/** Split courses into the ones taken and the ones taught or assisted, keeping order. */\nexport function splitCoursesByRole<T extends { role?: string | null }>(\n courses: readonly T[],\n): { taken: T[]; teaching: T[] } {\n const taken: T[] = [];\n const teaching: T[] = [];\n for (const c of courses) (isTeachingCourse(c) ? teaching : taken).push(c);\n return { taken, teaching };\n}\n","/**\n * Involvement-kind taxonomy. Mirrors `id.sifa.defs#involvementKind.knownValues`\n * from sifa-lexicons. `label` is the picker/select label; `heading` is the\n * profile section heading a record of this kind renders under (charity records,\n * including mapped legacy `volunteering`, render under \"Volunteering\").\n */\n\nexport interface InvolvementKindOption {\n value: string;\n label: string;\n heading: string;\n}\n\nexport const INVOLVEMENT_KIND_OPTIONS: InvolvementKindOption[] = [\n { value: 'id.sifa.defs#involvementOpenSource', label: 'Open source', heading: 'Open Source' },\n { value: 'id.sifa.defs#involvementCommunity', label: 'Community', heading: 'Community' },\n { value: 'id.sifa.defs#involvementCharity', label: 'Volunteering', heading: 'Volunteering' },\n { value: 'id.sifa.defs#involvementCivic', label: 'Civic', heading: 'Civic' },\n { value: 'id.sifa.defs#involvementOther', label: 'Other', heading: 'Other' },\n];\n\nexport const INVOLVEMENT_KIND_LABELS: Record<string, string> = Object.fromEntries(\n INVOLVEMENT_KIND_OPTIONS.map((o) => [o.value, o.label]),\n);\n\nexport const INVOLVEMENT_KIND_HEADINGS: Record<string, string> = Object.fromEntries(\n INVOLVEMENT_KIND_OPTIONS.map((o) => [o.value, o.heading]),\n);\n\n/** Resolve the select label for an involvement-kind token. Falls back to the raw value. */\nexport function getInvolvementKindLabel(value: string | undefined | null): string | undefined {\n if (!value) return undefined;\n return INVOLVEMENT_KIND_LABELS[value] ?? value;\n}\n\n/**\n * Resolve the display-section heading for an involvement-kind token. Unknown\n * kinds (including a future token an older client hasn't learned) fall under\n * \"Other\" so a record is never dropped from the profile.\n */\nexport function getInvolvementKindHeading(value: string | undefined | null): string {\n if (!value) return 'Other';\n return INVOLVEMENT_KIND_HEADINGS[value] ?? 'Other';\n}\n","export const SKILL_CATEGORIES = [\n { value: 'technical', label: 'Technical' },\n { value: 'business', label: 'Business' },\n { value: 'creative', label: 'Creative' },\n { value: 'interpersonal', label: 'Interpersonal' },\n { value: 'industry', label: 'Industry' },\n { value: 'community', label: 'Community' },\n { value: 'security', label: 'Security' },\n] as const;\n\nexport type SkillCategory = (typeof SKILL_CATEGORIES)[number]['value'];\n\nexport const CATEGORY_ORDER: ReadonlyArray<SkillCategory> = SKILL_CATEGORIES.map((c) => c.value);\n\nexport const CATEGORY_LABELS: Record<SkillCategory | 'other', string> = {\n ...(Object.fromEntries(SKILL_CATEGORIES.map((c) => [c.value, c.label])) as Record<\n SkillCategory,\n string\n >),\n other: 'Other',\n};\n\n/**\n * Reduces a `category` value from a skill record to a bare token.\n *\n * `id.sifa.profile.skill` publishes its `knownValues` in lexicon-ref form\n * (`id.sifa.defs#technical`), so a client writing that is following the\n * lexicon. Sifa's own surfaces store and compare bare tokens (`technical`), and\n * without this the ref form falls through to the \"other\" bucket. Both forms are\n * legal: `knownValues` is advisory in AT Protocol, not a closed enum.\n *\n * Normalising is not validating. An unrecognised value is returned as-is, in\n * lowercase, and callers decide what to do with it (`groupSkillsByCategory`\n * buckets it as \"other\").\n */\nexport function normalizeSkillCategory(value: string | undefined | null): string | undefined {\n if (typeof value !== 'string') return undefined;\n const afterRef = value.includes('#') ? value.slice(value.lastIndexOf('#') + 1) : value;\n const token = afterRef.trim().toLowerCase();\n return token === '' ? undefined : token;\n}\n","import type { ProfileSkill } from '../types/index.js';\n\nimport { CATEGORY_ORDER, normalizeSkillCategory } from './skill-categories.js';\nimport { compareText } from '../format/compare-text.js';\n\nexport type MergedProfileSkill = ProfileSkill & {\n mergedRkeys: string[];\n positionRkeys?: string[];\n};\n\n/**\n * Collapses skills that resolve to the same name (case-insensitive, trimmed).\n *\n * LinkedIn import creates one skill record per (skill, position) pair, so a\n * profile can have several \"Ruby\" rows. We surface them as a single chip with\n * all underlying rkeys exposed via `mergedRkeys` so edit/delete can fan out.\n */\nexport function dedupeSkills(skills: ProfileSkill[]): MergedProfileSkill[] {\n const groups = new Map<string, MergedProfileSkill>();\n\n for (const skill of skills) {\n const key = skill.name.trim().toLowerCase();\n const existing = groups.get(key);\n const positions = (skill as ProfileSkill & { positionRkeys?: string[] }).positionRkeys ?? [];\n\n if (!existing) {\n groups.set(key, {\n ...skill,\n mergedRkeys: [skill.rkey],\n positionRkeys: [...positions],\n });\n continue;\n }\n\n existing.mergedRkeys.push(skill.rkey);\n if (!existing.category && skill.category) existing.category = skill.category;\n const incomingSubCategory = skill.subCategory?.trim();\n if (incomingSubCategory && !existing.subCategory?.trim()) {\n existing.subCategory = incomingSubCategory;\n }\n if ((skill.endorsementCount ?? 0) > (existing.endorsementCount ?? 0)) {\n existing.endorsementCount = skill.endorsementCount;\n }\n if (skill.endorsed) existing.endorsed = true;\n if (skill.activityBacked) existing.activityBacked = true;\n const merged = new Set([...(existing.positionRkeys ?? []), ...positions]);\n existing.positionRkeys = Array.from(merged);\n }\n\n return Array.from(groups.values());\n}\n\n/**\n * Groups skills by category in CATEGORY_ORDER, with unknown/empty categories\n * collected under \"other\". Within each group: sorted by endorsementCount desc,\n * then alphabetical by name. Empty groups are omitted.\n */\nexport function groupSkillsByCategory<T extends ProfileSkill>(skills: T[]): [string, T[]][] {\n const grouped = new Map<string, T[]>();\n\n for (const skill of skills) {\n // Accepts the lexicon's own ref form (id.sifa.defs#technical) as well as\n // the bare token, so a record written to spec is not bucketed as \"other\".\n const normalised = normalizeSkillCategory(skill.category) ?? '';\n const key = (CATEGORY_ORDER as readonly string[]).includes(normalised) ? normalised : 'other';\n const bucket = grouped.get(key) ?? [];\n bucket.push(skill);\n grouped.set(key, bucket);\n }\n\n for (const [, groupSkills] of grouped) {\n groupSkills.sort((a, b) => {\n const countDiff = (b.endorsementCount ?? 0) - (a.endorsementCount ?? 0);\n if (countDiff !== 0) return countDiff;\n return compareText(a.name, b.name);\n });\n }\n\n const ordered: [string, T[]][] = [];\n for (const cat of CATEGORY_ORDER) {\n const group = grouped.get(cat);\n if (group?.length) ordered.push([cat, group]);\n }\n const otherGroup = grouped.get('other');\n if (otherGroup?.length) ordered.push(['other', otherGroup]);\n\n return ordered;\n}\n\n/**\n * Groups skills by their freeform `subCategory` label (#305), for renderers\n * that present skills in the user's own groups (Frontend, Backend, etc.).\n *\n * Labels are matched case-insensitively and surfaced under the first-seen\n * casing. Groups are ordered alphabetically by label; skills with no\n * `subCategory` collect under a trailing `null` bucket (omitted when empty).\n * Within each group: endorsementCount desc, then alphabetical by name.\n */\nexport function groupSkillsBySubCategory<T extends ProfileSkill>(\n skills: T[],\n): [string | null, T[]][] {\n const labels = new Map<string, string>();\n const grouped = new Map<string, T[]>();\n\n for (const skill of skills) {\n const raw = skill.subCategory?.trim();\n const key = raw ? raw.toLowerCase() : '';\n if (raw && !labels.has(key)) labels.set(key, raw);\n const bucket = grouped.get(key) ?? [];\n bucket.push(skill);\n grouped.set(key, bucket);\n }\n\n // Clone before sorting so the caller's arrays are never mutated in place.\n const sortByRank = (groupSkills: T[]): T[] =>\n [...groupSkills].sort((a, b) => {\n const countDiff = (b.endorsementCount ?? 0) - (a.endorsementCount ?? 0);\n if (countDiff !== 0) return countDiff;\n return compareText(a.name, b.name);\n });\n\n const ordered: [string | null, T[]][] = [];\n for (const key of [...labels.keys()].sort(compareText)) {\n const label = labels.get(key);\n const group = grouped.get(key);\n if (label && group?.length) ordered.push([label, sortByRank(group)]);\n }\n const ungrouped = grouped.get('');\n if (ungrouped?.length) ordered.push([null, sortByRank(ungrouped)]);\n\n return ordered;\n}\n","/** Shared URL helpers for the JSON-LD emitters. */\n\nexport const DEFAULT_BASE_URL = 'https://sifa.id';\n\n/**\n * Drop trailing slashes from a caller-supplied base URL.\n *\n * Written as a scan rather than `replace(/\\/+$/, '')` on purpose: the regex\n * form is a polynomial-backtracking hazard on input the library does not\n * control (CodeQL js/polynomial-redos). This runs in linear time.\n */\nexport function normaliseBaseUrl(baseUrl: string | undefined): string {\n const value = baseUrl ?? DEFAULT_BASE_URL;\n let end = value.length;\n while (end > 0 && value.charCodeAt(end - 1) === 0x2f) end -= 1;\n return value.slice(0, end);\n}\n\nexport function profileUrl(baseUrl: string, handle: string): string {\n return `${baseUrl}/p/${handle}`;\n}\n","/**\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 * Involvement, talks and courses taken have no JSON Resume key of their own and\n * go into the nearest standard section: involvement next to volunteering, talks\n * as publications of type \"Talks\", courses as certificates. Strict consumers\n * such as altacv refuse any unknown top-level key, so nothing new is added\n * there. Fields with no reasonable slot -- endorsements, confirmations,\n * investments, courses someone taught -- are dropped. The loss is documented\n * for 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 { isTeachingCourse } from '../taxonomy/course-role.js';\nimport { getInvolvementKindLabel } from '../taxonomy/involvement-kind.js';\nimport { CATEGORY_LABELS } from '../taxonomy/skill-categories.js';\nimport { groupSkillsByCategory } from '../taxonomy/skill-grouping.js';\nimport type {\n ExternalAccount,\n LanguageProficiency,\n LocationValue,\n ProfileCertification,\n ProfileCourse,\n ProfileEducation,\n ProfileHonor,\n ProfileInvolvement,\n ProfileLanguage,\n ProfileLocation,\n ProfilePosition,\n ProfilePresentation,\n ProfilePresentationDelivery,\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 involvement?: ProfileInvolvement[];\n readonly courses?: ProfileCourse[];\n readonly presentations?: ProfilePresentation[];\n /** Deliveries not tied to a presentation record are listed here only. */\n readonly presentationDeliveries?: ProfilePresentationDelivery[];\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 /** Expiry date. Not in the JSON Resume schema, which allows extra fields. */\n readonly endDate?: 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 * \"Talks\" for a talk. Not in the JSON Resume schema, which allows extra\n * fields; CV templates such as altacv group publications by it.\n */\n readonly type?: string;\n}\n\n/** A skill category, with the skills in it as keywords. */\nexport interface JsonResumeSkill {\n readonly name: string;\n readonly keywords: 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/** Event names a talk shows: the most recent ones, then how many more. */\nconst TALK_EVENTS_SHOWN = 3;\n\n/** Newest first; undated last. */\nfunction byDateDesc(a: { date?: string | null }, b: { date?: string | null }): number {\n return (b.date ?? '').localeCompare(a.date ?? '');\n}\n\n/**\n * Talks as publications of type \"Talks\": one per talk, with the events it was\n * given at (newest first) as the publisher and the latest date. A delivery not\n * tied to a talk record is a talk of its own. Newest first.\n */\nfunction mapTalks(profile: JsonResumeProfileInput, s: Sanitizer): JsonResumePublication[] {\n const standalone = filterHidden(profile.presentationDeliveries).filter(\n (d) => !d.presentationRkey,\n );\n const talks = filterHidden(profile.presentations).map((talk) => {\n const deliveries = filterHidden(talk.deliveries).sort(byDateDesc);\n const events = [\n ...new Set(deliveries.map((d) => text(d.eventName ?? undefined, s)).filter(Boolean)),\n ] as string[];\n const shown = events.slice(0, TALK_EVENTS_SHOWN).join(', ');\n const more = events.length - TALK_EVENTS_SHOWN;\n return compact<JsonResumePublication>({\n name: s(talk.title),\n publisher: more > 0 ? `${shown} and ${more} more` : shown || undefined,\n releaseDate: toResumeDate(deliveries[0]?.date ?? undefined),\n url: link(talk.links?.[0]?.uri, s),\n summary: text(talk.description ?? undefined, s),\n type: 'Talks',\n });\n });\n const loose = standalone.map((d) =>\n compact<JsonResumePublication>({\n name: s(d.title?.trim() || d.eventName?.trim() || ''),\n publisher: text(d.eventName ?? undefined, s),\n releaseDate: toResumeDate(d.date ?? undefined),\n url: link(d.links?.[0]?.uri, s),\n type: 'Talks',\n }),\n );\n return [...talks, ...loose]\n .filter((t) => t.name)\n .sort((a, b) => byDateDesc({ date: a.releaseDate }, { date: b.releaseDate }));\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 // Involvement (open source, communities, civic roles) has no JSON Resume key\n // and sits next to volunteering, sorted together.\n const volunteer = sortByActiveDateRange([\n ...filterHidden(profile.volunteering).map((entry) => ({\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 ...filterHidden(profile.involvement).map((entry) => ({\n organization: orgName(entry.entityName, entry.upstream, s),\n position: text(entry.role, s) ?? text(getInvolvementKindLabel(entry.kind), s),\n summary: text(entry.description, s),\n startDate: toResumeDate(entry.startedAt),\n endDate: toResumeDate(entry.endedAt),\n })),\n ]).map((entry) => compact<JsonResumeVolunteer>(entry));\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 endDate: toResumeDate(cert.expiryDate),\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 // Courses taken, after the certifications. A course whose credential is\n // already listed as a certification would print twice, and courses someone\n // taught are not certificates.\n const listedCredentials = new Set(filterHidden(profile.certifications).map((c) => c.rkey));\n for (const course of filterHidden(profile.courses)) {\n if (isTeachingCourse(course)) continue;\n if (course.credentialRkey && listedCredentials.has(course.credentialRkey)) continue;\n certificates.push(\n compact<JsonResumeCertificate>({\n name: s(course.name),\n date: toResumeDate(course.completedAt),\n issuer: orgName(course.entityName, course.institution, s),\n }),\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 publications.push(...mapTalks(profile, s));\n\n // JSON Resume's grouped shape: one group per category, in the profile's\n // category order, named as the profile names it. CV templates print the\n // group name as a label. Endorsement counts have no slot and are dropped.\n // Skill records carry no `hidden` flag, so there is nothing to filter here.\n const skills = groupSkillsByCategory(profile.skills ?? []).map(([category, items]) => ({\n name: CATEGORY_LABELS[category as keyof typeof CATEGORY_LABELS] ?? category,\n keywords: items.map((skill) => s(skill.name)),\n }));\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","/**\n * Funder-format CV documents: the NIH Biographical Sketch (Common Form plus\n * NIH Supplement) and the ERC Part B1 \"Curriculum vitae and Track Record\".\n *\n * A pure mapper from a Sifa profile and the owner's pick of items to a plain\n * JSON document a typesetter lays out. Like the JSON Resume emitter next door,\n * nothing here fetches or renders.\n *\n * Funders cap how many items a CV may list. The caps live in\n * `FUNDER_CV_GROUPS`, so the export page that offers the choice and the server\n * that enforces it read one number. Sections a funder asks for that Sifa holds\n * no records for (a personal statement, contributions to science, career\n * breaks) are emitted as `null` or empty, for the template to show as a\n * placeholder the applicant fills in.\n */\n\nimport { z } from 'zod';\n\nimport { formatLocation } from '../format/location-utils.js';\nimport { formatStructuredName } from '../format/pds-utils.js';\nimport { filterHidden } from '../profile/section-model.js';\nimport { isTeachingCourse } from '../taxonomy/course-role.js';\nimport type {\n ExternalAccount,\n ProfileCourse,\n ProfileEducation,\n ProfileHonor,\n ProfilePosition,\n ProfilePresentation,\n ProfilePublication,\n ProfileVolunteering,\n} from '../types/index.js';\nimport { normalizeExportContact, type ExportContact } from './export-contact.js';\nimport { toResumeDate } from './json-resume.js';\n\nexport const FUNDER_CV_FORMATS = ['nih', 'erc'] as const;\nexport type FunderCvFormat = (typeof FUNDER_CV_FORMATS)[number];\n\nexport const FUNDER_CV_ITEM_KINDS = ['publication', 'presentation', 'honor'] as const;\nexport type FunderCvItemKind = (typeof FUNDER_CV_ITEM_KINDS)[number];\n\nexport interface FunderCvGroupSpec {\n readonly kinds: readonly FunderCvItemKind[];\n /** Most items the funder's form takes for this group. */\n readonly max: number;\n}\n\n/**\n * The pickable groups per format, with the funder's item limits.\n *\n * - NIH Common Form \"Products\": up to 5 closely related to the proposed\n * project and up to 5 other significant products. Publications, conference\n * papers and presentations all count. NIH Supplement \"Honors\": up to 15.\n * - ERC Part B1 \"Research achievements\": up to ten research outputs. \"Peer\n * recognition\" is \"selected examples\" with no number; 15 is Sifa's own cap,\n * to keep the section inside the 4-page limit.\n */\nexport const FUNDER_CV_GROUPS = {\n nih: {\n related: { kinds: ['publication', 'presentation'], max: 5 },\n other: { kinds: ['publication', 'presentation'], max: 5 },\n honors: { kinds: ['honor'], max: 15 },\n },\n erc: {\n outputs: { kinds: ['publication'], max: 10 },\n recognition: { kinds: ['honor', 'presentation'], max: 15 },\n },\n} as const satisfies Record<FunderCvFormat, Record<string, FunderCvGroupSpec>>;\n\nexport type FunderCvGroupName<F extends FunderCvFormat> = keyof (typeof FUNDER_CV_GROUPS)[F] &\n string;\n\n/** A picked item: `<kind>:<rkey>`, e.g. `publication:3kxyz`. */\nexport function funderCvItemId(kind: FunderCvItemKind, rkey: string): string {\n return `${kind}:${rkey}`;\n}\n\n/**\n * Record key syntax (atproto: 1-512 of A-Z a-z 0-9 . - _ : ~), plus `/`:\n * publications from Standard.site are keyed by their AT URI (`std-at://...`).\n */\nconst ITEM_ID_RE = /^(publication|presentation|honor):[A-Za-z0-9._~:/-]{1,512}$/;\n\nfunction kindOf(id: string): FunderCvItemKind | undefined {\n const kind = id.slice(0, id.indexOf(':'));\n return (FUNDER_CV_ITEM_KINDS as readonly string[]).includes(kind)\n ? (kind as FunderCvItemKind)\n : undefined;\n}\n\nfunction groupSchema(spec: FunderCvGroupSpec) {\n return z\n .array(\n z\n .string()\n .regex(ITEM_ID_RE)\n .refine((id) => spec.kinds.includes(kindOf(id) as FunderCvItemKind), {\n message: `Only ${spec.kinds.join(', ')} items fit here`,\n }),\n )\n .max(spec.max)\n .default([]);\n}\n\nfunction noRepeats(lists: readonly string[][]): boolean {\n const all = lists.flat();\n return new Set(all).size === all.length;\n}\n\nconst nihSelectionSchema = z\n .object({\n format: z.literal('nih'),\n related: groupSchema(FUNDER_CV_GROUPS.nih.related),\n other: groupSchema(FUNDER_CV_GROUPS.nih.other),\n honors: groupSchema(FUNDER_CV_GROUPS.nih.honors),\n })\n .refine((s) => noRepeats([s.related, s.other, s.honors]), {\n message: 'An item can be listed once',\n });\n\nconst ercSelectionSchema = z\n .object({\n format: z.literal('erc'),\n outputs: groupSchema(FUNDER_CV_GROUPS.erc.outputs),\n recognition: groupSchema(FUNDER_CV_GROUPS.erc.recognition),\n })\n .refine((s) => noRepeats([s.outputs, s.recognition]), {\n message: 'An item can be listed once',\n });\n\n/**\n * The owner's pick for one format. Enforces the shape and the funder's limits;\n * whether each id is one of the owner's own visible records is a separate\n * check against the profile, `findUnknownFunderCvItems`.\n */\nexport const funderCvSelectionSchema = z.discriminatedUnion('format', [\n nihSelectionSchema,\n ercSelectionSchema,\n]);\n\nexport type FunderCvSelection = z.infer<typeof funderCvSelectionSchema>;\n\n/** The subset of `Profile` the funder mapper reads. */\nexport interface FunderCvProfileInput {\n readonly handle: string;\n readonly displayName?: string;\n readonly givenName?: string;\n readonly familyName?: string;\n readonly headline?: string;\n readonly website?: string;\n readonly positions?: ProfilePosition[];\n readonly education?: ProfileEducation[];\n readonly publications?: ProfilePublication[];\n readonly presentations?: ProfilePresentation[];\n readonly honors?: ProfileHonor[];\n readonly courses?: ProfileCourse[];\n readonly volunteering?: ProfileVolunteering[];\n readonly externalAccounts?: ExternalAccount[];\n}\n\nexport interface FunderCvCandidate {\n readonly id: string;\n readonly kind: FunderCvItemKind;\n readonly title: string;\n /** `YYYY`, `YYYY-MM` or `YYYY-MM-DD`; absent when the record has no date. */\n readonly date?: string;\n}\n\n/** The most recent visible delivery of a talk, which dates it. */\nfunction latestDeliveryRecord(presentation: ProfilePresentation) {\n const dateOf = (d: { date?: string | null }) => toResumeDate(d.date ?? undefined) ?? '';\n return [...filterHidden(presentation.deliveries)]\n .sort((a, b) => dateOf(a).localeCompare(dateOf(b)))\n .at(-1);\n}\n\nfunction latestDelivery(presentation: ProfilePresentation): string | undefined {\n return toResumeDate(latestDeliveryRecord(presentation)?.date ?? undefined);\n}\n\nfunction candidatesOf(profile: FunderCvProfileInput, kind: FunderCvItemKind): FunderCvCandidate[] {\n switch (kind) {\n case 'publication':\n return filterHidden(profile.publications).map((p) => ({\n id: funderCvItemId(kind, p.rkey),\n kind,\n title: p.title,\n date: toResumeDate(p.date),\n }));\n case 'presentation':\n return filterHidden(profile.presentations).map((p) => ({\n id: funderCvItemId(kind, p.rkey),\n kind,\n title: p.title,\n date: latestDelivery(p),\n }));\n case 'honor':\n return filterHidden(profile.honors).map((h) => ({\n id: funderCvItemId(kind, h.rkey),\n kind,\n title: h.title,\n date: toResumeDate(h.date),\n }));\n }\n}\n\n/**\n * The owner's visible items of the given kinds, most recent first. Undated\n * items go last, in profile order. The sort is stable, so equal dates keep\n * profile order too.\n */\nexport function listFunderCvCandidates(\n profile: FunderCvProfileInput,\n kinds: readonly FunderCvItemKind[],\n): FunderCvCandidate[] {\n const all = kinds.flatMap((kind) => candidatesOf(profile, kind));\n return all.sort((a, b) => {\n if (a.date && b.date) return b.date.localeCompare(a.date);\n if (a.date) return -1;\n if (b.date) return 1;\n return 0;\n });\n}\n\n/**\n * What the export page pre-ticks: the most recent publications up to each\n * limit (for NIH, the first five as closely related and the next five as\n * other), and the most recent honors. Talks are offered but not pre-ticked.\n */\nexport function defaultFunderCvSelection(\n profile: FunderCvProfileInput,\n format: FunderCvFormat,\n): FunderCvSelection {\n const publications = listFunderCvCandidates(profile, ['publication']).map((c) => c.id);\n const honors = listFunderCvCandidates(profile, ['honor']).map((c) => c.id);\n if (format === 'nih') {\n const { related, other } = FUNDER_CV_GROUPS.nih;\n return {\n format,\n related: publications.slice(0, related.max),\n other: publications.slice(related.max, related.max + other.max),\n honors: honors.slice(0, FUNDER_CV_GROUPS.nih.honors.max),\n };\n }\n return {\n format,\n outputs: publications.slice(0, FUNDER_CV_GROUPS.erc.outputs.max),\n recognition: honors.slice(0, FUNDER_CV_GROUPS.erc.recognition.max),\n };\n}\n\nfunction selectedIds(selection: FunderCvSelection): string[] {\n return selection.format === 'nih'\n ? [...selection.related, ...selection.other, ...selection.honors]\n : [...selection.outputs, ...selection.recognition];\n}\n\n/**\n * Ids in the selection that are not visible records on this profile. The\n * profile is the owner's own, so an empty result means every pick is theirs.\n */\nexport function findUnknownFunderCvItems(\n profile: FunderCvProfileInput,\n selection: FunderCvSelection,\n): string[] {\n const known = new Set(listFunderCvCandidates(profile, FUNDER_CV_ITEM_KINDS).map((c) => c.id));\n return selectedIds(selection).filter((id) => !known.has(id));\n}\n\n// ---------------------------------------------------------------------------\n// Document shapes\n// ---------------------------------------------------------------------------\n\nexport interface FunderCvPerson {\n /** Full name as the profile shows it; the handle when there is no name. */\n readonly name: string;\n readonly givenName?: string;\n readonly familyName?: string;\n /** Bare ORCID iD, e.g. `0000-0002-1825-0097`. */\n readonly orcid?: string;\n readonly website?: string;\n}\n\n/**\n * The ERC person, with the contact and personal details the owner typed for\n * this export. The NIH Biographical Sketch has no such block, so only ERC carries them.\n */\nexport interface ErcFunderCvPerson extends FunderCvPerson {\n readonly email?: string;\n readonly phone?: string;\n /** Lines are separated by `\\n`. */\n readonly address?: string;\n readonly driversLicense?: string;\n readonly rightToWork?: string;\n readonly nationality?: string;\n}\n\nexport interface FunderCvOptions {\n /**\n * Contact details the owner typed for this export. Sifa stores none of\n * them. Used for ERC only.\n */\n readonly contact?: ExportContact;\n}\n\n/** One product or research output, ready to cite. */\nexport interface FunderCvCitation {\n readonly kind: 'publication' | 'presentation';\n readonly title: string;\n /** Authors in record order, comma separated. For a talk, the speaker. */\n readonly authors?: string;\n /** Journal, publisher or event. */\n readonly venue?: string;\n /** Year. */\n readonly date?: string;\n readonly doi?: string;\n readonly url?: string;\n}\n\nexport interface FunderCvHonor {\n readonly year?: string;\n readonly title: string;\n readonly organization?: string;\n}\n\nexport interface NihEducation {\n readonly organization: string;\n readonly location?: string;\n readonly degree?: string;\n /** Start date, `MM/YYYY` or `YYYY`. */\n readonly start?: string;\n /** Receipt date, `MM/YYYY` or `YYYY`. */\n readonly end?: string;\n readonly field?: string;\n}\n\nexport interface FunderCvAppointment {\n /** `YYYY`. */\n readonly start?: string;\n /** `YYYY`, or null for a current appointment. */\n readonly end: string | null;\n readonly title: string;\n readonly organization?: string;\n readonly location?: string;\n}\n\n/** NIH Biographical Sketch: Common Form plus NIH Supplement. */\nexport interface NihFunderCv {\n readonly format: 'nih';\n readonly person: FunderCvPerson;\n readonly positionTitle?: string;\n /** Primary organization: the current position's. */\n readonly organization?: string;\n readonly location?: string;\n readonly education: NihEducation[];\n readonly appointments: FunderCvAppointment[];\n readonly products: { readonly related: FunderCvCitation[]; readonly other: FunderCvCitation[] };\n readonly honors: FunderCvHonor[];\n /** Supplement \"Personal Statement\". Sifa holds no record for it. */\n readonly personalStatement: string | null;\n /** Supplement \"Contributions to Science\". Sifa holds no record for them. */\n readonly contributions: string[];\n}\n\nexport interface ErcEducation {\n /** Receipt date, `MM/YYYY` or `YYYY`. */\n readonly date?: string;\n readonly degree?: string;\n readonly field?: string;\n readonly institution: string;\n}\n\nexport interface ErcRecognition {\n readonly kind: 'honor' | 'presentation';\n readonly year?: string;\n readonly title: string;\n /** Awarding body, or the event a talk was given at. */\n readonly organization?: string;\n}\n\nexport interface ErcContribution {\n readonly kind: 'teaching' | 'service';\n readonly start?: string;\n readonly end: string | null;\n readonly title: string;\n readonly organization?: string;\n}\n\n/** ERC Part B1, section \"Curriculum vitae and Track Record\". */\nexport interface ErcFunderCv {\n readonly format: 'erc';\n readonly person: ErcFunderCvPerson;\n readonly education: ErcEducation[];\n readonly currentPositions: FunderCvAppointment[];\n readonly previousPositions: FunderCvAppointment[];\n readonly outputs: FunderCvCitation[];\n readonly recognition: ErcRecognition[];\n readonly communityContributions: ErcContribution[];\n /** Proposal acronym for the page header. Not a profile fact. */\n readonly acronym: string | null;\n /** \"Career breaks, diverse career paths and major life events\". */\n readonly careerBreaks: string | null;\n}\n\nexport type FunderCvDocument = NihFunderCv | ErcFunderCv;\n\n// ---------------------------------------------------------------------------\n// Mapping\n// ---------------------------------------------------------------------------\n\nfunction text(value: string | null | undefined): string | undefined {\n const trimmed = value?.trim();\n return trimmed ? trimmed : undefined;\n}\n\nfunction compact<T extends object>(value: T): T {\n return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined)) as T;\n}\n\nfunction year(value: string | null | undefined): string | undefined {\n return toResumeDate(value ?? undefined)?.slice(0, 4);\n}\n\n/** `MM/YYYY` when the month is known, else `YYYY`. */\nfunction monthYear(value: string | null | undefined): string | undefined {\n const date = toResumeDate(value ?? undefined);\n if (!date) return undefined;\n return date.length >= 7 ? `${date.slice(5, 7)}/${date.slice(0, 4)}` : date;\n}\n\n/** Newest start first; undated entries last, in profile order. */\nfunction byStartDesc<T>(items: T[], start: (item: T) => string | undefined): T[] {\n return [...items].sort((a, b) => {\n const da = toResumeDate(start(a));\n const db = toResumeDate(start(b));\n if (da && db) return db.localeCompare(da);\n if (da) return -1;\n if (db) return 1;\n return 0;\n });\n}\n\nconst ORCID_RE = /\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]/;\n\nfunction orcidOf(accounts: ExternalAccount[] | undefined): string | undefined {\n const account = filterHidden(accounts).find((a) => a.platform.toLowerCase() === 'orcid');\n return account ? ORCID_RE.exec(account.url)?.[0] : undefined;\n}\n\nfunction personOf(profile: FunderCvProfileInput): FunderCvPerson {\n return compact<FunderCvPerson>({\n name:\n formatStructuredName(profile.givenName, profile.familyName) ??\n text(profile.displayName) ??\n profile.handle,\n givenName: text(profile.givenName),\n familyName: text(profile.familyName),\n orcid: orcidOf(profile.externalAccounts),\n website: text(profile.website),\n });\n}\n\nfunction appointment(position: ProfilePosition): FunderCvAppointment {\n return compact<FunderCvAppointment>({\n start: year(position.startedAt),\n end: year(position.endedAt) ?? null,\n title: position.title,\n organization: text(position.entityName) ?? text(position.company),\n location: text(formatLocation(position.location)),\n });\n}\n\n/** The current position to name on the form: the flagged primary, else the newest. */\nfunction currentPosition(positions: ProfilePosition[]): ProfilePosition | undefined {\n const current = byStartDesc(\n positions.filter((p) => !text(p.endedAt)),\n (p) => p.startedAt,\n );\n return current.find((p) => p.primary) ?? current[0];\n}\n\nfunction lookup(profile: FunderCvProfileInput) {\n const publications = new Map(filterHidden(profile.publications).map((p) => [p.rkey, p]));\n const presentations = new Map(filterHidden(profile.presentations).map((p) => [p.rkey, p]));\n const honors = new Map(filterHidden(profile.honors).map((h) => [h.rkey, h]));\n const split = (id: string) => {\n const at = id.indexOf(':');\n return { kind: id.slice(0, at), rkey: id.slice(at + 1) };\n };\n return { publications, presentations, honors, split };\n}\n\nfunction citations(\n ids: readonly string[],\n profile: FunderCvProfileInput,\n person: FunderCvPerson,\n): FunderCvCitation[] {\n const { publications, presentations, split } = lookup(profile);\n return ids.flatMap((id): FunderCvCitation[] => {\n const { kind, rkey } = split(id);\n if (kind === 'publication') {\n const p = publications.get(rkey);\n if (!p) return [];\n const authors = (p.contributors ?? []).map((c) => c.name.trim()).filter(Boolean);\n return [\n compact<FunderCvCitation>({\n kind: 'publication',\n title: p.title,\n authors: authors.length > 0 ? authors.join(', ') : undefined,\n venue: text(p.publisher),\n date: year(p.date),\n doi: text(p.doi),\n url: text(p.url),\n }),\n ];\n }\n if (kind === 'presentation') {\n const talk = presentations.get(rkey);\n if (!talk) return [];\n const delivery = latestDeliveryRecord(talk);\n return [\n compact<FunderCvCitation>({\n kind: 'presentation',\n title: talk.title,\n authors: person.name,\n venue: text(delivery?.eventName),\n date: year(delivery?.date),\n url: text(talk.links?.[0]?.uri),\n }),\n ];\n }\n return [];\n });\n}\n\nfunction honorsOf(ids: readonly string[], profile: FunderCvProfileInput): FunderCvHonor[] {\n const { honors, split } = lookup(profile);\n return ids.flatMap((id) => {\n const { kind, rkey } = split(id);\n const h = kind === 'honor' ? honors.get(rkey) : undefined;\n if (!h) return [];\n return [\n compact<FunderCvHonor>({\n year: year(h.date),\n title: h.title,\n organization: text(h.entityName) ?? text(h.issuer),\n }),\n ];\n });\n}\n\n/**\n * Build the funder document from the profile and the owner's selection.\n *\n * Hidden records never appear. Selected ids that match no visible record are\n * skipped; callers that must refuse them check `findUnknownFunderCvItems`\n * first. Selected items keep the order they were picked in.\n */\nexport function profileToFunderCv(\n profile: FunderCvProfileInput,\n selection: FunderCvSelection,\n options: FunderCvOptions = {},\n): FunderCvDocument {\n const person = personOf(profile);\n const positions = filterHidden(profile.positions);\n const education = byStartDesc(filterHidden(profile.education), (e) => e.startedAt);\n\n if (selection.format === 'nih') {\n const current = currentPosition(positions);\n return compact<NihFunderCv>({\n format: 'nih',\n person,\n positionTitle: text(current?.title),\n organization: current ? appointment(current).organization : undefined,\n location: text(formatLocation(current?.location)),\n education: education.map((e) =>\n compact<NihEducation>({\n organization: text(e.entityName) ?? e.institution,\n degree: text(e.degree),\n start: monthYear(e.startedAt),\n end: monthYear(e.endedAt),\n field: text(e.fieldOfStudy),\n }),\n ),\n appointments: byStartDesc(positions, (p) => p.startedAt).map(appointment),\n products: {\n related: citations(selection.related, profile, person),\n other: citations(selection.other, profile, person),\n },\n honors: honorsOf(selection.honors, profile),\n personalStatement: null,\n contributions: [],\n });\n }\n\n const appointments = byStartDesc(positions, (p) => p.startedAt);\n const { presentations, split } = lookup(profile);\n\n const recognition = selection.recognition.flatMap((id): ErcRecognition[] => {\n const { kind, rkey } = split(id);\n if (kind === 'honor') {\n const [honor] = honorsOf([id], profile);\n return honor ? [{ kind: 'honor', ...honor }] : [];\n }\n const talk = kind === 'presentation' ? presentations.get(rkey) : undefined;\n if (!talk) return [];\n const delivery = latestDeliveryRecord(talk);\n return [\n compact<ErcRecognition>({\n kind: 'presentation',\n year: year(delivery?.date),\n title: talk.title,\n organization: text(delivery?.eventName),\n }),\n ];\n });\n\n const teaching = filterHidden(profile.courses)\n .filter(isTeachingCourse)\n .map((c) =>\n compact<ErcContribution>({\n kind: 'teaching',\n start: year(c.startedAt),\n end: year(c.endedAt) ?? null,\n title: c.name,\n organization: text(c.entityName) ?? text(c.institution),\n }),\n );\n const service = filterHidden(profile.volunteering).map((v) =>\n compact<ErcContribution>({\n kind: 'service',\n start: year(v.startDate),\n end: year(v.endDate) ?? null,\n title: text(v.role) ?? text(v.entityName) ?? v.organization,\n organization: text(v.entityName) ?? text(v.organization),\n }),\n );\n\n return {\n format: 'erc',\n person: { ...person, ...normalizeExportContact(options.contact ?? {}) },\n education: education.map((e) =>\n compact<ErcEducation>({\n date: monthYear(e.endedAt) ?? monthYear(e.startedAt),\n degree: text(e.degree),\n field: text(e.fieldOfStudy),\n institution: text(e.entityName) ?? e.institution,\n }),\n ),\n currentPositions: appointments.filter((p) => !text(p.endedAt)).map(appointment),\n previousPositions: appointments.filter((p) => !!text(p.endedAt)).map(appointment),\n outputs: citations(selection.outputs, profile, person),\n recognition,\n communityContributions: [...teaching, ...service],\n acronym: null,\n careerBreaks: null,\n };\n}\n"]}
|
package/dist/resume/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { E as ExportContact } from '../export-contact-D_krcTBH.cjs';
|
|
2
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.cjs';
|
|
3
|
-
import { L as LocationValue, M as ProfileLocation, d as ProfilePosition, f as ProfileEducation, P as ProfileSkill, e as ProfileCertification, i as ProfileProject, j as ProfilePublication, S as ProfileVolunteering,
|
|
3
|
+
import { L as LocationValue, M as ProfileLocation, d as ProfilePosition, f as ProfileEducation, P as ProfileSkill, e as ProfileCertification, i as ProfileProject, j as ProfilePublication, S as ProfileVolunteering, k as ProfileInvolvement, G as ProfileCourse, Q as ProfilePresentation, a as ProfilePresentationDelivery, g as ProfileHonor, h as ProfileLanguage, p as ExternalAccount } from '../index-BQAKeEoj.cjs';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import '../verification-providers-DeyGqaoC.cjs';
|
|
6
6
|
|
|
@@ -17,10 +17,13 @@ import '../verification-providers-DeyGqaoC.cjs';
|
|
|
17
17
|
* emitting it hands a user every JSON Resume theme, and the Typst CV templates
|
|
18
18
|
* on Typst Universe, without Sifa writing a renderer for any of them.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
20
|
+
* Involvement, talks and courses taken have no JSON Resume key of their own and
|
|
21
|
+
* go into the nearest standard section: involvement next to volunteering, talks
|
|
22
|
+
* as publications of type "Talks", courses as certificates. Strict consumers
|
|
23
|
+
* such as altacv refuse any unknown top-level key, so nothing new is added
|
|
24
|
+
* there. Fields with no reasonable slot -- endorsements, confirmations,
|
|
25
|
+
* investments, courses someone taught -- are dropped. The loss is documented
|
|
26
|
+
* for the user at the point of download.
|
|
24
27
|
*/
|
|
25
28
|
|
|
26
29
|
type Sanitizer = (input: string) => string;
|
|
@@ -72,6 +75,11 @@ interface JsonResumeProfileInput {
|
|
|
72
75
|
readonly projects?: ProfileProject[];
|
|
73
76
|
readonly publications?: ProfilePublication[];
|
|
74
77
|
readonly volunteering?: ProfileVolunteering[];
|
|
78
|
+
readonly involvement?: ProfileInvolvement[];
|
|
79
|
+
readonly courses?: ProfileCourse[];
|
|
80
|
+
readonly presentations?: ProfilePresentation[];
|
|
81
|
+
/** Deliveries not tied to a presentation record are listed here only. */
|
|
82
|
+
readonly presentationDeliveries?: ProfilePresentationDelivery[];
|
|
75
83
|
readonly honors?: ProfileHonor[];
|
|
76
84
|
readonly languages?: ProfileLanguage[];
|
|
77
85
|
readonly externalAccounts?: ExternalAccount[];
|
|
@@ -146,9 +154,16 @@ interface JsonResumePublication {
|
|
|
146
154
|
readonly releaseDate?: string;
|
|
147
155
|
readonly url?: string;
|
|
148
156
|
readonly summary?: string;
|
|
157
|
+
/**
|
|
158
|
+
* "Talks" for a talk. Not in the JSON Resume schema, which allows extra
|
|
159
|
+
* fields; CV templates such as altacv group publications by it.
|
|
160
|
+
*/
|
|
161
|
+
readonly type?: string;
|
|
149
162
|
}
|
|
163
|
+
/** A skill category, with the skills in it as keywords. */
|
|
150
164
|
interface JsonResumeSkill {
|
|
151
165
|
readonly name: string;
|
|
166
|
+
readonly keywords: string[];
|
|
152
167
|
}
|
|
153
168
|
interface JsonResumeLanguage {
|
|
154
169
|
readonly language: string;
|