@singi-labs/sifa-sdk 0.19.45 → 0.19.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/logic/date-lookahead.ts","../../src/logic/primary-position.ts","../../src/logic/profile-summary.ts","../../src/query/client.ts","../../src/query/fetchers/get-profile-view.ts","../../src/query/fetchers/profile-summary.ts","../../src/badge/index.ts"],"names":[],"mappings":";;;AAiCO,SAAS,kBAAkB,KAAA,EAAe,MAAA,EAAgB,GAAA,mBAAY,IAAI,MAAK,EAAY;AAChG,EAAA,MAAM,KAAA,GAAQ,uBAAA,CAAwB,IAAA,CAAK,KAAK,CAAA;AAChD,EAAA,IAAI,CAAC,OAAO,OAAO,KAAA;AACnB,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,CAAA,GAAI,EAAA,IAAM,KAAA,CAAM,CAAC,CAAA,GAAI,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,CAAA,GAAI,CAAA,CAAA;AACrE,EAAA,MAAM,KAAA,GAAQ,IAAI,WAAA,EAAY,GAAI,KAAK,GAAA,CAAI,QAAA,KAAa,CAAA,GAAI,MAAA;AAC5D,EAAA,OAAO,KAAA,GAAQ,KAAA;AACjB;AAMO,SAAS,eAAA,CAAgB,SAAA,EAA+B,GAAA,mBAAY,IAAI,MAAK,EAAY;AAC9F,EAAA,OAAO,CAAC,CAAC,SAAA,IAAa,iBAAA,CAAkB,SAAA,EAAW,GAAG,GAAG,CAAA;AAC3D;;;ACjBO,SAAS,mBAAA,CACd,SAAA,EACA,GAAA,mBAAY,IAAI,MAAK,EACN;AACf,EAAA,IAAI,CAAC,SAAA,IAAa,SAAA,CAAU,MAAA,KAAW,GAAG,OAAO,MAAA;AAEjD,EAAA,MAAM,SAAS,SAAA,CAAU,MAAA;AAAA,IACvB,CAAC,CAAA,KAAM,CAAC,CAAA,CAAE,OAAA,IAA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AAQ,SAAA,EAAW;AACrC,QAAA,MAAM,IAAA,GAAO,QAAA,CAAS,aAAA,CAAc,MAAM,CAAA;AAC1C,QAAA,IAAA,CAAK,SAAA,GAAY,MAAA;AACjB,QAAA,IAAA,CAAK,WAAA,GAAc,KAAA;AACnB,QAAA,MAAA,CAAO,OAAO,IAAI,CAAA;AAAA,MACpB;AACA,MAAA,IAAA,CAAK,OAAO,MAAM,CAAA;AAAA,IACpB;AAEA,IAAA,IAAA,CAAK,OAAO,IAAI,CAAA;AAChB,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAGO,SAAS,eAAA,CAAgB,MAAc,GAAA,EAAW;AACvD,EAAA,IAAI,OAAO,cAAA,KAAmB,WAAA,IAAe,CAAC,cAAA,CAAe,GAAA,CAAI,GAAG,CAAA,EAAG;AACrE,IAAA,cAAA,CAAe,MAAA,CAAO,KAAK,gBAAgB,CAAA;AAAA,EAC7C;AACF;AAEA,eAAA,EAAgB","file":"index.cjs","sourcesContent":["/**\n * How far ahead a profile date may lie, per kind of date (sifa-workspace#581).\n *\n * A date that records something which already happened (a credential being\n * issued, an award, the end of a finished role) cannot be in the future. Some\n * dates are naturally a little ahead: an accepted job or a forthcoming paper,\n * a booked talk, an expected graduation. A credential's expiry has no cap.\n *\n * One table, so the editors on every client apply the same limits.\n */\nexport const DATE_LOOKAHEAD_MONTHS = {\n credentialIssue: 0,\n award: 0,\n course: 0,\n involvementStart: 0,\n investmentStart: 0,\n /** The end date of any finished (not ongoing) range. */\n completedRangeEnd: 0,\n careerStart: 6,\n projectStart: 6,\n publication: 6,\n talk: 12,\n educationEnd: 96,\n} as const;\n\nexport type DateLookaheadKind = keyof typeof DATE_LOOKAHEAD_MONTHS;\n\n/**\n * Is a partial date (`YYYY`, `YYYY-MM`, or `YYYY-MM-DD`) more than `months`\n * months after the current month? Compared at year-month resolution. A bare\n * year counts from its first month, so the current year always passes. A\n * malformed or empty value is never \"beyond\" (other validation handles it).\n */\nexport function isBeyondLookahead(value: string, months: number, now: Date = new Date()): boolean {\n const match = /^(\\d{4})(?:-(\\d{2}))?/.exec(value);\n if (!match) return false;\n const index = Number(match[1]) * 12 + (match[2] ? Number(match[2]) : 1);\n const limit = now.getFullYear() * 12 + now.getMonth() + 1 + months;\n return index > limit;\n}\n\n/**\n * Has a start date not arrived yet? A role that starts next month is shown as\n * upcoming, and is not anyone's current role until its start month.\n */\nexport function isUpcomingStart(startedAt: string | undefined, now: Date = new Date()): boolean {\n return !!startedAt && isBeyondLookahead(startedAt, 0, now);\n}\n","/**\n * Canonical rule for picking the \"primary\" position to surface on profile cards,\n * social previews, and structured-data outputs.\n *\n * Without this shared helper, different surfaces (visible hero, OG image,\n * <meta description>, JSON-LD) re-derived \"primary\" inconsistently and diverged\n * for users with multiple concurrent roles.\n *\n * A `hidden` position is one the user chose not to show on their public profile.\n * It is never surfaced as the featured role — hidden wins over `primary`, so a\n * role flagged both hidden and primary is excluded rather than featured.\n *\n * A position whose start month has not arrived yet (an accepted offer) is not\n * active: it is nobody's current role until it starts (sifa-workspace#581).\n *\n * Rules (in order):\n * 1. A position the user explicitly flagged `primary` AND that is still active AND not hidden.\n * 2. Otherwise, the active, non-hidden position with the most recent `startedAt`.\n * 3. Otherwise, undefined (no eligible position).\n */\n\nimport { isUpcomingStart } from './date-lookahead.js';\n\nexport interface PrimaryPositionCandidate {\n startedAt?: string;\n endedAt?: string;\n primary?: boolean;\n hidden?: boolean;\n}\n\nexport function pickPrimaryPosition<T extends PrimaryPositionCandidate>(\n positions: readonly T[] | undefined,\n now: Date = new Date(),\n): T | undefined {\n if (!positions || positions.length === 0) return undefined;\n\n const active = positions.filter(\n (p) => !p.endedAt && !p.hidden && !isUpcomingStart(p.startedAt, now),\n );\n if (active.length === 0) return undefined;\n\n const flagged = active.find((p) => p.primary === true);\n if (flagged) return flagged;\n\n return [...active].sort((a, b) => (b.startedAt ?? '').localeCompare(a.startedAt ?? ''))[0];\n}\n","/**\n * Compact professional summary derived from a {@link ProfileView}.\n *\n * The full `id.sifa.getProfileView` payload carries every section (all\n * positions, education, skills, publications, talks, and more). Third-party\n * surfaces that only want to show \"who is this, what do they do now\" — a badge,\n * a maintainer card, a byline — need a much smaller shape. This is that shape,\n * derived with the same canonical rules the Sifa web app uses (see\n * {@link pickPrimaryPosition}) so an embedded summary matches the profile page.\n *\n * Pure and I/O-free: pass it a view you already fetched. For the fetch +\n * summarize convenience, use `fetchProfileSummary` from `@singi-labs/sifa-sdk`.\n */\n\nimport type { ProfileView } from '../types/profile-view.js';\nimport { pickPrimaryPosition } from './primary-position.js';\n\nexport interface ProfileSummary {\n did: string;\n handle: string;\n displayName?: string;\n avatar?: string;\n pronouns?: string;\n headline?: string;\n /** Title of the current primary role, if the person has an active position. */\n currentTitle?: string;\n /** Current employer: the resolved entity name when linked, else the free-text company. */\n currentCompany?: string;\n /** Skill names in the order the AppView returns them, capped by `maxSkills`. */\n topSkills: string[];\n /** Whether the profile is claimed by its owner (vs an unclaimed placeholder). */\n claimed: boolean;\n}\n\nexport interface SummarizeProfileViewOptions {\n /** Maximum number of skills to include in `topSkills`. Default 5; negatives clamp to 0. */\n maxSkills?: number;\n}\n\nconst DEFAULT_MAX_SKILLS = 5;\n\nexport function summarizeProfileView(\n view: ProfileView,\n options: SummarizeProfileViewOptions = {},\n): ProfileSummary {\n const limit = Math.max(0, options.maxSkills ?? DEFAULT_MAX_SKILLS);\n const primary = pickPrimaryPosition(view.positions);\n\n return {\n did: view.did,\n handle: view.handle,\n displayName: view.displayName,\n avatar: view.avatar,\n pronouns: view.pronouns,\n headline: view.headline,\n currentTitle: primary?.title,\n currentCompany: primary ? (primary.entityName ?? primary.company) : undefined,\n topSkills: (view.skills ?? []).slice(0, limit).map((s) => s.name),\n claimed: view.claimed ?? false,\n };\n}\n","/**\n * Foundation HTTP client for talking to the Sifa AppView.\n *\n * Stateless. Consumers supply a {@link SifaApiConfig} per call (the React\n * hooks read it from context; non-React consumers pass it explicitly). No\n * singletons, no module-level state.\n */\n\n/** Configuration passed to every fetcher. */\nexport interface SifaApiConfig {\n /** Base URL of the sifa-api AppView, e.g. `https://api.sifa.id`. No trailing slash. */\n baseUrl: string;\n /**\n * Optional fetch implementation. Defaults to {@link globalThis.fetch}.\n * Lets Next.js consumers pass their cache-enhanced fetch; node/Expo\n * consumers can leave this unset.\n */\n fetch?: typeof fetch;\n /**\n * Optional per-request auth-token minter for auth-required reads. The NATIVE\n * app supplies this (it has no sifa-api session cookie): given a method NSID\n * (`lxm`), it mints a short-lived AT Protocol service-auth JWT on the user's\n * PDS (see the SDK's `/atproto` `mintServiceAuthToken`) and returns it; the\n * fetcher attaches it as `Authorization: Bearer`. Web omits this and relies on\n * its session cookie (`credentials: 'include'`). Return `null` to send no\n * token. See `sifa-api` `createIdentityMiddleware`.\n */\n getAuthToken?: (lxm: string) => Promise<string | null>;\n}\n\n/** Options accepted by {@link apiFetch}. */\nexport interface ApiFetchOptions {\n method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n /** Request body. Serialized to JSON automatically. */\n body?: unknown;\n /** AbortSignal. Defaults to `AbortSignal.timeout(timeoutMs)` if `timeoutMs` is set. */\n signal?: AbortSignal;\n /** Per-call timeout in milliseconds. Default: 10_000. Ignored if `signal` is provided. */\n timeoutMs?: number;\n /** Retry on HTTP 429 up to 3 times with the server's `Retry-After` delay (capped at 3s). */\n retryOn429?: boolean;\n /** Additional headers. `Content-Type: application/json` is set automatically when `body` is present. */\n headers?: Record<string, string>;\n credentials?: RequestCredentials;\n cache?: RequestCache;\n /**\n * Next.js-specific cache hints. Ignored on non-Next runtimes. Passed\n * through transparently as part of {@link RequestInit}.\n */\n next?: { revalidate?: number | false; tags?: string[] };\n}\n\n/** Error thrown by {@link apiFetch} on non-2xx responses. */\nexport class ApiError extends Error {\n readonly status: number;\n readonly body: unknown;\n\n constructor(message: string, status: number, body?: unknown) {\n super(message);\n this.name = 'ApiError';\n this.status = status;\n this.body = body;\n }\n}\n\nconst DEFAULT_TIMEOUT_MS = 10_000;\nconst MAX_RATE_LIMIT_RETRIES = 3;\nconst RATE_LIMIT_RETRY_CAP_SECONDS = 3;\n\n/**\n * Encode a handle or DID for safe interpolation into a request path,\n * idempotently.\n *\n * Plain {@link encodeURIComponent} double-encodes an already-encoded\n * identifier: Next.js hands route params to RSC pages percent-encoded on a\n * hard navigation (`did%3Aplc%3A...`) but decoded on client-side navigation\n * (`did:plc:...`). Encoding the former again turns `%` into `%25`, so the\n * AppView reads `did%3A...` as a literal handle, finds no match, and 404s —\n * which is why DID profile links broke on direct visits but worked when\n * clicked within the app.\n *\n * AT identifiers (handles are domain names, DIDs are `did:method:...`) never\n * contain a literal `%`, so decoding a decoded value is a no-op. A malformed\n * percent sequence (lone `%`) makes {@link decodeURIComponent} throw; in that\n * case we keep the original value so behaviour matches the prior bare\n * `encodeURIComponent`.\n */\nexport function encodeIdentifier(value: string): string {\n let decoded = value;\n try {\n decoded = decodeURIComponent(value);\n } catch {\n // Malformed percent-encoding — fall back to the raw value.\n }\n return encodeURIComponent(decoded);\n}\n\n/**\n * Generic fetcher used by all SDK query and mutation functions.\n *\n * Returns parsed JSON typed as `T`. Throws {@link ApiError} on non-2xx\n * responses. Use {@link apiFetchOrNull} when 404 should resolve to `null`\n * instead.\n */\nexport async function apiFetch<T = unknown>(\n config: SifaApiConfig,\n path: string,\n options: ApiFetchOptions = {},\n): Promise<T> {\n const fetchFn = config.fetch ?? globalThis.fetch;\n const url = `${config.baseUrl}${path}`;\n const maxRetries = options.retryOn429 ? MAX_RATE_LIMIT_RETRIES : 0;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n const signal = options.signal ?? AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS);\n\n const headers: Record<string, string> = { ...(options.headers ?? {}) };\n let body: BodyInit | undefined;\n if (options.body !== undefined) {\n headers['Content-Type'] ??= 'application/json';\n body = JSON.stringify(options.body);\n }\n\n // `next` is a Next.js extension to RequestInit; cast through.\n const init = {\n method: options.method ?? 'GET',\n headers,\n body,\n signal,\n credentials: options.credentials,\n cache: options.cache,\n ...(options.next ? { next: options.next } : {}),\n } as RequestInit;\n\n const res = await fetchFn(url, init);\n\n if (res.status === 429 && attempt < maxRetries) {\n const retryAfterRaw = res.headers.get('retry-after');\n const retryAfter = retryAfterRaw ? Number.parseInt(retryAfterRaw, 10) : 2;\n const waitSeconds = Math.min(\n Number.isFinite(retryAfter) ? retryAfter : 2,\n RATE_LIMIT_RETRY_CAP_SECONDS,\n );\n await new Promise((r) => setTimeout(r, waitSeconds * 1000));\n continue;\n }\n\n if (!res.ok) {\n let errBody: unknown;\n try {\n errBody = (await res.json()) as unknown;\n } catch {\n try {\n errBody = await res.text();\n } catch {\n errBody = undefined;\n }\n }\n throw new ApiError(`Sifa API ${res.status} on ${path}`, res.status, errBody);\n }\n\n // 204 and 205 are defined to carry no body, so res.json() throws on them.\n // apiWrite treats that throw as a failed write, which turned every\n // successful no-content response (roadmap unvote, remove reaction,\n // dismiss endorsement) into a reported error.\n if (res.status === 204 || res.status === 205) {\n return undefined as T;\n }\n\n return (await res.json()) as T;\n }\n\n throw new ApiError(`Sifa API exhausted retries on ${path}`, 429);\n}\n\n/**\n * Variant of {@link apiFetch} that resolves to `null` on HTTP 404 instead\n * of throwing. Useful for \"fetch by handle\" reads where missing is\n * expected (e.g. unknown profile).\n */\nexport async function apiFetchOrNull<T>(\n config: SifaApiConfig,\n path: string,\n options: ApiFetchOptions = {},\n): Promise<T | null> {\n try {\n return await apiFetch<T>(config, path, options);\n } catch (e) {\n if (e instanceof ApiError && e.status === 404) return null;\n throw e;\n }\n}\n\n/**\n * Result returned by record-write mutations (create / update / delete).\n *\n * Never throws -- writes against the user's PDS can fail in many ways\n * (network, PDS unreachable, rate limit) and the UI needs structured\n * results to render appropriate messages.\n */\nexport interface WriteResult {\n success: boolean;\n error?: string;\n /**\n * PDS hostname returned by sifa-api when a write failed at the user's\n * Personal Data Server (issue #167). Lets the UI render\n * \"Your data server (eurosky.social) isn't responding\" instead of a\n * generic \"Request failed (500)\".\n */\n pdsHost?: string;\n}\n\n/** Result returned by create mutations. Includes the newly created `rkey`. */\nexport interface CreateResult extends WriteResult {\n rkey?: string;\n}\n\ninterface ApiErrorBody {\n message?: string;\n pdsHost?: string;\n}\n\nfunction extractWriteError(data: unknown, status: number): { error: string; pdsHost?: string } {\n const body = (data ?? {}) as ApiErrorBody;\n return {\n error: body.message ?? `Request failed (${status})`,\n ...(body.pdsHost ? { pdsHost: body.pdsHost } : {}),\n };\n}\n\n/**\n * Write mutation against the Sifa AppView. Wraps {@link apiFetch} with the\n * never-throws contract used by all sifa-web mutations: returns a\n * structured {@link WriteResult} on both success and failure, and\n * preserves the `pdsHost` field when the AppView reports a PDS-side\n * failure (issue #167).\n *\n * On success: returns `{ success: true, ...payload }` where `payload` is\n * whatever the server returned in JSON (or `{}` for 204).\n *\n * On failure: returns `{ success: false, error, pdsHost? }`. Never throws.\n *\n * Use {@link apiWriteCreate} when you specifically need the `rkey` from a\n * create response folded into the result shape.\n */\nexport async function apiWrite<TExtra extends object = Record<never, never>>(\n config: SifaApiConfig,\n path: string,\n method: 'POST' | 'PUT' | 'DELETE' | 'PATCH',\n options: Omit<ApiFetchOptions, 'method'> = {},\n): Promise<WriteResult & TExtra> {\n try {\n const data = await apiFetch<TExtra>(config, path, {\n method,\n credentials: 'include',\n ...options,\n });\n return { success: true, ...(data ?? ({} as TExtra)) };\n } catch (e) {\n if (e instanceof ApiError) {\n return { success: false, ...extractWriteError(e.body, e.status) } as WriteResult & TExtra;\n }\n return { success: false, error: 'Network error' } as WriteResult & TExtra;\n }\n}\n\n/**\n * Write mutation that expects the server to return a record key (`rkey`)\n * in its response body. Wraps {@link apiWrite} and folds the `rkey` into\n * the result shape so consumers get `{ success, rkey?, error?, pdsHost? }`.\n *\n * If the server returns additional fields (e.g. `feedUrl` from external\n * account creation), pass them via the `TExtra` generic to keep them\n * typed.\n */\nexport function apiWriteCreate<TExtra extends object = Record<never, never>>(\n config: SifaApiConfig,\n path: string,\n body: unknown,\n options: Omit<ApiFetchOptions, 'method' | 'body'> = {},\n): Promise<CreateResult & TExtra> {\n return apiWrite<{ rkey?: string } & TExtra>(config, path, 'POST', {\n body,\n ...options,\n });\n}\n","import type { ProfileView } from '../../types/profile-view.js';\nimport {\n ApiError,\n apiFetch,\n encodeIdentifier,\n type ApiFetchOptions,\n type SifaApiConfig,\n} from '../client.js';\n\n/**\n * Read the aggregated public profile view via the `id.sifa.getProfileView`\n * XRPC query. This is the AppView-only join (positions, education, skills,\n * endorsements, and more) exposed as a standard lexicon method, distinct from\n * the internal `/api/profile/*` REST surface.\n *\n * Returns `null` when the AppView has no profile for the actor\n * (`ProfileNotFound`). Throws {@link ApiError} on other non-2xx responses.\n *\n * Server-callable (Next.js RSC) and client-callable (Expo, browser).\n */\nexport async function fetchGetProfileView(\n config: SifaApiConfig,\n actor: string,\n options: ApiFetchOptions = {},\n): Promise<ProfileView | null> {\n const path = `/xrpc/id.sifa.getProfileView?actor=${encodeIdentifier(actor)}`;\n try {\n return await apiFetch<ProfileView>(config, path, { retryOn429: true, ...options });\n } catch (e) {\n if (\n e instanceof ApiError &&\n e.status === 400 &&\n typeof e.body === 'object' &&\n e.body !== null &&\n (e.body as { error?: unknown }).error === 'ProfileNotFound'\n ) {\n return null;\n }\n throw e;\n }\n}\n","import {\n summarizeProfileView,\n type ProfileSummary,\n type SummarizeProfileViewOptions,\n} from '../../logic/profile-summary.js';\nimport { fetchGetProfileView } from './get-profile-view.js';\nimport type { ApiFetchOptions, SifaApiConfig } from '../client.js';\n\n/**\n * Fetch the aggregated public profile via `id.sifa.getProfileView` and reduce it\n * to a compact {@link ProfileSummary} (identity, headline, current role/employer,\n * top skills). Convenience over `fetchGetProfileView` + `summarizeProfileView`,\n * for third-party surfaces that only want the headline facts.\n *\n * Returns `null` when the AppView has no profile for the actor. Server-callable\n * (Next.js RSC) and client-callable (Expo, browser).\n */\nexport async function fetchProfileSummary(\n config: SifaApiConfig,\n actor: string,\n options: SummarizeProfileViewOptions & ApiFetchOptions = {},\n): Promise<ProfileSummary | null> {\n const { maxSkills, ...fetchOptions } = options;\n const view = await fetchGetProfileView(config, actor, fetchOptions);\n return view ? summarizeProfileView(view, { maxSkills }) : null;\n}\n","/**\n * `<sifa-badge>` — a framework-free custom element that renders a person's\n * professional headline (name, current role and employer, top skills) from\n * their Sifa profile. Drop it into any page:\n *\n * ```html\n * <script type=\"module\" src=\"https://esm.sh/@singi-labs/sifa-sdk/badge\"></script>\n * <sifa-badge handle=\"gui.do\"></sifa-badge>\n * ```\n *\n * Or, in a bundler: `import '@singi-labs/sifa-sdk/badge'` (importing registers\n * the element). Attributes: `handle` or `did` (required), `api` (AppView base,\n * default `https://api.sifa.id`), `max-skills` (default 5).\n *\n * Reads the public `id.sifa.getProfileView` query, so it needs no auth or key.\n * Cross-origin browser use depends on that endpoint's open CORS.\n */\n\nimport type { ProfileSummary } from '../logic/profile-summary.js';\nimport { fetchProfileSummary } from '../query/fetchers/profile-summary.js';\n\nconst TAG = 'sifa-badge';\nconst DEFAULT_API_BASE = 'https://api.sifa.id';\nconst PROFILE_BASE = 'https://sifa.id/p/';\n\n// Reference HTMLElement through a guarded base so importing this module never\n// throws in a non-DOM (SSR / Node) context. The real element is only ever\n// registered and instantiated in a browser, where defineSifaBadge runs.\nconst BaseElement: typeof HTMLElement =\n typeof HTMLElement !== 'undefined' ? HTMLElement : (class {} as unknown as typeof HTMLElement);\n\nconst STYLES = `\n :host { display: inline-block; max-width: 22rem; }\n a.card {\n display: flex; gap: 0.75rem; align-items: center;\n padding: 0.75rem 0.9rem; text-decoration: none; color: inherit;\n border: 1px solid rgba(0,0,0,0.12); border-radius: 0.75rem;\n background: canvas; font: 400 0.9rem/1.4 system-ui, sans-serif;\n }\n a.card:hover { border-color: rgba(0,0,0,0.28); }\n a.card:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }\n .avatar { width: 2.75rem; height: 2.75rem; border-radius: 50%; object-fit: cover; flex: none; }\n .body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }\n .name { font-weight: 600; }\n .role { color: color-mix(in srgb, canvastext 65%, canvas); }\n .skills { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.25rem; }\n .chip {\n font-size: 0.72rem; padding: 0.1rem 0.45rem; border-radius: 999px;\n background: color-mix(in srgb, canvastext 8%, canvas);\n }\n .msg { margin: 0; padding: 0.5rem 0.6rem; color: color-mix(in srgb, canvastext 60%, canvas);\n font: 400 0.85rem/1.4 system-ui, sans-serif; }\n`;\n\nexport class SifaBadgeElement extends BaseElement {\n static readonly observedAttributes = ['handle', 'did', 'api', 'max-skills'];\n\n private readonly shadow: ShadowRoot;\n private renderToken = 0;\n private scheduled = false;\n\n constructor() {\n super();\n this.shadow = this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback(): void {\n this.schedule();\n }\n\n attributeChangedCallback(): void {\n this.schedule();\n }\n\n /** Coalesce a burst of synchronous attribute writes (and the initial connect) into one load. */\n private schedule(): void {\n if (this.scheduled) return;\n this.scheduled = true;\n queueMicrotask(() => {\n this.scheduled = false;\n if (this.isConnected) void this.load();\n });\n }\n\n private async load(): Promise<void> {\n const token = ++this.renderToken;\n const actor = this.getAttribute('did') || this.getAttribute('handle');\n if (!actor) {\n this.paint(this.message('Set a handle or did attribute on <sifa-badge>.'));\n return;\n }\n\n const baseUrl = this.getAttribute('api') || DEFAULT_API_BASE;\n const rawMax = this.getAttribute('max-skills');\n const maxSkills = rawMax != null ? Number(rawMax) : undefined;\n const options = maxSkills != null && Number.isFinite(maxSkills) ? { maxSkills } : {};\n\n this.paint(this.message('Loading…'));\n\n let summary: ProfileSummary | null;\n try {\n summary = await fetchProfileSummary({ baseUrl }, actor, options);\n } catch {\n if (token === this.renderToken) this.paint(this.message('Could not load this profile.'));\n return;\n }\n\n if (token !== this.renderToken) return; // a newer load superseded this one\n this.paint(summary ? this.card(summary) : this.message(`No Sifa profile for ${actor}.`));\n }\n\n private paint(body: Node): void {\n const style = document.createElement('style');\n style.textContent = STYLES;\n this.shadow.replaceChildren(style, body);\n }\n\n private message(text: string): HTMLElement {\n const p = document.createElement('p');\n p.className = 'msg';\n p.textContent = text;\n return p;\n }\n\n private card(summary: ProfileSummary): HTMLElement {\n const name = summary.displayName || summary.handle;\n const link = document.createElement('a');\n link.className = 'card';\n link.href = PROFILE_BASE + encodeURIComponent(summary.handle);\n link.target = '_blank';\n link.rel = 'noopener';\n link.setAttribute('aria-label', `${name} on Sifa`);\n\n if (summary.avatar) {\n const img = document.createElement('img');\n img.className = 'avatar';\n img.src = summary.avatar;\n img.alt = '';\n img.loading = 'lazy';\n link.append(img);\n }\n\n const body = document.createElement('span');\n body.className = 'body';\n\n const nameEl = document.createElement('span');\n nameEl.className = 'name';\n nameEl.textContent = name;\n body.append(nameEl);\n\n const role =\n [summary.currentTitle, summary.currentCompany].filter(Boolean).join(' · ') ||\n summary.headline;\n if (role) {\n const roleEl = document.createElement('span');\n roleEl.className = 'role';\n roleEl.textContent = role;\n body.append(roleEl);\n }\n\n if (summary.topSkills.length > 0) {\n const skills = document.createElement('span');\n skills.className = 'skills';\n for (const skill of summary.topSkills) {\n const chip = document.createElement('span');\n chip.className = 'chip';\n chip.textContent = skill;\n skills.append(chip);\n }\n body.append(skills);\n }\n\n link.append(body);\n return link;\n }\n}\n\n/** Register the element (idempotent). Called automatically when this module is imported. */\nexport function defineSifaBadge(tag: string = TAG): void {\n if (typeof customElements !== 'undefined' && !customElements.get(tag)) {\n customElements.define(tag, SifaBadgeElement);\n }\n}\n\ndefineSifaBadge();\n"]}
1
+ {"version":3,"sources":["../../src/logic/date-lookahead.ts","../../src/logic/primary-position.ts","../../src/logic/profile-summary.ts","../../src/query/client.ts","../../src/query/fetchers/get-profile-view.ts","../../src/query/fetchers/profile-summary.ts","../../src/badge/index.ts"],"names":[],"mappings":";;;AAmCO,SAAS,kBAAkB,KAAA,EAAe,MAAA,EAAgB,GAAA,mBAAY,IAAI,MAAK,EAAY;AACh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,MAAc,GAAA,EAAW;AACvD,EAAA,IAAI,OAAO,cAAA,KAAmB,WAAA,IAAe,CAAC,cAAA,CAAe,GAAA,CAAI,GAAG,CAAA,EAAG;AACrE,IAAA,cAAA,CAAe,MAAA,CAAO,KAAK,gBAAgB,CAAA;AAAA,EAC7C;AACF;AAEA,eAAA,EAAgB","file":"index.cjs","sourcesContent":["/**\n * How far ahead a profile date may lie, per kind of date (sifa-workspace#581).\n *\n * A date that records something which already happened (a credential being\n * issued, an award, the end of a finished role) cannot be in the future. Some\n * dates are naturally a little ahead: an accepted job or a forthcoming paper,\n * a booked talk, an expected graduation. A credential's expiry has no cap.\n *\n * One table, so the editors on every client apply the same limits.\n */\nexport const DATE_LOOKAHEAD_MONTHS = {\n credentialIssue: 0,\n award: 0,\n course: 0,\n involvementStart: 0,\n investmentStart: 0,\n /** The end date of any finished (not ongoing) range. */\n completedRangeEnd: 0,\n careerStart: 6,\n projectStart: 6,\n publication: 6,\n talk: 12,\n /** Admitted to a programme that starts next year. */\n educationStart: 12,\n educationEnd: 96,\n} as const;\n\nexport type DateLookaheadKind = keyof typeof DATE_LOOKAHEAD_MONTHS;\n\n/**\n * Is a partial date (`YYYY`, `YYYY-MM`, or `YYYY-MM-DD`) more than `months`\n * months after the current month? Compared at year-month resolution. A bare\n * year counts from its first month, so the current year always passes. A\n * malformed or empty value is never \"beyond\" (other validation handles it).\n */\nexport function isBeyondLookahead(value: string, months: number, now: Date = new Date()): boolean {\n const match = /^(\\d{4})(?:-(\\d{2}))?/.exec(value);\n if (!match) return false;\n const index = Number(match[1]) * 12 + (match[2] ? Number(match[2]) : 1);\n const limit = now.getFullYear() * 12 + now.getMonth() + 1 + months;\n return index > limit;\n}\n\n/**\n * Has a start date not arrived yet? A role that starts next month is shown as\n * upcoming, and is not anyone's current role until its start month.\n */\nexport function isUpcomingStart(startedAt: string | undefined, now: Date = new Date()): boolean {\n return !!startedAt && isBeyondLookahead(startedAt, 0, now);\n}\n","/**\n * Canonical rule for picking the \"primary\" position to surface on profile cards,\n * social previews, and structured-data outputs.\n *\n * Without this shared helper, different surfaces (visible hero, OG image,\n * <meta description>, JSON-LD) re-derived \"primary\" inconsistently and diverged\n * for users with multiple concurrent roles.\n *\n * A `hidden` position is one the user chose not to show on their public profile.\n * It is never surfaced as the featured role — hidden wins over `primary`, so a\n * role flagged both hidden and primary is excluded rather than featured.\n *\n * A position whose start month has not arrived yet (an accepted offer) is not\n * active: it is nobody's current role until it starts (sifa-workspace#581).\n *\n * Rules (in order):\n * 1. A position the user explicitly flagged `primary` AND that is still active AND not hidden.\n * 2. Otherwise, the active, non-hidden position with the most recent `startedAt`.\n * 3. Otherwise, undefined (no eligible position).\n */\n\nimport { isUpcomingStart } from './date-lookahead.js';\n\nexport interface PrimaryPositionCandidate {\n startedAt?: string;\n endedAt?: string;\n primary?: boolean;\n hidden?: boolean;\n}\n\nexport function pickPrimaryPosition<T extends PrimaryPositionCandidate>(\n positions: readonly T[] | undefined,\n now: Date = new Date(),\n): T | undefined {\n if (!positions || positions.length === 0) return undefined;\n\n const active = positions.filter(\n (p) => !p.endedAt && !p.hidden && !isUpcomingStart(p.startedAt, now),\n );\n if (active.length === 0) return undefined;\n\n const flagged = active.find((p) => p.primary === true);\n if (flagged) return flagged;\n\n return [...active].sort((a, b) => (b.startedAt ?? '').localeCompare(a.startedAt ?? ''))[0];\n}\n","/**\n * Compact professional summary derived from a {@link ProfileView}.\n *\n * The full `id.sifa.getProfileView` payload carries every section (all\n * positions, education, skills, publications, talks, and more). Third-party\n * surfaces that only want to show \"who is this, what do they do now\" — a badge,\n * a maintainer card, a byline — need a much smaller shape. This is that shape,\n * derived with the same canonical rules the Sifa web app uses (see\n * {@link pickPrimaryPosition}) so an embedded summary matches the profile page.\n *\n * Pure and I/O-free: pass it a view you already fetched. For the fetch +\n * summarize convenience, use `fetchProfileSummary` from `@singi-labs/sifa-sdk`.\n */\n\nimport type { ProfileView } from '../types/profile-view.js';\nimport { pickPrimaryPosition } from './primary-position.js';\n\nexport interface ProfileSummary {\n did: string;\n handle: string;\n displayName?: string;\n avatar?: string;\n pronouns?: string;\n headline?: string;\n /** Title of the current primary role, if the person has an active position. */\n currentTitle?: string;\n /** Current employer: the resolved entity name when linked, else the free-text company. */\n currentCompany?: string;\n /** Skill names in the order the AppView returns them, capped by `maxSkills`. */\n topSkills: string[];\n /** Whether the profile is claimed by its owner (vs an unclaimed placeholder). */\n claimed: boolean;\n}\n\nexport interface SummarizeProfileViewOptions {\n /** Maximum number of skills to include in `topSkills`. Default 5; negatives clamp to 0. */\n maxSkills?: number;\n}\n\nconst DEFAULT_MAX_SKILLS = 5;\n\nexport function summarizeProfileView(\n view: ProfileView,\n options: SummarizeProfileViewOptions = {},\n): ProfileSummary {\n const limit = Math.max(0, options.maxSkills ?? DEFAULT_MAX_SKILLS);\n const primary = pickPrimaryPosition(view.positions);\n\n return {\n did: view.did,\n handle: view.handle,\n displayName: view.displayName,\n avatar: view.avatar,\n pronouns: view.pronouns,\n headline: view.headline,\n currentTitle: primary?.title,\n currentCompany: primary ? (primary.entityName ?? primary.company) : undefined,\n topSkills: (view.skills ?? []).slice(0, limit).map((s) => s.name),\n claimed: view.claimed ?? false,\n };\n}\n","/**\n * Foundation HTTP client for talking to the Sifa AppView.\n *\n * Stateless. Consumers supply a {@link SifaApiConfig} per call (the React\n * hooks read it from context; non-React consumers pass it explicitly). No\n * singletons, no module-level state.\n */\n\n/** Configuration passed to every fetcher. */\nexport interface SifaApiConfig {\n /** Base URL of the sifa-api AppView, e.g. `https://api.sifa.id`. No trailing slash. */\n baseUrl: string;\n /**\n * Optional fetch implementation. Defaults to {@link globalThis.fetch}.\n * Lets Next.js consumers pass their cache-enhanced fetch; node/Expo\n * consumers can leave this unset.\n */\n fetch?: typeof fetch;\n /**\n * Optional per-request auth-token minter for auth-required reads. The NATIVE\n * app supplies this (it has no sifa-api session cookie): given a method NSID\n * (`lxm`), it mints a short-lived AT Protocol service-auth JWT on the user's\n * PDS (see the SDK's `/atproto` `mintServiceAuthToken`) and returns it; the\n * fetcher attaches it as `Authorization: Bearer`. Web omits this and relies on\n * its session cookie (`credentials: 'include'`). Return `null` to send no\n * token. See `sifa-api` `createIdentityMiddleware`.\n */\n getAuthToken?: (lxm: string) => Promise<string | null>;\n}\n\n/** Options accepted by {@link apiFetch}. */\nexport interface ApiFetchOptions {\n method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n /** Request body. Serialized to JSON automatically. */\n body?: unknown;\n /** AbortSignal. Defaults to `AbortSignal.timeout(timeoutMs)` if `timeoutMs` is set. */\n signal?: AbortSignal;\n /** Per-call timeout in milliseconds. Default: 10_000. Ignored if `signal` is provided. */\n timeoutMs?: number;\n /** Retry on HTTP 429 up to 3 times with the server's `Retry-After` delay (capped at 3s). */\n retryOn429?: boolean;\n /** Additional headers. `Content-Type: application/json` is set automatically when `body` is present. */\n headers?: Record<string, string>;\n credentials?: RequestCredentials;\n cache?: RequestCache;\n /**\n * Next.js-specific cache hints. Ignored on non-Next runtimes. Passed\n * through transparently as part of {@link RequestInit}.\n */\n next?: { revalidate?: number | false; tags?: string[] };\n}\n\n/** Error thrown by {@link apiFetch} on non-2xx responses. */\nexport class ApiError extends Error {\n readonly status: number;\n readonly body: unknown;\n\n constructor(message: string, status: number, body?: unknown) {\n super(message);\n this.name = 'ApiError';\n this.status = status;\n this.body = body;\n }\n}\n\nconst DEFAULT_TIMEOUT_MS = 10_000;\nconst MAX_RATE_LIMIT_RETRIES = 3;\nconst RATE_LIMIT_RETRY_CAP_SECONDS = 3;\n\n/**\n * Encode a handle or DID for safe interpolation into a request path,\n * idempotently.\n *\n * Plain {@link encodeURIComponent} double-encodes an already-encoded\n * identifier: Next.js hands route params to RSC pages percent-encoded on a\n * hard navigation (`did%3Aplc%3A...`) but decoded on client-side navigation\n * (`did:plc:...`). Encoding the former again turns `%` into `%25`, so the\n * AppView reads `did%3A...` as a literal handle, finds no match, and 404s —\n * which is why DID profile links broke on direct visits but worked when\n * clicked within the app.\n *\n * AT identifiers (handles are domain names, DIDs are `did:method:...`) never\n * contain a literal `%`, so decoding a decoded value is a no-op. A malformed\n * percent sequence (lone `%`) makes {@link decodeURIComponent} throw; in that\n * case we keep the original value so behaviour matches the prior bare\n * `encodeURIComponent`.\n */\nexport function encodeIdentifier(value: string): string {\n let decoded = value;\n try {\n decoded = decodeURIComponent(value);\n } catch {\n // Malformed percent-encoding — fall back to the raw value.\n }\n return encodeURIComponent(decoded);\n}\n\n/**\n * Generic fetcher used by all SDK query and mutation functions.\n *\n * Returns parsed JSON typed as `T`. Throws {@link ApiError} on non-2xx\n * responses. Use {@link apiFetchOrNull} when 404 should resolve to `null`\n * instead.\n */\nexport async function apiFetch<T = unknown>(\n config: SifaApiConfig,\n path: string,\n options: ApiFetchOptions = {},\n): Promise<T> {\n const fetchFn = config.fetch ?? globalThis.fetch;\n const url = `${config.baseUrl}${path}`;\n const maxRetries = options.retryOn429 ? MAX_RATE_LIMIT_RETRIES : 0;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n const signal = options.signal ?? AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS);\n\n const headers: Record<string, string> = { ...(options.headers ?? {}) };\n let body: BodyInit | undefined;\n if (options.body !== undefined) {\n headers['Content-Type'] ??= 'application/json';\n body = JSON.stringify(options.body);\n }\n\n // `next` is a Next.js extension to RequestInit; cast through.\n const init = {\n method: options.method ?? 'GET',\n headers,\n body,\n signal,\n credentials: options.credentials,\n cache: options.cache,\n ...(options.next ? { next: options.next } : {}),\n } as RequestInit;\n\n const res = await fetchFn(url, init);\n\n if (res.status === 429 && attempt < maxRetries) {\n const retryAfterRaw = res.headers.get('retry-after');\n const retryAfter = retryAfterRaw ? Number.parseInt(retryAfterRaw, 10) : 2;\n const waitSeconds = Math.min(\n Number.isFinite(retryAfter) ? retryAfter : 2,\n RATE_LIMIT_RETRY_CAP_SECONDS,\n );\n await new Promise((r) => setTimeout(r, waitSeconds * 1000));\n continue;\n }\n\n if (!res.ok) {\n let errBody: unknown;\n try {\n errBody = (await res.json()) as unknown;\n } catch {\n try {\n errBody = await res.text();\n } catch {\n errBody = undefined;\n }\n }\n throw new ApiError(`Sifa API ${res.status} on ${path}`, res.status, errBody);\n }\n\n // 204 and 205 are defined to carry no body, so res.json() throws on them.\n // apiWrite treats that throw as a failed write, which turned every\n // successful no-content response (roadmap unvote, remove reaction,\n // dismiss endorsement) into a reported error.\n if (res.status === 204 || res.status === 205) {\n return undefined as T;\n }\n\n return (await res.json()) as T;\n }\n\n throw new ApiError(`Sifa API exhausted retries on ${path}`, 429);\n}\n\n/**\n * Variant of {@link apiFetch} that resolves to `null` on HTTP 404 instead\n * of throwing. Useful for \"fetch by handle\" reads where missing is\n * expected (e.g. unknown profile).\n */\nexport async function apiFetchOrNull<T>(\n config: SifaApiConfig,\n path: string,\n options: ApiFetchOptions = {},\n): Promise<T | null> {\n try {\n return await apiFetch<T>(config, path, options);\n } catch (e) {\n if (e instanceof ApiError && e.status === 404) return null;\n throw e;\n }\n}\n\n/**\n * Result returned by record-write mutations (create / update / delete).\n *\n * Never throws -- writes against the user's PDS can fail in many ways\n * (network, PDS unreachable, rate limit) and the UI needs structured\n * results to render appropriate messages.\n */\nexport interface WriteResult {\n success: boolean;\n error?: string;\n /**\n * PDS hostname returned by sifa-api when a write failed at the user's\n * Personal Data Server (issue #167). Lets the UI render\n * \"Your data server (eurosky.social) isn't responding\" instead of a\n * generic \"Request failed (500)\".\n */\n pdsHost?: string;\n}\n\n/** Result returned by create mutations. Includes the newly created `rkey`. */\nexport interface CreateResult extends WriteResult {\n rkey?: string;\n}\n\ninterface ApiErrorBody {\n message?: string;\n pdsHost?: string;\n}\n\nfunction extractWriteError(data: unknown, status: number): { error: string; pdsHost?: string } {\n const body = (data ?? {}) as ApiErrorBody;\n return {\n error: body.message ?? `Request failed (${status})`,\n ...(body.pdsHost ? { pdsHost: body.pdsHost } : {}),\n };\n}\n\n/**\n * Write mutation against the Sifa AppView. Wraps {@link apiFetch} with the\n * never-throws contract used by all sifa-web mutations: returns a\n * structured {@link WriteResult} on both success and failure, and\n * preserves the `pdsHost` field when the AppView reports a PDS-side\n * failure (issue #167).\n *\n * On success: returns `{ success: true, ...payload }` where `payload` is\n * whatever the server returned in JSON (or `{}` for 204).\n *\n * On failure: returns `{ success: false, error, pdsHost? }`. Never throws.\n *\n * Use {@link apiWriteCreate} when you specifically need the `rkey` from a\n * create response folded into the result shape.\n */\nexport async function apiWrite<TExtra extends object = Record<never, never>>(\n config: SifaApiConfig,\n path: string,\n method: 'POST' | 'PUT' | 'DELETE' | 'PATCH',\n options: Omit<ApiFetchOptions, 'method'> = {},\n): Promise<WriteResult & TExtra> {\n try {\n const data = await apiFetch<TExtra>(config, path, {\n method,\n credentials: 'include',\n ...options,\n });\n return { success: true, ...(data ?? ({} as TExtra)) };\n } catch (e) {\n if (e instanceof ApiError) {\n return { success: false, ...extractWriteError(e.body, e.status) } as WriteResult & TExtra;\n }\n return { success: false, error: 'Network error' } as WriteResult & TExtra;\n }\n}\n\n/**\n * Write mutation that expects the server to return a record key (`rkey`)\n * in its response body. Wraps {@link apiWrite} and folds the `rkey` into\n * the result shape so consumers get `{ success, rkey?, error?, pdsHost? }`.\n *\n * If the server returns additional fields (e.g. `feedUrl` from external\n * account creation), pass them via the `TExtra` generic to keep them\n * typed.\n */\nexport function apiWriteCreate<TExtra extends object = Record<never, never>>(\n config: SifaApiConfig,\n path: string,\n body: unknown,\n options: Omit<ApiFetchOptions, 'method' | 'body'> = {},\n): Promise<CreateResult & TExtra> {\n return apiWrite<{ rkey?: string } & TExtra>(config, path, 'POST', {\n body,\n ...options,\n });\n}\n","import type { ProfileView } from '../../types/profile-view.js';\nimport {\n ApiError,\n apiFetch,\n encodeIdentifier,\n type ApiFetchOptions,\n type SifaApiConfig,\n} from '../client.js';\n\n/**\n * Read the aggregated public profile view via the `id.sifa.getProfileView`\n * XRPC query. This is the AppView-only join (positions, education, skills,\n * endorsements, and more) exposed as a standard lexicon method, distinct from\n * the internal `/api/profile/*` REST surface.\n *\n * Returns `null` when the AppView has no profile for the actor\n * (`ProfileNotFound`). Throws {@link ApiError} on other non-2xx responses.\n *\n * Server-callable (Next.js RSC) and client-callable (Expo, browser).\n */\nexport async function fetchGetProfileView(\n config: SifaApiConfig,\n actor: string,\n options: ApiFetchOptions = {},\n): Promise<ProfileView | null> {\n const path = `/xrpc/id.sifa.getProfileView?actor=${encodeIdentifier(actor)}`;\n try {\n return await apiFetch<ProfileView>(config, path, { retryOn429: true, ...options });\n } catch (e) {\n if (\n e instanceof ApiError &&\n e.status === 400 &&\n typeof e.body === 'object' &&\n e.body !== null &&\n (e.body as { error?: unknown }).error === 'ProfileNotFound'\n ) {\n return null;\n }\n throw e;\n }\n}\n","import {\n summarizeProfileView,\n type ProfileSummary,\n type SummarizeProfileViewOptions,\n} from '../../logic/profile-summary.js';\nimport { fetchGetProfileView } from './get-profile-view.js';\nimport type { ApiFetchOptions, SifaApiConfig } from '../client.js';\n\n/**\n * Fetch the aggregated public profile via `id.sifa.getProfileView` and reduce it\n * to a compact {@link ProfileSummary} (identity, headline, current role/employer,\n * top skills). Convenience over `fetchGetProfileView` + `summarizeProfileView`,\n * for third-party surfaces that only want the headline facts.\n *\n * Returns `null` when the AppView has no profile for the actor. Server-callable\n * (Next.js RSC) and client-callable (Expo, browser).\n */\nexport async function fetchProfileSummary(\n config: SifaApiConfig,\n actor: string,\n options: SummarizeProfileViewOptions & ApiFetchOptions = {},\n): Promise<ProfileSummary | null> {\n const { maxSkills, ...fetchOptions } = options;\n const view = await fetchGetProfileView(config, actor, fetchOptions);\n return view ? summarizeProfileView(view, { maxSkills }) : null;\n}\n","/**\n * `<sifa-badge>` — a framework-free custom element that renders a person's\n * professional headline (name, current role and employer, top skills) from\n * their Sifa profile. Drop it into any page:\n *\n * ```html\n * <script type=\"module\" src=\"https://esm.sh/@singi-labs/sifa-sdk/badge\"></script>\n * <sifa-badge handle=\"gui.do\"></sifa-badge>\n * ```\n *\n * Or, in a bundler: `import '@singi-labs/sifa-sdk/badge'` (importing registers\n * the element). Attributes: `handle` or `did` (required), `api` (AppView base,\n * default `https://api.sifa.id`), `max-skills` (default 5).\n *\n * Reads the public `id.sifa.getProfileView` query, so it needs no auth or key.\n * Cross-origin browser use depends on that endpoint's open CORS.\n */\n\nimport type { ProfileSummary } from '../logic/profile-summary.js';\nimport { fetchProfileSummary } from '../query/fetchers/profile-summary.js';\n\nconst TAG = 'sifa-badge';\nconst DEFAULT_API_BASE = 'https://api.sifa.id';\nconst PROFILE_BASE = 'https://sifa.id/p/';\n\n// Reference HTMLElement through a guarded base so importing this module never\n// throws in a non-DOM (SSR / Node) context. The real element is only ever\n// registered and instantiated in a browser, where defineSifaBadge runs.\nconst BaseElement: typeof HTMLElement =\n typeof HTMLElement !== 'undefined' ? HTMLElement : (class {} as unknown as typeof HTMLElement);\n\nconst STYLES = `\n :host { display: inline-block; max-width: 22rem; }\n a.card {\n display: flex; gap: 0.75rem; align-items: center;\n padding: 0.75rem 0.9rem; text-decoration: none; color: inherit;\n border: 1px solid rgba(0,0,0,0.12); border-radius: 0.75rem;\n background: canvas; font: 400 0.9rem/1.4 system-ui, sans-serif;\n }\n a.card:hover { border-color: rgba(0,0,0,0.28); }\n a.card:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }\n .avatar { width: 2.75rem; height: 2.75rem; border-radius: 50%; object-fit: cover; flex: none; }\n .body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }\n .name { font-weight: 600; }\n .role { color: color-mix(in srgb, canvastext 65%, canvas); }\n .skills { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.25rem; }\n .chip {\n font-size: 0.72rem; padding: 0.1rem 0.45rem; border-radius: 999px;\n background: color-mix(in srgb, canvastext 8%, canvas);\n }\n .msg { margin: 0; padding: 0.5rem 0.6rem; color: color-mix(in srgb, canvastext 60%, canvas);\n font: 400 0.85rem/1.4 system-ui, sans-serif; }\n`;\n\nexport class SifaBadgeElement extends BaseElement {\n static readonly observedAttributes = ['handle', 'did', 'api', 'max-skills'];\n\n private readonly shadow: ShadowRoot;\n private renderToken = 0;\n private scheduled = false;\n\n constructor() {\n super();\n this.shadow = this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback(): void {\n this.schedule();\n }\n\n attributeChangedCallback(): void {\n this.schedule();\n }\n\n /** Coalesce a burst of synchronous attribute writes (and the initial connect) into one load. */\n private schedule(): void {\n if (this.scheduled) return;\n this.scheduled = true;\n queueMicrotask(() => {\n this.scheduled = false;\n if (this.isConnected) void this.load();\n });\n }\n\n private async load(): Promise<void> {\n const token = ++this.renderToken;\n const actor = this.getAttribute('did') || this.getAttribute('handle');\n if (!actor) {\n this.paint(this.message('Set a handle or did attribute on <sifa-badge>.'));\n return;\n }\n\n const baseUrl = this.getAttribute('api') || DEFAULT_API_BASE;\n const rawMax = this.getAttribute('max-skills');\n const maxSkills = rawMax != null ? Number(rawMax) : undefined;\n const options = maxSkills != null && Number.isFinite(maxSkills) ? { maxSkills } : {};\n\n this.paint(this.message('Loading…'));\n\n let summary: ProfileSummary | null;\n try {\n summary = await fetchProfileSummary({ baseUrl }, actor, options);\n } catch {\n if (token === this.renderToken) this.paint(this.message('Could not load this profile.'));\n return;\n }\n\n if (token !== this.renderToken) return; // a newer load superseded this one\n this.paint(summary ? this.card(summary) : this.message(`No Sifa profile for ${actor}.`));\n }\n\n private paint(body: Node): void {\n const style = document.createElement('style');\n style.textContent = STYLES;\n this.shadow.replaceChildren(style, body);\n }\n\n private message(text: string): HTMLElement {\n const p = document.createElement('p');\n p.className = 'msg';\n p.textContent = text;\n return p;\n }\n\n private card(summary: ProfileSummary): HTMLElement {\n const name = summary.displayName || summary.handle;\n const link = document.createElement('a');\n link.className = 'card';\n link.href = PROFILE_BASE + encodeURIComponent(summary.handle);\n link.target = '_blank';\n link.rel = 'noopener';\n link.setAttribute('aria-label', `${name} on Sifa`);\n\n if (summary.avatar) {\n const img = document.createElement('img');\n img.className = 'avatar';\n img.src = summary.avatar;\n img.alt = '';\n img.loading = 'lazy';\n link.append(img);\n }\n\n const body = document.createElement('span');\n body.className = 'body';\n\n const nameEl = document.createElement('span');\n nameEl.className = 'name';\n nameEl.textContent = name;\n body.append(nameEl);\n\n const role =\n [summary.currentTitle, summary.currentCompany].filter(Boolean).join(' · ') ||\n summary.headline;\n if (role) {\n const roleEl = document.createElement('span');\n roleEl.className = 'role';\n roleEl.textContent = role;\n body.append(roleEl);\n }\n\n if (summary.topSkills.length > 0) {\n const skills = document.createElement('span');\n skills.className = 'skills';\n for (const skill of summary.topSkills) {\n const chip = document.createElement('span');\n chip.className = 'chip';\n chip.textContent = skill;\n skills.append(chip);\n }\n body.append(skills);\n }\n\n link.append(body);\n return link;\n }\n}\n\n/** Register the element (idempotent). Called automatically when this module is imported. */\nexport function defineSifaBadge(tag: string = TAG): void {\n if (typeof customElements !== 'undefined' && !customElements.get(tag)) {\n customElements.define(tag, SifaBadgeElement);\n }\n}\n\ndefineSifaBadge();\n"]}
@@ -4,7 +4,12 @@ import { normalizeLegalForm } from "./normalize-legal-form.js";
4
4
  import { normalizeCompanyKey } from "./normalize-company-key.js";
5
5
  import { formatIsoTitle, formatRelativeTime } from "./format-time.js";
6
6
  import { formatPresentationDuration } from "./format-duration.js";
7
- import { formatDateRange, formatPositionDateRange, formatTimelineDate } from "./timeline.js";
7
+ import {
8
+ formatCredentialDateRange,
9
+ formatDateRange,
10
+ formatPositionDateRange,
11
+ formatTimelineDate
12
+ } from "./timeline.js";
8
13
  import {
9
14
  collapseContributors
10
15
  } from "./collapse-contributors.js";
@@ -58,6 +63,7 @@ export {
58
63
  dateRangeExtractor,
59
64
  detectPdsProvider,
60
65
  formatCompanyName,
66
+ formatCredentialDateRange,
61
67
  formatDateRange,
62
68
  formatDisplayUrl,
63
69
  formatDistanceToNow,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/format/index.ts"],"sourcesContent":["export { formatCompanyName } from './company-name.js';\nexport { normalizeLegalForm } from './normalize-legal-form.js';\nexport { normalizeCompanyKey } from './normalize-company-key.js';\nexport { formatIsoTitle, formatRelativeTime } from './format-time.js';\nexport { formatPresentationDuration } from './format-duration.js';\nexport { formatDateRange, formatPositionDateRange, formatTimelineDate } from './timeline.js';\nexport {\n collapseContributors,\n type CollapseContributorsOptions,\n type CollapsedContributors,\n} from './collapse-contributors.js';\nexport {\n summarizePresentationDeliveries,\n type PresentationDeliverySummary,\n} from './summarize-deliveries.js';\nexport {\n certDateExtractor,\n dateRangeExtractor,\n lexiconDateExtractor,\n singleDateExtractor,\n sortByDateDesc,\n} from './sort-by-date.js';\nexport { normalizeDoi } from './doi.js';\nexport {\n formatRelationship,\n parseEndorsementComment,\n type ParsedEndorsementComment,\n} from './endorsement-context.js';\nexport { sanitizeHandleInput } from './handle-utils.js';\nexport { countryCodeToFlag, formatLocation, parseLocationString } from './location-utils.js';\nexport { locationSegments } from './location-segments.js';\nexport type {\n LocationSegment,\n LocationSegmentKind,\n LocationSegmentsOptions,\n} from './location-segments.js';\nexport {\n detectPdsProvider,\n formatStructuredName,\n getDisplayLabel,\n getHandleStem,\n getPdsDisplayName,\n pdsProviderFromApi,\n type PdsProvider,\n} from './pds-utils.js';\nexport { resolveEmbed, youtubeVideoId, youtubeThumbnailUrl, type EmbedResult } from './embed.js';\nexport { buildTalkSlug, parseTalkRkey, slugifyTitle } from './talk-slug.js';\nexport { buildMetaDescription } from './meta-description.js';\nexport type { MetaDescriptionInput, MetaDescriptionPosition } from './meta-description.js';\nexport { limitCombiningMarks, sanitizeDisplayText } from './text-sanitize.js';\nexport { truncateGraphemes } from './text-truncate.js';\nexport { formatDisplayUrl } from './format-display-url.js';\nexport type { DisplayUrl, FormatDisplayUrlOptions, UrlPathPolicy } from './format-display-url.js';\nexport { formatDistanceToNow } from './time-utils.js';\nexport {\n contrastRatio,\n isValidRgbColor,\n meetsContrastAA,\n relativeLuminance,\n rgbToString,\n type RgbColor,\n} from './wcag-contrast.js';\n"],"mappings":";AAAA,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC,SAAS,gBAAgB,0BAA0B;AACnD,SAAS,kCAAkC;AAC3C,SAAS,iBAAiB,yBAAyB,0BAA0B;AAC7E;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,2BAA2B;AACpC,SAAS,mBAAmB,gBAAgB,2BAA2B;AACvE,SAAS,wBAAwB;AAMjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,cAAc,gBAAgB,2BAA6C;AACpF,SAAS,eAAe,eAAe,oBAAoB;AAC3D,SAAS,4BAA4B;AAErC,SAAS,qBAAqB,2BAA2B;AACzD,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAEjC,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;","names":[]}
1
+ {"version":3,"sources":["../../src/format/index.ts"],"sourcesContent":["export { formatCompanyName } from './company-name.js';\nexport { normalizeLegalForm } from './normalize-legal-form.js';\nexport { normalizeCompanyKey } from './normalize-company-key.js';\nexport { formatIsoTitle, formatRelativeTime } from './format-time.js';\nexport { formatPresentationDuration } from './format-duration.js';\nexport {\n formatCredentialDateRange,\n formatDateRange,\n formatPositionDateRange,\n formatTimelineDate,\n} from './timeline.js';\nexport {\n collapseContributors,\n type CollapseContributorsOptions,\n type CollapsedContributors,\n} from './collapse-contributors.js';\nexport {\n summarizePresentationDeliveries,\n type PresentationDeliverySummary,\n} from './summarize-deliveries.js';\nexport {\n certDateExtractor,\n dateRangeExtractor,\n lexiconDateExtractor,\n singleDateExtractor,\n sortByDateDesc,\n} from './sort-by-date.js';\nexport { normalizeDoi } from './doi.js';\nexport {\n formatRelationship,\n parseEndorsementComment,\n type ParsedEndorsementComment,\n} from './endorsement-context.js';\nexport { sanitizeHandleInput } from './handle-utils.js';\nexport { countryCodeToFlag, formatLocation, parseLocationString } from './location-utils.js';\nexport { locationSegments } from './location-segments.js';\nexport type {\n LocationSegment,\n LocationSegmentKind,\n LocationSegmentsOptions,\n} from './location-segments.js';\nexport {\n detectPdsProvider,\n formatStructuredName,\n getDisplayLabel,\n getHandleStem,\n getPdsDisplayName,\n pdsProviderFromApi,\n type PdsProvider,\n} from './pds-utils.js';\nexport { resolveEmbed, youtubeVideoId, youtubeThumbnailUrl, type EmbedResult } from './embed.js';\nexport { buildTalkSlug, parseTalkRkey, slugifyTitle } from './talk-slug.js';\nexport { buildMetaDescription } from './meta-description.js';\nexport type { MetaDescriptionInput, MetaDescriptionPosition } from './meta-description.js';\nexport { limitCombiningMarks, sanitizeDisplayText } from './text-sanitize.js';\nexport { truncateGraphemes } from './text-truncate.js';\nexport { formatDisplayUrl } from './format-display-url.js';\nexport type { DisplayUrl, FormatDisplayUrlOptions, UrlPathPolicy } from './format-display-url.js';\nexport { formatDistanceToNow } from './time-utils.js';\nexport {\n contrastRatio,\n isValidRgbColor,\n meetsContrastAA,\n relativeLuminance,\n rgbToString,\n type RgbColor,\n} from './wcag-contrast.js';\n"],"mappings":";AAAA,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC,SAAS,gBAAgB,0BAA0B;AACnD,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,2BAA2B;AACpC,SAAS,mBAAmB,gBAAgB,2BAA2B;AACvE,SAAS,wBAAwB;AAMjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,cAAc,gBAAgB,2BAA6C;AACpF,SAAS,eAAe,eAAe,oBAAoB;AAC3D,SAAS,4BAA4B;AAErC,SAAS,qBAAqB,2BAA2B;AACzD,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAEjC,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;","names":[]}
@@ -21,7 +21,11 @@ function formatPositionDateRange(start, end, now = /* @__PURE__ */ new Date()) {
21
21
  if (start && !end && isUpcomingStart(start, now)) return `Starts ${formatTimelineDate(start)}`;
22
22
  return formatDateRange(start, end);
23
23
  }
24
+ function formatCredentialDateRange(issueDate, expiryDate) {
25
+ return formatDateRange(issueDate ?? void 0, expiryDate ?? void 0, false);
26
+ }
24
27
  export {
28
+ formatCredentialDateRange,
25
29
  formatDateRange,
26
30
  formatPositionDateRange,
27
31
  formatTimelineDate
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/format/timeline.ts"],"sourcesContent":["/**\n * Server-safe timeline date formatters shared by every profile surface.\n */\n\nimport { isUpcomingStart } from '../logic/date-lookahead.js';\n\nconst MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n\n/** Format \"2007-01\" as \"Jan 2007\", pass through year-only strings. */\nexport function formatTimelineDate(dateStr: string): string {\n if (dateStr.length === 4) return dateStr;\n const [year, month] = dateStr.split('-');\n if (!month) return year ?? dateStr;\n const idx = parseInt(month, 10) - 1;\n return `${MONTHS[idx]} ${year}`;\n}\n\n/**\n * Format a date range for display. Handles missing dates, equal start/end,\n * and ongoing entries (showPresent defaults to true).\n */\nexport function formatDateRange(start?: string, end?: string, showPresent = true): string {\n if (!start && !end) return '';\n if (!start) return end ? formatTimelineDate(end) : '';\n const formattedStart = formatTimelineDate(start);\n if (!end) return showPresent ? `${formattedStart} - Present` : formattedStart;\n const formattedEnd = formatTimelineDate(end);\n if (formattedStart === formattedEnd) return formattedStart;\n return `${formattedStart} - ${formattedEnd}`;\n}\n\n/**\n * Format a position's dates. A role whose start month has not arrived yet (an\n * accepted offer) reads \"Starts Jan 2027\" rather than \"Jan 2027 - Present\",\n * which would claim it is already under way (sifa-workspace#581).\n */\nexport function formatPositionDateRange(\n start?: string,\n end?: string,\n now: Date = new Date(),\n): string {\n if (start && !end && isUpcomingStart(start, now)) return `Starts ${formatTimelineDate(start)}`;\n return formatDateRange(start, end);\n}\n"],"mappings":";AAIA,SAAS,uBAAuB;AAEhC,IAAM,SAAS,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAG3F,SAAS,mBAAmB,SAAyB;AAC1D,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,QAAM,CAAC,MAAM,KAAK,IAAI,QAAQ,MAAM,GAAG;AACvC,MAAI,CAAC,MAAO,QAAO,QAAQ;AAC3B,QAAM,MAAM,SAAS,OAAO,EAAE,IAAI;AAClC,SAAO,GAAG,OAAO,GAAG,CAAC,IAAI,IAAI;AAC/B;AAMO,SAAS,gBAAgB,OAAgB,KAAc,cAAc,MAAc;AACxF,MAAI,CAAC,SAAS,CAAC,IAAK,QAAO;AAC3B,MAAI,CAAC,MAAO,QAAO,MAAM,mBAAmB,GAAG,IAAI;AACnD,QAAM,iBAAiB,mBAAmB,KAAK;AAC/C,MAAI,CAAC,IAAK,QAAO,cAAc,GAAG,cAAc,eAAe;AAC/D,QAAM,eAAe,mBAAmB,GAAG;AAC3C,MAAI,mBAAmB,aAAc,QAAO;AAC5C,SAAO,GAAG,cAAc,MAAM,YAAY;AAC5C;AAOO,SAAS,wBACd,OACA,KACA,MAAY,oBAAI,KAAK,GACb;AACR,MAAI,SAAS,CAAC,OAAO,gBAAgB,OAAO,GAAG,EAAG,QAAO,UAAU,mBAAmB,KAAK,CAAC;AAC5F,SAAO,gBAAgB,OAAO,GAAG;AACnC;","names":[]}
1
+ {"version":3,"sources":["../../src/format/timeline.ts"],"sourcesContent":["/**\n * Server-safe timeline date formatters shared by every profile surface.\n */\n\nimport { isUpcomingStart } from '../logic/date-lookahead.js';\n\nconst MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n\n/** Format \"2007-01\" as \"Jan 2007\", pass through year-only strings. */\nexport function formatTimelineDate(dateStr: string): string {\n if (dateStr.length === 4) return dateStr;\n const [year, month] = dateStr.split('-');\n if (!month) return year ?? dateStr;\n const idx = parseInt(month, 10) - 1;\n return `${MONTHS[idx]} ${year}`;\n}\n\n/**\n * Format a date range for display. Handles missing dates, equal start/end,\n * and ongoing entries (showPresent defaults to true).\n */\nexport function formatDateRange(start?: string, end?: string, showPresent = true): string {\n if (!start && !end) return '';\n if (!start) return end ? formatTimelineDate(end) : '';\n const formattedStart = formatTimelineDate(start);\n if (!end) return showPresent ? `${formattedStart} - Present` : formattedStart;\n const formattedEnd = formatTimelineDate(end);\n if (formattedStart === formattedEnd) return formattedStart;\n return `${formattedStart} - ${formattedEnd}`;\n}\n\n/**\n * Format a position's dates. A role whose start month has not arrived yet (an\n * accepted offer) reads \"Starts Jan 2027\" rather than \"Jan 2027 - Present\",\n * which would claim it is already under way (sifa-workspace#581).\n */\nexport function formatPositionDateRange(\n start?: string,\n end?: string,\n now: Date = new Date(),\n): string {\n if (start && !end && isUpcomingStart(start, now)) return `Starts ${formatTimelineDate(start)}`;\n return formatDateRange(start, end);\n}\n\n/**\n * Format a credential's issue and expiry dates: \"Jan 2025 - Jan 2029\", or the\n * issue date alone for one that doesn't expire (never \"Present\").\n */\nexport function formatCredentialDateRange(\n issueDate?: string | null,\n expiryDate?: string | null,\n): string {\n return formatDateRange(issueDate ?? undefined, expiryDate ?? undefined, false);\n}\n"],"mappings":";AAIA,SAAS,uBAAuB;AAEhC,IAAM,SAAS,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAG3F,SAAS,mBAAmB,SAAyB;AAC1D,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,QAAM,CAAC,MAAM,KAAK,IAAI,QAAQ,MAAM,GAAG;AACvC,MAAI,CAAC,MAAO,QAAO,QAAQ;AAC3B,QAAM,MAAM,SAAS,OAAO,EAAE,IAAI;AAClC,SAAO,GAAG,OAAO,GAAG,CAAC,IAAI,IAAI;AAC/B;AAMO,SAAS,gBAAgB,OAAgB,KAAc,cAAc,MAAc;AACxF,MAAI,CAAC,SAAS,CAAC,IAAK,QAAO;AAC3B,MAAI,CAAC,MAAO,QAAO,MAAM,mBAAmB,GAAG,IAAI;AACnD,QAAM,iBAAiB,mBAAmB,KAAK;AAC/C,MAAI,CAAC,IAAK,QAAO,cAAc,GAAG,cAAc,eAAe;AAC/D,QAAM,eAAe,mBAAmB,GAAG;AAC3C,MAAI,mBAAmB,aAAc,QAAO;AAC5C,SAAO,GAAG,cAAc,MAAM,YAAY;AAC5C;AAOO,SAAS,wBACd,OACA,KACA,MAAY,oBAAI,KAAK,GACb;AACR,MAAI,SAAS,CAAC,OAAO,gBAAgB,OAAO,GAAG,EAAG,QAAO,UAAU,mBAAmB,KAAK,CAAC;AAC5F,SAAO,gBAAgB,OAAO,GAAG;AACnC;AAMO,SAAS,0BACd,WACA,YACQ;AACR,SAAO,gBAAgB,aAAa,QAAW,cAAc,QAAW,KAAK;AAC/E;","names":[]}
package/dist/index.cjs CHANGED
@@ -1393,7 +1393,6 @@ function categoryForApp(appId) {
1393
1393
 
1394
1394
  // src/taxonomy/activity-tiers.json
1395
1395
  var activity_tiers_default = {
1396
- $schema: "https://sifa.id/schemas/activity-tiers/v1.json",
1397
1396
  version: "1.4.0",
1398
1397
  updated: "2026-09-04",
1399
1398
  tiers: {
@@ -2298,27 +2297,12 @@ var activity_tiers_default = {
2298
2297
  };
2299
2298
 
2300
2299
  // src/taxonomy/activity-tiers.ts
2301
- var tierMetaSchema = zod.z.object({
2302
- label: zod.z.string().nullable(),
2303
- description: zod.z.string(),
2304
- shownOnPublicProfile: zod.z.boolean()
2305
- });
2306
- var lexiconEntrySchema = zod.z.object({
2307
- tier: zod.z.enum(["creation", "action", "filtered"]),
2308
- app: zod.z.string().optional(),
2309
- notes: zod.z.string().optional()
2310
- });
2311
- var taxonomySchema = zod.z.object({
2312
- version: zod.z.string(),
2313
- updated: zod.z.string(),
2314
- tiers: zod.z.object({
2315
- creation: tierMetaSchema,
2316
- action: tierMetaSchema,
2317
- filtered: tierMetaSchema
2318
- }),
2319
- lexicons: zod.z.record(zod.z.string(), lexiconEntrySchema)
2320
- });
2321
- var parsed = taxonomySchema.parse(activity_tiers_default);
2300
+ var parsed = {
2301
+ version: activity_tiers_default.version,
2302
+ updated: activity_tiers_default.updated,
2303
+ tiers: activity_tiers_default.tiers,
2304
+ lexicons: activity_tiers_default.lexicons
2305
+ };
2322
2306
  var ACTIVITY_TIERS = Object.freeze(parsed);
2323
2307
  function getActivityTier(nsid) {
2324
2308
  if (!nsid) return "filtered";
@@ -2824,6 +2808,8 @@ var DATE_LOOKAHEAD_MONTHS = {
2824
2808
  projectStart: 6,
2825
2809
  publication: 6,
2826
2810
  talk: 12,
2811
+ /** Admitted to a programme that starts next year. */
2812
+ educationStart: 12,
2827
2813
  educationEnd: 96
2828
2814
  };
2829
2815
  function isBeyondLookahead(value, months, now = /* @__PURE__ */ new Date()) {
@@ -2859,6 +2845,9 @@ function formatPositionDateRange(start, end, now = /* @__PURE__ */ new Date()) {
2859
2845
  if (start && !end && isUpcomingStart(start, now)) return `Starts ${formatTimelineDate(start)}`;
2860
2846
  return formatDateRange(start, end);
2861
2847
  }
2848
+ function formatCredentialDateRange(issueDate, expiryDate) {
2849
+ return formatDateRange(issueDate ?? void 0, expiryDate ?? void 0, false);
2850
+ }
2862
2851
 
2863
2852
  // src/format/collapse-contributors.ts
2864
2853
  function collapseContributors(contributors, options = {}) {
@@ -4334,7 +4323,6 @@ function getPublisherFromSiteUrl(siteUrl) {
4334
4323
 
4335
4324
  // src/stream/verbs.json
4336
4325
  var verbs_default = {
4337
- $schema: "https://sifa.id/schemas/activity-verbs/v1.json",
4338
4326
  version: "1.7.0",
4339
4327
  updated: "2026-09-26",
4340
4328
  defaultVerb: "created",
@@ -4425,14 +4413,12 @@ var STREAM_VERBS = [
4425
4413
  "received",
4426
4414
  "styledCharacter"
4427
4415
  ];
4428
- var streamVerbSchema = zod.z.enum(STREAM_VERBS);
4429
- var verbMapSchema = zod.z.object({
4430
- version: zod.z.string(),
4431
- updated: zod.z.string(),
4432
- defaultVerb: streamVerbSchema,
4433
- verbs: zod.z.record(zod.z.string(), streamVerbSchema)
4434
- });
4435
- var parsed2 = verbMapSchema.parse(verbs_default);
4416
+ var parsed2 = {
4417
+ version: verbs_default.version,
4418
+ updated: verbs_default.updated,
4419
+ defaultVerb: verbs_default.defaultVerb,
4420
+ verbs: verbs_default.verbs
4421
+ };
4436
4422
  var ACTIVITY_VERBS = Object.freeze(parsed2);
4437
4423
  function verbForCollection(collection) {
4438
4424
  if (!collection) return ACTIVITY_VERBS.defaultVerb;
@@ -4441,6 +4427,7 @@ function verbForCollection(collection) {
4441
4427
  function getActivityVerbsVersion() {
4442
4428
  return { version: ACTIVITY_VERBS.version, updated: ACTIVITY_VERBS.updated };
4443
4429
  }
4430
+ var streamVerbSchema = zod.z.enum(STREAM_VERBS);
4444
4431
  var rgbChannelSchema = zod.z.number().min(0).max(255);
4445
4432
  var rgbColorSchema = zod.z.object({
4446
4433
  r: rgbChannelSchema,
@@ -7084,7 +7071,7 @@ function describeSifaRecord(collection, value) {
7084
7071
  }
7085
7072
 
7086
7073
  // src/index.ts
7087
- var SIFA_SDK_VERSION = "0.19.45";
7074
+ var SIFA_SDK_VERSION = "0.19.47";
7088
7075
 
7089
7076
  exports.ACTIVITY_TIERS = ACTIVITY_TIERS;
7090
7077
  exports.ACTIVITY_VERBS = ACTIVITY_VERBS;
@@ -7244,6 +7231,7 @@ exports.externalRecordRefSchema = externalRecordRefSchema;
7244
7231
  exports.filterHidden = filterHidden;
7245
7232
  exports.findIndustry = findIndustry;
7246
7233
  exports.formatCompanyName = formatCompanyName;
7234
+ exports.formatCredentialDateRange = formatCredentialDateRange;
7247
7235
  exports.formatDateRange = formatDateRange;
7248
7236
  exports.formatDisplayUrl = formatDisplayUrl;
7249
7237
  exports.formatDistanceToNow = formatDistanceToNow;