Skip to content

Commit

Permalink
codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieusieben committed Dec 18, 2024
1 parent f2d5329 commit ba0dfe5
Show file tree
Hide file tree
Showing 881 changed files with 17,658 additions and 11,192 deletions.
190 changes: 98 additions & 92 deletions packages/api/src/client/index.ts

Large diffs are not rendered by default.

48 changes: 46 additions & 2 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 @@ -13575,6 +13581,44 @@ export const schemaDict = {

export const schemas = Object.values(schemaDict)
export const lexicons: Lexicons = new Lexicons(schemas)

export function validate<V>(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<V>
}

export function isValid<V extends { $type?: string }>(
v: unknown,
id: string,
hash: string,
requiredType: true,
): v is $Typed<V>
export function isValid<V extends { $type?: string }>(
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',
Expand Down Expand Up @@ -13825,4 +13869,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 ba0dfe5

Please sign in to comment.