diff --git a/packages/api/src/client/types/app/bsky/actor/defs.ts b/packages/api/src/client/types/app/bsky/actor/defs.ts index 78cff825671..c18f5618e77 100644 --- a/packages/api/src/client/types/app/bsky/actor/defs.ts +++ b/packages/api/src/client/types/app/bsky/actor/defs.ts @@ -2,13 +2,15 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' import * as AppBskyGraphDefs from '../graph/defs' import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' +const id = 'app.bsky.actor.defs' + export interface ProfileViewBasic { did: string handle: string @@ -21,16 +23,17 @@ export interface ProfileViewBasic { [k: string]: unknown } -export function isProfileViewBasic(v: unknown): v is ProfileViewBasic { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#profileViewBasic' - ) +export function isProfileViewBasic(v: unknown): v is ProfileViewBasic & { + $type: $Type<'app.bsky.actor.defs', 'profileViewBasic'> +} { + return is$typed(v, id, 'profileViewBasic') } -export function validateProfileViewBasic(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#profileViewBasic', v) +export function validateProfileViewBasic(v: unknown) { + return lexicons.validate( + `${id}#profileViewBasic`, + v, + ) as ValidationResult } export interface ProfileView { @@ -47,16 +50,17 @@ export interface ProfileView { [k: string]: unknown } -export function isProfileView(v: unknown): v is ProfileView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#profileView' - ) +export function isProfileView( + v: unknown, +): v is ProfileView & { $type: $Type<'app.bsky.actor.defs', 'profileView'> } { + return is$typed(v, id, 'profileView') } -export function validateProfileView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#profileView', v) +export function validateProfileView(v: unknown) { + return lexicons.validate( + `${id}#profileView`, + v, + ) as ValidationResult } export interface ProfileViewDetailed { @@ -79,16 +83,17 @@ export interface ProfileViewDetailed { [k: string]: unknown } -export function isProfileViewDetailed(v: unknown): v is ProfileViewDetailed { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#profileViewDetailed' - ) +export function isProfileViewDetailed(v: unknown): v is ProfileViewDetailed & { + $type: $Type<'app.bsky.actor.defs', 'profileViewDetailed'> +} { + return is$typed(v, id, 'profileViewDetailed') } -export function validateProfileViewDetailed(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#profileViewDetailed', v) +export function validateProfileViewDetailed(v: unknown) { + return lexicons.validate( + `${id}#profileViewDetailed`, + v, + ) as ValidationResult } export interface ProfileAssociated { @@ -100,16 +105,17 @@ export interface ProfileAssociated { [k: string]: unknown } -export function isProfileAssociated(v: unknown): v is ProfileAssociated { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#profileAssociated' - ) +export function isProfileAssociated(v: unknown): v is ProfileAssociated & { + $type: $Type<'app.bsky.actor.defs', 'profileAssociated'> +} { + return is$typed(v, id, 'profileAssociated') } -export function validateProfileAssociated(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#profileAssociated', v) +export function validateProfileAssociated(v: unknown) { + return lexicons.validate( + `${id}#profileAssociated`, + v, + ) as ValidationResult } export interface ProfileAssociatedChat { @@ -119,16 +125,17 @@ export interface ProfileAssociatedChat { export function isProfileAssociatedChat( v: unknown, -): v is ProfileAssociatedChat { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#profileAssociatedChat' - ) +): v is ProfileAssociatedChat & { + $type: $Type<'app.bsky.actor.defs', 'profileAssociatedChat'> +} { + return is$typed(v, id, 'profileAssociatedChat') } -export function validateProfileAssociatedChat(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#profileAssociatedChat', v) +export function validateProfileAssociatedChat(v: unknown) { + return lexicons.validate( + `${id}#profileAssociatedChat`, + v, + ) as ValidationResult } /** Metadata about the requesting account's relationship with the subject account. Only has meaningful content for authed requests. */ @@ -144,16 +151,17 @@ export interface ViewerState { [k: string]: unknown } -export function isViewerState(v: unknown): v is ViewerState { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#viewerState' - ) +export function isViewerState( + v: unknown, +): v is ViewerState & { $type: $Type<'app.bsky.actor.defs', 'viewerState'> } { + return is$typed(v, id, 'viewerState') } -export function validateViewerState(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#viewerState', v) +export function validateViewerState(v: unknown) { + return lexicons.validate( + `${id}#viewerState`, + v, + ) as ValidationResult } /** The subject's followers whom you also follow */ @@ -163,16 +171,17 @@ export interface KnownFollowers { [k: string]: unknown } -export function isKnownFollowers(v: unknown): v is KnownFollowers { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#knownFollowers' - ) +export function isKnownFollowers(v: unknown): v is KnownFollowers & { + $type: $Type<'app.bsky.actor.defs', 'knownFollowers'> +} { + return is$typed(v, id, 'knownFollowers') } -export function validateKnownFollowers(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#knownFollowers', v) +export function validateKnownFollowers(v: unknown) { + return lexicons.validate( + `${id}#knownFollowers`, + v, + ) as ValidationResult } export type Preferences = ( @@ -196,16 +205,17 @@ export interface AdultContentPref { [k: string]: unknown } -export function isAdultContentPref(v: unknown): v is AdultContentPref { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#adultContentPref' - ) +export function isAdultContentPref(v: unknown): v is AdultContentPref & { + $type: $Type<'app.bsky.actor.defs', 'adultContentPref'> +} { + return is$typed(v, id, 'adultContentPref') } -export function validateAdultContentPref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#adultContentPref', v) +export function validateAdultContentPref(v: unknown) { + return lexicons.validate( + `${id}#adultContentPref`, + v, + ) as ValidationResult } export interface ContentLabelPref { @@ -216,16 +226,17 @@ export interface ContentLabelPref { [k: string]: unknown } -export function isContentLabelPref(v: unknown): v is ContentLabelPref { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#contentLabelPref' - ) +export function isContentLabelPref(v: unknown): v is ContentLabelPref & { + $type: $Type<'app.bsky.actor.defs', 'contentLabelPref'> +} { + return is$typed(v, id, 'contentLabelPref') } -export function validateContentLabelPref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#contentLabelPref', v) +export function validateContentLabelPref(v: unknown) { + return lexicons.validate( + `${id}#contentLabelPref`, + v, + ) as ValidationResult } export interface SavedFeed { @@ -236,16 +247,14 @@ export interface SavedFeed { [k: string]: unknown } -export function isSavedFeed(v: unknown): v is SavedFeed { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#savedFeed' - ) +export function isSavedFeed( + v: unknown, +): v is SavedFeed & { $type: $Type<'app.bsky.actor.defs', 'savedFeed'> } { + return is$typed(v, id, 'savedFeed') } -export function validateSavedFeed(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#savedFeed', v) +export function validateSavedFeed(v: unknown) { + return lexicons.validate(`${id}#savedFeed`, v) as ValidationResult } export interface SavedFeedsPrefV2 { @@ -253,16 +262,17 @@ export interface SavedFeedsPrefV2 { [k: string]: unknown } -export function isSavedFeedsPrefV2(v: unknown): v is SavedFeedsPrefV2 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#savedFeedsPrefV2' - ) +export function isSavedFeedsPrefV2(v: unknown): v is SavedFeedsPrefV2 & { + $type: $Type<'app.bsky.actor.defs', 'savedFeedsPrefV2'> +} { + return is$typed(v, id, 'savedFeedsPrefV2') } -export function validateSavedFeedsPrefV2(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#savedFeedsPrefV2', v) +export function validateSavedFeedsPrefV2(v: unknown) { + return lexicons.validate( + `${id}#savedFeedsPrefV2`, + v, + ) as ValidationResult } export interface SavedFeedsPref { @@ -272,16 +282,17 @@ export interface SavedFeedsPref { [k: string]: unknown } -export function isSavedFeedsPref(v: unknown): v is SavedFeedsPref { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#savedFeedsPref' - ) +export function isSavedFeedsPref(v: unknown): v is SavedFeedsPref & { + $type: $Type<'app.bsky.actor.defs', 'savedFeedsPref'> +} { + return is$typed(v, id, 'savedFeedsPref') } -export function validateSavedFeedsPref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#savedFeedsPref', v) +export function validateSavedFeedsPref(v: unknown) { + return lexicons.validate( + `${id}#savedFeedsPref`, + v, + ) as ValidationResult } export interface PersonalDetailsPref { @@ -290,16 +301,17 @@ export interface PersonalDetailsPref { [k: string]: unknown } -export function isPersonalDetailsPref(v: unknown): v is PersonalDetailsPref { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#personalDetailsPref' - ) +export function isPersonalDetailsPref(v: unknown): v is PersonalDetailsPref & { + $type: $Type<'app.bsky.actor.defs', 'personalDetailsPref'> +} { + return is$typed(v, id, 'personalDetailsPref') } -export function validatePersonalDetailsPref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#personalDetailsPref', v) +export function validatePersonalDetailsPref(v: unknown) { + return lexicons.validate( + `${id}#personalDetailsPref`, + v, + ) as ValidationResult } export interface FeedViewPref { @@ -318,16 +330,17 @@ export interface FeedViewPref { [k: string]: unknown } -export function isFeedViewPref(v: unknown): v is FeedViewPref { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#feedViewPref' - ) +export function isFeedViewPref( + v: unknown, +): v is FeedViewPref & { $type: $Type<'app.bsky.actor.defs', 'feedViewPref'> } { + return is$typed(v, id, 'feedViewPref') } -export function validateFeedViewPref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#feedViewPref', v) +export function validateFeedViewPref(v: unknown) { + return lexicons.validate( + `${id}#feedViewPref`, + v, + ) as ValidationResult } export interface ThreadViewPref { @@ -344,16 +357,17 @@ export interface ThreadViewPref { [k: string]: unknown } -export function isThreadViewPref(v: unknown): v is ThreadViewPref { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#threadViewPref' - ) +export function isThreadViewPref(v: unknown): v is ThreadViewPref & { + $type: $Type<'app.bsky.actor.defs', 'threadViewPref'> +} { + return is$typed(v, id, 'threadViewPref') } -export function validateThreadViewPref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#threadViewPref', v) +export function validateThreadViewPref(v: unknown) { + return lexicons.validate( + `${id}#threadViewPref`, + v, + ) as ValidationResult } export interface InterestsPref { @@ -362,16 +376,17 @@ export interface InterestsPref { [k: string]: unknown } -export function isInterestsPref(v: unknown): v is InterestsPref { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#interestsPref' - ) +export function isInterestsPref(v: unknown): v is InterestsPref & { + $type: $Type<'app.bsky.actor.defs', 'interestsPref'> +} { + return is$typed(v, id, 'interestsPref') } -export function validateInterestsPref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#interestsPref', v) +export function validateInterestsPref(v: unknown) { + return lexicons.validate( + `${id}#interestsPref`, + v, + ) as ValidationResult } export type MutedWordTarget = 'content' | 'tag' | (string & {}) @@ -390,16 +405,14 @@ export interface MutedWord { [k: string]: unknown } -export function isMutedWord(v: unknown): v is MutedWord { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#mutedWord' - ) +export function isMutedWord( + v: unknown, +): v is MutedWord & { $type: $Type<'app.bsky.actor.defs', 'mutedWord'> } { + return is$typed(v, id, 'mutedWord') } -export function validateMutedWord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#mutedWord', v) +export function validateMutedWord(v: unknown) { + return lexicons.validate(`${id}#mutedWord`, v) as ValidationResult } export interface MutedWordsPref { @@ -408,16 +421,17 @@ export interface MutedWordsPref { [k: string]: unknown } -export function isMutedWordsPref(v: unknown): v is MutedWordsPref { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#mutedWordsPref' - ) +export function isMutedWordsPref(v: unknown): v is MutedWordsPref & { + $type: $Type<'app.bsky.actor.defs', 'mutedWordsPref'> +} { + return is$typed(v, id, 'mutedWordsPref') } -export function validateMutedWordsPref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#mutedWordsPref', v) +export function validateMutedWordsPref(v: unknown) { + return lexicons.validate( + `${id}#mutedWordsPref`, + v, + ) as ValidationResult } export interface HiddenPostsPref { @@ -426,16 +440,17 @@ export interface HiddenPostsPref { [k: string]: unknown } -export function isHiddenPostsPref(v: unknown): v is HiddenPostsPref { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#hiddenPostsPref' - ) +export function isHiddenPostsPref(v: unknown): v is HiddenPostsPref & { + $type: $Type<'app.bsky.actor.defs', 'hiddenPostsPref'> +} { + return is$typed(v, id, 'hiddenPostsPref') } -export function validateHiddenPostsPref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#hiddenPostsPref', v) +export function validateHiddenPostsPref(v: unknown) { + return lexicons.validate( + `${id}#hiddenPostsPref`, + v, + ) as ValidationResult } export interface LabelersPref { @@ -443,16 +458,17 @@ export interface LabelersPref { [k: string]: unknown } -export function isLabelersPref(v: unknown): v is LabelersPref { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#labelersPref' - ) +export function isLabelersPref( + v: unknown, +): v is LabelersPref & { $type: $Type<'app.bsky.actor.defs', 'labelersPref'> } { + return is$typed(v, id, 'labelersPref') } -export function validateLabelersPref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#labelersPref', v) +export function validateLabelersPref(v: unknown) { + return lexicons.validate( + `${id}#labelersPref`, + v, + ) as ValidationResult } export interface LabelerPrefItem { @@ -460,16 +476,17 @@ export interface LabelerPrefItem { [k: string]: unknown } -export function isLabelerPrefItem(v: unknown): v is LabelerPrefItem { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#labelerPrefItem' - ) +export function isLabelerPrefItem(v: unknown): v is LabelerPrefItem & { + $type: $Type<'app.bsky.actor.defs', 'labelerPrefItem'> +} { + return is$typed(v, id, 'labelerPrefItem') } -export function validateLabelerPrefItem(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#labelerPrefItem', v) +export function validateLabelerPrefItem(v: unknown) { + return lexicons.validate( + `${id}#labelerPrefItem`, + v, + ) as ValidationResult } /** A grab bag of state that's specific to the bsky.app program. Third-party apps shouldn't use this. */ @@ -482,16 +499,17 @@ export interface BskyAppStatePref { [k: string]: unknown } -export function isBskyAppStatePref(v: unknown): v is BskyAppStatePref { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#bskyAppStatePref' - ) +export function isBskyAppStatePref(v: unknown): v is BskyAppStatePref & { + $type: $Type<'app.bsky.actor.defs', 'bskyAppStatePref'> +} { + return is$typed(v, id, 'bskyAppStatePref') } -export function validateBskyAppStatePref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#bskyAppStatePref', v) +export function validateBskyAppStatePref(v: unknown) { + return lexicons.validate( + `${id}#bskyAppStatePref`, + v, + ) as ValidationResult } /** If set, an active progress guide. Once completed, can be set to undefined. Should have unspecced fields tracking progress. */ @@ -500,16 +518,19 @@ export interface BskyAppProgressGuide { [k: string]: unknown } -export function isBskyAppProgressGuide(v: unknown): v is BskyAppProgressGuide { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#bskyAppProgressGuide' - ) +export function isBskyAppProgressGuide( + v: unknown, +): v is BskyAppProgressGuide & { + $type: $Type<'app.bsky.actor.defs', 'bskyAppProgressGuide'> +} { + return is$typed(v, id, 'bskyAppProgressGuide') } -export function validateBskyAppProgressGuide(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#bskyAppProgressGuide', v) +export function validateBskyAppProgressGuide(v: unknown) { + return lexicons.validate( + `${id}#bskyAppProgressGuide`, + v, + ) as ValidationResult } /** A new user experiences (NUX) storage object */ @@ -523,12 +544,12 @@ export interface Nux { [k: string]: unknown } -export function isNux(v: unknown): v is Nux { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.actor.defs#nux' - ) +export function isNux( + v: unknown, +): v is Nux & { $type: $Type<'app.bsky.actor.defs', 'nux'> } { + return is$typed(v, id, 'nux') } -export function validateNux(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#nux', v) +export function validateNux(v: unknown) { + return lexicons.validate(`${id}#nux`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/actor/getPreferences.ts b/packages/api/src/client/types/app/bsky/actor/getPreferences.ts index 6cc35cc3c62..31e7e98c29d 100644 --- a/packages/api/src/client/types/app/bsky/actor/getPreferences.ts +++ b/packages/api/src/client/types/app/bsky/actor/getPreferences.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from './defs' +const id = 'app.bsky.actor.getPreferences' + export interface QueryParams {} export type InputSchema = undefined diff --git a/packages/api/src/client/types/app/bsky/actor/getProfile.ts b/packages/api/src/client/types/app/bsky/actor/getProfile.ts index 13618b6c2f7..6b9b7bc9759 100644 --- a/packages/api/src/client/types/app/bsky/actor/getProfile.ts +++ b/packages/api/src/client/types/app/bsky/actor/getProfile.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from './defs' +const id = 'app.bsky.actor.getProfile' + export interface QueryParams { /** Handle or DID of account to fetch profile of. */ actor: string diff --git a/packages/api/src/client/types/app/bsky/actor/getProfiles.ts b/packages/api/src/client/types/app/bsky/actor/getProfiles.ts index 2207218ac69..cb37b97f1cf 100644 --- a/packages/api/src/client/types/app/bsky/actor/getProfiles.ts +++ b/packages/api/src/client/types/app/bsky/actor/getProfiles.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from './defs' +const id = 'app.bsky.actor.getProfiles' + export interface QueryParams { actors: string[] } diff --git a/packages/api/src/client/types/app/bsky/actor/getSuggestions.ts b/packages/api/src/client/types/app/bsky/actor/getSuggestions.ts index 48553fd1b85..972adadf066 100644 --- a/packages/api/src/client/types/app/bsky/actor/getSuggestions.ts +++ b/packages/api/src/client/types/app/bsky/actor/getSuggestions.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from './defs' +const id = 'app.bsky.actor.getSuggestions' + export interface QueryParams { limit?: number cursor?: string diff --git a/packages/api/src/client/types/app/bsky/actor/profile.ts b/packages/api/src/client/types/app/bsky/actor/profile.ts index c109e93f9ab..9463df7cd24 100644 --- a/packages/api/src/client/types/app/bsky/actor/profile.ts +++ b/packages/api/src/client/types/app/bsky/actor/profile.ts @@ -2,12 +2,14 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' +const id = 'app.bsky.actor.profile' + export interface Record { displayName?: string /** Free-form profile description text. */ @@ -25,15 +27,12 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.actor.profile#main' || - v.$type === 'app.bsky.actor.profile') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.actor.profile', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.profile#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/actor/putPreferences.ts b/packages/api/src/client/types/app/bsky/actor/putPreferences.ts index 834b1bd247c..05f013edf7f 100644 --- a/packages/api/src/client/types/app/bsky/actor/putPreferences.ts +++ b/packages/api/src/client/types/app/bsky/actor/putPreferences.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from './defs' +const id = 'app.bsky.actor.putPreferences' + export interface QueryParams {} export interface InputSchema { diff --git a/packages/api/src/client/types/app/bsky/actor/searchActors.ts b/packages/api/src/client/types/app/bsky/actor/searchActors.ts index bcbde2b7bfb..d9b695f3e07 100644 --- a/packages/api/src/client/types/app/bsky/actor/searchActors.ts +++ b/packages/api/src/client/types/app/bsky/actor/searchActors.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from './defs' +const id = 'app.bsky.actor.searchActors' + export interface QueryParams { /** DEPRECATED: use 'q' instead. */ term?: string diff --git a/packages/api/src/client/types/app/bsky/actor/searchActorsTypeahead.ts b/packages/api/src/client/types/app/bsky/actor/searchActorsTypeahead.ts index abed0289f27..69ca089e356 100644 --- a/packages/api/src/client/types/app/bsky/actor/searchActorsTypeahead.ts +++ b/packages/api/src/client/types/app/bsky/actor/searchActorsTypeahead.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from './defs' +const id = 'app.bsky.actor.searchActorsTypeahead' + export interface QueryParams { /** DEPRECATED: use 'q' instead. */ term?: string diff --git a/packages/api/src/client/types/app/bsky/embed/defs.ts b/packages/api/src/client/types/app/bsky/embed/defs.ts index b7b753d65f6..662d2ea7b80 100644 --- a/packages/api/src/client/types/app/bsky/embed/defs.ts +++ b/packages/api/src/client/types/app/bsky/embed/defs.ts @@ -2,9 +2,11 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.embed.defs' /** width:height represents an aspect ratio. It may be approximate, and may not correspond to absolute dimensions in any given unit. */ export interface AspectRatio { @@ -13,14 +15,15 @@ export interface AspectRatio { [k: string]: unknown } -export function isAspectRatio(v: unknown): v is AspectRatio { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.defs#aspectRatio' - ) +export function isAspectRatio( + v: unknown, +): v is AspectRatio & { $type: $Type<'app.bsky.embed.defs', 'aspectRatio'> } { + return is$typed(v, id, 'aspectRatio') } -export function validateAspectRatio(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.defs#aspectRatio', v) +export function validateAspectRatio(v: unknown) { + return lexicons.validate( + `${id}#aspectRatio`, + v, + ) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/embed/external.ts b/packages/api/src/client/types/app/bsky/embed/external.ts index 5832cbb3987..0ca9b292aa2 100644 --- a/packages/api/src/client/types/app/bsky/embed/external.ts +++ b/packages/api/src/client/types/app/bsky/embed/external.ts @@ -2,9 +2,11 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.embed.external' /** A representation of some externally linked content (eg, a URL and 'card'), embedded in a Bluesky record (eg, a post). */ export interface Main { @@ -12,17 +14,14 @@ export interface Main { [k: string]: unknown } -export function isMain(v: unknown): v is Main { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.embed.external#main' || - v.$type === 'app.bsky.embed.external') - ) +export function isMain( + v: unknown, +): v is Main & { $type: $Type<'app.bsky.embed.external', 'main'> } { + return is$typed(v, id, 'main') } -export function validateMain(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.external#main', v) +export function validateMain(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult
} export interface External { @@ -33,16 +32,14 @@ export interface External { [k: string]: unknown } -export function isExternal(v: unknown): v is External { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.external#external' - ) +export function isExternal( + v: unknown, +): v is External & { $type: $Type<'app.bsky.embed.external', 'external'> } { + return is$typed(v, id, 'external') } -export function validateExternal(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.external#external', v) +export function validateExternal(v: unknown) { + return lexicons.validate(`${id}#external`, v) as ValidationResult } export interface View { @@ -50,16 +47,14 @@ export interface View { [k: string]: unknown } -export function isView(v: unknown): v is View { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.external#view' - ) +export function isView( + v: unknown, +): v is View & { $type: $Type<'app.bsky.embed.external', 'view'> } { + return is$typed(v, id, 'view') } -export function validateView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.external#view', v) +export function validateView(v: unknown) { + return lexicons.validate(`${id}#view`, v) as ValidationResult } export interface ViewExternal { @@ -70,14 +65,15 @@ export interface ViewExternal { [k: string]: unknown } -export function isViewExternal(v: unknown): v is ViewExternal { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.external#viewExternal' - ) +export function isViewExternal(v: unknown): v is ViewExternal & { + $type: $Type<'app.bsky.embed.external', 'viewExternal'> +} { + return is$typed(v, id, 'viewExternal') } -export function validateViewExternal(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.external#viewExternal', v) +export function validateViewExternal(v: unknown) { + return lexicons.validate( + `${id}#viewExternal`, + v, + ) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/embed/images.ts b/packages/api/src/client/types/app/bsky/embed/images.ts index 886ad7c5c5b..81fc960b1ab 100644 --- a/packages/api/src/client/types/app/bsky/embed/images.ts +++ b/packages/api/src/client/types/app/bsky/embed/images.ts @@ -2,27 +2,26 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyEmbedDefs from './defs' +const id = 'app.bsky.embed.images' + export interface Main { images: Image[] [k: string]: unknown } -export function isMain(v: unknown): v is Main { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.embed.images#main' || - v.$type === 'app.bsky.embed.images') - ) +export function isMain( + v: unknown, +): v is Main & { $type: $Type<'app.bsky.embed.images', 'main'> } { + return is$typed(v, id, 'main') } -export function validateMain(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.images#main', v) +export function validateMain(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult
} export interface Image { @@ -33,14 +32,14 @@ export interface Image { [k: string]: unknown } -export function isImage(v: unknown): v is Image { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.embed.images#image' - ) +export function isImage( + v: unknown, +): v is Image & { $type: $Type<'app.bsky.embed.images', 'image'> } { + return is$typed(v, id, 'image') } -export function validateImage(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.images#image', v) +export function validateImage(v: unknown) { + return lexicons.validate(`${id}#image`, v) as ValidationResult } export interface View { @@ -48,14 +47,14 @@ export interface View { [k: string]: unknown } -export function isView(v: unknown): v is View { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.embed.images#view' - ) +export function isView( + v: unknown, +): v is View & { $type: $Type<'app.bsky.embed.images', 'view'> } { + return is$typed(v, id, 'view') } -export function validateView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.images#view', v) +export function validateView(v: unknown) { + return lexicons.validate(`${id}#view`, v) as ValidationResult } export interface ViewImage { @@ -69,14 +68,12 @@ export interface ViewImage { [k: string]: unknown } -export function isViewImage(v: unknown): v is ViewImage { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.images#viewImage' - ) +export function isViewImage( + v: unknown, +): v is ViewImage & { $type: $Type<'app.bsky.embed.images', 'viewImage'> } { + return is$typed(v, id, 'viewImage') } -export function validateViewImage(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.images#viewImage', v) +export function validateViewImage(v: unknown) { + return lexicons.validate(`${id}#viewImage`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/embed/record.ts b/packages/api/src/client/types/app/bsky/embed/record.ts index a3744c29246..5b2bc9a62b6 100644 --- a/packages/api/src/client/types/app/bsky/embed/record.ts +++ b/packages/api/src/client/types/app/bsky/embed/record.ts @@ -2,9 +2,9 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' import * as AppBskyFeedDefs from '../feed/defs' import * as AppBskyGraphDefs from '../graph/defs' @@ -16,22 +16,21 @@ import * as AppBskyEmbedVideo from './video' import * as AppBskyEmbedExternal from './external' import * as AppBskyEmbedRecordWithMedia from './recordWithMedia' +const id = 'app.bsky.embed.record' + export interface Main { record: ComAtprotoRepoStrongRef.Main [k: string]: unknown } -export function isMain(v: unknown): v is Main { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.embed.record#main' || - v.$type === 'app.bsky.embed.record') - ) +export function isMain( + v: unknown, +): v is Main & { $type: $Type<'app.bsky.embed.record', 'main'> } { + return is$typed(v, id, 'main') } -export function validateMain(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.record#main', v) +export function validateMain(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult
} export interface View { @@ -48,14 +47,14 @@ export interface View { [k: string]: unknown } -export function isView(v: unknown): v is View { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.embed.record#view' - ) +export function isView( + v: unknown, +): v is View & { $type: $Type<'app.bsky.embed.record', 'view'> } { + return is$typed(v, id, 'view') } -export function validateView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.record#view', v) +export function validateView(v: unknown) { + return lexicons.validate(`${id}#view`, v) as ValidationResult } export interface ViewRecord { @@ -81,16 +80,17 @@ export interface ViewRecord { [k: string]: unknown } -export function isViewRecord(v: unknown): v is ViewRecord { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.record#viewRecord' - ) +export function isViewRecord( + v: unknown, +): v is ViewRecord & { $type: $Type<'app.bsky.embed.record', 'viewRecord'> } { + return is$typed(v, id, 'viewRecord') } -export function validateViewRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.record#viewRecord', v) +export function validateViewRecord(v: unknown) { + return lexicons.validate( + `${id}#viewRecord`, + v, + ) as ValidationResult } export interface ViewNotFound { @@ -99,16 +99,17 @@ export interface ViewNotFound { [k: string]: unknown } -export function isViewNotFound(v: unknown): v is ViewNotFound { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.record#viewNotFound' - ) +export function isViewNotFound(v: unknown): v is ViewNotFound & { + $type: $Type<'app.bsky.embed.record', 'viewNotFound'> +} { + return is$typed(v, id, 'viewNotFound') } -export function validateViewNotFound(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.record#viewNotFound', v) +export function validateViewNotFound(v: unknown) { + return lexicons.validate( + `${id}#viewNotFound`, + v, + ) as ValidationResult } export interface ViewBlocked { @@ -118,16 +119,17 @@ export interface ViewBlocked { [k: string]: unknown } -export function isViewBlocked(v: unknown): v is ViewBlocked { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.record#viewBlocked' - ) +export function isViewBlocked( + v: unknown, +): v is ViewBlocked & { $type: $Type<'app.bsky.embed.record', 'viewBlocked'> } { + return is$typed(v, id, 'viewBlocked') } -export function validateViewBlocked(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.record#viewBlocked', v) +export function validateViewBlocked(v: unknown) { + return lexicons.validate( + `${id}#viewBlocked`, + v, + ) as ValidationResult } export interface ViewDetached { @@ -136,14 +138,15 @@ export interface ViewDetached { [k: string]: unknown } -export function isViewDetached(v: unknown): v is ViewDetached { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.record#viewDetached' - ) +export function isViewDetached(v: unknown): v is ViewDetached & { + $type: $Type<'app.bsky.embed.record', 'viewDetached'> +} { + return is$typed(v, id, 'viewDetached') } -export function validateViewDetached(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.record#viewDetached', v) +export function validateViewDetached(v: unknown) { + return lexicons.validate( + `${id}#viewDetached`, + v, + ) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/embed/recordWithMedia.ts b/packages/api/src/client/types/app/bsky/embed/recordWithMedia.ts index 2b2b3ae6251..7c382d41853 100644 --- a/packages/api/src/client/types/app/bsky/embed/recordWithMedia.ts +++ b/packages/api/src/client/types/app/bsky/embed/recordWithMedia.ts @@ -2,14 +2,16 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyEmbedRecord from './record' import * as AppBskyEmbedImages from './images' import * as AppBskyEmbedVideo from './video' import * as AppBskyEmbedExternal from './external' +const id = 'app.bsky.embed.recordWithMedia' + export interface Main { record: AppBskyEmbedRecord.Main media: @@ -20,17 +22,14 @@ export interface Main { [k: string]: unknown } -export function isMain(v: unknown): v is Main { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.embed.recordWithMedia#main' || - v.$type === 'app.bsky.embed.recordWithMedia') - ) +export function isMain( + v: unknown, +): v is Main & { $type: $Type<'app.bsky.embed.recordWithMedia', 'main'> } { + return is$typed(v, id, 'main') } -export function validateMain(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.recordWithMedia#main', v) +export function validateMain(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult
} export interface View { @@ -43,14 +42,12 @@ export interface View { [k: string]: unknown } -export function isView(v: unknown): v is View { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.recordWithMedia#view' - ) +export function isView( + v: unknown, +): v is View & { $type: $Type<'app.bsky.embed.recordWithMedia', 'view'> } { + return is$typed(v, id, 'view') } -export function validateView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.recordWithMedia#view', v) +export function validateView(v: unknown) { + return lexicons.validate(`${id}#view`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/embed/video.ts b/packages/api/src/client/types/app/bsky/embed/video.ts index 2be451b85ed..eefabf0f660 100644 --- a/packages/api/src/client/types/app/bsky/embed/video.ts +++ b/packages/api/src/client/types/app/bsky/embed/video.ts @@ -2,11 +2,13 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyEmbedDefs from './defs' +const id = 'app.bsky.embed.video' + export interface Main { video: BlobRef captions?: Caption[] @@ -16,17 +18,14 @@ export interface Main { [k: string]: unknown } -export function isMain(v: unknown): v is Main { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.embed.video#main' || - v.$type === 'app.bsky.embed.video') - ) +export function isMain( + v: unknown, +): v is Main & { $type: $Type<'app.bsky.embed.video', 'main'> } { + return is$typed(v, id, 'main') } -export function validateMain(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.video#main', v) +export function validateMain(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult
} export interface Caption { @@ -35,16 +34,14 @@ export interface Caption { [k: string]: unknown } -export function isCaption(v: unknown): v is Caption { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.video#caption' - ) +export function isCaption( + v: unknown, +): v is Caption & { $type: $Type<'app.bsky.embed.video', 'caption'> } { + return is$typed(v, id, 'caption') } -export function validateCaption(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.video#caption', v) +export function validateCaption(v: unknown) { + return lexicons.validate(`${id}#caption`, v) as ValidationResult } export interface View { @@ -56,12 +53,12 @@ export interface View { [k: string]: unknown } -export function isView(v: unknown): v is View { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.embed.video#view' - ) +export function isView( + v: unknown, +): v is View & { $type: $Type<'app.bsky.embed.video', 'view'> } { + return is$typed(v, id, 'view') } -export function validateView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.video#view', v) +export function validateView(v: unknown) { + return lexicons.validate(`${id}#view`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/feed/defs.ts b/packages/api/src/client/types/app/bsky/feed/defs.ts index bc50067c1da..bb2693d18dc 100644 --- a/packages/api/src/client/types/app/bsky/feed/defs.ts +++ b/packages/api/src/client/types/app/bsky/feed/defs.ts @@ -2,9 +2,9 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from '../actor/defs' import * as AppBskyEmbedImages from '../embed/images' import * as AppBskyEmbedVideo from '../embed/video' @@ -15,6 +15,8 @@ import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' import * as AppBskyRichtextFacet from '../richtext/facet' import * as AppBskyGraphDefs from '../graph/defs' +const id = 'app.bsky.feed.defs' + export interface PostView { uri: string cid: string @@ -38,14 +40,14 @@ export interface PostView { [k: string]: unknown } -export function isPostView(v: unknown): v is PostView { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.feed.defs#postView' - ) +export function isPostView( + v: unknown, +): v is PostView & { $type: $Type<'app.bsky.feed.defs', 'postView'> } { + return is$typed(v, id, 'postView') } -export function validatePostView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#postView', v) +export function validatePostView(v: unknown) { + return lexicons.validate(`${id}#postView`, v) as ValidationResult } /** Metadata about the requesting account's relationship with the subject content. Only has meaningful content for authed requests. */ @@ -59,16 +61,17 @@ export interface ViewerState { [k: string]: unknown } -export function isViewerState(v: unknown): v is ViewerState { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#viewerState' - ) +export function isViewerState( + v: unknown, +): v is ViewerState & { $type: $Type<'app.bsky.feed.defs', 'viewerState'> } { + return is$typed(v, id, 'viewerState') } -export function validateViewerState(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#viewerState', v) +export function validateViewerState(v: unknown) { + return lexicons.validate( + `${id}#viewerState`, + v, + ) as ValidationResult } export interface FeedViewPost { @@ -80,16 +83,17 @@ export interface FeedViewPost { [k: string]: unknown } -export function isFeedViewPost(v: unknown): v is FeedViewPost { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#feedViewPost' - ) +export function isFeedViewPost( + v: unknown, +): v is FeedViewPost & { $type: $Type<'app.bsky.feed.defs', 'feedViewPost'> } { + return is$typed(v, id, 'feedViewPost') } -export function validateFeedViewPost(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#feedViewPost', v) +export function validateFeedViewPost(v: unknown) { + return lexicons.validate( + `${id}#feedViewPost`, + v, + ) as ValidationResult } export interface ReplyRef { @@ -107,14 +111,14 @@ export interface ReplyRef { [k: string]: unknown } -export function isReplyRef(v: unknown): v is ReplyRef { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.feed.defs#replyRef' - ) +export function isReplyRef( + v: unknown, +): v is ReplyRef & { $type: $Type<'app.bsky.feed.defs', 'replyRef'> } { + return is$typed(v, id, 'replyRef') } -export function validateReplyRef(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#replyRef', v) +export function validateReplyRef(v: unknown) { + return lexicons.validate(`${id}#replyRef`, v) as ValidationResult } export interface ReasonRepost { @@ -123,32 +127,31 @@ export interface ReasonRepost { [k: string]: unknown } -export function isReasonRepost(v: unknown): v is ReasonRepost { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#reasonRepost' - ) +export function isReasonRepost( + v: unknown, +): v is ReasonRepost & { $type: $Type<'app.bsky.feed.defs', 'reasonRepost'> } { + return is$typed(v, id, 'reasonRepost') } -export function validateReasonRepost(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#reasonRepost', v) +export function validateReasonRepost(v: unknown) { + return lexicons.validate( + `${id}#reasonRepost`, + v, + ) as ValidationResult } export interface ReasonPin { [k: string]: unknown } -export function isReasonPin(v: unknown): v is ReasonPin { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#reasonPin' - ) +export function isReasonPin( + v: unknown, +): v is ReasonPin & { $type: $Type<'app.bsky.feed.defs', 'reasonPin'> } { + return is$typed(v, id, 'reasonPin') } -export function validateReasonPin(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#reasonPin', v) +export function validateReasonPin(v: unknown) { + return lexicons.validate(`${id}#reasonPin`, v) as ValidationResult } export interface ThreadViewPost { @@ -167,16 +170,17 @@ export interface ThreadViewPost { [k: string]: unknown } -export function isThreadViewPost(v: unknown): v is ThreadViewPost { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#threadViewPost' - ) +export function isThreadViewPost(v: unknown): v is ThreadViewPost & { + $type: $Type<'app.bsky.feed.defs', 'threadViewPost'> +} { + return is$typed(v, id, 'threadViewPost') } -export function validateThreadViewPost(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#threadViewPost', v) +export function validateThreadViewPost(v: unknown) { + return lexicons.validate( + `${id}#threadViewPost`, + v, + ) as ValidationResult } export interface NotFoundPost { @@ -185,16 +189,17 @@ export interface NotFoundPost { [k: string]: unknown } -export function isNotFoundPost(v: unknown): v is NotFoundPost { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#notFoundPost' - ) +export function isNotFoundPost( + v: unknown, +): v is NotFoundPost & { $type: $Type<'app.bsky.feed.defs', 'notFoundPost'> } { + return is$typed(v, id, 'notFoundPost') } -export function validateNotFoundPost(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#notFoundPost', v) +export function validateNotFoundPost(v: unknown) { + return lexicons.validate( + `${id}#notFoundPost`, + v, + ) as ValidationResult } export interface BlockedPost { @@ -204,16 +209,17 @@ export interface BlockedPost { [k: string]: unknown } -export function isBlockedPost(v: unknown): v is BlockedPost { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#blockedPost' - ) +export function isBlockedPost( + v: unknown, +): v is BlockedPost & { $type: $Type<'app.bsky.feed.defs', 'blockedPost'> } { + return is$typed(v, id, 'blockedPost') } -export function validateBlockedPost(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#blockedPost', v) +export function validateBlockedPost(v: unknown) { + return lexicons.validate( + `${id}#blockedPost`, + v, + ) as ValidationResult } export interface BlockedAuthor { @@ -222,16 +228,17 @@ export interface BlockedAuthor { [k: string]: unknown } -export function isBlockedAuthor(v: unknown): v is BlockedAuthor { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#blockedAuthor' - ) +export function isBlockedAuthor(v: unknown): v is BlockedAuthor & { + $type: $Type<'app.bsky.feed.defs', 'blockedAuthor'> +} { + return is$typed(v, id, 'blockedAuthor') } -export function validateBlockedAuthor(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#blockedAuthor', v) +export function validateBlockedAuthor(v: unknown) { + return lexicons.validate( + `${id}#blockedAuthor`, + v, + ) as ValidationResult } export interface GeneratorView { @@ -251,16 +258,17 @@ export interface GeneratorView { [k: string]: unknown } -export function isGeneratorView(v: unknown): v is GeneratorView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#generatorView' - ) +export function isGeneratorView(v: unknown): v is GeneratorView & { + $type: $Type<'app.bsky.feed.defs', 'generatorView'> +} { + return is$typed(v, id, 'generatorView') } -export function validateGeneratorView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#generatorView', v) +export function validateGeneratorView(v: unknown) { + return lexicons.validate( + `${id}#generatorView`, + v, + ) as ValidationResult } export interface GeneratorViewerState { @@ -268,16 +276,19 @@ export interface GeneratorViewerState { [k: string]: unknown } -export function isGeneratorViewerState(v: unknown): v is GeneratorViewerState { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#generatorViewerState' - ) +export function isGeneratorViewerState( + v: unknown, +): v is GeneratorViewerState & { + $type: $Type<'app.bsky.feed.defs', 'generatorViewerState'> +} { + return is$typed(v, id, 'generatorViewerState') } -export function validateGeneratorViewerState(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#generatorViewerState', v) +export function validateGeneratorViewerState(v: unknown) { + return lexicons.validate( + `${id}#generatorViewerState`, + v, + ) as ValidationResult } export interface SkeletonFeedPost { @@ -291,16 +302,17 @@ export interface SkeletonFeedPost { [k: string]: unknown } -export function isSkeletonFeedPost(v: unknown): v is SkeletonFeedPost { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#skeletonFeedPost' - ) +export function isSkeletonFeedPost(v: unknown): v is SkeletonFeedPost & { + $type: $Type<'app.bsky.feed.defs', 'skeletonFeedPost'> +} { + return is$typed(v, id, 'skeletonFeedPost') } -export function validateSkeletonFeedPost(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#skeletonFeedPost', v) +export function validateSkeletonFeedPost(v: unknown) { + return lexicons.validate( + `${id}#skeletonFeedPost`, + v, + ) as ValidationResult } export interface SkeletonReasonRepost { @@ -308,32 +320,36 @@ export interface SkeletonReasonRepost { [k: string]: unknown } -export function isSkeletonReasonRepost(v: unknown): v is SkeletonReasonRepost { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#skeletonReasonRepost' - ) +export function isSkeletonReasonRepost( + v: unknown, +): v is SkeletonReasonRepost & { + $type: $Type<'app.bsky.feed.defs', 'skeletonReasonRepost'> +} { + return is$typed(v, id, 'skeletonReasonRepost') } -export function validateSkeletonReasonRepost(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#skeletonReasonRepost', v) +export function validateSkeletonReasonRepost(v: unknown) { + return lexicons.validate( + `${id}#skeletonReasonRepost`, + v, + ) as ValidationResult } export interface SkeletonReasonPin { [k: string]: unknown } -export function isSkeletonReasonPin(v: unknown): v is SkeletonReasonPin { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#skeletonReasonPin' - ) +export function isSkeletonReasonPin(v: unknown): v is SkeletonReasonPin & { + $type: $Type<'app.bsky.feed.defs', 'skeletonReasonPin'> +} { + return is$typed(v, id, 'skeletonReasonPin') } -export function validateSkeletonReasonPin(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#skeletonReasonPin', v) +export function validateSkeletonReasonPin(v: unknown) { + return lexicons.validate( + `${id}#skeletonReasonPin`, + v, + ) as ValidationResult } export interface ThreadgateView { @@ -344,16 +360,17 @@ export interface ThreadgateView { [k: string]: unknown } -export function isThreadgateView(v: unknown): v is ThreadgateView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#threadgateView' - ) +export function isThreadgateView(v: unknown): v is ThreadgateView & { + $type: $Type<'app.bsky.feed.defs', 'threadgateView'> +} { + return is$typed(v, id, 'threadgateView') } -export function validateThreadgateView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#threadgateView', v) +export function validateThreadgateView(v: unknown) { + return lexicons.validate( + `${id}#threadgateView`, + v, + ) as ValidationResult } export interface Interaction { @@ -377,39 +394,40 @@ export interface Interaction { [k: string]: unknown } -export function isInteraction(v: unknown): v is Interaction { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#interaction' - ) +export function isInteraction( + v: unknown, +): v is Interaction & { $type: $Type<'app.bsky.feed.defs', 'interaction'> } { + return is$typed(v, id, 'interaction') } -export function validateInteraction(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#interaction', v) +export function validateInteraction(v: unknown) { + return lexicons.validate( + `${id}#interaction`, + v, + ) as ValidationResult } /** Request that less content like the given feed item be shown in the feed */ -export const REQUESTLESS = 'app.bsky.feed.defs#requestLess' +export const REQUESTLESS = `${id}#requestLess` /** Request that more content like the given feed item be shown in the feed */ -export const REQUESTMORE = 'app.bsky.feed.defs#requestMore' +export const REQUESTMORE = `${id}#requestMore` /** User clicked through to the feed item */ -export const CLICKTHROUGHITEM = 'app.bsky.feed.defs#clickthroughItem' +export const CLICKTHROUGHITEM = `${id}#clickthroughItem` /** User clicked through to the author of the feed item */ -export const CLICKTHROUGHAUTHOR = 'app.bsky.feed.defs#clickthroughAuthor' +export const CLICKTHROUGHAUTHOR = `${id}#clickthroughAuthor` /** User clicked through to the reposter of the feed item */ -export const CLICKTHROUGHREPOSTER = 'app.bsky.feed.defs#clickthroughReposter' +export const CLICKTHROUGHREPOSTER = `${id}#clickthroughReposter` /** User clicked through to the embedded content of the feed item */ -export const CLICKTHROUGHEMBED = 'app.bsky.feed.defs#clickthroughEmbed' +export const CLICKTHROUGHEMBED = `${id}#clickthroughEmbed` /** Feed item was seen by user */ -export const INTERACTIONSEEN = 'app.bsky.feed.defs#interactionSeen' +export const INTERACTIONSEEN = `${id}#interactionSeen` /** User liked the feed item */ -export const INTERACTIONLIKE = 'app.bsky.feed.defs#interactionLike' +export const INTERACTIONLIKE = `${id}#interactionLike` /** User reposted the feed item */ -export const INTERACTIONREPOST = 'app.bsky.feed.defs#interactionRepost' +export const INTERACTIONREPOST = `${id}#interactionRepost` /** User replied to the feed item */ -export const INTERACTIONREPLY = 'app.bsky.feed.defs#interactionReply' +export const INTERACTIONREPLY = `${id}#interactionReply` /** User quoted the feed item */ -export const INTERACTIONQUOTE = 'app.bsky.feed.defs#interactionQuote' +export const INTERACTIONQUOTE = `${id}#interactionQuote` /** User shared the feed item */ -export const INTERACTIONSHARE = 'app.bsky.feed.defs#interactionShare' +export const INTERACTIONSHARE = `${id}#interactionShare` diff --git a/packages/api/src/client/types/app/bsky/feed/describeFeedGenerator.ts b/packages/api/src/client/types/app/bsky/feed/describeFeedGenerator.ts index b974f496144..81e845df856 100644 --- a/packages/api/src/client/types/app/bsky/feed/describeFeedGenerator.ts +++ b/packages/api/src/client/types/app/bsky/feed/describeFeedGenerator.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.feed.describeFeedGenerator' export interface QueryParams {} @@ -38,16 +40,14 @@ export interface Feed { [k: string]: unknown } -export function isFeed(v: unknown): v is Feed { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.describeFeedGenerator#feed' - ) +export function isFeed( + v: unknown, +): v is Feed & { $type: $Type<'app.bsky.feed.describeFeedGenerator', 'feed'> } { + return is$typed(v, id, 'feed') } -export function validateFeed(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.describeFeedGenerator#feed', v) +export function validateFeed(v: unknown) { + return lexicons.validate(`${id}#feed`, v) as ValidationResult } export interface Links { @@ -56,14 +56,12 @@ export interface Links { [k: string]: unknown } -export function isLinks(v: unknown): v is Links { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.describeFeedGenerator#links' - ) +export function isLinks(v: unknown): v is Links & { + $type: $Type<'app.bsky.feed.describeFeedGenerator', 'links'> +} { + return is$typed(v, id, 'links') } -export function validateLinks(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.describeFeedGenerator#links', v) +export function validateLinks(v: unknown) { + return lexicons.validate(`${id}#links`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/feed/generator.ts b/packages/api/src/client/types/app/bsky/feed/generator.ts index b36796dd353..b92a1a44ff9 100644 --- a/packages/api/src/client/types/app/bsky/feed/generator.ts +++ b/packages/api/src/client/types/app/bsky/feed/generator.ts @@ -2,12 +2,14 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyRichtextFacet from '../richtext/facet' import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +const id = 'app.bsky.feed.generator' + export interface Record { did: string displayName: string @@ -23,15 +25,12 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.feed.generator#main' || - v.$type === 'app.bsky.feed.generator') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.feed.generator', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.generator#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/feed/getActorFeeds.ts b/packages/api/src/client/types/app/bsky/feed/getActorFeeds.ts index e8a0cb94bd3..98032703d46 100644 --- a/packages/api/src/client/types/app/bsky/feed/getActorFeeds.ts +++ b/packages/api/src/client/types/app/bsky/feed/getActorFeeds.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.getActorFeeds' + export interface QueryParams { actor: string limit?: number diff --git a/packages/api/src/client/types/app/bsky/feed/getActorLikes.ts b/packages/api/src/client/types/app/bsky/feed/getActorLikes.ts index 1da239d96f3..99545f33fe1 100644 --- a/packages/api/src/client/types/app/bsky/feed/getActorLikes.ts +++ b/packages/api/src/client/types/app/bsky/feed/getActorLikes.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.getActorLikes' + export interface QueryParams { actor: string limit?: number diff --git a/packages/api/src/client/types/app/bsky/feed/getAuthorFeed.ts b/packages/api/src/client/types/app/bsky/feed/getAuthorFeed.ts index 77319f28d40..25bd09b0c5a 100644 --- a/packages/api/src/client/types/app/bsky/feed/getAuthorFeed.ts +++ b/packages/api/src/client/types/app/bsky/feed/getAuthorFeed.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.getAuthorFeed' + export interface QueryParams { actor: string limit?: number diff --git a/packages/api/src/client/types/app/bsky/feed/getFeed.ts b/packages/api/src/client/types/app/bsky/feed/getFeed.ts index b61a1248e2a..77cf2bf2d8e 100644 --- a/packages/api/src/client/types/app/bsky/feed/getFeed.ts +++ b/packages/api/src/client/types/app/bsky/feed/getFeed.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.getFeed' + export interface QueryParams { feed: string limit?: number diff --git a/packages/api/src/client/types/app/bsky/feed/getFeedGenerator.ts b/packages/api/src/client/types/app/bsky/feed/getFeedGenerator.ts index 8d222f8d521..d381a0e90d2 100644 --- a/packages/api/src/client/types/app/bsky/feed/getFeedGenerator.ts +++ b/packages/api/src/client/types/app/bsky/feed/getFeedGenerator.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.getFeedGenerator' + export interface QueryParams { /** AT-URI of the feed generator record. */ feed: string diff --git a/packages/api/src/client/types/app/bsky/feed/getFeedGenerators.ts b/packages/api/src/client/types/app/bsky/feed/getFeedGenerators.ts index 1d99fd6608c..76f852faf78 100644 --- a/packages/api/src/client/types/app/bsky/feed/getFeedGenerators.ts +++ b/packages/api/src/client/types/app/bsky/feed/getFeedGenerators.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.getFeedGenerators' + export interface QueryParams { feeds: string[] } diff --git a/packages/api/src/client/types/app/bsky/feed/getFeedSkeleton.ts b/packages/api/src/client/types/app/bsky/feed/getFeedSkeleton.ts index bf859cc1e87..76638027d38 100644 --- a/packages/api/src/client/types/app/bsky/feed/getFeedSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/feed/getFeedSkeleton.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.getFeedSkeleton' + export interface QueryParams { /** Reference to feed generator record describing the specific feed being requested. */ feed: string diff --git a/packages/api/src/client/types/app/bsky/feed/getLikes.ts b/packages/api/src/client/types/app/bsky/feed/getLikes.ts index 35af1b3aae5..2e3f58a2a4c 100644 --- a/packages/api/src/client/types/app/bsky/feed/getLikes.ts +++ b/packages/api/src/client/types/app/bsky/feed/getLikes.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from '../actor/defs' +const id = 'app.bsky.feed.getLikes' + export interface QueryParams { /** AT-URI of the subject (eg, a post record). */ uri: string @@ -49,12 +51,12 @@ export interface Like { [k: string]: unknown } -export function isLike(v: unknown): v is Like { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.feed.getLikes#like' - ) +export function isLike( + v: unknown, +): v is Like & { $type: $Type<'app.bsky.feed.getLikes', 'like'> } { + return is$typed(v, id, 'like') } -export function validateLike(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.getLikes#like', v) +export function validateLike(v: unknown) { + return lexicons.validate(`${id}#like`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/feed/getListFeed.ts b/packages/api/src/client/types/app/bsky/feed/getListFeed.ts index 4e47e597afd..6e6dfd6a9ff 100644 --- a/packages/api/src/client/types/app/bsky/feed/getListFeed.ts +++ b/packages/api/src/client/types/app/bsky/feed/getListFeed.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.getListFeed' + export interface QueryParams { /** Reference (AT-URI) to the list record. */ list: string diff --git a/packages/api/src/client/types/app/bsky/feed/getPostThread.ts b/packages/api/src/client/types/app/bsky/feed/getPostThread.ts index df012607df1..53f193dd8da 100644 --- a/packages/api/src/client/types/app/bsky/feed/getPostThread.ts +++ b/packages/api/src/client/types/app/bsky/feed/getPostThread.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.getPostThread' + export interface QueryParams { /** Reference (AT-URI) to post record. */ uri: string diff --git a/packages/api/src/client/types/app/bsky/feed/getPosts.ts b/packages/api/src/client/types/app/bsky/feed/getPosts.ts index 0ae8657de94..de9aa66b6cc 100644 --- a/packages/api/src/client/types/app/bsky/feed/getPosts.ts +++ b/packages/api/src/client/types/app/bsky/feed/getPosts.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.getPosts' + export interface QueryParams { /** List of post AT-URIs to return hydrated views for. */ uris: string[] diff --git a/packages/api/src/client/types/app/bsky/feed/getQuotes.ts b/packages/api/src/client/types/app/bsky/feed/getQuotes.ts index aafc487cd43..f0cff90d5e1 100644 --- a/packages/api/src/client/types/app/bsky/feed/getQuotes.ts +++ b/packages/api/src/client/types/app/bsky/feed/getQuotes.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.getQuotes' + export interface QueryParams { /** Reference (AT-URI) of post record */ uri: string diff --git a/packages/api/src/client/types/app/bsky/feed/getRepostedBy.ts b/packages/api/src/client/types/app/bsky/feed/getRepostedBy.ts index dfbac97453b..1db6626076f 100644 --- a/packages/api/src/client/types/app/bsky/feed/getRepostedBy.ts +++ b/packages/api/src/client/types/app/bsky/feed/getRepostedBy.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from '../actor/defs' +const id = 'app.bsky.feed.getRepostedBy' + export interface QueryParams { /** Reference (AT-URI) of post record */ uri: string diff --git a/packages/api/src/client/types/app/bsky/feed/getSuggestedFeeds.ts b/packages/api/src/client/types/app/bsky/feed/getSuggestedFeeds.ts index 2e9495d8c19..a62bed53103 100644 --- a/packages/api/src/client/types/app/bsky/feed/getSuggestedFeeds.ts +++ b/packages/api/src/client/types/app/bsky/feed/getSuggestedFeeds.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.getSuggestedFeeds' + export interface QueryParams { limit?: number cursor?: string diff --git a/packages/api/src/client/types/app/bsky/feed/getTimeline.ts b/packages/api/src/client/types/app/bsky/feed/getTimeline.ts index 6c5280443a9..b5a6032028c 100644 --- a/packages/api/src/client/types/app/bsky/feed/getTimeline.ts +++ b/packages/api/src/client/types/app/bsky/feed/getTimeline.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.getTimeline' + export interface QueryParams { /** Variant 'algorithm' for timeline. Implementation-specific. NOTE: most feed flexibility has been moved to feed generator mechanism. */ algorithm?: string diff --git a/packages/api/src/client/types/app/bsky/feed/like.ts b/packages/api/src/client/types/app/bsky/feed/like.ts index 10237e45f0d..1d0402a3288 100644 --- a/packages/api/src/client/types/app/bsky/feed/like.ts +++ b/packages/api/src/client/types/app/bsky/feed/like.ts @@ -2,25 +2,25 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' +const id = 'app.bsky.feed.like' + export interface Record { subject: ComAtprotoRepoStrongRef.Main createdAt: string [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.feed.like#main' || v.$type === 'app.bsky.feed.like') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.feed.like', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.like#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/feed/post.ts b/packages/api/src/client/types/app/bsky/feed/post.ts index e358409c0e0..4621ad0dc10 100644 --- a/packages/api/src/client/types/app/bsky/feed/post.ts +++ b/packages/api/src/client/types/app/bsky/feed/post.ts @@ -2,9 +2,9 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyRichtextFacet from '../richtext/facet' import * as AppBskyEmbedImages from '../embed/images' import * as AppBskyEmbedVideo from '../embed/video' @@ -14,6 +14,8 @@ import * as AppBskyEmbedRecordWithMedia from '../embed/recordWithMedia' import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' +const id = 'app.bsky.feed.post' + export interface Record { /** The primary post content. May be an empty string, if there are embeds. */ text: string @@ -41,16 +43,14 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.feed.post#main' || v.$type === 'app.bsky.feed.post') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.feed.post', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.post#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } export interface ReplyRef { @@ -59,14 +59,14 @@ export interface ReplyRef { [k: string]: unknown } -export function isReplyRef(v: unknown): v is ReplyRef { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.feed.post#replyRef' - ) +export function isReplyRef( + v: unknown, +): v is ReplyRef & { $type: $Type<'app.bsky.feed.post', 'replyRef'> } { + return is$typed(v, id, 'replyRef') } -export function validateReplyRef(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.post#replyRef', v) +export function validateReplyRef(v: unknown) { + return lexicons.validate(`${id}#replyRef`, v) as ValidationResult } /** Deprecated: use facets instead. */ @@ -78,14 +78,14 @@ export interface Entity { [k: string]: unknown } -export function isEntity(v: unknown): v is Entity { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.feed.post#entity' - ) +export function isEntity( + v: unknown, +): v is Entity & { $type: $Type<'app.bsky.feed.post', 'entity'> } { + return is$typed(v, id, 'entity') } -export function validateEntity(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.post#entity', v) +export function validateEntity(v: unknown) { + return lexicons.validate(`${id}#entity`, v) as ValidationResult } /** Deprecated. Use app.bsky.richtext instead -- A text segment. Start is inclusive, end is exclusive. Indices are for utf16-encoded strings. */ @@ -95,14 +95,12 @@ export interface TextSlice { [k: string]: unknown } -export function isTextSlice(v: unknown): v is TextSlice { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.post#textSlice' - ) +export function isTextSlice( + v: unknown, +): v is TextSlice & { $type: $Type<'app.bsky.feed.post', 'textSlice'> } { + return is$typed(v, id, 'textSlice') } -export function validateTextSlice(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.post#textSlice', v) +export function validateTextSlice(v: unknown) { + return lexicons.validate(`${id}#textSlice`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/feed/postgate.ts b/packages/api/src/client/types/app/bsky/feed/postgate.ts index aad8496699a..ff4de36f211 100644 --- a/packages/api/src/client/types/app/bsky/feed/postgate.ts +++ b/packages/api/src/client/types/app/bsky/feed/postgate.ts @@ -2,9 +2,11 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.feed.postgate' export interface Record { createdAt: string @@ -16,17 +18,14 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.feed.postgate#main' || - v.$type === 'app.bsky.feed.postgate') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.feed.postgate', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.postgate#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } /** Disables embedding of this post. */ @@ -34,14 +33,15 @@ export interface DisableRule { [k: string]: unknown } -export function isDisableRule(v: unknown): v is DisableRule { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.postgate#disableRule' - ) +export function isDisableRule(v: unknown): v is DisableRule & { + $type: $Type<'app.bsky.feed.postgate', 'disableRule'> +} { + return is$typed(v, id, 'disableRule') } -export function validateDisableRule(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.postgate#disableRule', v) +export function validateDisableRule(v: unknown) { + return lexicons.validate( + `${id}#disableRule`, + v, + ) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/feed/repost.ts b/packages/api/src/client/types/app/bsky/feed/repost.ts index 2e8f6e75548..e602112d344 100644 --- a/packages/api/src/client/types/app/bsky/feed/repost.ts +++ b/packages/api/src/client/types/app/bsky/feed/repost.ts @@ -2,26 +2,25 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' +const id = 'app.bsky.feed.repost' + export interface Record { subject: ComAtprotoRepoStrongRef.Main createdAt: string [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.feed.repost#main' || - v.$type === 'app.bsky.feed.repost') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.feed.repost', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.repost#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/feed/searchPosts.ts b/packages/api/src/client/types/app/bsky/feed/searchPosts.ts index 1a2ec64dcd2..d7d170af694 100644 --- a/packages/api/src/client/types/app/bsky/feed/searchPosts.ts +++ b/packages/api/src/client/types/app/bsky/feed/searchPosts.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.searchPosts' + export interface QueryParams { /** Search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended. */ q: string diff --git a/packages/api/src/client/types/app/bsky/feed/sendInteractions.ts b/packages/api/src/client/types/app/bsky/feed/sendInteractions.ts index 4d43e26f3dd..63701c701b4 100644 --- a/packages/api/src/client/types/app/bsky/feed/sendInteractions.ts +++ b/packages/api/src/client/types/app/bsky/feed/sendInteractions.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from './defs' +const id = 'app.bsky.feed.sendInteractions' + export interface QueryParams {} export interface InputSchema { diff --git a/packages/api/src/client/types/app/bsky/feed/threadgate.ts b/packages/api/src/client/types/app/bsky/feed/threadgate.ts index 558027fb8e9..85a1f66080d 100644 --- a/packages/api/src/client/types/app/bsky/feed/threadgate.ts +++ b/packages/api/src/client/types/app/bsky/feed/threadgate.ts @@ -2,9 +2,11 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.feed.threadgate' export interface Record { /** Reference (AT-URI) to the post record. */ @@ -21,17 +23,14 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.feed.threadgate#main' || - v.$type === 'app.bsky.feed.threadgate') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.feed.threadgate', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.threadgate#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } /** Allow replies from actors mentioned in your post. */ @@ -39,16 +38,17 @@ export interface MentionRule { [k: string]: unknown } -export function isMentionRule(v: unknown): v is MentionRule { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.threadgate#mentionRule' - ) +export function isMentionRule(v: unknown): v is MentionRule & { + $type: $Type<'app.bsky.feed.threadgate', 'mentionRule'> +} { + return is$typed(v, id, 'mentionRule') } -export function validateMentionRule(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.threadgate#mentionRule', v) +export function validateMentionRule(v: unknown) { + return lexicons.validate( + `${id}#mentionRule`, + v, + ) as ValidationResult } /** Allow replies from actors you follow. */ @@ -56,16 +56,17 @@ export interface FollowingRule { [k: string]: unknown } -export function isFollowingRule(v: unknown): v is FollowingRule { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.threadgate#followingRule' - ) +export function isFollowingRule(v: unknown): v is FollowingRule & { + $type: $Type<'app.bsky.feed.threadgate', 'followingRule'> +} { + return is$typed(v, id, 'followingRule') } -export function validateFollowingRule(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.threadgate#followingRule', v) +export function validateFollowingRule(v: unknown) { + return lexicons.validate( + `${id}#followingRule`, + v, + ) as ValidationResult } /** Allow replies from actors on a list. */ @@ -74,14 +75,12 @@ export interface ListRule { [k: string]: unknown } -export function isListRule(v: unknown): v is ListRule { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.threadgate#listRule' - ) +export function isListRule( + v: unknown, +): v is ListRule & { $type: $Type<'app.bsky.feed.threadgate', 'listRule'> } { + return is$typed(v, id, 'listRule') } -export function validateListRule(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.threadgate#listRule', v) +export function validateListRule(v: unknown) { + return lexicons.validate(`${id}#listRule`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/graph/block.ts b/packages/api/src/client/types/app/bsky/graph/block.ts index f2455fc08a2..4bc5a5f3038 100644 --- a/packages/api/src/client/types/app/bsky/graph/block.ts +++ b/packages/api/src/client/types/app/bsky/graph/block.ts @@ -2,9 +2,11 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.graph.block' export interface Record { /** DID of the account to be blocked. */ @@ -13,15 +15,12 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.graph.block#main' || - v.$type === 'app.bsky.graph.block') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.graph.block', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.block#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/graph/defs.ts b/packages/api/src/client/types/app/bsky/graph/defs.ts index aa7e2c068b5..8edbf9e888e 100644 --- a/packages/api/src/client/types/app/bsky/graph/defs.ts +++ b/packages/api/src/client/types/app/bsky/graph/defs.ts @@ -2,14 +2,16 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' import * as AppBskyActorDefs from '../actor/defs' import * as AppBskyRichtextFacet from '../richtext/facet' import * as AppBskyFeedDefs from '../feed/defs' +const id = 'app.bsky.graph.defs' + export interface ListViewBasic { uri: string cid: string @@ -23,16 +25,17 @@ export interface ListViewBasic { [k: string]: unknown } -export function isListViewBasic(v: unknown): v is ListViewBasic { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#listViewBasic' - ) +export function isListViewBasic(v: unknown): v is ListViewBasic & { + $type: $Type<'app.bsky.graph.defs', 'listViewBasic'> +} { + return is$typed(v, id, 'listViewBasic') } -export function validateListViewBasic(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#listViewBasic', v) +export function validateListViewBasic(v: unknown) { + return lexicons.validate( + `${id}#listViewBasic`, + v, + ) as ValidationResult } export interface ListView { @@ -51,16 +54,14 @@ export interface ListView { [k: string]: unknown } -export function isListView(v: unknown): v is ListView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#listView' - ) +export function isListView( + v: unknown, +): v is ListView & { $type: $Type<'app.bsky.graph.defs', 'listView'> } { + return is$typed(v, id, 'listView') } -export function validateListView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#listView', v) +export function validateListView(v: unknown) { + return lexicons.validate(`${id}#listView`, v) as ValidationResult } export interface ListItemView { @@ -69,16 +70,17 @@ export interface ListItemView { [k: string]: unknown } -export function isListItemView(v: unknown): v is ListItemView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#listItemView' - ) +export function isListItemView( + v: unknown, +): v is ListItemView & { $type: $Type<'app.bsky.graph.defs', 'listItemView'> } { + return is$typed(v, id, 'listItemView') } -export function validateListItemView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#listItemView', v) +export function validateListItemView(v: unknown) { + return lexicons.validate( + `${id}#listItemView`, + v, + ) as ValidationResult } export interface StarterPackView { @@ -96,16 +98,17 @@ export interface StarterPackView { [k: string]: unknown } -export function isStarterPackView(v: unknown): v is StarterPackView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#starterPackView' - ) +export function isStarterPackView(v: unknown): v is StarterPackView & { + $type: $Type<'app.bsky.graph.defs', 'starterPackView'> +} { + return is$typed(v, id, 'starterPackView') } -export function validateStarterPackView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#starterPackView', v) +export function validateStarterPackView(v: unknown) { + return lexicons.validate( + `${id}#starterPackView`, + v, + ) as ValidationResult } export interface StarterPackViewBasic { @@ -121,16 +124,19 @@ export interface StarterPackViewBasic { [k: string]: unknown } -export function isStarterPackViewBasic(v: unknown): v is StarterPackViewBasic { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#starterPackViewBasic' - ) +export function isStarterPackViewBasic( + v: unknown, +): v is StarterPackViewBasic & { + $type: $Type<'app.bsky.graph.defs', 'starterPackViewBasic'> +} { + return is$typed(v, id, 'starterPackViewBasic') } -export function validateStarterPackViewBasic(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#starterPackViewBasic', v) +export function validateStarterPackViewBasic(v: unknown) { + return lexicons.validate( + `${id}#starterPackViewBasic`, + v, + ) as ValidationResult } export type ListPurpose = @@ -140,11 +146,11 @@ export type ListPurpose = | (string & {}) /** A list of actors to apply an aggregate moderation action (mute/block) on. */ -export const MODLIST = 'app.bsky.graph.defs#modlist' +export const MODLIST = `${id}#modlist` /** A list of actors used for curation purposes such as list feeds or interaction gating. */ -export const CURATELIST = 'app.bsky.graph.defs#curatelist' +export const CURATELIST = `${id}#curatelist` /** A list of actors used for only for reference purposes such as within a starter pack. */ -export const REFERENCELIST = 'app.bsky.graph.defs#referencelist' +export const REFERENCELIST = `${id}#referencelist` export interface ListViewerState { muted?: boolean @@ -152,16 +158,17 @@ export interface ListViewerState { [k: string]: unknown } -export function isListViewerState(v: unknown): v is ListViewerState { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#listViewerState' - ) +export function isListViewerState(v: unknown): v is ListViewerState & { + $type: $Type<'app.bsky.graph.defs', 'listViewerState'> +} { + return is$typed(v, id, 'listViewerState') } -export function validateListViewerState(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#listViewerState', v) +export function validateListViewerState(v: unknown) { + return lexicons.validate( + `${id}#listViewerState`, + v, + ) as ValidationResult } /** indicates that a handle or DID could not be resolved */ @@ -171,16 +178,17 @@ export interface NotFoundActor { [k: string]: unknown } -export function isNotFoundActor(v: unknown): v is NotFoundActor { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#notFoundActor' - ) +export function isNotFoundActor(v: unknown): v is NotFoundActor & { + $type: $Type<'app.bsky.graph.defs', 'notFoundActor'> +} { + return is$typed(v, id, 'notFoundActor') } -export function validateNotFoundActor(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#notFoundActor', v) +export function validateNotFoundActor(v: unknown) { + return lexicons.validate( + `${id}#notFoundActor`, + v, + ) as ValidationResult } /** lists the bi-directional graph relationships between one actor (not indicated in the object), and the target actors (the DID included in the object) */ @@ -193,14 +201,15 @@ export interface Relationship { [k: string]: unknown } -export function isRelationship(v: unknown): v is Relationship { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#relationship' - ) +export function isRelationship( + v: unknown, +): v is Relationship & { $type: $Type<'app.bsky.graph.defs', 'relationship'> } { + return is$typed(v, id, 'relationship') } -export function validateRelationship(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#relationship', v) +export function validateRelationship(v: unknown) { + return lexicons.validate( + `${id}#relationship`, + v, + ) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/graph/follow.ts b/packages/api/src/client/types/app/bsky/graph/follow.ts index a68f434f3c8..cd7728fdd18 100644 --- a/packages/api/src/client/types/app/bsky/graph/follow.ts +++ b/packages/api/src/client/types/app/bsky/graph/follow.ts @@ -2,9 +2,11 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.graph.follow' export interface Record { subject: string @@ -12,15 +14,12 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.graph.follow#main' || - v.$type === 'app.bsky.graph.follow') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.graph.follow', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.follow#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/graph/getActorStarterPacks.ts b/packages/api/src/client/types/app/bsky/graph/getActorStarterPacks.ts index bb374e2318d..0d56a3536d0 100644 --- a/packages/api/src/client/types/app/bsky/graph/getActorStarterPacks.ts +++ b/packages/api/src/client/types/app/bsky/graph/getActorStarterPacks.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyGraphDefs from './defs' +const id = 'app.bsky.graph.getActorStarterPacks' + export interface QueryParams { actor: string limit?: number diff --git a/packages/api/src/client/types/app/bsky/graph/getBlocks.ts b/packages/api/src/client/types/app/bsky/graph/getBlocks.ts index f0e4bd96bc8..7858841eb61 100644 --- a/packages/api/src/client/types/app/bsky/graph/getBlocks.ts +++ b/packages/api/src/client/types/app/bsky/graph/getBlocks.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from '../actor/defs' +const id = 'app.bsky.graph.getBlocks' + export interface QueryParams { limit?: number cursor?: string diff --git a/packages/api/src/client/types/app/bsky/graph/getFollowers.ts b/packages/api/src/client/types/app/bsky/graph/getFollowers.ts index f55649dc769..3d4121bc0a7 100644 --- a/packages/api/src/client/types/app/bsky/graph/getFollowers.ts +++ b/packages/api/src/client/types/app/bsky/graph/getFollowers.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from '../actor/defs' +const id = 'app.bsky.graph.getFollowers' + export interface QueryParams { actor: string limit?: number diff --git a/packages/api/src/client/types/app/bsky/graph/getFollows.ts b/packages/api/src/client/types/app/bsky/graph/getFollows.ts index 8570c4a14c0..75b05d1c513 100644 --- a/packages/api/src/client/types/app/bsky/graph/getFollows.ts +++ b/packages/api/src/client/types/app/bsky/graph/getFollows.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from '../actor/defs' +const id = 'app.bsky.graph.getFollows' + export interface QueryParams { actor: string limit?: number diff --git a/packages/api/src/client/types/app/bsky/graph/getKnownFollowers.ts b/packages/api/src/client/types/app/bsky/graph/getKnownFollowers.ts index f55649dc769..24dfd79f3ab 100644 --- a/packages/api/src/client/types/app/bsky/graph/getKnownFollowers.ts +++ b/packages/api/src/client/types/app/bsky/graph/getKnownFollowers.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from '../actor/defs' +const id = 'app.bsky.graph.getKnownFollowers' + export interface QueryParams { actor: string limit?: number diff --git a/packages/api/src/client/types/app/bsky/graph/getList.ts b/packages/api/src/client/types/app/bsky/graph/getList.ts index bebde2b49c3..89bc0eeacb9 100644 --- a/packages/api/src/client/types/app/bsky/graph/getList.ts +++ b/packages/api/src/client/types/app/bsky/graph/getList.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyGraphDefs from './defs' +const id = 'app.bsky.graph.getList' + export interface QueryParams { /** Reference (AT-URI) of the list record to hydrate. */ list: string diff --git a/packages/api/src/client/types/app/bsky/graph/getListBlocks.ts b/packages/api/src/client/types/app/bsky/graph/getListBlocks.ts index d3c7ad5ed7b..0be93d089f6 100644 --- a/packages/api/src/client/types/app/bsky/graph/getListBlocks.ts +++ b/packages/api/src/client/types/app/bsky/graph/getListBlocks.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyGraphDefs from './defs' +const id = 'app.bsky.graph.getListBlocks' + export interface QueryParams { limit?: number cursor?: string diff --git a/packages/api/src/client/types/app/bsky/graph/getListMutes.ts b/packages/api/src/client/types/app/bsky/graph/getListMutes.ts index d3c7ad5ed7b..e377ac14d7a 100644 --- a/packages/api/src/client/types/app/bsky/graph/getListMutes.ts +++ b/packages/api/src/client/types/app/bsky/graph/getListMutes.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyGraphDefs from './defs' +const id = 'app.bsky.graph.getListMutes' + export interface QueryParams { limit?: number cursor?: string diff --git a/packages/api/src/client/types/app/bsky/graph/getLists.ts b/packages/api/src/client/types/app/bsky/graph/getLists.ts index 89a4bfd58df..6cae28caa98 100644 --- a/packages/api/src/client/types/app/bsky/graph/getLists.ts +++ b/packages/api/src/client/types/app/bsky/graph/getLists.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyGraphDefs from './defs' +const id = 'app.bsky.graph.getLists' + export interface QueryParams { /** The account (actor) to enumerate lists from. */ actor: string diff --git a/packages/api/src/client/types/app/bsky/graph/getMutes.ts b/packages/api/src/client/types/app/bsky/graph/getMutes.ts index 0ee441cf9eb..a3708bdc5e9 100644 --- a/packages/api/src/client/types/app/bsky/graph/getMutes.ts +++ b/packages/api/src/client/types/app/bsky/graph/getMutes.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from '../actor/defs' +const id = 'app.bsky.graph.getMutes' + export interface QueryParams { limit?: number cursor?: string diff --git a/packages/api/src/client/types/app/bsky/graph/getRelationships.ts b/packages/api/src/client/types/app/bsky/graph/getRelationships.ts index 20194662b71..fba7825bdfb 100644 --- a/packages/api/src/client/types/app/bsky/graph/getRelationships.ts +++ b/packages/api/src/client/types/app/bsky/graph/getRelationships.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyGraphDefs from './defs' +const id = 'app.bsky.graph.getRelationships' + export interface QueryParams { /** Primary account requesting relationships for. */ actor: string diff --git a/packages/api/src/client/types/app/bsky/graph/getStarterPack.ts b/packages/api/src/client/types/app/bsky/graph/getStarterPack.ts index 7eafb2d228d..c29073c7e8a 100644 --- a/packages/api/src/client/types/app/bsky/graph/getStarterPack.ts +++ b/packages/api/src/client/types/app/bsky/graph/getStarterPack.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyGraphDefs from './defs' +const id = 'app.bsky.graph.getStarterPack' + export interface QueryParams { /** Reference (AT-URI) of the starter pack record. */ starterPack: string diff --git a/packages/api/src/client/types/app/bsky/graph/getStarterPacks.ts b/packages/api/src/client/types/app/bsky/graph/getStarterPacks.ts index 50dbfdbaeda..d1c2df237b4 100644 --- a/packages/api/src/client/types/app/bsky/graph/getStarterPacks.ts +++ b/packages/api/src/client/types/app/bsky/graph/getStarterPacks.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyGraphDefs from './defs' +const id = 'app.bsky.graph.getStarterPacks' + export interface QueryParams { uris: string[] } diff --git a/packages/api/src/client/types/app/bsky/graph/getSuggestedFollowsByActor.ts b/packages/api/src/client/types/app/bsky/graph/getSuggestedFollowsByActor.ts index 4747afb19fc..b3df5a5e9c8 100644 --- a/packages/api/src/client/types/app/bsky/graph/getSuggestedFollowsByActor.ts +++ b/packages/api/src/client/types/app/bsky/graph/getSuggestedFollowsByActor.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from '../actor/defs' +const id = 'app.bsky.graph.getSuggestedFollowsByActor' + export interface QueryParams { actor: string } diff --git a/packages/api/src/client/types/app/bsky/graph/list.ts b/packages/api/src/client/types/app/bsky/graph/list.ts index fec652ccb12..f1e242d1661 100644 --- a/packages/api/src/client/types/app/bsky/graph/list.ts +++ b/packages/api/src/client/types/app/bsky/graph/list.ts @@ -2,13 +2,15 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyGraphDefs from './defs' import * as AppBskyRichtextFacet from '../richtext/facet' import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +const id = 'app.bsky.graph.list' + export interface Record { purpose: AppBskyGraphDefs.ListPurpose /** Display name for list; can not be empty. */ @@ -23,15 +25,12 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.graph.list#main' || - v.$type === 'app.bsky.graph.list') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.graph.list', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.list#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/graph/listblock.ts b/packages/api/src/client/types/app/bsky/graph/listblock.ts index e0f02be268f..ede600c112c 100644 --- a/packages/api/src/client/types/app/bsky/graph/listblock.ts +++ b/packages/api/src/client/types/app/bsky/graph/listblock.ts @@ -2,9 +2,11 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.graph.listblock' export interface Record { /** Reference (AT-URI) to the mod list record. */ @@ -13,15 +15,12 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.graph.listblock#main' || - v.$type === 'app.bsky.graph.listblock') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.graph.listblock', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.listblock#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/graph/listitem.ts b/packages/api/src/client/types/app/bsky/graph/listitem.ts index d4fb5631e84..0a1a4590db6 100644 --- a/packages/api/src/client/types/app/bsky/graph/listitem.ts +++ b/packages/api/src/client/types/app/bsky/graph/listitem.ts @@ -2,9 +2,11 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.graph.listitem' export interface Record { /** The account which is included on the list. */ @@ -15,15 +17,12 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.graph.listitem#main' || - v.$type === 'app.bsky.graph.listitem') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.graph.listitem', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.listitem#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/graph/muteActor.ts b/packages/api/src/client/types/app/bsky/graph/muteActor.ts index c21c00b2069..18fbd027e53 100644 --- a/packages/api/src/client/types/app/bsky/graph/muteActor.ts +++ b/packages/api/src/client/types/app/bsky/graph/muteActor.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.graph.muteActor' export interface QueryParams {} diff --git a/packages/api/src/client/types/app/bsky/graph/muteActorList.ts b/packages/api/src/client/types/app/bsky/graph/muteActorList.ts index 8a0e8586deb..6da99862d1c 100644 --- a/packages/api/src/client/types/app/bsky/graph/muteActorList.ts +++ b/packages/api/src/client/types/app/bsky/graph/muteActorList.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.graph.muteActorList' export interface QueryParams {} diff --git a/packages/api/src/client/types/app/bsky/graph/muteThread.ts b/packages/api/src/client/types/app/bsky/graph/muteThread.ts index 275ba7a0f22..1dde979bbbc 100644 --- a/packages/api/src/client/types/app/bsky/graph/muteThread.ts +++ b/packages/api/src/client/types/app/bsky/graph/muteThread.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.graph.muteThread' export interface QueryParams {} diff --git a/packages/api/src/client/types/app/bsky/graph/searchStarterPacks.ts b/packages/api/src/client/types/app/bsky/graph/searchStarterPacks.ts index 8291b219a62..10c89a85b0b 100644 --- a/packages/api/src/client/types/app/bsky/graph/searchStarterPacks.ts +++ b/packages/api/src/client/types/app/bsky/graph/searchStarterPacks.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyGraphDefs from './defs' +const id = 'app.bsky.graph.searchStarterPacks' + export interface QueryParams { /** Search query string. Syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended. */ q: string diff --git a/packages/api/src/client/types/app/bsky/graph/starterpack.ts b/packages/api/src/client/types/app/bsky/graph/starterpack.ts index 7cb0aa26c3f..7466af55782 100644 --- a/packages/api/src/client/types/app/bsky/graph/starterpack.ts +++ b/packages/api/src/client/types/app/bsky/graph/starterpack.ts @@ -2,11 +2,13 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyRichtextFacet from '../richtext/facet' +const id = 'app.bsky.graph.starterpack' + export interface Record { /** Display name for starter pack; can not be empty. */ name: string @@ -19,17 +21,14 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.graph.starterpack#main' || - v.$type === 'app.bsky.graph.starterpack') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.graph.starterpack', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.starterpack#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } export interface FeedItem { @@ -37,14 +36,12 @@ export interface FeedItem { [k: string]: unknown } -export function isFeedItem(v: unknown): v is FeedItem { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.starterpack#feedItem' - ) +export function isFeedItem( + v: unknown, +): v is FeedItem & { $type: $Type<'app.bsky.graph.starterpack', 'feedItem'> } { + return is$typed(v, id, 'feedItem') } -export function validateFeedItem(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.graph.starterpack#feedItem', v) +export function validateFeedItem(v: unknown) { + return lexicons.validate(`${id}#feedItem`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/graph/unmuteActor.ts b/packages/api/src/client/types/app/bsky/graph/unmuteActor.ts index c21c00b2069..0cb4970f37d 100644 --- a/packages/api/src/client/types/app/bsky/graph/unmuteActor.ts +++ b/packages/api/src/client/types/app/bsky/graph/unmuteActor.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.graph.unmuteActor' export interface QueryParams {} diff --git a/packages/api/src/client/types/app/bsky/graph/unmuteActorList.ts b/packages/api/src/client/types/app/bsky/graph/unmuteActorList.ts index 8a0e8586deb..f866d0d6cdd 100644 --- a/packages/api/src/client/types/app/bsky/graph/unmuteActorList.ts +++ b/packages/api/src/client/types/app/bsky/graph/unmuteActorList.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.graph.unmuteActorList' export interface QueryParams {} diff --git a/packages/api/src/client/types/app/bsky/graph/unmuteThread.ts b/packages/api/src/client/types/app/bsky/graph/unmuteThread.ts index 275ba7a0f22..25b03006f27 100644 --- a/packages/api/src/client/types/app/bsky/graph/unmuteThread.ts +++ b/packages/api/src/client/types/app/bsky/graph/unmuteThread.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.graph.unmuteThread' export interface QueryParams {} diff --git a/packages/api/src/client/types/app/bsky/labeler/defs.ts b/packages/api/src/client/types/app/bsky/labeler/defs.ts index 3d9b1d77f8a..fefa71f91a5 100644 --- a/packages/api/src/client/types/app/bsky/labeler/defs.ts +++ b/packages/api/src/client/types/app/bsky/labeler/defs.ts @@ -2,12 +2,14 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from '../actor/defs' import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +const id = 'app.bsky.labeler.defs' + export interface LabelerView { uri: string cid: string @@ -19,16 +21,17 @@ export interface LabelerView { [k: string]: unknown } -export function isLabelerView(v: unknown): v is LabelerView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.labeler.defs#labelerView' - ) +export function isLabelerView( + v: unknown, +): v is LabelerView & { $type: $Type<'app.bsky.labeler.defs', 'labelerView'> } { + return is$typed(v, id, 'labelerView') } -export function validateLabelerView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.labeler.defs#labelerView', v) +export function validateLabelerView(v: unknown) { + return lexicons.validate( + `${id}#labelerView`, + v, + ) as ValidationResult } export interface LabelerViewDetailed { @@ -43,16 +46,17 @@ export interface LabelerViewDetailed { [k: string]: unknown } -export function isLabelerViewDetailed(v: unknown): v is LabelerViewDetailed { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.labeler.defs#labelerViewDetailed' - ) +export function isLabelerViewDetailed(v: unknown): v is LabelerViewDetailed & { + $type: $Type<'app.bsky.labeler.defs', 'labelerViewDetailed'> +} { + return is$typed(v, id, 'labelerViewDetailed') } -export function validateLabelerViewDetailed(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.labeler.defs#labelerViewDetailed', v) +export function validateLabelerViewDetailed(v: unknown) { + return lexicons.validate( + `${id}#labelerViewDetailed`, + v, + ) as ValidationResult } export interface LabelerViewerState { @@ -60,16 +64,17 @@ export interface LabelerViewerState { [k: string]: unknown } -export function isLabelerViewerState(v: unknown): v is LabelerViewerState { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.labeler.defs#labelerViewerState' - ) +export function isLabelerViewerState(v: unknown): v is LabelerViewerState & { + $type: $Type<'app.bsky.labeler.defs', 'labelerViewerState'> +} { + return is$typed(v, id, 'labelerViewerState') } -export function validateLabelerViewerState(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.labeler.defs#labelerViewerState', v) +export function validateLabelerViewerState(v: unknown) { + return lexicons.validate( + `${id}#labelerViewerState`, + v, + ) as ValidationResult } export interface LabelerPolicies { @@ -80,14 +85,15 @@ export interface LabelerPolicies { [k: string]: unknown } -export function isLabelerPolicies(v: unknown): v is LabelerPolicies { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.labeler.defs#labelerPolicies' - ) +export function isLabelerPolicies(v: unknown): v is LabelerPolicies & { + $type: $Type<'app.bsky.labeler.defs', 'labelerPolicies'> +} { + return is$typed(v, id, 'labelerPolicies') } -export function validateLabelerPolicies(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.labeler.defs#labelerPolicies', v) +export function validateLabelerPolicies(v: unknown) { + return lexicons.validate( + `${id}#labelerPolicies`, + v, + ) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/labeler/getServices.ts b/packages/api/src/client/types/app/bsky/labeler/getServices.ts index 688f847d508..418dd8e906e 100644 --- a/packages/api/src/client/types/app/bsky/labeler/getServices.ts +++ b/packages/api/src/client/types/app/bsky/labeler/getServices.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyLabelerDefs from './defs' +const id = 'app.bsky.labeler.getServices' + export interface QueryParams { dids: string[] detailed?: boolean diff --git a/packages/api/src/client/types/app/bsky/labeler/service.ts b/packages/api/src/client/types/app/bsky/labeler/service.ts index 818249468ec..347645730d0 100644 --- a/packages/api/src/client/types/app/bsky/labeler/service.ts +++ b/packages/api/src/client/types/app/bsky/labeler/service.ts @@ -2,12 +2,14 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyLabelerDefs from './defs' import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +const id = 'app.bsky.labeler.service' + export interface Record { policies: AppBskyLabelerDefs.LabelerPolicies labels?: @@ -17,15 +19,12 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.labeler.service#main' || - v.$type === 'app.bsky.labeler.service') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'app.bsky.labeler.service', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.labeler.service#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/notification/getUnreadCount.ts b/packages/api/src/client/types/app/bsky/notification/getUnreadCount.ts index 00600ea54e7..b39aec7880a 100644 --- a/packages/api/src/client/types/app/bsky/notification/getUnreadCount.ts +++ b/packages/api/src/client/types/app/bsky/notification/getUnreadCount.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.notification.getUnreadCount' export interface QueryParams { priority?: boolean diff --git a/packages/api/src/client/types/app/bsky/notification/listNotifications.ts b/packages/api/src/client/types/app/bsky/notification/listNotifications.ts index 92b3a27fece..8b81dc38ff3 100644 --- a/packages/api/src/client/types/app/bsky/notification/listNotifications.ts +++ b/packages/api/src/client/types/app/bsky/notification/listNotifications.ts @@ -3,12 +3,14 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from '../actor/defs' import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +const id = 'app.bsky.notification.listNotifications' + export interface QueryParams { /** Notification reasons to include in response. */ reasons?: string[] @@ -65,17 +67,15 @@ export interface Notification { [k: string]: unknown } -export function isNotification(v: unknown): v is Notification { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.notification.listNotifications#notification' - ) +export function isNotification(v: unknown): v is Notification & { + $type: $Type<'app.bsky.notification.listNotifications', 'notification'> +} { + return is$typed(v, id, 'notification') } -export function validateNotification(v: unknown): ValidationResult { +export function validateNotification(v: unknown) { return lexicons.validate( - 'app.bsky.notification.listNotifications#notification', + `${id}#notification`, v, - ) + ) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/notification/putPreferences.ts b/packages/api/src/client/types/app/bsky/notification/putPreferences.ts index bc79909f459..507528b2e05 100644 --- a/packages/api/src/client/types/app/bsky/notification/putPreferences.ts +++ b/packages/api/src/client/types/app/bsky/notification/putPreferences.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.notification.putPreferences' export interface QueryParams {} diff --git a/packages/api/src/client/types/app/bsky/notification/registerPush.ts b/packages/api/src/client/types/app/bsky/notification/registerPush.ts index ddc9d438537..65f40b64633 100644 --- a/packages/api/src/client/types/app/bsky/notification/registerPush.ts +++ b/packages/api/src/client/types/app/bsky/notification/registerPush.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.notification.registerPush' export interface QueryParams {} diff --git a/packages/api/src/client/types/app/bsky/notification/updateSeen.ts b/packages/api/src/client/types/app/bsky/notification/updateSeen.ts index 7151e9b0cd4..eaa486ee2f4 100644 --- a/packages/api/src/client/types/app/bsky/notification/updateSeen.ts +++ b/packages/api/src/client/types/app/bsky/notification/updateSeen.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.notification.updateSeen' export interface QueryParams {} diff --git a/packages/api/src/client/types/app/bsky/richtext/facet.ts b/packages/api/src/client/types/app/bsky/richtext/facet.ts index 836136b7dac..56d2aebb4cd 100644 --- a/packages/api/src/client/types/app/bsky/richtext/facet.ts +++ b/packages/api/src/client/types/app/bsky/richtext/facet.ts @@ -2,9 +2,11 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.richtext.facet' /** Annotation of a sub-string within rich text. */ export interface Main { @@ -13,17 +15,14 @@ export interface Main { [k: string]: unknown } -export function isMain(v: unknown): v is Main { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.richtext.facet#main' || - v.$type === 'app.bsky.richtext.facet') - ) +export function isMain( + v: unknown, +): v is Main & { $type: $Type<'app.bsky.richtext.facet', 'main'> } { + return is$typed(v, id, 'main') } -export function validateMain(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.richtext.facet#main', v) +export function validateMain(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult
} /** Facet feature for mention of another account. The text is usually a handle, including a '@' prefix, but the facet reference is a DID. */ @@ -32,16 +31,14 @@ export interface Mention { [k: string]: unknown } -export function isMention(v: unknown): v is Mention { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.richtext.facet#mention' - ) +export function isMention( + v: unknown, +): v is Mention & { $type: $Type<'app.bsky.richtext.facet', 'mention'> } { + return is$typed(v, id, 'mention') } -export function validateMention(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.richtext.facet#mention', v) +export function validateMention(v: unknown) { + return lexicons.validate(`${id}#mention`, v) as ValidationResult } /** Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL. */ @@ -50,16 +47,14 @@ export interface Link { [k: string]: unknown } -export function isLink(v: unknown): v is Link { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.richtext.facet#link' - ) +export function isLink( + v: unknown, +): v is Link & { $type: $Type<'app.bsky.richtext.facet', 'link'> } { + return is$typed(v, id, 'link') } -export function validateLink(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.richtext.facet#link', v) +export function validateLink(v: unknown) { + return lexicons.validate(`${id}#link`, v) as ValidationResult } /** 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'). */ @@ -68,14 +63,14 @@ export interface Tag { [k: string]: unknown } -export function isTag(v: unknown): v is Tag { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.richtext.facet#tag' - ) +export function isTag( + v: unknown, +): v is Tag & { $type: $Type<'app.bsky.richtext.facet', 'tag'> } { + return is$typed(v, id, 'tag') } -export function validateTag(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.richtext.facet#tag', v) +export function validateTag(v: unknown) { + return lexicons.validate(`${id}#tag`, v) as ValidationResult } /** 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. */ @@ -85,14 +80,12 @@ export interface ByteSlice { [k: string]: unknown } -export function isByteSlice(v: unknown): v is ByteSlice { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.richtext.facet#byteSlice' - ) +export function isByteSlice( + v: unknown, +): v is ByteSlice & { $type: $Type<'app.bsky.richtext.facet', 'byteSlice'> } { + return is$typed(v, id, 'byteSlice') } -export function validateByteSlice(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.richtext.facet#byteSlice', v) +export function validateByteSlice(v: unknown) { + return lexicons.validate(`${id}#byteSlice`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/unspecced/defs.ts b/packages/api/src/client/types/app/bsky/unspecced/defs.ts index 81f821ecf73..7e5d8b5bb14 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/defs.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/defs.ts @@ -2,25 +2,28 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.unspecced.defs' export interface SkeletonSearchPost { uri: string [k: string]: unknown } -export function isSkeletonSearchPost(v: unknown): v is SkeletonSearchPost { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.unspecced.defs#skeletonSearchPost' - ) +export function isSkeletonSearchPost(v: unknown): v is SkeletonSearchPost & { + $type: $Type<'app.bsky.unspecced.defs', 'skeletonSearchPost'> +} { + return is$typed(v, id, 'skeletonSearchPost') } -export function validateSkeletonSearchPost(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.unspecced.defs#skeletonSearchPost', v) +export function validateSkeletonSearchPost(v: unknown) { + return lexicons.validate( + `${id}#skeletonSearchPost`, + v, + ) as ValidationResult } export interface SkeletonSearchActor { @@ -28,16 +31,17 @@ export interface SkeletonSearchActor { [k: string]: unknown } -export function isSkeletonSearchActor(v: unknown): v is SkeletonSearchActor { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.unspecced.defs#skeletonSearchActor' - ) +export function isSkeletonSearchActor(v: unknown): v is SkeletonSearchActor & { + $type: $Type<'app.bsky.unspecced.defs', 'skeletonSearchActor'> +} { + return is$typed(v, id, 'skeletonSearchActor') } -export function validateSkeletonSearchActor(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.unspecced.defs#skeletonSearchActor', v) +export function validateSkeletonSearchActor(v: unknown) { + return lexicons.validate( + `${id}#skeletonSearchActor`, + v, + ) as ValidationResult } export interface SkeletonSearchStarterPack { @@ -47,21 +51,17 @@ export interface SkeletonSearchStarterPack { export function isSkeletonSearchStarterPack( v: unknown, -): v is SkeletonSearchStarterPack { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.unspecced.defs#skeletonSearchStarterPack' - ) +): v is SkeletonSearchStarterPack & { + $type: $Type<'app.bsky.unspecced.defs', 'skeletonSearchStarterPack'> +} { + return is$typed(v, id, 'skeletonSearchStarterPack') } -export function validateSkeletonSearchStarterPack( - v: unknown, -): ValidationResult { +export function validateSkeletonSearchStarterPack(v: unknown) { return lexicons.validate( - 'app.bsky.unspecced.defs#skeletonSearchStarterPack', + `${id}#skeletonSearchStarterPack`, v, - ) + ) as ValidationResult } export interface TrendingTopic { @@ -72,14 +72,15 @@ export interface TrendingTopic { [k: string]: unknown } -export function isTrendingTopic(v: unknown): v is TrendingTopic { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.unspecced.defs#trendingTopic' - ) +export function isTrendingTopic(v: unknown): v is TrendingTopic & { + $type: $Type<'app.bsky.unspecced.defs', 'trendingTopic'> +} { + return is$typed(v, id, 'trendingTopic') } -export function validateTrendingTopic(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.unspecced.defs#trendingTopic', v) +export function validateTrendingTopic(v: unknown) { + return lexicons.validate( + `${id}#trendingTopic`, + v, + ) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/unspecced/getConfig.ts b/packages/api/src/client/types/app/bsky/unspecced/getConfig.ts index d1ee6f7957d..0f349472146 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getConfig.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getConfig.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.unspecced.getConfig' export interface QueryParams {} diff --git a/packages/api/src/client/types/app/bsky/unspecced/getPopularFeedGenerators.ts b/packages/api/src/client/types/app/bsky/unspecced/getPopularFeedGenerators.ts index 780b4b6641c..0192a32c8f7 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getPopularFeedGenerators.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getPopularFeedGenerators.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyFeedDefs from '../feed/defs' +const id = 'app.bsky.unspecced.getPopularFeedGenerators' + export interface QueryParams { limit?: number cursor?: string diff --git a/packages/api/src/client/types/app/bsky/unspecced/getSuggestionsSkeleton.ts b/packages/api/src/client/types/app/bsky/unspecced/getSuggestionsSkeleton.ts index 6ed519ef212..9df9298b22f 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getSuggestionsSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getSuggestionsSkeleton.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyUnspeccedDefs from './defs' +const id = 'app.bsky.unspecced.getSuggestionsSkeleton' + export interface QueryParams { /** DID of the account making the request (not included for public/unauthenticated queries). Used to boost followed accounts in ranking. */ viewer?: string diff --git a/packages/api/src/client/types/app/bsky/unspecced/getTaggedSuggestions.ts b/packages/api/src/client/types/app/bsky/unspecced/getTaggedSuggestions.ts index 0ee04b8e85d..54d1158c093 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getTaggedSuggestions.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getTaggedSuggestions.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.unspecced.getTaggedSuggestions' export interface QueryParams {} @@ -38,17 +40,15 @@ export interface Suggestion { [k: string]: unknown } -export function isSuggestion(v: unknown): v is Suggestion { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.unspecced.getTaggedSuggestions#suggestion' - ) +export function isSuggestion(v: unknown): v is Suggestion & { + $type: $Type<'app.bsky.unspecced.getTaggedSuggestions', 'suggestion'> +} { + return is$typed(v, id, 'suggestion') } -export function validateSuggestion(v: unknown): ValidationResult { +export function validateSuggestion(v: unknown) { return lexicons.validate( - 'app.bsky.unspecced.getTaggedSuggestions#suggestion', + `${id}#suggestion`, v, - ) + ) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/unspecced/getTrendingTopics.ts b/packages/api/src/client/types/app/bsky/unspecced/getTrendingTopics.ts index 70e790e14ba..6839bddeafe 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getTrendingTopics.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getTrendingTopics.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyUnspeccedDefs from './defs' +const id = 'app.bsky.unspecced.getTrendingTopics' + export interface QueryParams { /** DID of the account making the request (not included for public/unauthenticated queries). Used to boost followed accounts in ranking. */ viewer?: string diff --git a/packages/api/src/client/types/app/bsky/unspecced/searchActorsSkeleton.ts b/packages/api/src/client/types/app/bsky/unspecced/searchActorsSkeleton.ts index d9fe6737d37..7799158a8ec 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/searchActorsSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/searchActorsSkeleton.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyUnspeccedDefs from './defs' +const id = 'app.bsky.unspecced.searchActorsSkeleton' + export interface QueryParams { /** Search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended. For typeahead search, only simple term match is supported, not full syntax. */ q: string diff --git a/packages/api/src/client/types/app/bsky/unspecced/searchPostsSkeleton.ts b/packages/api/src/client/types/app/bsky/unspecced/searchPostsSkeleton.ts index ea0135dde83..00e032f2be9 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/searchPostsSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/searchPostsSkeleton.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyUnspeccedDefs from './defs' +const id = 'app.bsky.unspecced.searchPostsSkeleton' + export interface QueryParams { /** Search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended. */ q: string diff --git a/packages/api/src/client/types/app/bsky/unspecced/searchStarterPacksSkeleton.ts b/packages/api/src/client/types/app/bsky/unspecced/searchStarterPacksSkeleton.ts index c331b86d3e1..51cb7b9e78a 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/searchStarterPacksSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/searchStarterPacksSkeleton.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyUnspeccedDefs from './defs' +const id = 'app.bsky.unspecced.searchStarterPacksSkeleton' + export interface QueryParams { /** Search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended. */ q: string diff --git a/packages/api/src/client/types/app/bsky/video/defs.ts b/packages/api/src/client/types/app/bsky/video/defs.ts index a7ec84316b6..3cf6cae3436 100644 --- a/packages/api/src/client/types/app/bsky/video/defs.ts +++ b/packages/api/src/client/types/app/bsky/video/defs.ts @@ -2,9 +2,11 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.video.defs' export interface JobStatus { jobId: string @@ -19,14 +21,12 @@ export interface JobStatus { [k: string]: unknown } -export function isJobStatus(v: unknown): v is JobStatus { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.video.defs#jobStatus' - ) +export function isJobStatus( + v: unknown, +): v is JobStatus & { $type: $Type<'app.bsky.video.defs', 'jobStatus'> } { + return is$typed(v, id, 'jobStatus') } -export function validateJobStatus(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.video.defs#jobStatus', v) +export function validateJobStatus(v: unknown) { + return lexicons.validate(`${id}#jobStatus`, v) as ValidationResult } diff --git a/packages/api/src/client/types/app/bsky/video/getJobStatus.ts b/packages/api/src/client/types/app/bsky/video/getJobStatus.ts index 0e9638311c0..a303f44ed52 100644 --- a/packages/api/src/client/types/app/bsky/video/getJobStatus.ts +++ b/packages/api/src/client/types/app/bsky/video/getJobStatus.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyVideoDefs from './defs' +const id = 'app.bsky.video.getJobStatus' + export interface QueryParams { jobId: string } diff --git a/packages/api/src/client/types/app/bsky/video/getUploadLimits.ts b/packages/api/src/client/types/app/bsky/video/getUploadLimits.ts index 4a2f13617b3..dc653bc87f9 100644 --- a/packages/api/src/client/types/app/bsky/video/getUploadLimits.ts +++ b/packages/api/src/client/types/app/bsky/video/getUploadLimits.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'app.bsky.video.getUploadLimits' export interface QueryParams {} diff --git a/packages/api/src/client/types/app/bsky/video/uploadVideo.ts b/packages/api/src/client/types/app/bsky/video/uploadVideo.ts index f51ba897bbe..f56dd13cec2 100644 --- a/packages/api/src/client/types/app/bsky/video/uploadVideo.ts +++ b/packages/api/src/client/types/app/bsky/video/uploadVideo.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyVideoDefs from './defs' +const id = 'app.bsky.video.uploadVideo' + export interface QueryParams {} export type InputSchema = string | Uint8Array | Blob diff --git a/packages/api/src/client/types/chat/bsky/actor/declaration.ts b/packages/api/src/client/types/chat/bsky/actor/declaration.ts index 99b14f45608..a17b0b24ffd 100644 --- a/packages/api/src/client/types/chat/bsky/actor/declaration.ts +++ b/packages/api/src/client/types/chat/bsky/actor/declaration.ts @@ -2,24 +2,23 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'chat.bsky.actor.declaration' export interface Record { allowIncoming: 'all' | 'none' | 'following' | (string & {}) [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'chat.bsky.actor.declaration#main' || - v.$type === 'chat.bsky.actor.declaration') - ) +export function isRecord( + v: unknown, +): v is Record & { $type: $Type<'chat.bsky.actor.declaration', 'main'> } { + return is$typed(v, id, 'main') } -export function validateRecord(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.actor.declaration#main', v) +export function validateRecord(v: unknown) { + return lexicons.validate(`${id}#main`, v) as ValidationResult } diff --git a/packages/api/src/client/types/chat/bsky/actor/defs.ts b/packages/api/src/client/types/chat/bsky/actor/defs.ts index 87aaac96218..405dadae7cd 100644 --- a/packages/api/src/client/types/chat/bsky/actor/defs.ts +++ b/packages/api/src/client/types/chat/bsky/actor/defs.ts @@ -2,12 +2,14 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyActorDefs from '../../../app/bsky/actor/defs' import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +const id = 'chat.bsky.actor.defs' + export interface ProfileViewBasic { did: string handle: string @@ -21,14 +23,15 @@ export interface ProfileViewBasic { [k: string]: unknown } -export function isProfileViewBasic(v: unknown): v is ProfileViewBasic { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.actor.defs#profileViewBasic' - ) +export function isProfileViewBasic(v: unknown): v is ProfileViewBasic & { + $type: $Type<'chat.bsky.actor.defs', 'profileViewBasic'> +} { + return is$typed(v, id, 'profileViewBasic') } -export function validateProfileViewBasic(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.actor.defs#profileViewBasic', v) +export function validateProfileViewBasic(v: unknown) { + return lexicons.validate( + `${id}#profileViewBasic`, + v, + ) as ValidationResult } diff --git a/packages/api/src/client/types/chat/bsky/actor/deleteAccount.ts b/packages/api/src/client/types/chat/bsky/actor/deleteAccount.ts index 1a045c21c29..c96bdf96729 100644 --- a/packages/api/src/client/types/chat/bsky/actor/deleteAccount.ts +++ b/packages/api/src/client/types/chat/bsky/actor/deleteAccount.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'chat.bsky.actor.deleteAccount' export interface QueryParams {} diff --git a/packages/api/src/client/types/chat/bsky/actor/exportAccountData.ts b/packages/api/src/client/types/chat/bsky/actor/exportAccountData.ts index 0142436b05e..21d7bb32b26 100644 --- a/packages/api/src/client/types/chat/bsky/actor/exportAccountData.ts +++ b/packages/api/src/client/types/chat/bsky/actor/exportAccountData.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'chat.bsky.actor.exportAccountData' export interface QueryParams {} diff --git a/packages/api/src/client/types/chat/bsky/convo/defs.ts b/packages/api/src/client/types/chat/bsky/convo/defs.ts index 4908b2dc46a..4b08ce380ab 100644 --- a/packages/api/src/client/types/chat/bsky/convo/defs.ts +++ b/packages/api/src/client/types/chat/bsky/convo/defs.ts @@ -2,13 +2,15 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as AppBskyRichtextFacet from '../../../app/bsky/richtext/facet' import * as AppBskyEmbedRecord from '../../../app/bsky/embed/record' import * as ChatBskyActorDefs from '../actor/defs' +const id = 'chat.bsky.convo.defs' + export interface MessageRef { did: string convoId: string @@ -16,16 +18,17 @@ export interface MessageRef { [k: string]: unknown } -export function isMessageRef(v: unknown): v is MessageRef { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#messageRef' - ) +export function isMessageRef( + v: unknown, +): v is MessageRef & { $type: $Type<'chat.bsky.convo.defs', 'messageRef'> } { + return is$typed(v, id, 'messageRef') } -export function validateMessageRef(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#messageRef', v) +export function validateMessageRef(v: unknown) { + return lexicons.validate( + `${id}#messageRef`, + v, + ) as ValidationResult } export interface MessageInput { @@ -36,16 +39,17 @@ export interface MessageInput { [k: string]: unknown } -export function isMessageInput(v: unknown): v is MessageInput { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#messageInput' - ) +export function isMessageInput(v: unknown): v is MessageInput & { + $type: $Type<'chat.bsky.convo.defs', 'messageInput'> +} { + return is$typed(v, id, 'messageInput') } -export function validateMessageInput(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#messageInput', v) +export function validateMessageInput(v: unknown) { + return lexicons.validate( + `${id}#messageInput`, + v, + ) as ValidationResult } export interface MessageView { @@ -60,16 +64,17 @@ export interface MessageView { [k: string]: unknown } -export function isMessageView(v: unknown): v is MessageView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#messageView' - ) +export function isMessageView( + v: unknown, +): v is MessageView & { $type: $Type<'chat.bsky.convo.defs', 'messageView'> } { + return is$typed(v, id, 'messageView') } -export function validateMessageView(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#messageView', v) +export function validateMessageView(v: unknown) { + return lexicons.validate( + `${id}#messageView`, + v, + ) as ValidationResult } export interface DeletedMessageView { @@ -80,16 +85,17 @@ export interface DeletedMessageView { [k: string]: unknown } -export function isDeletedMessageView(v: unknown): v is DeletedMessageView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#deletedMessageView' - ) +export function isDeletedMessageView(v: unknown): v is DeletedMessageView & { + $type: $Type<'chat.bsky.convo.defs', 'deletedMessageView'> +} { + return is$typed(v, id, 'deletedMessageView') } -export function validateDeletedMessageView(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#deletedMessageView', v) +export function validateDeletedMessageView(v: unknown) { + return lexicons.validate( + `${id}#deletedMessageView`, + v, + ) as ValidationResult } export interface MessageViewSender { @@ -97,16 +103,17 @@ export interface MessageViewSender { [k: string]: unknown } -export function isMessageViewSender(v: unknown): v is MessageViewSender { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#messageViewSender' - ) +export function isMessageViewSender(v: unknown): v is MessageViewSender & { + $type: $Type<'chat.bsky.convo.defs', 'messageViewSender'> +} { + return is$typed(v, id, 'messageViewSender') } -export function validateMessageViewSender(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#messageViewSender', v) +export function validateMessageViewSender(v: unknown) { + return lexicons.validate( + `${id}#messageViewSender`, + v, + ) as ValidationResult } export interface ConvoView { @@ -123,16 +130,14 @@ export interface ConvoView { [k: string]: unknown } -export function isConvoView(v: unknown): v is ConvoView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#convoView' - ) +export function isConvoView( + v: unknown, +): v is ConvoView & { $type: $Type<'chat.bsky.convo.defs', 'convoView'> } { + return is$typed(v, id, 'convoView') } -export function validateConvoView(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#convoView', v) +export function validateConvoView(v: unknown) { + return lexicons.validate(`${id}#convoView`, v) as ValidationResult } export interface LogBeginConvo { @@ -141,16 +146,17 @@ export interface LogBeginConvo { [k: string]: unknown } -export function isLogBeginConvo(v: unknown): v is LogBeginConvo { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#logBeginConvo' - ) +export function isLogBeginConvo(v: unknown): v is LogBeginConvo & { + $type: $Type<'chat.bsky.convo.defs', 'logBeginConvo'> +} { + return is$typed(v, id, 'logBeginConvo') } -export function validateLogBeginConvo(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#logBeginConvo', v) +export function validateLogBeginConvo(v: unknown) { + return lexicons.validate( + `${id}#logBeginConvo`, + v, + ) as ValidationResult } export interface LogLeaveConvo { @@ -159,16 +165,17 @@ export interface LogLeaveConvo { [k: string]: unknown } -export function isLogLeaveConvo(v: unknown): v is LogLeaveConvo { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#logLeaveConvo' - ) +export function isLogLeaveConvo(v: unknown): v is LogLeaveConvo & { + $type: $Type<'chat.bsky.convo.defs', 'logLeaveConvo'> +} { + return is$typed(v, id, 'logLeaveConvo') } -export function validateLogLeaveConvo(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#logLeaveConvo', v) +export function validateLogLeaveConvo(v: unknown) { + return lexicons.validate( + `${id}#logLeaveConvo`, + v, + ) as ValidationResult } export interface LogCreateMessage { @@ -181,16 +188,17 @@ export interface LogCreateMessage { [k: string]: unknown } -export function isLogCreateMessage(v: unknown): v is LogCreateMessage { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#logCreateMessage' - ) +export function isLogCreateMessage(v: unknown): v is LogCreateMessage & { + $type: $Type<'chat.bsky.convo.defs', 'logCreateMessage'> +} { + return is$typed(v, id, 'logCreateMessage') } -export function validateLogCreateMessage(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#logCreateMessage', v) +export function validateLogCreateMessage(v: unknown) { + return lexicons.validate( + `${id}#logCreateMessage`, + v, + ) as ValidationResult } export interface LogDeleteMessage { @@ -203,14 +211,15 @@ export interface LogDeleteMessage { [k: string]: unknown } -export function isLogDeleteMessage(v: unknown): v is LogDeleteMessage { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#logDeleteMessage' - ) +export function isLogDeleteMessage(v: unknown): v is LogDeleteMessage & { + $type: $Type<'chat.bsky.convo.defs', 'logDeleteMessage'> +} { + return is$typed(v, id, 'logDeleteMessage') } -export function validateLogDeleteMessage(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#logDeleteMessage', v) +export function validateLogDeleteMessage(v: unknown) { + return lexicons.validate( + `${id}#logDeleteMessage`, + v, + ) as ValidationResult } diff --git a/packages/api/src/client/types/chat/bsky/convo/deleteMessageForSelf.ts b/packages/api/src/client/types/chat/bsky/convo/deleteMessageForSelf.ts index 863d2208cb8..0679a4fe677 100644 --- a/packages/api/src/client/types/chat/bsky/convo/deleteMessageForSelf.ts +++ b/packages/api/src/client/types/chat/bsky/convo/deleteMessageForSelf.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ChatBskyConvoDefs from './defs' +const id = 'chat.bsky.convo.deleteMessageForSelf' + export interface QueryParams {} export interface InputSchema { diff --git a/packages/api/src/client/types/chat/bsky/convo/getConvo.ts b/packages/api/src/client/types/chat/bsky/convo/getConvo.ts index b3834234b5f..ba605729939 100644 --- a/packages/api/src/client/types/chat/bsky/convo/getConvo.ts +++ b/packages/api/src/client/types/chat/bsky/convo/getConvo.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ChatBskyConvoDefs from './defs' +const id = 'chat.bsky.convo.getConvo' + export interface QueryParams { convoId: string } diff --git a/packages/api/src/client/types/chat/bsky/convo/getConvoForMembers.ts b/packages/api/src/client/types/chat/bsky/convo/getConvoForMembers.ts index 9db44887410..795845b7379 100644 --- a/packages/api/src/client/types/chat/bsky/convo/getConvoForMembers.ts +++ b/packages/api/src/client/types/chat/bsky/convo/getConvoForMembers.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ChatBskyConvoDefs from './defs' +const id = 'chat.bsky.convo.getConvoForMembers' + export interface QueryParams { members: string[] } diff --git a/packages/api/src/client/types/chat/bsky/convo/getLog.ts b/packages/api/src/client/types/chat/bsky/convo/getLog.ts index f1470fd89ba..4185bc39c12 100644 --- a/packages/api/src/client/types/chat/bsky/convo/getLog.ts +++ b/packages/api/src/client/types/chat/bsky/convo/getLog.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ChatBskyConvoDefs from './defs' +const id = 'chat.bsky.convo.getLog' + export interface QueryParams { cursor?: string } diff --git a/packages/api/src/client/types/chat/bsky/convo/getMessages.ts b/packages/api/src/client/types/chat/bsky/convo/getMessages.ts index eea7cba82e1..d9f043c8081 100644 --- a/packages/api/src/client/types/chat/bsky/convo/getMessages.ts +++ b/packages/api/src/client/types/chat/bsky/convo/getMessages.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ChatBskyConvoDefs from './defs' +const id = 'chat.bsky.convo.getMessages' + export interface QueryParams { convoId: string limit?: number diff --git a/packages/api/src/client/types/chat/bsky/convo/leaveConvo.ts b/packages/api/src/client/types/chat/bsky/convo/leaveConvo.ts index 4124db1855d..5feed2d0ffb 100644 --- a/packages/api/src/client/types/chat/bsky/convo/leaveConvo.ts +++ b/packages/api/src/client/types/chat/bsky/convo/leaveConvo.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'chat.bsky.convo.leaveConvo' export interface QueryParams {} diff --git a/packages/api/src/client/types/chat/bsky/convo/listConvos.ts b/packages/api/src/client/types/chat/bsky/convo/listConvos.ts index 3cd1ad68516..19fcfc73554 100644 --- a/packages/api/src/client/types/chat/bsky/convo/listConvos.ts +++ b/packages/api/src/client/types/chat/bsky/convo/listConvos.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ChatBskyConvoDefs from './defs' +const id = 'chat.bsky.convo.listConvos' + export interface QueryParams { limit?: number cursor?: string diff --git a/packages/api/src/client/types/chat/bsky/convo/muteConvo.ts b/packages/api/src/client/types/chat/bsky/convo/muteConvo.ts index 93ac8785db7..caf7dc9c4a7 100644 --- a/packages/api/src/client/types/chat/bsky/convo/muteConvo.ts +++ b/packages/api/src/client/types/chat/bsky/convo/muteConvo.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ChatBskyConvoDefs from './defs' +const id = 'chat.bsky.convo.muteConvo' + export interface QueryParams {} export interface InputSchema { diff --git a/packages/api/src/client/types/chat/bsky/convo/sendMessage.ts b/packages/api/src/client/types/chat/bsky/convo/sendMessage.ts index e260ba6eee0..b5749f68c49 100644 --- a/packages/api/src/client/types/chat/bsky/convo/sendMessage.ts +++ b/packages/api/src/client/types/chat/bsky/convo/sendMessage.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ChatBskyConvoDefs from './defs' +const id = 'chat.bsky.convo.sendMessage' + export interface QueryParams {} export interface InputSchema { diff --git a/packages/api/src/client/types/chat/bsky/convo/sendMessageBatch.ts b/packages/api/src/client/types/chat/bsky/convo/sendMessageBatch.ts index 68ff2711df5..448e6a695c4 100644 --- a/packages/api/src/client/types/chat/bsky/convo/sendMessageBatch.ts +++ b/packages/api/src/client/types/chat/bsky/convo/sendMessageBatch.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ChatBskyConvoDefs from './defs' +const id = 'chat.bsky.convo.sendMessageBatch' + export interface QueryParams {} export interface InputSchema { @@ -43,14 +45,12 @@ export interface BatchItem { [k: string]: unknown } -export function isBatchItem(v: unknown): v is BatchItem { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.sendMessageBatch#batchItem' - ) +export function isBatchItem(v: unknown): v is BatchItem & { + $type: $Type<'chat.bsky.convo.sendMessageBatch', 'batchItem'> +} { + return is$typed(v, id, 'batchItem') } -export function validateBatchItem(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.sendMessageBatch#batchItem', v) +export function validateBatchItem(v: unknown) { + return lexicons.validate(`${id}#batchItem`, v) as ValidationResult } diff --git a/packages/api/src/client/types/chat/bsky/convo/unmuteConvo.ts b/packages/api/src/client/types/chat/bsky/convo/unmuteConvo.ts index 93ac8785db7..7bbf475d509 100644 --- a/packages/api/src/client/types/chat/bsky/convo/unmuteConvo.ts +++ b/packages/api/src/client/types/chat/bsky/convo/unmuteConvo.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ChatBskyConvoDefs from './defs' +const id = 'chat.bsky.convo.unmuteConvo' + export interface QueryParams {} export interface InputSchema { diff --git a/packages/api/src/client/types/chat/bsky/convo/updateRead.ts b/packages/api/src/client/types/chat/bsky/convo/updateRead.ts index b7a8041dbd7..a990b1d14bf 100644 --- a/packages/api/src/client/types/chat/bsky/convo/updateRead.ts +++ b/packages/api/src/client/types/chat/bsky/convo/updateRead.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ChatBskyConvoDefs from './defs' +const id = 'chat.bsky.convo.updateRead' + export interface QueryParams {} export interface InputSchema { diff --git a/packages/api/src/client/types/chat/bsky/moderation/getActorMetadata.ts b/packages/api/src/client/types/chat/bsky/moderation/getActorMetadata.ts index 6761c9939b5..9e2b0789f2a 100644 --- a/packages/api/src/client/types/chat/bsky/moderation/getActorMetadata.ts +++ b/packages/api/src/client/types/chat/bsky/moderation/getActorMetadata.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'chat.bsky.moderation.getActorMetadata' export interface QueryParams { actor: string @@ -43,14 +45,12 @@ export interface Metadata { [k: string]: unknown } -export function isMetadata(v: unknown): v is Metadata { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.moderation.getActorMetadata#metadata' - ) +export function isMetadata(v: unknown): v is Metadata & { + $type: $Type<'chat.bsky.moderation.getActorMetadata', 'metadata'> +} { + return is$typed(v, id, 'metadata') } -export function validateMetadata(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.moderation.getActorMetadata#metadata', v) +export function validateMetadata(v: unknown) { + return lexicons.validate(`${id}#metadata`, v) as ValidationResult } diff --git a/packages/api/src/client/types/chat/bsky/moderation/getMessageContext.ts b/packages/api/src/client/types/chat/bsky/moderation/getMessageContext.ts index 2315bfd4ad8..5ac31fa6ea9 100644 --- a/packages/api/src/client/types/chat/bsky/moderation/getMessageContext.ts +++ b/packages/api/src/client/types/chat/bsky/moderation/getMessageContext.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ChatBskyConvoDefs from '../convo/defs' +const id = 'chat.bsky.moderation.getMessageContext' + export interface QueryParams { /** Conversation that the message is from. NOTE: this field will eventually be required. */ convoId?: string diff --git a/packages/api/src/client/types/chat/bsky/moderation/updateActorAccess.ts b/packages/api/src/client/types/chat/bsky/moderation/updateActorAccess.ts index d6f0205672e..daf01350424 100644 --- a/packages/api/src/client/types/chat/bsky/moderation/updateActorAccess.ts +++ b/packages/api/src/client/types/chat/bsky/moderation/updateActorAccess.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'chat.bsky.moderation.updateActorAccess' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/admin/defs.ts b/packages/api/src/client/types/com/atproto/admin/defs.ts index 26510680347..f9c218ab111 100644 --- a/packages/api/src/client/types/com/atproto/admin/defs.ts +++ b/packages/api/src/client/types/com/atproto/admin/defs.ts @@ -2,27 +2,30 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ComAtprotoServerDefs from '../server/defs' +const id = 'com.atproto.admin.defs' + export interface StatusAttr { applied: boolean ref?: string [k: string]: unknown } -export function isStatusAttr(v: unknown): v is StatusAttr { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'com.atproto.admin.defs#statusAttr' - ) +export function isStatusAttr( + v: unknown, +): v is StatusAttr & { $type: $Type<'com.atproto.admin.defs', 'statusAttr'> } { + return is$typed(v, id, 'statusAttr') } -export function validateStatusAttr(v: unknown): ValidationResult { - return lexicons.validate('com.atproto.admin.defs#statusAttr', v) +export function validateStatusAttr(v: unknown) { + return lexicons.validate( + `${id}#statusAttr`, + v, + ) as ValidationResult } export interface AccountView { @@ -41,16 +44,17 @@ export interface AccountView { [k: string]: unknown } -export function isAccountView(v: unknown): v is AccountView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'com.atproto.admin.defs#accountView' - ) +export function isAccountView(v: unknown): v is AccountView & { + $type: $Type<'com.atproto.admin.defs', 'accountView'> +} { + return is$typed(v, id, 'accountView') } -export function validateAccountView(v: unknown): ValidationResult { - return lexicons.validate('com.atproto.admin.defs#accountView', v) +export function validateAccountView(v: unknown) { + return lexicons.validate( + `${id}#accountView`, + v, + ) as ValidationResult } export interface RepoRef { @@ -58,16 +62,14 @@ export interface RepoRef { [k: string]: unknown } -export function isRepoRef(v: unknown): v is RepoRef { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'com.atproto.admin.defs#repoRef' - ) +export function isRepoRef( + v: unknown, +): v is RepoRef & { $type: $Type<'com.atproto.admin.defs', 'repoRef'> } { + return is$typed(v, id, 'repoRef') } -export function validateRepoRef(v: unknown): ValidationResult { - return lexicons.validate('com.atproto.admin.defs#repoRef', v) +export function validateRepoRef(v: unknown) { + return lexicons.validate(`${id}#repoRef`, v) as ValidationResult } export interface RepoBlobRef { @@ -77,16 +79,17 @@ export interface RepoBlobRef { [k: string]: unknown } -export function isRepoBlobRef(v: unknown): v is RepoBlobRef { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'com.atproto.admin.defs#repoBlobRef' - ) +export function isRepoBlobRef(v: unknown): v is RepoBlobRef & { + $type: $Type<'com.atproto.admin.defs', 'repoBlobRef'> +} { + return is$typed(v, id, 'repoBlobRef') } -export function validateRepoBlobRef(v: unknown): ValidationResult { - return lexicons.validate('com.atproto.admin.defs#repoBlobRef', v) +export function validateRepoBlobRef(v: unknown) { + return lexicons.validate( + `${id}#repoBlobRef`, + v, + ) as ValidationResult } export interface ThreatSignature { @@ -95,14 +98,15 @@ export interface ThreatSignature { [k: string]: unknown } -export function isThreatSignature(v: unknown): v is ThreatSignature { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'com.atproto.admin.defs#threatSignature' - ) +export function isThreatSignature(v: unknown): v is ThreatSignature & { + $type: $Type<'com.atproto.admin.defs', 'threatSignature'> +} { + return is$typed(v, id, 'threatSignature') } -export function validateThreatSignature(v: unknown): ValidationResult { - return lexicons.validate('com.atproto.admin.defs#threatSignature', v) +export function validateThreatSignature(v: unknown) { + return lexicons.validate( + `${id}#threatSignature`, + v, + ) as ValidationResult } diff --git a/packages/api/src/client/types/com/atproto/admin/deleteAccount.ts b/packages/api/src/client/types/com/atproto/admin/deleteAccount.ts index 72066a656b7..ad77e52f254 100644 --- a/packages/api/src/client/types/com/atproto/admin/deleteAccount.ts +++ b/packages/api/src/client/types/com/atproto/admin/deleteAccount.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.admin.deleteAccount' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/admin/disableAccountInvites.ts b/packages/api/src/client/types/com/atproto/admin/disableAccountInvites.ts index 8df420239de..0be94798622 100644 --- a/packages/api/src/client/types/com/atproto/admin/disableAccountInvites.ts +++ b/packages/api/src/client/types/com/atproto/admin/disableAccountInvites.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.admin.disableAccountInvites' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/admin/disableInviteCodes.ts b/packages/api/src/client/types/com/atproto/admin/disableInviteCodes.ts index c264b65dbc2..20149d69098 100644 --- a/packages/api/src/client/types/com/atproto/admin/disableInviteCodes.ts +++ b/packages/api/src/client/types/com/atproto/admin/disableInviteCodes.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.admin.disableInviteCodes' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/admin/enableAccountInvites.ts b/packages/api/src/client/types/com/atproto/admin/enableAccountInvites.ts index 094b3dfe0af..f98d75f0638 100644 --- a/packages/api/src/client/types/com/atproto/admin/enableAccountInvites.ts +++ b/packages/api/src/client/types/com/atproto/admin/enableAccountInvites.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.admin.enableAccountInvites' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/admin/getAccountInfo.ts b/packages/api/src/client/types/com/atproto/admin/getAccountInfo.ts index 645b9e613ff..b99538478f3 100644 --- a/packages/api/src/client/types/com/atproto/admin/getAccountInfo.ts +++ b/packages/api/src/client/types/com/atproto/admin/getAccountInfo.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ComAtprotoAdminDefs from './defs' +const id = 'com.atproto.admin.getAccountInfo' + export interface QueryParams { did: string } diff --git a/packages/api/src/client/types/com/atproto/admin/getAccountInfos.ts b/packages/api/src/client/types/com/atproto/admin/getAccountInfos.ts index 9c1c273b9d9..f92ab95b675 100644 --- a/packages/api/src/client/types/com/atproto/admin/getAccountInfos.ts +++ b/packages/api/src/client/types/com/atproto/admin/getAccountInfos.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ComAtprotoAdminDefs from './defs' +const id = 'com.atproto.admin.getAccountInfos' + export interface QueryParams { dids: string[] } diff --git a/packages/api/src/client/types/com/atproto/admin/getInviteCodes.ts b/packages/api/src/client/types/com/atproto/admin/getInviteCodes.ts index faa4c8bed25..dba73561108 100644 --- a/packages/api/src/client/types/com/atproto/admin/getInviteCodes.ts +++ b/packages/api/src/client/types/com/atproto/admin/getInviteCodes.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ComAtprotoServerDefs from '../server/defs' +const id = 'com.atproto.admin.getInviteCodes' + export interface QueryParams { sort?: 'recent' | 'usage' | (string & {}) limit?: number diff --git a/packages/api/src/client/types/com/atproto/admin/getSubjectStatus.ts b/packages/api/src/client/types/com/atproto/admin/getSubjectStatus.ts index f11b514507d..771b3aeb8fa 100644 --- a/packages/api/src/client/types/com/atproto/admin/getSubjectStatus.ts +++ b/packages/api/src/client/types/com/atproto/admin/getSubjectStatus.ts @@ -3,12 +3,14 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ComAtprotoAdminDefs from './defs' import * as ComAtprotoRepoStrongRef from '../repo/strongRef' +const id = 'com.atproto.admin.getSubjectStatus' + export interface QueryParams { did?: string uri?: string diff --git a/packages/api/src/client/types/com/atproto/admin/searchAccounts.ts b/packages/api/src/client/types/com/atproto/admin/searchAccounts.ts index 2d22806238c..861e1db3b48 100644 --- a/packages/api/src/client/types/com/atproto/admin/searchAccounts.ts +++ b/packages/api/src/client/types/com/atproto/admin/searchAccounts.ts @@ -3,11 +3,13 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ComAtprotoAdminDefs from './defs' +const id = 'com.atproto.admin.searchAccounts' + export interface QueryParams { email?: string cursor?: string diff --git a/packages/api/src/client/types/com/atproto/admin/sendEmail.ts b/packages/api/src/client/types/com/atproto/admin/sendEmail.ts index 3f7c06d7070..55ac6dbf24b 100644 --- a/packages/api/src/client/types/com/atproto/admin/sendEmail.ts +++ b/packages/api/src/client/types/com/atproto/admin/sendEmail.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.admin.sendEmail' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/admin/updateAccountEmail.ts b/packages/api/src/client/types/com/atproto/admin/updateAccountEmail.ts index d13878711a6..99a48490a6d 100644 --- a/packages/api/src/client/types/com/atproto/admin/updateAccountEmail.ts +++ b/packages/api/src/client/types/com/atproto/admin/updateAccountEmail.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.admin.updateAccountEmail' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/admin/updateAccountHandle.ts b/packages/api/src/client/types/com/atproto/admin/updateAccountHandle.ts index 38fbcae1681..974144910ee 100644 --- a/packages/api/src/client/types/com/atproto/admin/updateAccountHandle.ts +++ b/packages/api/src/client/types/com/atproto/admin/updateAccountHandle.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.admin.updateAccountHandle' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/admin/updateAccountPassword.ts b/packages/api/src/client/types/com/atproto/admin/updateAccountPassword.ts index 412f0facca2..5c06c7f0df0 100644 --- a/packages/api/src/client/types/com/atproto/admin/updateAccountPassword.ts +++ b/packages/api/src/client/types/com/atproto/admin/updateAccountPassword.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.admin.updateAccountPassword' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/admin/updateSubjectStatus.ts b/packages/api/src/client/types/com/atproto/admin/updateSubjectStatus.ts index d890993cf3a..977ff64ab4e 100644 --- a/packages/api/src/client/types/com/atproto/admin/updateSubjectStatus.ts +++ b/packages/api/src/client/types/com/atproto/admin/updateSubjectStatus.ts @@ -3,12 +3,14 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' import * as ComAtprotoAdminDefs from './defs' import * as ComAtprotoRepoStrongRef from '../repo/strongRef' +const id = 'com.atproto.admin.updateSubjectStatus' + export interface QueryParams {} export interface InputSchema { diff --git a/packages/api/src/client/types/com/atproto/identity/getRecommendedDidCredentials.ts b/packages/api/src/client/types/com/atproto/identity/getRecommendedDidCredentials.ts index a5e4a0296de..040338ae5e9 100644 --- a/packages/api/src/client/types/com/atproto/identity/getRecommendedDidCredentials.ts +++ b/packages/api/src/client/types/com/atproto/identity/getRecommendedDidCredentials.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.identity.getRecommendedDidCredentials' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/identity/requestPlcOperationSignature.ts b/packages/api/src/client/types/com/atproto/identity/requestPlcOperationSignature.ts index dcab71e2558..e3dccdc0b20 100644 --- a/packages/api/src/client/types/com/atproto/identity/requestPlcOperationSignature.ts +++ b/packages/api/src/client/types/com/atproto/identity/requestPlcOperationSignature.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.identity.requestPlcOperationSignature' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/identity/resolveHandle.ts b/packages/api/src/client/types/com/atproto/identity/resolveHandle.ts index 32db72138f7..afc0829e338 100644 --- a/packages/api/src/client/types/com/atproto/identity/resolveHandle.ts +++ b/packages/api/src/client/types/com/atproto/identity/resolveHandle.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.identity.resolveHandle' export interface QueryParams { /** The handle to resolve. */ diff --git a/packages/api/src/client/types/com/atproto/identity/signPlcOperation.ts b/packages/api/src/client/types/com/atproto/identity/signPlcOperation.ts index 88c04c5993c..3847e611a56 100644 --- a/packages/api/src/client/types/com/atproto/identity/signPlcOperation.ts +++ b/packages/api/src/client/types/com/atproto/identity/signPlcOperation.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.identity.signPlcOperation' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/identity/submitPlcOperation.ts b/packages/api/src/client/types/com/atproto/identity/submitPlcOperation.ts index 74dea9f196d..e1042ad1774 100644 --- a/packages/api/src/client/types/com/atproto/identity/submitPlcOperation.ts +++ b/packages/api/src/client/types/com/atproto/identity/submitPlcOperation.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.identity.submitPlcOperation' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/identity/updateHandle.ts b/packages/api/src/client/types/com/atproto/identity/updateHandle.ts index c01d4887a4a..9ff1845c051 100644 --- a/packages/api/src/client/types/com/atproto/identity/updateHandle.ts +++ b/packages/api/src/client/types/com/atproto/identity/updateHandle.ts @@ -3,9 +3,11 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.identity.updateHandle' export interface QueryParams {} diff --git a/packages/api/src/client/types/com/atproto/label/defs.ts b/packages/api/src/client/types/com/atproto/label/defs.ts index 131682e550c..dfc59333ea6 100644 --- a/packages/api/src/client/types/com/atproto/label/defs.ts +++ b/packages/api/src/client/types/com/atproto/label/defs.ts @@ -2,9 +2,11 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { $Type, is$typed } from '../../../../util' +import { lexicons } from '../../../../lexicons' + +const id = 'com.atproto.label.defs' /** Metadata tag on an atproto resource (eg, repo or record). */ export interface Label { @@ -29,16 +31,14 @@ export interface Label { [k: string]: unknown } -export function isLabel(v: unknown): v is Label { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'com.atproto.label.defs#label' - ) +export function isLabel( + v: unknown, +): v is Label & { $type: $Type<'com.atproto.label.defs', 'label'> } { + return is$typed(v, id, 'label') } -export function validateLabel(v: unknown): ValidationResult { - return lexicons.validate('com.atproto.label.defs#label', v) +export function validateLabel(v: unknown) { + return lexicons.validate(`${id}#label`, v) as ValidationResult