@eluvio/elv-client-js 4.0.11 → 4.0.13

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.
Files changed (111) hide show
  1. package/dist/.keep +0 -0
  2. package/dist/ElvClient-min.js +11 -10
  3. package/dist/ElvClient-node-min.js +11 -10
  4. package/dist/ElvFrameClient-min.js +11 -10
  5. package/dist/ElvPermissionsClient-min.js +10 -9
  6. package/dist/ElvWalletClient-min.js +10 -9
  7. package/dist/ElvWalletClient-node-min.js +10 -9
  8. package/dist/src/AuthorizationClient.js +1555 -2076
  9. package/dist/src/ContentObjectVerification.js +134 -185
  10. package/dist/src/Crypto.js +224 -319
  11. package/dist/src/ElvClient.js +822 -1114
  12. package/dist/src/ElvWallet.js +64 -106
  13. package/dist/src/EthClient.js +719 -974
  14. package/dist/src/FrameClient.js +223 -319
  15. package/dist/src/HttpClient.js +117 -156
  16. package/dist/src/Id.js +1 -6
  17. package/dist/src/LogMessage.js +4 -8
  18. package/dist/src/PermissionsClient.js +973 -1271
  19. package/dist/src/RemoteSigner.js +161 -232
  20. package/dist/src/UserProfileClient.js +781 -1038
  21. package/dist/src/Utils.js +159 -299
  22. package/dist/src/Validation.js +2 -17
  23. package/dist/src/client/ABRPublishing.js +828 -958
  24. package/dist/src/client/AccessGroups.js +849 -1095
  25. package/dist/src/client/ContentAccess.js +3323 -4195
  26. package/dist/src/client/ContentManagement.js +1818 -2290
  27. package/dist/src/client/Contracts.js +468 -614
  28. package/dist/src/client/Files.js +1506 -1846
  29. package/dist/src/client/NFT.js +94 -116
  30. package/dist/src/client/NTP.js +326 -425
  31. package/dist/src/index.js +2 -5
  32. package/dist/src/walletClient/ClientMethods.js +1368 -1763
  33. package/dist/src/walletClient/Configuration.js +5 -3
  34. package/dist/src/walletClient/Notifications.js +98 -127
  35. package/dist/src/walletClient/Profile.js +184 -246
  36. package/dist/src/walletClient/Utils.js +76 -122
  37. package/dist/src/walletClient/index.js +1171 -1496
  38. package/package.json +4 -21
  39. package/src/FrameClient.js +1 -0
  40. package/src/HttpClient.js +4 -2
  41. package/src/client/ABRPublishing.js +126 -105
  42. package/src/client/ContentAccess.js +1 -0
  43. package/src/client/ContentManagement.js +4 -2
  44. package/src/walletClient/Configuration.js +3 -2
  45. package/dist/AccessClient-min.js +0 -54
  46. package/dist/AccessClient-node-min.js +0 -74
  47. package/dist/src/AccessClient.js +0 -798
  48. package/dist/src/LimitedMap.js +0 -120
  49. package/dist/src/client/Access.js +0 -1
  50. package/dist/src/client/Management.js +0 -1606
  51. package/dist/src/contracts/AccessIndexor.js +0 -831
  52. package/dist/src/contracts/Accessible.js +0 -31
  53. package/dist/src/contracts/AdmgrAdvertisement.js +0 -695
  54. package/dist/src/contracts/AdmgrCampaign.js +0 -648
  55. package/dist/src/contracts/AdmgrCampaignManager.js +0 -493
  56. package/dist/src/contracts/AdmgrCommercialOffering.js +0 -622
  57. package/dist/src/contracts/AdmgrCommercialOfferingManager.js +0 -413
  58. package/dist/src/contracts/AdmgrMarketPlace.js +0 -413
  59. package/dist/src/contracts/AvailsDelivery.js +0 -535
  60. package/dist/src/contracts/BaseAccessControlGroup.js +0 -1221
  61. package/dist/src/contracts/BaseAccessWallet.js +0 -1575
  62. package/dist/src/contracts/BaseAccessWalletFactory.js +0 -93
  63. package/dist/src/contracts/BaseContent.js +0 -1104
  64. package/dist/src/contracts/BaseContentFactory.js +0 -99
  65. package/dist/src/contracts/BaseContentFactoryExt.js +0 -219
  66. package/dist/src/contracts/BaseContentSpace.js +0 -1346
  67. package/dist/src/contracts/BaseContentType.js +0 -353
  68. package/dist/src/contracts/BaseFactory.js +0 -107
  69. package/dist/src/contracts/BaseGroupFactory.js +0 -93
  70. package/dist/src/contracts/BaseLibrary.js +0 -1035
  71. package/dist/src/contracts/BaseLibraryFactory.js +0 -96
  72. package/dist/src/contracts/Certifyer.js +0 -87
  73. package/dist/src/contracts/Container.js +0 -543
  74. package/dist/src/contracts/Content.js +0 -432
  75. package/dist/src/contracts/Editable.js +0 -295
  76. package/dist/src/contracts/FactorySpace.js +0 -57
  77. package/dist/src/contracts/KmsSpace.js +0 -52
  78. package/dist/src/contracts/LvProvider.js +0 -512
  79. package/dist/src/contracts/LvRecordableStream.js +0 -1026
  80. package/dist/src/contracts/LvRecording.js +0 -627
  81. package/dist/src/contracts/LvStreamRightsHolder.js +0 -551
  82. package/dist/src/contracts/MetaObject.js +0 -110
  83. package/dist/src/contracts/Node.js +0 -167
  84. package/dist/src/contracts/NodeSpace.js +0 -18
  85. package/dist/src/contracts/NodeSpaceImpl.js +0 -273
  86. package/dist/src/contracts/Ownable.js +0 -87
  87. package/dist/src/contracts/PaymentService.js +0 -616
  88. package/dist/src/contracts/Precompile.js +0 -15
  89. package/dist/src/contracts/SampleContentAdMarketplace.js +0 -564
  90. package/dist/src/contracts/SampleContentAdvertising.js +0 -444
  91. package/dist/src/contracts/SampleContentHelloWorld.js +0 -459
  92. package/dist/src/contracts/SampleContentLicensing.js +0 -618
  93. package/dist/src/contracts/SampleContentSigned.js +0 -447
  94. package/dist/src/contracts/SampleInstance.js +0 -438
  95. package/dist/src/contracts/SampleInstanceFactory.js +0 -451
  96. package/dist/src/contracts/Transactable.js +0 -82
  97. package/dist/src/contracts/UserSpace.js +0 -18
  98. package/dist/src/contracts/UserSpaceImpl.js +0 -43
  99. package/dist/src/contracts/Utils.js +0 -18
  100. package/dist/src/contracts/Verifier.js +0 -53
  101. package/dist/src/contracts/strings.js +0 -4
  102. package/dist/src/contracts/v2/BaseContentFactoryExt.js +0 -219
  103. package/dist/src/contracts/v2/FactorySpace.js +0 -57
  104. package/dist/src/contracts/v2/KmsSpace.js +0 -52
  105. package/dist/src/contracts/v2/NodeSpaceImpl.js +0 -273
  106. package/dist/src/contracts/v2/UserSpaceImpl.js +0 -43
  107. package/dist/src/marketplaceClient/ClientMethods.js +0 -1918
  108. package/dist/src/marketplaceClient/Configuration.js +0 -29
  109. package/dist/src/marketplaceClient/Utils.js +0 -304
  110. package/dist/src/marketplaceClient/index.js +0 -1553
  111. package/utilities/ListAccessGroups.js +0 -34
@@ -1,15 +1,9 @@
1
1
  var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
2
-
3
2
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
4
-
5
3
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
6
-
7
4
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
8
-
9
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
-
11
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
-
13
7
  /**
14
8
  * Methods for ABR video creation and management
15
9
  *
@@ -17,16 +11,29 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
17
11
  *
18
12
  * @module ElvClient/ABRPublishing
19
13
  */
20
- var R = require("ramda");
21
14
 
15
+ var R = require("ramda");
22
16
  var UrlJoin = require("url-join");
23
-
24
- var HttpClient = require("../HttpClient");
25
-
26
17
  var _require = require("../Validation"),
27
- ValidateLibrary = _require.ValidateLibrary,
28
- ValidateVersion = _require.ValidateVersion,
29
- ValidateParameters = _require.ValidateParameters;
18
+ ValidateLibrary = _require.ValidateLibrary,
19
+ ValidateVersion = _require.ValidateVersion,
20
+ ValidateParameters = _require.ValidateParameters;
21
+
22
+ // When `/abr_mezzanine/offerings` contains more than one entry, only 1 is the 'real' offering, the others are
23
+ // additional copies to be modified upon finalization due to addlOfferingSpecs having been specified in call to
24
+ // `CreateABRMezzanine()`. The 'real' offering will have an object stored in `mez_prep_specs`, the copies will not.
25
+ // This function accepts the metadata retrieved from `/abr_mezzanine/offerings` and returns the offering key for the
26
+ // 'real' offering that actually has transcode LROs.
27
+ // If no suitable offering is found, throws an error.
28
+ var MezJobMainOfferingKey = function MezJobMainOfferingKey(abrMezOfferings) {
29
+ if (!abrMezOfferings) throw Error("No mezzanine preparation job info found at /abr_mezzanine");
30
+ var mainOfferingKey = Object.keys(abrMezOfferings).find(function (offKey) {
31
+ return abrMezOfferings[offKey].mez_prep_specs;
32
+ });
33
+ if (!mainOfferingKey) throw Error("Could not determine offering key for last submitted job");
34
+ return mainOfferingKey;
35
+ };
36
+
30
37
  /**
31
38
  * Create a master media content object with the given files.
32
39
  *
@@ -79,266 +86,223 @@ var _require = require("../Validation"),
79
86
  * @throws {Object} error - If the initialization of the master fails, error details can be found in error.body
80
87
  * @return {Object} - The finalize response for the object, as well as logs, warnings and errors from the master initialization
81
88
  */
