@fedify/vocab 2.2.0-dev.731 → 2.2.0-dev.766
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 +3371 -472
- package/dist/mod.d.cts +618 -6
- package/dist/mod.d.ts +618 -6
- package/dist/mod.js +3368 -473
- package/dist-tests/actor.test.mjs +2 -2
- package/dist-tests/announce.yaml +8 -0
- package/dist-tests/article.yaml +28 -0
- package/dist-tests/chatmessage.yaml +28 -0
- package/dist-tests/collection.yaml +8 -0
- package/dist-tests/collectionpage.yaml +8 -0
- package/dist-tests/create.yaml +8 -0
- package/dist-tests/delete.yaml +8 -0
- package/dist-tests/{deno-D3oW1uY5.mjs → deno-_GjGa9o1.mjs} +2 -2
- package/dist-tests/interactionpolicy.yaml +16 -2
- package/dist-tests/lookup.test.mjs +2 -2
- package/dist-tests/note.yaml +28 -0
- package/dist-tests/object.yaml +3 -3
- package/dist-tests/orderedcollection.yaml +8 -0
- package/dist-tests/orderedcollectionpage.yaml +8 -0
- package/dist-tests/question.yaml +28 -0
- package/dist-tests/quoteauthorization.yaml +39 -0
- package/dist-tests/quoterequest.yaml +47 -0
- package/dist-tests/tombstone.yaml +10 -0
- package/dist-tests/type.test.mjs +10 -1
- package/dist-tests/update.yaml +8 -0
- package/dist-tests/{vocab-CGZuHaxe.mjs → vocab-DKp-OcRQ.mjs} +3372 -473
- package/dist-tests/vocab.test.mjs +356 -42
- package/package.json +4 -4
- package/src/__snapshots__/vocab.test.ts.snap +327 -15
- package/src/announce.yaml +8 -0
- package/src/article.yaml +28 -0
- package/src/chatmessage.yaml +28 -0
- package/src/collection.yaml +8 -0
- package/src/collectionpage.yaml +8 -0
- package/src/create.yaml +8 -0
- package/src/delete.yaml +8 -0
- package/src/interactionpolicy.yaml +16 -2
- package/src/note.yaml +28 -0
- package/src/object.yaml +3 -3
- package/src/orderedcollection.yaml +8 -0
- package/src/orderedcollectionpage.yaml +8 -0
- package/src/question.yaml +28 -0
- package/src/quoteauthorization.yaml +39 -0
- package/src/quoterequest.yaml +47 -0
- package/src/tombstone.yaml +10 -0
- package/src/type.test.ts +17 -1
- package/src/update.yaml +8 -0
- package/src/vocab.test.ts +498 -40
|
@@ -1,13 +1,90 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import { _ as
|
|
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-DKp-OcRQ.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";
|
|
7
|
+
import { configure, reset } from "@logtape/logtape";
|
|
7
8
|
import { LanguageString, decodeMultibase, parseDecimal } from "@fedify/vocab-runtime";
|
|
8
9
|
import { pascalCase } from "es-toolkit";
|
|
9
10
|
import { areAllScalarTypes, loadSchemaFiles } from "@fedify/vocab-tools";
|
|
10
11
|
//#region src/vocab.test.ts
|
|
12
|
+
const NOTE_QUOTE_CONTEXT = [
|
|
13
|
+
"https://www.w3.org/ns/activitystreams",
|
|
14
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
15
|
+
"https://gotosocial.org/ns",
|
|
16
|
+
{
|
|
17
|
+
Emoji: "toot:Emoji",
|
|
18
|
+
Hashtag: "as:Hashtag",
|
|
19
|
+
_misskey_quote: "misskey:_misskey_quote",
|
|
20
|
+
QuoteAuthorization: "https://w3id.org/fep/044f#QuoteAuthorization",
|
|
21
|
+
fedibird: "http://fedibird.com/ns#",
|
|
22
|
+
misskey: "https://misskey-hub.net/ns#",
|
|
23
|
+
quote: {
|
|
24
|
+
"@id": "https://w3id.org/fep/044f#quote",
|
|
25
|
+
"@type": "@id"
|
|
26
|
+
},
|
|
27
|
+
quoteAuthorization: {
|
|
28
|
+
"@id": "https://w3id.org/fep/044f#quoteAuthorization",
|
|
29
|
+
"@type": "@id"
|
|
30
|
+
},
|
|
31
|
+
quoteUri: "fedibird:quoteUri",
|
|
32
|
+
quoteUrl: "as:quoteUrl",
|
|
33
|
+
sensitive: "as:sensitive",
|
|
34
|
+
toot: "http://joinmastodon.org/ns#",
|
|
35
|
+
emojiReactions: {
|
|
36
|
+
"@id": "fedibird:emojiReactions",
|
|
37
|
+
"@type": "@id"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
const QUOTE_REQUEST_CONTEXT = [
|
|
42
|
+
"https://w3id.org/identity/v1",
|
|
43
|
+
"https://www.w3.org/ns/activitystreams",
|
|
44
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
45
|
+
"https://gotosocial.org/ns",
|
|
46
|
+
{
|
|
47
|
+
...NOTE_QUOTE_CONTEXT[3],
|
|
48
|
+
ChatMessage: "http://litepub.social/ns#ChatMessage",
|
|
49
|
+
QuoteRequest: "https://w3id.org/fep/044f#QuoteRequest",
|
|
50
|
+
votersCount: {
|
|
51
|
+
"@id": "toot:votersCount",
|
|
52
|
+
"@type": "http://www.w3.org/2001/XMLSchema#nonNegativeInteger"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
const DELETE_QUOTE_REQUEST_CONTEXT = [
|
|
57
|
+
"https://w3id.org/identity/v1",
|
|
58
|
+
"https://www.w3.org/ns/activitystreams",
|
|
59
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
60
|
+
"https://gotosocial.org/ns",
|
|
61
|
+
{
|
|
62
|
+
ChatMessage: "http://litepub.social/ns#ChatMessage",
|
|
63
|
+
Emoji: "toot:Emoji",
|
|
64
|
+
Hashtag: "as:Hashtag",
|
|
65
|
+
QuoteAuthorization: "https://w3id.org/fep/044f#QuoteAuthorization",
|
|
66
|
+
QuoteRequest: "https://w3id.org/fep/044f#QuoteRequest",
|
|
67
|
+
_misskey_quote: "misskey:_misskey_quote",
|
|
68
|
+
fedibird: "http://fedibird.com/ns#",
|
|
69
|
+
misskey: "https://misskey-hub.net/ns#",
|
|
70
|
+
quote: {
|
|
71
|
+
"@id": "https://w3id.org/fep/044f#quote",
|
|
72
|
+
"@type": "@id"
|
|
73
|
+
},
|
|
74
|
+
quoteAuthorization: {
|
|
75
|
+
"@id": "https://w3id.org/fep/044f#quoteAuthorization",
|
|
76
|
+
"@type": "@id"
|
|
77
|
+
},
|
|
78
|
+
quoteUri: "fedibird:quoteUri",
|
|
79
|
+
quoteUrl: "as:quoteUrl",
|
|
80
|
+
sensitive: "as:sensitive",
|
|
81
|
+
toot: "http://joinmastodon.org/ns#",
|
|
82
|
+
votersCount: {
|
|
83
|
+
"@id": "toot:votersCount",
|
|
84
|
+
"@type": "http://www.w3.org/2001/XMLSchema#nonNegativeInteger"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
];
|
|
11
88
|
test("new Object()", () => {
|
|
12
89
|
const obj = new Object$1({
|
|
13
90
|
name: "Test",
|
|
@@ -150,26 +227,7 @@ test("Note.toJsonLd()", async () => {
|
|
|
150
227
|
href: new URL("https://fedify.dev/")
|
|
151
228
|
})] });
|
|
152
229
|
deepStrictEqual(await note.toJsonLd({ contextLoader: mockDocumentLoader }), {
|
|
153
|
-
"@context":
|
|
154
|
-
"https://www.w3.org/ns/activitystreams",
|
|
155
|
-
"https://w3id.org/security/data-integrity/v1",
|
|
156
|
-
"https://gotosocial.org/ns",
|
|
157
|
-
{
|
|
158
|
-
Emoji: "toot:Emoji",
|
|
159
|
-
Hashtag: "as:Hashtag",
|
|
160
|
-
_misskey_quote: "misskey:_misskey_quote",
|
|
161
|
-
fedibird: "http://fedibird.com/ns#",
|
|
162
|
-
misskey: "https://misskey-hub.net/ns#",
|
|
163
|
-
quoteUri: "fedibird:quoteUri",
|
|
164
|
-
quoteUrl: "as:quoteUrl",
|
|
165
|
-
sensitive: "as:sensitive",
|
|
166
|
-
toot: "http://joinmastodon.org/ns#",
|
|
167
|
-
emojiReactions: {
|
|
168
|
-
"@id": "fedibird:emojiReactions",
|
|
169
|
-
"@type": "@id"
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
],
|
|
230
|
+
"@context": NOTE_QUOTE_CONTEXT,
|
|
173
231
|
tag: {
|
|
174
232
|
"@context": ["https://www.w3.org/ns/activitystreams", { Hashtag: "as:Hashtag" }],
|
|
175
233
|
href: "https://fedify.dev/",
|
|
@@ -427,6 +485,96 @@ test("Person.toJsonLd()", async () => {
|
|
|
427
485
|
type: "Person"
|
|
428
486
|
});
|
|
429
487
|
});
|
|
488
|
+
test("Tombstone.toJsonLd() serializes formerType", async () => {
|
|
489
|
+
const deleted = Temporal.Instant.from("2024-01-15T00:00:00Z");
|
|
490
|
+
const tombstone = new Tombstone({
|
|
491
|
+
id: new URL("https://example.com/users/alice"),
|
|
492
|
+
formerType: Person,
|
|
493
|
+
deleted
|
|
494
|
+
});
|
|
495
|
+
deepStrictEqual(await tombstone.toJsonLd({ contextLoader: mockDocumentLoader }), {
|
|
496
|
+
"@context": [
|
|
497
|
+
"https://www.w3.org/ns/activitystreams",
|
|
498
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
499
|
+
"https://gotosocial.org/ns"
|
|
500
|
+
],
|
|
501
|
+
id: "https://example.com/users/alice",
|
|
502
|
+
type: "Tombstone",
|
|
503
|
+
formerType: "as:Person",
|
|
504
|
+
deleted: "2024-01-15T00:00:00Z"
|
|
505
|
+
});
|
|
506
|
+
deepStrictEqual(await tombstone.toJsonLd({
|
|
507
|
+
format: "expand",
|
|
508
|
+
contextLoader: mockDocumentLoader
|
|
509
|
+
}), [{
|
|
510
|
+
"@id": "https://example.com/users/alice",
|
|
511
|
+
"@type": ["https://www.w3.org/ns/activitystreams#Tombstone"],
|
|
512
|
+
"https://www.w3.org/ns/activitystreams#formerType": [{ "@id": "https://www.w3.org/ns/activitystreams#Person" }],
|
|
513
|
+
"https://www.w3.org/ns/activitystreams#deleted": [{
|
|
514
|
+
"@type": "http://www.w3.org/2001/XMLSchema#dateTime",
|
|
515
|
+
"@value": "2024-01-15T00:00:00Z"
|
|
516
|
+
}]
|
|
517
|
+
}]);
|
|
518
|
+
});
|
|
519
|
+
test("Tombstone.fromJsonLd() restores formerType", async () => {
|
|
520
|
+
const tombstone = await Tombstone.fromJsonLd({
|
|
521
|
+
"@context": [
|
|
522
|
+
"https://www.w3.org/ns/activitystreams",
|
|
523
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
524
|
+
"https://gotosocial.org/ns"
|
|
525
|
+
],
|
|
526
|
+
id: "https://example.com/users/alice",
|
|
527
|
+
type: "Tombstone",
|
|
528
|
+
formerType: "as:Person",
|
|
529
|
+
deleted: "2024-01-15T00:00:00Z"
|
|
530
|
+
}, { contextLoader: mockDocumentLoader });
|
|
531
|
+
deepStrictEqual(tombstone.formerType, Person);
|
|
532
|
+
deepStrictEqual(tombstone.formerTypes, [Person]);
|
|
533
|
+
deepStrictEqual(tombstone.deleted, Temporal.Instant.from("2024-01-15T00:00:00Z"));
|
|
534
|
+
});
|
|
535
|
+
test("Tombstone.fromJsonLd() ignores unknown formerType values", async () => {
|
|
536
|
+
const records = [];
|
|
537
|
+
await reset();
|
|
538
|
+
try {
|
|
539
|
+
await configure({
|
|
540
|
+
sinks: { buffer(record) {
|
|
541
|
+
records.push(record);
|
|
542
|
+
} },
|
|
543
|
+
filters: {},
|
|
544
|
+
loggers: [{
|
|
545
|
+
category: [],
|
|
546
|
+
sinks: ["buffer"]
|
|
547
|
+
}]
|
|
548
|
+
});
|
|
549
|
+
const tombstone = await Tombstone.fromJsonLd({
|
|
550
|
+
"@id": "https://example.com/users/alice",
|
|
551
|
+
"@type": ["https://www.w3.org/ns/activitystreams#Tombstone"],
|
|
552
|
+
"https://www.w3.org/ns/activitystreams#formerType": [{ "@id": "https://example.com/ns#Widget" }],
|
|
553
|
+
"https://www.w3.org/ns/activitystreams#deleted": [{
|
|
554
|
+
"@type": "http://www.w3.org/2001/XMLSchema#dateTime",
|
|
555
|
+
"@value": "2024-01-15T00:00:00Z"
|
|
556
|
+
}]
|
|
557
|
+
});
|
|
558
|
+
deepStrictEqual(tombstone.formerTypes, []);
|
|
559
|
+
deepStrictEqual(tombstone.deleted, Temporal.Instant.from("2024-01-15T00:00:00Z"));
|
|
560
|
+
deepStrictEqual(records.some((record) => record.rawMessage === "Ignoring unknown vocabulary entity type reference: {typeId}" && record.properties.typeId === "https://example.com/ns#Widget"), true);
|
|
561
|
+
} finally {
|
|
562
|
+
await reset();
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
test("Tombstone.fromJsonLd() ignores malformed formerType values", async () => {
|
|
566
|
+
const tombstone = await Tombstone.fromJsonLd({
|
|
567
|
+
"@id": "https://example.com/users/alice",
|
|
568
|
+
"@type": ["https://www.w3.org/ns/activitystreams#Tombstone"],
|
|
569
|
+
"https://www.w3.org/ns/activitystreams#formerType": [{ "@value": "Widget" }],
|
|
570
|
+
"https://www.w3.org/ns/activitystreams#deleted": [{
|
|
571
|
+
"@type": "http://www.w3.org/2001/XMLSchema#dateTime",
|
|
572
|
+
"@value": "2024-01-15T00:00:00Z"
|
|
573
|
+
}]
|
|
574
|
+
});
|
|
575
|
+
deepStrictEqual(tombstone.formerTypes, []);
|
|
576
|
+
deepStrictEqual(tombstone.deleted, Temporal.Instant.from("2024-01-15T00:00:00Z"));
|
|
577
|
+
});
|
|
430
578
|
test("Endpoints.toJsonLd() omits type", async () => {
|
|
431
579
|
const ep = new Endpoints({ sharedInbox: new URL("https://example.com/inbox") });
|
|
432
580
|
const compact = await ep.toJsonLd();
|
|
@@ -675,26 +823,7 @@ test("Collection.fromJsonLd()", async () => {
|
|
|
675
823
|
test("Note.quoteUrl", async () => {
|
|
676
824
|
const note = new Note({ quoteUrl: new URL("https://example.com/object") });
|
|
677
825
|
const expected = {
|
|
678
|
-
"@context":
|
|
679
|
-
"https://www.w3.org/ns/activitystreams",
|
|
680
|
-
"https://w3id.org/security/data-integrity/v1",
|
|
681
|
-
"https://gotosocial.org/ns",
|
|
682
|
-
{
|
|
683
|
-
Emoji: "toot:Emoji",
|
|
684
|
-
Hashtag: "as:Hashtag",
|
|
685
|
-
_misskey_quote: "misskey:_misskey_quote",
|
|
686
|
-
fedibird: "http://fedibird.com/ns#",
|
|
687
|
-
misskey: "https://misskey-hub.net/ns#",
|
|
688
|
-
quoteUri: "fedibird:quoteUri",
|
|
689
|
-
quoteUrl: "as:quoteUrl",
|
|
690
|
-
sensitive: "as:sensitive",
|
|
691
|
-
toot: "http://joinmastodon.org/ns#",
|
|
692
|
-
emojiReactions: {
|
|
693
|
-
"@id": "fedibird:emojiReactions",
|
|
694
|
-
"@type": "@id"
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
],
|
|
826
|
+
"@context": NOTE_QUOTE_CONTEXT,
|
|
698
827
|
_misskey_quote: "https://example.com/object",
|
|
699
828
|
quoteUri: "https://example.com/object",
|
|
700
829
|
quoteUrl: "https://example.com/object",
|
|
@@ -721,6 +850,190 @@ test("Note.quoteUrl", async () => {
|
|
|
721
850
|
delete jsonLd._misskey_quote;
|
|
722
851
|
deepStrictEqual((await Note.fromJsonLd(jsonLd)).quoteUrl, new URL("https://example.com/object3"));
|
|
723
852
|
});
|
|
853
|
+
test("Note.quote", async () => {
|
|
854
|
+
const note = new Note({ quote: new URL("https://example.com/object") });
|
|
855
|
+
const expected = {
|
|
856
|
+
"@context": NOTE_QUOTE_CONTEXT,
|
|
857
|
+
quote: "https://example.com/object",
|
|
858
|
+
type: "Note"
|
|
859
|
+
};
|
|
860
|
+
deepStrictEqual(await note.toJsonLd(), expected);
|
|
861
|
+
deepStrictEqual(await note.toJsonLd({ format: "compact" }), expected);
|
|
862
|
+
deepStrictEqual((await Note.fromJsonLd({
|
|
863
|
+
"@context": ["https://www.w3.org/ns/activitystreams", { quote: {
|
|
864
|
+
"@id": "https://w3id.org/fep/044f#quote",
|
|
865
|
+
"@type": "@id"
|
|
866
|
+
} }],
|
|
867
|
+
type: "Note",
|
|
868
|
+
quote: "https://example.com/object"
|
|
869
|
+
})).quoteId, new URL("https://example.com/object"));
|
|
870
|
+
});
|
|
871
|
+
test("Note.quoteAuthorization", async () => {
|
|
872
|
+
const note = new Note({ quoteAuthorization: new URL("https://example.com/authorizations/1") });
|
|
873
|
+
const expected = {
|
|
874
|
+
"@context": NOTE_QUOTE_CONTEXT,
|
|
875
|
+
quoteAuthorization: "https://example.com/authorizations/1",
|
|
876
|
+
type: "Note"
|
|
877
|
+
};
|
|
878
|
+
deepStrictEqual(await note.toJsonLd(), expected);
|
|
879
|
+
deepStrictEqual(await note.toJsonLd({ format: "compact" }), expected);
|
|
880
|
+
deepStrictEqual((await Note.fromJsonLd({
|
|
881
|
+
"@context": ["https://www.w3.org/ns/activitystreams", {
|
|
882
|
+
QuoteAuthorization: "https://w3id.org/fep/044f#QuoteAuthorization",
|
|
883
|
+
quoteAuthorization: {
|
|
884
|
+
"@id": "https://w3id.org/fep/044f#quoteAuthorization",
|
|
885
|
+
"@type": "@id"
|
|
886
|
+
}
|
|
887
|
+
}],
|
|
888
|
+
type: "Note",
|
|
889
|
+
quoteAuthorization: "https://example.com/authorizations/1"
|
|
890
|
+
})).quoteAuthorizationId, new URL("https://example.com/authorizations/1"));
|
|
891
|
+
deepStrictEqual((await Note.fromJsonLd({
|
|
892
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://gotosocial.org/ns"],
|
|
893
|
+
type: "Note",
|
|
894
|
+
quoteAuthorization: "https://example.com/authorizations/2"
|
|
895
|
+
}, {
|
|
896
|
+
documentLoader: mockDocumentLoader,
|
|
897
|
+
contextLoader: mockDocumentLoader
|
|
898
|
+
})).quoteAuthorizationId, new URL("https://example.com/authorizations/2"));
|
|
899
|
+
});
|
|
900
|
+
test("InteractionPolicy.canQuote", async () => {
|
|
901
|
+
const note = new Note({ interactionPolicy: new InteractionPolicy({ canQuote: new InteractionRule({ automaticApproval: new URL("https://www.w3.org/ns/activitystreams#Public") }) }) });
|
|
902
|
+
const expected = {
|
|
903
|
+
"@context": NOTE_QUOTE_CONTEXT,
|
|
904
|
+
interactionPolicy: { canQuote: { automaticApproval: "as:Public" } },
|
|
905
|
+
type: "Note"
|
|
906
|
+
};
|
|
907
|
+
deepStrictEqual(await note.toJsonLd({ contextLoader: mockDocumentLoader }), expected);
|
|
908
|
+
deepStrictEqual(await (await Note.fromJsonLd(expected, {
|
|
909
|
+
documentLoader: mockDocumentLoader,
|
|
910
|
+
contextLoader: mockDocumentLoader
|
|
911
|
+
})).toJsonLd({ contextLoader: mockDocumentLoader }), expected);
|
|
912
|
+
});
|
|
913
|
+
test("QuoteAuthorization.fromJsonLd()", async () => {
|
|
914
|
+
const jsonLd = {
|
|
915
|
+
"@context": [
|
|
916
|
+
"https://www.w3.org/ns/activitystreams",
|
|
917
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
918
|
+
"https://gotosocial.org/ns",
|
|
919
|
+
{ QuoteAuthorization: "https://w3id.org/fep/044f#QuoteAuthorization" }
|
|
920
|
+
],
|
|
921
|
+
type: "QuoteAuthorization",
|
|
922
|
+
id: "https://example.com/users/alice/stamps/1",
|
|
923
|
+
attributedTo: "https://example.com/users/alice",
|
|
924
|
+
interactingObject: "https://example.com/users/bob/statuses/1",
|
|
925
|
+
interactionTarget: "https://example.com/users/alice/statuses/1"
|
|
926
|
+
};
|
|
927
|
+
const authorization = await QuoteAuthorization.fromJsonLd(jsonLd, {
|
|
928
|
+
documentLoader: mockDocumentLoader,
|
|
929
|
+
contextLoader: mockDocumentLoader
|
|
930
|
+
});
|
|
931
|
+
assertInstanceOf(authorization, QuoteAuthorization);
|
|
932
|
+
deepStrictEqual(await authorization.toJsonLd({ contextLoader: mockDocumentLoader }), jsonLd);
|
|
933
|
+
const loadedFromGoToSocialContext = await QuoteAuthorization.fromJsonLd({
|
|
934
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://gotosocial.org/ns"],
|
|
935
|
+
type: "QuoteAuthorization",
|
|
936
|
+
id: "https://example.com/users/alice/stamps/2",
|
|
937
|
+
attributedTo: "https://example.com/users/alice",
|
|
938
|
+
interactingObject: "https://example.com/users/bob/statuses/2",
|
|
939
|
+
interactionTarget: "https://example.com/users/alice/statuses/2"
|
|
940
|
+
}, {
|
|
941
|
+
documentLoader: mockDocumentLoader,
|
|
942
|
+
contextLoader: mockDocumentLoader
|
|
943
|
+
});
|
|
944
|
+
assertInstanceOf(loadedFromGoToSocialContext, QuoteAuthorization);
|
|
945
|
+
deepStrictEqual(loadedFromGoToSocialContext.id, new URL("https://example.com/users/alice/stamps/2"));
|
|
946
|
+
});
|
|
947
|
+
test("QuoteRequest.toJsonLd()", async () => {
|
|
948
|
+
const request = new QuoteRequest({
|
|
949
|
+
object: new URL("https://example.com/users/alice/statuses/1"),
|
|
950
|
+
instrument: new Note({
|
|
951
|
+
id: new URL("https://example.com/users/bob/statuses/1"),
|
|
952
|
+
content: "I am quoting alice's post",
|
|
953
|
+
quote: new URL("https://example.com/users/alice/statuses/1")
|
|
954
|
+
})
|
|
955
|
+
});
|
|
956
|
+
const expected = {
|
|
957
|
+
"@context": QUOTE_REQUEST_CONTEXT,
|
|
958
|
+
type: "QuoteRequest",
|
|
959
|
+
object: "https://example.com/users/alice/statuses/1",
|
|
960
|
+
instrument: {
|
|
961
|
+
type: "Note",
|
|
962
|
+
id: "https://example.com/users/bob/statuses/1",
|
|
963
|
+
content: "I am quoting alice's post",
|
|
964
|
+
quote: "https://example.com/users/alice/statuses/1"
|
|
965
|
+
}
|
|
966
|
+
};
|
|
967
|
+
deepStrictEqual(await request.toJsonLd({ contextLoader: mockDocumentLoader }), expected);
|
|
968
|
+
const loaded = await QuoteRequest.fromJsonLd(expected, {
|
|
969
|
+
documentLoader: mockDocumentLoader,
|
|
970
|
+
contextLoader: mockDocumentLoader
|
|
971
|
+
});
|
|
972
|
+
assertInstanceOf(loaded, QuoteRequest);
|
|
973
|
+
deepStrictEqual(await loaded.toJsonLd({ contextLoader: mockDocumentLoader }), expected);
|
|
974
|
+
const loadedFromGoToSocialContext = await QuoteRequest.fromJsonLd({
|
|
975
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://gotosocial.org/ns"],
|
|
976
|
+
type: "QuoteRequest",
|
|
977
|
+
object: "https://example.com/users/alice/statuses/3"
|
|
978
|
+
}, {
|
|
979
|
+
documentLoader: mockDocumentLoader,
|
|
980
|
+
contextLoader: mockDocumentLoader
|
|
981
|
+
});
|
|
982
|
+
assertInstanceOf(loadedFromGoToSocialContext, QuoteRequest);
|
|
983
|
+
deepStrictEqual(loadedFromGoToSocialContext.objectId, new URL("https://example.com/users/alice/statuses/3"));
|
|
984
|
+
});
|
|
985
|
+
test("Collection.toJsonLd() compacts embedded QuoteRequest", async () => {
|
|
986
|
+
deepStrictEqual(await new Collection({ items: [new QuoteRequest({ object: new URL("https://example.com/users/alice/statuses/1") })] }).toJsonLd({ contextLoader: mockDocumentLoader }), {
|
|
987
|
+
"@context": [
|
|
988
|
+
"https://www.w3.org/ns/activitystreams",
|
|
989
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
990
|
+
"https://gotosocial.org/ns",
|
|
991
|
+
{
|
|
992
|
+
ChatMessage: "http://litepub.social/ns#ChatMessage",
|
|
993
|
+
Emoji: "toot:Emoji",
|
|
994
|
+
Hashtag: "as:Hashtag",
|
|
995
|
+
QuoteAuthorization: "https://w3id.org/fep/044f#QuoteAuthorization",
|
|
996
|
+
QuoteRequest: "https://w3id.org/fep/044f#QuoteRequest",
|
|
997
|
+
_misskey_quote: "misskey:_misskey_quote",
|
|
998
|
+
fedibird: "http://fedibird.com/ns#",
|
|
999
|
+
misskey: "https://misskey-hub.net/ns#",
|
|
1000
|
+
quote: {
|
|
1001
|
+
"@id": "https://w3id.org/fep/044f#quote",
|
|
1002
|
+
"@type": "@id"
|
|
1003
|
+
},
|
|
1004
|
+
quoteAuthorization: {
|
|
1005
|
+
"@id": "https://w3id.org/fep/044f#quoteAuthorization",
|
|
1006
|
+
"@type": "@id"
|
|
1007
|
+
},
|
|
1008
|
+
quoteUri: "fedibird:quoteUri",
|
|
1009
|
+
quoteUrl: "as:quoteUrl",
|
|
1010
|
+
sensitive: "as:sensitive",
|
|
1011
|
+
toot: "http://joinmastodon.org/ns#",
|
|
1012
|
+
votersCount: "toot:votersCount",
|
|
1013
|
+
emojiReactions: {
|
|
1014
|
+
"@id": "fedibird:emojiReactions",
|
|
1015
|
+
"@type": "@id"
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
],
|
|
1019
|
+
items: {
|
|
1020
|
+
"@context": QUOTE_REQUEST_CONTEXT,
|
|
1021
|
+
object: "https://example.com/users/alice/statuses/1",
|
|
1022
|
+
type: "QuoteRequest"
|
|
1023
|
+
},
|
|
1024
|
+
type: "Collection"
|
|
1025
|
+
});
|
|
1026
|
+
});
|
|
1027
|
+
test("Delete.toJsonLd() compacts embedded QuoteRequest", async () => {
|
|
1028
|
+
deepStrictEqual(await new Delete({ object: new QuoteRequest({ object: new URL("https://example.com/users/alice/statuses/1") }) }).toJsonLd({ contextLoader: mockDocumentLoader }), {
|
|
1029
|
+
"@context": DELETE_QUOTE_REQUEST_CONTEXT,
|
|
1030
|
+
object: {
|
|
1031
|
+
object: "https://example.com/users/alice/statuses/1",
|
|
1032
|
+
type: "QuoteRequest"
|
|
1033
|
+
},
|
|
1034
|
+
type: "Delete"
|
|
1035
|
+
});
|
|
1036
|
+
});
|
|
724
1037
|
test("Key.publicKey", async () => {
|
|
725
1038
|
const jwk = {
|
|
726
1039
|
kty: "RSA",
|
|
@@ -1300,7 +1613,8 @@ const sampleValues = {
|
|
|
1300
1613
|
"fedify:publicKey": rsaPublicKey.publicKey,
|
|
1301
1614
|
"fedify:multibaseKey": ed25519PublicKey.publicKey,
|
|
1302
1615
|
"fedify:proofPurpose": "assertionMethod",
|
|
1303
|
-
"fedify:units": "m"
|
|
1616
|
+
"fedify:units": "m",
|
|
1617
|
+
"fedify:vocabEntityType": Person
|
|
1304
1618
|
};
|
|
1305
1619
|
const types = navigator?.userAgent === "Cloudflare-Workers" ? {} : await loadSchemaFiles(import.meta.dirname);
|
|
1306
1620
|
for (const typeUri in types) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/vocab",
|
|
3
|
-
"version": "2.2.0-dev.
|
|
3
|
+
"version": "2.2.0-dev.766+e04e54aa",
|
|
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.2.0-dev.
|
|
50
|
-
"@fedify/webfinger": "2.2.0-dev.
|
|
51
|
-
"@fedify/vocab-runtime": "2.2.0-dev.
|
|
49
|
+
"@fedify/vocab-tools": "2.2.0-dev.766+e04e54aa",
|
|
50
|
+
"@fedify/webfinger": "2.2.0-dev.766+e04e54aa",
|
|
51
|
+
"@fedify/vocab-runtime": "2.2.0-dev.766+e04e54aa"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^22.17.0",
|