moeralib 0.18.6 → 0.18.7

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/lib/node/node.js CHANGED
@@ -1360,17 +1360,40 @@ class MoeraNode extends caller_1.Caller {
1360
1360
  });
1361
1361
  }
1362
1362
  /**
1363
- * Upload a new private media file. The content of the file is passed in the request body.
1363
+ * Parse the page located at the URL and return the title, the description and the picture that may be used to
1364
+ * build a preview of the page.
1364
1365
  *
1365
- * @param {Buffer} body
1366
- * @param {string} contentType - content-type of ``body``
1367
- * @return {Promise<API.PrivateMediaFileInfo>}
1366
+ * @param {string} url
1367
+ * @return {Promise<API.LinkPreviewInfo>}
1368
1368
  */
1369
- uploadPrivateMedia(body, contentType) {
1369
+ createLinkPreview(url) {
1370
1370
  return __awaiter(this, void 0, void 0, function* () {
1371
- const location = "/media/private";
1371
+ const location = (0, util_1.ut) `/link-preview`;
1372
+ const params = { url };
1373
+ return yield this.call("createLinkPreview", location, {
1374
+ method: "GET", params, schema: "LinkPreviewInfo"
1375
+ });
1376
+ });
1377
+ }
1378
+ /**
1379
+ * Upload a new private media file. The content of the file is passed in the request body. Alternatively, the file
1380
+ * can be uploaded using Media upload API and its ID passed in the `upload` query parameter. The second alternative
1381
+ * is to pass the URL of the media in the `url` query parameter, the media will be downloaded to the node.
1382
+ *
1383
+ * @param {string | null} upload - ID of the media upload to be used instead of the request body
1384
+ * @param {string | null} url - URL of the media to be used instead of the request body
1385
+ * @param {boolean | null} downsize - `true` to scale the uploaded image down to the size recommended by the node,
1386
+ * if possible; the default is `false`
1387
+ * @param {Buffer | null} body - optional
1388
+ * @param {string | null} contentType - optional content-type of ``body``
1389
+ * @return {Promise<API.PrivateMediaFileInfo>}
1390
+ */
1391
+ uploadPrivateMedia() {
1392
+ return __awaiter(this, arguments, void 0, function* (body = null, contentType = null, upload = null, url = null, downsize = null) {
1393
+ const location = (0, util_1.ut) `/media/private`;
1394
+ const params = { upload, url, downsize };
1372
1395
  return yield this.call("uploadPrivateMedia", location, {
1373
- method: "POST", body, contentType, schema: "PrivateMediaFileInfo"
1396
+ method: "POST", params, body, contentType, schema: "PrivateMediaFileInfo"
1374
1397
  });
1375
1398
  });
1376
1399
  }
@@ -1503,6 +1526,65 @@ class MoeraNode extends caller_1.Caller {
1503
1526
  });
1504
1527
  });
1505
1528
  }