82
-
83
-
84
89
  exports.CreateProductionMaster = /*#__PURE__*/function () {
85
90
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
86
91
  var libraryId, type, name, description, _ref$metadata, metadata, fileInfo, _ref$encrypt, encrypt, _ref$access, access, _ref$copy, copy, callback, _ref$respLogLevel, respLogLevel, _ref$structLogLevel, structLogLevel, _yield$this$CreateCon, id, write_token, s3prefixRegex, i, oneFileInfo, matched, j, credentialSet, credentialSetBucket, matchers, k, matcher, fileSourcePath, s3prefixMatch, bucketName, _i, _credentialSet, region, bucket, accessKey, secret, _yield$this$CallBitco, logs, errors, warnings, finalizeResponse;
87
-
88
92
  return _regeneratorRuntime.wrap(function _callee$(_context) {
89
- while (1) {
90
- switch (_context.prev = _context.next) {
91
- case 0:
92
- libraryId = _ref.libraryId, type = _ref.type, name = _ref.name, description = _ref.description, _ref$metadata = _ref.metadata, metadata = _ref$metadata === void 0 ? {} : _ref$metadata, fileInfo = _ref.fileInfo, _ref$encrypt = _ref.encrypt, encrypt = _ref$encrypt === void 0 ? true : _ref$encrypt, _ref$access = _ref.access, access = _ref$access === void 0 ? [] : _ref$access, _ref$copy = _ref.copy, copy = _ref$copy === void 0 ? false : _ref$copy, callback = _ref.callback, _ref$respLogLevel = _ref.respLogLevel, respLogLevel = _ref$respLogLevel === void 0 ? "warn" : _ref$respLogLevel, _ref$structLogLevel = _ref.structLogLevel, structLogLevel = _ref$structLogLevel === void 0 ? "none" : _ref$structLogLevel;
93
- ValidateLibrary(libraryId);
94
- _context.next = 4;
95
- return this.CreateContentObject({
96
- libraryId: libraryId,
97
- options: type ? {
98
- type: type
99
- } : {}
100
- });
101
-
102
- case 4:
103
- _yield$this$CreateCon = _context.sent;
104
- id = _yield$this$CreateCon.id;
105
- write_token = _yield$this$CreateCon.write_token;
106
-
107
- if (!fileInfo) {
108
- _context.next = 59;
109
- break;
110
- }
111
-
112
- if (!(access.length > 0)) {
113
- _context.next = 57;
114
- break;
115
- }
116
-
117
- // S3 Upload
118
- s3prefixRegex = /^s3:\/\/([^/]+)\//i; // for matching and extracting bucket name when full s3:// path is specified
119
- // batch the cloud storage files by matching credential set, check each file's source path against credential set path_matchers
120
-
121
- i = 0;
122
-
123
- case 11:
124
- if (!(i < fileInfo.length)) {
125
- _context.next = 42;
126
- break;
127
- }
128
-
129
- oneFileInfo = fileInfo[i];
130
- matched = false;
131
- j = 0;
132
-
133
- case 15:
134
- if (!(!matched && j < access.length)) {
135
- _context.next = 37;
136
- break;
137
- }
138
-
139
- credentialSet = access[j]; // strip trailing slash to get bucket name for credential set
140
-
141
- credentialSetBucket = credentialSet.remote_access.path.replace(/\/$/, "");
142
- matchers = credentialSet.path_matchers;
143
- k = 0;
144
-
145
- case 20:
146
- if (!(!matched && k < matchers.length)) {
147
- _context.next = 34;
148
- break;
149
- }
150
-
151
- matcher = new RegExp(matchers[k]);
152
- fileSourcePath = oneFileInfo.source;
153
-
154
- if (!matcher.test(fileSourcePath)) {
155
- _context.next = 31;
156
- break;
157
- }
158
-
159
- matched = true; // if full s3 path supplied, check bucket name
160
-
161
- s3prefixMatch = s3prefixRegex.exec(fileSourcePath);
162
-
163
- if (!s3prefixMatch) {
164
- _context.next = 30;
165
- break;
166
- }
167
-
168
- bucketName = s3prefixMatch[1];
169
-
170
- if (!(bucketName !== credentialSetBucket)) {
171
- _context.next = 30;
172
- break;
173
- }
174
-
175
- throw Error("Full S3 file path \"" + fileSourcePath + "\" matched to credential set with different bucket name '" + credentialSetBucket + "'");
176
-
177
- case 30:
178
- if (credentialSet.hasOwnProperty("matched")) {
179
- credentialSet.matched.push(oneFileInfo);
180
- } else {
181
- // first matching file path for this credential set,
182
- // initialize new 'matched' property to 1-element array
183
- credentialSet.matched = [oneFileInfo];
184
- }
185
-
186
- case 31:
187
- k++;
188
- _context.next = 20;
93
+ while (1) switch (_context.prev = _context.next) {
94
+ case 0:
95
+ libraryId = _ref.libraryId, type = _ref.type, name = _ref.name, description = _ref.description, _ref$metadata = _ref.metadata, metadata = _ref$metadata === void 0 ? {} : _ref$metadata, fileInfo = _ref.fileInfo, _ref$encrypt = _ref.encrypt, encrypt = _ref$encrypt === void 0 ? true : _ref$encrypt, _ref$access = _ref.access, access = _ref$access === void 0 ? [] : _ref$access, _ref$copy = _ref.copy, copy = _ref$copy === void 0 ? false : _ref$copy, callback = _ref.callback, _ref$respLogLevel = _ref.respLogLevel, respLogLevel = _ref$respLogLevel === void 0 ? "warn" : _ref$respLogLevel, _ref$structLogLevel = _ref.structLogLevel, structLogLevel = _ref$structLogLevel === void 0 ? "none" : _ref$structLogLevel;
96
+ ValidateLibrary(libraryId);
97
+ _context.next = 4;
98
+ return this.CreateContentObject({
99
+ libraryId: libraryId,
100
+ options: type ? {
101
+ type: type
102
+ } : {}
103
+ });
104
+ case 4:
105
+ _yield$this$CreateCon = _context.sent;
106
+ id = _yield$this$CreateCon.id;
107
+ write_token = _yield$this$CreateCon.write_token;
108
+ if (!fileInfo) {
109
+ _context.next = 59;
189
110
  break;
190
-
191
- case 34:
192
- j++;
193
- _context.next = 15;
111
+ }
112
+ if (!(access.length > 0)) {
113
+ _context.next = 57;
194
114
  break;
195
-
196
- case 37:
197
- if (matched) {
198
- _context.next = 39;
199
- break;
200
- }
201
-
202
- throw Error("no credential set found for file path: \"" + filePath + "\"");
203
-
204
- case 39:
205
- i++;
206
- _context.next = 11;
115
+ }
116
+ // S3 Upload
117
+ s3prefixRegex = /^s3:\/\/([^/]+)\//i; // for matching and extracting bucket name when full s3:// path is specified
118
+ // batch the cloud storage files by matching credential set, check each file's source path against credential set path_matchers
119
+ i = 0;
120
+ case 11:
121
+ if (!(i < fileInfo.length)) {
122
+ _context.next = 42;
207
123
  break;
208
-
209
- case 42:
210
- _i = 0;
211
-
212
- case 43:
213
- if (!(_i < access.length)) {
214
- _context.next = 55;
215
- break;
216
- }
217
-
218
- _credentialSet = access[_i];
219
-
220
- if (!(_credentialSet.hasOwnProperty("matched") && _credentialSet.matched.length > 0)) {
221
- _context.next = 52;
222
- break;
223
- }
224
-
225
- region = _credentialSet.remote_access.storage_endpoint.region;
226
- bucket = _credentialSet.remote_access.path.replace(/\/$/, "");
227
- accessKey = _credentialSet.remote_access.cloud_credentials.access_key_id;
228
- secret = _credentialSet.remote_access.cloud_credentials.secret_access_key;
229
- _context.next = 52;
230
- return this.UploadFilesFromS3({
231
- libraryId: libraryId,
232
- objectId: id,
233
- writeToken: write_token,
234
- fileInfo: _credentialSet.matched,
235
- region: region,
236
- bucket: bucket,
237
- accessKey: accessKey,
238
- secret: secret,
239
- copy: copy,
240
- callback: callback,
241
- encryption: encrypt ? "cgck" : "none"
242
- });
243
-
244
- case 52:
245
- _i++;
246
- _context.next = 43;
124
+ }
125
+ oneFileInfo = fileInfo[i];
126
+ matched = false;
127
+ j = 0;
128
+ case 15:
129
+ if (!(!matched && j < access.length)) {
130
+ _context.next = 37;
247
131
  break;
248
-
249
- case 55:
250
- _context.next = 59;
132
+ }
133
+ credentialSet = access[j]; // strip trailing slash to get bucket name for credential set
134
+ credentialSetBucket = credentialSet.remote_access.path.replace(/\/$/, "");
135
+ matchers = credentialSet.path_matchers;
136
+ k = 0;
137
+ case 20:
138
+ if (!(!matched && k < matchers.length)) {
139
+ _context.next = 34;
251
140
  break;
252
-
253
- case 57:
254
- _context.next = 59;
255
- return this.UploadFiles({
256
- libraryId: libraryId,
257
- objectId: id,
258
- writeToken: write_token,
259
- fileInfo: fileInfo,
260
- callback: callback,
261
- encryption: encrypt ? "cgck" : "none"
262
- });
263
-
264
- case 59:
265
- _context.next = 61;
266
- return this.CreateEncryptionConk({
267
- libraryId: libraryId,
268
- objectId: id,
269
- writeToken: write_token,
270
- createKMSConk: true
271
- });
272
-
273
- case 61:
274
- _context.next = 63;
275
- return this.CallBitcodeMethod({
276
- libraryId: libraryId,
277
- objectId: id,
278
- writeToken: write_token,
279
- method: UrlJoin("media", "production_master", "init"),
280
- queryParams: {
281
- response_log_level: respLogLevel,
282
- struct_log_level: structLogLevel
283
- },
284
- body: {
285
- access: access
286
- },
287
- constant: false
288
- });
289
-
290
- case 63:
291
- _yield$this$CallBitco = _context.sent;
292
- logs = _yield$this$CallBitco.logs;
293
- errors = _yield$this$CallBitco.errors;
294
- warnings = _yield$this$CallBitco.warnings;
295
- _context.next = 69;
296
- return this.MergeMetadata({
297
- libraryId: libraryId,
298
- objectId: id,
299
- writeToken: write_token,
300
- metadata: _objectSpread(_objectSpread({}, metadata || {}), {}, {
301
- name: name,
302
- description: description,
303
- reference: access && !copy,
304
- "public": _objectSpread(_objectSpread({}, (metadata || {})["public"] || {}), {}, {
305
- name: name || "",
306
- description: description || ""
307
- }),
308
- elv_created_at: new Date().getTime()
309
- })
310
- });
311
-
312
- case 69:
313
- _context.next = 71;
314
- return this.FinalizeContentObject({
315
- libraryId: libraryId,
316
- objectId: id,
317
- writeToken: write_token,
318
- commitMessage: "Create master",
319
- awaitCommitConfirmation: false
320
- });
321
-
322
- case 71:
323
- finalizeResponse = _context.sent;
324
- return _context.abrupt("return", _objectSpread({
325
- errors: errors || [],
326
- logs: logs || [],
327
- warnings: warnings || []
328
- }, finalizeResponse));
329
-
330
- case 73:
331
- case "end":
332
- return _context.stop();
333
- }
141
+ }
142
+ matcher = new RegExp(matchers[k]);
143
+ fileSourcePath = oneFileInfo.source;
144
+ if (!matcher.test(fileSourcePath)) {
145
+ _context.next = 31;
146
+ break;
147
+ }
148
+ matched = true;
149
+ // if full s3 path supplied, check bucket name
150
+ s3prefixMatch = s3prefixRegex.exec(fileSourcePath);
151
+ if (!s3prefixMatch) {
152
+ _context.next = 30;
153
+ break;
154
+ }
155
+ bucketName = s3prefixMatch[1];
156
+ if (!(bucketName !== credentialSetBucket)) {
157
+ _context.next = 30;
158
+ break;
159
+ }
160
+ throw Error("Full S3 file path \"" + fileSourcePath + "\" matched to credential set with different bucket name '" + credentialSetBucket + "'");
161
+ case 30:
162
+ if (credentialSet.hasOwnProperty("matched")) {
163
+ credentialSet.matched.push(oneFileInfo);
164
+ } else {
165
+ // first matching file path for this credential set,
166
+ // initialize new 'matched' property to 1-element array
167
+ credentialSet.matched = [oneFileInfo];
168
+ }
169
+ case 31:
170
+ k++;
171
+ _context.next = 20;
172
+ break;
173
+ case 34:
174
+ j++;
175
+ _context.next = 15;
176
+ break;
177
+ case 37:
178
+ if (matched) {
179
+ _context.next = 39;
180
+ break;
181
+ }
182
+ throw Error("no credential set found for file path: \"" + filePath + "\"");
183
+ case 39:
184
+ i++;
185
+ _context.next = 11;
186
+ break;
187
+ case 42:
188
+ _i = 0;
189
+ case 43:
190
+ if (!(_i < access.length)) {
191
+ _context.next = 55;
192
+ break;
193
+ }
194
+ _credentialSet = access[_i];
195
+ if (!(_credentialSet.hasOwnProperty("matched") && _credentialSet.matched.length > 0)) {
196
+ _context.next = 52;
197
+ break;
198
+ }
199
+ region = _credentialSet.remote_access.storage_endpoint.region;
200
+ bucket = _credentialSet.remote_access.path.replace(/\/$/, "");
201
+ accessKey = _credentialSet.remote_access.cloud_credentials.access_key_id;
202
+ secret = _credentialSet.remote_access.cloud_credentials.secret_access_key;
203
+ _context.next = 52;
204
+ return this.UploadFilesFromS3({
205
+ libraryId: libraryId,
206
+ objectId: id,
207
+ writeToken: write_token,
208
+ fileInfo: _credentialSet.matched,
209
+ region: region,
210
+ bucket: bucket,
211
+ accessKey: accessKey,
212
+ secret: secret,
213
+ copy: copy,
214
+ callback: callback,
215
+ encryption: encrypt ? "cgck" : "none"
216
+ });
217
+ case 52:
218
+ _i++;
219
+ _context.next = 43;
220
+ break;
221
+ case 55:
222
+ _context.next = 59;
223
+ break;
224
+ case 57:
225
+ _context.next = 59;
226
+ return this.UploadFiles({
227
+ libraryId: libraryId,
228
+ objectId: id,
229
+ writeToken: write_token,
230
+ fileInfo: fileInfo,
231
+ callback: callback,
232
+ encryption: encrypt ? "cgck" : "none"
233
+ });
234
+ case 59:
235
+ _context.next = 61;
236
+ return this.CreateEncryptionConk({
237
+ libraryId: libraryId,
238
+ objectId: id,
239
+ writeToken: write_token,
240
+ createKMSConk: true
241
+ });
242
+ case 61:
243
+ _context.next = 63;
244
+ return this.CallBitcodeMethod({
245
+ libraryId: libraryId,
246
+ objectId: id,
247
+ writeToken: write_token,
248
+ method: UrlJoin("media", "production_master", "init"),
249
+ queryParams: {
250
+ response_log_level: respLogLevel,
251
+ struct_log_level: structLogLevel
252
+ },
253
+ body: {
254
+ access: access
255
+ },
256
+ constant: false
257
+ });
258
+ case 63:
259
+ _yield$this$CallBitco = _context.sent;
260
+ logs = _yield$this$CallBitco.logs;
261
+ errors = _yield$this$CallBitco.errors;
262
+ warnings = _yield$this$CallBitco.warnings;
263
+ _context.next = 69;
264
+ return this.MergeMetadata({
265
+ libraryId: libraryId,
266
+ objectId: id,
267
+ writeToken: write_token,
268
+ metadata: _objectSpread(_objectSpread({}, metadata || {}), {}, {
269
+ name: name,
270
+ description: description,
271
+ reference: access && !copy,
272
+ "public": _objectSpread(_objectSpread({}, (metadata || {})["public"] || {}), {}, {
273
+ name: name || "",
274
+ description: description || ""
275
+ }),
276
+ elv_created_at: new Date().getTime()
277
+ })
278
+ });
279
+ case 69:
280
+ _context.next = 71;
281
+ return this.FinalizeContentObject({
282
+ libraryId: libraryId,
283
+ objectId: id,
284
+ writeToken: write_token,
285
+ commitMessage: "Create master",
286
+ awaitCommitConfirmation: false
287
+ });
288
+ case 71:
289
+ finalizeResponse = _context.sent;
290
+ return _context.abrupt("return", _objectSpread({
291
+ errors: errors || [],
292
+ logs: logs || [],
293
+ warnings: warnings || []
294
+ }, finalizeResponse));
295
+ case 73:
296
+ case "end":
297
+ return _context.stop();
334
298
  }
335
299
  }, _callee, this);
336
300
  }));
