@singi-labs/sifa-sdk 0.12.18 → 0.12.20

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
@@ -2828,6 +2828,12 @@ var streamSourceSchema = zod.z.object({
2828
2828
  label: zod.z.string(),
2829
2829
  color: zod.z.string()
2830
2830
  });
2831
+ var streamAuthorSchema = zod.z.object({
2832
+ did: zod.z.string().optional(),
2833
+ handle: zod.z.string().optional(),
2834
+ displayName: zod.z.string().optional(),
2835
+ avatar: zod.z.string().optional()
2836
+ });
2831
2837
  var streamThemeSchema = zod.z.object({
2832
2838
  background: rgbColorSchema,
2833
2839
  foreground: rgbColorSchema,
@@ -3010,6 +3016,7 @@ var streamCardVMSchema = zod.z.lazy(
3010
3016
  cid: zod.z.string(),
3011
3017
  verb: streamVerbSchema,
3012
3018
  source: streamSourceSchema,
3019
+ author: streamAuthorSchema.optional(),
3013
3020
  tier: zod.z.enum(["creation", "action", "filtered"]),
3014
3021
  timestamp: zod.z.string(),
3015
3022
  title: zod.z.string(),
@@ -3175,6 +3182,19 @@ function buildSource(item, options) {
3175
3182
  color: options.resolveSourceColor?.(item.appId) ?? DEFAULT_SOURCE_COLOR
3176
3183
  };
3177
3184
  }
3185
+ function buildAuthor(item) {
3186
+ const did = didFromUri(item.uri);
3187
+ const handle = asNonEmptyString(item.authorHandle);
3188
+ const displayName = asNonEmptyString(item.authorDisplayName);
3189
+ const avatar = asNonEmptyString(item.authorAvatar);
3190
+ if (!did && !handle && !displayName && !avatar) return void 0;
3191
+ const author = {};
3192
+ if (did) author.did = did;
3193
+ if (handle) author.handle = handle;
3194
+ if (displayName) author.displayName = displayName;
3195
+ if (avatar) author.avatar = avatar;
3196
+ return author;
3197
+ }
3178
3198
  var TITLE_BY_VERB = {
3179
3199
  posted: () => "Posted",
3180
3200
  reposted: () => "Reposted",
@@ -3278,6 +3298,13 @@ function withGeneric(vm) {
3278
3298
  vm.body = { kind: "generic" };
3279
3299
  return vm;
3280
3300
  }
3301
+ function applyFediversePost(vm, record) {
3302
+ const url = httpUrl(record.url);
3303
+ if (url) vm.sourceUrl = url;
3304
+ const text = asNonEmptyString(record.excerpt);
3305
+ vm.body = text ? { kind: "text", text } : { kind: "generic" };
3306
+ return vm;
3307
+ }
3281
3308
  function applyGithubPr(vm, record) {
3282
3309
  const body = {
3283
3310
  kind: "github-pr",
@@ -3699,6 +3726,8 @@ function toStreamCardVM(item, options = {}) {
3699
3726
  timestamp,
3700
3727
  title: buildTitle(verb, source.label)
3701
3728
  };
3729
+ const author = buildAuthor(item);
3730
+ if (author) vm.author = author;
3702
3731
  const theme = readTheme(record);
3703
3732
  if (theme) vm.theme = theme;
3704
3733
  if (record) {
@@ -3733,6 +3762,8 @@ function toStreamCardVM(item, options = {}) {
3733
3762
  return record ? applyYouAndMe(vm, record) : withGeneric(vm);
3734
3763
  case "fyi.asq.answer":
3735
3764
  return record ? applyAsqAnswer(vm, record) : withGeneric(vm);
3765
+ case "fediverse.post":
3766
+ return record ? applyFediversePost(vm, record) : withGeneric(vm);
3736
3767
  }
3737
3768
  if (record && item.collection.startsWith("social.popfeed.feed.")) {
3738
3769
  return applyMediaReview(vm, item, record);
@@ -4566,7 +4597,7 @@ var ProfileVolunteeringRecordSchema = zod.z.object({
4566
4597
  });
4567
4598
 
4568
4599
  // src/index.ts
4569
- var SIFA_SDK_VERSION = "0.12.18";
4600
+ var SIFA_SDK_VERSION = "0.12.20";
4570
4601
 
4571
4602
  exports.ACTIVITY_TIERS = ACTIVITY_TIERS;
4572
4603
  exports.ACTIVITY_VERBS = ACTIVITY_VERBS;
@@ -4791,6 +4822,7 @@ exports.sortPositions = sortPositions;
4791
4822
  exports.sortProjects = sortProjects;
4792
4823
  exports.sortPublications = sortPublications;
4793
4824
  exports.streamAddressSchema = streamAddressSchema;
4825
+ exports.streamAuthorSchema = streamAuthorSchema;
4794
4826
  exports.streamCardBodySchema = streamCardBodySchema;
4795
4827
  exports.streamCardSubjectSchema = streamCardSubjectSchema;
4796
4828
  exports.streamCardVMSchema = streamCardVMSchema;