@eluvio/elv-client-js 4.0.89 → 4.0.91
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/dist/ElvClient-min.js +10 -10
- package/dist/ElvClient-node-min.js +10 -10
- package/dist/ElvFrameClient-min.js +4 -4
- package/dist/ElvPermissionsClient-min.js +1 -1
- package/dist/ElvWalletClient-min.js +4 -4
- package/dist/ElvWalletClient-node-min.js +6 -6
- package/dist/src/HttpClient.js +26 -2
- package/dist/src/Utils.js +60 -25
- package/dist/src/client/ContentAccess.js +102 -101
- package/dist/src/client/ContentManagement.js +24 -21
- package/dist/src/client/Files.js +75 -86
- package/dist/src/client/LiveConf.js +0 -2
- package/dist/src/client/LiveStream.js +35 -34
- package/package.json +1 -1
- package/src/HttpClient.js +16 -2
- package/src/Utils.js +27 -5
- package/src/client/ContentAccess.js +63 -80
- package/src/client/ContentManagement.js +28 -13
- package/src/client/Files.js +43 -51
- package/src/client/LiveStream.js +5 -1
- package/testScripts/BasicObjectOperations.js +93 -0
|
@@ -328,9 +328,10 @@ exports.CreateContentType = /*#__PURE__*/function () {
|
|
|
328
328
|
case 21:
|
|
329
329
|
rawCreateResponse = _context4.sent;
|
|
330
330
|
// extract the url for the node that handled the request
|
|
331
|
+
// TODO: remove/simplify after we start using /nodes API call to get node URLs for write tokens
|
|
331
332
|
nodeUrl = new URL(rawCreateResponse.url).origin;
|
|
332
333
|
_context4.next = 25;
|
|
333
|
-
return this.utils.ResponseToJson(rawCreateResponse);
|
|
334
|
+
return this.utils.ResponseToJson(rawCreateResponse, this.HttpClient.debug, this.HttpClient.Log.bind(this.HttpClient));
|
|
334
335
|
case 25:
|
|
335
336
|
createResponse = _context4.sent;
|
|
336
337
|
// Record the node used in creating this write token
|
|
@@ -971,9 +972,11 @@ exports.CreateContentObject = /*#__PURE__*/function () {
|
|
|
971
972
|
return _context11.t4.Request.call(_context11.t4, _context11.t8);
|
|
972
973
|
case 65:
|
|
973
974
|
rawCreateResponse = _context11.sent;
|
|
975
|
+
// extract the url for the node that handled the request
|
|
976
|
+
// TODO: remove/simplify after we start using /nodes API call to get node URLs for write tokens
|
|
974
977
|
nodeUrl = new URL(rawCreateResponse.url).origin;
|
|
975
978
|
_context11.next = 69;
|
|
976
|
-
return this.utils.ResponseToJson(rawCreateResponse);
|
|
979
|
+
return this.utils.ResponseToJson(rawCreateResponse, this.HttpClient.debug, this.HttpClient.Log.bind(this.HttpClient));
|
|
977
980
|
case 69:
|
|
978
981
|
createResponse = _context11.sent;
|
|
979
982
|
// Record the node used in creating this write token
|
|
@@ -1315,9 +1318,10 @@ exports.EditContentObject = /*#__PURE__*/function () {
|
|
|
1315
1318
|
case 33:
|
|
1316
1319
|
rawEditResponse = _context15.sent;
|
|
1317
1320
|
// extract the url for the node that handled the request
|
|
1321
|
+
// TODO: remove/simplify after we start using /nodes API call to get node URLs for write tokens
|
|
1318
1322
|
nodeUrl = new URL(rawEditResponse.url).origin;
|
|
1319
1323
|
_context15.next = 37;
|
|
1320
|
-
return this.utils.ResponseToJson(rawEditResponse);
|
|
1324
|
+
return this.utils.ResponseToJson(rawEditResponse, this.HttpClient.debug, this.HttpClient.Log.bind(this.HttpClient));
|
|
1321
1325
|
case 37:
|
|
1322
1326
|
editResponse = _context15.sent;
|
|
1323
1327
|
// Record the node used in creating this write token
|
|
@@ -1651,44 +1655,42 @@ exports.FinalizeContentObject = /*#__PURE__*/function () {
|
|
|
1651
1655
|
return this.AwaitPending(objectId);
|
|
1652
1656
|
case 23:
|
|
1653
1657
|
path = UrlJoin("q", writeToken);
|
|
1654
|
-
_context20.t11 = this.
|
|
1655
|
-
_context20.
|
|
1656
|
-
_context20.next = 28;
|
|
1658
|
+
_context20.t11 = this.HttpClient;
|
|
1659
|
+
_context20.next = 27;
|
|
1657
1660
|
return this.authClient.AuthorizationHeader({
|
|
1658
1661
|
libraryId: libraryId,
|
|
1659
1662
|
objectId: objectId,
|
|
1660
1663
|
update: true
|
|
1661
1664
|
});
|
|
1662
|
-
case
|
|
1663
|
-
_context20.
|
|
1664
|
-
_context20.
|
|
1665
|
-
_context20.
|
|
1666
|
-
headers: _context20.
|
|
1665
|
+
case 27:
|
|
1666
|
+
_context20.t12 = _context20.sent;
|
|
1667
|
+
_context20.t13 = path;
|
|
1668
|
+
_context20.t14 = {
|
|
1669
|
+
headers: _context20.t12,
|
|
1667
1670
|
method: "POST",
|
|
1668
|
-
path: _context20.
|
|
1671
|
+
path: _context20.t13,
|
|
1669
1672
|
allowFailover: false
|
|
1670
1673
|
};
|
|
1671
|
-
_context20.
|
|
1672
|
-
_context20.
|
|
1673
|
-
|
|
1674
|
-
case 34:
|
|
1674
|
+
_context20.next = 32;
|
|
1675
|
+
return _context20.t11.RequestJsonBody.call(_context20.t11, _context20.t14);
|
|
1676
|
+
case 32:
|
|
1675
1677
|
finalizeResponse = _context20.sent;
|
|
1676
1678
|
this.Log("Finalized: ".concat(finalizeResponse.hash));
|
|
1677
1679
|
if (!publish) {
|
|
1678
|
-
_context20.next =
|
|
1680
|
+
_context20.next = 37;
|
|
1679
1681
|
break;
|
|
1680
1682
|
}
|
|
1681
|
-
_context20.next =
|
|
1683
|
+
_context20.next = 37;
|
|
1682
1684
|
return this.PublishContentVersion({
|
|
1683
1685
|
objectId: objectId,
|
|
1684
1686
|
versionHash: finalizeResponse.hash,
|
|
1685
1687
|
awaitCommitConfirmation: awaitCommitConfirmation
|
|
1686
1688
|
});
|
|
1687
|
-
case
|
|
1689
|
+
case 37:
|
|
1688
1690
|
// Invalidate cached content type, if this is one.
|
|
1689
1691
|
delete this.contentTypes[objectId];
|
|
1690
1692
|
return _context20.abrupt("return", finalizeResponse);
|
|
1691
|
-
case
|
|
1693
|
+
case 39:
|
|
1692
1694
|
case "end":
|
|
1693
1695
|
return _context20.stop();
|
|
1694
1696
|
}
|
|
@@ -1735,7 +1737,7 @@ exports.PublishContentVersion = /*#__PURE__*/function () {
|
|
|
1735
1737
|
});
|
|
1736
1738
|
case 9:
|
|
1737
1739
|
abi = _context21.sent;
|
|
1738
|
-
fromBlock = commit.blockNumber
|
|
1740
|
+
fromBlock = commit.blockNumber - 30; // due to block re-org
|
|
1739
1741
|
_context21.next = 13;
|
|
1740
1742
|
return this.ExtractValueFromEvent({
|
|
1741
1743
|
abi: abi,
|
|
@@ -1779,6 +1781,7 @@ exports.PublishContentVersion = /*#__PURE__*/function () {
|
|
|
1779
1781
|
contractAddress: this.utils.HashToAddress(objectId),
|
|
1780
1782
|
abi: abi,
|
|
1781
1783
|
fromBlock: fromBlock,
|
|
1784
|
+
topics: [Ethers.utils.id("VersionConfirm(address,address,string)")],
|
|
1782
1785
|
count: 1000
|
|
1783
1786
|
});
|
|
1784
1787
|
case 27:
|
package/dist/src/client/Files.js
CHANGED
|
@@ -56,25 +56,23 @@ exports.ListFiles = /*#__PURE__*/function () {
|
|
|
56
56
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
57
57
|
}
|
|
58
58
|
urlPath = UrlJoin("q", writeToken || versionHash || objectId, "files_list", path);
|
|
59
|
-
_context.t0 = this.
|
|
60
|
-
_context.
|
|
61
|
-
_context.next = 8;
|
|
59
|
+
_context.t0 = this.HttpClient;
|
|
60
|
+
_context.next = 7;
|
|
62
61
|
return this.authClient.AuthorizationHeader({
|
|
63
62
|
libraryId: libraryId,
|
|
64
63
|
objectId: objectId,
|
|
65
64
|
versionHash: versionHash
|
|
66
65
|
});
|
|
67
|
-
case
|
|
68
|
-
_context.
|
|
69
|
-
_context.
|
|
70
|
-
_context.
|
|
71
|
-
headers: _context.
|
|
66
|
+
case 7:
|
|
67
|
+
_context.t1 = _context.sent;
|
|
68
|
+
_context.t2 = urlPath;
|
|
69
|
+
_context.t3 = {
|
|
70
|
+
headers: _context.t1,
|
|
72
71
|
method: "GET",
|
|
73
|
-
path: _context.
|
|
72
|
+
path: _context.t2
|
|
74
73
|
};
|
|
75
|
-
_context.
|
|
76
|
-
|
|
77
|
-
case 13:
|
|
74
|
+
return _context.abrupt("return", _context.t0.RequestJsonBody.call(_context.t0, _context.t3));
|
|
75
|
+
case 11:
|
|
78
76
|
case "end":
|
|
79
77
|
return _context.stop();
|
|
80
78
|
}
|
|
@@ -159,7 +157,11 @@ exports.UploadFilesFromS3 = /*#__PURE__*/function () {
|
|
|
159
157
|
_context2.next = 5;
|
|
160
158
|
break;
|
|
161
159
|
case 18:
|
|
162
|
-
|
|
160
|
+
if (copy) {
|
|
161
|
+
this.Log("Copying files from S3: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
162
|
+
} else {
|
|
163
|
+
this.Log("Adding links to files in S3: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
164
|
+
}
|
|
163
165
|
if (!(encryption === "cgck")) {
|
|
164
166
|
_context2.next = 25;
|
|
165
167
|
break;
|
|
@@ -700,29 +702,27 @@ exports.CreateFileUploadJob = /*#__PURE__*/function () {
|
|
|
700
702
|
ops: ops
|
|
701
703
|
};
|
|
702
704
|
path = UrlJoin("q", writeToken, "file_jobs");
|
|
703
|
-
_context8.t0 = this.
|
|
704
|
-
_context8.
|
|
705
|
-
_context8.next = 12;
|
|
705
|
+
_context8.t0 = this.HttpClient;
|
|
706
|
+
_context8.next = 11;
|
|
706
707
|
return this.authClient.AuthorizationHeader({
|
|
707
708
|
libraryId: libraryId,
|
|
708
709
|
objectId: objectId,
|
|
709
710
|
update: true,
|
|
710
711
|
encryption: encryption
|
|
711
712
|
});
|
|
712
|
-
case
|
|
713
|
-
_context8.
|
|
714
|
-
_context8.
|
|
715
|
-
_context8.
|
|
716
|
-
_context8.
|
|
717
|
-
headers: _context8.
|
|
713
|
+
case 11:
|
|
714
|
+
_context8.t1 = _context8.sent;
|
|
715
|
+
_context8.t2 = path;
|
|
716
|
+
_context8.t3 = body;
|
|
717
|
+
_context8.t4 = {
|
|
718
|
+
headers: _context8.t1,
|
|
718
719
|
method: "POST",
|
|
719
|
-
path: _context8.
|
|
720
|
-
body: _context8.
|
|
720
|
+
path: _context8.t2,
|
|
721
|
+
body: _context8.t3,
|
|
721
722
|
allowFailover: false
|
|
722
723
|
};
|
|
723
|
-
_context8.
|
|
724
|
-
|
|
725
|
-
case 18:
|
|
724
|
+
return _context8.abrupt("return", _context8.t0.RequestJsonBody.call(_context8.t0, _context8.t4));
|
|
725
|
+
case 16:
|
|
726
726
|
case "end":
|
|
727
727
|
return _context8.stop();
|
|
728
728
|
}
|
|
@@ -1375,29 +1375,27 @@ exports.ContentParts = /*#__PURE__*/function () {
|
|
|
1375
1375
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1376
1376
|
}
|
|
1377
1377
|
path = UrlJoin("q", versionHash || objectId, "parts");
|
|
1378
|
-
_context17.t0 = this.
|
|
1379
|
-
_context17.
|
|
1380
|
-
_context17.next = 9;
|
|
1378
|
+
_context17.t0 = this.HttpClient;
|
|
1379
|
+
_context17.next = 8;
|
|
1381
1380
|
return this.authClient.AuthorizationHeader({
|
|
1382
1381
|
libraryId: libraryId,
|
|
1383
1382
|
objectId: objectId,
|
|
1384
1383
|
versionHash: versionHash
|
|
1385
1384
|
});
|
|
1386
|
-
case
|
|
1387
|
-
_context17.
|
|
1388
|
-
_context17.
|
|
1389
|
-
_context17.
|
|
1390
|
-
headers: _context17.
|
|
1385
|
+
case 8:
|
|
1386
|
+
_context17.t1 = _context17.sent;
|
|
1387
|
+
_context17.t2 = path;
|
|
1388
|
+
_context17.t3 = {
|
|
1389
|
+
headers: _context17.t1,
|
|
1391
1390
|
method: "GET",
|
|
1392
|
-
path: _context17.
|
|
1391
|
+
path: _context17.t2
|
|
1393
1392
|
};
|
|
1394
|
-
_context17.
|
|
1395
|
-
_context17.
|
|
1396
|
-
|
|
1397
|
-
case 15:
|
|
1393
|
+
_context17.next = 13;
|
|
1394
|
+
return _context17.t0.RequestJsonBody.call(_context17.t0, _context17.t3);
|
|
1395
|
+
case 13:
|
|
1398
1396
|
response = _context17.sent;
|
|
1399
1397
|
return _context17.abrupt("return", response.parts);
|
|
1400
|
-
case
|
|
1398
|
+
case 15:
|
|
1401
1399
|
case "end":
|
|
1402
1400
|
return _context17.stop();
|
|
1403
1401
|
}
|
|
@@ -1439,28 +1437,26 @@ exports.ContentPart = /*#__PURE__*/function () {
|
|
|
1439
1437
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1440
1438
|
}
|
|
1441
1439
|
path = UrlJoin("q", versionHash || objectId, "parts", partHash);
|
|
1442
|
-
_context18.t0 = this.
|
|
1443
|
-
_context18.
|
|
1444
|
-
_context18.next = 10;
|
|
1440
|
+
_context18.t0 = this.HttpClient;
|
|
1441
|
+
_context18.next = 9;
|
|
1445
1442
|
return this.authClient.AuthorizationHeader({
|
|
1446
1443
|
libraryId: libraryId,
|
|
1447
1444
|
objectId: objectId,
|
|
1448
1445
|
versionHash: versionHash
|
|
1449
1446
|
});
|
|
1450
|
-
case
|
|
1451
|
-
_context18.
|
|
1452
|
-
_context18.
|
|
1453
|
-
_context18.
|
|
1454
|
-
headers: _context18.
|
|
1447
|
+
case 9:
|
|
1448
|
+
_context18.t1 = _context18.sent;
|
|
1449
|
+
_context18.t2 = path;
|
|
1450
|
+
_context18.t3 = {
|
|
1451
|
+
headers: _context18.t1,
|
|
1455
1452
|
method: "GET",
|
|
1456
|
-
path: _context18.
|
|
1453
|
+
path: _context18.t2
|
|
1457
1454
|
};
|
|
1458
|
-
_context18.
|
|
1459
|
-
_context18.
|
|
1460
|
-
|
|
1461
|
-
case 16:
|
|
1455
|
+
_context18.next = 14;
|
|
1456
|
+
return _context18.t0.RequestJsonBody.call(_context18.t0, _context18.t3);
|
|
1457
|
+
case 14:
|
|
1462
1458
|
return _context18.abrupt("return", _context18.sent);
|
|
1463
|
-
case
|
|
1459
|
+
case 15:
|
|
1464
1460
|
case "end":
|
|
1465
1461
|
return _context18.stop();
|
|
1466
1462
|
}
|
|
@@ -1856,33 +1852,31 @@ exports.CreatePart = /*#__PURE__*/function () {
|
|
|
1856
1852
|
});
|
|
1857
1853
|
ValidateWriteToken(writeToken);
|
|
1858
1854
|
path = UrlJoin("q", writeToken, "parts");
|
|
1859
|
-
_context23.t0 = this.
|
|
1860
|
-
_context23.
|
|
1861
|
-
_context23.next = 8;
|
|
1855
|
+
_context23.t0 = this.HttpClient;
|
|
1856
|
+
_context23.next = 7;
|
|
1862
1857
|
return this.authClient.AuthorizationHeader({
|
|
1863
1858
|
libraryId: libraryId,
|
|
1864
1859
|
objectId: objectId,
|
|
1865
1860
|
update: true,
|
|
1866
1861
|
encryption: encryption
|
|
1867
1862
|
});
|
|
1868
|
-
case
|
|
1869
|
-
_context23.
|
|
1870
|
-
_context23.
|
|
1871
|
-
_context23.
|
|
1872
|
-
headers: _context23.
|
|
1863
|
+
case 7:
|
|
1864
|
+
_context23.t1 = _context23.sent;
|
|
1865
|
+
_context23.t2 = path;
|
|
1866
|
+
_context23.t3 = {
|
|
1867
|
+
headers: _context23.t1,
|
|
1873
1868
|
method: "POST",
|
|
1874
|
-
path: _context23.
|
|
1869
|
+
path: _context23.t2,
|
|
1875
1870
|
bodyType: "BINARY",
|
|
1876
1871
|
body: "",
|
|
1877
1872
|
allowFailover: false
|
|
1878
1873
|
};
|
|
1879
|
-
_context23.
|
|
1880
|
-
_context23.
|
|
1881
|
-
|
|
1882
|
-
case 14:
|
|
1874
|
+
_context23.next = 12;
|
|
1875
|
+
return _context23.t0.RequestJsonBody.call(_context23.t0, _context23.t3);
|
|
1876
|
+
case 12:
|
|
1883
1877
|
openResponse = _context23.sent;
|
|
1884
1878
|
return _context23.abrupt("return", openResponse.part.write_token);
|
|
1885
|
-
case
|
|
1879
|
+
case 14:
|
|
1886
1880
|
case "end":
|
|
1887
1881
|
return _context23.stop();
|
|
1888
1882
|
}
|
|
@@ -2000,35 +1994,30 @@ exports.FinalizePart = /*#__PURE__*/function () {
|
|
|
2000
1994
|
});
|
|
2001
1995
|
ValidateWriteToken(writeToken);
|
|
2002
1996
|
path = UrlJoin("q", writeToken, "parts");
|
|
2003
|
-
_context25.t0 = this.
|
|
2004
|
-
_context25.
|
|
2005
|
-
_context25.next = 8;
|
|
1997
|
+
_context25.t0 = this.HttpClient;
|
|
1998
|
+
_context25.next = 7;
|
|
2006
1999
|
return this.authClient.AuthorizationHeader({
|
|
2007
2000
|
libraryId: libraryId,
|
|
2008
2001
|
objectId: objectId,
|
|
2009
2002
|
update: true,
|
|
2010
2003
|
encryption: encryption
|
|
2011
2004
|
});
|
|
2012
|
-
case
|
|
2013
|
-
_context25.
|
|
2014
|
-
_context25.
|
|
2015
|
-
_context25.
|
|
2016
|
-
headers: _context25.
|
|
2005
|
+
case 7:
|
|
2006
|
+
_context25.t1 = _context25.sent;
|
|
2007
|
+
_context25.t2 = UrlJoin(path, partWriteToken);
|
|
2008
|
+
_context25.t3 = {
|
|
2009
|
+
headers: _context25.t1,
|
|
2017
2010
|
method: "POST",
|
|
2018
|
-
path: _context25.
|
|
2011
|
+
path: _context25.t2,
|
|
2019
2012
|
bodyType: "BINARY",
|
|
2020
2013
|
body: "",
|
|
2021
2014
|
allowFailover: false
|
|
2022
2015
|
};
|
|
2023
|
-
_context25.next =
|
|
2024
|
-
return _context25.
|
|
2025
|
-
case
|
|
2026
|
-
_context25.t5 = _context25.sent;
|
|
2027
|
-
_context25.next = 16;
|
|
2028
|
-
return _context25.t0.ResponseToJson.call(_context25.t0, _context25.t5);
|
|
2029
|
-
case 16:
|
|
2016
|
+
_context25.next = 12;
|
|
2017
|
+
return _context25.t0.RequestJsonBody.call(_context25.t0, _context25.t3);
|
|
2018
|
+
case 12:
|
|
2030
2019
|
return _context25.abrupt("return", _context25.sent);
|
|
2031
|
-
case
|
|
2020
|
+
case 13:
|
|
2032
2021
|
case "end":
|
|
2033
2022
|
return _context25.stop();
|
|
2034
2023
|
}
|
|
@@ -317,7 +317,6 @@ var LiveConf = /*#__PURE__*/function () {
|
|
|
317
317
|
break;
|
|
318
318
|
default:
|
|
319
319
|
throw "unsupported frame rate for MPEGTS - " + frameRate;
|
|
320
|
-
break;
|
|
321
320
|
}
|
|
322
321
|
return seg;
|
|
323
322
|
}
|
|
@@ -379,7 +378,6 @@ var LiveConf = /*#__PURE__*/function () {
|
|
|
379
378
|
break;
|
|
380
379
|
default:
|
|
381
380
|
throw "unsupported frame rate for RTMP - " + frameRate;
|
|
382
|
-
break;
|
|
383
381
|
}
|
|
384
382
|
return seg;
|
|
385
383
|
}
|
|
@@ -1664,7 +1664,7 @@ exports.StreamInsertion = /*#__PURE__*/function () {
|
|
|
1664
1664
|
*/
|
|
1665
1665
|
exports.StreamConfig = /*#__PURE__*/function () {
|
|
1666
1666
|
var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref21) {
|
|
1667
|
-
var name, _ref21$customSettings, customSettings, probeMetadata, objectId, status, libraryId, probe, mainMeta, userConfig, hostName, streamUrl, nodes, node, endpoint, controller, timeoutId, probeUrl, lc, liveRecordingConfig, e, writeToken;
|
|
1667
|
+
var name, _ref21$customSettings, customSettings, probeMetadata, objectId, status, libraryId, probe, mainMeta, userConfig, parsedName, hostName, streamUrl, nodes, node, endpoint, controller, timeoutId, probeUrl, lc, liveRecordingConfig, e, writeToken;
|
|
1668
1668
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
1669
1669
|
while (1) switch (_context11.prev = _context11.next) {
|
|
1670
1670
|
case 0:
|
|
@@ -1693,22 +1693,23 @@ exports.StreamConfig = /*#__PURE__*/function () {
|
|
|
1693
1693
|
status.user_config = userConfig;
|
|
1694
1694
|
|
|
1695
1695
|
// Get node URI from user config
|
|
1696
|
-
|
|
1696
|
+
parsedName = userConfig.url.replace("udp://", "https://").replace("rtmp://", "https://").replace("srt://", "https://");
|
|
1697
|
+
hostName = new URL(parsedName).hostname;
|
|
1697
1698
|
streamUrl = new URL(userConfig.url);
|
|
1698
1699
|
console.log("Retrieving nodes - matching", hostName);
|
|
1699
|
-
_context11.next =
|
|
1700
|
+
_context11.next = 20;
|
|
1700
1701
|
return this.SpaceNodes({
|
|
1701
1702
|
matchEndpoint: hostName
|
|
1702
1703
|
});
|
|
1703
|
-
case
|
|
1704
|
+
case 20:
|
|
1704
1705
|
nodes = _context11.sent;
|
|
1705
1706
|
if (!(nodes.length < 1)) {
|
|
1706
|
-
_context11.next =
|
|
1707
|
+
_context11.next = 24;
|
|
1707
1708
|
break;
|
|
1708
1709
|
}
|
|
1709
1710
|
status.error = "No node matching stream URL " + streamUrl.href;
|
|
1710
1711
|
return _context11.abrupt("return", status);
|
|
1711
|
-
case
|
|
1712
|
+
case 24:
|
|
1712
1713
|
node = {
|
|
1713
1714
|
endpoints: nodes[0].services.fabric_api.urls,
|
|
1714
1715
|
id: nodes[0].id
|
|
@@ -1716,7 +1717,7 @@ exports.StreamConfig = /*#__PURE__*/function () {
|
|
|
1716
1717
|
status.node = node;
|
|
1717
1718
|
endpoint = node.endpoints[0];
|
|
1718
1719
|
if (probe) {
|
|
1719
|
-
_context11.next =
|
|
1720
|
+
_context11.next = 56;
|
|
1720
1721
|
break;
|
|
1721
1722
|
}
|
|
1722
1723
|
this.SetNodes({
|
|
@@ -1729,17 +1730,17 @@ exports.StreamConfig = /*#__PURE__*/function () {
|
|
|
1729
1730
|
timeoutId = setTimeout(function () {
|
|
1730
1731
|
controller.abort();
|
|
1731
1732
|
}, 60 * 1000); // milliseconds
|
|
1732
|
-
_context11.prev =
|
|
1733
|
-
_context11.next =
|
|
1733
|
+
_context11.prev = 32;
|
|
1734
|
+
_context11.next = 35;
|
|
1734
1735
|
return this.Rep({
|
|
1735
1736
|
libraryId: libraryId,
|
|
1736
1737
|
objectId: objectId,
|
|
1737
1738
|
rep: "probe"
|
|
1738
1739
|
});
|
|
1739
|
-
case
|
|
1740
|
+
case 35:
|
|
1740
1741
|
probeUrl = _context11.sent;
|
|
1741
1742
|
_context11.t0 = this.utils;
|
|
1742
|
-
_context11.next =
|
|
1743
|
+
_context11.next = 39;
|
|
1743
1744
|
return HttpClient.Fetch(probeUrl, {
|
|
1744
1745
|
body: JSON.stringify({
|
|
1745
1746
|
"filename": streamUrl.href,
|
|
@@ -1748,50 +1749,50 @@ exports.StreamConfig = /*#__PURE__*/function () {
|
|
|
1748
1749
|
method: "POST",
|
|
1749
1750
|
signal: controller.signal
|
|
1750
1751
|
});
|
|
1751
|
-
case
|
|
1752
|
+
case 39:
|
|
1752
1753
|
_context11.t1 = _context11.sent;
|
|
1753
|
-
_context11.next =
|
|
1754
|
+
_context11.next = 42;
|
|
1754
1755
|
return _context11.t0.ResponseToJson.call(_context11.t0, _context11.t1);
|
|
1755
|
-
case
|
|
1756
|
+
case 42:
|
|
1756
1757
|
probe = _context11.sent;
|
|
1757
1758
|
if (probe) {
|
|
1758
1759
|
clearTimeout(timeoutId);
|
|
1759
1760
|
}
|
|
1760
1761
|
if (!probe.errors) {
|
|
1761
|
-
_context11.next =
|
|
1762
|
+
_context11.next = 46;
|
|
1762
1763
|
break;
|
|
1763
1764
|
}
|
|
1764
1765
|
throw probe.errors[0];
|
|
1765
|
-
case
|
|
1766
|
-
_context11.next =
|
|
1766
|
+
case 46:
|
|
1767
|
+
_context11.next = 55;
|
|
1767
1768
|
break;
|
|
1768
|
-
case
|
|
1769
|
-
_context11.prev =
|
|
1770
|
-
_context11.t2 = _context11["catch"](
|
|
1769
|
+
case 48:
|
|
1770
|
+
_context11.prev = 48;
|
|
1771
|
+
_context11.t2 = _context11["catch"](32);
|
|
1771
1772
|
if (!(_context11.t2.code === "ETIMEDOUT")) {
|
|
1772
|
-
_context11.next =
|
|
1773
|
+
_context11.next = 54;
|
|
1773
1774
|
break;
|
|
1774
1775
|
}
|
|
1775
1776
|
throw "Stream probe time out - make sure the stream source is available";
|
|
1776
|
-
case 53:
|
|
1777
|
-
throw _context11.t2;
|
|
1778
1777
|
case 54:
|
|
1779
|
-
|
|
1778
|
+
throw _context11.t2;
|
|
1780
1779
|
case 55:
|
|
1780
|
+
probe.format.filename = streamUrl.href;
|
|
1781
|
+
case 56:
|
|
1781
1782
|
// Create live recording config
|
|
1782
1783
|
lc = new LiveConf(probe, node.id, endpoint, false, false, true);
|
|
1783
1784
|
liveRecordingConfig = lc.generateLiveConf({
|
|
1784
1785
|
customSettings: customSettings
|
|
1785
1786
|
}); // Store live recording config into the stream object
|
|
1786
|
-
_context11.next =
|
|
1787
|
+
_context11.next = 60;
|
|
1787
1788
|
return this.EditContentObject({
|
|
1788
1789
|
libraryId: libraryId,
|
|
1789
1790
|
objectId: objectId
|
|
1790
1791
|
});
|
|
1791
|
-
case
|
|
1792
|
+
case 60:
|
|
1792
1793
|
e = _context11.sent;
|
|
1793
1794
|
writeToken = e.write_token;
|
|
1794
|
-
_context11.next =
|
|
1795
|
+
_context11.next = 64;
|
|
1795
1796
|
return this.ReplaceMetadata({
|
|
1796
1797
|
libraryId: libraryId,
|
|
1797
1798
|
objectId: objectId,
|
|
@@ -1799,8 +1800,8 @@ exports.StreamConfig = /*#__PURE__*/function () {
|
|
|
1799
1800
|
metadataSubtree: "live_recording",
|
|
1800
1801
|
metadata: liveRecordingConfig.live_recording
|
|
1801
1802
|
});
|
|
1802
|
-
case
|
|
1803
|
-
_context11.next =
|
|
1803
|
+
case 64:
|
|
1804
|
+
_context11.next = 66;
|
|
1804
1805
|
return this.ReplaceMetadata({
|
|
1805
1806
|
libraryId: libraryId,
|
|
1806
1807
|
objectId: objectId,
|
|
@@ -1808,22 +1809,22 @@ exports.StreamConfig = /*#__PURE__*/function () {
|
|
|
1808
1809
|
metadataSubtree: "live_recording_config/probe_info",
|
|
1809
1810
|
metadata: probe
|
|
1810
1811
|
});
|
|
1811
|
-
case
|
|
1812
|
-
_context11.next =
|
|
1812
|
+
case 66:
|
|
1813
|
+
_context11.next = 68;
|
|
1813
1814
|
return this.FinalizeContentObject({
|
|
1814
1815
|
libraryId: libraryId,
|
|
1815
1816
|
objectId: objectId,
|
|
1816
1817
|
writeToken: writeToken,
|
|
1817
1818
|
commitMessage: "Apply live stream configuration"
|
|
1818
1819
|
});
|
|
1819
|
-
case
|
|
1820
|
+
case 68:
|
|
1820
1821
|
status.fin = _context11.sent;
|
|
1821
1822
|
return _context11.abrupt("return", status);
|
|
1822
|
-
case
|
|
1823
|
+
case 70:
|
|
1823
1824
|
case "end":
|
|
1824
1825
|
return _context11.stop();
|
|
1825
1826
|
}
|
|
1826
|
-
}, _callee11, this, [[
|
|
1827
|
+
}, _callee11, this, [[32, 48]]);
|
|
1827
1828
|
}));
|
|
1828
1829
|
return function (_x11) {
|
|
1829
1830
|
return _ref22.apply(this, arguments);
|
package/package.json
CHANGED
package/src/HttpClient.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const URI = require("urijs");
|
|
2
2
|
const Fetch = typeof fetch !== "undefined" ? fetch : require("node-fetch").default;
|
|
3
3
|
const {LogMessage} = require("./LogMessage");
|
|
4
|
+
const Utils = require("./Utils");
|
|
4
5
|
|
|
5
6
|
class HttpClient {
|
|
6
7
|
Log(message, error=false) {
|
|
@@ -100,7 +101,10 @@ class HttpClient {
|
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
let response;
|
|
103
|
-
this.
|
|
104
|
+
if(this.debug) {
|
|
105
|
+
this.Log(`${method} - ${uri.toString()}`);
|
|
106
|
+
this.Log(`fetchParameters: ${JSON.stringify(fetchParameters, null, 2)}`);
|
|
107
|
+
}
|
|
104
108
|
try {
|
|
105
109
|
response =
|
|
106
110
|
await HttpClient.Fetch(
|
|
@@ -166,7 +170,7 @@ class HttpClient {
|
|
|
166
170
|
requestParams: fetchParameters
|
|
167
171
|
};
|
|
168
172
|
|
|
169
|
-
this.Log(
|
|
173
|
+
if(this.debug) this.Log(
|
|
170
174
|
JSON.stringify(error, null, 2),
|
|
171
175
|
true
|
|
172
176
|
);
|
|
@@ -208,6 +212,16 @@ class HttpClient {
|
|
|
208
212
|
);
|
|
209
213
|
}
|
|
210
214
|
|
|
215
|
+
// Perform http request and then return response body parsed as JSON
|
|
216
|
+
// ResponseToJson() will log response if this.debug === true
|
|
217
|
+
async RequestJsonBody(params) {
|
|
218
|
+
return Utils.ResponseToJson(
|
|
219
|
+
this.Request(params),
|
|
220
|
+
this.debug,
|
|
221
|
+
this.Log.bind(this)
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
211
225
|
URL({path, queryParams={}}) {
|
|
212
226
|
let baseURI = this.BaseURI();
|
|
213
227
|
|