@atlaskit/editor-card-provider 5.0.3 → 5.1.0

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.
@@ -8,7 +8,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
8
8
  import _setPrototypeOf from "@babel/runtime/helpers/setPrototypeOf";
9
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
10
10
  function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new BabelRegExp(e, void 0, r); }; var e = RegExp.prototype, r = new WeakMap(); function BabelRegExp(e, t, p) { var o = RegExp(e, t); return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); } function buildGroups(e, t) { var p = r.get(t); return Object.keys(p).reduce(function (r, t) { var o = p[t]; if ("number" == typeof o) r[t] = e[o];else { for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; r[t] = e[o[i]]; } return r; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { var t = e.exec.call(this, r); if (t) { t.groups = buildGroups(t, this); var p = t.indices; p && (p.groups = buildGroups(p, this)); } return t; }, BabelRegExp.prototype[Symbol.replace] = function (t, p) { if ("string" == typeof p) { var o = r.get(this); return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)(>|$)/g, function (e, r, t) { if ("" === t) return e; var p = o[r]; return Array.isArray(p) ? "$" + p.join("$") : "number" == typeof p ? "$" + p : ""; })); } if ("function" == typeof p) { var i = this; return e[Symbol.replace].call(this, t, function () { var e = arguments; return "object" != _typeof(e[e.length - 1]) && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); }); } return e[Symbol.replace].call(this, t, p); }, _wrapRegExp.apply(this, arguments); }
11
- import { extractPreview, extractSmartLinkEmbed } from '@atlaskit/link-extractors';
11
+ import { extractSmartLinkEmbed } from '@atlaskit/link-extractors';
12
12
  import { getStatus } from '@atlaskit/linking-common';
13
13
  import DataLoader from 'dataloader';
14
14
  import { Transformer } from './transformer';
@@ -98,8 +98,11 @@ var isConfluenceTeamCalendars = function isConfluenceTeamCalendars(url) {
98
98
  var isJiraIssueNavigator = function isJiraIssueNavigator(url) {
99
99
  return url.match(/^https:\/\/.*?\/jira\/software|core\/(c\/)?projects\/[^\/]+?\/issues\/?/);
100
100
  };
101
+ export var isJiraWorkItem = function isJiraWorkItem(url) {
102
+ return /\/browse\/((?:\w+)-(?:\d+))/i.test(url);
103
+ };
101
104
  export var EditorCardProvider = /*#__PURE__*/function () {
102
- function EditorCardProvider(envKey, baseUrlOverride, product) {
105
+ function EditorCardProvider(envKey, baseUrlOverride, product, onResolve) {
103
106
  var _this = this;
104
107
  _classCallCheck(this, EditorCardProvider);
105
108
  _defineProperty(this, "getExperimentValue", function (experimentName, parameterName, defaultValue) {
@@ -112,6 +115,7 @@ export var EditorCardProvider = /*#__PURE__*/function () {
112
115
  this.baseUrl = baseUrlOverride || getBaseUrl(envKey);
113
116
  this.resolverUrl = getResolverUrl(envKey, baseUrlOverride);
114
117
  this.transformer = new Transformer();
118
+ this.onResolve = onResolve;
115
119
  this.requestHeaders = {
116
120
  Origin: this.baseUrl
117
121
  };
@@ -190,19 +194,63 @@ export var EditorCardProvider = /*#__PURE__*/function () {
190
194
  return checkLinkResolved;
191
195
  }()
192
196
  }, {
193
- key: "fetchProvidersData",
197
+ key: "fetchDataForResource",
194
198
  value: function () {
195
- var _fetchProvidersData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
196
- var endpoint, response;
199
+ var _fetchDataForResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(resourceUrl) {
200
+ var response;
197
201
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
198
202
  while (1) switch (_context3.prev = _context3.next) {
199
203
  case 0:
200
- endpoint = "".concat(this.resolverUrl, "/providers");
204
+ _context3.prev = 0;
201
205
  _context3.next = 3;
202
- return api.request('post', endpoint, undefined, this.requestHeaders);
206
+ return this.cardClient.fetchData(resourceUrl);
203
207
  case 3:
204
208
  response = _context3.sent;
205
- return _context3.abrupt("return", {
209
+ if (!(getStatus(response) !== 'not_found')) {
210
+ _context3.next = 6;
211
+ break;
212
+ }
213
+ return _context3.abrupt("return", response);
214
+ case 6:
215
+ _context3.next = 11;
216
+ break;
217
+ case 8:
218
+ _context3.prev = 8;
219
+ _context3.t0 = _context3["catch"](0);
220
+ return _context3.abrupt("return", undefined);
221
+ case 11:
222
+ case "end":
223
+ return _context3.stop();
224
+ }
225
+ }, _callee3, this, [[0, 8]]);
226
+ }));
227
+ function fetchDataForResource(_x3) {
228
+ return _fetchDataForResource.apply(this, arguments);
229
+ }
230
+ return fetchDataForResource;
231
+ }()
232
+ }, {
233
+ key: "extractAriFromData",
234
+ value: function extractAriFromData(responseData) {
235
+ if (responseData.data && 'atlassian:ari' in responseData.data) {
236
+ return responseData.data['atlassian:ari'];
237
+ }
238
+ return undefined;
239
+ }
240
+ }, {
241
+ key: "fetchProvidersData",
242
+ value: function () {
243
+ var _fetchProvidersData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
244
+ var endpoint, response;
245
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
246
+ while (1) switch (_context4.prev = _context4.next) {
247
+ case 0:
248
+ endpoint = "".concat(this.resolverUrl, "/providers");
249
+ _context4.next = 3;
250
+ return api.request('post', endpoint, undefined, this.requestHeaders);
251
+ case 3:
252
+ response = _context4.sent;
253
+ return _context4.abrupt("return", {
206
254
  patterns: response.providers.reduce(function (allSources, provider) {
207
255
  return allSources.concat(provider.patterns);
208
256
  }, []),
@@ -210,9 +258,9 @@ export var EditorCardProvider = /*#__PURE__*/function () {
210
258
  });
211
259
  case 5:
212
260
  case "end":
213
- return _context3.stop();
261
+ return _context4.stop();
214
262
  }
215
- }, _callee3, this);
263
+ }, _callee4, this);
216
264
  }));
