tshex-cli 1.0.29 → 1.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,161 +0,0 @@
1
- ### Open Graph
2
-
3
- `opengraph.ts` declares a type-only implementation of the
4
- [Open Graph protocol](https://ogp.me/), the Twitter Card meta tags, and
5
- Facebook's compatibility extensions. It is used when an adapter needs to build
6
- or read the social-sharing metadata of a page.
7
-
8
- This module has no runtime values or implementations, including no HTML
9
- rendering. Use it to build the data and a separate template or renderer to
10
- emit the actual `<meta>` tags.
11
-
12
- #### Base Shape
13
-
14
- Every Open Graph object shares `OpenGraphBase<TType>`: the required `title`,
15
- `type`, `images` (`OneOrMore<OpenGraphImage>`, first has precedence), and
16
- `url`, plus the optional `audio`, `description`, `determiner`, `locale`,
17
- `alternateLocales`, `siteName`, and `videos`. `OpenGraphObjectExtensions`
18
- adds an optional `extensions` map for CURIE-namespaced custom properties
19
- (`'product:color'`, etc.), kept as opaque strings.
20
-
21
- #### Standard Object Types
22
-
23
- `OpenGraphType` selects one of thirteen standard types
24
- (`OpenGraphStandardType`) or a custom CURIE type
25
- (`OpenGraphCustomType`, e.g. `'product:item'`). Each standard type has its
26
- own interface adding the fields that type requires:
27
-
28
- | `type` | Interface | Extra fields |
29
- | --- | --- | --- |
30
- | `'website'` | `OpenGraphWebsite` | none |
31
- | `'article'` | `OpenGraphArticle` | `publishedTime`, `modifiedTime`, `expirationTime`, `authors`, `section`, `tags` |
32
- | `'book'` | `OpenGraphBook` | `authors`, `isbn`, `releaseDate`, `tags` |
33
- | `'profile'` | `OpenGraphProfile` | `firstName`, `lastName`, `username`, `gender` |
34
- | `'music.song'` | `OpenGraphMusicSong` | `duration`, `albums`, `musicians` |
35
- | `'music.album'` | `OpenGraphMusicAlbum` | `songs`, `musicians`, `releaseDate` |
36
- | `'music.playlist'` | `OpenGraphMusicPlaylist` | `songs`, `creator` |
37
- | `'music.radio_station'` | `OpenGraphMusicRadioStation` | `creator` |
38
- | `'video.movie'` | `OpenGraphVideoMovie` | `actors`, `directors`, `writers`, `duration`, `releaseDate`, `tags` (`OpenGraphVideoMetadata`) |
39
- | `'video.episode'` | `OpenGraphVideoEpisode` | `OpenGraphVideoMetadata` + `series` |
40
- | `'video.tv_show'` | `OpenGraphVideoTvShow` | `OpenGraphVideoMetadata` |
41
- | `'video.other'` | `OpenGraphVideoOther` | `OpenGraphVideoMetadata` |
42
- | `'payment.link'` | `OpenGraphPaymentLink` | `paymentDescription`, `currency`, `amount`, `expiresAt`, `paymentStatus`, `paymentId`, `successUrl` (marked beta by the protocol) |
43
- | CURIE type | `OpenGraphCustomObject` | none beyond the base shape |
44
-
45
- `OpenGraphMetadata` is the union of all fourteen. Building one selects the
46
- type through the discriminant and, from there, TypeScript narrows to that
47
- type's own extra fields.
48
-
49
- ```ts title="users/adapters/user-profile-metadata.ts"
50
- import { OpenGraphProfile } from '../../shared/application/http/opengraph.js'
51
-
52
- export function buildProfileMetadata(username: string): OpenGraphProfile {
53
- return {
54
- type: 'profile',
55
- title: username,
56
- url: `https://example.com/users/${username}`,
57
- images: [{ url: `https://example.com/users/${username}/avatar.png` }],
58
- username,
59
- }
60
- }
61
- ```
62
-
63
- ```ts title="users/adapters/article-metadata.ts"
64
- import { OpenGraphArticle } from '../../shared/application/http/opengraph.js'
65
-
66
- export function buildArticleMetadata(slug: string): OpenGraphArticle {
67
- return {
68
- type: 'article',
69
- title: 'How context ports work',
70
- url: `https://example.com/blog/${slug}`,
71
- images: [{ url: `https://example.com/blog/${slug}/cover.png` }],
72
- publishedTime: new Date().toISOString(),
73
- tags: ['architecture', 'typescript'],
74
- }
75
- }
76
- ```
77
-
78
- `OpenGraphPaymentStatus` (`'PENDING' | 'PAID' | 'FAILED' | 'EXPIRED'`) types
79
- `OpenGraphPaymentLink['paymentStatus']`.
80
-
81
- #### Twitter Cards
82
-
83
- `TwitterCardType` selects one of four card layouts. `TwitterCardBase<TCard>`
84
- carries the members every card shares (`site`, `siteId`, `creator`,
85
- `creatorId`, `title`, `description`); each concrete card adds the fields that
86
- layout needs:
87
-
88
- | `card` | Interface | Extra/required fields |
89
- | --- | --- | --- |
90
- | `'summary'` | `TwitterSummaryCard` | optional `image` |
91
- | `'summary_large_image'` | `TwitterSummaryLargeImageCard` | optional `image` |
92
- | `'player'` | `TwitterPlayerCard` | required `image`, `player`, `playerWidth`, `playerHeight`; optional `playerStream`, `playerStreamContentType` |
93
- | `'app'` | `TwitterAppCard` | optional `country`, `iphone`, `ipad`, `googlePlay` (each `TwitterAppPlatform`) |
94
-
95
- `TwitterCardMetadata` is the union of all four.
96
-
97
- ```ts
98
- import type { TwitterPlayerCard } from '../../../shared/application/http/opengraph.js'
99
-
100
- const playerCard: TwitterPlayerCard = {
101
- card: 'player',
102
- image: { url: 'https://example.com/videos/1/thumb.png' },
103
- player: 'https://example.com/videos/1/embed',
104
- playerWidth: 640,
105
- playerHeight: 360,
106
- }
107
- ```
108
-
109
- #### Raw Meta Tag Representation
110
-
111
- `OpenGraphMetaTag`/`TwitterMetaTag` are the flat `property`/`content` and
112
- `name`/`content` tag forms closer to the actual `<meta>` markup, for a
113
- renderer that emits tags directly instead of consuming the structured
114
- objects above.
115
-
116
- | Tag family | Type | Attribute pair |
117
- | --- | --- | --- |
118
- | Open Graph (standard) | `OpenGraphStandardMetaTag` | `property`/`content`, e.g. `'og:title'` |
119
- | Open Graph (custom) | `OpenGraphCustomMetaTag` | any `` `${string}:${string}` `` property |
120
- | Twitter | `TwitterMetaTag` | `name`/`content`, e.g. `'twitter:card'` |
121
- | Facebook | `FacebookMetaTag` | `PropertyMetaTag<'fb:app_id'>` |
122
- | Standard HTML | `StandardHtmlMetaTag` | `'description'` \| `'theme-color'` |
123
-
124
- `SocialMetaTag` is the union of all five families. `CanonicalLinkTag` types
125
- the `<link rel="canonical">` element separately, since it is not a `<meta>`
126
- tag.
127
-
128
- #### Aggregate Document
129
-
130
- Two document shapes cover the two stages of building a page's social
131
- metadata:
132
-
133
- | Type | Shape | Use |
134
- | --- | --- | --- |
135
- | `SocialMetadataDocument` | `head?`, `openGraph` (required), `twitter?`, `facebook?` | Structured data a service builds before rendering |
136
- | `RawSocialMetadataDocument` | `title?`, `meta: SocialMetaTag[]`, `links?: CanonicalLinkTag[]` | The rendered, tag-list form a template consumes |
137
-
138
- ```ts title="users/adapters/social-metadata-document.ts"
139
- import {
140
- SocialMetadataDocument,
141
- OpenGraphProfile,
142
- } from '../../shared/application/http/opengraph.js'
143
-
144
- export function buildSocialMetadata(profile: OpenGraphProfile): SocialMetadataDocument {
145
- return {
146
- head: { title: profile.title, description: profile.description },
147
- openGraph: profile,
148
- twitter: { card: 'summary', title: profile.title },
149
- }
150
- }
151
- ```
152
-
153
- Converting a `SocialMetadataDocument` into a `RawSocialMetadataDocument` is
154
- the responsibility of a renderer, which flattens each structured field into
155
- its corresponding `SocialMetaTag` entries; that conversion is not implemented
156
- by this module.
157
-
158
- > **Hint**
159
- > This module has no runtime implementation, including no HTML rendering. Use
160
- > `OpenGraphMetadata` to build the data and a separate template or renderer to
161
- > emit the `<meta>` tags described by `OpenGraphMetaTag`/`TwitterMetaTag`.