@eluvio/elv-client-js 4.0.114 → 4.0.116

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 (129) hide show
  1. package/dist/ElvClient-min.js +68 -0
  2. package/dist/ElvClient-node-min.js +67 -0
  3. package/dist/ElvFrameClient-min.js +60 -0
  4. package/dist/ElvPermissionsClient-min.js +60 -0
  5. package/dist/ElvWalletClient-min.js +68 -0
  6. package/dist/ElvWalletClient-node-min.js +67 -0
  7. package/dist/src/AuthorizationClient.js +2166 -0
  8. package/dist/src/ContentObjectAudit.js +175 -0
  9. package/dist/src/ContentObjectVerification.js +281 -0
  10. package/dist/src/Crypto.js +412 -0
  11. package/dist/src/ElvClient.js +2063 -0
  12. package/dist/src/ElvWallet.js +247 -0
  13. package/dist/src/EthClient.js +1153 -0
  14. package/dist/src/FrameClient.js +484 -0
  15. package/dist/src/HttpClient.js +314 -0
  16. package/dist/src/Id.js +20 -0
  17. package/dist/src/LogMessage.js +25 -0
  18. package/dist/src/PermissionsClient.js +1556 -0
  19. package/dist/src/RemoteSigner.js +383 -0
  20. package/dist/src/UserProfileClient.js +1465 -0
  21. package/dist/src/Utils.js +893 -0
  22. package/dist/src/Validation.js +121 -0
  23. package/dist/src/abr_profiles/abr_profile_live_drm.js +1661 -0
  24. package/dist/src/abr_profiles/abr_profile_live_to_vod.js +1606 -0
  25. package/dist/src/client/ABRPublishing.js +1018 -0
  26. package/dist/src/client/AccessGroups.js +1503 -0
  27. package/dist/src/client/ContentAccess.js +5202 -0
  28. package/dist/src/client/ContentManagement.js +2680 -0
  29. package/dist/src/client/Contracts.js +1520 -0
  30. package/dist/src/client/Files.js +2181 -0
  31. package/dist/src/client/LiveConf.js +567 -0
  32. package/dist/src/client/LiveStream.js +2638 -0
  33. package/dist/src/client/NFT.js +162 -0
  34. package/dist/src/client/NTP.js +581 -0
  35. package/dist/src/contracts/v2/AccessIndexor.js +831 -0
  36. package/dist/src/contracts/v2/Accessible.js +31 -0
  37. package/dist/src/contracts/v2/BaseAccessControlGroup.js +1263 -0
  38. package/dist/src/contracts/v2/BaseAccessWallet.js +1609 -0
  39. package/dist/src/contracts/v2/BaseAccessWalletFactory.js +93 -0
  40. package/dist/src/contracts/v2/BaseContent.js +1076 -0
  41. package/dist/src/contracts/v2/BaseContentFactory.js +219 -0
  42. package/dist/src/contracts/v2/BaseContentSpace.js +1352 -0
  43. package/dist/src/contracts/v2/BaseContentType.js +364 -0
  44. package/dist/src/contracts/v2/BaseFactory.js +107 -0
  45. package/dist/src/contracts/v2/BaseGroupFactory.js +93 -0
  46. package/dist/src/contracts/v2/BaseLibrary.js +1041 -0
  47. package/dist/src/contracts/v2/BaseLibraryFactory.js +96 -0
  48. package/dist/src/contracts/v2/Certifyer.js +86 -0
  49. package/dist/src/contracts/v2/Container.js +540 -0
  50. package/dist/src/contracts/v2/Content.js +443 -0
  51. package/dist/src/contracts/v2/Editable.js +306 -0
  52. package/dist/src/contracts/v2/ExternalUserWallet.js +379 -0
  53. package/dist/src/contracts/v2/IFactorySpace.js +57 -0
  54. package/dist/src/contracts/v2/IKmsSpace.js +52 -0
  55. package/dist/src/contracts/v2/INodeSpace.js +18 -0
  56. package/dist/src/contracts/v2/IUserSpace.js +18 -0
  57. package/dist/src/contracts/v2/LvRecordableStream.js +1037 -0
  58. package/dist/src/contracts/v2/LvRecording.js +627 -0
  59. package/dist/src/contracts/v2/LvStreamRightsHolder.js +562 -0
  60. package/dist/src/contracts/v2/MetaObject.js +119 -0
  61. package/dist/src/contracts/v2/Node.js +167 -0
  62. package/dist/src/contracts/v2/NodeSpace.js +273 -0
  63. package/dist/src/contracts/v2/Ownable.js +87 -0
  64. package/dist/src/contracts/v2/PaymentService.js +627 -0
  65. package/dist/src/contracts/v2/Precompile.js +15 -0
  66. package/dist/src/contracts/v2/Transactable.js +82 -0
  67. package/dist/src/contracts/v2/UserSpace.js +29 -0
  68. package/dist/src/contracts/v2/Utils.js +18 -0
  69. package/dist/src/contracts/v2/Verifier.js +53 -0
  70. package/dist/src/contracts/v2/strings.js +4 -0
  71. package/dist/src/contracts/v3/AccessIndexor.js +774 -0
  72. package/dist/src/contracts/v3/Accessible.js +232 -0
  73. package/dist/src/contracts/v3/Adminable.js +107 -0
  74. package/dist/src/contracts/v3/AvailsDelivery.js +586 -0
  75. package/dist/src/contracts/v3/BaseAccessControlGroup.js +1603 -0
  76. package/dist/src/contracts/v3/BaseAccessWallet.js +1628 -0
  77. package/dist/src/contracts/v3/BaseAccessWalletFactory.js +112 -0
  78. package/dist/src/contracts/v3/BaseContent.js +1312 -0
  79. package/dist/src/contracts/v3/BaseContentFactory.js +183 -0
  80. package/dist/src/contracts/v3/BaseContentFactoryExt.js +175 -0
  81. package/dist/src/contracts/v3/BaseContentSpace.js +1515 -0
  82. package/dist/src/contracts/v3/BaseContentType.js +527 -0
  83. package/dist/src/contracts/v3/BaseFactory.js +126 -0
  84. package/dist/src/contracts/v3/BaseGroupFactory.js +112 -0
  85. package/dist/src/contracts/v3/BaseLibrary.js +1204 -0
  86. package/dist/src/contracts/v3/BaseLibraryFactory.js +115 -0
  87. package/dist/src/contracts/v3/BaseTenantSpace.js +1587 -0
  88. package/dist/src/contracts/v3/Certifyer.js +86 -0
  89. package/dist/src/contracts/v3/Container.js +739 -0
  90. package/dist/src/contracts/v3/Content.js +438 -0
  91. package/dist/src/contracts/v3/CounterObject.js +243 -0
  92. package/dist/src/contracts/v3/Editable.js +519 -0
  93. package/dist/src/contracts/v3/EncToken.js +4 -0
  94. package/dist/src/contracts/v3/ExternalUserWallet.js +587 -0
  95. package/dist/src/contracts/v3/IAdmin.js +18 -0
  96. package/dist/src/contracts/v3/IFactorySpace.js +57 -0
  97. package/dist/src/contracts/v3/IKmsSpace.js +52 -0
  98. package/dist/src/contracts/v3/INodeSpace.js +18 -0
  99. package/dist/src/contracts/v3/IUserSpace.js +32 -0
  100. package/dist/src/contracts/v3/LvRecordableStream.js +1032 -0
  101. package/dist/src/contracts/v3/LvRecording.js +650 -0
  102. package/dist/src/contracts/v3/LvStreamRightsHolder.js +557 -0
  103. package/dist/src/contracts/v3/MetaObject.js +144 -0
  104. package/dist/src/contracts/v3/Node.js +178 -0
  105. package/dist/src/contracts/v3/NodeSpace.js +284 -0
  106. package/dist/src/contracts/v3/Ownable.js +98 -0
  107. package/dist/src/contracts/v3/PaymentService.js +622 -0
  108. package/dist/src/contracts/v3/Precompile.js +26 -0
  109. package/dist/src/contracts/v3/TenantFuncsBase.js +351 -0
  110. package/dist/src/contracts/v3/Transactable.js +82 -0
  111. package/dist/src/contracts/v3/UserSpace.js +43 -0
  112. package/dist/src/contracts/v3/Utils.js +18 -0
  113. package/dist/src/contracts/v3/Verifier.js +53 -0
  114. package/dist/src/contracts/v3/strings.js +4 -0
  115. package/dist/src/contracts/v3b/BaseAccessControlGroup.js +1704 -0
  116. package/dist/src/events/Topics.js +1793 -0
  117. package/dist/src/index.js +8 -0
  118. package/dist/src/walletClient/ClientMethods.js +3102 -0
  119. package/dist/src/walletClient/Configuration.js +38 -0
  120. package/dist/src/walletClient/Notifications.js +168 -0
  121. package/dist/src/walletClient/Profile.js +332 -0
  122. package/dist/src/walletClient/Utils.js +281 -0
  123. package/dist/src/walletClient/index.js +2109 -0
  124. package/package.json +1 -1
  125. package/src/AuthorizationClient.js +24 -16
  126. package/src/ElvClient.js +19 -0
  127. package/src/client/ContentAccess.js +20 -2
  128. package/src/client/LiveConf.js +10 -8
  129. package/src/client/LiveStream.js +6 -4