217
265
  function fetchProvidersData() {
218
266
  return _fetchProvidersData.apply(this, arguments);
@@ -222,29 +270,29 @@ export var EditorCardProvider = /*#__PURE__*/function () {
222
270
  }, {
223
271
  key: "loadProviderData",
224
272
  value: function () {
225
- var _loadProviderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
226
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
227
- while (1) switch (_context4.prev = _context4.next) {
273
+ var _loadProviderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
274
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
275
+ while (1) switch (_context5.prev = _context5.next) {
228
276
  case 0:
229
- _context4.prev = 0;
230
- _context4.next = 3;
277
+ _context5.prev = 0;
278
+ _context5.next = 3;
231
279
  return this.providersLoader.load('providersData');
232
280
  case 3:
233
- this.providersData = _context4.sent;
234
- _context4.next = 11;
281
+ this.providersData = _context5.sent;
282
+ _context5.next = 11;
235
283
  break;
236
284
  case 6:
237
- _context4.prev = 6;
238
- _context4.t0 = _context4["catch"](0);
285
+ _context5.prev = 6;
286
+ _context5.t0 = _context5["catch"](0);
239
287
  // eslint-disable-next-line
240
- console.error('failed to fetch /providers', _context4.t0);
288
+ console.error('failed to fetch /providers', _context5.t0);
241
289
  this.providersLoader.clear('providerData');
242
- return _context4.abrupt("return", undefined);
290
+ return _context5.abrupt("return", undefined);
243
291
  case 11:
244
292
  case "end":
245
- return _context4.stop();
293
+ return _context5.stop();
246
294
  }
247
- }, _callee4, this, [[0, 6]]);
295
+ }, _callee5, this, [[0, 6]]);
248
296
  }));