1529
+ /**
1530
+ * Create a new chunked upload of a private media source file.
1531
+ *
1532
+ * @param {API.MediaUploadAttributes} attributes
1533
+ * @return {Promise<API.MediaUploadInfo>}
1534
+ */
1535
+ createMediaUpload(attributes) {
1536
+ return __awaiter(this, void 0, void 0, function* () {
1537
+ const location = "/media/upload";
1538
+ return yield this.call("createMediaUpload", location, {
1539
+ method: "POST", body: attributes, schema: "MediaUploadInfo"
1540
+ });
1541
+ });
1542
+ }
1543
+ /**
1544
+ * Get chunked upload details.
1545
+ *
1546
+ * @param {string} id - upload ID
1547
+ * @return {Promise<API.MediaUploadInfo>}
1548
+ */
1549
+ getMediaUpload(id) {
1550
+ return __awaiter(this, void 0, void 0, function* () {
1551
+ const location = (0, util_1.ut) `/media/upload/${id}`;
1552
+ return yield this.call("getMediaUpload", location, {
1553
+ method: "GET", schema: "MediaUploadInfo"
1554
+ });
1555
+ });
1556
+ }
1557
+ /**
1558
+ * Upload one chunk of a private media source file.
1559
+ *
1560
+ * @param {string} id - upload ID
1561
+ * @param {number} chunk - zero-based chunk number
1562
+ * @param {Buffer} body
1563
+ * @param {string} contentType - content-type of ``body``
1564
+ * @return {Promise<API.MediaUploadInfo>}
1565
+ */
1566
+ uploadMediaChunk(id, chunk, body, contentType) {
1567
+ return __awaiter(this, void 0, void 0, function* () {
1568
+ const location = (0, util_1.ut) `/media/upload/${id}/${chunk}`;
1569
+ return yield this.call("uploadMediaChunk", location, {
1570
+ method: "PUT", body, contentType, schema: "MediaUploadInfo"
1571
+ });
1572
+ });
1573
+ }
1574
+ /**
1575
+ * Delete a chunked media upload and the corresponding source file.
1576
+ *
1577
+ * @param {string} id - upload ID
1578
+ * @return {Promise<API.Result>}
1579
+ */
1580
+ deleteMediaUpload(id) {
1581
+ return __awaiter(this, void 0, void 0, function* () {
1582
+ const location = (0, util_1.ut) `/media/upload/${id}`;
1583
+ return yield this.call("deleteMediaUpload", location, {
1584
+ method: "DELETE", schema: "Result"
1585
+ });
1586
+ });
1587
+ }
1506
1588
  /**
1507
1589
  * Get the name of the node. Admin user receives the current status of the latest operation with the node name.
1508
1590
  *
@@ -2057,37 +2139,6 @@ class MoeraNode extends caller_1.Caller {
2057
2139
  });
2058
2140
  });
2059
2141
  }
2060
- /**
2061
- * Open the URL passed in the parameters and pass to the client the media file returned by the server.
2062
- *
2063
- * @param {string} url
2064
- * @return {Promise<Blob>}
2065
- */
2066
- proxyMedia(url) {
2067
- return __awaiter(this, void 0, void 0, function* () {
2068
- const location = (0, util_1.ut) `/proxy/media`;
2069
- const params = { url };
2070
- return yield this.call("proxyMedia", location, {
2071
- method: "GET", params, schema: "blob"
2072
- });
2073
- });
2074
- }
2075
- /**
2076
- * Parse the page located at the URL and return the title, the description and the picture that may be used to
2077
- * build a preview of the page.
2078
- *
2079
- * @param {string} url
2080
- * @return {Promise<API.LinkPreviewInfo>}
2081
- */
2082
- proxyLinkPreview(url) {
2083
- return __awaiter(this, void 0, void 0, function* () {
2084
- const location = (0, util_1.ut) `/proxy/link-preview`;
2085
- const params = { url };
2086
- return yield this.call("proxyLinkPreview", location, {
2087
- method: "GET", params, schema: "LinkPreviewInfo"
2088
- });
2089
- });
2090
- }
2091
2142
  /**
2092
2143
  * Register a client at the push relay server to receive messages from this node. The operation is synchronous.
2093
2144
  *
@@ -3139,6 +3190,56 @@ class MoeraNode extends caller_1.Caller {
3139
3190
  });
3140
3191
  });
3141
3192
  }
3193
+ /**
3194
+ * Search for visited nodes matching the search ``query``. Every space-delimited word in the query must match
3195
+ * case-insensitively a beginning of the node's name or a beginning of any space-delimited word in the node's full
3196
+ * name. The order of words is not significant. \
3197
+ * \
3198
+ * The node may decide to return fewer nodes than the given ``limit``. \
3199
+ * \
3200
+ * The nodes are sorted by *social distance* from the node.
3201
+ *
3202
+ * @param {string | null} query - the search query
3203
+ * @param {number | null} limit - maximum number of nodes returned
3204
+ * @return {Promise<API.SearchNodeInfo[]>}
3205
+ */
3206
+ getVisitedNodes() {
3207
+ return __awaiter(this, arguments, void 0, function* (query = null, limit = null) {
3208
+ const location = (0, util_1.ut) `/people/visited`;
3209
+ const params = { query, limit };
3210
+ return yield this.call("getVisitedNodes", location, {
3211
+ method: "GET", params, schema: "SearchNodeInfoArray"
3212
+ });
3213
+ });
3214
+ }
3215
+ /**
3216
+ * Record a visit to the node.
3217
+ *
3218
+ * @param {API.VisitedNodeAttributes} node
3219
+ * @return {Promise<API.Result>}
3220
+ */
3221
+ recordVisitedNode(node) {
3222
+ return __awaiter(this, void 0, void 0, function* () {
3223
+ const location = "/people/visited";
3224
+ return yield this.call("recordVisitedNode", location, {
3225
+ method: "POST", body: node, schema: "Result"
3226
+ });
3227
+ });
3228
+ }
3229
+ /**
3230
+ * Delete all visits to the node.
3231
+ *
3232
+ * @param {string} remoteNodeName - name of the visited node
3233
+ * @return {Promise<API.Result>}
3234
+ */
3235
+ deleteVisitedNode(remoteNodeName) {
3236
+ return __awaiter(this, void 0, void 0, function* () {
3237
+ const location = (0, util_1.ut) `/people/visited/${remoteNodeName}`;
3238
+ return yield this.call("deleteVisitedNode", location, {
3239
+ method: "DELETE", schema: "Result"
3240
+ });
3241
+ });
3242
+ }
3142
3243
  /**
3143
3244
  * Record a visit to a posting, comment or media.
3144
3245
  *