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