From b871383939965ad9db0cfb2014e18442de105d36 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Sat, 2 Aug 2025 10:58:50 +0100 Subject: [PATCH] lexicons: introduce sh.tangled.repo.collaborator Change-Id: outlroutwynwxyvpxtuqwosynyymqvqt Signed-off-by: oppiliappan --- api/tangled/cbor_gen.go | 198 ++++++++++++++++++++++++++++++++ api/tangled/repocollaborator.go | 25 ++++ cmd/gen.go | 1 + lexicons/repo/collaborator.json | 36 ++++++ 4 files changed, 260 insertions(+) create mode 100644 api/tangled/repocollaborator.go create mode 100644 lexicons/repo/collaborator.json diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go index 352567a..a1117f4 100644 --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -5854,6 +5854,204 @@ func (t *RepoArtifact) UnmarshalCBOR(r io.Reader) (err error) { return nil } +func (t *RepoCollaborator) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{164}); err != nil { + return err + } + + // t.Repo (string) (string) + if len("repo") > 1000000 { + return xerrors.Errorf("Value in field \"repo\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { + return err + } + if _, err := cw.WriteString(string("repo")); err != nil { + return err + } + + if len(t.Repo) > 1000000 { + return xerrors.Errorf("Value in field t.Repo was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Repo)); err != nil { + return err + } + + // t.LexiconTypeID (string) (string) + if len("$type") > 1000000 { + return xerrors.Errorf("Value in field \"$type\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + return err + } + if _, err := cw.WriteString(string("$type")); err != nil { + return err + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.collaborator"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sh.tangled.repo.collaborator")); err != nil { + return err + } + + // t.Subject (string) (string) + if len("subject") > 1000000 { + return xerrors.Errorf("Value in field \"subject\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil { + return err + } + if _, err := cw.WriteString(string("subject")); err != nil { + return err + } + + if len(t.Subject) > 1000000 { + return xerrors.Errorf("Value in field t.Subject was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Subject))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Subject)); err != nil { + return err + } + + // t.CreatedAt (string) (string) + if len("createdAt") > 1000000 { + return xerrors.Errorf("Value in field \"createdAt\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { + return err + } + if _, err := cw.WriteString(string("createdAt")); err != nil { + return err + } + + if len(t.CreatedAt) > 1000000 { + return xerrors.Errorf("Value in field t.CreatedAt was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { + return err + } + return nil +} + +func (t *RepoCollaborator) UnmarshalCBOR(r io.Reader) (err error) { + *t = RepoCollaborator{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("RepoCollaborator: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 9) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.Repo (string) (string) + case "repo": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Repo = string(sval) + } + // t.LexiconTypeID (string) (string) + case "$type": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.LexiconTypeID = string(sval) + } + // t.Subject (string) (string) + case "subject": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Subject = string(sval) + } + // t.CreatedAt (string) (string) + case "createdAt": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.CreatedAt = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} func (t *RepoIssue) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) diff --git a/api/tangled/repocollaborator.go b/api/tangled/repocollaborator.go new file mode 100644 index 0000000..532ca5d --- /dev/null +++ b/api/tangled/repocollaborator.go @@ -0,0 +1,25 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package tangled + +// schema: sh.tangled.repo.collaborator + +import ( + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + RepoCollaboratorNSID = "sh.tangled.repo.collaborator" +) + +func init() { + util.RegisterType("sh.tangled.repo.collaborator", &RepoCollaborator{}) +} // +// RECORDTYPE: RepoCollaborator +type RepoCollaborator struct { + LexiconTypeID string `json:"$type,const=sh.tangled.repo.collaborator" cborgen:"$type,const=sh.tangled.repo.collaborator"` + CreatedAt string `json:"createdAt" cborgen:"createdAt"` + // repo: repo to add this user to + Repo string `json:"repo" cborgen:"repo"` + Subject string `json:"subject" cborgen:"subject"` +} diff --git a/cmd/gen.go b/cmd/gen.go index ca42aa7..b484de7 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -40,6 +40,7 @@ func main() { tangled.PublicKey{}, tangled.Repo{}, tangled.RepoArtifact{}, + tangled.RepoCollaborator{}, tangled.RepoIssue{}, tangled.RepoIssueComment{}, tangled.RepoIssueState{}, diff --git a/lexicons/repo/collaborator.json b/lexicons/repo/collaborator.json new file mode 100644 index 0000000..b05db96 --- /dev/null +++ b/lexicons/repo/collaborator.json @@ -0,0 +1,36 @@ +{ + "lexicon": 1, + "id": "sh.tangled.repo.collaborator", + "needsCbor": true, + "needsType": true, + "defs": { + "main": { + "type": "record", + "key": "tid", + "record": { + "type": "object", + "required": [ + "subject", + "repo", + "createdAt" + ], + "properties": { + "subject": { + "type": "string", + "format": "did" + }, + "repo": { + "type": "string", + "description": "repo to add this user to", + "format": "at-uri" + }, + "createdAt": { + "type": "string", + "format": "datetime" + } + } + } + } + } +} + -- 2.43.0