From c00498cb46bd6e65a700f6576557916fd1fc9617 Mon Sep 17 00:00:00 2001 From: rafael Date: Sun, 1 Dec 2024 19:55:37 -0300 Subject: [PATCH] codegen --- packages/api/src/client/index.ts | 14 ++++ packages/api/src/client/lexicons.ts | 71 +++++++++++++++++++ .../subscription/getActiveSubscriptions.ts | 59 +++++++++++++++ packages/bsky/src/lexicon/index.ts | 12 ++++ packages/bsky/src/lexicon/lexicons.ts | 71 +++++++++++++++++++ .../subscription/getActiveSubscriptions.ts | 70 ++++++++++++++++++ packages/ozone/src/lexicon/index.ts | 12 ++++ packages/ozone/src/lexicon/lexicons.ts | 71 +++++++++++++++++++ .../subscription/getActiveSubscriptions.ts | 70 ++++++++++++++++++ packages/pds/src/lexicon/index.ts | 12 ++++ packages/pds/src/lexicon/lexicons.ts | 71 +++++++++++++++++++ .../subscription/getActiveSubscriptions.ts | 70 ++++++++++++++++++ 12 files changed, 603 insertions(+) create mode 100644 packages/api/src/client/types/app/bsky/subscription/getActiveSubscriptions.ts create mode 100644 packages/bsky/src/lexicon/types/app/bsky/subscription/getActiveSubscriptions.ts create mode 100644 packages/ozone/src/lexicon/types/app/bsky/subscription/getActiveSubscriptions.ts create mode 100644 packages/pds/src/lexicon/types/app/bsky/subscription/getActiveSubscriptions.ts diff --git a/packages/api/src/client/index.ts b/packages/api/src/client/index.ts index b76413a21e0..32b55deaf15 100644 --- a/packages/api/src/client/index.ts +++ b/packages/api/src/client/index.ts @@ -162,6 +162,7 @@ import * as AppBskyNotificationPutPreferences from './types/app/bsky/notificatio import * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/registerPush' import * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen' import * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet' +import * as AppBskySubscriptionGetActiveSubscriptions from './types/app/bsky/subscription/getActiveSubscriptions' import * as AppBskySubscriptionGetSubscriptionFeatures from './types/app/bsky/subscription/getSubscriptionFeatures' import * as AppBskySubscriptionRefreshSubscriptionCache from './types/app/bsky/subscription/refreshSubscriptionCache' import * as AppBskyUnspeccedDefs from './types/app/bsky/unspecced/defs' @@ -391,6 +392,7 @@ export * as AppBskyNotificationPutPreferences from './types/app/bsky/notificatio export * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/registerPush' export * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen' export * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet' +export * as AppBskySubscriptionGetActiveSubscriptions from './types/app/bsky/subscription/getActiveSubscriptions' export * as AppBskySubscriptionGetSubscriptionFeatures from './types/app/bsky/subscription/getSubscriptionFeatures' export * as AppBskySubscriptionRefreshSubscriptionCache from './types/app/bsky/subscription/refreshSubscriptionCache' export * as AppBskyUnspeccedDefs from './types/app/bsky/unspecced/defs' @@ -3047,6 +3049,18 @@ export class AppBskySubscriptionNS { this._client = client } + getActiveSubscriptions( + params?: AppBskySubscriptionGetActiveSubscriptions.QueryParams, + opts?: AppBskySubscriptionGetActiveSubscriptions.CallOptions, + ): Promise { + return this._client.call( + 'app.bsky.subscription.getActiveSubscriptions', + params, + undefined, + opts, + ) + } + getSubscriptionFeatures( params?: AppBskySubscriptionGetSubscriptionFeatures.QueryParams, opts?: AppBskySubscriptionGetSubscriptionFeatures.CallOptions, diff --git a/packages/api/src/client/lexicons.ts b/packages/api/src/client/lexicons.ts index 1ec49eb7ef1..255bde678e5 100644 --- a/packages/api/src/client/lexicons.ts +++ b/packages/api/src/client/lexicons.ts @@ -9214,6 +9214,75 @@ export const schemaDict = { }, }, }, + AppBskySubscriptionGetActiveSubscriptions: { + lexicon: 1, + id: 'app.bsky.subscription.getActiveSubscriptions', + defs: { + main: { + type: 'query', + description: + 'Enumerate active subscriptions for the requesting account. Requires auth.', + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['subscriptions'], + properties: { + subscriptions: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:app.bsky.subscription.getActiveSubscriptions#subscription', + }, + }, + }, + }, + }, + }, + subscription: { + type: 'object', + required: [ + 'status', + 'renewalStatus', + 'group', + 'platform', + 'offering', + 'periodEndsAt', + 'periodStartsAt', + 'purchasedAt', + ], + 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', + }, + }, + }, + }, + }, AppBskySubscriptionGetSubscriptionFeatures: { lexicon: 1, id: 'app.bsky.subscription.getSubscriptionFeatures', @@ -13735,6 +13804,8 @@ export const ids = { AppBskyNotificationRegisterPush: 'app.bsky.notification.registerPush', AppBskyNotificationUpdateSeen: 'app.bsky.notification.updateSeen', AppBskyRichtextFacet: 'app.bsky.richtext.facet', + AppBskySubscriptionGetActiveSubscriptions: + 'app.bsky.subscription.getActiveSubscriptions', AppBskySubscriptionGetSubscriptionFeatures: 'app.bsky.subscription.getSubscriptionFeatures', AppBskySubscriptionRefreshSubscriptionCache: diff --git a/packages/api/src/client/types/app/bsky/subscription/getActiveSubscriptions.ts b/packages/api/src/client/types/app/bsky/subscription/getActiveSubscriptions.ts new file mode 100644 index 00000000000..45d08d79b72 --- /dev/null +++ b/packages/api/src/client/types/app/bsky/subscription/getActiveSubscriptions.ts @@ -0,0 +1,59 @@ +/** + * 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 { + subscriptions: Subscription[] + [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 Subscription { + status: string + renewalStatus: string + group: string + platform: string + offering: string + periodEndsAt: string + periodStartsAt: string + purchasedAt: string + [k: string]: unknown +} + +export function isSubscription(v: unknown): v is Subscription { + return ( + isObj(v) && + hasProp(v, '$type') && + v.$type === 'app.bsky.subscription.getActiveSubscriptions#subscription' + ) +} + +export function validateSubscription(v: unknown): ValidationResult { + return lexicons.validate( + 'app.bsky.subscription.getActiveSubscriptions#subscription', + v, + ) +} diff --git a/packages/bsky/src/lexicon/index.ts b/packages/bsky/src/lexicon/index.ts index 9ae5a8a7955..f7b7385af0a 100644 --- a/packages/bsky/src/lexicon/index.ts +++ b/packages/bsky/src/lexicon/index.ts @@ -136,6 +136,7 @@ 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 AppBskySubscriptionGetActiveSubscriptions from './types/app/bsky/subscription/getActiveSubscriptions' import * as AppBskySubscriptionGetSubscriptionFeatures from './types/app/bsky/subscription/getSubscriptionFeatures' import * as AppBskySubscriptionRefreshSubscriptionCache from './types/app/bsky/subscription/refreshSubscriptionCache' import * as AppBskyUnspeccedGetConfig from './types/app/bsky/unspecced/getConfig' @@ -1813,6 +1814,17 @@ export class AppBskySubscriptionNS { this._server = server } + getActiveSubscriptions( + cfg: ConfigOf< + AV, + AppBskySubscriptionGetActiveSubscriptions.Handler>, + AppBskySubscriptionGetActiveSubscriptions.HandlerReqCtx> + >, + ) { + const nsid = 'app.bsky.subscription.getActiveSubscriptions' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + getSubscriptionFeatures( cfg: ConfigOf< AV, diff --git a/packages/bsky/src/lexicon/lexicons.ts b/packages/bsky/src/lexicon/lexicons.ts index 3ce1b1af3d8..9c42bb8ee3d 100644 --- a/packages/bsky/src/lexicon/lexicons.ts +++ b/packages/bsky/src/lexicon/lexicons.ts @@ -9214,6 +9214,75 @@ export const schemaDict = { }, }, }, + AppBskySubscriptionGetActiveSubscriptions: { + lexicon: 1, + id: 'app.bsky.subscription.getActiveSubscriptions', + defs: { + main: { + type: 'query', + description: + 'Enumerate active subscriptions for the requesting account. Requires auth.', + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['subscriptions'], + properties: { + subscriptions: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:app.bsky.subscription.getActiveSubscriptions#subscription', + }, + }, + }, + }, + }, + }, + subscription: { + type: 'object', + required: [ + 'status', + 'renewalStatus', + 'group', + 'platform', + 'offering', + 'periodEndsAt', + 'periodStartsAt', + 'purchasedAt', + ], + 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', + }, + }, + }, + }, + }, AppBskySubscriptionGetSubscriptionFeatures: { lexicon: 1, id: 'app.bsky.subscription.getSubscriptionFeatures', @@ -10974,6 +11043,8 @@ export const ids = { AppBskyNotificationRegisterPush: 'app.bsky.notification.registerPush', AppBskyNotificationUpdateSeen: 'app.bsky.notification.updateSeen', AppBskyRichtextFacet: 'app.bsky.richtext.facet', + AppBskySubscriptionGetActiveSubscriptions: + 'app.bsky.subscription.getActiveSubscriptions', AppBskySubscriptionGetSubscriptionFeatures: 'app.bsky.subscription.getSubscriptionFeatures', AppBskySubscriptionRefreshSubscriptionCache: diff --git a/packages/bsky/src/lexicon/types/app/bsky/subscription/getActiveSubscriptions.ts b/packages/bsky/src/lexicon/types/app/bsky/subscription/getActiveSubscriptions.ts new file mode 100644 index 00000000000..778dc2f4cfe --- /dev/null +++ b/packages/bsky/src/lexicon/types/app/bsky/subscription/getActiveSubscriptions.ts @@ -0,0 +1,70 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { lexicons } from '../../../../lexicons' +import { isObj, hasProp } from '../../../../util' +import { CID } from 'multiformats/cid' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' + +export interface QueryParams {} + +export type InputSchema = undefined + +export interface OutputSchema { + subscriptions: Subscription[] + [k: string]: unknown +} + +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput + +export interface Subscription { + status: string + renewalStatus: string + group: string + platform: string + offering: string + periodEndsAt: string + periodStartsAt: string + purchasedAt: string + [k: string]: unknown +} + +export function isSubscription(v: unknown): v is Subscription { + return ( + isObj(v) && + hasProp(v, '$type') && + v.$type === 'app.bsky.subscription.getActiveSubscriptions#subscription' + ) +} + +export function validateSubscription(v: unknown): ValidationResult { + return lexicons.validate( + 'app.bsky.subscription.getActiveSubscriptions#subscription', + v, + ) +} diff --git a/packages/ozone/src/lexicon/index.ts b/packages/ozone/src/lexicon/index.ts index 713757cf3c2..31a50875321 100644 --- a/packages/ozone/src/lexicon/index.ts +++ b/packages/ozone/src/lexicon/index.ts @@ -136,6 +136,7 @@ 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 AppBskySubscriptionGetActiveSubscriptions from './types/app/bsky/subscription/getActiveSubscriptions' import * as AppBskySubscriptionGetSubscriptionFeatures from './types/app/bsky/subscription/getSubscriptionFeatures' import * as AppBskySubscriptionRefreshSubscriptionCache from './types/app/bsky/subscription/refreshSubscriptionCache' import * as AppBskyUnspeccedGetConfig from './types/app/bsky/unspecced/getConfig' @@ -1856,6 +1857,17 @@ export class AppBskySubscriptionNS { this._server = server } + getActiveSubscriptions( + cfg: ConfigOf< + AV, + AppBskySubscriptionGetActiveSubscriptions.Handler>, + AppBskySubscriptionGetActiveSubscriptions.HandlerReqCtx> + >, + ) { + const nsid = 'app.bsky.subscription.getActiveSubscriptions' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + getSubscriptionFeatures( cfg: ConfigOf< AV, diff --git a/packages/ozone/src/lexicon/lexicons.ts b/packages/ozone/src/lexicon/lexicons.ts index 1ec49eb7ef1..255bde678e5 100644 --- a/packages/ozone/src/lexicon/lexicons.ts +++ b/packages/ozone/src/lexicon/lexicons.ts @@ -9214,6 +9214,75 @@ export const schemaDict = { }, }, }, + AppBskySubscriptionGetActiveSubscriptions: { + lexicon: 1, + id: 'app.bsky.subscription.getActiveSubscriptions', + defs: { + main: { + type: 'query', + description: + 'Enumerate active subscriptions for the requesting account. Requires auth.', + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['subscriptions'], + properties: { + subscriptions: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:app.bsky.subscription.getActiveSubscriptions#subscription', + }, + }, + }, + }, + }, + }, + subscription: { + type: 'object', + required: [ + 'status', + 'renewalStatus', + 'group', + 'platform', + 'offering', + 'periodEndsAt', + 'periodStartsAt', + 'purchasedAt', + ], + 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', + }, + }, + }, + }, + }, AppBskySubscriptionGetSubscriptionFeatures: { lexicon: 1, id: 'app.bsky.subscription.getSubscriptionFeatures', @@ -13735,6 +13804,8 @@ export const ids = { AppBskyNotificationRegisterPush: 'app.bsky.notification.registerPush', AppBskyNotificationUpdateSeen: 'app.bsky.notification.updateSeen', AppBskyRichtextFacet: 'app.bsky.richtext.facet', + AppBskySubscriptionGetActiveSubscriptions: + 'app.bsky.subscription.getActiveSubscriptions', AppBskySubscriptionGetSubscriptionFeatures: 'app.bsky.subscription.getSubscriptionFeatures', AppBskySubscriptionRefreshSubscriptionCache: diff --git a/packages/ozone/src/lexicon/types/app/bsky/subscription/getActiveSubscriptions.ts b/packages/ozone/src/lexicon/types/app/bsky/subscription/getActiveSubscriptions.ts new file mode 100644 index 00000000000..778dc2f4cfe --- /dev/null +++ b/packages/ozone/src/lexicon/types/app/bsky/subscription/getActiveSubscriptions.ts @@ -0,0 +1,70 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { lexicons } from '../../../../lexicons' +import { isObj, hasProp } from '../../../../util' +import { CID } from 'multiformats/cid' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' + +export interface QueryParams {} + +export type InputSchema = undefined + +export interface OutputSchema { + subscriptions: Subscription[] + [k: string]: unknown +} + +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput + +export interface Subscription { + status: string + renewalStatus: string + group: string + platform: string + offering: string + periodEndsAt: string + periodStartsAt: string + purchasedAt: string + [k: string]: unknown +} + +export function isSubscription(v: unknown): v is Subscription { + return ( + isObj(v) && + hasProp(v, '$type') && + v.$type === 'app.bsky.subscription.getActiveSubscriptions#subscription' + ) +} + +export function validateSubscription(v: unknown): ValidationResult { + return lexicons.validate( + 'app.bsky.subscription.getActiveSubscriptions#subscription', + v, + ) +} diff --git a/packages/pds/src/lexicon/index.ts b/packages/pds/src/lexicon/index.ts index 713757cf3c2..31a50875321 100644 --- a/packages/pds/src/lexicon/index.ts +++ b/packages/pds/src/lexicon/index.ts @@ -136,6 +136,7 @@ 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 AppBskySubscriptionGetActiveSubscriptions from './types/app/bsky/subscription/getActiveSubscriptions' import * as AppBskySubscriptionGetSubscriptionFeatures from './types/app/bsky/subscription/getSubscriptionFeatures' import * as AppBskySubscriptionRefreshSubscriptionCache from './types/app/bsky/subscription/refreshSubscriptionCache' import * as AppBskyUnspeccedGetConfig from './types/app/bsky/unspecced/getConfig' @@ -1856,6 +1857,17 @@ export class AppBskySubscriptionNS { this._server = server } + getActiveSubscriptions( + cfg: ConfigOf< + AV, + AppBskySubscriptionGetActiveSubscriptions.Handler>, + AppBskySubscriptionGetActiveSubscriptions.HandlerReqCtx> + >, + ) { + const nsid = 'app.bsky.subscription.getActiveSubscriptions' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + getSubscriptionFeatures( cfg: ConfigOf< AV, diff --git a/packages/pds/src/lexicon/lexicons.ts b/packages/pds/src/lexicon/lexicons.ts index 1ec49eb7ef1..255bde678e5 100644 --- a/packages/pds/src/lexicon/lexicons.ts +++ b/packages/pds/src/lexicon/lexicons.ts @@ -9214,6 +9214,75 @@ export const schemaDict = { }, }, }, + AppBskySubscriptionGetActiveSubscriptions: { + lexicon: 1, + id: 'app.bsky.subscription.getActiveSubscriptions', + defs: { + main: { + type: 'query', + description: + 'Enumerate active subscriptions for the requesting account. Requires auth.', + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['subscriptions'], + properties: { + subscriptions: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:app.bsky.subscription.getActiveSubscriptions#subscription', + }, + }, + }, + }, + }, + }, + subscription: { + type: 'object', + required: [ + 'status', + 'renewalStatus', + 'group', + 'platform', + 'offering', + 'periodEndsAt', + 'periodStartsAt', + 'purchasedAt', + ], + 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', + }, + }, + }, + }, + }, AppBskySubscriptionGetSubscriptionFeatures: { lexicon: 1, id: 'app.bsky.subscription.getSubscriptionFeatures', @@ -13735,6 +13804,8 @@ export const ids = { AppBskyNotificationRegisterPush: 'app.bsky.notification.registerPush', AppBskyNotificationUpdateSeen: 'app.bsky.notification.updateSeen', AppBskyRichtextFacet: 'app.bsky.richtext.facet', + AppBskySubscriptionGetActiveSubscriptions: + 'app.bsky.subscription.getActiveSubscriptions', AppBskySubscriptionGetSubscriptionFeatures: 'app.bsky.subscription.getSubscriptionFeatures', AppBskySubscriptionRefreshSubscriptionCache: diff --git a/packages/pds/src/lexicon/types/app/bsky/subscription/getActiveSubscriptions.ts b/packages/pds/src/lexicon/types/app/bsky/subscription/getActiveSubscriptions.ts new file mode 100644 index 00000000000..778dc2f4cfe --- /dev/null +++ b/packages/pds/src/lexicon/types/app/bsky/subscription/getActiveSubscriptions.ts @@ -0,0 +1,70 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { lexicons } from '../../../../lexicons' +import { isObj, hasProp } from '../../../../util' +import { CID } from 'multiformats/cid' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' + +export interface QueryParams {} + +export type InputSchema = undefined + +export interface OutputSchema { + subscriptions: Subscription[] + [k: string]: unknown +} + +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput + +export interface Subscription { + status: string + renewalStatus: string + group: string + platform: string + offering: string + periodEndsAt: string + periodStartsAt: string + purchasedAt: string + [k: string]: unknown +} + +export function isSubscription(v: unknown): v is Subscription { + return ( + isObj(v) && + hasProp(v, '$type') && + v.$type === 'app.bsky.subscription.getActiveSubscriptions#subscription' + ) +} + +export function validateSubscription(v: unknown): ValidationResult { + return lexicons.validate( + 'app.bsky.subscription.getActiveSubscriptions#subscription', + v, + ) +}