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