@atlaskit/link-client-extension 0.4.3 → 1.0.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.
- package/CHANGELOG.md +20 -0
- package/dist/cjs/index.js +14 -1
- package/dist/cjs/services/use-data-source-client-extension/index.js +5 -2
- package/dist/cjs/services/use-data-source-client-extension/mocks.js +52 -18
- package/dist/cjs/services/use-smart-link-client-extension/index.js +31 -34
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/services/use-data-source-client-extension/index.js +8 -2
- package/dist/es2019/services/use-data-source-client-extension/mocks.js +52 -18
- package/dist/es2019/version.json +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/services/use-data-source-client-extension/index.js +5 -2
- package/dist/esm/services/use-data-source-client-extension/mocks.js +52 -18
- package/dist/esm/services/use-smart-link-client-extension/index.js +31 -34
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/services/use-data-source-client-extension/index.d.ts +1 -2
- package/package.json +4 -4
- package/report.api.md +8 -2
- package/tmp/api-report-tmp.d.ts +0 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/link-client-extension
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip minor dependency bump
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 0.5.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- [`5f0b51cb0e9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5f0b51cb0e9) - Updated `useDatasourceClientExtension` hook to use `useSmartLinkContext` for creating smart-card client
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 0.4.3
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "mockDatasourceDataResponse", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _mocks.mockDatasourceDataResponse;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "mockDatasourceResponse", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _mocks.mockDatasourceResponse;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
6
18
|
Object.defineProperty(exports, "useDatasourceClientExtension", {
|
|
7
19
|
enumerable: true,
|
|
8
20
|
get: function get() {
|
|
@@ -16,4 +28,5 @@ Object.defineProperty(exports, "useSmartLinkClientExtension", {
|
|
|
16
28
|
}
|
|
17
29
|
});
|
|
18
30
|
var _useSmartLinkClientExtension = require("./services/use-smart-link-client-extension");
|
|
19
|
-
var _useDataSourceClientExtension = require("./services/use-data-source-client-extension");
|
|
31
|
+
var _useDataSourceClientExtension = require("./services/use-data-source-client-extension");
|
|
32
|
+
var _mocks = require("./services/use-data-source-client-extension/mocks");
|
|
@@ -5,10 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useDatasourceClientExtension = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
var _linkProvider = require("@atlaskit/link-provider");
|
|
8
9
|
var _linkingCommon = require("@atlaskit/linking-common");
|
|
9
10
|
var _useResolverUrl = require("../use-resolver-url");
|
|
10
|
-
var useDatasourceClientExtension = function useDatasourceClientExtension(
|
|
11
|
-
var
|
|
11
|
+
var useDatasourceClientExtension = function useDatasourceClientExtension() {
|
|
12
|
+
var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
|
|
13
|
+
client = _useSmartLinkContext.connections.client;
|
|
14
|
+
var resolverUrl = (0, _useResolverUrl.useResolverUrl)(client);
|
|
12
15
|
var getDatasourceDetails = (0, _react.useCallback)(function (datasourceId, data) {
|
|
13
16
|
return (0, _linkingCommon.request)('post', "".concat(resolverUrl, "/datasource/").concat(datasourceId, "/fetch/details"), data, undefined, [200, 201, 202, 203, 204]);
|
|
14
17
|
}, [resolverUrl]);
|
|
@@ -12,7 +12,10 @@ var mockDatasourceDataResponse = {
|
|
|
12
12
|
assigned: {
|
|
13
13
|
displayName: 'Sasha'
|
|
14
14
|
},
|
|
15
|
-
|
|
15
|
+
status: {
|
|
16
|
+
text: 'In Progress',
|
|
17
|
+
status: 'inprogress'
|
|
18
|
+
}
|
|
16
19
|
}, {
|
|
17
20
|
id: 'EDM-14',
|
|
18
21
|
description: 'Implement datasource feature',
|
|
@@ -20,7 +23,10 @@ var mockDatasourceDataResponse = {
|
|
|
20
23
|
assigned: {
|
|
21
24
|
displayName: 'Hana'
|
|
22
25
|
},
|
|
23
|
-
|
|
26
|
+
status: {
|
|
27
|
+
text: 'To Do',
|
|
28
|
+
status: 'new'
|
|
29
|
+
}
|
|
24
30
|
}, {
|
|
25
31
|
id: 'EDM-15',
|
|
26
32
|
description: 'Add Jira Provider',
|
|
@@ -28,7 +34,10 @@ var mockDatasourceDataResponse = {
|
|
|
28
34
|
assigned: {
|
|
29
35
|
displayName: 'Princey'
|
|
30
36
|
},
|
|
31
|
-
|
|
37
|
+
status: {
|
|
38
|
+
text: 'To Do',
|
|
39
|
+
status: 'default'
|
|
40
|
+
}
|
|
32
41
|
}, {
|
|
33
42
|
id: 'EDM-16',
|
|
34
43
|
description: 'Plan team party',
|
|
@@ -36,7 +45,10 @@ var mockDatasourceDataResponse = {
|
|
|
36
45
|
assigned: {
|
|
37
46
|
displayName: 'Nidhin'
|
|
38
47
|
},
|
|
39
|
-
|
|
48
|
+
status: {
|
|
49
|
+
text: 'Done',
|
|
50
|
+
status: 'success'
|
|
51
|
+
}
|
|
40
52
|
}],
|
|
41
53
|
nextPageCursor: 'c3RhcnRBdD01'
|
|
42
54
|
};
|
|
@@ -58,26 +70,48 @@ var mockDatasourceResponse = {
|
|
|
58
70
|
schema: {
|
|
59
71
|
properties: [{
|
|
60
72
|
key: 'id',
|
|
73
|
+
title: '',
|
|
61
74
|
type: 'string',
|
|
62
|
-
|
|
75
|
+
isIdentity: true
|
|
63
76
|
}, {
|
|
64
|
-
key: '
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
key: 'issue',
|
|
78
|
+
title: 'Key',
|
|
79
|
+
type: 'link'
|
|
67
80
|
}, {
|
|
68
|
-
key: '
|
|
69
|
-
type: '
|
|
70
|
-
title: '
|
|
81
|
+
key: 'type',
|
|
82
|
+
type: 'icon',
|
|
83
|
+
title: 'Type'
|
|
71
84
|
}, {
|
|
72
|
-
key: '
|
|
73
|
-
|
|
74
|
-
|
|
85
|
+
key: 'summary',
|
|
86
|
+
title: 'Summary',
|
|
87
|
+
type: 'link'
|
|
75
88
|
}, {
|
|
76
|
-
key: '
|
|
77
|
-
|
|
78
|
-
|
|
89
|
+
key: 'assignee',
|
|
90
|
+
title: 'Assignee',
|
|
91
|
+
type: 'user'
|
|
92
|
+
}, {
|
|
93
|
+
key: 'priority',
|
|
94
|
+
title: 'P',
|
|
95
|
+
type: 'icon'
|
|
96
|
+
}, {
|
|
97
|
+
key: 'labels',
|
|
98
|
+
title: 'Labels',
|
|
99
|
+
type: 'tag',
|
|
100
|
+
isList: true
|
|
101
|
+
}, {
|
|
102
|
+
key: 'status',
|
|
103
|
+
title: 'Status',
|
|
104
|
+
type: 'status'
|
|
105
|
+
}, {
|
|
106
|
+
key: 'created',
|
|
107
|
+
title: 'Created',
|
|
108
|
+
type: 'string'
|
|
109
|
+
}, {
|
|
110
|
+
key: 'due',
|
|
111
|
+
title: 'Due Date',
|
|
112
|
+
type: 'string'
|
|
79
113
|
}],
|
|
80
|
-
defaultProperties: ['
|
|
114
|
+
defaultProperties: ['type', 'issue', 'summary', 'assignee', 'priority', 'labels', 'status', 'created']
|
|
81
115
|
}
|
|
82
116
|
};
|
|
83
117
|
exports.mockDatasourceResponse = mockDatasourceResponse;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.useSmartLinkClientExtension = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _linkingCommon = require("@atlaskit/linking-common");
|
|
12
12
|
var _smartLinkActions = require("@atlaskit/linking-types/smart-link-actions");
|
|
13
13
|
var _useResolverUrl = require("../use-resolver-url");
|
|
14
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
15
14
|
/**
|
|
16
15
|
* useSmartLinkClientExtension
|
|
17
16
|
*
|
|
@@ -23,39 +22,37 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
23
22
|
var useSmartLinkClientExtension = function useSmartLinkClientExtension(cardClient) {
|
|
24
23
|
var resolvedUrl = (0, _useResolverUrl.useResolverUrl)(cardClient);
|
|
25
24
|
var invoke = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
26
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
25
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(data) {
|
|
27
26
|
var errorBody;
|
|
28
|
-
return
|
|
29
|
-
while (1) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return _context.stop();
|
|
58
|
-
}
|
|
27
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
28
|
+
while (1) switch (_context.prev = _context.next) {
|
|
29
|
+
case 0:
|
|
30
|
+
_context.prev = 0;
|
|
31
|
+
_context.next = 3;
|
|
32
|
+
return (0, _linkingCommon.request)('post', "".concat(resolvedUrl, "/invoke"), data, undefined, [200, 201, 202, 203, 204]);
|
|
33
|
+
case 3:
|
|
34
|
+
return _context.abrupt("return", _context.sent);
|
|
35
|
+
case 6:
|
|
36
|
+
_context.prev = 6;
|
|
37
|
+
_context.t0 = _context["catch"](0);
|
|
38
|
+
if (!(_context.t0 && _context.t0.json && typeof _context.t0.json === 'function')) {
|
|
39
|
+
_context.next = 14;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
_context.next = 11;
|
|
43
|
+
return _context.t0.json();
|
|
44
|
+
case 11:
|
|
45
|
+
errorBody = _context.sent;
|
|
46
|
+
if (!errorBody) {
|
|
47
|
+
_context.next = 14;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
throw new _smartLinkActions.InvokeError(errorBody === null || errorBody === void 0 ? void 0 : errorBody.error.message, errorBody === null || errorBody === void 0 ? void 0 : errorBody.error.status);
|
|
51
|
+
case 14:
|
|
52
|
+
throw _context.t0;
|
|
53
|
+
case 15:
|
|
54
|
+
case "end":
|
|
55
|
+
return _context.stop();
|
|
59
56
|
}
|
|
60
57
|
}, _callee, null, [[0, 6]]);
|
|
61
58
|
}));
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { useSmartLinkClientExtension } from './services/use-smart-link-client-extension';
|
|
2
|
-
export { useDatasourceClientExtension } from './services/use-data-source-client-extension';
|
|
2
|
+
export { useDatasourceClientExtension } from './services/use-data-source-client-extension';
|
|
3
|
+
export { mockDatasourceResponse, mockDatasourceDataResponse } from './services/use-data-source-client-extension/mocks';
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
2
3
|
import { request } from '@atlaskit/linking-common';
|
|
3
4
|
import { useResolverUrl } from '../use-resolver-url';
|
|
4
|
-
export const useDatasourceClientExtension =
|
|
5
|
-
const
|
|
5
|
+
export const useDatasourceClientExtension = () => {
|
|
6
|
+
const {
|
|
7
|
+
connections: {
|
|
8
|
+
client
|
|
9
|
+
}
|
|
10
|
+
} = useSmartLinkContext();
|
|
11
|
+
const resolverUrl = useResolverUrl(client);
|
|
6
12
|
const getDatasourceDetails = useCallback((datasourceId, data) => request('post', `${resolverUrl}/datasource/${datasourceId}/fetch/details`, data, undefined, [200, 201, 202, 203, 204]), [resolverUrl]);
|
|
7
13
|
const getDatasourceData = useCallback((datasourceId, data) => request('post', `${resolverUrl}/datasource/${datasourceId}/fetch/data`, data, undefined, [200, 201, 202, 203, 204]), [resolverUrl]);
|
|
8
14
|
return useMemo(() => ({
|
|
@@ -6,7 +6,10 @@ export const mockDatasourceDataResponse = {
|
|
|
6
6
|
assigned: {
|
|
7
7
|
displayName: 'Sasha'
|
|
8
8
|
},
|
|
9
|
-
|
|
9
|
+
status: {
|
|
10
|
+
text: 'In Progress',
|
|
11
|
+
status: 'inprogress'
|
|
12
|
+
}
|
|
10
13
|
}, {
|
|
11
14
|
id: 'EDM-14',
|
|
12
15
|
description: 'Implement datasource feature',
|
|
@@ -14,7 +17,10 @@ export const mockDatasourceDataResponse = {
|
|
|
14
17
|
assigned: {
|
|
15
18
|
displayName: 'Hana'
|
|
16
19
|
},
|
|
17
|
-
|
|
20
|
+
status: {
|
|
21
|
+
text: 'To Do',
|
|
22
|
+
status: 'new'
|
|
23
|
+
}
|
|
18
24
|
}, {
|
|
19
25
|
id: 'EDM-15',
|
|
20
26
|
description: 'Add Jira Provider',
|
|
@@ -22,7 +28,10 @@ export const mockDatasourceDataResponse = {
|
|
|
22
28
|
assigned: {
|
|
23
29
|
displayName: 'Princey'
|
|
24
30
|
},
|
|
25
|
-
|
|
31
|
+
status: {
|
|
32
|
+
text: 'To Do',
|
|
33
|
+
status: 'default'
|
|
34
|
+
}
|
|
26
35
|
}, {
|
|
27
36
|
id: 'EDM-16',
|
|
28
37
|
description: 'Plan team party',
|
|
@@ -30,7 +39,10 @@ export const mockDatasourceDataResponse = {
|
|
|
30
39
|
assigned: {
|
|
31
40
|
displayName: 'Nidhin'
|
|
32
41
|
},
|
|
33
|
-
|
|
42
|
+
status: {
|
|
43
|
+
text: 'Done',
|
|
44
|
+
status: 'success'
|
|
45
|
+
}
|
|
34
46
|
}],
|
|
35
47
|
nextPageCursor: 'c3RhcnRBdD01'
|
|
36
48
|
};
|
|
@@ -51,25 +63,47 @@ export const mockDatasourceResponse = {
|
|
|
51
63
|
schema: {
|
|
52
64
|
properties: [{
|
|
53
65
|
key: 'id',
|
|
66
|
+
title: '',
|
|
54
67
|
type: 'string',
|
|
55
|
-
|
|
68
|
+
isIdentity: true
|
|
56
69
|
}, {
|
|
57
|
-
key: '
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
key: 'issue',
|
|
71
|
+
title: 'Key',
|
|
72
|
+
type: 'link'
|
|
60
73
|
}, {
|
|
61
|
-
key: '
|
|
62
|
-
type: '
|
|
63
|
-
title: '
|
|
74
|
+
key: 'type',
|
|
75
|
+
type: 'icon',
|
|
76
|
+
title: 'Type'
|
|
64
77
|
}, {
|
|
65
|
-
key: '
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
key: 'summary',
|
|
79
|
+
title: 'Summary',
|
|
80
|
+
type: 'link'
|
|
68
81
|
}, {
|
|
69
|
-
key: '
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
key: 'assignee',
|
|
83
|
+
title: 'Assignee',
|
|
84
|
+
type: 'user'
|
|
85
|
+
}, {
|
|
86
|
+
key: 'priority',
|
|
87
|
+
title: 'P',
|
|
88
|
+
type: 'icon'
|
|
89
|
+
}, {
|
|
90
|
+
key: 'labels',
|
|
91
|
+
title: 'Labels',
|
|
92
|
+
type: 'tag',
|
|
93
|
+
isList: true
|
|
94
|
+
}, {
|
|
95
|
+
key: 'status',
|
|
96
|
+
title: 'Status',
|
|
97
|
+
type: 'status'
|
|
98
|
+
}, {
|
|
99
|
+
key: 'created',
|
|
100
|
+
title: 'Created',
|
|
101
|
+
type: 'string'
|
|
102
|
+
}, {
|
|
103
|
+
key: 'due',
|
|
104
|
+
title: 'Due Date',
|
|
105
|
+
type: 'string'
|
|
72
106
|
}],
|
|
73
|
-
defaultProperties: ['
|
|
107
|
+
defaultProperties: ['type', 'issue', 'summary', 'assignee', 'priority', 'labels', 'status', 'created']
|
|
74
108
|
}
|
|
75
109
|
};
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { useSmartLinkClientExtension } from './services/use-smart-link-client-extension';
|
|
2
|
-
export { useDatasourceClientExtension } from './services/use-data-source-client-extension';
|
|
2
|
+
export { useDatasourceClientExtension } from './services/use-data-source-client-extension';
|
|
3
|
+
export { mockDatasourceResponse, mockDatasourceDataResponse } from './services/use-data-source-client-extension/mocks';
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { useSmartLinkContext } from '@atlaskit/link-provider';
|
|
2
3
|
import { request } from '@atlaskit/linking-common';
|
|
3
4
|
import { useResolverUrl } from '../use-resolver-url';
|
|
4
|
-
export var useDatasourceClientExtension = function useDatasourceClientExtension(
|
|
5
|
-
var
|
|
5
|
+
export var useDatasourceClientExtension = function useDatasourceClientExtension() {
|
|
6
|
+
var _useSmartLinkContext = useSmartLinkContext(),
|
|
7
|
+
client = _useSmartLinkContext.connections.client;
|
|
8
|
+
var resolverUrl = useResolverUrl(client);
|
|
6
9
|
var getDatasourceDetails = useCallback(function (datasourceId, data) {
|
|
7
10
|
return request('post', "".concat(resolverUrl, "/datasource/").concat(datasourceId, "/fetch/details"), data, undefined, [200, 201, 202, 203, 204]);
|
|
8
11
|
}, [resolverUrl]);
|
|
@@ -6,7 +6,10 @@ export var mockDatasourceDataResponse = {
|
|
|
6
6
|
assigned: {
|
|
7
7
|
displayName: 'Sasha'
|
|
8
8
|
},
|
|
9
|
-
|
|
9
|
+
status: {
|
|
10
|
+
text: 'In Progress',
|
|
11
|
+
status: 'inprogress'
|
|
12
|
+
}
|
|
10
13
|
}, {
|
|
11
14
|
id: 'EDM-14',
|
|
12
15
|
description: 'Implement datasource feature',
|
|
@@ -14,7 +17,10 @@ export var mockDatasourceDataResponse = {
|
|
|
14
17
|
assigned: {
|
|
15
18
|
displayName: 'Hana'
|
|
16
19
|
},
|
|
17
|
-
|
|
20
|
+
status: {
|
|
21
|
+
text: 'To Do',
|
|
22
|
+
status: 'new'
|
|
23
|
+
}
|
|
18
24
|
}, {
|
|
19
25
|
id: 'EDM-15',
|
|
20
26
|
description: 'Add Jira Provider',
|
|
@@ -22,7 +28,10 @@ export var mockDatasourceDataResponse = {
|
|
|
22
28
|
assigned: {
|
|
23
29
|
displayName: 'Princey'
|
|
24
30
|
},
|
|
25
|
-
|
|
31
|
+
status: {
|
|
32
|
+
text: 'To Do',
|
|
33
|
+
status: 'default'
|
|
34
|
+
}
|
|
26
35
|
}, {
|
|
27
36
|
id: 'EDM-16',
|
|
28
37
|
description: 'Plan team party',
|
|
@@ -30,7 +39,10 @@ export var mockDatasourceDataResponse = {
|
|
|
30
39
|
assigned: {
|
|
31
40
|
displayName: 'Nidhin'
|
|
32
41
|
},
|
|
33
|
-
|
|
42
|
+
status: {
|
|
43
|
+
text: 'Done',
|
|
44
|
+
status: 'success'
|
|
45
|
+
}
|
|
34
46
|
}],
|
|
35
47
|
nextPageCursor: 'c3RhcnRBdD01'
|
|
36
48
|
};
|
|
@@ -51,25 +63,47 @@ export var mockDatasourceResponse = {
|
|
|
51
63
|
schema: {
|
|
52
64
|
properties: [{
|
|
53
65
|
key: 'id',
|
|
66
|
+
title: '',
|
|
54
67
|
type: 'string',
|
|
55
|
-
|
|
68
|
+
isIdentity: true
|
|
56
69
|
}, {
|
|
57
|
-
key: '
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
key: 'issue',
|
|
71
|
+
title: 'Key',
|
|
72
|
+
type: 'link'
|
|
60
73
|
}, {
|
|
61
|
-
key: '
|
|
62
|
-
type: '
|
|
63
|
-
title: '
|
|
74
|
+
key: 'type',
|
|
75
|
+
type: 'icon',
|
|
76
|
+
title: 'Type'
|
|
64
77
|
}, {
|
|
65
|
-
key: '
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
key: 'summary',
|
|
79
|
+
title: 'Summary',
|
|
80
|
+
type: 'link'
|
|
68
81
|
}, {
|
|
69
|
-
key: '
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
key: 'assignee',
|
|
83
|
+
title: 'Assignee',
|
|
84
|
+
type: 'user'
|
|
85
|
+
}, {
|
|
86
|
+
key: 'priority',
|
|
87
|
+
title: 'P',
|
|
88
|
+
type: 'icon'
|
|
89
|
+
}, {
|
|
90
|
+
key: 'labels',
|
|
91
|
+
title: 'Labels',
|
|
92
|
+
type: 'tag',
|
|
93
|
+
isList: true
|
|
94
|
+
}, {
|
|
95
|
+
key: 'status',
|
|
96
|
+
title: 'Status',
|
|
97
|
+
type: 'status'
|
|
98
|
+
}, {
|
|
99
|
+
key: 'created',
|
|
100
|
+
title: 'Created',
|
|
101
|
+
type: 'string'
|
|
102
|
+
}, {
|
|
103
|
+
key: 'due',
|
|
104
|
+
title: 'Due Date',
|
|
105
|
+
type: 'string'
|
|
72
106
|
}],
|
|
73
|
-
defaultProperties: ['
|
|
107
|
+
defaultProperties: ['type', 'issue', 'summary', 'assignee', 'priority', 'labels', 'status', 'created']
|
|
74
108
|
}
|
|
75
109
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
3
|
import { useCallback, useMemo } from 'react';
|
|
5
4
|
import { request } from '@atlaskit/linking-common';
|
|
6
5
|
import { InvokeError } from '@atlaskit/linking-types/smart-link-actions';
|
|
@@ -17,39 +16,37 @@ import { useResolverUrl } from '../use-resolver-url';
|
|
|
17
16
|
export var useSmartLinkClientExtension = function useSmartLinkClientExtension(cardClient) {
|
|
18
17
|
var resolvedUrl = useResolverUrl(cardClient);
|
|
19
18
|
var invoke = useCallback( /*#__PURE__*/function () {
|
|
20
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime
|
|
19
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
|
|
21
20
|
var errorBody;
|
|
22
|
-
return _regeneratorRuntime
|
|
23
|
-
while (1) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return _context.stop();
|
|
52
|
-
}
|
|
21
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
22
|
+
while (1) switch (_context.prev = _context.next) {
|
|
23
|
+
case 0:
|
|
24
|
+
_context.prev = 0;
|
|
25
|
+
_context.next = 3;
|
|
26
|
+
return request('post', "".concat(resolvedUrl, "/invoke"), data, undefined, [200, 201, 202, 203, 204]);
|
|
27
|
+
case 3:
|
|
28
|
+
return _context.abrupt("return", _context.sent);
|
|
29
|
+
case 6:
|
|
30
|
+
_context.prev = 6;
|
|
31
|
+
_context.t0 = _context["catch"](0);
|
|
32
|
+
if (!(_context.t0 && _context.t0.json && typeof _context.t0.json === 'function')) {
|
|
33
|
+
_context.next = 14;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
_context.next = 11;
|
|
37
|
+
return _context.t0.json();
|
|
38
|
+
case 11:
|
|
39
|
+
errorBody = _context.sent;
|
|
40
|
+
if (!errorBody) {
|
|
41
|
+
_context.next = 14;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
throw new InvokeError(errorBody === null || errorBody === void 0 ? void 0 : errorBody.error.message, errorBody === null || errorBody === void 0 ? void 0 : errorBody.error.status);
|
|
45
|
+
case 14:
|
|
46
|
+
throw _context.t0;
|
|
47
|
+
case 15:
|
|
48
|
+
case "end":
|
|
49
|
+
return _context.stop();
|
|
53
50
|
}
|
|
54
51
|
}, _callee, null, [[0, 6]]);
|
|
55
52
|
}));
|
package/dist/esm/version.json
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { useSmartLinkClientExtension } from './services/use-smart-link-client-extension';
|
|
2
2
|
export { useDatasourceClientExtension } from './services/use-data-source-client-extension';
|
|
3
|
+
export { mockDatasourceResponse, mockDatasourceDataResponse, } from './services/use-data-source-client-extension/mocks';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { CardClient } from '@atlaskit/link-provider';
|
|
2
1
|
import type { DatasourceDataRequest, DatasourceDataResponse, DatasourceParameters, DatasourceResponse } from '@atlaskit/linking-types';
|
|
3
|
-
export declare const useDatasourceClientExtension: (
|
|
2
|
+
export declare const useDatasourceClientExtension: () => {
|
|
4
3
|
getDatasourceDetails: (datasourceId: string, data: DatasourceParameters) => Promise<DatasourceResponse>;
|
|
5
4
|
getDatasourceData: (datasourceId: string, data: DatasourceDataRequest) => Promise<DatasourceDataResponse>;
|
|
6
5
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-client-extension",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Extension methods for linking platform client",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
".": "./src/index.ts"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@atlaskit/linking-common": "^2.
|
|
30
|
-
"@atlaskit/linking-types": "^1.
|
|
29
|
+
"@atlaskit/linking-common": "^2.8.0",
|
|
30
|
+
"@atlaskit/linking-types": "^1.4.0",
|
|
31
31
|
"@babel/runtime": "^7.0.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@atlaskit/link-provider": "^1.
|
|
34
|
+
"@atlaskit/link-provider": "^1.6.0",
|
|
35
35
|
"react": "^16.8.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
package/report.api.md
CHANGED
|
@@ -24,7 +24,13 @@ import { InvokeRequest } from '@atlaskit/linking-types/smart-link-actions';
|
|
|
24
24
|
import { InvokeResponse } from '@atlaskit/linking-types/smart-link-actions';
|
|
25
25
|
|
|
26
26
|
// @public (undocumented)
|
|
27
|
-
export const
|
|
27
|
+
export const mockDatasourceDataResponse: DatasourceDataResponse;
|
|
28
|
+
|
|
29
|
+
// @public (undocumented)
|
|
30
|
+
export const mockDatasourceResponse: DatasourceResponse;
|
|
31
|
+
|
|
32
|
+
// @public (undocumented)
|
|
33
|
+
export const useDatasourceClientExtension: () => {
|
|
28
34
|
getDatasourceDetails: (
|
|
29
35
|
datasourceId: string,
|
|
30
36
|
data: DatasourceParameters,
|
|
@@ -51,7 +57,7 @@ export const useSmartLinkClientExtension: (cardClient: CardClient) => {
|
|
|
51
57
|
|
|
52
58
|
```json
|
|
53
59
|
{
|
|
54
|
-
"@atlaskit/link-provider": "^1.
|
|
60
|
+
"@atlaskit/link-provider": "^1.6.0",
|
|
55
61
|
"react": "^16.8.0"
|
|
56
62
|
}
|
|
57
63
|
```
|
package/tmp/api-report-tmp.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
## API Report File for "@atlaskit/link-client-extension"
|
|
2
|
-
|
|
3
|
-
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
|
|
7
|
-
import type { CardClient } from '@atlaskit/link-provider';
|
|
8
|
-
import type { DatasourceDataRequest } from '@atlaskit/linking-types';
|
|
9
|
-
import type { DatasourceDataResponse } from '@atlaskit/linking-types';
|
|
10
|
-
import type { DatasourceParameters } from '@atlaskit/linking-types';
|
|
11
|
-
import type { DatasourceResponse } from '@atlaskit/linking-types';
|
|
12
|
-
import { InvokeRequest } from '@atlaskit/linking-types/smart-link-actions';
|
|
13
|
-
import { InvokeResponse } from '@atlaskit/linking-types/smart-link-actions';
|
|
14
|
-
|
|
15
|
-
// @public (undocumented)
|
|
16
|
-
export const useDatasourceClientExtension: (cardClient: CardClient) => {
|
|
17
|
-
getDatasourceDetails: (datasourceId: string, data: DatasourceParameters) => Promise<DatasourceResponse>;
|
|
18
|
-
getDatasourceData: (datasourceId: string, data: DatasourceDataRequest) => Promise<DatasourceDataResponse>;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// @public
|
|
22
|
-
export const useSmartLinkClientExtension: (cardClient: CardClient) => {
|
|
23
|
-
invoke: (data: InvokeRequest) => Promise<InvokeResponse>;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// (No @packageDocumentation comment for this package)
|
|
27
|
-
|
|
28
|
-
```
|