@singi-labs/sifa-sdk 0.9.13 → 0.9.14

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.d.cts CHANGED
@@ -445,6 +445,36 @@ declare function getAppIdForCollection(collection: string): string;
445
445
  */
446
446
  declare function resolveCardUrl(item: ActivityItemForUrl): string | null;
447
447
 
448
+ /**
449
+ * Per-collection visibility rules for activity items.
450
+ *
451
+ * These rules express "this record has nothing meaningful to render as a card"
452
+ * — e.g. a BookHive shelf-add with no review/stars, or a BeaconBits pin with
453
+ * no shout. They are a UX/card concern, distinct from the api-side blocklists
454
+ * in sifa-api/atproto-app-registry that exclude whole collections (likes,
455
+ * follows, games) or filter spammy record shapes (empty quote posts).
456
+ *
457
+ * Used in two places:
458
+ * - sifa-api's activity feed pagination, so a page-of-N returns N visible
459
+ * items rather than silently-dropped placeholders.
460
+ * - sifa-web's activity-feed component (and as defense-in-depth in the card
461
+ * components themselves), so the client never relies on a stale api.
462
+ *
463
+ * Adding a new rule = one PR to this file. Unknown collections default to
464
+ * visible, so the rule set is purely additive — adding a rule can only ever
465
+ * hide more, never expose what was hidden before.
466
+ */
467
+ type VisibilityPredicate = (record: Record<string, unknown>) => boolean;
468
+ declare const ACTIVITY_VISIBILITY_RULES: Readonly<Record<string, VisibilityPredicate>>;
469
+ /**
470
+ * Return true if the activity item should render a card in the timeline.
471
+ * Records that fail the rule for their collection are dropped silently —
472
+ * they exist in the user's PDS but carry no card-worthy content.
473
+ *
474
+ * Unknown collections (no registered rule) default to visible.
475
+ */
476
+ declare function isVisibleActivityItem(collection: string, record: unknown): boolean;
477
+
448
478
  /**
449
479
  * Profile completeness scoring.
450
480
  *
@@ -552,4 +582,4 @@ declare function pickPrimaryPosition<T extends PrimaryPositionCandidate>(positio
552
582
  */
553
583
  declare const SIFA_SDK_VERSION: string;
554
584
 
