@singi-labs/sifa-sdk 0.12.14 → 0.12.16

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
@@ -805,11 +805,13 @@ var PLATFORM_LABELS = {
805
805
  keyoxide: "Keyoxide"
806
806
  };
807
807
  var PLATFORM_TOKEN_PREFIX = "id.sifa.defs#platform";
808
+ var PLATFORM_ALIASES = {
809
+ activitypub: "fediverse",
810
+ mastodon: "fediverse"
811
+ };
808
812
  function normalizePlatformId(platform) {
809
- if (platform.startsWith(PLATFORM_TOKEN_PREFIX)) {
810
- return platform.slice(PLATFORM_TOKEN_PREFIX.length).toLowerCase();
811
- }
812
- return platform;
813
+ const code = platform.startsWith(PLATFORM_TOKEN_PREFIX) ? platform.slice(PLATFORM_TOKEN_PREFIX.length).toLowerCase() : platform;
814
+ return PLATFORM_ALIASES[code.toLowerCase()] ?? code;
813
815
  }
814
816
  function isKnownPlatform(platform) {
815
817
  return platform in PLATFORM_LABELS;
@@ -3011,6 +3013,7 @@ var streamCardVMSchema = zod.z.lazy(
3011
3013
  tier: zod.z.enum(["creation", "action", "filtered"]),
3012
3014
  timestamp: zod.z.string(),
3013
3015
  title: zod.z.string(),
3016
+ sourceUrl: zod.z.string().optional(),
3014
3017
  body: streamCardBodySchema.optional(),
3015
3018
  media: zod.z.array(streamMediaSchema).optional(),
3016
3019
  externalLink: streamExternalLinkSchema.optional(),
@@ -3186,6 +3189,20 @@ var TITLE_BY_VERB = {
3186
3189
  function buildTitle(verb, label) {
3187
3190
  return TITLE_BY_VERB[verb](label);
3188
3191
  }
3192
+ function resolveSourceUrl(item, record) {
3193
+ const authorDid = didFromUri(item.uri);
3194
+ if (!authorDid) return void 0;
3195
+ const authorHandle = asNonEmptyString(item.authorHandle) ?? asNonEmptyString(record.handle);
3196
+ const url = resolveCardUrl({
3197
+ collection: item.collection,
3198
+ record,
3199
+ uri: item.uri,
3200
+ rkey: item.rkey,
3201
+ authorDid,
3202
+ ...authorHandle ? { authorHandle } : {}
3203
+ });
3204
+ return url && /^https?:\/\//i.test(url) ? url : void 0;
3205
+ }
3189
3206
  function readTheme(record) {
3190
3207
  const theme = asRecord(record?.publicationTheme ?? record?.theme);
3191
3208
  if (!theme) return void 0;
@@ -3683,6 +3700,10 @@ function toStreamCardVM(item, options = {}) {
3683
3700
  };
3684
3701
  const theme = readTheme(record);
3685
3702
  if (theme) vm.theme = theme;
3703
+ if (record) {
3704
+ const sourceUrl = resolveSourceUrl(item, record);
3705
+ if (sourceUrl) vm.sourceUrl = sourceUrl;
3706
+ }
3686
3707
  if (item.subject) {
3687
3708
  vm.subject = { kind: "post", post: toStreamCardVM(item.subject, options) };
3688
3709
  }
@@ -4544,7 +4565,7 @@ var ProfileVolunteeringRecordSchema = zod.z.object({
4544
4565
  });
4545
4566
 
4546
4567
  // src/index.ts
4547
- var SIFA_SDK_VERSION = "0.12.14";
4568
+ var SIFA_SDK_VERSION = "0.12.16";
4548
4569
 
4549
4570
  exports.ACTIVITY_TIERS = ACTIVITY_TIERS;
4550
4571
  exports.ACTIVITY_VERBS = ACTIVITY_VERBS;