diff --git a/.changeset/brown-flies-stare.md b/.changeset/brown-flies-stare.md new file mode 100644 index 00000000000..97aa88fdec2 --- /dev/null +++ b/.changeset/brown-flies-stare.md @@ -0,0 +1,9 @@ +--- +"@atproto/ozone": patch +"@atproto/bsky": patch +"@atproto/api": patch +"@atproto/pds": patch +--- + +Update generated code to better reflect actual entity structure + diff --git a/.changeset/eleven-knives-complain.md b/.changeset/eleven-knives-complain.md new file mode 100644 index 00000000000..a62cbd72fbd --- /dev/null +++ b/.changeset/eleven-knives-complain.md @@ -0,0 +1,5 @@ +--- +"@atproto/lex-cli": patch +--- + +Improve typing of isX and validateX return values diff --git a/.changeset/fast-points-walk.md b/.changeset/fast-points-walk.md new file mode 100644 index 00000000000..697405d5178 --- /dev/null +++ b/.changeset/fast-points-walk.md @@ -0,0 +1,5 @@ +--- +"@atproto/syntax": patch +--- + +Improve performance of isValidTid diff --git a/.changeset/fast-waves-jog.md b/.changeset/fast-waves-jog.md new file mode 100644 index 00000000000..401816823af --- /dev/null +++ b/.changeset/fast-waves-jog.md @@ -0,0 +1,5 @@ +--- +"@atproto/lex-cli": patch +--- + +Strongly type result of generated validation helpers diff --git a/.changeset/funny-buses-fly.md b/.changeset/funny-buses-fly.md new file mode 100644 index 00000000000..4302b0f17d0 --- /dev/null +++ b/.changeset/funny-buses-fly.md @@ -0,0 +1,5 @@ +--- +"@atproto/api": patch +--- + +Small reduction in bundle size diff --git a/.changeset/green-cherries-shave.md b/.changeset/green-cherries-shave.md new file mode 100644 index 00000000000..13326d6d967 --- /dev/null +++ b/.changeset/green-cherries-shave.md @@ -0,0 +1,5 @@ +--- +"@atproto/pds": patch +--- + +Minor typing fixes diff --git a/.changeset/green-forks-lie.md b/.changeset/green-forks-lie.md new file mode 100644 index 00000000000..a877f89f412 --- /dev/null +++ b/.changeset/green-forks-lie.md @@ -0,0 +1,5 @@ +--- +"@atproto/api": minor +--- + +Exposed type utilities (e.g. isRecord) no longer cast the output value. Use the new "isValid" helper for that purpose. diff --git a/.changeset/itchy-rockets-speak.md b/.changeset/itchy-rockets-speak.md new file mode 100644 index 00000000000..0aa342c8d04 --- /dev/null +++ b/.changeset/itchy-rockets-speak.md @@ -0,0 +1,5 @@ +--- +"@atproto/lex-cli": patch +--- + +Add isValidX helper to check $type and validate schema diff --git a/.changeset/lazy-moles-switch.md b/.changeset/lazy-moles-switch.md new file mode 100644 index 00000000000..d9518a118c5 --- /dev/null +++ b/.changeset/lazy-moles-switch.md @@ -0,0 +1,5 @@ +--- +"@atproto/api": minor +--- + +Add a `$type` property to record and custom user type interfaces diff --git a/.changeset/popular-shirts-rescue.md b/.changeset/popular-shirts-rescue.md new file mode 100644 index 00000000000..3e7b8ed68bb --- /dev/null +++ b/.changeset/popular-shirts-rescue.md @@ -0,0 +1,5 @@ +--- +"@atproto/lexicon": patch +--- + +Various performance improvements diff --git a/.changeset/shiny-suns-walk.md b/.changeset/shiny-suns-walk.md new file mode 100644 index 00000000000..8b16e53ad29 --- /dev/null +++ b/.changeset/shiny-suns-walk.md @@ -0,0 +1,5 @@ +--- +"@atproto/lex-cli": patch +--- + +Strongly type client "ids" const diff --git a/.changeset/silly-starfishes-pay.md b/.changeset/silly-starfishes-pay.md new file mode 100644 index 00000000000..2c55fce3515 --- /dev/null +++ b/.changeset/silly-starfishes-pay.md @@ -0,0 +1,5 @@ +--- +"@atproto/lexicon": patch +--- + +Add generic parameter to ValidationResult diff --git a/.changeset/small-pumas-rush.md b/.changeset/small-pumas-rush.md new file mode 100644 index 00000000000..d1024198e22 --- /dev/null +++ b/.changeset/small-pumas-rush.md @@ -0,0 +1,5 @@ +--- +"@atproto/lexicon": patch +--- + +Add "value" parameter in ValidationResult diff --git a/.changeset/spotty-bottles-march.md b/.changeset/spotty-bottles-march.md new file mode 100644 index 00000000000..910f685c7c1 --- /dev/null +++ b/.changeset/spotty-bottles-march.md @@ -0,0 +1,5 @@ +--- +"@atproto/lex-cli": minor +--- + +Remove string index signature from custom objects, input and output schemas. diff --git a/.changeset/tall-laws-play.md b/.changeset/tall-laws-play.md new file mode 100644 index 00000000000..ef3fbc40b59 --- /dev/null +++ b/.changeset/tall-laws-play.md @@ -0,0 +1,5 @@ +--- +"@atproto/lex-cli": patch +--- + +Fully type validation result of generated "validate" helpers diff --git a/.changeset/yellow-gorillas-thank.md b/.changeset/yellow-gorillas-thank.md new file mode 100644 index 00000000000..13d72311850 --- /dev/null +++ b/.changeset/yellow-gorillas-thank.md @@ -0,0 +1,5 @@ +--- +"@atproto/lex-cli": minor +--- + +isX utility no longer type casts input diff --git a/.changeset/young-lamps-hunt.md b/.changeset/young-lamps-hunt.md new file mode 100644 index 00000000000..3117ec9d2a1 --- /dev/null +++ b/.changeset/young-lamps-hunt.md @@ -0,0 +1,5 @@ +--- +"@atproto/lex-cli": minor +--- + +Add "$type" property to record and custom user types. diff --git a/Makefile b/Makefile index d7424038a49..81b7b8acf67 100644 --- a/Makefile +++ b/Makefile @@ -28,12 +28,7 @@ run-dev-env-logged: ## Run a "development environment" shell (with logging) .PHONY: codegen codegen: ## Re-generate packages from lexicon/ files - cd packages/api; pnpm run codegen - cd packages/pds; pnpm run codegen - cd packages/bsky; pnpm run codegen - cd packages/ozone; pnpm run codegen - # clean up codegen output - pnpm format + pnpm codegen .PHONY: lint lint: ## Run style checks and verify syntax diff --git a/package.json b/package.json index 78ab708d4e8..99de129b746 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "verify:lint": "pnpm lint", "verify:types": "tsc --build tsconfig.json", "format": "pnpm lint:fix && pnpm style:fix", + "codegen": "pnpm run --recursive --stream --filter '@atproto/lex-cli...' build --force && pnpm run --recursive --stream --parallel codegen && pnpm run lint:fix", "build": "pnpm --recursive --stream build", "dev": "NODE_ENV=development pnpm --stream '/^dev:.+$/'", "dev:tsc": "tsc --build tsconfig.json --watch", diff --git a/packages/api/src/agent.ts b/packages/api/src/agent.ts index 7613e58d1fa..929b012d8d5 100644 --- a/packages/api/src/agent.ts +++ b/packages/api/src/agent.ts @@ -1,11 +1,6 @@ import { TID } from '@atproto/common-web' import { AtUri, ensureValidDid } from '@atproto/syntax' -import { - buildFetchHandler, - BuildFetchHandlerOptions, - FetchHandler, - XrpcClient, -} from '@atproto/xrpc' +import { buildFetchHandler, FetchHandler, XrpcClient } from '@atproto/xrpc' import AwaitLock from 'await-lock' import { AppBskyActorDefs, @@ -20,6 +15,7 @@ import { } from './client/index' import { schemas } from './client/lexicons' import { MutedWord, Nux } from './client/types/app/bsky/actor/defs' +import { $Typed } from './client/util' import { BSKY_LABELER_DID } from './const' import { interpretLabelValueDefinitions } from './moderation' import { DEFAULT_LABEL_SETTINGS } from './moderation/const/labels' @@ -44,8 +40,8 @@ import { isDid, sanitizeMutedWordValue, savedFeedsToUriArrays, - validateSavedFeed, validateNux, + validateSavedFeed, } from './util' const FEED_VIEW_PREF_DEFAULTS = { @@ -61,15 +57,6 @@ const THREAD_VIEW_PREF_DEFAULTS = { prioritizeFollowedUsers: true, } -declare global { - interface Array { - findLast( - predicate: (value: T, index: number, obj: T[]) => unknown, - thisArg?: any, - ): T - } -} - export type { FetchHandler } /** @@ -592,23 +579,14 @@ export class Agent extends XrpcClient { const res = await this.app.bsky.actor.getPreferences({}) const labelPrefs: AppBskyActorDefs.ContentLabelPref[] = [] for (const pref of res.data.preferences) { - if ( - AppBskyActorDefs.isAdultContentPref(pref) && - AppBskyActorDefs.validateAdultContentPref(pref).success - ) { + if (AppBskyActorDefs.isValidAdultContentPref(pref)) { // adult content preferences prefs.moderationPrefs.adultContentEnabled = pref.enabled - } else if ( - AppBskyActorDefs.isContentLabelPref(pref) && - AppBskyActorDefs.validateContentLabelPref(pref).success - ) { + } else if (AppBskyActorDefs.isValidContentLabelPref(pref)) { // content label preference const adjustedPref = adjustLegacyContentLabelPref(pref) labelPrefs.push(adjustedPref) - } else if ( - AppBskyActorDefs.isLabelersPref(pref) && - AppBskyActorDefs.validateLabelersPref(pref).success - ) { + } else if (AppBskyActorDefs.isValidLabelersPref(pref)) { // labelers preferences prefs.moderationPrefs.labelers = this.appLabelers .map((did: string) => ({ did, labels: {} })) @@ -618,56 +596,30 @@ export class Agent extends XrpcClient { labels: {}, })), ) - } else if ( - AppBskyActorDefs.isSavedFeedsPrefV2(pref) && - AppBskyActorDefs.validateSavedFeedsPrefV2(pref).success - ) { + } else if (AppBskyActorDefs.isValidSavedFeedsPrefV2(pref)) { prefs.savedFeeds = pref.items - } else if ( - AppBskyActorDefs.isSavedFeedsPref(pref) && - AppBskyActorDefs.validateSavedFeedsPref(pref).success - ) { + } else if (AppBskyActorDefs.isValidSavedFeedsPref(pref)) { // saved and pinned feeds prefs.feeds.saved = pref.saved prefs.feeds.pinned = pref.pinned - } else if ( - AppBskyActorDefs.isPersonalDetailsPref(pref) && - AppBskyActorDefs.validatePersonalDetailsPref(pref).success - ) { + } else if (AppBskyActorDefs.isValidPersonalDetailsPref(pref)) { // birth date (irl) if (pref.birthDate) { prefs.birthDate = new Date(pref.birthDate) } - } else if ( - AppBskyActorDefs.isFeedViewPref(pref) && - AppBskyActorDefs.validateFeedViewPref(pref).success - ) { + } else if (AppBskyActorDefs.isValidFeedViewPref(pref)) { // feed view preferences - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { $type, feed, ...v } = pref - prefs.feedViewPrefs[pref.feed] = { ...FEED_VIEW_PREF_DEFAULTS, ...v } - } else if ( - AppBskyActorDefs.isThreadViewPref(pref) && - AppBskyActorDefs.validateThreadViewPref(pref).success - ) { + const { $type: _, feed, ...v } = pref + prefs.feedViewPrefs[feed] = { ...FEED_VIEW_PREF_DEFAULTS, ...v } + } else if (AppBskyActorDefs.isValidThreadViewPref(pref)) { // thread view preferences - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { $type, ...v } = pref + const { $type: _, ...v } = pref prefs.threadViewPrefs = { ...prefs.threadViewPrefs, ...v } - } else if ( - AppBskyActorDefs.isInterestsPref(pref) && - AppBskyActorDefs.validateInterestsPref(pref).success - ) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { $type, ...v } = pref + } else if (AppBskyActorDefs.isValidInterestsPref(pref)) { + const { $type: _, ...v } = pref prefs.interests = { ...prefs.interests, ...v } - } else if ( - AppBskyActorDefs.isMutedWordsPref(pref) && - AppBskyActorDefs.validateMutedWordsPref(pref).success - ) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { $type, ...v } = pref - prefs.moderationPrefs.mutedWords = v.items + } else if (AppBskyActorDefs.isValidMutedWordsPref(pref)) { + prefs.moderationPrefs.mutedWords = pref.items if (prefs.moderationPrefs.mutedWords.length) { prefs.moderationPrefs.mutedWords = @@ -676,22 +628,12 @@ export class Agent extends XrpcClient { return word }) } - } else if ( - AppBskyActorDefs.isHiddenPostsPref(pref) && - AppBskyActorDefs.validateHiddenPostsPref(pref).success - ) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { $type, ...v } = pref - prefs.moderationPrefs.hiddenPosts = v.items - } else if ( - AppBskyActorDefs.isBskyAppStatePref(pref) && - AppBskyActorDefs.validateBskyAppStatePref(pref).success - ) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { $type, ...v } = pref - prefs.bskyAppState.queuedNudges = v.queuedNudges || [] - prefs.bskyAppState.activeProgressGuide = v.activeProgressGuide - prefs.bskyAppState.nuxs = v.nuxs || [] + } else if (AppBskyActorDefs.isValidHiddenPostsPref(pref)) { + prefs.moderationPrefs.hiddenPosts = pref.items + } else if (AppBskyActorDefs.isValidBskyAppStatePref(pref)) { + prefs.bskyAppState.queuedNudges = pref.queuedNudges || [] + prefs.bskyAppState.activeProgressGuide = pref.activeProgressGuide + prefs.bskyAppState.nuxs = pref.nuxs || [] } } @@ -894,22 +836,18 @@ export class Agent extends XrpcClient { async setAdultContentEnabled(v: boolean) { await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { - let adultContentPref = prefs.findLast( - (pref) => - AppBskyActorDefs.isAdultContentPref(pref) && - AppBskyActorDefs.validateAdultContentPref(pref).success, - ) - if (adultContentPref) { - adultContentPref.enabled = v - } else { - adultContentPref = { - $type: 'app.bsky.actor.defs#adultContentPref', - enabled: v, - } + const adultContentPref = prefs.findLast( + AppBskyActorDefs.isValidAdultContentPref, + ) || { + $type: 'app.bsky.actor.defs#adultContentPref', + enabled: v, } + + adultContentPref.enabled = v + return prefs .filter((pref) => !AppBskyActorDefs.isAdultContentPref(pref)) - .concat([adultContentPref]) + .concat(adultContentPref) }) } @@ -922,26 +860,20 @@ export class Agent extends XrpcClient { ensureValidDid(labelerDid) } await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { - let labelPref = prefs.findLast( - (pref) => - AppBskyActorDefs.isContentLabelPref(pref) && - AppBskyActorDefs.validateContentLabelPref(pref).success && - pref.label === key && - pref.labelerDid === labelerDid, - ) - let legacyLabelPref: AppBskyActorDefs.ContentLabelPref | undefined - - if (labelPref) { - labelPref.visibility = value - } else { - labelPref = { - $type: 'app.bsky.actor.defs#contentLabelPref', - label: key, - labelerDid, - visibility: value, - } + const labelPref = prefs + .filter(AppBskyActorDefs.isValidContentLabelPref) + .findLast( + (pref) => pref.label === key && pref.labelerDid === labelerDid, + ) || { + $type: 'app.bsky.actor.defs#contentLabelPref', + label: key, + labelerDid, + visibility: value, } + labelPref.visibility = value + + let legacyLabelPref: $Typed | undefined if (AppBskyActorDefs.isContentLabelPref(labelPref)) { // is global if (!labelPref.labelerDid) { @@ -949,28 +881,26 @@ export class Agent extends XrpcClient { 'graphic-media': 'gore', porn: 'nsfw', sexual: 'suggestive', + // Protect against using toString, hasOwnProperty, etc. as a label: + __proto__: null, }[labelPref.label] // if it's a legacy label, double-write the legacy label if (legacyLabelValue) { - legacyLabelPref = prefs.findLast( - (pref) => - AppBskyActorDefs.isContentLabelPref(pref) && - AppBskyActorDefs.validateContentLabelPref(pref).success && - pref.label === legacyLabelValue && - pref.labelerDid === undefined, - ) as AppBskyActorDefs.ContentLabelPref | undefined - - if (legacyLabelPref) { - legacyLabelPref.visibility = value - } else { - legacyLabelPref = { - $type: 'app.bsky.actor.defs#contentLabelPref', - label: legacyLabelValue, - labelerDid: undefined, - visibility: value, - } + legacyLabelPref = prefs + .filter(AppBskyActorDefs.isValidContentLabelPref) + .findLast( + (pref) => + pref.label === legacyLabelValue && + pref.labelerDid === undefined, + ) || { + $type: 'app.bsky.actor.defs#contentLabelPref', + label: legacyLabelValue, + labelerDid: undefined, + visibility: value, } + + legacyLabelPref!.visibility = value } } } @@ -981,7 +911,7 @@ export class Agent extends XrpcClient { !AppBskyActorDefs.isContentLabelPref(pref) || !(pref.label === key && pref.labelerDid === labelerDid), ) - .concat([labelPref]) + .concat(labelPref) .filter((pref) => { if (!legacyLabelPref) return true return ( @@ -999,31 +929,20 @@ export class Agent extends XrpcClient { async addLabeler(did: string) { const prefs = await this.updatePreferences( (prefs: AppBskyActorDefs.Preferences) => { - let labelersPref = prefs.findLast( - (pref) => - AppBskyActorDefs.isLabelersPref(pref) && - AppBskyActorDefs.validateLabelersPref(pref).success, - ) - if (!labelersPref) { - labelersPref = { - $type: 'app.bsky.actor.defs#labelersPref', - labelers: [], - } + const labelersPref = prefs.findLast( + AppBskyActorDefs.isValidLabelersPref, + ) || { + $type: 'app.bsky.actor.defs#labelersPref', + labelers: [], } - if (AppBskyActorDefs.isLabelersPref(labelersPref)) { - let labelerPrefItem = labelersPref.labelers.find( - (labeler) => labeler.did === did, - ) - if (!labelerPrefItem) { - labelerPrefItem = { - did, - } - labelersPref.labelers.push(labelerPrefItem) - } + + if (!labelersPref.labelers.some((labeler) => labeler.did === did)) { + labelersPref.labelers.push({ did }) } + return prefs .filter((pref) => !AppBskyActorDefs.isLabelersPref(pref)) - .concat([labelersPref]) + .concat(labelersPref) }, ) // automatically configure the client @@ -1033,25 +952,20 @@ export class Agent extends XrpcClient { async removeLabeler(did: string) { const prefs = await this.updatePreferences( (prefs: AppBskyActorDefs.Preferences) => { - let labelersPref = prefs.findLast( - (pref) => - AppBskyActorDefs.isLabelersPref(pref) && - AppBskyActorDefs.validateLabelersPref(pref).success, - ) - if (!labelersPref) { - labelersPref = { - $type: 'app.bsky.actor.defs#labelersPref', - labelers: [], - } - } - if (AppBskyActorDefs.isLabelersPref(labelersPref)) { - labelersPref.labelers = labelersPref.labelers.filter( - (labeler) => labeler.did !== did, - ) + const labelersPref = prefs.findLast( + AppBskyActorDefs.isValidLabelersPref, + ) || { + $type: 'app.bsky.actor.defs#labelersPref', + labelers: [], } + + labelersPref.labelers = labelersPref.labelers.filter( + (labeler) => labeler.did !== did, + ) + return prefs .filter((pref) => !AppBskyActorDefs.isLabelersPref(pref)) - .concat([labelersPref]) + .concat(labelersPref) }, ) // automatically configure the client @@ -1065,73 +979,63 @@ export class Agent extends XrpcClient { }) { birthDate = birthDate instanceof Date ? birthDate.toISOString() : birthDate await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { - let personalDetailsPref = prefs.findLast( - (pref) => - AppBskyActorDefs.isPersonalDetailsPref(pref) && - AppBskyActorDefs.validatePersonalDetailsPref(pref).success, - ) - if (personalDetailsPref) { - personalDetailsPref.birthDate = birthDate - } else { - personalDetailsPref = { - $type: 'app.bsky.actor.defs#personalDetailsPref', - birthDate, - } + const personalDetailsPref = prefs.findLast( + AppBskyActorDefs.isValidPersonalDetailsPref, + ) || { + $type: 'app.bsky.actor.defs#personalDetailsPref', + birthDate, } + + personalDetailsPref.birthDate = birthDate + return prefs .filter((pref) => !AppBskyActorDefs.isPersonalDetailsPref(pref)) - .concat([personalDetailsPref]) + .concat(personalDetailsPref) }) } async setFeedViewPrefs(feed: string, pref: Partial) { await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { - const existing = prefs.findLast( - (pref) => - AppBskyActorDefs.isFeedViewPref(pref) && - AppBskyActorDefs.validateFeedViewPref(pref).success && - pref.feed === feed, - ) - if (existing) { - pref = { ...existing, ...pref } - } + const existing = prefs + .filter(AppBskyActorDefs.isValidFeedViewPref) + .findLast((pref) => pref.feed === feed) + return prefs - .filter( - (p) => !AppBskyActorDefs.isFeedViewPref(pref) || p.feed !== feed, - ) - .concat([{ ...pref, $type: 'app.bsky.actor.defs#feedViewPref', feed }]) + .filter((p) => !AppBskyActorDefs.isFeedViewPref(p) || p.feed !== feed) + .concat({ + ...existing, + ...pref, + $type: 'app.bsky.actor.defs#feedViewPref', + feed, + }) }) } async setThreadViewPrefs(pref: Partial) { await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { - const existing = prefs.findLast( - (pref) => - AppBskyActorDefs.isThreadViewPref(pref) && - AppBskyActorDefs.validateThreadViewPref(pref).success, - ) - if (existing) { - pref = { ...existing, ...pref } - } + const existing = prefs.findLast(AppBskyActorDefs.isValidThreadViewPref) + return prefs .filter((p) => !AppBskyActorDefs.isThreadViewPref(p)) - .concat([{ ...pref, $type: 'app.bsky.actor.defs#threadViewPref' }]) + .concat({ + ...existing, + ...pref, + $type: 'app.bsky.actor.defs#threadViewPref', + }) }) } async setInterestsPref(pref: Partial) { await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { - const existing = prefs.findLast( - (pref) => - AppBskyActorDefs.isInterestsPref(pref) && - AppBskyActorDefs.validateInterestsPref(pref).success, - ) - if (existing) { - pref = { ...existing, ...pref } - } + const existing = prefs.findLast(AppBskyActorDefs.isValidInterestsPref) + return prefs .filter((p) => !AppBskyActorDefs.isInterestsPref(p)) - .concat([{ ...pref, $type: 'app.bsky.actor.defs#interestsPref' }]) + .concat({ + ...existing, + ...pref, + $type: 'app.bsky.actor.defs#interestsPref', + }) }) } @@ -1150,9 +1054,7 @@ export class Agent extends XrpcClient { await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { let mutedWordsPref = prefs.findLast( - (pref) => - AppBskyActorDefs.isMutedWordsPref(pref) && - AppBskyActorDefs.validateMutedWordsPref(pref).success, + AppBskyActorDefs.isValidMutedWordsPref, ) const newMutedWord: AppBskyActorDefs.MutedWord = { @@ -1175,15 +1077,14 @@ export class Agent extends XrpcClient { } else { // if the pref doesn't exist, create it mutedWordsPref = { + $type: 'app.bsky.actor.defs#mutedWordsPref', items: [newMutedWord], } } return prefs .filter((p) => !AppBskyActorDefs.isMutedWordsPref(p)) - .concat([ - { ...mutedWordsPref, $type: 'app.bsky.actor.defs#mutedWordsPref' }, - ]) + .concat(mutedWordsPref) }) } @@ -1212,9 +1113,7 @@ export class Agent extends XrpcClient { async updateMutedWord(mutedWord: AppBskyActorDefs.MutedWord) { await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { const mutedWordsPref = prefs.findLast( - (pref) => - AppBskyActorDefs.isMutedWordsPref(pref) && - AppBskyActorDefs.validateMutedWordsPref(pref).success, + AppBskyActorDefs.isValidMutedWordsPref, ) if (mutedWordsPref && AppBskyActorDefs.isMutedWordsPref(mutedWordsPref)) { @@ -1248,9 +1147,10 @@ export class Agent extends XrpcClient { return prefs .filter((p) => !AppBskyActorDefs.isMutedWordsPref(p)) - .concat([ - { ...mutedWordsPref, $type: 'app.bsky.actor.defs#mutedWordsPref' }, - ]) + .concat({ + ...mutedWordsPref, + $type: 'app.bsky.actor.defs#mutedWordsPref', + }) } return prefs @@ -1263,9 +1163,7 @@ export class Agent extends XrpcClient { async removeMutedWord(mutedWord: AppBskyActorDefs.MutedWord) { await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { const mutedWordsPref = prefs.findLast( - (pref) => - AppBskyActorDefs.isMutedWordsPref(pref) && - AppBskyActorDefs.validateMutedWordsPref(pref).success, + AppBskyActorDefs.isValidMutedWordsPref, ) if (mutedWordsPref && AppBskyActorDefs.isMutedWordsPref(mutedWordsPref)) { @@ -1287,9 +1185,10 @@ export class Agent extends XrpcClient { return prefs .filter((p) => !AppBskyActorDefs.isMutedWordsPref(p)) - .concat([ - { ...mutedWordsPref, $type: 'app.bsky.actor.defs#mutedWordsPref' }, - ]) + .concat({ + ...mutedWordsPref, + $type: 'app.bsky.actor.defs#mutedWordsPref', + }) } return prefs @@ -1313,38 +1212,30 @@ export class Agent extends XrpcClient { async bskyAppQueueNudges(nudges: string | string[]) { await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { - let bskyAppStatePref: AppBskyActorDefs.BskyAppStatePref = prefs.findLast( - (pref) => - AppBskyActorDefs.isBskyAppStatePref(pref) && - AppBskyActorDefs.validateBskyAppStatePref(pref).success, - ) + const bskyAppStatePref = prefs.findLast( + AppBskyActorDefs.isValidBskyAppStatePref, + ) || { + $type: 'app.bsky.actor.defs#bskyAppStatePref', + } - bskyAppStatePref = bskyAppStatePref || {} - nudges = Array.isArray(nudges) ? nudges : [nudges] bskyAppStatePref.queuedNudges = ( bskyAppStatePref.queuedNudges || [] ).concat(nudges) return prefs .filter((p) => !AppBskyActorDefs.isBskyAppStatePref(p)) - .concat([ - { - ...bskyAppStatePref, - $type: 'app.bsky.actor.defs#bskyAppStatePref', - }, - ]) + .concat(bskyAppStatePref) }) } async bskyAppDismissNudges(nudges: string | string[]) { await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { - let bskyAppStatePref: AppBskyActorDefs.BskyAppStatePref = prefs.findLast( - (pref) => - AppBskyActorDefs.isBskyAppStatePref(pref) && - AppBskyActorDefs.validateBskyAppStatePref(pref).success, - ) + const bskyAppStatePref = prefs.findLast( + AppBskyActorDefs.isValidBskyAppStatePref, + ) || { + $type: 'app.bsky.actor.defs#bskyAppStatePref', + } - bskyAppStatePref = bskyAppStatePref || {} nudges = Array.isArray(nudges) ? nudges : [nudges] bskyAppStatePref.queuedNudges = ( bskyAppStatePref.queuedNudges || [] @@ -1352,12 +1243,7 @@ export class Agent extends XrpcClient { return prefs .filter((p) => !AppBskyActorDefs.isBskyAppStatePref(p)) - .concat([ - { - ...bskyAppStatePref, - $type: 'app.bsky.actor.defs#bskyAppStatePref', - }, - ]) + .concat(bskyAppStatePref) }) } @@ -1372,23 +1258,17 @@ export class Agent extends XrpcClient { } await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { - let bskyAppStatePref: AppBskyActorDefs.BskyAppStatePref = prefs.findLast( - (pref) => - AppBskyActorDefs.isBskyAppStatePref(pref) && - AppBskyActorDefs.validateBskyAppStatePref(pref).success, - ) + const bskyAppStatePref = prefs.findLast( + AppBskyActorDefs.isValidBskyAppStatePref, + ) || { + $type: 'app.bsky.actor.defs#bskyAppStatePref', + } - bskyAppStatePref = bskyAppStatePref || {} bskyAppStatePref.activeProgressGuide = guide return prefs .filter((p) => !AppBskyActorDefs.isBskyAppStatePref(p)) - .concat([ - { - ...bskyAppStatePref, - $type: 'app.bsky.actor.defs#bskyAppStatePref', - }, - ]) + .concat(bskyAppStatePref) }) } @@ -1399,13 +1279,12 @@ export class Agent extends XrpcClient { validateNux(nux) await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { - let bskyAppStatePref: AppBskyActorDefs.BskyAppStatePref = prefs.findLast( - (pref) => - AppBskyActorDefs.isBskyAppStatePref(pref) && - AppBskyActorDefs.validateBskyAppStatePref(pref).success, - ) + const bskyAppStatePref = prefs.findLast( + AppBskyActorDefs.isValidBskyAppStatePref, + ) || { + $type: 'app.bsky.actor.defs#bskyAppStatePref', + } - bskyAppStatePref = bskyAppStatePref || {} bskyAppStatePref.nuxs = bskyAppStatePref.nuxs || [] const existing = bskyAppStatePref.nuxs?.find((n) => { @@ -1432,12 +1311,7 @@ export class Agent extends XrpcClient { return prefs .filter((p) => !AppBskyActorDefs.isBskyAppStatePref(p)) - .concat([ - { - ...bskyAppStatePref, - $type: 'app.bsky.actor.defs#bskyAppStatePref', - }, - ]) + .concat(bskyAppStatePref) }) } @@ -1446,25 +1320,19 @@ export class Agent extends XrpcClient { */ async bskyAppRemoveNuxs(ids: string[]) { await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { - let bskyAppStatePref: AppBskyActorDefs.BskyAppStatePref = prefs.findLast( - (pref) => - AppBskyActorDefs.isBskyAppStatePref(pref) && - AppBskyActorDefs.validateBskyAppStatePref(pref).success, - ) + const bskyAppStatePref = prefs.findLast( + AppBskyActorDefs.isValidBskyAppStatePref, + ) || { + $type: 'app.bsky.actor.defs#bskyAppStatePref', + } - bskyAppStatePref = bskyAppStatePref || {} bskyAppStatePref.nuxs = (bskyAppStatePref.nuxs || []).filter((nux) => { return !ids.includes(nux.id) }) return prefs .filter((p) => !AppBskyActorDefs.isBskyAppStatePref(p)) - .concat([ - { - ...bskyAppStatePref, - $type: 'app.bsky.actor.defs#bskyAppStatePref', - }, - ]) + .concat(bskyAppStatePref) }) } @@ -1503,27 +1371,21 @@ export class Agent extends XrpcClient { private async updateHiddenPost(postUri: string, action: 'hide' | 'unhide') { await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { - let pref = prefs.findLast( - (pref) => - AppBskyActorDefs.isHiddenPostsPref(pref) && - AppBskyActorDefs.validateHiddenPostsPref(pref).success, - ) - if (pref && AppBskyActorDefs.isHiddenPostsPref(pref)) { - pref.items = - action === 'hide' - ? Array.from(new Set([...pref.items, postUri])) - : pref.items.filter((uri) => uri !== postUri) - } else { - if (action === 'hide') { - pref = { - $type: 'app.bsky.actor.defs#hiddenPostsPref', - items: [postUri], - } - } + const pref = prefs.findLast(AppBskyActorDefs.isValidHiddenPostsPref) || { + $type: 'app.bsky.actor.defs#hiddenPostsPref', + items: [], } + + const hiddenItems = new Set(pref.items) + + if (action === 'hide') hiddenItems.add(postUri) + else hiddenItems.delete(postUri) + + pref.items = [...hiddenItems] + return prefs .filter((p) => !AppBskyActorDefs.isInterestsPref(p)) - .concat([{ ...pref, $type: 'app.bsky.actor.defs#hiddenPostsPref' }]) + .concat(pref) }) } @@ -1538,26 +1400,21 @@ export class Agent extends XrpcClient { ): Promise<{ saved: string[]; pinned: string[] }> { let res await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { - let feedsPref = prefs.findLast( - (pref) => - AppBskyActorDefs.isSavedFeedsPref(pref) && - AppBskyActorDefs.validateSavedFeedsPref(pref).success, - ) as AppBskyActorDefs.SavedFeedsPref | undefined - if (feedsPref) { - res = cb(feedsPref.saved, feedsPref.pinned) - feedsPref.saved = res.saved - feedsPref.pinned = res.pinned - } else { - res = cb([], []) - feedsPref = { - $type: 'app.bsky.actor.defs#savedFeedsPref', - saved: res.saved, - pinned: res.pinned, - } + const feedsPref = prefs.findLast( + AppBskyActorDefs.isValidSavedFeedsPref, + ) || { + $type: 'app.bsky.actor.defs#savedFeedsPref', + saved: [], + pinned: [], } + + res = cb(feedsPref.saved, feedsPref.pinned) + feedsPref.saved = res.saved + feedsPref.pinned = res.pinned + return prefs .filter((pref) => !AppBskyActorDefs.isSavedFeedsPref(pref)) - .concat([feedsPref]) + .concat(feedsPref) }) return res } @@ -1571,15 +1428,11 @@ export class Agent extends XrpcClient { await this.updatePreferences((prefs: AppBskyActorDefs.Preferences) => { let existingV2Pref = prefs.findLast( - (pref) => - AppBskyActorDefs.isSavedFeedsPrefV2(pref) && - AppBskyActorDefs.validateSavedFeedsPrefV2(pref).success, - ) as AppBskyActorDefs.SavedFeedsPrefV2 | undefined + AppBskyActorDefs.isValidSavedFeedsPrefV2, + ) let existingV1Pref = prefs.findLast( - (pref) => - AppBskyActorDefs.isSavedFeedsPref(pref) && - AppBskyActorDefs.validateSavedFeedsPref(pref).success, - ) as AppBskyActorDefs.SavedFeedsPref | undefined + AppBskyActorDefs.isValidSavedFeedsPref, + ) if (existingV2Pref) { maybeMutatedSavedFeeds = cb(existingV2Pref.items) @@ -1680,11 +1533,7 @@ function remapLegacyLabels( function prefsArrayToLabelerDids( prefs: AppBskyActorDefs.Preferences, ): string[] { - const labelersPref = prefs.findLast( - (pref) => - AppBskyActorDefs.isLabelersPref(pref) && - AppBskyActorDefs.validateLabelersPref(pref).success, - ) + const labelersPref = prefs.findLast(AppBskyActorDefs.isValidLabelersPref) let dids: string[] = [] if (labelersPref) { dids = (labelersPref as AppBskyActorDefs.LabelersPref).labelers.map( 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 78cff825671..5e42bd080d5 100644 --- a/packages/api/src/client/types/app/bsky/actor/defs.ts +++ b/packages/api/src/client/types/app/bsky/actor/defs.ts @@ -2,14 +2,23 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 @@ -18,22 +27,24 @@ export interface ProfileViewBasic { viewer?: ViewerState labels?: ComAtprotoLabelDefs.Label[] createdAt?: string - [k: string]: unknown } -export function isProfileViewBasic(v: unknown): v is ProfileViewBasic { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#profileViewBasic', v) +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 @@ -44,22 +55,24 @@ export interface ProfileView { createdAt?: string viewer?: ViewerState labels?: ComAtprotoLabelDefs.Label[] - [k: string]: unknown } -export function isProfileView(v: unknown): v is ProfileView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#profileView' - ) +const hashProfileView = 'profileView' + +export function isProfileView(v: V) { + return is$typed(v, id, hashProfileView) } -export function validateProfileView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#profileView', v) +export function validateProfileView(v: V) { + return validate(v, id, hashProfileView) +} + +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 @@ -76,63 +89,67 @@ export interface ProfileViewDetailed { viewer?: ViewerState labels?: ComAtprotoLabelDefs.Label[] pinnedPost?: ComAtprotoRepoStrongRef.Main - [k: string]: unknown } -export function isProfileViewDetailed(v: unknown): v is ProfileViewDetailed { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#profileViewDetailed', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#profileAssociated', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#profileAssociatedChat' - ) +const hashProfileAssociatedChat = 'profileAssociatedChat' + +export function isProfileAssociatedChat(v: V) { + return is$typed(v, id, hashProfileAssociatedChat) } -export function validateProfileAssociatedChat(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#profileAssociatedChat', v) +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 @@ -141,168 +158,184 @@ export interface ViewerState { following?: string followedBy?: string knownFollowers?: KnownFollowers - [k: string]: unknown } -export function isViewerState(v: unknown): v is ViewerState { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#viewerState', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#knownFollowers', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#adultContentPref' - ) +const hashAdultContentPref = 'adultContentPref' + +export function isAdultContentPref(v: V) { + return is$typed(v, id, hashAdultContentPref) } -export function validateAdultContentPref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#adultContentPref', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#contentLabelPref', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#savedFeed', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#savedFeedsPrefV2' - ) +const hashSavedFeedsPrefV2 = 'savedFeedsPrefV2' + +export function isSavedFeedsPrefV2(v: V) { + return is$typed(v, id, hashSavedFeedsPrefV2) } -export function validateSavedFeedsPrefV2(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#savedFeedsPrefV2', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#savedFeedsPref', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#personalDetailsPref', v) +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. */ @@ -315,22 +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#feedViewPref' - ) +const hashFeedViewPref = 'feedViewPref' + +export function isFeedViewPref(v: V) { + return is$typed(v, id, hashFeedViewPref) } -export function validateFeedViewPref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#feedViewPref', v) +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' @@ -341,43 +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#threadViewPref', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#interestsPref', v) +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 @@ -387,148 +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#mutedWord' - ) +const hashMutedWord = 'mutedWord' + +export function isMutedWord(v: V) { + return is$typed(v, id, hashMutedWord) } -export function validateMutedWord(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#mutedWord', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#mutedWordsPref', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#hiddenPostsPref', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#labelersPref' - ) +const hashLabelersPref = 'labelersPref' + +export function isLabelersPref(v: V) { + return is$typed(v, id, hashLabelersPref) } -export function validateLabelersPref(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#labelersPref', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#labelerPrefItem', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#bskyAppStatePref', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.actor.defs#bskyAppProgressGuide' - ) +const hashBskyAppProgressGuide = 'bskyAppProgressGuide' + +export function isBskyAppProgressGuide(v: V) { + return is$typed(v, id, hashBskyAppProgressGuide) } -export function validateBskyAppProgressGuide(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#bskyAppProgressGuide', v) +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 { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('app.bsky.actor.defs#nux', v) +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 6cc35cc3c62..387315cc221 100644 --- a/packages/api/src/client/types/app/bsky/actor/getPreferences.ts +++ b/packages/api/src/client/types/app/bsky/actor/getPreferences.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 {} @@ -14,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 13618b6c2f7..3807b4d6cd9 100644 --- a/packages/api/src/client/types/app/bsky/actor/getProfile.ts +++ b/packages/api/src/client/types/app/bsky/actor/getProfile.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Handle or DID of account to fetch profile of. */ diff --git a/packages/api/src/client/types/app/bsky/actor/getProfiles.ts b/packages/api/src/client/types/app/bsky/actor/getProfiles.ts index 2207218ac69..f8f02263f39 100644 --- a/packages/api/src/client/types/app/bsky/actor/getProfiles.ts +++ b/packages/api/src/client/types/app/bsky/actor/getProfiles.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { actors: string[] @@ -16,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 48553fd1b85..6f92c4c79dc 100644 --- a/packages/api/src/client/types/app/bsky/actor/getSuggestions.ts +++ b/packages/api/src/client/types/app/bsky/actor/getSuggestions.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { limit?: number @@ -18,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 c109e93f9ab..666b6c48976 100644 --- a/packages/api/src/client/types/app/bsky/actor/profile.ts +++ b/packages/api/src/client/types/app/bsky/actor/profile.ts @@ -2,13 +2,22 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 @@ -16,24 +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.actor.profile#main' || - v.$type === 'app.bsky.actor.profile') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.actor.profile#main', v) +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 834b1bd247c..70d7542f85b 100644 --- a/packages/api/src/client/types/app/bsky/actor/putPreferences.ts +++ b/packages/api/src/client/types/app/bsky/actor/putPreferences.ts @@ -3,16 +3,23 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 bcbde2b7bfb..2c357ba0f12 100644 --- a/packages/api/src/client/types/app/bsky/actor/searchActors.ts +++ b/packages/api/src/client/types/app/bsky/actor/searchActors.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** DEPRECATED: use 'q' instead. */ @@ -22,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 abed0289f27..a2c571706f9 100644 --- a/packages/api/src/client/types/app/bsky/actor/searchActorsTypeahead.ts +++ b/packages/api/src/client/types/app/bsky/actor/searchActorsTypeahead.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** DEPRECATED: use 'q' instead. */ @@ -20,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 b7b753d65f6..73c40d8bdcb 100644 --- a/packages/api/src/client/types/app/bsky/embed/defs.ts +++ b/packages/api/src/client/types/app/bsky/embed/defs.ts @@ -2,25 +2,35 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.defs#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): ValidationResult { - return lexicons.validate('app.bsky.embed.defs#aspectRatio', v) +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 5832cbb3987..1e4a775c3fe 100644 --- a/packages/api/src/client/types/app/bsky/embed/external.ts +++ b/packages/api/src/client/types/app/bsky/embed/external.ts @@ -2,82 +2,97 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.embed.external#main' || - v.$type === 'app.bsky.embed.external') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.embed.external#main', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.external#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): ValidationResult { - return lexicons.validate('app.bsky.embed.external#external', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.external#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): ValidationResult { - return lexicons.validate('app.bsky.embed.external#view', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.external#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): ValidationResult { - return lexicons.validate('app.bsky.embed.external#viewExternal', v) +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 886ad7c5c5b..d0c14d0f827 100644 --- a/packages/api/src/client/types/app/bsky/embed/images.ts +++ b/packages/api/src/client/types/app/bsky/embed/images.ts @@ -2,63 +2,81 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.embed.images#main' || - v.$type === 'app.bsky.embed.images') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.embed.images#main', v) +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 { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.embed.images#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): ValidationResult { - return lexicons.validate('app.bsky.embed.images#image', v) +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 { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.embed.images#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): ValidationResult { - return lexicons.validate('app.bsky.embed.images#view', v) +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. */ @@ -66,17 +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.images#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): ValidationResult { - return lexicons.validate('app.bsky.embed.images#viewImage', v) +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 a3744c29246..082545b5db4 100644 --- a/packages/api/src/client/types/app/bsky/embed/record.ts +++ b/packages/api/src/client/types/app/bsky/embed/record.ts @@ -2,148 +2,169 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.embed.record#main' || - v.$type === 'app.bsky.embed.record') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.embed.record#main', v) +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 } } -export function isView(v: unknown): v is View { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.embed.record#view' - ) +const hashView = 'view' + +export function isView(v: V) { + return is$typed(v, id, hashView) } -export function validateView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.record#view', v) +export function validateView(v: V) { + return validate(v, id, hashView) +} + +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.record#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): ValidationResult { - return lexicons.validate('app.bsky.embed.record#viewRecord', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.record#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): ValidationResult { - return lexicons.validate('app.bsky.embed.record#viewNotFound', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.record#viewBlocked' - ) +const hashViewBlocked = 'viewBlocked' + +export function isViewBlocked(v: V) { + return is$typed(v, id, hashViewBlocked) } -export function validateViewBlocked(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.record#viewBlocked', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.record#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): ValidationResult { - return lexicons.validate('app.bsky.embed.record#viewDetached', v) +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 2b2b3ae6251..c22958741f3 100644 --- a/packages/api/src/client/types/app/bsky/embed/recordWithMedia.ts +++ b/packages/api/src/client/types/app/bsky/embed/recordWithMedia.ts @@ -2,55 +2,66 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 } +} + +const hashMain = 'main' + +export function isMain(v: V) { + return is$typed(v, id, hashMain) } -export function isMain(v: unknown): v is Main { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.embed.recordWithMedia#main' || - v.$type === 'app.bsky.embed.recordWithMedia') - ) +export function validateMain(v: V) { + return validate
(v, id, hashMain) } -export function validateMain(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.recordWithMedia#main', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.recordWithMedia#view' - ) +export function validateView(v: V) { + return validate(v, id, hashView) } -export function validateView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.recordWithMedia#view', v) +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 2be451b85ed..3b8880139a1 100644 --- a/packages/api/src/client/types/app/bsky/embed/video.ts +++ b/packages/api/src/client/types/app/bsky/embed/video.ts @@ -2,66 +2,81 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.embed.video#main' || - v.$type === 'app.bsky.embed.video') - ) +const hashMain = 'main' + +export function isMain(v: V) { + return is$typed(v, id, hashMain) } -export function validateMain(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.video#main', v) +export function validateMain(v: V) { + return validate
(v, id, hashMain) +} + +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.embed.video#caption' - ) +const hashCaption = 'caption' + +export function isCaption(v: V) { + return is$typed(v, id, hashCaption) +} + +export function validateCaption(v: V) { + return validate(v, id, hashCaption) } -export function validateCaption(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.embed.video#caption', v) +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 { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.embed.video#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): ValidationResult { - return lexicons.validate('app.bsky.embed.video#view', v) +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 bc50067c1da..1269ef50b0a 100644 --- a/packages/api/src/client/types/app/bsky/feed/defs.ts +++ b/packages/api/src/client/types/app/bsky/feed/defs.ts @@ -2,31 +2,40 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 @@ -35,206 +44,230 @@ export interface PostView { viewer?: ViewerState labels?: ComAtprotoLabelDefs.Label[] threadgate?: ThreadgateView - [k: string]: unknown } -export function isPostView(v: unknown): v is PostView { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.feed.defs#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): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#postView', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#viewerState' - ) +const hashViewerState = 'viewerState' + +export function isViewerState(v: V) { + return is$typed(v, id, hashViewerState) } -export function validateViewerState(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#viewerState', v) +export function validateViewerState(v: V) { + return validate(v, id, hashViewerState) +} + +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#feedViewPost' - ) +const hashFeedViewPost = 'feedViewPost' + +export function isFeedViewPost(v: V) { + return is$typed(v, id, hashFeedViewPost) } -export function validateFeedViewPost(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#feedViewPost', v) +export function validateFeedViewPost(v: V) { + return validate(v, id, hashFeedViewPost) +} + +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 { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.feed.defs#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): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#replyRef', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#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): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#reasonRepost', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#reasonPin' - ) +const hashReasonPin = 'reasonPin' + +export function isReasonPin(v: V) { + return is$typed(v, id, hashReasonPin) } -export function validateReasonPin(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#reasonPin', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#threadViewPost' - ) +const hashThreadViewPost = 'threadViewPost' + +export function isThreadViewPost(v: V) { + return is$typed(v, id, hashThreadViewPost) } -export function validateThreadViewPost(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#threadViewPost', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#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): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#notFoundPost', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#blockedPost' - ) +const hashBlockedPost = 'blockedPost' + +export function isBlockedPost(v: V) { + return is$typed(v, id, hashBlockedPost) } -export function validateBlockedPost(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#blockedPost', v) +export function validateBlockedPost(v: V) { + return validate(v, id, hashBlockedPost) +} + +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#blockedAuthor' - ) +const hashBlockedAuthor = 'blockedAuthor' + +export function isBlockedAuthor(v: V) { + return is$typed(v, id, hashBlockedAuthor) +} + +export function validateBlockedAuthor(v: V) { + return validate(v, id, hashBlockedAuthor) } -export function validateBlockedAuthor(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#blockedAuthor', v) +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 @@ -248,115 +281,127 @@ export interface GeneratorView { labels?: ComAtprotoLabelDefs.Label[] viewer?: GeneratorViewerState indexedAt: string - [k: string]: unknown } -export function isGeneratorView(v: unknown): v is GeneratorView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#generatorView' - ) +const hashGeneratorView = 'generatorView' + +export function isGeneratorView(v: V) { + return is$typed(v, id, hashGeneratorView) +} + +export function validateGeneratorView(v: V) { + return validate(v, id, hashGeneratorView) } -export function validateGeneratorView(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#generatorView', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#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): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#generatorViewerState', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#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): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#skeletonFeedPost', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#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): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#skeletonReasonRepost', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#skeletonReasonPin' - ) +export function validateSkeletonReasonPin(v: V) { + return validate(v, id, hashSkeletonReasonPin) } -export function validateSkeletonReasonPin(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#skeletonReasonPin', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#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): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#threadgateView', v) +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' @@ -374,42 +419,43 @@ 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.defs#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): ValidationResult { - return lexicons.validate('app.bsky.feed.defs#interaction', v) +export function isValidInteraction(v: V) { + return isValid(v, id, hashInteraction) } /** Request that less content like the given feed item be shown in the feed */ -export const REQUESTLESS = 'app.bsky.feed.defs#requestLess' +export const REQUESTLESS = `${id}#requestLess` /** Request that more content like the given feed item be shown in the feed */ -export const REQUESTMORE = 'app.bsky.feed.defs#requestMore' +export const REQUESTMORE = `${id}#requestMore` /** User clicked through to the feed item */ -export const CLICKTHROUGHITEM = 'app.bsky.feed.defs#clickthroughItem' +export const CLICKTHROUGHITEM = `${id}#clickthroughItem` /** User clicked through to the author of the feed item */ -export const CLICKTHROUGHAUTHOR = 'app.bsky.feed.defs#clickthroughAuthor' +export const CLICKTHROUGHAUTHOR = `${id}#clickthroughAuthor` /** User clicked through to the reposter of the feed item */ -export const CLICKTHROUGHREPOSTER = 'app.bsky.feed.defs#clickthroughReposter' +export const CLICKTHROUGHREPOSTER = `${id}#clickthroughReposter` /** User clicked through to the embedded content of the feed item */ -export const CLICKTHROUGHEMBED = 'app.bsky.feed.defs#clickthroughEmbed' +export const CLICKTHROUGHEMBED = `${id}#clickthroughEmbed` /** Feed item was seen by user */ -export const INTERACTIONSEEN = 'app.bsky.feed.defs#interactionSeen' +export const INTERACTIONSEEN = `${id}#interactionSeen` /** User liked the feed item */ -export const INTERACTIONLIKE = 'app.bsky.feed.defs#interactionLike' +export const INTERACTIONLIKE = `${id}#interactionLike` /** User reposted the feed item */ -export const INTERACTIONREPOST = 'app.bsky.feed.defs#interactionRepost' +export const INTERACTIONREPOST = `${id}#interactionRepost` /** User replied to the feed item */ -export const INTERACTIONREPLY = 'app.bsky.feed.defs#interactionReply' +export const INTERACTIONREPLY = `${id}#interactionReply` /** User quoted the feed item */ -export const INTERACTIONQUOTE = 'app.bsky.feed.defs#interactionQuote' +export const INTERACTIONQUOTE = `${id}#interactionQuote` /** User shared the feed item */ -export const INTERACTIONSHARE = 'app.bsky.feed.defs#interactionShare' +export const INTERACTIONSHARE = `${id}#interactionShare` diff --git a/packages/api/src/client/types/app/bsky/feed/describeFeedGenerator.ts b/packages/api/src/client/types/app/bsky/feed/describeFeedGenerator.ts index b974f496144..c93c90d7ab8 100644 --- a/packages/api/src/client/types/app/bsky/feed/describeFeedGenerator.ts +++ b/packages/api/src/client/types/app/bsky/feed/describeFeedGenerator.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} @@ -15,7 +23,6 @@ export interface OutputSchema { did: string feeds: Feed[] links?: Links - [k: string]: unknown } export interface CallOptions { @@ -34,36 +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.describeFeedGenerator#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): ValidationResult { - return lexicons.validate('app.bsky.feed.describeFeedGenerator#feed', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.describeFeedGenerator#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): ValidationResult { - return lexicons.validate('app.bsky.feed.describeFeedGenerator#links', v) +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 b36796dd353..9c7a3fc0d62 100644 --- a/packages/api/src/client/types/app/bsky/feed/generator.ts +++ b/packages/api/src/client/types/app/bsky/feed/generator.ts @@ -2,13 +2,22 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 @@ -16,22 +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.feed.generator#main' || - v.$type === 'app.bsky.feed.generator') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.feed.generator#main', v) +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 e8a0cb94bd3..e8b037e4b84 100644 --- a/packages/api/src/client/types/app/bsky/feed/getActorFeeds.ts +++ b/packages/api/src/client/types/app/bsky/feed/getActorFeeds.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { actor: string @@ -19,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 1da239d96f3..cb673b1efc7 100644 --- a/packages/api/src/client/types/app/bsky/feed/getActorLikes.ts +++ b/packages/api/src/client/types/app/bsky/feed/getActorLikes.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { actor: string @@ -19,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 77319f28d40..2b85919c8e1 100644 --- a/packages/api/src/client/types/app/bsky/feed/getAuthorFeed.ts +++ b/packages/api/src/client/types/app/bsky/feed/getAuthorFeed.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { actor: string @@ -27,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 b61a1248e2a..f51b0802123 100644 --- a/packages/api/src/client/types/app/bsky/feed/getFeed.ts +++ b/packages/api/src/client/types/app/bsky/feed/getFeed.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { feed: string @@ -19,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 8d222f8d521..d3a244a3812 100644 --- a/packages/api/src/client/types/app/bsky/feed/getFeedGenerator.ts +++ b/packages/api/src/client/types/app/bsky/feed/getFeedGenerator.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** AT-URI of the feed generator record. */ @@ -21,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 1d99fd6608c..842ec2aef5f 100644 --- a/packages/api/src/client/types/app/bsky/feed/getFeedGenerators.ts +++ b/packages/api/src/client/types/app/bsky/feed/getFeedGenerators.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { feeds: string[] @@ -16,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 bf859cc1e87..c94141820e8 100644 --- a/packages/api/src/client/types/app/bsky/feed/getFeedSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/feed/getFeedSkeleton.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Reference to feed generator record describing the specific feed being requested. */ @@ -20,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 35af1b3aae5..2b3a9f5e0fc 100644 --- a/packages/api/src/client/types/app/bsky/feed/getLikes.ts +++ b/packages/api/src/client/types/app/bsky/feed/getLikes.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** AT-URI of the subject (eg, a post record). */ @@ -24,7 +32,6 @@ export interface OutputSchema { cid?: string cursor?: string likes: Like[] - [k: string]: unknown } export interface CallOptions { @@ -43,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 { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.feed.getLikes#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): ValidationResult { - return lexicons.validate('app.bsky.feed.getLikes#like', v) +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 4e47e597afd..f56a761022f 100644 --- a/packages/api/src/client/types/app/bsky/feed/getListFeed.ts +++ b/packages/api/src/client/types/app/bsky/feed/getListFeed.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Reference (AT-URI) to the list record. */ @@ -20,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 df012607df1..245c55b9ced 100644 --- a/packages/api/src/client/types/app/bsky/feed/getPostThread.ts +++ b/packages/api/src/client/types/app/bsky/feed/getPostThread.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Reference (AT-URI) to post record. */ @@ -21,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 0ae8657de94..6ca851e6819 100644 --- a/packages/api/src/client/types/app/bsky/feed/getPosts.ts +++ b/packages/api/src/client/types/app/bsky/feed/getPosts.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** List of post AT-URIs to return hydrated views for. */ @@ -17,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 aafc487cd43..4550f286646 100644 --- a/packages/api/src/client/types/app/bsky/feed/getQuotes.ts +++ b/packages/api/src/client/types/app/bsky/feed/getQuotes.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Reference (AT-URI) of post record */ @@ -24,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 dfbac97453b..1aecb6c715e 100644 --- a/packages/api/src/client/types/app/bsky/feed/getRepostedBy.ts +++ b/packages/api/src/client/types/app/bsky/feed/getRepostedBy.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Reference (AT-URI) of post record */ @@ -24,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 2e9495d8c19..0e81367ec1c 100644 --- a/packages/api/src/client/types/app/bsky/feed/getSuggestedFeeds.ts +++ b/packages/api/src/client/types/app/bsky/feed/getSuggestedFeeds.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { limit?: number @@ -18,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 6c5280443a9..08135f639aa 100644 --- a/packages/api/src/client/types/app/bsky/feed/getTimeline.ts +++ b/packages/api/src/client/types/app/bsky/feed/getTimeline.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Variant 'algorithm' for timeline. Implementation-specific. NOTE: most feed flexibility has been moved to feed generator mechanism. */ @@ -20,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 10237e45f0d..08ede56a096 100644 --- a/packages/api/src/client/types/app/bsky/feed/like.ts +++ b/packages/api/src/client/types/app/bsky/feed/like.ts @@ -2,25 +2,36 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.feed.like#main' || v.$type === 'app.bsky.feed.like') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.feed.like#main', v) +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 e358409c0e0..8fcd72f9ac9 100644 --- a/packages/api/src/client/types/app/bsky/feed/post.ts +++ b/packages/api/src/client/types/app/bsky/feed/post.ts @@ -2,19 +2,28 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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. */ @@ -23,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. */ @@ -41,68 +48,80 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.feed.post#main' || v.$type === 'app.bsky.feed.post') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.feed.post#main', v) +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 { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.feed.post#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): ValidationResult { - return lexicons.validate('app.bsky.feed.post#replyRef', v) +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 { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.feed.post#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): ValidationResult { - return lexicons.validate('app.bsky.feed.post#entity', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.post#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): ValidationResult { - return lexicons.validate('app.bsky.feed.post#textSlice', v) +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 aad8496699a..25e9d32ff8c 100644 --- a/packages/api/src/client/types/app/bsky/feed/postgate.ts +++ b/packages/api/src/client/types/app/bsky/feed/postgate.ts @@ -2,46 +2,58 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.feed.postgate#main' || - v.$type === 'app.bsky.feed.postgate') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.feed.postgate#main', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.postgate#disableRule' - ) +export function validateDisableRule(v: V) { + return validate(v, id, hashDisableRule) } -export function validateDisableRule(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.postgate#disableRule', v) +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 2e8f6e75548..f51561588c7 100644 --- a/packages/api/src/client/types/app/bsky/feed/repost.ts +++ b/packages/api/src/client/types/app/bsky/feed/repost.ts @@ -2,26 +2,36 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.feed.repost#main' || - v.$type === 'app.bsky.feed.repost') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.feed.repost#main', v) +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 1a2ec64dcd2..c945c5f284a 100644 --- a/packages/api/src/client/types/app/bsky/feed/searchPosts.ts +++ b/packages/api/src/client/types/app/bsky/feed/searchPosts.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended. */ @@ -41,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 4d43e26f3dd..63a8d1abe5a 100644 --- a/packages/api/src/client/types/app/bsky/feed/sendInteractions.ts +++ b/packages/api/src/client/types/app/bsky/feed/sendInteractions.ts @@ -3,21 +3,26 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 558027fb8e9..eefa35a8dab 100644 --- a/packages/api/src/client/types/app/bsky/feed/threadgate.ts +++ b/packages/api/src/client/types/app/bsky/feed/threadgate.ts @@ -2,18 +2,27 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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. */ @@ -21,67 +30,74 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.feed.threadgate#main' || - v.$type === 'app.bsky.feed.threadgate') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.feed.threadgate#main', v) +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'> +} + +const hashMentionRule = 'mentionRule' + +export function isMentionRule(v: V) { + return is$typed(v, id, hashMentionRule) } -export function isMentionRule(v: unknown): v is MentionRule { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.threadgate#mentionRule' - ) +export function validateMentionRule(v: V) { + return validate(v, id, hashMentionRule) } -export function validateMentionRule(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.threadgate#mentionRule', v) +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'> +} + +const hashFollowingRule = 'followingRule' + +export function isFollowingRule(v: V) { + return is$typed(v, id, hashFollowingRule) } -export function isFollowingRule(v: unknown): v is FollowingRule { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.threadgate#followingRule' - ) +export function validateFollowingRule(v: V) { + return validate(v, id, hashFollowingRule) } -export function validateFollowingRule(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.feed.threadgate#followingRule', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.feed.threadgate#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): ValidationResult { - return lexicons.validate('app.bsky.feed.threadgate#listRule', v) +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 f2455fc08a2..c10702a4403 100644 --- a/packages/api/src/client/types/app/bsky/graph/block.ts +++ b/packages/api/src/client/types/app/bsky/graph/block.ts @@ -2,26 +2,36 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.graph.block#main' || - v.$type === 'app.bsky.graph.block') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.graph.block#main', v) +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 aa7e2c068b5..52c8471a7d8 100644 --- a/packages/api/src/client/types/app/bsky/graph/defs.ts +++ b/packages/api/src/client/types/app/bsky/graph/defs.ts @@ -2,15 +2,24 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 @@ -20,22 +29,24 @@ export interface ListViewBasic { labels?: ComAtprotoLabelDefs.Label[] viewer?: ListViewerState indexedAt?: string - [k: string]: unknown } -export function isListViewBasic(v: unknown): v is ListViewBasic { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#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): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#listViewBasic', v) +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 @@ -48,43 +59,47 @@ export interface ListView { labels?: ComAtprotoLabelDefs.Label[] viewer?: ListViewerState indexedAt: string - [k: string]: unknown } -export function isListView(v: unknown): v is ListView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#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): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#listView', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#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): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#listItemView', v) +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[] @@ -93,44 +108,47 @@ export interface StarterPackView { joinedAllTimeCount?: number labels?: ComAtprotoLabelDefs.Label[] indexedAt: string - [k: string]: unknown } -export function isStarterPackView(v: unknown): v is StarterPackView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#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): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#starterPackView', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#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): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#starterPackViewBasic', v) +export function isValidStarterPackViewBasic(v: V) { + return isValid(v, id, hashStarterPackViewBasic) } export type ListPurpose = @@ -140,67 +158,73 @@ export type ListPurpose = | (string & {}) /** A list of actors to apply an aggregate moderation action (mute/block) on. */ -export const MODLIST = 'app.bsky.graph.defs#modlist' +export const MODLIST = `${id}#modlist` /** A list of actors used for curation purposes such as list feeds or interaction gating. */ -export const CURATELIST = 'app.bsky.graph.defs#curatelist' +export const CURATELIST = `${id}#curatelist` /** A list of actors used for only for reference purposes such as within a starter pack. */ -export const REFERENCELIST = 'app.bsky.graph.defs#referencelist' +export const REFERENCELIST = `${id}#referencelist` export interface ListViewerState { + $type?: $Type<'app.bsky.graph.defs', 'listViewerState'> muted?: boolean blocked?: string - [k: string]: unknown } -export function isListViewerState(v: unknown): v is ListViewerState { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#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): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#listViewerState', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#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): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#notFoundActor', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.defs#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): ValidationResult { - return lexicons.validate('app.bsky.graph.defs#relationship', v) +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 a68f434f3c8..28c81906d31 100644 --- a/packages/api/src/client/types/app/bsky/graph/follow.ts +++ b/packages/api/src/client/types/app/bsky/graph/follow.ts @@ -2,25 +2,35 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.graph.follow#main' || - v.$type === 'app.bsky.graph.follow') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.graph.follow#main', v) +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 bb374e2318d..9de0f733842 100644 --- a/packages/api/src/client/types/app/bsky/graph/getActorStarterPacks.ts +++ b/packages/api/src/client/types/app/bsky/graph/getActorStarterPacks.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { actor: string @@ -19,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 f0e4bd96bc8..a0331c45abc 100644 --- a/packages/api/src/client/types/app/bsky/graph/getBlocks.ts +++ b/packages/api/src/client/types/app/bsky/graph/getBlocks.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { limit?: number @@ -18,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 f55649dc769..0c1ca06b069 100644 --- a/packages/api/src/client/types/app/bsky/graph/getFollowers.ts +++ b/packages/api/src/client/types/app/bsky/graph/getFollowers.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { actor: string @@ -20,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 8570c4a14c0..929b139cba2 100644 --- a/packages/api/src/client/types/app/bsky/graph/getFollows.ts +++ b/packages/api/src/client/types/app/bsky/graph/getFollows.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { actor: string @@ -20,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 f55649dc769..698596e78bd 100644 --- a/packages/api/src/client/types/app/bsky/graph/getKnownFollowers.ts +++ b/packages/api/src/client/types/app/bsky/graph/getKnownFollowers.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { actor: string @@ -20,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 bebde2b49c3..1f8a98fc7d1 100644 --- a/packages/api/src/client/types/app/bsky/graph/getList.ts +++ b/packages/api/src/client/types/app/bsky/graph/getList.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Reference (AT-URI) of the list record to hydrate. */ @@ -21,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 d3c7ad5ed7b..70868b61ea8 100644 --- a/packages/api/src/client/types/app/bsky/graph/getListBlocks.ts +++ b/packages/api/src/client/types/app/bsky/graph/getListBlocks.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { limit?: number @@ -18,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 d3c7ad5ed7b..009957651a4 100644 --- a/packages/api/src/client/types/app/bsky/graph/getListMutes.ts +++ b/packages/api/src/client/types/app/bsky/graph/getListMutes.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { limit?: number @@ -18,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 89a4bfd58df..e4d619929e8 100644 --- a/packages/api/src/client/types/app/bsky/graph/getLists.ts +++ b/packages/api/src/client/types/app/bsky/graph/getLists.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** The account (actor) to enumerate lists from. */ @@ -20,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 0ee441cf9eb..5ca4d20ced6 100644 --- a/packages/api/src/client/types/app/bsky/graph/getMutes.ts +++ b/packages/api/src/client/types/app/bsky/graph/getMutes.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { limit?: number @@ -18,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 20194662b71..cf014538efc 100644 --- a/packages/api/src/client/types/app/bsky/graph/getRelationships.ts +++ b/packages/api/src/client/types/app/bsky/graph/getRelationships.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Primary account requesting relationships for. */ @@ -20,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 7eafb2d228d..9ada3286741 100644 --- a/packages/api/src/client/types/app/bsky/graph/getStarterPack.ts +++ b/packages/api/src/client/types/app/bsky/graph/getStarterPack.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Reference (AT-URI) of the starter pack record. */ @@ -17,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 50dbfdbaeda..3ac4ba0fb14 100644 --- a/packages/api/src/client/types/app/bsky/graph/getStarterPacks.ts +++ b/packages/api/src/client/types/app/bsky/graph/getStarterPacks.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { uris: string[] @@ -16,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 4747afb19fc..b7a3b754c11 100644 --- a/packages/api/src/client/types/app/bsky/graph/getSuggestedFollowsByActor.ts +++ b/packages/api/src/client/types/app/bsky/graph/getSuggestedFollowsByActor.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { actor: string @@ -18,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 fec652ccb12..97bf1c00559 100644 --- a/packages/api/src/client/types/app/bsky/graph/list.ts +++ b/packages/api/src/client/types/app/bsky/graph/list.ts @@ -2,36 +2,44 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.graph.list#main' || - v.$type === 'app.bsky.graph.list') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.graph.list#main', v) +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 e0f02be268f..6ebd36c4cb3 100644 --- a/packages/api/src/client/types/app/bsky/graph/listblock.ts +++ b/packages/api/src/client/types/app/bsky/graph/listblock.ts @@ -2,26 +2,36 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.graph.listblock#main' || - v.$type === 'app.bsky.graph.listblock') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.graph.listblock#main', v) +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 d4fb5631e84..a3b7efb0eb1 100644 --- a/packages/api/src/client/types/app/bsky/graph/listitem.ts +++ b/packages/api/src/client/types/app/bsky/graph/listitem.ts @@ -2,11 +2,20 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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). */ @@ -15,15 +24,16 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.graph.listitem#main' || - v.$type === 'app.bsky.graph.listitem') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.graph.listitem#main', v) +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 c21c00b2069..f3580483cf3 100644 --- a/packages/api/src/client/types/app/bsky/graph/muteActor.ts +++ b/packages/api/src/client/types/app/bsky/graph/muteActor.ts @@ -3,15 +3,22 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 8a0e8586deb..371563d2193 100644 --- a/packages/api/src/client/types/app/bsky/graph/muteActorList.ts +++ b/packages/api/src/client/types/app/bsky/graph/muteActorList.ts @@ -3,15 +3,22 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 275ba7a0f22..a99cb101c9e 100644 --- a/packages/api/src/client/types/app/bsky/graph/muteThread.ts +++ b/packages/api/src/client/types/app/bsky/graph/muteThread.ts @@ -3,15 +3,22 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 8291b219a62..cb683571f07 100644 --- a/packages/api/src/client/types/app/bsky/graph/searchStarterPacks.ts +++ b/packages/api/src/client/types/app/bsky/graph/searchStarterPacks.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Search query string. Syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended. */ @@ -20,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 7cb0aa26c3f..66abf07fd50 100644 --- a/packages/api/src/client/types/app/bsky/graph/starterpack.ts +++ b/packages/api/src/client/types/app/bsky/graph/starterpack.ts @@ -2,12 +2,21 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 @@ -19,32 +28,35 @@ export interface Record { [k: string]: unknown } -export function isRecord(v: unknown): v is Record { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.graph.starterpack#main' || - v.$type === 'app.bsky.graph.starterpack') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.graph.starterpack#main', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.graph.starterpack#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): ValidationResult { - return lexicons.validate('app.bsky.graph.starterpack#feedItem', v) +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 c21c00b2069..548a2ad0cf1 100644 --- a/packages/api/src/client/types/app/bsky/graph/unmuteActor.ts +++ b/packages/api/src/client/types/app/bsky/graph/unmuteActor.ts @@ -3,15 +3,22 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 8a0e8586deb..1be31921fd9 100644 --- a/packages/api/src/client/types/app/bsky/graph/unmuteActorList.ts +++ b/packages/api/src/client/types/app/bsky/graph/unmuteActorList.ts @@ -3,15 +3,22 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 275ba7a0f22..657c17c949a 100644 --- a/packages/api/src/client/types/app/bsky/graph/unmuteThread.ts +++ b/packages/api/src/client/types/app/bsky/graph/unmuteThread.ts @@ -3,15 +3,22 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 3d9b1d77f8a..e0f2f945b4e 100644 --- a/packages/api/src/client/types/app/bsky/labeler/defs.ts +++ b/packages/api/src/client/types/app/bsky/labeler/defs.ts @@ -2,13 +2,22 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 @@ -16,22 +25,24 @@ export interface LabelerView { viewer?: LabelerViewerState indexedAt: string labels?: ComAtprotoLabelDefs.Label[] - [k: string]: unknown } -export function isLabelerView(v: unknown): v is LabelerView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.labeler.defs#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): ValidationResult { - return lexicons.validate('app.bsky.labeler.defs#labelerView', v) +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 @@ -40,54 +51,59 @@ export interface LabelerViewDetailed { viewer?: LabelerViewerState indexedAt: string labels?: ComAtprotoLabelDefs.Label[] - [k: string]: unknown } -export function isLabelerViewDetailed(v: unknown): v is LabelerViewDetailed { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.labeler.defs#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): ValidationResult { - return lexicons.validate('app.bsky.labeler.defs#labelerViewDetailed', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.labeler.defs#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): ValidationResult { - return lexicons.validate('app.bsky.labeler.defs#labelerViewerState', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.labeler.defs#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): ValidationResult { - return lexicons.validate('app.bsky.labeler.defs#labelerPolicies', v) +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 688f847d508..07a694b8b9c 100644 --- a/packages/api/src/client/types/app/bsky/labeler/getServices.ts +++ b/packages/api/src/client/types/app/bsky/labeler/getServices.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { dids: string[] @@ -17,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 818249468ec..5973c2fd285 100644 --- a/packages/api/src/client/types/app/bsky/labeler/service.ts +++ b/packages/api/src/client/types/app/bsky/labeler/service.ts @@ -2,30 +2,38 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.labeler.service#main' || - v.$type === 'app.bsky.labeler.service') - ) +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): ValidationResult { - return lexicons.validate('app.bsky.labeler.service#main', v) +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 00600ea54e7..2684ce1b6bf 100644 --- a/packages/api/src/client/types/app/bsky/notification/getUnreadCount.ts +++ b/packages/api/src/client/types/app/bsky/notification/getUnreadCount.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 { priority?: boolean @@ -16,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 92b3a27fece..ffd554e9af0 100644 --- a/packages/api/src/client/types/app/bsky/notification/listNotifications.ts +++ b/packages/api/src/client/types/app/bsky/notification/listNotifications.ts @@ -3,11 +3,19 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Notification reasons to include in response. */ @@ -25,7 +33,6 @@ export interface OutputSchema { notifications: Notification[] priority?: boolean seenAt?: string - [k: string]: unknown } export interface CallOptions { @@ -44,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 @@ -58,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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.notification.listNotifications#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): ValidationResult { - return lexicons.validate( - 'app.bsky.notification.listNotifications#notification', - v, - ) +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 bc79909f459..b1a0ec01752 100644 --- a/packages/api/src/client/types/app/bsky/notification/putPreferences.ts +++ b/packages/api/src/client/types/app/bsky/notification/putPreferences.ts @@ -3,15 +3,22 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 ddc9d438537..a3091791f85 100644 --- a/packages/api/src/client/types/app/bsky/notification/registerPush.ts +++ b/packages/api/src/client/types/app/bsky/notification/registerPush.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} @@ -14,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 7151e9b0cd4..6085286804a 100644 --- a/packages/api/src/client/types/app/bsky/notification/updateSeen.ts +++ b/packages/api/src/client/types/app/bsky/notification/updateSeen.ts @@ -3,15 +3,22 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 836136b7dac..a73bef3f85a 100644 --- a/packages/api/src/client/types/app/bsky/richtext/facet.ts +++ b/packages/api/src/client/types/app/bsky/richtext/facet.ts @@ -2,97 +2,116 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'app.bsky.richtext.facet#main' || - v.$type === 'app.bsky.richtext.facet') - ) +export function validateMain(v: V) { + return validate
(v, id, hashMain) } -export function validateMain(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.richtext.facet#main', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.richtext.facet#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): ValidationResult { - return lexicons.validate('app.bsky.richtext.facet#mention', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.richtext.facet#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): ValidationResult { - return lexicons.validate('app.bsky.richtext.facet#link', v) +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 { - return ( - isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.richtext.facet#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): ValidationResult { - return lexicons.validate('app.bsky.richtext.facet#tag', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.richtext.facet#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): ValidationResult { - return lexicons.validate('app.bsky.richtext.facet#byteSlice', v) +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 81f821ecf73..a4286c5222e 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/defs.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/defs.ts @@ -2,84 +2,101 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.unspecced.defs#skeletonSearchPost' - ) +const hashSkeletonSearchPost = 'skeletonSearchPost' + +export function isSkeletonSearchPost(v: V) { + return is$typed(v, id, hashSkeletonSearchPost) +} + +export function validateSkeletonSearchPost(v: V) { + return validate(v, id, hashSkeletonSearchPost) } -export function validateSkeletonSearchPost(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.unspecced.defs#skeletonSearchPost', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.unspecced.defs#skeletonSearchActor' - ) +const hashSkeletonSearchActor = 'skeletonSearchActor' + +export function isSkeletonSearchActor(v: V) { + return is$typed(v, id, hashSkeletonSearchActor) +} + +export function validateSkeletonSearchActor(v: V) { + return validate(v, id, hashSkeletonSearchActor) } -export function validateSkeletonSearchActor(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.unspecced.defs#skeletonSearchActor', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.unspecced.defs#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, -): ValidationResult { - return lexicons.validate( - 'app.bsky.unspecced.defs#skeletonSearchStarterPack', +export function isValidSkeletonSearchStarterPack(v: V) { + return isValid( v, + 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.unspecced.defs#trendingTopic' - ) +const hashTrendingTopic = 'trendingTopic' + +export function isTrendingTopic(v: V) { + return is$typed(v, id, hashTrendingTopic) +} + +export function validateTrendingTopic(v: V) { + return validate(v, id, hashTrendingTopic) } -export function validateTrendingTopic(v: unknown): ValidationResult { - return lexicons.validate('app.bsky.unspecced.defs#trendingTopic', v) +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 d1ee6f7957d..fa9c268fe8a 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getConfig.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getConfig.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} @@ -13,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 780b4b6641c..9435afd636f 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getPopularFeedGenerators.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getPopularFeedGenerators.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { limit?: number @@ -19,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 6ed519ef212..c503ad22335 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getSuggestionsSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getSuggestionsSkeleton.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** DID of the account making the request (not included for public/unauthenticated queries). Used to boost followed accounts in ranking. */ @@ -24,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 0ee04b8e85d..91baf4c1c5f 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getTaggedSuggestions.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getTaggedSuggestions.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} @@ -13,7 +21,6 @@ export type InputSchema = undefined export interface OutputSchema { suggestions: Suggestion[] - [k: string]: unknown } export interface CallOptions { @@ -32,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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.unspecced.getTaggedSuggestions#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): ValidationResult { - return lexicons.validate( - 'app.bsky.unspecced.getTaggedSuggestions#suggestion', - v, - ) +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 70e790e14ba..369d41b2b35 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/getTrendingTopics.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/getTrendingTopics.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** DID of the account making the request (not included for public/unauthenticated queries). Used to boost followed accounts in ranking. */ @@ -19,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 d9fe6737d37..0f501c2abf5 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/searchActorsSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/searchActorsSkeleton.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended. For typeahead search, only simple term match is supported, not full syntax. */ @@ -27,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 ea0135dde83..22b9501bdbb 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/searchPostsSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/searchPostsSkeleton.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended. */ @@ -43,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 c331b86d3e1..d1b38953cc8 100644 --- a/packages/api/src/client/types/app/bsky/unspecced/searchStarterPacksSkeleton.ts +++ b/packages/api/src/client/types/app/bsky/unspecced/searchStarterPacksSkeleton.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended. */ @@ -25,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 a7ec84316b6..93ed16829ca 100644 --- a/packages/api/src/client/types/app/bsky/video/defs.ts +++ b/packages/api/src/client/types/app/bsky/video/defs.ts @@ -2,11 +2,20 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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. */ @@ -16,17 +25,18 @@ export interface JobStatus { blob?: BlobRef error?: string message?: string - [k: string]: unknown } -export function isJobStatus(v: unknown): v is JobStatus { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'app.bsky.video.defs#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): ValidationResult { - return lexicons.validate('app.bsky.video.defs#jobStatus', v) +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 0e9638311c0..987c9b5544d 100644 --- a/packages/api/src/client/types/app/bsky/video/getJobStatus.ts +++ b/packages/api/src/client/types/app/bsky/video/getJobStatus.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { jobId: string @@ -16,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 4a2f13617b3..a79b6be3bcc 100644 --- a/packages/api/src/client/types/app/bsky/video/getUploadLimits.ts +++ b/packages/api/src/client/types/app/bsky/video/getUploadLimits.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} @@ -17,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 f51ba897bbe..118be71e31d 100644 --- a/packages/api/src/client/types/app/bsky/video/uploadVideo.ts +++ b/packages/api/src/client/types/app/bsky/video/uploadVideo.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 {} @@ -14,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 99b14f45608..745d97fc50a 100644 --- a/packages/api/src/client/types/chat/bsky/actor/declaration.ts +++ b/packages/api/src/client/types/chat/bsky/actor/declaration.ts @@ -2,24 +2,34 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - (v.$type === 'chat.bsky.actor.declaration#main' || - v.$type === 'chat.bsky.actor.declaration') - ) +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): ValidationResult { - return lexicons.validate('chat.bsky.actor.declaration#main', v) +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 87aaac96218..0a12bbedea1 100644 --- a/packages/api/src/client/types/chat/bsky/actor/defs.ts +++ b/packages/api/src/client/types/chat/bsky/actor/defs.ts @@ -2,13 +2,22 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 @@ -18,17 +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.actor.defs#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): ValidationResult { - return lexicons.validate('chat.bsky.actor.defs#profileViewBasic', v) +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 1a045c21c29..bc0a05dc4b3 100644 --- a/packages/api/src/client/types/chat/bsky/actor/deleteAccount.ts +++ b/packages/api/src/client/types/chat/bsky/actor/deleteAccount.ts @@ -3,17 +3,23 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 0142436b05e..21d6f936432 100644 --- a/packages/api/src/client/types/chat/bsky/actor/exportAccountData.ts +++ b/packages/api/src/client/types/chat/bsky/actor/exportAccountData.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 4908b2dc46a..1b1a357aabc 100644 --- a/packages/api/src/client/types/chat/bsky/convo/defs.ts +++ b/packages/api/src/client/types/chat/bsky/convo/defs.ts @@ -2,215 +2,237 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#messageRef' - ) +const hashMessageRef = 'messageRef' + +export function isMessageRef(v: V) { + return is$typed(v, id, hashMessageRef) +} + +export function validateMessageRef(v: V) { + return validate(v, id, hashMessageRef) } -export function validateMessageRef(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#messageRef', v) +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 } +} + +const hashMessageInput = 'messageInput' + +export function isMessageInput(v: V) { + return is$typed(v, id, hashMessageInput) } -export function isMessageInput(v: unknown): v is MessageInput { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#messageInput' - ) +export function validateMessageInput(v: V) { + return validate(v, id, hashMessageInput) } -export function validateMessageInput(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#messageInput', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#messageView' - ) +const hashMessageView = 'messageView' + +export function isMessageView(v: V) { + return is$typed(v, id, hashMessageView) } -export function validateMessageView(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#messageView', v) +export function validateMessageView(v: V) { + return validate(v, id, hashMessageView) +} + +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#deletedMessageView' - ) +const hashDeletedMessageView = 'deletedMessageView' + +export function isDeletedMessageView(v: V) { + return is$typed(v, id, hashDeletedMessageView) +} + +export function validateDeletedMessageView(v: V) { + return validate(v, id, hashDeletedMessageView) } -export function validateDeletedMessageView(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#deletedMessageView', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#messageViewSender' - ) +const hashMessageViewSender = 'messageViewSender' + +export function isMessageViewSender(v: V) { + return is$typed(v, id, hashMessageViewSender) +} + +export function validateMessageViewSender(v: V) { + return validate(v, id, hashMessageViewSender) } -export function validateMessageViewSender(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#messageViewSender', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#convoView' - ) +const hashConvoView = 'convoView' + +export function isConvoView(v: V) { + return is$typed(v, id, hashConvoView) +} + +export function validateConvoView(v: V) { + return validate(v, id, hashConvoView) } -export function validateConvoView(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#convoView', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#logBeginConvo' - ) +const hashLogBeginConvo = 'logBeginConvo' + +export function isLogBeginConvo(v: V) { + return is$typed(v, id, hashLogBeginConvo) +} + +export function validateLogBeginConvo(v: V) { + return validate(v, id, hashLogBeginConvo) } -export function validateLogBeginConvo(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#logBeginConvo', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#logLeaveConvo' - ) +const hashLogLeaveConvo = 'logLeaveConvo' + +export function isLogLeaveConvo(v: V) { + return is$typed(v, id, hashLogLeaveConvo) } -export function validateLogLeaveConvo(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#logLeaveConvo', v) +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 } +} + +const hashLogCreateMessage = 'logCreateMessage' + +export function isLogCreateMessage(v: V) { + return is$typed(v, id, hashLogCreateMessage) } -export function isLogCreateMessage(v: unknown): v is LogCreateMessage { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#logCreateMessage' - ) +export function validateLogCreateMessage(v: V) { + return validate(v, id, hashLogCreateMessage) } -export function validateLogCreateMessage(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#logCreateMessage', v) +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 + message: $Typed | $Typed | { $type: string } +} + +const hashLogDeleteMessage = 'logDeleteMessage' + +export function isLogDeleteMessage(v: V) { + return is$typed(v, id, hashLogDeleteMessage) } -export function isLogDeleteMessage(v: unknown): v is LogDeleteMessage { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.defs#logDeleteMessage' - ) +export function validateLogDeleteMessage(v: V) { + return validate(v, id, hashLogDeleteMessage) } -export function validateLogDeleteMessage(v: unknown): ValidationResult { - return lexicons.validate('chat.bsky.convo.defs#logDeleteMessage', v) +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 863d2208cb8..c5bcf1c1e96 100644 --- a/packages/api/src/client/types/chat/bsky/convo/deleteMessageForSelf.ts +++ b/packages/api/src/client/types/chat/bsky/convo/deleteMessageForSelf.ts @@ -3,17 +3,24 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 {} 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 b3834234b5f..99c309bdb93 100644 --- a/packages/api/src/client/types/chat/bsky/convo/getConvo.ts +++ b/packages/api/src/client/types/chat/bsky/convo/getConvo.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { convoId: string @@ -16,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 9db44887410..ecc1f026651 100644 --- a/packages/api/src/client/types/chat/bsky/convo/getConvoForMembers.ts +++ b/packages/api/src/client/types/chat/bsky/convo/getConvoForMembers.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { members: string[] @@ -16,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 f1470fd89ba..ce8801ddf1d 100644 --- a/packages/api/src/client/types/chat/bsky/convo/getLog.ts +++ b/packages/api/src/client/types/chat/bsky/convo/getLog.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { cursor?: string @@ -17,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 eea7cba82e1..dfa319e6338 100644 --- a/packages/api/src/client/types/chat/bsky/convo/getMessages.ts +++ b/packages/api/src/client/types/chat/bsky/convo/getMessages.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { convoId: string @@ -19,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 4124db1855d..c43b59daa29 100644 --- a/packages/api/src/client/types/chat/bsky/convo/leaveConvo.ts +++ b/packages/api/src/client/types/chat/bsky/convo/leaveConvo.ts @@ -3,21 +3,27 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 3cd1ad68516..fd9f8250386 100644 --- a/packages/api/src/client/types/chat/bsky/convo/listConvos.ts +++ b/packages/api/src/client/types/chat/bsky/convo/listConvos.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { limit?: number @@ -18,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 93ac8785db7..514f1c56145 100644 --- a/packages/api/src/client/types/chat/bsky/convo/muteConvo.ts +++ b/packages/api/src/client/types/chat/bsky/convo/muteConvo.ts @@ -3,21 +3,27 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 e260ba6eee0..7422ea58fef 100644 --- a/packages/api/src/client/types/chat/bsky/convo/sendMessage.ts +++ b/packages/api/src/client/types/chat/bsky/convo/sendMessage.ts @@ -3,17 +3,24 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 {} 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 68ff2711df5..6f8759347ee 100644 --- a/packages/api/src/client/types/chat/bsky/convo/sendMessageBatch.ts +++ b/packages/api/src/client/types/chat/bsky/convo/sendMessageBatch.ts @@ -3,21 +3,27 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { @@ -38,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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.convo.sendMessageBatch#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): ValidationResult { - return lexicons.validate('chat.bsky.convo.sendMessageBatch#batchItem', v) +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 93ac8785db7..d959a497457 100644 --- a/packages/api/src/client/types/chat/bsky/convo/unmuteConvo.ts +++ b/packages/api/src/client/types/chat/bsky/convo/unmuteConvo.ts @@ -3,21 +3,27 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 b7a8041dbd7..1cb1f99841f 100644 --- a/packages/api/src/client/types/chat/bsky/convo/updateRead.ts +++ b/packages/api/src/client/types/chat/bsky/convo/updateRead.ts @@ -3,22 +3,28 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 {} 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 6761c9939b5..f94ae2d7e1d 100644 --- a/packages/api/src/client/types/chat/bsky/moderation/getActorMetadata.ts +++ b/packages/api/src/client/types/chat/bsky/moderation/getActorMetadata.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 { actor: string @@ -17,7 +25,6 @@ export interface OutputSchema { day: Metadata month: Metadata all: Metadata - [k: string]: unknown } export interface CallOptions { @@ -36,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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'chat.bsky.moderation.getActorMetadata#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): ValidationResult { - return lexicons.validate('chat.bsky.moderation.getActorMetadata#metadata', v) +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 2315bfd4ad8..a919014ea1c 100644 --- a/packages/api/src/client/types/chat/bsky/moderation/getMessageContext.ts +++ b/packages/api/src/client/types/chat/bsky/moderation/getMessageContext.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { /** Conversation that the message is from. NOTE: this field will eventually be required. */ @@ -20,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 d6f0205672e..19b121fe761 100644 --- a/packages/api/src/client/types/chat/bsky/moderation/updateActorAccess.ts +++ b/packages/api/src/client/types/chat/bsky/moderation/updateActorAccess.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} @@ -13,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 26510680347..83f247d978c 100644 --- a/packages/api/src/client/types/com/atproto/admin/defs.ts +++ b/packages/api/src/client/types/com/atproto/admin/defs.ts @@ -2,34 +2,45 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'com.atproto.admin.defs#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): ValidationResult { - return lexicons.validate('com.atproto.admin.defs#statusAttr', v) +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[] @@ -38,71 +49,78 @@ export interface AccountView { inviteNote?: string deactivatedAt?: string threatSignatures?: ThreatSignature[] - [k: string]: unknown } -export function isAccountView(v: unknown): v is AccountView { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'com.atproto.admin.defs#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): ValidationResult { - return lexicons.validate('com.atproto.admin.defs#accountView', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'com.atproto.admin.defs#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): ValidationResult { - return lexicons.validate('com.atproto.admin.defs#repoRef', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'com.atproto.admin.defs#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): ValidationResult { - return lexicons.validate('com.atproto.admin.defs#repoBlobRef', v) +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'com.atproto.admin.defs#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): ValidationResult { - return lexicons.validate('com.atproto.admin.defs#threatSignature', v) +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 72066a656b7..807b7cd9f3f 100644 --- a/packages/api/src/client/types/com/atproto/admin/deleteAccount.ts +++ b/packages/api/src/client/types/com/atproto/admin/deleteAccount.ts @@ -3,15 +3,22 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 8df420239de..b5737b5fcc0 100644 --- a/packages/api/src/client/types/com/atproto/admin/disableAccountInvites.ts +++ b/packages/api/src/client/types/com/atproto/admin/disableAccountInvites.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} @@ -13,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 c264b65dbc2..110c252da7b 100644 --- a/packages/api/src/client/types/com/atproto/admin/disableInviteCodes.ts +++ b/packages/api/src/client/types/com/atproto/admin/disableInviteCodes.ts @@ -3,16 +3,23 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} 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 094b3dfe0af..10bb24f7e63 100644 --- a/packages/api/src/client/types/com/atproto/admin/enableAccountInvites.ts +++ b/packages/api/src/client/types/com/atproto/admin/enableAccountInvites.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} @@ -13,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 645b9e613ff..d486b45e6be 100644 --- a/packages/api/src/client/types/com/atproto/admin/getAccountInfo.ts +++ b/packages/api/src/client/types/com/atproto/admin/getAccountInfo.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { did: string diff --git a/packages/api/src/client/types/com/atproto/admin/getAccountInfos.ts b/packages/api/src/client/types/com/atproto/admin/getAccountInfos.ts index 9c1c273b9d9..38d4792c59e 100644 --- a/packages/api/src/client/types/com/atproto/admin/getAccountInfos.ts +++ b/packages/api/src/client/types/com/atproto/admin/getAccountInfos.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { dids: string[] @@ -16,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 faa4c8bed25..cb6bded3d9d 100644 --- a/packages/api/src/client/types/com/atproto/admin/getInviteCodes.ts +++ b/packages/api/src/client/types/com/atproto/admin/getInviteCodes.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { sort?: 'recent' | 'usage' | (string & {}) @@ -19,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 f11b514507d..58263489656 100644 --- a/packages/api/src/client/types/com/atproto/admin/getSubjectStatus.ts +++ b/packages/api/src/client/types/com/atproto/admin/getSubjectStatus.ts @@ -3,11 +3,19 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { did?: string @@ -19,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 2d22806238c..0e9c1612eea 100644 --- a/packages/api/src/client/types/com/atproto/admin/searchAccounts.ts +++ b/packages/api/src/client/types/com/atproto/admin/searchAccounts.ts @@ -3,10 +3,18 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 { email?: string @@ -19,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 3f7c06d7070..f591655a596 100644 --- a/packages/api/src/client/types/com/atproto/admin/sendEmail.ts +++ b/packages/api/src/client/types/com/atproto/admin/sendEmail.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} @@ -16,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 d13878711a6..e8ca06d32fb 100644 --- a/packages/api/src/client/types/com/atproto/admin/updateAccountEmail.ts +++ b/packages/api/src/client/types/com/atproto/admin/updateAccountEmail.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} @@ -13,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 38fbcae1681..1c154cc2852 100644 --- a/packages/api/src/client/types/com/atproto/admin/updateAccountHandle.ts +++ b/packages/api/src/client/types/com/atproto/admin/updateAccountHandle.ts @@ -3,16 +3,23 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} 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 412f0facca2..1f2068d5024 100644 --- a/packages/api/src/client/types/com/atproto/admin/updateAccountPassword.ts +++ b/packages/api/src/client/types/com/atproto/admin/updateAccountPassword.ts @@ -3,16 +3,23 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} 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 d890993cf3a..45c6ad7a4d3 100644 --- a/packages/api/src/client/types/com/atproto/admin/updateSubjectStatus.ts +++ b/packages/api/src/client/types/com/atproto/admin/updateSubjectStatus.ts @@ -3,33 +3,39 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -import * 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 a5e4a0296de..e556ed41061 100644 --- a/packages/api/src/client/types/com/atproto/identity/getRecommendedDidCredentials.ts +++ b/packages/api/src/client/types/com/atproto/identity/getRecommendedDidCredentials.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} @@ -15,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 dcab71e2558..d454c5c4583 100644 --- a/packages/api/src/client/types/com/atproto/identity/requestPlcOperationSignature.ts +++ b/packages/api/src/client/types/com/atproto/identity/requestPlcOperationSignature.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 32db72138f7..3c8518e6251 100644 --- a/packages/api/src/client/types/com/atproto/identity/resolveHandle.ts +++ b/packages/api/src/client/types/com/atproto/identity/resolveHandle.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 { /** The handle to resolve. */ @@ -16,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 88c04c5993c..b343fe63c16 100644 --- a/packages/api/src/client/types/com/atproto/identity/signPlcOperation.ts +++ b/packages/api/src/client/types/com/atproto/identity/signPlcOperation.ts @@ -3,9 +3,17 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} @@ -14,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 74dea9f196d..af223b1e4ef 100644 --- a/packages/api/src/client/types/com/atproto/identity/submitPlcOperation.ts +++ b/packages/api/src/client/types/com/atproto/identity/submitPlcOperation.ts @@ -3,15 +3,22 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 c01d4887a4a..92e98805b1f 100644 --- a/packages/api/src/client/types/com/atproto/identity/updateHandle.ts +++ b/packages/api/src/client/types/com/atproto/identity/updateHandle.ts @@ -3,16 +3,23 @@ */ import { HeadersMap, XRPCError } from '@atproto/xrpc' import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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 {} 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 131682e550c..07a0a5293cd 100644 --- a/packages/api/src/client/types/com/atproto/label/defs.ts +++ b/packages/api/src/client/types/com/atproto/label/defs.ts @@ -2,12 +2,21 @@ * GENERATED CODE - DO NOT MODIFY */ import { ValidationResult, BlobRef } from '@atproto/lexicon' -import { isObj, hasProp } from '../../../../util' -import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' +import { + 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. */ @@ -26,60 +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 { - return ( - isObj(v) && - hasProp(v, '$type') && - v.$type === 'com.atproto.label.defs#label' - ) +const hashLabel = 'label' + +export function isLabel(v: V) { + return is$typed(v, id, hashLabel) } -export function validateLabel(v: unknown): ValidationResult { - return lexicons.validate('com.atproto.label.defs#label', v) +export function validateLabel(v: V) { + return validate