Skip to content

Commit

Permalink
codegen lex and buf
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelbsky committed Dec 9, 2024
1 parent 78b6690 commit 742277a
Show file tree
Hide file tree
Showing 30 changed files with 3,111 additions and 10 deletions.
66 changes: 66 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ import * as AppBskyNotificationListNotifications from './types/app/bsky/notifica
import * as AppBskyNotificationPutPreferences from './types/app/bsky/notification/putPreferences'
import * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/registerPush'
import * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
import * as AppBskyPurchaseGetFeatures from './types/app/bsky/purchase/getFeatures'
import * as AppBskyPurchaseGetSubscriptionGroup from './types/app/bsky/purchase/getSubscriptionGroup'
import * as AppBskyPurchaseGetSubscriptions from './types/app/bsky/purchase/getSubscriptions'
import * as AppBskyPurchaseRefreshCache from './types/app/bsky/purchase/refreshCache'
import * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet'
import * as AppBskyUnspeccedDefs from './types/app/bsky/unspecced/defs'
import * as AppBskyUnspeccedGetConfig from './types/app/bsky/unspecced/getConfig'
Expand Down Expand Up @@ -388,6 +392,10 @@ export * as AppBskyNotificationListNotifications from './types/app/bsky/notifica
export * as AppBskyNotificationPutPreferences from './types/app/bsky/notification/putPreferences'
export * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/registerPush'
export * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
export * as AppBskyPurchaseGetFeatures from './types/app/bsky/purchase/getFeatures'
export * as AppBskyPurchaseGetSubscriptionGroup from './types/app/bsky/purchase/getSubscriptionGroup'
export * as AppBskyPurchaseGetSubscriptions from './types/app/bsky/purchase/getSubscriptions'
export * as AppBskyPurchaseRefreshCache from './types/app/bsky/purchase/refreshCache'
export * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet'
export * as AppBskyUnspeccedDefs from './types/app/bsky/unspecced/defs'
export * as AppBskyUnspeccedGetConfig from './types/app/bsky/unspecced/getConfig'
Expand Down Expand Up @@ -1486,6 +1494,7 @@ export class AppBskyNS {
graph: AppBskyGraphNS
labeler: AppBskyLabelerNS
notification: AppBskyNotificationNS
purchase: AppBskyPurchaseNS
richtext: AppBskyRichtextNS
unspecced: AppBskyUnspeccedNS
video: AppBskyVideoNS
Expand All @@ -1498,6 +1507,7 @@ export class AppBskyNS {
this.graph = new AppBskyGraphNS(client)
this.labeler = new AppBskyLabelerNS(client)
this.notification = new AppBskyNotificationNS(client)
this.purchase = new AppBskyPurchaseNS(client)
this.richtext = new AppBskyRichtextNS(client)
this.unspecced = new AppBskyUnspeccedNS(client)
this.video = new AppBskyVideoNS(client)
Expand Down Expand Up @@ -3026,6 +3036,62 @@ export class AppBskyNotificationNS {
}
}

export class AppBskyPurchaseNS {
_client: XrpcClient

constructor(client: XrpcClient) {
this._client = client
}

getFeatures(
params?: AppBskyPurchaseGetFeatures.QueryParams,
opts?: AppBskyPurchaseGetFeatures.CallOptions,
): Promise<AppBskyPurchaseGetFeatures.Response> {
return this._client.call(
'app.bsky.purchase.getFeatures',
params,
undefined,
opts,
)
}

getSubscriptionGroup(
params?: AppBskyPurchaseGetSubscriptionGroup.QueryParams,
opts?: AppBskyPurchaseGetSubscriptionGroup.CallOptions,
): Promise<AppBskyPurchaseGetSubscriptionGroup.Response> {
return this._client.call(
'app.bsky.purchase.getSubscriptionGroup',
params,
undefined,
opts,
)
}

getSubscriptions(
params?: AppBskyPurchaseGetSubscriptions.QueryParams,
opts?: AppBskyPurchaseGetSubscriptions.CallOptions,
): Promise<AppBskyPurchaseGetSubscriptions.Response> {
return this._client.call(
'app.bsky.purchase.getSubscriptions',
params,
undefined,
opts,
)
}

refreshCache(
data?: AppBskyPurchaseRefreshCache.InputSchema,
opts?: AppBskyPurchaseRefreshCache.CallOptions,
): Promise<AppBskyPurchaseRefreshCache.Response> {
return this._client.call(
'app.bsky.purchase.refreshCache',
opts?.qp,
data,
opts,
)
}
}

export class AppBskyRichtextNS {
_client: XrpcClient

Expand Down
195 changes: 193 additions & 2 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9133,6 +9133,192 @@ export const schemaDict = {
},
},
},
AppBskyPurchaseGetFeatures: {
lexicon: 1,
id: 'app.bsky.purchase.getFeatures',
defs: {
main: {
type: 'query',
description:
'Enumerate unlocked paid feature flags for the requesting account. Requires auth.',
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['features'],
properties: {
features: {
type: 'ref',
ref: 'lex:app.bsky.purchase.getFeatures#features',
},
},
},
},
},
features: {
type: 'object',
required: [],
properties: {
customProfileColor: {
type: 'boolean',
description:
'Indicates to client apps to allow the requesting account to customize the profile color.',
},
},
},
},
},
AppBskyPurchaseGetSubscriptionGroup: {
lexicon: 1,
id: 'app.bsky.purchase.getSubscriptionGroup',
defs: {
main: {
type: 'query',
description:
'Gets a subscription group and its offerings for the target platform. Requires auth.',
parameters: {
type: 'params',
required: ['group', 'platform'],
properties: {
group: {
type: 'string',
},
platform: {
type: 'string',
},
},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: [],
properties: {
group: {
type: 'string',
},
offerings: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:app.bsky.purchase.getSubscriptionGroup#offering',
},
},
},
},
},
},
offering: {
type: 'object',
required: [],
properties: {
id: {
type: 'string',
},
platform: {
type: 'string',
},
product: {
type: 'string',
},
},
},
},
},
AppBskyPurchaseGetSubscriptions: {
lexicon: 1,
id: 'app.bsky.purchase.getSubscriptions',
defs: {
main: {
type: 'query',
description:
'Enumerate subscriptions for the requesting account, and the email used in the purchase. Requires auth.',
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['subscriptions'],
properties: {
email: {
type: 'string',
},
subscriptions: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:app.bsky.purchase.getSubscriptions#subscription',
},
},
},
},
},
},
subscription: {
type: 'object',
required: [],
properties: {
status: {
type: 'string',
},
renewalStatus: {
type: 'string',
},
group: {
type: 'string',
},
platform: {
type: 'string',
},
offering: {
type: 'string',
},
periodEndsAt: {
type: 'string',
format: 'datetime',
},
periodStartsAt: {
type: 'string',
format: 'datetime',
},
purchasedAt: {
type: 'string',
format: 'datetime',
},
},
},
},
},
AppBskyPurchaseRefreshCache: {
lexicon: 1,
id: 'app.bsky.purchase.refreshCache',
defs: {
main: {
type: 'procedure',
description:
'Refresh the purchase cache for the requesting account or for another account if the role authorizes it. Requires auth.',
input: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['did'],
properties: {
did: {
type: 'string',
format: 'did',
},
},
},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
properties: {},
},
},
},
},
},
AppBskyRichtextFacet: {
lexicon: 1,
id: 'app.bsky.richtext.facet',
Expand Down Expand Up @@ -13489,8 +13675,9 @@ export const schemaDict = {
},
},
},
}
export const schemas: LexiconDoc[] = Object.values(schemaDict) as LexiconDoc[]
} as const satisfies Record<string, LexiconDoc>