555
- export { ACTIVITY_TIERS, APP_URL_PATTERNS, type ActivityItemForUrl, type ActivityTaxonomy, type ActivityTier, type AppUrlPatterns, CATEGORY_LABELS, CATEGORY_ORDER, COLLECTION_TO_APP, COMPLETENESS_MAX_SCORE, CONTINENTS, COUNTRIES, type ContinentCode, DIMENSIONS_MAX_SCORE, type DimensionKey, type DimensionMap, EMPLOYMENT_TYPE_GROUPS, EMPLOYMENT_TYPE_LABELS, type EmploymentTypeGroup, type EmploymentTypeOption, INDUSTRY_OPTIONS, type IndustryOption, type LexiconEntry, LocationValue, MIN_SKILLS, type MergedProfileSkill, OPEN_TO_OPTIONS, type OpenToOption, PLATFORM_LABELS, PLATFORM_OPTIONS, type PdsProvider, PdsProviderInfo, type PlatformId, type PrimaryPositionCandidate, Profile, type ProfileCompletion, type ProfileDimensionInputs, ProfileSkill, type RgbColor, SIFA_SDK_VERSION, SKILL_CATEGORIES, type SkillCategory, type TierMeta, WORKPLACE_TYPE_LABELS, WORKPLACE_TYPE_OPTIONS, type WorkplaceTypeOption, certDateExtractor, completenessPercent, completenessScore, contrastRatio, countFilledDimensions, countryCodeToFlag, dateRangeExtractor, dedupeSkills, detectPdsProvider, dimensionsFromInputs, findIndustry, formatDistanceToNow, formatLocation, formatRelativeTime, getActivityTaxonomyVersion, getActivityTier, getAppIdForCollection, getContinent, getDisplayLabel, getEmploymentTypeLabel, getFaviconUrl, getFilledDimensionsMap, getHandleStem, getIndustryLabelKey, getLexiconEntry, getOpenToLabelKey, getPdsDisplayName, getPlatformLabel, getTierMeta, getWorkplaceTypeLabel, groupSkillsByCategory, isKnownPlatform, isValidRgbColor, lexiconDateExtractor, limitCombiningMarks, meetsContrastAA, parseLocationString, pdsProviderFromApi, pickPrimaryPosition, profileToDimensionInputs, relativeLuminance, resolveCardUrl, rgbToString, sanitizeDisplayText, sanitizeHandleInput, singleDateExtractor, sortByDateDesc, truncateGraphemes };
585
+ export { ACTIVITY_TIERS, ACTIVITY_VISIBILITY_RULES, APP_URL_PATTERNS, type ActivityItemForUrl, type ActivityTaxonomy, type ActivityTier, type AppUrlPatterns, CATEGORY_LABELS, CATEGORY_ORDER, COLLECTION_TO_APP, COMPLETENESS_MAX_SCORE, CONTINENTS, COUNTRIES, type ContinentCode, DIMENSIONS_MAX_SCORE, type DimensionKey, type DimensionMap, EMPLOYMENT_TYPE_GROUPS, EMPLOYMENT_TYPE_LABELS, type EmploymentTypeGroup, type EmploymentTypeOption, INDUSTRY_OPTIONS, type IndustryOption, type LexiconEntry, LocationValue, MIN_SKILLS, type MergedProfileSkill, OPEN_TO_OPTIONS, type OpenToOption, PLATFORM_LABELS, PLATFORM_OPTIONS, type PdsProvider, PdsProviderInfo, type PlatformId, type PrimaryPositionCandidate, Profile, type ProfileCompletion, type ProfileDimensionInputs, ProfileSkill, type RgbColor, SIFA_SDK_VERSION, SKILL_CATEGORIES, type SkillCategory, type TierMeta, WORKPLACE_TYPE_LABELS, WORKPLACE_TYPE_OPTIONS, type WorkplaceTypeOption, certDateExtractor, completenessPercent, completenessScore, contrastRatio, countFilledDimensions, countryCodeToFlag, dateRangeExtractor, dedupeSkills, detectPdsProvider, dimensionsFromInputs, findIndustry, formatDistanceToNow, formatLocation, formatRelativeTime, getActivityTaxonomyVersion, getActivityTier, getAppIdForCollection, getContinent, getDisplayLabel, getEmploymentTypeLabel, getFaviconUrl, getFilledDimensionsMap, getHandleStem, getIndustryLabelKey, getLexiconEntry, getOpenToLabelKey, getPdsDisplayName, getPlatformLabel, getTierMeta, getWorkplaceTypeLabel, groupSkillsByCategory, isKnownPlatform, isValidRgbColor, isVisibleActivityItem, lexiconDateExtractor, limitCombiningMarks, meetsContrastAA, parseLocationString, pdsProviderFromApi, pickPrimaryPosition, profileToDimensionInputs, relativeLuminance, resolveCardUrl, rgbToString, sanitizeDisplayText, sanitizeHandleInput, singleDateExtractor, sortByDateDesc, truncateGraphemes };
package/dist/index.d.ts CHANGED
@@ -445,6 +445,36 @@ declare function getAppIdForCollection(collection: string): string;
445
445
  */
446
446
  declare function resolveCardUrl(item: ActivityItemForUrl): string | null;
447
447
 
448
+ /**
449
+ * Per-collection visibility rules for activity items.
450
+ *
451
+ * These rules express "this record has nothing meaningful to render as a card"
452
+ * — e.g. a BookHive shelf-add with no review/stars, or a BeaconBits pin with
453
+ * no shout. They are a UX/card concern, distinct from the api-side blocklists
454
+ * in sifa-api/atproto-app-registry that exclude whole collections (likes,
455
+ * follows, games) or filter spammy record shapes (empty quote posts).
456
+ *
457
+ * Used in two places:
458
+ * - sifa-api's activity feed pagination, so a page-of-N returns N visible
459
+ * items rather than silently-dropped placeholders.
460
+ * - sifa-web's activity-feed component (and as defense-in-depth in the card
461
+ * components themselves), so the client never relies on a stale api.
462
+ *
463
+ * Adding a new rule = one PR to this file. Unknown collections default to
464
+ * visible, so the rule set is purely additive — adding a rule can only ever
465
+ * hide more, never expose what was hidden before.
466
+ */
467
+ type VisibilityPredicate = (record: Record<string, unknown>) => boolean;
468
+ declare const ACTIVITY_VISIBILITY_RULES: Readonly<Record<string, VisibilityPredicate>>;
469
+ /**
470
+ * Return true if the activity item should render a card in the timeline.
471
+ * Records that fail the rule for their collection are dropped silently —
472
+ * they exist in the user's PDS but carry no card-worthy content.
473
+ *
474
+ * Unknown collections (no registered rule) default to visible.
475
+ */
476
+ declare function isVisibleActivityItem(collection: string, record: unknown): boolean;
477
+
448
478
  /**
449
479
  * Profile completeness scoring.
450
480
  *
@@ -552,4 +582,4 @@ declare function pickPrimaryPosition<T extends PrimaryPositionCandidate>(positio
552
582
  */
