diff --git a/api/tangled/gitkeepCommit.go b/api/tangled/gitkeepCommit.go new file mode 100644 --- /dev/null +++ b/api/tangled/gitkeepCommit.go @@ -0,0 +1,92 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package tangled + +// schema: sh.tangled.git.keepCommit + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + GitKeepCommitNSID = "sh.tangled.git.keepCommit" +) + +// GitKeepCommit_Commit is a "commit" in the sh.tangled.git.keepCommit schema. +// +// RECORDTYPE: GitKeepCommit_Commit +type GitKeepCommit_Commit struct { + LexiconTypeID string `json:"$type,const=sh.tangled.git.keepCommit#commit" cborgen:"$type,const=sh.tangled.git.keepCommit#commit"` + Oid string `json:"oid" cborgen:"oid"` + Repo string `json:"repo" cborgen:"repo"` +} + +// GitKeepCommit_Input is the input argument to a sh.tangled.git.keepCommit call. +type GitKeepCommit_Input struct { + // record: at-uri of target record. rkey is required + Record string `json:"record" cborgen:"record"` + Repo string `json:"repo" cborgen:"repo"` + Source *GitKeepCommit_Input_Source `json:"source" cborgen:"source"` +} + +type GitKeepCommit_Input_Source struct { + GitKeepCommit_Commit *GitKeepCommit_Commit + GitKeepCommit_Patches *GitKeepCommit_Patches +} + +func (t *GitKeepCommit_Input_Source) MarshalJSON() ([]byte, error) { + if t.GitKeepCommit_Commit != nil { + t.GitKeepCommit_Commit.LexiconTypeID = "sh.tangled.git.keepCommit#commit" + return json.Marshal(t.GitKeepCommit_Commit) + } + if t.GitKeepCommit_Patches != nil { + t.GitKeepCommit_Patches.LexiconTypeID = "sh.tangled.git.keepCommit#patches" + return json.Marshal(t.GitKeepCommit_Patches) + } + return nil, fmt.Errorf("cannot marshal empty enum") +} +func (t *GitKeepCommit_Input_Source) UnmarshalJSON(b []byte) error { + typ, err := util.TypeExtract(b) + if err != nil { + return err + } + + switch typ { + case "sh.tangled.git.keepCommit#commit": + t.GitKeepCommit_Commit = new(GitKeepCommit_Commit) + return json.Unmarshal(b, t.GitKeepCommit_Commit) + case "sh.tangled.git.keepCommit#patches": + t.GitKeepCommit_Patches = new(GitKeepCommit_Patches) + return json.Unmarshal(b, t.GitKeepCommit_Patches) + + default: + return nil + } +} + +// GitKeepCommit_Output is the output of a sh.tangled.git.keepCommit call. +type GitKeepCommit_Output struct { + Commit string `json:"commit" cborgen:"commit"` +} + +// GitKeepCommit_Patches is a "patches" in the sh.tangled.git.keepCommit schema. +// +// RECORDTYPE: GitKeepCommit_Patches +type GitKeepCommit_Patches struct { + LexiconTypeID string `json:"$type,const=sh.tangled.git.keepCommit#patches" cborgen:"$type,const=sh.tangled.git.keepCommit#patches"` + Patches []string `json:"patches,omitempty" cborgen:"patches,omitempty"` +} + +// GitKeepCommit calls the XRPC method "sh.tangled.git.keepCommit". +func GitKeepCommit(ctx context.Context, c util.LexClient, input *GitKeepCommit_Input) (*GitKeepCommit_Output, error) { + var out GitKeepCommit_Output + if err := c.LexDo(ctx, util.Procedure, "application/json", "sh.tangled.git.keepCommit", nil, input, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/lexicons/git/keepCommit.json b/lexicons/git/keepCommit.json new file mode 100644 --- /dev/null +++ b/lexicons/git/keepCommit.json @@ -0,0 +1,89 @@ +{ + "lexicon": 1, + "id": "sh.tangled.git.keepCommit", + "defs": { + "main": { + "type": "procedure", + "description": "Keep commit for an atproto record.", + "input": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["repo", "source", "record"], + "properties": { + "repo": { + "type": "string", + "format": "did" + }, + "source": { + "type": "union", + "refs": ["#commit", "#patches"] + }, + "record": { + "type": "string", + "format": "at-uri", + "description": "at-uri of target record. rkey is required" + } + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["commit"], + "properties": { + "commit": { + "type": "string", + "minLength": 40, + "maxLength": 128 + } + } + } + }, + "errors": [ + { + "name": "InvalidRequest", + "description": "Invalid request parameters" + }, + { + "name": "RepoNotFound", + "description": "Repo is not registered on this knot" + }, + { + "name": "CommitNotFound", + "description": "Commit is not found from source Repo" + }, + { + "name": "PatchApplyFailed", + "description": "Failed to apply patches" + } + ] + }, + "commit": { + "type": "object", + "required": ["repo", "oid"], + "properties": { + "repo": { + "type": "string", + "format": "did" + }, + "oid": { + "type": "string", + "minLength": 40, + "maxLength": 128 + } + } + }, + "patches": { + "type": "object", + "required": ["patch"], + "properties": { + "patches": { + "type": "array", + "items": { "type": "string" } + } + } + } + } +}