diff --git a/api/org_tangled/searchsearchCode.go b/api/org_tangled/searchsearchCode.go index c7aee7755..da8c4c63f 100644 --- a/api/org_tangled/searchsearchCode.go +++ b/api/org_tangled/searchsearchCode.go @@ -8,6 +8,7 @@ import ( "context" "github.com/bluesky-social/indigo/lex/util" + shtangledtypes "tangled.org/core/api/tangled" ) const ( @@ -26,13 +27,17 @@ type TempSearchSearchCode_Chunk struct { // TempSearchSearchCode_FileResult is a "fileResult" in the org.tangled.temp.search.searchCode schema. type TempSearchSearchCode_FileResult struct { - Chunks []*TempSearchSearchCode_Chunk `json:"chunks" cborgen:"chunks"` + Branches []string `json:"branches,omitempty" cborgen:"branches,omitempty"` + // chunks: set for content matches + Chunks []*TempSearchSearchCode_Chunk `json:"chunks,omitempty" cborgen:"chunks,omitempty"` + Commit string `json:"commit" cborgen:"commit"` // language: Detected programming language. Language *string `json:"language,omitempty" cborgen:"language,omitempty"` // path: File path relative to repository root. Path string `json:"path" cborgen:"path"` - // repoDid: DID of the repository as minted by the knot. - RepoDid string `json:"repoDid" cborgen:"repoDid"` + // ranges: set for a filename match + Ranges []*TempSearchSearchCode_Highlight `json:"ranges,omitempty" cborgen:"ranges,omitempty"` + Repo *shtangledtypes.RepoDefs_RepoViewBasic `json:"repo" cborgen:"repo"` } // TempSearchSearchCode_Highlight is a "highlight" in the org.tangled.temp.search.searchCode schema. @@ -51,25 +56,21 @@ type TempSearchSearchCode_Output struct { // TempSearchSearchCode calls the XRPC method "org.tangled.temp.search.searchCode". // -// lang: Restrict search to a specific programming language (e.g. 'go', 'rust'). // q: Search query string. -// repoDid: Restrict search to a specific repository, by its DID. -func TempSearchSearchCode(ctx context.Context, c util.LexClient, cursor string, lang string, limit int64, q string, repoDid string) (*TempSearchSearchCode_Output, error) { +// repo: Restrict search to a specific repository, by its DID. +func TempSearchSearchCode(ctx context.Context, c util.LexClient, cursor string, limit int64, q string, repo string) (*TempSearchSearchCode_Output, error) { var out TempSearchSearchCode_Output params := map[string]interface{}{} if cursor != "" { params["cursor"] = cursor } - if lang != "" { - params["lang"] = lang - } if limit != 0 { params["limit"] = limit } params["q"] = q - if repoDid != "" { - params["repoDid"] = repoDid + if repo != "" { + params["repo"] = repo } if err := c.LexDo(ctx, util.Query, "", "org.tangled.temp.search.searchCode", params, nil, &out); err != nil { return nil, err diff --git a/lexicons/temp/search/searchCode.json b/lexicons/temp/search/searchCode.json index 92256cfb2..15b0ace4c 100644 --- a/lexicons/temp/search/searchCode.json +++ b/lexicons/temp/search/searchCode.json @@ -13,15 +13,11 @@ "type": "string", "description": "Search query string." }, - "repoDid": { + "repo": { "type": "string", "format": "did", "description": "Restrict search to a specific repository, by its DID." }, - "lang": { - "type": "string", - "description": "Restrict search to a specific programming language (e.g. 'go', 'rust')." - }, "limit": { "type": "integer", "minimum": 1, @@ -54,23 +50,36 @@ }, "fileResult": { "type": "object", - "required": ["repoDid", "path", "chunks"], + "required": ["repo", "path", "commit"], "properties": { - "repoDid": { - "type": "string", - "format": "did", - "description": "DID of the repository as minted by the knot." + "repo": { + "type": "ref", + "ref": "sh.tangled.repo.defs#repoViewBasic" }, "path": { "type": "string", "description": "File path relative to repository root." }, + "branches": { + "type": "array", + "items": { "type": "string" } + }, + "commit": { "type": "string" }, "language": { "type": "string", "description": "Detected programming language." }, + "ranges": { + "type": "array", + "description": "set for a filename match", + "items": { + "type": "ref", + "ref": "#highlight" + } + }, "chunks": { "type": "array", + "description": "set for content matches", "items": { "type": "ref", "ref": "#chunk" diff --git a/web/src/lib/api/lexicons/types/org/tangled/temp/search/searchCode.ts b/web/src/lib/api/lexicons/types/org/tangled/temp/search/searchCode.ts index 4a124f68f..cafc04da3 100644 --- a/web/src/lib/api/lexicons/types/org/tangled/temp/search/searchCode.ts +++ b/web/src/lib/api/lexicons/types/org/tangled/temp/search/searchCode.ts @@ -1,6 +1,7 @@ import type {} from "@atcute/lexicons"; import * as v from "@atcute/lexicons/validations"; import type {} from "@atcute/lexicons/ambient"; +import * as ShTangledRepoDefs from "../../../../sh/tangled/repo/defs.js"; const _chunkSchema = /*#__PURE__*/ v.object({ $type: /*#__PURE__*/ v.optional( @@ -25,9 +26,16 @@ const _fileResultSchema = /*#__PURE__*/ v.object({ $type: /*#__PURE__*/ v.optional( /*#__PURE__*/ v.literal("org.tangled.temp.search.searchCode#fileResult"), ), + branches: /*#__PURE__*/ v.optional( + /*#__PURE__*/ v.array(/*#__PURE__*/ v.string()), + ), + /** + * set for content matches + */ get chunks() { - return /*#__PURE__*/ v.array(chunkSchema); + return /*#__PURE__*/ v.optional(/*#__PURE__*/ v.array(chunkSchema)); }, + commit: /*#__PURE__*/ v.string(), /** * Detected programming language. */ @@ -37,9 +45,14 @@ const _fileResultSchema = /*#__PURE__*/ v.object({ */ path: /*#__PURE__*/ v.string(), /** - * DID of the repository as minted by the knot. + * set for a filename match */ - repoDid: /*#__PURE__*/ v.didString(), + get ranges() { + return /*#__PURE__*/ v.optional(/*#__PURE__*/ v.array(highlightSchema)); + }, + get repo() { + return ShTangledRepoDefs.repoViewBasicSchema; + }, }); const _highlightSchema = /*#__PURE__*/ v.object({ $type: /*#__PURE__*/ v.optional( @@ -59,10 +72,6 @@ const _mainSchema = /*#__PURE__*/ v.query( { params: /*#__PURE__*/ v.object({ cursor: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.string()), - /** - * Restrict search to a specific programming language (e.g. 'go', 'rust'). - */ - lang: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.string()), /** * @minimum 1 * @maximum 100 @@ -79,7 +88,7 @@ const _mainSchema = /*#__PURE__*/ v.query( /** * Restrict search to a specific repository, by its DID. */ - repoDid: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.didString()), + repo: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.didString()), }), output: { type: "lex",