@fedify/vocab 2.2.6 → 2.2.8

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,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  globalThis.addEventListener = () => {};
3
- import { C as QuoteRequest, E as Tombstone, S as QuoteAuthorization, T as Source, _ as OrderedCollectionPage, a as Create, b as Place, c as Endpoints, d as Hashtag, f as InteractionPolicy, g as Object$1, h as Note, i as Collection, k as vocab_exports, l as Follow, m as Link, n as Announce, o as CryptographicKey, p as InteractionRule, s as Delete, t as Activity, x as Question, y as Person } from "./vocab-BJL2RQRV.mjs";
3
+ import { A as vocab_exports, C as QuoteAuthorization, D as Tombstone, E as Source, S as Question, _ as OrderedCollectionPage, a as Create, b as Place, c as Endpoints, d as Hashtag, f as InteractionPolicy, g as Object$1, h as Note, i as Collection, l as Follow, m as Link, n as Announce, o as CryptographicKey, p as InteractionRule, s as Delete, t as Activity, w as QuoteRequest, x as PropertyValue, y as Person } from "./vocab-KiMp-Gly.mjs";
4
4
  import { t as assertInstanceOf } from "./utils-CE8Dk5hm.mjs";
5
5
  import { mockDocumentLoader, test } from "@fedify/fixture";
6
6
  import { deepStrictEqual, notDeepStrictEqual, ok, rejects, throws } from "node:assert/strict";
@@ -237,6 +237,36 @@ test("Object.toJsonLd()", async () => {
237
237
  }
238
238
  });
239
239
  });
240
+ test("Note.fromJsonLd() ignores malformed language tags", async () => {
241
+ const note = await Note.fromJsonLd({
242
+ "@context": "https://www.w3.org/ns/activitystreams",
243
+ type: "Note",
244
+ contentMap: {
245
+ invalid_tag: "Hello",
246
+ en: "Hi"
247
+ }
248
+ });
249
+ deepStrictEqual(note.contents, [new LanguageString("Hi", "en")]);
250
+ deepStrictEqual((await note.toJsonLd()).contentMap, { en: "Hi" });
251
+ });
252
+ test("Note.fromJsonLd() ignores malformed language tags in nested objects", async () => {
253
+ const note = await Note.fromJsonLd({
254
+ "@type": ["https://www.w3.org/ns/activitystreams#Note"],
255
+ "https://www.w3.org/ns/activitystreams#attachment": [{
256
+ "@type": ["http://schema.org#PropertyValue"],
257
+ "https://www.w3.org/ns/activitystreams#name": [{
258
+ "@value": "Malformed",
259
+ "@language": "invalid_tag"
260
+ }, {
261
+ "@value": "Valid",
262
+ "@language": "en"
263
+ }]
264
+ }]
265
+ });
266
+ deepStrictEqual(await Array.fromAsync(note.getAttachments()), [new PropertyValue({ name: new LanguageString("Valid", "en") })]);
267
+ const attachment = (await note.toJsonLd()).attachment;
268
+ deepStrictEqual(attachment.nameMap, { en: "Valid" });
269
+ });
240
270
  test("Note.toJsonLd()", async () => {
241
271
  const note = new Note({ tags: [new Hashtag({
242
272
  name: "#Fedify",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "homepage": "https://fedify.dev/",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,9 +46,9 @@
46
46
  "es-toolkit": "1.43.0",
47
47
  "jsonld": "^9.0.0",
48
48
  "pkijs": "^3.3.3",
49
- "@fedify/webfinger": "2.2.6",
50
- "@fedify/vocab-runtime": "2.2.6",
51
- "@fedify/vocab-tools": "2.2.6"
49
+ "@fedify/vocab-tools": "2.2.8",
50
+ "@fedify/webfinger": "2.2.8",
51
+ "@fedify/vocab-runtime": "2.2.8"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "^22.17.0",
package/src/vocab.test.ts CHANGED
@@ -40,6 +40,7 @@ import {
40
40
  OrderedCollectionPage,
41
41
  Person,
42
42
  Place,
43
+ PropertyValue,
43
44
  Question,
44
45
  QuoteAuthorization,
45
46
  QuoteRequest,
@@ -359,6 +360,41 @@ test("Object.toJsonLd()", async () => {
359
360
  });
360
361
  });
361
362
 
363
+ test("Note.fromJsonLd() ignores malformed language tags", async () => {
364
+ const note = await Note.fromJsonLd({
365
+ "@context": "https://www.w3.org/ns/activitystreams",
366
+ type: "Note",
367
+ contentMap: {
368
+ invalid_tag: "Hello",
369
+ en: "Hi",
370
+ },
371
+ });
372
+
373
+ deepStrictEqual(note.contents, [new LanguageString("Hi", "en")]);
374
+ const jsonLd = await note.toJsonLd() as Record<string, unknown>;
375
+ deepStrictEqual(jsonLd.contentMap, { en: "Hi" });
376
+ });
377
+
378
+ test("Note.fromJsonLd() ignores malformed language tags in nested objects", async () => {
379
+ const note = await Note.fromJsonLd({
380
+ "@type": ["https://www.w3.org/ns/activitystreams#Note"],
381
+ "https://www.w3.org/ns/activitystreams#attachment": [{
382
+ "@type": ["http://schema.org#PropertyValue"],
383
+ "https://www.w3.org/ns/activitystreams#name": [
384
+ { "@value": "Malformed", "@language": "invalid_tag" },
385
+ { "@value": "Valid", "@language": "en" },
386
+ ],
387
+ }],
388
+ });
389
+
390
+ deepStrictEqual(await Array.fromAsync(note.getAttachments()), [
391
+ new PropertyValue({ name: new LanguageString("Valid", "en") }),
392
+ ]);
393
+ const jsonLd = await note.toJsonLd() as Record<string, unknown>;
394
+ const attachment = jsonLd.attachment as Record<string, unknown>;
395
+ deepStrictEqual(attachment.nameMap, { en: "Valid" });
396
+ });
397
+
362
398
  test("Note.toJsonLd()", async () => {
363
399
  const note = new Note({
364
400
  tags: [