this repo has no description

lexicon: add sh.tangled.knot.ack

the response from knots upon ingestion

Signed-off-by: oppiliappan <me@oppi.li>

Changed files
+303
api
cmd
lexicons
knot
+232
api/tangled/cbor_gen.go
··· 4038 4038 4039 4039 return nil 4040 4040 } 4041 + func (t *KnotAck) MarshalCBOR(w io.Writer) error { 4042 + if t == nil { 4043 + _, err := w.Write(cbg.CborNull) 4044 + return err 4045 + } 4046 + 4047 + cw := cbg.NewCborWriter(w) 4048 + 4049 + if _, err := cw.Write([]byte{165}); err != nil { 4050 + return err 4051 + } 4052 + 4053 + // t.Host (string) (string) 4054 + if len("host") > 1000000 { 4055 + return xerrors.Errorf("Value in field \"host\" was too long") 4056 + } 4057 + 4058 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("host"))); err != nil { 4059 + return err 4060 + } 4061 + if _, err := cw.WriteString(string("host")); err != nil { 4062 + return err 4063 + } 4064 + 4065 + if len(t.Host) > 1000000 { 4066 + return xerrors.Errorf("Value in field t.Host was too long") 4067 + } 4068 + 4069 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Host))); err != nil { 4070 + return err 4071 + } 4072 + if _, err := cw.WriteString(string(t.Host)); err != nil { 4073 + return err 4074 + } 4075 + 4076 + // t.LexiconTypeID (string) (string) 4077 + if len("$type") > 1000000 { 4078 + return xerrors.Errorf("Value in field \"$type\" was too long") 4079 + } 4080 + 4081 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { 4082 + return err 4083 + } 4084 + if _, err := cw.WriteString(string("$type")); err != nil { 4085 + return err 4086 + } 4087 + 4088 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.knot.ack"))); err != nil { 4089 + return err 4090 + } 4091 + if _, err := cw.WriteString(string("sh.tangled.knot.ack")); err != nil { 4092 + return err 4093 + } 4094 + 4095 + // t.Aturi (string) (string) 4096 + if len("aturi") > 1000000 { 4097 + return xerrors.Errorf("Value in field \"aturi\" was too long") 4098 + } 4099 + 4100 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("aturi"))); err != nil { 4101 + return err 4102 + } 4103 + if _, err := cw.WriteString(string("aturi")); err != nil { 4104 + return err 4105 + } 4106 + 4107 + if len(t.Aturi) > 1000000 { 4108 + return xerrors.Errorf("Value in field t.Aturi was too long") 4109 + } 4110 + 4111 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Aturi))); err != nil { 4112 + return err 4113 + } 4114 + if _, err := cw.WriteString(string(t.Aturi)); err != nil { 4115 + return err 4116 + } 4117 + 4118 + // t.Status (string) (string) 4119 + if len("status") > 1000000 { 4120 + return xerrors.Errorf("Value in field \"status\" was too long") 4121 + } 4122 + 4123 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil { 4124 + return err 4125 + } 4126 + if _, err := cw.WriteString(string("status")); err != nil { 4127 + return err 4128 + } 4129 + 4130 + if len(t.Status) > 1000000 { 4131 + return xerrors.Errorf("Value in field t.Status was too long") 4132 + } 4133 + 4134 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Status))); err != nil { 4135 + return err 4136 + } 4137 + if _, err := cw.WriteString(string(t.Status)); err != nil { 4138 + return err 4139 + } 4140 + 4141 + // t.CreatedAt (string) (string) 4142 + if len("createdAt") > 1000000 { 4143 + return xerrors.Errorf("Value in field \"createdAt\" was too long") 4144 + } 4145 + 4146 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { 4147 + return err 4148 + } 4149 + if _, err := cw.WriteString(string("createdAt")); err != nil { 4150 + return err 4151 + } 4152 + 4153 + if len(t.CreatedAt) > 1000000 { 4154 + return xerrors.Errorf("Value in field t.CreatedAt was too long") 4155 + } 4156 + 4157 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { 4158 + return err 4159 + } 4160 + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { 4161 + return err 4162 + } 4163 + return nil 4164 + } 4165 + 4166 + func (t *KnotAck) UnmarshalCBOR(r io.Reader) (err error) { 4167 + *t = KnotAck{} 4168 + 4169 + cr := cbg.NewCborReader(r) 4170 + 4171 + maj, extra, err := cr.ReadHeader() 4172 + if err != nil { 4173 + return err 4174 + } 4175 + defer func() { 4176 + if err == io.EOF { 4177 + err = io.ErrUnexpectedEOF 4178 + } 4179 + }() 4180 + 4181 + if maj != cbg.MajMap { 4182 + return fmt.Errorf("cbor input should be of type map") 4183 + } 4184 + 4185 + if extra > cbg.MaxLength { 4186 + return fmt.Errorf("KnotAck: map struct too large (%d)", extra) 4187 + } 4188 + 4189 + n := extra 4190 + 4191 + nameBuf := make([]byte, 9) 4192 + for i := uint64(0); i < n; i++ { 4193 + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 4194 + if err != nil { 4195 + return err 4196 + } 4197 + 4198 + if !ok { 4199 + // Field doesn't exist on this type, so ignore it 4200 + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 4201 + return err 4202 + } 4203 + continue 4204 + } 4205 + 4206 + switch string(nameBuf[:nameLen]) { 4207 + // t.Host (string) (string) 4208 + case "host": 4209 + 4210 + { 4211 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 4212 + if err != nil { 4213 + return err 4214 + } 4215 + 4216 + t.Host = string(sval) 4217 + } 4218 + // t.LexiconTypeID (string) (string) 4219 + case "$type": 4220 + 4221 + { 4222 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 4223 + if err != nil { 4224 + return err 4225 + } 4226 + 4227 + t.LexiconTypeID = string(sval) 4228 + } 4229 + // t.Aturi (string) (string) 4230 + case "aturi": 4231 + 4232 + { 4233 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 4234 + if err != nil { 4235 + return err 4236 + } 4237 + 4238 + t.Aturi = string(sval) 4239 + } 4240 + // t.Status (string) (string) 4241 + case "status": 4242 + 4243 + { 4244 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 4245 + if err != nil { 4246 + return err 4247 + } 4248 + 4249 + t.Status = string(sval) 4250 + } 4251 + // t.CreatedAt (string) (string) 4252 + case "createdAt": 4253 + 4254 + { 4255 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 4256 + if err != nil { 4257 + return err 4258 + } 4259 + 4260 + t.CreatedAt = string(sval) 4261 + } 4262 + 4263 + default: 4264 + // Field doesn't exist on this type, so ignore it 4265 + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 4266 + return err 4267 + } 4268 + } 4269 + } 4270 + 4271 + return nil 4272 + }
+27
api/tangled/knotack.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package tangled 4 + 5 + // schema: sh.tangled.knot.ack 6 + 7 + import ( 8 + "github.com/bluesky-social/indigo/lex/util" 9 + ) 10 + 11 + const ( 12 + KnotAckNSID = "sh.tangled.knot.ack" 13 + ) 14 + 15 + func init() { 16 + util.RegisterType("sh.tangled.knot.ack", &KnotAck{}) 17 + } // 18 + // RECORDTYPE: KnotAck 19 + type KnotAck struct { 20 + LexiconTypeID string `json:"$type,const=sh.tangled.knot.ack" cborgen:"$type,const=sh.tangled.knot.ack"` 21 + // aturi: the at-uri to ack 22 + Aturi string `json:"aturi" cborgen:"aturi"` 23 + CreatedAt string `json:"createdAt" cborgen:"createdAt"` 24 + // host: the host of the knot that is acking this at-uri 25 + Host string `json:"host" cborgen:"host"` 26 + Status string `json:"status" cborgen:"status"` 27 + }
+1
cmd/gen.go
··· 29 29 tangled.RepoArtifact{}, 30 30 tangled.ActorProfile{}, 31 31 tangled.Knot{}, 32 + tangled.KnotAck{}, 32 33 ); err != nil { 33 34 panic(err) 34 35 }
+43
lexicons/knot/ack.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "sh.tangled.knot.ack", 4 + "needsCbor": true, 5 + "needsType": true, 6 + "defs": { 7 + "main": { 8 + "type": "record", 9 + "key": "tid", 10 + "record": { 11 + "type": "object", 12 + "required": [ 13 + "host", 14 + "aturi", 15 + "status", 16 + "createdAt" 17 + ], 18 + "properties": { 19 + "host": { 20 + "type": "string", 21 + "description": "the host of the knot that is acking this at-uri" 22 + }, 23 + "aturi": { 24 + "type": "string", 25 + "format": "at-uri", 26 + "description": "the at-uri to ack" 27 + }, 28 + "status": { 29 + "type": "string", 30 + "enum": [ 31 + "ACK", 32 + "NAK" 33 + ] 34 + }, 35 + "createdAt": { 36 + "type": "string", 37 + "format": "datetime" 38 + } 39 + } 40 + } 41 + } 42 + } 43 + }