249
297
  function loadProviderData() {
250
298
  return _loadProviderData.apply(this, arguments);
@@ -254,31 +302,31 @@ export var EditorCardProvider = /*#__PURE__*/function () {
254
302
  }, {
255
303
  key: "findPattern",
256
304
  value: function () {
257
- var _findPattern = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(url) {
258
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
259
- while (1) switch (_context5.prev = _context5.next) {
305
+ var _findPattern = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(url) {
306
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
307
+ while (1) switch (_context6.prev = _context6.next) {
260
308
  case 0:
261
- _context5.next = 2;
309
+ _context6.next = 2;
262
310
  return this.findPatternData(url);
263
311
  case 2:
264
- _context5.t0 = !!_context5.sent;
265
- if (_context5.t0) {
266
- _context5.next = 7;
312
+ _context6.t0 = !!_context6.sent;
313
+ if (_context6.t0) {
314
+ _context6.next = 7;
267
315
  break;
268
316
  }
269
- _context5.next = 6;
317
+ _context6.next = 6;
270
318
  return this.checkLinkResolved(url);
271
319
  case 6:
272
- _context5.t0 = !!_context5.sent;
320
+ _context6.t0 = !!_context6.sent;
273
321
  case 7:
274
- return _context5.abrupt("return", _context5.t0);
322
+ return _context6.abrupt("return", _context6.t0);
275
323
  case 8:
276
324
  case "end":
277
- return _context5.stop();
325
+ return _context6.stop();
278
326
  }
279
- }, _callee5, this);
327
+ }, _callee6, this);
280
328
  }));
281
- function findPattern(_x3) {
329
+ function findPattern(_x4) {
282
330
  return _findPattern.apply(this, arguments);
283
331
  }
284
332
  return findPattern;
@@ -296,23 +344,23 @@ export var EditorCardProvider = /*#__PURE__*/function () {
296
344
  }, {
297
345
  key: "findUserPreference",
298
346
  value: function () {
299
- var _findUserPreference = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(url) {
347
+ var _findUserPreference = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(url) {
300
348
  var _this$providersData,
301
349
  _this2 = this;
302
350
  var userPreferences, defaultAppearance, appearances, allMatchedLabeledAppearances, longestMatchedLabeledAppearance;
303
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
304
- while (1) switch (_context6.prev = _context6.next) {
351
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
352
+ while (1) switch (_context7.prev = _context7.next) {
305
353
  case 0:
306
354
  if (this.providersData) {
307
- _context6.next = 3;
355
+ _context7.next = 3;
308
356
  break;
309
357
  }
310
- _context6.next = 3;
358
+ _context7.next = 3;
311
359
  return this.loadProviderData();
312
360
  case 3:
313
361
  userPreferences = (_this$providersData = this.providersData) === null || _this$providersData === void 0 ? void 0 : _this$providersData.userPreferences;
314
362
  if (!userPreferences) {
315
- _context6.next = 12;
363
+ _context7.next = 12;
316
364
  break;
317
365
  }
318
366
  defaultAppearance = userPreferences.defaultAppearance, appearances = userPreferences.appearances;
@@ -321,26 +369,26 @@ export var EditorCardProvider = /*#__PURE__*/function () {
321
369
  return _this2.doesUrlMatchPath(urlSegment, url);
322
370
  });
323
371
  if (!(allMatchedLabeledAppearances.length > 0)) {
324
- _context6.next = 10;
372
+ _context7.next = 10;
325
373
  break;
326
374
  }
327
375
  longestMatchedLabeledAppearance = allMatchedLabeledAppearances.reduce(function (previousLabeledAppearance, currentLabeledAppearance) {
328
376
  return previousLabeledAppearance.urlSegment.length > currentLabeledAppearance.urlSegment.length ? previousLabeledAppearance : currentLabeledAppearance;
329
377
  });
330
- return _context6.abrupt("return", longestMatchedLabeledAppearance.appearance);
378
+ return _context7.abrupt("return", longestMatchedLabeledAppearance.appearance);
331
379
  case 10:
332
380
  if (!(defaultAppearance !== 'inline')) {
333
- _context6.next = 12;
381
+ _context7.next = 12;
334
382
  break;
335
383
  }
336
- return _context6.abrupt("return", defaultAppearance);
384
+ return _context7.abrupt("return", defaultAppearance);
337
385
  case 12:
338
386
  case "end":
339
- return _context6.stop();
387
+ return _context7.stop();
340
388
  }
341
- }, _callee6, this);
389
+ }, _callee7, this);
342
390
  }));
