@fedify/vocab 2.3.1 → 2.3.2
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.
- package/deno.json +1 -1
- package/dist/mod.cjs +1946 -571
- package/dist/mod.d.cts +42 -0
- package/dist/mod.d.ts +42 -0
- package/dist/mod.js +1946 -571
- package/dist-tests/{actor-CNzah615.mjs → actor-C1JXaHGB.mjs} +2 -2
- package/dist-tests/actor.test.mjs +2 -2
- package/dist-tests/lookup.test.mjs +2 -2
- package/dist-tests/type.test.mjs +1 -1
- package/dist-tests/{vocab-Dc1CSo93.mjs → vocab-qOXUdrGm.mjs} +1946 -571
- package/dist-tests/vocab.test.mjs +31 -1
- package/package.json +4 -4
- package/src/vocab.test.ts +36 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { A as
|
|
3
|
+
import { A as Question, C as Offer, D as Place, E as Person, F as Source, I as Tombstone, M as QuoteRequest, N as Reject, O as PropertyValue, S as Object$1, _ as InteractionPolicy, b as Measure, c as Create, d as Document, f as Endpoints, g as Intent, h as Hashtag, i as Announce, j as QuoteAuthorization, k as Proposal, l as CryptographicKey, n as Activity, o as Collection, p as Follow, r as Agreement, s as Commitment, t as Accept, u as Delete, v as InteractionRule, w as OrderedCollectionPage, x as Note, y as Link, z as vocab_exports } from "./vocab-qOXUdrGm.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.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"homepage": "https://fedify.dev/",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"es-toolkit": "1.46.1",
|
|
47
47
|
"jsonld": "^9.0.0",
|
|
48
48
|
"pkijs": "^3.3.3",
|
|
49
|
-
"@fedify/vocab-tools": "2.3.
|
|
50
|
-
"@fedify/webfinger": "2.3.
|
|
51
|
-
"@fedify/vocab-runtime": "2.3.
|
|
49
|
+
"@fedify/vocab-tools": "2.3.2",
|
|
50
|
+
"@fedify/webfinger": "2.3.2",
|
|
51
|
+
"@fedify/vocab-runtime": "2.3.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^22.17.0",
|
package/src/vocab.test.ts
CHANGED
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
OrderedCollectionPage,
|
|
48
48
|
Person,
|
|
49
49
|
Place,
|
|
50
|
+
PropertyValue,
|
|
50
51
|
Proposal,
|
|
51
52
|
Question,
|
|
52
53
|
QuoteAuthorization,
|
|
@@ -368,6 +369,41 @@ test("Object.toJsonLd()", async () => {
|
|
|
368
369
|
});
|
|
369
370
|
});
|
|
370
371
|
|
|
372
|
+
test("Note.fromJsonLd() ignores malformed language tags", async () => {
|
|
373
|
+
const note = await Note.fromJsonLd({
|
|
374
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
375
|
+
type: "Note",
|
|
376
|
+
contentMap: {
|
|
377
|
+
invalid_tag: "Hello",
|
|
378
|
+
en: "Hi",
|
|
379
|
+
},
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
deepStrictEqual(note.contents, [new LanguageString("Hi", "en")]);
|
|
383
|
+
const jsonLd = await note.toJsonLd() as Record<string, unknown>;
|
|
384
|
+
deepStrictEqual(jsonLd.contentMap, { en: "Hi" });
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
test("Note.fromJsonLd() ignores malformed language tags in nested objects", async () => {
|
|
388
|
+
const note = await Note.fromJsonLd({
|
|
389
|
+
"@type": ["https://www.w3.org/ns/activitystreams#Note"],
|
|
390
|
+
"https://www.w3.org/ns/activitystreams#attachment": [{
|
|
391
|
+
"@type": ["http://schema.org#PropertyValue"],
|
|
392
|
+
"https://www.w3.org/ns/activitystreams#name": [
|
|
393
|
+
{ "@value": "Malformed", "@language": "invalid_tag" },
|
|
394
|
+
{ "@value": "Valid", "@language": "en" },
|
|
395
|
+
],
|
|
396
|
+
}],
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
deepStrictEqual(await Array.fromAsync(note.getAttachments()), [
|
|
400
|
+
new PropertyValue({ name: new LanguageString("Valid", "en") }),
|
|
401
|
+
]);
|
|
402
|
+
const jsonLd = await note.toJsonLd() as Record<string, unknown>;
|
|
403
|
+
const attachment = jsonLd.attachment as Record<string, unknown>;
|
|
404
|
+
deepStrictEqual(attachment.nameMap, { en: "Valid" });
|
|
405
|
+
});
|
|
406
|
+
|
|
371
407
|
test("Note.toJsonLd()", async () => {
|
|
372
408
|
const note = new Note({
|
|
373
409
|
tags: [
|