553
583
  declare const SIFA_SDK_VERSION: string;
554
584
 
555
- export { ACTIVITY_TIERS, APP_URL_PATTERNS, type ActivityItemForUrl, type ActivityTaxonomy, type ActivityTier, type AppUrlPatterns, CATEGORY_LABELS, CATEGORY_ORDER, COLLECTION_TO_APP, COMPLETENESS_MAX_SCORE, CONTINENTS, COUNTRIES, type ContinentCode, DIMENSIONS_MAX_SCORE, type DimensionKey, type DimensionMap, EMPLOYMENT_TYPE_GROUPS, EMPLOYMENT_TYPE_LABELS, type EmploymentTypeGroup, type EmploymentTypeOption, INDUSTRY_OPTIONS, type IndustryOption, type LexiconEntry, LocationValue, MIN_SKILLS, type MergedProfileSkill, OPEN_TO_OPTIONS, type OpenToOption, PLATFORM_LABELS, PLATFORM_OPTIONS, type PdsProvider, PdsProviderInfo, type PlatformId, type PrimaryPositionCandidate, Profile, type ProfileCompletion, type ProfileDimensionInputs, ProfileSkill, type RgbColor, SIFA_SDK_VERSION, SKILL_CATEGORIES, type SkillCategory, type TierMeta, WORKPLACE_TYPE_LABELS, WORKPLACE_TYPE_OPTIONS, type WorkplaceTypeOption, certDateExtractor, completenessPercent, completenessScore, contrastRatio, countFilledDimensions, countryCodeToFlag, dateRangeExtractor, dedupeSkills, detectPdsProvider, dimensionsFromInputs, findIndustry, formatDistanceToNow, formatLocation, formatRelativeTime, getActivityTaxonomyVersion, getActivityTier, getAppIdForCollection, getContinent, getDisplayLabel, getEmploymentTypeLabel, getFaviconUrl, getFilledDimensionsMap, getHandleStem, getIndustryLabelKey, getLexiconEntry, getOpenToLabelKey, getPdsDisplayName, getPlatformLabel, getTierMeta, getWorkplaceTypeLabel, groupSkillsByCategory, isKnownPlatform, isValidRgbColor, lexiconDateExtractor, limitCombiningMarks, meetsContrastAA, parseLocationString, pdsProviderFromApi, pickPrimaryPosition, profileToDimensionInputs, relativeLuminance, resolveCardUrl, rgbToString, sanitizeDisplayText, sanitizeHandleInput, singleDateExtractor, sortByDateDesc, truncateGraphemes };
585
+ export { ACTIVITY_TIERS, ACTIVITY_VISIBILITY_RULES, APP_URL_PATTERNS, type ActivityItemForUrl, type ActivityTaxonomy, type ActivityTier, type AppUrlPatterns, CATEGORY_LABELS, CATEGORY_ORDER, COLLECTION_TO_APP, COMPLETENESS_MAX_SCORE, CONTINENTS, COUNTRIES, type ContinentCode, DIMENSIONS_MAX_SCORE, type DimensionKey, type DimensionMap, EMPLOYMENT_TYPE_GROUPS, EMPLOYMENT_TYPE_LABELS, type EmploymentTypeGroup, type EmploymentTypeOption, INDUSTRY_OPTIONS, type IndustryOption, type LexiconEntry, LocationValue, MIN_SKILLS, type MergedProfileSkill, OPEN_TO_OPTIONS, type OpenToOption, PLATFORM_LABELS, PLATFORM_OPTIONS, type PdsProvider, PdsProviderInfo, type PlatformId, type PrimaryPositionCandidate, Profile, type ProfileCompletion, type ProfileDimensionInputs, ProfileSkill, type RgbColor, SIFA_SDK_VERSION, SKILL_CATEGORIES, type SkillCategory, type TierMeta, WORKPLACE_TYPE_LABELS, WORKPLACE_TYPE_OPTIONS, type WorkplaceTypeOption, certDateExtractor, completenessPercent, completenessScore, contrastRatio, countFilledDimensions, countryCodeToFlag, dateRangeExtractor, dedupeSkills, detectPdsProvider, dimensionsFromInputs, findIndustry, formatDistanceToNow, formatLocation, formatRelativeTime, getActivityTaxonomyVersion, getActivityTier, getAppIdForCollection, getContinent, getDisplayLabel, getEmploymentTypeLabel, getFaviconUrl, getFilledDimensionsMap, getHandleStem, getIndustryLabelKey, getLexiconEntry, getOpenToLabelKey, getPdsDisplayName, getPlatformLabel, getTierMeta, getWorkplaceTypeLabel, groupSkillsByCategory, isKnownPlatform, isValidRgbColor, isVisibleActivityItem, lexiconDateExtractor, limitCombiningMarks, meetsContrastAA, parseLocationString, pdsProviderFromApi, pickPrimaryPosition, profileToDimensionInputs, relativeLuminance, resolveCardUrl, rgbToString, sanitizeDisplayText, sanitizeHandleInput, singleDateExtractor, sortByDateDesc, truncateGraphemes };
package/dist/index.js CHANGED
@@ -1598,6 +1598,43 @@ function resolveCardUrl(item) {
1598
1598
  return patternUrl(appId, { handle: authorHandle, did: authorDid, rkey }, collection);
1599
1599
  }
