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