Skip to content

Commit

Permalink
com.atproto.sync.listReposByCollection Lexicon, for collections direc…
Browse files Browse the repository at this point in the history
…tory (#3524)

* com.atproto.sync.listReposByCollection, for collections directory

* bump listReposByCollection limit

* update max+default to align more with listRepos

* codegen

* changeset for listReposByCollection
  • Loading branch information
bnewbold authored Feb 18, 2025
1 parent b41ff4b commit 010f10c
Show file tree
Hide file tree
Showing 14 changed files with 609 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-trainers-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/api": patch
---

add com.atproto.sync.listReposByCollection Lexicon
46 changes: 46 additions & 0 deletions lexicons/com/atproto/sync/listReposByCollection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"lexicon": 1,
"id": "com.atproto.sync.listReposByCollection",
"defs": {
"main": {
"type": "query",
"description": "Enumerates all the DIDs which have records with the given collection NSID.",
"parameters": {
"type": "params",
"required": ["collection"],
"properties": {
"collection": { "type": "string", "format": "nsid" },
"limit": {
"type": "integer",
"description": "Maximum size of response set. Recommend setting a large maximum (1000+) when enumerating large DID lists.",
"minimum": 1,
"maximum": 2000,
"default": 500
},
"cursor": { "type": "string" }
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["repos"],
"properties": {
"cursor": { "type": "string" },
"repos": {
"type": "array",
"items": { "type": "ref", "ref": "#repo" }
}
}
}
}
},
"repo": {
"type": "object",
"required": ["did"],
"properties": {
"did": { "type": "string", "format": "did" }
}
}
}
}
14 changes: 14 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import * as ComAtprotoSyncGetRepo from './types/com/atproto/sync/getRepo.js'
import * as ComAtprotoSyncGetRepoStatus from './types/com/atproto/sync/getRepoStatus.js'
import * as ComAtprotoSyncListBlobs from './types/com/atproto/sync/listBlobs.js'
import * as ComAtprotoSyncListRepos from './types/com/atproto/sync/listRepos.js'
import * as ComAtprotoSyncListReposByCollection from './types/com/atproto/sync/listReposByCollection.js'
import * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOfUpdate.js'
import * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl.js'
import * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos.js'
Expand Down Expand Up @@ -310,6 +311,7 @@ export * as ComAtprotoSyncGetRepo from './types/com/atproto/sync/getRepo.js'
export * as ComAtprotoSyncGetRepoStatus from './types/com/atproto/sync/getRepoStatus.js'
export * as ComAtprotoSyncListBlobs from './types/com/atproto/sync/listBlobs.js'
export * as ComAtprotoSyncListRepos from './types/com/atproto/sync/listRepos.js'
export * as ComAtprotoSyncListReposByCollection from './types/com/atproto/sync/listReposByCollection.js'
export * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOfUpdate.js'
export * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl.js'
export * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos.js'
Expand Down Expand Up @@ -1473,6 +1475,18 @@ export class ComAtprotoSyncNS {
)
}

listReposByCollection(
params?: ComAtprotoSyncListReposByCollection.QueryParams,
opts?: ComAtprotoSyncListReposByCollection.CallOptions,
): Promise<ComAtprotoSyncListReposByCollection.Response> {
return this._client.call(
'com.atproto.sync.listReposByCollection',
params,
undefined,
opts,
)
}

