+448
api/tangled/cbor_gen.go
+448
api/tangled/cbor_gen.go
···
3077
3077
3078
3078
return nil
3079
3079
}
3080
+
func (t *LabelOp) MarshalCBOR(w io.Writer) error {
3081
+
if t == nil {
3082
+
_, err := w.Write(cbg.CborNull)
3083
+
return err
3084
+
}
3085
+
3086
+
cw := cbg.NewCborWriter(w)
3087
+
3088
+
if _, err := cw.Write([]byte{165}); err != nil {
3089
+
return err
3090
+
}
3091
+
3092
+
// t.Add ([]*tangled.LabelOp_Operand) (slice)
3093
+
if len("add") > 1000000 {
3094
+
return xerrors.Errorf("Value in field \"add\" was too long")
3095
+
}
3096
+
3097
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("add"))); err != nil {
3098
+
return err
3099
+
}
3100
+
if _, err := cw.WriteString(string("add")); err != nil {
3101
+
return err
3102
+
}
3103
+
3104
+
if len(t.Add) > 8192 {
3105
+
return xerrors.Errorf("Slice value in field t.Add was too long")
3106
+
}
3107
+
3108
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Add))); err != nil {
3109
+
return err
3110
+
}
3111
+
for _, v := range t.Add {
3112
+
if err := v.MarshalCBOR(cw); err != nil {
3113
+
return err
3114
+
}
3115
+
3116
+
}
3117
+
3118
+
// t.LexiconTypeID (string) (string)
3119
+
if len("$type") > 1000000 {
3120
+
return xerrors.Errorf("Value in field \"$type\" was too long")
3121
+
}
3122
+
3123
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
3124
+
return err
3125
+
}
3126
+
if _, err := cw.WriteString(string("$type")); err != nil {
3127
+
return err
3128
+
}
3129
+
3130
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.label.op"))); err != nil {
3131
+
return err
3132
+
}
3133
+
if _, err := cw.WriteString(string("sh.tangled.label.op")); err != nil {
3134
+
return err
3135
+
}
3136
+
3137
+
// t.Delete ([]*tangled.LabelOp_Operand) (slice)
3138
+
if len("delete") > 1000000 {
3139
+
return xerrors.Errorf("Value in field \"delete\" was too long")
3140
+
}
3141
+
3142
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("delete"))); err != nil {
3143
+
return err
3144
+
}
3145
+
if _, err := cw.WriteString(string("delete")); err != nil {
3146
+
return err
3147
+
}
3148
+
3149
+
if len(t.Delete) > 8192 {
3150
+
return xerrors.Errorf("Slice value in field t.Delete was too long")
3151
+
}
3152
+
3153
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Delete))); err != nil {
3154
+
return err
3155
+
}
3156
+
for _, v := range t.Delete {
3157
+
if err := v.MarshalCBOR(cw); err != nil {
3158
+
return err
3159
+
}
3160
+
3161
+
}
3162
+
3163
+
// t.Subject (string) (string)
3164
+
if len("subject") > 1000000 {
3165
+
return xerrors.Errorf("Value in field \"subject\" was too long")
3166
+
}
3167
+
3168
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("subject"))); err != nil {
3169
+
return err
3170
+
}
3171
+
if _, err := cw.WriteString(string("subject")); err != nil {
3172
+
return err
3173
+
}
3174
+
3175
+
if len(t.Subject) > 1000000 {
3176
+
return xerrors.Errorf("Value in field t.Subject was too long")
3177
+
}
3178
+
3179
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Subject))); err != nil {
3180
+
return err
3181
+
}
3182
+
if _, err := cw.WriteString(string(t.Subject)); err != nil {
3183
+
return err
3184
+
}
3185
+
3186
+
// t.PerformedAt (string) (string)
3187
+
if len("performedAt") > 1000000 {
3188
+
return xerrors.Errorf("Value in field \"performedAt\" was too long")
3189
+
}
3190
+
3191
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("performedAt"))); err != nil {
3192
+
return err
3193
+
}
3194
+
if _, err := cw.WriteString(string("performedAt")); err != nil {
3195
+
return err
3196
+
}
3197
+
3198
+
if len(t.PerformedAt) > 1000000 {
3199
+
return xerrors.Errorf("Value in field t.PerformedAt was too long")
3200
+
}
3201
+
3202
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.PerformedAt))); err != nil {
3203
+
return err
3204
+
}
3205
+
if _, err := cw.WriteString(string(t.PerformedAt)); err != nil {
3206
+
return err
3207
+
}
3208
+
return nil
3209
+
}
3210
+
3211
+
func (t *LabelOp) UnmarshalCBOR(r io.Reader) (err error) {
3212
+
*t = LabelOp{}
3213
+
3214
+
cr := cbg.NewCborReader(r)
3215
+
3216
+
maj, extra, err := cr.ReadHeader()
3217
+
if err != nil {
3218
+
return err
3219
+
}
3220
+
defer func() {
3221
+
if err == io.EOF {
3222
+
err = io.ErrUnexpectedEOF
3223
+
}
3224
+
}()
3225
+
3226
+
if maj != cbg.MajMap {
3227
+
return fmt.Errorf("cbor input should be of type map")
3228
+
}
3229
+
3230
+
if extra > cbg.MaxLength {
3231
+
return fmt.Errorf("LabelOp: map struct too large (%d)", extra)
3232
+
}
3233
+
3234
+
n := extra
3235
+
3236
+
nameBuf := make([]byte, 11)
3237
+
for i := uint64(0); i < n; i++ {
3238
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
3239
+
if err != nil {
3240
+
return err
3241
+
}
3242
+
3243
+
if !ok {
3244
+
// Field doesn't exist on this type, so ignore it
3245
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
3246
+
return err
3247
+
}
3248
+
continue
3249
+
}
3250
+
3251
+
switch string(nameBuf[:nameLen]) {
3252
+
// t.Add ([]*tangled.LabelOp_Operand) (slice)
3253
+
case "add":
3254
+
3255
+
maj, extra, err = cr.ReadHeader()
3256
+
if err != nil {
3257
+
return err
3258
+
}
3259
+
3260
+
if extra > 8192 {
3261
+
return fmt.Errorf("t.Add: array too large (%d)", extra)
3262
+
}
3263
+
3264
+
if maj != cbg.MajArray {
3265
+
return fmt.Errorf("expected cbor array")
3266
+
}
3267
+
3268
+
if extra > 0 {
3269
+
t.Add = make([]*LabelOp_Operand, extra)
3270
+
}
3271
+
3272
+
for i := 0; i < int(extra); i++ {
3273
+
{
3274
+
var maj byte
3275
+
var extra uint64
3276
+
var err error
3277
+
_ = maj
3278
+
_ = extra
3279
+
_ = err
3280
+
3281
+
{
3282
+
3283
+
b, err := cr.ReadByte()
3284
+
if err != nil {
3285
+
return err
3286
+
}
3287
+
if b != cbg.CborNull[0] {
3288
+
if err := cr.UnreadByte(); err != nil {
3289
+
return err
3290
+
}
3291
+
t.Add[i] = new(LabelOp_Operand)
3292
+
if err := t.Add[i].UnmarshalCBOR(cr); err != nil {
3293
+
return xerrors.Errorf("unmarshaling t.Add[i] pointer: %w", err)
3294
+
}
3295
+
}
3296
+
3297
+
}
3298
+
3299
+
}
3300
+
}
3301
+
// t.LexiconTypeID (string) (string)
3302
+
case "$type":
3303
+
3304
+
{
3305
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3306
+
if err != nil {
3307
+
return err
3308
+
}
3309
+
3310
+
t.LexiconTypeID = string(sval)
3311
+
}
3312
+
// t.Delete ([]*tangled.LabelOp_Operand) (slice)
3313
+
case "delete":
3314
+
3315
+
maj, extra, err = cr.ReadHeader()
3316
+
if err != nil {
3317
+
return err
3318
+
}
3319
+
3320
+
if extra > 8192 {
3321
+
return fmt.Errorf("t.Delete: array too large (%d)", extra)
3322
+
}
3323
+
3324
+
if maj != cbg.MajArray {
3325
+
return fmt.Errorf("expected cbor array")
3326
+
}
3327
+
3328
+
if extra > 0 {
3329
+
t.Delete = make([]*LabelOp_Operand, extra)
3330
+
}
3331
+
3332
+
for i := 0; i < int(extra); i++ {
3333
+
{
3334
+
var maj byte
3335
+
var extra uint64
3336
+
var err error
3337
+
_ = maj
3338
+
_ = extra
3339
+
_ = err
3340
+
3341
+
{
3342
+
3343
+
b, err := cr.ReadByte()
3344
+
if err != nil {
3345
+
return err
3346
+
}
3347
+
if b != cbg.CborNull[0] {
3348
+
if err := cr.UnreadByte(); err != nil {
3349
+
return err
3350
+
}
3351
+
t.Delete[i] = new(LabelOp_Operand)
3352
+
if err := t.Delete[i].UnmarshalCBOR(cr); err != nil {
3353
+
return xerrors.Errorf("unmarshaling t.Delete[i] pointer: %w", err)
3354
+
}
3355
+
}
3356
+
3357
+
}
3358
+
3359
+
}
3360
+
}
3361
+
// t.Subject (string) (string)
3362
+
case "subject":
3363
+
3364
+
{
3365
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3366
+
if err != nil {
3367
+
return err
3368
+
}
3369
+
3370
+
t.Subject = string(sval)
3371
+
}
3372
+
// t.PerformedAt (string) (string)
3373
+
case "performedAt":
3374
+
3375
+
{
3376
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3377
+
if err != nil {
3378
+
return err
3379
+
}
3380
+
3381
+
t.PerformedAt = string(sval)
3382
+
}
3383
+
3384
+
default:
3385
+
// Field doesn't exist on this type, so ignore it
3386
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
3387
+
return err
3388
+
}
3389
+
}
3390
+
}
3391
+
3392
+
return nil
3393
+
}
3394
+
func (t *LabelOp_Operand) MarshalCBOR(w io.Writer) error {
3395
+
if t == nil {
3396
+
_, err := w.Write(cbg.CborNull)
3397
+
return err
3398
+
}
3399
+
3400
+
cw := cbg.NewCborWriter(w)
3401
+
3402
+
if _, err := cw.Write([]byte{162}); err != nil {
3403
+
return err
3404
+
}
3405
+
3406
+
// t.Key (string) (string)
3407
+
if len("key") > 1000000 {
3408
+
return xerrors.Errorf("Value in field \"key\" was too long")
3409
+
}
3410
+
3411
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil {
3412
+
return err
3413
+
}
3414
+
if _, err := cw.WriteString(string("key")); err != nil {
3415
+
return err
3416
+
}
3417
+
3418
+
if len(t.Key) > 1000000 {
3419
+
return xerrors.Errorf("Value in field t.Key was too long")
3420
+
}
3421
+
3422
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
3423
+
return err
3424
+
}
3425
+
if _, err := cw.WriteString(string(t.Key)); err != nil {
3426
+
return err
3427
+
}
3428
+
3429
+
// t.Value (string) (string)
3430
+
if len("value") > 1000000 {
3431
+
return xerrors.Errorf("Value in field \"value\" was too long")
3432
+
}
3433
+
3434
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil {
3435
+
return err
3436
+
}
3437
+
if _, err := cw.WriteString(string("value")); err != nil {
3438
+
return err
3439
+
}
3440
+
3441
+
if len(t.Value) > 1000000 {
3442
+
return xerrors.Errorf("Value in field t.Value was too long")
3443
+
}
3444
+
3445
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil {
3446
+
return err
3447
+
}
3448
+
if _, err := cw.WriteString(string(t.Value)); err != nil {
3449
+
return err
3450
+
}
3451
+
return nil
3452
+
}
3453
+
3454
+
func (t *LabelOp_Operand) UnmarshalCBOR(r io.Reader) (err error) {
3455
+
*t = LabelOp_Operand{}
3456
+
3457
+
cr := cbg.NewCborReader(r)
3458
+
3459
+
maj, extra, err := cr.ReadHeader()
3460
+
if err != nil {
3461
+
return err
3462
+
}
3463
+
defer func() {
3464
+
if err == io.EOF {
3465
+
err = io.ErrUnexpectedEOF
3466
+
}
3467
+
}()
3468
+
3469
+
if maj != cbg.MajMap {
3470
+
return fmt.Errorf("cbor input should be of type map")
3471
+
}
3472
+
3473
+
if extra > cbg.MaxLength {
3474
+
return fmt.Errorf("LabelOp_Operand: map struct too large (%d)", extra)
3475
+
}
3476
+
3477
+
n := extra
3478
+
3479
+
nameBuf := make([]byte, 5)
3480
+
for i := uint64(0); i < n; i++ {
3481
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
3482
+
if err != nil {
3483
+
return err
3484
+
}
3485
+
3486
+
if !ok {
3487
+
// Field doesn't exist on this type, so ignore it
3488
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
3489
+
return err
3490
+
}
3491
+
continue
3492
+
}
3493
+
3494
+
switch string(nameBuf[:nameLen]) {
3495
+
// t.Key (string) (string)
3496
+
case "key":
3497
+
3498
+
{
3499
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3500
+
if err != nil {
3501
+
return err
3502
+
}
3503
+
3504
+
t.Key = string(sval)
3505
+
}
3506
+
// t.Value (string) (string)
3507
+
case "value":
3508
+
3509
+
{
3510
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3511
+
if err != nil {
3512
+
return err
3513
+
}
3514
+
3515
+
t.Value = string(sval)
3516
+
}
3517
+
3518
+
default:
3519
+
// Field doesn't exist on this type, so ignore it
3520
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
3521
+
return err
3522
+
}
3523
+
}
3524
+
}
3525
+
3526
+
return nil
3527
+
}
3080
3528
func (t *Pipeline) MarshalCBOR(w io.Writer) error {
3081
3529
if t == nil {
3082
3530
_, 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
+
}