prototypey.org - atproto lexicon typescript toolkit - mirror https://github.com/tylersayshi/prototypey
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

remove extra prettify to improve type perf and add bench

Tyler 9cc03533 5f3fa64a

+72 -5
+3 -3
src/lib.ts
··· 1 1 /* eslint-disable @typescript-eslint/no-empty-object-type */ 2 2 import type { Infer } from "./infer.ts"; 3 - import type { Prettify, UnionToTuple } from "./type-utils.ts"; 3 + import type { UnionToTuple } from "./type-utils.ts"; 4 4 5 5 /** @see https://atproto.com/specs/lexicon#overview-of-types */ 6 6 type LexiconType = ··· 490 490 * Creates an object type with defined properties. 491 491 * @see https://atproto.com/specs/lexicon#object 492 492 */ 493 - object<T extends ObjectProperties>(options: T): Prettify<ObjectResult<T>> { 493 + object<T extends ObjectProperties>(options: T): ObjectResult<T> { 494 494 const required = Object.keys(options).filter( 495 495 (key) => "required" in options[key] && options[key].required, 496 496 ); ··· 515 515 */ 516 516 params<Properties extends ParamsProperties>( 517 517 properties: Properties, 518 - ): Prettify<ParamsResult<Properties>> { 518 + ): ParamsResult<Properties> { 519 519 const required = Object.keys(properties).filter( 520 520 (key) => properties[key].required, 521 521 );
+69 -2
tests/infer.bench.ts
··· 9 9 }), 10 10 }); 11 11 return schema.infer; 12 - }).types([244, "instantiations"]); 12 + }).types([221, "instantiations"]); 13 13 14 14 bench("InferNS with complex nested structure", () => { 15 15 const schema = lx.namespace("test.complex", { ··· 32 32 }), 33 33 }); 34 34 return schema.infer; 35 - }).types([507, "instantiations"]); 35 + }).types([454, "instantiations"]); 36 + 37 + bench("InferNS with app.bsky.feed.defs namespace", () => { 38 + const schema = lx.namespace("app.bsky.feed.defs", { 39 + postView: lx.object({ 40 + uri: lx.string({ required: true, format: "at-uri" }), 41 + cid: lx.string({ required: true, format: "cid" }), 42 + author: lx.ref("app.bsky.actor.defs#profileViewBasic", { 43 + required: true, 44 + }), 45 + record: lx.unknown({ required: true }), 46 + embed: lx.union([ 47 + "app.bsky.embed.images#view", 48 + "app.bsky.embed.video#view", 49 + "app.bsky.embed.external#view", 50 + "app.bsky.embed.record#view", 51 + "app.bsky.embed.recordWithMedia#view", 52 + ]), 53 + bookmarkCount: lx.integer(), 54 + replyCount: lx.integer(), 55 + repostCount: lx.integer(), 56 + likeCount: lx.integer(), 57 + quoteCount: lx.integer(), 58 + indexedAt: lx.string({ required: true, format: "datetime" }), 59 + viewer: lx.ref("#viewerState"), 60 + labels: lx.array(lx.ref("com.atproto.label.defs#label")), 61 + threadgate: lx.ref("#threadgateView"), 62 + }), 63 + viewerState: lx.object({ 64 + repost: lx.string({ format: "at-uri" }), 65 + like: lx.string({ format: "at-uri" }), 66 + bookmarked: lx.boolean(), 67 + threadMuted: lx.boolean(), 68 + replyDisabled: lx.boolean(), 69 + embeddingDisabled: lx.boolean(), 70 + pinned: lx.boolean(), 71 + }), 72 + requestLess: lx.token( 73 + "Request that less content like the given feed item be shown in the feed", 74 + ), 75 + requestMore: lx.token( 76 + "Request that more content like the given feed item be shown in the feed", 77 + ), 78 + clickthroughItem: lx.token("User clicked through to the feed item"), 79 + clickthroughAuthor: lx.token( 80 + "User clicked through to the author of the feed item", 81 + ), 82 + clickthroughReposter: lx.token( 83 + "User clicked through to the reposter of the feed item", 84 + ), 85 + clickthroughEmbed: lx.token( 86 + "User clicked through to the embedded content of the feed item", 87 + ), 88 + contentModeUnspecified: lx.token( 89 + "Declares the feed generator returns any types of posts.", 90 + ), 91 + contentModeVideo: lx.token( 92 + "Declares the feed generator returns posts containing app.bsky.embed.video embeds.", 93 + ), 94 + interactionSeen: lx.token("Feed item was seen by user"), 95 + interactionLike: lx.token("User liked the feed item"), 96 + interactionRepost: lx.token("User reposted the feed item"), 97 + interactionReply: lx.token("User replied to the feed item"), 98 + interactionQuote: lx.token("User quoted the feed item"), 99 + interactionShare: lx.token("User shared the feed item"), 100 + }); 101 + return schema.infer; 102 + }).types([658, "instantiations"]);