@eluvio/elv-client-js 4.0.18 → 4.0.19

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.
@@ -422,7 +422,7 @@ var FrameClient = /*#__PURE__*/function () {
422
422
  }, {
423
423
  key: "FileMethods",
424
424
  value: function FileMethods() {
425
- return ["DownloadFile", "DownloadPart", "UpdateContentObjectGraph", "UploadFiles", "UploadFilesFromS3", "UploadPart", "UploadPartChunk"];
425
+ return ["CreateFileUploadJob", "DownloadEncrypted", "DownloadFile", "DownloadPart", "FinalizeUploadJob", "UpdateContentObjectGraph", "UploadFileData", "UploadFiles", "UploadFilesFromS3", "UploadJobStatus", "UploadPart", "UploadPartChunk", "UploadStatus"];
426
426
  }
427
427
  }]);
428
428
  return FrameClient;
@@ -558,8 +558,10 @@ exports.UploadFiles = /*#__PURE__*/function () {
558
558
  return function UploadJob(_x4, _x5) {
559
559
  return _ref8.apply(this, arguments);
560
560
  };
561
- }(); // Preparing jobs is done asyncronously
562
- PrepareJobs();
561
+ }(); // Preparing jobs is done asynchronously
562
+ PrepareJobs()["catch"](function (e) {
563
+ throw e;
564
+ });
563
565
 
564
566
  // Upload the first several chunks in sequence, to determine average upload rate
565
567
  rateTestJobs = Math.min(3, jobs.length);
@@ -768,7 +770,7 @@ exports.UploadJobStatus = /*#__PURE__*/function () {
768
770
  }();
769
771
  exports.UploadFileData = /*#__PURE__*/function () {
770
772
  var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref16) {
771
- var libraryId, objectId, writeToken, uploadId, jobId, fileData, path;
773
+ var libraryId, objectId, writeToken, uploadId, jobId, fileData, retries, jobStatus, path;
772
774
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
773
775
  while (1) switch (_context10.prev = _context10.next) {
774
776
  case 0:
@@ -778,6 +780,29 @@ exports.UploadFileData = /*#__PURE__*/function () {
778
780
  objectId: objectId
779
781
  });
780
782
  ValidateWriteToken(writeToken);
783
+ retries = 0;
784
+ case 4:
785
+ _context10.prev = 4;
786
+ _context10.next = 7;
787
+ return this.UploadJobStatus({
788
+ libraryId: libraryId,
789
+ objectId: objectId,
790
+ writeToken: writeToken,
791
+ uploadId: uploadId,
792
+ jobId: jobId
793
+ });
794
+ case 7:
795
+ jobStatus = _context10.sent;
796
+ if (!(jobStatus.rem === 0)) {
797
+ _context10.next = 12;
798
+ break;
799
+ }
800
+ return _context10.abrupt("return");
801
+ case 12:
802
+ if (jobStatus.skip) {
803
+ fileData = fileData.slice(jobStatus.skip);
804
+ }
805
+ case 13:
781
806
  path = UrlJoin("q", writeToken, "file_jobs", uploadId, jobId);
782
807
  _context10.t0 = this.utils;
783
808
  _context10.t1 = this.HttpClient;
@@ -787,13 +812,13 @@ exports.UploadFileData = /*#__PURE__*/function () {
787
812
  _context10.t5 = {
788
813
  "Content-type": "application/octet-stream"
789
814
  };
790
- _context10.next = 12;
815
+ _context10.next = 22;
791
816
  return this.authClient.AuthorizationHeader({
792
817
  libraryId: libraryId,
793
818
  objectId: objectId,
794
819
  update: true
795
820
  });
796
- case 12:
821
+ case 22:
797
822
  _context10.t6 = _context10.sent;
798
823
  _context10.t7 = (0, _context10.t4)(_context10.t5, _context10.t6);
799
824
  _context10.t8 = {
@@ -805,13 +830,35 @@ exports.UploadFileData = /*#__PURE__*/function () {
805
830
  failover: false
806
831
  };
807
832
  _context10.t9 = _context10.t1.Request.call(_context10.t1, _context10.t8);
808
- _context10.next = 18;
833
+ _context10.next = 28;
809
834
  return _context10.t0.ResponseToJson.call(_context10.t0, _context10.t9);
810
- case 18:
835
+ case 28:
836
+ return _context10.abrupt("return", _context10.sent);
837
+ case 31:
838
+ _context10.prev = 31;
839
+ _context10.t10 = _context10["catch"](4);
840
+ this.Log(_context10.t10, true);
841
+ retries += 1;
842
+ if (!(retries >= 5)) {
843
+ _context10.next = 37;
844
+ break;
845
+ }
846
+ throw _context10.t10;
847
+ case 37:
848
+ _context10.next = 39;
849
+ return new Promise(function (resolve) {
850
+ return setTimeout(resolve, 10 * retries * 1000);
851
+ });
852
+ case 39:
853
+ if (retries < 5) {
854
+ _context10.next = 4;
855
+ break;
856
+ }
857
+ case 40:
811
858
  case "end":
812
859
  return _context10.stop();
813
860
  }
814
- }, _callee10, this);
861
+ }, _callee10, this, [[4, 31]]);
815
862
  }));