337
-
338
301
  return function (_x) {
339
302
  return _ref2.apply(this, arguments);
340
303
  };
341
304
  }();
305
+
342
306
  /**
343
307
  * Create (or edit) a mezzanine offering based on the a given master content object version and variant key
344
308
  *
@@ -362,586 +326,556 @@ exports.CreateProductionMaster = /*#__PURE__*/function () {
362
326
  *
363
327
  * @return {Object} - The finalize response for the object, as well as logs, warnings and errors from the mezzanine initialization
364
328
  */
365
-
366
-
367
329
  exports.CreateABRMezzanine = /*#__PURE__*/function () {
368
330
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
369
331
  var libraryId, objectId, type, name, description, metadata, masterVersionHash, abrProfile, addlOfferingSpecs, _ref3$variant, variant, _ref3$offeringKey, offeringKey, _ref3$keepOtherStream, keepOtherStreams, _ref3$respLogLevel, respLogLevel, _ref3$structLogLevel, structLogLevel, streamKeys, existingMez, options, id, write_token, editResponse, createResponse, masterName, authorizationTokens, headers, body, storeClear, _yield$this$CallBitco2, logs, errors, warnings, existingMetadata, finalizeResponse;
370
-
371
332
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
372
- while (1) {
373
- switch (_context2.prev = _context2.next) {
374
- case 0:
375
- libraryId = _ref3.libraryId, objectId = _ref3.objectId, type = _ref3.type, name = _ref3.name, description = _ref3.description, metadata = _ref3.metadata, masterVersionHash = _ref3.masterVersionHash, abrProfile = _ref3.abrProfile, addlOfferingSpecs = _ref3.addlOfferingSpecs, _ref3$variant = _ref3.variant, variant = _ref3$variant === void 0 ? "default" : _ref3$variant, _ref3$offeringKey = _ref3.offeringKey, offeringKey = _ref3$offeringKey === void 0 ? "default" : _ref3$offeringKey, _ref3$keepOtherStream = _ref3.keepOtherStreams, keepOtherStreams = _ref3$keepOtherStream === void 0 ? false : _ref3$keepOtherStream, _ref3$respLogLevel = _ref3.respLogLevel, respLogLevel = _ref3$respLogLevel === void 0 ? "warn" : _ref3$respLogLevel, _ref3$structLogLevel = _ref3.structLogLevel, structLogLevel = _ref3$structLogLevel === void 0 ? "none" : _ref3$structLogLevel, streamKeys = _ref3.streamKeys;
376
- ValidateLibrary(libraryId);
377
- ValidateVersion(masterVersionHash);
378
-
379
- if (masterVersionHash) {
380
- _context2.next = 5;
381
- break;
382
- }
383
-
384
- throw Error("Master version hash not specified");
385
-
386
- case 5:
387
- if (!(!objectId && keepOtherStreams)) {
388
- _context2.next = 7;
389
- break;
390
- }
391
-
392
- throw Error("Existing mezzanine object ID required in order to use 'keepOtherStreams'");
393
-
394
- case 7:
395
- if (!(addlOfferingSpecs && !abrProfile)) {
396
- _context2.next = 9;
397
- break;
398
- }
399
-
400
- throw Error("abrProfile required when using addlOfferingSpecs");
401
-
402
- case 9:
403
- existingMez = !!objectId;
404
- options = type ? {
405
- type: type
406
- } : {};
407
-
408
- if (!existingMez) {
409
- _context2.next = 19;
410
- break;
411
- }
412
-
413
- _context2.next = 14;
414
- return this.EditContentObject({
415
- libraryId: libraryId,
416
- objectId: objectId,
417
- options: options
418
- });
419
-
420
- case 14:
421
- editResponse = _context2.sent;
422
- id = editResponse.id;
423
- write_token = editResponse.write_token;
424
- _context2.next = 24;
333
+ while (1) switch (_context2.prev = _context2.next) {
334
+ case 0:
335
+ libraryId = _ref3.libraryId, objectId = _ref3.objectId, type = _ref3.type, name = _ref3.name, description = _ref3.description, metadata = _ref3.metadata, masterVersionHash = _ref3.masterVersionHash, abrProfile = _ref3.abrProfile, addlOfferingSpecs = _ref3.addlOfferingSpecs, _ref3$variant = _ref3.variant, variant = _ref3$variant === void 0 ? "default" : _ref3$variant, _ref3$offeringKey = _ref3.offeringKey, offeringKey = _ref3$offeringKey === void 0 ? "default" : _ref3$offeringKey, _ref3$keepOtherStream = _ref3.keepOtherStreams, keepOtherStreams = _ref3$keepOtherStream === void 0 ? false : _ref3$keepOtherStream, _ref3$respLogLevel = _ref3.respLogLevel, respLogLevel = _ref3$respLogLevel === void 0 ? "warn" : _ref3$respLogLevel, _ref3$structLogLevel = _ref3.structLogLevel, structLogLevel = _ref3$structLogLevel === void 0 ? "none" : _ref3$structLogLevel, streamKeys = _ref3.streamKeys;
336
+ ValidateLibrary(libraryId);
337
+ ValidateVersion(masterVersionHash);
338
+ if (masterVersionHash) {
339
+ _context2.next = 5;
425
340
  break;
426
-
427
- case 19:
428
- _context2.next = 21;
429
- return this.CreateContentObject({
430
- libraryId: libraryId,
431
- options: options
432
- });
433
-
434
- case 21:
435
- createResponse = _context2.sent;
436
- id = createResponse.id;
437
- write_token = createResponse.write_token;
438
-
439
- case 24:
440
- _context2.next = 26;
441
- return this.CreateEncryptionConk({
442
- libraryId: libraryId,
443
- objectId: id,
444
- writeToken: write_token,
445
- createKMSConk: true
446
- });
447
-
448
- case 26:
449
- _context2.next = 28;
450
- return this.ContentObjectMetadata({
451
- versionHash: masterVersionHash,
452
- metadataSubtree: "public/name"
453
- });
454
-
455
- case 28:
456
- masterName = _context2.sent;
457
- // Include authorization for library, master, and mezzanine
458
- authorizationTokens = [];
459
- _context2.t0 = authorizationTokens;
460
- _context2.next = 33;
461
- return this.authClient.AuthorizationToken({
462
- libraryId: libraryId,
463
- objectId: id,
464
- update: true
465
- });
466
-
467
- case 33:
468
- _context2.t1 = _context2.sent;
469
-
470
- _context2.t0.push.call(_context2.t0, _context2.t1);
471
-
472
- _context2.t2 = authorizationTokens;
473
- _context2.next = 38;
474
- return this.authClient.AuthorizationToken({
475
- libraryId: libraryId
476
- });
477
-
478
- case 38:
479
- _context2.t3 = _context2.sent;
480
-
481
- _context2.t2.push.call(_context2.t2, _context2.t3);
482
-
483
- _context2.t4 = authorizationTokens;
484
- _context2.next = 43;
485
- return this.authClient.AuthorizationToken({
486
- versionHash: masterVersionHash
487
- });
488
-
489
- case 43:
490
- _context2.t5 = _context2.sent;
491
-
492
- _context2.t4.push.call(_context2.t4, _context2.t5);
493
-
494
- headers = {
495
- Authorization: authorizationTokens.map(function (token) {
496
- return "Bearer ".concat(token);
497
- }).join(",")
498
- };
499
- body = {
500
- additional_offering_specs: addlOfferingSpecs,
501
- offering_key: offeringKey,
502
- keep_other_streams: keepOtherStreams,
503
- prod_master_hash: masterVersionHash,
504
- stream_keys: streamKeys,
505
- variant_key: variant
506
- };
507
- storeClear = false;
508
-
509
- if (!abrProfile) {
510
- _context2.next = 53;
511
- break;
512
- }
513
-
514
- body.abr_profile = abrProfile;
515
- storeClear = abrProfile.store_clear;
516
- _context2.next = 56;
341
+ }
342
+ throw Error("Master version hash not specified");
343
+ case 5:
344
+ if (!(!objectId && keepOtherStreams)) {
345
+ _context2.next = 7;
517
346
  break;
518
-
519
- case 53:
520
- _context2.next = 55;
521
- return this.ContentObjectMetadata({
522
- libraryId: libraryId,
523
- objectId: this.utils.AddressToObjectId(this.utils.HashToAddress(libraryId)),
524
- metadataSubtree: "abr_profile/store_clear"
525
- });
526
-
527
- case 55:
528
- storeClear = _context2.sent;
529
-
530
- case 56:
531
- if (storeClear) {
532
- _context2.next = 59;
533
- break;
534
- }
535
-
347
+ }
348
+ throw Error("Existing mezzanine object ID required in order to use 'keepOtherStreams'");
349
+ case 7:
350
+ if (!(addlOfferingSpecs && !abrProfile)) {
351
+ _context2.next = 9;
352
+ break;
353
+ }
354
+ throw Error("abrProfile required when using addlOfferingSpecs");
355
+ case 9:
356
+ existingMez = !!objectId;
357
+ options = type ? {
358
+ type: type
359
+ } : {};
360
+ if (!existingMez) {
361
+ _context2.next = 19;
362
+ break;
363
+ }
364
+ _context2.next = 14;
365
+ return this.EditContentObject({
366
+ libraryId: libraryId,
367
+ objectId: objectId,
368
+ options: options
369
+ });
370
+ case 14:
371
+ editResponse = _context2.sent;
372
+ id = editResponse.id;
373
+ write_token = editResponse.write_token;
374
+ _context2.next = 24;
375
+ break;
376
+ case 19:
377
+ _context2.next = 21;
378
+ return this.CreateContentObject({
379
+ libraryId: libraryId,
380
+ options: options
381
+ });
382
+ case 21:
383
+ createResponse = _context2.sent;
384
+ id = createResponse.id;
385
+ write_token = createResponse.write_token;
386
+ case 24:
387
+ _context2.next = 26;
388
+ return this.CreateEncryptionConk({
389
+ libraryId: libraryId,
390
+ objectId: id,
391
+ writeToken: write_token,
392
+ createKMSConk: true
393
+ });
394
+ case 26:
395
+ _context2.next = 28;
396
+ return this.ContentObjectMetadata({
397
+ versionHash: masterVersionHash,
398
+ metadataSubtree: "public/name"
399
+ });
400
+ case 28:
401
+ masterName = _context2.sent;
402
+ // Include authorization for library, master, and mezzanine
403
+ authorizationTokens = [];
404
+ _context2.t0 = authorizationTokens;
405
+ _context2.next = 33;
406
+ return this.authClient.AuthorizationToken({
407
+ libraryId: libraryId,
408
+ objectId: id,
409
+ update: true
410
+ });
411
+ case 33:
412
+ _context2.t1 = _context2.sent;
413
+ _context2.t0.push.call(_context2.t0, _context2.t1);
414
+ _context2.t2 = authorizationTokens;
415
+ _context2.next = 38;
416
+ return this.authClient.AuthorizationToken({
417
+ libraryId: libraryId
418
+ });
419
+ case 38:
420
+ _context2.t3 = _context2.sent;
421
+ _context2.t2.push.call(_context2.t2, _context2.t3);
422
+ _context2.t4 = authorizationTokens;
423
+ _context2.next = 43;
424
+ return this.authClient.AuthorizationToken({
425
+ versionHash: masterVersionHash
426
+ });
427
+ case 43:
428
+ _context2.t5 = _context2.sent;
429
+ _context2.t4.push.call(_context2.t4, _context2.t5);
430
+ headers = {
431
+ Authorization: authorizationTokens.map(function (token) {
432
+ return "Bearer ".concat(token);
433
+ }).join(",")
434
+ };
435
+ body = {
436
+ additional_offering_specs: addlOfferingSpecs,
437
+ offering_key: offeringKey,
438
+ keep_other_streams: keepOtherStreams,
439
+ prod_master_hash: masterVersionHash,
440
+ stream_keys: streamKeys,
441
+ variant_key: variant
442
+ };
443
+ storeClear = false;
444
+ if (!abrProfile) {
445
+ _context2.next = 53;
446
+ break;
447
+ }
448
+ body.abr_profile = abrProfile;
449
+ storeClear = abrProfile.store_clear;
450
+ _context2.next = 56;
451
+ break;
452
+ case 53:
453
+ _context2.next = 55;
454
+ return this.ContentObjectMetadata({
455
+ libraryId: libraryId,
456
+ objectId: this.utils.AddressToObjectId(this.utils.HashToAddress(libraryId)),
457
+ metadataSubtree: "abr_profile/store_clear"
458
+ });
459
+ case 55:
460
+ storeClear = _context2.sent;
461
+ case 56:
462
+ if (storeClear) {
536
463
  _context2.next = 59;
537
- return this.EncryptionConk({
538
- libraryId: libraryId,
539
- objectId: id,
540
- writeToken: write_token
541
- });
542
-
543
- case 59:
544
- _context2.next = 61;
545
- return this.CallBitcodeMethod({
546
- libraryId: libraryId,
547
- objectId: id,
548
- writeToken: write_token,
549
- method: UrlJoin("media", "abr_mezzanine", "init"),
550
- queryParams: {
551
- response_log_level: respLogLevel,
552
- struct_log_level: structLogLevel
553
- },
554
- headers: headers,
555
- body: body,
556
- constant: false
557
- });
558
-
559
- case 61:
560
- _yield$this$CallBitco2 = _context2.sent;
561
- logs = _yield$this$CallBitco2.logs;
562
- errors = _yield$this$CallBitco2.errors;
563
- warnings = _yield$this$CallBitco2.warnings;
564
-
565
- if (!metadata) {
566
- metadata = {};
567
- }
568
-
569
- if (!metadata["public"]) {
570
- metadata["public"] = {};
571
- }
572
-
573
- if (!metadata["public"].asset_metadata) {
574
- metadata["public"].asset_metadata = {};
575
- }
576
-
577
- metadata.master = {
578
- name: masterName,
579
- id: this.utils.DecodeVersionHash(masterVersionHash).objectId,
580
- hash: masterVersionHash,
581
- variant: variant
582
- };
583
- metadata["public"] = _objectSpread({}, metadata["public"]);
584
- metadata["public"].asset_metadata = _objectSpread({
585
- sources: _defineProperty({}, offeringKey, {
586
- "/": "./rep/playout/".concat(offeringKey, "/options.json")
587
- })
588
- }, metadata["public"].asset_metadata);
589
-
590
- if (name || !existingMez) {
591
- metadata.name = name || "".concat(masterName, " Mezzanine");
592
- metadata["public"].name = name || "".concat(masterName, " Mezzanine");
593
- }
594
-
595
- if (description || !existingMez) {
596
- metadata.description = description || "";
597
- metadata["public"].description = description || "";
598
- } // retrieve existing metadata to merge with updated metadata
599
-
600
-
601
- _context2.next = 75;
602
- return this.ContentObjectMetadata({
603
- libraryId: libraryId,
604
- objectId: id,
605
- writeToken: write_token
606
- });
607
-
608
- case 75:
609
- existingMetadata = _context2.sent;
610
- // newer metadata values replace existing metadata, unless both new and old values are objects,
611
- // in which case their keys are merged recursively
612
- metadata = R.mergeDeepRight(existingMetadata, metadata);
613
-
614
- if (!existingMez) {
615
- // set creation date
616
- metadata.elv_created_at = new Date().getTime();
617
- } // write metadata to mezzanine object
618
-
619
-
620
- _context2.next = 80;
621
- return this.ReplaceMetadata({
622
- libraryId: libraryId,
623
- objectId: id,
624
- writeToken: write_token,
625
- metadata: metadata
626
- });
627
-
628
- case 80:
629
- _context2.next = 82;
630
- return this.FinalizeContentObject({
631
- libraryId: libraryId,
632
- objectId: id,
633
- writeToken: write_token,
634
- commitMessage: "Create ABR mezzanine"
635
- });
636
-
637
- case 82:
638
- finalizeResponse = _context2.sent;
639
- return _context2.abrupt("return", _objectSpread({
640
- logs: logs || [],
641
- warnings: warnings || [],
642
- errors: errors || []
643
- }, finalizeResponse));
644
-
645
- case 84:
646
- case "end":
647
- return _context2.stop();
648
- }
464
+ break;
465
+ }
466
+ _context2.next = 59;
467
+ return this.EncryptionConk({
468
+ libraryId: libraryId,
469
+ objectId: id,
470
+ writeToken: write_token
471
+ });
472
+ case 59:
473
+ _context2.next = 61;
474
+ return this.CallBitcodeMethod({
475
+ libraryId: libraryId,
476
+ objectId: id,
477
+ writeToken: write_token,
478
+ method: UrlJoin("media", "abr_mezzanine", "init"),
479
+ queryParams: {
480
+ response_log_level: respLogLevel,
481
+ struct_log_level: structLogLevel
482
+ },
483
+ headers: headers,
484
+ body: body,
485
+ constant: false
486
+ });
487
+ case 61:
488
+ _yield$this$CallBitco2 = _context2.sent;
489
+ logs = _yield$this$CallBitco2.logs;
490
+ errors = _yield$this$CallBitco2.errors;
491
+ warnings = _yield$this$CallBitco2.warnings;
492
+ if (!metadata) {
493
+ metadata = {};
494
+ }
495
+ if (!metadata["public"]) {
496
+ metadata["public"] = {};
497
+ }
498
+ if (!metadata["public"].asset_metadata) {
499
+ metadata["public"].asset_metadata = {};
500
+ }
501
+ metadata.master = {
502
+ name: masterName,
503
+ id: this.utils.DecodeVersionHash(masterVersionHash).objectId,
504
+ hash: masterVersionHash,
505
+ variant: variant
506
+ };
507
+ metadata["public"] = _objectSpread({}, metadata["public"]);
508
+ metadata["public"].asset_metadata = _objectSpread({
509
+ sources: _defineProperty({}, offeringKey, {
510
+ "/": "./rep/playout/".concat(offeringKey, "/options.json")
511
+ })
512
+ }, metadata["public"].asset_metadata);
513
+ if (name || !existingMez) {
514
+ metadata.name = name || "".concat(masterName, " Mezzanine");
515
+ metadata["public"].name = name || "".concat(masterName, " Mezzanine");
516
+ }
517
+ if (description || !existingMez) {
518
+ metadata.description = description || "";
519
+ metadata["public"].description = description || "";
520
+ }
521
+
522
+ // retrieve existing metadata to merge with updated metadata
523
+ _context2.next = 75;
524
+ return this.ContentObjectMetadata({
525
+ libraryId: libraryId,
526
+ objectId: id,
527
+ writeToken: write_token
528
+ });
529
+ case 75:
530
+ existingMetadata = _context2.sent;
531
+ // newer metadata values replace existing metadata, unless both new and old values are objects,
532
+ // in which case their keys are merged recursively
533
+ metadata = R.mergeDeepRight(existingMetadata, metadata);
534
+ if (!existingMez) {
535
+ // set creation date
536
+ metadata.elv_created_at = new Date().getTime();
537
+ }
538
+
539
+ // write metadata to mezzanine object
540
+ _context2.next = 80;
541
+ return this.ReplaceMetadata({
542
+ libraryId: libraryId,
543
+ objectId: id,
544
+ writeToken: write_token,
545
+ metadata: metadata
546
+ });
547
+ case 80:
548
+ _context2.next = 82;
549
+ return this.FinalizeContentObject({
550
+ libraryId: libraryId,
551
+ objectId: id,
552
+ writeToken: write_token,
553
+ commitMessage: "Create ABR mezzanine"
554
+ });
555
+ case 82:
556
+ finalizeResponse = _context2.sent;
557
+ return _context2.abrupt("return", _objectSpread({
558
+ logs: logs || [],
559
+ warnings: warnings || [],
560
+ errors: errors || []
561
+ }, finalizeResponse));
562
+ case 84:
563
+ case "end":
564
+ return _context2.stop();
649
565
  }
650
566
  }, _callee2, this);
651
567
  }));
