From 5276029b3c11c79c779f57b65af9e025d2ecfede Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Mon, 23 Mar 2026 11:26:27 +0000 Subject: [PATCH] lexicons: `com.atproto.repo.strongRef` and `sh.tangled.markup.markdown` use `com.atproto.repo.strongRef` for more explicit reference & `markup.markdown` type to give clear semantic meaning in markdown Close: Signed-off-by: Seongmin Lee --- api/tangled/cbor_gen.go | 555 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- api/tangled/feedcomment.go | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ api/tangled/markupmarkdown.go | 29 +++++++++++++++++++++++++++++ api/tangled/tangledcomment.go | 27 --------------------------- cmd/cborgen/cborgen.go | 3 ++- lexicon-build-config.json | 6 ++++++ lexicons/com/atproto/repo/strongRef.json | 15 +++++++++++++++ lexicons/comment/comment.json | 51 --------------------------------------------------- lexicons/feed/comment.json | 43 +++++++++++++++++++++++++++++++++++++++++++ lexicons/markup/markdown.json | 30 ++++++++++++++++++++++++++++++ 10 file(s) changed, 577 insertion(s)(+), 270 deletion(s)(-) diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -8,6 +8,7 @@ "io" "math" "sort" + atproto "github.com/bluesky-social/indigo/api/atproto" util "github.com/bluesky-social/indigo/lex/util" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -661,20 +662,16 @@ } return nil } -func (t *Comment) MarshalCBOR(w io.Writer) error { +func (t *FeedComment) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } cw := cbg.NewCborWriter(w) - fieldCount := 7 + fieldCount := 6 - if t.Mentions == nil { - fieldCount-- - } - - if t.References == nil { + if t.PullRoundIdx == nil { fieldCount-- } @@ -686,7 +683,7 @@ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { return err } - // t.Body (string) (string) + // t.Body (tangled.FeedComment_Body) (struct) if len("body") > 1000000 { return xerrors.Errorf("Value in field \"body\" was too long") } @@ -698,14 +695,7 @@ if _, err := cw.WriteString(string("body")); err != nil { return err } - if len(t.Body) > 1000000 { - return xerrors.Errorf("Value in field t.Body was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Body))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Body)); err != nil { + if err := t.Body.MarshalCBOR(cw); err != nil { return err } @@ -721,14 +711,14 @@ if _, err := cw.WriteString(string("$type")); err != nil { return err } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.comment"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.feed.comment"))); err != nil { return err } - if _, err := cw.WriteString(string("sh.tangled.comment")); err != nil { + if _, err := cw.WriteString(string("sh.tangled.feed.comment")); err != nil { return err } - // t.ReplyTo (string) (string) + // t.ReplyTo (atproto.RepoStrongRef) (struct) if t.ReplyTo != nil { if len("replyTo") > 1000000 { @@ -742,25 +732,12 @@ if _, err := cw.WriteString(string("replyTo")); err != nil { return err } - if t.ReplyTo == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.ReplyTo) > 1000000 { - return xerrors.Errorf("Value in field t.ReplyTo was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.ReplyTo))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.ReplyTo)); err != nil { - return err - } + if err := t.ReplyTo.MarshalCBOR(cw); err != nil { + return err } } - // t.Subject (string) (string) + // t.Subject (atproto.RepoStrongRef) (struct) if len("subject") > 1000000 { return xerrors.Errorf("Value in field \"subject\" was too long") } @@ -772,53 +749,10 @@ 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 { + if err := t.Subject.MarshalCBOR(cw); err != nil { return err } - // t.Mentions ([]string) (slice) - if t.Mentions != nil { - - if len("mentions") > 1000000 { - return xerrors.Errorf("Value in field \"mentions\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mentions"))); err != nil { - return err - } - if _, err := cw.WriteString(string("mentions")); err != nil { - return err - } - - if len(t.Mentions) > 8192 { - return xerrors.Errorf("Slice value in field t.Mentions was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Mentions))); err != nil { - return err - } - for _, v := range t.Mentions { - if len(v) > 1000000 { - return xerrors.Errorf("Value in field v was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { - return err - } - if _, err := cw.WriteString(string(v)); err != nil { - return err - } - - } - } - // t.CreatedAt (string) (string) if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") @@ -842,46 +776,42 @@ if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { return err } - // t.References ([]string) (slice) - if t.References != nil { + // t.PullRoundIdx (int64) (int64) + if t.PullRoundIdx != nil { - if len("references") > 1000000 { - return xerrors.Errorf("Value in field \"references\" was too long") + if len("pullRoundIdx") > 1000000 { + return xerrors.Errorf("Value in field \"pullRoundIdx\" was too long") } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("references"))); err != nil { + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pullRoundIdx"))); err != nil { return err } - if _, err := cw.WriteString(string("references")); err != nil { + if _, err := cw.WriteString(string("pullRoundIdx")); err != nil { return err } - if len(t.References) > 8192 { - return xerrors.Errorf("Slice value in field t.References was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.References))); err != nil { - return err - } - for _, v := range t.References { - if len(v) > 1000000 { - return xerrors.Errorf("Value in field v was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { + if t.PullRoundIdx == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { return err } - if _, err := cw.WriteString(string(v)); err != nil { - return err + } else { + if *t.PullRoundIdx >= 0 { + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.PullRoundIdx)); err != nil { + return err + } + } else { + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.PullRoundIdx-1)); err != nil { + return err + } } + } - } } return nil } -func (t *Comment) UnmarshalCBOR(r io.Reader) (err error) { - *t = Comment{} +func (t *FeedComment) UnmarshalCBOR(r io.Reader) (err error) { + *t = FeedComment{} cr := cbg.NewCborReader(r) @@ -900,12 +830,12 @@ return fmt.Errorf("cbor input should be of type map") } if extra > cbg.MaxLength { - return fmt.Errorf("Comment: map struct too large (%d)", extra) + return fmt.Errorf("FeedComment: map struct too large (%d)", extra) } n := extra - nameBuf := make([]byte, 10) + nameBuf := make([]byte, 12) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -921,16 +851,25 @@ continue } switch string(nameBuf[:nameLen]) { - // t.Body (string) (string) + // t.Body (tangled.FeedComment_Body) (struct) case "body": { - sval, err := cbg.ReadStringWithMax(cr, 1000000) + + b, err := cr.ReadByte() if err != nil { return err } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Body = new(FeedComment_Body) + if err := t.Body.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Body pointer: %w", err) + } + } - t.Body = string(sval) } // t.LexiconTypeID (string) (string) case "$type": @@ -943,10 +882,11 @@ } t.LexiconTypeID = string(sval) } - // t.ReplyTo (string) (string) + // t.ReplyTo (atproto.RepoStrongRef) (struct) case "replyTo": { + b, err := cr.ReadByte() if err != nil { return err @@ -955,65 +895,32 @@ if b != cbg.CborNull[0] { if err := cr.UnreadByte(); err != nil { return err } - - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err + t.ReplyTo = new(atproto.RepoStrongRef) + if err := t.ReplyTo.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.ReplyTo pointer: %w", err) } + } - t.ReplyTo = (*string)(&sval) - } } - // t.Subject (string) (string) + // t.Subject (atproto.RepoStrongRef) (struct) case "subject": { - sval, err := cbg.ReadStringWithMax(cr, 1000000) + + b, err := cr.ReadByte() if err != nil { return err } - - t.Subject = string(sval) - } - // t.Mentions ([]string) (slice) - case "mentions": - - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - - if extra > 8192 { - return fmt.Errorf("t.Mentions: array too large (%d)", extra) - } - - if maj != cbg.MajArray { - return fmt.Errorf("expected cbor array") - } - - if extra > 0 { - t.Mentions = make([]string, extra) - } - - for i := 0; i < int(extra); i++ { - { - var maj byte - var extra uint64 - var err error - _ = maj - _ = extra - _ = err - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Mentions[i] = string(sval) + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err } + t.Subject = new(atproto.RepoStrongRef) + if err := t.Subject.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Subject pointer: %w", err) + } + } - } } // t.CreatedAt (string) (string) case "createdAt": @@ -1026,44 +933,40 @@ } t.CreatedAt = string(sval) } - // t.References ([]string) (slice) - case "references": + // t.PullRoundIdx (int64) (int64) + case "pullRoundIdx": + { - maj, extra, err = cr.ReadHeader() - if err != nil { - return err - } - - if extra > 8192 { - return fmt.Errorf("t.References: array too large (%d)", extra) - } - - if maj != cbg.MajArray { - return fmt.Errorf("expected cbor array") - } - - if extra > 0 { - t.References = make([]string, extra) - } - - for i := 0; i < int(extra); i++ { - { - var maj byte - var extra uint64 - var err error - _ = maj - _ = extra - _ = err - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + var extraI int64 + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") + } + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative overflow") } - - t.References[i] = string(sval) + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) } + t.PullRoundIdx = (*int64)(&extraI) } } @@ -4674,6 +4577,276 @@ return err } t.Value = 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 *MarkupMarkdown) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + fieldCount := 4 + + if t.Blobs == nil { + fieldCount-- + } + + if t.Original == nil { + fieldCount-- + } + + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + return err + } + + // t.Text (string) (string) + if len("text") > 1000000 { + return xerrors.Errorf("Value in field \"text\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("text"))); err != nil { + return err + } + if _, err := cw.WriteString(string("text")); err != nil { + return err + } + + if len(t.Text) > 1000000 { + return xerrors.Errorf("Value in field t.Text was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Text))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Text)); 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.markup.markdown"))); err != nil { + return err + } + if _, err := cw.WriteString(string("sh.tangled.markup.markdown")); err != nil { + return err + } + + // t.Blobs ([]*util.LexBlob) (slice) + if t.Blobs != nil { + + if len("blobs") > 1000000 { + return xerrors.Errorf("Value in field \"blobs\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("blobs"))); err != nil { + return err + } + if _, err := cw.WriteString(string("blobs")); err != nil { + return err + } + + if len(t.Blobs) > 8192 { + return xerrors.Errorf("Slice value in field t.Blobs was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Blobs))); err != nil { + return err + } + for _, v := range t.Blobs { + if err := v.MarshalCBOR(cw); err != nil { + return err + } + + } + } + + // t.Original (string) (string) + if t.Original != nil { + + if len("original") > 1000000 { + return xerrors.Errorf("Value in field \"original\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("original"))); err != nil { + return err + } + if _, err := cw.WriteString(string("original")); err != nil { + return err + } + + if t.Original == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Original) > 1000000 { + return xerrors.Errorf("Value in field t.Original was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Original))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Original)); err != nil { + return err + } + } + } + return nil +} + +func (t *MarkupMarkdown) UnmarshalCBOR(r io.Reader) (err error) { + *t = MarkupMarkdown{} + + 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("MarkupMarkdown: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 8) + 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.Text (string) (string) + case "text": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Text = string(sval) + } + // t.LexiconTypeID (string) (string) + case "$type": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.LexiconTypeID = string(sval) + } + // t.Blobs ([]*util.LexBlob) (slice) + case "blobs": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + + if extra > 8192 { + return fmt.Errorf("t.Blobs: array too large (%d)", extra) + } + + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") + } + + if extra > 0 { + t.Blobs = make([]*util.LexBlob, extra) + } + + for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Blobs[i] = new(util.LexBlob) + if err := t.Blobs[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Blobs[i] pointer: %w", err) + } + } + + } + + } + } + // t.Original (string) (string) + case "original": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Original = (*string)(&sval) + } } default: diff --git a/api/tangled/feedcomment.go b/api/tangled/feedcomment.go new file mode 100644 --- /dev/null +++ b/api/tangled/feedcomment.go @@ -0,0 +1,88 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package tangled + +// schema: sh.tangled.feed.comment + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + + comatprototypes "github.com/bluesky-social/indigo/api/atproto" + "github.com/bluesky-social/indigo/lex/util" + cbg "github.com/whyrusleeping/cbor-gen" +) + +const ( + FeedCommentNSID = "sh.tangled.feed.comment" +) + +func init() { + util.RegisterType("sh.tangled.feed.comment", &FeedComment{}) +} // +// RECORDTYPE: FeedComment +type FeedComment struct { + LexiconTypeID string `json:"$type,const=sh.tangled.feed.comment" cborgen:"$type,const=sh.tangled.feed.comment"` + Body *FeedComment_Body `json:"body" cborgen:"body"` + CreatedAt string `json:"createdAt" cborgen:"createdAt"` + // pullRoundIdx: optional pull submission round index. required when subject is sh.tangled.repo.pull + PullRoundIdx *int64 `json:"pullRoundIdx,omitempty" cborgen:"pullRoundIdx,omitempty"` + ReplyTo *comatprototypes.RepoStrongRef `json:"replyTo,omitempty" cborgen:"replyTo,omitempty"` + Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` +} + +type FeedComment_Body struct { + MarkupMarkdown *MarkupMarkdown +} + +func (t *FeedComment_Body) MarshalJSON() ([]byte, error) { + if t.MarkupMarkdown != nil { + t.MarkupMarkdown.LexiconTypeID = "sh.tangled.markup.markdown" + return json.Marshal(t.MarkupMarkdown) + } + return nil, fmt.Errorf("cannot marshal empty enum") +} +func (t *FeedComment_Body) UnmarshalJSON(b []byte) error { + typ, err := util.TypeExtract(b) + if err != nil { + return err + } + + switch typ { + case "sh.tangled.markup.markdown": + t.MarkupMarkdown = new(MarkupMarkdown) + return json.Unmarshal(b, t.MarkupMarkdown) + + default: + return nil + } +} + +func (t *FeedComment_Body) MarshalCBOR(w io.Writer) error { + + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + if t.MarkupMarkdown != nil { + return t.MarkupMarkdown.MarshalCBOR(w) + } + return fmt.Errorf("cannot cbor marshal empty enum") +} +func (t *FeedComment_Body) UnmarshalCBOR(r io.Reader) error { + typ, b, err := util.CborTypeExtractReader(r) + if err != nil { + return err + } + + switch typ { + case "sh.tangled.markup.markdown": + t.MarkupMarkdown = new(MarkupMarkdown) + return t.MarkupMarkdown.UnmarshalCBOR(bytes.NewReader(b)) + + default: + return nil + } +} diff --git a/api/tangled/markupmarkdown.go b/api/tangled/markupmarkdown.go new file mode 100644 --- /dev/null +++ b/api/tangled/markupmarkdown.go @@ -0,0 +1,29 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package tangled + +// schema: sh.tangled.markup.markdown + +import ( + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + MarkupMarkdownNSID = "sh.tangled.markup.markdown" +) + +func init() { + util.RegisterType("sh.tangled.markup.markdown#main", &MarkupMarkdown{}) +} // MarkupMarkdown is a "main" in the sh.tangled.markup.markdown schema. +// Tangled Flavored Markdown format text +// +// RECORDTYPE: MarkupMarkdown +type MarkupMarkdown struct { + LexiconTypeID string `json:"$type,const=sh.tangled.markup.markdown" cborgen:"$type,const=sh.tangled.markup.markdown"` + // blobs: list of blobs referenced in markdown + Blobs []*util.LexBlob `json:"blobs,omitempty" cborgen:"blobs,omitempty"` + // original: Original Markdown before post-processing. Used to restore original input on edit. + Original *string `json:"original,omitempty" cborgen:"original,omitempty"` + // text: Final post-processed markdown content that will be rendered + Text string `json:"text" cborgen:"text"` +} diff --git a/api/tangled/tangledcomment.go b/api/tangled/tangledcomment.go deleted file mode 100644 --- a/api/tangled/tangledcomment.go +++ /dev/null @@ -1,27 +0,0 @@ -// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. - -package tangled - -// schema: sh.tangled.comment - -import ( - "github.com/bluesky-social/indigo/lex/util" -) - -const ( - CommentNSID = "sh.tangled.comment" -) - -func init() { - util.RegisterType("sh.tangled.comment", &Comment{}) -} // -// RECORDTYPE: Comment -type Comment struct { - LexiconTypeID string `json:"$type,const=sh.tangled.comment" cborgen:"$type,const=sh.tangled.comment"` - Body string `json:"body" cborgen:"body"` - CreatedAt string `json:"createdAt" cborgen:"createdAt"` - Mentions []string `json:"mentions,omitempty" cborgen:"mentions,omitempty"` - References []string `json:"references,omitempty" cborgen:"references,omitempty"` - ReplyTo *string `json:"replyTo,omitempty" cborgen:"replyTo,omitempty"` - Subject string `json:"subject" cborgen:"subject"` -} diff --git a/cmd/cborgen/cborgen.go b/cmd/cborgen/cborgen.go --- a/cmd/cborgen/cborgen.go +++ b/cmd/cborgen/cborgen.go @@ -15,7 +15,7 @@ if err := genCfg.WriteMapEncodersToFile( "api/tangled/cbor_gen.go", "tangled", tangled.ActorProfile{}, - tangled.Comment{}, + tangled.FeedComment{}, tangled.FeedReaction{}, tangled.FeedStar{}, tangled.FeedStar_Repo{}, @@ -34,6 +34,7 @@ tangled.LabelDefinition{}, tangled.LabelDefinition_ValueType{}, tangled.LabelOp{}, tangled.LabelOp_Operand{}, + tangled.MarkupMarkdown{}, tangled.Pipeline{}, tangled.Pipeline_CloneOpts{}, tangled.Pipeline_ManualTriggerData{}, diff --git a/lexicon-build-config.json b/lexicon-build-config.json --- a/lexicon-build-config.json +++ b/lexicon-build-config.json @@ -1,5 +1,11 @@ [ { + "package": "atproto", + "prefix": "com.atproto", + "outdir": "/tmp/atproto", + "import": "github.com/bluesky-social/indigo/api/atproto" + }, + { "package": "tangled", "prefix": "sh.tangled", "outdir": "api/tangled", diff --git a/lexicons/com/atproto/repo/strongRef.json b/lexicons/com/atproto/repo/strongRef.json new file mode 100644 --- /dev/null +++ b/lexicons/com/atproto/repo/strongRef.json @@ -0,0 +1,15 @@ +{ + "lexicon": 1, + "id": "com.atproto.repo.strongRef", + "description": "A URI with a content-hash fingerprint.", + "defs": { + "main": { + "type": "object", + "required": ["uri", "cid"], + "properties": { + "uri": { "type": "string", "format": "at-uri" }, + "cid": { "type": "string", "format": "cid" } + } + } + } +} diff --git a/lexicons/comment/comment.json b/lexicons/comment/comment.json deleted file mode 100644 --- a/lexicons/comment/comment.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "lexicon": 1, - "id": "sh.tangled.comment", - "needsCbor": true, - "needsType": true, - "defs": { - "main": { - "type": "record", - "key": "tid", - "record": { - "type": "object", - "required": [ - "subject", - "body", - "createdAt" - ], - "properties": { - "subject": { - "type": "string", - "format": "at-uri" - }, - "body": { - "type": "string" - }, - "createdAt": { - "type": "string", - "format": "datetime" - }, - "replyTo": { - "type": "string", - "format": "at-uri" - }, - "mentions": { - "type": "array", - "items": { - "type": "string", - "format": "did" - } - }, - "references": { - "type": "array", - "items": { - "type": "string", - "format": "at-uri" - } - } - } - } - } - } -} diff --git a/lexicons/feed/comment.json b/lexicons/feed/comment.json new file mode 100644 --- /dev/null +++ b/lexicons/feed/comment.json @@ -0,0 +1,43 @@ +{ + "lexicon": 1, + "id": "sh.tangled.feed.comment", + "needsCbor": true, + "needsType": true, + "defs": { + "main": { + "type": "record", + "key": "tid", + "record": { + "type": "object", + "required": [ + "subject", + "body", + "createdAt" + ], + "properties": { + "subject": { + "type": "ref", + "ref": "com.atproto.repo.strongRef" + }, + "body": { + "type": "union", + "refs": ["sh.tangled.markup.markdown"] + }, + "createdAt": { + "type": "string", + "format": "datetime" + }, + "replyTo": { + "type": "ref", + "ref": "com.atproto.repo.strongRef" + }, + "pullRoundIdx": { + "type": "integer", + "minimum": 0, + "description": "optional pull submission round index. required when subject is sh.tangled.repo.pull" + } + } + } + } + } +} diff --git a/lexicons/markup/markdown.json b/lexicons/markup/markdown.json new file mode 100644 --- /dev/null +++ b/lexicons/markup/markdown.json @@ -0,0 +1,30 @@ +{ + "lexicon": 1, + "id": "sh.tangled.markup.markdown", + "defs": { + "main": { + "type": "object", + "required": ["text"], + "description": "Tangled Flavored Markdown format text", + "properties": { + "text": { + "type": "string", + "description": "Final post-processed markdown content that will be rendered" + }, + "original": { + "type": "string", + "description": "Original Markdown before post-processing. Used to restore original input on edit." + }, + "blobs": { + "type": "array", + "items": { + "type": "blob", + "accept": ["image/*"], + "maxSize": 1000000 + }, + "description": "list of blobs referenced in markdown" + } + } + } + } +} -- tangled.sh