Skip to content

Commit

Permalink
Add app.bsky.unspecced.getConfig endpoint (#2918)
Browse files Browse the repository at this point in the history
* lexicon: add app.bsky.unspecced.getConfig for client runtime config

* bsky: add app.bsky.unspecced.getConfig w/ new env for checkEmailConfirmed

* changeset
  • Loading branch information
devinivy authored Oct 30, 2024
1 parent d9fcaf8 commit 2092387
Show file tree
Hide file tree
Showing 17 changed files with 356 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/fluffy-baboons-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@atproto/bsky": patch
"@atproto/api": patch
---

add app.bsky.unspecced.getConfig endpoint
20 changes: 20 additions & 0 deletions lexicons/app/bsky/unspecced/getConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"lexicon": 1,
"id": "app.bsky.unspecced.getConfig",
"defs": {
"main": {
"type": "query",
"description": "Get miscellaneous runtime configuration.",
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": [],
"properties": {
"checkEmailConfirmed": { "type": "boolean" }
}
}
}
}
}
}
14 changes: 14 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ import * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/
import * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
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'
import * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators'
import * as AppBskyUnspeccedGetSuggestionsSkeleton from './types/app/bsky/unspecced/getSuggestionsSkeleton'
import * as AppBskyUnspeccedGetTaggedSuggestions from './types/app/bsky/unspecced/getTaggedSuggestions'
Expand Down Expand Up @@ -380,6 +381,7 @@ export * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/
export * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
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'
export * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators'
export * as AppBskyUnspeccedGetSuggestionsSkeleton from './types/app/bsky/unspecced/getSuggestionsSkeleton'
export * as AppBskyUnspeccedGetTaggedSuggestions from './types/app/bsky/unspecced/getTaggedSuggestions'
Expand Down Expand Up @@ -3001,6 +3003,18 @@ export class AppBskyUnspeccedNS {
this._client = client
}

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