1600
1600
 
1601
+ // src/cards/visibility.ts
1602
+ function isNonEmptyString(value) {
1603
+ return typeof value === "string" && value.trim().length > 0;
1604
+ }
1605
+ function bookhiveHasOpinion(record) {
1606
+ const review = typeof record.review === "string" ? record.review.trim() : "";
1607
+ const stars = typeof record.stars === "number" ? record.stars : 0;
1608
+ return review.length > 0 || stars > 0;
1609
+ }
1610
+ function beaconbitsHasContent(record) {
1611
+ return isNonEmptyString(record.shout) || record.postRef != null;
1612
+ }
1613
+ function marginBookmarkHasSource(record) {
1614
+ return isNonEmptyString(record.source);
1615
+ }
1616
+ function marginAnnotationHasBody(record) {
1617
+ const body = record.body;
1618
+ if (typeof body === "string") return body.trim().length > 0;
1619
+ if (body != null && typeof body === "object") {
1620
+ const value = body.value;
1621
+ return typeof value === "string" && value.trim().length > 0;
1622
+ }
1623
+ return false;
1624
+ }
1625
+ var ACTIVITY_VISIBILITY_RULES = Object.freeze({
1626
+ "buzz.bookhive.book": bookhiveHasOpinion,
1627
+ "app.beaconbits.beacon": beaconbitsHasContent,
1628
+ "at.margin.bookmark": marginBookmarkHasSource,
1629
+ "at.margin.annotation": marginAnnotationHasBody
1630
+ });
1631
+ function isVisibleActivityItem(collection, record) {
1632
+ if (record === null || typeof record !== "object") return false;
1633
+ const rule = ACTIVITY_VISIBILITY_RULES[collection];
1634
+ if (!rule) return true;
1635
+ return rule(record);
1636
+ }
1637
+
1601
1638
  // src/logic/profile-completeness.ts
1602
1639
  var COMPLETENESS_MAX_SCORE = 6;
