Monorepo for Tangled tangled.org

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: <https://tangled.org/tangled.org/core/issues/383>
Signed-off-by: Seongmin Lee <git@boltless.me>

boltless.me 04d54367 465920dc

verified
+577 -270
+364 -191
api/tangled/cbor_gen.go
··· 8 8 "math" 9 9 "sort" 10 10 11 + atproto "github.com/bluesky-social/indigo/api/atproto" 11 12 util "github.com/bluesky-social/indigo/lex/util" 12 13 cid "github.com/ipfs/go-cid" 13 14 cbg "github.com/whyrusleeping/cbor-gen" ··· 661 662 662 663 return nil 663 664 } 664 - func (t *Comment) MarshalCBOR(w io.Writer) error { 665 + func (t *FeedComment) MarshalCBOR(w io.Writer) error { 665 666 if t == nil { 666 667 _, err := w.Write(cbg.CborNull) 667 668 return err 668 669 } 669 670 670 671 cw := cbg.NewCborWriter(w) 671 - fieldCount := 7 672 + fieldCount := 6 672 673 673 - if t.Mentions == nil { 674 - fieldCount-- 675 - } 676 - 677 - if t.References == nil { 674 + if t.PullRoundIdx == nil { 678 675 fieldCount-- 679 676 } 680 677 ··· 686 683 return err 687 684 } 688 685 689 - // t.Body (string) (string) 686 + // t.Body (tangled.FeedComment_Body) (struct) 690 687 if len("body") > 1000000 { 691 688 return xerrors.Errorf("Value in field \"body\" was too long") 692 689 } ··· 698 695 return err 699 696 } 700 697 701 - if len(t.Body) > 1000000 { 702 - return xerrors.Errorf("Value in field t.Body was too long") 703 - } 704 - 705 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Body))); err != nil { 706 - return err 707 - } 708 - if _, err := cw.WriteString(string(t.Body)); err != nil { 698 + if err := t.Body.MarshalCBOR(cw); err != nil { 709 699 return err 710 700 } 711 701 ··· 721 711 return err 722 712 } 723 713 724 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.comment"))); err != nil { 714 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.feed.comment"))); err != nil { 725 715 return err 726 716 } 727 - if _, err := cw.WriteString(string("sh.tangled.comment")); err != nil { 717 + if _, err := cw.WriteString(string("sh.tangled.feed.comment")); err != nil { 728 718 return err 729 719 } 730 720 731 - // t.ReplyTo (string) (string) 721 + // t.ReplyTo (atproto.RepoStrongRef) (struct) 732 722 if t.ReplyTo != nil { 733 723 734 724 if len("replyTo") > 1000000 { ··· 742 732 return err 743 733 } 744 734 745 - if t.ReplyTo == nil { 746 - if _, err := cw.Write(cbg.CborNull); err != nil { 747 - return err 748 - } 749 - } else { 750 - if len(*t.ReplyTo) > 1000000 { 751 - return xerrors.Errorf("Value in field t.ReplyTo was too long") 752 - } 753 - 754 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.ReplyTo))); err != nil { 755 - return err 756 - } 757 - if _, err := cw.WriteString(string(*t.ReplyTo)); err != nil { 758 - return err 759 - } 735 + if err := t.ReplyTo.MarshalCBOR(cw); err != nil { 736 + return err 760 737 } 761 738 } 762 739 763 - // t.Subject (string) (string) 740 + // t.Subject (atproto.RepoStrongRef) (struct) 764 741 if len("subject") > 1000000 { 765 742 return xerrors.Errorf("Value in field \"subject\" was too long") 766 743 } ··· 772 749 return err 773 750 } 774 751 775 - if len(t.Subject) > 1000000 { 776 - return xerrors.Errorf("Value in field t.Subject was too long") 777 - } 778 - 779 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Subject))); err != nil { 780 - return err 781 - } 782 - if _, err := cw.WriteString(string(t.Subject)); err != nil { 752 + if err := t.Subject.MarshalCBOR(cw); err != nil { 783 753 return err 784 754 } 785 755 786 - // t.Mentions ([]string) (slice) 787 - if t.Mentions != nil { 788 - 789 - if len("mentions") > 1000000 { 790 - return xerrors.Errorf("Value in field \"mentions\" was too long") 791 - } 792 - 793 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mentions"))); err != nil { 794 - return err 795 - } 796 - if _, err := cw.WriteString(string("mentions")); err != nil { 797 - return err 798 - } 799 - 800 - if len(t.Mentions) > 8192 { 801 - return xerrors.Errorf("Slice value in field t.Mentions was too long") 802 - } 803 - 804 - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Mentions))); err != nil { 805 - return err 806 - } 807 - for _, v := range t.Mentions { 808 - if len(v) > 1000000 { 809 - return xerrors.Errorf("Value in field v was too long") 810 - } 811 - 812 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { 813 - return err 814 - } 815 - if _, err := cw.WriteString(string(v)); err != nil { 816 - return err 817 - } 818 - 819 - } 820 - } 821 - 822 756 // t.CreatedAt (string) (string) 823 757 if len("createdAt") > 1000000 { 824 758 return xerrors.Errorf("Value in field \"createdAt\" was too long") ··· 842 776 return err 843 777 } 844 778 845 - // t.References ([]string) (slice) 846 - if t.References != nil { 779 + // t.PullRoundIdx (int64) (int64) 780 + if t.PullRoundIdx != nil { 847 781 848 - if len("references") > 1000000 { 849 - return xerrors.Errorf("Value in field \"references\" was too long") 782 + if len("pullRoundIdx") > 1000000 { 783 + return xerrors.Errorf("Value in field \"pullRoundIdx\" was too long") 850 784 } 851 785 852 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("references"))); err != nil { 786 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pullRoundIdx"))); err != nil { 853 787 return err 854 788 } 855 - if _, err := cw.WriteString(string("references")); err != nil { 789 + if _, err := cw.WriteString(string("pullRoundIdx")); err != nil { 856 790 return err 857 791 } 858 792 859 - if len(t.References) > 8192 { 860 - return xerrors.Errorf("Slice value in field t.References was too long") 861 - } 862 - 863 - if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.References))); err != nil { 864 - return err 865 - } 866 - for _, v := range t.References { 867 - if len(v) > 1000000 { 868 - return xerrors.Errorf("Value in field v was too long") 869 - } 870 - 871 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { 793 + if t.PullRoundIdx == nil { 794 + if _, err := cw.Write(cbg.CborNull); err != nil { 872 795 return err 873 796 } 874 - if _, err := cw.WriteString(string(v)); err != nil { 875 - return err 797 + } else { 798 + if *t.PullRoundIdx >= 0 { 799 + if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(*t.PullRoundIdx)); err != nil { 800 + return err 801 + } 802 + } else { 803 + if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-*t.PullRoundIdx-1)); err != nil { 804 + return err 805 + } 876 806 } 807 + } 877 808 878 - } 879 809 } 880 810 return nil 881 811 } 882 812 883 - func (t *Comment) UnmarshalCBOR(r io.Reader) (err error) { 884 - *t = Comment{} 813 + func (t *FeedComment) UnmarshalCBOR(r io.Reader) (err error) { 814 + *t = FeedComment{} 885 815 886 816 cr := cbg.NewCborReader(r) 887 817 ··· 900 830 } 901 831 902 832 if extra > cbg.MaxLength { 903 - return fmt.Errorf("Comment: map struct too large (%d)", extra) 833 + return fmt.Errorf("FeedComment: map struct too large (%d)", extra) 904 834 } 905 835 906 836 n := extra 907 837 908 - nameBuf := make([]byte, 10) 838 + nameBuf := make([]byte, 12) 909 839 for i := uint64(0); i < n; i++ { 910 840 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 911 841 if err != nil { ··· 921 851 } 922 852 923 853 switch string(nameBuf[:nameLen]) { 924 - // t.Body (string) (string) 854 + // t.Body (tangled.FeedComment_Body) (struct) 925 855 case "body": 926 856 927 857 { 928 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 858 + 859 + b, err := cr.ReadByte() 929 860 if err != nil { 930 861 return err 931 862 } 863 + if b != cbg.CborNull[0] { 864 + if err := cr.UnreadByte(); err != nil { 865 + return err 866 + } 867 + t.Body = new(FeedComment_Body) 868 + if err := t.Body.UnmarshalCBOR(cr); err != nil { 869 + return xerrors.Errorf("unmarshaling t.Body pointer: %w", err) 870 + } 871 + } 932 872 933 - t.Body = string(sval) 934 873 } 935 874 // t.LexiconTypeID (string) (string) 936 875 case "$type": ··· 943 882 944 883 t.LexiconTypeID = string(sval) 945 884 } 946 - // t.ReplyTo (string) (string) 885 + // t.ReplyTo (atproto.RepoStrongRef) (struct) 947 886 case "replyTo": 948 887 949 888 { 889 + 950 890 b, err := cr.ReadByte() 951 891 if err != nil { 952 892 return err ··· 955 895 if err := cr.UnreadByte(); err != nil { 956 896 return err 957 897 } 958 - 959 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 960 - if err != nil { 961 - return err 898 + t.ReplyTo = new(atproto.RepoStrongRef) 899 + if err := t.ReplyTo.UnmarshalCBOR(cr); err != nil { 900 + return xerrors.Errorf("unmarshaling t.ReplyTo pointer: %w", err) 962 901 } 902 + } 963 903 964 - t.ReplyTo = (*string)(&sval) 965 - } 966 904 } 967 - // t.Subject (string) (string) 905 + // t.Subject (atproto.RepoStrongRef) (struct) 968 906 case "subject": 969 907 970 908 { 971 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 909 + 910 + b, err := cr.ReadByte() 972 911 if err != nil { 973 912 return err 974 913 } 975 - 976 - t.Subject = string(sval) 977 - } 978 - // t.Mentions ([]string) (slice) 979 - case "mentions": 980 - 981 - maj, extra, err = cr.ReadHeader() 982 - if err != nil { 983 - return err 984 - } 985 - 986 - if extra > 8192 { 987 - return fmt.Errorf("t.Mentions: array too large (%d)", extra) 988 - } 989 - 990 - if maj != cbg.MajArray { 991 - return fmt.Errorf("expected cbor array") 992 - } 993 - 994 - if extra > 0 { 995 - t.Mentions = make([]string, extra) 996 - } 997 - 998 - for i := 0; i < int(extra); i++ { 999 - { 1000 - var maj byte 1001 - var extra uint64 1002 - var err error 1003 - _ = maj 1004 - _ = extra 1005 - _ = err 1006 - 1007 - { 1008 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 1009 - if err != nil { 1010 - return err 1011 - } 1012 - 1013 - t.Mentions[i] = string(sval) 914 + if b != cbg.CborNull[0] { 915 + if err := cr.UnreadByte(); err != nil { 916 + return err 1014 917 } 918 + t.Subject = new(atproto.RepoStrongRef) 919 + if err := t.Subject.UnmarshalCBOR(cr); err != nil { 920 + return xerrors.Errorf("unmarshaling t.Subject pointer: %w", err) 921 + } 922 + } 1015 923 1016 - } 1017 924 } 1018 925 // t.CreatedAt (string) (string) 1019 926 case "createdAt": ··· 1026 933 1027 934 t.CreatedAt = string(sval) 1028 935 } 1029 - // t.References ([]string) (slice) 1030 - case "references": 936 + // t.PullRoundIdx (int64) (int64) 937 + case "pullRoundIdx": 938 + { 1031 939 1032 - maj, extra, err = cr.ReadHeader() 1033 - if err != nil { 1034 - return err 1035 - } 1036 - 1037 - if extra > 8192 { 1038 - return fmt.Errorf("t.References: array too large (%d)", extra) 1039 - } 1040 - 1041 - if maj != cbg.MajArray { 1042 - return fmt.Errorf("expected cbor array") 1043 - } 1044 - 1045 - if extra > 0 { 1046 - t.References = make([]string, extra) 1047 - } 1048 - 1049 - for i := 0; i < int(extra); i++ { 1050 - { 1051 - var maj byte 1052 - var extra uint64 1053 - var err error 1054 - _ = maj 1055 - _ = extra 1056 - _ = err 1057 - 1058 - { 1059 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 1060 - if err != nil { 1061 - return err 940 + b, err := cr.ReadByte() 941 + if err != nil { 942 + return err 943 + } 944 + if b != cbg.CborNull[0] { 945 + if err := cr.UnreadByte(); err != nil { 946 + return err 947 + } 948 + maj, extra, err := cr.ReadHeader() 949 + if err != nil { 950 + return err 951 + } 952 + var extraI int64 953 + switch maj { 954 + case cbg.MajUnsignedInt: 955 + extraI = int64(extra) 956 + if extraI < 0 { 957 + return fmt.Errorf("int64 positive overflow") 958 + } 959 + case cbg.MajNegativeInt: 960 + extraI = int64(extra) 961 + if extraI < 0 { 962 + return fmt.Errorf("int64 negative overflow") 1062 963 } 1063 - 1064 - t.References[i] = string(sval) 964 + extraI = -1 - extraI 965 + default: 966 + return fmt.Errorf("wrong type for int64 field: %d", maj) 1065 967 } 1066 968 969 + t.PullRoundIdx = (*int64)(&extraI) 1067 970 } 1068 971 } 1069 972 ··· 4248 4151 } 4249 4152 4250 4153 t.Value = string(sval) 4154 + } 4155 + 4156 + default: 4157 + // Field doesn't exist on this type, so ignore it 4158 + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 4159 + return err 4160 + } 4161 + } 4162 + } 4163 + 4164 + return nil 4165 + } 4166 + func (t *MarkupMarkdown) MarshalCBOR(w io.Writer) error { 4167 + if t == nil { 4168 + _, err := w.Write(cbg.CborNull) 4169 + return err 4170 + } 4171 + 4172 + cw := cbg.NewCborWriter(w) 4173 + fieldCount := 4 4174 + 4175 + if t.Blobs == nil { 4176 + fieldCount-- 4177 + } 4178 + 4179 + if t.Original == nil { 4180 + fieldCount-- 4181 + } 4182 + 4183 + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 4184 + return err 4185 + } 4186 + 4187 + // t.Text (string) (string) 4188 + if len("text") > 1000000 { 4189 + return xerrors.Errorf("Value in field \"text\" was too long") 4190 + } 4191 + 4192 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("text"))); err != nil { 4193 + return err 4194 + } 4195 + if _, err := cw.WriteString(string("text")); err != nil { 4196 + return err 4197 + } 4198 + 4199 + if len(t.Text) > 1000000 { 4200 + return xerrors.Errorf("Value in field t.Text was too long") 4201 + } 4202 + 4203 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Text))); err != nil { 4204 + return err 4205 + } 4206 + if _, err := cw.WriteString(string(t.Text)); err != nil { 4207 + return err 4208 + } 4209 + 4210 + // t.LexiconTypeID (string) (string) 4211 + if len("$type") > 1000000 { 4212 + return xerrors.Errorf("Value in field \"$type\" was too long") 4213 + } 4214 + 4215 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 4216 + return err 4217 + } 4218 + if _, err := cw.WriteString(string("$type")); err != nil { 4219 + return err 4220 + } 4221 + 4222 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.markup.markdown"))); err != nil { 4223 + return err 4224 + } 4225 + if _, err := cw.WriteString(string("sh.tangled.markup.markdown")); err != nil { 4226 + return err 4227 + } 4228 + 4229 + // t.Blobs ([]*util.LexBlob) (slice) 4230 + if t.Blobs != nil { 4231 + 4232 + if len("blobs") > 1000000 { 4233 + return xerrors.Errorf("Value in field \"blobs\" was too long") 4234 + } 4235 + 4236 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("blobs"))); err != nil { 4237 + return err 4238 + } 4239 + if _, err := cw.WriteString(string("blobs")); err != nil { 4240 + return err 4241 + } 4242 + 4243 + if len(t.Blobs) > 8192 { 4244 + return xerrors.Errorf("Slice value in field t.Blobs was too long") 4245 + } 4246 + 4247 + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Blobs))); err != nil { 4248 + return err 4249 + } 4250 + for _, v := range t.Blobs { 4251 + if err := v.MarshalCBOR(cw); err != nil { 4252 + return err 4253 + } 4254 + 4255 + } 4256 + } 4257 + 4258 + // t.Original (string) (string) 4259 + if t.Original != nil { 4260 + 4261 + if len("original") > 1000000 { 4262 + return xerrors.Errorf("Value in field \"original\" was too long") 4263 + } 4264 + 4265 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("original"))); err != nil { 4266 + return err 4267 + } 4268 + if _, err := cw.WriteString(string("original")); err != nil { 4269 + return err 4270 + } 4271 + 4272 + if t.Original == nil { 4273 + if _, err := cw.Write(cbg.CborNull); err != nil { 4274 + return err 4275 + } 4276 + } else { 4277 + if len(*t.Original) > 1000000 { 4278 + return xerrors.Errorf("Value in field t.Original was too long") 4279 + } 4280 + 4281 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Original))); err != nil { 4282 + return err 4283 + } 4284 + if _, err := cw.WriteString(string(*t.Original)); err != nil { 4285 + return err 4286 + } 4287 + } 4288 + } 4289 + return nil 4290 + } 4291 + 4292 + func (t *MarkupMarkdown) UnmarshalCBOR(r io.Reader) (err error) { 4293 + *t = MarkupMarkdown{} 4294 + 4295 + cr := cbg.NewCborReader(r) 4296 + 4297 + maj, extra, err := cr.ReadHeader() 4298 + if err != nil { 4299 + return err 4300 + } 4301 + defer func() { 4302 + if err == io.EOF { 4303 + err = io.ErrUnexpectedEOF 4304 + } 4305 + }() 4306 + 4307 + if maj != cbg.MajMap { 4308 + return fmt.Errorf("cbor input should be of type map") 4309 + } 4310 + 4311 + if extra > cbg.MaxLength { 4312 + return fmt.Errorf("MarkupMarkdown: map struct too large (%d)", extra) 4313 + } 4314 + 4315 + n := extra 4316 + 4317 + nameBuf := make([]byte, 8) 4318 + for i := uint64(0); i < n; i++ { 4319 + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 4320 + if err != nil { 4321 + return err 4322 + } 4323 + 4324 + if !ok { 4325 + // Field doesn't exist on this type, so ignore it 4326 + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 4327 + return err 4328 + } 4329 + continue 4330 + } 4331 + 4332 + switch string(nameBuf[:nameLen]) { 4333 + // t.Text (string) (string) 4334 + case "text": 4335 + 4336 + { 4337 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 4338 + if err != nil { 4339 + return err 4340 + } 4341 + 4342 + t.Text = string(sval) 4343 + } 4344 + // t.LexiconTypeID (string) (string) 4345 + case "$type": 4346 + 4347 + { 4348 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 4349 + if err != nil { 4350 + return err 4351 + } 4352 + 4353 + t.LexiconTypeID = string(sval) 4354 + } 4355 + // t.Blobs ([]*util.LexBlob) (slice) 4356 + case "blobs": 4357 + 4358 + maj, extra, err = cr.ReadHeader() 4359 + if err != nil { 4360 + return err 4361 + } 4362 + 4363 + if extra > 8192 { 4364 + return fmt.Errorf("t.Blobs: array too large (%d)", extra) 4365 + } 4366 + 4367 + if maj != cbg.MajArray { 4368 + return fmt.Errorf("expected cbor array") 4369 + } 4370 + 4371 + if extra > 0 { 4372 + t.Blobs = make([]*util.LexBlob, extra) 4373 + } 4374 + 4375 + for i := 0; i < int(extra); i++ { 4376 + { 4377 + var maj byte 4378 + var extra uint64 4379 + var err error 4380 + _ = maj 4381 + _ = extra 4382 + _ = err 4383 + 4384 + { 4385 + 4386 + b, err := cr.ReadByte() 4387 + if err != nil { 4388 + return err 4389 + } 4390 + if b != cbg.CborNull[0] { 4391 + if err := cr.UnreadByte(); err != nil { 4392 + return err 4393 + } 4394 + t.Blobs[i] = new(util.LexBlob) 4395 + if err := t.Blobs[i].UnmarshalCBOR(cr); err != nil { 4396 + return xerrors.Errorf("unmarshaling t.Blobs[i] pointer: %w", err) 4397 + } 4398 + } 4399 + 4400 + } 4401 + 4402 + } 4403 + } 4404 + // t.Original (string) (string) 4405 + case "original": 4406 + 4407 + { 4408 + b, err := cr.ReadByte() 4409 + if err != nil { 4410 + return err 4411 + } 4412 + if b != cbg.CborNull[0] { 4413 + if err := cr.UnreadByte(); err != nil { 4414 + return err 4415 + } 4416 + 4417 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 4418 + if err != nil { 4419 + return err 4420 + } 4421 + 4422 + t.Original = (*string)(&sval) 4423 + } 4251 4424 } 4252 4425 4253 4426 default:
+88
api/tangled/feedcomment.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package tangled 4 + 5 + // schema: sh.tangled.feed.comment 6 + 7 + import ( 8 + "bytes" 9 + "encoding/json" 10 + "fmt" 11 + "io" 12 + 13 + comatprototypes "github.com/bluesky-social/indigo/api/atproto" 14 + "github.com/bluesky-social/indigo/lex/util" 15 + cbg "github.com/whyrusleeping/cbor-gen" 16 + ) 17 + 18 + const ( 19 + FeedCommentNSID = "sh.tangled.feed.comment" 20 + ) 21 + 22 + func init() { 23 + util.RegisterType("sh.tangled.feed.comment", &FeedComment{}) 24 + } // 25 + // RECORDTYPE: FeedComment 26 + type FeedComment struct { 27 + LexiconTypeID string `json:"$type,const=sh.tangled.feed.comment" cborgen:"$type,const=sh.tangled.feed.comment"` 28 + Body *FeedComment_Body `json:"body" cborgen:"body"` 29 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 30 + // pullRoundIdx: optional pull submission round index. required when subject is sh.tangled.repo.pull 31 + PullRoundIdx *int64 `json:"pullRoundIdx,omitempty" cborgen:"pullRoundIdx,omitempty"` 32 + ReplyTo *comatprototypes.RepoStrongRef `json:"replyTo,omitempty" cborgen:"replyTo,omitempty"` 33 + Subject *comatprototypes.RepoStrongRef `json:"subject" cborgen:"subject"` 34 + } 35 + 36 + type FeedComment_Body struct { 37 + MarkupMarkdown *MarkupMarkdown 38 + } 39 + 40 + func (t *FeedComment_Body) MarshalJSON() ([]byte, error) { 41 + if t.MarkupMarkdown != nil { 42 + t.MarkupMarkdown.LexiconTypeID = "sh.tangled.markup.markdown" 43 + return json.Marshal(t.MarkupMarkdown) 44 + } 45 + return nil, fmt.Errorf("cannot marshal empty enum") 46 + } 47 + func (t *FeedComment_Body) UnmarshalJSON(b []byte) error { 48 + typ, err := util.TypeExtract(b) 49 + if err != nil { 50 + return err 51 + } 52 + 53 + switch typ { 54 + case "sh.tangled.markup.markdown": 55 + t.MarkupMarkdown = new(MarkupMarkdown) 56 + return json.Unmarshal(b, t.MarkupMarkdown) 57 + 58 + default: 59 + return nil 60 + } 61 + } 62 + 63 + func (t *FeedComment_Body) MarshalCBOR(w io.Writer) error { 64 + 65 + if t == nil { 66 + _, err := w.Write(cbg.CborNull) 67 + return err 68 + } 69 + if t.MarkupMarkdown != nil { 70 + return t.MarkupMarkdown.MarshalCBOR(w) 71 + } 72 + return fmt.Errorf("cannot cbor marshal empty enum") 73 + } 74 + func (t *FeedComment_Body) UnmarshalCBOR(r io.Reader) error { 75 + typ, b, err := util.CborTypeExtractReader(r) 76 + if err != nil { 77 + return err 78 + } 79 + 80 + switch typ { 81 + case "sh.tangled.markup.markdown": 82 + t.MarkupMarkdown = new(MarkupMarkdown) 83 + return t.MarkupMarkdown.UnmarshalCBOR(bytes.NewReader(b)) 84 + 85 + default: 86 + return nil 87 + } 88 + }
+29
api/tangled/markupmarkdown.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package tangled 4 + 5 + // schema: sh.tangled.markup.markdown 6 + 7 + import ( 8 + "github.com/bluesky-social/indigo/lex/util" 9 + ) 10 + 11 + const ( 12 + MarkupMarkdownNSID = "sh.tangled.markup.markdown" 13 + ) 14 + 15 + func init() { 16 + util.RegisterType("sh.tangled.markup.markdown#main", &MarkupMarkdown{}) 17 + } // MarkupMarkdown is a "main" in the sh.tangled.markup.markdown schema. 18 + // Tangled Flavored Markdown format text 19 + // 20 + // RECORDTYPE: MarkupMarkdown 21 + type MarkupMarkdown struct { 22 + LexiconTypeID string `json:"$type,const=sh.tangled.markup.markdown" cborgen:"$type,const=sh.tangled.markup.markdown"` 23 + // blobs: list of blobs referenced in markdown 24 + Blobs []*util.LexBlob `json:"blobs,omitempty" cborgen:"blobs,omitempty"` 25 + // original: Original Markdown before post-processing. Used to restore original input on edit. 26 + Original *string `json:"original,omitempty" cborgen:"original,omitempty"` 27 + // text: Final post-processed markdown content that will be rendered 28 + Text string `json:"text" cborgen:"text"` 29 + }
-27
api/tangled/tangledcomment.go
··· 1 - // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 - 3 - package tangled 4 - 5 - // schema: sh.tangled.comment 6 - 7 - import ( 8 - "github.com/bluesky-social/indigo/lex/util" 9 - ) 10 - 11 - const ( 12 - CommentNSID = "sh.tangled.comment" 13 - ) 14 - 15 - func init() { 16 - util.RegisterType("sh.tangled.comment", &Comment{}) 17 - } // 18 - // RECORDTYPE: Comment 19 - type Comment struct { 20 - LexiconTypeID string `json:"$type,const=sh.tangled.comment" cborgen:"$type,const=sh.tangled.comment"` 21 - Body string `json:"body" cborgen:"body"` 22 - CreatedAt string `json:"createdAt" cborgen:"createdAt"` 23 - Mentions []string `json:"mentions,omitempty" cborgen:"mentions,omitempty"` 24 - References []string `json:"references,omitempty" cborgen:"references,omitempty"` 25 - ReplyTo *string `json:"replyTo,omitempty" cborgen:"replyTo,omitempty"` 26 - Subject string `json:"subject" cborgen:"subject"` 27 - }
+2 -1
cmd/cborgen/cborgen.go
··· 15 15 "api/tangled/cbor_gen.go", 16 16 "tangled", 17 17 tangled.ActorProfile{}, 18 - tangled.Comment{}, 18 + tangled.FeedComment{}, 19 19 tangled.FeedReaction{}, 20 20 tangled.FeedStar{}, 21 21 tangled.GitRefUpdate{}, ··· 31 31 tangled.LabelDefinition_ValueType{}, 32 32 tangled.LabelOp{}, 33 33 tangled.LabelOp_Operand{}, 34 + tangled.MarkupMarkdown{}, 34 35 tangled.Pipeline{}, 35 36 tangled.Pipeline_CloneOpts{}, 36 37 tangled.Pipeline_ManualTriggerData{},
+6
lexicon-build-config.json
··· 1 1 [ 2 2 { 3 + "package": "atproto", 4 + "prefix": "com.atproto", 5 + "outdir": "/tmp/atproto", 6 + "import": "github.com/bluesky-social/indigo/api/atproto" 7 + }, 8 + { 3 9 "package": "tangled", 4 10 "prefix": "sh.tangled", 5 11 "outdir": "api/tangled",
+15
lexicons/com/atproto/repo/strongRef.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.repo.strongRef", 4 + "description": "A URI with a content-hash fingerprint.", 5 + "defs": { 6 + "main": { 7 + "type": "object", 8 + "required": ["uri", "cid"], 9 + "properties": { 10 + "uri": { "type": "string", "format": "at-uri" }, 11 + "cid": { "type": "string", "format": "cid" } 12 + } 13 + } 14 + } 15 + }
-51
lexicons/comment/comment.json
··· 1 - { 2 - "lexicon": 1, 3 - "id": "sh.tangled.comment", 4 - "needsCbor": true, 5 - "needsType": true, 6 - "defs": { 7 - "main": { 8 - "type": "record", 9 - "key": "tid", 10 - "record": { 11 - "type": "object", 12 - "required": [ 13 - "subject", 14 - "body", 15 - "createdAt" 16 - ], 17 - "properties": { 18 - "subject": { 19 - "type": "string", 20 - "format": "at-uri" 21 - }, 22 - "body": { 23 - "type": "string" 24 - }, 25 - "createdAt": { 26 - "type": "string", 27 - "format": "datetime" 28 - }, 29 - "replyTo": { 30 - "type": "string", 31 - "format": "at-uri" 32 - }, 33 - "mentions": { 34 - "type": "array", 35 - "items": { 36 - "type": "string", 37 - "format": "did" 38 - } 39 - }, 40 - "references": { 41 - "type": "array", 42 - "items": { 43 - "type": "string", 44 - "format": "at-uri" 45 - } 46 - } 47 - } 48 - } 49 - } 50 - } 51 - }
+43
lexicons/feed/comment.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "sh.tangled.feed.comment", 4 + "needsCbor": true, 5 + "needsType": true, 6 + "defs": { 7 + "main": { 8 + "type": "record", 9 + "key": "tid", 10 + "record": { 11 + "type": "object", 12 + "required": [ 13 + "subject", 14 + "body", 15 + "createdAt" 16 + ], 17 + "properties": { 18 + "subject": { 19 + "type": "ref", 20 + "ref": "com.atproto.repo.strongRef" 21 + }, 22 + "body": { 23 + "type": "union", 24 + "refs": ["sh.tangled.markup.markdown"] 25 + }, 26 + "createdAt": { 27 + "type": "string", 28 + "format": "datetime" 29 + }, 30 + "replyTo": { 31 + "type": "ref", 32 + "ref": "com.atproto.repo.strongRef" 33 + }, 34 + "pullRoundIdx": { 35 + "type": "integer", 36 + "minimum": 0, 37 + "description": "optional pull submission round index. required when subject is sh.tangled.repo.pull" 38 + } 39 + } 40 + } 41 + } 42 + } 43 + }
+30
lexicons/markup/markdown.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "sh.tangled.markup.markdown", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "required": ["text"], 8 + "description": "Tangled Flavored Markdown format text", 9 + "properties": { 10 + "text": { 11 + "type": "string", 12 + "description": "Final post-processed markdown content that will be rendered" 13 + }, 14 + "original": { 15 + "type": "string", 16 + "description": "Original Markdown before post-processing. Used to restore original input on edit." 17 + }, 18 + "blobs": { 19 + "type": "array", 20 + "items": { 21 + "type": "blob", 22 + "accept": ["image/*"], 23 + "maxSize": 1000000 24 + }, 25 + "description": "list of blobs referenced in markdown" 26 + } 27 + } 28 + } 29 + } 30 + }