+448
api/tangled/cbor_gen.go
+448
api/tangled/cbor_gen.go
···
3068
3069
return nil
3070
}
3071
+
func (t *LabelOp) MarshalCBOR(w io.Writer) error {
3072
+
if t == nil {
3073
+
_, err := w.Write(cbg.CborNull)
3074
+
return err
3075
+
}
3076
+
3077
+
cw := cbg.NewCborWriter(w)
3078
+
3079
+
if _, err := cw.Write([]byte{165}); err != nil {
3080
+
return err
3081
+
}
3082
+
3083
+
// t.Add ([]*tangled.LabelOp_Operand) (slice)
3084
+
if len("add") > 1000000 {
3085
+
return xerrors.Errorf("Value in field \"add\" was too long")
3086
+
}
3087
+
3088
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("add"))); err != nil {
3089
+
return err
3090
+
}
3091
+
if _, err := cw.WriteString(string("add")); err != nil {
3092
+
return err
3093
+
}
3094
+
3095
+
if len(t.Add) > 8192 {
3096
+
return xerrors.Errorf("Slice value in field t.Add was too long")
3097
+
}
3098
+
3099
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Add))); err != nil {
3100
+
return err
3101
+
}
3102
+
for _, v := range t.Add {
3103
+
if err := v.MarshalCBOR(cw); err != nil {
3104
+
return err
3105
+
}
3106
+
3107
+
}
3108
+
3109
+
// t.LexiconTypeID (string) (string)
3110
+
if len("$type") > 1000000 {
3111
+
return xerrors.Errorf("Value in field \"$type\" was too long")
3112
+
}
3113
+
3114
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
3115
+
return err
3116
+
}
3117
+
if _, err := cw.WriteString(string("$type")); err != nil {
3118
+
return err
3119
+
}
3120
+
3121
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.label.op"))); err != nil {
3122
+
return err
3123
+
}
3124
+
if _, err := cw.WriteString(string("sh.tangled.label.op")); err != nil {
3125
+
return err
3126
+
}
3127
+
3128
+
// t.Delete ([]*tangled.LabelOp_Operand) (slice)
3129
+
if len("delete") > 1000000 {
3130
+
return xerrors.Errorf("Value in field \"delete\" was too long")
3131
+
}
3132
+
3133
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("delete"))); err != nil {
3134
+
return err
3135
+
}
3136
+
if _, err := cw.WriteString(string("delete")); err != nil {
3137
+
return err
3138
+
}
3139
+
3140
+
if len(t.Delete) > 8192 {
3141
+
return xerrors.Errorf("Slice value in field t.Delete was too long")
3142
+
}
3143
+
3144
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Delete))); err != nil {
3145
+
return err
3146
+
}
3147
+
for _, v := range t.Delete {
3148
+
if err := v.MarshalCBOR(cw); err != nil {
3149
+
return err
3150
+
}
3151
+
3152
+
}
3153
+
3154
+
// t.Subject (string) (string)
3155
+
if len("subject") > 1000000 {
3156
+
return xerrors.Errorf("Value in field \"subject\" was too long")
3157
+
}
3158
+
3159
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil {
3160
+
return err
3161
+
}
3162
+
if _, err := cw.WriteString(string("subject")); err != nil {
3163
+
return err
3164
+
}
3165
+
3166
+
if len(t.Subject) > 1000000 {
3167
+
return xerrors.Errorf("Value in field t.Subject was too long")
3168
+
}
3169
+
3170
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Subject))); err != nil {
3171
+
return err
3172
+
}
3173
+
if _, err := cw.WriteString(string(t.Subject)); err != nil {
3174
+
return err
3175
+
}
3176
+
3177
+
// t.PerformedAt (string) (string)
3178
+
if len("performedAt") > 1000000 {
3179
+
return xerrors.Errorf("Value in field \"performedAt\" was too long")
3180
+
}
3181
+
3182
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("performedAt"))); err != nil {
3183
+
return err
3184
+
}
3185
+
if _, err := cw.WriteString(string("performedAt")); err != nil {
3186
+
return err
3187
+
}
3188
+
3189
+
if len(t.PerformedAt) > 1000000 {
3190
+
return xerrors.Errorf("Value in field t.PerformedAt was too long")
3191
+
}
3192
+
3193
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.PerformedAt))); err != nil {
3194
+
return err
3195
+
}
3196
+
if _, err := cw.WriteString(string(t.PerformedAt)); err != nil {
3197
+
return err
3198
+
}
3199
+
return nil
3200
+
}
3201
+
3202
+
func (t *LabelOp) UnmarshalCBOR(r io.Reader) (err error) {
3203
+
*t = LabelOp{}
3204
+
3205
+
cr := cbg.NewCborReader(r)
3206
+
3207
+
maj, extra, err := cr.ReadHeader()
3208
+
if err != nil {
3209
+
return err
3210
+
}
3211
+
defer func() {
3212
+
if err == io.EOF {
3213
+
err = io.ErrUnexpectedEOF
3214
+
}
3215
+
}()
3216
+
3217
+
if maj != cbg.MajMap {
3218
+
return fmt.Errorf("cbor input should be of type map")
3219
+
}
3220
+
3221
+
if extra > cbg.MaxLength {
3222
+
return fmt.Errorf("LabelOp: map struct too large (%d)", extra)
3223
+
}
3224
+
3225
+
n := extra
3226
+
3227
+
nameBuf := make([]byte, 11)
3228
+
for i := uint64(0); i < n; i++ {
3229
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
3230
+
if err != nil {
3231
+
return err
3232
+
}
3233
+
3234
+
if !ok {
3235
+
// Field doesn't exist on this type, so ignore it
3236
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
3237
+
return err
3238
+
}
3239
+
continue
3240
+
}
3241
+
3242
+
switch string(nameBuf[:nameLen]) {
3243
+
// t.Add ([]*tangled.LabelOp_Operand) (slice)
3244
+
case "add":
3245
+
3246
+
maj, extra, err = cr.ReadHeader()
3247
+
if err != nil {
3248
+
return err
3249
+
}
3250
+
3251
+
if extra > 8192 {
3252
+
return fmt.Errorf("t.Add: array too large (%d)", extra)
3253
+
}
3254
+
3255
+
if maj != cbg.MajArray {
3256
+
return fmt.Errorf("expected cbor array")
3257
+
}
3258
+
3259
+
if extra > 0 {
3260
+
t.Add = make([]*LabelOp_Operand, extra)
3261
+
}
3262
+
3263
+
for i := 0; i < int(extra); i++ {
3264
+
{
3265
+
var maj byte
3266
+
var extra uint64
3267
+
var err error
3268
+
_ = maj
3269
+
_ = extra
3270
+
_ = err
3271
+
3272
+
{
3273
+
3274
+
b, err := cr.ReadByte()
3275
+
if err != nil {
3276
+
return err
3277
+
}
3278
+
if b != cbg.CborNull[0] {
3279
+
if err := cr.UnreadByte(); err != nil {
3280
+
return err
3281
+
}
3282
+
t.Add[i] = new(LabelOp_Operand)
3283
+
if err := t.Add[i].UnmarshalCBOR(cr); err != nil {
3284
+
return xerrors.Errorf("unmarshaling t.Add[i] pointer: %w", err)
3285
+
}
3286
+
}
3287
+
3288
+
}
3289
+
3290
+
}
3291
+
}
3292
+
// t.LexiconTypeID (string) (string)
3293
+
case "$type":
3294
+
3295
+
{
3296
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3297
+
if err != nil {
3298
+
return err
3299
+
}
3300
+
3301
+
t.LexiconTypeID = string(sval)
3302
+
}
3303
+
// t.Delete ([]*tangled.LabelOp_Operand) (slice)
3304
+
case "delete":
3305
+
3306
+
maj, extra, err = cr.ReadHeader()
3307
+
if err != nil {
3308
+
return err
3309
+
}
3310
+
3311
+
if extra > 8192 {
3312
+
return fmt.Errorf("t.Delete: array too large (%d)", extra)
3313
+
}
3314
+
3315
+
if maj != cbg.MajArray {
3316
+
return fmt.Errorf("expected cbor array")
3317
+
}
3318
+
3319
+
if extra > 0 {
3320
+
t.Delete = make([]*LabelOp_Operand, extra)
3321
+
}
3322
+
3323
+
for i := 0; i < int(extra); i++ {
3324
+
{
3325
+
var maj byte
3326
+
var extra uint64
3327
+
var err error
3328
+
_ = maj
3329
+
_ = extra
3330
+
_ = err
3331
+
3332
+
{
3333
+
3334
+
b, err := cr.ReadByte()
3335
+
if err != nil {
3336
+
return err
3337
+
}
3338
+
if b != cbg.CborNull[0] {
3339
+
if err := cr.UnreadByte(); err != nil {
3340
+
return err
3341
+
}
3342
+
t.Delete[i] = new(LabelOp_Operand)
3343
+
if err := t.Delete[i].UnmarshalCBOR(cr); err != nil {
3344
+
return xerrors.Errorf("unmarshaling t.Delete[i] pointer: %w", err)
3345
+
}
3346
+
}
3347
+
3348
+
}
3349
+
3350
+
}
3351
+
}
3352
+
// t.Subject (string) (string)
3353
+
case "subject":
3354
+
3355
+
{
3356
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3357
+
if err != nil {
3358
+
return err
3359
+
}
3360
+
3361
+
t.Subject = string(sval)
3362
+
}
3363
+
// t.PerformedAt (string) (string)
3364
+
case "performedAt":
3365
+
3366
+
{
3367
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3368
+
if err != nil {
3369
+
return err
3370
+
}
3371
+
3372
+
t.PerformedAt = string(sval)
3373
+
}
3374
+
3375
+
default:
3376
+
// Field doesn't exist on this type, so ignore it
3377
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
3378
+
return err
3379
+
}
3380
+
}
3381
+
}
3382
+
3383
+
return nil
3384
+
}
3385
+
func (t *LabelOp_Operand) MarshalCBOR(w io.Writer) error {
3386
+
if t == nil {
3387
+
_, err := w.Write(cbg.CborNull)
3388
+
return err
3389
+
}
3390
+
3391
+
cw := cbg.NewCborWriter(w)
3392
+
3393
+
if _, err := cw.Write([]byte{162}); err != nil {
3394
+
return err
3395
+
}
3396
+
3397
+
// t.Key (string) (string)
3398
+
if len("key") > 1000000 {
3399
+
return xerrors.Errorf("Value in field \"key\" was too long")
3400
+
}
3401
+
3402
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil {
3403
+
return err
3404
+
}
3405
+
if _, err := cw.WriteString(string("key")); err != nil {
3406
+
return err
3407
+
}
3408
+
3409
+
if len(t.Key) > 1000000 {
3410
+
return xerrors.Errorf("Value in field t.Key was too long")
3411
+
}
3412
+
3413
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
3414
+
return err
3415
+
}
3416
+
if _, err := cw.WriteString(string(t.Key)); err != nil {
3417
+
return err
3418
+
}
3419
+
3420
+
// t.Value (string) (string)
3421
+
if len("value") > 1000000 {
3422
+
return xerrors.Errorf("Value in field \"value\" was too long")
3423
+
}
3424
+
3425
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil {
3426
+
return err
3427
+
}
3428
+
if _, err := cw.WriteString(string("value")); err != nil {
3429
+
return err
3430
+
}
3431
+
3432
+
if len(t.Value) > 1000000 {
3433
+
return xerrors.Errorf("Value in field t.Value was too long")
3434
+
}
3435
+
3436
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil {
3437
+
return err
3438
+
}
3439
+
if _, err := cw.WriteString(string(t.Value)); err != nil {
3440
+
return err
3441
+
}
3442
+
return nil
3443
+
}
3444
+
3445
+
func (t *LabelOp_Operand) UnmarshalCBOR(r io.Reader) (err error) {
3446
+
*t = LabelOp_Operand{}
3447
+
3448
+
cr := cbg.NewCborReader(r)
3449
+
3450
+
maj, extra, err := cr.ReadHeader()
3451
+
if err != nil {
3452
+
return err
3453
+
}
3454
+
defer func() {
3455
+
if err == io.EOF {
3456
+
err = io.ErrUnexpectedEOF
3457
+
}
3458
+
}()
3459
+
3460
+
if maj != cbg.MajMap {
3461
+
return fmt.Errorf("cbor input should be of type map")
3462
+
}
3463
+
3464
+
if extra > cbg.MaxLength {
3465
+
return fmt.Errorf("LabelOp_Operand: map struct too large (%d)", extra)
3466
+
}
3467
+
3468
+
n := extra
3469
+
3470
+
nameBuf := make([]byte, 5)
3471
+
for i := uint64(0); i < n; i++ {
3472
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
3473
+
if err != nil {
3474
+
return err
3475
+
}
3476
+
3477
+
if !ok {
3478
+
// Field doesn't exist on this type, so ignore it
3479
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
3480
+
return err
3481
+
}
3482
+
continue
3483
+
}
3484
+
3485
+
switch string(nameBuf[:nameLen]) {
3486
+
// t.Key (string) (string)
3487
+
case "key":
3488
+
3489
+
{
3490
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3491
+
if err != nil {
3492
+
return err
3493
+
}
3494
+
3495
+
t.Key = string(sval)
3496
+
}
3497
+
// t.Value (string) (string)
3498
+
case "value":
3499
+
3500
+
{
3501
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3502
+
if err != nil {
3503
+
return err
3504
+
}
3505
+
3506
+
t.Value = string(sval)
3507
+
}
3508
+
3509
+
default:
3510
+
// Field doesn't exist on this type, so ignore it
3511
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
3512
+
return err
3513
+
}
3514
+
}
3515
+
}
3516
+
3517
+
return nil
3518
+
}
3519
func (t *Pipeline) MarshalCBOR(w io.Writer) error {
3520
if t == nil {
3521
_, err := w.Write(cbg.CborNull)
+34
api/tangled/labelop.go
+34
api/tangled/labelop.go
···
···
1
+
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
+
3
+
package tangled
4
+
5
+
// schema: sh.tangled.label.op
6
+
7
+
import (
8
+
"github.com/bluesky-social/indigo/lex/util"
9
+
)
10
+
11
+
const (
12
+
LabelOpNSID = "sh.tangled.label.op"
13
+
)
14
+
15
+
func init() {
16
+
util.RegisterType("sh.tangled.label.op", &LabelOp{})
17
+
} //
18
+
// RECORDTYPE: LabelOp
19
+
type LabelOp struct {
20
+
LexiconTypeID string `json:"$type,const=sh.tangled.label.op" cborgen:"$type,const=sh.tangled.label.op"`
21
+
Add []*LabelOp_Operand `json:"add" cborgen:"add"`
22
+
Delete []*LabelOp_Operand `json:"delete" cborgen:"delete"`
23
+
PerformedAt string `json:"performedAt" cborgen:"performedAt"`
24
+
// subject: The subject (task, pull or discussion) of this label. Appviews may apply a `scope` check and refuse this op.
25
+
Subject string `json:"subject" cborgen:"subject"`
26
+
}
27
+
28
+
// LabelOp_Operand is a "operand" in the sh.tangled.label.op schema.
29
+
type LabelOp_Operand struct {
30
+
// key: ATURI to the label definition
31
+
Key string `json:"key" cborgen:"key"`
32
+
// value: Stringified value of the label. This is first unstringed by appviews and then interpreted as a concrete value.
33
+
Value string `json:"value" cborgen:"value"`
34
+
}
+2
cmd/gen.go
+2
cmd/gen.go
+64
lexicons/label/op.json
+64
lexicons/label/op.json
···
···
1
+
{
2
+
"lexicon": 1,
3
+
"id": "sh.tangled.label.op",
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
+
"add",
15
+
"delete",
16
+
"performedAt"
17
+
],
18
+
"properties": {
19
+
"subject": {
20
+
"type": "string",
21
+
"format": "at-uri",
22
+
"description": "The subject (task, pull or discussion) of this label. Appviews may apply a `scope` check and refuse this op."
23
+
},
24
+
"performedAt": {
25
+
"type": "string",
26
+
"format": "datetime"
27
+
},
28
+
"add": {
29
+
"type": "array",
30
+
"items": {
31
+
"type": "ref",
32
+
"ref": "#operand"
33
+
}
34
+
},
35
+
"delete": {
36
+
"type": "array",
37
+
"items": {
38
+
"type": "ref",
39
+
"ref": "#operand"
40
+
}
41
+
}
42
+
}
43
+
}
44
+
},
45
+
"operand": {
46
+
"type": "object",
47
+
"required": [
48
+
"key",
49
+
"value"
50
+
],
51
+
"properties": {
52
+
"key": {
53
+
"type": "string",
54
+
"format": "at-uri",
55
+
"description": "ATURI to the label definition"
56
+
},
57
+
"value": {
58
+
"type": "string",
59
+
"description": "Stringified value of the label. This is first unstringed by appviews and then interpreted as a concrete value."
60
+
}
61
+
}
62
+
}
63
+
}
64
+
}