alternative tangled frontend (extremely wip)

feat: why is bsky's post lexicon so complex wtf

serenity 31824107 bf663b11

+196 -2
+106
src/lib/types/lexicons/app/bsky/feed/post.ts
··· 1 + import { appBskyRichtextFacetSchema } from "@/lib/types/lexicons/app/bsky/richtext/facet"; 2 + import { comAtprotoLabelDefsSelfLabelSchema } from "@/lib/types/lexicons/com/atproto/label/defs"; 3 + import { comAtprotoRepoStrongRefSchema } from "@/lib/types/lexicons/com/atproto/repo/strongRef"; 4 + import { z } from "zod/v4"; 5 + 6 + /** Embed types (union members) – stubbed as loose objects keyed by $type */ 7 + const embedImages = z 8 + .object({ $type: z.literal("app.bsky.embed.images") }) 9 + .loose() 10 + .describe("app.bsky.embed.images"); 11 + 12 + const embedVideo = z 13 + .object({ $type: z.literal("app.bsky.embed.video") }) 14 + .loose() 15 + .describe("app.bsky.embed.video"); 16 + 17 + const embedExternal = z 18 + .object({ $type: z.literal("app.bsky.embed.external") }) 19 + .loose() 20 + .describe("app.bsky.embed.external"); 21 + 22 + const embedRecord = z 23 + .object({ $type: z.literal("app.bsky.embed.record") }) 24 + .loose() 25 + .describe("app.bsky.embed.record"); 26 + 27 + const embedRecordWithMedia = z 28 + .object({ $type: z.literal("app.bsky.embed.recordWithMedia") }) 29 + .loose() 30 + .describe("app.bsky.embed.recordWithMedia"); 31 + 32 + const embed = z.discriminatedUnion("$type", [ 33 + embedImages, 34 + embedVideo, 35 + embedExternal, 36 + embedRecord, 37 + embedRecordWithMedia, 38 + ]); 39 + 40 + const replyRef = z.object({ 41 + root: comAtprotoRepoStrongRefSchema, 42 + parent: comAtprotoRepoStrongRefSchema, 43 + }); 44 + 45 + const labels = z 46 + .discriminatedUnion("$type", [comAtprotoLabelDefsSelfLabelSchema]) 47 + .describe("Self-label values for this post. Effectively content warnings."); 48 + 49 + const textSlice = z 50 + .object({ 51 + start: z.int().min(0), 52 + end: z.int().min(0), 53 + }) 54 + .describe( 55 + "Deprecated. Use app.bsky.richtext instead – A text segment. " + 56 + "Start is inclusive, end is exclusive. Indices are for utf16-encoded strings.", 57 + ); 58 + 59 + const entity = z 60 + .object({ 61 + index: textSlice, 62 + type: z.string().describe("Expected values are 'mention' and 'link'."), 63 + value: z.string(), 64 + }) 65 + .describe("Deprecated: use facets instead."); 66 + 67 + export const appBskyFeedPostSchema = z 68 + .object({ 69 + text: z 70 + .string() 71 + .max(3000) 72 + .describe( 73 + "The primary post content. May be an empty string, if there are embeds.", 74 + ), 75 + entities: z 76 + .array(entity) 77 + .optional() 78 + .describe("DEPRECATED: replaced by app.bsky.richtext.facet."), 79 + facets: z 80 + .array(appBskyRichtextFacetSchema) 81 + .optional() 82 + .describe("Annotations of text (mentions, URLs, hashtags, etc)"), 83 + reply: replyRef.optional(), 84 + embed: embed.optional(), 85 + langs: z 86 + .array(z.string().describe("BCP-47 language tag")) 87 + .max(3) 88 + .optional() 89 + .describe("Indicates human language of post primary text content."), 90 + labels: labels.optional(), 91 + tags: z 92 + .array(z.string().max(640)) 93 + .max(8) 94 + .optional() 95 + .describe( 96 + "Additional hashtags, in addition to any included in post text and facets.", 97 + ), 98 + createdAt: z.iso 99 + .datetime() 100 + .describe( 101 + "Client-declared timestamp when this post was originally created.", 102 + ), 103 + }) 104 + .describe("Record containing a Bluesky post."); 105 + 106 + export type Post = z.infer<typeof appBskyFeedPostSchema>;
+88
src/lib/types/lexicons/app/bsky/richtext/facet.ts
··· 1 + // I'm not gonna lie. I let Claude (Opus 4.6) handle this. I genuinely cannot be arsed, at least until I finish Anaxagoras. 2 + 3 + import { z } from "zod/v4"; 4 + 5 + // --------------------------------------------------------------------------- 6 + // #byteSlice 7 + // --------------------------------------------------------------------------- 8 + 9 + /** 10 + * Specifies the sub-string range a facet feature applies to. 11 + * Start index is inclusive, end index is exclusive. Indices are zero-indexed, 12 + * counting bytes of the UTF-8 encoded text. 13 + * 14 + * NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for 15 + * string slice indexing; in these languages, convert to byte arrays before 16 + * working with facets. 17 + */ 18 + export const appBskyRichtextFacetByteSliceSchema = z 19 + .object({ 20 + byteStart: z.int().min(0), 21 + byteEnd: z.int().min(0), 22 + }) 23 + .describe( 24 + "Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets.", 25 + ); 26 + 27 + export type AppBskyRichtextFacetByteSlice = z.infer< 28 + typeof appBskyRichtextFacetByteSliceSchema 29 + >; 30 + 31 + export const appBskyRichtextFacetMentionSchema = z 32 + .object({ 33 + $type: z.literal("app.bsky.richtext.facet#mention"), 34 + did: z.string().describe("DID of the mentioned account."), 35 + }) 36 + .describe( 37 + "Facet feature for mention of another account. The text is usually a handle, including a '@' prefix, but the facet reference is a DID.", 38 + ); 39 + 40 + export type AppBskyRichtextFacetMention = z.infer< 41 + typeof appBskyRichtextFacetMentionSchema 42 + >; 43 + 44 + export const appBskyRichtextFacetLinkSchema = z 45 + .object({ 46 + $type: z.literal("app.bsky.richtext.facet#link"), 47 + uri: z.url().describe("Complete URL the facet refers to."), 48 + }) 49 + .describe( 50 + "Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.", 51 + ); 52 + 53 + export type AppBskyRichtextFacetLink = z.infer< 54 + typeof appBskyRichtextFacetLinkSchema 55 + >; 56 + 57 + export const appBskyRichtextFacetTagSchema = z 58 + .object({ 59 + $type: z.literal("app.bsky.richtext.facet#tag"), 60 + tag: z 61 + .string() 62 + .max(640) 63 + .describe("The hashtag value (without leading '#')."), 64 + }) 65 + .describe( 66 + "Facet feature for a hashtag. The text usually includes a '#' prefix, but the facet reference should not (except in the case of 'double hash tags').", 67 + ); 68 + 69 + export type AppBskyRichtextFacetTag = z.infer< 70 + typeof appBskyRichtextFacetTagSchema 71 + >; 72 + 73 + export const feature = z.discriminatedUnion("$type", [ 74 + appBskyRichtextFacetMentionSchema, 75 + appBskyRichtextFacetLinkSchema, 76 + appBskyRichtextFacetTagSchema, 77 + ]); 78 + 79 + export type Feature = z.infer<typeof feature>; 80 + 81 + export const appBskyRichtextFacetSchema = z 82 + .object({ 83 + index: appBskyRichtextFacetByteSliceSchema, 84 + features: z.array(feature), 85 + }) 86 + .describe("Annotation of a sub-string within rich text."); 87 + 88 + export type AppBskyRichtextFacet = z.infer<typeof appBskyRichtextFacetSchema>;
+2 -2
src/lib/types/lexicons/com/atproto/repo/strongRef.ts
··· 2 2 3 3 export const comAtprotoRepoStrongRefSchema = z 4 4 .object({ 5 - uri: z.string().describe("AT-URI of the referenced record."), 6 - cid: z.string().describe("CID hash of the referenced record."), 5 + uri: z.string(), 6 + cid: z.string(), 7 7 }) 8 8 .describe("A URI with a content-hash fingerprint."); 9 9