moeralib 0.19.1 → 0.19.3

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/AGENTS.md ADDED
@@ -0,0 +1,5 @@
1
+ # TypeScript
2
+
3
+ 1. Do not use `enum` or `namespace`. Represent string-valued enumerations as
4
+ string literal union types, adding new values with `|`. For example:
5
+ `type NodeSourceUriService = "telegram" | "rss" | "livejournal"`.
package/lib/index.js CHANGED
@@ -1,2 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NodeSourceUri = void 0;
4
+ var node_source_uri_1 = require("./node-source-uri");
5
+ Object.defineProperty(exports, "NodeSourceUri", { enumerable: true, get: function () { return node_source_uri_1.NodeSourceUri; } });
@@ -10,6 +10,7 @@ exports.createCommentFingerprint1 = createCommentFingerprint1;
10
10
  exports.createCommentFingerprint0 = createCommentFingerprint0;
11
11
  exports.createMediaGrantFingerprint1 = createMediaGrantFingerprint1;
12
12
  exports.createMediaGrantFingerprint0 = createMediaGrantFingerprint0;
13
+ exports.createNotificationPacketFingerprint2 = createNotificationPacketFingerprint2;
13
14
  exports.createNotificationPacketFingerprint1 = createNotificationPacketFingerprint1;
14
15
  exports.createNotificationPacketFingerprint0 = createNotificationPacketFingerprint0;
15
16
  exports.createPostingFingerprint1 = createPostingFingerprint1;
@@ -151,6 +152,21 @@ function createMediaGrantFingerprint0(nodeName, postingId, commentId, mediaId, e
151
152
  return (0, crypto_1.fingerprintBytes)({ "version": 0, "objectType": "MEDIA_GRANT", nodeName, postingId, commentId, mediaId, expires, download, fileName,
152
153
  salt }, MEDIA_GRANT_FINGERPRINT0_SCHEMA);
153
154
  }
155
+ const NOTIFICATION_PACKET_FINGERPRINT2_SCHEMA = [
156
+ ["version", "number"],
157
+ ["objectType", "string"],
158
+ ["id", "string"],
159
+ ["nodeName", "string"],
160
+ ["fullName", "string"],
161
+ ["nodeSourceUri", "string"],
162
+ ["createdAt", "number"],
163
+ ["type", "string"],
164
+ ["notification", "string"],
165
+ ];
166
+ function createNotificationPacketFingerprint2(id, nodeName, fullName, nodeSourceUri, createdAt, type, notification) {
167
+ return (0, crypto_1.fingerprintBytes)({ "version": 2, "objectType": "NOTIFICATION_PACKET", id, nodeName, fullName, nodeSourceUri, createdAt, type,
168
+ notification }, NOTIFICATION_PACKET_FINGERPRINT2_SCHEMA);
169
+ }
154
170
  const NOTIFICATION_PACKET_FINGERPRINT1_SCHEMA = [
155
171
  ["version", "number"],
156
172
  ["objectType", "string"],
package/lib/node/node.js CHANGED
@@ -1715,62 +1715,6 @@ class MoeraNode extends caller_1.Caller {
1715
1715
  });
1716
1716
  });
1717
1717
  }