343
- function findUserPreference(_x4) {
391
+ function findUserPreference(_x5) {
344
392
  return _findUserPreference.apply(this, arguments);
345
393
  }
346
394
  return findUserPreference;
@@ -348,28 +396,28 @@ export var EditorCardProvider = /*#__PURE__*/function () {
348
396
  }, {
349
397
  key: "findPatternData",
350
398
  value: function () {
351
- var _findPatternData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(url) {
399
+ var _findPatternData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(url) {
352
400
  var _this$providersData2;
353
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
354
- while (1) switch (_context7.prev = _context7.next) {
401
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
402
+ while (1) switch (_context8.prev = _context8.next) {
355
403
  case 0:
356
404
  if (this.providersData) {
357
- _context7.next = 3;
405
+ _context8.next = 3;
358
406
  break;
359
407
  }
360
- _context7.next = 3;
408
+ _context8.next = 3;
361
409
  return this.loadProviderData();
362
410
  case 3:
363
- return _context7.abrupt("return", (_this$providersData2 = this.providersData) === null || _this$providersData2 === void 0 ? void 0 : _this$providersData2.patterns.find(function (pattern) {
411
+ return _context8.abrupt("return", (_this$providersData2 = this.providersData) === null || _this$providersData2 === void 0 ? void 0 : _this$providersData2.patterns.find(function (pattern) {
364
412
  return url.match(pattern.source);
365
413
  }));
366
414
  case 4:
367
415
  case "end":
368
- return _context7.stop();
416
+ return _context8.stop();
369
417
  }
370
- }, _callee7, this);
418
+ }, _callee8, this);
371
419
  }));
372
- function findPatternData(_x5) {
420
+ function findPatternData(_x6) {
373
421
  return _findPatternData.apply(this, arguments);
374
422
  }
375
423
  return findPatternData;
@@ -418,55 +466,41 @@ export var EditorCardProvider = /*#__PURE__*/function () {
418
466
  * Make a /resolve call and find out if result has embed capability
419
467
  */
420
468
  function () {
421
- var _canBeResolvedAsEmbed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(url) {
422
- var details, embed, data, preview;
423
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
424
- while (1) switch (_context8.prev = _context8.next) {
469
+ var _canBeResolvedAsEmbed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(url) {
470
+ var details, embed;
471
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
472
+ while (1) switch (_context9.prev = _context9.next) {
425
473
  case 0:
426
- _context8.prev = 0;
427
- _context8.next = 3;
474
+ _context9.prev = 0;
475
+ _context9.next = 3;
428
476
  return this.cardClient.fetchData(url);
429
477
  case 3:
430
- details = _context8.sent;
431
- if (!fg('smart_links_noun_support')) {
432
- _context8.next = 9;
433
- break;
434
- }
478
+ details = _context9.sent;
435
479
  if (details) {
436
- _context8.next = 7;
480
+ _context9.next = 6;
437
481
  break;
438
482
  }
439
- return _context8.abrupt("return", false);
440
- case 7:
441
- embed = extractSmartLinkEmbed(details);
442
- return _context8.abrupt("return", !!embed);
443
- case 9:
444
- data = details && details.data;
445
- if (data) {
446
- _context8.next = 12;
447
- break;
448
- }
449
- return _context8.abrupt("return", false);
450
- case 12:
483
+ return _context9.abrupt("return", false);
484
+ case 6:
451
485
  if (!(getStatus(details) !== 'resolved')) {
452
- _context8.next = 14;
486
+ _context9.next = 8;
453
487
  break;
454
488
  }
455
- return _context8.abrupt("return", false);
456
- case 14:
457
- preview = extractPreview(data, 'web');
458
- return _context8.abrupt("return", !!preview);
459
- case 18:
460
- _context8.prev = 18;
461
- _context8.t0 = _context8["catch"](0);
462
- return _context8.abrupt("return", false);
463
- case 21:
489
+ return _context9.abrupt("return", false);
490
+ case 8:
491
+ embed = extractSmartLinkEmbed(details);
492
+ return _context9.abrupt("return", !!embed);
493
+ case 12:
494
+ _context9.prev = 12;
495
+ _context9.t0 = _context9["catch"](0);
496
+ return _context9.abrupt("return", false);
497
+ case 15:
464
498
  case "end":
465
- return _context8.stop();
499
+ return _context9.stop();
466
500
  }
467
- }, _callee8, this, [[0, 18]]);
501
+ }, _callee9, this, [[0, 12]]);
468
502
  }));
469
- function canBeResolvedAsEmbed(_x6) {
503
+ function canBeResolvedAsEmbed(_x7) {
470
504
  return _canBeResolvedAsEmbed.apply(this, arguments);
471
505
  }
472
506
  return canBeResolvedAsEmbed;
@@ -478,82 +512,110 @@ export var EditorCardProvider = /*#__PURE__*/function () {
478
512
  }, {
479
513
  key: "getDatasourceFromResolveResponse",
480
514
  value: (function () {
481
- var _getDatasourceFromResolveResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(url) {
515
+ var _getDatasourceFromResolveResponse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(url) {
482
516
  var response, datasources;
483
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
484
- while (1) switch (_context9.prev = _context9.next) {
517
+ return _regeneratorRuntime.wrap(function _callee0$(_context0) {
518
+ while (1) switch (_context0.prev = _context0.next) {
485
519
  case 0:
486
- _context9.prev = 0;
487
- _context9.next = 3;
520
+ _context0.prev = 0;
521
+ _context0.next = 3;
488
522
  return this.cardClient.fetchData(url);
489
523
  case 3:
490
- response = _context9.sent;
524
+ response = _context0.sent;
491
525
  datasources = response && response.datasources || [];
492
526
  if (!(datasources.length > 0)) {
493
- _context9.next = 7;
527
+ _context0.next = 7;
494
528
  break;
495
529
  }
496
- return _context9.abrupt("return", datasources[0]);
530
+ return _context0.abrupt("return", datasources[0]);
497
531
  case 7:
498
- _context9.next = 12;
532
+ _context0.next = 12;
499
533
  break;
500
534
  case 9:
501
- _context9.prev = 9;
502
- _context9.t0 = _context9["catch"](0);
503
- return _context9.abrupt("return", undefined);
535
+ _context0.prev = 9;
536
+ _context0.t0 = _context0["catch"](0);
537
+ return _context0.abrupt("return", undefined);
504
538
  case 12:
505
539
  case "end":
506
- return _context9.stop();
540
+ return _context0.stop();
507
541
  }
508
- }, _callee9, this, [[0, 9]]);
542
+ }, _callee0, this, [[0, 9]]);
509
543
  }));
510
- function getDatasourceFromResolveResponse(_x7) {
544
+ function getDatasourceFromResolveResponse(_x8) {
511
545
  return _getDatasourceFromResolveResponse.apply(this, arguments);
512
546
  }
513
547
  return getDatasourceFromResolveResponse;
514
- }())
548
+ }()
549
+ /**
550
+ * This is used to determine if the url is a local Jira url or a remote one.
551
+ */
552
+ )
553
+ }, {
554
+ key: "isLocalUrl",
555
+ value: function isLocalUrl(url) {
556
+ return new URL(url).origin === this.baseUrl;
557
+ }
515
558
  }, {
516
559
  key: "resolve",
517
560
  value: function () {
518
- var _resolve = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(url, appearance, shouldForceAppearance, isEmbedFriendlyLocation) {
519
- var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, isSupported, providerDefaultAppearance, preferredAppearance, canItBeEmbed, datasource, id, parameters;
520
- return _regeneratorRuntime.wrap(function _callee0$(_context0) {
521
- while (1) switch (_context0.prev = _context0.next) {
561
+ var _resolve = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee1(url, appearance, shouldForceAppearance, isEmbedFriendlyLocation) {
562
+ var hardCodedAppearance, _yield$Promise$all, _yield$Promise$all2, matchedProviderPattern, userPreference, data, issueAri, _this$onResolve, isSupported, providerDefaultAppearance, preferredAppearance, canItBeEmbed, datasource, id, parameters;
563
+ return _regeneratorRuntime.wrap(function _callee1$(_context1) {
564
+ while (1) switch (_context1.prev = _context1.next) {
522
565
  case 0:
523
- _context0.prev = 0;
566
+ _context1.prev = 0;
524
567
  if (!(shouldForceAppearance === true)) {
525
- _context0.next = 3;
568
+ _context1.next = 3;
526
569
  break;
527
570
  }
528
- return _context0.abrupt("return", this.transformer.toSmartlinkAdf(url, appearance));
571
+ return _context1.abrupt("return", this.transformer.toSmartlinkAdf(url, appearance));
529
572
  case 3:
530
573
  hardCodedAppearance = this.getHardCodedAppearance(url);
531
- _context0.next = 6;
574
+ _context1.next = 6;
532
575
  return Promise.all([this.findPatternData(url), this.findUserPreference(url)]);
533
576
  case 6:
534
- _yield$Promise$all = _context0.sent;
577
+ _yield$Promise$all = _context1.sent;
535
578
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
536
579
  matchedProviderPattern = _yield$Promise$all2[0];
537
580
  userPreference = _yield$Promise$all2[1];
581
+ if (!fg('issue-link-suggestions-in-comments')) {
582
+ _context1.next = 16;
583
+ break;
584
+ }
585
+ if (!(isJiraWorkItem(url) && this.isLocalUrl(url))) {
586
+ _context1.next = 16;
587
+ break;
588
+ }
589
+ _context1.next = 14;
590
+ return this.fetchDataForResource(url);
591
+ case 14:
592
+ data = _context1.sent;
593
+ if (data) {
594
+ issueAri = this.extractAriFromData(data);
595
+ if (issueAri) {
596
+ (_this$onResolve = this.onResolve) === null || _this$onResolve === void 0 || _this$onResolve.call(this, url, issueAri);
597
+ }
598
+ }
599
+ case 16:
538
600
  if (!(shouldForceAppearance === false && userPreference === 'url')) {
539
- _context0.next = 12;
601
+ _context1.next = 18;
540
602
  break;
541
603
  }
542
- return _context0.abrupt("return", Promise.reject(undefined));
543
- case 12:
544
- _context0.t0 = !!matchedProviderPattern;
545
- if (_context0.t0) {
546
- _context0.next = 17;
604
+ return _context1.abrupt("return", Promise.reject(undefined));
605
+ case 18:
606
+ _context1.t0 = !!matchedProviderPattern;
607
+ if (_context1.t0) {
608
+ _context1.next = 23;
547
609
  break;
548
610
  }
549
- _context0.next = 16;
611
+ _context1.next = 22;
550
612
  return this.checkLinkResolved(url);
551
- case 16:
552
- _context0.t0 = _context0.sent;
553
- case 17:
554
- isSupported = _context0.t0;
613
+ case 22:
614
+ _context1.t0 = _context1.sent;
615
+ case 23:
616
+ isSupported = _context1.t0;
555
617
  if (!isSupported) {
556
- _context0.next = 33;
618
+ _context1.next = 39;
557
619
  break;
558
620
  }
559
621
  providerDefaultAppearance = matchedProviderPattern === null || matchedProviderPattern === void 0 ? void 0 : matchedProviderPattern.defaultView;
@@ -571,27 +633,27 @@ export var EditorCardProvider = /*#__PURE__*/function () {
571
633
  // If not, we pick what editor (or any other client) requested
572
634
  appearance;
573
635
  if (!(preferredAppearance === userPreference && userPreference === 'embed')) {
574
- _context0.next = 26;
636
+ _context1.next = 32;
575
637
  break;
576
638
  }
577
- _context0.next = 24;
639
+ _context1.next = 30;
578
640
  return this.canBeResolvedAsEmbed(url);
579
- case 24:
580
- canItBeEmbed = _context0.sent;
641
+ case 30:
642
+ canItBeEmbed = _context1.sent;
581
643
  if (!canItBeEmbed) {
582
644
  preferredAppearance = 'inline';
583
645
  }
584
- case 26:
585
- _context0.next = 28;
646
+ case 32:
647
+ _context1.next = 34;
586
648
  return this.getDatasourceFromResolveResponse(url);
587
- case 28:
588
- datasource = _context0.sent;
649
+ case 34:
650
+ datasource = _context1.sent;
589
651
  if (!datasource) {
590
- _context0.next = 32;
652
+ _context1.next = 38;
591
653
  break;
592
654
  }
593
655
  id = datasource.id, parameters = datasource.parameters;
594
- return _context0.abrupt("return", this.transformer.toDatasourceAdf({
656
+ return _context1.abrupt("return", this.transformer.toDatasourceAdf({
595
657
  id: id,
596
658
  parameters: parameters,
597
659
  // in the future when we support multiple views, we will need to pass this in as a parameter
@@ -600,25 +662,25 @@ export var EditorCardProvider = /*#__PURE__*/function () {
600
662
  type: 'table'
601
663
  }]
602
664
  }, url));
603
- case 32:
604
- return _context0.abrupt("return", this.transformer.toSmartlinkAdf(url, preferredAppearance));
605
- case 33:
606
- _context0.next = 38;
607
- break;
608
- case 35:
609
- _context0.prev = 35;
610
- _context0.t1 = _context0["catch"](0);
611
- // eslint-disable-next-line
612
- console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_context0.t1 instanceof Error ? " - ".concat(_context0.t1.name, " ").concat(_context0.t1.message) : ''), _context0.t1);
613
665
  case 38:
614
- return _context0.abrupt("return", Promise.reject(undefined));
666
+ return _context1.abrupt("return", this.transformer.toSmartlinkAdf(url, preferredAppearance));
615
667
  case 39:
668
+ _context1.next = 44;
669
+ break;
670
+ case 41:
671
+ _context1.prev = 41;
672
+ _context1.t1 = _context1["catch"](0);
673
+ // eslint-disable-next-line
674
+ console.warn("Error when trying to check Smart Card url \"".concat(url, "\"").concat(_context1.t1 instanceof Error ? " - ".concat(_context1.t1.name, " ").concat(_context1.t1.message) : ''), _context1.t1);
675
+ case 44:
676
+ return _context1.abrupt("return", Promise.reject(undefined));
677
+ case 45:
616
678
  case "end":
617
- return _context0.stop();
679
+ return _context1.stop();
618
680
  }
619
- }, _callee0, this, [[0, 35]]);
681
+ }, _callee1, this, [[0, 41]]);
620
682
  }));
621
- function resolve(_x8, _x9, _x0, _x1) {
683
+ function resolve(_x9, _x0, _x1, _x10) {
622
684
  return _resolve.apply(this, arguments);
623
685
  }
624
686
  return resolve;
@@ -1,6 +1,7 @@
1
1
  import { type CardAdf, type CardAppearance, type DatasourceAdf, type ProductType } from '@atlaskit/linking-common';
2
2
  import { type CardProvider } from './types';
3
3
  import { type EnvironmentsKeys } from '@atlaskit/linking-common';
4
+ export declare const isJiraWorkItem: (url: string) => boolean;
4
5
  export declare class EditorCardProvider implements CardProvider {
5
6
  private baseUrl;
6
7
  private resolverUrl;
@@ -9,9 +10,12 @@ export declare class EditorCardProvider implements CardProvider {
9
10
  private transformer;
10
11
  private providersLoader;
11
12
  private cardClient;
12
- constructor(envKey?: EnvironmentsKeys, baseUrlOverride?: string, product?: ProductType);
13
+ private onResolve;
14
+ constructor(envKey?: EnvironmentsKeys, baseUrlOverride?: string, product?: ProductType, onResolve?: (url: string) => void);
13
15
  private batchProviders;
14
16
  private checkLinkResolved;
17
+ private fetchDataForResource;
18
+ private extractAriFromData;
15
19
  private fetchProvidersData;
16
20
  private loadProviderData;
17
21
  findPattern(url: string): Promise<boolean>;
@@ -37,6 +41,10 @@ export declare class EditorCardProvider implements CardProvider {
37
41
  * Make a /resolve call and find out if result has datasource capability
38
42
  */
39
43
  private getDatasourceFromResolveResponse;
44
+ /**
45
+ * This is used to determine if the url is a local Jira url or a remote one.
46
+ */
47
+ private isLocalUrl;
40
48
  resolve(url: string, appearance: CardAppearance, shouldForceAppearance?: boolean, isEmbedFriendlyLocation?: boolean): Promise<CardAdf | DatasourceAdf>;
41
49
  }
42
50
  export declare const editorCardProvider: EditorCardProvider;