diff --git a/api/atproto/admindeleteAccount.go b/api/atproto/admindeleteAccount.go new file mode 100644 index 000000000..b57992bc3 --- /dev/null +++ b/api/atproto/admindeleteAccount.go @@ -0,0 +1,25 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package atproto + +// schema: com.atproto.admin.deleteAccount + +import ( + "context" + + "github.com/bluesky-social/indigo/xrpc" +) + +// AdminDeleteAccount_Input is the input argument to a com.atproto.admin.deleteAccount call. +type AdminDeleteAccount_Input struct { + Did string `json:"did" cborgen:"did"` +} + +// AdminDeleteAccount calls the XRPC method "com.atproto.admin.deleteAccount". +func AdminDeleteAccount(ctx context.Context, c *xrpc.Client, input *AdminDeleteAccount_Input) error { + if err := c.Do(ctx, xrpc.Procedure, "application/json", "com.atproto.admin.deleteAccount", nil, input, nil); err != nil { + return err + } + + return nil +} diff --git a/api/atproto/cbor_gen.go b/api/atproto/cbor_gen.go index 23b390941..b7c29a67e 100644 --- a/api/atproto/cbor_gen.go +++ b/api/atproto/cbor_gen.go @@ -525,13 +525,32 @@ func (t *SyncSubscribeRepos_Commit) UnmarshalCBOR(r io.Reader) (err error) { } for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Ops[i] = new(SyncSubscribeRepos_RepoOp) + if err := t.Ops[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Ops[i] pointer: %w", err) + } + } - var v SyncSubscribeRepos_RepoOp - if err := v.UnmarshalCBOR(cr); err != nil { - return err + } } - - t.Ops[i] = &v } // t.Rev (string) (string) @@ -634,13 +653,22 @@ func (t *SyncSubscribeRepos_Commit) UnmarshalCBOR(r io.Reader) (err error) { } for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err - var v util.LexLink - if err := v.UnmarshalCBOR(cr); err != nil { - return err - } + { + + if err := t.Blobs[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Blobs[i]: %w", err) + } - t.Blobs[i] = v + } + } } // t.Since (string) (string) @@ -1802,13 +1830,32 @@ func (t *LabelDefs_SelfLabels) UnmarshalCBOR(r io.Reader) (err error) { } for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Values[i] = new(LabelDefs_SelfLabel) + if err := t.Values[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Values[i] pointer: %w", err) + } + } - var v LabelDefs_SelfLabel - if err := v.UnmarshalCBOR(cr); err != nil { - return err + } } - - t.Values[i] = &v } default: diff --git a/api/atproto/repodescribeRepo.go b/api/atproto/repodescribeRepo.go index f6fac4b68..4755fa376 100644 --- a/api/atproto/repodescribeRepo.go +++ b/api/atproto/repodescribeRepo.go @@ -7,16 +7,17 @@ package atproto import ( "context" + "github.com/bluesky-social/indigo/lex/util" "github.com/bluesky-social/indigo/xrpc" ) // RepoDescribeRepo_Output is the output of a com.atproto.repo.describeRepo call. type RepoDescribeRepo_Output struct { - Collections []string `json:"collections" cborgen:"collections"` - Did string `json:"did" cborgen:"did"` - DidDoc interface{} `json:"didDoc" cborgen:"didDoc"` - Handle string `json:"handle" cborgen:"handle"` - HandleIsCorrect bool `json:"handleIsCorrect" cborgen:"handleIsCorrect"` + Collections []string `json:"collections" cborgen:"collections"` + Did string `json:"did" cborgen:"did"` + DidDoc *util.LexiconTypeDecoder `json:"didDoc" cborgen:"didDoc"` + Handle string `json:"handle" cborgen:"handle"` + HandleIsCorrect bool `json:"handleIsCorrect" cborgen:"handleIsCorrect"` } // RepoDescribeRepo calls the XRPC method "com.atproto.repo.describeRepo". diff --git a/api/atproto/servercreateAccount.go b/api/atproto/servercreateAccount.go index 3ef944e41..5f12573c8 100644 --- a/api/atproto/servercreateAccount.go +++ b/api/atproto/servercreateAccount.go @@ -7,27 +7,28 @@ package atproto import ( "context" + "github.com/bluesky-social/indigo/lex/util" "github.com/bluesky-social/indigo/xrpc" ) // ServerCreateAccount_Input is the input argument to a com.atproto.server.createAccount call. type ServerCreateAccount_Input struct { - Did *string `json:"did,omitempty" cborgen:"did,omitempty"` - Email *string `json:"email,omitempty" cborgen:"email,omitempty"` - Handle string `json:"handle" cborgen:"handle"` - InviteCode *string `json:"inviteCode,omitempty" cborgen:"inviteCode,omitempty"` - Password *string `json:"password,omitempty" cborgen:"password,omitempty"` - PlcOp *interface{} `json:"plcOp,omitempty" cborgen:"plcOp,omitempty"` - RecoveryKey *string `json:"recoveryKey,omitempty" cborgen:"recoveryKey,omitempty"` + Did *string `json:"did,omitempty" cborgen:"did,omitempty"` + Email *string `json:"email,omitempty" cborgen:"email,omitempty"` + Handle string `json:"handle" cborgen:"handle"` + InviteCode *string `json:"inviteCode,omitempty" cborgen:"inviteCode,omitempty"` + Password *string `json:"password,omitempty" cborgen:"password,omitempty"` + PlcOp *util.LexiconTypeDecoder `json:"plcOp,omitempty" cborgen:"plcOp,omitempty"` + RecoveryKey *string `json:"recoveryKey,omitempty" cborgen:"recoveryKey,omitempty"` } // ServerCreateAccount_Output is the output of a com.atproto.server.createAccount call. type ServerCreateAccount_Output struct { - AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` - Did string `json:"did" cborgen:"did"` - DidDoc *interface{} `json:"didDoc,omitempty" cborgen:"didDoc,omitempty"` - Handle string `json:"handle" cborgen:"handle"` - RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` + AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` + Did string `json:"did" cborgen:"did"` + DidDoc *util.LexiconTypeDecoder `json:"didDoc,omitempty" cborgen:"didDoc,omitempty"` + Handle string `json:"handle" cborgen:"handle"` + RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` } // ServerCreateAccount calls the XRPC method "com.atproto.server.createAccount". diff --git a/api/atproto/servercreateSession.go b/api/atproto/servercreateSession.go index eb54b3bd3..ac197250c 100644 --- a/api/atproto/servercreateSession.go +++ b/api/atproto/servercreateSession.go @@ -7,6 +7,7 @@ package atproto import ( "context" + "github.com/bluesky-social/indigo/lex/util" "github.com/bluesky-social/indigo/xrpc" ) @@ -19,13 +20,13 @@ type ServerCreateSession_Input struct { // ServerCreateSession_Output is the output of a com.atproto.server.createSession call. type ServerCreateSession_Output struct { - AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` - Did string `json:"did" cborgen:"did"` - DidDoc *interface{} `json:"didDoc,omitempty" cborgen:"didDoc,omitempty"` - Email *string `json:"email,omitempty" cborgen:"email,omitempty"` - EmailConfirmed *bool `json:"emailConfirmed,omitempty" cborgen:"emailConfirmed,omitempty"` - Handle string `json:"handle" cborgen:"handle"` - RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` + AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` + Did string `json:"did" cborgen:"did"` + DidDoc *util.LexiconTypeDecoder `json:"didDoc,omitempty" cborgen:"didDoc,omitempty"` + Email *string `json:"email,omitempty" cborgen:"email,omitempty"` + EmailConfirmed *bool `json:"emailConfirmed,omitempty" cborgen:"emailConfirmed,omitempty"` + Handle string `json:"handle" cborgen:"handle"` + RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` } // ServerCreateSession calls the XRPC method "com.atproto.server.createSession". diff --git a/api/atproto/servergetSession.go b/api/atproto/servergetSession.go index 3af41baf8..0c2704897 100644 --- a/api/atproto/servergetSession.go +++ b/api/atproto/servergetSession.go @@ -7,16 +7,17 @@ package atproto import ( "context" + "github.com/bluesky-social/indigo/lex/util" "github.com/bluesky-social/indigo/xrpc" ) // ServerGetSession_Output is the output of a com.atproto.server.getSession call. type ServerGetSession_Output struct { - Did string `json:"did" cborgen:"did"` - DidDoc *interface{} `json:"didDoc,omitempty" cborgen:"didDoc,omitempty"` - Email *string `json:"email,omitempty" cborgen:"email,omitempty"` - EmailConfirmed *bool `json:"emailConfirmed,omitempty" cborgen:"emailConfirmed,omitempty"` - Handle string `json:"handle" cborgen:"handle"` + Did string `json:"did" cborgen:"did"` + DidDoc *util.LexiconTypeDecoder `json:"didDoc,omitempty" cborgen:"didDoc,omitempty"` + Email *string `json:"email,omitempty" cborgen:"email,omitempty"` + EmailConfirmed *bool `json:"emailConfirmed,omitempty" cborgen:"emailConfirmed,omitempty"` + Handle string `json:"handle" cborgen:"handle"` } // ServerGetSession calls the XRPC method "com.atproto.server.getSession". diff --git a/api/atproto/serverrefreshSession.go b/api/atproto/serverrefreshSession.go index 215e00be5..4c500538d 100644 --- a/api/atproto/serverrefreshSession.go +++ b/api/atproto/serverrefreshSession.go @@ -7,16 +7,17 @@ package atproto import ( "context" + "github.com/bluesky-social/indigo/lex/util" "github.com/bluesky-social/indigo/xrpc" ) // ServerRefreshSession_Output is the output of a com.atproto.server.refreshSession call. type ServerRefreshSession_Output struct { - AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` - Did string `json:"did" cborgen:"did"` - DidDoc *interface{} `json:"didDoc,omitempty" cborgen:"didDoc,omitempty"` - Handle string `json:"handle" cborgen:"handle"` - RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` + AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` + Did string `json:"did" cborgen:"did"` + DidDoc *util.LexiconTypeDecoder `json:"didDoc,omitempty" cborgen:"didDoc,omitempty"` + Handle string `json:"handle" cborgen:"handle"` + RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` } // ServerRefreshSession calls the XRPC method "com.atproto.server.refreshSession". diff --git a/api/atproto/temppushBlob.go b/api/atproto/temppushBlob.go new file mode 100644 index 000000000..1a5908c36 --- /dev/null +++ b/api/atproto/temppushBlob.go @@ -0,0 +1,27 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package atproto + +// schema: com.atproto.temp.pushBlob + +import ( + "context" + "io" + + "github.com/bluesky-social/indigo/xrpc" +) + +// TempPushBlob calls the XRPC method "com.atproto.temp.pushBlob". +// +// did: The DID of the repo. +func TempPushBlob(ctx context.Context, c *xrpc.Client, input io.Reader, did string) error { + + params := map[string]interface{}{ + "did": did, + } + if err := c.Do(ctx, xrpc.Procedure, "*/*", "com.atproto.temp.pushBlob", params, input, nil); err != nil { + return err + } + + return nil +} diff --git a/api/atproto/temptransferAccount.go b/api/atproto/temptransferAccount.go new file mode 100644 index 000000000..ab2d589fb --- /dev/null +++ b/api/atproto/temptransferAccount.go @@ -0,0 +1,37 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package atproto + +// schema: com.atproto.temp.transferAccount + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" + "github.com/bluesky-social/indigo/xrpc" +) + +// TempTransferAccount_Input is the input argument to a com.atproto.temp.transferAccount call. +type TempTransferAccount_Input struct { + Did string `json:"did" cborgen:"did"` + Handle string `json:"handle" cborgen:"handle"` + PlcOp *util.LexiconTypeDecoder `json:"plcOp" cborgen:"plcOp"` +} + +// TempTransferAccount_Output is the output of a com.atproto.temp.transferAccount call. +type TempTransferAccount_Output struct { + AccessJwt string `json:"accessJwt" cborgen:"accessJwt"` + Did string `json:"did" cborgen:"did"` + Handle string `json:"handle" cborgen:"handle"` + RefreshJwt string `json:"refreshJwt" cborgen:"refreshJwt"` +} + +// TempTransferAccount calls the XRPC method "com.atproto.temp.transferAccount". +func TempTransferAccount(ctx context.Context, c *xrpc.Client, input *TempTransferAccount_Input) (*TempTransferAccount_Output, error) { + var out TempTransferAccount_Output + if err := c.Do(ctx, xrpc.Procedure, "application/json", "com.atproto.temp.transferAccount", nil, input, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/api/bsky/cbor_gen.go b/api/bsky/cbor_gen.go index 0542bcec2..1de8fc5ce 100644 --- a/api/bsky/cbor_gen.go +++ b/api/bsky/cbor_gen.go @@ -370,14 +370,22 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { } for i := 0; i < int(extra); i++ { - { - sval, err := cbg.ReadString(cr) - if err != nil { - return err + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + t.Tags[i] = string(sval) } - - t.Tags[i] = string(sval) } } @@ -444,14 +452,22 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { } for i := 0; i < int(extra); i++ { - { - sval, err := cbg.ReadString(cr) - if err != nil { - return err + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + t.Langs[i] = string(sval) } - - t.Langs[i] = string(sval) } } @@ -496,13 +512,32 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { } for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Facets[i] = new(RichtextFacet) + if err := t.Facets[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Facets[i] pointer: %w", err) + } + } - var v RichtextFacet - if err := v.UnmarshalCBOR(cr); err != nil { - return err + } } - - t.Facets[i] = &v } // t.Labels (bsky.FeedPost_Labels) (struct) @@ -546,13 +581,32 @@ func (t *FeedPost) UnmarshalCBOR(r io.Reader) (err error) { } for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Entities[i] = new(FeedPost_Entity) + if err := t.Entities[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Entities[i] pointer: %w", err) + } + } - var v FeedPost_Entity - if err := v.UnmarshalCBOR(cr); err != nil { - return err + } } - - t.Entities[i] = &v } // t.CreatedAt (string) (string) @@ -1319,13 +1373,32 @@ func (t *EmbedImages) UnmarshalCBOR(r io.Reader) (err error) { } for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Images[i] = new(EmbedImages_Image) + if err := t.Images[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Images[i] pointer: %w", err) + } + } - var v EmbedImages_Image - if err := v.UnmarshalCBOR(cr); err != nil { - return err + } } - - t.Images[i] = &v } default: @@ -2761,13 +2834,32 @@ func (t *RichtextFacet) UnmarshalCBOR(r io.Reader) (err error) { } for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Features[i] = new(RichtextFacet_Features_Elem) + if err := t.Features[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Features[i] pointer: %w", err) + } + } - var v RichtextFacet_Features_Elem - if err := v.UnmarshalCBOR(cr); err != nil { - return err + } } - - t.Features[i] = &v } default: @@ -4188,13 +4280,32 @@ func (t *GraphList) UnmarshalCBOR(r io.Reader) (err error) { } for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.DescriptionFacets[i] = new(RichtextFacet) + if err := t.DescriptionFacets[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.DescriptionFacets[i] pointer: %w", err) + } + } - var v RichtextFacet - if err := v.UnmarshalCBOR(cr); err != nil { - return err + } } - - t.DescriptionFacets[i] = &v } default: @@ -4779,13 +4890,32 @@ func (t *FeedGenerator) UnmarshalCBOR(r io.Reader) (err error) { } for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.DescriptionFacets[i] = new(RichtextFacet) + if err := t.DescriptionFacets[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.DescriptionFacets[i] pointer: %w", err) + } + } - var v RichtextFacet - if err := v.UnmarshalCBOR(cr); err != nil { - return err + } } - - t.DescriptionFacets[i] = &v } default: @@ -5112,3 +5242,551 @@ func (t *EmbedImages_AspectRatio) UnmarshalCBOR(r io.Reader) (err error) { return nil } +func (t *FeedThreadgate) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + fieldCount := 4 + + if t.Allow == nil { + fieldCount-- + } + + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + return err + } + + // t.Post (string) (string) + if len("post") > cbg.MaxLength { + return xerrors.Errorf("Value in field \"post\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("post"))); err != nil { + return err + } + if _, err := cw.WriteString(string("post")); err != nil { + return err + } + + if len(t.Post) > cbg.MaxLength { + return xerrors.Errorf("Value in field t.Post was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Post))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Post)); err != nil { + return err + } + + // t.LexiconTypeID (string) (string) + if len("$type") > cbg.MaxLength { + return xerrors.Errorf("Value in field \"$type\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + return err + } + if _, err := cw.WriteString(string("$type")); err != nil { + return err + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("app.bsky.feed.threadgate"))); err != nil { + return err + } + if _, err := cw.WriteString(string("app.bsky.feed.threadgate")); err != nil { + return err + } + + // t.Allow ([]*bsky.FeedThreadgate_Allow_Elem) (slice) + if t.Allow != nil { + + if len("allow") > cbg.MaxLength { + return xerrors.Errorf("Value in field \"allow\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("allow"))); err != nil { + return err + } + if _, err := cw.WriteString(string("allow")); err != nil { + return err + } + + if len(t.Allow) > cbg.MaxLength { + return xerrors.Errorf("Slice value in field t.Allow was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Allow))); err != nil { + return err + } + for _, v := range t.Allow { + if err := v.MarshalCBOR(cw); err != nil { + return err + } + } + } + + // t.CreatedAt (string) (string) + if len("createdAt") > cbg.MaxLength { + return xerrors.Errorf("Value in field \"createdAt\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { + return err + } + if _, err := cw.WriteString(string("createdAt")); err != nil { + return err + } + + if len(t.CreatedAt) > cbg.MaxLength { + return xerrors.Errorf("Value in field t.CreatedAt was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { + return err + } + return nil +} + +func (t *FeedThreadgate) UnmarshalCBOR(r io.Reader) (err error) { + *t = FeedThreadgate{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("FeedThreadgate: map struct too large (%d)", extra) + } + + var name string + n := extra + + for i := uint64(0); i < n; i++ { + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + name = string(sval) + } + + switch name { + // t.Post (string) (string) + case "post": + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + t.Post = string(sval) + } + // t.LexiconTypeID (string) (string) + case "$type": + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + t.LexiconTypeID = string(sval) + } + // t.Allow ([]*bsky.FeedThreadgate_Allow_Elem) (slice) + case "allow": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + + if extra > cbg.MaxLength { + return fmt.Errorf("t.Allow: array too large (%d)", extra) + } + + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") + } + + if extra > 0 { + t.Allow = make([]*FeedThreadgate_Allow_Elem, extra) + } + + for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Allow[i] = new(FeedThreadgate_Allow_Elem) + if err := t.Allow[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Allow[i] pointer: %w", err) + } + } + + } + } + } + + // t.CreatedAt (string) (string) + case "createdAt": + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + t.CreatedAt = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + cbg.ScanForLinks(r, func(cid.Cid) {}) + } + } + + return nil +} +func (t *FeedThreadgate_ListRule) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{162}); err != nil { + return err + } + + // t.List (string) (string) + if len("list") > cbg.MaxLength { + return xerrors.Errorf("Value in field \"list\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("list"))); err != nil { + return err + } + if _, err := cw.WriteString(string("list")); err != nil { + return err + } + + if len(t.List) > cbg.MaxLength { + return xerrors.Errorf("Value in field t.List was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.List))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.List)); err != nil { + return err + } + + // t.LexiconTypeID (string) (string) + if len("$type") > cbg.MaxLength { + return xerrors.Errorf("Value in field \"$type\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + return err + } + if _, err := cw.WriteString(string("$type")); err != nil { + return err + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("app.bsky.feed.threadgate#listRule"))); err != nil { + return err + } + if _, err := cw.WriteString(string("app.bsky.feed.threadgate#listRule")); err != nil { + return err + } + return nil +} + +func (t *FeedThreadgate_ListRule) UnmarshalCBOR(r io.Reader) (err error) { + *t = FeedThreadgate_ListRule{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("FeedThreadgate_ListRule: map struct too large (%d)", extra) + } + + var name string + n := extra + + for i := uint64(0); i < n; i++ { + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + name = string(sval) + } + + switch name { + // t.List (string) (string) + case "list": + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + t.List = string(sval) + } + // t.LexiconTypeID (string) (string) + case "$type": + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + t.LexiconTypeID = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + cbg.ScanForLinks(r, func(cid.Cid) {}) + } + } + + return nil +} +func (t *FeedThreadgate_MentionRule) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{161}); err != nil { + return err + } + + // t.LexiconTypeID (string) (string) + if len("$type") > cbg.MaxLength { + return xerrors.Errorf("Value in field \"$type\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + return err + } + if _, err := cw.WriteString(string("$type")); err != nil { + return err + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("app.bsky.feed.threadgate#mentionRule"))); err != nil { + return err + } + if _, err := cw.WriteString(string("app.bsky.feed.threadgate#mentionRule")); err != nil { + return err + } + return nil +} + +func (t *FeedThreadgate_MentionRule) UnmarshalCBOR(r io.Reader) (err error) { + *t = FeedThreadgate_MentionRule{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("FeedThreadgate_MentionRule: map struct too large (%d)", extra) + } + + var name string + n := extra + + for i := uint64(0); i < n; i++ { + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + name = string(sval) + } + + switch name { + // t.LexiconTypeID (string) (string) + case "$type": + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + t.LexiconTypeID = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + cbg.ScanForLinks(r, func(cid.Cid) {}) + } + } + + return nil +} +func (t *FeedThreadgate_FollowingRule) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{161}); err != nil { + return err + } + + // t.LexiconTypeID (string) (string) + if len("$type") > cbg.MaxLength { + return xerrors.Errorf("Value in field \"$type\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil { + return err + } + if _, err := cw.WriteString(string("$type")); err != nil { + return err + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("app.bsky.feed.threadgate#followingRule"))); err != nil { + return err + } + if _, err := cw.WriteString(string("app.bsky.feed.threadgate#followingRule")); err != nil { + return err + } + return nil +} + +func (t *FeedThreadgate_FollowingRule) UnmarshalCBOR(r io.Reader) (err error) { + *t = FeedThreadgate_FollowingRule{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("FeedThreadgate_FollowingRule: map struct too large (%d)", extra) + } + + var name string + n := extra + + for i := uint64(0); i < n; i++ { + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + name = string(sval) + } + + switch name { + // t.LexiconTypeID (string) (string) + case "$type": + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + t.LexiconTypeID = string(sval) + } + + default: + // Field doesn't exist on this type, so ignore it + cbg.ScanForLinks(r, func(cid.Cid) {}) + } + } + + return nil +} diff --git a/api/bsky/feeddefs.go b/api/bsky/feeddefs.go index 4fc61cbda..b84275778 100644 --- a/api/bsky/feeddefs.go +++ b/api/bsky/feeddefs.go @@ -314,7 +314,6 @@ type FeedDefs_ThreadViewPost struct { Parent *FeedDefs_ThreadViewPost_Parent `json:"parent,omitempty" cborgen:"parent,omitempty"` Post *FeedDefs_PostView `json:"post" cborgen:"post"` Replies []*FeedDefs_ThreadViewPost_Replies_Elem `json:"replies,omitempty" cborgen:"replies,omitempty"` - Viewer *FeedDefs_ViewerThreadState `json:"viewer,omitempty" cborgen:"viewer,omitempty"` } type FeedDefs_ThreadViewPost_Parent struct { @@ -413,11 +412,7 @@ type FeedDefs_ThreadgateView struct { // FeedDefs_ViewerState is a "viewerState" in the app.bsky.feed.defs schema. type FeedDefs_ViewerState struct { - Like *string `json:"like,omitempty" cborgen:"like,omitempty"` - Repost *string `json:"repost,omitempty" cborgen:"repost,omitempty"` -} - -// FeedDefs_ViewerThreadState is a "viewerThreadState" in the app.bsky.feed.defs schema. -type FeedDefs_ViewerThreadState struct { - CanReply *bool `json:"canReply,omitempty" cborgen:"canReply,omitempty"` + Like *string `json:"like,omitempty" cborgen:"like,omitempty"` + ReplyDisabled *bool `json:"replyDisabled,omitempty" cborgen:"replyDisabled,omitempty"` + Repost *string `json:"repost,omitempty" cborgen:"repost,omitempty"` } diff --git a/api/bsky/feedthreadgate.go b/api/bsky/feedthreadgate.go new file mode 100644 index 000000000..27045871b --- /dev/null +++ b/api/bsky/feedthreadgate.go @@ -0,0 +1,136 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package bsky + +// schema: app.bsky.feed.threadgate + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + + "github.com/bluesky-social/indigo/lex/util" + cbg "github.com/whyrusleeping/cbor-gen" +) + +func init() { + util.RegisterType("app.bsky.feed.threadgate", &FeedThreadgate{}) +} // +// RECORDTYPE: FeedThreadgate +type FeedThreadgate struct { + LexiconTypeID string `json:"$type,const=app.bsky.feed.threadgate" cborgen:"$type,const=app.bsky.feed.threadgate"` + Allow []*FeedThreadgate_Allow_Elem `json:"allow,omitempty" cborgen:"allow,omitempty"` + CreatedAt string `json:"createdAt" cborgen:"createdAt"` + Post string `json:"post" cborgen:"post"` +} + +type FeedThreadgate_Allow_Elem struct { + FeedThreadgate_MentionRule *FeedThreadgate_MentionRule + FeedThreadgate_FollowingRule *FeedThreadgate_FollowingRule + FeedThreadgate_ListRule *FeedThreadgate_ListRule +} + +func (t *FeedThreadgate_Allow_Elem) MarshalJSON() ([]byte, error) { + if t.FeedThreadgate_MentionRule != nil { + t.FeedThreadgate_MentionRule.LexiconTypeID = "app.bsky.feed.threadgate#mentionRule" + return json.Marshal(t.FeedThreadgate_MentionRule) + } + if t.FeedThreadgate_FollowingRule != nil { + t.FeedThreadgate_FollowingRule.LexiconTypeID = "app.bsky.feed.threadgate#followingRule" + return json.Marshal(t.FeedThreadgate_FollowingRule) + } + if t.FeedThreadgate_ListRule != nil { + t.FeedThreadgate_ListRule.LexiconTypeID = "app.bsky.feed.threadgate#listRule" + return json.Marshal(t.FeedThreadgate_ListRule) + } + return nil, fmt.Errorf("cannot marshal empty enum") +} +func (t *FeedThreadgate_Allow_Elem) UnmarshalJSON(b []byte) error { + typ, err := util.TypeExtract(b) + if err != nil { + return err + } + + switch typ { + case "app.bsky.feed.threadgate#mentionRule": + t.FeedThreadgate_MentionRule = new(FeedThreadgate_MentionRule) + return json.Unmarshal(b, t.FeedThreadgate_MentionRule) + case "app.bsky.feed.threadgate#followingRule": + t.FeedThreadgate_FollowingRule = new(FeedThreadgate_FollowingRule) + return json.Unmarshal(b, t.FeedThreadgate_FollowingRule) + case "app.bsky.feed.threadgate#listRule": + t.FeedThreadgate_ListRule = new(FeedThreadgate_ListRule) + return json.Unmarshal(b, t.FeedThreadgate_ListRule) + + default: + return nil + } +} + +func (t *FeedThreadgate_Allow_Elem) MarshalCBOR(w io.Writer) error { + + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + if t.FeedThreadgate_MentionRule != nil { + return t.FeedThreadgate_MentionRule.MarshalCBOR(w) + } + if t.FeedThreadgate_FollowingRule != nil { + return t.FeedThreadgate_FollowingRule.MarshalCBOR(w) + } + if t.FeedThreadgate_ListRule != nil { + return t.FeedThreadgate_ListRule.MarshalCBOR(w) + } + return fmt.Errorf("cannot cbor marshal empty enum") +} +func (t *FeedThreadgate_Allow_Elem) UnmarshalCBOR(r io.Reader) error { + typ, b, err := util.CborTypeExtractReader(r) + if err != nil { + return err + } + + switch typ { + case "app.bsky.feed.threadgate#mentionRule": + t.FeedThreadgate_MentionRule = new(FeedThreadgate_MentionRule) + return t.FeedThreadgate_MentionRule.UnmarshalCBOR(bytes.NewReader(b)) + case "app.bsky.feed.threadgate#followingRule": + t.FeedThreadgate_FollowingRule = new(FeedThreadgate_FollowingRule) + return t.FeedThreadgate_FollowingRule.UnmarshalCBOR(bytes.NewReader(b)) + case "app.bsky.feed.threadgate#listRule": + t.FeedThreadgate_ListRule = new(FeedThreadgate_ListRule) + return t.FeedThreadgate_ListRule.UnmarshalCBOR(bytes.NewReader(b)) + + default: + return nil + } +} + +// FeedThreadgate_FollowingRule is a "followingRule" in the app.bsky.feed.threadgate schema. +// +// Allow replies from actors you follow. +// +// RECORDTYPE: FeedThreadgate_FollowingRule +type FeedThreadgate_FollowingRule struct { + LexiconTypeID string `json:"$type,const=app.bsky.feed.threadgate#followingRule" cborgen:"$type,const=app.bsky.feed.threadgate#followingRule"` +} + +// FeedThreadgate_ListRule is a "listRule" in the app.bsky.feed.threadgate schema. +// +// Allow replies from actors on a list. +// +// RECORDTYPE: FeedThreadgate_ListRule +type FeedThreadgate_ListRule struct { + LexiconTypeID string `json:"$type,const=app.bsky.feed.threadgate#listRule" cborgen:"$type,const=app.bsky.feed.threadgate#listRule"` + List string `json:"list" cborgen:"list"` +} + +// FeedThreadgate_MentionRule is a "mentionRule" in the app.bsky.feed.threadgate schema. +// +// Allow replies from actors mentioned in your post. +// +// RECORDTYPE: FeedThreadgate_MentionRule +type FeedThreadgate_MentionRule struct { + LexiconTypeID string `json:"$type,const=app.bsky.feed.threadgate#mentionRule" cborgen:"$type,const=app.bsky.feed.threadgate#mentionRule"` +} diff --git a/api/bsky/graphdefs.go b/api/bsky/graphdefs.go index a662b2ba6..41531b037 100644 --- a/api/bsky/graphdefs.go +++ b/api/bsky/graphdefs.go @@ -7,6 +7,7 @@ package bsky // GraphDefs_ListItemView is a "listItemView" in the app.bsky.graph.defs schema. type GraphDefs_ListItemView struct { Subject *ActorDefs_ProfileView `json:"subject" cborgen:"subject"` + Uri string `json:"uri" cborgen:"uri"` } // GraphDefs_ListView is a "listView" in the app.bsky.graph.defs schema. diff --git a/api/label/cbor_gen.go b/api/label/cbor_gen.go index dd3dc5af2..3222c29b1 100644 --- a/api/label/cbor_gen.go +++ b/api/label/cbor_gen.go @@ -719,13 +719,32 @@ func (t *SubscribeLabels_Labels) UnmarshalCBOR(r io.Reader) (err error) { } for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Labels[i] = new(Label) + if err := t.Labels[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Labels[i] pointer: %w", err) + } + } - var v Label - if err := v.UnmarshalCBOR(cr); err != nil { - return err + } } - - t.Labels[i] = &v } default: diff --git a/gen/main.go b/gen/main.go index aefbdfb26..cd5065b8b 100644 --- a/gen/main.go +++ b/gen/main.go @@ -47,6 +47,10 @@ func main() { bsky.FeedGenerator{}, bsky.GraphListblock{}, bsky.EmbedImages_AspectRatio{}, + bsky.FeedThreadgate{}, + bsky.FeedThreadgate_ListRule{}, + bsky.FeedThreadgate_MentionRule{}, + bsky.FeedThreadgate_FollowingRule{}, /*bsky.EmbedImages_View{}, bsky.EmbedRecord_View{}, bsky.EmbedRecordWithMedia_View{}, bsky.EmbedExternal_View{}, bsky.EmbedImages_ViewImage{}, diff --git a/lex/gen.go b/lex/gen.go index 385bc1ca7..0bcd489e5 100644 --- a/lex/gen.go +++ b/lex/gen.go @@ -173,7 +173,7 @@ func (s *Schema) AllTypes(prefix string, defMap map[string]*ExtDef) []outputType if ts.Input != nil { if ts.Input.Schema == nil { - if ts.Input.Encoding != "application/cbor" && ts.Input.Encoding != "*/*" { + if ts.Input.Encoding != "application/cbor" && ts.Input.Encoding != "*/*" && ts.Input.Encoding != "application/vnd.ipld.car" { panic(fmt.Sprintf("strange input type def in %s", s.ID)) } } else { @@ -1199,11 +1199,6 @@ func (ts *TypeSchema) writeTypeDefinition(name string, w io.Writer) error { case "boolean": pf("type %s bool\n", name) case "object": - if len(ts.Properties) == 0 { - pf("type %s interface{}\n", name) - return nil - } - if ts.needsType { pf("//\n// RECORDTYPE: %s\n", name) } diff --git a/mst/cbor_gen.go b/mst/cbor_gen.go index ac29f2d9c..cf1983c86 100644 --- a/mst/cbor_gen.go +++ b/mst/cbor_gen.go @@ -139,13 +139,22 @@ func (t *nodeData) UnmarshalCBOR(r io.Reader) (err error) { } for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err - var v treeEntry - if err := v.UnmarshalCBOR(cr); err != nil { - return err - } + { + + if err := t.Entries[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Entries[i]: %w", err) + } - t.Entries[i] = v + } + } } // t.Left (cid.Cid) (struct)