816
863
  return function (_x11) {
817
864
  return _ref17.apply(this, arguments);
@@ -2482,8 +2482,6 @@ exports.RejectMarketplaceOffer = /*#__PURE__*/function () {
2482
2482
  /* Voting */
2483
2483
 
2484
2484
  /**
2485
- * <b><i>Requires login</i></b>
2486
- *
2487
2485
  * Retrieve the current status of the specified voting event
2488
2486
  *
2489
2487
  * @methodGroup Voting
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.18",
3
+ "version": "4.0.19",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
@@ -54,7 +54,6 @@ class FrameClient {
54
54
  this.Crypto = Crypto;
55
55
  this.Crypto.ElvCrypto();
56
56
 
57
-
58
57
  // Dynamically defined methods defined in AllowedMethods
59
58
  for(const methodName of this.AllowedMethods()){
60
59
  this[methodName] = async (args) => {
@@ -258,13 +257,19 @@ class FrameClient {
258
257
 
259
258
  static FileMethods() {
260
259
  return [
260
+ "CreateFileUploadJob",
261
+ "DownloadEncrypted",
261
262
  "DownloadFile",
262
263
  "DownloadPart",
264
+ "FinalizeUploadJob",
263
265
  "UpdateContentObjectGraph",
266
+ "UploadFileData",
264
267
  "UploadFiles",
265
268
  "UploadFilesFromS3",
269
+ "UploadJobStatus",
266
270
  "UploadPart",
267
- "UploadPartChunk"
271
+ "UploadPartChunk",
272
+ "UploadStatus"
268
273
  ];
269
274
  }
270
275
 
@@ -403,8 +403,10 @@ exports.UploadFiles = async function({libraryId, objectId, writeToken, fileInfo,
403
403
  }
404
404
  };
405
405
 
406
- // Preparing jobs is done asyncronously
407
- PrepareJobs();
406
+ // Preparing jobs is done asynchronously
407
+ PrepareJobs().catch(e => {
408
+ throw e;
409
+ });
408
410
 
409
411
  // Upload the first several chunks in sequence, to determine average upload rate
410
412
  const rateTestJobs = Math.min(3, jobs.length);
@@ -499,21 +501,45 @@ exports.UploadFileData = async function({libraryId, objectId, writeToken, upload
499
501
  ValidateParameters({libraryId, objectId});
500
502
  ValidateWriteToken(writeToken);
501
503
 
502
- let path = UrlJoin("q", writeToken, "file_jobs", uploadId, jobId);
504
+ let retries = 0;
505
+ do {
506
+ try {
507
+ const jobStatus = await this.UploadJobStatus({libraryId, objectId, writeToken, uploadId, jobId});
503
508
 
504
- await this.utils.ResponseToJson(
505
- this.HttpClient.Request({
506
- method: "POST",
507
- path: path,
508
- body: fileData,
509
- bodyType: "BINARY",
510
- headers: {
511
- "Content-type": "application/octet-stream",
512
- ...(await this.authClient.AuthorizationHeader({libraryId, objectId, update: true}))
513
- },
514
- failover: false
515
- })
516
- );
509
+ if(jobStatus.rem === 0) {
510
+ // Job is actually done
511
+ return;
512
+ } else if(jobStatus.skip) {
513
+ fileData = fileData.slice(jobStatus.skip);
514
+ }
515
+
516
+ let path = UrlJoin("q", writeToken, "file_jobs", uploadId, jobId);
517
+
518
+ return await this.utils.ResponseToJson(
519
+ this.HttpClient.Request({
520
+ method: "POST",
521
+ path: path,
522
+ body: fileData,
523
+ bodyType: "BINARY",
524
+ headers: {
525
+ "Content-type": "application/octet-stream",
526
+ ...(await this.authClient.AuthorizationHeader({libraryId, objectId, update: true}))
527
+ },
528
+ failover: false
529
+ })
530
+ );
531
+ } catch(error){
532
+ this.Log(error, true);
533
+
534
+ retries += 1;
535
+
536
+ if(retries >= 5) {
537
+ throw error;
538
+ }
539
+
540
+ await new Promise(resolve => setTimeout(resolve, 10 * retries * 1000));
541
+ }
542
+ } while(retries < 5);
517
543
  };
518
544
 
519
545
  exports.FinalizeUploadJob = async function({libraryId, objectId, writeToken}) {
@@ -1481,8 +1481,6 @@ exports.RejectMarketplaceOffer = async function({offerId}) {
1481
1481
  /* Voting */
1482
1482
 
1483
1483
  /**
1484
- * <b><i>Requires login</i></b>
1485
- *
1486
1484
  * Retrieve the current status of the specified voting event
1487
1485
  *
1488
1486
  * @methodGroup Voting