Skip to content

Commit

Permalink
codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieusieben committed Jan 8, 2025
1 parent 6a801da commit 49690ba
Show file tree
Hide file tree
Showing 881 changed files with 19,527 additions and 11,448 deletions.
190 changes: 98 additions & 92 deletions packages/api/src/client/index.ts

Large diffs are not rendered by default.

50 changes: 47 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 @@ -12359,7 +12365,7 @@ export const schemaDict = {
items: {
type: 'string',
description:
'If specified, only events where the policy matches the given policy are returned',
'If specified, only events where the action policies match any of the given policies are returned',
},
},
cursor: {
Expand Down Expand Up @@ -13614,6 +13620,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 @@ -13864,4 +13908,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 49690ba

Please sign in to comment.