diff --git a/api/bsky/embedexternal.go b/api/bsky/embedexternal.go --- a/api/bsky/embedexternal.go +++ b/api/bsky/embedexternal.go @@ -5,6 +5,7 @@ package bsky import ( + comatproto "github.com/bluesky-social/indigo/api/atproto" lexutil "github.com/bluesky-social/indigo/lex/util" ) @@ -20,12 +21,23 @@ External *EmbedExternal_External `json:"external" cborgen:"external"` } +// EmbedExternal_ColorRGB is a "colorRGB" in the app.bsky.embed.external schema. +// +// RGB color definition, inspired by site.standard.theme.color#rgb +type EmbedExternal_ColorRGB struct { + B int64 `json:"b" cborgen:"b"` + G int64 `json:"g" cborgen:"g"` + R int64 `json:"r" cborgen:"r"` +} + // EmbedExternal_External is a "external" in the app.bsky.embed.external schema. type EmbedExternal_External struct { - Description string `json:"description" cborgen:"description"` - Thumb *lexutil.LexBlob `json:"thumb,omitempty" cborgen:"thumb,omitempty"` - Title string `json:"title" cborgen:"title"` - Uri string `json:"uri" cborgen:"uri"` + // associatedRefs: StrongRefs (uri+cid) of the Atmosphere records that backed this view, suitable for embedding into a post's external.associatedRefs. + AssociatedRefs []*comatproto.RepoStrongRef `json:"associatedRefs,omitempty" cborgen:"associatedRefs,omitempty"` + Description string `json:"description" cborgen:"description"` + Thumb *lexutil.LexBlob `json:"thumb,omitempty" cborgen:"thumb,omitempty"` + Title string `json:"title" cborgen:"title"` + Uri string `json:"uri" cborgen:"uri"` } // EmbedExternal_View is a "view" in the app.bsky.embed.external schema. @@ -36,8 +48,40 @@ // EmbedExternal_ViewExternal is a "viewExternal" in the app.bsky.embed.external schema. type EmbedExternal_ViewExternal struct { - Description string `json:"description" cborgen:"description"` - Thumb *string `json:"thumb,omitempty" cborgen:"thumb,omitempty"` - Title string `json:"title" cborgen:"title"` - Uri string `json:"uri" cborgen:"uri"` + // associatedRefs: StrongRefs (uri+cid) of the Atmosphere records that backed this view, suitable for embedding into a post's external.associatedRefs. + AssociatedRefs []*comatproto.RepoStrongRef `json:"associatedRefs,omitempty" cborgen:"associatedRefs,omitempty"` + // createdAt: When the external content was created, if available. Example: a publication date, for an article. + CreatedAt *string `json:"createdAt,omitempty" cborgen:"createdAt,omitempty"` + Description string `json:"description" cborgen:"description"` + Labels []*comatproto.LabelDefs_Label `json:"labels,omitempty" cborgen:"labels,omitempty"` + // readingTime: Estimated reading time in minutes, if applicable and available. + ReadingTime *int64 `json:"readingTime,omitempty" cborgen:"readingTime,omitempty"` + Source *EmbedExternal_ViewExternalSource `json:"source,omitempty" cborgen:"source,omitempty"` + Thumb *string `json:"thumb,omitempty" cborgen:"thumb,omitempty"` + Title string `json:"title" cborgen:"title"` + // updatedAt: When the external content was updated, if available. + UpdatedAt *string `json:"updatedAt,omitempty" cborgen:"updatedAt,omitempty"` + Uri string `json:"uri" cborgen:"uri"` +} + +// EmbedExternal_ViewExternalSource is a "viewExternalSource" in the app.bsky.embed.external schema. +// +// The source of an external embed, such as a standard.site publication. +type EmbedExternal_ViewExternalSource struct { + Description *string `json:"description,omitempty" cborgen:"description,omitempty"` + // icon: Fully-qualified URL where an icon representing the source can be fetched. For example, CDN location provided by the App View. + Icon *string `json:"icon,omitempty" cborgen:"icon,omitempty"` + Name *string `json:"name,omitempty" cborgen:"name,omitempty"` + Theme *EmbedExternal_ViewExternalSourceTheme `json:"theme,omitempty" cborgen:"theme,omitempty"` + Uri *string `json:"uri,omitempty" cborgen:"uri,omitempty"` +} + +// EmbedExternal_ViewExternalSourceTheme is a "viewExternalSourceTheme" in the app.bsky.embed.external schema. +// +// The theme colors of an external source, such as a site.standard.publication. These colors may be used when rendering an embed from that source. +type EmbedExternal_ViewExternalSourceTheme struct { + AccentForegroundRGB *EmbedExternal_ColorRGB `json:"accentForegroundRGB,omitempty" cborgen:"accentForegroundRGB,omitempty"` + AccentRGB *EmbedExternal_ColorRGB `json:"accentRGB,omitempty" cborgen:"accentRGB,omitempty"` + BackgroundRGB *EmbedExternal_ColorRGB `json:"backgroundRGB,omitempty" cborgen:"backgroundRGB,omitempty"` + ForegroundRGB *EmbedExternal_ColorRGB `json:"foregroundRGB,omitempty" cborgen:"foregroundRGB,omitempty"` } diff --git a/api/bsky/embedgetEmbedExternalView.go b/api/bsky/embedgetEmbedExternalView.go new file mode 100644 --- /dev/null +++ b/api/bsky/embedgetEmbedExternalView.go @@ -0,0 +1,37 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +// Lexicon schema: app.bsky.embed.getEmbedExternalView + +package bsky + +import ( + "context" + + comatproto "github.com/bluesky-social/indigo/api/atproto" + lexutil "github.com/bluesky-social/indigo/lex/util" +) + +// EmbedGetEmbedExternalView_Output is the output of a app.bsky.embed.getEmbedExternalView call. +type EmbedGetEmbedExternalView_Output struct { + AssociatedRecords []*lexutil.LexiconTypeDecoder `json:"associatedRecords,omitempty" cborgen:"associatedRecords,omitempty"` + // associatedRefs: StrongRefs (uri+cid) of the Atmosphere records that backed this view, suitable for embedding into a post's external.associatedRefs. + AssociatedRefs []*comatproto.RepoStrongRef `json:"associatedRefs,omitempty" cborgen:"associatedRefs,omitempty"` + View *EmbedExternal_View `json:"view,omitempty" cborgen:"view,omitempty"` +} + +// EmbedGetEmbedExternalView calls the XRPC method "app.bsky.embed.getEmbedExternalView". +// +// uris: AT-URIs of any Atmosphere records that can be resolved and used to construct #externalView views. Example: a site.standard.document and optionally its associated site.standard.publication. +// url: The canonical web URL the embed represents (typically the URL the user pasted into the composer). Used as the returned view's `uri`. +func EmbedGetEmbedExternalView(ctx context.Context, c lexutil.LexClient, uris []string, url string) (*EmbedGetEmbedExternalView_Output, error) { + var out EmbedGetEmbedExternalView_Output + + params := map[string]interface{}{} + params["uris"] = uris + params["url"] = url + if err := c.LexDo(ctx, lexutil.Query, "", "app.bsky.embed.getEmbedExternalView", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/lexicons/app/bsky/embed/external.json b/lexicons/app/bsky/embed/external.json --- a/lexicons/app/bsky/embed/external.json +++ b/lexicons/app/bsky/embed/external.json @@ -67,6 +67,10 @@ "type": "integer", "description": "Estimated reading time in minutes, if applicable and available." }, + "labels": { + "type": "array", + "items": { "type": "ref", "ref": "com.atproto.label.defs#label" } + }, "source": { "type": "ref", "ref": "#viewExternalSource" }, "associatedRefs": { "type": "array", @@ -100,19 +104,19 @@ "type": "object", "description": "The theme colors of an external source, such as a site.standard.publication. These colors may be used when rendering an embed from that source.", "properties": { - "background": { + "backgroundRGB": { "type": "ref", "ref": "#colorRGB" }, - "foreground": { + "foregroundRGB": { "type": "ref", "ref": "#colorRGB" }, - "accent": { + "accentRGB": { "type": "ref", "ref": "#colorRGB" }, - "accentForeground": { + "accentForegroundRGB": { "type": "ref", "ref": "#colorRGB" } diff --git a/lexicons/app/bsky/embed/getEmbedExternalView.json b/lexicons/app/bsky/embed/getEmbedExternalView.json --- a/lexicons/app/bsky/embed/getEmbedExternalView.json +++ b/lexicons/app/bsky/embed/getEmbedExternalView.json @@ -4,11 +4,16 @@ "defs": { "main": { "type": "query", - "description": "Get a hydrated view of an external embed for one or more site.standard.* AT-URIs. Returns the view plus the strongRefs of records that backed it, suitable for embedding into a post's external.associatedRecords.", + "description": "Resolve one or more site.standard.* AT-URIs into the data needed to render an enhanced external embed. Returns `associatedRefs` (strongRefs to embed into a post's external.associatedRefs) and the raw `associatedRecords`; `view` is also included when the resolved records can produce a renderable view, but may be omitted when no records were hydratable.", "parameters": { "type": "params", - "required": ["uris"], + "required": ["url", "uris"], "properties": { + "url": { + "type": "string", + "format": "uri", + "description": "The canonical web URL the embed represents (typically the URL the user pasted into the composer). Used as the returned view's `uri`." + }, "uris": { "type": "array", "description": "AT-URIs of any Atmosphere records that can be resolved and used to construct #externalView views. Example: a site.standard.document and optionally its associated site.standard.publication.",