652
-
653
568
  return function (_x2) {
654
569
  return _ref4.apply(this, arguments);
655
570
  };
656
571
  }();
572
+
657
573
  /**
658
- * Start any incomplete jobs on the specified mezzanine
574
+ * Start transcoding jobs previously set up by CreateABRMezzanine() on the specified mezzanine
659
575
  *
660
576
  * @methodGroup ABR Publishing
661
577
  * @namedParams
662
578
  * @param {string} libraryId - ID of the mezzanine library
663
579
  * @param {string} objectId - ID of the mezzanine object
664
- * @param {string=} offeringKey=default - The offering to process
665
580
  * @param {Array<Object>=} access - Array of S3 credentials, along with path matching regexes - Required if any files in the masters are S3 references (See CreateProductionMaster method)
666
581
  * - Format: {region, bucket, accessKey, secret}
667
582
  * @param {number[]} jobIndexes - Array of LRO job indexes to start. LROs are listed in a map under metadata key /abr_mezzanine/offerings/(offeringKey)/mez_prep_specs/, and job indexes start with 0, corresponding to map keys in alphabetical order
668
583
  *
669
584
  * @return {Promise<Object>} - A write token for the mezzanine object, as well as any logs, warnings and errors from the job initialization
670
585
  */
671
-
672
-
673
586
  exports.StartABRMezzanineJobs = /*#__PURE__*/function () {
674
587
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
675
588
  var _this = this;
676
-
677
- var libraryId, objectId, _ref5$offeringKey, offeringKey, _ref5$access, access, _ref5$jobIndexes, jobIndexes, mezzanineMetadata, prepSpecs, masterVersionHashes, authorizationTokens, headers, processingDraft, lroInfo, statusDraft, finalizeResponse, _yield$this$CallBitco3, data, errors, warnings, logs;
678
-
589
+ var libraryId, objectId, _ref5$access, access, _ref5$jobIndexes, jobIndexes, lastJobOfferingsInfo, offeringKey, prepSpecs, masterVersionHashes, authorizationTokens, headers, processingDraft, lroInfo, statusDraft, finalizeResponse, _yield$this$CallBitco3, data, errors, warnings, logs;
679
590
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
680
- while (1) {
681
- switch (_context4.prev = _context4.next) {
682
- case 0:
683
- libraryId = _ref5.libraryId, objectId = _ref5.objectId, _ref5$offeringKey = _ref5.offeringKey, offeringKey = _ref5$offeringKey === void 0 ? "default" : _ref5$offeringKey, _ref5$access = _ref5.access, access = _ref5$access === void 0 ? [] : _ref5$access, _ref5$jobIndexes = _ref5.jobIndexes, jobIndexes = _ref5$jobIndexes === void 0 ? null : _ref5$jobIndexes;
684
- ValidateParameters({
685
- libraryId: libraryId,
686
- objectId: objectId
687
- });
688
- _context4.next = 4;
689
- return this.ContentObjectMetadata({
690
- libraryId: libraryId,
691
- objectId: objectId,
692
- metadataSubtree: UrlJoin("abr_mezzanine", "offerings")
693
- });
694
-
695
- case 4:
696
- mezzanineMetadata = _context4.sent;
697
- prepSpecs = mezzanineMetadata[offeringKey].mez_prep_specs || []; // Retrieve all masters associated with this offering
698
-
699
- masterVersionHashes = Object.keys(prepSpecs).map(function (spec) {
700
- return (prepSpecs[spec].source_streams || []).map(function (stream) {
701
- return stream.source_hash;
702
- });
703
- }); // Flatten and filter
704
-
705
- masterVersionHashes = [].concat.apply([], masterVersionHashes).filter(function (hash) {
706
- return hash;
707
- }).filter(function (v, i, a) {
708
- return a.indexOf(v) === i;
709
- }); // Retrieve authorization tokens for all masters and the mezzanine
710
-
711
- _context4.next = 10;
712
- return Promise.all(masterVersionHashes.map( /*#__PURE__*/function () {
713
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(versionHash) {
714
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
715
- while (1) {
716
- switch (_context3.prev = _context3.next) {
717
- case 0:
718
- _context3.next = 2;
719
- return _this.authClient.AuthorizationToken({
720
- versionHash: versionHash
721
- });
722
-
723
- case 2:
724
- return _context3.abrupt("return", _context3.sent);
725
-
726
- case 3:
727
- case "end":
728
- return _context3.stop();
729
- }
730
- }
731
- }, _callee3);
732
- }));
733
-
734
- return function (_x4) {
735
- return _ref7.apply(this, arguments);
736
- };
737
- }()));
738
-
739
- case 10:
740
- authorizationTokens = _context4.sent;
741
- _context4.next = 13;
742
- return this.authClient.AuthorizationToken({
743
- libraryId: libraryId,
744
- objectId: objectId,
745
- update: true
746
- });
747
-
748
- case 13:
749
- _context4.t0 = _context4.sent;
750
- authorizationTokens = [_context4.t0].concat(_toConsumableArray(authorizationTokens));
751
- headers = {
752
- Authorization: authorizationTokens.map(function (token) {
753
- return "Bearer ".concat(token);
754
- }).join(",")
591
+ while (1) switch (_context4.prev = _context4.next) {
592
+ case 0:
593
+ libraryId = _ref5.libraryId, objectId = _ref5.objectId, _ref5$access = _ref5.access, access = _ref5$access === void 0 ? [] : _ref5$access, _ref5$jobIndexes = _ref5.jobIndexes, jobIndexes = _ref5$jobIndexes === void 0 ? null : _ref5$jobIndexes;
594
+ ValidateParameters({
595
+ libraryId: libraryId,
596
+ objectId: objectId
597
+ });
598
+ _context4.next = 4;
599
+ return this.ContentObjectMetadata({
600
+ libraryId: libraryId,
601
+ objectId: objectId,
602
+ metadataSubtree: UrlJoin("abr_mezzanine", "offerings")
603
+ });
604
+ case 4:
605
+ lastJobOfferingsInfo = _context4.sent;
606
+ offeringKey = MezJobMainOfferingKey(lastJobOfferingsInfo);
607
+ prepSpecs = lastJobOfferingsInfo[offeringKey].mez_prep_specs;
608
+ if (prepSpecs) {
609
+ _context4.next = 9;
610
+ break;
611
+ }
612
+ throw Error("No stream preparation specs found");
613
+ case 9:
614
+ // Retrieve all masters associated with this offering
615
+ masterVersionHashes = Object.keys(prepSpecs).map(function (spec) {
616
+ return (prepSpecs[spec].source_streams || []).map(function (stream) {
617
+ return stream.source_hash;
618
+ });
619
+ }); // Flatten and filter
620
+ masterVersionHashes = [].concat.apply([], masterVersionHashes).filter(function (hash) {
621
+ return hash;
622
+ }).filter(function (v, i, a) {
623
+ return a.indexOf(v) === i;
624
+ });
625
+
626
+ // Retrieve authorization tokens for all masters and the mezzanine
627
+ _context4.next = 13;
628
+ return Promise.all(masterVersionHashes.map( /*#__PURE__*/function () {
629
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(versionHash) {
630
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
631
+ while (1) switch (_context3.prev = _context3.next) {
632
+ case 0:
633
+ _context3.next = 2;
634
+ return _this.authClient.AuthorizationToken({
635
+ versionHash: versionHash
636
+ });
637
+ case 2:
638
+ return _context3.abrupt("return", _context3.sent);
639
+ case 3:
640
+ case "end":
641
+ return _context3.stop();
642
+ }
643
+ }, _callee3);
644
+ }));
645
+ return function (_x4) {
646
+ return _ref7.apply(this, arguments);
755
647
  };
756
- _context4.next = 18;
757
- return this.EditContentObject({
758
- libraryId: libraryId,
759
- objectId: objectId
760
- });
761
-
762
- case 18:
763
- processingDraft = _context4.sent;
764
- lroInfo = {
765
- write_token: processingDraft.write_token,
766
- node: this.HttpClient.BaseURI().toString(),
767
- offering: offeringKey
768
- }; // Update metadata with LRO version write token
769
-
770
- _context4.next = 22;
771
- return this.EditContentObject({
772
- libraryId: libraryId,
773
- objectId: objectId
774
- });
775
-
776
- case 22:
777
- statusDraft = _context4.sent;
778
- _context4.next = 25;
779
- return this.ReplaceMetadata({
780
- libraryId: libraryId,
781
- objectId: objectId,
782
- writeToken: statusDraft.write_token,
783
- metadataSubtree: "lro_draft_".concat(offeringKey),
784
- metadata: lroInfo
785
- });
786
-
787
- case 25:
788
- _context4.next = 27;
789
- return this.FinalizeContentObject({
790
- libraryId: libraryId,
791
- objectId: objectId,
792
- writeToken: statusDraft.write_token,
793
- commitMessage: "Mezzanine LRO status"
794
- });
795
-
796
- case 27:
797
- finalizeResponse = _context4.sent;
798
- _context4.next = 30;
799
- return this.CallBitcodeMethod({
800
- libraryId: libraryId,
801
- objectId: objectId,
802
- writeToken: processingDraft.write_token,
803
- headers: headers,
804
- method: UrlJoin("media", "abr_mezzanine", "prep_start"),
805
- constant: false,
806
- body: {
807
- access: access,
808
- offering_key: offeringKey,
809
- job_indexes: jobIndexes
810
- }
811
- });
812
-
813
- case 30:
814
- _yield$this$CallBitco3 = _context4.sent;
815
- data = _yield$this$CallBitco3.data;
816
- errors = _yield$this$CallBitco3.errors;
817
- warnings = _yield$this$CallBitco3.warnings;
818
- logs = _yield$this$CallBitco3.logs;
819
- return _context4.abrupt("return", {
820
- hash: finalizeResponse.hash,
821
- lro_draft: lroInfo,
822
- writeToken: processingDraft.write_token,
823
- data: data,
824
- logs: logs || [],
825
- warnings: warnings || [],
826
- errors: errors || []
827
- });
828
-
829
- case 36:
830
- case "end":
831
- return _context4.stop();
832
- }
648
+ }()));
649
+ case 13:
650
+ authorizationTokens = _context4.sent;
651
+ _context4.next = 16;
652
+ return this.authClient.AuthorizationToken({
653
+ libraryId: libraryId,
654
+ objectId: objectId,
655
+ update: true
656
+ });
657
+ case 16:
658
+ _context4.t0 = _context4.sent;
659
+ authorizationTokens = [_context4.t0].concat(_toConsumableArray(authorizationTokens));
660
+ headers = {
661
+ Authorization: authorizationTokens.map(function (token) {
662
+ return "Bearer ".concat(token);
663
+ }).join(",")
664
+ };
665
+ _context4.next = 21;
666
+ return this.EditContentObject({
667
+ libraryId: libraryId,
668
+ objectId: objectId
669
+ });
670
+ case 21:
671
+ processingDraft = _context4.sent;
672
+ lroInfo = {
673
+ write_token: processingDraft.write_token,
674
+ node: processingDraft.nodeUrl,
675
+ offering: offeringKey
676
+ }; // Update metadata with LRO version write token
677
+ _context4.next = 25;
678
+ return this.EditContentObject({
679
+ libraryId: libraryId,
680
+ objectId: objectId
681
+ });
682
+ case 25:
683
+ statusDraft = _context4.sent;
684
+ _context4.next = 28;
685
+ return this.ReplaceMetadata({
686
+ libraryId: libraryId,
687
+ objectId: objectId,
688
+ writeToken: statusDraft.write_token,
689
+ metadataSubtree: "lro_draft",
690
+ metadata: lroInfo
691
+ });
692
+ case 28:
693
+ _context4.next = 30;
694
+ return this.FinalizeContentObject({
695
+ libraryId: libraryId,
696
+ objectId: objectId,
697
+ writeToken: statusDraft.write_token,
698
+ commitMessage: "Mezzanine LRO status"
699
+ });
700
+ case 30:
701
+ finalizeResponse = _context4.sent;
702
+ _context4.next = 33;
703
+ return this.CallBitcodeMethod({
704
+ libraryId: libraryId,
705
+ objectId: objectId,
706
+ writeToken: processingDraft.write_token,
707
+ headers: headers,
708
+ method: UrlJoin("media", "abr_mezzanine", "prep_start"),
709
+ constant: false,
710
+ body: {
711
+ access: access,
712
+ offering_key: offeringKey,
713
+ job_indexes: jobIndexes
714
+ }
715
+ });
716
+ case 33:
717
+ _yield$this$CallBitco3 = _context4.sent;
718
+ data = _yield$this$CallBitco3.data;
719
+ errors = _yield$this$CallBitco3.errors;
720
+ warnings = _yield$this$CallBitco3.warnings;
721
+ logs = _yield$this$CallBitco3.logs;
722
+ return _context4.abrupt("return", {
723
+ hash: finalizeResponse.hash,
724
+ lro_draft: lroInfo,
725
+ writeToken: processingDraft.write_token,
726
+ nodeUrl: processingDraft.nodeUrl,
727
+ data: data,
728
+ logs: logs || [],
729
+ warnings: warnings || [],
730
+ errors: errors || []
731
+ });
732
+ case 39:
733
+ case "end":
734
+ return _context4.stop();
833
735
  }
