+8
-6
api/atproto/admindefs.go
+8
-6
api/atproto/admindefs.go
···
20
20
21
21
// AdminDefs_ActionView is a "actionView" in the com.atproto.admin.defs schema.
22
22
type AdminDefs_ActionView struct {
23
-
Action *string `json:"action" cborgen:"action"`
23
+
Action *AdminDefs_ActionType `json:"action" cborgen:"action"`
24
24
CreateLabelVals []string `json:"createLabelVals,omitempty" cborgen:"createLabelVals,omitempty"`
25
25
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
26
26
CreatedBy string `json:"createdBy" cborgen:"createdBy"`
···
35
35
36
36
// AdminDefs_ActionViewCurrent is a "actionViewCurrent" in the com.atproto.admin.defs schema.
37
37
type AdminDefs_ActionViewCurrent struct {
38
-
Action *string `json:"action" cborgen:"action"`
39
-
Id int64 `json:"id" cborgen:"id"`
38
+
Action *AdminDefs_ActionType `json:"action" cborgen:"action"`
39
+
Id int64 `json:"id" cborgen:"id"`
40
40
}
41
41
42
42
// AdminDefs_ActionViewDetail is a "actionViewDetail" in the com.atproto.admin.defs schema.
43
43
type AdminDefs_ActionViewDetail struct {
44
-
Action *string `json:"action" cborgen:"action"`
44
+
Action *AdminDefs_ActionType `json:"action" cborgen:"action"`
45
45
CreateLabelVals []string `json:"createLabelVals,omitempty" cborgen:"createLabelVals,omitempty"`
46
46
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
47
47
CreatedBy string `json:"createdBy" cborgen:"createdBy"`
···
257
257
Email *string `json:"email,omitempty" cborgen:"email,omitempty"`
258
258
Handle string `json:"handle" cborgen:"handle"`
259
259
IndexedAt string `json:"indexedAt" cborgen:"indexedAt"`
260
+
InviteNote *string `json:"inviteNote,omitempty" cborgen:"inviteNote,omitempty"`
260
261
InvitedBy *ServerDefs_InviteCode `json:"invitedBy,omitempty" cborgen:"invitedBy,omitempty"`
261
262
InvitesDisabled *bool `json:"invitesDisabled,omitempty" cborgen:"invitesDisabled,omitempty"`
262
263
Moderation *AdminDefs_Moderation `json:"moderation" cborgen:"moderation"`
···
269
270
Email *string `json:"email,omitempty" cborgen:"email,omitempty"`
270
271
Handle string `json:"handle" cborgen:"handle"`
271
272
IndexedAt string `json:"indexedAt" cborgen:"indexedAt"`
273
+
InviteNote *string `json:"inviteNote,omitempty" cborgen:"inviteNote,omitempty"`
272
274
InvitedBy *ServerDefs_InviteCode `json:"invitedBy,omitempty" cborgen:"invitedBy,omitempty"`
273
275
Invites []*ServerDefs_InviteCode `json:"invites,omitempty" cborgen:"invites,omitempty"`
274
276
InvitesDisabled *bool `json:"invitesDisabled,omitempty" cborgen:"invitesDisabled,omitempty"`
···
290
292
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
291
293
Id int64 `json:"id" cborgen:"id"`
292
294
Reason *string `json:"reason,omitempty" cborgen:"reason,omitempty"`
293
-
ReasonType *string `json:"reasonType" cborgen:"reasonType"`
295
+
ReasonType *ModerationDefs_ReasonType `json:"reasonType" cborgen:"reasonType"`
294
296
ReportedBy string `json:"reportedBy" cborgen:"reportedBy"`
295
297
ResolvedByActionIds []int64 `json:"resolvedByActionIds" cborgen:"resolvedByActionIds"`
296
298
Subject *AdminDefs_ReportView_Subject `json:"subject" cborgen:"subject"`
···
302
304
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
303
305
Id int64 `json:"id" cborgen:"id"`
304
306
Reason *string `json:"reason,omitempty" cborgen:"reason,omitempty"`
305
-
ReasonType *string `json:"reasonType" cborgen:"reasonType"`
307
+
ReasonType *ModerationDefs_ReasonType `json:"reasonType" cborgen:"reasonType"`
306
308
ReportedBy string `json:"reportedBy" cborgen:"reportedBy"`
307
309
ResolvedByActions []*AdminDefs_ActionView `json:"resolvedByActions" cborgen:"resolvedByActions"`
308
310
Subject *AdminDefs_ReportViewDetail_Subject `json:"subject" cborgen:"subject"`
+2
api/atproto/admindisableAccountInvites.go
+2
api/atproto/admindisableAccountInvites.go
···
13
13
// AdminDisableAccountInvites_Input is the input argument to a com.atproto.admin.disableAccountInvites call.
14
14
type AdminDisableAccountInvites_Input struct {
15
15
Account string `json:"account" cborgen:"account"`
16
+
// note: Additionally add a note describing why the invites were disabled
17
+
Note *string `json:"note,omitempty" cborgen:"note,omitempty"`
16
18
}
17
19
18
20
// AdminDisableAccountInvites calls the XRPC method "com.atproto.admin.disableAccountInvites".
+2
api/atproto/adminenableAccountInvites.go
+2
api/atproto/adminenableAccountInvites.go
···
13
13
// AdminEnableAccountInvites_Input is the input argument to a com.atproto.admin.enableAccountInvites call.
14
14
type AdminEnableAccountInvites_Input struct {
15
15
Account string `json:"account" cborgen:"account"`
16
+
// note: Additionally add a note describing why the invites were enabled
17
+
Note *string `json:"note,omitempty" cborgen:"note,omitempty"`
16
18
}
17
19
18
20
// AdminEnableAccountInvites calls the XRPC method "com.atproto.admin.enableAccountInvites".
+15
api/atproto/labeldefs.go
+15
api/atproto/labeldefs.go
···
21
21
// val: the short string name of the value or type of this label
22
22
Val string `json:"val" cborgen:"val"`
23
23
}
24
+
25
+
// LabelDefs_SelfLabel is a "selfLabel" in the com.atproto.label.defs schema.
26
+
//
27
+
// Metadata tag on an atproto record, published by the author within the record. Note -- schemas should use #selfLabels, not #selfLabel.
28
+
type LabelDefs_SelfLabel struct {
29
+
// val: the short string name of the value or type of this label
30
+
Val string `json:"val" cborgen:"val"`
31
+
}
32
+
33
+
// LabelDefs_SelfLabels is a "selfLabels" in the com.atproto.label.defs schema.
34
+
//
35
+
// Metadata tags on an atproto record, published by the author within the record.
36
+
type LabelDefs_SelfLabels struct {
37
+
Values []*LabelDefs_SelfLabel `json:"values" cborgen:"values"`
38
+
}
+2
-2
api/atproto/moderationcreateReport.go
+2
-2
api/atproto/moderationcreateReport.go
···
16
16
// ModerationCreateReport_Input is the input argument to a com.atproto.moderation.createReport call.
17
17
type ModerationCreateReport_Input struct {
18
18
Reason *string `json:"reason,omitempty" cborgen:"reason,omitempty"`
19
-
ReasonType *string `json:"reasonType" cborgen:"reasonType"`
19
+
ReasonType *ModerationDefs_ReasonType `json:"reasonType" cborgen:"reasonType"`
20
20
Subject *ModerationCreateReport_Input_Subject `json:"subject" cborgen:"subject"`
21
21
}
22
22
···
60
60
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
61
61
Id int64 `json:"id" cborgen:"id"`
62
62
Reason *string `json:"reason,omitempty" cborgen:"reason,omitempty"`
63
-
ReasonType *string `json:"reasonType" cborgen:"reasonType"`
63
+
ReasonType *ModerationDefs_ReasonType `json:"reasonType" cborgen:"reasonType"`
64
64
ReportedBy string `json:"reportedBy" cborgen:"reportedBy"`
65
65
Subject *ModerationCreateReport_Output_Subject `json:"subject" cborgen:"subject"`
66
66
}
+67
-5
api/bsky/actorprofile.go
+67
-5
api/bsky/actorprofile.go
···
5
5
// schema: app.bsky.actor.profile
6
6
7
7
import (
8
+
"bytes"
9
+
"encoding/json"
10
+
"fmt"
11
+
"io"
12
+
13
+
comatprototypes "github.com/bluesky-social/indigo/api/atproto"
8
14
"github.com/bluesky-social/indigo/lex/util"
15
+
cbg "github.com/whyrusleeping/cbor-gen"
9
16
)
10
17
11
18
func init() {
···
13
20
} //
14
21
// RECORDTYPE: ActorProfile
15
22
type ActorProfile struct {
16
-
LexiconTypeID string `json:"$type,const=app.bsky.actor.profile" cborgen:"$type,const=app.bsky.actor.profile"`
17
-
Avatar *util.LexBlob `json:"avatar,omitempty" cborgen:"avatar,omitempty"`
18
-
Banner *util.LexBlob `json:"banner,omitempty" cborgen:"banner,omitempty"`
19
-
Description *string `json:"description,omitempty" cborgen:"description,omitempty"`
20
-
DisplayName *string `json:"displayName,omitempty" cborgen:"displayName,omitempty"`
23
+
LexiconTypeID string `json:"$type,const=app.bsky.actor.profile" cborgen:"$type,const=app.bsky.actor.profile"`
24
+
Avatar *util.LexBlob `json:"avatar,omitempty" cborgen:"avatar,omitempty"`
25
+
Banner *util.LexBlob `json:"banner,omitempty" cborgen:"banner,omitempty"`
26
+
Description *string `json:"description,omitempty" cborgen:"description,omitempty"`
27
+
DisplayName *string `json:"displayName,omitempty" cborgen:"displayName,omitempty"`
28
+
Labels *ActorProfile_Labels `json:"labels,omitempty" cborgen:"labels,omitempty"`
29
+
}
30
+
31
+
type ActorProfile_Labels struct {
32
+
LabelDefs_SelfLabels *comatprototypes.LabelDefs_SelfLabels
33
+
}
34
+
35
+
func (t *ActorProfile_Labels) MarshalJSON() ([]byte, error) {
36
+
if t.LabelDefs_SelfLabels != nil {
37
+
t.LabelDefs_SelfLabels.LexiconTypeID = "com.atproto.label.defs#selfLabels"
38
+
return json.Marshal(t.LabelDefs_SelfLabels)
39
+
}
40
+
return nil, fmt.Errorf("cannot marshal empty enum")
41
+
}
42
+
func (t *ActorProfile_Labels) UnmarshalJSON(b []byte) error {
43
+
typ, err := util.TypeExtract(b)
44
+
if err != nil {
45
+
return err
46
+
}
47
+
48
+
switch typ {
49
+
case "com.atproto.label.defs#selfLabels":
50
+
t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
51
+
return json.Unmarshal(b, t.LabelDefs_SelfLabels)
52
+
53
+
default:
54
+
return nil
55
+
}
56
+
}
57
+
58
+
func (t *ActorProfile_Labels) MarshalCBOR(w io.Writer) error {
59
+
60
+
if t == nil {
61
+
_, err := w.Write(cbg.CborNull)
62
+
return err
63
+
}
64
+
if t.LabelDefs_SelfLabels != nil {
65
+
return t.LabelDefs_SelfLabels.MarshalCBOR(w)
66
+
}
67
+
return fmt.Errorf("cannot cbor marshal empty enum")
68
+
}
69
+
func (t *ActorProfile_Labels) UnmarshalCBOR(r io.Reader) error {
70
+
typ, b, err := util.CborTypeExtractReader(r)
71
+
if err != nil {
72
+
return err
73
+
}
74
+
75
+
switch typ {
76
+
case "com.atproto.label.defs#selfLabels":
77
+
t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
78
+
return t.LabelDefs_SelfLabels.UnmarshalCBOR(bytes.NewReader(b))
79
+
80
+
default:
81
+
return nil
82
+
}
21
83
}
+10
-3
api/bsky/feeddefs.go
+10
-3
api/bsky/feeddefs.go
···
12
12
"github.com/bluesky-social/indigo/lex/util"
13
13
)
14
14
15
+
// FeedDefs_BlockedAuthor is a "blockedAuthor" in the app.bsky.feed.defs schema.
16
+
type FeedDefs_BlockedAuthor struct {
17
+
Did string `json:"did" cborgen:"did"`
18
+
Viewer *ActorDefs_ViewerState `json:"viewer,omitempty" cborgen:"viewer,omitempty"`
19
+
}
20
+
15
21
// FeedDefs_BlockedPost is a "blockedPost" in the app.bsky.feed.defs schema.
16
22
//
17
23
// RECORDTYPE: FeedDefs_BlockedPost
18
24
type FeedDefs_BlockedPost struct {
19
-
LexiconTypeID string `json:"$type,const=app.bsky.feed.defs" cborgen:"$type,const=app.bsky.feed.defs"`
20
-
Blocked bool `json:"blocked" cborgen:"blocked"`
21
-
Uri string `json:"uri" cborgen:"uri"`
25
+
LexiconTypeID string `json:"$type,const=app.bsky.feed.defs" cborgen:"$type,const=app.bsky.feed.defs"`
26
+
Author *FeedDefs_BlockedAuthor `json:"author" cborgen:"author"`
27
+
Blocked bool `json:"blocked" cborgen:"blocked"`
28
+
Uri string `json:"uri" cborgen:"uri"`
22
29
}
23
30
24
31
// FeedDefs_FeedViewPost is a "feedViewPost" in the app.bsky.feed.defs schema.
+69
-7
api/bsky/feedgenerator.go
+69
-7
api/bsky/feedgenerator.go
···
5
5
// schema: app.bsky.feed.generator
6
6
7
7
import (
8
+
"bytes"
9
+
"encoding/json"
10
+
"fmt"
11
+
"io"
12
+
13
+
comatprototypes "github.com/bluesky-social/indigo/api/atproto"
8
14
"github.com/bluesky-social/indigo/lex/util"
15
+
cbg "github.com/whyrusleeping/cbor-gen"
9
16
)
10
17
11
18
func init() {
···
13
20
} //
14
21
// RECORDTYPE: FeedGenerator
15
22
type FeedGenerator struct {
16
-
LexiconTypeID string `json:"$type,const=app.bsky.feed.generator" cborgen:"$type,const=app.bsky.feed.generator"`
17
-
Avatar *util.LexBlob `json:"avatar,omitempty" cborgen:"avatar,omitempty"`
18
-
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
19
-
Description *string `json:"description,omitempty" cborgen:"description,omitempty"`
20
-
DescriptionFacets []*RichtextFacet `json:"descriptionFacets,omitempty" cborgen:"descriptionFacets,omitempty"`
21
-
Did string `json:"did" cborgen:"did"`
22
-
DisplayName string `json:"displayName" cborgen:"displayName"`
23
+
LexiconTypeID string `json:"$type,const=app.bsky.feed.generator" cborgen:"$type,const=app.bsky.feed.generator"`
24
+
Avatar *util.LexBlob `json:"avatar,omitempty" cborgen:"avatar,omitempty"`
25
+
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
26
+
Description *string `json:"description,omitempty" cborgen:"description,omitempty"`
27
+
DescriptionFacets []*RichtextFacet `json:"descriptionFacets,omitempty" cborgen:"descriptionFacets,omitempty"`
28
+
Did string `json:"did" cborgen:"did"`
29
+
DisplayName string `json:"displayName" cborgen:"displayName"`
30
+
Labels *FeedGenerator_Labels `json:"labels,omitempty" cborgen:"labels,omitempty"`
31
+
}
32
+
33
+
type FeedGenerator_Labels struct {
34
+
LabelDefs_SelfLabels *comatprototypes.LabelDefs_SelfLabels
35
+
}
36
+
37
+
func (t *FeedGenerator_Labels) MarshalJSON() ([]byte, error) {
38
+
if t.LabelDefs_SelfLabels != nil {
39
+
t.LabelDefs_SelfLabels.LexiconTypeID = "com.atproto.label.defs#selfLabels"
40
+
return json.Marshal(t.LabelDefs_SelfLabels)
41
+
}
42
+
return nil, fmt.Errorf("cannot marshal empty enum")
43
+
}
44
+
func (t *FeedGenerator_Labels) UnmarshalJSON(b []byte) error {
45
+
typ, err := util.TypeExtract(b)
46
+
if err != nil {
47
+
return err
48
+
}
49
+
50
+
switch typ {
51
+
case "com.atproto.label.defs#selfLabels":
52
+
t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
53
+
return json.Unmarshal(b, t.LabelDefs_SelfLabels)
54
+
55
+
default:
56
+
return nil
57
+
}
58
+
}
59
+
60
+
func (t *FeedGenerator_Labels) MarshalCBOR(w io.Writer) error {
61
+
62
+
if t == nil {
63
+
_, err := w.Write(cbg.CborNull)
64
+
return err
65
+
}
66
+
if t.LabelDefs_SelfLabels != nil {
67
+
return t.LabelDefs_SelfLabels.MarshalCBOR(w)
68
+
}
69
+
return fmt.Errorf("cannot cbor marshal empty enum")
70
+
}
71
+
func (t *FeedGenerator_Labels) UnmarshalCBOR(r io.Reader) error {
72
+
typ, b, err := util.CborTypeExtractReader(r)
73
+
if err != nil {
74
+
return err
75
+
}
76
+
77
+
switch typ {
78
+
case "com.atproto.label.defs#selfLabels":
79
+
t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
80
+
return t.LabelDefs_SelfLabels.UnmarshalCBOR(bytes.NewReader(b))
81
+
82
+
default:
83
+
return nil
84
+
}
23
85
}
+2
-1
api/bsky/feedgetAuthorFeed.go
+2
-1
api/bsky/feedgetAuthorFeed.go
···
17
17
}
18
18
19
19
// FeedGetAuthorFeed calls the XRPC method "app.bsky.feed.getAuthorFeed".
20
-
func FeedGetAuthorFeed(ctx context.Context, c *xrpc.Client, actor string, cursor string, limit int64) (*FeedGetAuthorFeed_Output, error) {
20
+
func FeedGetAuthorFeed(ctx context.Context, c *xrpc.Client, actor string, cursor string, filter string, limit int64) (*FeedGetAuthorFeed_Output, error) {
21
21
var out FeedGetAuthorFeed_Output
22
22
23
23
params := map[string]interface{}{
24
24
"actor": actor,
25
25
"cursor": cursor,
26
+
"filter": filter,
26
27
"limit": limit,
27
28
}
28
29
if err := c.Do(ctx, xrpc.Query, "", "app.bsky.feed.getAuthorFeed", params, nil, &out); err != nil {
+55
api/bsky/feedpost.go
+55
api/bsky/feedpost.go
···
26
26
// entities: Deprecated: replaced by app.bsky.richtext.facet.
27
27
Entities []*FeedPost_Entity `json:"entities,omitempty" cborgen:"entities,omitempty"`
28
28
Facets []*RichtextFacet `json:"facets,omitempty" cborgen:"facets,omitempty"`
29
+
Labels *FeedPost_Labels `json:"labels,omitempty" cborgen:"labels,omitempty"`
29
30
Langs []string `json:"langs,omitempty" cborgen:"langs,omitempty"`
30
31
Reply *FeedPost_ReplyRef `json:"reply,omitempty" cborgen:"reply,omitempty"`
31
32
Text string `json:"text" cborgen:"text"`
···
135
136
// type: Expected values are 'mention' and 'link'.
136
137
Type string `json:"type" cborgen:"type"`
137
138
Value string `json:"value" cborgen:"value"`
139
+
}
140
+
141
+
type FeedPost_Labels struct {
142
+
LabelDefs_SelfLabels *comatprototypes.LabelDefs_SelfLabels
143
+
}
144
+
145
+
func (t *FeedPost_Labels) MarshalJSON() ([]byte, error) {
146
+
if t.LabelDefs_SelfLabels != nil {
147
+
t.LabelDefs_SelfLabels.LexiconTypeID = "com.atproto.label.defs#selfLabels"
148
+
return json.Marshal(t.LabelDefs_SelfLabels)
149
+
}
150
+
return nil, fmt.Errorf("cannot marshal empty enum")
151
+
}
152
+
func (t *FeedPost_Labels) UnmarshalJSON(b []byte) error {
153
+
typ, err := util.TypeExtract(b)
154
+
if err != nil {
155
+
return err
156
+
}
157
+
158
+
switch typ {
159
+
case "com.atproto.label.defs#selfLabels":
160
+
t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
161
+
return json.Unmarshal(b, t.LabelDefs_SelfLabels)
162
+
163
+
default:
164
+
return nil
165
+
}
166
+
}
167
+
168
+
func (t *FeedPost_Labels) MarshalCBOR(w io.Writer) error {
169
+
170
+
if t == nil {
171
+
_, err := w.Write(cbg.CborNull)
172
+
return err
173
+
}
174
+
if t.LabelDefs_SelfLabels != nil {
175
+
return t.LabelDefs_SelfLabels.MarshalCBOR(w)
176
+
}
177
+
return fmt.Errorf("cannot cbor marshal empty enum")
178
+
}
179
+
func (t *FeedPost_Labels) UnmarshalCBOR(r io.Reader) error {
180
+
typ, b, err := util.CborTypeExtractReader(r)
181
+
if err != nil {
182
+
return err
183
+
}
184
+
185
+
switch typ {
186
+
case "com.atproto.label.defs#selfLabels":
187
+
t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
188
+
return t.LabelDefs_SelfLabels.UnmarshalCBOR(bytes.NewReader(b))
189
+
190
+
default:
191
+
return nil
192
+
}
138
193
}
139
194
140
195
// FeedPost_ReplyRef is a "replyRef" in the app.bsky.feed.post schema.
+2
-2
api/bsky/graphdefs.go
+2
-2
api/bsky/graphdefs.go
···
21
21
DescriptionFacets []*RichtextFacet `json:"descriptionFacets,omitempty" cborgen:"descriptionFacets,omitempty"`
22
22
IndexedAt string `json:"indexedAt" cborgen:"indexedAt"`
23
23
Name string `json:"name" cborgen:"name"`
24
-
Purpose *string `json:"purpose" cborgen:"purpose"`
24
+
Purpose *GraphDefs_ListPurpose `json:"purpose" cborgen:"purpose"`
25
25
Uri string `json:"uri" cborgen:"uri"`
26
26
Viewer *GraphDefs_ListViewerState `json:"viewer,omitempty" cborgen:"viewer,omitempty"`
27
27
}
···
32
32
Cid string `json:"cid" cborgen:"cid"`
33
33
IndexedAt *string `json:"indexedAt,omitempty" cborgen:"indexedAt,omitempty"`
34
34
Name string `json:"name" cborgen:"name"`
35
-
Purpose *string `json:"purpose" cborgen:"purpose"`
35
+
Purpose *GraphDefs_ListPurpose `json:"purpose" cborgen:"purpose"`
36
36
Uri string `json:"uri" cborgen:"uri"`
37
37
Viewer *GraphDefs_ListViewerState `json:"viewer,omitempty" cborgen:"viewer,omitempty"`
38
38
}
+69
-7
api/bsky/graphlist.go
+69
-7
api/bsky/graphlist.go
···
5
5
// schema: app.bsky.graph.list
6
6
7
7
import (
8
+
"bytes"
9
+
"encoding/json"
10
+
"fmt"
11
+
"io"
12
+
13
+
comatprototypes "github.com/bluesky-social/indigo/api/atproto"
8
14
"github.com/bluesky-social/indigo/lex/util"
15
+
cbg "github.com/whyrusleeping/cbor-gen"
9
16
)
10
17
11
18
func init() {
···
13
20
} //
14
21
// RECORDTYPE: GraphList
15
22
type GraphList struct {
16
-
LexiconTypeID string `json:"$type,const=app.bsky.graph.list" cborgen:"$type,const=app.bsky.graph.list"`
17
-
Avatar *util.LexBlob `json:"avatar,omitempty" cborgen:"avatar,omitempty"`
18
-
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
19
-
Description *string `json:"description,omitempty" cborgen:"description,omitempty"`
20
-
DescriptionFacets []*RichtextFacet `json:"descriptionFacets,omitempty" cborgen:"descriptionFacets,omitempty"`
21
-
Name string `json:"name" cborgen:"name"`
22
-
Purpose *string `json:"purpose" cborgen:"purpose"`
23
+
LexiconTypeID string `json:"$type,const=app.bsky.graph.list" cborgen:"$type,const=app.bsky.graph.list"`
24
+
Avatar *util.LexBlob `json:"avatar,omitempty" cborgen:"avatar,omitempty"`
25
+
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
26
+
Description *string `json:"description,omitempty" cborgen:"description,omitempty"`
27
+
DescriptionFacets []*RichtextFacet `json:"descriptionFacets,omitempty" cborgen:"descriptionFacets,omitempty"`
28
+
Labels *GraphList_Labels `json:"labels,omitempty" cborgen:"labels,omitempty"`
29
+
Name string `json:"name" cborgen:"name"`
30
+
Purpose *GraphDefs_ListPurpose `json:"purpose" cborgen:"purpose"`
31
+
}
32
+
33
+
type GraphList_Labels struct {
34
+
LabelDefs_SelfLabels *comatprototypes.LabelDefs_SelfLabels
35
+
}
36
+
37
+
func (t *GraphList_Labels) MarshalJSON() ([]byte, error) {
38
+
if t.LabelDefs_SelfLabels != nil {
39
+
t.LabelDefs_SelfLabels.LexiconTypeID = "com.atproto.label.defs#selfLabels"
40
+
return json.Marshal(t.LabelDefs_SelfLabels)
41
+
}
42
+
return nil, fmt.Errorf("cannot marshal empty enum")
43
+
}
44
+
func (t *GraphList_Labels) UnmarshalJSON(b []byte) error {
45
+
typ, err := util.TypeExtract(b)
46
+
if err != nil {
47
+
return err
48
+
}
49
+
50
+
switch typ {
51
+
case "com.atproto.label.defs#selfLabels":
52
+
t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
53
+
return json.Unmarshal(b, t.LabelDefs_SelfLabels)
54
+
55
+
default:
56
+
return nil
57
+
}
58
+
}
59
+
60
+
func (t *GraphList_Labels) MarshalCBOR(w io.Writer) error {
61
+
62
+
if t == nil {
63
+
_, err := w.Write(cbg.CborNull)
64
+
return err
65
+
}
66
+
if t.LabelDefs_SelfLabels != nil {
67
+
return t.LabelDefs_SelfLabels.MarshalCBOR(w)
68
+
}
69
+
return fmt.Errorf("cannot cbor marshal empty enum")
70
+
}
71
+
func (t *GraphList_Labels) UnmarshalCBOR(r io.Reader) error {
72
+
typ, b, err := util.CborTypeExtractReader(r)
73
+
if err != nil {
74
+
return err
75
+
}
76
+
77
+
switch typ {
78
+
case "com.atproto.label.defs#selfLabels":
79
+
t.LabelDefs_SelfLabels = new(comatprototypes.LabelDefs_SelfLabels)
80
+
return t.LabelDefs_SelfLabels.UnmarshalCBOR(bytes.NewReader(b))
81
+
82
+
default:
83
+
return nil
84
+
}
23
85
}
+26
api/bsky/unspeccedapplyLabels.go
+26
api/bsky/unspeccedapplyLabels.go
···
1
+
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
+
3
+
package bsky
4
+
5
+
// schema: app.bsky.unspecced.applyLabels
6
+
7
+
import (
8
+
"context"
9
+
10
+
comatprototypes "github.com/bluesky-social/indigo/api/atproto"
11
+
"github.com/bluesky-social/indigo/xrpc"
12
+
)
13
+
14
+
// UnspeccedApplyLabels_Input is the input argument to a app.bsky.unspecced.applyLabels call.
15
+
type UnspeccedApplyLabels_Input struct {
16
+
Labels []*comatprototypes.LabelDefs_Label `json:"labels" cborgen:"labels"`
17
+
}
18
+
19
+
// UnspeccedApplyLabels calls the XRPC method "app.bsky.unspecced.applyLabels".
20
+
func UnspeccedApplyLabels(ctx context.Context, c *xrpc.Client, input *UnspeccedApplyLabels_Input) error {
21
+
if err := c.Do(ctx, xrpc.Procedure, "application/json", "app.bsky.unspecced.applyLabels", nil, input, nil); err != nil {
22
+
return err
23
+
}
24
+
25
+
return nil
26
+
}
+37
-25
lex/gen.go
+37
-25
lex/gen.go
···
145
145
if ts.Type == "ref" {
146
146
refname := ts.Ref
147
147
if strings.HasPrefix(refname, "#") {
148
+
fmt.Println("Foo")
148
149
refname = s.ID + ts.Ref
149
150
}
150
151
···
386
387
func writeCodeFile(b []byte, fname string) error {
387
388
fixed, err := imports.Process(fname, b, nil)
388
389
if err != nil {
390
+
werr := os.WriteFile("temp", b, 0664)
391
+
if werr != nil {
392
+
return werr
393
+
}
389
394
return fmt.Errorf("failed to format output of %q with goimports: %w", fname, err)
390
395
}
391
396
···
494
499
case EncodingJSON:
495
500
outname := fname + "_Output"
496
501
if s.Output.Schema.Type == "ref" {
497
-
outname = s.typeNameFromRef(s.Output.Schema.Ref)
502
+
_, outname = s.namesFromRef(s.Output.Schema.Ref)
498
503
}
499
504
500
505
out = fmt.Sprintf("(*%s, error)", outname)
···
530
535
case EncodingJSON:
531
536
outname := fname + "_Output"
532
537
if s.Output.Schema.Type == "ref" {
533
-
outname = s.typeNameFromRef(s.Output.Schema.Ref)
538
+
_, outname = s.namesFromRef(s.Output.Schema.Ref)
534
539
}
535
540
pf("\tvar out %s\n", outname)
536
541
outvar = "&out"
···
801
806
case "application/json":
802
807
outname := shortname + "_Output"
803
808
if s.Output.Schema.Type == "ref" {
804
-
outname = s.typeNameFromRef(s.Output.Schema.Ref)
809
+
outname, _ = s.namesFromRef(s.Output.Schema.Ref)
805
810
}
806
811
returndef = fmt.Sprintf("(*%s.%s, error)", impname, outname)
807
812
case "application/cbor", "application/vnd.ipld.car", "*/*":
···
993
998
assign = "out, handleErr"
994
999
outname := tname + "_Output"
995
1000
if s.Output.Schema.Type == "ref" {
996
-
outname = s.typeNameFromRef(s.Output.Schema.Ref)
1001
+
outname, _ = s.namesFromRef(s.Output.Schema.Ref)
997
1002
}
998
1003
pf("var out *%s.%s\n", impname, outname)
999
1004
returndef = fmt.Sprintf("(*%s.%s, error)", impname, outname)
···
1030
1035
return nil
1031
1036
}
1032
1037
1033
-
func (s *TypeSchema) typeNameFromRef(r string) string {
1038
+
func (s *TypeSchema) namesFromRef(r string) (string, string) {
1034
1039
ts, err := s.lookupRef(r)
1035
1040
if err != nil {
1036
1041
panic(err)
···
1046
1051
1047
1052
// TODO: probably not technically correct, but i'm kinda over how lexicon
1048
1053
// tries to enforce application logic in a schema language
1049
-
if ts.Type == "string" {
1050
-
return "string"
1051
-
}
1054
+
// if ts.Type == "string" {
1055
+
// return "string"
1056
+
// }
1052
1057
1053
1058
var pkg string
1054
1059
if ts.prefix != s.prefix {
1055
1060
pkg = importNameForPrefix(ts.prefix) + "."
1056
1061
}
1057
1062
1058
-
return pkg + ts.TypeName()
1063
+
tname := pkg + ts.TypeName()
1064
+
vname := tname
1065
+
if strings.Contains(vname, ".") {
1066
+
// Trim the package name from the variable name
1067
+
vname = strings.Split(vname, ".")[1]
1068
+
}
1069
+
1070
+
return vname, tname
1059
1071
}
1060
1072
1061
1073
func (s *TypeSchema) TypeName() string {
···
1094
1106
case "object":
1095
1107
return "*" + name + "_" + strings.Title(k), nil
1096
1108
case "ref":
1097
-
tn := s.typeNameFromRef(v.Ref)
1109
+
_, tn := s.namesFromRef(v.Ref)
1098
1110
if tn[0] == '[' {
1099
1111
return tn, nil
1100
1112
}
···
1263
1275
if len(ts.Refs) > 0 {
1264
1276
pf("type %s struct {\n", name)
1265
1277
for _, r := range ts.Refs {
1266
-
tname := ts.typeNameFromRef(r)
1267
-
pf("\t%s *%s\n", tname, tname)
1278
+
vname, tname := ts.namesFromRef(r)
1279
+
pf("\t%s *%s\n", vname, tname)
1268
1280
}
1269
1281
pf("}\n\n")
1270
1282
}
···
1354
1366
pf("func (t *%s) MarshalJSON() ([]byte, error) {\n", name)
1355
1367
1356
1368
for _, e := range ts.Refs {
1357
-
tname := ts.typeNameFromRef(e)
1369
+
vname, _ := ts.namesFromRef(e)
1358
1370
if strings.HasPrefix(e, "#") {
1359
1371
e = ts.id + e
1360
1372
}
1361
1373
1362
-
pf("\tif t.%s != nil {\n", tname)
1363
-
pf("\tt.%s.LexiconTypeID = %q\n", tname, e)
1364
-
pf("\t\treturn json.Marshal(t.%s)\n\t}\n", tname)
1374
+
pf("\tif t.%s != nil {\n", vname)
1375
+
pf("\tt.%s.LexiconTypeID = %q\n", vname, e)
1376
+
pf("\t\treturn json.Marshal(t.%s)\n\t}\n", vname)
1365
1377
}
1366
1378
1367
1379
pf("\treturn nil, fmt.Errorf(\"cannot marshal empty enum\")\n}\n")
···
1399
1411
e = ts.id + e
1400
1412
}
1401
1413
1402
-
goname := ts.typeNameFromRef(e)
1414
+
vname, goname := ts.namesFromRef(e)
1403
1415
1404
1416
pf("\t\tcase \"%s\":\n", e)
1405
-
pf("\t\t\tt.%s = new(%s)\n", goname, goname)
1406
-
pf("\t\t\treturn json.Unmarshal(b, t.%s)\n", goname)
1417
+
pf("\t\t\tt.%s = new(%s)\n", vname, goname)
1418
+
pf("\t\t\treturn json.Unmarshal(b, t.%s)\n", vname)
1407
1419
}
1408
1420
1409
1421
if ts.Closed {
···
1436
1448
`)
1437
1449
1438
1450
for _, e := range ts.Refs {
1439
-
tname := ts.typeNameFromRef(e)
1440
-
pf("\tif t.%s != nil {\n", tname)
1441
-
pf("\t\treturn t.%s.MarshalCBOR(w)\n\t}\n", tname)
1451
+
vname, _ := ts.namesFromRef(e)
1452
+
pf("\tif t.%s != nil {\n", vname)
1453
+
pf("\t\treturn t.%s.MarshalCBOR(w)\n\t}\n", vname)
1442
1454
}
1443
1455
1444
1456
pf("\treturn fmt.Errorf(\"cannot cbor marshal empty enum\")\n}\n")
···
1456
1468
e = ts.id + e
1457
1469
}
1458
1470
1459
-
goname := ts.typeNameFromRef(e)
1471
+
vname, goname := ts.namesFromRef(e)
1460
1472
1461
1473
pf("\t\tcase \"%s\":\n", e)
1462
-
pf("\t\t\tt.%s = new(%s)\n", goname, goname)
1463
-
pf("\t\t\treturn t.%s.UnmarshalCBOR(bytes.NewReader(b))\n", goname)
1474
+
pf("\t\t\tt.%s = new(%s)\n", vname, goname)
1475
+
pf("\t\t\treturn t.%s.UnmarshalCBOR(bytes.NewReader(b))\n", vname)
1464
1476
}
1465
1477
1466
1478
if ts.Closed {