@eluvio/elv-client-js 3.2.43 → 3.2.45

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.
@@ -19,6 +19,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
19
19
  */
20
20
  var UrlJoin = require("url-join");
21
21
 
22
+ var objectPath = require("object-path");
23
+
22
24
  var HttpClient = require("../HttpClient");
23
25
 
24
26
  var _require = require("../Validation"),
@@ -1154,6 +1156,7 @@ exports.ContentObjects = /*#__PURE__*/function () {
1154
1156
  * @param {string=} libraryId - ID of the library
1155
1157
  * @param {string=} objectId - ID of the object
1156
1158
  * @param {string=} versionHash - Version hash of the object -- if not specified, latest version is returned
1159
+ * @param {string=} writeToken - Write token for an object draft -- if supplied, versionHash will be ignored
1157
1160
  *
1158
1161
  * @returns {Promise<Object>} - Description of content object
1159
1162
  */
@@ -1161,24 +1164,24 @@ exports.ContentObjects = /*#__PURE__*/function () {
1161
1164
 
1162
1165
  exports.ContentObject = /*#__PURE__*/function () {
1163
1166
  var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref25) {
1164
- var libraryId, objectId, versionHash, path;
1167
+ var libraryId, objectId, versionHash, writeToken, path;
1165
1168
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
1166
1169
  while (1) {
1167
1170
  switch (_context15.prev = _context15.next) {
1168
1171
  case 0:
1169
- libraryId = _ref25.libraryId, objectId = _ref25.objectId, versionHash = _ref25.versionHash;
1172
+ libraryId = _ref25.libraryId, objectId = _ref25.objectId, versionHash = _ref25.versionHash, writeToken = _ref25.writeToken;
1170
1173
  ValidateParameters({
1171
1174
  libraryId: libraryId,
1172
1175
  objectId: objectId,
1173
1176
  versionHash: versionHash
1174
1177
  });
1175
- this.Log("Retrieving content object: ".concat(libraryId || "", " ").concat(objectId || versionHash));
1178
+ this.Log("Retrieving content object: ".concat(libraryId || "", " ").concat(writeToken || versionHash || objectId));
1176
1179
 
1177
1180
  if (versionHash) {
1178
1181
  objectId = this.utils.DecodeVersionHash(versionHash).objectId;
1179
1182
  }
1180
1183
 
1181
- path = UrlJoin("q", versionHash || objectId);
1184
+ path = UrlJoin("q", writeToken || versionHash || objectId);
1182
1185
  _context15.t0 = this.utils;
1183
1186
  _context15.t1 = this.HttpClient;
1184
1187
  _context15.next = 9;
@@ -1782,7 +1785,7 @@ exports.MetadataAuth = /*#__PURE__*/function () {
1782
1785
 
1783
1786
  exports.ContentObjectMetadata = /*#__PURE__*/function () {
1784
1787
  var _ref41 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref40) {
1785
- var libraryId, objectId, versionHash, writeToken, _ref40$metadataSubtre, metadataSubtree, _ref40$queryParams, queryParams, _ref40$select, select, _ref40$remove, remove, authorizationToken, _ref40$noAuth, noAuth, _ref40$resolveLinks, resolveLinks, _ref40$resolveInclude, resolveIncludeSource, _ref40$resolveIgnoreE, resolveIgnoreErrors, _ref40$linkDepthLimit, linkDepthLimit, _ref40$produceLinkUrl, produceLinkUrls, path, defaultAuthToken, authTokens, metadata;
1788
+ var libraryId, objectId, versionHash, writeToken, _ref40$metadataSubtre, metadataSubtree, _ref40$queryParams, queryParams, _ref40$select, select, _ref40$remove, remove, authorizationToken, _ref40$noAuth, noAuth, _ref40$resolveLinks, resolveLinks, _ref40$resolveInclude, resolveIncludeSource, _ref40$resolveIgnoreE, resolveIgnoreErrors, _ref40$linkDepthLimit, linkDepthLimit, _ref40$produceLinkUrl, produceLinkUrls, path, defaultAuthToken, authTokens, metadata, errQwtoken;
1786
1789
 
1787
1790
  return _regeneratorRuntime.wrap(function _callee24$(_context24) {
1788
1791
  while (1) {
@@ -1841,7 +1844,7 @@ exports.ContentObjectMetadata = /*#__PURE__*/function () {
1841
1844
 
1842
1845
  case 14:
1843
1846
  metadata = _context24.sent;
1844
- _context24.next = 22;
1847
+ _context24.next = 27;
1845
1848
  break;
1846
1849
 
1847
1850
  case 17:
@@ -1856,18 +1859,32 @@ exports.ContentObjectMetadata = /*#__PURE__*/function () {
1856
1859
  throw _context24.t0;
1857
1860
 
1858
1861
  case 21:
1862
+ // For a 404 error, check if error was due to write token not found
1863
+ errQwtoken = objectPath.get(_context24.t0.body, "errors[0].cause.cause.cause.qwtoken");
1864
+
1865
+ if (!errQwtoken) {
1866
+ _context24.next = 26;
1867
+ break;
1868
+ }
1869
+
1870
+ throw _context24.t0;
1871
+
1872
+ case 26:
1873
+ // For all other 404 errors (not just 'subtree not found'), suppress error and
1874
+ // return an empty value. (there are function call chains that depend on this behavior,
1875
+ // e.g. CreateABRMezzanine -> CreateEncryptionConk -> ContentObjectMetadata)
1859
1876
  metadata = metadataSubtree === "/" ? {} : undefined;
1860
1877
 
1861
- case 22:
1878
+ case 27:
1862
1879
  if (produceLinkUrls) {
1863
- _context24.next = 24;
1880
+ _context24.next = 29;
1864
1881
  break;
1865
1882
  }
1866
1883
 
1867
1884
  return _context24.abrupt("return", metadata);
1868
1885
 
1869
- case 24:
1870
- _context24.next = 26;
1886
+ case 29:
1887
+ _context24.next = 31;
1871
1888
  return this.ProduceMetadataLinks({
1872
1889
  libraryId: libraryId,
1873
1890
  objectId: objectId,
@@ -1878,10 +1895,10 @@ exports.ContentObjectMetadata = /*#__PURE__*/function () {
1878
1895
  noAuth: noAuth
1879
1896
  });
1880
1897
 
1881
- case 26:
1898
+ case 31:
1882
1899
  return _context24.abrupt("return", _context24.sent);
1883
1900
 
1884
- case 27:
1901
+ case 32:
1885
1902
  case "end":
1886
1903
  return _context24.stop();
1887
1904
  }
@@ -1429,13 +1429,13 @@ exports.CreateNonOwnerCap = /*#__PURE__*/function () {
1429
1429
  * meta: New metadata for the object - will be merged into existing metadata if specified
1430
1430
  * type: New type for the object - Object ID, version hash or name of type
1431
1431
  *
1432
- * @returns {Promise<object>} - Response containing the object ID and write token of the draft
1432
+ * @returns {Promise<object>} - Response containing the object ID and write token of the draft, as well as URL of node handling the draft
1433
1433
  */
1434
1434
 
1435
1435
 
1436
1436
  exports.EditContentObject = /*#__PURE__*/function () {
1437
1437
  var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref27) {
1438
- var libraryId, objectId, _ref27$options, options, path, editResponse;
1438
+ var libraryId, objectId, _ref27$options, options, path, rawEditResponse, actualUrl, nodeUrl, editResponse;
1439
1439
 
1440
1440
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
1441
1441
  while (1) {
@@ -1505,38 +1505,47 @@ exports.EditContentObject = /*#__PURE__*/function () {
1505
1505
 
1506
1506
  case 23:
1507
1507
  path = UrlJoin("qid", objectId);
1508
- _context15.t0 = this.utils;
1509
- _context15.t1 = this.HttpClient;
1510
- _context15.next = 28;
1508
+ _context15.t0 = this.HttpClient;
1509
+ _context15.next = 27;
1511
1510
  return this.authClient.AuthorizationHeader({
1512
1511
  libraryId: libraryId,
1513
1512
  objectId: objectId,
1514
1513
  update: true
1515
1514
  });
1516
1515
 
1517
- case 28:
1518
- _context15.t2 = _context15.sent;
1519
- _context15.t3 = path;
1520
- _context15.t4 = options;
1521
- _context15.t5 = {
1522
- headers: _context15.t2,
1516
+ case 27:
1517
+ _context15.t1 = _context15.sent;
1518
+ _context15.t2 = path;
1519
+ _context15.t3 = options;
1520
+ _context15.t4 = {
1521
+ headers: _context15.t1,
1523
1522
  method: "POST",
1524
- path: _context15.t3,
1525
- body: _context15.t4
1523
+ path: _context15.t2,
1524
+ body: _context15.t3
1526
1525
  };
1527
- _context15.t6 = _context15.t1.Request.call(_context15.t1, _context15.t5);
1528
- _context15.next = 35;
1529
- return _context15.t0.ResponseToJson.call(_context15.t0, _context15.t6);
1526
+ _context15.next = 33;
1527
+ return _context15.t0.Request.call(_context15.t0, _context15.t4);
1530
1528
 
1531
- case 35:
1529
+ case 33:
1530
+ rawEditResponse = _context15.sent;
1531
+ actualUrl = new URL(rawEditResponse.url);
1532
+ actualUrl.pathname = "";
1533
+ actualUrl.search = "";
1534
+ actualUrl.hash = "";
1535
+ nodeUrl = actualUrl.href;
1536
+ _context15.next = 41;
1537
+ return this.utils.ResponseToJson(rawEditResponse);
1538
+
1539
+ case 41:
1532
1540
  editResponse = _context15.sent;
1533
1541
  // Record the node used in creating this write token
1534
- this.HttpClient.RecordWriteToken(editResponse.write_token);
1542
+ this.HttpClient.RecordWriteToken(editResponse.write_token, nodeUrl);
1535
1543
  editResponse.writeToken = editResponse.write_token;
1536
1544
  editResponse.objectId = editResponse.id;
1545
+ editResponse.nodeUrl = nodeUrl;
1537
1546
  return _context15.abrupt("return", editResponse);
1538
1547
 
1539
- case 40:
1548
+ case 47:
1540
1549
  case "end":
1541
1550
  return _context15.stop();
1542
1551
  }
@@ -2639,7 +2648,7 @@ exports.UpdateContentObjectGraph = /*#__PURE__*/function () {
2639
2648
  /**
2640
2649
  * Generate a signed link token.
2641
2650
  *
2642
- * @methodGroup Access Requests
2651
+ * @methodGroup Links
2643
2652
  * @namedParams
2644
2653
  * @param {string=} containerId - ID of the container object
2645
2654
  * @param {string=} versionHash - Version hash of the object