Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entryway: tagged suggestions #2078

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions lexicons/app/bsky/unspecced/getTaggedSuggestions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"lexicon": 1,
"id": "app.bsky.unspecced.getTaggedSuggestions",
"defs": {
"main": {
"type": "query",
"description": "Get a list of suggestions (feeds and users) tagged with categories",
"parameters": {
"type": "params",
"properties": {}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["suggestions"],
"properties": {
"suggestions": {
"type": "array",
"items": {
"type": "ref",
"ref": "#suggestion"
}
}
}
}
}
},
"suggestion": {
"type": "object",
"required": ["tag", "subjectType", "subject"],
"properties": {
"tag": { "type": "string" },
"subjectType": {
"type": "string",
"knownValues": ["actor", "feed"]
},
"subject": { "type": "string", "format": "uri" }
}
}
}
}
13 changes: 13 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ import * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet'
import * as AppBskyUnspeccedDefs from './types/app/bsky/unspecced/defs'
import * as AppBskyUnspeccedGetPopular from './types/app/bsky/unspecced/getPopular'
import * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators'
import * as AppBskyUnspeccedGetTaggedSuggestions from './types/app/bsky/unspecced/getTaggedSuggestions'
import * as AppBskyUnspeccedGetTimelineSkeleton from './types/app/bsky/unspecced/getTimelineSkeleton'
import * as AppBskyUnspeccedSearchActorsSkeleton from './types/app/bsky/unspecced/searchActorsSkeleton'
import * as AppBskyUnspeccedSearchPostsSkeleton from './types/app/bsky/unspecced/searchPostsSkeleton'
Expand Down Expand Up @@ -291,6 +292,7 @@ export * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet'
export * as AppBskyUnspeccedDefs from './types/app/bsky/unspecced/defs'
export * as AppBskyUnspeccedGetPopular from './types/app/bsky/unspecced/getPopular'
export * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators'
export * as AppBskyUnspeccedGetTaggedSuggestions from './types/app/bsky/unspecced/getTaggedSuggestions'
export * as AppBskyUnspeccedGetTimelineSkeleton from './types/app/bsky/unspecced/getTimelineSkeleton'
export * as AppBskyUnspeccedSearchActorsSkeleton from './types/app/bsky/unspecced/searchActorsSkeleton'
export * as AppBskyUnspeccedSearchPostsSkeleton from './types/app/bsky/unspecced/searchPostsSkeleton'
Expand Down Expand Up @@ -2508,6 +2510,17 @@ export class UnspeccedNS {
})
}

getTaggedSuggestions(
params?: AppBskyUnspeccedGetTaggedSuggestions.QueryParams,
opts?: AppBskyUnspeccedGetTaggedSuggestions.CallOptions,
): Promise<AppBskyUnspeccedGetTaggedSuggestions.Response> {
return this._service.xrpc
.call('app.bsky.unspecced.getTaggedSuggestions', params, undefined, opts)
.catch((e) => {
throw AppBskyUnspeccedGetTaggedSuggestions.toKnownErr(e)
})
}

