@fedify/vocab 2.4.0-dev.1531 → 2.4.0-dev.1567

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 { A as QuoteAuthorization, C as Offer, D as Place, E as Person, F as Tombstone, M as Reject, O as Proposal, P as Source, R as vocab_exports, 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 QuoteRequest, k as Question, 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 } from "./vocab-CQX0Zq_l.mjs";
3
+ import { A as Person, C as Link, D as Offer, E as Object$1, F as QuoteRequest, H as vocab_exports, I as Reject, M as Proposal, N as Question, O as OrderedCollectionPage, P as QuoteAuthorization, R as Source, S as InteractionRule, T as Note, _ as Follow, b as Intent, c as Create, d as Document, f as Endpoints, g as FeaturedItem, h as FeaturedCollection, i as Announce, j as Place, l as CryptographicKey, m as FeatureRequest, n as Activity, o as Collection, p as FeatureAuthorization, r as Agreement, s as Commitment, t as Accept, u as Delete, w as Measure, x as InteractionPolicy, y as Hashtag, z as Tombstone } from "./vocab-DOHLQ4UQ.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";
@@ -53,6 +53,18 @@ const QUOTE_REQUEST_CONTEXT = [
53
53
  }
54
54
  }
55
55
  ];
56
+ const FEATURE_CONTEXT = [
57
+ "https://www.w3.org/ns/activitystreams",
58
+ "https://w3id.org/security/data-integrity/v1",
59
+ "https://gotosocial.org/ns",
60
+ "https://w3id.org/fep/7aa9"
61
+ ];
62
+ const FEATURED_COLLECTION_CONTEXT = [...FEATURE_CONTEXT, {
63
+ Hashtag: "as:Hashtag",
64
+ discoverable: "toot:discoverable",
65
+ sensitive: "as:sensitive",
66
+ toot: "http://joinmastodon.org/ns#"
67
+ }];
56
68
  const DELETE_QUOTE_REQUEST_CONTEXT = [
57
69
  "https://w3id.org/identity/v1",
58
70
  "https://www.w3.org/ns/activitystreams",
@@ -1149,6 +1161,7 @@ test("Person.toJsonLd()", async () => {
1149
1161
  "https://www.w3.org/ns/did/v1",
1150
1162
  "https://w3id.org/security/multikey/v1",
1151
1163
  "https://gotosocial.org/ns",
1164
+ "https://w3id.org/fep/7aa9",
1152
1165
  {
1153
1166
  PropertyValue: "schema:PropertyValue",
1154
1167
  alsoKnownAs: {
@@ -1164,6 +1177,10 @@ test("Person.toJsonLd()", async () => {
1164
1177
  "@id": "toot:featured",
1165
1178
  "@type": "@id"
1166
1179
  },
1180
+ featuredCollections: {
1181
+ "@id": "https://w3id.org/fep/7aa9#featuredCollections",
1182
+ "@type": "@id"
1183
+ },
1167
1184
  featuredTags: {
1168
1185
  "@id": "toot:featuredTags",
1169
1186
  "@type": "@id"
@@ -1610,6 +1627,187 @@ test("InteractionPolicy.canQuote", async () => {
1610
1627
  contextLoader: mockDocumentLoader
1611
1628
  })).toJsonLd({ contextLoader: mockDocumentLoader }), expected);
1612
1629
  });
1630
+ test("InteractionPolicy.canFeature", async () => {
1631
+ const person = new Person({
1632
+ id: new URL("https://example.com/users/alice"),
1633
+ featuredCollections: new URL("https://example.com/users/alice/featured_collections"),
1634
+ interactionPolicy: new InteractionPolicy({ canFeature: new InteractionRule({ automaticApproval: new URL("https://www.w3.org/ns/activitystreams#Public") }) })
1635
+ });
1636
+ const expected = {
1637
+ "@context": [
1638
+ "https://www.w3.org/ns/activitystreams",
1639
+ "https://w3id.org/security/v1",
1640
+ "https://w3id.org/security/data-integrity/v1",
1641
+ "https://www.w3.org/ns/did/v1",
1642
+ "https://w3id.org/security/multikey/v1",
1643
+ "https://gotosocial.org/ns",
1644
+ "https://w3id.org/fep/7aa9",
1645
+ {
1646
+ Emoji: "toot:Emoji",
1647
+ PropertyValue: "schema:PropertyValue",
1648
+ _misskey_followedMessage: "misskey:_misskey_followedMessage",
1649
+ alsoKnownAs: {
1650
+ "@id": "as:alsoKnownAs",
1651
+ "@type": "@id"
1652
+ },
1653
+ discoverable: "toot:discoverable",
1654
+ featured: {
1655
+ "@id": "toot:featured",
1656
+ "@type": "@id"
1657
+ },
1658
+ featuredCollections: {
1659
+ "@id": "https://w3id.org/fep/7aa9#featuredCollections",
1660
+ "@type": "@id"
1661
+ },
1662
+ featuredTags: {
1663
+ "@id": "toot:featuredTags",
1664
+ "@type": "@id"
1665
+ },
1666
+ indexable: "toot:indexable",
1667
+ isCat: "misskey:isCat",
1668
+ manuallyApprovesFollowers: "as:manuallyApprovesFollowers",
1669
+ memorial: "toot:memorial",
1670
+ misskey: "https://misskey-hub.net/ns#",
1671
+ movedTo: {
1672
+ "@id": "as:movedTo",
1673
+ "@type": "@id"
1674
+ },
1675
+ schema: "http://schema.org#",
1676
+ suspended: "toot:suspended",
1677
+ toot: "http://joinmastodon.org/ns#",
1678
+ value: "schema:value"
1679
+ }
1680
+ ],
1681
+ type: "Person",
1682
+ id: "https://example.com/users/alice",
1683
+ featuredCollections: "https://example.com/users/alice/featured_collections",
1684
+ interactionPolicy: { canFeature: { automaticApproval: "as:Public" } }
1685
+ };
1686
+ deepStrictEqual(await person.toJsonLd({ contextLoader: mockDocumentLoader }), expected);
1687
+ const loaded = await Person.fromJsonLd(expected, {
1688
+ documentLoader: mockDocumentLoader,
1689
+ contextLoader: mockDocumentLoader
1690
+ });
1691
+ deepStrictEqual(loaded.featuredCollectionsId, new URL("https://example.com/users/alice/featured_collections"));
1692
+ assertInstanceOf(loaded.interactionPolicy, InteractionPolicy);
1693
+ assertInstanceOf(loaded.interactionPolicy.canFeature, InteractionRule);
1694
+ deepStrictEqual(loaded.interactionPolicy.canFeature.automaticApproval, new URL("https://www.w3.org/ns/activitystreams#Public"));
1695
+ deepStrictEqual(await loaded.toJsonLd({ contextLoader: mockDocumentLoader }), expected);
1696
+ deepStrictEqual((await Person.fromJsonLd({
1697
+ "@context": [
1698
+ "https://www.w3.org/ns/activitystreams",
1699
+ "https://gotosocial.org/ns",
1700
+ "https://w3id.org/fep/7aa9",
1701
+ { featuredCollections: {
1702
+ "@id": "https://w3id.org/fep/7aa9#featuredCollections",
1703
+ "@type": "@id"
1704
+ } }
1705
+ ],
1706
+ type: "Person",
1707
+ id: "https://example.com/users/alice",
1708
+ featuredCollections: "https://example.com/users/alice/featured_collections"
1709
+ }, {
1710
+ documentLoader: mockDocumentLoader,
1711
+ contextLoader: mockDocumentLoader
1712
+ })).featuredCollectionsId, new URL("https://example.com/users/alice/featured_collections"));
1713
+ });
1714
+ test("FeaturedCollection.toJsonLd()", async () => {
1715
+ const collection = new FeaturedCollection({
1716
+ id: new URL("https://example.com/users/alice/featured/1"),
1717
+ name: "Cute cats",
1718
+ attribution: new URL("https://example.com/users/alice"),
1719
+ topic: new Hashtag({ name: "#cats" }),
1720
+ discoverable: false,
1721
+ totalItems: 1
1722
+ });
1723
+ const expected = {
1724
+ "@context": FEATURED_COLLECTION_CONTEXT,
1725
+ type: "FeaturedCollection",
1726
+ id: "https://example.com/users/alice/featured/1",
1727
+ attributedTo: "https://example.com/users/alice",
1728
+ name: "Cute cats",
1729
+ totalItems: 1,
1730
+ topic: {
1731
+ type: "Hashtag",
1732
+ name: "#cats"
1733
+ },
1734
+ discoverable: false
1735
+ };
1736
+ deepStrictEqual(await collection.toJsonLd({ contextLoader: mockDocumentLoader }), expected);
1737
+ const loaded = await FeaturedCollection.fromJsonLd(expected, {
1738
+ documentLoader: mockDocumentLoader,
1739
+ contextLoader: mockDocumentLoader
1740
+ });
1741
+ assertInstanceOf(loaded, FeaturedCollection);
1742
+ deepStrictEqual(loaded.name, "Cute cats");
1743
+ deepStrictEqual(loaded.attributionId, new URL("https://example.com/users/alice"));
1744
+ assertInstanceOf(loaded.topic, Hashtag);
1745
+ deepStrictEqual(loaded.topic.name, "#cats");
1746
+ deepStrictEqual(loaded.discoverable, false);
1747
+ deepStrictEqual(loaded.totalItems, 1);
1748
+ deepStrictEqual(await loaded.toJsonLd({ contextLoader: mockDocumentLoader }), expected);
1749
+ });
1750
+ test("FeaturedItem.toJsonLd()", async () => {
1751
+ const item = new FeaturedItem({
1752
+ id: new URL("https://example.com/users/alice/featured/1/items/1"),
1753
+ featuredObject: new URL("https://example.com/users/bob"),
1754
+ featureAuthorization: new URL("https://example.com/users/bob/stamps/1")
1755
+ });
1756
+ const expected = {
1757
+ "@context": FEATURE_CONTEXT,
1758
+ type: "FeaturedItem",
1759
+ id: "https://example.com/users/alice/featured/1/items/1",
1760
+ featuredObject: "https://example.com/users/bob",
1761
+ featureAuthorization: "https://example.com/users/bob/stamps/1"
1762
+ };
1763
+ deepStrictEqual(await item.toJsonLd({ contextLoader: mockDocumentLoader }), expected);
1764
+ const loaded = await FeaturedItem.fromJsonLd(expected, {
1765
+ documentLoader: mockDocumentLoader,
1766
+ contextLoader: mockDocumentLoader
1767
+ });
1768
+ assertInstanceOf(loaded, FeaturedItem);
1769
+ deepStrictEqual(loaded.featuredObjectId, new URL("https://example.com/users/bob"));
1770
+ deepStrictEqual(loaded.featureAuthorizationId, new URL("https://example.com/users/bob/stamps/1"));
1771
+ });
1772
+ test("FeatureAuthorization.fromJsonLd()", async () => {
1773
+ const jsonLd = {
1774
+ "@context": FEATURE_CONTEXT,
1775
+ type: "FeatureAuthorization",
1776
+ id: "https://example.com/users/bob/stamps/1",
1777
+ interactingObject: "https://example.com/users/alice/featured/1",
1778
+ interactionTarget: "https://example.com/users/bob"
1779
+ };
1780
+ const authorization = await FeatureAuthorization.fromJsonLd(jsonLd, {
1781
+ documentLoader: mockDocumentLoader,
1782
+ contextLoader: mockDocumentLoader
1783
+ });
1784
+ assertInstanceOf(authorization, FeatureAuthorization);
1785
+ deepStrictEqual(authorization.interactingObjectId, new URL("https://example.com/users/alice/featured/1"));
1786
+ deepStrictEqual(authorization.interactionTargetId, new URL("https://example.com/users/bob"));
1787
+ deepStrictEqual(await authorization.toJsonLd({ contextLoader: mockDocumentLoader }), jsonLd);
1788
+ });
1789
+ test("FeatureRequest.toJsonLd()", async () => {
1790
+ const request = new FeatureRequest({
1791
+ id: new URL("https://example.com/users/alice/featured/1/requests/1"),
1792
+ object: new URL("https://example.com/users/bob"),
1793
+ instrument: new URL("https://example.com/users/alice/featured/1")
1794
+ });
1795
+ const expected = {
1796
+ "@context": ["https://w3id.org/identity/v1", ...FEATURE_CONTEXT],
1797
+ type: "FeatureRequest",
1798
+ id: "https://example.com/users/alice/featured/1/requests/1",
1799
+ object: "https://example.com/users/bob",
1800
+ instrument: "https://example.com/users/alice/featured/1"
1801
+ };
1802
+ deepStrictEqual(await request.toJsonLd({ contextLoader: mockDocumentLoader }), expected);
1803
+ const loaded = await FeatureRequest.fromJsonLd(expected, {
1804
+ documentLoader: mockDocumentLoader,
1805
+ contextLoader: mockDocumentLoader
1806
+ });
1807
+ assertInstanceOf(loaded, FeatureRequest);
1808
+ deepStrictEqual(loaded.objectId, new URL("https://example.com/users/bob"));
1809
+ deepStrictEqual(loaded.instrumentId, new URL("https://example.com/users/alice/featured/1"));
1810
+ });
1613
1811
  test("QuoteAuthorization.fromJsonLd()", async () => {
1614
1812
  const jsonLd = {
1615
1813
  "@context": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab",
3
- "version": "2.4.0-dev.1531+0896bc51",
3
+ "version": "2.4.0-dev.1567+12e6a3c0",
4
4
  "homepage": "https://fedify.dev/",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,9 +43,9 @@
43
43
  "es-toolkit": "1.46.1",
44
44
  "jsonld": "^9.0.0",
45
45
  "pkijs": "^3.3.3",
46
- "@fedify/vocab-tools": "2.4.0-dev.1531+0896bc51",
47
- "@fedify/webfinger": "2.4.0-dev.1531+0896bc51",
48
- "@fedify/vocab-runtime": "2.4.0-dev.1531+0896bc51"
46
+ "@fedify/vocab-tools": "2.4.0-dev.1567+12e6a3c0",
47
+ "@fedify/vocab-runtime": "2.4.0-dev.1567+12e6a3c0",
48
+ "@fedify/webfinger": "2.4.0-dev.1567+12e6a3c0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^22.17.0",