getPopularFeedGenerators(
params?: AppBskyUnspeccedGetPopularFeedGenerators.QueryParams,
opts?: AppBskyUnspeccedGetPopularFeedGenerators.CallOptions,
Expand Down
23 changes: 23 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9155,6 +9155,28 @@ export const schemaDict = {
},
},
},
AppBskyUnspeccedGetConfig: {
lexicon: 1,
id: 'app.bsky.unspecced.getConfig',
defs: {
main: {
type: 'query',
description: 'Get miscellaneous runtime configuration.',
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: [],
properties: {
checkEmailConfirmed: {
type: 'boolean',
},
},
},
},
},
},
},
AppBskyUnspeccedGetPopularFeedGenerators: {
lexicon: 1,
id: 'app.bsky.unspecced.getPopularFeedGenerators',
Expand Down Expand Up @@ -13056,6 +13078,7 @@ export const ids = {
AppBskyNotificationUpdateSeen: 'app.bsky.notification.updateSeen',
AppBskyRichtextFacet: 'app.bsky.richtext.facet',
AppBskyUnspeccedDefs: 'app.bsky.unspecced.defs',
AppBskyUnspeccedGetConfig: 'app.bsky.unspecced.getConfig',
AppBskyUnspeccedGetPopularFeedGenerators:
'app.bsky.unspecced.getPopularFeedGenerators',
AppBskyUnspeccedGetSuggestionsSkeleton:
Expand Down
32 changes: 32 additions & 0 deletions packages/api/src/client/types/app/bsky/unspecced/getConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* 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 {
checkEmailConfirmed?: boolean
[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
}
16 changes: 16 additions & 0 deletions packages/bsky/src/api/app/bsky/unspecced/getConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Server } from '../../../../lexicon'
import AppContext from '../../../../context'

// THIS IS A TEMPORARY UNSPECCED ROUTE
export default function (server: Server, ctx: AppContext) {
server.app.bsky.unspecced.getConfig({
handler: async () => {
return {
encoding: 'application/json',
body: {
checkEmailConfirmed: ctx.cfg.clientCheckEmailConfirmed,
},
}
},
})
}
2 changes: 2 additions & 0 deletions packages/bsky/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import listNotifications from './app/bsky/notification/listNotifications'
import updateSeen from './app/bsky/notification/updateSeen'
import putPreferences from './app/bsky/notification/putPreferences'
import registerPush from './app/bsky/notification/registerPush'
import getConfig from './app/bsky/unspecced/getConfig'
import getPopularFeedGenerators from './app/bsky/unspecced/getPopularFeedGenerators'
import getTaggedSuggestions from './app/bsky/unspecced/getTaggedSuggestions'
import getSubjectStatus from './com/atproto/admin/getSubjectStatus'
Expand Down Expand Up @@ -110,6 +111,7 @@ export default function (server: Server, ctx: AppContext) {
updateSeen(server, ctx)
putPreferences(server, ctx)
registerPush(server, ctx)
getConfig(server, ctx)
getPopularFeedGenerators(server, ctx)
getTaggedSuggestions(server, ctx)
// com.atproto
Expand Down
9 changes: 9 additions & 0 deletions packages/bsky/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export interface ServerConfigValues {
blobCacheLocation?: string
statsigKey?: string
statsigEnv?: string
// client config
clientCheckEmailConfirmed?: boolean
}

export class ServerConfig {
Expand Down Expand Up @@ -121,6 +123,8 @@ export class ServerConfig {
process.env.NODE_ENV === 'test'
? 'test'
: process.env.BSKY_STATSIG_ENV || 'development'
const clientCheckEmailConfirmed =
process.env.BSKY_CLIENT_CHECK_EMAIL_CONFIRMED === 'true'
return new ServerConfig({
version,
debugMode,
Expand Down Expand Up @@ -156,6 +160,7 @@ export class ServerConfig {
modServiceDid,
statsigKey,
statsigEnv,
clientCheckEmailConfirmed,
...stripUndefineds(overrides ?? {}),
})
}
Expand Down Expand Up @@ -308,6 +313,10 @@ export class ServerConfig {
get statsigEnv() {
return this.cfg.statsigEnv
}

get clientCheckEmailConfirmed() {
return this.cfg.clientCheckEmailConfirmed
}
}

function stripUndefineds(
Expand Down
12 changes: 12 additions & 0 deletions packages/bsky/src/lexicon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,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 AppBskyUnspeccedGetConfig from './types/app/bsky/unspecced/getConfig'
import * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators'
import * as AppBskyUnspeccedGetSuggestionsSkeleton from './types/app/bsky/unspecced/getSuggestionsSkeleton'
import * as AppBskyUnspeccedGetTaggedSuggestions from './types/app/bsky/unspecced/getTaggedSuggestions'
Expand Down Expand Up @@ -1783,6 +1784,17 @@ export class AppBskyUnspeccedNS {
this._server = server
}

getConfig<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
AppBskyUnspeccedGetConfig.Handler<ExtractAuth<AV>>,
AppBskyUnspeccedGetConfig.HandlerReqCtx<ExtractAuth<AV>>
>,
) {
const nsid = 'app.bsky.unspecced.getConfig' // @ts-ignore
return this._server.xrpc.method(nsid, cfg)
}

getPopularFeedGenerators<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
Expand Down
23 changes: 23 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9155,6 +9155,28 @@ export const schemaDict = {
},
},
},
AppBskyUnspeccedGetConfig: {
lexicon: 1,
id: 'app.bsky.unspecced.getConfig',
defs: {
main: {
type: 'query',
description: 'Get miscellaneous runtime configuration.',
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: [],
properties: {
checkEmailConfirmed: {
type: 'boolean',
},
},
},
},
},
},
},
AppBskyUnspeccedGetPopularFeedGenerators: {
lexicon: 1,
id: 'app.bsky.unspecced.getPopularFeedGenerators',
Expand Down Expand Up @@ -10714,6 +10736,7 @@ export const ids = {
AppBskyNotificationUpdateSeen: 'app.bsky.notification.updateSeen',
AppBskyRichtextFacet: 'app.bsky.richtext.facet',
AppBskyUnspeccedDefs: 'app.bsky.unspecced.defs',
AppBskyUnspeccedGetConfig: 'app.bsky.unspecced.getConfig',
AppBskyUnspeccedGetPopularFeedGenerators:
'app.bsky.unspecced.getPopularFeedGenerators',
AppBskyUnspeccedGetSuggestionsSkeleton:
Expand Down
43 changes: 43 additions & 0 deletions packages/bsky/src/lexicon/types/app/bsky/unspecced/getConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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 {
checkEmailConfirmed?: boolean
[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<HA extends HandlerAuth = never> = {
auth: HA
params: QueryParams
input: HandlerInput
req: express.Request
res: express.Response
}
export type Handler<HA extends HandlerAuth = never> = (
ctx: HandlerReqCtx<HA>,
) => Promise<HandlerOutput> | HandlerOutput
12 changes: 12 additions & 0 deletions packages/ozone/src/lexicon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,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 AppBskyUnspeccedGetConfig from './types/app/bsky/unspecced/getConfig'
import * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators'
import * as AppBskyUnspeccedGetSuggestionsSkeleton from './types/app/bsky/unspecced/getSuggestionsSkeleton'
import * as AppBskyUnspeccedGetTaggedSuggestions from './types/app/bsky/unspecced/getTaggedSuggestions'
Expand Down Expand Up @@ -1823,6 +1824,17 @@ export class AppBskyUnspeccedNS {
this._server = server
}

getConfig<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
AppBskyUnspeccedGetConfig.Handler<ExtractAuth<AV>>,
AppBskyUnspeccedGetConfig.HandlerReqCtx<ExtractAuth<AV>>
>,
) {
const nsid = 'app.bsky.unspecced.getConfig' // @ts-ignore
return this._server.xrpc.method(nsid, cfg)
}

getPopularFeedGenerators<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
Expand Down
23 changes: 23 additions & 0 deletions packages/ozone/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9155,6 +9155,28 @@ export const schemaDict = {
},
},
},
AppBskyUnspeccedGetConfig: {
lexicon: 1,
id: 'app.bsky.unspecced.getConfig',
defs: {
main: {
type: 'query',
description: 'Get miscellaneous runtime configuration.',
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: [],
properties: {
checkEmailConfirmed: {
type: 'boolean',
},
},
},
},
},
},
},
AppBskyUnspeccedGetPopularFeedGenerators: {
lexicon: 1,
id: 'app.bsky.unspecced.getPopularFeedGenerators',
Expand Down Expand Up @@ -13056,6 +13078,7 @@ export const ids = {
AppBskyNotificationUpdateSeen: 'app.bsky.notification.updateSeen',
AppBskyRichtextFacet: 'app.bsky.richtext.facet',
AppBskyUnspeccedDefs: 'app.bsky.unspecced.defs',
AppBskyUnspeccedGetConfig: 'app.bsky.unspecced.getConfig',
AppBskyUnspeccedGetPopularFeedGenerators:
'app.bsky.unspecced.getPopularFeedGenerators',
AppBskyUnspeccedGetSuggestionsSkeleton:
Expand Down
Loading

0 comments on commit 2092387

Please sign in to comment.