@singi-labs/sifa-sdk 0.11.10 → 0.11.11

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
@@ -2057,6 +2057,12 @@ function getAppIdForCollection(collection) {
2057
2057
  if (parts.length >= 2) return `${parts[0]}.${parts[1]}`;
2058
2058
  return collection;
2059
2059
  }
2060
+ function urlHealth(url) {
2061
+ return url ? { url, strategy: "url" } : { url: null, strategy: "none" };
2062
+ }
2063
+ function recordHealth(url) {
2064
+ return url ? { url, strategy: "record" } : { url: null, strategy: "none" };
2065
+ }
2060
2066
  function interpolate(pattern, vars) {
2061
2067
  let result = pattern;
2062
2068
  for (const [key, value] of Object.entries(vars)) {
@@ -2073,18 +2079,18 @@ function shouldUseItemPattern(appId, collection) {
2073
2079
  }
2074
2080
  return true;
2075
2081
  }
2076
- function patternUrl(appId, vars, collection) {
2082
+ function patternHealth(appId, vars, collection) {
2077
2083
  const patterns = APP_URL_PATTERNS[appId];
2078
- if (!patterns) return null;
2084
+ if (!patterns) return { url: null, strategy: "none" };
2079
2085
  if (patterns.urlPattern && shouldUseItemPattern(appId, collection)) {
2080
2086
  const url = interpolate(patterns.urlPattern, vars);
2081
- if (url) return url;
2087
+ if (url) return recordHealth(url);
2082
2088
  }
2083
2089
  if (patterns.profileUrlPattern) {
2084
2090
  const url = interpolate(patterns.profileUrlPattern, vars);
2085
- if (url) return url;
2091
+ if (url) return urlHealth(url);
2086
2092
  }
2087
- return null;
2093
+ return { url: null, strategy: "none" };
2088
2094
  }
2089
2095
  var TANGLED_REPO_SLUG = /^[a-zA-Z0-9._-]+$/;
2090
2096
  function stringOrNull(value) {
@@ -2097,33 +2103,31 @@ function parseAtUri(atUri) {
2097
2103
  if (!match || !match[1] || !match[2]) return null;
2098
2104
  return { did: match[1], rkey: match[2] };
2099
2105
  }
2100
- function resolveCardUrl(item) {
2106
+ function resolveCardHealth(item) {
2101
2107
  const { collection, record, uri, rkey, authorDid, authorHandle } = item;
2102
2108
  const appId = getAppIdForCollection(collection);
2103
2109
  if (collection.startsWith("sh.tangled.")) {
2104
2110
  const repoName = stringOrNull(record.name) ?? (collection === "sh.tangled.repo" ? rkey : null);
2105
2111
  if (repoName && authorHandle && TANGLED_REPO_SLUG.test(repoName)) {
2106
- return `https://tangled.sh/${authorHandle}/${repoName}`;
2112
+ return recordHealth(`https://tangled.sh/${authorHandle}/${repoName}`);
2107
2113
  }
2108
- return patternUrl("tangled", { handle: authorHandle, did: authorDid, rkey }, collection);
2114
+ return patternHealth("tangled", { handle: authorHandle, did: authorDid, rkey }, collection);
2109
2115
  }
2110
2116
  if (collection.startsWith("com.kipclip.") || collection.startsWith("community.lexicon.bookmarks.")) {
2111
2117
  const subject = stringOrNull(record.subject);
2112
- if (subject) return subject;
2113
- return patternUrl("kipclip", { handle: authorHandle, did: authorDid, rkey });
2118
+ if (subject) return urlHealth(subject);
2119
+ return patternHealth("kipclip", { handle: authorHandle, did: authorDid, rkey });
2114
2120
  }
2115
2121
  if (collection === "at.margin.bookmark") {
2116
- const source = stringOrNull(record.source);
2117
- if (source) return source;
2118
- return null;
2122
+ return urlHealth(stringOrNull(record.source));
2119
2123
  }
2120
2124
  if (collection === "at.margin.annotation" || collection === "at.margin.note") {
2121
2125
  const target = record.target;
2122
2126
  if (target != null && typeof target === "object") {
2123
2127
  const source = stringOrNull(target.source);
2124
- if (source) return source;
2128
+ if (source) return urlHealth(source);
2125
2129
  }
2126
- return APP_URL_PATTERNS.margin?.profileUrlPattern ?? null;
2130
+ return urlHealth(APP_URL_PATTERNS.margin?.profileUrlPattern ?? null);
2127
2131
  }
2128
2132
  if (collection === "community.lexicon.calendar.rsvp") {
2129
2133
  const subject = record.subject;
@@ -2132,65 +2136,68 @@ function resolveCardUrl(item) {
2132
2136
  if (subjectUri) {
2133
2137
  const parsed2 = parseAtUri(subjectUri);
2134
2138
  if (parsed2) {
2135
- return `https://smokesignal.events/${parsed2.did}/${parsed2.rkey}`;
2139
+ return urlHealth(`https://smokesignal.events/${parsed2.did}/${parsed2.rkey}`);
2136
2140
  }
2137
2141
  }
2138
2142
  }
2139
- return null;
2143
+ return { url: null, strategy: "none" };
2140
2144
  }
2141
2145
  if (collection === "community.lexicon.calendar.event") {
2142
2146
  const parsed2 = parseAtUri(uri);
2143
2147
  if (parsed2) {
2144
- return `https://smokesignal.events/${parsed2.did}/${parsed2.rkey}`;
2148
+ return recordHealth(`https://smokesignal.events/${parsed2.did}/${parsed2.rkey}`);
2145
2149
  }
2146
- return null;
2150
+ return { url: null, strategy: "none" };
2147
2151
  }
2148
2152
  if (collection === "quest.atmo.event") {
2149
2153
  const parsed2 = parseAtUri(uri);
2150
2154
  if (parsed2) {
2151
- return `https://atmo.rsvp/p/${parsed2.did}/e/${parsed2.rkey}`;
2155
+ return recordHealth(`https://atmo.rsvp/p/${parsed2.did}/e/${parsed2.rkey}`);
2152
2156
  }
2153
- return null;
2157
+ return { url: null, strategy: "none" };
2154
2158
  }
2155
2159
  if (collection === "quest.atmo.checkin") {
2156
2160
  const eventUri = stringOrNull(record.event);
2157
2161
  if (eventUri) {
2158
2162
  const parsed2 = parseAtUri(eventUri);
2159
2163
  if (parsed2) {
2160
- return `https://atmo.rsvp/p/${parsed2.did}/e/${parsed2.rkey}`;
2164
+ return urlHealth(`https://atmo.rsvp/p/${parsed2.did}/e/${parsed2.rkey}`);
2161
2165
  }
2162
2166
  }
2163
- return null;
2167
+ return { url: null, strategy: "none" };
2164
2168
  }
2165
2169
  if (collection === "fyi.atstore.listing.review") {
2166
2170
  const listingMeta = record.listingMeta;
2167
2171
  if (listingMeta != null && typeof listingMeta === "object") {
2168
2172
  const slug = stringOrNull(listingMeta.slug);
2169
- if (slug) return `https://atstore.fyi/products/${encodeURIComponent(slug)}`;
2173
+ if (slug) return urlHealth(`https://atstore.fyi/products/${encodeURIComponent(slug)}`);
2170
2174
  }
2171
- return APP_URL_PATTERNS.atstore?.profileUrlPattern ?? null;
2175
+ return urlHealth(APP_URL_PATTERNS.atstore?.profileUrlPattern ?? null);
2172
2176
  }
2173
2177
  if (collection === "social.crate.content") {
2174
- return stringOrNull(record.canonicalUrl);
2178
+ return urlHealth(stringOrNull(record.canonicalUrl));
2175
2179
  }
2176
2180
  if (collection === "social.crate.note") {
2177
- return null;
2181
+ return { url: null, strategy: "none" };
2178
2182
  }
2179
2183
  if (collection.startsWith("site.standard.")) {
2180
2184
  const siteUrl = stringOrNull(record.siteUrl);
2181
2185
  const path = stringOrNull(record.path);
2182
- if (siteUrl && path) return `${siteUrl}${path}`;
2183
- if (siteUrl) return siteUrl;
2186
+ if (siteUrl && path) return urlHealth(`${siteUrl}${path}`);
2187
+ if (siteUrl) return urlHealth(siteUrl);
2184
2188
  }
2185
2189
  if (collection === "io.kich.recipe.recipe") {
2186
- return patternUrl("kich", { handle: authorHandle, did: authorDid, rkey }, collection);
2190
+ return patternHealth("kich", { handle: authorHandle, did: authorDid, rkey }, collection);
2187
2191
  }
2188
2192
  if (collection === "exchange.recipe.recipe") {
2189
- return patternUrl("recipe", { handle: authorHandle, did: authorDid, rkey }, collection);
2193
+ return patternHealth("recipe", { handle: authorHandle, did: authorDid, rkey }, collection);
2190
2194
  }
2191
2195
  const recordUrl = stringOrNull(record.url);
2192
- if (recordUrl) return recordUrl;
2193
- return patternUrl(appId, { handle: authorHandle, did: authorDid, rkey }, collection);
2196
+ if (recordUrl) return urlHealth(recordUrl);
2197
+ return patternHealth(appId, { handle: authorHandle, did: authorDid, rkey }, collection);
2198
+ }
2199
+ function resolveCardUrl(item) {
2200
+ return resolveCardHealth(item).url;
2194
2201
  }
2195
2202
 
2196
2203
  // src/cards/visibility.ts
@@ -2686,7 +2693,7 @@ var ProfileVolunteeringRecordSchema = zod.z.object({
2686
2693
  });
2687
2694
 
2688
2695
  // src/index.ts
2689
- var SIFA_SDK_VERSION = "0.11.10";
2696
+ var SIFA_SDK_VERSION = "0.11.11";
2690
2697
 
2691
2698
  exports.ACTIVITY_TIERS = ACTIVITY_TIERS;
2692
2699
  exports.ACTIVITY_VISIBILITY_RULES = ACTIVITY_VISIBILITY_RULES;
@@ -2832,6 +2839,7 @@ exports.presentationCsvRowToRecord = presentationCsvRowToRecord;
2832
2839
  exports.presentationDeliveryCsvRowToRecord = presentationDeliveryCsvRowToRecord;
2833
2840
  exports.profileToDimensionInputs = profileToDimensionInputs;
2834
2841
  exports.relativeLuminance = relativeLuminance;
2842
+ exports.resolveCardHealth = resolveCardHealth;
2835
2843
  exports.resolveCardUrl = resolveCardUrl;
2836
2844
  exports.rgbToString = rgbToString;
2837
2845
  exports.sanitizeDisplayText = sanitizeDisplayText;