Skip to content

Commit

Permalink
codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieusieben committed Jan 26, 2025
1 parent 02654fc commit cfa432c
Show file tree
Hide file tree
Showing 885 changed files with 13,103 additions and 11,628 deletions.
234 changes: 120 additions & 114 deletions packages/api/src/client/index.ts

Large diffs are not rendered by default.

41 changes: 38 additions & 3 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down Expand Up @@ -13788,8 +13794,37 @@ export const schemaDict = {
},
} as const satisfies Record<string, LexiconDoc>

export const schemas = Object.values(schemaDict)
export const schemas = Object.values(schemaDict) satisfies LexiconDoc[]
export const lexicons: Lexicons = new Lexicons(schemas)

export function validate<T extends { $type: string }>(
v: unknown,
id: string,
hash: string,
requiredType: true,
): ValidationResult<T>
export function validate<T extends { $type?: string }>(
v: unknown,
id: string,
hash: string,
requiredType?: false,
): ValidationResult<T>
export function validate(
v: unknown,
id: string,
hash: string,
requiredType?: boolean,
): ValidationResult {
return (requiredType ? is$typed : maybe$typed)(v, id, hash)
? lexicons.validate(`${id}#${hash}`, v)
: {
success: false,
error: new ValidationError(
`Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`,
),
}
}

export const ids = {
ComAtprotoAdminDefs: 'com.atproto.admin.defs',
ComAtprotoAdminDeleteAccount: 'com.atproto.admin.deleteAccount',
Expand Down Expand Up @@ -14041,4 +14076,4 @@ export const ids = {
ToolsOzoneTeamDeleteMember: 'tools.ozone.team.deleteMember',
ToolsOzoneTeamListMembers: 'tools.ozone.team.listMembers',
ToolsOzoneTeamUpdateMember: 'tools.ozone.team.updateMember',
}
} as const
Loading

0 comments on commit cfa432c

Please sign in to comment.