From 46d18d69795fdc58407c68475e2b97253dab0979 Mon Sep 17 00:00:00 2001 From: Lewis Date: Tue, 23 Jun 2026 12:50:03 +0300 Subject: [PATCH] lexicons/sync: getRepoRefs & listRepos Lewis: May this revision serve well! --- api/tangled/gitlistRefs.go | 62 ++++++++++++++++++++ api/tangled/synclistRepos.go | 62 ++++++++++++++++++++ lexicons/git/listRefs.json | 100 ++++++++++++++++++++++++++++++++ lexicons/repo/describeRepo.json | 1 + lexicons/sync/listRepos.json | 90 ++++++++++++++++++++++++++++ 5 files changed, 315 insertions(+) create mode 100644 api/tangled/gitlistRefs.go create mode 100644 api/tangled/synclistRepos.go create mode 100644 lexicons/git/listRefs.json create mode 100644 lexicons/sync/listRepos.json diff --git a/api/tangled/gitlistRefs.go b/api/tangled/gitlistRefs.go new file mode 100644 index 00000000..90878e91 --- /dev/null +++ b/api/tangled/gitlistRefs.go @@ -0,0 +1,62 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package tangled + +// schema: sh.tangled.git.listRefs + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + GitListRefsNSID = "sh.tangled.git.listRefs" +) + +// GitListRefs_DefaultBranch is a "defaultBranch" in the sh.tangled.git.listRefs schema. +type GitListRefs_DefaultBranch struct { + // head: Commit SHA at the tip of the default branch, for reconciling against a last-known state. Width depends on the repo's git object-format. + Head *string `json:"head,omitempty" cborgen:"head,omitempty"` + // ref: Default branch ref name that HEAD points at, eg. refs/heads/main. + Ref string `json:"ref" cborgen:"ref"` +} + +// GitListRefs_Output is the output of a sh.tangled.git.listRefs call. +type GitListRefs_Output struct { + // cursor: Cursor for the next page, absent when the last page is reached + Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"` + DefaultBranch *GitListRefs_DefaultBranch `json:"defaultBranch,omitempty" cborgen:"defaultBranch,omitempty"` + Refs []*GitListRefs_Ref `json:"refs" cborgen:"refs"` +} + +// GitListRefs_Ref is a "ref" in the sh.tangled.git.listRefs schema. +type GitListRefs_Ref struct { + // ref: Full ref name, eg. refs/heads/main or refs/tags/v1.0 + Ref string `json:"ref" cborgen:"ref"` + // sha: Object SHA the ref points at. Width depends on the repo's git object-format. + Sha string `json:"sha" cborgen:"sha"` +} + +// GitListRefs calls the XRPC method "sh.tangled.git.listRefs". +// +// cursor: Pagination cursor +// limit: Maximum number of refs to return in this page +// repo: DID of the git repo as minted by the knot +func GitListRefs(ctx context.Context, c util.LexClient, cursor string, limit int64, repo string) (*GitListRefs_Output, error) { + var out GitListRefs_Output + + params := map[string]interface{}{} + if cursor != "" { + params["cursor"] = cursor + } + if limit != 0 { + params["limit"] = limit + } + params["repo"] = repo + if err := c.LexDo(ctx, util.Query, "", "sh.tangled.git.listRefs", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/api/tangled/synclistRepos.go b/api/tangled/synclistRepos.go new file mode 100644 index 00000000..cf2db8eb --- /dev/null +++ b/api/tangled/synclistRepos.go @@ -0,0 +1,62 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package tangled + +// schema: sh.tangled.sync.listRepos + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + SyncListReposNSID = "sh.tangled.sync.listRepos" +) + +// SyncListRepos_DefaultBranch is a "defaultBranch" in the sh.tangled.sync.listRepos schema. +type SyncListRepos_DefaultBranch struct { + // head: Commit SHA at the tip of the default branch, for reconciling against a last-known state. Width depends on the repo's git object-format. + Head *string `json:"head,omitempty" cborgen:"head,omitempty"` + // ref: Default branch ref name, eg. refs/heads/main. + Ref string `json:"ref" cborgen:"ref"` +} + +// SyncListRepos_Output is the output of a sh.tangled.sync.listRepos call. +type SyncListRepos_Output struct { + Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"` + Repos []*SyncListRepos_Repo `json:"repos" cborgen:"repos"` +} + +// SyncListRepos_Repo is a "repo" in the sh.tangled.sync.listRepos schema. +type SyncListRepos_Repo struct { + DefaultBranch *SyncListRepos_DefaultBranch `json:"defaultBranch,omitempty" cborgen:"defaultBranch,omitempty"` + // repo: DID of the git repo as minted by the knot + Repo string `json:"repo" cborgen:"repo"` + // status: Serving status of the repo according to the knot. + Status string `json:"status" cborgen:"status"` +} + +// SyncListRepos calls the XRPC method "sh.tangled.sync.listRepos". +// +// cursor: Pagination cursor +// order: Sort direction over the service's repo listing order. +func SyncListRepos(ctx context.Context, c util.LexClient, cursor string, limit int64, order string) (*SyncListRepos_Output, error) { + var out SyncListRepos_Output + + params := map[string]interface{}{} + if cursor != "" { + params["cursor"] = cursor + } + if limit != 0 { + params["limit"] = limit + } + if order != "" { + params["order"] = order + } + if err := c.LexDo(ctx, util.Query, "", "sh.tangled.sync.listRepos", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/lexicons/git/listRefs.json b/lexicons/git/listRefs.json new file mode 100644 index 00000000..5ee0661a --- /dev/null +++ b/lexicons/git/listRefs.json @@ -0,0 +1,100 @@ +{ + "lexicon": 1, + "id": "sh.tangled.git.listRefs", + "defs": { + "main": { + "type": "query", + "description": "List every ref & its commit SHA for a git repo, equivalent to git ls-remote. Gives the full ref state of a repo.", + "parameters": { + "type": "params", + "required": ["repo"], + "properties": { + "repo": { + "type": "string", + "format": "did", + "description": "DID of the git repo as minted by the knot" + }, + "limit": { + "type": "integer", + "minimum": 1, + "maximum": 1000, + "default": 100, + "description": "Maximum number of refs to return in this page" + }, + "cursor": { + "type": "string", + "description": "Pagination cursor" + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["refs"], + "properties": { + "refs": { + "type": "array", + "items": { "type": "ref", "ref": "#ref" }, + "maxLength": 1000 + }, + "cursor": { + "type": "string", + "description": "Cursor for the next page, absent when the last page is reached" + }, + "defaultBranch": { + "type": "ref", + "ref": "#defaultBranch" + } + } + } + }, + "errors": [ + { + "name": "RepoNotFound", + "description": "Repo is not registered on this knot" + }, + { + "name": "InvalidRequest", + "description": "Invalid request parameters" + } + ] + }, + "ref": { + "type": "object", + "required": ["ref", "sha"], + "properties": { + "ref": { + "type": "string", + "description": "Full ref name, eg. refs/heads/main or refs/tags/v1.0", + "maxGraphemes": 256, + "maxLength": 2560 + }, + "sha": { + "type": "string", + "description": "Object SHA the ref points at. Width depends on the repo's git object-format.", + "minLength": 40, + "maxLength": 128 + } + } + }, + "defaultBranch": { + "type": "object", + "required": ["ref"], + "properties": { + "ref": { + "type": "string", + "description": "Default branch ref name that HEAD points at, eg. refs/heads/main.", + "maxGraphemes": 256, + "maxLength": 2560 + }, + "head": { + "type": "string", + "description": "Commit SHA at the tip of the default branch, for reconciling against a last-known state. Width depends on the repo's git object-format.", + "minLength": 40, + "maxLength": 128 + } + } + } + } +} diff --git a/lexicons/repo/describeRepo.json b/lexicons/repo/describeRepo.json index a3ba3162..96a0f643 100644 --- a/lexicons/repo/describeRepo.json +++ b/lexicons/repo/describeRepo.json @@ -33,6 +33,7 @@ }, "rkey": { "type": "string", + "format": "record-key", "description": "Current rkey of the sh.tangled.repo record tracked by this knot" } } diff --git a/lexicons/sync/listRepos.json b/lexicons/sync/listRepos.json new file mode 100644 index 00000000..22011539 --- /dev/null +++ b/lexicons/sync/listRepos.json @@ -0,0 +1,90 @@ +{ + "lexicon": 1, + "id": "sh.tangled.sync.listRepos", + "defs": { + "main": { + "type": "query", + "description": "List git repos hosted on this service.", + "parameters": { + "type": "params", + "properties": { + "cursor": { + "type": "string", + "description": "Pagination cursor" + }, + "limit": { + "type": "integer", + "minimum": 1, + "maximum": 1000, + "default": 50 + }, + "order": { + "type": "string", + "knownValues": ["asc", "desc"], + "default": "desc", + "description": "Sort direction over the service's repo listing order." + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["repos"], + "properties": { + "repos": { + "type": "array", + "items": { "type": "ref", "ref": "#repo" }, + "maxLength": 1000 + }, + "cursor": { "type": "string" } + } + } + }, + "errors": [ + { + "name": "InvalidRequest", + "description": "Invalid request parameters" + } + ] + }, + "repo": { + "type": "object", + "required": ["repo", "status"], + "properties": { + "repo": { + "type": "string", + "format": "did", + "description": "DID of the git repo as minted by the knot" + }, + "status": { + "type": "string", + "knownValues": ["active", "archived", "disabled"], + "description": "Serving status of the repo according to the knot." + }, + "defaultBranch": { + "type": "ref", + "ref": "#defaultBranch" + } + } + }, + "defaultBranch": { + "type": "object", + "required": ["ref"], + "properties": { + "ref": { + "type": "string", + "description": "Default branch ref name, eg. refs/heads/main.", + "maxGraphemes": 256, + "maxLength": 2560 + }, + "head": { + "type": "string", + "description": "Commit SHA at the tip of the default branch, for reconciling against a last-known state. Width depends on the repo's git object-format.", + "minLength": 40, + "maxLength": 128 + } + } + } + } +} -- 2.51.2