From 2768fb9e4533d7c04097aaea6faf4524b2eeca48 Mon Sep 17 00:00:00 2001 From: Daniel Holmgren Date: Tue, 20 Jun 2023 09:36:09 -0500 Subject: [PATCH] Make requestCrawl & notifyOfUpdate procedures (#1217) make requestCrawl & notifyOfUpdate procedures --- lexicons/com/atproto/sync/notifyOfUpdate.json | 15 ++++--- lexicons/com/atproto/sync/requestCrawl.json | 15 ++++--- packages/api/src/client/index.ts | 8 ++-- packages/api/src/client/lexicons.ts | 42 +++++++++++-------- .../types/com/atproto/sync/notifyOfUpdate.ts | 9 ++-- .../types/com/atproto/sync/requestCrawl.ts | 9 ++-- packages/bsky/src/lexicon/lexicons.ts | 42 +++++++++++-------- .../types/com/atproto/sync/notifyOfUpdate.ts | 11 +++-- .../types/com/atproto/sync/requestCrawl.ts | 11 +++-- packages/pds/src/lexicon/lexicons.ts | 42 +++++++++++-------- .../types/com/atproto/sync/notifyOfUpdate.ts | 11 +++-- .../types/com/atproto/sync/requestCrawl.ts | 11 +++-- 12 files changed, 138 insertions(+), 88 deletions(-) diff --git a/lexicons/com/atproto/sync/notifyOfUpdate.json b/lexicons/com/atproto/sync/notifyOfUpdate.json index 53a82b77187..a5449b152fe 100644 --- a/lexicons/com/atproto/sync/notifyOfUpdate.json +++ b/lexicons/com/atproto/sync/notifyOfUpdate.json @@ -3,13 +3,16 @@ "id": "com.atproto.sync.notifyOfUpdate", "defs": { "main": { - "type": "query", + "type": "procedure", "description": "Notify a crawling service of a recent update. Often when a long break between updates causes the connection with the crawling service to break.", - "parameters": { - "type": "params", - "required": ["hostname"], - "properties": { - "hostname": {"type": "string", "description": "Hostname of the service that is notifying of update."} + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["hostname"], + "properties": { + "hostname": {"type": "string", "description": "Hostname of the service that is notifying of update."} + } } } } diff --git a/lexicons/com/atproto/sync/requestCrawl.json b/lexicons/com/atproto/sync/requestCrawl.json index a9989350e27..1bd09829002 100644 --- a/lexicons/com/atproto/sync/requestCrawl.json +++ b/lexicons/com/atproto/sync/requestCrawl.json @@ -3,13 +3,16 @@ "id": "com.atproto.sync.requestCrawl", "defs": { "main": { - "type": "query", + "type": "procedure", "description": "Request a service to persistently crawl hosted repos.", - "parameters": { - "type": "params", - "required": ["hostname"], - "properties": { - "hostname": {"type": "string", "description": "Hostname of the service that is requesting to be crawled."} + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["hostname"], + "properties": { + "hostname": {"type": "string", "description": "Hostname of the service that is requesting to be crawled."} + } } } } diff --git a/packages/api/src/client/index.ts b/packages/api/src/client/index.ts index 6328c8c4768..e74bee840e0 100644 --- a/packages/api/src/client/index.ts +++ b/packages/api/src/client/index.ts @@ -982,22 +982,22 @@ export class SyncNS { } notifyOfUpdate( - params?: ComAtprotoSyncNotifyOfUpdate.QueryParams, + data?: ComAtprotoSyncNotifyOfUpdate.InputSchema, opts?: ComAtprotoSyncNotifyOfUpdate.CallOptions, ): Promise { return this._service.xrpc - .call('com.atproto.sync.notifyOfUpdate', params, undefined, opts) + .call('com.atproto.sync.notifyOfUpdate', opts?.qp, data, opts) .catch((e) => { throw ComAtprotoSyncNotifyOfUpdate.toKnownErr(e) }) } requestCrawl( - params?: ComAtprotoSyncRequestCrawl.QueryParams, + data?: ComAtprotoSyncRequestCrawl.InputSchema, opts?: ComAtprotoSyncRequestCrawl.CallOptions, ): Promise { return this._service.xrpc - .call('com.atproto.sync.requestCrawl', params, undefined, opts) + .call('com.atproto.sync.requestCrawl', opts?.qp, data, opts) .catch((e) => { throw ComAtprotoSyncRequestCrawl.toKnownErr(e) }) diff --git a/packages/api/src/client/lexicons.ts b/packages/api/src/client/lexicons.ts index 7215be028ee..cb409c558f5 100644 --- a/packages/api/src/client/lexicons.ts +++ b/packages/api/src/client/lexicons.ts @@ -3248,17 +3248,20 @@ export const schemaDict = { id: 'com.atproto.sync.notifyOfUpdate', defs: { main: { - type: 'query', + type: 'procedure', description: 'Notify a crawling service of a recent update. Often when a long break between updates causes the connection with the crawling service to break.', - parameters: { - type: 'params', - required: ['hostname'], - properties: { - hostname: { - type: 'string', - description: - 'Hostname of the service that is notifying of update.', + input: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['hostname'], + properties: { + hostname: { + type: 'string', + description: + 'Hostname of the service that is notifying of update.', + }, }, }, }, @@ -3270,16 +3273,19 @@ export const schemaDict = { id: 'com.atproto.sync.requestCrawl', defs: { main: { - type: 'query', + type: 'procedure', description: 'Request a service to persistently crawl hosted repos.', - parameters: { - type: 'params', - required: ['hostname'], - properties: { - hostname: { - type: 'string', - description: - 'Hostname of the service that is requesting to be crawled.', + input: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['hostname'], + properties: { + hostname: { + type: 'string', + description: + 'Hostname of the service that is requesting to be crawled.', + }, }, }, }, diff --git a/packages/api/src/client/types/com/atproto/sync/notifyOfUpdate.ts b/packages/api/src/client/types/com/atproto/sync/notifyOfUpdate.ts index fdd03750d7c..2b098982684 100644 --- a/packages/api/src/client/types/com/atproto/sync/notifyOfUpdate.ts +++ b/packages/api/src/client/types/com/atproto/sync/notifyOfUpdate.ts @@ -7,15 +7,18 @@ import { isObj, hasProp } from '../../../../util' import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -export interface QueryParams { +export interface QueryParams {} + +export interface InputSchema { /** Hostname of the service that is notifying of update. */ hostname: string + [k: string]: unknown } -export type InputSchema = undefined - export interface CallOptions { headers?: Headers + qp?: QueryParams + encoding: 'application/json' } export interface Response { diff --git a/packages/api/src/client/types/com/atproto/sync/requestCrawl.ts b/packages/api/src/client/types/com/atproto/sync/requestCrawl.ts index b517ed4574f..c07330a6fb1 100644 --- a/packages/api/src/client/types/com/atproto/sync/requestCrawl.ts +++ b/packages/api/src/client/types/com/atproto/sync/requestCrawl.ts @@ -7,15 +7,18 @@ import { isObj, hasProp } from '../../../../util' import { lexicons } from '../../../../lexicons' import { CID } from 'multiformats/cid' -export interface QueryParams { +export interface QueryParams {} + +export interface InputSchema { /** Hostname of the service that is requesting to be crawled. */ hostname: string + [k: string]: unknown } -export type InputSchema = undefined - export interface CallOptions { headers?: Headers + qp?: QueryParams + encoding: 'application/json' } export interface Response { diff --git a/packages/bsky/src/lexicon/lexicons.ts b/packages/bsky/src/lexicon/lexicons.ts index 7215be028ee..cb409c558f5 100644 --- a/packages/bsky/src/lexicon/lexicons.ts +++ b/packages/bsky/src/lexicon/lexicons.ts @@ -3248,17 +3248,20 @@ export const schemaDict = { id: 'com.atproto.sync.notifyOfUpdate', defs: { main: { - type: 'query', + type: 'procedure', description: 'Notify a crawling service of a recent update. Often when a long break between updates causes the connection with the crawling service to break.', - parameters: { - type: 'params', - required: ['hostname'], - properties: { - hostname: { - type: 'string', - description: - 'Hostname of the service that is notifying of update.', + input: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['hostname'], + properties: { + hostname: { + type: 'string', + description: + 'Hostname of the service that is notifying of update.', + }, }, }, }, @@ -3270,16 +3273,19 @@ export const schemaDict = { id: 'com.atproto.sync.requestCrawl', defs: { main: { - type: 'query', + type: 'procedure', description: 'Request a service to persistently crawl hosted repos.', - parameters: { - type: 'params', - required: ['hostname'], - properties: { - hostname: { - type: 'string', - description: - 'Hostname of the service that is requesting to be crawled.', + input: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['hostname'], + properties: { + hostname: { + type: 'string', + description: + 'Hostname of the service that is requesting to be crawled.', + }, }, }, }, diff --git a/packages/bsky/src/lexicon/types/com/atproto/sync/notifyOfUpdate.ts b/packages/bsky/src/lexicon/types/com/atproto/sync/notifyOfUpdate.ts index 8cd27fd7203..df921fb8bc2 100644 --- a/packages/bsky/src/lexicon/types/com/atproto/sync/notifyOfUpdate.ts +++ b/packages/bsky/src/lexicon/types/com/atproto/sync/notifyOfUpdate.ts @@ -8,13 +8,18 @@ import { isObj, hasProp } from '../../../../util' import { CID } from 'multiformats/cid' import { HandlerAuth } from '@atproto/xrpc-server' -export interface QueryParams { +export interface QueryParams {} + +export interface InputSchema { /** Hostname of the service that is notifying of update. */ hostname: string + [k: string]: unknown } -export type InputSchema = undefined -export type HandlerInput = undefined +export interface HandlerInput { + encoding: 'application/json' + body: InputSchema +} export interface HandlerError { status: number diff --git a/packages/bsky/src/lexicon/types/com/atproto/sync/requestCrawl.ts b/packages/bsky/src/lexicon/types/com/atproto/sync/requestCrawl.ts index 4ae875dbab5..c634409f6ba 100644 --- a/packages/bsky/src/lexicon/types/com/atproto/sync/requestCrawl.ts +++ b/packages/bsky/src/lexicon/types/com/atproto/sync/requestCrawl.ts @@ -8,13 +8,18 @@ import { isObj, hasProp } from '../../../../util' import { CID } from 'multiformats/cid' import { HandlerAuth } from '@atproto/xrpc-server' -export interface QueryParams { +export interface QueryParams {} + +export interface InputSchema { /** Hostname of the service that is requesting to be crawled. */ hostname: string + [k: string]: unknown } -export type InputSchema = undefined -export type HandlerInput = undefined +export interface HandlerInput { + encoding: 'application/json' + body: InputSchema +} export interface HandlerError { status: number diff --git a/packages/pds/src/lexicon/lexicons.ts b/packages/pds/src/lexicon/lexicons.ts index 7215be028ee..cb409c558f5 100644 --- a/packages/pds/src/lexicon/lexicons.ts +++ b/packages/pds/src/lexicon/lexicons.ts @@ -3248,17 +3248,20 @@ export const schemaDict = { id: 'com.atproto.sync.notifyOfUpdate', defs: { main: { - type: 'query', + type: 'procedure', description: 'Notify a crawling service of a recent update. Often when a long break between updates causes the connection with the crawling service to break.', - parameters: { - type: 'params', - required: ['hostname'], - properties: { - hostname: { - type: 'string', - description: - 'Hostname of the service that is notifying of update.', + input: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['hostname'], + properties: { + hostname: { + type: 'string', + description: + 'Hostname of the service that is notifying of update.', + }, }, }, }, @@ -3270,16 +3273,19 @@ export const schemaDict = { id: 'com.atproto.sync.requestCrawl', defs: { main: { - type: 'query', + type: 'procedure', description: 'Request a service to persistently crawl hosted repos.', - parameters: { - type: 'params', - required: ['hostname'], - properties: { - hostname: { - type: 'string', - description: - 'Hostname of the service that is requesting to be crawled.', + input: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['hostname'], + properties: { + hostname: { + type: 'string', + description: + 'Hostname of the service that is requesting to be crawled.', + }, }, }, }, diff --git a/packages/pds/src/lexicon/types/com/atproto/sync/notifyOfUpdate.ts b/packages/pds/src/lexicon/types/com/atproto/sync/notifyOfUpdate.ts index 8cd27fd7203..df921fb8bc2 100644 --- a/packages/pds/src/lexicon/types/com/atproto/sync/notifyOfUpdate.ts +++ b/packages/pds/src/lexicon/types/com/atproto/sync/notifyOfUpdate.ts @@ -8,13 +8,18 @@ import { isObj, hasProp } from '../../../../util' import { CID } from 'multiformats/cid' import { HandlerAuth } from '@atproto/xrpc-server' -export interface QueryParams { +export interface QueryParams {} + +export interface InputSchema { /** Hostname of the service that is notifying of update. */ hostname: string + [k: string]: unknown } -export type InputSchema = undefined -export type HandlerInput = undefined +export interface HandlerInput { + encoding: 'application/json' + body: InputSchema +} export interface HandlerError { status: number diff --git a/packages/pds/src/lexicon/types/com/atproto/sync/requestCrawl.ts b/packages/pds/src/lexicon/types/com/atproto/sync/requestCrawl.ts index 4ae875dbab5..c634409f6ba 100644 --- a/packages/pds/src/lexicon/types/com/atproto/sync/requestCrawl.ts +++ b/packages/pds/src/lexicon/types/com/atproto/sync/requestCrawl.ts @@ -8,13 +8,18 @@ import { isObj, hasProp } from '../../../../util' import { CID } from 'multiformats/cid' import { HandlerAuth } from '@atproto/xrpc-server' -export interface QueryParams { +export interface QueryParams {} + +export interface InputSchema { /** Hostname of the service that is requesting to be crawled. */ hostname: string + [k: string]: unknown } -export type InputSchema = undefined -export type HandlerInput = undefined +export interface HandlerInput { + encoding: 'application/json' + body: InputSchema +} export interface HandlerError { status: number