@atlaskit/editor-card-provider 6.1.1 → 6.2.1
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 +17 -0
- package/dist/cjs/provider.js +205 -177
- package/dist/es2019/provider.js +53 -37
- package/dist/esm/provider.js +205 -177
- package/dist/types/provider.d.ts +2 -0
- package/dist/types-ts4.5/provider.d.ts +2 -0
- package/package.json +3 -3
package/dist/esm/provider.js
CHANGED
|
@@ -16,6 +16,7 @@ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new B
|
|
|
16
16
|
import { extractSmartLinkEmbed } from '@atlaskit/link-extractors';
|
|
17
17
|
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
18
18
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
19
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
19
20
|
import { getStatus, getBaseUrl, getResolverUrl } from '@atlaskit/linking-common';
|
|
20
21
|
import DataLoader from 'dataloader';
|
|
21
22
|
import { Transformer } from './transformer';
|
|
@@ -211,45 +212,27 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
211
212
|
while (1) switch (_context2.prev = _context2.next) {
|
|
212
213
|
case 0:
|
|
213
214
|
_context2.prev = 0;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
_context2.next = 4;
|
|
219
|
-
return this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
220
|
-
type: 'inlineCard',
|
|
221
|
-
attrs: {
|
|
222
|
-
url: resourceUrl
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
case 4:
|
|
226
|
-
_context2.t0 = _context2.sent;
|
|
227
|
-
_context2.next = 10;
|
|
228
|
-
break;
|
|
229
|
-
case 7:
|
|
230
|
-
_context2.next = 9;
|
|
231
|
-
return this.cardClient.fetchData(resourceUrl);
|
|
232
|
-
case 9:
|
|
233
|
-
_context2.t0 = _context2.sent;
|
|
234
|
-
case 10:
|
|
235
|
-
response = _context2.t0;
|
|
215
|
+
_context2.next = 3;
|
|
216
|
+
return this.fetchData(resourceUrl);
|
|
217
|
+
case 3:
|
|
218
|
+
response = _context2.sent;
|
|
236
219
|
if (!(getStatus(response) !== 'not_found')) {
|
|
237
|
-
_context2.next =
|
|
220
|
+
_context2.next = 6;
|
|
238
221
|
break;
|
|
239
222
|
}
|
|
240
223
|
return _context2.abrupt("return", true);
|
|
241
|
-
case
|
|
242
|
-
_context2.next =
|
|
224
|
+
case 6:
|
|
225
|
+
_context2.next = 11;
|
|
243
226
|
break;
|
|
244
|
-
case
|
|
245
|
-
_context2.prev =
|
|
246
|
-
_context2.
|
|
227
|
+
case 8:
|
|
228
|
+
_context2.prev = 8;
|
|
229
|
+
_context2.t0 = _context2["catch"](0);
|
|
247
230
|
return _context2.abrupt("return", false);
|
|
248
|
-
case
|
|
231
|
+
case 11:
|
|
249
232
|
case "end":
|
|
250
233
|
return _context2.stop();
|
|
251
234
|
}
|
|
252
|
-
}, _callee2, this, [[0,
|
|
235
|
+
}, _callee2, this, [[0, 8]]);
|
|
253
236
|
}));
|
|
254
237
|
function checkLinkResolved(_x2) {
|
|
255
238
|
return _checkLinkResolved.apply(this, arguments);
|
|
@@ -265,45 +248,27 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
265
248
|
while (1) switch (_context3.prev = _context3.next) {
|
|
266
249
|
case 0:
|
|
267
250
|
_context3.prev = 0;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
_context3.next = 4;
|
|
273
|
-
return this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
274
|
-
type: 'inlineCard',
|
|
275
|
-
attrs: {
|
|
276
|
-
url: resourceUrl
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
case 4:
|
|
280
|
-
_context3.t0 = _context3.sent;
|
|
281
|
-
_context3.next = 10;
|
|
282
|
-
break;
|
|
283
|
-
case 7:
|
|
284
|
-
_context3.next = 9;
|
|
285
|
-
return this.cardClient.fetchData(resourceUrl);
|
|
286
|
-
case 9:
|
|
287
|
-
_context3.t0 = _context3.sent;
|
|
288
|
-
case 10:
|
|
289
|
-
response = _context3.t0;
|
|
251
|
+
_context3.next = 3;
|
|
252
|
+
return this.fetchData(resourceUrl);
|
|
253
|
+
case 3:
|
|
254
|
+
response = _context3.sent;
|
|
290
255
|
if (!(getStatus(response) !== 'not_found')) {
|
|
291
|
-
_context3.next =
|
|
256
|
+
_context3.next = 6;
|
|
292
257
|
break;
|
|
293
258
|
}
|
|
294
259
|
return _context3.abrupt("return", response);
|
|
295
|
-
case
|
|
296
|
-
_context3.next =
|
|
260
|
+
case 6:
|
|
261
|
+
_context3.next = 11;
|
|
297
262
|
break;
|
|
298
|
-
case
|
|
299
|
-
_context3.prev =
|
|
300
|
-
_context3.
|
|
263
|
+
case 8:
|
|
264
|
+
_context3.prev = 8;
|
|
265
|
+
_context3.t0 = _context3["catch"](0);
|
|
301
266
|
return _context3.abrupt("return", undefined);
|
|
302
|
-
case
|
|
267
|
+
case 11:
|
|
303
268
|
case "end":
|
|
304
269
|
return _context3.stop();
|
|
305
270
|
}
|
|
306
|
-
}, _callee3, this, [[0,
|
|
271
|
+
}, _callee3, this, [[0, 8]]);
|
|
307
272
|
}));
|
|
308
273
|
function fetchDataForResource(_x3) {
|
|
309
274
|
return _fetchDataForResource.apply(this, arguments);
|
|
@@ -530,125 +495,162 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
530
495
|
return 'embed';
|
|
531
496
|
}
|
|
532
497
|
}
|
|
533
|
-
|
|
534
|
-
/**
|
|
535
|
-
* Make a /resolve call and find out if result has embed capability
|
|
536
|
-
*/
|
|
537
498
|
}, {
|
|
538
|
-
key: "
|
|
539
|
-
value:
|
|
540
|
-
var
|
|
541
|
-
var details, embed;
|
|
499
|
+
key: "fetchData",
|
|
500
|
+
value: function () {
|
|
501
|
+
var _fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(url) {
|
|
542
502
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
543
503
|
while (1) switch (_context9.prev = _context9.next) {
|
|
544
504
|
case 0:
|
|
545
|
-
_context9.prev = 0;
|
|
546
505
|
if (!expValEquals('platform_editor_smart_card_otp', 'isEnabled', true)) {
|
|
547
|
-
_context9.next =
|
|
506
|
+
_context9.next = 6;
|
|
548
507
|
break;
|
|
549
508
|
}
|
|
550
|
-
_context9.next =
|
|
509
|
+
_context9.next = 3;
|
|
551
510
|
return this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
552
511
|
type: 'inlineCard',
|
|
553
512
|
attrs: {
|
|
554
513
|
url: url
|
|
555
514
|
}
|
|
556
515
|
});
|
|
557
|
-
case
|
|
516
|
+
case 3:
|
|
558
517
|
_context9.t0 = _context9.sent;
|
|
559
|
-
_context9.next = 10;
|
|
560
|
-
break;
|
|
561
|
-
case 7:
|
|
562
518
|
_context9.next = 9;
|
|
519
|
+
break;
|
|
520
|
+
case 6:
|
|
521
|
+
_context9.next = 8;
|
|
563
522
|
return this.cardClient.fetchData(url);
|
|
564
|
-
case
|
|
523
|
+
case 8:
|
|
565
524
|
_context9.t0 = _context9.sent;
|
|
525
|
+
case 9:
|
|
526
|
+
return _context9.abrupt("return", _context9.t0);
|
|
566
527
|
case 10:
|
|
567
|
-
|
|
528
|
+
case "end":
|
|
529
|
+
return _context9.stop();
|
|
530
|
+
}
|
|
531
|
+
}, _callee9, this);
|
|
532
|
+
}));
|
|
533
|
+
function fetchData(_x7) {
|
|
534
|
+
return _fetchData.apply(this, arguments);
|
|
535
|
+
}
|
|
536
|
+
return fetchData;
|
|
537
|
+
}()
|
|
538
|
+
/**
|
|
539
|
+
* Make a /resolve call and find out if result has embed capability
|
|
540
|
+
*/
|
|
541
|
+
}, {
|
|
542
|
+
key: "canBeResolvedAsEmbed",
|
|
543
|
+
value: (function () {
|
|
544
|
+
var _canBeResolvedAsEmbed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(url) {
|
|
545
|
+
var details, embed;
|
|
546
|
+
return _regeneratorRuntime.wrap(function _callee0$(_context0) {
|
|
547
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
548
|
+
case 0:
|
|
549
|
+
_context0.prev = 0;
|
|
550
|
+
_context0.next = 3;
|
|
551
|
+
return this.fetchData(url);
|
|
552
|
+
case 3:
|
|
553
|
+
details = _context0.sent;
|
|
568
554
|
if (details) {
|
|
569
|
-
|
|
555
|
+
_context0.next = 6;
|
|
570
556
|
break;
|
|
571
557
|
}
|
|
572
|
-
return
|
|
573
|
-
case
|
|
558
|
+
return _context0.abrupt("return", false);
|
|
559
|
+
case 6:
|
|
574
560
|
if (!(getStatus(details) !== 'resolved')) {
|
|
575
|
-
|
|
561
|
+
_context0.next = 8;
|
|
576
562
|
break;
|
|
577
563
|
}
|
|
578
|
-
return
|
|
579
|
-
case
|
|
564
|
+
return _context0.abrupt("return", false);
|
|
565
|
+
case 8:
|
|
580
566
|
embed = extractSmartLinkEmbed(details);
|
|
581
|
-
return
|
|
582
|
-
case
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
return
|
|
586
|
-
case
|
|
567
|
+
return _context0.abrupt("return", !!embed);
|
|
568
|
+
case 12:
|
|
569
|
+
_context0.prev = 12;
|
|
570
|
+
_context0.t0 = _context0["catch"](0);
|
|
571
|
+
return _context0.abrupt("return", false);
|
|
572
|
+
case 15:
|
|
587
573
|
case "end":
|
|
588
|
-
return
|
|
574
|
+
return _context0.stop();
|
|
589
575
|
}
|
|
590
|
-
},
|
|
576
|
+
}, _callee0, this, [[0, 12]]);
|
|
591
577
|
}));
|
|
592
|
-
function canBeResolvedAsEmbed(
|
|
578
|
+
function canBeResolvedAsEmbed(_x8) {
|
|
593
579
|
return _canBeResolvedAsEmbed.apply(this, arguments);
|
|
594
580
|
}
|
|
595
581
|
return canBeResolvedAsEmbed;
|
|
582
|
+
}())
|
|
583
|
+
}, {
|
|
584
|
+
key: "getAuthStatusFromResolveResponse",
|
|
585
|
+
value: function () {
|
|
586
|
+
var _getAuthStatusFromResolveResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee1(url) {
|
|
587
|
+
var _yield$this$fetchData, _yield$this$fetchData2, access, visibility;
|
|
588
|
+
return _regeneratorRuntime.wrap(function _callee1$(_context1) {
|
|
589
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
590
|
+
case 0:
|
|
591
|
+
_context1.prev = 0;
|
|
592
|
+
_context1.next = 3;
|
|
593
|
+
return this.fetchData(url);
|
|
594
|
+
case 3:
|
|
595
|
+
_yield$this$fetchData = _context1.sent;
|
|
596
|
+
_yield$this$fetchData2 = _yield$this$fetchData.meta;
|
|
597
|
+
access = _yield$this$fetchData2.access;
|
|
598
|
+
visibility = _yield$this$fetchData2.visibility;
|
|
599
|
+
return _context1.abrupt("return", {
|
|
600
|
+
access: access,
|
|
601
|
+
visibility: visibility
|
|
602
|
+
});
|
|
603
|
+
case 10:
|
|
604
|
+
_context1.prev = 10;
|
|
605
|
+
_context1.t0 = _context1["catch"](0);
|
|
606
|
+
return _context1.abrupt("return", undefined);
|
|
607
|
+
case 13:
|
|
608
|
+
case "end":
|
|
609
|
+
return _context1.stop();
|
|
610
|
+
}
|
|
611
|
+
}, _callee1, this, [[0, 10]]);
|
|
612
|
+
}));
|
|
613
|
+
function getAuthStatusFromResolveResponse(_x9) {
|
|
614
|
+
return _getAuthStatusFromResolveResponse.apply(this, arguments);
|
|
615
|
+
}
|
|
616
|
+
return getAuthStatusFromResolveResponse;
|
|
596
617
|
}()
|
|
597
618
|
/**
|
|
598
619
|
* Make a /resolve call and find out if result has datasource capability
|
|
599
620
|
*/
|
|
600
|
-
)
|
|
601
621
|
}, {
|
|
602
622
|
key: "getDatasourceFromResolveResponse",
|
|
603
623
|
value: (function () {
|
|
604
|
-
var _getDatasourceFromResolveResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
624
|
+
var _getDatasourceFromResolveResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(url) {
|
|
605
625
|
var response, datasources;
|
|
606
|
-
return _regeneratorRuntime.wrap(function
|
|
607
|
-
while (1) switch (
|
|
626
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
627
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
608
628
|
case 0:
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
_context0.next = 4;
|
|
615
|
-
return this.getDataAsPromise_DO_NOT_USE_OUTSIDE_MIGRATIONS({
|
|
616
|
-
type: 'inlineCard',
|
|
617
|
-
attrs: {
|
|
618
|
-
url: url
|
|
619
|
-
}
|
|
620
|
-
});
|
|
621
|
-
case 4:
|
|
622
|
-
_context0.t0 = _context0.sent;
|
|
623
|
-
_context0.next = 10;
|
|
624
|
-
break;
|
|
625
|
-
case 7:
|
|
626
|
-
_context0.next = 9;
|
|
627
|
-
return this.cardClient.fetchData(url);
|
|
628
|
-
case 9:
|
|
629
|
-
_context0.t0 = _context0.sent;
|
|
630
|
-
case 10:
|
|
631
|
-
response = _context0.t0;
|
|
629
|
+
_context10.prev = 0;
|
|
630
|
+
_context10.next = 3;
|
|
631
|
+
return this.fetchData(url);
|
|
632
|
+
case 3:
|
|
633
|
+
response = _context10.sent;
|
|
632
634
|
datasources = response && response.datasources || [];
|
|
633
635
|
if (!(datasources.length > 0)) {
|
|
634
|
-
|
|
636
|
+
_context10.next = 7;
|
|
635
637
|
break;
|
|
636
638
|
}
|
|
637
|
-
return
|
|
638
|
-
case
|
|
639
|
-
|
|
639
|
+
return _context10.abrupt("return", datasources[0]);
|
|
640
|
+
case 7:
|
|
641
|
+
_context10.next = 12;
|
|
640
642
|
break;
|
|
641
|
-
case
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
return
|
|
645
|
-
case
|
|
643
|
+
case 9:
|
|
644
|
+
_context10.prev = 9;
|
|
645
|
+
_context10.t0 = _context10["catch"](0);
|
|
646
|
+
return _context10.abrupt("return", undefined);
|
|
647
|
+
case 12:
|
|
646
648
|
case "end":
|
|
647
|
-
return
|
|
649
|
+
return _context10.stop();
|
|
648
650
|
}
|
|
649
|
-
},
|
|
651
|
+
}, _callee10, this, [[0, 9]]);
|
|
650
652
|
}));
|
|
651
|
-
function getDatasourceFromResolveResponse(
|
|
653
|
+
function getDatasourceFromResolveResponse(_x0) {
|
|
652
654
|
return _getDatasourceFromResolveResponse.apply(this, arguments);
|
|
653
655
|
}
|
|
654
656
|
return getDatasourceFromResolveResponse;
|
|
@@ -665,38 +667,38 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
665
667
|
}, {
|
|
666
668
|
key: "resolve",
|
|
667
669
|
value: function () {
|
|
668
|
-
var _resolve = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
669
|
-
var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, data, issueAri, _this$onResolve, isSupported, providerDefaultAppearance, preferredAppearance, canItBeEmbed, datasource, id, parameters;
|
|
670
|
-
return _regeneratorRuntime.wrap(function
|
|
671
|
-
while (1) switch (
|
|
670
|
+
var _resolve = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(url, appearance, shouldForceAppearance, isEmbedFriendlyLocation) {
|
|
671
|
+
var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, data, issueAri, _this$onResolve, isSupported, providerDefaultAppearance, isEmbedFriendlyLocationEvaluated, preferredAppearance, canItBeEmbed, datasource, id, parameters, isUnauthPasteAsBlockCardEnabledNoExposure, authStatus, access, isUnauthPasteAsBlockCardEnabled;
|
|
672
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
673
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
672
674
|
case 0:
|
|
673
|
-
|
|
675
|
+
_context11.prev = 0;
|
|
674
676
|
if (!(shouldForceAppearance === true)) {
|
|
675
|
-
|
|
677
|
+
_context11.next = 3;
|
|
676
678
|
break;
|
|
677
679
|
}
|
|
678
|
-
return
|
|
680
|
+
return _context11.abrupt("return", this.transformer.toSmartlinkAdf(url, appearance));
|
|
679
681
|
case 3:
|
|
680
682
|
hardCodedAppearance = this.getHardCodedAppearance(url);
|
|
681
|
-
|
|
683
|
+
_context11.next = 6;
|
|
682
684
|
return Promise.all([this.findPatternData(url), this.findUserPreference(url)]);
|
|
683
685
|
case 6:
|
|
684
|
-
_yield$Promise$all =
|
|
686
|
+
_yield$Promise$all = _context11.sent;
|
|
685
687
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
686
688
|
matchedProviderPattern = _yield$Promise$all2[0];
|
|
687
689
|
userPreference = _yield$Promise$all2[1];
|
|
688
690
|
if (!fg('issue-link-suggestions-in-comments')) {
|
|
689
|
-
|
|
691
|
+
_context11.next = 16;
|
|
690
692
|
break;
|
|
691
693
|
}
|
|
692
694
|
if (!(isJiraWorkItem(url) && this.isLocalUrl(url))) {
|
|
693
|
-
|
|
695
|
+
_context11.next = 16;
|
|
694
696
|
break;
|
|
695
697
|
}
|
|
696
|
-
|
|
698
|
+
_context11.next = 14;
|
|
697
699
|
return this.fetchDataForResource(url);
|
|
698
700
|
case 14:
|
|
699
|
-
data =
|
|
701
|
+
data = _context11.sent;
|
|
700
702
|
if (data) {
|
|
701
703
|
issueAri = this.extractAriFromData(data);
|
|
702
704
|
if (issueAri) {
|
|
@@ -705,27 +707,28 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
705
707
|
}
|
|
706
708
|
case 16:
|
|
707
709
|
if (!(shouldForceAppearance === false && userPreference === 'url')) {
|
|
708
|
-
|
|
710
|
+
_context11.next = 18;
|
|
709
711
|
break;
|
|
710
712
|
}
|
|
711
|
-
return
|
|
713
|
+
return _context11.abrupt("return", Promise.reject(undefined));
|
|
712
714
|
case 18:
|
|
713
|
-
|
|
714
|
-
if (
|
|
715
|
-
|
|
715
|
+
_context11.t0 = !!matchedProviderPattern;
|
|
716
|
+
if (_context11.t0) {
|
|
717
|
+
_context11.next = 23;
|
|
716
718
|
break;
|
|
717
719
|
}
|
|
718
|
-
|
|
720
|
+
_context11.next = 22;
|
|
719
721
|
return this.checkLinkResolved(url);
|
|
720
722
|
case 22:
|
|
721
|
-
|
|
723
|
+
_context11.t0 = _context11.sent;
|
|
722
724
|
case 23:
|
|
723
|
-
isSupported =
|
|
725
|
+
isSupported = _context11.t0;
|
|
724
726
|
if (!isSupported) {
|
|
725
|
-
|
|
727
|
+
_context11.next = 51;
|
|
726
728
|
break;
|
|
727
729
|
}
|
|
728
730
|
providerDefaultAppearance = matchedProviderPattern === null || matchedProviderPattern === void 0 ? void 0 : matchedProviderPattern.defaultView;
|
|
731
|
+
isEmbedFriendlyLocationEvaluated = isEmbedFriendlyLocation || isEmbedFriendlyLocation === undefined;
|
|
729
732
|
preferredAppearance = shouldForceAppearance === undefined ?
|
|
730
733
|
// Ignore both User and provider's appearances if older editor that doesn't send shouldForceAppearance
|
|
731
734
|
hardCodedAppearance || appearance :
|
|
@@ -734,33 +737,33 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
734
737
|
userPreference ||
|
|
735
738
|
// If user's default choice is "inline" or user hasn't specified preferences at all,
|
|
736
739
|
// we check whatever one of the hardcoded providers match url (jira /timeline, polaris, etc)
|
|
737
|
-
|
|
740
|
+
isEmbedFriendlyLocationEvaluated && hardCodedAppearance ||
|
|
738
741
|
// If non match, we see if this provider has default appearance for this particular regexp
|
|
739
742
|
providerDefaultAppearance ||
|
|
740
743
|
// If not, we pick what editor (or any other client) requested
|
|
741
744
|
appearance;
|
|
742
745
|
if (!(preferredAppearance === userPreference && userPreference === 'embed')) {
|
|
743
|
-
|
|
746
|
+
_context11.next = 33;
|
|
744
747
|
break;
|
|
745
748
|
}
|
|
746
|
-
|
|
749
|
+
_context11.next = 31;
|
|
747
750
|
return this.canBeResolvedAsEmbed(url);
|
|
748
|
-
case
|
|
749
|
-
canItBeEmbed =
|
|
751
|
+
case 31:
|
|
752
|
+
canItBeEmbed = _context11.sent;
|
|
750
753
|
if (!canItBeEmbed) {
|
|
751
754
|
preferredAppearance = 'inline';
|
|
752
755
|
}
|
|
753
|
-
case
|
|
754
|
-
|
|
756
|
+
case 33:
|
|
757
|
+
_context11.next = 35;
|
|
755
758
|
return this.getDatasourceFromResolveResponse(url);
|
|
756
|
-
case
|
|
757
|
-
datasource =
|
|
759
|
+
case 35:
|
|
760
|
+
datasource = _context11.sent;
|
|
758
761
|
if (!datasource) {
|
|
759
|
-
|
|
762
|
+
_context11.next = 39;
|
|
760
763
|
break;
|
|
761
764
|
}
|
|
762
765
|
id = datasource.id, parameters = datasource.parameters;
|
|
763
|
-
return
|
|
766
|
+
return _context11.abrupt("return", this.transformer.toDatasourceAdf({
|
|
764
767
|
id: id,
|
|
765
768
|
parameters: parameters,
|
|
766
769
|
// in the future when we support multiple views, we will need to pass this in as a parameter
|
|
@@ -769,25 +772,50 @@ export var EditorCardProvider = /*#__PURE__*/function (_ref) {
|
|
|
769
772
|
type: 'table'
|
|
770
773
|
}]
|
|
771
774
|
}, url));
|
|
772
|
-
case 38:
|
|
773
|
-
return _context1.abrupt("return", this.transformer.toSmartlinkAdf(url, preferredAppearance));
|
|
774
775
|
case 39:
|
|
775
|
-
|
|
776
|
+
isUnauthPasteAsBlockCardEnabledNoExposure = !expValEqualsNoExposure('platform_sl_3p_unauth_paste_as_block_card', 'cohort', 'control', 'control');
|
|
777
|
+
if (!(isUnauthPasteAsBlockCardEnabledNoExposure && isEmbedFriendlyLocationEvaluated && !userPreference)) {
|
|
778
|
+
_context11.next = 50;
|
|
779
|
+
break;
|
|
780
|
+
}
|
|
781
|
+
_context11.next = 43;
|
|
782
|
+
return this.getAuthStatusFromResolveResponse(url);
|
|
783
|
+
case 43:
|
|
784
|
+
authStatus = _context11.sent;
|
|
785
|
+
if (!authStatus) {
|
|
786
|
+
_context11.next = 50;
|
|
787
|
+
break;
|
|
788
|
+
}
|
|
789
|
+
access = authStatus.access;
|
|
790
|
+
if (!(access === 'unauthorized')) {
|
|
791
|
+
_context11.next = 50;
|
|
792
|
+
break;
|
|
793
|
+
}
|
|
794
|
+
isUnauthPasteAsBlockCardEnabled = !expValEquals('platform_sl_3p_unauth_paste_as_block_card', 'cohort', 'control', 'control');
|
|
795
|
+
if (!isUnauthPasteAsBlockCardEnabled) {
|
|
796
|
+
_context11.next = 50;
|
|
797
|
+
break;
|
|
798
|
+
}
|
|
799
|
+
return _context11.abrupt("return", this.transformer.toSmartlinkAdf(url, 'block'));
|
|
800
|
+
case 50:
|
|
801
|
+
return _context11.abrupt("return", this.transformer.toSmartlinkAdf(url, preferredAppearance));
|
|
802
|
+
case 51:
|
|
803
|
+
_context11.next = 56;
|
|
776
804
|
break;
|
|
777
|
-
case
|
|
778
|
-
|
|
779
|
-
|
|
805
|
+
case 53:
|
|
806
|
+
_context11.prev = 53;
|
|
807
|
+
_context11.t1 = _context11["catch"](0);
|
|
780
808
|
// eslint-disable-next-line
|
|
781
|
-
console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(
|
|
782
|
-
case
|
|
783
|
-
return
|
|
784
|
-
case
|
|
809
|
+
console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_context11.t1 instanceof Error ? " - ".concat(_context11.t1.name, " ").concat(_context11.t1.message) : ''), _context11.t1);
|
|
810
|
+
case 56:
|
|
811
|
+
return _context11.abrupt("return", Promise.reject(undefined));
|
|
812
|
+
case 57:
|
|
785
813
|
case "end":
|
|
786
|
-
return
|
|
814
|
+
return _context11.stop();
|
|
787
815
|
}
|
|
788
|
-
},
|
|
816
|
+
}, _callee11, this, [[0, 53]]);
|
|
789
817
|
}));
|
|
790
|
-
function resolve(
|
|
818
|
+
function resolve(_x1, _x10, _x11, _x12) {
|
|
791
819
|
return _resolve.apply(this, arguments);
|
|
792
820
|
}
|
|
793
821
|
return resolve;
|
package/dist/types/provider.d.ts
CHANGED
|
@@ -40,10 +40,12 @@ export declare class EditorCardProvider extends NodeDataProvider<CardNode, JsonL
|
|
|
40
40
|
* @returns 'embed' for the card appearance to embed by default
|
|
41
41
|
*/
|
|
42
42
|
protected getHardCodedAppearance(url: string): CardAppearance | undefined;
|
|
43
|
+
private fetchData;
|
|
43
44
|
/**
|
|
44
45
|
* Make a /resolve call and find out if result has embed capability
|
|
45
46
|
*/
|
|
46
47
|
private canBeResolvedAsEmbed;
|
|
48
|
+
private getAuthStatusFromResolveResponse;
|
|
47
49
|
/**
|
|
48
50
|
* Make a /resolve call and find out if result has datasource capability
|
|
49
51
|
*/
|
|
@@ -40,10 +40,12 @@ export declare class EditorCardProvider extends NodeDataProvider<CardNode, JsonL
|
|
|
40
40
|
* @returns 'embed' for the card appearance to embed by default
|
|
41
41
|
*/
|
|
42
42
|
protected getHardCodedAppearance(url: string): CardAppearance | undefined;
|
|
43
|
+
private fetchData;
|
|
43
44
|
/**
|
|
44
45
|
* Make a /resolve call and find out if result has embed capability
|
|
45
46
|
*/
|
|
46
47
|
private canBeResolvedAsEmbed;
|
|
48
|
+
private getAuthStatusFromResolveResponse;
|
|
47
49
|
/**
|
|
48
50
|
* Make a /resolve call and find out if result has datasource capability
|
|
49
51
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-card-provider",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.1",
|
|
4
4
|
"description": "Contains the EditorCardProvider, for determining smart card behaviour in the editor.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"@atlaskit/json-ld-types": "^1.4.0",
|
|
35
35
|
"@atlaskit/link-client-extension": "^6.0.0",
|
|
36
36
|
"@atlaskit/link-extractors": "^2.4.0",
|
|
37
|
-
"@atlaskit/linking-common": "^9.
|
|
37
|
+
"@atlaskit/linking-common": "^9.9.0",
|
|
38
38
|
"@atlaskit/linking-types": "^14.2.0",
|
|
39
39
|
"@atlaskit/node-data-provider": "^7.5.0",
|
|
40
40
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
41
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
41
|
+
"@atlaskit/tmp-editor-statsig": "^15.0.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|
|
43
43
|
"dataloader": "^2.1.0"
|
|
44
44
|
},
|