Signed-off-by: oppiliappan me@oppi.li
+424
-137
Diff
round #2
+358
-136
api/tangled/cbor_gen.go
+358
-136
api/tangled/cbor_gen.go
···
2460
2460
2461
2461
return nil
2462
2462
}
2463
+
func (t *GraphVouch) MarshalCBOR(w io.Writer) error {
2464
+
if t == nil {
2465
+
_, err := w.Write(cbg.CborNull)
2466
+
return err
2467
+
}
2468
+
2469
+
cw := cbg.NewCborWriter(w)
2470
+
fieldCount := 4
2471
+
2472
+
if t.Reason == nil {
2473
+
fieldCount--
2474
+
}
2475
+
2476
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
2477
+
return err
2478
+
}
2479
+
2480
+
// t.Kind (string) (string)
2481
+
if len("kind") > 1000000 {
2482
+
return xerrors.Errorf("Value in field \"kind\" was too long")
2483
+
}
2484
+
2485
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("kind"))); err != nil {
2486
+
return err
2487
+
}
2488
+
if _, err := cw.WriteString(string("kind")); err != nil {
2489
+
return err
2490
+
}
2491
+
2492
+
if len(t.Kind) > 1000000 {
2493
+
return xerrors.Errorf("Value in field t.Kind was too long")
2494
+
}
2495
+
2496
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Kind))); err != nil {
2497
+
return err
2498
+
}
2499
+
if _, err := cw.WriteString(string(t.Kind)); err != nil {
2500
+
return err
2501
+
}
2502
+
2503
+
// t.LexiconTypeID (string) (string)
2504
+
if len("$type") > 1000000 {
2505
+
return xerrors.Errorf("Value in field \"$type\" was too long")
2506
+
}
2507
+
2508
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
2509
+
return err
2510
+
}
2511
+
if _, err := cw.WriteString(string("$type")); err != nil {
2512
+
return err
2513
+
}
2514
+
2515
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.graph.vouch"))); err != nil {
2516
+
return err
2517
+
}
2518
+
if _, err := cw.WriteString(string("sh.tangled.graph.vouch")); err != nil {
2519
+
return err
2520
+
}
2521
+
2522
+
// t.Reason (string) (string)
2523
+
if t.Reason != nil {
2524
+
2525
+
if len("reason") > 1000000 {
2526
+
return xerrors.Errorf("Value in field \"reason\" was too long")
2527
+
}
2528
+
2529
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("reason"))); err != nil {
2530
+
return err
2531
+
}
2532
+
if _, err := cw.WriteString(string("reason")); err != nil {
2533
+
return err
2534
+
}
2535
+
2536
+
if t.Reason == nil {
2537
+
if _, err := cw.Write(cbg.CborNull); err != nil {
2538
+
return err
2539
+
}
2540
+
} else {
2541
+
if len(*t.Reason) > 1000000 {
2542
+
return xerrors.Errorf("Value in field t.Reason was too long")
2543
+
}
2544
+
2545
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Reason))); err != nil {
2546
+
return err
2547
+
}
2548
+
if _, err := cw.WriteString(string(*t.Reason)); err != nil {
2549
+
return err
2550
+
}
2551
+
}
2552
+
}
2553
+
2554
+
// t.CreatedAt (string) (string)
2555
+
if len("createdAt") > 1000000 {
2556
+
return xerrors.Errorf("Value in field \"createdAt\" was too long")
2557
+
}
2558
+
2559
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
2560
+
return err
2561
+
}
2562
+
if _, err := cw.WriteString(string("createdAt")); err != nil {
2563
+
return err
2564
+
}
2565
+
2566
+
if len(t.CreatedAt) > 1000000 {
2567
+
return xerrors.Errorf("Value in field t.CreatedAt was too long")
2568
+
}
2569
+
2570
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
2571
+
return err
2572
+
}
2573
+
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
2574
+
return err
2575
+
}
2576
+
return nil
2577
+
}
2578
+
2579
+
func (t *GraphVouch) UnmarshalCBOR(r io.Reader) (err error) {
2580
+
*t = GraphVouch{}
2581
+
2582
+
cr := cbg.NewCborReader(r)
2583
+
2584
+
maj, extra, err := cr.ReadHeader()
2585
+
if err != nil {
2586
+
return err
2587
+
}
2588
+
defer func() {
2589
+
if err == io.EOF {
2590
+
err = io.ErrUnexpectedEOF
2591
+
}
2592
+
}()
2593
+
2594
+
if maj != cbg.MajMap {
2595
+
return fmt.Errorf("cbor input should be of type map")
2596
+
}
2597
+
2598
+
if extra > cbg.MaxLength {
2599
+
return fmt.Errorf("GraphVouch: map struct too large (%d)", extra)
2600
+
}
2601
+
2602
+
n := extra
2603
+
2604
+
nameBuf := make([]byte, 9)
2605
+
for i := uint64(0); i < n; i++ {
2606
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
2607
+
if err != nil {
2608
+
return err
2609
+
}
2610
+
2611
+
if !ok {
2612
+
// Field doesn't exist on this type, so ignore it
2613
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
2614
+
return err
2615
+
}
2616
+
continue
2617
+
}
2618
+
2619
+
switch string(nameBuf[:nameLen]) {
2620
+
// t.Kind (string) (string)
2621
+
case "kind":
2622
+
2623
+
{
2624
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2625
+
if err != nil {
2626
+
return err
2627
+
}
2628
+
2629
+
t.Kind = string(sval)
2630
+
}
2631
+
// t.LexiconTypeID (string) (string)
2632
+
case "$type":
2633
+
2634
+
{
2635
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2636
+
if err != nil {
2637
+
return err
2638
+
}
2639
+
2640
+
t.LexiconTypeID = string(sval)
2641
+
}
2642
+
// t.Reason (string) (string)
2643
+
case "reason":
2644
+
2645
+
{
2646
+
b, err := cr.ReadByte()
2647
+
if err != nil {
2648
+
return err
2649
+
}
2650
+
if b != cbg.CborNull[0] {
2651
+
if err := cr.UnreadByte(); err != nil {
2652
+
return err
2653
+
}
2654
+
2655
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2656
+
if err != nil {
2657
+
return err
2658
+
}
2659
+
2660
+
t.Reason = (*string)(&sval)
2661
+
}
2662
+
}
2663
+
// t.CreatedAt (string) (string)
2664
+
case "createdAt":
2665
+
2666
+
{
2667
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2668
+
if err != nil {
2669
+
return err
2670
+
}
2671
+
2672
+
t.CreatedAt = string(sval)
2673
+
}
2674
+
2675
+
default:
2676
+
// Field doesn't exist on this type, so ignore it
2677
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
2678
+
return err
2679
+
}
2680
+
}
2681
+
}
2682
+
2683
+
return nil
2684
+
}
2463
2685
func (t *Knot) MarshalCBOR(w io.Writer) error {
2464
2686
if t == nil {
2465
2687
_, err := w.Write(cbg.CborNull)
···
9520
9742
9521
9743
return nil
9522
9744
}
9745
+
func (t *RepoPull_Round) MarshalCBOR(w io.Writer) error {
9746
+
if t == nil {
9747
+
_, err := w.Write(cbg.CborNull)
9748
+
return err
9749
+
}
9750
+
9751
+
cw := cbg.NewCborWriter(w)
9752
+
9753
+
if _, err := cw.Write([]byte{162}); err != nil {
9754
+
return err
9755
+
}
9756
+
9757
+
// t.CreatedAt (string) (string)
9758
+
if len("createdAt") > 1000000 {
9759
+
return xerrors.Errorf("Value in field \"createdAt\" was too long")
9760
+
}
9761
+
9762
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
9763
+
return err
9764
+
}
9765
+
if _, err := cw.WriteString(string("createdAt")); err != nil {
9766
+
return err
9767
+
}
9768
+
9769
+
if len(t.CreatedAt) > 1000000 {
9770
+
return xerrors.Errorf("Value in field t.CreatedAt was too long")
9771
+
}
9772
+
9773
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
9774
+
return err
9775
+
}
9776
+
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
9777
+
return err
9778
+
}
9779
+
9780
+
// t.PatchBlob (util.LexBlob) (struct)
9781
+
if len("patchBlob") > 1000000 {
9782
+
return xerrors.Errorf("Value in field \"patchBlob\" was too long")
9783
+
}
9784
+
9785
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("patchBlob"))); err != nil {
9786
+
return err
9787
+
}
9788
+
if _, err := cw.WriteString(string("patchBlob")); err != nil {
9789
+
return err
9790
+
}
9791
+
9792
+
if err := t.PatchBlob.MarshalCBOR(cw); err != nil {
9793
+
return err
9794
+
}
9795
+
return nil
9796
+
}
9797
+
9798
+
func (t *RepoPull_Round) UnmarshalCBOR(r io.Reader) (err error) {
9799
+
*t = RepoPull_Round{}
9800
+
9801
+
cr := cbg.NewCborReader(r)
9802
+
9803
+
maj, extra, err := cr.ReadHeader()
9804
+
if err != nil {
9805
+
return err
9806
+
}
9807
+
defer func() {
9808
+
if err == io.EOF {
9809
+
err = io.ErrUnexpectedEOF
9810
+
}
9811
+
}()
9812
+
9813
+
if maj != cbg.MajMap {
9814
+
return fmt.Errorf("cbor input should be of type map")
9815
+
}
9816
+
9817
+
if extra > cbg.MaxLength {
9818
+
return fmt.Errorf("RepoPull_Round: map struct too large (%d)", extra)
9819
+
}
9820
+
9821
+
n := extra
9822
+
9823
+
nameBuf := make([]byte, 9)
9824
+
for i := uint64(0); i < n; i++ {
9825
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
9826
+
if err != nil {
9827
+
return err
9828
+
}
9829
+
9830
+
if !ok {
9831
+
// Field doesn't exist on this type, so ignore it
9832
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
9833
+
return err
9834
+
}
9835
+
continue
9836
+
}
9837
+
9838
+
switch string(nameBuf[:nameLen]) {
9839
+
// t.CreatedAt (string) (string)
9840
+
case "createdAt":
9841
+
9842
+
{
9843
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
9844
+
if err != nil {
9845
+
return err
9846
+
}
9847
+
9848
+
t.CreatedAt = string(sval)
9849
+
}
9850
+
// t.PatchBlob (util.LexBlob) (struct)
9851
+
case "patchBlob":
9852
+
9853
+
{
9854
+
9855
+
b, err := cr.ReadByte()
9856
+
if err != nil {
9857
+
return err
9858
+
}
9859
+
if b != cbg.CborNull[0] {
9860
+
if err := cr.UnreadByte(); err != nil {
9861
+
return err
9862
+
}
9863
+
t.PatchBlob = new(util.LexBlob)
9864
+
if err := t.PatchBlob.UnmarshalCBOR(cr); err != nil {
9865
+
return xerrors.Errorf("unmarshaling t.PatchBlob pointer: %w", err)
9866
+
}
9867
+
}
9868
+
9869
+
}
9870
+
9871
+
default:
9872
+
// Field doesn't exist on this type, so ignore it
9873
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
9874
+
return err
9875
+
}
9876
+
}
9877
+
}
9878
+
9879
+
return nil
9880
+
}
9523
9881
func (t *RepoPull_Source) MarshalCBOR(w io.Writer) error {
9524
9882
if t == nil {
9525
9883
_, err := w.Write(cbg.CborNull)
···
9735
10093
9736
10094
return nil
9737
10095
}
9738
-
func (t *RepoPull_Round) MarshalCBOR(w io.Writer) error {
9739
-
if t == nil {
9740
-
_, err := w.Write(cbg.CborNull)
9741
-
return err
9742
-
}
9743
-
9744
-
cw := cbg.NewCborWriter(w)
9745
-
9746
-
if _, err := cw.Write([]byte{162}); err != nil {
9747
-
return err
9748
-
}
9749
-
9750
-
// t.CreatedAt (string) (string)
9751
-
if len("createdAt") > 1000000 {
9752
-
return xerrors.Errorf("Value in field \"createdAt\" was too long")
9753
-
}
9754
-
9755
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
9756
-
return err
9757
-
}
9758
-
if _, err := cw.WriteString(string("createdAt")); err != nil {
9759
-
return err
9760
-
}
9761
-
9762
-
if len(t.CreatedAt) > 1000000 {
9763
-
return xerrors.Errorf("Value in field t.CreatedAt was too long")
9764
-
}
9765
-
9766
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
9767
-
return err
9768
-
}
9769
-
if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
9770
-
return err
9771
-
}
9772
-
9773
-
// t.PatchBlob (util.LexBlob) (struct)
9774
-
if len("patchBlob") > 1000000 {
9775
-
return xerrors.Errorf("Value in field \"patchBlob\" was too long")
9776
-
}
9777
-
9778
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("patchBlob"))); err != nil {
9779
-
return err
9780
-
}
9781
-
if _, err := cw.WriteString(string("patchBlob")); err != nil {
9782
-
return err
9783
-
}
9784
-
9785
-
if err := t.PatchBlob.MarshalCBOR(cw); err != nil {
9786
-
return err
9787
-
}
9788
-
return nil
9789
-
}
9790
-
9791
-
func (t *RepoPull_Round) UnmarshalCBOR(r io.Reader) (err error) {
9792
-
*t = RepoPull_Round{}
9793
-
9794
-
cr := cbg.NewCborReader(r)
9795
-
9796
-
maj, extra, err := cr.ReadHeader()
9797
-
if err != nil {
9798
-
return err
9799
-
}
9800
-
defer func() {
9801
-
if err == io.EOF {
9802
-
err = io.ErrUnexpectedEOF
9803
-
}
9804
-
}()
9805
-
9806
-
if maj != cbg.MajMap {
9807
-
return fmt.Errorf("cbor input should be of type map")
9808
-
}
9809
-
9810
-
if extra > cbg.MaxLength {
9811
-
return fmt.Errorf("RepoPull_Round: map struct too large (%d)", extra)
9812
-
}
9813
-
9814
-
n := extra
9815
-
9816
-
nameBuf := make([]byte, 9)
9817
-
for i := uint64(0); i < n; i++ {
9818
-
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
9819
-
if err != nil {
9820
-
return err
9821
-
}
9822
-
9823
-
if !ok {
9824
-
// Field doesn't exist on this type, so ignore it
9825
-
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
9826
-
return err
9827
-
}
9828
-
continue
9829
-
}
9830
-
9831
-
switch string(nameBuf[:nameLen]) {
9832
-
// t.CreatedAt (string) (string)
9833
-
case "createdAt":
9834
-
9835
-
{
9836
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
9837
-
if err != nil {
9838
-
return err
9839
-
}
9840
-
9841
-
t.CreatedAt = string(sval)
9842
-
}
9843
-
// t.PatchBlob (util.LexBlob) (struct)
9844
-
case "patchBlob":
9845
-
9846
-
{
9847
-
9848
-
b, err := cr.ReadByte()
9849
-
if err != nil {
9850
-
return err
9851
-
}
9852
-
if b != cbg.CborNull[0] {
9853
-
if err := cr.UnreadByte(); err != nil {
9854
-
return err
9855
-
}
9856
-
t.PatchBlob = new(util.LexBlob)
9857
-
if err := t.PatchBlob.UnmarshalCBOR(cr); err != nil {
9858
-
return xerrors.Errorf("unmarshaling t.PatchBlob pointer: %w", err)
9859
-
}
9860
-
}
9861
-
9862
-
}
9863
-
9864
-
default:
9865
-
// Field doesn't exist on this type, so ignore it
9866
-
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
9867
-
return err
9868
-
}
9869
-
}
9870
-
}
9871
-
9872
-
return nil
9873
-
}
9874
10096
func (t *RepoPullStatus) MarshalCBOR(w io.Writer) error {
9875
10097
if t == nil {
9876
10098
_, err := w.Write(cbg.CborNull)
+26
api/tangled/graphvouch.go
+26
api/tangled/graphvouch.go
···
1
+
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
+
3
+
package tangled
4
+
5
+
// schema: sh.tangled.graph.vouch
6
+
7
+
import (
8
+
"github.com/bluesky-social/indigo/lex/util"
9
+
)
10
+
11
+
const (
12
+
GraphVouchNSID = "sh.tangled.graph.vouch"
13
+
)
14
+
15
+
func init() {
16
+
util.RegisterType("sh.tangled.graph.vouch", &GraphVouch{})
17
+
} //
18
+
// RECORDTYPE: GraphVouch
19
+
type GraphVouch struct {
20
+
LexiconTypeID string `json:"$type,const=sh.tangled.graph.vouch" cborgen:"$type,const=sh.tangled.graph.vouch"`
21
+
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
22
+
// kind: Whether this user is being vouched for or denounced
23
+
Kind string `json:"kind" cborgen:"kind"`
24
+
// reason: The reason for this vouch/denouncement
25
+
Reason *string `json:"reason,omitempty" cborgen:"reason,omitempty"`
26
+
}
+2
-1
cmd/cborgen/cborgen.go
+2
-1
cmd/cborgen/cborgen.go
···
24
24
tangled.GitRefUpdate_LangBreakdown{},
25
25
tangled.GitRefUpdate_Meta{},
26
26
tangled.GraphFollow{},
27
+
tangled.GraphVouch{},
27
28
tangled.Knot{},
28
29
tangled.KnotMember{},
29
30
tangled.LabelDefinition{},
···
49
50
tangled.RepoIssueState{},
50
51
tangled.RepoPull{},
51
52
tangled.RepoPullComment{},
52
-
tangled.RepoPull_Source{},
53
53
tangled.RepoPull_Round{},
54
+
tangled.RepoPull_Source{},
54
55
tangled.RepoPullStatus{},
55
56
tangled.RepoPull_Target{},
56
57
tangled.Spindle{},
+38
lexicons/graph/vouch.json
+38
lexicons/graph/vouch.json
···
1
+
{
2
+
"lexicon": 1,
3
+
"id": "sh.tangled.graph.vouch",
4
+
"needsCbor": true,
5
+
"needsType": true,
6
+
"defs": {
7
+
"main": {
8
+
"type": "record",
9
+
"key": "any",
10
+
"record": {
11
+
"type": "object",
12
+
"required": [
13
+
"kind",
14
+
"createdAt"
15
+
],
16
+
"properties": {
17
+
"kind": {
18
+
"type": "string",
19
+
"description": "Whether this user is being vouched for or denounced",
20
+
"enum": ["vouch", "denounce"],
21
+
"default": "vouch"
22
+
},
23
+
"reason": {
24
+
"type": "string",
25
+
"description": "The reason for this vouch/denouncement",
26
+
"maxGraphemes": 256,
27
+
"maxLength": 2560
28
+
},
29
+
"createdAt": {
30
+
"type": "string",
31
+
"format": "datetime"
32
+
}
33
+
}
34
+
}
35
+
}
36
+
}
37
+
}
38
+