1603
1640
  function completenessScore(c) {
@@ -1828,8 +1865,8 @@ var ProfileVolunteeringRecordSchema = z.object({
1828
1865
  });
1829
1866
 
1830
1867
  // src/index.ts
1831
- var SIFA_SDK_VERSION = "0.9.13";
1868
+ var SIFA_SDK_VERSION = "0.9.14";
1832
1869
 
1833
- export { ACTIVITY_TIERS, APP_URL_PATTERNS, CATEGORY_LABELS, CATEGORY_ORDER, COLLECTION_TO_APP, COMPLETENESS_MAX_SCORE, CONTINENTS, COUNTRIES, DIMENSIONS_MAX_SCORE, EMPLOYMENT_TYPE_GROUPS, EMPLOYMENT_TYPE_LABELS, EndorsementConfirmationRecordSchema, EndorsementRecordSchema, GraphFollowRecordSchema, INDUSTRY_OPTIONS, MIN_SKILLS, OPEN_TO_OPTIONS, PLATFORM_LABELS, PLATFORM_OPTIONS, ProfileCertificationRecordSchema, ProfileCourseRecordSchema, ProfileEducationRecordSchema, ProfileExternalAccountRecordSchema, ProfileHonorRecordSchema, ProfileLanguageRecordSchema, ProfilePositionRecordSchema, ProfileProjectRecordSchema, ProfilePublicationRecordSchema, ProfileSelfRecordSchema, ProfileSkillRecordSchema, ProfileVolunteeringRecordSchema, PublicationAuthorSchema, SIFA_SDK_VERSION, SKILL_CATEGORIES, WORKPLACE_TYPE_LABELS, WORKPLACE_TYPE_OPTIONS, atUriSchema, certDateExtractor, cidSchema, completenessPercent, completenessScore, contrastRatio, countFilledDimensions, countryCodeToFlag, dateRangeExtractor, datetimeSchema, dedupeSkills, detectPdsProvider, didSchema, dimensionsFromInputs, findIndustry, formatDistanceToNow, formatLocation, formatRelativeTime, getActivityTaxonomyVersion, getActivityTier, getAppIdForCollection, getContinent, getDisplayLabel, getEmploymentTypeLabel, getFaviconUrl, getFilledDimensionsMap, getHandleStem, getIndustryLabelKey, getLexiconEntry, getOpenToLabelKey, getPdsDisplayName, getPlatformLabel, getTierMeta, getWorkplaceTypeLabel, groupSkillsByCategory, isKnownPlatform, isValidRgbColor, languageTagSchema, lexiconDateExtractor, limitCombiningMarks, maxGraphemes, meetsContrastAA, parseLocationString, pdsProviderFromApi, pickPrimaryPosition, profileToDimensionInputs, relativeLuminance, resolveCardUrl, rgbToString, sanitizeDisplayText, sanitizeHandleInput, selfLabelsSchema, singleDateExtractor, sortByDateDesc, strongRefSchema, truncateGraphemes, uriSchema };
1870
+ export { ACTIVITY_TIERS, ACTIVITY_VISIBILITY_RULES, APP_URL_PATTERNS, CATEGORY_LABELS, CATEGORY_ORDER, COLLECTION_TO_APP, COMPLETENESS_MAX_SCORE, CONTINENTS, COUNTRIES, DIMENSIONS_MAX_SCORE, EMPLOYMENT_TYPE_GROUPS, EMPLOYMENT_TYPE_LABELS, EndorsementConfirmationRecordSchema, EndorsementRecordSchema, GraphFollowRecordSchema, INDUSTRY_OPTIONS, MIN_SKILLS, OPEN_TO_OPTIONS, PLATFORM_LABELS, PLATFORM_OPTIONS, ProfileCertificationRecordSchema, ProfileCourseRecordSchema, ProfileEducationRecordSchema, ProfileExternalAccountRecordSchema, ProfileHonorRecordSchema, ProfileLanguageRecordSchema, ProfilePositionRecordSchema, ProfileProjectRecordSchema, ProfilePublicationRecordSchema, ProfileSelfRecordSchema, ProfileSkillRecordSchema, ProfileVolunteeringRecordSchema, PublicationAuthorSchema, SIFA_SDK_VERSION, SKILL_CATEGORIES, WORKPLACE_TYPE_LABELS, WORKPLACE_TYPE_OPTIONS, atUriSchema, certDateExtractor, cidSchema, completenessPercent, completenessScore, contrastRatio, countFilledDimensions, countryCodeToFlag, dateRangeExtractor, datetimeSchema, dedupeSkills, detectPdsProvider, didSchema, dimensionsFromInputs, findIndustry, formatDistanceToNow, formatLocation, formatRelativeTime, getActivityTaxonomyVersion, getActivityTier, getAppIdForCollection, getContinent, getDisplayLabel, getEmploymentTypeLabel, getFaviconUrl, getFilledDimensionsMap, getHandleStem, getIndustryLabelKey, getLexiconEntry, getOpenToLabelKey, getPdsDisplayName, getPlatformLabel, getTierMeta, getWorkplaceTypeLabel, groupSkillsByCategory, isKnownPlatform, isValidRgbColor, isVisibleActivityItem, languageTagSchema, lexiconDateExtractor, limitCombiningMarks, maxGraphemes, meetsContrastAA, parseLocationString, pdsProviderFromApi, pickPrimaryPosition, profileToDimensionInputs, relativeLuminance, resolveCardUrl, rgbToString, sanitizeDisplayText, sanitizeHandleInput, selfLabelsSchema, singleDateExtractor, sortByDateDesc, strongRefSchema, truncateGraphemes, uriSchema };
1834
1871
  //# sourceMappingURL=index.js.map
1835
1872
  //# sourceMappingURL=index.js.map