@xylabs/sdk-meta 5.0.84 → 5.0.86

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.
Files changed (2) hide show
  1. package/README.md +112 -487
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -15,6 +15,8 @@
15
15
 
16
16
  Base functionality used throughout XYO TypeScript/JavaScript libraries
17
17
 
18
+
19
+
18
20
  ## Reference
19
21
 
20
22
  **@xylabs/sdk-meta**
@@ -23,24 +25,30 @@ Base functionality used throughout XYO TypeScript/JavaScript libraries
23
25
 
24
26
  ## Interfaces
25
27
 
26
- - [Meta](#interfaces/Meta)
27
- - [OpenGraphMeta](#interfaces/OpenGraphMeta)
28
- - [OpenGraphStructured](#interfaces/OpenGraphStructured)
29
- - [TwitterMeta](#interfaces/TwitterMeta)
30
- - [TwitterApp](#interfaces/TwitterApp)
31
- - [TwitterPlayer](#interfaces/TwitterPlayer)
28
+ | Interface | Description |
29
+ | ------ | ------ |
30
+ | [Meta](#interfaces/Meta) | Represents page metadata including Open Graph and Twitter card properties. |
31
+ | [OpenGraphMeta](#interfaces/OpenGraphMeta) | Open Graph protocol metadata for rich link previews. |
32
+ | [OpenGraphStructured](#interfaces/OpenGraphStructured) | Structured properties for an Open Graph media object (image, video, or audio). |
33
+ | [TwitterMeta](#interfaces/TwitterMeta) | https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/markup |
34
+ | [TwitterApp](#interfaces/TwitterApp) | Twitter App Card metadata containing app store identifiers, names, and URLs per platform. |
35
+ | [TwitterPlayer](#interfaces/TwitterPlayer) | https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/player-card |
32
36
 
33
37
  ## Type Aliases
34
38
 
35
- - [StringIndexable](#type-aliases/StringIndexable)
36
- - [OpenGraphStructuredProperty](#type-aliases/OpenGraphStructuredProperty)
39
+ | Type Alias | Description |
40
+ | ------ | ------ |
41
+ | [StringIndexable](#type-aliases/StringIndexable) | An object with string keys and arbitrary values, used for recursive meta flattening. |
42
+ | [OpenGraphStructuredProperty](#type-aliases/OpenGraphStructuredProperty) | A structured Open Graph property value: a URL string, a structured object, or an array of either. |
37
43
 
38
44
  ## Functions
39
45
 
40
- - [mergeDocumentHead](#functions/mergeDocumentHead)
41
- - [getMetaAsDict](#functions/getMetaAsDict)
42
- - [addMetaToHead](#functions/addMetaToHead)
43
- - [metaBuilder](#functions/metaBuilder)
46
+ | Function | Description |
47
+ | ------ | ------ |
48
+ | [mergeDocumentHead](#functions/mergeDocumentHead) | Merges meta tags from the source HTML head into the destination HTML head. Existing meta tags with matching property attributes are replaced; others are appended. |
49
+ | [getMetaAsDict](#functions/getMetaAsDict) | Recursively flattens a nested meta object into a flat dictionary with colon-delimited keys. |
50
+ | [addMetaToHead](#functions/addMetaToHead) | Adds or replaces a meta tag in the document head. |
51
+ | [metaBuilder](#functions/metaBuilder) | Injects meta properties, title, and description into an HTML string. |
44
52
 
45
53
  ### functions
46
54
 
@@ -52,32 +60,20 @@ Base functionality used throughout XYO TypeScript/JavaScript libraries
52
60
 
53
61
  ```ts
54
62
  function addMetaToHead(
55
- $,
56
- name,
57
- value): void;
63
+ $: CheerioAPI,
64
+ name: string,
65
+ value: string | object): void;
58
66
  ```
59
67
 
60
68
  Adds or replaces a meta tag in the document head.
61
69
 
62
70
  ## Parameters
63
71
 
64
- ### $
65
-
66
- `CheerioAPI`
67
-
68
- The Cheerio API instance for the document.
69
-
70
- ### name
71
-
72
- `string`
73
-
74
- The meta property name.
75
-
76
- ### value
77
-
78
- The meta content value (string, array, or nested object).
79
-
80
- `string` | `object`
72
+ | Parameter | Type | Description |
73
+ | ------ | ------ | ------ |
74
+ | `$` | `CheerioAPI` | The Cheerio API instance for the document. |
75
+ | `name` | `string` | The meta property name. |
76
+ | `value` | `string` \| `object` | The meta content value (string, array, or nested object). |
81
77
 
82
78
  ## Returns
83
79
 
@@ -90,24 +86,17 @@ The meta content value (string, array, or nested object).
90
86
  ***
91
87
 
92
88
  ```ts
93
- function getMetaAsDict(obj, parentKey?): Record<string, string>;
89
+ function getMetaAsDict(obj: StringIndexable, parentKey?: string): Record<string, string>;
94
90
  ```
95
91
 
96
92
  Recursively flattens a nested meta object into a flat dictionary with colon-delimited keys.
97
93
 
98
94
  ## Parameters
99
95
 
100
- ### obj
101
-
102
- [`StringIndexable`](#../type-aliases/StringIndexable)
103
-
104
- The nested object to flatten.
105
-
106
- ### parentKey?
107
-
108
- `string`
109
-
110
- The accumulated key prefix from parent levels.
96
+ | Parameter | Type | Description |
97
+ | ------ | ------ | ------ |
98
+ | `obj` | [`StringIndexable`](#../type-aliases/StringIndexable) | The nested object to flatten. |
99
+ | `parentKey?` | `string` | The accumulated key prefix from parent levels. |
111
100
 
112
101
  ## Returns
113
102
 
@@ -122,7 +111,7 @@ A flat record mapping colon-delimited property names to string values.
122
111
  ***
123
112
 
124
113
  ```ts
125
- function mergeDocumentHead(destination, source): string;
114
+ function mergeDocumentHead(destination: string, source: string): string;
126
115
  ```
127
116
 
128
117
  Merges meta tags from the source HTML head into the destination HTML head.
@@ -130,17 +119,10 @@ Existing meta tags with matching property attributes are replaced; others are ap
130
119
 
131
120
  ## Parameters
132
121
 
133
- ### destination
134
-
135
- `string`
136
-
137
- The base HTML string to merge into.
138
-
139
- ### source
140
-
141
- `string`
142
-
143
- The HTML string whose head meta tags will be merged.
122
+ | Parameter | Type | Description |
123
+ | ------ | ------ | ------ |
124
+ | `destination` | `string` | The base HTML string to merge into. |
125
+ | `source` | `string` | The HTML string whose head meta tags will be merged. |
144
126
 
145
127
  ## Returns
146
128
 
@@ -156,32 +138,20 @@ The merged HTML string.
156
138
 
157
139
  ```ts
158
140
  function metaBuilder(
159
- html,
160
- meta,
161
- handler?): string;
141
+ html: string,
142
+ meta: Meta,
143
+ handler?: string): string;
162
144
  ```
163
145
 
164
146
  Injects meta properties, title, and description into an HTML string.
165
147
 
166
148
  ## Parameters
167
149
 
168
- ### html
169
-
170
- `string`
171
-
172
- The base HTML string to modify.
173
-
174
- ### meta
175
-
176
- [`Meta`](#../interfaces/Meta)
177
-
178
- The metadata to inject.
179
-
180
- ### handler?
181
-
182
- `string`
183
-
184
- Optional meta-handler property value to include.
150
+ | Parameter | Type | Description |
151
+ | ------ | ------ | ------ |
152
+ | `html` | `string` | The base HTML string to modify. |
153
+ | `meta` | [`Meta`](#../interfaces/Meta) | The metadata to inject. |
154
+ | `handler?` | `string` | Optional meta-handler property value to include. |
185
155
 
186
156
  ## Returns
187
157
 
@@ -201,35 +171,12 @@ Represents page metadata including Open Graph and Twitter card properties.
201
171
 
202
172
  ## Properties
203
173
 
204
- ### description?
205
-
206
- ```ts
207
- optional description: string;
208
- ```
209
-
210
- ***
211
-
212
- ### og?
213
-
214
- ```ts
215
- optional og: OpenGraphMeta;
216
- ```
217
-
218
- ***
219
-
220
- ### title?
221
-
222
- ```ts
223
- optional title: string;
224
- ```
225
-
226
- ***
227
-
228
- ### twitter?
229
-
230
- ```ts
231
- optional twitter: TwitterMeta;
232
- ```
174
+ | Property | Type |
175
+ | ------ | ------ |
176
+ | <a id="description"></a> `description?` | `string` |
177
+ | <a id="og"></a> `og?` | [`OpenGraphMeta`](#OpenGraphMeta) |
178
+ | <a id="title"></a> `title?` | `string` |
179
+ | <a id="twitter"></a> `twitter?` | [`TwitterMeta`](#TwitterMeta) |
233
180
 
234
181
  ### <a id="OpenGraphMeta"></a>OpenGraphMeta
235
182
 
@@ -241,83 +188,18 @@ Open Graph protocol metadata for rich link previews.
241
188
 
242
189
  ## Properties
243
190
 
244
- ### audio?
245
-
246
- ```ts
247
- optional audio: OpenGraphStructuredProperty;
248
- ```
249
-
250
- ***
251
-
252
- ### description?
253
-
254
- ```ts
255
- optional description: string;
256
- ```
257
-
258
- ***
259
-
260
- ### determiner?
261
-
262
- ```ts
263
- optional determiner: string;
264
- ```
265
-
266
- ***
267
-
268
- ### image?
269
-
270
- ```ts
271
- optional image: OpenGraphStructuredProperty;
272
- ```
273
-
274
- ***
275
-
276
- ### locale?
277
-
278
- ```ts
279
- optional locale: string | string[];
280
- ```
281
-
282
- ***
283
-
284
- ### site\_name?
285
-
286
- ```ts
287
- optional site_name: string;
288
- ```
289
-
290
- ***
291
-
292
- ### title?
293
-
294
- ```ts
295
- optional title: string;
296
- ```
297
-
298
- ***
299
-
300
- ### type?
301
-
302
- ```ts
303
- optional type: string;
304
- ```
305
-
306
- ***
307
-
308
- ### url?
309
-
310
- ```ts
311
- optional url: string;
312
- ```
313
-
314
- ***
315
-
316
- ### video?
317
-
318
- ```ts
319
- optional video: OpenGraphStructuredProperty;
320
- ```
191
+ | Property | Type |
192
+ | ------ | ------ |
193
+ | <a id="audio"></a> `audio?` | [`OpenGraphStructuredProperty`](#../type-aliases/OpenGraphStructuredProperty) |
194
+ | <a id="description"></a> `description?` | `string` |
195
+ | <a id="determiner"></a> `determiner?` | `string` |
196
+ | <a id="image"></a> `image?` | [`OpenGraphStructuredProperty`](#../type-aliases/OpenGraphStructuredProperty) |
197
+ | <a id="locale"></a> `locale?` | `string` \| `string`[] |
198
+ | <a id="site_name"></a> `site_name?` | `string` |
199
+ | <a id="title"></a> `title?` | `string` |
200
+ | <a id="type"></a> `type?` | `string` |
201
+ | <a id="url"></a> `url?` | `string` |
202
+ | <a id="video"></a> `video?` | [`OpenGraphStructuredProperty`](#../type-aliases/OpenGraphStructuredProperty) |
321
203
 
322
204
  ### <a id="OpenGraphStructured"></a>OpenGraphStructured
323
205
 
@@ -329,59 +211,15 @@ Structured properties for an Open Graph media object (image, video, or audio).
329
211
 
330
212
  ## Properties
331
213
 
332
- ### ?
333
-
334
- ```ts
335
- optional : string;
336
- ```
337
-
338
- ***
339
-
340
- ### alt?
341
-
342
- ```ts
343
- optional alt: string;
344
- ```
345
-
346
- ***
347
-
348
- ### height?
349
-
350
- ```ts
351
- optional height: number;
352
- ```
353
-
354
- ***
355
-
356
- ### secure\_url?
357
-
358
- ```ts
359
- optional secure_url: string;
360
- ```
361
-
362
- ***
363
-
364
- ### type?
365
-
366
- ```ts
367
- optional type: string;
368
- ```
369
-
370
- ***
371
-
372
- ### url?
373
-
374
- ```ts
375
- optional url: string;
376
- ```
377
-
378
- ***
379
-
380
- ### width?
381
-
382
- ```ts
383
- optional width: number;
384
- ```
214
+ | Property | Type |
215
+ | ------ | ------ |
216
+ | <a id="_"></a> `?` | `string` |
217
+ | <a id="alt"></a> `alt?` | `string` |
218
+ | <a id="height"></a> `height?` | `number` |
219
+ | <a id="secure_url"></a> `secure_url?` | `string` |
220
+ | <a id="type"></a> `type?` | `string` |
221
+ | <a id="url"></a> `url?` | `string` |
222
+ | <a id="width"></a> `width?` | `number` |
385
223
 
386
224
  ### <a id="TwitterApp"></a>TwitterApp
387
225
 
@@ -393,81 +231,20 @@ Twitter App Card metadata containing app store identifiers, names, and URLs per
393
231
 
394
232
  ## Properties
395
233
 
396
- ### id?
397
-
398
- ```ts
399
- optional id: object;
400
- ```
401
-
402
- ### googleplay?
403
-
404
- ```ts
405
- optional googleplay: string;
406
- ```
407
-
408
- ### ipad?
409
-
410
- ```ts
411
- optional ipad: string;
412
- ```
413
-
414
- ### iphone?
415
-
416
- ```ts
417
- optional iphone: string;
418
- ```
419
-
420
- ***
421
-
422
- ### name?
423
-
424
- ```ts
425
- optional name: object;
426
- ```
427
-
428
- ### googleplay?
429
-
430
- ```ts
431
- optional googleplay: string;
432
- ```
433
-
434
- ### ipad?
435
-
436
- ```ts
437
- optional ipad: string;
438
- ```
439
-
440
- ### iphone?
441
-
442
- ```ts
443
- optional iphone: string;
444
- ```
445
-
446
- ***
447
-
448
- ### url?
449
-
450
- ```ts
451
- optional url: object;
452
- ```
453
-
454
- ### googleplay?
455
-
456
- ```ts
457
- optional googleplay: string;
458
- ```
459
-
460
- ### ipad?
461
-
462
- ```ts
463
- optional ipad: string;
464
- ```
465
-
466
- ### iphone?
467
-
468
- ```ts
469
- optional iphone: string;
470
- ```
234
+ | Property | Type |
235
+ | ------ | ------ |
236
+ | <a id="id"></a> `id?` | \{ `googleplay?`: `string`; `ipad?`: `string`; `iphone?`: `string`; \} |
237
+ | `id.googleplay?` | `string` |
238
+ | `id.ipad?` | `string` |
239
+ | `id.iphone?` | `string` |
240
+ | <a id="name"></a> `name?` | \{ `googleplay?`: `string`; `ipad?`: `string`; `iphone?`: `string`; \} |
241
+ | `name.googleplay?` | `string` |
242
+ | `name.ipad?` | `string` |
243
+ | `name.iphone?` | `string` |
244
+ | <a id="url"></a> `url?` | \{ `googleplay?`: `string`; `ipad?`: `string`; `iphone?`: `string`; \} |
245
+ | `url.googleplay?` | `string` |
246
+ | `url.ipad?` | `string` |
247
+ | `url.iphone?` | `string` |
471
248
 
472
249
  ### <a id="TwitterMeta"></a>TwitterMeta
473
250
 
@@ -479,143 +256,22 @@ https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/markup
479
256
 
480
257
  ## Properties
481
258
 
482
- ### app?
483
-
484
- ```ts
485
- optional app: TwitterApp;
486
- ```
487
-
488
- ***
489
-
490
- ### card?
491
-
492
- ```ts
493
- optional card: "summary" | "summary_large_image" | "app" | "player";
494
- ```
495
-
496
- The card type. Used with all cards. Fallback: og:type.
497
- If an og:type, og:title and og:description exist in the markup but
498
- twitter:card is absent, then a summary card may be rendered.
499
-
500
- ***
501
-
502
- ### creator?
503
-
504
- ```ts
505
- optional creator: object;
506
- ```
507
-
508
- ### ?
509
-
510
- ```ts
511
- optional : string;
512
- ```
513
-
514
- The
515
-
516
- #### Username
517
-
518
- of content creator. Used with summary_large_image cards
519
-
520
- ### id?
521
-
522
- ```ts
523
- optional id: string;
524
- ```
525
-
526
- Twitter user ID of content creator. Used with summary,
527
- summary_large_image cards
528
-
529
- ***
530
-
531
- ### description?
532
-
533
- ```ts
534
- optional description: string;
535
- ```
536
-
537
- Description of content (maximum 200 characters). Used with summary,
538
- summary_large_image, player cards. Fallback: og:description.
539
-
540
- ***
541
-
542
- ### image?
543
-
544
- ```ts
545
- optional image: object;
546
- ```
547
-
548
- ### ?
549
-
550
- ```ts
551
- optional : string;
552
- ```
553
-
554
- URL of image to use in the card. Images must be less than 5MB in size.
555
- JPG, PNG, WEBP and GIF formats are supported. Only the first frame of
556
- an animated GIF will be used. SVG is not supported. Used with summary,
557
- summary_large_image, player cards. Fallback: og:image
558
-
559
- ### alt?
560
-
561
- ```ts
562
- optional alt: string;
563
- ```
564
-
565
- A text description of the image conveying the essential nature of
566
- an image to users who are visually impaired. Maximum 420
567
- characters. Used with summary, summary_large_image, player cards
568
-
569
- ***
570
-
571
- ### player?
572
-
573
- ```ts
574
- optional player: TwitterPlayer;
575
- ```
576
-
577
- ***
578
-
579
- ### site?
580
-
581
- ```ts
582
- optional site: object;
583
- ```
584
-
585
- The
586
-
587
- ### ?
588
-
589
- ```ts
590
- optional : string;
591
- ```
592
-
593
- ### id?
594
-
595
- ```ts
596
- optional id: string;
597
- ```
598
-
599
- Same as twitter:site, but the user’s Twitter ID. Either
600
- twitter:site or twitter:site:id is required. Used with
601
- summary, summary_large_image, player cards
602
-
603
- ### Username
604
-
605
- of website. Either twitter:site or twitter:site:id is
606
- required. Used with summary, summary_large_image, app, player
607
- cards
608
-
609
- ***
610
-
611
- ### title?
612
-
613
- ```ts
614
- optional title: string;
615
- ```
616
-
617
- Title of content (max 70 characters). Used with summary,
618
- summary_large_image, player cards. Fallback: og:title.
259
+ | Property | Type | Description |
260
+ | ------ | ------ | ------ |
261
+ | <a id="app"></a> `app?` | [`TwitterApp`](#TwitterApp) | - |
262
+ | <a id="card"></a> `card?` | `"summary"` \| `"summary_large_image"` \| `"app"` \| `"player"` | The card type. Used with all cards. Fallback: og:type. If an og:type, og:title and og:description exist in the markup but twitter:card is absent, then a summary card may be rendered. |
263
+ | <a id="creator"></a> `creator?` | \{ `?`: `string`; `id?`: `string`; \} | - |
264
+ | `creator.?` | `string` | The **Username** of content creator. Used with summary_large_image cards |
265
+ | `creator.id?` | `string` | Twitter user ID of content creator. Used with summary, summary_large_image cards |
266
+ | <a id="description"></a> `description?` | `string` | Description of content (maximum 200 characters). Used with summary, summary_large_image, player cards. Fallback: og:description. |
267
+ | <a id="image"></a> `image?` | \{ `?`: `string`; `alt?`: `string`; \} | - |
268
+ | `image.?` | `string` | URL of image to use in the card. Images must be less than 5MB in size. JPG, PNG, WEBP and GIF formats are supported. Only the first frame of an animated GIF will be used. SVG is not supported. Used with summary, summary_large_image, player cards. Fallback: og:image |
269
+ | `image.alt?` | `string` | A text description of the image conveying the essential nature of an image to users who are visually impaired. Maximum 420 characters. Used with summary, summary_large_image, player cards |
270
+ | <a id="player"></a> `player?` | [`TwitterPlayer`](#TwitterPlayer) | - |
271
+ | <a id="site"></a> `site?` | \{ `?`: `string`; `id?`: `string`; \} | The **Username** of website. Either twitter:site or twitter:site:id is required. Used with summary, summary_large_image, app, player cards |
272
+ | `site.?` | `string` | - |
273
+ | `site.id?` | `string` | Same as twitter:site, but the user’s Twitter ID. Either twitter:site or twitter:site:id is required. Used with summary, summary_large_image, player cards |
274
+ | <a id="title"></a> `title?` | `string` | Title of content (max 70 characters). Used with summary, summary_large_image, player cards. Fallback: og:title. |
619
275
 
620
276
  ### <a id="TwitterPlayer"></a>TwitterPlayer
621
277
 
@@ -627,45 +283,12 @@ https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/player
627
283
 
628
284
  ## Properties
629
285
 
630
- ###
631
-
632
- ```ts
633
- : string;
634
- ```
635
-
636
- HTTPS URL to iFrame player. This must be a HTTPS URL which does not
637
- generate active mixed content warnings in a web browser. The audio or
638
- video player must not require plugins such as Adobe Flash.
639
-
640
- ***
641
-
642
- ### height?
643
-
644
- ```ts
645
- optional height: number;
646
- ```
647
-
648
- Height of iframe in pixels. Used with player card
649
-
650
- ***
651
-
652
- ### stream?
653
-
654
- ```ts
655
- optional stream: string;
656
- ```
657
-
658
- URL to raw video or audio stream. Used with player card
659
-
660
- ***
661
-
662
- ### width?
663
-
664
- ```ts
665
- optional width: number;
666
- ```
667
-
668
- Width of iframe in pixels. Used with player card
286
+ | Property | Type | Description |
287
+ | ------ | ------ | ------ |
288
+ | <a id="_"></a> `` | `string` | HTTPS URL to iFrame player. This must be a HTTPS URL which does not generate active mixed content warnings in a web browser. The audio or video player must not require plugins such as Adobe Flash. |
289
+ | <a id="height"></a> `height?` | `number` | Height of iframe in pixels. Used with player card |
290
+ | <a id="stream"></a> `stream?` | `string` | URL to raw video or audio stream. Used with player card |
291
+ | <a id="width"></a> `width?` | `number` | Width of iframe in pixels. Used with player card |
669
292
 
670
293
  ### type-aliases
671
294
 
@@ -691,7 +314,9 @@ A structured Open Graph property value: a URL string, a structured object, or an
691
314
  ***
692
315
 
693
316
  ```ts
694
- type StringIndexable = object;
317
+ type StringIndexable = {
318
+ [key: string]: any;
319
+ };
695
320
  ```
696
321
 
697
322
  An object with string keys and arbitrary values, used for recursive meta flattening.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/sdk-meta",
3
- "version": "5.0.84",
3
+ "version": "5.0.86",
4
4
  "description": "Base functionality used throughout XYO TypeScript/JavaScript libraries",
5
5
  "keywords": [
6
6
  "meta",
@@ -37,13 +37,13 @@
37
37
  "!**/*.test.*"
38
38
  ],
39
39
  "dependencies": {
40
- "@xylabs/typeof": "~5.0.84",
40
+ "@xylabs/typeof": "~5.0.86",
41
41
  "cheerio": "~1.2.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "~25.4.0",
45
- "@xylabs/ts-scripts-yarn3": "~7.4.13",
46
- "@xylabs/tsconfig": "~7.4.13",
45
+ "@xylabs/ts-scripts-yarn3": "~7.4.16",
46
+ "@xylabs/tsconfig": "~7.4.16",
47
47
  "typescript": "~5.9.3",
48
48
  "vitest": "~4.0.18"
49
49
  },