@fedify/vocab 2.1.17 → 2.1.19
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 +1475 -622
- package/dist/mod.d.cts +33 -0
- package/dist/mod.d.ts +33 -0
- package/dist/mod.js +1475 -622
- package/dist-tests/actor.test.mjs +2 -2
- package/dist-tests/{deno-D1Pq0QRg.mjs → deno-DBX7hUHw.mjs} +2 -2
- package/dist-tests/lookup.test.mjs +2 -2
- package/dist-tests/type.test.mjs +1 -1
- package/dist-tests/{vocab-Dz46WAsF.mjs → vocab-DgKQ7NUh.mjs} +1475 -622
- 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 {
|
|
3
|
+
import { S as vocab_exports, _ as Place, a as Create, c as Follow, d as Link, f as Note, g as Person, i as Collection, m as OrderedCollectionPage, n as Announce, o as CryptographicKey, p as Object$1, s as Endpoints, t as Activity, u as Hashtag, v as PropertyValue, x as Source, y as Question } from "./vocab-DgKQ7NUh.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";
|
|
@@ -160,6 +160,36 @@ test("Object.toJsonLd()", async () => {
|
|
|
160
160
|
}
|
|
161
161
|
});
|
|
162
162
|
});
|
|
163
|
+
test("Note.fromJsonLd() ignores malformed language tags", async () => {
|
|
164
|
+
const note = await Note.fromJsonLd({
|
|
165
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
166
|
+
type: "Note",
|
|
167
|
+
contentMap: {
|
|
168
|
+
invalid_tag: "Hello",
|
|
169
|
+
en: "Hi"
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
deepStrictEqual(note.contents, [new LanguageString("Hi", "en")]);
|
|
173
|
+
deepStrictEqual((await note.toJsonLd()).contentMap, { en: "Hi" });
|
|
174
|
+
});
|
|
175
|
+
test("Note.fromJsonLd() ignores malformed language tags in nested objects", async () => {
|
|
176
|
+
const note = await Note.fromJsonLd({
|
|
177
|
+
"@type": ["https://www.w3.org/ns/activitystreams#Note"],
|
|
178
|
+
"https://www.w3.org/ns/activitystreams#attachment": [{
|
|
179
|
+
"@type": ["http://schema.org#PropertyValue"],
|
|
180
|
+
"https://www.w3.org/ns/activitystreams#name": [{
|
|
181
|
+
"@value": "Malformed",
|
|
182
|
+
"@language": "invalid_tag"
|
|
183
|
+
}, {
|
|
184
|
+
"@value": "Valid",
|
|
185
|
+
"@language": "en"
|
|
186
|
+
}]
|
|
187
|
+
}]
|
|
188
|
+
});
|
|
189
|
+
deepStrictEqual(await Array.fromAsync(note.getAttachments()), [new PropertyValue({ name: new LanguageString("Valid", "en") })]);
|
|
190
|
+
const attachment = (await note.toJsonLd()).attachment;
|
|
191
|
+
deepStrictEqual(attachment.nameMap, { en: "Valid" });
|
|
192
|
+
});
|
|
163
193
|
test("Note.toJsonLd()", async () => {
|
|
164
194
|
const note = new Note({ tags: [new Hashtag({
|
|
165
195
|
name: "#Fedify",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/vocab",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.19",
|
|
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/
|
|
50
|
-
"@fedify/vocab-runtime": "2.1.
|
|
51
|
-
"@fedify/
|
|
49
|
+
"@fedify/vocab-tools": "2.1.19",
|
|
50
|
+
"@fedify/vocab-runtime": "2.1.19",
|
|
51
|
+
"@fedify/webfinger": "2.1.19"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^22.17.0",
|
package/src/vocab.test.ts
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
OrderedCollectionPage,
|
|
33
33
|
Person,
|
|
34
34
|
Place,
|
|
35
|
+
PropertyValue,
|
|
35
36
|
Question,
|
|
36
37
|
Source,
|
|
37
38
|
} from "./vocab.ts";
|
|
@@ -269,6 +270,41 @@ test("Object.toJsonLd()", async () => {
|
|
|
269
270
|
});
|
|
270
271
|
});
|
|
271
272
|
|
|
273
|
+
test("Note.fromJsonLd() ignores malformed language tags", async () => {
|
|
274
|
+
const note = await Note.fromJsonLd({
|
|
275
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
276
|
+
type: "Note",
|
|
277
|
+
contentMap: {
|
|
278
|
+
invalid_tag: "Hello",
|
|
279
|
+
en: "Hi",
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
deepStrictEqual(note.contents, [new LanguageString("Hi", "en")]);
|
|
284
|
+
const jsonLd = await note.toJsonLd() as Record<string, unknown>;
|
|
285
|
+
deepStrictEqual(jsonLd.contentMap, { en: "Hi" });
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
test("Note.fromJsonLd() ignores malformed language tags in nested objects", async () => {
|
|
289
|
+
const note = await Note.fromJsonLd({
|
|
290
|
+
"@type": ["https://www.w3.org/ns/activitystreams#Note"],
|
|
291
|
+
"https://www.w3.org/ns/activitystreams#attachment": [{
|
|
292
|
+
"@type": ["http://schema.org#PropertyValue"],
|
|
293
|
+
"https://www.w3.org/ns/activitystreams#name": [
|
|
294
|
+
{ "@value": "Malformed", "@language": "invalid_tag" },
|
|
295
|
+
{ "@value": "Valid", "@language": "en" },
|
|
296
|
+
],
|
|
297
|
+
}],
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
deepStrictEqual(await Array.fromAsync(note.getAttachments()), [
|
|
301
|
+
new PropertyValue({ name: new LanguageString("Valid", "en") }),
|
|
302
|
+
]);
|
|
303
|
+
const jsonLd = await note.toJsonLd() as Record<string, unknown>;
|
|
304
|
+
const attachment = jsonLd.attachment as Record<string, unknown>;
|
|
305
|
+
deepStrictEqual(attachment.nameMap, { en: "Valid" });
|
|
306
|
+
});
|
|
307
|
+
|
|
272
308
|
test("Note.toJsonLd()", async () => {
|
|
273
309
|
const note = new Note({
|
|
274
310
|
tags: [
|