@singi-labs/sifa-sdk 0.12.7 → 0.12.9

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
@@ -2409,34 +2409,34 @@ function resolveCardHealth(item) {
2409
2409
  if (subject != null && typeof subject === "object") {
2410
2410
  const subjectUri = stringOrNull(subject.uri);
2411
2411
  if (subjectUri) {
2412
- const parsed2 = parseAtUri(subjectUri);
2413
- if (parsed2) {
2414
- return urlHealth(`https://smokesignal.events/${parsed2.did}/${parsed2.rkey}`);
2412
+ const parsed3 = parseAtUri(subjectUri);
2413
+ if (parsed3) {
2414
+ return urlHealth(`https://smokesignal.events/${parsed3.did}/${parsed3.rkey}`);
2415
2415
  }
2416
2416
  }
2417
2417
  }
2418
2418
  return { url: null, strategy: "none" };
2419
2419
  }
2420
2420
  if (collection === "community.lexicon.calendar.event") {
2421
- const parsed2 = parseAtUri(uri);
2422
- if (parsed2) {
2423
- return recordHealth(`https://smokesignal.events/${parsed2.did}/${parsed2.rkey}`);
2421
+ const parsed3 = parseAtUri(uri);
2422
+ if (parsed3) {
2423
+ return recordHealth(`https://smokesignal.events/${parsed3.did}/${parsed3.rkey}`);
2424
2424
  }
2425
2425
  return { url: null, strategy: "none" };
2426
2426
  }
2427
2427
  if (collection === "quest.atmo.event") {
2428
- const parsed2 = parseAtUri(uri);
2429
- if (parsed2) {
2430
- return recordHealth(`https://atmo.rsvp/p/${parsed2.did}/e/${parsed2.rkey}`);
2428
+ const parsed3 = parseAtUri(uri);
2429
+ if (parsed3) {
2430
+ return recordHealth(`https://atmo.rsvp/p/${parsed3.did}/e/${parsed3.rkey}`);
2431
2431
  }
2432
2432
  return { url: null, strategy: "none" };
2433
2433
  }
2434
2434
  if (collection === "quest.atmo.checkin") {
2435
2435
  const eventUri = stringOrNull(record.event);
2436
2436
  if (eventUri) {
2437
- const parsed2 = parseAtUri(eventUri);
2438
- if (parsed2) {
2439
- return urlHealth(`https://atmo.rsvp/p/${parsed2.did}/e/${parsed2.rkey}`);
2437
+ const parsed3 = parseAtUri(eventUri);
2438
+ if (parsed3) {
2439
+ return urlHealth(`https://atmo.rsvp/p/${parsed3.did}/e/${parsed3.rkey}`);
2440
2440
  }
2441
2441
  }
2442
2442
  return { url: null, strategy: "none" };
@@ -2581,9 +2581,9 @@ function getPublisherFromSiteUrl(siteUrl) {
2581
2581
  let hostname;
2582
2582
  let homeUrl;
2583
2583
  try {
2584
- const parsed2 = new URL(siteUrl);
2585
- hostname = parsed2.hostname;
2586
- homeUrl = `${parsed2.protocol}//${parsed2.hostname}`;
2584
+ const parsed3 = new URL(siteUrl);
2585
+ hostname = parsed3.hostname;
2586
+ homeUrl = `${parsed3.protocol}//${parsed3.hostname}`;
2587
2587
  } catch {
2588
2588
  return {
2589
2589
  id: STANDARD_PUBLISHER_ID,
@@ -2602,6 +2602,312 @@ function getPublisherFromSiteUrl(siteUrl) {
2602
2602
  };
2603
2603
  }
2604
2604
 
2605
+ // src/stream/verbs.json
2606
+ var verbs_default = {
2607
+ $schema: "https://sifa.id/schemas/activity-verbs/v1.json",
2608
+ version: "1.0.0",
2609
+ updated: "2026-07-17",
2610
+ defaultVerb: "created",
2611
+ verbs: {
2612
+ "app.bsky.feed.post": "posted",
2613
+ "blue.flashes.feed.post": "posted",
2614
+ "social.psky.feed.post": "posted",
2615
+ "social.popfeed.feed.post": "posted",
2616
+ "social.popfeed.feed.note": "posted",
2617
+ "fyi.unravel.frontpage.post": "posted",
2618
+ "forum.barazo.post": "posted",
2619
+ "app.bsky.feed.repost": "reposted",
2620
+ "com.whtwnd.blog.entry": "published",
2621
+ "site.standard.document": "published",
2622
+ "computer.aetheros.page": "published",
2623
+ "link.pastesphere.snippet": "published",
2624
+ "pub.leaflet.comment": "published",
2625
+ "id.sifa.profile.presentation": "presented",
2626
+ "id.sifa.profile.presentationDelivery": "presented",
2627
+ "id.sifa.endorsement": "endorsed",
2628
+ "sh.tangled.repo": "shipped",
2629
+ "sh.tangled.repo.issue": "shipped",
2630
+ "sh.tangled.repo.pull": "shipped",
2631
+ "app.sidetrail.trail": "shipped",
2632
+ "app.sidetrail.walk": "shipped",
2633
+ "social.colibri.membership": "joined",
2634
+ "id.sifa.project.membership": "joined",
2635
+ "id.sifa.project.member": "joined",
2636
+ "community.lexicon.calendar.rsvp": "joined",
2637
+ "at.youandme.connection": "joined",
2638
+ "id.sifa.graph.connection": "joined"
2639
+ }
2640
+ };
2641
+
2642
+ // src/stream/verbs.ts
2643
+ var STREAM_VERBS = [
2644
+ "posted",
2645
+ "reposted",
2646
+ "published",
2647
+ "presented",
2648
+ "endorsed",
2649
+ "joined",
2650
+ "shipped",
2651
+ "created"
2652
+ ];
2653
+ var streamVerbSchema = zod.z.enum(STREAM_VERBS);
2654
+ var verbMapSchema = zod.z.object({
2655
+ version: zod.z.string(),
2656
+ updated: zod.z.string(),
2657
+ defaultVerb: streamVerbSchema,
2658
+ verbs: zod.z.record(zod.z.string(), streamVerbSchema)
2659
+ });
2660
+ var parsed2 = verbMapSchema.parse(verbs_default);
2661
+ var ACTIVITY_VERBS = Object.freeze(parsed2);
2662
+ function verbForCollection(collection) {
2663
+ if (!collection) return ACTIVITY_VERBS.defaultVerb;
2664
+ return ACTIVITY_VERBS.verbs[collection] ?? ACTIVITY_VERBS.defaultVerb;
2665
+ }
2666
+ function getActivityVerbsVersion() {
2667
+ return { version: ACTIVITY_VERBS.version, updated: ACTIVITY_VERBS.updated };
2668
+ }
2669
+ var rgbChannelSchema = zod.z.number().min(0).max(255);
2670
+ var rgbColorSchema = zod.z.object({
2671
+ r: rgbChannelSchema,
2672
+ g: rgbChannelSchema,
2673
+ b: rgbChannelSchema
2674
+ });
2675
+ var aspectRatioSchema = zod.z.object({
2676
+ width: zod.z.number(),
2677
+ height: zod.z.number()
2678
+ });
2679
+ var streamSourceSchema = zod.z.object({
2680
+ appId: zod.z.string(),
2681
+ label: zod.z.string(),
2682
+ color: zod.z.string()
2683
+ });
2684
+ var streamThemeSchema = zod.z.object({
2685
+ background: rgbColorSchema,
2686
+ foreground: rgbColorSchema,
2687
+ accent: rgbColorSchema
2688
+ });
2689
+ var streamMediaResolvedSchema = zod.z.object({
2690
+ url: zod.z.string(),
2691
+ alt: zod.z.string(),
2692
+ aspectRatio: aspectRatioSchema.optional(),
2693
+ mimeType: zod.z.string().optional()
2694
+ });
2695
+ var streamMediaBlobSchema = zod.z.object({
2696
+ did: zod.z.string(),
2697
+ cid: zod.z.string(),
2698
+ alt: zod.z.string(),
2699
+ aspectRatio: aspectRatioSchema.optional(),
2700
+ mimeType: zod.z.string().optional()
2701
+ });
2702
+ var streamMediaSchema = zod.z.union([
2703
+ streamMediaResolvedSchema,
2704
+ streamMediaBlobSchema
2705
+ ]);
2706
+ var streamExternalLinkSchema = zod.z.object({
2707
+ url: zod.z.string(),
2708
+ title: zod.z.string().optional(),
2709
+ thumb: zod.z.string().optional()
2710
+ });
2711
+ var streamCardBodySchema = zod.z.discriminatedUnion("kind", [
2712
+ zod.z.object({ kind: zod.z.literal("text"), text: zod.z.string() }),
2713
+ zod.z.object({ kind: zod.z.literal("media"), text: zod.z.string().optional() }),
2714
+ zod.z.object({ kind: zod.z.literal("link"), text: zod.z.string().optional() }),
2715
+ zod.z.object({
2716
+ kind: zod.z.literal("track"),
2717
+ text: zod.z.string().optional(),
2718
+ trackTitle: zod.z.string().optional(),
2719
+ artist: zod.z.string().optional()
2720
+ }),
2721
+ zod.z.object({ kind: zod.z.literal("generic"), text: zod.z.string().optional() })
2722
+ ]);
2723
+ var streamCardSubjectSchema = zod.z.discriminatedUnion("kind", [
2724
+ zod.z.object({
2725
+ kind: zod.z.literal("post"),
2726
+ post: zod.z.lazy(() => streamCardVMSchema)
2727
+ }),
2728
+ zod.z.object({
2729
+ kind: zod.z.literal("person"),
2730
+ did: zod.z.string(),
2731
+ handle: zod.z.string().optional(),
2732
+ displayName: zod.z.string().optional(),
2733
+ avatar: zod.z.string().optional()
2734
+ }),
2735
+ zod.z.object({
2736
+ kind: zod.z.literal("record"),
2737
+ uri: zod.z.string(),
2738
+ title: zod.z.string().optional()
2739
+ })
2740
+ ]);
2741
+ var streamCardVMSchema = zod.z.lazy(
2742
+ () => zod.z.object({
2743
+ uri: zod.z.string(),
2744
+ cid: zod.z.string(),
2745
+ verb: streamVerbSchema,
2746
+ source: streamSourceSchema,
2747
+ tier: zod.z.enum(["creation", "action", "filtered"]),
2748
+ timestamp: zod.z.string(),
2749
+ title: zod.z.string(),
2750
+ body: streamCardBodySchema.optional(),
2751
+ media: zod.z.array(streamMediaSchema).optional(),
2752
+ externalLink: streamExternalLinkSchema.optional(),
2753
+ theme: streamThemeSchema.optional(),
2754
+ subject: zod.z.lazy(() => streamCardSubjectSchema).optional()
2755
+ })
2756
+ );
2757
+
2758
+ // src/stream/to-stream-card-vm.ts
2759
+ var DEFAULT_SOURCE_COLOR = "slate";
2760
+ function asRecord(value) {
2761
+ return value !== null && typeof value === "object" ? value : null;
2762
+ }
2763
+ function asNonEmptyString(value) {
2764
+ return typeof value === "string" && value.length > 0 ? value : void 0;
2765
+ }
2766
+ function didFromUri(uri) {
2767
+ const match = uri.match(/^at:\/\/(did:[^/]+)\//);
2768
+ return match?.[1];
2769
+ }
2770
+ function blobCid(blob) {
2771
+ const rec = asRecord(blob);
2772
+ if (!rec) return void 0;
2773
+ const ref = rec.ref;
2774
+ if (typeof ref === "string") return ref;
2775
+ const link2 = asRecord(ref)?.["$link"];
2776
+ return typeof link2 === "string" ? link2 : void 0;
2777
+ }
2778
+ function aspectRatio(value) {
2779
+ const rec = asRecord(value);
2780
+ const width = rec?.width;
2781
+ const height = rec?.height;
2782
+ if (typeof width === "number" && typeof height === "number") return { width, height };
2783
+ return void 0;
2784
+ }
2785
+ function buildSource(item, options) {
2786
+ return {
2787
+ appId: item.appId,
2788
+ label: item.appName,
2789
+ color: options.resolveSourceColor?.(item.appId) ?? DEFAULT_SOURCE_COLOR
2790
+ };
2791
+ }
2792
+ var TITLE_BY_VERB = {
2793
+ posted: (label) => `Posted on ${label}`,
2794
+ reposted: () => "Reposted a post",
2795
+ published: (label) => `Published on ${label}`,
2796
+ presented: () => "Gave a presentation",
2797
+ endorsed: () => "Wrote an endorsement",
2798
+ joined: (label) => `Joined ${label}`,
2799
+ shipped: (label) => `Shipped on ${label}`,
2800
+ created: (label) => `Created a record on ${label}`
2801
+ };
2802
+ function buildTitle(verb, label) {
2803
+ return TITLE_BY_VERB[verb](label);
2804
+ }
2805
+ function readTheme(record) {
2806
+ const theme = asRecord(record?.publicationTheme ?? record?.theme);
2807
+ if (!theme) return void 0;
2808
+ const { background, foreground, accent } = theme;
2809
+ if (isValidRgbColor(background) && isValidRgbColor(foreground) && isValidRgbColor(accent)) {
2810
+ return { background, foreground, accent };
2811
+ }
2812
+ return void 0;
2813
+ }
2814
+ function bskyImages(embed, did) {
2815
+ const images = embed.images;
2816
+ if (!Array.isArray(images)) return [];
2817
+ const out = [];
2818
+ for (const raw of images) {
2819
+ const img = asRecord(raw);
2820
+ if (!img) continue;
2821
+ const cid = blobCid(img.image);
2822
+ if (!cid) continue;
2823
+ const media = { did, cid, alt: asNonEmptyString(img.alt) ?? "" };
2824
+ const ratio = aspectRatio(img.aspectRatio);
2825
+ if (ratio) media.aspectRatio = ratio;
2826
+ const mimeType = asNonEmptyString(asRecord(img.image)?.mimeType);
2827
+ if (mimeType) media.mimeType = mimeType;
2828
+ out.push(media);
2829
+ }
2830
+ return out;
2831
+ }
2832
+ function bskyExternal(embed) {
2833
+ const external = asRecord(embed.external);
2834
+ if (!external) return void 0;
2835
+ const url = asNonEmptyString(external.uri);
2836
+ if (!url) return void 0;
2837
+ const link2 = { url };
2838
+ const title = asNonEmptyString(external.title);
2839
+ if (title) link2.title = title;
2840
+ return link2;
2841
+ }
2842
+ function bskyEmbedContent(record, did) {
2843
+ const embed = asRecord(record.embed);
2844
+ if (!embed) return {};
2845
+ const type = asNonEmptyString(embed["$type"]);
2846
+ const target = type === "app.bsky.embed.recordWithMedia" ? asRecord(embed.media) : embed;
2847
+ if (!target) return {};
2848
+ if (Array.isArray(target.images)) {
2849
+ const media = bskyImages(target, did);
2850
+ return media.length > 0 ? { media } : {};
2851
+ }
2852
+ if (target.external != null) {
2853
+ const externalLink = bskyExternal(target);
2854
+ return externalLink ? { externalLink } : {};
2855
+ }
2856
+ return {};
2857
+ }
2858
+ function applyBskyPost(vm, item, record) {
2859
+ if (!record) {
2860
+ vm.body = { kind: "generic" };
2861
+ return vm;
2862
+ }
2863
+ const did = didFromUri(item.uri);
2864
+ const text = asNonEmptyString(record.text);
2865
+ const { media, externalLink } = did ? bskyEmbedContent(record, did) : {};
2866
+ if (media) vm.media = media;
2867
+ if (externalLink) vm.externalLink = externalLink;
2868
+ let body;
2869
+ if (text) body = { kind: "text", text };
2870
+ else if (vm.media) body = { kind: "media" };
2871
+ else if (vm.externalLink) body = { kind: "link" };
2872
+ else body = { kind: "generic" };
2873
+ vm.body = body;
2874
+ return vm;
2875
+ }
2876
+ function toStreamCardVM(item, options = {}) {
2877
+ const verb = verbForCollection(item.collection);
2878
+ const source = buildSource(item, options);
2879
+ const record = asRecord(item.record);
2880
+ const timestamp = (record ? asNonEmptyString(record.createdAt) : void 0) ?? item.indexedAt;
2881
+ const vm = {
2882
+ uri: item.uri,
2883
+ cid: item.cid,
2884
+ verb,
2885
+ source,
2886
+ tier: getActivityTier(item.collection),
2887
+ timestamp,
2888
+ title: buildTitle(verb, source.label)
2889
+ };
2890
+ const theme = readTheme(record);
2891
+ if (theme) vm.theme = theme;
2892
+ if (item.subject) {
2893
+ vm.subject = { kind: "post", post: toStreamCardVM(item.subject, options) };
2894
+ }
2895
+ if (item.collection === "app.bsky.feed.post") {
2896
+ return applyBskyPost(vm, item, record);
2897
+ }
2898
+ vm.body = { kind: "generic" };
2899
+ return vm;
2900
+ }
2901
+ function toStreamCardVMs(items, options = {}) {
2902
+ const out = [];
2903
+ for (const item of items) {
2904
+ if (isVisibleActivityItem(item.collection, item.record)) {
2905
+ out.push(toStreamCardVM(item, options));
2906
+ }
2907
+ }
2908
+ return out;
2909
+ }
2910
+
2605
2911
  // src/logic/profile-completeness.ts
2606
2912
  var COMPLETENESS_MAX_SCORE = 6;
2607
2913
  function completenessScore(c) {
@@ -3217,8 +3523,8 @@ function encodeFeedCursor(cursor) {
3217
3523
  }
3218
3524
  function decodeFeedCursor(encoded) {
3219
3525
  const json = fromBase64Url(encoded);
3220
- const parsed2 = JSON.parse(json);
3221
- return FeedCursorSchema.parse(parsed2);
3526
+ const parsed3 = JSON.parse(json);
3527
+ return FeedCursorSchema.parse(parsed3);
3222
3528
  }
3223
3529
  var ProfileCertificationRecordSchema = zod.z.object({
3224
3530
  name: zod.z.string().min(1).refine(maxGraphemes(100)).max(1e3),
@@ -3432,9 +3738,10 @@ var ProfileVolunteeringRecordSchema = zod.z.object({
3432
3738
  });
3433
3739
 
3434
3740
  // src/index.ts
3435
- var SIFA_SDK_VERSION = "0.12.7";
3741
+ var SIFA_SDK_VERSION = "0.12.9";
3436
3742
 
3437
3743
  exports.ACTIVITY_TIERS = ACTIVITY_TIERS;
3744
+ exports.ACTIVITY_VERBS = ACTIVITY_VERBS;
3438
3745
  exports.ACTIVITY_VISIBILITY_RULES = ACTIVITY_VISIBILITY_RULES;
3439
3746
  exports.ADULT_CONTENT_LABELS = ADULT_CONTENT_LABELS;
3440
3747
  exports.ALL_SECTIONS = ALL_SECTIONS;
@@ -3521,6 +3828,7 @@ exports.SECTION_LABELS = SECTION_LABELS;
3521
3828
  exports.SIFA_SDK_VERSION = SIFA_SDK_VERSION;
3522
3829
  exports.SKILL_CATEGORIES = SKILL_CATEGORIES;
3523
3830
  exports.STANDARD_PUBLISHER_ID = STANDARD_PUBLISHER_ID;
3831
+ exports.STREAM_VERBS = STREAM_VERBS;
3524
3832
  exports.SifaFeedItemSchema = SifaFeedItemSchema;
3525
3833
  exports.VERIFICATION_PROVIDERS = VERIFICATION_PROVIDERS;
3526
3834
  exports.WORKPLACE_TYPE_LABELS = WORKPLACE_TYPE_LABELS;
@@ -3558,6 +3866,7 @@ exports.formatRelativeTime = formatRelativeTime;
3558
3866
  exports.formatTimelineDate = formatTimelineDate;
3559
3867
  exports.getActivityTaxonomyVersion = getActivityTaxonomyVersion;
3560
3868
  exports.getActivityTier = getActivityTier;
3869
+ exports.getActivityVerbsVersion = getActivityVerbsVersion;
3561
3870
  exports.getAppCategoryIcon = getAppCategoryIcon;
3562
3871
  exports.getAppIdForCollection = getAppIdForCollection;
3563
3872
  exports.getArtifactLinkKindLabel = getArtifactLinkKindLabel;
@@ -3648,11 +3957,22 @@ exports.sortLanguagesByProficiency = sortLanguagesByProficiency;
3648
3957
  exports.sortPositions = sortPositions;
3649
3958
  exports.sortProjects = sortProjects;
3650
3959
  exports.sortPublications = sortPublications;
3960
+ exports.streamCardBodySchema = streamCardBodySchema;
3961
+ exports.streamCardSubjectSchema = streamCardSubjectSchema;
3962
+ exports.streamCardVMSchema = streamCardVMSchema;
3963
+ exports.streamExternalLinkSchema = streamExternalLinkSchema;
3964
+ exports.streamMediaSchema = streamMediaSchema;
3965
+ exports.streamSourceSchema = streamSourceSchema;
3966
+ exports.streamThemeSchema = streamThemeSchema;
3967
+ exports.streamVerbSchema = streamVerbSchema;
3651
3968
  exports.stripHtmlToText = stripHtmlToText;
3652
3969
  exports.strongRefSchema = strongRefSchema;
3653
3970
  exports.summarizePresentationDeliveries = summarizePresentationDeliveries;
3971
+ exports.toStreamCardVM = toStreamCardVM;
3972
+ exports.toStreamCardVMs = toStreamCardVMs;
3654
3973
  exports.truncateGraphemes = truncateGraphemes;
3655
3974
  exports.uriSchema = uriSchema;
3975
+ exports.verbForCollection = verbForCollection;
3656
3976
  exports.visibleItems = visibleItems;
3657
3977
  //# sourceMappingURL=index.cjs.map
3658
3978
  //# sourceMappingURL=index.cjs.map