export const schemas = Object.values(schemaDict)
export const lexicons: Lexicons = new Lexicons(schemas)
export const ids = {
ComAtprotoAdminDefs: 'com.atproto.admin.defs',
Expand Down Expand Up @@ -13662,6 +13849,10 @@ export const ids = {
AppBskyNotificationPutPreferences: 'app.bsky.notification.putPreferences',
AppBskyNotificationRegisterPush: 'app.bsky.notification.registerPush',
AppBskyNotificationUpdateSeen: 'app.bsky.notification.updateSeen',
AppBskyPurchaseGetFeatures: 'app.bsky.purchase.getFeatures',
AppBskyPurchaseGetSubscriptionGroup: 'app.bsky.purchase.getSubscriptionGroup',
AppBskyPurchaseGetSubscriptions: 'app.bsky.purchase.getSubscriptions',
AppBskyPurchaseRefreshCache: 'app.bsky.purchase.refreshCache',
AppBskyRichtextFacet: 'app.bsky.richtext.facet',
AppBskyUnspeccedDefs: 'app.bsky.unspecced.defs',
AppBskyUnspeccedGetConfig: 'app.bsky.unspecced.getConfig',
Expand Down
50 changes: 50 additions & 0 deletions packages/api/src/client/types/app/bsky/purchase/getFeatures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* GENERATED CODE - DO NOT MODIFY
*/
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'

export interface QueryParams {}

export type InputSchema = undefined

export interface OutputSchema {
features: Features
[k: string]: unknown
}

export interface CallOptions {
signal?: AbortSignal
headers?: HeadersMap
}

export interface Response {
success: boolean
headers: HeadersMap
data: OutputSchema
}

export function toKnownErr(e: any) {
return e
}

export interface Features {
/** Indicates to client apps to allow the requesting account to customize the profile color. */
customProfileColor?: boolean
[k: string]: unknown
}

export function isFeatures(v: unknown): v is Features {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'app.bsky.purchase.getFeatures#features'
)
}

export function validateFeatures(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.purchase.getFeatures#features', v)
}
Loading

0 comments on commit 742277a

Please sign in to comment.