834
736
  }, _callee4, this);
835
737
  }));
836
-
837
738
  return function (_x3) {
838
739
  return _ref6.apply(this, arguments);
839
740
  };
840
741
  }();
742
+
841
743
  /**
842
- * Retrieve status information for a long running operation (LRO) on the given object.
744
+ * Retrieve node and write token for a mezzanine's current offering preparation job (if any).
745
+ * Also returns the offering key.
843
746
  *
844
747
  * @methodGroup ABR Publishing
845
748
  * @namedParams
846
749
  * @param {string} libraryId - ID of the library
847
750
  * @param {string} objectId - ID of the object
848
- * @param {string=} offeringKey=default - Offering key of the mezzanine
849
751
  *
850
752
  * @return {Promise<Object>} - LRO status
851
753
  */
852
-
853
-
854
- exports.LROStatus = /*#__PURE__*/function () {
754
+ exports.LRODraftInfo = /*#__PURE__*/function () {
855
755
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
856
- var libraryId, objectId, _ref8$offeringKey, offeringKey, lroDraft, ready;
857
-
756
+ var libraryId, objectId, standardPathContents, lastJobOfferingsInfo, mainOfferingKey, ready, oldPathContents;
858
757
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
859
- while (1) {
860
- switch (_context5.prev = _context5.next) {
861
- case 0:
862
- libraryId = _ref8.libraryId, objectId = _ref8.objectId, _ref8$offeringKey = _ref8.offeringKey, offeringKey = _ref8$offeringKey === void 0 ? "default" : _ref8$offeringKey;
863
- ValidateParameters({
864
- libraryId: libraryId,
865
- objectId: objectId
866
- });
867
- _context5.next = 4;
868
- return this.ContentObjectMetadata({
869
- libraryId: libraryId,
870
- objectId: objectId,
871
- metadataSubtree: "lro_draft_".concat(offeringKey)
872
- });
873
-
874
- case 4:
875
- _context5.t0 = _context5.sent;
876
-
877
- if (_context5.t0) {
878
- _context5.next = 9;
879
- break;
880
- }
881
-
882
- _context5.next = 8;
883
- return this.ContentObjectMetadata({
884
- libraryId: libraryId,
885
- objectId: objectId,
886
- metadataSubtree: "lro_draft"
887
- });
888
-
889
- case 8:
890
- _context5.t0 = _context5.sent;
891
-
892
- case 9:
893
- lroDraft = _context5.t0;
894
-
895
- if (!(!lroDraft || !lroDraft.write_token)) {
896
- _context5.next = 19;
897
- break;
898
- }
899
-
900
- _context5.next = 13;
901
- return this.ContentObjectMetadata({
902
- libraryId: libraryId,
903
- objectId: objectId,
904
- metadataSubtree: UrlJoin("abr_mezzanine", "offerings", offeringKey, "ready")
905
- });
906
-
907
- case 13:
908
- ready = _context5.sent;
909
-
910
- if (!ready) {
911
- _context5.next = 18;
912
- break;
913
- }
914
-
915
- throw Error("Mezzanine already finalized for offering '".concat(offeringKey, "'"));
916
-
917
- case 18:
918
- throw Error("No LRO draft found for this mezzanine");
919
-
920
- case 19:
921
- this.HttpClient.RecordWriteToken(lroDraft.write_token, lroDraft.node);
758
+ while (1) switch (_context5.prev = _context5.next) {
759
+ case 0:
760
+ libraryId = _ref8.libraryId, objectId = _ref8.objectId;
761
+ _context5.next = 3;
762
+ return this.ContentObjectMetadata({
763
+ libraryId: libraryId,
764
+ objectId: objectId,
765
+ metadataSubtree: "lro_draft"
766
+ });
767
+ case 3:
768
+ standardPathContents = _context5.sent;
769
+ if (!standardPathContents) {
770
+ _context5.next = 6;
771
+ break;
772
+ }
773
+ return _context5.abrupt("return", standardPathContents);
774
+ case 6:
775
+ _context5.next = 8;
776
+ return this.ContentObjectMetadata({
777
+ libraryId: libraryId,
778
+ objectId: objectId,
779
+ metadataSubtree: UrlJoin("abr_mezzanine", "offerings")
780
+ });
781
+ case 8:
782
+ lastJobOfferingsInfo = _context5.sent;
783
+ if (lastJobOfferingsInfo) {
784
+ _context5.next = 11;
785
+ break;
786
+ }
787
+ throw Error("No metadata for mezzanine preparation job found at /abr_mezzanine");
788
+ case 11:
789
+ mainOfferingKey = MezJobMainOfferingKey(lastJobOfferingsInfo);
790
+ if (mainOfferingKey) {
791
+ _context5.next = 14;
792
+ break;
793
+ }
794
+ throw Error("Could not determine offering key for last submitted job");
795
+ case 14:
796
+ // see if offering from last job was finalized
797
+ ready = lastJobOfferingsInfo[mainOfferingKey].ready; // old location for LRO draft info
798
+ _context5.next = 17;
799
+ return this.ContentObjectMetadata({
800
+ libraryId: libraryId,
801
+ objectId: objectId,
802
+ metadataSubtree: "lro_draft_".concat(mainOfferingKey)
803
+ });
804
+ case 17:
805
+ oldPathContents = _context5.sent;
806
+ if (!oldPathContents) {
922
807
  _context5.next = 22;
923
- return this.ContentObjectMetadata({
924
- libraryId: libraryId,
925
- objectId: objectId,
926
- writeToken: lroDraft.write_token,
927
- metadataSubtree: "lro_status"
928
- });
929
-
930
- case 22:
931
- return _context5.abrupt("return", _context5.sent);
932
-
933
- case 23:
934
- case "end":
935
- return _context5.stop();
936
- }
808
+ break;
809
+ }
810
+ return _context5.abrupt("return", oldPathContents);
811
+ case 22:
812
+ if (!ready) {
813
+ _context5.next = 26;
814
+ break;
815
+ }
816
+ throw Error("No LRO draft found for this mezzanine - looks like last mez prep job was already finalized.");
817
+ case 26:
818
+ throw Error("No LRO draft found for this mezzanine - looks like last mez prep job was either cancelled or discarded.");
819
+ case 27:
820
+ case "end":
821
+ return _context5.stop();
937
822
  }
938
823
  }, _callee5, this);
939
824
  }));