getTimelineSkeleton(
params?: AppBskyUnspeccedGetTimelineSkeleton.QueryParams,
opts?: AppBskyUnspeccedGetTimelineSkeleton.CallOptions,
Expand Down
50 changes: 50 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7924,6 +7924,54 @@ export const schemaDict = {
},
},
},
AppBskyUnspeccedGetTaggedSuggestions: {
lexicon: 1,
id: 'app.bsky.unspecced.getTaggedSuggestions',
defs: {
main: {
type: 'query',
description:
'Get a list of suggestions (feeds and users) tagged with categories',
parameters: {
type: 'params',
properties: {},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['suggestions'],
properties: {
suggestions: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:app.bsky.unspecced.getTaggedSuggestions#suggestion',
},
},
},
},
},
},
suggestion: {
type: 'object',
required: ['tag', 'subjectType', 'subject'],
properties: {
tag: {
type: 'string',
},
subjectType: {
type: 'string',
knownValues: ['actor', 'feed'],
},
subject: {
type: 'string',
format: 'uri',
},
},
},
},
},
AppBskyUnspeccedGetTimelineSkeleton: {
lexicon: 1,
id: 'app.bsky.unspecced.getTimelineSkeleton',
Expand Down Expand Up @@ -8257,6 +8305,8 @@ export const ids = {
AppBskyUnspeccedGetPopular: 'app.bsky.unspecced.getPopular',
AppBskyUnspeccedGetPopularFeedGenerators:
'app.bsky.unspecced.getPopularFeedGenerators',
AppBskyUnspeccedGetTaggedSuggestions:
'app.bsky.unspecced.getTaggedSuggestions',
AppBskyUnspeccedGetTimelineSkeleton: 'app.bsky.unspecced.getTimelineSkeleton',
AppBskyUnspeccedSearchActorsSkeleton:
'app.bsky.unspecced.searchActorsSkeleton',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* GENERATED CODE - DO NOT MODIFY
*/
import { Headers, 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 {
suggestions: Suggestion[]
[k: string]: unknown
}

export interface CallOptions {
headers?: Headers
}

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

export function toKnownErr(e: any) {
if (e instanceof XRPCError) {
}
return e
}

export interface Suggestion {
tag: string
subjectType: 'actor' | 'feed' | (string & {})
subject: string
[k: string]: unknown
}

export function isSuggestion(v: unknown): v is Suggestion {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'app.bsky.unspecced.getTaggedSuggestions#suggestion'
)
}

export function validateSuggestion(v: unknown): ValidationResult {
return lexicons.validate(
'app.bsky.unspecced.getTaggedSuggestions#suggestion',
v,
)
}
14 changes: 12 additions & 2 deletions packages/bsky/src/lexicon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ import * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/
import * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
import * as AppBskyUnspeccedGetPopular from './types/app/bsky/unspecced/getPopular'
import * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators'
import * as AppBskyUnspeccedGetTaggedSuggestions from './types/app/bsky/unspecced/getTaggedSuggestions'
import * as AppBskyUnspeccedGetTimelineSkeleton from './types/app/bsky/unspecced/getTimelineSkeleton'
import * as AppBskyUnspeccedSearchActorsSkeleton from './types/app/bsky/unspecced/searchActorsSkeleton'
import * as AppBskyUnspeccedSearchPostsSkeleton from './types/app/bsky/unspecced/searchPostsSkeleton'
Expand Down Expand Up @@ -1613,6 +1614,17 @@ export class UnspeccedNS {
return this._server.xrpc.method(nsid, cfg)
}

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

getTimelineSkeleton<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
Expand Down Expand Up @@ -1658,13 +1670,11 @@ type RouteRateLimitOpts<T> = {
calcKey?: (ctx: T) => string
calcPoints?: (ctx: T) => number
}
type HandlerOpts = { blobLimit?: number }
type HandlerRateLimitOpts<T> = SharedRateLimitOpts<T> | RouteRateLimitOpts<T>
type ConfigOf<Auth, Handler, ReqCtx> =
| Handler
| {
auth?: Auth
opts?: HandlerOpts
rateLimit?: HandlerRateLimitOpts<ReqCtx> | HandlerRateLimitOpts<ReqCtx>[]
handler: Handler
}
Expand Down
50 changes: 50 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7924,6 +7924,54 @@ export const schemaDict = {
},
},
},
AppBskyUnspeccedGetTaggedSuggestions: {
lexicon: 1,
id: 'app.bsky.unspecced.getTaggedSuggestions',
defs: {
main: {
type: 'query',
description:
'Get a list of suggestions (feeds and users) tagged with categories',
parameters: {
type: 'params',
properties: {},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['suggestions'],
properties: {
suggestions: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:app.bsky.unspecced.getTaggedSuggestions#suggestion',
},
},
},
},
},
},
suggestion: {
type: 'object',
required: ['tag', 'subjectType', 'subject'],
properties: {
tag: {
type: 'string',
},
subjectType: {
type: 'string',
knownValues: ['actor', 'feed'],
},
subject: {
type: 'string',
format: 'uri',
},
},
},
},
},
AppBskyUnspeccedGetTimelineSkeleton: {
lexicon: 1,
id: 'app.bsky.unspecced.getTimelineSkeleton',
Expand Down Expand Up @@ -8257,6 +8305,8 @@ export const ids = {
AppBskyUnspeccedGetPopular: 'app.bsky.unspecced.getPopular',
AppBskyUnspeccedGetPopularFeedGenerators:
'app.bsky.unspecced.getPopularFeedGenerators',
AppBskyUnspeccedGetTaggedSuggestions:
'app.bsky.unspecced.getTaggedSuggestions',
AppBskyUnspeccedGetTimelineSkeleton: 'app.bsky.unspecced.getTimelineSkeleton',
AppBskyUnspeccedSearchActorsSkeleton:
'app.bsky.unspecced.searchActorsSkeleton',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* 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 } from '@atproto/xrpc-server'

export interface QueryParams {}

export type InputSchema = undefined

export interface OutputSchema {
suggestions: Suggestion[]
[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
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

export interface Suggestion {
tag: string
subjectType: 'actor' | 'feed' | (string & {})
subject: string
[k: string]: unknown
}

export function isSuggestion(v: unknown): v is Suggestion {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'app.bsky.unspecced.getTaggedSuggestions#suggestion'
)
}

export function validateSuggestion(v: unknown): ValidationResult {
return lexicons.validate(
'app.bsky.unspecced.getTaggedSuggestions#suggestion',
v,
)
}
Loading
Loading