notifyOfUpdate(
data?: ComAtprotoSyncNotifyOfUpdate.InputSchema,
opts?: ComAtprotoSyncNotifyOfUpdate.CallOptions,
Expand Down
62 changes: 62 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3661,6 +3661,67 @@ export const schemaDict = {
},
},
},
ComAtprotoSyncListReposByCollection: {
lexicon: 1,
id: 'com.atproto.sync.listReposByCollection',
defs: {
main: {
type: 'query',
description:
'Enumerates all the DIDs which have records with the given collection NSID.',
parameters: {
type: 'params',
required: ['collection'],
properties: {
collection: {
type: 'string',
format: 'nsid',
},
limit: {
type: 'integer',
description:
'Maximum size of response set. Recommend setting a large maximum (1000+) when enumerating large DID lists.',
minimum: 1,
maximum: 2000,
default: 500,
},
cursor: {
type: 'string',
},
},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['repos'],
properties: {
cursor: {
type: 'string',
},
repos: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.sync.listReposByCollection#repo',
},
},
},
},
},
},
repo: {
type: 'object',
required: ['did'],
properties: {
did: {
type: 'string',
format: 'did',
},
},
},
},
},
ComAtprotoSyncNotifyOfUpdate: {
lexicon: 1,
id: 'com.atproto.sync.notifyOfUpdate',
Expand Down Expand Up @@ -14091,6 +14152,7 @@ export const ids = {
ComAtprotoSyncGetRepoStatus: 'com.atproto.sync.getRepoStatus',
ComAtprotoSyncListBlobs: 'com.atproto.sync.listBlobs',
ComAtprotoSyncListRepos: 'com.atproto.sync.listRepos',
ComAtprotoSyncListReposByCollection: 'com.atproto.sync.listReposByCollection',
ComAtprotoSyncNotifyOfUpdate: 'com.atproto.sync.notifyOfUpdate',
ComAtprotoSyncRequestCrawl: 'com.atproto.sync.requestCrawl',
ComAtprotoSyncSubscribeRepos: 'com.atproto.sync.subscribeRepos',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* GENERATED CODE - DO NOT MODIFY
*/
import { HeadersMap, XRPCError } from '@atproto/xrpc'
import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { CID } from 'multiformats/cid'
import { validate as _validate } from '../../../../lexicons'
import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util'

const is$typed = _is$typed,
validate = _validate
const id = 'com.atproto.sync.listReposByCollection'

export interface QueryParams {
collection: string
/** Maximum size of response set. Recommend setting a large maximum (1000+) when enumerating large DID lists. */
limit?: number
cursor?: string
}

export type InputSchema = undefined

export interface OutputSchema {
cursor?: string
repos: Repo[]
}

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 Repo {
$type?: 'com.atproto.sync.listReposByCollection#repo'
did: string
}

const hashRepo = 'repo'

export function isRepo<V>(v: V) {
return is$typed(v, id, hashRepo)
}

export function validateRepo<V>(v: V) {
return validate<Repo & V>(v, id, hashRepo)
}
12 changes: 12 additions & 0 deletions packages/bsky/src/lexicon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import * as ComAtprotoSyncGetRepo from './types/com/atproto/sync/getRepo.js'
import * as ComAtprotoSyncGetRepoStatus from './types/com/atproto/sync/getRepoStatus.js'
import * as ComAtprotoSyncListBlobs from './types/com/atproto/sync/listBlobs.js'
import * as ComAtprotoSyncListRepos from './types/com/atproto/sync/listRepos.js'
import * as ComAtprotoSyncListReposByCollection from './types/com/atproto/sync/listReposByCollection.js'
import * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOfUpdate.js'
import * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl.js'
import * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos.js'
Expand Down Expand Up @@ -1065,6 +1066,17 @@ export class ComAtprotoSyncNS {
return this._server.xrpc.method(nsid, cfg)
}

listReposByCollection<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
ComAtprotoSyncListReposByCollection.Handler<ExtractAuth<AV>>,
ComAtprotoSyncListReposByCollection.HandlerReqCtx<ExtractAuth<AV>>
>,
) {
const nsid = 'com.atproto.sync.listReposByCollection' // @ts-ignore
return this._server.xrpc.method(nsid, cfg)
}

notifyOfUpdate<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
Expand Down
62 changes: 62 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3661,6 +3661,67 @@ export const schemaDict = {
},
},
},
ComAtprotoSyncListReposByCollection: {
lexicon: 1,
id: 'com.atproto.sync.listReposByCollection',
defs: {
main: {
type: 'query',
description:
'Enumerates all the DIDs which have records with the given collection NSID.',
parameters: {
type: 'params',
required: ['collection'],
properties: {
collection: {
type: 'string',
format: 'nsid',
},
limit: {
type: 'integer',
description:
'Maximum size of response set. Recommend setting a large maximum (1000+) when enumerating large DID lists.',
minimum: 1,
maximum: 2000,
default: 500,
},
cursor: {
type: 'string',
},
},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['repos'],
properties: {
cursor: {
type: 'string',
},
repos: {
type: 'array',
items: {
type: 'ref',
ref: 'lex:com.atproto.sync.listReposByCollection#repo',
},
},
},
},
},
},
repo: {
type: 'object',
required: ['did'],
properties: {
did: {
type: 'string',
format: 'did',
},
},
},
},
},
ComAtprotoSyncNotifyOfUpdate: {
lexicon: 1,
id: 'com.atproto.sync.notifyOfUpdate',
Expand Down Expand Up @@ -11055,6 +11116,7 @@ export const ids = {
ComAtprotoSyncGetRepoStatus: 'com.atproto.sync.getRepoStatus',
ComAtprotoSyncListBlobs: 'com.atproto.sync.listBlobs',
ComAtprotoSyncListRepos: 'com.atproto.sync.listRepos',
ComAtprotoSyncListReposByCollection: 'com.atproto.sync.listReposByCollection',
ComAtprotoSyncNotifyOfUpdate: 'com.atproto.sync.notifyOfUpdate',
ComAtprotoSyncRequestCrawl: 'com.atproto.sync.requestCrawl',
ComAtprotoSyncSubscribeRepos: 'com.atproto.sync.subscribeRepos',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* GENERATED CODE - DO NOT MODIFY
*/
import express from 'express'
import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { CID } from 'multiformats/cid'
import { validate as _validate } from '../../../../lexicons'
import { $Typed, is$typed as _is$typed, OmitKey } from '../../../../util'
import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'

const is$typed = _is$typed,
validate = _validate
const id = 'com.atproto.sync.listReposByCollection'

export interface QueryParams {
collection: string
/** Maximum size of response set. Recommend setting a large maximum (1000+) when enumerating large DID lists. */
limit: number
cursor?: string
}

export type InputSchema = undefined

export interface OutputSchema {
cursor?: string
repos: Repo[]
}

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
resetRouteRateLimits: () => Promise<void>
}
export type Handler<HA extends HandlerAuth = never> = (
ctx: HandlerReqCtx<HA>,
) => Promise<HandlerOutput> | HandlerOutput

export interface Repo {
$type?: 'com.atproto.sync.listReposByCollection#repo'
did: string
}

const hashRepo = 'repo'

export function isRepo<V>(v: V) {
return is$typed(v, id, hashRepo)
}

export function validateRepo<V>(v: V) {
return validate<Repo & V>(v, id, hashRepo)
}
Loading

0 comments on commit 010f10c

Please sign in to comment.