940
-
941
825
  return function (_x5) {
942
826
  return _ref9.apply(this, arguments);
943
827
  };
944
828
  }();
829
+
830
+ /**
831
+ * Retrieve status information for mezzanine transcoding jobs, aka long running operations (LROs) on the given object.
832
+ *
833
+ * @methodGroup ABR Publishing
834
+ * @namedParams
835
+ * @param {string} libraryId - ID of the library
836
+ * @param {string} objectId - ID of the object
837
+ *
838
+ * @return {Promise<Object>} - LRO status
839
+ */
840
+ exports.LROStatus = /*#__PURE__*/function () {
841
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref10) {
842
+ var libraryId, objectId, lroDraft;
843
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
844
+ while (1) switch (_context6.prev = _context6.next) {
845
+ case 0:
846
+ libraryId = _ref10.libraryId, objectId = _ref10.objectId;
847
+ ValidateParameters({
848
+ libraryId: libraryId,
849
+ objectId: objectId
850
+ });
851
+ _context6.next = 4;
852
+ return this.LRODraftInfo({
853
+ libraryId: libraryId,
854
+ objectId: objectId
855
+ });
856
+ case 4:
857
+ lroDraft = _context6.sent;
858
+ this.HttpClient.RecordWriteToken(lroDraft.write_token, lroDraft.node);
859
+ _context6.next = 8;
860
+ return this.ContentObjectMetadata({
861
+ libraryId: libraryId,
862
+ objectId: objectId,
863
+ writeToken: lroDraft.write_token,
864
+ metadataSubtree: "lro_status"
865
+ });
866
+ case 8:
867
+ return _context6.abrupt("return", _context6.sent);
868
+ case 9:
869
+ case "end":
870
+ return _context6.stop();
871
+ }
872
+ }, _callee6, this);
873
+ }));
874
+ return function (_x6) {
875
+ return _ref11.apply(this, arguments);
876
+ };
877
+ }();
878
+
945
879
  /**
946
880
  * Finalize a mezzanine object after all jobs have finished
947
881
  *
@@ -950,193 +884,129 @@ exports.LROStatus = /*#__PURE__*/function () {
950
884
  * @param {string} libraryId - ID of the mezzanine library
951
885
  * @param {string} objectId - ID of the mezzanine object
952
886
  * @param {string} writeToken - Write token for the mezzanine object
953
- * @param {string=} offeringKey=default - The offering to process
954
887
  * @param {function=} preFinalizeFn - A function to call before finalizing changes, to allow further modifications to offering. The function will be invoked with {elvClient, nodeUrl, writeToken} to allow access to the draft and MUST NOT finalize the draft.
955
888
  * @param {boolean=} preFinalizeThrow - If set to `true` then any error thrown by preFinalizeFn will not be caught. Otherwise, any exception will be appended to the `warnings` array returned after finalization.
956
889
  *
957
890
  * @return {Promise<Object>} - The finalize response for the mezzanine object, as well as any logs, warnings and errors from the finalization
958
891
  */
959
-
960
-
961
892
  exports.FinalizeABRMezzanine = /*#__PURE__*/function () {
962
- var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref10) {
963
- var libraryId, objectId, _ref10$offeringKey, offeringKey, preFinalizeFn, preFinalizeThrow, lroDraft, httpClient, error, result, mezzanineMetadata, masterHash, authorizationTokens, headers, _yield$this$CallBitco4, data, errors, warnings, logs, preFinalizeWarnings, params, finalizeResponse;
964
-
965
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
966
- while (1) {
967
- switch (_context6.prev = _context6.next) {
968
- case 0:
969
- libraryId = _ref10.libraryId, objectId = _ref10.objectId, _ref10$offeringKey = _ref10.offeringKey, offeringKey = _ref10$offeringKey === void 0 ? "default" : _ref10$offeringKey, preFinalizeFn = _ref10.preFinalizeFn, preFinalizeThrow = _ref10.preFinalizeThrow;
970
- ValidateParameters({
971
- libraryId: libraryId,
972
- objectId: objectId
973
- });
974
- _context6.next = 4;
975
- return this.ContentObjectMetadata({
976
- libraryId: libraryId,
977
- objectId: objectId,
978
- metadataSubtree: "lro_draft_".concat(offeringKey)
979
- });
980
-
981
- case 4:
982
- lroDraft = _context6.sent;
983
-
984
- if (!(!lroDraft || !lroDraft.write_token)) {
985
- _context6.next = 7;
986
- break;
987
- }
988
-
989
- throw Error("No LRO draft found for this mezzanine");
990
-
991
- case 7:
992
- httpClient = this.HttpClient;
993
- _context6.prev = 8;
994
- // Point directly to the node containing the draft
995
- this.HttpClient = new HttpClient({
996
- uris: [lroDraft.node],
997
- debug: httpClient.debug
998
- });
999
- _context6.next = 12;
1000
- return this.ContentObjectMetadata({
1001
- libraryId: libraryId,
1002
- objectId: objectId,
1003
- writeToken: lroDraft.write_token,
1004
- metadataSubtree: UrlJoin("abr_mezzanine", "offerings")
1005
- });
1006
-
1007
- case 12:
1008
- mezzanineMetadata = _context6.sent;
1009
- masterHash = mezzanineMetadata[offeringKey].prod_master_hash; // Authorization token for mezzanine and master
1010
-
1011
- _context6.next = 16;
1012
- return this.authClient.AuthorizationToken({
1013
- libraryId: libraryId,
1014
- objectId: objectId,
1015
- update: true
1016
- });
1017
-
1018
- case 16:
1019
- _context6.t0 = _context6.sent;
1020
- _context6.next = 19;
1021
- return this.authClient.AuthorizationToken({
1022
- versionHash: masterHash
1023
- });
1024
-
1025
- case 19:
1026
- _context6.t1 = _context6.sent;
1027
- authorizationTokens = [_context6.t0, _context6.t1];
1028
- headers = {
1029
- Authorization: authorizationTokens.map(function (token) {
1030
- return "Bearer ".concat(token);
1031
- }).join(",")
1032
- };
1033
- _context6.next = 24;
1034
- return this.CallBitcodeMethod({
1035
- objectId: objectId,
1036
- libraryId: libraryId,
1037
- writeToken: lroDraft.write_token,
1038
- method: UrlJoin("media", "abr_mezzanine", "offerings", offeringKey, "finalize"),
1039
- headers: headers,
1040
- constant: false
1041
- });
1042
-
1043
- case 24:
1044
- _yield$this$CallBitco4 = _context6.sent;
1045
- data = _yield$this$CallBitco4.data;
1046
- errors = _yield$this$CallBitco4.errors;
1047
- warnings = _yield$this$CallBitco4.warnings;
1048
- logs = _yield$this$CallBitco4.logs;
1049
- preFinalizeWarnings = [];
1050
-
1051
- if (!preFinalizeFn) {
1052
- _context6.next = 45;
1053
- break;
1054
- }
1055
-
1056
- params = {
1057
- elvClient: this,
1058
- nodeUrl: lroDraft.node,
1059
- writeToken: lroDraft.write_token
1060
- };
1061
-
1062
- if (!preFinalizeThrow) {
1063
- _context6.next = 37;
1064
- break;
1065
- }
1066
-
1067
- _context6.next = 35;
1068
- return preFinalizeFn(params);
1069
-
1070
- case 35:
1071
- _context6.next = 45;
1072
- break;
1073
-
1074
- case 37:
1075
- _context6.prev = 37;
1076
- _context6.next = 40;
1077
- return preFinalizeFn(params);
1078
-
1079
- case 40:
1080
- _context6.next = 45;
893
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref12) {
894
+ var libraryId, objectId, preFinalizeFn, preFinalizeThrow, lroDraft, lastJobOfferingsInfo, offeringKey, masterHash, authorizationTokens, headers, _yield$this$CallBitco4, data, errors, warnings, logs, preFinalizeWarnings, params, finalizeResponse;
895
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
896
+ while (1) switch (_context7.prev = _context7.next) {
897
+ case 0:
898
+ libraryId = _ref12.libraryId, objectId = _ref12.objectId, preFinalizeFn = _ref12.preFinalizeFn, preFinalizeThrow = _ref12.preFinalizeThrow;
899
+ ValidateParameters({
900
+ libraryId: libraryId,
901
+ objectId: objectId
902
+ });
903
+ _context7.next = 4;
904
+ return this.LRODraftInfo({
905
+ libraryId: libraryId,
906
+ objectId: objectId
907
+ });
908
+ case 4:
909
+ lroDraft = _context7.sent;
910
+ // tell http client what node to contact for this write token
911
+ this.HttpClient.RecordWriteToken(lroDraft.write_token, lroDraft.node);
912
+ _context7.next = 8;
913
+ return this.ContentObjectMetadata({
914
+ libraryId: libraryId,
915
+ objectId: objectId,
916
+ writeToken: lroDraft.write_token,
917
+ metadataSubtree: UrlJoin("abr_mezzanine", "offerings")
918
+ });
919
+ case 8:
920
+ lastJobOfferingsInfo = _context7.sent;
921
+ offeringKey = MezJobMainOfferingKey(lastJobOfferingsInfo);
922
+ masterHash = lastJobOfferingsInfo[offeringKey].prod_master_hash; // Authorization token for mezzanine and master
923
+ _context7.next = 13;
924
+ return this.authClient.AuthorizationToken({
925
+ libraryId: libraryId,
926
+ objectId: objectId,
927
+ update: true
928
+ });
929
+ case 13:
930
+ _context7.t0 = _context7.sent;
931
+ _context7.next = 16;
932
+ return this.authClient.AuthorizationToken({
933
+ versionHash: masterHash
934
+ });
935
+ case 16:
936
+ _context7.t1 = _context7.sent;
937
+ authorizationTokens = [_context7.t0, _context7.t1];
938
+ headers = {
939
+ Authorization: authorizationTokens.map(function (token) {
940
+ return "Bearer ".concat(token);
941
+ }).join(",")
942
+ };
943
+ _context7.next = 21;
944
+ return this.CallBitcodeMethod({
945
+ objectId: objectId,
946
+ libraryId: libraryId,
947
+ writeToken: lroDraft.write_token,
948
+ method: UrlJoin("media", "abr_mezzanine", "offerings", offeringKey, "finalize"),
949
+ headers: headers,
950
+ constant: false
951
+ });
952
+ case 21:
953
+ _yield$this$CallBitco4 = _context7.sent;
954
+ data = _yield$this$CallBitco4.data;
955
+ errors = _yield$this$CallBitco4.errors;
956
+ warnings = _yield$this$CallBitco4.warnings;
957
+ logs = _yield$this$CallBitco4.logs;
958
+ preFinalizeWarnings = [];
959
+ if (!preFinalizeFn) {
960
+ _context7.next = 41;
1081
961
  break;
1082
-
1083
- case 42:
1084
- _context6.prev = 42;
1085
- _context6.t2 = _context6["catch"](37);
1086
- preFinalizeWarnings = "Error trying to set video stream codec descriptors: ".concat(_context6.t2);
1087
-
1088
- case 45:
1089
- _context6.next = 47;
1090
- return this.FinalizeContentObject({
1091
- libraryId: libraryId,
1092
- objectId: objectId,
1093
- writeToken: lroDraft.write_token,
1094
- commitMessage: "Finalize ABR mezzanine",
1095
- awaitCommitConfirmation: false
1096
- });
1097
-
1098
- case 47:
1099
- finalizeResponse = _context6.sent;
1100
- result = _objectSpread({
1101
- data: data,
1102
- logs: logs || [],
1103
- warnings: (warnings || []).concat(preFinalizeWarnings),
1104
- errors: errors || []
1105
- }, finalizeResponse);
1106
- _context6.next = 54;
962
+ }
963
+ params = {
964
+ elvClient: this,
965
+ nodeUrl: lroDraft.node,
966
+ writeToken: lroDraft.write_token
967
+ };
968
+ _context7.prev = 29;
969
+ _context7.next = 32;
970
+ return preFinalizeFn(params);
971
+ case 32:
972
+ _context7.next = 41;
973
+ break;
974
+ case 34:
975
+ _context7.prev = 34;
976
+ _context7.t2 = _context7["catch"](29);
977
+ if (!preFinalizeThrow) {
978
+ _context7.next = 40;
1107
979
  break;
1108
-
1109
- case 51:
1110
- _context6.prev = 51;
1111
- _context6.t3 = _context6["catch"](8);
1112
- error = _context6.t3;
1113
-
1114
- case 54:
1115
- _context6.prev = 54;
1116
- // Ensure original http client is restored
1117
- this.HttpClient = httpClient;
1118
- return _context6.finish(54);
1119
-
1120
- case 57:
1121
- if (!error) {
1122
- _context6.next = 59;
1123
- break;
1124
- }
1125
-
1126
- throw error;
1127
-
1128
- case 59:
1129
- return _context6.abrupt("return", result);
1130
-
1131
- case 60:
1132
- case "end":
1133
- return _context6.stop();
1134
- }
980
+ }
981
+ throw new Error("Error running preFinalize function", {
982
+ cause: _context7.t2
983
+ });
984
+ case 40:
985
+ preFinalizeWarnings = "Error running preFinalize function: ".concat(_context7.t2);
986
+ case 41:
987
+ _context7.next = 43;
988
+ return this.FinalizeContentObject({
989
+ libraryId: libraryId,
990
+ objectId: objectId,
991
+ writeToken: lroDraft.write_token,
992
+ commitMessage: "Finalize ABR mezzanine",
993
+ awaitCommitConfirmation: false
994
+ });
995
+ case 43:
996
+ finalizeResponse = _context7.sent;
997
+ return _context7.abrupt("return", _objectSpread({
998
+ data: data,
999
+ logs: logs || [],
1000
+ warnings: (warnings || []).concat(preFinalizeWarnings),
1001
+ errors: errors || []
1002
+ }, finalizeResponse));
1003
+ case 45:
1004
+ case "end":
1005
+ return _context7.stop();
1135
1006
  }
1136
- }, _callee6, this, [[8, 51, 54, 57], [37, 42]]);
1007
+ }, _callee7, this, [[29, 34]]);
1137
1008
  }));
1138
-
1139
- return function (_x6) {
1140
- return _ref11.apply(this, arguments);
1009
+ return function (_x7) {
1010
+ return _ref13.apply(this, arguments);
1141
1011
  };
1142
1012
  }();