@atlaskit/editor-card-provider 6.8.3 → 6.8.4
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/CHANGELOG.md +8 -0
- package/dist/cjs/api.js +18 -18
- package/dist/cjs/provider.js +173 -192
- package/dist/es2019/provider.js +16 -37
- package/dist/esm/api.js +18 -18
- package/dist/esm/provider.js +173 -192
- package/package.json +3 -3
package/dist/esm/provider.js
CHANGED
|
@@ -190,7 +190,7 @@ export function isExternalUrl(url) {
|
|
|
190
190
|
function isCardNode(node) {
|
|
191
191
|
return ['inlineCard', 'blockCard', 'embedCard'].includes(node.type) && !!node.attrs && 'url' in node.attrs && typeof node.attrs.url === 'string';
|
|
192
192
|
}
|
|
193
|
-
export var EditorCardProvider = /*#__PURE__*/function (
|
|
193
|
+
export var EditorCardProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
194
194
|
function EditorCardProvider(envKey, baseUrlOverride, product, onResolve, customCardClient, supportedUrlFilter) {
|
|
195
195
|
var _this;
|
|
196
196
|
_classCallCheck(this, EditorCardProvider);
|
|
@@ -218,7 +218,7 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
218
218
|
}
|
|
219
219
|
return _this;
|
|
220
220
|
}
|
|
221
|
-
_inherits(EditorCardProvider,
|
|
221
|
+
_inherits(EditorCardProvider, _NodeDataProvider);
|
|
222
222
|
return _createClass(EditorCardProvider, [{
|
|
223
223
|
key: "refreshCache",
|
|
224
224
|
value: function refreshCache(node) {
|
|
@@ -242,48 +242,27 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
242
242
|
// if we can load a response from cache, use it first
|
|
243
243
|
var key = this.nodeDataKey(jsonNode);
|
|
244
244
|
var details = this.smartCardLocalCacheClient.getItem(key);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// if parent class NodeDataProvider has cached the network request for the node
|
|
255
|
-
// we can skip fetching the data async and updating the session storage cache
|
|
256
|
-
if (isResolvedCachedResponse && this.getCacheStatusForNode(jsonNode) === 'network') {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
} else {
|
|
260
|
-
if (details) {
|
|
261
|
-
callback({
|
|
262
|
-
data: details
|
|
263
|
-
});
|
|
264
|
-
}
|
|
245
|
+
// NAVX-4712: Handle responses with non-resolved statuses that were previously cached
|
|
246
|
+
var isResolvedCachedResponse = details && details.meta && getStatus(details) === 'resolved';
|
|
247
|
+
if (isResolvedCachedResponse) {
|
|
248
|
+
callback({
|
|
249
|
+
data: details
|
|
250
|
+
});
|
|
251
|
+
}
|
|
265
252
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
253
|
+
// if parent class NodeDataProvider has cached the network request for the node
|
|
254
|
+
// we can skip fetching the data async and updating the session storage cache
|
|
255
|
+
if (isResolvedCachedResponse && this.getCacheStatusForNode(jsonNode) === 'network') {
|
|
256
|
+
return;
|
|
272
257
|
}
|
|
273
258
|
|
|
274
259
|
// fetch the latest data async and update the session storage cache
|
|
275
260
|
this.getDataAsync(node, function (payload) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
_this2.smartCardLocalCacheClient.setItem(key, response);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
} else {
|
|
285
|
-
if (payload.data && !payload.error) {
|
|
286
|
-
_this2.smartCardLocalCacheClient.setItem(key, payload.data);
|
|
261
|
+
var response = payload.data;
|
|
262
|
+
if (!payload.error && response !== null && response !== void 0 && response.meta) {
|
|
263
|
+
var status = getStatus(response);
|
|
264
|
+
if (status === 'resolved') {
|
|
265
|
+
_this2.smartCardLocalCacheClient.setItem(key, response);
|
|
287
266
|
}
|
|
288
267
|
}
|
|
289
268
|
callback(payload);
|
|
@@ -322,17 +301,17 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
322
301
|
value: function () {
|
|
323
302
|
var _batchProviders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(keys) {
|
|
324
303
|
var providersData;
|
|
325
|
-
return _regeneratorRuntime.wrap(function
|
|
304
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
326
305
|
while (1) switch (_context.prev = _context.next) {
|
|
327
306
|
case 0:
|
|
328
|
-
_context.next =
|
|
307
|
+
_context.next = 1;
|
|
329
308
|
return this.fetchProvidersData();
|
|
330
|
-
case
|
|
309
|
+
case 1:
|
|
331
310
|
providersData = _context.sent;
|
|
332
311
|
return _context.abrupt("return", keys.map(function () {
|
|
333
312
|
return providersData;
|
|
334
313
|
}));
|
|
335
|
-
case
|
|
314
|
+
case 2:
|
|
336
315
|
case "end":
|
|
337
316
|
return _context.stop();
|
|
338
317
|
}
|
|
@@ -347,32 +326,32 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
347
326
|
key: "checkLinkResolved",
|
|
348
327
|
value: function () {
|
|
349
328
|
var _checkLinkResolved = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resourceUrl) {
|
|
350
|
-
var response;
|
|
351
|
-
return _regeneratorRuntime.wrap(function
|
|
329
|
+
var response, _t;
|
|
330
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
352
331
|
while (1) switch (_context2.prev = _context2.next) {
|
|
353
332
|
case 0:
|
|
354
333
|
_context2.prev = 0;
|
|
355
|
-
_context2.next =
|
|
334
|
+
_context2.next = 1;
|
|
356
335
|
return this.fetchData(resourceUrl);
|
|
357
|
-
case
|
|
336
|
+
case 1:
|
|
358
337
|
response = _context2.sent;
|
|
359
338
|
if (!(getStatus(response) !== 'not_found')) {
|
|
360
|
-
_context2.next =
|
|
339
|
+
_context2.next = 2;
|
|
361
340
|
break;
|
|
362
341
|
}
|
|
363
342
|
return _context2.abrupt("return", true);
|
|
364
|
-
case
|
|
365
|
-
_context2.next =
|
|
343
|
+
case 2:
|
|
344
|
+
_context2.next = 4;
|
|
366
345
|
break;
|
|
367
|
-
case
|
|
368
|
-
_context2.prev =
|
|
369
|
-
|
|
346
|
+
case 3:
|
|
347
|
+
_context2.prev = 3;
|
|
348
|
+
_t = _context2["catch"](0);
|
|
370
349
|
return _context2.abrupt("return", false);
|
|
371
|
-
case
|
|
350
|
+
case 4:
|
|
372
351
|
case "end":
|
|
373
352
|
return _context2.stop();
|
|
374
353
|
}
|
|
375
|
-
}, _callee2, this, [[0,
|
|
354
|
+
}, _callee2, this, [[0, 3]]);
|
|
376
355
|
}));
|
|
377
356
|
function checkLinkResolved(_x2) {
|
|
378
357
|
return _checkLinkResolved.apply(this, arguments);
|
|
@@ -383,32 +362,32 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
383
362
|
key: "fetchDataForResource",
|
|
384
363
|
value: function () {
|
|
385
364
|
var _fetchDataForResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(resourceUrl) {
|
|
386
|
-
var response;
|
|
387
|
-
return _regeneratorRuntime.wrap(function
|
|
365
|
+
var response, _t2;
|
|
366
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
388
367
|
while (1) switch (_context3.prev = _context3.next) {
|
|
389
368
|
case 0:
|
|
390
369
|
_context3.prev = 0;
|
|
391
|
-
_context3.next =
|
|
370
|
+
_context3.next = 1;
|
|
392
371
|
return this.fetchData(resourceUrl);
|
|
393
|
-
case
|
|
372
|
+
case 1:
|
|
394
373
|
response = _context3.sent;
|
|
395
374
|
if (!(getStatus(response) !== 'not_found')) {
|
|
396
|
-
_context3.next =
|
|
375
|
+
_context3.next = 2;
|
|
397
376
|
break;
|
|
398
377
|
}
|
|
399
378
|
return _context3.abrupt("return", response);
|
|
400
|
-
case
|
|
401
|
-
_context3.next =
|
|
379
|
+
case 2:
|
|
380
|
+
_context3.next = 4;
|
|
402
381
|
break;
|
|
403
|
-
case
|
|
404
|
-
_context3.prev =
|
|
405
|
-
|
|
382
|
+
case 3:
|
|
383
|
+
_context3.prev = 3;
|
|
384
|
+
_t2 = _context3["catch"](0);
|
|
406
385
|
return _context3.abrupt("return", undefined);
|
|
407
|
-
case
|
|
386
|
+
case 4:
|
|
408
387
|
case "end":
|
|
409
388
|
return _context3.stop();
|
|
410
389
|
}
|
|
411
|
-
}, _callee3, this, [[0,
|
|
390
|
+
}, _callee3, this, [[0, 3]]);
|
|
412
391
|
}));
|
|
413
392
|
function fetchDataForResource(_x3) {
|
|
414
393
|
return _fetchDataForResource.apply(this, arguments);
|
|
@@ -428,13 +407,13 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
428
407
|
value: function () {
|
|
429
408
|
var _fetchProvidersData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
430
409
|
var endpoint, response;
|
|
431
|
-
return _regeneratorRuntime.wrap(function
|
|
410
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
432
411
|
while (1) switch (_context4.prev = _context4.next) {
|
|
433
412
|
case 0:
|
|
434
413
|
endpoint = "".concat(this.resolverUrl, "/providers");
|
|
435
|
-
_context4.next =
|
|
414
|
+
_context4.next = 1;
|
|
436
415
|
return request('post', endpoint, undefined, this.requestHeaders);
|
|
437
|
-
case
|
|
416
|
+
case 1:
|
|
438
417
|
response = _context4.sent;
|
|
439
418
|
return _context4.abrupt("return", {
|
|
440
419
|
patterns: response.providers.reduce(function (allSources, provider) {
|
|
@@ -442,7 +421,7 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
442
421
|
}, []),
|
|
443
422
|
userPreferences: response.userPreferences
|
|
444
423
|
});
|
|
445
|
-
case
|
|
424
|
+
case 2:
|
|
446
425
|
case "end":
|
|
447
426
|
return _context4.stop();
|
|
448
427
|
}
|
|
@@ -457,28 +436,29 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
457
436
|
key: "loadProviderData",
|
|
458
437
|
value: function () {
|
|
459
438
|
var _loadProviderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
460
|
-
|
|
439
|
+
var _t3;
|
|
440
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
461
441
|
while (1) switch (_context5.prev = _context5.next) {
|
|
462
442
|
case 0:
|
|
463
443
|
_context5.prev = 0;
|
|
464
|
-
_context5.next =
|
|
444
|
+
_context5.next = 1;
|
|
465
445
|
return this.providersLoader.load('providersData');
|
|
466
|
-
case
|
|
446
|
+
case 1:
|
|
467
447
|
this.providersData = _context5.sent;
|
|
468
|
-
_context5.next =
|
|
448
|
+
_context5.next = 3;
|
|
469
449
|
break;
|
|
470
|
-
case
|
|
471
|
-
_context5.prev =
|
|
472
|
-
|
|
450
|
+
case 2:
|
|
451
|
+
_context5.prev = 2;
|
|
452
|
+
_t3 = _context5["catch"](0);
|
|
473
453
|
// eslint-disable-next-line
|
|
474
|
-
console.error('failed to fetch /providers',
|
|
454
|
+
console.error('failed to fetch /providers', _t3);
|
|
475
455
|
this.providersLoader.clear('providerData');
|
|
476
456
|
return _context5.abrupt("return", undefined);
|
|
477
|
-
case
|
|
457
|
+
case 3:
|
|
478
458
|
case "end":
|
|
479
459
|
return _context5.stop();
|
|
480
460
|
}
|
|
481
|
-
}, _callee5, this, [[0,
|
|
461
|
+
}, _callee5, this, [[0, 2]]);
|
|
482
462
|
}));
|
|
483
463
|
function loadProviderData() {
|
|
484
464
|
return _loadProviderData.apply(this, arguments);
|
|
@@ -489,24 +469,25 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
489
469
|
key: "findPattern",
|
|
490
470
|
value: function () {
|
|
491
471
|
var _findPattern = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(url) {
|
|
492
|
-
|
|
472
|
+
var _t4;
|
|
473
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
493
474
|
while (1) switch (_context6.prev = _context6.next) {
|
|
494
475
|
case 0:
|
|
495
|
-
_context6.next =
|
|
476
|
+
_context6.next = 1;
|
|
496
477
|
return this.findPatternData(url);
|
|
497
|
-
case
|
|
498
|
-
|
|
499
|
-
if (
|
|
500
|
-
_context6.next =
|
|
478
|
+
case 1:
|
|
479
|
+
_t4 = !!_context6.sent;
|
|
480
|
+
if (_t4) {
|
|
481
|
+
_context6.next = 3;
|
|
501
482
|
break;
|
|
502
483
|
}
|
|
503
|
-
_context6.next =
|
|
484
|
+
_context6.next = 2;
|
|
504
485
|
return this.checkLinkResolved(url);
|
|
505
|
-
case
|
|
506
|
-
|
|
507
|
-
case
|
|
508
|
-
return _context6.abrupt("return",
|
|
509
|
-
case
|
|
486
|
+
case 2:
|
|
487
|
+
_t4 = !!_context6.sent;
|
|
488
|
+
case 3:
|
|
489
|
+
return _context6.abrupt("return", _t4);
|
|
490
|
+
case 4:
|
|
510
491
|
case "end":
|
|
511
492
|
return _context6.stop();
|
|
512
493
|
}
|
|
@@ -534,41 +515,41 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
534
515
|
var _this$providersData,
|
|
535
516
|
_this4 = this;
|
|
536
517
|
var userPreferences, defaultAppearance, appearances, allMatchedLabeledAppearances, longestMatchedLabeledAppearance;
|
|
537
|
-
return _regeneratorRuntime.wrap(function
|
|
518
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
538
519
|
while (1) switch (_context7.prev = _context7.next) {
|
|
539
520
|
case 0:
|
|
540
521
|
if (this.providersData) {
|
|
541
|
-
_context7.next =
|
|
522
|
+
_context7.next = 1;
|
|
542
523
|
break;
|
|
543
524
|
}
|
|
544
|
-
_context7.next =
|
|
525
|
+
_context7.next = 1;
|
|
545
526
|
return this.loadProviderData();
|
|
546
|
-
case
|
|
527
|
+
case 1:
|
|
547
528
|
userPreferences = (_this$providersData = this.providersData) === null || _this$providersData === void 0 ? void 0 : _this$providersData.userPreferences;
|
|
548
529
|
if (!userPreferences) {
|
|
549
|
-
_context7.next =
|
|
530
|
+
_context7.next = 3;
|
|
550
531
|
break;
|
|
551
532
|
}
|
|
552
533
|
defaultAppearance = userPreferences.defaultAppearance, appearances = userPreferences.appearances;
|
|
553
|
-
allMatchedLabeledAppearances = appearances.filter(function (
|
|
554
|
-
var urlSegment =
|
|
534
|
+
allMatchedLabeledAppearances = appearances.filter(function (_ref) {
|
|
535
|
+
var urlSegment = _ref.urlSegment;
|
|
555
536
|
return _this4.doesUrlMatchPath(urlSegment, url);
|
|
556
537
|
});
|
|
557
538
|
if (!(allMatchedLabeledAppearances.length > 0)) {
|
|
558
|
-
_context7.next =
|
|
539
|
+
_context7.next = 2;
|
|
559
540
|
break;
|
|
560
541
|
}
|
|
561
542
|
longestMatchedLabeledAppearance = allMatchedLabeledAppearances.reduce(function (previousLabeledAppearance, currentLabeledAppearance) {
|
|
562
543
|
return previousLabeledAppearance.urlSegment.length > currentLabeledAppearance.urlSegment.length ? previousLabeledAppearance : currentLabeledAppearance;
|
|
563
544
|
});
|
|
564
545
|
return _context7.abrupt("return", longestMatchedLabeledAppearance.appearance);
|
|
565
|
-
case
|
|
546
|
+
case 2:
|
|
566
547
|
if (!(defaultAppearance !== 'inline')) {
|
|
567
|
-
_context7.next =
|
|
548
|
+
_context7.next = 3;
|
|
568
549
|
break;
|
|
569
550
|
}
|
|
570
551
|
return _context7.abrupt("return", defaultAppearance);
|
|
571
|
-
case
|
|
552
|
+
case 3:
|
|
572
553
|
case "end":
|
|
573
554
|
return _context7.stop();
|
|
574
555
|
}
|
|
@@ -584,20 +565,20 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
584
565
|
value: function () {
|
|
585
566
|
var _findPatternData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(url) {
|
|
586
567
|
var _this$providersData2;
|
|
587
|
-
return _regeneratorRuntime.wrap(function
|
|
568
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
588
569
|
while (1) switch (_context8.prev = _context8.next) {
|
|
589
570
|
case 0:
|
|
590
571
|
if (this.providersData) {
|
|
591
|
-
_context8.next =
|
|
572
|
+
_context8.next = 1;
|
|
592
573
|
break;
|
|
593
574
|
}
|
|
594
|
-
_context8.next =
|
|
575
|
+
_context8.next = 1;
|
|
595
576
|
return this.loadProviderData();
|
|
596
|
-
case
|
|
577
|
+
case 1:
|
|
597
578
|
return _context8.abrupt("return", (_this$providersData2 = this.providersData) === null || _this$providersData2 === void 0 ? void 0 : _this$providersData2.patterns.find(function (pattern) {
|
|
598
579
|
return url.match(pattern.source);
|
|
599
580
|
}));
|
|
600
|
-
case
|
|
581
|
+
case 2:
|
|
601
582
|
case "end":
|
|
602
583
|
return _context8.stop();
|
|
603
584
|
}
|
|
@@ -636,10 +617,10 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
636
617
|
key: "fetchData",
|
|
637
618
|
value: function () {
|
|
638
619
|
var _fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(url) {
|
|
639
|
-
return _regeneratorRuntime.wrap(function
|
|
620
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
640
621
|
while (1) switch (_context9.prev = _context9.next) {
|
|
641
622
|
case 0:
|
|
642
|
-
_context9.next =
|
|
623
|
+
_context9.next = 1;
|
|
643
624
|
return this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
644
625
|
// It's ok to cast any resourceUrl to inlineCard here, because only URL is important for the request.
|
|
645
626
|
type: 'inlineCard',
|
|
@@ -647,9 +628,9 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
647
628
|
url: url
|
|
648
629
|
}
|
|
649
630
|
});
|
|
650
|
-
case
|
|
631
|
+
case 1:
|
|
651
632
|
return _context9.abrupt("return", _context9.sent);
|
|
652
|
-
case
|
|
633
|
+
case 2:
|
|
653
634
|
case "end":
|
|
654
635
|
return _context9.stop();
|
|
655
636
|
}
|
|
@@ -667,38 +648,38 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
667
648
|
key: "canBeResolvedAsEmbed",
|
|
668
649
|
value: (function () {
|
|
669
650
|
var _canBeResolvedAsEmbed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(url) {
|
|
670
|
-
var details, embed;
|
|
671
|
-
return _regeneratorRuntime.wrap(function
|
|
651
|
+
var details, embed, _t5;
|
|
652
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
672
653
|
while (1) switch (_context0.prev = _context0.next) {
|
|
673
654
|
case 0:
|
|
674
655
|
_context0.prev = 0;
|
|
675
|
-
_context0.next =
|
|
656
|
+
_context0.next = 1;
|
|
676
657
|
return this.fetchData(url);
|
|
677
|
-
case
|
|
658
|
+
case 1:
|
|
678
659
|
details = _context0.sent;
|
|
679
660
|
if (details) {
|
|
680
|
-
_context0.next =
|
|
661
|
+
_context0.next = 2;
|
|
681
662
|
break;
|
|
682
663
|
}
|
|
683
664
|
return _context0.abrupt("return", false);
|
|
684
|
-
case
|
|
665
|
+
case 2:
|
|
685
666
|
if (!(getStatus(details) !== 'resolved')) {
|
|
686
|
-
_context0.next =
|
|
667
|
+
_context0.next = 3;
|
|
687
668
|
break;
|
|
688
669
|
}
|
|
689
670
|
return _context0.abrupt("return", false);
|
|
690
|
-
case
|
|
671
|
+
case 3:
|
|
691
672
|
embed = extractSmartLinkEmbed(details);
|
|
692
673
|
return _context0.abrupt("return", !!embed);
|
|
693
|
-
case
|
|
694
|
-
_context0.prev =
|
|
695
|
-
|
|
674
|
+
case 4:
|
|
675
|
+
_context0.prev = 4;
|
|
676
|
+
_t5 = _context0["catch"](0);
|
|
696
677
|
return _context0.abrupt("return", false);
|
|
697
|
-
case
|
|
678
|
+
case 5:
|
|
698
679
|
case "end":
|
|
699
680
|
return _context0.stop();
|
|
700
681
|
}
|
|
701
|
-
}, _callee0, this, [[0,
|
|
682
|
+
}, _callee0, this, [[0, 4]]);
|
|
702
683
|
}));
|
|
703
684
|
function canBeResolvedAsEmbed(_x8) {
|
|
704
685
|
return _canBeResolvedAsEmbed.apply(this, arguments);
|
|
@@ -709,14 +690,14 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
709
690
|
key: "getAuthStatusFromResolveResponse",
|
|
710
691
|
value: function () {
|
|
711
692
|
var _getAuthStatusFromResolveResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee1(url) {
|
|
712
|
-
var _yield$this$fetchData, _yield$this$fetchData2, access, visibility;
|
|
713
|
-
return _regeneratorRuntime.wrap(function
|
|
693
|
+
var _yield$this$fetchData, _yield$this$fetchData2, access, visibility, _t6;
|
|
694
|
+
return _regeneratorRuntime.wrap(function (_context1) {
|
|
714
695
|
while (1) switch (_context1.prev = _context1.next) {
|
|
715
696
|
case 0:
|
|
716
697
|
_context1.prev = 0;
|
|
717
|
-
_context1.next =
|
|
698
|
+
_context1.next = 1;
|
|
718
699
|
return this.fetchData(url);
|
|
719
|
-
case
|
|
700
|
+
case 1:
|
|
720
701
|
_yield$this$fetchData = _context1.sent;
|
|
721
702
|
_yield$this$fetchData2 = _yield$this$fetchData.meta;
|
|
722
703
|
access = _yield$this$fetchData2.access;
|
|
@@ -725,15 +706,15 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
725
706
|
access: access,
|
|
726
707
|
visibility: visibility
|
|
727
708
|
});
|
|
728
|
-
case
|
|
729
|
-
_context1.prev =
|
|
730
|
-
|
|
709
|
+
case 2:
|
|
710
|
+
_context1.prev = 2;
|
|
711
|
+
_t6 = _context1["catch"](0);
|
|
731
712
|
return _context1.abrupt("return", undefined);
|
|
732
|
-
case
|
|
713
|
+
case 3:
|
|
733
714
|
case "end":
|
|
734
715
|
return _context1.stop();
|
|
735
716
|
}
|
|
736
|
-
}, _callee1, this, [[0,
|
|
717
|
+
}, _callee1, this, [[0, 2]]);
|
|
737
718
|
}));
|
|
738
719
|
function getAuthStatusFromResolveResponse(_x9) {
|
|
739
720
|
return _getAuthStatusFromResolveResponse.apply(this, arguments);
|
|
@@ -747,33 +728,33 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
747
728
|
key: "getDatasourceFromResolveResponse",
|
|
748
729
|
value: (function () {
|
|
749
730
|
var _getDatasourceFromResolveResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(url) {
|
|
750
|
-
var response, datasources;
|
|
751
|
-
return _regeneratorRuntime.wrap(function
|
|
731
|
+
var response, datasources, _t7;
|
|
732
|
+
return _regeneratorRuntime.wrap(function (_context10) {
|
|
752
733
|
while (1) switch (_context10.prev = _context10.next) {
|
|
753
734
|
case 0:
|
|
754
735
|
_context10.prev = 0;
|
|
755
|
-
_context10.next =
|
|
736
|
+
_context10.next = 1;
|
|
756
737
|
return this.fetchData(url);
|
|
757
|
-
case
|
|
738
|
+
case 1:
|
|
758
739
|
response = _context10.sent;
|
|
759
740
|
datasources = response && response.datasources || [];
|
|
760
741
|
if (!(datasources.length > 0)) {
|
|
761
|
-
_context10.next =
|
|
742
|
+
_context10.next = 2;
|
|
762
743
|
break;
|
|
763
744
|
}
|
|
764
745
|
return _context10.abrupt("return", datasources[0]);
|
|
765
|
-
case
|
|
766
|
-
_context10.next =
|
|
746
|
+
case 2:
|
|
747
|
+
_context10.next = 4;
|
|
767
748
|
break;
|
|
768
|
-
case
|
|
769
|
-
_context10.prev =
|
|
770
|
-
|
|
749
|
+
case 3:
|
|
750
|
+
_context10.prev = 3;
|
|
751
|
+
_t7 = _context10["catch"](0);
|
|
771
752
|
return _context10.abrupt("return", undefined);
|
|
772
|
-
case
|
|
753
|
+
case 4:
|
|
773
754
|
case "end":
|
|
774
755
|
return _context10.stop();
|
|
775
756
|
}
|
|
776
|
-
}, _callee10, this, [[0,
|
|
757
|
+
}, _callee10, this, [[0, 3]]);
|
|
777
758
|
}));
|
|
778
759
|
function getDatasourceFromResolveResponse(_x0) {
|
|
779
760
|
return _getDatasourceFromResolveResponse.apply(this, arguments);
|
|
@@ -793,36 +774,36 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
793
774
|
key: "resolve",
|
|
794
775
|
value: function () {
|
|
795
776
|
var _resolve = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(url, appearance, shouldForceAppearance, isEmbedFriendlyLocation) {
|
|
796
|
-
var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, data, issueAri, _this$onResolve, isSupported, providerDefaultAppearance, isEmbedFriendlyLocationEvaluated, preferredAppearance, canItBeEmbed, datasource, id, parameters, authStatus, access;
|
|
797
|
-
return _regeneratorRuntime.wrap(function
|
|
777
|
+
var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, data, issueAri, _this$onResolve, isSupported, providerDefaultAppearance, isEmbedFriendlyLocationEvaluated, preferredAppearance, canItBeEmbed, datasource, id, parameters, authStatus, access, _t8, _t9;
|
|
778
|
+
return _regeneratorRuntime.wrap(function (_context11) {
|
|
798
779
|
while (1) switch (_context11.prev = _context11.next) {
|
|
799
780
|
case 0:
|
|
800
781
|
_context11.prev = 0;
|
|
801
782
|
if (!(shouldForceAppearance === true)) {
|
|
802
|
-
_context11.next =
|
|
783
|
+
_context11.next = 1;
|
|
803
784
|
break;
|
|
804
785
|
}
|
|
805
786
|
return _context11.abrupt("return", this.transformer.toSmartlinkAdf(url, appearance));
|
|
806
|
-
case
|
|
787
|
+
case 1:
|
|
807
788
|
hardCodedAppearance = this.getHardCodedAppearance(url);
|
|
808
|
-
_context11.next =
|
|
789
|
+
_context11.next = 2;
|
|
809
790
|
return Promise.all([this.findPatternData(url), this.findUserPreference(url)]);
|
|
810
|
-
case
|
|
791
|
+
case 2:
|
|
811
792
|
_yield$Promise$all = _context11.sent;
|
|
812
793
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
813
794
|
matchedProviderPattern = _yield$Promise$all2[0];
|
|
814
795
|
userPreference = _yield$Promise$all2[1];
|
|
815
796
|
if (!fg('issue-link-suggestions-in-comments')) {
|
|
816
|
-
_context11.next =
|
|
797
|
+
_context11.next = 4;
|
|
817
798
|
break;
|
|
818
799
|
}
|
|
819
800
|
if (!(isJiraWorkItem(url) && this.isLocalUrl(url))) {
|
|
820
|
-
_context11.next =
|
|
801
|
+
_context11.next = 4;
|
|
821
802
|
break;
|
|
822
803
|
}
|
|
823
|
-
_context11.next =
|
|
804
|
+
_context11.next = 3;
|
|
824
805
|
return this.fetchDataForResource(url);
|
|
825
|
-
case
|
|
806
|
+
case 3:
|
|
826
807
|
data = _context11.sent;
|
|
827
808
|
if (data) {
|
|
828
809
|
issueAri = this.extractAriFromData(data);
|
|
@@ -830,26 +811,26 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
830
811
|
(_this$onResolve = this.onResolve) === null || _this$onResolve === void 0 || _this$onResolve.call(this, url, issueAri);
|
|
831
812
|
}
|
|
832
813
|
}
|
|
833
|
-
case
|
|
814
|
+
case 4:
|
|
834
815
|
if (!(shouldForceAppearance === false && userPreference === 'url')) {
|
|
835
|
-
_context11.next =
|
|
816
|
+
_context11.next = 5;
|
|
836
817
|
break;
|
|
837
818
|
}
|
|
838
819
|
return _context11.abrupt("return", Promise.reject(undefined));
|
|
839
|
-
case
|
|
840
|
-
|
|
841
|
-
if (
|
|
842
|
-
_context11.next =
|
|
820
|
+
case 5:
|
|
821
|
+
_t8 = !!matchedProviderPattern;
|
|
822
|
+
if (_t8) {
|
|
823
|
+
_context11.next = 7;
|
|
843
824
|
break;
|
|
844
825
|
}
|
|
845
|
-
_context11.next =
|
|
826
|
+
_context11.next = 6;
|
|
846
827
|
return this.checkLinkResolved(url);
|
|
847
|
-
case
|
|
848
|
-
|
|
849
|
-
case
|
|
850
|
-
isSupported =
|
|
828
|
+
case 6:
|
|
829
|
+
_t8 = _context11.sent;
|
|
830
|
+
case 7:
|
|
831
|
+
isSupported = _t8;
|
|
851
832
|
if (!isSupported) {
|
|
852
|
-
_context11.next =
|
|
833
|
+
_context11.next = 14;
|
|
853
834
|
break;
|
|
854
835
|
}
|
|
855
836
|
providerDefaultAppearance = matchedProviderPattern === null || matchedProviderPattern === void 0 ? void 0 : matchedProviderPattern.defaultView;
|
|
@@ -868,23 +849,23 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
868
849
|
// If not, we pick what editor (or any other client) requested
|
|
869
850
|
appearance;
|
|
870
851
|
if (!(preferredAppearance === userPreference && userPreference === 'embed')) {
|
|
871
|
-
_context11.next =
|
|
852
|
+
_context11.next = 9;
|
|
872
853
|
break;
|
|
873
854
|
}
|
|
874
|
-
_context11.next =
|
|
855
|
+
_context11.next = 8;
|
|
875
856
|
return this.canBeResolvedAsEmbed(url);
|
|
876
|
-
case
|
|
857
|
+
case 8:
|
|
877
858
|
canItBeEmbed = _context11.sent;
|
|
878
859
|
if (!canItBeEmbed) {
|
|
879
860
|
preferredAppearance = 'inline';
|
|
880
861
|
}
|
|
881
|
-
case
|
|
882
|
-
_context11.next =
|
|
862
|
+
case 9:
|
|
863
|
+
_context11.next = 10;
|
|
883
864
|
return this.getDatasourceFromResolveResponse(url);
|
|
884
|
-
case
|
|
865
|
+
case 10:
|
|
885
866
|
datasource = _context11.sent;
|
|
886
867
|
if (!datasource) {
|
|
887
|
-
_context11.next =
|
|
868
|
+
_context11.next = 11;
|
|
888
869
|
break;
|
|
889
870
|
}
|
|
890
871
|
id = datasource.id, parameters = datasource.parameters;
|
|
@@ -897,42 +878,42 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
897
878
|
type: 'table'
|
|
898
879
|
}]
|
|
899
880
|
}, url));
|
|
900
|
-
case
|
|
881
|
+
case 11:
|
|
901
882
|
if (!(isEmbedFriendlyLocationEvaluated && !userPreference)) {
|
|
902
|
-
_context11.next =
|
|
883
|
+
_context11.next = 13;
|
|
903
884
|
break;
|
|
904
885
|
}
|
|
905
|
-
_context11.next =
|
|
886
|
+
_context11.next = 12;
|
|
906
887
|
return this.getAuthStatusFromResolveResponse(url);
|
|
907
|
-
case
|
|
888
|
+
case 12:
|
|
908
889
|
authStatus = _context11.sent;
|
|
909
890
|
if (!authStatus) {
|
|
910
|
-
_context11.next =
|
|
891
|
+
_context11.next = 13;
|
|
911
892
|
break;
|
|
912
893
|
}
|
|
913
894
|
access = authStatus.access;
|
|
914
895
|
if (!(access === 'unauthorized')) {
|
|
915
|
-
_context11.next =
|
|
896
|
+
_context11.next = 13;
|
|
916
897
|
break;
|
|
917
898
|
}
|
|
918
899
|
return _context11.abrupt("return", this.transformer.toSmartlinkAdf(url, 'block'));
|
|
919
|
-
case
|
|
900
|
+
case 13:
|
|
920
901
|
return _context11.abrupt("return", this.transformer.toSmartlinkAdf(url, preferredAppearance));
|
|
921
|
-
case
|
|
922
|
-
_context11.next =
|
|
902
|
+
case 14:
|
|
903
|
+
_context11.next = 16;
|
|
923
904
|
break;
|
|
924
|
-
case
|
|
925
|
-
_context11.prev =
|
|
926
|
-
|
|
905
|
+
case 15:
|
|
906
|
+
_context11.prev = 15;
|
|
907
|
+
_t9 = _context11["catch"](0);
|
|
927
908
|
// eslint-disable-next-line
|
|
928
|
-
console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(
|
|
929
|
-
case
|
|
909
|
+
console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_t9 instanceof Error ? " - ".concat(_t9.name, " ").concat(_t9.message) : ''), _t9);
|
|
910
|
+
case 16:
|
|
930
911
|
return _context11.abrupt("return", Promise.reject(undefined));
|
|
931
|
-
case
|
|
912
|
+
case 17:
|
|
932
913
|
case "end":
|
|
933
914
|
return _context11.stop();
|
|
934
915
|
}
|
|
935
|
-
}, _callee11, this, [[0,
|
|
916
|
+
}, _callee11, this, [[0, 15]]);
|
|
936
917
|
}));
|
|
937
918
|
function resolve(_x1, _x10, _x11, _x12) {
|
|
938
919
|
return _resolve.apply(this, arguments);
|