@singi-labs/sifa-sdk 0.18.16 → 0.18.18

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/index.cjs CHANGED
@@ -5412,6 +5412,185 @@ function groupInvolvementByHeading(items) {
5412
5412
  }
5413
5413
  return groups;
5414
5414
  }
5415
+
5416
+ // src/profile/highlights.ts
5417
+ function coPeopleLabel(people, self) {
5418
+ const names = (people ?? []).filter((p) => p.did !== self.did && (!p.handle || p.handle !== self.handle)).map((p) => p.displayName ?? p.name ?? p.handle).filter((n) => Boolean(n && n.trim()));
5419
+ return names.length ? `with ${names.join(", ")}` : void 0;
5420
+ }
5421
+ var EN_DASH = "\u2013";
5422
+ function visible(items) {
5423
+ return (items ?? []).filter((i) => !i.hidden);
5424
+ }
5425
+ function metaLine(parts) {
5426
+ const kept = parts.filter((p) => Boolean(p && p.trim()));
5427
+ return kept.length ? kept.join(" \xB7 ") : void 0;
5428
+ }
5429
+ function formatSpanDate(start, end) {
5430
+ if (start && !end) return `Since ${formatTimelineDate(start)}`;
5431
+ if (!start && !end) return void 0;
5432
+ if (!start) return formatTimelineDate(end);
5433
+ const a = formatTimelineDate(start);
5434
+ const b = formatTimelineDate(end);
5435
+ return a === b ? a : `${a} ${EN_DASH} ${b}`;
5436
+ }
5437
+ function formatSingleDate(date) {
5438
+ return date ? formatTimelineDate(date) : void 0;
5439
+ }
5440
+ var EVENT_DAY_FMT = new Intl.DateTimeFormat("en", {
5441
+ year: "numeric",
5442
+ month: "short",
5443
+ day: "numeric",
5444
+ timeZone: "UTC"
5445
+ });
5446
+ function formatEventDate(date) {
5447
+ if (!date) return void 0;
5448
+ if (date.length === 10) {
5449
+ const d = /* @__PURE__ */ new Date(`${date}T00:00:00Z`);
5450
+ if (!Number.isNaN(d.getTime())) return EVENT_DAY_FMT.format(d);
5451
+ }
5452
+ return formatTimelineDate(date);
5453
+ }
5454
+ function pickTalk(presentations, deliveries, today, self) {
5455
+ const talkRkeys = new Set(presentations.map((p) => p.rkey));
5456
+ const occasions = [];
5457
+ for (const p of presentations) {
5458
+ const dated = visible(p.deliveries).filter((d) => d.date);
5459
+ if (!dated.length) continue;
5460
+ const date = dated.reduce((max, d) => d.date && d.date > max ? d.date : max, "");
5461
+ const delivery2 = dated.find((d) => d.date === date);
5462
+ if (!delivery2) continue;
5463
+ occasions.push({
5464
+ date,
5465
+ title: p.title,
5466
+ delivery: delivery2,
5467
+ imageUrl: p.coverImageUrl ?? void 0,
5468
+ primary: p.primary === true
5469
+ });
5470
+ }
5471
+ for (const d of deliveries) {
5472
+ const standalone = !d.presentationRkey || !talkRkeys.has(d.presentationRkey);
5473
+ if (!standalone || !d.date || d.hidden) continue;
5474
+ occasions.push({ date: d.date, title: d.title || d.eventName || "Talk", delivery: d });
5475
+ }
5476
+ if (!occasions.length) return void 0;
5477
+ const primaryOccasions = occasions.filter((o) => o.primary);
5478
+ const pool = primaryOccasions.length ? primaryOccasions : occasions;
5479
+ const best = pool.reduce((a, b) => b.date > a.date ? b : a);
5480
+ const { delivery } = best;
5481
+ return {
5482
+ section: "talk",
5483
+ href: "#presentations",
5484
+ title: best.title,
5485
+ meta: metaLine([
5486
+ delivery.eventName,
5487
+ delivery.location,
5488
+ getPresentationRoleLabel(delivery.role ?? void 0),
5489
+ getCalendarEventModeLabel(delivery.mode ?? void 0),
5490
+ coPeopleLabel(delivery.coSpeakers, self)
5491
+ ]),
5492
+ dateStr: formatEventDate(best.date),
5493
+ imageUrl: best.imageUrl,
5494
+ status: best.date > today ? "upcoming" : "recent"
5495
+ };
5496
+ }
5497
+ function buildProfileHighlights(profile, { today }) {
5498
+ const row1 = [];
5499
+ const row2 = [];
5500
+ const self = { did: profile.did, handle: profile.handle };
5501
+ const talk = pickTalk(
5502
+ visible(profile.presentations),
5503
+ visible(profile.presentationDeliveries),
5504
+ today,
5505
+ self
5506
+ );
5507
+ if (talk) row1.push(talk);
5508
+ const visiblePublications = visible(profile.publications);
5509
+ const publication = pickPrimaryFlagged(visiblePublications) ?? sortByDateDesc(visiblePublications, singleDateExtractor)[0];
5510
+ if (publication) {
5511
+ const venue = publication.publicationName ?? publication.publisher;
5512
+ const coAuthors = coPeopleLabel(publication.contributors, self);
5513
+ const venueIsSelf = venue === profile.handle || !!profile.displayName && venue === profile.displayName && !coAuthors;
5514
+ row1.push({
5515
+ section: "publication",
5516
+ href: "#publications",
5517
+ title: publication.title,
5518
+ meta: metaLine([coAuthors, venue && !venueIsSelf ? venue : void 0, publication.subtitle]),
5519
+ dateStr: formatSingleDate(publication.date),
5520
+ imageUrl: publication.image ?? void 0,
5521
+ status: "recent"
5522
+ });
5523
+ }
5524
+ const positions = visible(profile.positions);
5525
+ const career = pickPrimaryPosition(positions) ?? sortByDateDesc(positions, lexiconDateExtractor)[0];
5526
+ if (career) {
5527
+ row2.push({
5528
+ section: "career",
5529
+ href: "#career",
5530
+ title: career.title,
5531
+ meta: metaLine([career.entityName ?? career.company]),
5532
+ dateStr: formatSpanDate(career.startedAt, career.endedAt),
5533
+ status: career.endedAt ? "recent" : "current"
5534
+ });
5535
+ }
5536
+ const visibleEducation = visible(profile.education);
5537
+ const education = pickPrimaryFlagged(visibleEducation) ?? sortByDateDesc(visibleEducation, lexiconDateExtractor)[0];
5538
+ if (education) {
5539
+ const institution = education.entityName ?? education.institution;
5540
+ const title = education.degree || education.fieldOfStudy || institution || "Education";
5541
+ row2.push({
5542
+ section: "education",
5543
+ href: "#education",
5544
+ title,
5545
+ meta: metaLine([title === institution ? void 0 : institution]),
5546
+ dateStr: formatSpanDate(education.startedAt, education.endedAt),
5547
+ status: education.endedAt ? "recent" : "current"
5548
+ });
5549
+ } else {
5550
+ const course = visible(profile.courses)[0];
5551
+ if (course) {
5552
+ row2.push({
5553
+ section: "education",
5554
+ href: "#courses",
5555
+ title: course.name,
5556
+ meta: metaLine([course.entityName ?? course.institution]),
5557
+ dateStr: formatSingleDate(course.completedAt),
5558
+ status: "recent"
5559
+ });
5560
+ }
5561
+ }
5562
+ const ongoingProjects = visible(profile.projects).filter((p) => !p.endDate);
5563
+ const project = pickPrimaryFlagged(ongoingProjects) ?? sortByDateDesc(ongoingProjects, dateRangeExtractor)[0];
5564
+ if (project) {
5565
+ row2.push({
5566
+ section: "project",
5567
+ href: "#projects",
5568
+ title: project.name,
5569
+ meta: coPeopleLabel(project.members, self),
5570
+ dateStr: formatSpanDate(project.startDate, project.endDate),
5571
+ status: "current"
5572
+ });
5573
+ }
5574
+ const ongoingInvolvement = visible(profile.involvement).filter((i) => !i.endedAt);
5575
+ const involvement = pickPrimaryFlagged(ongoingInvolvement) ?? sortByDateDesc(ongoingInvolvement, lexiconDateExtractor)[0];
5576
+ if (involvement) {
5577
+ row2.push({
5578
+ section: "involvement",
5579
+ href: "#involvement",
5580
+ title: involvement.role || involvement.kind || "Involvement",
5581
+ meta: metaLine([
5582
+ involvement.entityName ?? involvement.upstream,
5583
+ coPeopleLabel(involvement.collaborators, self)
5584
+ ]),
5585
+ dateStr: formatSpanDate(involvement.startedAt, involvement.endedAt),
5586
+ status: "current"
5587
+ });
5588
+ }
5589
+ return { row1, row2 };
5590
+ }
5591
+ function shouldRenderHighlights(rows) {
5592
+ return rows.row1.length + rows.row2.length >= 2;
5593
+ }
5415
5594
  var BlobRefSchema = zod.z.object({
5416
5595
  $type: zod.z.literal("blob"),
5417
5596
  ref: zod.z.object({ $link: zod.z.string().min(1) }),
@@ -6238,7 +6417,7 @@ function describeSifaRecord(collection, value) {
6238
6417
  }
6239
6418
 
6240
6419
  // src/index.ts
6241
- var SIFA_SDK_VERSION = "0.18.16";
6420
+ var SIFA_SDK_VERSION = "0.18.18";
6242
6421
 
6243
6422
  exports.ACTIVITY_TIERS = ACTIVITY_TIERS;
6244
6423
  exports.ACTIVITY_VERBS = ACTIVITY_VERBS;
@@ -6355,6 +6534,7 @@ exports.actorShowsIdentity = actorShowsIdentity;
6355
6534
  exports.agentRefSchema = agentRefSchema;
6356
6535
  exports.atUriSchema = atUriSchema;
6357
6536
  exports.buildMetaDescription = buildMetaDescription;
6537
+ exports.buildProfileHighlights = buildProfileHighlights;
6358
6538
  exports.buildTalkSlug = buildTalkSlug;
6359
6539
  exports.categoryForApp = categoryForApp;
6360
6540
  exports.certDateExtractor = certDateExtractor;
@@ -6386,9 +6566,12 @@ exports.formatCompanyName = formatCompanyName;
6386
6566
  exports.formatDateRange = formatDateRange;
6387
6567
  exports.formatDisplayUrl = formatDisplayUrl;
6388
6568
  exports.formatDistanceToNow = formatDistanceToNow;
6569
+ exports.formatEventDate = formatEventDate;
6389
6570
  exports.formatLocation = formatLocation;
6390
6571
  exports.formatPresentationDuration = formatPresentationDuration;
6391
6572
  exports.formatRelativeTime = formatRelativeTime;
6573
+ exports.formatSingleDate = formatSingleDate;
6574
+ exports.formatSpanDate = formatSpanDate;
6392
6575
  exports.formatTimelineDate = formatTimelineDate;
6393
6576
  exports.getActivityTaxonomyVersion = getActivityTaxonomyVersion;
6394
6577
  exports.getActivityTier = getActivityTier;
@@ -6493,6 +6676,7 @@ exports.sanitizeDisplayText = sanitizeDisplayText;
6493
6676
  exports.sanitizeHandleInput = sanitizeHandleInput;
6494
6677
  exports.searchResultDisambiguation = searchResultDisambiguation;
6495
6678
  exports.selfLabelsSchema = selfLabelsSchema;
6679
+ exports.shouldRenderHighlights = shouldRenderHighlights;
6496
6680
  exports.singleDateExtractor = singleDateExtractor;
6497
6681
  exports.skillRefSchema = skillRefSchema;
6498
6682
  exports.slugifyTitle = slugifyTitle;