Skip to content

Commit

Permalink
proposed new search lexicons (#1594)
Browse files Browse the repository at this point in the history
* proposed new search lexicons

* lexicons: lint

* lexicons: fix actors typo

* lexicons: camelCase bites again, ssssss

* lexicons: add 'q' and mark 'term' as deprecated for search endpoints

* codegen for search lexicon updates

* bsky: prefer 'q' over 'term' in existing search endpoints

* search: bugfix

* lexicons: make unspecced search endpoints return skeleton obj

* re-codegen for search skeleton obj
  • Loading branch information
bnewbold authored Sep 25, 2023
1 parent 4a64944 commit 233a132
Show file tree
Hide file tree
Showing 37 changed files with 1,671 additions and 17 deletions.
13 changes: 10 additions & 3 deletions lexicons/app/bsky/actor/searchActors.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@
"defs": {
"main": {
"type": "query",
"description": "Find actors matching search criteria.",
"description": "Find actors (profiles) matching search criteria.",
"parameters": {
"type": "params",
"properties": {
"term": { "type": "string" },
"term": {
"type": "string",
"description": "DEPRECATED: use 'q' instead"
},
"q": {
"type": "string",
"description": "search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended"
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 50
"default": 25
},
"cursor": { "type": "string" }
}
Expand Down
11 changes: 9 additions & 2 deletions lexicons/app/bsky/actor/searchActorsTypeahead.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@
"parameters": {
"type": "params",
"properties": {
"term": { "type": "string" },
"term": {
"type": "string",
"description": "DEPRECATED: use 'q' instead"
},
"q": {
"type": "string",
"description": "search query prefix; not a full query string"
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 50
"default": 10
}
}
},
Expand Down
52 changes: 52 additions & 0 deletions lexicons/app/bsky/feed/searchPosts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"lexicon": 1,
"id": "app.bsky.feed.searchPosts",
"defs": {
"main": {
"type": "query",
"description": "Find posts matching search criteria",
"parameters": {
"type": "params",
"required": ["q"],
"properties": {
"q": {
"type": "string",
"description": "search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended"
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 25
},
"cursor": {
"type": "string",
"description": "optional pagination mechanism; may not necessarily allow scrolling through entire result set"
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["posts"],
"properties": {
"cursor": { "type": "string" },
"hitsTotal": {
"type": "integer",
"description": "count of search hits. optional, may be rounded/truncated, and may not be possible to paginate through all hits"
},
"posts": {
"type": "array",
"items": {
"type": "ref",
"ref": "app.bsky.feed.defs#postView"
}
}
}
}
},
"errors": [{ "name": "BadQueryString" }]
}
}
}
20 changes: 20 additions & 0 deletions lexicons/app/bsky/unspecced/defs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"lexicon": 1,
"id": "app.bsky.unspecced.defs",
"defs": {
"skeletonSearchPost": {
"type": "object",
"required": ["uri"],
"properties": {
"uri": { "type": "string", "format": "at-uri" }
}
},
"skeletonSearchActor": {
"type": "object",
"required": ["did"],
"properties": {
"did": { "type": "string", "format": "did" }
}
}
}
}
56 changes: 56 additions & 0 deletions lexicons/app/bsky/unspecced/searchActorsSkeleton.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"lexicon": 1,
"id": "app.bsky.unspecced.searchActorsSkeleton",
"defs": {
"main": {
"type": "query",
"description": "Backend Actors (profile) search, returning only skeleton",
"parameters": {
"type": "params",
"required": ["q"],
"properties": {
"q": {
"type": "string",
"description": "search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended. For typeahead search, only simple term match is supported, not full syntax"
},
"typeahead": {
"type": "boolean",
"description": "if true, acts as fast/simple 'typeahead' query"
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 25
},
"cursor": {
"type": "string",
"description": "optional pagination mechanism; may not necessarily allow scrolling through entire result set"
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["actors"],
"properties": {
"cursor": { "type": "string" },
"hitsTotal": {
"type": "integer",
"description": "count of search hits. optional, may be rounded/truncated, and may not be possible to paginate through all hits"
},
"actors": {
"type": "array",
"items": {
"type": "ref",
"ref": "app.bsky.unspecced.defs#skeletonSearchActor"
}
}
}
}
},
"errors": [{ "name": "BadQueryString" }]
}
}
}
52 changes: 52 additions & 0 deletions lexicons/app/bsky/unspecced/searchPostsSkeleton.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"lexicon": 1,
"id": "app.bsky.unspecced.searchPostsSkeleton",
"defs": {
"main": {
"type": "query",
"description": "Backend Posts search, returning only skeleton",
"parameters": {
"type": "params",
"required": ["q"],
"properties": {
"q": {
"type": "string",
"description": "search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended"
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 25
},
"cursor": {
"type": "string",
"description": "optional pagination mechanism; may not necessarily allow scrolling through entire result set"
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["posts"],
"properties": {
"cursor": { "type": "string" },
"hitsTotal": {
"type": "integer",
"description": "count of search hits. optional, may be rounded/truncated, and may not be possible to paginate through all hits"
},
"posts": {
"type": "array",
"items": {
"type": "ref",
"ref": "app.bsky.unspecced.defs#skeletonSearchPost"
}
}
}
}
},
"errors": [{ "name": "BadQueryString" }]
}
}
}
6 changes: 5 additions & 1 deletion lexicons/com/atproto/admin/searchRepos.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
"parameters": {
"type": "params",
"properties": {
"term": { "type": "string" },
"term": {
"type": "string",
"description": "DEPRECATED: use 'q' instead"
},
"q": { "type": "string" },
"invitedBy": { "type": "string" },
"limit": {
"type": "integer",
Expand Down
41 changes: 41 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import * as AppBskyFeedGetTimeline from './types/app/bsky/feed/getTimeline'
import * as AppBskyFeedLike from './types/app/bsky/feed/like'
import * as AppBskyFeedPost from './types/app/bsky/feed/post'
import * as AppBskyFeedRepost from './types/app/bsky/feed/repost'
import * as AppBskyFeedSearchPosts from './types/app/bsky/feed/searchPosts'
import * as AppBskyFeedThreadgate from './types/app/bsky/feed/threadgate'
import * as AppBskyGraphBlock from './types/app/bsky/graph/block'
import * as AppBskyGraphDefs from './types/app/bsky/graph/defs'
Expand All @@ -129,9 +130,12 @@ 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 AppBskyUnspeccedApplyLabels from './types/app/bsky/unspecced/applyLabels'
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 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'

export * as ComAtprotoAdminDefs from './types/com/atproto/admin/defs'
export * as ComAtprotoAdminDisableAccountInvites from './types/com/atproto/admin/disableAccountInvites'
Expand Down Expand Up @@ -229,6 +233,7 @@ export * as AppBskyFeedGetTimeline from './types/app/bsky/feed/getTimeline'
export * as AppBskyFeedLike from './types/app/bsky/feed/like'
export * as AppBskyFeedPost from './types/app/bsky/feed/post'
export * as AppBskyFeedRepost from './types/app/bsky/feed/repost'
export * as AppBskyFeedSearchPosts from './types/app/bsky/feed/searchPosts'
export * as AppBskyFeedThreadgate from './types/app/bsky/feed/threadgate'
export * as AppBskyGraphBlock from './types/app/bsky/graph/block'
export * as AppBskyGraphDefs from './types/app/bsky/graph/defs'
Expand All @@ -255,9 +260,12 @@ 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 AppBskyUnspeccedApplyLabels from './types/app/bsky/unspecced/applyLabels'
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 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'

export const COM_ATPROTO_ADMIN = {
DefsTakedown: 'com.atproto.admin.defs#takedown',
Expand Down Expand Up @@ -1381,6 +1389,17 @@ export class FeedNS {
throw AppBskyFeedGetTimeline.toKnownErr(e)
})
}

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

export class GeneratorRecord {
Expand Down Expand Up @@ -2282,4 +2301,26 @@ export class UnspeccedNS {
throw AppBskyUnspeccedGetTimelineSkeleton.toKnownErr(e)
})
}

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

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

0 comments on commit 233a132

Please sign in to comment.