1718
- /**
1719
- * Register the plugin. If the plugin authenticates as root admin, the plugin is registered at the server level. If
1720
- * the plugin authenticates as node admin, the plugin is registered at the node level.
1721
- *
1722
- * @param {API.PluginDescription} plugin
1723
- * @return {Promise<API.PluginInfo>}
1724
- */
1725
- registerPlugin(plugin) {
1726
- return __awaiter(this, void 0, void 0, function* () {
1727
- const location = "/plugins";
1728
- return yield this.call("registerPlugin", location, {
1729
- method: "POST", body: plugin, schema: "PluginInfo"
1730
- });
1731
- });
1732
- }
1733
- /**
1734
- * Get information about all plugins registered for the node and server.
1735
- *
1736
- * @return {Promise<API.PluginInfo[]>}
1737
- */
1738
- getPlugins() {
1739
- return __awaiter(this, void 0, void 0, function* () {
1740
- const location = "/plugins";
1741
- return yield this.call("getPlugins", location, {
1742
- method: "GET", schema: "PluginInfoArray"
1743
- });
1744
- });
1745
- }
1746
- /**
1747
- * Get information about the plugin.
1748
- *
1749
- * @param {string} pluginName - name of the plugin
1750
- * @return {Promise<API.PluginInfo>}
1751
- */
1752
- getPlugin(pluginName) {
1753
- return __awaiter(this, void 0, void 0, function* () {
1754
- const location = (0, util_1.ut) `/plugins/${pluginName}`;
1755
- return yield this.call("getPlugin", location, {
1756
- method: "GET", schema: "PluginInfo"
1757
- });
1758
- });
1759
- }
1760
- /**
1761
- * Unregister the plugin.
1762
- *
1763
- * @param {string} pluginName - name of the plugin
1764
- * @return {Promise<API.Result>}
1765
- */
1766
- unregisterPlugin(pluginName) {
1767
- return __awaiter(this, void 0, void 0, function* () {
1768
- const location = (0, util_1.ut) `/plugins/${pluginName}`;
1769
- return yield this.call("unregisterPlugin", location, {
1770
- method: "DELETE", schema: "Result"
1771
- });
1772
- });
1773
- }
1774
1718
  /**
1775
1719
  * Create a new posting from the text given and publish it in the given feeds (if any). The heading and the preview
1776
1720
  * of the posting are created automatically, if needed. The posting owner must authenticate in some way. If the
@@ -1804,7 +1748,9 @@ class MoeraNode extends caller_1.Caller {
1804
1748
  });
1805
1749
  }
1806
1750
  /**
1807
- * Update the posting, creating a new revision of it. The text is processed just like in the ``POST`` request.
1751
+ * Update the posting, creating a new revision of it. The text is processed just like in the ``POST`` request. If
1752
+ * the posting is not original (a cached copy of a remote posting), only its permissions can be changed; all other
1753
+ * fields are ignored and no new revision is created.
1808
1754
  *
1809
1755
  * @param {string} id - ID of the posting
1810
1756
  * @param {API.PostingText} posting
@@ -1850,6 +1796,21 @@ class MoeraNode extends caller_1.Caller {
1850
1796
  });
1851
1797
  });
1852
1798
  }
1799
+ /**
1800
+ * Update the posting visibility if requested and publish it in the specified feeds.
1801
+ *
1802
+ * @param {string} id - ID of the posting
1803
+ * @param {API.PostingRepublishAttributes} attributes
1804
+ * @return {Promise<API.Result>}
1805
+ */
1806
+ republishPosting(id, attributes) {
1807
+ return __awaiter(this, void 0, void 0, function* () {
1808
+ const location = (0, util_1.ut) `/postings/${id}/republish`;
1809
+ return yield this.call("republishPosting", location, {
1810
+ method: "POST", body: attributes, schema: "Result"
1811
+ });
1812
+ });
1813
+ }
1853
1814
  /**
1854
1815
  * Get all postings linked to media attached to the given posting.
1855
1816
  *
@@ -2056,6 +2017,26 @@ class MoeraNode extends caller_1.Caller {
2056
2017
  });
2057
2018
  });
2058
2019
  }
2020
+ /**
2021
+ * Get a slice of the sharings of the posting, delimited by the ``before`` moment and the given ``limit``. If
2022
+ * ``before`` is not provided, the latest sharings are returned. The node may decide to return fewer sharings than
2023
+ * the given ``limit``. The sharings are always sorted by moment, descending. The list is empty when viewing
2024
+ * sharings is not permitted. The total is zero when viewing the sharing counter is not permitted.
2025
+ *
2026
+ * @param {string} postingId - ID of the posting
2027
+ * @param {number | null} before - filter sharings created at or before this moment
2028
+ * @param {number | null} limit - maximum number of sharings returned
2029
+ * @return {Promise<API.SharingsSliceInfo>}
2030
+ */
2031
+ getPostingSharings(postingId_1) {
2032
+ return __awaiter(this, arguments, void 0, function* (postingId, before = null, limit = null) {
2033
+ const location = (0, util_1.ut) `/postings/${postingId}/sharings`;
2034
+ const params = { before, limit };
2035
+ return yield this.call("getPostingSharings", location, {
2036
+ method: "GET", params, schema: "SharingsSliceInfo"
2037
+ });
2038
+ });
2039
+ }
2059
2040
  /**
2060
2041
  * Get the profile.
2061
2042
  *
@@ -2073,8 +2054,9 @@ class MoeraNode extends caller_1.Caller {
2073
2054
  });
2074
2055
  }
2075
2056
  /**
2076
- * Update the profile. Fields that are not set in the request body are left intact. Fields that are set to an empty
2077
- * value are reset to their defaults.
2057
+ * To update a profile attribute, include the field with its new value. For a partial update, include only the
2058
+ * fields to be changed; omitted fields remain unchanged. To delete an attribute, include the field with an empty
2059
+ * value, which resets it to its default.
2078
2060
  *
2079
2061
  * @param {API.ProfileAttributes} profile
2080
2062
  * @return {Promise<API.ProfileInfo>}
@@ -2487,6 +2469,22 @@ class MoeraNode extends caller_1.Caller {
2487
2469
  });
2488
2470
  });
2489
2471
  }
2472
+ /**
2473
+ * Download the posting from the remote node and publish it in the specified feeds.
2474
+ *
2475
+ * @param {string} remoteNodeName - name of the remote node
2476
+ * @param {string} id - ID of the posting on the remote node
2477
+ * @param {API.RemotePostingRepublishAttributes} attributes
2478
+ * @return {Promise<API.Result>}
2479
+ */
2480
+ republishRemotePosting(remoteNodeName, id, attributes) {
2481
+ return __awaiter(this, void 0, void 0, function* () {
2482
+ const location = (0, util_1.ut) `/nodes/${remoteNodeName}/postings/${id}/republish`;
2483
+ return yield this.call("republishRemotePosting", location, {
2484
+ method: "POST", body: attributes, schema: "Result"
2485
+ });
2486
+ });
2487
+ }
2490
2488
  /**
2491
2489
  * Verify the signature of the given posting.
2492
2490
  *
@@ -2850,6 +2848,21 @@ class MoeraNode extends caller_1.Caller {
2850
2848
  });
2851
2849
  });
2852
2850
  }
2851
+ /**
2852
+ * Get all stories coming from the given external source.
2853
+ *
2854
+ * @param {string} external - URI of the external source of the story
2855
+ * @return {Promise<API.StoryInfo[]>}
2856
+ */
2857
+ getStoriesByExternalSource(external) {
2858
+ return __awaiter(this, void 0, void 0, function* () {
2859
+ const location = (0, util_1.ut) `/stories`;
2860
+ const params = { external };
2861
+ return yield this.call("getStoriesByExternalSource", location, {
2862
+ method: "GET", params, schema: "StoryInfoArray", bodies: true
2863
+ });
2864
+ });
2865
+ }
2853
2866
  /**
2854
2867
  * Get an individual story.
2855
2868
  *
package/lib/node/types.js CHANGED
@@ -22,7 +22,6 @@ exports.SCOPE_VALUES = {
22
22
  "view-feeds": 0x00008000,
23
23
  "update-feeds": 0x00010000,
24
24
  "name": 0x00020000,
25
- "plugins": 0x00040000,
26
25
  "view-profile": 0x00080000,
27
26
  "update-profile": 0x00100000,
28
27
  "sheriff": 0x00200000,
@@ -36,5 +35,5 @@ exports.SCOPE_VALUES = {
36
35
  "upload-private-media": 0x20000000,
37
36
  "lease-media": 0x40000000,
38
37
  "view-all": 0x00088404,
39
- "all": 0x7ffffffd,
38
+ "all": 0x7ffbfffd,
40
39
  };