diff --git a/packages/api/src/client/index.ts b/packages/api/src/client/index.ts index f9cd36fafae..9d09dcf77cb 100644 --- a/packages/api/src/client/index.ts +++ b/packages/api/src/client/index.ts @@ -4,6 +4,7 @@ import { XrpcClient, FetchHandler, FetchHandlerOptions } from '@atproto/xrpc' import { schemas } from './lexicons' import { CID } from 'multiformats/cid' +import { OmitKey } from './util' import * as ComAtprotoAdminDefs from './types/com/atproto/admin/defs' import * as ComAtprotoAdminDeleteAccount from './types/com/atproto/admin/deleteAccount' import * as ComAtprotoAdminDisableAccountInvites from './types/com/atproto/admin/disableAccountInvites' @@ -1608,7 +1609,7 @@ export class ProfileRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyActorProfile.Record }[] @@ -1621,7 +1622,7 @@ export class ProfileRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string; cid: string; value: AppBskyActorProfile.Record }> { const res = await this._client.call('com.atproto.repo.getRecord', { collection: 'app.bsky.actor.profile', @@ -1631,25 +1632,30 @@ export class ProfileRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyActorProfile.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.actor.profile' + const collection = 'app.bsky.actor.profile' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, - { collection: 'app.bsky.actor.profile', rkey: 'self', ...params, record }, + { + collection, + rkey: 'self', + ...params, + record: { ...record, $type: collection }, + }, { encoding: 'application/json', headers }, ) return res.data } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -1891,7 +1897,7 @@ export class GeneratorRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyFeedGenerator.Record }[] @@ -1904,7 +1910,7 @@ export class GeneratorRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string; cid: string; value: AppBskyFeedGenerator.Record }> { const res = await this._client.call('com.atproto.repo.getRecord', { collection: 'app.bsky.feed.generator', @@ -1914,25 +1920,25 @@ export class GeneratorRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyFeedGenerator.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.feed.generator' + const collection = 'app.bsky.feed.generator' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, - { collection: 'app.bsky.feed.generator', ...params, record }, + { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers }, ) return res.data } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -1952,7 +1958,7 @@ export class LikeRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyFeedLike.Record }[] @@ -1965,7 +1971,7 @@ export class LikeRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string; cid: string; value: AppBskyFeedLike.Record }> { const res = await this._client.call('com.atproto.repo.getRecord', { collection: 'app.bsky.feed.like', @@ -1975,25 +1981,25 @@ export class LikeRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyFeedLike.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.feed.like' + const collection = 'app.bsky.feed.like' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, - { collection: 'app.bsky.feed.like', ...params, record }, + { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers }, ) return res.data } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -2013,7 +2019,7 @@ export class PostRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyFeedPost.Record }[] @@ -2026,7 +2032,7 @@ export class PostRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string; cid: string; value: AppBskyFeedPost.Record }> { const res = await this._client.call('com.atproto.repo.getRecord', { collection: 'app.bsky.feed.post', @@ -2036,25 +2042,25 @@ export class PostRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyFeedPost.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.feed.post' + const collection = 'app.bsky.feed.post' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, - { collection: 'app.bsky.feed.post', ...params, record }, + { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers }, ) return res.data } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -2074,7 +2080,7 @@ export class PostgateRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyFeedPostgate.Record }[] @@ -2087,7 +2093,7 @@ export class PostgateRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string; cid: string; value: AppBskyFeedPostgate.Record }> { const res = await this._client.call('com.atproto.repo.getRecord', { collection: 'app.bsky.feed.postgate', @@ -2097,25 +2103,25 @@ export class PostgateRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyFeedPostgate.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.feed.postgate' + const collection = 'app.bsky.feed.postgate' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, - { collection: 'app.bsky.feed.postgate', ...params, record }, + { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers }, ) return res.data } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -2135,7 +2141,7 @@ export class RepostRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyFeedRepost.Record }[] @@ -2148,7 +2154,7 @@ export class RepostRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string; cid: string; value: AppBskyFeedRepost.Record }> { const res = await this._client.call('com.atproto.repo.getRecord', { collection: 'app.bsky.feed.repost', @@ -2158,25 +2164,25 @@ export class RepostRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyFeedRepost.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.feed.repost' + const collection = 'app.bsky.feed.repost' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, - { collection: 'app.bsky.feed.repost', ...params, record }, + { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers }, ) return res.data } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -2196,7 +2202,7 @@ export class ThreadgateRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyFeedThreadgate.Record }[] @@ -2209,7 +2215,7 @@ export class ThreadgateRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string cid: string @@ -2223,25 +2229,25 @@ export class ThreadgateRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyFeedThreadgate.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.feed.threadgate' + const collection = 'app.bsky.feed.threadgate' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, - { collection: 'app.bsky.feed.threadgate', ...params, record }, + { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers }, ) return res.data } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -2502,7 +2508,7 @@ export class BlockRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyGraphBlock.Record }[] @@ -2515,7 +2521,7 @@ export class BlockRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string; cid: string; value: AppBskyGraphBlock.Record }> { const res = await this._client.call('com.atproto.repo.getRecord', { collection: 'app.bsky.graph.block', @@ -2525,25 +2531,25 @@ export class BlockRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyGraphBlock.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.graph.block' + const collection = 'app.bsky.graph.block' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, - { collection: 'app.bsky.graph.block', ...params, record }, + { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers }, ) return res.data } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -2563,7 +2569,7 @@ export class FollowRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyGraphFollow.Record }[] @@ -2576,7 +2582,7 @@ export class FollowRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string; cid: string; value: AppBskyGraphFollow.Record }> { const res = await this._client.call('com.atproto.repo.getRecord', { collection: 'app.bsky.graph.follow', @@ -2586,25 +2592,25 @@ export class FollowRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyGraphFollow.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.graph.follow' + const collection = 'app.bsky.graph.follow' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, - { collection: 'app.bsky.graph.follow', ...params, record }, + { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers }, ) return res.data } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -2624,7 +2630,7 @@ export class ListRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyGraphList.Record }[] @@ -2637,7 +2643,7 @@ export class ListRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string; cid: string; value: AppBskyGraphList.Record }> { const res = await this._client.call('com.atproto.repo.getRecord', { collection: 'app.bsky.graph.list', @@ -2647,25 +2653,25 @@ export class ListRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyGraphList.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.graph.list' + const collection = 'app.bsky.graph.list' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, - { collection: 'app.bsky.graph.list', ...params, record }, + { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers }, ) return res.data } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -2685,7 +2691,7 @@ export class ListblockRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyGraphListblock.Record }[] @@ -2698,7 +2704,7 @@ export class ListblockRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string cid: string @@ -2712,25 +2718,25 @@ export class ListblockRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyGraphListblock.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.graph.listblock' + const collection = 'app.bsky.graph.listblock' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, - { collection: 'app.bsky.graph.listblock', ...params, record }, + { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers }, ) return res.data } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -2750,7 +2756,7 @@ export class ListitemRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyGraphListitem.Record }[] @@ -2763,7 +2769,7 @@ export class ListitemRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string; cid: string; value: AppBskyGraphListitem.Record }> { const res = await this._client.call('com.atproto.repo.getRecord', { collection: 'app.bsky.graph.listitem', @@ -2773,25 +2779,25 @@ export class ListitemRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyGraphListitem.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.graph.listitem' + const collection = 'app.bsky.graph.listitem' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, - { collection: 'app.bsky.graph.listitem', ...params, record }, + { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers }, ) return res.data } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -2811,7 +2817,7 @@ export class StarterpackRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyGraphStarterpack.Record }[] @@ -2824,7 +2830,7 @@ export class StarterpackRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string cid: string @@ -2838,25 +2844,25 @@ export class StarterpackRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyGraphStarterpack.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.graph.starterpack' + const collection = 'app.bsky.graph.starterpack' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, - { collection: 'app.bsky.graph.starterpack', ...params, record }, + { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers }, ) return res.data } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -2898,7 +2904,7 @@ export class ServiceRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: AppBskyLabelerService.Record }[] @@ -2911,7 +2917,7 @@ export class ServiceRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string cid: string @@ -2925,22 +2931,22 @@ export class ServiceRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: AppBskyLabelerService.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'app.bsky.labeler.service' + const collection = 'app.bsky.labeler.service' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, { - collection: 'app.bsky.labeler.service', + collection, rkey: 'self', ...params, - record, + record: { ...record, $type: collection }, }, { encoding: 'application/json', headers }, ) @@ -2948,7 +2954,7 @@ export class ServiceRecord { } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( @@ -3247,7 +3253,7 @@ export class DeclarationRecord { } async list( - params: Omit, + params: OmitKey, ): Promise<{ cursor?: string records: { uri: string; value: ChatBskyActorDeclaration.Record }[] @@ -3260,7 +3266,7 @@ export class DeclarationRecord { } async get( - params: Omit, + params: OmitKey, ): Promise<{ uri: string cid: string @@ -3274,22 +3280,22 @@ export class DeclarationRecord { } async create( - params: Omit< + params: OmitKey< ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record' >, record: ChatBskyActorDeclaration.Record, headers?: Record, ): Promise<{ uri: string; cid: string }> { - record.$type = 'chat.bsky.actor.declaration' + const collection = 'chat.bsky.actor.declaration' const res = await this._client.call( 'com.atproto.repo.createRecord', undefined, { - collection: 'chat.bsky.actor.declaration', + collection, rkey: 'self', ...params, - record, + record: { ...record, $type: collection }, }, { encoding: 'application/json', headers }, ) @@ -3297,7 +3303,7 @@ export class DeclarationRecord { } async delete( - params: Omit, + params: OmitKey, headers?: Record, ): Promise { await this._client.call( diff --git a/packages/api/src/client/lexicons.ts b/packages/api/src/client/lexicons.ts index 32bd89f98a4..adc2ae7f0a9 100644 --- a/packages/api/src/client/lexicons.ts +++ b/packages/api/src/client/lexicons.ts @@ -1,7 +1,13 @@ /** * GENERATED CODE - DO NOT MODIFY */ -import { LexiconDoc, Lexicons } from '@atproto/lexicon' +import { + LexiconDoc, + Lexicons, + ValidationError, + ValidationResult, +} from '@atproto/lexicon' +import { $Typed, is$typed, maybe$typed } from './util' export const schemaDict = { ComAtprotoAdminDefs: { @@ -13575,6 +13581,44 @@ export const schemaDict = { export const schemas = Object.values(schemaDict) export const lexicons: Lexicons = new Lexicons(schemas) + +export function validate(v: unknown, id: string, hash: string) { + return ( + maybe$typed(v, id, hash) + ? lexicons.validate(`${id}#${hash}`, v) + : { + success: false, + error: new ValidationError( + `Must be an object with "${id}#${hash}" $type property`, + ), + } + ) as ValidationResult +} + +export function isValid( + v: unknown, + id: string, + hash: string, + requiredType: true, +): v is $Typed +export function isValid( + v: unknown, + id: string, + hash: string, + requiredType?: boolean, +): v is V +export function isValid( + v: unknown, + id: string, + hash: string, + requiredType?: boolean, +) { + return ( + (requiredType ? is$typed : maybe$typed)(v, id, hash) && + validate(v, id, hash).success + ) +} + export const ids = { ComAtprotoAdminDefs: 'com.atproto.admin.defs', ComAtprotoAdminDeleteAccount: 'com.atproto.admin.deleteAccount', @@ -13825,4 +13869,4 @@ export const ids = { ToolsOzoneTeamDeleteMember: 'tools.ozone.team.deleteMember', ToolsOzoneTeamListMembers: 'tools.ozone.team.listMembers', ToolsOzoneTeamUpdateMember: 'tools.ozone.team.updateMember', -} +} as const 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 3266a4d0ee5..5e42bd080d5 100644 --- a/packages/api/src/client/types/app/bsky/actor/defs.ts +++ b/packages/api/src/client/types/app/bsky/actor/defs.ts @@ -3,15 +3,22 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +import type * as AppBskyGraphDefs from '../graph/defs' +import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.actor.defs' export interface ProfileViewBasic { + $type?: $Type<'app.bsky.actor.defs', 'profileViewBasic'> did: string handle: string displayName?: string @@ -20,25 +27,24 @@ export interface ProfileViewBasic { viewer?: ViewerState labels?: ComAtprotoLabelDefs.Label[] createdAt?: string - [k: string]: unknown } -export function isProfileViewBasic( - v: unknown, -): v is ProfileViewBasic & { - $type: $Type<'app.bsky.actor.defs', 'profileViewBasic'> -} { - return is$typed(v, id, 'profileViewBasic') +const hashProfileViewBasic = 'profileViewBasic' + +export function isProfileViewBasic(v: V) { + return is$typed(v, id, hashProfileViewBasic) } -export function validateProfileViewBasic(v: unknown) { - return lexicons.validate( - `${id}#profileViewBasic`, - v, - ) as ValidationResult +export function validateProfileViewBasic(v: V) { + return validate(v, id, hashProfileViewBasic) +} + +export function isValidProfileViewBasic(v: V) { + return isValid(v, id, hashProfileViewBasic) } export interface ProfileView { + $type?: $Type<'app.bsky.actor.defs', 'profileView'> did: string handle: string displayName?: string @@ -49,23 +55,24 @@ export interface ProfileView { createdAt?: string viewer?: ViewerState labels?: ComAtprotoLabelDefs.Label[] - [k: string]: unknown } -export function isProfileView( - v: unknown, -): v is ProfileView & { $type: $Type<'app.bsky.actor.defs', 'profileView'> } { - return is$typed(v, id, 'profileView') +const hashProfileView = 'profileView' + +export function isProfileView(v: V) { + return is$typed(v, id, hashProfileView) +} + +export function validateProfileView(v: V) { + return validate(v, id, hashProfileView) } -export function validateProfileView(v: unknown) { - return lexicons.validate( - `${id}#profileView`, - v, - ) as ValidationResult +export function isValidProfileView(v: V) { + return isValid(v, id, hashProfileView) } export interface ProfileViewDetailed { + $type?: $Type<'app.bsky.actor.defs', 'profileViewDetailed'> did: string handle: string displayName?: string @@ -82,70 +89,67 @@ export interface ProfileViewDetailed { viewer?: ViewerState labels?: ComAtprotoLabelDefs.Label[] pinnedPost?: ComAtprotoRepoStrongRef.Main - [k: string]: unknown } -export function isProfileViewDetailed( - v: unknown, -): v is ProfileViewDetailed & { - $type: $Type<'app.bsky.actor.defs', 'profileViewDetailed'> -} { - return is$typed(v, id, 'profileViewDetailed') +const hashProfileViewDetailed = 'profileViewDetailed' + +export function isProfileViewDetailed(v: V) { + return is$typed(v, id, hashProfileViewDetailed) +} + +export function validateProfileViewDetailed(v: V) { + return validate(v, id, hashProfileViewDetailed) } -export function validateProfileViewDetailed(v: unknown) { - return lexicons.validate( - `${id}#profileViewDetailed`, - v, - ) as ValidationResult +export function isValidProfileViewDetailed(v: V) { + return isValid(v, id, hashProfileViewDetailed) } export interface ProfileAssociated { + $type?: $Type<'app.bsky.actor.defs', 'profileAssociated'> lists?: number feedgens?: number starterPacks?: number labeler?: boolean chat?: ProfileAssociatedChat - [k: string]: unknown } -export function isProfileAssociated( - v: unknown, -): v is ProfileAssociated & { - $type: $Type<'app.bsky.actor.defs', 'profileAssociated'> -} { - return is$typed(v, id, 'profileAssociated') +const hashProfileAssociated = 'profileAssociated' + +export function isProfileAssociated(v: V) { + return is$typed(v, id, hashProfileAssociated) +} + +export function validateProfileAssociated(v: V) { + return validate(v, id, hashProfileAssociated) } -export function validateProfileAssociated(v: unknown) { - return lexicons.validate( - `${id}#profileAssociated`, - v, - ) as ValidationResult +export function isValidProfileAssociated(v: V) { + return isValid(v, id, hashProfileAssociated) } export interface ProfileAssociatedChat { + $type?: $Type<'app.bsky.actor.defs', 'profileAssociatedChat'> allowIncoming: 'all' | 'none' | 'following' | (string & {}) - [k: string]: unknown } -export function isProfileAssociatedChat( - v: unknown, -): v is ProfileAssociatedChat & { - $type: $Type<'app.bsky.actor.defs', 'profileAssociatedChat'> -} { - return is$typed(v, id, 'profileAssociatedChat') +const hashProfileAssociatedChat = 'profileAssociatedChat' + +export function isProfileAssociatedChat(v: V) { + return is$typed(v, id, hashProfileAssociatedChat) } -export function validateProfileAssociatedChat(v: unknown) { - return lexicons.validate( - `${id}#profileAssociatedChat`, - v, - ) as ValidationResult +export function validateProfileAssociatedChat(v: V) { + return validate(v, id, hashProfileAssociatedChat) +} + +export function isValidProfileAssociatedChat(v: V) { + return isValid(v, id, hashProfileAssociatedChat) } /** Metadata about the requesting account's relationship with the subject account. Only has meaningful content for authed requests. */ export interface ViewerState { + $type?: $Type<'app.bsky.actor.defs', 'viewerState'> muted?: boolean mutedByList?: AppBskyGraphDefs.ListViewBasic blockedBy?: boolean @@ -154,185 +158,184 @@ export interface ViewerState { following?: string followedBy?: string knownFollowers?: KnownFollowers - [k: string]: unknown } -export function isViewerState( - v: unknown, -): v is ViewerState & { $type: $Type<'app.bsky.actor.defs', 'viewerState'> } { - return is$typed(v, id, 'viewerState') +const hashViewerState = 'viewerState' + +export function isViewerState(v: V) { + return is$typed(v, id, hashViewerState) +} + +export function validateViewerState(v: V) { + return validate(v, id, hashViewerState) } -export function validateViewerState(v: unknown) { - return lexicons.validate( - `${id}#viewerState`, - v, - ) as ValidationResult +export function isValidViewerState(v: V) { + return isValid(v, id, hashViewerState) } /** The subject's followers whom you also follow */ export interface KnownFollowers { + $type?: $Type<'app.bsky.actor.defs', 'knownFollowers'> count: number followers: ProfileViewBasic[] - [k: string]: unknown } -export function isKnownFollowers( - v: unknown, -): v is KnownFollowers & { - $type: $Type<'app.bsky.actor.defs', 'knownFollowers'> -} { - return is$typed(v, id, 'knownFollowers') +const hashKnownFollowers = 'knownFollowers' + +export function isKnownFollowers(v: V) { + return is$typed(v, id, hashKnownFollowers) +} + +export function validateKnownFollowers(v: V) { + return validate(v, id, hashKnownFollowers) } -export function validateKnownFollowers(v: unknown) { - return lexicons.validate( - `${id}#knownFollowers`, - v, - ) as ValidationResult +export function isValidKnownFollowers(v: V) { + return isValid(v, id, hashKnownFollowers) } export type Preferences = ( - | AdultContentPref - | ContentLabelPref - | SavedFeedsPref - | SavedFeedsPrefV2 - | PersonalDetailsPref - | FeedViewPref - | ThreadViewPref - | InterestsPref - | MutedWordsPref - | HiddenPostsPref - | BskyAppStatePref - | LabelersPref - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | { $type: string } )[] export interface AdultContentPref { + $type?: $Type<'app.bsky.actor.defs', 'adultContentPref'> enabled: boolean - [k: string]: unknown } -export function isAdultContentPref( - v: unknown, -): v is AdultContentPref & { - $type: $Type<'app.bsky.actor.defs', 'adultContentPref'> -} { - return is$typed(v, id, 'adultContentPref') +const hashAdultContentPref = 'adultContentPref' + +export function isAdultContentPref(v: V) { + return is$typed(v, id, hashAdultContentPref) } -export function validateAdultContentPref(v: unknown) { - return lexicons.validate( - `${id}#adultContentPref`, - v, - ) as ValidationResult +export function validateAdultContentPref(v: V) { + return validate(v, id, hashAdultContentPref) +} + +export function isValidAdultContentPref(v: V) { + return isValid(v, id, hashAdultContentPref) } export interface ContentLabelPref { + $type?: $Type<'app.bsky.actor.defs', 'contentLabelPref'> /** Which labeler does this preference apply to? If undefined, applies globally. */ labelerDid?: string label: string visibility: 'ignore' | 'show' | 'warn' | 'hide' | (string & {}) - [k: string]: unknown } -export function isContentLabelPref( - v: unknown, -): v is ContentLabelPref & { - $type: $Type<'app.bsky.actor.defs', 'contentLabelPref'> -} { - return is$typed(v, id, 'contentLabelPref') +const hashContentLabelPref = 'contentLabelPref' + +export function isContentLabelPref(v: V) { + return is$typed(v, id, hashContentLabelPref) +} + +export function validateContentLabelPref(v: V) { + return validate(v, id, hashContentLabelPref) } -export function validateContentLabelPref(v: unknown) { - return lexicons.validate( - `${id}#contentLabelPref`, - v, - ) as ValidationResult +export function isValidContentLabelPref(v: V) { + return isValid(v, id, hashContentLabelPref) } export interface SavedFeed { + $type?: $Type<'app.bsky.actor.defs', 'savedFeed'> id: string type: 'feed' | 'list' | 'timeline' | (string & {}) value: string pinned: boolean - [k: string]: unknown } -export function isSavedFeed( - v: unknown, -): v is SavedFeed & { $type: $Type<'app.bsky.actor.defs', 'savedFeed'> } { - return is$typed(v, id, 'savedFeed') +const hashSavedFeed = 'savedFeed' + +export function isSavedFeed(v: V) { + return is$typed(v, id, hashSavedFeed) +} + +export function validateSavedFeed(v: V) { + return validate(v, id, hashSavedFeed) } -export function validateSavedFeed(v: unknown) { - return lexicons.validate(`${id}#savedFeed`, v) as ValidationResult +export function isValidSavedFeed(v: V) { + return isValid(v, id, hashSavedFeed) } export interface SavedFeedsPrefV2 { + $type?: $Type<'app.bsky.actor.defs', 'savedFeedsPrefV2'> items: SavedFeed[] - [k: string]: unknown } -export function isSavedFeedsPrefV2( - v: unknown, -): v is SavedFeedsPrefV2 & { - $type: $Type<'app.bsky.actor.defs', 'savedFeedsPrefV2'> -} { - return is$typed(v, id, 'savedFeedsPrefV2') +const hashSavedFeedsPrefV2 = 'savedFeedsPrefV2' + +export function isSavedFeedsPrefV2(v: V) { + return is$typed(v, id, hashSavedFeedsPrefV2) } -export function validateSavedFeedsPrefV2(v: unknown) { - return lexicons.validate( - `${id}#savedFeedsPrefV2`, - v, - ) as ValidationResult +export function validateSavedFeedsPrefV2(v: V) { + return validate(v, id, hashSavedFeedsPrefV2) +} + +export function isValidSavedFeedsPrefV2(v: V) { + return isValid(v, id, hashSavedFeedsPrefV2) } export interface SavedFeedsPref { + $type?: $Type<'app.bsky.actor.defs', 'savedFeedsPref'> pinned: string[] saved: string[] timelineIndex?: number - [k: string]: unknown } -export function isSavedFeedsPref( - v: unknown, -): v is SavedFeedsPref & { - $type: $Type<'app.bsky.actor.defs', 'savedFeedsPref'> -} { - return is$typed(v, id, 'savedFeedsPref') +const hashSavedFeedsPref = 'savedFeedsPref' + +export function isSavedFeedsPref(v: V) { + return is$typed(v, id, hashSavedFeedsPref) +} + +export function validateSavedFeedsPref(v: V) { + return validate(v, id, hashSavedFeedsPref) } -export function validateSavedFeedsPref(v: unknown) { - return lexicons.validate( - `${id}#savedFeedsPref`, - v, - ) as ValidationResult +export function isValidSavedFeedsPref(v: V) { + return isValid(v, id, hashSavedFeedsPref) } export interface PersonalDetailsPref { + $type?: $Type<'app.bsky.actor.defs', 'personalDetailsPref'> /** The birth date of account owner. */ birthDate?: string - [k: string]: unknown } -export function isPersonalDetailsPref( - v: unknown, -): v is PersonalDetailsPref & { - $type: $Type<'app.bsky.actor.defs', 'personalDetailsPref'> -} { - return is$typed(v, id, 'personalDetailsPref') +const hashPersonalDetailsPref = 'personalDetailsPref' + +export function isPersonalDetailsPref(v: V) { + return is$typed(v, id, hashPersonalDetailsPref) +} + +export function validatePersonalDetailsPref(v: V) { + return validate(v, id, hashPersonalDetailsPref) } -export function validatePersonalDetailsPref(v: unknown) { - return lexicons.validate( - `${id}#personalDetailsPref`, - v, - ) as ValidationResult +export function isValidPersonalDetailsPref(v: V) { + return isValid(v, id, hashPersonalDetailsPref) } export interface FeedViewPref { + $type?: $Type<'app.bsky.actor.defs', 'feedViewPref'> /** The URI of the feed, or an identifier which describes the feed. */ feed: string /** Hide replies in the feed. */ @@ -345,23 +348,24 @@ export interface FeedViewPref { hideReposts?: boolean /** Hide quote posts in the feed. */ hideQuotePosts?: boolean - [k: string]: unknown } -export function isFeedViewPref( - v: unknown, -): v is FeedViewPref & { $type: $Type<'app.bsky.actor.defs', 'feedViewPref'> } { - return is$typed(v, id, 'feedViewPref') +const hashFeedViewPref = 'feedViewPref' + +export function isFeedViewPref(v: V) { + return is$typed(v, id, hashFeedViewPref) } -export function validateFeedViewPref(v: unknown) { - return lexicons.validate( - `${id}#feedViewPref`, - v, - ) as ValidationResult +export function validateFeedViewPref(v: V) { + return validate(v, id, hashFeedViewPref) +} + +export function isValidFeedViewPref(v: V) { + return isValid(v, id, hashFeedViewPref) } export interface ThreadViewPref { + $type?: $Type<'app.bsky.actor.defs', 'threadViewPref'> /** Sorting mode for threads. */ sort?: | 'oldest' @@ -372,49 +376,47 @@ export interface ThreadViewPref { | (string & {}) /** Show followed users at the top of all replies. */ prioritizeFollowedUsers?: boolean - [k: string]: unknown } -export function isThreadViewPref( - v: unknown, -): v is ThreadViewPref & { - $type: $Type<'app.bsky.actor.defs', 'threadViewPref'> -} { - return is$typed(v, id, 'threadViewPref') +const hashThreadViewPref = 'threadViewPref' + +export function isThreadViewPref(v: V) { + return is$typed(v, id, hashThreadViewPref) +} + +export function validateThreadViewPref(v: V) { + return validate(v, id, hashThreadViewPref) } -export function validateThreadViewPref(v: unknown) { - return lexicons.validate( - `${id}#threadViewPref`, - v, - ) as ValidationResult +export function isValidThreadViewPref(v: V) { + return isValid(v, id, hashThreadViewPref) } export interface InterestsPref { + $type?: $Type<'app.bsky.actor.defs', 'interestsPref'> /** A list of tags which describe the account owner's interests gathered during onboarding. */ tags: string[] - [k: string]: unknown } -export function isInterestsPref( - v: unknown, -): v is InterestsPref & { - $type: $Type<'app.bsky.actor.defs', 'interestsPref'> -} { - return is$typed(v, id, 'interestsPref') +const hashInterestsPref = 'interestsPref' + +export function isInterestsPref(v: V) { + return is$typed(v, id, hashInterestsPref) +} + +export function validateInterestsPref(v: V) { + return validate(v, id, hashInterestsPref) } -export function validateInterestsPref(v: unknown) { - return lexicons.validate( - `${id}#interestsPref`, - v, - ) as ValidationResult +export function isValidInterestsPref(v: V) { + return isValid(v, id, hashInterestsPref) } export type MutedWordTarget = 'content' | 'tag' | (string & {}) /** A word that the account owner has muted. */ export interface MutedWord { + $type?: $Type<'app.bsky.actor.defs', 'mutedWord'> id?: string /** The muted word itself. */ value: string @@ -424,162 +426,165 @@ export interface MutedWord { actorTarget: 'all' | 'exclude-following' | (string & {}) /** The date and time at which the muted word will expire and no longer be applied. */ expiresAt?: string - [k: string]: unknown } -export function isMutedWord( - v: unknown, -): v is MutedWord & { $type: $Type<'app.bsky.actor.defs', 'mutedWord'> } { - return is$typed(v, id, 'mutedWord') +const hashMutedWord = 'mutedWord' + +export function isMutedWord(v: V) { + return is$typed(v, id, hashMutedWord) } -export function validateMutedWord(v: unknown) { - return lexicons.validate(`${id}#mutedWord`, v) as ValidationResult +export function validateMutedWord(v: V) { + return validate(v, id, hashMutedWord) +} + +export function isValidMutedWord(v: V) { + return isValid(v, id, hashMutedWord) } export interface MutedWordsPref { + $type?: $Type<'app.bsky.actor.defs', 'mutedWordsPref'> /** A list of words the account owner has muted. */ items: MutedWord[] - [k: string]: unknown } -export function isMutedWordsPref( - v: unknown, -): v is MutedWordsPref & { - $type: $Type<'app.bsky.actor.defs', 'mutedWordsPref'> -} { - return is$typed(v, id, 'mutedWordsPref') +const hashMutedWordsPref = 'mutedWordsPref' + +export function isMutedWordsPref(v: V) { + return is$typed(v, id, hashMutedWordsPref) +} + +export function validateMutedWordsPref(v: V) { + return validate(v, id, hashMutedWordsPref) } -export function validateMutedWordsPref(v: unknown) { - return lexicons.validate( - `${id}#mutedWordsPref`, - v, - ) as ValidationResult +export function isValidMutedWordsPref(v: V) { + return isValid(v, id, hashMutedWordsPref) } export interface HiddenPostsPref { + $type?: $Type<'app.bsky.actor.defs', 'hiddenPostsPref'> /** A list of URIs of posts the account owner has hidden. */ items: string[] - [k: string]: unknown } -export function isHiddenPostsPref( - v: unknown, -): v is HiddenPostsPref & { - $type: $Type<'app.bsky.actor.defs', 'hiddenPostsPref'> -} { - return is$typed(v, id, 'hiddenPostsPref') +const hashHiddenPostsPref = 'hiddenPostsPref' + +export function isHiddenPostsPref(v: V) { + return is$typed(v, id, hashHiddenPostsPref) +} + +export function validateHiddenPostsPref(v: V) { + return validate(v, id, hashHiddenPostsPref) } -export function validateHiddenPostsPref(v: unknown) { - return lexicons.validate( - `${id}#hiddenPostsPref`, - v, - ) as ValidationResult +export function isValidHiddenPostsPref(v: V) { + return isValid(v, id, hashHiddenPostsPref) } export interface LabelersPref { + $type?: $Type<'app.bsky.actor.defs', 'labelersPref'> labelers: LabelerPrefItem[] - [k: string]: unknown } -export function isLabelersPref( - v: unknown, -): v is LabelersPref & { $type: $Type<'app.bsky.actor.defs', 'labelersPref'> } { - return is$typed(v, id, 'labelersPref') +const hashLabelersPref = 'labelersPref' + +export function isLabelersPref(v: V) { + return is$typed(v, id, hashLabelersPref) } -export function validateLabelersPref(v: unknown) { - return lexicons.validate( - `${id}#labelersPref`, - v, - ) as ValidationResult +export function validateLabelersPref(v: V) { + return validate(v, id, hashLabelersPref) +} + +export function isValidLabelersPref(v: V) { + return isValid(v, id, hashLabelersPref) } export interface LabelerPrefItem { + $type?: $Type<'app.bsky.actor.defs', 'labelerPrefItem'> did: string - [k: string]: unknown } -export function isLabelerPrefItem( - v: unknown, -): v is LabelerPrefItem & { - $type: $Type<'app.bsky.actor.defs', 'labelerPrefItem'> -} { - return is$typed(v, id, 'labelerPrefItem') +const hashLabelerPrefItem = 'labelerPrefItem' + +export function isLabelerPrefItem(v: V) { + return is$typed(v, id, hashLabelerPrefItem) +} + +export function validateLabelerPrefItem(v: V) { + return validate(v, id, hashLabelerPrefItem) } -export function validateLabelerPrefItem(v: unknown) { - return lexicons.validate( - `${id}#labelerPrefItem`, - v, - ) as ValidationResult +export function isValidLabelerPrefItem(v: V) { + return isValid(v, id, hashLabelerPrefItem) } /** A grab bag of state that's specific to the bsky.app program. Third-party apps shouldn't use this. */ export interface BskyAppStatePref { + $type?: $Type<'app.bsky.actor.defs', 'bskyAppStatePref'> activeProgressGuide?: BskyAppProgressGuide /** An array of tokens which identify nudges (modals, popups, tours, highlight dots) that should be shown to the user. */ queuedNudges?: string[] /** Storage for NUXs the user has encountered. */ nuxs?: Nux[] - [k: string]: unknown } -export function isBskyAppStatePref( - v: unknown, -): v is BskyAppStatePref & { - $type: $Type<'app.bsky.actor.defs', 'bskyAppStatePref'> -} { - return is$typed(v, id, 'bskyAppStatePref') +const hashBskyAppStatePref = 'bskyAppStatePref' + +export function isBskyAppStatePref(v: V) { + return is$typed(v, id, hashBskyAppStatePref) +} + +export function validateBskyAppStatePref(v: V) { + return validate(v, id, hashBskyAppStatePref) } -export function validateBskyAppStatePref(v: unknown) { - return lexicons.validate( - `${id}#bskyAppStatePref`, - v, - ) as ValidationResult +export function isValidBskyAppStatePref(v: V) { + return isValid(v, id, hashBskyAppStatePref) } /** If set, an active progress guide. Once completed, can be set to undefined. Should have unspecced fields tracking progress. */ export interface BskyAppProgressGuide { + $type?: $Type<'app.bsky.actor.defs', 'bskyAppProgressGuide'> guide: string - [k: string]: unknown } -export function isBskyAppProgressGuide( - v: unknown, -): v is BskyAppProgressGuide & { - $type: $Type<'app.bsky.actor.defs', 'bskyAppProgressGuide'> -} { - return is$typed(v, id, 'bskyAppProgressGuide') +const hashBskyAppProgressGuide = 'bskyAppProgressGuide' + +export function isBskyAppProgressGuide(v: V) { + return is$typed(v, id, hashBskyAppProgressGuide) } -export function validateBskyAppProgressGuide(v: unknown) { - return lexicons.validate( - `${id}#bskyAppProgressGuide`, - v, - ) as ValidationResult +export function validateBskyAppProgressGuide(v: V) { + return validate(v, id, hashBskyAppProgressGuide) +} + +export function isValidBskyAppProgressGuide(v: V) { + return isValid(v, id, hashBskyAppProgressGuide) } /** A new user experiences (NUX) storage object */ export interface Nux { + $type?: $Type<'app.bsky.actor.defs', 'nux'> id: string completed: boolean /** Arbitrary data for the NUX. The structure is defined by the NUX itself. Limited to 300 characters. */ data?: string /** The date and time at which the NUX will expire and should be considered completed. */ expiresAt?: string - [k: string]: unknown } -export function isNux( - v: unknown, -): v is Nux & { $type: $Type<'app.bsky.actor.defs', 'nux'> } { - return is$typed(v, id, 'nux') +const hashNux = 'nux' + +export function isNux(v: V) { + return is$typed(v, id, hashNux) +} + +export function validateNux(v: V) { + return validate(v, id, hashNux) } -export function validateNux(v: unknown) { - return lexicons.validate(`${id}#nux`, v) as ValidationResult +export function isValidNux(v: V) { + return isValid(v, id, hashNux) } 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 31e7e98c29d..387315cc221 100644 --- a/packages/api/src/client/types/app/bsky/actor/getPreferences.ts +++ b/packages/api/src/client/types/app/bsky/actor/getPreferences.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.actor.getPreferences' export interface QueryParams {} @@ -16,7 +22,6 @@ export type InputSchema = undefined export interface OutputSchema { preferences: AppBskyActorDefs.Preferences - [k: string]: unknown } export interface CallOptions { 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 6b9b7bc9759..3807b4d6cd9 100644 --- a/packages/api/src/client/types/app/bsky/actor/getProfile.ts +++ b/packages/api/src/client/types/app/bsky/actor/getProfile.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.actor.getProfile' export interface QueryParams { 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 cb37b97f1cf..f8f02263f39 100644 --- a/packages/api/src/client/types/app/bsky/actor/getProfiles.ts +++ b/packages/api/src/client/types/app/bsky/actor/getProfiles.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.actor.getProfiles' export interface QueryParams { @@ -18,7 +24,6 @@ export type InputSchema = undefined export interface OutputSchema { profiles: AppBskyActorDefs.ProfileViewDetailed[] - [k: string]: unknown } export interface CallOptions { 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 972adadf066..6f92c4c79dc 100644 --- a/packages/api/src/client/types/app/bsky/actor/getSuggestions.ts +++ b/packages/api/src/client/types/app/bsky/actor/getSuggestions.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.actor.getSuggestions' export interface QueryParams { @@ -20,7 +26,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string actors: AppBskyActorDefs.ProfileView[] - [k: string]: unknown } export interface CallOptions { 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 9463df7cd24..666b6c48976 100644 --- a/packages/api/src/client/types/app/bsky/actor/profile.ts +++ b/packages/api/src/client/types/app/bsky/actor/profile.ts @@ -3,14 +3,21 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.actor.profile' export interface Record { + $type?: $Type<'app.bsky.actor.profile', 'main'> displayName?: string /** Free-form profile description text. */ description?: string @@ -18,21 +25,23 @@ export interface Record { avatar?: BlobRef /** Larger horizontal image to display behind profile view. */ banner?: BlobRef - labels?: - | ComAtprotoLabelDefs.SelfLabels - | { $type: string; [k: string]: unknown } + labels?: $Typed | { $type: string } joinedViaStarterPack?: ComAtprotoRepoStrongRef.Main pinnedPost?: ComAtprotoRepoStrongRef.Main createdAt?: string [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.actor.profile', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } 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 05f013edf7f..70d7542f85b 100644 --- a/packages/api/src/client/types/app/bsky/actor/putPreferences.ts +++ b/packages/api/src/client/types/app/bsky/actor/putPreferences.ts @@ -4,17 +4,22 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.actor.putPreferences' export interface QueryParams {} export interface InputSchema { preferences: AppBskyActorDefs.Preferences - [k: string]: unknown } export interface CallOptions { 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 d9b695f3e07..2c357ba0f12 100644 --- a/packages/api/src/client/types/app/bsky/actor/searchActors.ts +++ b/packages/api/src/client/types/app/bsky/actor/searchActors.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.actor.searchActors' export interface QueryParams { @@ -24,7 +30,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string actors: AppBskyActorDefs.ProfileView[] - [k: string]: unknown } export interface CallOptions { 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 69ca089e356..a2c571706f9 100644 --- a/packages/api/src/client/types/app/bsky/actor/searchActorsTypeahead.ts +++ b/packages/api/src/client/types/app/bsky/actor/searchActorsTypeahead.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.actor.searchActorsTypeahead' export interface QueryParams { @@ -22,7 +28,6 @@ export type InputSchema = undefined export interface OutputSchema { actors: AppBskyActorDefs.ProfileViewBasic[] - [k: string]: unknown } export interface CallOptions { 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 662d2ea7b80..73c40d8bdcb 100644 --- a/packages/api/src/client/types/app/bsky/embed/defs.ts +++ b/packages/api/src/client/types/app/bsky/embed/defs.ts @@ -3,27 +3,34 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate 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 { + $type?: $Type<'app.bsky.embed.defs', 'aspectRatio'> width: number height: number - [k: string]: unknown } -export function isAspectRatio( - v: unknown, -): v is AspectRatio & { $type: $Type<'app.bsky.embed.defs', 'aspectRatio'> } { - return is$typed(v, id, 'aspectRatio') +const hashAspectRatio = 'aspectRatio' + +export function isAspectRatio(v: V) { + return is$typed(v, id, hashAspectRatio) +} + +export function validateAspectRatio(v: V) { + return validate(v, id, hashAspectRatio) } -export function validateAspectRatio(v: unknown) { - return lexicons.validate( - `${id}#aspectRatio`, - v, - ) as ValidationResult +export function isValidAspectRatio(v: V) { + return isValid(v, id, hashAspectRatio) } 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 613608f7797..1e4a775c3fe 100644 --- a/packages/api/src/client/types/app/bsky/embed/external.ts +++ b/packages/api/src/client/types/app/bsky/embed/external.ts @@ -3,79 +3,96 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate 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 { + $type?: $Type<'app.bsky.embed.external', 'main'> external: External - [k: string]: unknown } -export function isMain( - v: unknown, -): v is Main & { $type: $Type<'app.bsky.embed.external', 'main'> } { - return is$typed(v, id, 'main') +const hashMain = 'main' + +export function isMain(v: V) { + return is$typed(v, id, hashMain) +} + +export function validateMain(v: V) { + return validate
(v, id, hashMain) } -export function validateMain(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult
+export function isValidMain(v: V) { + return isValid
(v, id, hashMain) } export interface External { + $type?: $Type<'app.bsky.embed.external', 'external'> uri: string title: string description: string thumb?: BlobRef - [k: string]: unknown } -export function isExternal( - v: unknown, -): v is External & { $type: $Type<'app.bsky.embed.external', 'external'> } { - return is$typed(v, id, 'external') +const hashExternal = 'external' + +export function isExternal(v: V) { + return is$typed(v, id, hashExternal) +} + +export function validateExternal(v: V) { + return validate(v, id, hashExternal) } -export function validateExternal(v: unknown) { - return lexicons.validate(`${id}#external`, v) as ValidationResult +export function isValidExternal(v: V) { + return isValid(v, id, hashExternal) } export interface View { + $type?: $Type<'app.bsky.embed.external', 'view'> external: ViewExternal - [k: string]: unknown } -export function isView( - v: unknown, -): v is View & { $type: $Type<'app.bsky.embed.external', 'view'> } { - return is$typed(v, id, 'view') +const hashView = 'view' + +export function isView(v: V) { + return is$typed(v, id, hashView) +} + +export function validateView(v: V) { + return validate(v, id, hashView) } -export function validateView(v: unknown) { - return lexicons.validate(`${id}#view`, v) as ValidationResult +export function isValidView(v: V) { + return isValid(v, id, hashView) } export interface ViewExternal { + $type?: $Type<'app.bsky.embed.external', 'viewExternal'> uri: string title: string description: string thumb?: string - [k: string]: unknown } -export function isViewExternal( - v: unknown, -): v is ViewExternal & { - $type: $Type<'app.bsky.embed.external', 'viewExternal'> -} { - return is$typed(v, id, 'viewExternal') +const hashViewExternal = 'viewExternal' + +export function isViewExternal(v: V) { + return is$typed(v, id, hashViewExternal) +} + +export function validateViewExternal(v: V) { + return validate(v, id, hashViewExternal) } -export function validateViewExternal(v: unknown) { - return lexicons.validate( - `${id}#viewExternal`, - v, - ) as ValidationResult +export function isValidViewExternal(v: V) { + return isValid(v, id, hashViewExternal) } 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 81fc960b1ab..d0c14d0f827 100644 --- a/packages/api/src/client/types/app/bsky/embed/images.ts +++ b/packages/api/src/client/types/app/bsky/embed/images.ts @@ -3,61 +3,80 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyEmbedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyEmbedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.embed.images' export interface Main { + $type?: $Type<'app.bsky.embed.images', 'main'> images: Image[] - [k: string]: unknown } -export function isMain( - v: unknown, -): v is Main & { $type: $Type<'app.bsky.embed.images', 'main'> } { - return is$typed(v, id, 'main') +const hashMain = 'main' + +export function isMain(v: V) { + return is$typed(v, id, hashMain) +} + +export function validateMain(v: V) { + return validate
(v, id, hashMain) } -export function validateMain(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult
+export function isValidMain(v: V) { + return isValid
(v, id, hashMain) } export interface Image { + $type?: $Type<'app.bsky.embed.images', 'image'> image: BlobRef /** Alt text description of the image, for accessibility. */ alt: string aspectRatio?: AppBskyEmbedDefs.AspectRatio - [k: string]: unknown } -export function isImage( - v: unknown, -): v is Image & { $type: $Type<'app.bsky.embed.images', 'image'> } { - return is$typed(v, id, 'image') +const hashImage = 'image' + +export function isImage(v: V) { + return is$typed(v, id, hashImage) +} + +export function validateImage(v: V) { + return validate(v, id, hashImage) } -export function validateImage(v: unknown) { - return lexicons.validate(`${id}#image`, v) as ValidationResult +export function isValidImage(v: V) { + return isValid(v, id, hashImage) } export interface View { + $type?: $Type<'app.bsky.embed.images', 'view'> images: ViewImage[] - [k: string]: unknown } -export function isView( - v: unknown, -): v is View & { $type: $Type<'app.bsky.embed.images', 'view'> } { - return is$typed(v, id, 'view') +const hashView = 'view' + +export function isView(v: V) { + return is$typed(v, id, hashView) +} + +export function validateView(v: V) { + return validate(v, id, hashView) } -export function validateView(v: unknown) { - return lexicons.validate(`${id}#view`, v) as ValidationResult +export function isValidView(v: V) { + return isValid(v, id, hashView) } export interface ViewImage { + $type?: $Type<'app.bsky.embed.images', 'viewImage'> /** Fully-qualified URL where a thumbnail of the image can be fetched. For example, CDN location provided by the App View. */ thumb: string /** Fully-qualified URL where a large version of the image can be fetched. May or may not be the exact original blob. For example, CDN location provided by the App View. */ @@ -65,15 +84,18 @@ export interface ViewImage { /** Alt text description of the image, for accessibility. */ alt: string aspectRatio?: AppBskyEmbedDefs.AspectRatio - [k: string]: unknown } -export function isViewImage( - v: unknown, -): v is ViewImage & { $type: $Type<'app.bsky.embed.images', 'viewImage'> } { - return is$typed(v, id, 'viewImage') +const hashViewImage = 'viewImage' + +export function isViewImage(v: V) { + return is$typed(v, id, hashViewImage) +} + +export function validateViewImage(v: V) { + return validate(v, id, hashViewImage) } -export function validateViewImage(v: unknown) { - return lexicons.validate(`${id}#viewImage`, v) as ValidationResult +export function isValidViewImage(v: V) { + return isValid(v, id, hashViewImage) } 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 223ad43e5f4..082545b5db4 100644 --- a/packages/api/src/client/types/app/bsky/embed/record.ts +++ b/packages/api/src/client/types/app/bsky/embed/record.ts @@ -3,154 +3,168 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' -import * as AppBskyLabelerDefs from '../labeler/defs' -import * as AppBskyActorDefs from '../actor/defs' -import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' -import * as AppBskyEmbedImages from './images' -import * as AppBskyEmbedVideo from './video' -import * as AppBskyEmbedExternal from './external' -import * as AppBskyEmbedRecordWithMedia from './recordWithMedia' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' +import type * as AppBskyFeedDefs from '../feed/defs' +import type * as AppBskyGraphDefs from '../graph/defs' +import type * as AppBskyLabelerDefs from '../labeler/defs' +import type * as AppBskyActorDefs from '../actor/defs' +import type * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +import type * as AppBskyEmbedImages from './images' +import type * as AppBskyEmbedVideo from './video' +import type * as AppBskyEmbedExternal from './external' +import type * as AppBskyEmbedRecordWithMedia from './recordWithMedia' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.embed.record' export interface Main { + $type?: $Type<'app.bsky.embed.record', 'main'> record: ComAtprotoRepoStrongRef.Main - [k: string]: unknown } -export function isMain( - v: unknown, -): v is Main & { $type: $Type<'app.bsky.embed.record', 'main'> } { - return is$typed(v, id, 'main') +const hashMain = 'main' + +export function isMain(v: V) { + return is$typed(v, id, hashMain) } -export function validateMain(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult
+export function validateMain(v: V) { + return validate
(v, id, hashMain) +} + +export function isValidMain(v: V) { + return isValid
(v, id, hashMain) } export interface View { + $type?: $Type<'app.bsky.embed.record', 'view'> record: - | ViewRecord - | ViewNotFound - | ViewBlocked - | ViewDetached - | AppBskyFeedDefs.GeneratorView - | AppBskyGraphDefs.ListView - | AppBskyLabelerDefs.LabelerView - | AppBskyGraphDefs.StarterPackViewBasic - | { $type: string; [k: string]: unknown } - [k: string]: unknown + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | { $type: string } +} + +const hashView = 'view' + +export function isView(v: V) { + return is$typed(v, id, hashView) } -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: V) { + return validate(v, id, hashView) } -export function validateView(v: unknown) { - return lexicons.validate(`${id}#view`, v) as ValidationResult +export function isValidView(v: V) { + return isValid(v, id, hashView) } export interface ViewRecord { + $type?: $Type<'app.bsky.embed.record', 'viewRecord'> uri: string cid: string author: AppBskyActorDefs.ProfileViewBasic /** The record data itself. */ - value: {} + value: { [_ in string]: unknown } labels?: ComAtprotoLabelDefs.Label[] replyCount?: number repostCount?: number likeCount?: number quoteCount?: number embeds?: ( - | AppBskyEmbedImages.View - | AppBskyEmbedVideo.View - | AppBskyEmbedExternal.View - | View - | AppBskyEmbedRecordWithMedia.View - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | { $type: string } )[] indexedAt: string - [k: string]: unknown } -export function isViewRecord( - v: unknown, -): v is ViewRecord & { $type: $Type<'app.bsky.embed.record', 'viewRecord'> } { - return is$typed(v, id, 'viewRecord') +const hashViewRecord = 'viewRecord' + +export function isViewRecord(v: V) { + return is$typed(v, id, hashViewRecord) +} + +export function validateViewRecord(v: V) { + return validate(v, id, hashViewRecord) } -export function validateViewRecord(v: unknown) { - return lexicons.validate( - `${id}#viewRecord`, - v, - ) as ValidationResult +export function isValidViewRecord(v: V) { + return isValid(v, id, hashViewRecord) } export interface ViewNotFound { + $type?: $Type<'app.bsky.embed.record', 'viewNotFound'> uri: string notFound: true - [k: string]: unknown } -export function isViewNotFound( - v: unknown, -): v is ViewNotFound & { - $type: $Type<'app.bsky.embed.record', 'viewNotFound'> -} { - return is$typed(v, id, 'viewNotFound') +const hashViewNotFound = 'viewNotFound' + +export function isViewNotFound(v: V) { + return is$typed(v, id, hashViewNotFound) +} + +export function validateViewNotFound(v: V) { + return validate(v, id, hashViewNotFound) } -export function validateViewNotFound(v: unknown) { - return lexicons.validate( - `${id}#viewNotFound`, - v, - ) as ValidationResult +export function isValidViewNotFound(v: V) { + return isValid(v, id, hashViewNotFound) } export interface ViewBlocked { + $type?: $Type<'app.bsky.embed.record', 'viewBlocked'> uri: string blocked: true author: AppBskyFeedDefs.BlockedAuthor - [k: string]: unknown } -export function isViewBlocked( - v: unknown, -): v is ViewBlocked & { $type: $Type<'app.bsky.embed.record', 'viewBlocked'> } { - return is$typed(v, id, 'viewBlocked') +const hashViewBlocked = 'viewBlocked' + +export function isViewBlocked(v: V) { + return is$typed(v, id, hashViewBlocked) } -export function validateViewBlocked(v: unknown) { - return lexicons.validate( - `${id}#viewBlocked`, - v, - ) as ValidationResult +export function validateViewBlocked(v: V) { + return validate(v, id, hashViewBlocked) +} + +export function isValidViewBlocked(v: V) { + return isValid(v, id, hashViewBlocked) } export interface ViewDetached { + $type?: $Type<'app.bsky.embed.record', 'viewDetached'> uri: string detached: true - [k: string]: unknown } -export function isViewDetached( - v: unknown, -): v is ViewDetached & { - $type: $Type<'app.bsky.embed.record', 'viewDetached'> -} { - return is$typed(v, id, 'viewDetached') +const hashViewDetached = 'viewDetached' + +export function isViewDetached(v: V) { + return is$typed(v, id, hashViewDetached) +} + +export function validateViewDetached(v: V) { + return validate(v, id, hashViewDetached) } -export function validateViewDetached(v: unknown) { - return lexicons.validate( - `${id}#viewDetached`, - v, - ) as ValidationResult +export function isValidViewDetached(v: V) { + return isValid(v, id, hashViewDetached) } 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 7c382d41853..c22958741f3 100644 --- a/packages/api/src/client/types/app/bsky/embed/recordWithMedia.ts +++ b/packages/api/src/client/types/app/bsky/embed/recordWithMedia.ts @@ -3,51 +3,65 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyEmbedRecord from './record' +import type * as AppBskyEmbedImages from './images' +import type * as AppBskyEmbedVideo from './video' +import type * as AppBskyEmbedExternal from './external' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.embed.recordWithMedia' export interface Main { + $type?: $Type<'app.bsky.embed.recordWithMedia', 'main'> record: AppBskyEmbedRecord.Main media: - | AppBskyEmbedImages.Main - | AppBskyEmbedVideo.Main - | AppBskyEmbedExternal.Main - | { $type: string; [k: string]: unknown } - [k: string]: unknown + | $Typed + | $Typed + | $Typed + | { $type: string } } -export function isMain( - v: unknown, -): v is Main & { $type: $Type<'app.bsky.embed.recordWithMedia', 'main'> } { - return is$typed(v, id, 'main') +const hashMain = 'main' + +export function isMain(v: V) { + return is$typed(v, id, hashMain) +} + +export function validateMain(v: V) { + return validate
(v, id, hashMain) } -export function validateMain(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult
+export function isValidMain(v: V) { + return isValid
(v, id, hashMain) } export interface View { + $type?: $Type<'app.bsky.embed.recordWithMedia', 'view'> record: AppBskyEmbedRecord.View media: - | AppBskyEmbedImages.View - | AppBskyEmbedVideo.View - | AppBskyEmbedExternal.View - | { $type: string; [k: string]: unknown } - [k: string]: unknown + | $Typed + | $Typed + | $Typed + | { $type: string } +} + +const hashView = 'view' + +export function isView(v: V) { + return is$typed(v, id, hashView) } -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: V) { + return validate(v, id, hashView) } -export function validateView(v: unknown) { - return lexicons.validate(`${id}#view`, v) as ValidationResult +export function isValidView(v: V) { + return isValid(v, id, hashView) } 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 eefabf0f660..3b8880139a1 100644 --- a/packages/api/src/client/types/app/bsky/embed/video.ts +++ b/packages/api/src/client/types/app/bsky/embed/video.ts @@ -3,62 +3,80 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyEmbedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyEmbedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.embed.video' export interface Main { + $type?: $Type<'app.bsky.embed.video', 'main'> video: BlobRef captions?: Caption[] /** Alt text description of the video, for accessibility. */ alt?: string aspectRatio?: AppBskyEmbedDefs.AspectRatio - [k: string]: unknown } -export function isMain( - v: unknown, -): v is Main & { $type: $Type<'app.bsky.embed.video', 'main'> } { - return is$typed(v, id, 'main') +const hashMain = 'main' + +export function isMain(v: V) { + return is$typed(v, id, hashMain) +} + +export function validateMain(v: V) { + return validate
(v, id, hashMain) } -export function validateMain(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult
+export function isValidMain(v: V) { + return isValid
(v, id, hashMain) } export interface Caption { + $type?: $Type<'app.bsky.embed.video', 'caption'> lang: string file: BlobRef - [k: string]: unknown } -export function isCaption( - v: unknown, -): v is Caption & { $type: $Type<'app.bsky.embed.video', 'caption'> } { - return is$typed(v, id, 'caption') +const hashCaption = 'caption' + +export function isCaption(v: V) { + return is$typed(v, id, hashCaption) } -export function validateCaption(v: unknown) { - return lexicons.validate(`${id}#caption`, v) as ValidationResult +export function validateCaption(v: V) { + return validate(v, id, hashCaption) +} + +export function isValidCaption(v: V) { + return isValid(v, id, hashCaption) } export interface View { + $type?: $Type<'app.bsky.embed.video', 'view'> cid: string playlist: string thumbnail?: string alt?: string aspectRatio?: AppBskyEmbedDefs.AspectRatio - [k: string]: unknown } -export function isView( - v: unknown, -): v is View & { $type: $Type<'app.bsky.embed.video', 'view'> } { - return is$typed(v, id, 'view') +const hashView = 'view' + +export function isView(v: V) { + return is$typed(v, id, hashView) +} + +export function validateView(v: V) { + return validate(v, id, hashView) } -export function validateView(v: unknown) { - return lexicons.validate(`${id}#view`, v) as ValidationResult +export function isValidView(v: V) { + return isValid(v, id, hashView) } 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 2447b305a2d..1269ef50b0a 100644 --- a/packages/api/src/client/types/app/bsky/feed/defs.ts +++ b/packages/api/src/client/types/app/bsky/feed/defs.ts @@ -3,32 +3,39 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' -import * as AppBskyEmbedExternal from '../embed/external' -import * as AppBskyEmbedRecord from '../embed/record' -import * as AppBskyEmbedRecordWithMedia from '../embed/recordWithMedia' -import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' -import * as AppBskyRichtextFacet from '../richtext/facet' -import * as AppBskyGraphDefs from '../graph/defs' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from '../actor/defs' +import type * as AppBskyEmbedImages from '../embed/images' +import type * as AppBskyEmbedVideo from '../embed/video' +import type * as AppBskyEmbedExternal from '../embed/external' +import type * as AppBskyEmbedRecord from '../embed/record' +import type * as AppBskyEmbedRecordWithMedia from '../embed/recordWithMedia' +import type * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +import type * as AppBskyRichtextFacet from '../richtext/facet' +import type * as AppBskyGraphDefs from '../graph/defs' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.defs' export interface PostView { + $type?: $Type<'app.bsky.feed.defs', 'postView'> uri: string cid: string author: AppBskyActorDefs.ProfileViewBasic - record: {} + record: { [_ in string]: unknown } embed?: - | AppBskyEmbedImages.View - | AppBskyEmbedVideo.View - | AppBskyEmbedExternal.View - | AppBskyEmbedRecord.View - | AppBskyEmbedRecordWithMedia.View - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | { $type: string } replyCount?: number repostCount?: number likeCount?: number @@ -37,215 +44,230 @@ export interface PostView { viewer?: ViewerState labels?: ComAtprotoLabelDefs.Label[] threadgate?: ThreadgateView - [k: string]: unknown } -export function isPostView( - v: unknown, -): v is PostView & { $type: $Type<'app.bsky.feed.defs', 'postView'> } { - return is$typed(v, id, 'postView') +const hashPostView = 'postView' + +export function isPostView(v: V) { + return is$typed(v, id, hashPostView) +} + +export function validatePostView(v: V) { + return validate(v, id, hashPostView) } -export function validatePostView(v: unknown) { - return lexicons.validate(`${id}#postView`, v) as ValidationResult +export function isValidPostView(v: V) { + return isValid(v, id, hashPostView) } /** Metadata about the requesting account's relationship with the subject content. Only has meaningful content for authed requests. */ export interface ViewerState { + $type?: $Type<'app.bsky.feed.defs', 'viewerState'> repost?: string like?: string threadMuted?: boolean replyDisabled?: boolean embeddingDisabled?: boolean pinned?: boolean - [k: string]: unknown } -export function isViewerState( - v: unknown, -): v is ViewerState & { $type: $Type<'app.bsky.feed.defs', 'viewerState'> } { - return is$typed(v, id, 'viewerState') +const hashViewerState = 'viewerState' + +export function isViewerState(v: V) { + return is$typed(v, id, hashViewerState) +} + +export function validateViewerState(v: V) { + return validate(v, id, hashViewerState) } -export function validateViewerState(v: unknown) { - return lexicons.validate( - `${id}#viewerState`, - v, - ) as ValidationResult +export function isValidViewerState(v: V) { + return isValid(v, id, hashViewerState) } export interface FeedViewPost { + $type?: $Type<'app.bsky.feed.defs', 'feedViewPost'> post: PostView reply?: ReplyRef - reason?: ReasonRepost | ReasonPin | { $type: string; [k: string]: unknown } + reason?: $Typed | $Typed | { $type: string } /** Context provided by feed generator that may be passed back alongside interactions. */ feedContext?: string - [k: string]: unknown } -export function isFeedViewPost( - v: unknown, -): v is FeedViewPost & { $type: $Type<'app.bsky.feed.defs', 'feedViewPost'> } { - return is$typed(v, id, 'feedViewPost') +const hashFeedViewPost = 'feedViewPost' + +export function isFeedViewPost(v: V) { + return is$typed(v, id, hashFeedViewPost) +} + +export function validateFeedViewPost(v: V) { + return validate(v, id, hashFeedViewPost) } -export function validateFeedViewPost(v: unknown) { - return lexicons.validate( - `${id}#feedViewPost`, - v, - ) as ValidationResult +export function isValidFeedViewPost(v: V) { + return isValid(v, id, hashFeedViewPost) } export interface ReplyRef { + $type?: $Type<'app.bsky.feed.defs', 'replyRef'> root: - | PostView - | NotFoundPost - | BlockedPost - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | { $type: string } parent: - | PostView - | NotFoundPost - | BlockedPost - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | { $type: string } grandparentAuthor?: AppBskyActorDefs.ProfileViewBasic - [k: string]: unknown } -export function isReplyRef( - v: unknown, -): v is ReplyRef & { $type: $Type<'app.bsky.feed.defs', 'replyRef'> } { - return is$typed(v, id, 'replyRef') +const hashReplyRef = 'replyRef' + +export function isReplyRef(v: V) { + return is$typed(v, id, hashReplyRef) +} + +export function validateReplyRef(v: V) { + return validate(v, id, hashReplyRef) } -export function validateReplyRef(v: unknown) { - return lexicons.validate(`${id}#replyRef`, v) as ValidationResult +export function isValidReplyRef(v: V) { + return isValid(v, id, hashReplyRef) } export interface ReasonRepost { + $type?: $Type<'app.bsky.feed.defs', 'reasonRepost'> by: AppBskyActorDefs.ProfileViewBasic indexedAt: string - [k: string]: unknown } -export function isReasonRepost( - v: unknown, -): v is ReasonRepost & { $type: $Type<'app.bsky.feed.defs', 'reasonRepost'> } { - return is$typed(v, id, 'reasonRepost') +const hashReasonRepost = 'reasonRepost' + +export function isReasonRepost(v: V) { + return is$typed(v, id, hashReasonRepost) +} + +export function validateReasonRepost(v: V) { + return validate(v, id, hashReasonRepost) } -export function validateReasonRepost(v: unknown) { - return lexicons.validate( - `${id}#reasonRepost`, - v, - ) as ValidationResult +export function isValidReasonRepost(v: V) { + return isValid(v, id, hashReasonRepost) } export interface ReasonPin { - [k: string]: unknown + $type?: $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') +const hashReasonPin = 'reasonPin' + +export function isReasonPin(v: V) { + return is$typed(v, id, hashReasonPin) } -export function validateReasonPin(v: unknown) { - return lexicons.validate(`${id}#reasonPin`, v) as ValidationResult +export function validateReasonPin(v: V) { + return validate(v, id, hashReasonPin) +} + +export function isValidReasonPin(v: V) { + return isValid(v, id, hashReasonPin) } export interface ThreadViewPost { + $type?: $Type<'app.bsky.feed.defs', 'threadViewPost'> post: PostView parent?: - | ThreadViewPost - | NotFoundPost - | BlockedPost - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | { $type: string } replies?: ( - | ThreadViewPost - | NotFoundPost - | BlockedPost - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | { $type: string } )[] - [k: string]: unknown } -export function isThreadViewPost( - v: unknown, -): v is ThreadViewPost & { - $type: $Type<'app.bsky.feed.defs', 'threadViewPost'> -} { - return is$typed(v, id, 'threadViewPost') +const hashThreadViewPost = 'threadViewPost' + +export function isThreadViewPost(v: V) { + return is$typed(v, id, hashThreadViewPost) } -export function validateThreadViewPost(v: unknown) { - return lexicons.validate( - `${id}#threadViewPost`, - v, - ) as ValidationResult +export function validateThreadViewPost(v: V) { + return validate(v, id, hashThreadViewPost) +} + +export function isValidThreadViewPost(v: V) { + return isValid(v, id, hashThreadViewPost) } export interface NotFoundPost { + $type?: $Type<'app.bsky.feed.defs', 'notFoundPost'> uri: string notFound: true - [k: string]: unknown } -export function isNotFoundPost( - v: unknown, -): v is NotFoundPost & { $type: $Type<'app.bsky.feed.defs', 'notFoundPost'> } { - return is$typed(v, id, 'notFoundPost') +const hashNotFoundPost = 'notFoundPost' + +export function isNotFoundPost(v: V) { + return is$typed(v, id, hashNotFoundPost) +} + +export function validateNotFoundPost(v: V) { + return validate(v, id, hashNotFoundPost) } -export function validateNotFoundPost(v: unknown) { - return lexicons.validate( - `${id}#notFoundPost`, - v, - ) as ValidationResult +export function isValidNotFoundPost(v: V) { + return isValid(v, id, hashNotFoundPost) } export interface BlockedPost { + $type?: $Type<'app.bsky.feed.defs', 'blockedPost'> uri: string blocked: true author: BlockedAuthor - [k: string]: unknown } -export function isBlockedPost( - v: unknown, -): v is BlockedPost & { $type: $Type<'app.bsky.feed.defs', 'blockedPost'> } { - return is$typed(v, id, 'blockedPost') +const hashBlockedPost = 'blockedPost' + +export function isBlockedPost(v: V) { + return is$typed(v, id, hashBlockedPost) +} + +export function validateBlockedPost(v: V) { + return validate(v, id, hashBlockedPost) } -export function validateBlockedPost(v: unknown) { - return lexicons.validate( - `${id}#blockedPost`, - v, - ) as ValidationResult +export function isValidBlockedPost(v: V) { + return isValid(v, id, hashBlockedPost) } export interface BlockedAuthor { + $type?: $Type<'app.bsky.feed.defs', 'blockedAuthor'> did: string viewer?: AppBskyActorDefs.ViewerState - [k: string]: unknown } -export function isBlockedAuthor( - v: unknown, -): v is BlockedAuthor & { - $type: $Type<'app.bsky.feed.defs', 'blockedAuthor'> -} { - return is$typed(v, id, 'blockedAuthor') +const hashBlockedAuthor = 'blockedAuthor' + +export function isBlockedAuthor(v: V) { + return is$typed(v, id, hashBlockedAuthor) } -export function validateBlockedAuthor(v: unknown) { - return lexicons.validate( - `${id}#blockedAuthor`, - v, - ) as ValidationResult +export function validateBlockedAuthor(v: V) { + return validate(v, id, hashBlockedAuthor) +} + +export function isValidBlockedAuthor(v: V) { + return isValid(v, id, hashBlockedAuthor) } export interface GeneratorView { + $type?: $Type<'app.bsky.feed.defs', 'generatorView'> uri: string cid: string did: string @@ -259,133 +281,127 @@ export interface GeneratorView { labels?: ComAtprotoLabelDefs.Label[] viewer?: GeneratorViewerState indexedAt: string - [k: string]: unknown } -export function isGeneratorView( - v: unknown, -): v is GeneratorView & { - $type: $Type<'app.bsky.feed.defs', 'generatorView'> -} { - return is$typed(v, id, 'generatorView') +const hashGeneratorView = 'generatorView' + +export function isGeneratorView(v: V) { + return is$typed(v, id, hashGeneratorView) } -export function validateGeneratorView(v: unknown) { - return lexicons.validate( - `${id}#generatorView`, - v, - ) as ValidationResult +export function validateGeneratorView(v: V) { + return validate(v, id, hashGeneratorView) +} + +export function isValidGeneratorView(v: V) { + return isValid(v, id, hashGeneratorView) } export interface GeneratorViewerState { + $type?: $Type<'app.bsky.feed.defs', 'generatorViewerState'> like?: string - [k: string]: unknown } -export function isGeneratorViewerState( - v: unknown, -): v is GeneratorViewerState & { - $type: $Type<'app.bsky.feed.defs', 'generatorViewerState'> -} { - return is$typed(v, id, 'generatorViewerState') +const hashGeneratorViewerState = 'generatorViewerState' + +export function isGeneratorViewerState(v: V) { + return is$typed(v, id, hashGeneratorViewerState) +} + +export function validateGeneratorViewerState(v: V) { + return validate(v, id, hashGeneratorViewerState) } -export function validateGeneratorViewerState(v: unknown) { - return lexicons.validate( - `${id}#generatorViewerState`, - v, - ) as ValidationResult +export function isValidGeneratorViewerState(v: V) { + return isValid(v, id, hashGeneratorViewerState) } export interface SkeletonFeedPost { + $type?: $Type<'app.bsky.feed.defs', 'skeletonFeedPost'> post: string reason?: - | SkeletonReasonRepost - | SkeletonReasonPin - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | { $type: string } /** Context that will be passed through to client and may be passed to feed generator back alongside interactions. */ feedContext?: string - [k: string]: unknown } -export function isSkeletonFeedPost( - v: unknown, -): v is SkeletonFeedPost & { - $type: $Type<'app.bsky.feed.defs', 'skeletonFeedPost'> -} { - return is$typed(v, id, 'skeletonFeedPost') +const hashSkeletonFeedPost = 'skeletonFeedPost' + +export function isSkeletonFeedPost(v: V) { + return is$typed(v, id, hashSkeletonFeedPost) +} + +export function validateSkeletonFeedPost(v: V) { + return validate(v, id, hashSkeletonFeedPost) } -export function validateSkeletonFeedPost(v: unknown) { - return lexicons.validate( - `${id}#skeletonFeedPost`, - v, - ) as ValidationResult +export function isValidSkeletonFeedPost(v: V) { + return isValid(v, id, hashSkeletonFeedPost) } export interface SkeletonReasonRepost { + $type?: $Type<'app.bsky.feed.defs', 'skeletonReasonRepost'> repost: string - [k: string]: unknown } -export function isSkeletonReasonRepost( - v: unknown, -): v is SkeletonReasonRepost & { - $type: $Type<'app.bsky.feed.defs', 'skeletonReasonRepost'> -} { - return is$typed(v, id, 'skeletonReasonRepost') +const hashSkeletonReasonRepost = 'skeletonReasonRepost' + +export function isSkeletonReasonRepost(v: V) { + return is$typed(v, id, hashSkeletonReasonRepost) +} + +export function validateSkeletonReasonRepost(v: V) { + return validate(v, id, hashSkeletonReasonRepost) } -export function validateSkeletonReasonRepost(v: unknown) { - return lexicons.validate( - `${id}#skeletonReasonRepost`, - v, - ) as ValidationResult +export function isValidSkeletonReasonRepost(v: V) { + return isValid(v, id, hashSkeletonReasonRepost) } export interface SkeletonReasonPin { - [k: string]: unknown + $type?: $Type<'app.bsky.feed.defs', 'skeletonReasonPin'> +} + +const hashSkeletonReasonPin = 'skeletonReasonPin' + +export function isSkeletonReasonPin(v: V) { + return is$typed(v, id, hashSkeletonReasonPin) } -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: V) { + return validate(v, id, hashSkeletonReasonPin) } -export function validateSkeletonReasonPin(v: unknown) { - return lexicons.validate( - `${id}#skeletonReasonPin`, - v, - ) as ValidationResult +export function isValidSkeletonReasonPin(v: V) { + return isValid(v, id, hashSkeletonReasonPin) } export interface ThreadgateView { + $type?: $Type<'app.bsky.feed.defs', 'threadgateView'> uri?: string cid?: string - record?: {} + record?: { [_ in string]: unknown } lists?: AppBskyGraphDefs.ListViewBasic[] - [k: string]: unknown } -export function isThreadgateView( - v: unknown, -): v is ThreadgateView & { - $type: $Type<'app.bsky.feed.defs', 'threadgateView'> -} { - return is$typed(v, id, 'threadgateView') +const hashThreadgateView = 'threadgateView' + +export function isThreadgateView(v: V) { + return is$typed(v, id, hashThreadgateView) +} + +export function validateThreadgateView(v: V) { + return validate(v, id, hashThreadgateView) } -export function validateThreadgateView(v: unknown) { - return lexicons.validate( - `${id}#threadgateView`, - v, - ) as ValidationResult +export function isValidThreadgateView(v: V) { + return isValid(v, id, hashThreadgateView) } export interface Interaction { + $type?: $Type<'app.bsky.feed.defs', 'interaction'> item?: string event?: | 'app.bsky.feed.defs#requestLess' @@ -403,20 +419,20 @@ export interface Interaction { | (string & {}) /** Context on a feed item that was originally supplied by the feed generator on getFeedSkeleton. */ feedContext?: string - [k: string]: unknown } -export function isInteraction( - v: unknown, -): v is Interaction & { $type: $Type<'app.bsky.feed.defs', 'interaction'> } { - return is$typed(v, id, 'interaction') +const hashInteraction = 'interaction' + +export function isInteraction(v: V) { + return is$typed(v, id, hashInteraction) +} + +export function validateInteraction(v: V) { + return validate(v, id, hashInteraction) } -export function validateInteraction(v: unknown) { - return lexicons.validate( - `${id}#interaction`, - v, - ) as ValidationResult +export function isValidInteraction(v: V) { + return isValid(v, id, hashInteraction) } /** Request that less content like the given feed item be shown in the feed */ 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 a9dd02e4c45..c93c90d7ab8 100644 --- a/packages/api/src/client/types/app/bsky/feed/describeFeedGenerator.ts +++ b/packages/api/src/client/types/app/bsky/feed/describeFeedGenerator.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.describeFeedGenerator' export interface QueryParams {} @@ -17,7 +23,6 @@ export interface OutputSchema { did: string feeds: Feed[] links?: Links - [k: string]: unknown } export interface CallOptions { @@ -36,34 +41,40 @@ export function toKnownErr(e: any) { } export interface Feed { + $type?: $Type<'app.bsky.feed.describeFeedGenerator', 'feed'> uri: string - [k: string]: unknown } -export function isFeed( - v: unknown, -): v is Feed & { $type: $Type<'app.bsky.feed.describeFeedGenerator', 'feed'> } { - return is$typed(v, id, 'feed') +const hashFeed = 'feed' + +export function isFeed(v: V) { + return is$typed(v, id, hashFeed) +} + +export function validateFeed(v: V) { + return validate(v, id, hashFeed) } -export function validateFeed(v: unknown) { - return lexicons.validate(`${id}#feed`, v) as ValidationResult +export function isValidFeed(v: V) { + return isValid(v, id, hashFeed) } export interface Links { + $type?: $Type<'app.bsky.feed.describeFeedGenerator', 'links'> privacyPolicy?: string termsOfService?: string - [k: string]: unknown } -export function isLinks( - v: unknown, -): v is Links & { - $type: $Type<'app.bsky.feed.describeFeedGenerator', 'links'> -} { - return is$typed(v, id, 'links') +const hashLinks = 'links' + +export function isLinks(v: V) { + return is$typed(v, id, hashLinks) +} + +export function validateLinks(v: V) { + return validate(v, id, hashLinks) } -export function validateLinks(v: unknown) { - return lexicons.validate(`${id}#links`, v) as ValidationResult +export function isValidLinks(v: V) { + return isValid(v, id, hashLinks) } 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 b92a1a44ff9..9c7a3fc0d62 100644 --- a/packages/api/src/client/types/app/bsky/feed/generator.ts +++ b/packages/api/src/client/types/app/bsky/feed/generator.ts @@ -3,14 +3,21 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyRichtextFacet from '../richtext/facet' +import type * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.generator' export interface Record { + $type?: $Type<'app.bsky.feed.generator', 'main'> did: string displayName: string description?: string @@ -18,19 +25,21 @@ export interface Record { avatar?: BlobRef /** Declaration that a feed accepts feedback interactions from a client through app.bsky.feed.sendInteractions */ acceptsInteractions?: boolean - labels?: - | ComAtprotoLabelDefs.SelfLabels - | { $type: string; [k: string]: unknown } + labels?: $Typed | { $type: string } createdAt: string [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.feed.generator', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } 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 98032703d46..e8b037e4b84 100644 --- a/packages/api/src/client/types/app/bsky/feed/getActorFeeds.ts +++ b/packages/api/src/client/types/app/bsky/feed/getActorFeeds.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getActorFeeds' export interface QueryParams { @@ -21,7 +27,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string feeds: AppBskyFeedDefs.GeneratorView[] - [k: string]: unknown } export interface CallOptions { 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 99545f33fe1..cb673b1efc7 100644 --- a/packages/api/src/client/types/app/bsky/feed/getActorLikes.ts +++ b/packages/api/src/client/types/app/bsky/feed/getActorLikes.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getActorLikes' export interface QueryParams { @@ -21,7 +27,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string feed: AppBskyFeedDefs.FeedViewPost[] - [k: string]: unknown } export interface CallOptions { 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 25bd09b0c5a..2b85919c8e1 100644 --- a/packages/api/src/client/types/app/bsky/feed/getAuthorFeed.ts +++ b/packages/api/src/client/types/app/bsky/feed/getAuthorFeed.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getAuthorFeed' export interface QueryParams { @@ -29,7 +35,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string feed: AppBskyFeedDefs.FeedViewPost[] - [k: string]: unknown } export interface CallOptions { 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 77cf2bf2d8e..f51b0802123 100644 --- a/packages/api/src/client/types/app/bsky/feed/getFeed.ts +++ b/packages/api/src/client/types/app/bsky/feed/getFeed.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getFeed' export interface QueryParams { @@ -21,7 +27,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string feed: AppBskyFeedDefs.FeedViewPost[] - [k: string]: unknown } export interface CallOptions { 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 d381a0e90d2..d3a244a3812 100644 --- a/packages/api/src/client/types/app/bsky/feed/getFeedGenerator.ts +++ b/packages/api/src/client/types/app/bsky/feed/getFeedGenerator.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getFeedGenerator' export interface QueryParams { @@ -23,7 +29,6 @@ export interface OutputSchema { isOnline: boolean /** Indicates whether the feed generator service is compatible with the record declaration. */ isValid: boolean - [k: string]: unknown } export interface CallOptions { 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 76f852faf78..842ec2aef5f 100644 --- a/packages/api/src/client/types/app/bsky/feed/getFeedGenerators.ts +++ b/packages/api/src/client/types/app/bsky/feed/getFeedGenerators.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getFeedGenerators' export interface QueryParams { @@ -18,7 +24,6 @@ export type InputSchema = undefined export interface OutputSchema { feeds: AppBskyFeedDefs.GeneratorView[] - [k: string]: unknown } export interface CallOptions { 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 76638027d38..c94141820e8 100644 --- a/packages/api/src/client/types/app/bsky/feed/getFeedSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/feed/getFeedSkeleton.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getFeedSkeleton' export interface QueryParams { @@ -22,7 +28,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string feed: AppBskyFeedDefs.SkeletonFeedPost[] - [k: string]: unknown } export interface CallOptions { 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 2e3f58a2a4c..2b3a9f5e0fc 100644 --- a/packages/api/src/client/types/app/bsky/feed/getLikes.ts +++ b/packages/api/src/client/types/app/bsky/feed/getLikes.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from '../actor/defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from '../actor/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getLikes' export interface QueryParams { @@ -26,7 +32,6 @@ export interface OutputSchema { cid?: string cursor?: string likes: Like[] - [k: string]: unknown } export interface CallOptions { @@ -45,18 +50,22 @@ export function toKnownErr(e: any) { } export interface Like { + $type?: $Type<'app.bsky.feed.getLikes', 'like'> indexedAt: string createdAt: string actor: AppBskyActorDefs.ProfileView - [k: string]: unknown } -export function isLike( - v: unknown, -): v is Like & { $type: $Type<'app.bsky.feed.getLikes', 'like'> } { - return is$typed(v, id, 'like') +const hashLike = 'like' + +export function isLike(v: V) { + return is$typed(v, id, hashLike) +} + +export function validateLike(v: V) { + return validate(v, id, hashLike) } -export function validateLike(v: unknown) { - return lexicons.validate(`${id}#like`, v) as ValidationResult +export function isValidLike(v: V) { + return isValid(v, id, hashLike) } 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 6e6dfd6a9ff..f56a761022f 100644 --- a/packages/api/src/client/types/app/bsky/feed/getListFeed.ts +++ b/packages/api/src/client/types/app/bsky/feed/getListFeed.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getListFeed' export interface QueryParams { @@ -22,7 +28,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string feed: AppBskyFeedDefs.FeedViewPost[] - [k: string]: unknown } export interface CallOptions { 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 53f193dd8da..245c55b9ced 100644 --- a/packages/api/src/client/types/app/bsky/feed/getPostThread.ts +++ b/packages/api/src/client/types/app/bsky/feed/getPostThread.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getPostThread' export interface QueryParams { @@ -23,12 +29,11 @@ export type InputSchema = undefined export interface OutputSchema { thread: - | AppBskyFeedDefs.ThreadViewPost - | AppBskyFeedDefs.NotFoundPost - | AppBskyFeedDefs.BlockedPost - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | { $type: string } threadgate?: AppBskyFeedDefs.ThreadgateView - [k: string]: unknown } export interface CallOptions { 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 de9aa66b6cc..6ca851e6819 100644 --- a/packages/api/src/client/types/app/bsky/feed/getPosts.ts +++ b/packages/api/src/client/types/app/bsky/feed/getPosts.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getPosts' export interface QueryParams { @@ -19,7 +25,6 @@ export type InputSchema = undefined export interface OutputSchema { posts: AppBskyFeedDefs.PostView[] - [k: string]: unknown } export interface CallOptions { 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 f0cff90d5e1..4550f286646 100644 --- a/packages/api/src/client/types/app/bsky/feed/getQuotes.ts +++ b/packages/api/src/client/types/app/bsky/feed/getQuotes.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getQuotes' export interface QueryParams { @@ -26,7 +32,6 @@ export interface OutputSchema { cid?: string cursor?: string posts: AppBskyFeedDefs.PostView[] - [k: string]: unknown } export interface CallOptions { 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 1db6626076f..1aecb6c715e 100644 --- a/packages/api/src/client/types/app/bsky/feed/getRepostedBy.ts +++ b/packages/api/src/client/types/app/bsky/feed/getRepostedBy.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from '../actor/defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from '../actor/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getRepostedBy' export interface QueryParams { @@ -26,7 +32,6 @@ export interface OutputSchema { cid?: string cursor?: string repostedBy: AppBskyActorDefs.ProfileView[] - [k: string]: unknown } export interface CallOptions { 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 a62bed53103..0e81367ec1c 100644 --- a/packages/api/src/client/types/app/bsky/feed/getSuggestedFeeds.ts +++ b/packages/api/src/client/types/app/bsky/feed/getSuggestedFeeds.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getSuggestedFeeds' export interface QueryParams { @@ -20,7 +26,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string feeds: AppBskyFeedDefs.GeneratorView[] - [k: string]: unknown } export interface CallOptions { 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 b5a6032028c..08135f639aa 100644 --- a/packages/api/src/client/types/app/bsky/feed/getTimeline.ts +++ b/packages/api/src/client/types/app/bsky/feed/getTimeline.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.getTimeline' export interface QueryParams { @@ -22,7 +28,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string feed: AppBskyFeedDefs.FeedViewPost[] - [k: string]: unknown } export interface CallOptions { 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 1d0402a3288..08ede56a096 100644 --- a/packages/api/src/client/types/app/bsky/feed/like.ts +++ b/packages/api/src/client/types/app/bsky/feed/like.ts @@ -3,24 +3,35 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.like' export interface Record { + $type?: $Type<'app.bsky.feed.like', 'main'> subject: ComAtprotoRepoStrongRef.Main createdAt: string [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.feed.like', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } 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 4621ad0dc10..8fcd72f9ac9 100644 --- a/packages/api/src/client/types/app/bsky/feed/post.ts +++ b/packages/api/src/client/types/app/bsky/feed/post.ts @@ -3,20 +3,27 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' -import * as AppBskyEmbedExternal from '../embed/external' -import * as AppBskyEmbedRecord from '../embed/record' -import * as AppBskyEmbedRecordWithMedia from '../embed/recordWithMedia' -import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' -import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyRichtextFacet from '../richtext/facet' +import type * as AppBskyEmbedImages from '../embed/images' +import type * as AppBskyEmbedVideo from '../embed/video' +import type * as AppBskyEmbedExternal from '../embed/external' +import type * as AppBskyEmbedRecord from '../embed/record' +import type * as AppBskyEmbedRecordWithMedia from '../embed/recordWithMedia' +import type * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.post' export interface Record { + $type?: $Type<'app.bsky.feed.post', 'main'> /** The primary post content. May be an empty string, if there are embeds. */ text: string /** DEPRECATED: replaced by app.bsky.richtext.facet. */ @@ -25,17 +32,15 @@ export interface Record { facets?: AppBskyRichtextFacet.Main[] reply?: ReplyRef embed?: - | AppBskyEmbedImages.Main - | AppBskyEmbedVideo.Main - | AppBskyEmbedExternal.Main - | AppBskyEmbedRecord.Main - | AppBskyEmbedRecordWithMedia.Main - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | $Typed + | $Typed + | { $type: string } /** Indicates human language of post primary text content. */ langs?: string[] - labels?: - | ComAtprotoLabelDefs.SelfLabels - | { $type: string; [k: string]: unknown } + labels?: $Typed | { $type: string } /** Additional hashtags, in addition to any included in post text and facets. */ tags?: string[] /** Client-declared timestamp when this post was originally created. */ @@ -43,64 +48,80 @@ export interface Record { [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.feed.post', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } export interface ReplyRef { + $type?: $Type<'app.bsky.feed.post', 'replyRef'> root: ComAtprotoRepoStrongRef.Main parent: ComAtprotoRepoStrongRef.Main - [k: string]: unknown } -export function isReplyRef( - v: unknown, -): v is ReplyRef & { $type: $Type<'app.bsky.feed.post', 'replyRef'> } { - return is$typed(v, id, 'replyRef') +const hashReplyRef = 'replyRef' + +export function isReplyRef(v: V) { + return is$typed(v, id, hashReplyRef) +} + +export function validateReplyRef(v: V) { + return validate(v, id, hashReplyRef) } -export function validateReplyRef(v: unknown) { - return lexicons.validate(`${id}#replyRef`, v) as ValidationResult +export function isValidReplyRef(v: V) { + return isValid(v, id, hashReplyRef) } /** Deprecated: use facets instead. */ export interface Entity { + $type?: $Type<'app.bsky.feed.post', 'entity'> index: TextSlice /** Expected values are 'mention' and 'link'. */ type: string value: string - [k: string]: unknown } -export function isEntity( - v: unknown, -): v is Entity & { $type: $Type<'app.bsky.feed.post', 'entity'> } { - return is$typed(v, id, 'entity') +const hashEntity = 'entity' + +export function isEntity(v: V) { + return is$typed(v, id, hashEntity) +} + +export function validateEntity(v: V) { + return validate(v, id, hashEntity) } -export function validateEntity(v: unknown) { - return lexicons.validate(`${id}#entity`, v) as ValidationResult +export function isValidEntity(v: V) { + return isValid(v, id, hashEntity) } /** Deprecated. Use app.bsky.richtext instead -- A text segment. Start is inclusive, end is exclusive. Indices are for utf16-encoded strings. */ export interface TextSlice { + $type?: $Type<'app.bsky.feed.post', 'textSlice'> start: number end: number - [k: string]: unknown } -export function isTextSlice( - v: unknown, -): v is TextSlice & { $type: $Type<'app.bsky.feed.post', 'textSlice'> } { - return is$typed(v, id, 'textSlice') +const hashTextSlice = 'textSlice' + +export function isTextSlice(v: V) { + return is$typed(v, id, hashTextSlice) +} + +export function validateTextSlice(v: V) { + return validate(v, id, hashTextSlice) } -export function validateTextSlice(v: unknown) { - return lexicons.validate(`${id}#textSlice`, v) as ValidationResult +export function isValidTextSlice(v: V) { + return isValid(v, id, hashTextSlice) } 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 bf7e40a70fa..25e9d32ff8c 100644 --- a/packages/api/src/client/types/app/bsky/feed/postgate.ts +++ b/packages/api/src/client/types/app/bsky/feed/postgate.ts @@ -3,47 +3,57 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.postgate' export interface Record { + $type?: $Type<'app.bsky.feed.postgate', 'main'> createdAt: string /** Reference (AT-URI) to the post record. */ post: string /** List of AT-URIs embedding this post that the author has detached from. */ detachedEmbeddingUris?: string[] - embeddingRules?: (DisableRule | { $type: string; [k: string]: unknown })[] + embeddingRules?: ($Typed | { $type: string })[] [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.feed.postgate', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } /** Disables embedding of this post. */ export interface DisableRule { - [k: string]: unknown + $type?: $Type<'app.bsky.feed.postgate', 'disableRule'> +} + +const hashDisableRule = 'disableRule' + +export function isDisableRule(v: V) { + return is$typed(v, id, hashDisableRule) } -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: V) { + return validate(v, id, hashDisableRule) } -export function validateDisableRule(v: unknown) { - return lexicons.validate( - `${id}#disableRule`, - v, - ) as ValidationResult +export function isValidDisableRule(v: V) { + return isValid(v, id, hashDisableRule) } 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 e602112d344..f51561588c7 100644 --- a/packages/api/src/client/types/app/bsky/feed/repost.ts +++ b/packages/api/src/client/types/app/bsky/feed/repost.ts @@ -3,24 +3,35 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.repost' export interface Record { + $type?: $Type<'app.bsky.feed.repost', 'main'> subject: ComAtprotoRepoStrongRef.Main createdAt: string [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.feed.repost', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } 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 d7d170af694..c945c5f284a 100644 --- a/packages/api/src/client/types/app/bsky/feed/searchPosts.ts +++ b/packages/api/src/client/types/app/bsky/feed/searchPosts.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.searchPosts' export interface QueryParams { @@ -43,7 +49,6 @@ export interface OutputSchema { /** Count of search hits. Optional, may be rounded/truncated, and may not be possible to paginate through all hits. */ hitsTotal?: number posts: AppBskyFeedDefs.PostView[] - [k: string]: unknown } export interface CallOptions { 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 63701c701b4..63a8d1abe5a 100644 --- a/packages/api/src/client/types/app/bsky/feed/sendInteractions.ts +++ b/packages/api/src/client/types/app/bsky/feed/sendInteractions.ts @@ -4,22 +4,25 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.sendInteractions' export interface QueryParams {} export interface InputSchema { interactions: AppBskyFeedDefs.Interaction[] - [k: string]: unknown } -export interface OutputSchema { - [k: string]: unknown -} +export interface OutputSchema {} export interface CallOptions { signal?: AbortSignal 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 a679c24f9cd..eefa35a8dab 100644 --- a/packages/api/src/client/types/app/bsky/feed/threadgate.ts +++ b/packages/api/src/client/types/app/bsky/feed/threadgate.ts @@ -3,19 +3,26 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.feed.threadgate' export interface Record { + $type?: $Type<'app.bsky.feed.threadgate', 'main'> /** Reference (AT-URI) to the post record. */ post: string allow?: ( - | MentionRule - | FollowingRule - | ListRule - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | { $type: string } )[] createdAt: string /** List of hidden reply URIs. */ @@ -23,68 +30,74 @@ export interface Record { [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.feed.threadgate', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } /** Allow replies from actors mentioned in your post. */ export interface MentionRule { - [k: string]: unknown + $type?: $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') +const hashMentionRule = 'mentionRule' + +export function isMentionRule(v: V) { + return is$typed(v, id, hashMentionRule) +} + +export function validateMentionRule(v: V) { + return validate(v, id, hashMentionRule) } -export function validateMentionRule(v: unknown) { - return lexicons.validate( - `${id}#mentionRule`, - v, - ) as ValidationResult +export function isValidMentionRule(v: V) { + return isValid(v, id, hashMentionRule) } /** Allow replies from actors you follow. */ export interface FollowingRule { - [k: string]: unknown + $type?: $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') +const hashFollowingRule = 'followingRule' + +export function isFollowingRule(v: V) { + return is$typed(v, id, hashFollowingRule) +} + +export function validateFollowingRule(v: V) { + return validate(v, id, hashFollowingRule) } -export function validateFollowingRule(v: unknown) { - return lexicons.validate( - `${id}#followingRule`, - v, - ) as ValidationResult +export function isValidFollowingRule(v: V) { + return isValid(v, id, hashFollowingRule) } /** Allow replies from actors on a list. */ export interface ListRule { + $type?: $Type<'app.bsky.feed.threadgate', 'listRule'> list: string - [k: string]: unknown } -export function isListRule( - v: unknown, -): v is ListRule & { $type: $Type<'app.bsky.feed.threadgate', 'listRule'> } { - return is$typed(v, id, 'listRule') +const hashListRule = 'listRule' + +export function isListRule(v: V) { + return is$typed(v, id, hashListRule) +} + +export function validateListRule(v: V) { + return validate(v, id, hashListRule) } -export function validateListRule(v: unknown) { - return lexicons.validate(`${id}#listRule`, v) as ValidationResult +export function isValidListRule(v: V) { + return isValid(v, id, hashListRule) } 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 4bc5a5f3038..c10702a4403 100644 --- a/packages/api/src/client/types/app/bsky/graph/block.ts +++ b/packages/api/src/client/types/app/bsky/graph/block.ts @@ -3,24 +3,35 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.block' export interface Record { + $type?: $Type<'app.bsky.graph.block', 'main'> /** DID of the account to be blocked. */ subject: string createdAt: string [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.graph.block', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } 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 90921996adc..52c8471a7d8 100644 --- a/packages/api/src/client/types/app/bsky/graph/defs.ts +++ b/packages/api/src/client/types/app/bsky/graph/defs.ts @@ -3,16 +3,23 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +import type * as AppBskyActorDefs from '../actor/defs' +import type * as AppBskyRichtextFacet from '../richtext/facet' +import type * as AppBskyFeedDefs from '../feed/defs' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.defs' export interface ListViewBasic { + $type?: $Type<'app.bsky.graph.defs', 'listViewBasic'> uri: string cid: string name: string @@ -22,25 +29,24 @@ export interface ListViewBasic { labels?: ComAtprotoLabelDefs.Label[] viewer?: ListViewerState indexedAt?: string - [k: string]: unknown } -export function isListViewBasic( - v: unknown, -): v is ListViewBasic & { - $type: $Type<'app.bsky.graph.defs', 'listViewBasic'> -} { - return is$typed(v, id, 'listViewBasic') +const hashListViewBasic = 'listViewBasic' + +export function isListViewBasic(v: V) { + return is$typed(v, id, hashListViewBasic) +} + +export function validateListViewBasic(v: V) { + return validate(v, id, hashListViewBasic) } -export function validateListViewBasic(v: unknown) { - return lexicons.validate( - `${id}#listViewBasic`, - v, - ) as ValidationResult +export function isValidListViewBasic(v: V) { + return isValid(v, id, hashListViewBasic) } export interface ListView { + $type?: $Type<'app.bsky.graph.defs', 'listView'> uri: string cid: string creator: AppBskyActorDefs.ProfileView @@ -53,42 +59,47 @@ export interface ListView { labels?: ComAtprotoLabelDefs.Label[] viewer?: ListViewerState indexedAt: string - [k: string]: unknown } -export function isListView( - v: unknown, -): v is ListView & { $type: $Type<'app.bsky.graph.defs', 'listView'> } { - return is$typed(v, id, 'listView') +const hashListView = 'listView' + +export function isListView(v: V) { + return is$typed(v, id, hashListView) +} + +export function validateListView(v: V) { + return validate(v, id, hashListView) } -export function validateListView(v: unknown) { - return lexicons.validate(`${id}#listView`, v) as ValidationResult +export function isValidListView(v: V) { + return isValid(v, id, hashListView) } export interface ListItemView { + $type?: $Type<'app.bsky.graph.defs', 'listItemView'> uri: string subject: AppBskyActorDefs.ProfileView - [k: string]: unknown } -export function isListItemView( - v: unknown, -): v is ListItemView & { $type: $Type<'app.bsky.graph.defs', 'listItemView'> } { - return is$typed(v, id, 'listItemView') +const hashListItemView = 'listItemView' + +export function isListItemView(v: V) { + return is$typed(v, id, hashListItemView) +} + +export function validateListItemView(v: V) { + return validate(v, id, hashListItemView) } -export function validateListItemView(v: unknown) { - return lexicons.validate( - `${id}#listItemView`, - v, - ) as ValidationResult +export function isValidListItemView(v: V) { + return isValid(v, id, hashListItemView) } export interface StarterPackView { + $type?: $Type<'app.bsky.graph.defs', 'starterPackView'> uri: string cid: string - record: {} + record: { [_ in string]: unknown } creator: AppBskyActorDefs.ProfileViewBasic list?: ListViewBasic listItemsSample?: ListItemView[] @@ -97,50 +108,47 @@ export interface StarterPackView { joinedAllTimeCount?: number labels?: ComAtprotoLabelDefs.Label[] indexedAt: string - [k: string]: unknown } -export function isStarterPackView( - v: unknown, -): v is StarterPackView & { - $type: $Type<'app.bsky.graph.defs', 'starterPackView'> -} { - return is$typed(v, id, 'starterPackView') +const hashStarterPackView = 'starterPackView' + +export function isStarterPackView(v: V) { + return is$typed(v, id, hashStarterPackView) +} + +export function validateStarterPackView(v: V) { + return validate(v, id, hashStarterPackView) } -export function validateStarterPackView(v: unknown) { - return lexicons.validate( - `${id}#starterPackView`, - v, - ) as ValidationResult +export function isValidStarterPackView(v: V) { + return isValid(v, id, hashStarterPackView) } export interface StarterPackViewBasic { + $type?: $Type<'app.bsky.graph.defs', 'starterPackViewBasic'> uri: string cid: string - record: {} + record: { [_ in string]: unknown } creator: AppBskyActorDefs.ProfileViewBasic listItemCount?: number joinedWeekCount?: number joinedAllTimeCount?: number labels?: ComAtprotoLabelDefs.Label[] indexedAt: string - [k: string]: unknown } -export function isStarterPackViewBasic( - v: unknown, -): v is StarterPackViewBasic & { - $type: $Type<'app.bsky.graph.defs', 'starterPackViewBasic'> -} { - return is$typed(v, id, 'starterPackViewBasic') +const hashStarterPackViewBasic = 'starterPackViewBasic' + +export function isStarterPackViewBasic(v: V) { + return is$typed(v, id, hashStarterPackViewBasic) +} + +export function validateStarterPackViewBasic(v: V) { + return validate(v, id, hashStarterPackViewBasic) } -export function validateStarterPackViewBasic(v: unknown) { - return lexicons.validate( - `${id}#starterPackViewBasic`, - v, - ) as ValidationResult +export function isValidStarterPackViewBasic(v: V) { + return isValid(v, id, hashStarterPackViewBasic) } export type ListPurpose = @@ -157,67 +165,66 @@ export const CURATELIST = `${id}#curatelist` export const REFERENCELIST = `${id}#referencelist` export interface ListViewerState { + $type?: $Type<'app.bsky.graph.defs', 'listViewerState'> muted?: boolean blocked?: string - [k: string]: unknown } -export function isListViewerState( - v: unknown, -): v is ListViewerState & { - $type: $Type<'app.bsky.graph.defs', 'listViewerState'> -} { - return is$typed(v, id, 'listViewerState') +const hashListViewerState = 'listViewerState' + +export function isListViewerState(v: V) { + return is$typed(v, id, hashListViewerState) +} + +export function validateListViewerState(v: V) { + return validate(v, id, hashListViewerState) } -export function validateListViewerState(v: unknown) { - return lexicons.validate( - `${id}#listViewerState`, - v, - ) as ValidationResult +export function isValidListViewerState(v: V) { + return isValid(v, id, hashListViewerState) } /** indicates that a handle or DID could not be resolved */ export interface NotFoundActor { + $type?: $Type<'app.bsky.graph.defs', 'notFoundActor'> actor: string notFound: true - [k: string]: unknown } -export function isNotFoundActor( - v: unknown, -): v is NotFoundActor & { - $type: $Type<'app.bsky.graph.defs', 'notFoundActor'> -} { - return is$typed(v, id, 'notFoundActor') +const hashNotFoundActor = 'notFoundActor' + +export function isNotFoundActor(v: V) { + return is$typed(v, id, hashNotFoundActor) +} + +export function validateNotFoundActor(v: V) { + return validate(v, id, hashNotFoundActor) } -export function validateNotFoundActor(v: unknown) { - return lexicons.validate( - `${id}#notFoundActor`, - v, - ) as ValidationResult +export function isValidNotFoundActor(v: V) { + return isValid(v, id, hashNotFoundActor) } /** lists the bi-directional graph relationships between one actor (not indicated in the object), and the target actors (the DID included in the object) */ export interface Relationship { + $type?: $Type<'app.bsky.graph.defs', 'relationship'> did: string /** if the actor follows this DID, this is the AT-URI of the follow record */ following?: string /** if the actor is followed by this DID, contains the AT-URI of the follow record */ followedBy?: string - [k: string]: unknown } -export function isRelationship( - v: unknown, -): v is Relationship & { $type: $Type<'app.bsky.graph.defs', 'relationship'> } { - return is$typed(v, id, 'relationship') +const hashRelationship = 'relationship' + +export function isRelationship(v: V) { + return is$typed(v, id, hashRelationship) +} + +export function validateRelationship(v: V) { + return validate(v, id, hashRelationship) } -export function validateRelationship(v: unknown) { - return lexicons.validate( - `${id}#relationship`, - v, - ) as ValidationResult +export function isValidRelationship(v: V) { + return isValid(v, id, hashRelationship) } 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 cd7728fdd18..28c81906d31 100644 --- a/packages/api/src/client/types/app/bsky/graph/follow.ts +++ b/packages/api/src/client/types/app/bsky/graph/follow.ts @@ -3,23 +3,34 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.follow' export interface Record { + $type?: $Type<'app.bsky.graph.follow', 'main'> subject: string createdAt: string [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.graph.follow', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } 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 0d56a3536d0..9de0f733842 100644 --- a/packages/api/src/client/types/app/bsky/graph/getActorStarterPacks.ts +++ b/packages/api/src/client/types/app/bsky/graph/getActorStarterPacks.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyGraphDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyGraphDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getActorStarterPacks' export interface QueryParams { @@ -21,7 +27,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string starterPacks: AppBskyGraphDefs.StarterPackViewBasic[] - [k: string]: unknown } export interface CallOptions { 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 7858841eb61..a0331c45abc 100644 --- a/packages/api/src/client/types/app/bsky/graph/getBlocks.ts +++ b/packages/api/src/client/types/app/bsky/graph/getBlocks.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from '../actor/defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from '../actor/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getBlocks' export interface QueryParams { @@ -20,7 +26,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string blocks: AppBskyActorDefs.ProfileView[] - [k: string]: unknown } export interface CallOptions { 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 3d4121bc0a7..0c1ca06b069 100644 --- a/packages/api/src/client/types/app/bsky/graph/getFollowers.ts +++ b/packages/api/src/client/types/app/bsky/graph/getFollowers.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from '../actor/defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from '../actor/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getFollowers' export interface QueryParams { @@ -22,7 +28,6 @@ export interface OutputSchema { subject: AppBskyActorDefs.ProfileView cursor?: string followers: AppBskyActorDefs.ProfileView[] - [k: string]: unknown } export interface CallOptions { 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 75b05d1c513..929b139cba2 100644 --- a/packages/api/src/client/types/app/bsky/graph/getFollows.ts +++ b/packages/api/src/client/types/app/bsky/graph/getFollows.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from '../actor/defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from '../actor/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getFollows' export interface QueryParams { @@ -22,7 +28,6 @@ export interface OutputSchema { subject: AppBskyActorDefs.ProfileView cursor?: string follows: AppBskyActorDefs.ProfileView[] - [k: string]: unknown } export interface CallOptions { 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 24dfd79f3ab..698596e78bd 100644 --- a/packages/api/src/client/types/app/bsky/graph/getKnownFollowers.ts +++ b/packages/api/src/client/types/app/bsky/graph/getKnownFollowers.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from '../actor/defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from '../actor/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getKnownFollowers' export interface QueryParams { @@ -22,7 +28,6 @@ export interface OutputSchema { subject: AppBskyActorDefs.ProfileView cursor?: string followers: AppBskyActorDefs.ProfileView[] - [k: string]: unknown } export interface CallOptions { 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 89bc0eeacb9..1f8a98fc7d1 100644 --- a/packages/api/src/client/types/app/bsky/graph/getList.ts +++ b/packages/api/src/client/types/app/bsky/graph/getList.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyGraphDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyGraphDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getList' export interface QueryParams { @@ -23,7 +29,6 @@ export interface OutputSchema { cursor?: string list: AppBskyGraphDefs.ListView items: AppBskyGraphDefs.ListItemView[] - [k: string]: unknown } export interface CallOptions { 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 0be93d089f6..70868b61ea8 100644 --- a/packages/api/src/client/types/app/bsky/graph/getListBlocks.ts +++ b/packages/api/src/client/types/app/bsky/graph/getListBlocks.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyGraphDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyGraphDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getListBlocks' export interface QueryParams { @@ -20,7 +26,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string lists: AppBskyGraphDefs.ListView[] - [k: string]: unknown } export interface CallOptions { 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 e377ac14d7a..009957651a4 100644 --- a/packages/api/src/client/types/app/bsky/graph/getListMutes.ts +++ b/packages/api/src/client/types/app/bsky/graph/getListMutes.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyGraphDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyGraphDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getListMutes' export interface QueryParams { @@ -20,7 +26,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string lists: AppBskyGraphDefs.ListView[] - [k: string]: unknown } export interface CallOptions { 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 6cae28caa98..e4d619929e8 100644 --- a/packages/api/src/client/types/app/bsky/graph/getLists.ts +++ b/packages/api/src/client/types/app/bsky/graph/getLists.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyGraphDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyGraphDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getLists' export interface QueryParams { @@ -22,7 +28,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string lists: AppBskyGraphDefs.ListView[] - [k: string]: unknown } export interface CallOptions { 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 a3708bdc5e9..5ca4d20ced6 100644 --- a/packages/api/src/client/types/app/bsky/graph/getMutes.ts +++ b/packages/api/src/client/types/app/bsky/graph/getMutes.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from '../actor/defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from '../actor/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getMutes' export interface QueryParams { @@ -20,7 +26,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string mutes: AppBskyActorDefs.ProfileView[] - [k: string]: unknown } export interface CallOptions { 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 fba7825bdfb..cf014538efc 100644 --- a/packages/api/src/client/types/app/bsky/graph/getRelationships.ts +++ b/packages/api/src/client/types/app/bsky/graph/getRelationships.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyGraphDefs from './defs' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyGraphDefs from './defs' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getRelationships' export interface QueryParams { @@ -22,11 +28,10 @@ export type InputSchema = undefined export interface OutputSchema { actor?: string relationships: ( - | AppBskyGraphDefs.Relationship - | AppBskyGraphDefs.NotFoundActor - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | { $type: string } )[] - [k: string]: unknown } export interface CallOptions { 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 c29073c7e8a..9ada3286741 100644 --- a/packages/api/src/client/types/app/bsky/graph/getStarterPack.ts +++ b/packages/api/src/client/types/app/bsky/graph/getStarterPack.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyGraphDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyGraphDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getStarterPack' export interface QueryParams { @@ -19,7 +25,6 @@ export type InputSchema = undefined export interface OutputSchema { starterPack: AppBskyGraphDefs.StarterPackView - [k: string]: unknown } export interface CallOptions { 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 d1c2df237b4..3ac4ba0fb14 100644 --- a/packages/api/src/client/types/app/bsky/graph/getStarterPacks.ts +++ b/packages/api/src/client/types/app/bsky/graph/getStarterPacks.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyGraphDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyGraphDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getStarterPacks' export interface QueryParams { @@ -18,7 +24,6 @@ export type InputSchema = undefined export interface OutputSchema { starterPacks: AppBskyGraphDefs.StarterPackViewBasic[] - [k: string]: unknown } export interface CallOptions { 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 b3df5a5e9c8..b7a3b754c11 100644 --- a/packages/api/src/client/types/app/bsky/graph/getSuggestedFollowsByActor.ts +++ b/packages/api/src/client/types/app/bsky/graph/getSuggestedFollowsByActor.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyActorDefs from '../actor/defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from '../actor/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.getSuggestedFollowsByActor' export interface QueryParams { @@ -20,7 +26,6 @@ export interface OutputSchema { suggestions: AppBskyActorDefs.ProfileView[] /** If true, response has fallen-back to generic results, and is not scoped using relativeToDid */ isFallback: boolean - [k: string]: unknown } export interface CallOptions { 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 f1e242d1661..97bf1c00559 100644 --- a/packages/api/src/client/types/app/bsky/graph/list.ts +++ b/packages/api/src/client/types/app/bsky/graph/list.ts @@ -3,34 +3,43 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyGraphDefs from './defs' +import type * as AppBskyRichtextFacet from '../richtext/facet' +import type * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.list' export interface Record { + $type?: $Type<'app.bsky.graph.list', 'main'> purpose: AppBskyGraphDefs.ListPurpose /** Display name for list; can not be empty. */ name: string description?: string descriptionFacets?: AppBskyRichtextFacet.Main[] avatar?: BlobRef - labels?: - | ComAtprotoLabelDefs.SelfLabels - | { $type: string; [k: string]: unknown } + labels?: $Typed | { $type: string } createdAt: string [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.graph.list', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } 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 ede600c112c..6ebd36c4cb3 100644 --- a/packages/api/src/client/types/app/bsky/graph/listblock.ts +++ b/packages/api/src/client/types/app/bsky/graph/listblock.ts @@ -3,24 +3,35 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.listblock' export interface Record { + $type?: $Type<'app.bsky.graph.listblock', 'main'> /** Reference (AT-URI) to the mod list record. */ subject: string createdAt: string [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.graph.listblock', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } 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 0a1a4590db6..a3b7efb0eb1 100644 --- a/packages/api/src/client/types/app/bsky/graph/listitem.ts +++ b/packages/api/src/client/types/app/bsky/graph/listitem.ts @@ -3,12 +3,19 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.listitem' export interface Record { + $type?: $Type<'app.bsky.graph.listitem', 'main'> /** The account which is included on the list. */ subject: string /** Reference (AT-URI) to the list record (app.bsky.graph.list). */ @@ -17,12 +24,16 @@ export interface Record { [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.graph.listitem', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } 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 18fbd027e53..f3580483cf3 100644 --- a/packages/api/src/client/types/app/bsky/graph/muteActor.ts +++ b/packages/api/src/client/types/app/bsky/graph/muteActor.ts @@ -4,16 +4,21 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.muteActor' export interface QueryParams {} export interface InputSchema { actor: string - [k: string]: unknown } export interface CallOptions { 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 6da99862d1c..371563d2193 100644 --- a/packages/api/src/client/types/app/bsky/graph/muteActorList.ts +++ b/packages/api/src/client/types/app/bsky/graph/muteActorList.ts @@ -4,16 +4,21 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.muteActorList' export interface QueryParams {} export interface InputSchema { list: string - [k: string]: unknown } export interface CallOptions { 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 1dde979bbbc..a99cb101c9e 100644 --- a/packages/api/src/client/types/app/bsky/graph/muteThread.ts +++ b/packages/api/src/client/types/app/bsky/graph/muteThread.ts @@ -4,16 +4,21 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.muteThread' export interface QueryParams {} export interface InputSchema { root: string - [k: string]: unknown } export interface CallOptions { 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 10c89a85b0b..cb683571f07 100644 --- a/packages/api/src/client/types/app/bsky/graph/searchStarterPacks.ts +++ b/packages/api/src/client/types/app/bsky/graph/searchStarterPacks.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyGraphDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyGraphDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.searchStarterPacks' export interface QueryParams { @@ -22,7 +28,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string starterPacks: AppBskyGraphDefs.StarterPackViewBasic[] - [k: string]: unknown } export interface CallOptions { 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 7466af55782..66abf07fd50 100644 --- a/packages/api/src/client/types/app/bsky/graph/starterpack.ts +++ b/packages/api/src/client/types/app/bsky/graph/starterpack.ts @@ -3,13 +3,20 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyRichtextFacet from '../richtext/facet' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyRichtextFacet from '../richtext/facet' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.starterpack' export interface Record { + $type?: $Type<'app.bsky.graph.starterpack', 'main'> /** Display name for starter pack; can not be empty. */ name: string description?: string @@ -21,27 +28,35 @@ export interface Record { [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.graph.starterpack', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } export interface FeedItem { + $type?: $Type<'app.bsky.graph.starterpack', 'feedItem'> uri: string - [k: string]: unknown } -export function isFeedItem( - v: unknown, -): v is FeedItem & { $type: $Type<'app.bsky.graph.starterpack', 'feedItem'> } { - return is$typed(v, id, 'feedItem') +const hashFeedItem = 'feedItem' + +export function isFeedItem(v: V) { + return is$typed(v, id, hashFeedItem) +} + +export function validateFeedItem(v: V) { + return validate(v, id, hashFeedItem) } -export function validateFeedItem(v: unknown) { - return lexicons.validate(`${id}#feedItem`, v) as ValidationResult +export function isValidFeedItem(v: V) { + return isValid(v, id, hashFeedItem) } 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 0cb4970f37d..548a2ad0cf1 100644 --- a/packages/api/src/client/types/app/bsky/graph/unmuteActor.ts +++ b/packages/api/src/client/types/app/bsky/graph/unmuteActor.ts @@ -4,16 +4,21 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.unmuteActor' export interface QueryParams {} export interface InputSchema { actor: string - [k: string]: unknown } export interface CallOptions { 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 f866d0d6cdd..1be31921fd9 100644 --- a/packages/api/src/client/types/app/bsky/graph/unmuteActorList.ts +++ b/packages/api/src/client/types/app/bsky/graph/unmuteActorList.ts @@ -4,16 +4,21 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.unmuteActorList' export interface QueryParams {} export interface InputSchema { list: string - [k: string]: unknown } export interface CallOptions { 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 25b03006f27..657c17c949a 100644 --- a/packages/api/src/client/types/app/bsky/graph/unmuteThread.ts +++ b/packages/api/src/client/types/app/bsky/graph/unmuteThread.ts @@ -4,16 +4,21 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.graph.unmuteThread' export interface QueryParams {} export interface InputSchema { root: string - [k: string]: unknown } export interface CallOptions { 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 50a5302866e..e0f2f945b4e 100644 --- a/packages/api/src/client/types/app/bsky/labeler/defs.ts +++ b/packages/api/src/client/types/app/bsky/labeler/defs.ts @@ -3,14 +3,21 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from '../actor/defs' +import type * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.labeler.defs' export interface LabelerView { + $type?: $Type<'app.bsky.labeler.defs', 'labelerView'> uri: string cid: string creator: AppBskyActorDefs.ProfileView @@ -18,23 +25,24 @@ export interface LabelerView { viewer?: LabelerViewerState indexedAt: string labels?: ComAtprotoLabelDefs.Label[] - [k: string]: unknown } -export function isLabelerView( - v: unknown, -): v is LabelerView & { $type: $Type<'app.bsky.labeler.defs', 'labelerView'> } { - return is$typed(v, id, 'labelerView') +const hashLabelerView = 'labelerView' + +export function isLabelerView(v: V) { + return is$typed(v, id, hashLabelerView) +} + +export function validateLabelerView(v: V) { + return validate(v, id, hashLabelerView) } -export function validateLabelerView(v: unknown) { - return lexicons.validate( - `${id}#labelerView`, - v, - ) as ValidationResult +export function isValidLabelerView(v: V) { + return isValid(v, id, hashLabelerView) } export interface LabelerViewDetailed { + $type?: $Type<'app.bsky.labeler.defs', 'labelerViewDetailed'> uri: string cid: string creator: AppBskyActorDefs.ProfileView @@ -43,63 +51,59 @@ export interface LabelerViewDetailed { viewer?: LabelerViewerState indexedAt: string labels?: ComAtprotoLabelDefs.Label[] - [k: string]: unknown } -export function isLabelerViewDetailed( - v: unknown, -): v is LabelerViewDetailed & { - $type: $Type<'app.bsky.labeler.defs', 'labelerViewDetailed'> -} { - return is$typed(v, id, 'labelerViewDetailed') +const hashLabelerViewDetailed = 'labelerViewDetailed' + +export function isLabelerViewDetailed(v: V) { + return is$typed(v, id, hashLabelerViewDetailed) +} + +export function validateLabelerViewDetailed(v: V) { + return validate(v, id, hashLabelerViewDetailed) } -export function validateLabelerViewDetailed(v: unknown) { - return lexicons.validate( - `${id}#labelerViewDetailed`, - v, - ) as ValidationResult +export function isValidLabelerViewDetailed(v: V) { + return isValid(v, id, hashLabelerViewDetailed) } export interface LabelerViewerState { + $type?: $Type<'app.bsky.labeler.defs', 'labelerViewerState'> like?: string - [k: string]: unknown } -export function isLabelerViewerState( - v: unknown, -): v is LabelerViewerState & { - $type: $Type<'app.bsky.labeler.defs', 'labelerViewerState'> -} { - return is$typed(v, id, 'labelerViewerState') +const hashLabelerViewerState = 'labelerViewerState' + +export function isLabelerViewerState(v: V) { + return is$typed(v, id, hashLabelerViewerState) +} + +export function validateLabelerViewerState(v: V) { + return validate(v, id, hashLabelerViewerState) } -export function validateLabelerViewerState(v: unknown) { - return lexicons.validate( - `${id}#labelerViewerState`, - v, - ) as ValidationResult +export function isValidLabelerViewerState(v: V) { + return isValid(v, id, hashLabelerViewerState) } export interface LabelerPolicies { + $type?: $Type<'app.bsky.labeler.defs', 'labelerPolicies'> /** The label values which this labeler publishes. May include global or custom labels. */ labelValues: ComAtprotoLabelDefs.LabelValue[] /** Label values created by this labeler and scoped exclusively to it. Labels defined here will override global label definitions for this labeler. */ labelValueDefinitions?: ComAtprotoLabelDefs.LabelValueDefinition[] - [k: string]: unknown } -export function isLabelerPolicies( - v: unknown, -): v is LabelerPolicies & { - $type: $Type<'app.bsky.labeler.defs', 'labelerPolicies'> -} { - return is$typed(v, id, 'labelerPolicies') +const hashLabelerPolicies = 'labelerPolicies' + +export function isLabelerPolicies(v: V) { + return is$typed(v, id, hashLabelerPolicies) +} + +export function validateLabelerPolicies(v: V) { + return validate(v, id, hashLabelerPolicies) } -export function validateLabelerPolicies(v: unknown) { - return lexicons.validate( - `${id}#labelerPolicies`, - v, - ) as ValidationResult +export function isValidLabelerPolicies(v: V) { + return isValid(v, id, hashLabelerPolicies) } 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 418dd8e906e..07a694b8b9c 100644 --- a/packages/api/src/client/types/app/bsky/labeler/getServices.ts +++ b/packages/api/src/client/types/app/bsky/labeler/getServices.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyLabelerDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyLabelerDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.labeler.getServices' export interface QueryParams { @@ -19,11 +25,10 @@ export type InputSchema = undefined export interface OutputSchema { views: ( - | AppBskyLabelerDefs.LabelerView - | AppBskyLabelerDefs.LabelerViewDetailed - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | { $type: string } )[] - [k: string]: unknown } export interface CallOptions { 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 347645730d0..5973c2fd285 100644 --- a/packages/api/src/client/types/app/bsky/labeler/service.ts +++ b/packages/api/src/client/types/app/bsky/labeler/service.ts @@ -3,28 +3,37 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyLabelerDefs from './defs' +import type * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.labeler.service' export interface Record { + $type?: $Type<'app.bsky.labeler.service', 'main'> policies: AppBskyLabelerDefs.LabelerPolicies - labels?: - | ComAtprotoLabelDefs.SelfLabels - | { $type: string; [k: string]: unknown } + labels?: $Typed | { $type: string } createdAt: string [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'app.bsky.labeler.service', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } 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 b39aec7880a..2684ce1b6bf 100644 --- a/packages/api/src/client/types/app/bsky/notification/getUnreadCount.ts +++ b/packages/api/src/client/types/app/bsky/notification/getUnreadCount.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.notification.getUnreadCount' export interface QueryParams { @@ -18,7 +24,6 @@ export type InputSchema = undefined export interface OutputSchema { count: number - [k: string]: unknown } export interface CallOptions { 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 b2b2bfdf5f7..ffd554e9af0 100644 --- a/packages/api/src/client/types/app/bsky/notification/listNotifications.ts +++ b/packages/api/src/client/types/app/bsky/notification/listNotifications.ts @@ -4,11 +4,17 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from '../actor/defs' +import type * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.notification.listNotifications' export interface QueryParams { @@ -27,7 +33,6 @@ export interface OutputSchema { notifications: Notification[] priority?: boolean seenAt?: string - [k: string]: unknown } export interface CallOptions { @@ -46,6 +51,7 @@ export function toKnownErr(e: any) { } export interface Notification { + $type?: $Type<'app.bsky.notification.listNotifications', 'notification'> uri: string cid: string author: AppBskyActorDefs.ProfileView @@ -60,24 +66,22 @@ export interface Notification { | 'starterpack-joined' | (string & {}) reasonSubject?: string - record: {} + record: { [_ in string]: unknown } isRead: boolean indexedAt: string labels?: ComAtprotoLabelDefs.Label[] - [k: string]: unknown } -export function isNotification( - v: unknown, -): v is Notification & { - $type: $Type<'app.bsky.notification.listNotifications', 'notification'> -} { - return is$typed(v, id, 'notification') +const hashNotification = 'notification' + +export function isNotification(v: V) { + return is$typed(v, id, hashNotification) +} + +export function validateNotification(v: V) { + return validate(v, id, hashNotification) } -export function validateNotification(v: unknown) { - return lexicons.validate( - `${id}#notification`, - v, - ) as ValidationResult +export function isValidNotification(v: V) { + return isValid(v, id, hashNotification) } 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 507528b2e05..b1a0ec01752 100644 --- a/packages/api/src/client/types/app/bsky/notification/putPreferences.ts +++ b/packages/api/src/client/types/app/bsky/notification/putPreferences.ts @@ -4,16 +4,21 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.notification.putPreferences' export interface QueryParams {} export interface InputSchema { priority: boolean - [k: string]: unknown } export interface CallOptions { 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 65f40b64633..a3091791f85 100644 --- a/packages/api/src/client/types/app/bsky/notification/registerPush.ts +++ b/packages/api/src/client/types/app/bsky/notification/registerPush.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.notification.registerPush' export interface QueryParams {} @@ -16,7 +22,6 @@ export interface InputSchema { token: string platform: 'ios' | 'android' | 'web' | (string & {}) appId: string - [k: string]: unknown } export interface CallOptions { 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 eaa486ee2f4..6085286804a 100644 --- a/packages/api/src/client/types/app/bsky/notification/updateSeen.ts +++ b/packages/api/src/client/types/app/bsky/notification/updateSeen.ts @@ -4,16 +4,21 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.notification.updateSeen' export interface QueryParams {} export interface InputSchema { seenAt: string - [k: string]: unknown } export interface CallOptions { 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 56d2aebb4cd..a73bef3f85a 100644 --- a/packages/api/src/client/types/app/bsky/richtext/facet.ts +++ b/packages/api/src/client/types/app/bsky/richtext/facet.ts @@ -3,89 +3,115 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.richtext.facet' /** Annotation of a sub-string within rich text. */ export interface Main { + $type?: $Type<'app.bsky.richtext.facet', 'main'> index: ByteSlice - features: (Mention | Link | Tag | { $type: string; [k: string]: unknown })[] - [k: string]: unknown + features: ($Typed | $Typed | $Typed | { $type: string })[] +} + +const hashMain = 'main' + +export function isMain(v: V) { + return is$typed(v, id, hashMain) } -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: V) { + return validate
(v, id, hashMain) } -export function validateMain(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult
+export function isValidMain(v: V) { + return isValid
(v, id, hashMain) } /** Facet feature for mention of another account. The text is usually a handle, including a '@' prefix, but the facet reference is a DID. */ export interface Mention { + $type?: $Type<'app.bsky.richtext.facet', 'mention'> did: string - [k: string]: unknown } -export function isMention( - v: unknown, -): v is Mention & { $type: $Type<'app.bsky.richtext.facet', 'mention'> } { - return is$typed(v, id, 'mention') +const hashMention = 'mention' + +export function isMention(v: V) { + return is$typed(v, id, hashMention) +} + +export function validateMention(v: V) { + return validate(v, id, hashMention) } -export function validateMention(v: unknown) { - return lexicons.validate(`${id}#mention`, v) as ValidationResult +export function isValidMention(v: V) { + return isValid(v, id, hashMention) } /** Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL. */ export interface Link { + $type?: $Type<'app.bsky.richtext.facet', 'link'> uri: string - [k: string]: unknown } -export function isLink( - v: unknown, -): v is Link & { $type: $Type<'app.bsky.richtext.facet', 'link'> } { - return is$typed(v, id, 'link') +const hashLink = 'link' + +export function isLink(v: V) { + return is$typed(v, id, hashLink) +} + +export function validateLink(v: V) { + return validate(v, id, hashLink) } -export function validateLink(v: unknown) { - return lexicons.validate(`${id}#link`, v) as ValidationResult +export function isValidLink(v: V) { + return isValid(v, id, hashLink) } /** 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'). */ export interface Tag { + $type?: $Type<'app.bsky.richtext.facet', 'tag'> tag: string - [k: string]: unknown } -export function isTag( - v: unknown, -): v is Tag & { $type: $Type<'app.bsky.richtext.facet', 'tag'> } { - return is$typed(v, id, 'tag') +const hashTag = 'tag' + +export function isTag(v: V) { + return is$typed(v, id, hashTag) +} + +export function validateTag(v: V) { + return validate(v, id, hashTag) } -export function validateTag(v: unknown) { - return lexicons.validate(`${id}#tag`, v) as ValidationResult +export function isValidTag(v: V) { + return isValid(v, id, hashTag) } /** 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. */ export interface ByteSlice { + $type?: $Type<'app.bsky.richtext.facet', 'byteSlice'> byteStart: number byteEnd: number - [k: string]: unknown } -export function isByteSlice( - v: unknown, -): v is ByteSlice & { $type: $Type<'app.bsky.richtext.facet', 'byteSlice'> } { - return is$typed(v, id, 'byteSlice') +const hashByteSlice = 'byteSlice' + +export function isByteSlice(v: V) { + return is$typed(v, id, hashByteSlice) +} + +export function validateByteSlice(v: V) { + return validate(v, id, hashByteSlice) } -export function validateByteSlice(v: unknown) { - return lexicons.validate(`${id}#byteSlice`, v) as ValidationResult +export function isValidByteSlice(v: V) { + return isValid(v, id, hashByteSlice) } 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 1459a765dbf..a4286c5222e 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/defs.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/defs.ts @@ -3,90 +3,100 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.unspecced.defs' export interface SkeletonSearchPost { + $type?: $Type<'app.bsky.unspecced.defs', 'skeletonSearchPost'> uri: string - [k: string]: unknown } -export function isSkeletonSearchPost( - v: unknown, -): v is SkeletonSearchPost & { - $type: $Type<'app.bsky.unspecced.defs', 'skeletonSearchPost'> -} { - return is$typed(v, id, 'skeletonSearchPost') +const hashSkeletonSearchPost = 'skeletonSearchPost' + +export function isSkeletonSearchPost(v: V) { + return is$typed(v, id, hashSkeletonSearchPost) } -export function validateSkeletonSearchPost(v: unknown) { - return lexicons.validate( - `${id}#skeletonSearchPost`, - v, - ) as ValidationResult +export function validateSkeletonSearchPost(v: V) { + return validate(v, id, hashSkeletonSearchPost) +} + +export function isValidSkeletonSearchPost(v: V) { + return isValid(v, id, hashSkeletonSearchPost) } export interface SkeletonSearchActor { + $type?: $Type<'app.bsky.unspecced.defs', 'skeletonSearchActor'> did: string - [k: string]: unknown } -export function isSkeletonSearchActor( - v: unknown, -): v is SkeletonSearchActor & { - $type: $Type<'app.bsky.unspecced.defs', 'skeletonSearchActor'> -} { - return is$typed(v, id, 'skeletonSearchActor') +const hashSkeletonSearchActor = 'skeletonSearchActor' + +export function isSkeletonSearchActor(v: V) { + return is$typed(v, id, hashSkeletonSearchActor) } -export function validateSkeletonSearchActor(v: unknown) { - return lexicons.validate( - `${id}#skeletonSearchActor`, - v, - ) as ValidationResult +export function validateSkeletonSearchActor(v: V) { + return validate(v, id, hashSkeletonSearchActor) +} + +export function isValidSkeletonSearchActor(v: V) { + return isValid(v, id, hashSkeletonSearchActor) } export interface SkeletonSearchStarterPack { + $type?: $Type<'app.bsky.unspecced.defs', 'skeletonSearchStarterPack'> uri: string - [k: string]: unknown } -export function isSkeletonSearchStarterPack( - v: unknown, -): v is SkeletonSearchStarterPack & { - $type: $Type<'app.bsky.unspecced.defs', 'skeletonSearchStarterPack'> -} { - return is$typed(v, id, 'skeletonSearchStarterPack') +const hashSkeletonSearchStarterPack = 'skeletonSearchStarterPack' + +export function isSkeletonSearchStarterPack(v: V) { + return is$typed(v, id, hashSkeletonSearchStarterPack) +} + +export function validateSkeletonSearchStarterPack(v: V) { + return validate( + v, + id, + hashSkeletonSearchStarterPack, + ) } -export function validateSkeletonSearchStarterPack(v: unknown) { - return lexicons.validate( - `${id}#skeletonSearchStarterPack`, +export function isValidSkeletonSearchStarterPack(v: V) { + return isValid( v, - ) as ValidationResult + id, + hashSkeletonSearchStarterPack, + ) } export interface TrendingTopic { + $type?: $Type<'app.bsky.unspecced.defs', 'trendingTopic'> topic: string displayName?: string description?: string link: string - [k: string]: unknown } -export function isTrendingTopic( - v: unknown, -): v is TrendingTopic & { - $type: $Type<'app.bsky.unspecced.defs', 'trendingTopic'> -} { - return is$typed(v, id, 'trendingTopic') +const hashTrendingTopic = 'trendingTopic' + +export function isTrendingTopic(v: V) { + return is$typed(v, id, hashTrendingTopic) } -export function validateTrendingTopic(v: unknown) { - return lexicons.validate( - `${id}#trendingTopic`, - v, - ) as ValidationResult +export function validateTrendingTopic(v: V) { + return validate(v, id, hashTrendingTopic) +} + +export function isValidTrendingTopic(v: V) { + return isValid(v, id, hashTrendingTopic) } 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 0f349472146..fa9c268fe8a 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getConfig.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getConfig.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.unspecced.getConfig' export interface QueryParams {} @@ -15,7 +21,6 @@ export type InputSchema = undefined export interface OutputSchema { checkEmailConfirmed?: boolean - [k: string]: unknown } export interface CallOptions { 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 0192a32c8f7..9435afd636f 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getPopularFeedGenerators.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getPopularFeedGenerators.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyFeedDefs from '../feed/defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyFeedDefs from '../feed/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.unspecced.getPopularFeedGenerators' export interface QueryParams { @@ -21,7 +27,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string feeds: AppBskyFeedDefs.GeneratorView[] - [k: string]: unknown } export interface CallOptions { 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 9df9298b22f..c503ad22335 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getSuggestionsSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getSuggestionsSkeleton.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyUnspeccedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyUnspeccedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.unspecced.getSuggestionsSkeleton' export interface QueryParams { @@ -26,7 +32,6 @@ export interface OutputSchema { actors: AppBskyUnspeccedDefs.SkeletonSearchActor[] /** DID of the account these suggestions are relative to. If this is returned undefined, suggestions are based on the viewer. */ relativeToDid?: string - [k: string]: unknown } export interface CallOptions { 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 346ef080ca8..91baf4c1c5f 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getTaggedSuggestions.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getTaggedSuggestions.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.unspecced.getTaggedSuggestions' export interface QueryParams {} @@ -15,7 +21,6 @@ export type InputSchema = undefined export interface OutputSchema { suggestions: Suggestion[] - [k: string]: unknown } export interface CallOptions { @@ -34,23 +39,22 @@ export function toKnownErr(e: any) { } export interface Suggestion { + $type?: $Type<'app.bsky.unspecced.getTaggedSuggestions', 'suggestion'> tag: string subjectType: 'actor' | 'feed' | (string & {}) subject: string - [k: string]: unknown } -export function isSuggestion( - v: unknown, -): v is Suggestion & { - $type: $Type<'app.bsky.unspecced.getTaggedSuggestions', 'suggestion'> -} { - return is$typed(v, id, 'suggestion') +const hashSuggestion = 'suggestion' + +export function isSuggestion(v: V) { + return is$typed(v, id, hashSuggestion) +} + +export function validateSuggestion(v: V) { + return validate(v, id, hashSuggestion) } -export function validateSuggestion(v: unknown) { - return lexicons.validate( - `${id}#suggestion`, - v, - ) as ValidationResult +export function isValidSuggestion(v: V) { + return isValid(v, id, hashSuggestion) } 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 6839bddeafe..369d41b2b35 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getTrendingTopics.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getTrendingTopics.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyUnspeccedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyUnspeccedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.unspecced.getTrendingTopics' export interface QueryParams { @@ -21,7 +27,6 @@ export type InputSchema = undefined export interface OutputSchema { topics: AppBskyUnspeccedDefs.TrendingTopic[] suggested: AppBskyUnspeccedDefs.TrendingTopic[] - [k: string]: unknown } export interface CallOptions { 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 7799158a8ec..0f501c2abf5 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/searchActorsSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/searchActorsSkeleton.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyUnspeccedDefs from './defs' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyUnspeccedDefs from './defs' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.unspecced.searchActorsSkeleton' export interface QueryParams { @@ -29,7 +35,6 @@ export interface OutputSchema { /** Count of search hits. Optional, may be rounded/truncated, and may not be possible to paginate through all hits. */ hitsTotal?: number actors: AppBskyUnspeccedDefs.SkeletonSearchActor[] - [k: string]: unknown } export interface CallOptions { 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 00e032f2be9..22b9501bdbb 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/searchPostsSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/searchPostsSkeleton.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyUnspeccedDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyUnspeccedDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.unspecced.searchPostsSkeleton' export interface QueryParams { @@ -45,7 +51,6 @@ export interface OutputSchema { /** Count of search hits. Optional, may be rounded/truncated, and may not be possible to paginate through all hits. */ hitsTotal?: number posts: AppBskyUnspeccedDefs.SkeletonSearchPost[] - [k: string]: unknown } export interface CallOptions { 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 51cb7b9e78a..d1b38953cc8 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/searchStarterPacksSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/searchStarterPacksSkeleton.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyUnspeccedDefs from './defs' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyUnspeccedDefs from './defs' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.unspecced.searchStarterPacksSkeleton' export interface QueryParams { @@ -27,7 +33,6 @@ export interface OutputSchema { /** Count of search hits. Optional, may be rounded/truncated, and may not be possible to paginate through all hits. */ hitsTotal?: number starterPacks: AppBskyUnspeccedDefs.SkeletonSearchStarterPack[] - [k: string]: unknown } export interface CallOptions { 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 3cf6cae3436..93ed16829ca 100644 --- a/packages/api/src/client/types/app/bsky/video/defs.ts +++ b/packages/api/src/client/types/app/bsky/video/defs.ts @@ -3,12 +3,19 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.video.defs' export interface JobStatus { + $type?: $Type<'app.bsky.video.defs', 'jobStatus'> jobId: string did: string /** The state of the video processing job. All values not listed as a known value indicate that the job is in process. */ @@ -18,15 +25,18 @@ export interface JobStatus { blob?: BlobRef error?: string message?: string - [k: string]: unknown } -export function isJobStatus( - v: unknown, -): v is JobStatus & { $type: $Type<'app.bsky.video.defs', 'jobStatus'> } { - return is$typed(v, id, 'jobStatus') +const hashJobStatus = 'jobStatus' + +export function isJobStatus(v: V) { + return is$typed(v, id, hashJobStatus) +} + +export function validateJobStatus(v: V) { + return validate(v, id, hashJobStatus) } -export function validateJobStatus(v: unknown) { - return lexicons.validate(`${id}#jobStatus`, v) as ValidationResult +export function isValidJobStatus(v: V) { + return isValid(v, id, hashJobStatus) } 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 a303f44ed52..987c9b5544d 100644 --- a/packages/api/src/client/types/app/bsky/video/getJobStatus.ts +++ b/packages/api/src/client/types/app/bsky/video/getJobStatus.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyVideoDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyVideoDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.video.getJobStatus' export interface QueryParams { @@ -18,7 +24,6 @@ export type InputSchema = undefined export interface OutputSchema { jobStatus: AppBskyVideoDefs.JobStatus - [k: string]: unknown } export interface CallOptions { 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 dc653bc87f9..a79b6be3bcc 100644 --- a/packages/api/src/client/types/app/bsky/video/getUploadLimits.ts +++ b/packages/api/src/client/types/app/bsky/video/getUploadLimits.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.video.getUploadLimits' export interface QueryParams {} @@ -19,7 +25,6 @@ export interface OutputSchema { remainingDailyBytes?: number message?: string error?: string - [k: string]: unknown } export interface CallOptions { 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 f56dd13cec2..118be71e31d 100644 --- a/packages/api/src/client/types/app/bsky/video/uploadVideo.ts +++ b/packages/api/src/client/types/app/bsky/video/uploadVideo.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as AppBskyVideoDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyVideoDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'app.bsky.video.uploadVideo' export interface QueryParams {} @@ -16,7 +22,6 @@ export type InputSchema = string | Uint8Array | Blob export interface OutputSchema { jobStatus: AppBskyVideoDefs.JobStatus - [k: string]: unknown } export interface CallOptions { 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 a17b0b24ffd..745d97fc50a 100644 --- a/packages/api/src/client/types/chat/bsky/actor/declaration.ts +++ b/packages/api/src/client/types/chat/bsky/actor/declaration.ts @@ -3,22 +3,33 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.actor.declaration' export interface Record { + $type?: $Type<'chat.bsky.actor.declaration', 'main'> allowIncoming: 'all' | 'none' | 'following' | (string & {}) [k: string]: unknown } -export function isRecord( - v: unknown, -): v is Record & { $type: $Type<'chat.bsky.actor.declaration', 'main'> } { - return is$typed(v, id, 'main') +const hashRecord = 'main' + +export function isRecord(v: V) { + return is$typed(v, id, hashRecord) +} + +export function validateRecord(v: V) { + return validate(v, id, hashRecord) } -export function validateRecord(v: unknown) { - return lexicons.validate(`${id}#main`, v) as ValidationResult +export function isValidRecord(v: V) { + return isValid(v, id, hashRecord, true) } 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 e4a14d1b220..0a12bbedea1 100644 --- a/packages/api/src/client/types/chat/bsky/actor/defs.ts +++ b/packages/api/src/client/types/chat/bsky/actor/defs.ts @@ -3,14 +3,21 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyActorDefs from '../../../app/bsky/actor/defs' +import type * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.actor.defs' export interface ProfileViewBasic { + $type?: $Type<'chat.bsky.actor.defs', 'profileViewBasic'> did: string handle: string displayName?: string @@ -20,20 +27,18 @@ export interface ProfileViewBasic { labels?: ComAtprotoLabelDefs.Label[] /** Set to true when the actor cannot actively participate in converations */ chatDisabled?: boolean - [k: string]: unknown } -export function isProfileViewBasic( - v: unknown, -): v is ProfileViewBasic & { - $type: $Type<'chat.bsky.actor.defs', 'profileViewBasic'> -} { - return is$typed(v, id, 'profileViewBasic') +const hashProfileViewBasic = 'profileViewBasic' + +export function isProfileViewBasic(v: V) { + return is$typed(v, id, hashProfileViewBasic) +} + +export function validateProfileViewBasic(v: V) { + return validate(v, id, hashProfileViewBasic) } -export function validateProfileViewBasic(v: unknown) { - return lexicons.validate( - `${id}#profileViewBasic`, - v, - ) as ValidationResult +export function isValidProfileViewBasic(v: V) { + return isValid(v, id, hashProfileViewBasic) } 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 c96bdf96729..bc0a05dc4b3 100644 --- a/packages/api/src/client/types/chat/bsky/actor/deleteAccount.ts +++ b/packages/api/src/client/types/chat/bsky/actor/deleteAccount.ts @@ -4,18 +4,22 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.actor.deleteAccount' export interface QueryParams {} export type InputSchema = undefined -export interface OutputSchema { - [k: string]: unknown -} +export interface OutputSchema {} export interface CallOptions { signal?: AbortSignal 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 21d7bb32b26..21d6f936432 100644 --- a/packages/api/src/client/types/chat/bsky/actor/exportAccountData.ts +++ b/packages/api/src/client/types/chat/bsky/actor/exportAccountData.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate 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 e79d83b0e60..1b1a357aabc 100644 --- a/packages/api/src/client/types/chat/bsky/convo/defs.ts +++ b/packages/api/src/client/types/chat/bsky/convo/defs.ts @@ -3,237 +3,236 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as AppBskyRichtextFacet from '../../../app/bsky/richtext/facet' +import type * as AppBskyEmbedRecord from '../../../app/bsky/embed/record' +import type * as ChatBskyActorDefs from '../actor/defs' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.convo.defs' export interface MessageRef { + $type?: $Type<'chat.bsky.convo.defs', 'messageRef'> did: string convoId: string messageId: string - [k: string]: unknown } -export function isMessageRef( - v: unknown, -): v is MessageRef & { $type: $Type<'chat.bsky.convo.defs', 'messageRef'> } { - return is$typed(v, id, 'messageRef') +const hashMessageRef = 'messageRef' + +export function isMessageRef(v: V) { + return is$typed(v, id, hashMessageRef) } -export function validateMessageRef(v: unknown) { - return lexicons.validate( - `${id}#messageRef`, - v, - ) as ValidationResult +export function validateMessageRef(v: V) { + return validate(v, id, hashMessageRef) +} + +export function isValidMessageRef(v: V) { + return isValid(v, id, hashMessageRef) } export interface MessageInput { + $type?: $Type<'chat.bsky.convo.defs', 'messageInput'> text: string /** Annotations of text (mentions, URLs, hashtags, etc) */ facets?: AppBskyRichtextFacet.Main[] - embed?: AppBskyEmbedRecord.Main | { $type: string; [k: string]: unknown } - [k: string]: unknown + embed?: $Typed | { $type: string } } -export function isMessageInput( - v: unknown, -): v is MessageInput & { - $type: $Type<'chat.bsky.convo.defs', 'messageInput'> -} { - return is$typed(v, id, 'messageInput') +const hashMessageInput = 'messageInput' + +export function isMessageInput(v: V) { + return is$typed(v, id, hashMessageInput) } -export function validateMessageInput(v: unknown) { - return lexicons.validate( - `${id}#messageInput`, - v, - ) as ValidationResult +export function validateMessageInput(v: V) { + return validate(v, id, hashMessageInput) +} + +export function isValidMessageInput(v: V) { + return isValid(v, id, hashMessageInput) } export interface MessageView { + $type?: $Type<'chat.bsky.convo.defs', 'messageView'> id: string rev: string text: string /** Annotations of text (mentions, URLs, hashtags, etc) */ facets?: AppBskyRichtextFacet.Main[] - embed?: AppBskyEmbedRecord.View | { $type: string; [k: string]: unknown } + embed?: $Typed | { $type: string } sender: MessageViewSender sentAt: string - [k: string]: unknown } -export function isMessageView( - v: unknown, -): v is MessageView & { $type: $Type<'chat.bsky.convo.defs', 'messageView'> } { - return is$typed(v, id, 'messageView') +const hashMessageView = 'messageView' + +export function isMessageView(v: V) { + return is$typed(v, id, hashMessageView) +} + +export function validateMessageView(v: V) { + return validate(v, id, hashMessageView) } -export function validateMessageView(v: unknown) { - return lexicons.validate( - `${id}#messageView`, - v, - ) as ValidationResult +export function isValidMessageView(v: V) { + return isValid(v, id, hashMessageView) } export interface DeletedMessageView { + $type?: $Type<'chat.bsky.convo.defs', 'deletedMessageView'> id: string rev: string sender: MessageViewSender sentAt: string - [k: string]: unknown } -export function isDeletedMessageView( - v: unknown, -): v is DeletedMessageView & { - $type: $Type<'chat.bsky.convo.defs', 'deletedMessageView'> -} { - return is$typed(v, id, 'deletedMessageView') +const hashDeletedMessageView = 'deletedMessageView' + +export function isDeletedMessageView(v: V) { + return is$typed(v, id, hashDeletedMessageView) } -export function validateDeletedMessageView(v: unknown) { - return lexicons.validate( - `${id}#deletedMessageView`, - v, - ) as ValidationResult +export function validateDeletedMessageView(v: V) { + return validate(v, id, hashDeletedMessageView) +} + +export function isValidDeletedMessageView(v: V) { + return isValid(v, id, hashDeletedMessageView) } export interface MessageViewSender { + $type?: $Type<'chat.bsky.convo.defs', 'messageViewSender'> did: string - [k: string]: unknown } -export function isMessageViewSender( - v: unknown, -): v is MessageViewSender & { - $type: $Type<'chat.bsky.convo.defs', 'messageViewSender'> -} { - return is$typed(v, id, 'messageViewSender') +const hashMessageViewSender = 'messageViewSender' + +export function isMessageViewSender(v: V) { + return is$typed(v, id, hashMessageViewSender) } -export function validateMessageViewSender(v: unknown) { - return lexicons.validate( - `${id}#messageViewSender`, - v, - ) as ValidationResult +export function validateMessageViewSender(v: V) { + return validate(v, id, hashMessageViewSender) +} + +export function isValidMessageViewSender(v: V) { + return isValid(v, id, hashMessageViewSender) } export interface ConvoView { + $type?: $Type<'chat.bsky.convo.defs', 'convoView'> id: string rev: string members: ChatBskyActorDefs.ProfileViewBasic[] lastMessage?: - | MessageView - | DeletedMessageView - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | { $type: string } muted: boolean opened?: boolean unreadCount: number - [k: string]: unknown } -export function isConvoView( - v: unknown, -): v is ConvoView & { $type: $Type<'chat.bsky.convo.defs', 'convoView'> } { - return is$typed(v, id, 'convoView') +const hashConvoView = 'convoView' + +export function isConvoView(v: V) { + return is$typed(v, id, hashConvoView) } -export function validateConvoView(v: unknown) { - return lexicons.validate(`${id}#convoView`, v) as ValidationResult +export function validateConvoView(v: V) { + return validate(v, id, hashConvoView) +} + +export function isValidConvoView(v: V) { + return isValid(v, id, hashConvoView) } export interface LogBeginConvo { + $type?: $Type<'chat.bsky.convo.defs', 'logBeginConvo'> rev: string convoId: string - [k: string]: unknown } -export function isLogBeginConvo( - v: unknown, -): v is LogBeginConvo & { - $type: $Type<'chat.bsky.convo.defs', 'logBeginConvo'> -} { - return is$typed(v, id, 'logBeginConvo') +const hashLogBeginConvo = 'logBeginConvo' + +export function isLogBeginConvo(v: V) { + return is$typed(v, id, hashLogBeginConvo) } -export function validateLogBeginConvo(v: unknown) { - return lexicons.validate( - `${id}#logBeginConvo`, - v, - ) as ValidationResult +export function validateLogBeginConvo(v: V) { + return validate(v, id, hashLogBeginConvo) +} + +export function isValidLogBeginConvo(v: V) { + return isValid(v, id, hashLogBeginConvo) } export interface LogLeaveConvo { + $type?: $Type<'chat.bsky.convo.defs', 'logLeaveConvo'> rev: string convoId: string - [k: string]: unknown } -export function isLogLeaveConvo( - v: unknown, -): v is LogLeaveConvo & { - $type: $Type<'chat.bsky.convo.defs', 'logLeaveConvo'> -} { - return is$typed(v, id, 'logLeaveConvo') +const hashLogLeaveConvo = 'logLeaveConvo' + +export function isLogLeaveConvo(v: V) { + return is$typed(v, id, hashLogLeaveConvo) } -export function validateLogLeaveConvo(v: unknown) { - return lexicons.validate( - `${id}#logLeaveConvo`, - v, - ) as ValidationResult +export function validateLogLeaveConvo(v: V) { + return validate(v, id, hashLogLeaveConvo) +} + +export function isValidLogLeaveConvo(v: V) { + return isValid(v, id, hashLogLeaveConvo) } export interface LogCreateMessage { + $type?: $Type<'chat.bsky.convo.defs', 'logCreateMessage'> rev: string convoId: string - message: - | MessageView - | DeletedMessageView - | { $type: string; [k: string]: unknown } - [k: string]: unknown + message: $Typed | $Typed | { $type: string } } -export function isLogCreateMessage( - v: unknown, -): v is LogCreateMessage & { - $type: $Type<'chat.bsky.convo.defs', 'logCreateMessage'> -} { - return is$typed(v, id, 'logCreateMessage') +const hashLogCreateMessage = 'logCreateMessage' + +export function isLogCreateMessage(v: V) { + return is$typed(v, id, hashLogCreateMessage) } -export function validateLogCreateMessage(v: unknown) { - return lexicons.validate( - `${id}#logCreateMessage`, - v, - ) as ValidationResult +export function validateLogCreateMessage(v: V) { + return validate(v, id, hashLogCreateMessage) +} + +export function isValidLogCreateMessage(v: V) { + return isValid(v, id, hashLogCreateMessage) } export interface LogDeleteMessage { + $type?: $Type<'chat.bsky.convo.defs', 'logDeleteMessage'> rev: string convoId: string - message: - | MessageView - | DeletedMessageView - | { $type: string; [k: string]: unknown } - [k: string]: unknown -} - -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) { - return lexicons.validate( - `${id}#logDeleteMessage`, - v, - ) as ValidationResult + message: $Typed | $Typed | { $type: string } +} + +const hashLogDeleteMessage = 'logDeleteMessage' + +export function isLogDeleteMessage(v: V) { + return is$typed(v, id, hashLogDeleteMessage) +} + +export function validateLogDeleteMessage(v: V) { + return validate(v, id, hashLogDeleteMessage) +} + +export function isValidLogDeleteMessage(v: V) { + return isValid(v, id, hashLogDeleteMessage) } 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 0679a4fe677..c5bcf1c1e96 100644 --- a/packages/api/src/client/types/chat/bsky/convo/deleteMessageForSelf.ts +++ b/packages/api/src/client/types/chat/bsky/convo/deleteMessageForSelf.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ChatBskyConvoDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ChatBskyConvoDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.convo.deleteMessageForSelf' export interface QueryParams {} @@ -15,7 +21,6 @@ export interface QueryParams {} export interface InputSchema { convoId: string messageId: string - [k: string]: unknown } export type OutputSchema = ChatBskyConvoDefs.DeletedMessageView 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 ba605729939..99c309bdb93 100644 --- a/packages/api/src/client/types/chat/bsky/convo/getConvo.ts +++ b/packages/api/src/client/types/chat/bsky/convo/getConvo.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ChatBskyConvoDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ChatBskyConvoDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.convo.getConvo' export interface QueryParams { @@ -18,7 +24,6 @@ export type InputSchema = undefined export interface OutputSchema { convo: ChatBskyConvoDefs.ConvoView - [k: string]: unknown } export interface CallOptions { 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 795845b7379..ecc1f026651 100644 --- a/packages/api/src/client/types/chat/bsky/convo/getConvoForMembers.ts +++ b/packages/api/src/client/types/chat/bsky/convo/getConvoForMembers.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ChatBskyConvoDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ChatBskyConvoDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.convo.getConvoForMembers' export interface QueryParams { @@ -18,7 +24,6 @@ export type InputSchema = undefined export interface OutputSchema { convo: ChatBskyConvoDefs.ConvoView - [k: string]: unknown } export interface CallOptions { 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 4185bc39c12..ce8801ddf1d 100644 --- a/packages/api/src/client/types/chat/bsky/convo/getLog.ts +++ b/packages/api/src/client/types/chat/bsky/convo/getLog.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ChatBskyConvoDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ChatBskyConvoDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.convo.getLog' export interface QueryParams { @@ -19,13 +25,12 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string logs: ( - | ChatBskyConvoDefs.LogBeginConvo - | ChatBskyConvoDefs.LogLeaveConvo - | ChatBskyConvoDefs.LogCreateMessage - | ChatBskyConvoDefs.LogDeleteMessage - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | $Typed + | { $type: string } )[] - [k: string]: unknown } export interface CallOptions { 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 d9f043c8081..dfa319e6338 100644 --- a/packages/api/src/client/types/chat/bsky/convo/getMessages.ts +++ b/packages/api/src/client/types/chat/bsky/convo/getMessages.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ChatBskyConvoDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ChatBskyConvoDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.convo.getMessages' export interface QueryParams { @@ -21,11 +27,10 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string messages: ( - | ChatBskyConvoDefs.MessageView - | ChatBskyConvoDefs.DeletedMessageView - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | { $type: string } )[] - [k: string]: unknown } export interface CallOptions { 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 5feed2d0ffb..c43b59daa29 100644 --- a/packages/api/src/client/types/chat/bsky/convo/leaveConvo.ts +++ b/packages/api/src/client/types/chat/bsky/convo/leaveConvo.ts @@ -4,22 +4,26 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.convo.leaveConvo' export interface QueryParams {} export interface InputSchema { convoId: string - [k: string]: unknown } export interface OutputSchema { convoId: string rev: string - [k: string]: unknown } export interface CallOptions { 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 19fcfc73554..fd9f8250386 100644 --- a/packages/api/src/client/types/chat/bsky/convo/listConvos.ts +++ b/packages/api/src/client/types/chat/bsky/convo/listConvos.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ChatBskyConvoDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ChatBskyConvoDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.convo.listConvos' export interface QueryParams { @@ -20,7 +26,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string convos: ChatBskyConvoDefs.ConvoView[] - [k: string]: unknown } export interface CallOptions { 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 caf7dc9c4a7..514f1c56145 100644 --- a/packages/api/src/client/types/chat/bsky/convo/muteConvo.ts +++ b/packages/api/src/client/types/chat/bsky/convo/muteConvo.ts @@ -4,22 +4,26 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ChatBskyConvoDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ChatBskyConvoDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.convo.muteConvo' export interface QueryParams {} export interface InputSchema { convoId: string - [k: string]: unknown } export interface OutputSchema { convo: ChatBskyConvoDefs.ConvoView - [k: string]: unknown } export interface CallOptions { 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 b5749f68c49..7422ea58fef 100644 --- a/packages/api/src/client/types/chat/bsky/convo/sendMessage.ts +++ b/packages/api/src/client/types/chat/bsky/convo/sendMessage.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ChatBskyConvoDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ChatBskyConvoDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.convo.sendMessage' export interface QueryParams {} @@ -15,7 +21,6 @@ export interface QueryParams {} export interface InputSchema { convoId: string message: ChatBskyConvoDefs.MessageInput - [k: string]: unknown } export type OutputSchema = ChatBskyConvoDefs.MessageView 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 64e86464576..6f8759347ee 100644 --- a/packages/api/src/client/types/chat/bsky/convo/sendMessageBatch.ts +++ b/packages/api/src/client/types/chat/bsky/convo/sendMessageBatch.ts @@ -4,22 +4,26 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ChatBskyConvoDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ChatBskyConvoDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.convo.sendMessageBatch' export interface QueryParams {} export interface InputSchema { items: BatchItem[] - [k: string]: unknown } export interface OutputSchema { items: ChatBskyConvoDefs.MessageView[] - [k: string]: unknown } export interface CallOptions { @@ -40,19 +44,21 @@ export function toKnownErr(e: any) { } export interface BatchItem { + $type?: $Type<'chat.bsky.convo.sendMessageBatch', 'batchItem'> convoId: string message: ChatBskyConvoDefs.MessageInput - [k: string]: unknown } -export function isBatchItem( - v: unknown, -): v is BatchItem & { - $type: $Type<'chat.bsky.convo.sendMessageBatch', 'batchItem'> -} { - return is$typed(v, id, 'batchItem') +const hashBatchItem = 'batchItem' + +export function isBatchItem(v: V) { + return is$typed(v, id, hashBatchItem) +} + +export function validateBatchItem(v: V) { + return validate(v, id, hashBatchItem) } -export function validateBatchItem(v: unknown) { - return lexicons.validate(`${id}#batchItem`, v) as ValidationResult +export function isValidBatchItem(v: V) { + return isValid(v, id, hashBatchItem) } 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 7bbf475d509..d959a497457 100644 --- a/packages/api/src/client/types/chat/bsky/convo/unmuteConvo.ts +++ b/packages/api/src/client/types/chat/bsky/convo/unmuteConvo.ts @@ -4,22 +4,26 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ChatBskyConvoDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ChatBskyConvoDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.convo.unmuteConvo' export interface QueryParams {} export interface InputSchema { convoId: string - [k: string]: unknown } export interface OutputSchema { convo: ChatBskyConvoDefs.ConvoView - [k: string]: unknown } export interface CallOptions { 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 a990b1d14bf..1cb1f99841f 100644 --- a/packages/api/src/client/types/chat/bsky/convo/updateRead.ts +++ b/packages/api/src/client/types/chat/bsky/convo/updateRead.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ChatBskyConvoDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ChatBskyConvoDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.convo.updateRead' export interface QueryParams {} @@ -15,12 +21,10 @@ export interface QueryParams {} export interface InputSchema { convoId: string messageId?: string - [k: string]: unknown } export interface OutputSchema { convo: ChatBskyConvoDefs.ConvoView - [k: string]: unknown } export interface CallOptions { 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 3071f5cea03..f94ae2d7e1d 100644 --- a/packages/api/src/client/types/chat/bsky/moderation/getActorMetadata.ts +++ b/packages/api/src/client/types/chat/bsky/moderation/getActorMetadata.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.moderation.getActorMetadata' export interface QueryParams { @@ -19,7 +25,6 @@ export interface OutputSchema { day: Metadata month: Metadata all: Metadata - [k: string]: unknown } export interface CallOptions { @@ -38,21 +43,23 @@ export function toKnownErr(e: any) { } export interface Metadata { + $type?: $Type<'chat.bsky.moderation.getActorMetadata', 'metadata'> messagesSent: number messagesReceived: number convos: number convosStarted: number - [k: string]: unknown } -export function isMetadata( - v: unknown, -): v is Metadata & { - $type: $Type<'chat.bsky.moderation.getActorMetadata', 'metadata'> -} { - return is$typed(v, id, 'metadata') +const hashMetadata = 'metadata' + +export function isMetadata(v: V) { + return is$typed(v, id, hashMetadata) +} + +export function validateMetadata(v: V) { + return validate(v, id, hashMetadata) } -export function validateMetadata(v: unknown) { - return lexicons.validate(`${id}#metadata`, v) as ValidationResult +export function isValidMetadata(v: V) { + return isValid(v, id, hashMetadata) } 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 5ac31fa6ea9..a919014ea1c 100644 --- a/packages/api/src/client/types/chat/bsky/moderation/getMessageContext.ts +++ b/packages/api/src/client/types/chat/bsky/moderation/getMessageContext.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ChatBskyConvoDefs from '../convo/defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ChatBskyConvoDefs from '../convo/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.moderation.getMessageContext' export interface QueryParams { @@ -22,11 +28,10 @@ export type InputSchema = undefined export interface OutputSchema { messages: ( - | ChatBskyConvoDefs.MessageView - | ChatBskyConvoDefs.DeletedMessageView - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | { $type: string } )[] - [k: string]: unknown } export interface CallOptions { 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 daf01350424..19b121fe761 100644 --- a/packages/api/src/client/types/chat/bsky/moderation/updateActorAccess.ts +++ b/packages/api/src/client/types/chat/bsky/moderation/updateActorAccess.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'chat.bsky.moderation.updateActorAccess' export interface QueryParams {} @@ -15,7 +21,6 @@ export interface InputSchema { actor: string allowAccess: boolean ref?: string - [k: string]: unknown } export interface CallOptions { 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 329f267aad1..83f247d978c 100644 --- a/packages/api/src/client/types/com/atproto/admin/defs.ts +++ b/packages/api/src/client/types/com/atproto/admin/defs.ts @@ -3,36 +3,44 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ComAtprotoServerDefs from '../server/defs' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoServerDefs from '../server/defs' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.defs' export interface StatusAttr { + $type?: $Type<'com.atproto.admin.defs', 'statusAttr'> applied: boolean ref?: string - [k: string]: unknown } -export function isStatusAttr( - v: unknown, -): v is StatusAttr & { $type: $Type<'com.atproto.admin.defs', 'statusAttr'> } { - return is$typed(v, id, 'statusAttr') +const hashStatusAttr = 'statusAttr' + +export function isStatusAttr(v: V) { + return is$typed(v, id, hashStatusAttr) +} + +export function validateStatusAttr(v: V) { + return validate(v, id, hashStatusAttr) } -export function validateStatusAttr(v: unknown) { - return lexicons.validate( - `${id}#statusAttr`, - v, - ) as ValidationResult +export function isValidStatusAttr(v: V) { + return isValid(v, id, hashStatusAttr) } export interface AccountView { + $type?: $Type<'com.atproto.admin.defs', 'accountView'> did: string handle: string email?: string - relatedRecords?: {}[] + relatedRecords?: { [_ in string]: unknown }[] indexedAt: string invitedBy?: ComAtprotoServerDefs.InviteCode invites?: ComAtprotoServerDefs.InviteCode[] @@ -41,78 +49,78 @@ export interface AccountView { inviteNote?: string deactivatedAt?: string threatSignatures?: ThreatSignature[] - [k: string]: unknown } -export function isAccountView( - v: unknown, -): v is AccountView & { - $type: $Type<'com.atproto.admin.defs', 'accountView'> -} { - return is$typed(v, id, 'accountView') +const hashAccountView = 'accountView' + +export function isAccountView(v: V) { + return is$typed(v, id, hashAccountView) +} + +export function validateAccountView(v: V) { + return validate(v, id, hashAccountView) } -export function validateAccountView(v: unknown) { - return lexicons.validate( - `${id}#accountView`, - v, - ) as ValidationResult +export function isValidAccountView(v: V) { + return isValid(v, id, hashAccountView) } export interface RepoRef { + $type?: $Type<'com.atproto.admin.defs', 'repoRef'> did: string - [k: string]: unknown } -export function isRepoRef( - v: unknown, -): v is RepoRef & { $type: $Type<'com.atproto.admin.defs', 'repoRef'> } { - return is$typed(v, id, 'repoRef') +const hashRepoRef = 'repoRef' + +export function isRepoRef(v: V) { + return is$typed(v, id, hashRepoRef) +} + +export function validateRepoRef(v: V) { + return validate(v, id, hashRepoRef) } -export function validateRepoRef(v: unknown) { - return lexicons.validate(`${id}#repoRef`, v) as ValidationResult +export function isValidRepoRef(v: V) { + return isValid(v, id, hashRepoRef) } export interface RepoBlobRef { + $type?: $Type<'com.atproto.admin.defs', 'repoBlobRef'> did: string cid: string recordUri?: string - [k: string]: unknown } -export function isRepoBlobRef( - v: unknown, -): v is RepoBlobRef & { - $type: $Type<'com.atproto.admin.defs', 'repoBlobRef'> -} { - return is$typed(v, id, 'repoBlobRef') +const hashRepoBlobRef = 'repoBlobRef' + +export function isRepoBlobRef(v: V) { + return is$typed(v, id, hashRepoBlobRef) +} + +export function validateRepoBlobRef(v: V) { + return validate(v, id, hashRepoBlobRef) } -export function validateRepoBlobRef(v: unknown) { - return lexicons.validate( - `${id}#repoBlobRef`, - v, - ) as ValidationResult +export function isValidRepoBlobRef(v: V) { + return isValid(v, id, hashRepoBlobRef) } export interface ThreatSignature { + $type?: $Type<'com.atproto.admin.defs', 'threatSignature'> property: string value: string - [k: string]: unknown } -export function isThreatSignature( - v: unknown, -): v is ThreatSignature & { - $type: $Type<'com.atproto.admin.defs', 'threatSignature'> -} { - return is$typed(v, id, 'threatSignature') +const hashThreatSignature = 'threatSignature' + +export function isThreatSignature(v: V) { + return is$typed(v, id, hashThreatSignature) +} + +export function validateThreatSignature(v: V) { + return validate(v, id, hashThreatSignature) } -export function validateThreatSignature(v: unknown) { - return lexicons.validate( - `${id}#threatSignature`, - v, - ) as ValidationResult +export function isValidThreatSignature(v: V) { + return isValid(v, id, hashThreatSignature) } 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 ad77e52f254..807b7cd9f3f 100644 --- a/packages/api/src/client/types/com/atproto/admin/deleteAccount.ts +++ b/packages/api/src/client/types/com/atproto/admin/deleteAccount.ts @@ -4,16 +4,21 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.deleteAccount' export interface QueryParams {} export interface InputSchema { did: string - [k: string]: unknown } export interface CallOptions { 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 0be94798622..b5737b5fcc0 100644 --- a/packages/api/src/client/types/com/atproto/admin/disableAccountInvites.ts +++ b/packages/api/src/client/types/com/atproto/admin/disableAccountInvites.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.disableAccountInvites' export interface QueryParams {} @@ -15,7 +21,6 @@ export interface InputSchema { account: string /** Optional reason for disabled invites. */ note?: string - [k: string]: unknown } export interface CallOptions { 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 20149d69098..110c252da7b 100644 --- a/packages/api/src/client/types/com/atproto/admin/disableInviteCodes.ts +++ b/packages/api/src/client/types/com/atproto/admin/disableInviteCodes.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.disableInviteCodes' export interface QueryParams {} @@ -14,7 +20,6 @@ export interface QueryParams {} export interface InputSchema { codes?: string[] accounts?: string[] - [k: string]: unknown } export interface CallOptions { 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 f98d75f0638..10bb24f7e63 100644 --- a/packages/api/src/client/types/com/atproto/admin/enableAccountInvites.ts +++ b/packages/api/src/client/types/com/atproto/admin/enableAccountInvites.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.enableAccountInvites' export interface QueryParams {} @@ -15,7 +21,6 @@ export interface InputSchema { account: string /** Optional reason for enabled invites. */ note?: string - [k: string]: unknown } export interface CallOptions { 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 b99538478f3..d486b45e6be 100644 --- a/packages/api/src/client/types/com/atproto/admin/getAccountInfo.ts +++ b/packages/api/src/client/types/com/atproto/admin/getAccountInfo.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ComAtprotoAdminDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoAdminDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.getAccountInfo' export interface QueryParams { 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 f92ab95b675..38d4792c59e 100644 --- a/packages/api/src/client/types/com/atproto/admin/getAccountInfos.ts +++ b/packages/api/src/client/types/com/atproto/admin/getAccountInfos.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ComAtprotoAdminDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoAdminDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.getAccountInfos' export interface QueryParams { @@ -18,7 +24,6 @@ export type InputSchema = undefined export interface OutputSchema { infos: ComAtprotoAdminDefs.AccountView[] - [k: string]: unknown } export interface CallOptions { 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 dba73561108..cb6bded3d9d 100644 --- a/packages/api/src/client/types/com/atproto/admin/getInviteCodes.ts +++ b/packages/api/src/client/types/com/atproto/admin/getInviteCodes.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ComAtprotoServerDefs from '../server/defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoServerDefs from '../server/defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.getInviteCodes' export interface QueryParams { @@ -21,7 +27,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string codes: ComAtprotoServerDefs.InviteCode[] - [k: string]: unknown } export interface CallOptions { 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 771b3aeb8fa..58263489656 100644 --- a/packages/api/src/client/types/com/atproto/admin/getSubjectStatus.ts +++ b/packages/api/src/client/types/com/atproto/admin/getSubjectStatus.ts @@ -4,11 +4,17 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoAdminDefs from './defs' +import type * as ComAtprotoRepoStrongRef from '../repo/strongRef' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.getSubjectStatus' export interface QueryParams { @@ -21,13 +27,12 @@ export type InputSchema = undefined export interface OutputSchema { subject: - | ComAtprotoAdminDefs.RepoRef - | ComAtprotoRepoStrongRef.Main - | ComAtprotoAdminDefs.RepoBlobRef - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | { $type: string } takedown?: ComAtprotoAdminDefs.StatusAttr deactivated?: ComAtprotoAdminDefs.StatusAttr - [k: string]: unknown } export interface CallOptions { 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 861e1db3b48..0e9c1612eea 100644 --- a/packages/api/src/client/types/com/atproto/admin/searchAccounts.ts +++ b/packages/api/src/client/types/com/atproto/admin/searchAccounts.ts @@ -4,10 +4,16 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' -import * as ComAtprotoAdminDefs from './defs' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoAdminDefs from './defs' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.searchAccounts' export interface QueryParams { @@ -21,7 +27,6 @@ export type InputSchema = undefined export interface OutputSchema { cursor?: string accounts: ComAtprotoAdminDefs.AccountView[] - [k: string]: unknown } export interface CallOptions { 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 55ac6dbf24b..f591655a596 100644 --- a/packages/api/src/client/types/com/atproto/admin/sendEmail.ts +++ b/packages/api/src/client/types/com/atproto/admin/sendEmail.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.sendEmail' export interface QueryParams {} @@ -18,12 +24,10 @@ export interface InputSchema { senderDid: string /** Additional comment by the sender that won't be used in the email itself but helpful to provide more context for moderators/reviewers */ comment?: string - [k: string]: unknown } export interface OutputSchema { sent: boolean - [k: string]: unknown } export interface CallOptions { 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 99a48490a6d..e8ca06d32fb 100644 --- a/packages/api/src/client/types/com/atproto/admin/updateAccountEmail.ts +++ b/packages/api/src/client/types/com/atproto/admin/updateAccountEmail.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.updateAccountEmail' export interface QueryParams {} @@ -15,7 +21,6 @@ export interface InputSchema { /** The handle or DID of the repo. */ account: string email: string - [k: string]: unknown } export interface CallOptions { 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 974144910ee..1c154cc2852 100644 --- a/packages/api/src/client/types/com/atproto/admin/updateAccountHandle.ts +++ b/packages/api/src/client/types/com/atproto/admin/updateAccountHandle.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.updateAccountHandle' export interface QueryParams {} @@ -14,7 +20,6 @@ export interface QueryParams {} export interface InputSchema { did: string handle: string - [k: string]: unknown } export interface CallOptions { 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 5c06c7f0df0..1f2068d5024 100644 --- a/packages/api/src/client/types/com/atproto/admin/updateAccountPassword.ts +++ b/packages/api/src/client/types/com/atproto/admin/updateAccountPassword.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.updateAccountPassword' export interface QueryParams {} @@ -14,7 +20,6 @@ export interface QueryParams {} export interface InputSchema { did: string password: string - [k: string]: unknown } export interface CallOptions { 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 977ff64ab4e..45c6ad7a4d3 100644 --- a/packages/api/src/client/types/com/atproto/admin/updateSubjectStatus.ts +++ b/packages/api/src/client/types/com/atproto/admin/updateSubjectStatus.ts @@ -4,34 +4,38 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' 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' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +import type * as ComAtprotoAdminDefs from './defs' +import type * as ComAtprotoRepoStrongRef from '../repo/strongRef' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.admin.updateSubjectStatus' export interface QueryParams {} export interface InputSchema { subject: - | ComAtprotoAdminDefs.RepoRef - | ComAtprotoRepoStrongRef.Main - | ComAtprotoAdminDefs.RepoBlobRef - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | { $type: string } takedown?: ComAtprotoAdminDefs.StatusAttr deactivated?: ComAtprotoAdminDefs.StatusAttr - [k: string]: unknown } export interface OutputSchema { subject: - | ComAtprotoAdminDefs.RepoRef - | ComAtprotoRepoStrongRef.Main - | ComAtprotoAdminDefs.RepoBlobRef - | { $type: string; [k: string]: unknown } + | $Typed + | $Typed + | $Typed + | { $type: string } takedown?: ComAtprotoAdminDefs.StatusAttr - [k: string]: unknown } export interface CallOptions { 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 040338ae5e9..e556ed41061 100644 --- a/packages/api/src/client/types/com/atproto/identity/getRecommendedDidCredentials.ts +++ b/packages/api/src/client/types/com/atproto/identity/getRecommendedDidCredentials.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.identity.getRecommendedDidCredentials' export interface QueryParams {} @@ -17,9 +23,8 @@ export interface OutputSchema { /** Recommended rotation keys for PLC dids. Should be undefined (or ignored) for did:webs. */ rotationKeys?: string[] alsoKnownAs?: string[] - verificationMethods?: {} - services?: {} - [k: string]: unknown + verificationMethods?: { [_ in string]: unknown } + services?: { [_ in string]: unknown } } export interface CallOptions { 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 e3dccdc0b20..d454c5c4583 100644 --- a/packages/api/src/client/types/com/atproto/identity/requestPlcOperationSignature.ts +++ b/packages/api/src/client/types/com/atproto/identity/requestPlcOperationSignature.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate 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 afc0829e338..3c8518e6251 100644 --- a/packages/api/src/client/types/com/atproto/identity/resolveHandle.ts +++ b/packages/api/src/client/types/com/atproto/identity/resolveHandle.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.identity.resolveHandle' export interface QueryParams { @@ -18,7 +24,6 @@ export type InputSchema = undefined export interface OutputSchema { did: string - [k: string]: unknown } export interface CallOptions { 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 3847e611a56..b343fe63c16 100644 --- a/packages/api/src/client/types/com/atproto/identity/signPlcOperation.ts +++ b/packages/api/src/client/types/com/atproto/identity/signPlcOperation.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.identity.signPlcOperation' export interface QueryParams {} @@ -16,15 +22,13 @@ export interface InputSchema { token?: string rotationKeys?: string[] alsoKnownAs?: string[] - verificationMethods?: {} - services?: {} - [k: string]: unknown + verificationMethods?: { [_ in string]: unknown } + services?: { [_ in string]: unknown } } export interface OutputSchema { /** A signed DID PLC operation. */ - operation: {} - [k: string]: unknown + operation: { [_ in string]: unknown } } export interface CallOptions { 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 e1042ad1774..af223b1e4ef 100644 --- a/packages/api/src/client/types/com/atproto/identity/submitPlcOperation.ts +++ b/packages/api/src/client/types/com/atproto/identity/submitPlcOperation.ts @@ -4,16 +4,21 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.identity.submitPlcOperation' export interface QueryParams {} export interface InputSchema { - operation: {} - [k: string]: unknown + operation: { [_ in string]: unknown } } export interface CallOptions { 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 9ff1845c051..92e98805b1f 100644 --- a/packages/api/src/client/types/com/atproto/identity/updateHandle.ts +++ b/packages/api/src/client/types/com/atproto/identity/updateHandle.ts @@ -4,9 +4,15 @@ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.identity.updateHandle' export interface QueryParams {} @@ -14,7 +20,6 @@ export interface QueryParams {} export interface InputSchema { /** The new handle. */ handle: string - [k: string]: unknown } export interface CallOptions { 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 dfc59333ea6..07a0a5293cd 100644 --- a/packages/api/src/client/types/com/atproto/label/defs.ts +++ b/packages/api/src/client/types/com/atproto/label/defs.ts @@ -3,13 +3,20 @@ */ import { ValidationResult, BlobRef } from '@atproto/lexicon' import { CID } from 'multiformats/cid' -import { $Type, is$typed } from '../../../../util' -import { lexicons } from '../../../../lexicons' - +import { + isValid as _isValid, + validate as _validate, +} from '../../../../lexicons' +import { $Type, $Typed, is$typed as _is$typed, OmitKey } from '../../../../util' + +const is$typed = _is$typed, + isValid = _isValid, + validate = _validate const id = 'com.atproto.label.defs' /** Metadata tag on an atproto resource (eg, repo or record). */ export interface Label { + $type?: $Type<'com.atproto.label.defs', 'label'> /** The AT Protocol version of the label object. */ ver?: number /** DID of the actor who created this label. */ @@ -28,57 +35,66 @@ export interface Label { exp?: string /** Signature of dag-cbor encoded label. */ sig?: Uint8Array - [k: string]: unknown } -export function isLabel( - v: unknown, -): v is Label & { $type: $Type<'com.atproto.label.defs', 'label'> } { - return is$typed(v, id, 'label') +const hashLabel = 'label' + +export function isLabel(v: V) { + return is$typed(v, id, hashLabel) } -export function validateLabel(v: unknown) { - return lexicons.validate(`${id}#label`, v) as ValidationResult