@@ -0,0 +1,1018 @@
1
+ var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
2
+ var _regeneratorRuntime = require("@babel/runtime/regenerator");
3
+ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4
+ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ /**
8
+ * Methods for ABR video creation and management
9
+ *
10
+ * For more information on how to publish ABR content see <a href="./abr/index.html">this detailed guide</a>
11
+ *
12
+ * @module ElvClient/ABRPublishing
13
+ */
14
+
15
+ var R = require("ramda");
16
+ var UrlJoin = require("url-join");
17
+ var _require = require("../Validation"),
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
+
37
+ /**
38
+ * Create a master media content object with the given files.
39
+ *
40
+ * - If uploading using local files, use fileInfo parameter (see UploadFiles for format)
41
+ * - If uploading from S3 bucket, use access, filePath and copy, parameters (see UploadFilesFromS3 method)
42
+ *
43
+ * @methodGroup ABR Publishing
44
+ * @namedParams
45
+ * @param {string} libraryId - ID of the library
46
+ * @param {string=} type - ID or version hash of the content type for this master
47
+ * @param {string} name - Name of the content
48
+ * @param {string=} description - Description of the content
49
+ * @param {string} contentTypeName - Name of the content type to use
50
+ * @param {Object=} metadata - Additional metadata for the content object
51
+ * @param {Array<Object>=} fileInfo - Files to upload (See UploadFiles/UploadFilesFromS3 method)
52
+ * @param {boolean=} encrypt=true - (Local or copied files only) - Unless `false` is passed in explicitly, any uploaded/copied files will be stored encrypted
53
+ * @param {boolean=} copy=false - (S3) If specified, files will be copied from S3
54
+ * @param {function=} callback - Progress callback for file upload (See UploadFiles/UploadFilesFromS3 method)
55
+ * @param {("warn"|"info"|"debug")=} respLogLevel=warn - The level of logging to return in http response
56
+ * @param {("none"|"error"|"warn"|"info"|"debug")=} structLogLevel=none - The level of logging to save to object metadata
57
+ * @param {Array<Object>=} access=[] - Array of cloud credentials, along with path matching regex strings - Required if any files in the masters are cloud references (currently only AWS S3 is supported)
58
+ * - If this parameter is non-empty, all items in fileInfo are assumed to be items in cloud storage
59
+ * - Format: [
60
+ * - {
61
+ * - path_matchers: ["FILE_PATH_MATCH_REGEX_1", "FILE_PATH_MATCH_REGEX_2" ...],
62
+ * - remote_access: {
63
+ * - protocol: "s3",
64
+ * - platform: "aws",
65
+ * - path: "YOUR_AWS_S3_BUCKET_NAME" + "/",
66
+ * - storage_endpoint: {
67
+ * - region: "YOUR_AWS_REGION_NAME"
68
+ * - },
69
+ * - cloud_credentials: {
70
+ * - access_key_id: "YOUR_AWS_S3_ACCESS_KEY",
71
+ * - secret_access_key: "YOUR_AWS_S3_SECRET"
72
+ * - }
73
+ * - }
74
+ * - },
75
+ * - {
76
+ * - path_matchers: [".*"], // <-- catch-all for any remaining unmatched items in fileInfo
77
+ * - remote_access: {
78
+ * - ...
79
+ * - }
80
+ * - },
81
+ * - ...
82
+ * - ]
83
+ * -
84
+ * - The simplest case is a one element array with .path_matchers == [".*"], in which case the same credentials will be used for all items in fileInfo
85
+ *
86
+ * @throws {Object} error - If the initialization of the master fails, error details can be found in error.body
87
+ * @return {Object} - The finalize response for the object, as well as logs, warnings and errors from the master initialization
88
+ */
89
+ exports.CreateProductionMaster = /*#__PURE__*/function () {
90
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
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;
92
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
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;
110
+ break;
111
+ }
112
+ if (!(access.length > 0)) {
113
+ _context.next = 57;
114
+ break;
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;
123
+ break;
124
+ }
125
+ oneFileInfo = fileInfo[i];
126
+ matched = false;
127
+ j = 0;
128
+ case 15:
129
+ if (!(!matched && j < access.length)) {
130
+ _context.next = 37;
131
+ break;
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;
140
+ break;
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();
298
+ }
299
+ }, _callee, this);
300
+ }));
301
+ return function (_x) {
302
+ return _ref2.apply(this, arguments);
303
+ };
304
+ }();
305
+
306
+ /**
307
+ * Create (or edit) a mezzanine offering based on the a given master content object version and variant key
308
+ *
309
+ * @methodGroup ABR Publishing
310
+ * @namedParams
311
+ * @param {Object=} abrProfile - Custom ABR profile. If not specified, the profile of the mezzanine library will be used
312
+ * @param {Object=} addlOfferingSpecs - Specs for additional offerings to create by patching the offering being created/edited
313
+ * @param {string=} description - Description for mezzanine content object
314
+ * @param {boolean=} keepOtherStreams=false - If objectId is specified, whether to preserve existing streams with keys other than the ones specified in production master
315
+ * @param {string} libraryId - ID of the mezzanine library
316
+ * @param {string} masterVersionHash - The version hash of the production master content object
317
+ * @param {Object=} metadata - Additional metadata for mezzanine content object
318
+ * @param {string} name - Name for mezzanine content object
319
+ * @param {string=} objectId - ID of existing object (if not specified, new object will be created)
320
+ * @param {string=} offeringKey=default - The key of the offering to create
321
+ * @param {("warn"|"info"|"debug")=} respLogLevel=warn - The level of logging to return in http response
322
+ * @param {("none"|"error"|"warn"|"info"|"debug")=} structLogLevel=none - The level of logging to save to object metadata
323
+ * @param {Array<string>} streamKeys - List of stream keys from variant to include. If not supplied all streams will be included.
324
+ * @param {string=} type - ID or version hash of the content type for the mezzanine
325
+ * @param {string=} variant=default - What variant of the master content object to use
326
+ *
327
+ * @return {Object} - The finalize response for the object, as well as logs, warnings and errors from the mezzanine initialization
328
+ */
329
+ exports.CreateABRMezzanine = /*#__PURE__*/function () {
330
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
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;
332
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
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;
340
+ break;
341
+ }
342
+ throw Error("Master version hash not specified");
343
+ case 5:
344
+ if (!(!objectId && keepOtherStreams)) {
345
+ _context2.next = 7;
346
+ break;
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) {
463
+ _context2.next = 59;
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();
565
+ }
566
+ }, _callee2, this);
567
+ }));
568
+ return function (_x2) {
569
+ return _ref4.apply(this, arguments);
570
+ };
571
+ }();
572
+
573
+ /**
574
+ * Start transcoding jobs previously set up by CreateABRMezzanine() on the specified mezzanine
575
+ *
576
+ * @methodGroup ABR Publishing
577
+ * @namedParams
578
+ * @param {string} libraryId - ID of the mezzanine library
579
+ * @param {string} objectId - ID of the mezzanine object
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)
581
+ * - Format: {region, bucket, accessKey, secret}
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
583
+ *
584
+ * @return {Promise<Object>} - A write token for the mezzanine object, as well as any logs, warnings and errors from the job initialization
585
+ */
586
+ exports.StartABRMezzanineJobs = /*#__PURE__*/function () {
587
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
588
+ var _this = this;
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;
590
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
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);
647
+ };
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();
735
+ }
736
+ }, _callee4, this);
737
+ }));
738
+ return function (_x3) {
739
+ return _ref6.apply(this, arguments);
740
+ };
741
+ }();
742
+
743
+ /**
744
+ * Retrieve node and write token for a mezzanine's current offering preparation job (if any).
745
+ * Also returns the offering key.
746
+ *
747
+ * @methodGroup ABR Publishing
748
+ * @namedParams
749
+ * @param {string} libraryId - ID of the library
750
+ * @param {string} objectId - ID of the object
751
+ *
752
+ * @return {Promise<Object>} - LRO status
753
+ */
754
+ exports.LRODraftInfo = /*#__PURE__*/function () {
755
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
756
+ var libraryId, objectId, standardPathContents, lastJobOfferingsInfo, mainOfferingKey, ready, oldPathContents;
757
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
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) {
807
+ _context5.next = 22;
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();
822
+ }
823
+ }, _callee5, this);
824
+ }));
825
+ return function (_x5) {
826
+ return _ref9.apply(this, arguments);
827
+ };
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.RecordWriteToken({
859
+ writeToken: lroDraft.write_token,
860
+ fabricNodeUrl: lroDraft.node
861
+ });
862
+ _context6.next = 8;
863
+ return this.ContentObjectMetadata({
864
+ libraryId: libraryId,
865
+ objectId: objectId,
866
+ writeToken: lroDraft.write_token,
867
+ metadataSubtree: "lro_status"
868
+ });
869
+ case 8:
870
+ return _context6.abrupt("return", _context6.sent);
871
+ case 9:
872
+ case "end":
873
+ return _context6.stop();
874
+ }
875
+ }, _callee6, this);
876
+ }));
877
+ return function (_x6) {
878
+ return _ref11.apply(this, arguments);
879
+ };
880
+ }();
881
+
882
+ /**
883
+ * Finalize a mezzanine object after all jobs have finished
884
+ *
885
+ * @methodGroup ABR Publishing
886
+ * @namedParams
887
+ * @param {string} libraryId - ID of the mezzanine library
888
+ * @param {string} objectId - ID of the mezzanine object
889
+ * @param {string} writeToken - Write token for the mezzanine object
890
+ * @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.
891
+ * @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.
892
+ *
893
+ * @return {Promise<Object>} - The finalize response for the mezzanine object, as well as any logs, warnings and errors from the finalization
894
+ */
895
+ exports.FinalizeABRMezzanine = /*#__PURE__*/function () {
896
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref12) {
897
+ var libraryId, objectId, preFinalizeFn, preFinalizeThrow, lroDraft, lastJobOfferingsInfo, offeringKey, masterHash, authorizationTokens, headers, _yield$this$CallBitco4, data, errors, warnings, logs, preFinalizeWarnings, params, finalizeResponse;
898
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
899
+ while (1) switch (_context7.prev = _context7.next) {
900
+ case 0:
901
+ libraryId = _ref12.libraryId, objectId = _ref12.objectId, preFinalizeFn = _ref12.preFinalizeFn, preFinalizeThrow = _ref12.preFinalizeThrow;
902
+ ValidateParameters({
903
+ libraryId: libraryId,
904
+ objectId: objectId
905
+ });
906
+ _context7.next = 4;
907
+ return this.LRODraftInfo({
908
+ libraryId: libraryId,
909
+ objectId: objectId
910
+ });
911
+ case 4:
912
+ lroDraft = _context7.sent;
913
+ // tell http client what node to contact for this write token
914
+ this.RecordWriteToken({
915
+ writeToken: lroDraft.write_token,
916
+ fabricNodeUrl: lroDraft.node
917
+ });
918
+ _context7.next = 8;
919
+ return this.ContentObjectMetadata({
920
+ libraryId: libraryId,
921
+ objectId: objectId,
922
+ writeToken: lroDraft.write_token,
923
+ metadataSubtree: UrlJoin("abr_mezzanine", "offerings")
924
+ });
925
+ case 8:
926
+ lastJobOfferingsInfo = _context7.sent;
927
+ offeringKey = MezJobMainOfferingKey(lastJobOfferingsInfo);
928
+ masterHash = lastJobOfferingsInfo[offeringKey].prod_master_hash; // Authorization token for mezzanine and master
929
+ _context7.next = 13;
930
+ return this.authClient.AuthorizationToken({
931
+ libraryId: libraryId,
932
+ objectId: objectId,
933
+ update: true
934
+ });
935
+ case 13:
936
+ _context7.t0 = _context7.sent;
937
+ _context7.next = 16;
938
+ return this.authClient.AuthorizationToken({
939
+ versionHash: masterHash
940
+ });
941
+ case 16:
942
+ _context7.t1 = _context7.sent;
943
+ authorizationTokens = [_context7.t0, _context7.t1];
944
+ headers = {
945
+ Authorization: authorizationTokens.map(function (token) {
946
+ return "Bearer ".concat(token);
947
+ }).join(",")
948
+ };
949
+ _context7.next = 21;
950
+ return this.CallBitcodeMethod({
951
+ objectId: objectId,
952
+ libraryId: libraryId,
953
+ writeToken: lroDraft.write_token,
954
+ method: UrlJoin("media", "abr_mezzanine", "offerings", offeringKey, "finalize"),
955
+ headers: headers,
956
+ constant: false
957
+ });
958
+ case 21:
959
+ _yield$this$CallBitco4 = _context7.sent;
960
+ data = _yield$this$CallBitco4.data;
961
+ errors = _yield$this$CallBitco4.errors;
962
+ warnings = _yield$this$CallBitco4.warnings;
963
+ logs = _yield$this$CallBitco4.logs;
964
+ preFinalizeWarnings = [];
965
+ if (!preFinalizeFn) {
966
+ _context7.next = 41;
967
+ break;
968
+ }
969
+ params = {
970
+ nodeUrl: lroDraft.node,
971
+ offeringKey: offeringKey,
972
+ writeToken: lroDraft.write_token
973
+ };
974
+ _context7.prev = 29;
975
+ _context7.next = 32;
976
+ return preFinalizeFn(params);
977
+ case 32:
978
+ _context7.next = 41;
979
+ break;
980
+ case 34:
981
+ _context7.prev = 34;
982
+ _context7.t2 = _context7["catch"](29);
983
+ if (!preFinalizeThrow) {
984
+ _context7.next = 40;
985
+ break;
986
+ }
987
+ throw new Error("Error running preFinalize function", {
988
+ cause: _context7.t2
989
+ });
990
+ case 40:
991
+ preFinalizeWarnings = "Error running preFinalize function: ".concat(_context7.t2);
992
+ case 41:
993
+ _context7.next = 43;
994
+ return this.FinalizeContentObject({
995
+ libraryId: libraryId,
996
+ objectId: objectId,
997
+ writeToken: lroDraft.write_token,
998
+ commitMessage: "Finalize ABR mezzanine",
999
+ awaitCommitConfirmation: false
1000
+ });
1001
+ case 43:
1002
+ finalizeResponse = _context7.sent;
1003
+ return _context7.abrupt("return", _objectSpread({
1004
+ data: data,
1005
+ logs: logs || [],
1006
+ warnings: (warnings || []).concat(preFinalizeWarnings),
1007
+ errors: errors || []
1008
+ }, finalizeResponse));
1009
+ case 45:
1010
+ case "end":
1011
+ return _context7.stop();
1012
+ }
1013
+ }, _callee7, this, [[29, 34]]);
1014
+ }));
1015
+ return function (_x7) {
1016
+ return _ref13.apply(this, arguments);
1017
+ };
1018
+ }();