@crystaldesign/media-upload 26.5.0-beta.36 → 26.5.0-beta.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +333 -166
- package/build/esm/index.js +333 -166
- package/build/types/media-upload/src/DivaFile.d.ts +2 -0
- package/build/types/media-upload/src/DivaFile.d.ts.map +1 -1
- package/build/types/media-upload/src/types.d.ts +10 -0
- package/build/types/media-upload/src/types.d.ts.map +1 -1
- package/build/umd/media-upload.umd.min.js +1 -1
- package/build/umd/report.html +1 -1
- package/package.json +2 -2
package/build/cjs/index.js
CHANGED
|
@@ -274,35 +274,183 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
274
274
|
get: function get() {
|
|
275
275
|
return this._mediaType;
|
|
276
276
|
}
|
|
277
|
+
}, {
|
|
278
|
+
key: "parseErrorResponse",
|
|
279
|
+
value: function () {
|
|
280
|
+
var _parseErrorResponse = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(response, fallbackMessage) {
|
|
281
|
+
var errorMessage, err;
|
|
282
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
283
|
+
while (1) switch (_context.prev = _context.next) {
|
|
284
|
+
case 0:
|
|
285
|
+
errorMessage = fallbackMessage;
|
|
286
|
+
_context.prev = 1;
|
|
287
|
+
_context.next = 4;
|
|
288
|
+
return response.json();
|
|
289
|
+
case 4:
|
|
290
|
+
err = _context.sent;
|
|
291
|
+
if (err !== null && err !== void 0 && err.error && typeof err.error === 'string') {
|
|
292
|
+
errorMessage = err.error;
|
|
293
|
+
}
|
|
294
|
+
_context.next = 10;
|
|
295
|
+
break;
|
|
296
|
+
case 8:
|
|
297
|
+
_context.prev = 8;
|
|
298
|
+
_context.t0 = _context["catch"](1);
|
|
299
|
+
case 10:
|
|
300
|
+
throw new Error(errorMessage);
|
|
301
|
+
case 11:
|
|
302
|
+
case "end":
|
|
303
|
+
return _context.stop();
|
|
304
|
+
}
|
|
305
|
+
}, _callee, null, [[1, 8]]);
|
|
306
|
+
}));
|
|
307
|
+
function parseErrorResponse(_x, _x2) {
|
|
308
|
+
return _parseErrorResponse.apply(this, arguments);
|
|
309
|
+
}
|
|
310
|
+
return parseErrorResponse;
|
|
311
|
+
}()
|
|
312
|
+
}, {
|
|
313
|
+
key: "uploadViaAssetsEndpoint",
|
|
314
|
+
value: function () {
|
|
315
|
+
var _uploadViaAssetsEndpoint = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(file, organizationId, params) {
|
|
316
|
+
var _params$metadata, _this$_classes, _simpleUpload$headers;
|
|
317
|
+
var type, metadata, uploadInitResponse, uploadInitResult, uploadInitData, simpleUpload, uploadFileResponse, completeUploadResponse;
|
|
318
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
|
319
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
320
|
+
case 0:
|
|
321
|
+
type = file.type;
|
|
322
|
+
if (!type) type = 'application/octet-stream';
|
|
323
|
+
metadata = _objectSpread$1(_objectSpread$1({}, (_params$metadata = params === null || params === void 0 ? void 0 : params.metadata) !== null && _params$metadata !== void 0 ? _params$metadata : {}), (_this$_classes = this._classes) !== null && _this$_classes !== void 0 && _this$_classes.length ? {
|
|
324
|
+
classes: this._classes
|
|
325
|
+
} : {});
|
|
326
|
+
_context2.next = 5;
|
|
327
|
+
return fetch("".concat(this.config.url, "/v1/assets/uploads"), {
|
|
328
|
+
method: 'POST',
|
|
329
|
+
headers: _objectSpread$1({
|
|
330
|
+
'Content-Type': 'application/json'
|
|
331
|
+
}, this.config.jwt ? {
|
|
332
|
+
Authorization: "Bearer ".concat(this.config.jwt)
|
|
333
|
+
} : {}),
|
|
334
|
+
body: JSON.stringify({
|
|
335
|
+
uploads: [{
|
|
336
|
+
fileName: this._fileName,
|
|
337
|
+
mimeType: type,
|
|
338
|
+
size: file.size,
|
|
339
|
+
organizationId: organizationId,
|
|
340
|
+
mediaType: this._mediaType
|
|
341
|
+
}]
|
|
342
|
+
})
|
|
343
|
+
});
|
|
344
|
+
case 5:
|
|
345
|
+
uploadInitResponse = _context2.sent;
|
|
346
|
+
if (uploadInitResponse.ok) {
|
|
347
|
+
_context2.next = 9;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
_context2.next = 9;
|
|
351
|
+
return this.parseErrorResponse(uploadInitResponse, 'Error while starting upload');
|
|
352
|
+
case 9:
|
|
353
|
+
_context2.next = 11;
|
|
354
|
+
return uploadInitResponse.json();
|
|
355
|
+
case 11:
|
|
356
|
+
uploadInitResult = _context2.sent;
|
|
357
|
+
uploadInitData = Array.isArray(uploadInitResult) ? uploadInitResult[0] : uploadInitResult;
|
|
358
|
+
simpleUpload = uploadInitData === null || uploadInitData === void 0 ? void 0 : uploadInitData.simpleUpload;
|
|
359
|
+
if (!(!(simpleUpload !== null && simpleUpload !== void 0 && simpleUpload.url) || !(simpleUpload !== null && simpleUpload !== void 0 && simpleUpload.method))) {
|
|
360
|
+
_context2.next = 16;
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
throw new Error('Upload initialization response is missing upload information');
|
|
364
|
+
case 16:
|
|
365
|
+
_context2.next = 18;
|
|
366
|
+
return fetch(simpleUpload.url, {
|
|
367
|
+
method: simpleUpload.method,
|
|
368
|
+
headers: (_simpleUpload$headers = simpleUpload.headers) !== null && _simpleUpload$headers !== void 0 ? _simpleUpload$headers : {},
|
|
369
|
+
body: file
|
|
370
|
+
});
|
|
371
|
+
case 18:
|
|
372
|
+
uploadFileResponse = _context2.sent;
|
|
373
|
+
if (uploadFileResponse.ok) {
|
|
374
|
+
_context2.next = 21;
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
throw new Error('Error while uploading file');
|
|
378
|
+
case 21:
|
|
379
|
+
_context2.next = 23;
|
|
380
|
+
return fetch("".concat(this.config.url, "/v1/assets/uploads/complete"), {
|
|
381
|
+
method: 'POST',
|
|
382
|
+
headers: _objectSpread$1({
|
|
383
|
+
'Content-Type': 'application/json'
|
|
384
|
+
}, this.config.jwt ? {
|
|
385
|
+
Authorization: "Bearer ".concat(this.config.jwt)
|
|
386
|
+
} : {}),
|
|
387
|
+
body: JSON.stringify(_objectSpread$1(_objectSpread$1(_objectSpread$1(_objectSpread$1(_objectSpread$1({
|
|
388
|
+
uploadId: uploadInitData.uploadId,
|
|
389
|
+
fileName: this._fileName,
|
|
390
|
+
organizationId: organizationId,
|
|
391
|
+
mediaType: this._mediaType
|
|
392
|
+
}, params !== null && params !== void 0 && params.renderJob ? {
|
|
393
|
+
renderJob: params.renderJob
|
|
394
|
+
} : {}), Object.keys(metadata).length ? {
|
|
395
|
+
metadata: metadata
|
|
396
|
+
} : {}), params !== null && params !== void 0 && params.reference ? {
|
|
397
|
+
reference: params.reference
|
|
398
|
+
} : {}), params !== null && params !== void 0 && params.ref ? {
|
|
399
|
+
ref: params.ref
|
|
400
|
+
} : {}), params !== null && params !== void 0 && params.overwrite ? {
|
|
401
|
+
overwrite: params.overwrite
|
|
402
|
+
} : {}))
|
|
403
|
+
});
|
|
404
|
+
case 23:
|
|
405
|
+
completeUploadResponse = _context2.sent;
|
|
406
|
+
if (completeUploadResponse.ok) {
|
|
407
|
+
_context2.next = 27;
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
_context2.next = 27;
|
|
411
|
+
return this.parseErrorResponse(completeUploadResponse, 'Error while completing upload');
|
|
412
|
+
case 27:
|
|
413
|
+
return _context2.abrupt("return", completeUploadResponse.json());
|
|
414
|
+
case 28:
|
|
415
|
+
case "end":
|
|
416
|
+
return _context2.stop();
|
|
417
|
+
}
|
|
418
|
+
}, _callee2, this);
|
|
419
|
+
}));
|
|
420
|
+
function uploadViaAssetsEndpoint(_x3, _x4, _x5) {
|
|
421
|
+
return _uploadViaAssetsEndpoint.apply(this, arguments);
|
|
422
|
+
}
|
|
423
|
+
return uploadViaAssetsEndpoint;
|
|
424
|
+
}()
|
|
277
425
|
}, {
|
|
278
426
|
key: "save",
|
|
279
427
|
value: function () {
|
|
280
|
-
var _save = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
281
|
-
var mediaItemRef, _refUrl, _this$fileObject, _refs, _this$itemRef, _this$itemRef$url, _this$itemRef2, _file2, _url, response, blob, formData, mediaitem, _url2, mediaitemref, refs, data, _mediaitemref, media, _media, ref, item, _this$item, _params$refIds, _refs2, _this$itemRef3, _this$itemRef4, result;
|
|
282
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
283
|
-
while (1) switch (
|
|
428
|
+
var _save = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee7(params) {
|
|
429
|
+
var mediaItemRef, _refUrl, _this$fileObject, _refs, _this$itemRef, _this$itemRef$url, _this$itemRef2, _file2, _url, response, blob, formData, mediaitem, _url2, organizationId, useAssetsUploadEndpoint, _completedUpload$medi, _uploadedMediaItem$ur, _uploadedMediaItem$ur2, completedUpload, uploadedMediaItem, mediaitemref, refs, data, _mediaitemref, media, _media, ref, item, _this$item, _params$refIds, _refs2, _this$itemRef3, _this$itemRef4, result;
|
|
430
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee7$(_context7) {
|
|
431
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
284
432
|
case 0:
|
|
285
433
|
if (!(!this.itemRef && this._state != 'NEW')) {
|
|
286
|
-
|
|
434
|
+
_context7.next = 22;
|
|
287
435
|
break;
|
|
288
436
|
}
|
|
289
437
|
if (this._ref) {
|
|
290
|
-
|
|
438
|
+
_context7.next = 3;
|
|
291
439
|
break;
|
|
292
440
|
}
|
|
293
441
|
throw new Error('If state is not NEW, there must be a ref present');
|
|
294
442
|
case 3:
|
|
295
|
-
|
|
443
|
+
_context7.next = 5;
|
|
296
444
|
return this.getMediaItemRef(this._ref, (params === null || params === void 0 ? void 0 : params.organizationId) || this._organizationId);
|
|
297
445
|
case 5:
|
|
298
|
-
mediaItemRef =
|
|
446
|
+
mediaItemRef = _context7.sent;
|
|
299
447
|
this.itemRef = mediaItemRef;
|
|
300
448
|
if (!this._functionType) this._functionType = this.itemRef.functionType;
|
|
301
449
|
if (!this._description) this._description = this.itemRef.description;
|
|
302
450
|
if (!this._fileName) this._fileName = this.itemRef.fileName;
|
|
303
451
|
this._mediaType = this.itemRef.mediaType;
|
|
304
452
|
if (!(this._organizationId && this._organizationId != this.itemRef.organizationId)) {
|
|
305
|
-
|
|
453
|
+
_context7.next = 13;
|
|
306
454
|
break;
|
|
307
455
|
}
|
|
308
456
|
throw new Error('The existing mediaItemRef belongs to a different organization');
|
|
@@ -311,22 +459,22 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
311
459
|
this._url = this.itemRef.url;
|
|
312
460
|
this._ref = this.itemRef._id;
|
|
313
461
|
if (this.item) {
|
|
314
|
-
|
|
462
|
+
_context7.next = 22;
|
|
315
463
|
break;
|
|
316
464
|
}
|
|
317
465
|
if (this.itemRef) {
|
|
318
|
-
|
|
466
|
+
_context7.next = 19;
|
|
319
467
|
break;
|
|
320
468
|
}
|
|
321
469
|
throw new Error('If state is not NEW, there must be a url present');
|
|
322
470
|
case 19:
|
|
323
|
-
|
|
471
|
+
_context7.next = 21;
|
|
324
472
|
return this.getMediaItem((_refUrl = this.itemRef.refUrl) !== null && _refUrl !== void 0 ? _refUrl : this.itemRef.url, (params === null || params === void 0 ? void 0 : params.organizationId) || this._organizationId);
|
|
325
473
|
case 21:
|
|
326
|
-
this.item =
|
|
474
|
+
this.item = _context7.sent;
|
|
327
475
|
case 22:
|
|
328
476
|
if (!(this._state == 'NEW' && !this.isExternalVid(this._url))) {
|
|
329
|
-
|
|
477
|
+
_context7.next = 82;
|
|
330
478
|
break;
|
|
331
479
|
}
|
|
332
480
|
// create the mediaItem
|
|
@@ -334,11 +482,11 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
334
482
|
// for this type we only support url
|
|
335
483
|
_file2 = (_this$fileObject = this.fileObject) === null || _this$fileObject === void 0 ? void 0 : _this$fileObject.file;
|
|
336
484
|
if (!(!_file2 && !this._spinFiles)) {
|
|
337
|
-
|
|
485
|
+
_context7.next = 38;
|
|
338
486
|
break;
|
|
339
487
|
}
|
|
340
488
|
if (this._url) {
|
|
341
|
-
|
|
489
|
+
_context7.next = 27;
|
|
342
490
|
break;
|
|
343
491
|
}
|
|
344
492
|
throw new Error('Either file or url must be specified');
|
|
@@ -349,20 +497,20 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
349
497
|
// add a dummy query to avoid the browser cache (cached response is missing cors headers)
|
|
350
498
|
_url.searchParams.set('dt', Date.now().toString());
|
|
351
499
|
}
|
|
352
|
-
|
|
500
|
+
_context7.next = 31;
|
|
353
501
|
return fetch(_url.toString());
|
|
354
502
|
case 31:
|
|
355
|
-
response =
|
|
503
|
+
response = _context7.sent;
|
|
356
504
|
if (!(response.status === 400)) {
|
|
357
|
-
|
|
505
|
+
_context7.next = 34;
|
|
358
506
|
break;
|
|
359
507
|
}
|
|
360
508
|
throw new Error('Error on saving media.');
|
|
361
509
|
case 34:
|
|
362
|
-
|
|
510
|
+
_context7.next = 36;
|
|
363
511
|
return response.blob();
|
|
364
512
|
case 36:
|
|
365
|
-
blob =
|
|
513
|
+
blob = _context7.sent;
|
|
366
514
|
_file2 = new File([blob], this._fileName, {
|
|
367
515
|
type: blob.type
|
|
368
516
|
});
|
|
@@ -385,9 +533,28 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
385
533
|
mediaitem.borderPercentage = this._borderPercentage;
|
|
386
534
|
}
|
|
387
535
|
if (!_file2) {
|
|
388
|
-
|
|
536
|
+
_context7.next = 63;
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
organizationId = (params === null || params === void 0 ? void 0 : params.organizationId) || this._organizationId;
|
|
540
|
+
useAssetsUploadEndpoint = !this.createRef && !(params !== null && params !== void 0 && params.refCount) && !!organizationId;
|
|
541
|
+
if (!(useAssetsUploadEndpoint && organizationId)) {
|
|
542
|
+
_context7.next = 57;
|
|
389
543
|
break;
|
|
390
544
|
}
|
|
545
|
+
_context7.next = 50;
|
|
546
|
+
return this.uploadViaAssetsEndpoint(_file2, organizationId, params);
|
|
547
|
+
case 50:
|
|
548
|
+
completedUpload = _context7.sent;
|
|
549
|
+
uploadedMediaItem = (_completedUpload$medi = completedUpload === null || completedUpload === void 0 ? void 0 : completedUpload.mediaItem) !== null && _completedUpload$medi !== void 0 ? _completedUpload$medi : completedUpload;
|
|
550
|
+
this.item = _objectSpread$1(_objectSpread$1({}, uploadedMediaItem), {}, {
|
|
551
|
+
url: (_uploadedMediaItem$ur = uploadedMediaItem === null || uploadedMediaItem === void 0 ? void 0 : uploadedMediaItem.url) !== null && _uploadedMediaItem$ur !== void 0 ? _uploadedMediaItem$ur : uploadedMediaItem === null || uploadedMediaItem === void 0 ? void 0 : uploadedMediaItem.cdnUrl
|
|
552
|
+
});
|
|
553
|
+
this.itemRef = undefined;
|
|
554
|
+
this._ref = undefined;
|
|
555
|
+
this._url = (_uploadedMediaItem$ur2 = uploadedMediaItem === null || uploadedMediaItem === void 0 ? void 0 : uploadedMediaItem.url) !== null && _uploadedMediaItem$ur2 !== void 0 ? _uploadedMediaItem$ur2 : uploadedMediaItem === null || uploadedMediaItem === void 0 ? void 0 : uploadedMediaItem.cdnUrl;
|
|
556
|
+
return _context7.abrupt("return", []);
|
|
557
|
+
case 57:
|
|
391
558
|
formData.append('mediaItem', JSON.stringify(mediaitem));
|
|
392
559
|
formData.append('file', _file2);
|
|
393
560
|
_url2 = "".concat(this.config.url, "/v1/mediaitems");
|
|
@@ -398,12 +565,12 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
398
565
|
formData.append('mediaItemRef', JSON.stringify(mediaitemref));
|
|
399
566
|
_url2 = _url2 + '?ref=true';
|
|
400
567
|
}
|
|
401
|
-
|
|
568
|
+
_context7.next = 64;
|
|
402
569
|
break;
|
|
403
|
-
case
|
|
570
|
+
case 63:
|
|
404
571
|
throw new Error('Either file or url must be specified');
|
|
405
|
-
case
|
|
406
|
-
|
|
572
|
+
case 64:
|
|
573
|
+
_context7.next = 66;
|
|
407
574
|
return fetch(_url2, {
|
|
408
575
|
method: 'POST',
|
|
409
576
|
body: formData,
|
|
@@ -411,52 +578,52 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
411
578
|
Authorization: "Bearer ".concat(this.config.jwt)
|
|
412
579
|
} : {}
|
|
413
580
|
}).then(/*#__PURE__*/function () {
|
|
414
|
-
var _ref2 = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
581
|
+
var _ref2 = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(r) {
|
|
415
582
|
var error, err;
|
|
416
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
417
|
-
while (1) switch (
|
|
583
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
|
|
584
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
418
585
|
case 0:
|
|
419
586
|
if (r.ok) {
|
|
420
|
-
|
|
587
|
+
_context3.next = 12;
|
|
421
588
|
break;
|
|
422
589
|
}
|
|
423
|
-
|
|
424
|
-
|
|
590
|
+
_context3.prev = 1;
|
|
591
|
+
_context3.next = 4;
|
|
425
592
|
return r.json();
|
|
426
593
|
case 4:
|
|
427
|
-
err =
|
|
594
|
+
err = _context3.sent;
|
|
428
595
|
error = err.error;
|
|
429
|
-
|
|
596
|
+
_context3.next = 11;
|
|
430
597
|
break;
|
|
431
598
|
case 8:
|
|
432
|
-
|
|
433
|
-
|
|
599
|
+
_context3.prev = 8;
|
|
600
|
+
_context3.t0 = _context3["catch"](1);
|
|
434
601
|
throw new Error('Error while saving');
|
|
435
602
|
case 11:
|
|
436
603
|
throw new Error(error);
|
|
437
604
|
case 12:
|
|
438
|
-
return
|
|
605
|
+
return _context3.abrupt("return", r.json());
|
|
439
606
|
case 13:
|
|
440
607
|
case "end":
|
|
441
|
-
return
|
|
608
|
+
return _context3.stop();
|
|
442
609
|
}
|
|
443
|
-
},
|
|
610
|
+
}, _callee3, null, [[1, 8]]);
|
|
444
611
|
}));
|
|
445
|
-
return function (
|
|
612
|
+
return function (_x7) {
|
|
446
613
|
return _ref2.apply(this, arguments);
|
|
447
614
|
};
|
|
448
615
|
}());
|
|
449
|
-
case
|
|
450
|
-
data =
|
|
616
|
+
case 66:
|
|
617
|
+
data = _context7.sent;
|
|
451
618
|
if (!(this.createRef && params !== null && params !== void 0 && params.refCount)) {
|
|
452
|
-
|
|
619
|
+
_context7.next = 73;
|
|
453
620
|
break;
|
|
454
621
|
}
|
|
455
622
|
_mediaitemref = {
|
|
456
623
|
functionType: this._functionType
|
|
457
624
|
};
|
|
458
625
|
_url2 = "".concat(this.config.url, "/v1/mediaitems/").concat(data._id, "/refs/").concat(params.refCount);
|
|
459
|
-
|
|
626
|
+
_context7.next = 72;
|
|
460
627
|
return fetch(_url2, {
|
|
461
628
|
method: 'POST',
|
|
462
629
|
body: JSON.stringify(_mediaitemref),
|
|
@@ -465,57 +632,57 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
465
632
|
Authorization: "Bearer ".concat(this.config.jwt)
|
|
466
633
|
} : {}
|
|
467
634
|
}).then(/*#__PURE__*/function () {
|
|
468
|
-
var _ref3 = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
635
|
+
var _ref3 = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(r) {
|
|
469
636
|
var error, err;
|
|
470
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
471
|
-
while (1) switch (
|
|
637
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
|
|
638
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
472
639
|
case 0:
|
|
473
640
|
if (r.ok) {
|
|
474
|
-
|
|
641
|
+
_context4.next = 12;
|
|
475
642
|
break;
|
|
476
643
|
}
|
|
477
|
-
|
|
478
|
-
|
|
644
|
+
_context4.prev = 1;
|
|
645
|
+
_context4.next = 4;
|
|
479
646
|
return r.json();
|
|
480
647
|
case 4:
|
|
481
|
-
err =
|
|
648
|
+
err = _context4.sent;
|
|
482
649
|
error = err.error;
|
|
483
|
-
|
|
650
|
+
_context4.next = 11;
|
|
484
651
|
break;
|
|
485
652
|
case 8:
|
|
486
|
-
|
|
487
|
-
|
|
653
|
+
_context4.prev = 8;
|
|
654
|
+
_context4.t0 = _context4["catch"](1);
|
|
488
655
|
throw new Error('Error while saving');
|
|
489
656
|
case 11:
|
|
490
657
|
throw new Error(error);
|
|
491
658
|
case 12:
|
|
492
|
-
return
|
|
659
|
+
return _context4.abrupt("return", r.json());
|
|
493
660
|
case 13:
|
|
494
661
|
case "end":
|
|
495
|
-
return
|
|
662
|
+
return _context4.stop();
|
|
496
663
|
}
|
|
497
|
-
},
|
|
664
|
+
}, _callee4, null, [[1, 8]]);
|
|
498
665
|
}));
|
|
499
|
-
return function (
|
|
666
|
+
return function (_x8) {
|
|
500
667
|
return _ref3.apply(this, arguments);
|
|
501
668
|
};
|
|
502
669
|
}());
|
|
503
|
-
case
|
|
504
|
-
refs =
|
|
505
|
-
case
|
|
670
|
+
case 72:
|
|
671
|
+
refs = _context7.sent;
|
|
672
|
+
case 73:
|
|
506
673
|
media = data;
|
|
507
674
|
_media = media, ref = _media.ref, item = _objectWithoutProperties__default["default"](_media, _excluded);
|
|
508
675
|
this.item = item;
|
|
509
676
|
this.itemRef = ref !== null && ref !== void 0 ? ref : (_refs = refs) === null || _refs === void 0 ? void 0 : _refs[0];
|
|
510
677
|
this._ref = (_this$itemRef = this.itemRef) === null || _this$itemRef === void 0 ? void 0 : _this$itemRef._id;
|
|
511
678
|
this._url = (_this$itemRef$url = (_this$itemRef2 = this.itemRef) === null || _this$itemRef2 === void 0 ? void 0 : _this$itemRef2.url) !== null && _this$itemRef$url !== void 0 ? _this$itemRef$url : this.item.url;
|
|
512
|
-
return
|
|
513
|
-
case
|
|
679
|
+
return _context7.abrupt("return", refs);
|
|
680
|
+
case 82:
|
|
514
681
|
if (!(this._state == 'CHANGED')) {
|
|
515
|
-
|
|
682
|
+
_context7.next = 95;
|
|
516
683
|
break;
|
|
517
684
|
}
|
|
518
|
-
|
|
685
|
+
_context7.next = 85;
|
|
519
686
|
return fetch("".concat(this.config.url, "/v1/mediaitems/").concat((_this$item = this.item) === null || _this$item === void 0 ? void 0 : _this$item._id), {
|
|
520
687
|
method: 'PATCH',
|
|
521
688
|
body: JSON.stringify({
|
|
@@ -543,49 +710,49 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
543
710
|
Authorization: "Bearer ".concat(this.config.jwt)
|
|
544
711
|
} : {})
|
|
545
712
|
}).then(/*#__PURE__*/function () {
|
|
546
|
-
var _ref4 = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
713
|
+
var _ref4 = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(r) {
|
|
547
714
|
var error, err;
|
|
548
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
549
|
-
while (1) switch (
|
|
715
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context5) {
|
|
716
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
550
717
|
case 0:
|
|
551
718
|
if (r.ok) {
|
|
552
|
-
|
|
719
|
+
_context5.next = 12;
|
|
553
720
|
break;
|
|
554
721
|
}
|
|
555
|
-
|
|
556
|
-
|
|
722
|
+
_context5.prev = 1;
|
|
723
|
+
_context5.next = 4;
|
|
557
724
|
return r.json();
|
|
558
725
|
case 4:
|
|
559
|
-
err =
|
|
726
|
+
err = _context5.sent;
|
|
560
727
|
error = err.error;
|
|
561
|
-
|
|
728
|
+
_context5.next = 11;
|
|
562
729
|
break;
|
|
563
730
|
case 8:
|
|
564
|
-
|
|
565
|
-
|
|
731
|
+
_context5.prev = 8;
|
|
732
|
+
_context5.t0 = _context5["catch"](1);
|
|
566
733
|
throw new Error('Error while saving');
|
|
567
734
|
case 11:
|
|
568
735
|
throw new Error(error);
|
|
569
736
|
case 12:
|
|
570
|
-
return
|
|
737
|
+
return _context5.abrupt("return", r.json());
|
|
571
738
|
case 13:
|
|
572
739
|
case "end":
|
|
573
|
-
return
|
|
740
|
+
return _context5.stop();
|
|
574
741
|
}
|
|
575
|
-
},
|
|
742
|
+
}, _callee5, null, [[1, 8]]);
|
|
576
743
|
}));
|
|
577
|
-
return function (
|
|
744
|
+
return function (_x9) {
|
|
578
745
|
return _ref4.apply(this, arguments);
|
|
579
746
|
};
|
|
580
747
|
}());
|
|
581
|
-
case
|
|
582
|
-
this.item =
|
|
748
|
+
case 85:
|
|
749
|
+
this.item = _context7.sent;
|
|
583
750
|
_refs2 = (_params$refIds = params === null || params === void 0 ? void 0 : params.refIds) !== null && _params$refIds !== void 0 ? _params$refIds : [this.ref];
|
|
584
751
|
if (!(_refs2 !== null && _refs2 !== void 0 && _refs2.length)) {
|
|
585
|
-
|
|
752
|
+
_context7.next = 95;
|
|
586
753
|
break;
|
|
587
754
|
}
|
|
588
|
-
|
|
755
|
+
_context7.next = 90;
|
|
589
756
|
return fetch("".concat(this.config.url, "/v1/mediaitems/refs/bulk"), {
|
|
590
757
|
method: 'PATCH',
|
|
591
758
|
body: JSON.stringify({
|
|
@@ -602,58 +769,58 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
602
769
|
Authorization: "Bearer ".concat(this.config.jwt)
|
|
603
770
|
} : {})
|
|
604
771
|
}).then(/*#__PURE__*/function () {
|
|
605
|
-
var _ref5 = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
772
|
+
var _ref5 = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6(r) {
|
|
606
773
|
var error, err;
|
|
607
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
608
|
-
while (1) switch (
|
|
774
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context6) {
|
|
775
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
609
776
|
case 0:
|
|
610
777
|
if (r.ok) {
|
|
611
|
-
|
|
778
|
+
_context6.next = 12;
|
|
612
779
|
break;
|
|
613
780
|
}
|
|
614
|
-
|
|
615
|
-
|
|
781
|
+
_context6.prev = 1;
|
|
782
|
+
_context6.next = 4;
|
|
616
783
|
return r.json();
|
|
617
784
|
case 4:
|
|
618
|
-
err =
|
|
785
|
+
err = _context6.sent;
|
|
619
786
|
error = err.error;
|
|
620
|
-
|
|
787
|
+
_context6.next = 11;
|
|
621
788
|
break;
|
|
622
789
|
case 8:
|
|
623
|
-
|
|
624
|
-
|
|
790
|
+
_context6.prev = 8;
|
|
791
|
+
_context6.t0 = _context6["catch"](1);
|
|
625
792
|
throw new Error('Error while saving');
|
|
626
793
|
case 11:
|
|
627
794
|
throw new Error(error);
|
|
628
795
|
case 12:
|
|
629
|
-
return
|
|
796
|
+
return _context6.abrupt("return", r.json());
|
|
630
797
|
case 13:
|
|
631
798
|
case "end":
|
|
632
|
-
return
|
|
799
|
+
return _context6.stop();
|
|
633
800
|
}
|
|
634
|
-
},
|
|
801
|
+
}, _callee6, null, [[1, 8]]);
|
|
635
802
|
}));
|
|
636
|
-
return function (
|
|
803
|
+
return function (_x10) {
|
|
637
804
|
return _ref5.apply(this, arguments);
|
|
638
805
|
};
|
|
639
806
|
}());
|
|
640
|
-
case
|
|
641
|
-
result =
|
|
807
|
+
case 90:
|
|
808
|
+
result = _context7.sent;
|
|
642
809
|
this.itemRef = result[0];
|
|
643
810
|
this._ref = (_this$itemRef3 = this.itemRef) === null || _this$itemRef3 === void 0 ? void 0 : _this$itemRef3._id;
|
|
644
811
|
this._url = (_this$itemRef4 = this.itemRef) === null || _this$itemRef4 === void 0 ? void 0 : _this$itemRef4.url;
|
|
645
|
-
return
|
|
812
|
+
return _context7.abrupt("return", result.map(function (r) {
|
|
646
813
|
return r._id;
|
|
647
814
|
}));
|
|
648
|
-
case
|
|
649
|
-
return
|
|
650
|
-
case
|
|
815
|
+
case 95:
|
|
816
|
+
return _context7.abrupt("return", []);
|
|
817
|
+
case 96:
|
|
651
818
|
case "end":
|
|
652
|
-
return
|
|
819
|
+
return _context7.stop();
|
|
653
820
|
}
|
|
654
|
-
},
|
|
821
|
+
}, _callee7, this);
|
|
655
822
|
}));
|
|
656
|
-
function save(
|
|
823
|
+
function save(_x6) {
|
|
657
824
|
return _save.apply(this, arguments);
|
|
658
825
|
}
|
|
659
826
|
return save;
|
|
@@ -661,31 +828,31 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
661
828
|
}, {
|
|
662
829
|
key: "load",
|
|
663
830
|
value: function () {
|
|
664
|
-
var _load = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
831
|
+
var _load = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8(params) {
|
|
665
832
|
var _mediaItemRef$refUrl;
|
|
666
833
|
var mediaItemRef;
|
|
667
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
668
|
-
while (1) switch (
|
|
834
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee8$(_context8) {
|
|
835
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
669
836
|
case 0:
|
|
670
837
|
if (!(!this.ref || !(params !== null && params !== void 0 && params.organizationId) && !this._organizationId)) {
|
|
671
|
-
|
|
838
|
+
_context8.next = 2;
|
|
672
839
|
break;
|
|
673
840
|
}
|
|
674
841
|
throw new Error('Ref or OrganizationId must be set to load data form server');
|
|
675
842
|
case 2:
|
|
676
843
|
if (!this.itemRef) {
|
|
677
|
-
|
|
844
|
+
_context8.next = 4;
|
|
678
845
|
break;
|
|
679
846
|
}
|
|
680
|
-
return
|
|
847
|
+
return _context8.abrupt("return");
|
|
681
848
|
case 4:
|
|
682
|
-
|
|
849
|
+
_context8.next = 6;
|
|
683
850
|
return this.getMediaItemRef(this.ref, (params === null || params === void 0 ? void 0 : params.organizationId) || this._organizationId);
|
|
684
851
|
case 6:
|
|
685
|
-
mediaItemRef =
|
|
852
|
+
mediaItemRef = _context8.sent;
|
|
686
853
|
this.itemRef = mediaItemRef;
|
|
687
854
|
if (!(this._organizationId && this._organizationId != this.itemRef.organizationId)) {
|
|
688
|
-
|
|
855
|
+
_context8.next = 10;
|
|
689
856
|
break;
|
|
690
857
|
}
|
|
691
858
|
throw new Error('The existing mediaItemRef belongs to a different organization');
|
|
@@ -696,21 +863,21 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
696
863
|
this._mediaType = mediaItemRef.mediaType;
|
|
697
864
|
this._functionType = mediaItemRef.functionType;
|
|
698
865
|
this._state = 'SAVED';
|
|
699
|
-
|
|
866
|
+
_context8.next = 18;
|
|
700
867
|
return this.getMediaItem((_mediaItemRef$refUrl = mediaItemRef.refUrl) !== null && _mediaItemRef$refUrl !== void 0 ? _mediaItemRef$refUrl : mediaItemRef.url, (params === null || params === void 0 ? void 0 : params.organizationId) || this._organizationId);
|
|
701
868
|
case 18:
|
|
702
|
-
this.item =
|
|
869
|
+
this.item = _context8.sent;
|
|
703
870
|
this._description = this.item.description;
|
|
704
871
|
this._borderPercentage = this.item.borderPercentage;
|
|
705
872
|
this._fileName = this.item.fileName;
|
|
706
873
|
this._classes = this.item.classes;
|
|
707
874
|
case 23:
|
|
708
875
|
case "end":
|
|
709
|
-
return
|
|
876
|
+
return _context8.stop();
|
|
710
877
|
}
|
|
711
|
-
},
|
|
878
|
+
}, _callee8, this);
|
|
712
879
|
}));
|
|
713
|
-
function load(
|
|
880
|
+
function load(_x11) {
|
|
714
881
|
return _load.apply(this, arguments);
|
|
715
882
|
}
|
|
716
883
|
return load;
|
|
@@ -718,43 +885,43 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
718
885
|
}, {
|
|
719
886
|
key: "loadMany",
|
|
720
887
|
value: function () {
|
|
721
|
-
var _loadMany = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
888
|
+
var _loadMany = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee9(params) {
|
|
722
889
|
var _params$refIds2, _params$organizationI, _refs$0$refUrl;
|
|
723
890
|
var refs, mediaItem;
|
|
724
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
725
|
-
while (1) switch (
|
|
891
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee9$(_context9) {
|
|
892
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
726
893
|
case 0:
|
|
727
894
|
if (params !== null && params !== void 0 && (_params$refIds2 = params.refIds) !== null && _params$refIds2 !== void 0 && _params$refIds2.length) {
|
|
728
|
-
|
|
895
|
+
_context9.next = 2;
|
|
729
896
|
break;
|
|
730
897
|
}
|
|
731
898
|
throw new Error('refs are undefined');
|
|
732
899
|
case 2:
|
|
733
900
|
if (!(!(params !== null && params !== void 0 && params.organizationId) && !this._organizationId)) {
|
|
734
|
-
|
|
901
|
+
_context9.next = 4;
|
|
735
902
|
break;
|
|
736
903
|
}
|
|
737
904
|
throw new Error('Ref or OrganizationId must be set to load data form server');
|
|
738
905
|
case 4:
|
|
739
|
-
|
|
906
|
+
_context9.next = 6;
|
|
740
907
|
return this.getMediaItemRefs(params.refIds, (_params$organizationI = params === null || params === void 0 ? void 0 : params.organizationId) !== null && _params$organizationI !== void 0 ? _params$organizationI : this._organizationId);
|
|
741
908
|
case 6:
|
|
742
|
-
refs =
|
|
743
|
-
|
|
909
|
+
refs = _context9.sent;
|
|
910
|
+
_context9.next = 9;
|
|
744
911
|
return this.getMediaItem((_refs$0$refUrl = refs[0].refUrl) !== null && _refs$0$refUrl !== void 0 ? _refs$0$refUrl : refs[0].url, (params === null || params === void 0 ? void 0 : params.organizationId) || this._organizationId);
|
|
745
912
|
case 9:
|
|
746
|
-
mediaItem =
|
|
747
|
-
return
|
|
913
|
+
mediaItem = _context9.sent;
|
|
914
|
+
return _context9.abrupt("return", {
|
|
748
915
|
mediaItem: mediaItem,
|
|
749
916
|
refs: refs
|
|
750
917
|
});
|
|
751
918
|
case 11:
|
|
752
919
|
case "end":
|
|
753
|
-
return
|
|
920
|
+
return _context9.stop();
|
|
754
921
|
}
|
|
755
|
-
},
|
|
922
|
+
}, _callee9, this);
|
|
756
923
|
}));
|
|
757
|
-
function loadMany(
|
|
924
|
+
function loadMany(_x12) {
|
|
758
925
|
return _loadMany.apply(this, arguments);
|
|
759
926
|
}
|
|
760
927
|
return loadMany;
|
|
@@ -767,10 +934,10 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
767
934
|
}, {
|
|
768
935
|
key: "getMediaItem",
|
|
769
936
|
value: function () {
|
|
770
|
-
var _getMediaItem = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
937
|
+
var _getMediaItem = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee10(imageUrl, organizationId) {
|
|
771
938
|
var url, filter, mediaItem;
|
|
772
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
773
|
-
while (1) switch (
|
|
939
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee10$(_context10) {
|
|
940
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
774
941
|
case 0:
|
|
775
942
|
url = new URL("".concat(this.config.url, "/v1/mediaitems"));
|
|
776
943
|
filter = "{url,eq,".concat(imageUrl, "}");
|
|
@@ -779,7 +946,7 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
779
946
|
}
|
|
780
947
|
url.searchParams.append('limit', '1');
|
|
781
948
|
url.searchParams.append('filter', encodeURIComponent("[".concat(filter, "]")));
|
|
782
|
-
|
|
949
|
+
_context10.next = 7;
|
|
783
950
|
return fetch(url.toString(), {
|
|
784
951
|
method: 'GET',
|
|
785
952
|
headers: this.config.jwt ? {
|
|
@@ -789,18 +956,18 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
789
956
|
return r.json();
|
|
790
957
|
});
|
|
791
958
|
case 7:
|
|
792
|
-
|
|
793
|
-
return
|
|
959
|
+
_context10.next = 9;
|
|
960
|
+
return _context10.sent;
|
|
794
961
|
case 9:
|
|
795
|
-
mediaItem =
|
|
796
|
-
return
|
|
962
|
+
mediaItem = _context10.sent;
|
|
963
|
+
return _context10.abrupt("return", mediaItem === null || mediaItem === void 0 ? void 0 : mediaItem.data[0]);
|
|
797
964
|
case 11:
|
|
798
965
|
case "end":
|
|
799
|
-
return
|
|
966
|
+
return _context10.stop();
|
|
800
967
|
}
|
|
801
|
-
},
|
|
968
|
+
}, _callee10, this);
|
|
802
969
|
}));
|
|
803
|
-
function getMediaItem(
|
|
970
|
+
function getMediaItem(_x13, _x14) {
|
|
804
971
|
return _getMediaItem.apply(this, arguments);
|
|
805
972
|
}
|
|
806
973
|
return getMediaItem;
|
|
@@ -808,10 +975,10 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
808
975
|
}, {
|
|
809
976
|
key: "getMediaItemRef",
|
|
810
977
|
value: function () {
|
|
811
|
-
var _getMediaItemRef = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
978
|
+
var _getMediaItemRef = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee11(ref, organizationId) {
|
|
812
979
|
var url, filter, mediaItemRef;
|
|
813
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
814
|
-
while (1) switch (
|
|
980
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee11$(_context11) {
|
|
981
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
815
982
|
case 0:
|
|
816
983
|
url = new URL("".concat(this.config.url, "/v1/mediaitems/refs"));
|
|
817
984
|
filter = "{_id,eq,".concat(ref, "}");
|
|
@@ -820,7 +987,7 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
820
987
|
}
|
|
821
988
|
url.searchParams.append('limit', '1');
|
|
822
989
|
url.searchParams.append('filter', encodeURIComponent("[".concat(filter, "]")));
|
|
823
|
-
|
|
990
|
+
_context11.next = 7;
|
|
824
991
|
return fetch(url.toString(), {
|
|
825
992
|
method: 'GET',
|
|
826
993
|
headers: this.config.jwt ? {
|
|
@@ -830,18 +997,18 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
830
997
|
return r.json();
|
|
831
998
|
});
|
|
832
999
|
case 7:
|
|
833
|
-
|
|
834
|
-
return
|
|
1000
|
+
_context11.next = 9;
|
|
1001
|
+
return _context11.sent;
|
|
835
1002
|
case 9:
|
|
836
|
-
mediaItemRef =
|
|
837
|
-
return
|
|
1003
|
+
mediaItemRef = _context11.sent;
|
|
1004
|
+
return _context11.abrupt("return", mediaItemRef === null || mediaItemRef === void 0 ? void 0 : mediaItemRef.data[0]);
|
|
838
1005
|
case 11:
|
|
839
1006
|
case "end":
|
|
840
|
-
return
|
|
1007
|
+
return _context11.stop();
|
|
841
1008
|
}
|
|
842
|
-
},
|
|
1009
|
+
}, _callee11, this);
|
|
843
1010
|
}));
|
|
844
|
-
function getMediaItemRef(
|
|
1011
|
+
function getMediaItemRef(_x15, _x16) {
|
|
845
1012
|
return _getMediaItemRef.apply(this, arguments);
|
|
846
1013
|
}
|
|
847
1014
|
return getMediaItemRef;
|
|
@@ -849,10 +1016,10 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
849
1016
|
}, {
|
|
850
1017
|
key: "getMediaItemRefs",
|
|
851
1018
|
value: function () {
|
|
852
|
-
var _getMediaItemRefs = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
1019
|
+
var _getMediaItemRefs = _asyncToGenerator__default["default"](/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee12(refs, organizationId) {
|
|
853
1020
|
var url, filter, mediaItemRef;
|
|
854
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
855
|
-
while (1) switch (
|
|
1021
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee12$(_context12) {
|
|
1022
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
856
1023
|
case 0:
|
|
857
1024
|
url = new URL("".concat(this.config.url, "/v1/mediaitems/refs"));
|
|
858
1025
|
filter = "{_id,in,".concat(refs.join(','), "}");
|
|
@@ -861,7 +1028,7 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
861
1028
|
}
|
|
862
1029
|
url.searchParams.append('limit', refs.length.toString());
|
|
863
1030
|
url.searchParams.append('filter', encodeURIComponent("[".concat(filter, "]")));
|
|
864
|
-
|
|
1031
|
+
_context12.next = 7;
|
|
865
1032
|
return fetch(url.toString(), {
|
|
866
1033
|
method: 'GET',
|
|
867
1034
|
headers: this.config.jwt ? {
|
|
@@ -871,18 +1038,18 @@ var DivaFile = /*#__PURE__*/function () {
|
|
|
871
1038
|
return r.json();
|
|
872
1039
|
});
|
|
873
1040
|
case 7:
|
|
874
|
-
|
|
875
|
-
return
|
|
1041
|
+
_context12.next = 9;
|
|
1042
|
+
return _context12.sent;
|
|
876
1043
|
case 9:
|
|
877
|
-
mediaItemRef =
|
|
878
|
-
return
|
|
1044
|
+
mediaItemRef = _context12.sent;
|
|
1045
|
+
return _context12.abrupt("return", mediaItemRef === null || mediaItemRef === void 0 ? void 0 : mediaItemRef.data);
|
|
879
1046
|
case 11:
|
|
880
1047
|
case "end":
|
|
881
|
-
return
|
|
1048
|
+
return _context12.stop();
|
|
882
1049
|
}
|
|
883
|
-
},
|
|
1050
|
+
}, _callee12, this);
|
|
884
1051
|
}));
|
|
885
|
-
function getMediaItemRefs(
|
|
1052
|
+
function getMediaItemRefs(_x17, _x18) {
|
|
886
1053
|
return _getMediaItemRefs.apply(this, arguments);
|
|
887
1054
|
}
|
|
888
1055
|
return getMediaItemRefs;
|