@singi-labs/sifa-sdk 0.12.9 → 0.12.10
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 +476 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +117 -5
- package/dist/index.d.ts +117 -5
- package/dist/index.js +475 -39
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2708,6 +2708,18 @@ var streamExternalLinkSchema = zod.z.object({
|
|
|
2708
2708
|
title: zod.z.string().optional(),
|
|
2709
2709
|
thumb: zod.z.string().optional()
|
|
2710
2710
|
});
|
|
2711
|
+
var streamGeoSchema = zod.z.object({
|
|
2712
|
+
latitude: zod.z.number(),
|
|
2713
|
+
longitude: zod.z.number()
|
|
2714
|
+
});
|
|
2715
|
+
var streamAddressSchema = zod.z.object({
|
|
2716
|
+
name: zod.z.string().optional(),
|
|
2717
|
+
street: zod.z.string().optional(),
|
|
2718
|
+
locality: zod.z.string().optional(),
|
|
2719
|
+
region: zod.z.string().optional(),
|
|
2720
|
+
country: zod.z.string().optional(),
|
|
2721
|
+
postalCode: zod.z.string().optional()
|
|
2722
|
+
});
|
|
2711
2723
|
var streamCardBodySchema = zod.z.discriminatedUnion("kind", [
|
|
2712
2724
|
zod.z.object({ kind: zod.z.literal("text"), text: zod.z.string() }),
|
|
2713
2725
|
zod.z.object({ kind: zod.z.literal("media"), text: zod.z.string().optional() }),
|
|
@@ -2718,7 +2730,91 @@ var streamCardBodySchema = zod.z.discriminatedUnion("kind", [
|
|
|
2718
2730
|
trackTitle: zod.z.string().optional(),
|
|
2719
2731
|
artist: zod.z.string().optional()
|
|
2720
2732
|
}),
|
|
2721
|
-
zod.z.object({ kind: zod.z.literal("generic"), text: zod.z.string().optional() })
|
|
2733
|
+
zod.z.object({ kind: zod.z.literal("generic"), text: zod.z.string().optional() }),
|
|
2734
|
+
zod.z.object({
|
|
2735
|
+
kind: zod.z.literal("github-pr"),
|
|
2736
|
+
repoOwner: zod.z.string(),
|
|
2737
|
+
repoName: zod.z.string(),
|
|
2738
|
+
prNumber: zod.z.number(),
|
|
2739
|
+
title: zod.z.string(),
|
|
2740
|
+
url: zod.z.string().optional(),
|
|
2741
|
+
language: zod.z.string().optional(),
|
|
2742
|
+
additions: zod.z.number(),
|
|
2743
|
+
deletions: zod.z.number(),
|
|
2744
|
+
mergedAt: zod.z.string().optional()
|
|
2745
|
+
}),
|
|
2746
|
+
zod.z.object({
|
|
2747
|
+
kind: zod.z.literal("book"),
|
|
2748
|
+
title: zod.z.string(),
|
|
2749
|
+
authors: zod.z.array(zod.z.string()),
|
|
2750
|
+
stars: zod.z.number().optional(),
|
|
2751
|
+
status: zod.z.string().optional(),
|
|
2752
|
+
review: zod.z.string().optional()
|
|
2753
|
+
}),
|
|
2754
|
+
zod.z.object({
|
|
2755
|
+
kind: zod.z.literal("media-review"),
|
|
2756
|
+
reviewKind: zod.z.enum(["review", "post", "note", "other"]),
|
|
2757
|
+
title: zod.z.string().optional(),
|
|
2758
|
+
mediaType: zod.z.string().optional(),
|
|
2759
|
+
rating: zod.z.number().optional(),
|
|
2760
|
+
mainCredit: zod.z.string().optional(),
|
|
2761
|
+
reviewText: zod.z.string().optional(),
|
|
2762
|
+
isRevisit: zod.z.boolean()
|
|
2763
|
+
}),
|
|
2764
|
+
zod.z.object({
|
|
2765
|
+
kind: zod.z.literal("event-rsvp"),
|
|
2766
|
+
rsvpStatus: zod.z.enum(["going", "interested", "notgoing", "unknown"]),
|
|
2767
|
+
eventName: zod.z.string().optional(),
|
|
2768
|
+
startsAt: zod.z.string().optional(),
|
|
2769
|
+
endsAt: zod.z.string().optional(),
|
|
2770
|
+
mode: zod.z.enum(["inperson", "virtual", "hybrid"]).optional(),
|
|
2771
|
+
locationName: zod.z.string().optional(),
|
|
2772
|
+
locationLocality: zod.z.string().optional(),
|
|
2773
|
+
locationCountry: zod.z.string().optional()
|
|
2774
|
+
}),
|
|
2775
|
+
zod.z.object({
|
|
2776
|
+
kind: zod.z.literal("verification"),
|
|
2777
|
+
platform: zod.z.string(),
|
|
2778
|
+
verified: zod.z.boolean(),
|
|
2779
|
+
subjectLabel: zod.z.string().optional(),
|
|
2780
|
+
handle: zod.z.string().optional(),
|
|
2781
|
+
profileUrl: zod.z.string().optional()
|
|
2782
|
+
}),
|
|
2783
|
+
zod.z.object({
|
|
2784
|
+
kind: zod.z.literal("membership"),
|
|
2785
|
+
communityName: zod.z.string().optional(),
|
|
2786
|
+
description: zod.z.string().optional(),
|
|
2787
|
+
communityUri: zod.z.string().optional()
|
|
2788
|
+
}),
|
|
2789
|
+
zod.z.object({
|
|
2790
|
+
kind: zod.z.literal("location"),
|
|
2791
|
+
venueName: zod.z.string().optional(),
|
|
2792
|
+
shout: zod.z.string().optional(),
|
|
2793
|
+
address: streamAddressSchema.optional(),
|
|
2794
|
+
geo: streamGeoSchema.optional()
|
|
2795
|
+
}),
|
|
2796
|
+
zod.z.object({
|
|
2797
|
+
kind: zod.z.literal("travel"),
|
|
2798
|
+
origin: zod.z.string().optional(),
|
|
2799
|
+
destination: zod.z.string().optional(),
|
|
2800
|
+
transportation: zod.z.string().optional(),
|
|
2801
|
+
carrier: zod.z.string().optional(),
|
|
2802
|
+
carrierCode: zod.z.string().optional(),
|
|
2803
|
+
startDate: zod.z.string().optional(),
|
|
2804
|
+
endDate: zod.z.string().optional()
|
|
2805
|
+
}),
|
|
2806
|
+
zod.z.object({
|
|
2807
|
+
kind: zod.z.literal("standard-site"),
|
|
2808
|
+
title: zod.z.string().optional(),
|
|
2809
|
+
description: zod.z.string().optional(),
|
|
2810
|
+
siteUrl: zod.z.string().optional(),
|
|
2811
|
+
path: zod.z.string().optional(),
|
|
2812
|
+
publisherName: zod.z.string().optional(),
|
|
2813
|
+
icon: zod.z.string().optional(),
|
|
2814
|
+
coverImageUrl: zod.z.string().optional(),
|
|
2815
|
+
readingTime: zod.z.number().optional(),
|
|
2816
|
+
publishedAt: zod.z.string().optional()
|
|
2817
|
+
})
|
|
2722
2818
|
]);
|
|
2723
2819
|
var streamCardSubjectSchema = zod.z.discriminatedUnion("kind", [
|
|
2724
2820
|
zod.z.object({
|
|
@@ -2754,6 +2850,62 @@ var streamCardVMSchema = zod.z.lazy(
|
|
|
2754
2850
|
subject: zod.z.lazy(() => streamCardSubjectSchema).optional()
|
|
2755
2851
|
})
|
|
2756
2852
|
);
|
|
2853
|
+
function maxGraphemes(max) {
|
|
2854
|
+
return (value) => {
|
|
2855
|
+
const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
2856
|
+
let count = 0;
|
|
2857
|
+
for (const _ of segmenter.segment(value)) {
|
|
2858
|
+
count++;
|
|
2859
|
+
if (count > max) return false;
|
|
2860
|
+
}
|
|
2861
|
+
return true;
|
|
2862
|
+
};
|
|
2863
|
+
}
|
|
2864
|
+
var didSchema = zod.z.string().regex(/^did:[a-z]+:[a-zA-Z0-9._:%-]+$/, "Invalid DID");
|
|
2865
|
+
var datetimeSchema = zod.z.string().datetime({ offset: true });
|
|
2866
|
+
var partialDateSchema = zod.z.string().regex(/^\d{4}(-\d{2}(-\d{2}(T.+)?)?)?$/, "Expected YYYY, YYYY-MM, YYYY-MM-DD, or a datetime");
|
|
2867
|
+
var atUriSchema = zod.z.string().regex(/^at:\/\/[^\s]+$/, "Invalid AT-URI");
|
|
2868
|
+
var cidSchema = zod.z.string().regex(/^(Qm[1-9A-HJ-NP-Za-km-z]{44}|b[A-Za-z0-9+/=]+)$/, "Invalid CID");
|
|
2869
|
+
var languageTagSchema = zod.z.string().regex(/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/, "Invalid BCP 47 language tag");
|
|
2870
|
+
var uriSchema = zod.z.string().url();
|
|
2871
|
+
var strongRefSchema = zod.z.object({
|
|
2872
|
+
uri: atUriSchema,
|
|
2873
|
+
cid: cidSchema
|
|
2874
|
+
});
|
|
2875
|
+
var externalRecordRefSchema = zod.z.object({
|
|
2876
|
+
uri: atUriSchema,
|
|
2877
|
+
cid: cidSchema.optional()
|
|
2878
|
+
});
|
|
2879
|
+
var selfLabelsSchema = zod.z.object({
|
|
2880
|
+
$type: zod.z.literal("com.atproto.label.defs#selfLabels").optional(),
|
|
2881
|
+
values: zod.z.array(zod.z.object({ val: zod.z.string() }))
|
|
2882
|
+
});
|
|
2883
|
+
|
|
2884
|
+
// src/publishing/registry.ts
|
|
2885
|
+
var STANDARD_SITE_PUBLISHERS = Object.freeze([
|
|
2886
|
+
{ host: "leaflet.pub", name: "Leaflet", iconKey: "leaflet" },
|
|
2887
|
+
{ host: "pckt.blog", name: "pckt", iconKey: "pckt" },
|
|
2888
|
+
{ host: "offprint.app", name: "Offprint", iconKey: "offprint" }
|
|
2889
|
+
]);
|
|
2890
|
+
function hostMatches(host, target) {
|
|
2891
|
+
return host === target || host.endsWith("." + target);
|
|
2892
|
+
}
|
|
2893
|
+
function hostFromUri(uri) {
|
|
2894
|
+
if (!uri) return null;
|
|
2895
|
+
try {
|
|
2896
|
+
return new URL(uri).host.toLowerCase();
|
|
2897
|
+
} catch {
|
|
2898
|
+
return null;
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
function matchPublisherByHost(host) {
|
|
2902
|
+
if (!host) return null;
|
|
2903
|
+
const lower = host.toLowerCase();
|
|
2904
|
+
return STANDARD_SITE_PUBLISHERS.find((p) => hostMatches(lower, p.host)) ?? null;
|
|
2905
|
+
}
|
|
2906
|
+
function matchPublisherByUri(uri) {
|
|
2907
|
+
return matchPublisherByHost(hostFromUri(uri));
|
|
2908
|
+
}
|
|
2757
2909
|
|
|
2758
2910
|
// src/stream/to-stream-card-vm.ts
|
|
2759
2911
|
var DEFAULT_SOURCE_COLOR = "slate";
|
|
@@ -2782,6 +2934,69 @@ function aspectRatio(value) {
|
|
|
2782
2934
|
if (typeof width === "number" && typeof height === "number") return { width, height };
|
|
2783
2935
|
return void 0;
|
|
2784
2936
|
}
|
|
2937
|
+
function asFiniteNumber(value) {
|
|
2938
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
2939
|
+
}
|
|
2940
|
+
function looseBlobCid(value) {
|
|
2941
|
+
const viaRef = blobCid(value);
|
|
2942
|
+
if (viaRef) return viaRef;
|
|
2943
|
+
const cid = asRecord(value)?.cid;
|
|
2944
|
+
return typeof cid === "string" && cid.length > 0 ? cid : void 0;
|
|
2945
|
+
}
|
|
2946
|
+
function blobMedia(value, did, alt) {
|
|
2947
|
+
const cid = looseBlobCid(value);
|
|
2948
|
+
if (!cid) return void 0;
|
|
2949
|
+
const media = { did, cid, alt };
|
|
2950
|
+
const ratio = aspectRatio(asRecord(value)?.aspectRatio);
|
|
2951
|
+
if (ratio) media.aspectRatio = ratio;
|
|
2952
|
+
const mimeType = asNonEmptyString(asRecord(value)?.mimeType);
|
|
2953
|
+
if (mimeType) media.mimeType = mimeType;
|
|
2954
|
+
return media;
|
|
2955
|
+
}
|
|
2956
|
+
function hashSuffix(value) {
|
|
2957
|
+
const i = value.lastIndexOf("#");
|
|
2958
|
+
return i >= 0 ? value.slice(i) : "";
|
|
2959
|
+
}
|
|
2960
|
+
var WORDS_PER_MINUTE = 200;
|
|
2961
|
+
function estimateReadingTime(text) {
|
|
2962
|
+
if (!text) return void 0;
|
|
2963
|
+
const words = text.trim().split(/\s+/).filter(Boolean).length;
|
|
2964
|
+
if (words === 0) return void 0;
|
|
2965
|
+
return Math.max(1, Math.round(words / WORDS_PER_MINUTE));
|
|
2966
|
+
}
|
|
2967
|
+
function beaconGeo(value) {
|
|
2968
|
+
const rec = asRecord(value);
|
|
2969
|
+
if (!rec) return void 0;
|
|
2970
|
+
const { latitude, longitude } = rec;
|
|
2971
|
+
const okType = (v) => typeof v === "string" || typeof v === "number";
|
|
2972
|
+
if (!okType(latitude) || !okType(longitude)) return void 0;
|
|
2973
|
+
const lat = Number(latitude);
|
|
2974
|
+
const lng = Number(longitude);
|
|
2975
|
+
if (!Number.isFinite(lat) || !Number.isFinite(lng)) return void 0;
|
|
2976
|
+
return { latitude: lat, longitude: lng };
|
|
2977
|
+
}
|
|
2978
|
+
function beaconAddress(value) {
|
|
2979
|
+
const rec = asRecord(value);
|
|
2980
|
+
if (!rec) return void 0;
|
|
2981
|
+
const address = {};
|
|
2982
|
+
const name = asNonEmptyString(rec.name);
|
|
2983
|
+
if (name) address.name = name;
|
|
2984
|
+
const street = asNonEmptyString(rec.street);
|
|
2985
|
+
if (street) address.street = street;
|
|
2986
|
+
const locality = asNonEmptyString(rec.locality);
|
|
2987
|
+
if (locality) address.locality = locality;
|
|
2988
|
+
const region = asNonEmptyString(rec.region);
|
|
2989
|
+
if (region) address.region = region;
|
|
2990
|
+
const country = asNonEmptyString(rec.country);
|
|
2991
|
+
if (country) address.country = country;
|
|
2992
|
+
const postalCode = asNonEmptyString(rec.postalCode);
|
|
2993
|
+
if (postalCode) address.postalCode = postalCode;
|
|
2994
|
+
return Object.keys(address).length > 0 ? address : void 0;
|
|
2995
|
+
}
|
|
2996
|
+
function parseAuthors(value) {
|
|
2997
|
+
if (typeof value !== "string") return [];
|
|
2998
|
+
return value.split(" ").map((a) => a.trim()).filter((a) => a.length > 0);
|
|
2999
|
+
}
|
|
2785
3000
|
function buildSource(item, options) {
|
|
2786
3001
|
return {
|
|
2787
3002
|
appId: item.appId,
|
|
@@ -2873,6 +3088,234 @@ function applyBskyPost(vm, item, record) {
|
|
|
2873
3088
|
vm.body = body;
|
|
2874
3089
|
return vm;
|
|
2875
3090
|
}
|
|
3091
|
+
function withGeneric(vm) {
|
|
3092
|
+
vm.body = { kind: "generic" };
|
|
3093
|
+
return vm;
|
|
3094
|
+
}
|
|
3095
|
+
function applyGithubPr(vm, record) {
|
|
3096
|
+
const body = {
|
|
3097
|
+
kind: "github-pr",
|
|
3098
|
+
repoOwner: asNonEmptyString(record.repoOwner) ?? "",
|
|
3099
|
+
repoName: asNonEmptyString(record.repoName) ?? "",
|
|
3100
|
+
prNumber: asFiniteNumber(record.prNumber) ?? 0,
|
|
3101
|
+
title: asNonEmptyString(record.title) ?? "",
|
|
3102
|
+
additions: asFiniteNumber(record.additions) ?? 0,
|
|
3103
|
+
deletions: asFiniteNumber(record.deletions) ?? 0
|
|
3104
|
+
};
|
|
3105
|
+
const url = asNonEmptyString(record.url);
|
|
3106
|
+
if (url) body.url = url;
|
|
3107
|
+
const language = asNonEmptyString(record.language);
|
|
3108
|
+
if (language) body.language = language;
|
|
3109
|
+
const mergedAt = asNonEmptyString(record.mergedAt);
|
|
3110
|
+
if (mergedAt) body.mergedAt = mergedAt;
|
|
3111
|
+
vm.body = body;
|
|
3112
|
+
return vm;
|
|
3113
|
+
}
|
|
3114
|
+
function applyBook(vm, item, record) {
|
|
3115
|
+
const title = asNonEmptyString(record.title) ?? "Untitled book";
|
|
3116
|
+
const body = {
|
|
3117
|
+
kind: "book",
|
|
3118
|
+
title,
|
|
3119
|
+
authors: parseAuthors(record.authors)
|
|
3120
|
+
};
|
|
3121
|
+
const stars = asFiniteNumber(record.stars);
|
|
3122
|
+
if (stars !== void 0 && stars > 0) body.stars = stars;
|
|
3123
|
+
const status = asNonEmptyString(record.status);
|
|
3124
|
+
if (status) body.status = status;
|
|
3125
|
+
const review = asNonEmptyString(
|
|
3126
|
+
typeof record.review === "string" ? record.review.trim() : void 0
|
|
3127
|
+
);
|
|
3128
|
+
if (review) body.review = review;
|
|
3129
|
+
vm.body = body;
|
|
3130
|
+
const did = didFromUri(item.uri);
|
|
3131
|
+
if (did) {
|
|
3132
|
+
const cover = blobMedia(record.cover, did, `The cover of ${title}`);
|
|
3133
|
+
if (cover) vm.media = [cover];
|
|
3134
|
+
}
|
|
3135
|
+
return vm;
|
|
3136
|
+
}
|
|
3137
|
+
function popfeedReviewKind(collection) {
|
|
3138
|
+
if (collection.endsWith(".review")) return "review";
|
|
3139
|
+
if (collection.endsWith(".post")) return "post";
|
|
3140
|
+
if (collection.endsWith(".note")) return "note";
|
|
3141
|
+
return "other";
|
|
3142
|
+
}
|
|
3143
|
+
function applyMediaReview(vm, item, record) {
|
|
3144
|
+
const title = asNonEmptyString(record.title) ?? asNonEmptyString(record.name);
|
|
3145
|
+
const body = {
|
|
3146
|
+
kind: "media-review",
|
|
3147
|
+
reviewKind: popfeedReviewKind(item.collection),
|
|
3148
|
+
isRevisit: record.isRevisit === true
|
|
3149
|
+
};
|
|
3150
|
+
if (title) body.title = title;
|
|
3151
|
+
const mediaType = asNonEmptyString(record.creativeWorkType);
|
|
3152
|
+
if (mediaType) body.mediaType = mediaType;
|
|
3153
|
+
const rating = asFiniteNumber(record.rating);
|
|
3154
|
+
if (rating !== void 0) body.rating = rating;
|
|
3155
|
+
const mainCredit = asNonEmptyString(record.mainCredit);
|
|
3156
|
+
if (mainCredit) body.mainCredit = mainCredit;
|
|
3157
|
+
const reviewText = asNonEmptyString(record.text);
|
|
3158
|
+
if (reviewText) body.reviewText = reviewText;
|
|
3159
|
+
vm.body = body;
|
|
3160
|
+
const posterUrl = asNonEmptyString(record.posterUrl);
|
|
3161
|
+
if (posterUrl) vm.media = [{ url: posterUrl, alt: title ? `${title} poster` : "" }];
|
|
3162
|
+
return vm;
|
|
3163
|
+
}
|
|
3164
|
+
var RSVP_STATUS = {
|
|
3165
|
+
"#going": "going",
|
|
3166
|
+
"#interested": "interested",
|
|
3167
|
+
"#notgoing": "notgoing"
|
|
3168
|
+
};
|
|
3169
|
+
var RSVP_MODE = {
|
|
3170
|
+
"#inperson": "inperson",
|
|
3171
|
+
"#virtual": "virtual",
|
|
3172
|
+
"#hybrid": "hybrid"
|
|
3173
|
+
};
|
|
3174
|
+
function applyEventRsvp(vm, record) {
|
|
3175
|
+
const status = asNonEmptyString(record.status);
|
|
3176
|
+
const body = {
|
|
3177
|
+
kind: "event-rsvp",
|
|
3178
|
+
rsvpStatus: (status ? RSVP_STATUS[hashSuffix(status)] : void 0) ?? "unknown"
|
|
3179
|
+
};
|
|
3180
|
+
const meta = asRecord(record.eventMeta);
|
|
3181
|
+
if (meta) {
|
|
3182
|
+
const eventName = asNonEmptyString(meta.name);
|
|
3183
|
+
if (eventName) body.eventName = eventName;
|
|
3184
|
+
const startsAt = asNonEmptyString(meta.startsAt);
|
|
3185
|
+
if (startsAt) body.startsAt = startsAt;
|
|
3186
|
+
const endsAt = asNonEmptyString(meta.endsAt);
|
|
3187
|
+
if (endsAt) body.endsAt = endsAt;
|
|
3188
|
+
const mode = asNonEmptyString(meta.mode);
|
|
3189
|
+
const modeEnum = mode ? RSVP_MODE[hashSuffix(mode)] : void 0;
|
|
3190
|
+
if (modeEnum) body.mode = modeEnum;
|
|
3191
|
+
const locationName = asNonEmptyString(meta.locationName);
|
|
3192
|
+
if (locationName) body.locationName = locationName;
|
|
3193
|
+
const locationLocality = asNonEmptyString(meta.locationLocality);
|
|
3194
|
+
if (locationLocality) body.locationLocality = locationLocality;
|
|
3195
|
+
const locationCountry = asNonEmptyString(meta.locationCountry);
|
|
3196
|
+
if (locationCountry) body.locationCountry = locationCountry;
|
|
3197
|
+
}
|
|
3198
|
+
vm.body = body;
|
|
3199
|
+
return vm;
|
|
3200
|
+
}
|
|
3201
|
+
function applyKeytraceVerification(vm, record) {
|
|
3202
|
+
const identity = asRecord(record.identity) ?? {};
|
|
3203
|
+
const subject = asNonEmptyString(identity.subject);
|
|
3204
|
+
const displayName = asNonEmptyString(identity.displayName);
|
|
3205
|
+
const body = {
|
|
3206
|
+
kind: "verification",
|
|
3207
|
+
platform: asNonEmptyString(record.type) ?? "unknown",
|
|
3208
|
+
verified: record.status === "verified"
|
|
3209
|
+
};
|
|
3210
|
+
const subjectLabel = displayName ?? subject;
|
|
3211
|
+
if (subjectLabel) body.subjectLabel = subjectLabel;
|
|
3212
|
+
const profileUrl = asNonEmptyString(identity.profileUrl);
|
|
3213
|
+
if (profileUrl) body.profileUrl = profileUrl;
|
|
3214
|
+
vm.body = body;
|
|
3215
|
+
return vm;
|
|
3216
|
+
}
|
|
3217
|
+
function applyBskyVerification(vm, record) {
|
|
3218
|
+
const handle = asNonEmptyString(record.handle);
|
|
3219
|
+
const displayName = asNonEmptyString(record.displayName);
|
|
3220
|
+
const body = {
|
|
3221
|
+
kind: "verification",
|
|
3222
|
+
platform: "bluesky",
|
|
3223
|
+
verified: true
|
|
3224
|
+
};
|
|
3225
|
+
const subjectLabel = displayName ?? handle;
|
|
3226
|
+
if (subjectLabel) body.subjectLabel = subjectLabel;
|
|
3227
|
+
if (handle) body.handle = handle;
|
|
3228
|
+
vm.body = body;
|
|
3229
|
+
return vm;
|
|
3230
|
+
}
|
|
3231
|
+
function applyMembership(vm, record) {
|
|
3232
|
+
const body = { kind: "membership" };
|
|
3233
|
+
const communityUri = asNonEmptyString(record.community);
|
|
3234
|
+
if (communityUri) body.communityUri = communityUri;
|
|
3235
|
+
const meta = asRecord(record.communityMeta);
|
|
3236
|
+
const communityName = meta ? asNonEmptyString(meta.name) : void 0;
|
|
3237
|
+
if (communityName) body.communityName = communityName;
|
|
3238
|
+
const description = meta ? asNonEmptyString(meta.description) : void 0;
|
|
3239
|
+
if (description) body.description = description;
|
|
3240
|
+
vm.body = body;
|
|
3241
|
+
if (meta) {
|
|
3242
|
+
const ownerDid = asNonEmptyString(meta.ownerDid) ?? (communityUri ? didFromUri(communityUri) : void 0);
|
|
3243
|
+
if (ownerDid) {
|
|
3244
|
+
const picture = blobMedia(meta.picture, ownerDid, communityName ?? "");
|
|
3245
|
+
if (picture) vm.media = [picture];
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
return vm;
|
|
3249
|
+
}
|
|
3250
|
+
function applyLocation(vm, record) {
|
|
3251
|
+
const body = { kind: "location" };
|
|
3252
|
+
const venueName = asNonEmptyString(record.venueName);
|
|
3253
|
+
if (venueName) body.venueName = venueName;
|
|
3254
|
+
const shout = asNonEmptyString(record.shout);
|
|
3255
|
+
if (shout) body.shout = shout;
|
|
3256
|
+
const address = beaconAddress(record.addressDetails);
|
|
3257
|
+
if (address) body.address = address;
|
|
3258
|
+
const geo = beaconGeo(record.location);
|
|
3259
|
+
if (geo) body.geo = geo;
|
|
3260
|
+
vm.body = body;
|
|
3261
|
+
return vm;
|
|
3262
|
+
}
|
|
3263
|
+
function applyTravel(vm, record) {
|
|
3264
|
+
const body = { kind: "travel" };
|
|
3265
|
+
const origin = asNonEmptyString(record.originTransportCode);
|
|
3266
|
+
if (origin) body.origin = origin;
|
|
3267
|
+
const destination = asNonEmptyString(record.destinationTransportCode);
|
|
3268
|
+
if (destination) body.destination = destination;
|
|
3269
|
+
const transportation = asNonEmptyString(record.transportation);
|
|
3270
|
+
if (transportation) body.transportation = transportation;
|
|
3271
|
+
const carrier = asNonEmptyString(record.carrier);
|
|
3272
|
+
if (carrier) body.carrier = carrier;
|
|
3273
|
+
const carrierCode = asNonEmptyString(record.carrierCode);
|
|
3274
|
+
if (carrierCode) body.carrierCode = carrierCode;
|
|
3275
|
+
const startDate = asNonEmptyString(record.startDate);
|
|
3276
|
+
if (startDate) body.startDate = startDate;
|
|
3277
|
+
const endDate = asNonEmptyString(record.endDate);
|
|
3278
|
+
if (endDate) body.endDate = endDate;
|
|
3279
|
+
vm.body = body;
|
|
3280
|
+
return vm;
|
|
3281
|
+
}
|
|
3282
|
+
function applyStandardSite(vm, record) {
|
|
3283
|
+
const body = { kind: "standard-site" };
|
|
3284
|
+
const title = asNonEmptyString(record.title);
|
|
3285
|
+
if (title) body.title = title;
|
|
3286
|
+
const description = asNonEmptyString(record.description);
|
|
3287
|
+
if (description) body.description = description;
|
|
3288
|
+
const siteUrl = asNonEmptyString(record.siteUrl);
|
|
3289
|
+
if (siteUrl) {
|
|
3290
|
+
body.siteUrl = siteUrl;
|
|
3291
|
+
const publisherName = matchPublisherByUri(siteUrl)?.name;
|
|
3292
|
+
if (publisherName) body.publisherName = publisherName;
|
|
3293
|
+
}
|
|
3294
|
+
const path = asNonEmptyString(record.path);
|
|
3295
|
+
if (path) body.path = path;
|
|
3296
|
+
const icon = asNonEmptyString(record.publicationIcon);
|
|
3297
|
+
if (icon) body.icon = icon;
|
|
3298
|
+
const coverImageUrl = asNonEmptyString(record.coverImageUrl);
|
|
3299
|
+
if (coverImageUrl) body.coverImageUrl = coverImageUrl;
|
|
3300
|
+
const readingTime = estimateReadingTime(asNonEmptyString(record.textContent));
|
|
3301
|
+
if (readingTime !== void 0) body.readingTime = readingTime;
|
|
3302
|
+
const publishedAt = asNonEmptyString(record.publishedAt);
|
|
3303
|
+
if (publishedAt) body.publishedAt = publishedAt;
|
|
3304
|
+
vm.body = body;
|
|
3305
|
+
return vm;
|
|
3306
|
+
}
|
|
3307
|
+
function applyYouAndMe(vm, record) {
|
|
3308
|
+
const did = asNonEmptyString(record.subject);
|
|
3309
|
+
if (did) vm.subject = { kind: "person", did };
|
|
3310
|
+
vm.body = { kind: "generic" };
|
|
3311
|
+
return vm;
|
|
3312
|
+
}
|
|
3313
|
+
function applyAsqAnswer(vm, record) {
|
|
3314
|
+
const uri = asNonEmptyString(asRecord(record.subject)?.uri);
|
|
3315
|
+
if (uri) vm.subject = { kind: "record", uri };
|
|
3316
|
+
vm.body = { kind: "generic" };
|
|
3317
|
+
return vm;
|
|
3318
|
+
}
|
|
2876
3319
|
function toStreamCardVM(item, options = {}) {
|
|
2877
3320
|
const verb = verbForCollection(item.collection);
|
|
2878
3321
|
const source = buildSource(item, options);
|
|
@@ -2892,11 +3335,36 @@ function toStreamCardVM(item, options = {}) {
|
|
|
2892
3335
|
if (item.subject) {
|
|
2893
3336
|
vm.subject = { kind: "post", post: toStreamCardVM(item.subject, options) };
|
|
2894
3337
|
}
|
|
2895
|
-
|
|
2896
|
-
|
|
3338
|
+
switch (item.collection) {
|
|
3339
|
+
case "app.bsky.feed.post":
|
|
3340
|
+
return applyBskyPost(vm, item, record);
|
|
3341
|
+
case "github.pull_request":
|
|
3342
|
+
return record ? applyGithubPr(vm, record) : withGeneric(vm);
|
|
3343
|
+
case "buzz.bookhive.book":
|
|
3344
|
+
return record ? applyBook(vm, item, record) : withGeneric(vm);
|
|
3345
|
+
case "community.lexicon.calendar.rsvp":
|
|
3346
|
+
return record ? applyEventRsvp(vm, record) : withGeneric(vm);
|
|
3347
|
+
case "dev.keytrace.claim":
|
|
3348
|
+
return record ? applyKeytraceVerification(vm, record) : withGeneric(vm);
|
|
3349
|
+
case "app.bsky.graph.verification":
|
|
3350
|
+
return record ? applyBskyVerification(vm, record) : withGeneric(vm);
|
|
3351
|
+
case "social.colibri.membership":
|
|
3352
|
+
return record ? applyMembership(vm, record) : withGeneric(vm);
|
|
3353
|
+
case "app.beaconbits.beacon":
|
|
3354
|
+
return record ? applyLocation(vm, record) : withGeneric(vm);
|
|
3355
|
+
case "social.passports.travel.leg":
|
|
3356
|
+
return record ? applyTravel(vm, record) : withGeneric(vm);
|
|
3357
|
+
case "site.standard.document":
|
|
3358
|
+
return record ? applyStandardSite(vm, record) : withGeneric(vm);
|
|
3359
|
+
case "at.youandme.connection":
|
|
3360
|
+
return record ? applyYouAndMe(vm, record) : withGeneric(vm);
|
|
3361
|
+
case "fyi.asq.answer":
|
|
3362
|
+
return record ? applyAsqAnswer(vm, record) : withGeneric(vm);
|
|
2897
3363
|
}
|
|
2898
|
-
|
|
2899
|
-
|
|
3364
|
+
if (record && item.collection.startsWith("social.popfeed.feed.")) {
|
|
3365
|
+
return applyMediaReview(vm, item, record);
|
|
3366
|
+
}
|
|
3367
|
+
return withGeneric(vm);
|
|
2900
3368
|
}
|
|
2901
3369
|
function toStreamCardVMs(items, options = {}) {
|
|
2902
3370
|
const out = [];
|
|
@@ -3312,38 +3780,6 @@ function groupInvolvementByHeading(items) {
|
|
|
3312
3780
|
}
|
|
3313
3781
|
return groups;
|
|
3314
3782
|
}
|
|
3315
|
-
function maxGraphemes(max) {
|
|
3316
|
-
return (value) => {
|
|
3317
|
-
const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
3318
|
-
let count = 0;
|
|
3319
|
-
for (const _ of segmenter.segment(value)) {
|
|
3320
|
-
count++;
|
|
3321
|
-
if (count > max) return false;
|
|
3322
|
-
}
|
|
3323
|
-
return true;
|
|
3324
|
-
};
|
|
3325
|
-
}
|
|
3326
|
-
var didSchema = zod.z.string().regex(/^did:[a-z]+:[a-zA-Z0-9._:%-]+$/, "Invalid DID");
|
|
3327
|
-
var datetimeSchema = zod.z.string().datetime({ offset: true });
|
|
3328
|
-
var partialDateSchema = zod.z.string().regex(/^\d{4}(-\d{2}(-\d{2}(T.+)?)?)?$/, "Expected YYYY, YYYY-MM, YYYY-MM-DD, or a datetime");
|
|
3329
|
-
var atUriSchema = zod.z.string().regex(/^at:\/\/[^\s]+$/, "Invalid AT-URI");
|
|
3330
|
-
var cidSchema = zod.z.string().regex(/^(Qm[1-9A-HJ-NP-Za-km-z]{44}|b[A-Za-z0-9+/=]+)$/, "Invalid CID");
|
|
3331
|
-
var languageTagSchema = zod.z.string().regex(/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/, "Invalid BCP 47 language tag");
|
|
3332
|
-
var uriSchema = zod.z.string().url();
|
|
3333
|
-
var strongRefSchema = zod.z.object({
|
|
3334
|
-
uri: atUriSchema,
|
|
3335
|
-
cid: cidSchema
|
|
3336
|
-
});
|
|
3337
|
-
var externalRecordRefSchema = zod.z.object({
|
|
3338
|
-
uri: atUriSchema,
|
|
3339
|
-
cid: cidSchema.optional()
|
|
3340
|
-
});
|
|
3341
|
-
var selfLabelsSchema = zod.z.object({
|
|
3342
|
-
$type: zod.z.literal("com.atproto.label.defs#selfLabels").optional(),
|
|
3343
|
-
values: zod.z.array(zod.z.object({ val: zod.z.string() }))
|
|
3344
|
-
});
|
|
3345
|
-
|
|
3346
|
-
// src/schemas/endorsement-confirmation.ts
|
|
3347
3783
|
var EndorsementConfirmationRecordSchema = zod.z.object({
|
|
3348
3784
|
endorsement: strongRefSchema,
|
|
3349
3785
|
createdAt: datetimeSchema
|
|
@@ -3738,7 +4174,7 @@ var ProfileVolunteeringRecordSchema = zod.z.object({
|
|
|
3738
4174
|
});
|
|
3739
4175
|
|
|
3740
4176
|
// src/index.ts
|
|
3741
|
-
var SIFA_SDK_VERSION = "0.12.
|
|
4177
|
+
var SIFA_SDK_VERSION = "0.12.10";
|
|
3742
4178
|
|
|
3743
4179
|
exports.ACTIVITY_TIERS = ACTIVITY_TIERS;
|
|
3744
4180
|
exports.ACTIVITY_VERBS = ACTIVITY_VERBS;
|
|
@@ -3957,10 +4393,12 @@ exports.sortLanguagesByProficiency = sortLanguagesByProficiency;
|
|
|
3957
4393
|
exports.sortPositions = sortPositions;
|
|
3958
4394
|
exports.sortProjects = sortProjects;
|
|
3959
4395
|
exports.sortPublications = sortPublications;
|
|
4396
|
+
exports.streamAddressSchema = streamAddressSchema;
|
|
3960
4397
|
exports.streamCardBodySchema = streamCardBodySchema;
|
|
3961
4398
|
exports.streamCardSubjectSchema = streamCardSubjectSchema;
|
|
3962
4399
|
exports.streamCardVMSchema = streamCardVMSchema;
|
|
3963
4400
|
exports.streamExternalLinkSchema = streamExternalLinkSchema;
|
|
4401
|
+
exports.streamGeoSchema = streamGeoSchema;
|
|
3964
4402
|
exports.streamMediaSchema = streamMediaSchema;
|
|
3965
4403
|
exports.streamSourceSchema = streamSourceSchema;
|
|
3966
4404
|
exports.streamThemeSchema = streamThemeSchema;
|