UNPKG

@atcute/bluesky

Version:

Bluesky (app.bsky.* and chat.bsky.*) schema definitions

82 lines (81 loc) 3.16 kB
import type { $type } from '@atcute/lexicons'; import type * as AppBskyEmbedRecord from '../lexicons/types/app/bsky/embed/record.js'; import type * as AppBskyEmbedRecordWithMedia from '../lexicons/types/app/bsky/embed/recordWithMedia.js'; import type * as AppBskyFeedDefs from '../lexicons/types/app/bsky/feed/defs.js'; import type * as AppBskyFeedPost from '../lexicons/types/app/bsky/feed/post.js'; /** * a union type of all possible raw embeds. */ export interface RawEmbeds { media?: AppBskyEmbedRecordWithMedia.Main['media']; record?: AppBskyEmbedRecordWithMedia.Main['record']; } /** * a raw media embed. */ export type RawMediaEmbed = NonNullable<RawEmbeds['media']>; /** * a raw record embed. */ export type RawRecordEmbed = NonNullable<RawEmbeds['record']>; /** * extracts raw media embed from a post record embed * @param embed the embed interface to extract from * @returns the extracted raw media embed, if any */ export declare const unwrapRawMediaEmbed: (embed: AppBskyFeedPost.Main["embed"]) => RawEmbeds["media"]; /** * extracts raw record embed from a post record embed * @param embed the embed interface to extract from * @returns the extracted raw record embed, if any */ export declare const unwrapRawRecordEmbed: (embed: AppBskyFeedPost.Main["embed"]) => RawEmbeds["record"]; /** * extracts raw media and record embeds from a post record embed * @param embed the embed interface to extract from * @returns the extracted raw media and record embeds, if any */ export declare const unwrapRawEmbed: (embed: AppBskyFeedPost.Main["embed"]) => RawEmbeds; /** * a union type of all possible embeds. */ export interface Embeds { media?: AppBskyEmbedRecordWithMedia.View['media']; record?: AppBskyEmbedRecordWithMedia.View['record']['record']; } /** * a media embed. */ export type MediaEmbed = NonNullable<Embeds['media']>; /** * a record embed. */ export type RecordEmbed = NonNullable<Embeds['record']>; /** * extracts media embed from a post embed * @param embed the embed interface to extract from * @returns the extracted media embed, if any */ export declare const unwrapMediaEmbed: (embed: AppBskyFeedDefs.PostView["embed"]) => Embeds["media"]; /** * extracts record embed from a post embed * @param embed the embed interface to extract from * @returns the extracted record embed, if any */ export declare const unwrapRecordEmbed: (embed: AppBskyFeedDefs.PostView["embed"]) => Embeds["record"]; /** * extracts media and record embeds from a post embed * @param embed the embed interface to extract from * @returns the extracted media and record embeds, if any */ export declare const unwrapEmbed: (embed: AppBskyFeedDefs.PostView["embed"]) => Embeds; /** * a quote embed. */ export type QuoteEmbed = $type.enforce<AppBskyEmbedRecord.ViewBlocked | AppBskyEmbedRecord.ViewDetached | AppBskyEmbedRecord.ViewNotFound | AppBskyEmbedRecord.ViewRecord>; /** * get quote embed from a record embed * @param embed the record embed to extract from * @returns the extracted quote embed, if any */ export declare const unwrapQuoteEmbed: (embed: RecordEmbed | undefined) => QuoteEmbed | undefined;