chayns-api 1.0.0 → 1.0.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/dist/cjs/bootstrap.js +11 -0
- package/dist/cjs/calls/abstractApiListener.js +40 -0
- package/dist/cjs/calls/apiEventListener.js +40 -0
- package/dist/cjs/calls/dialogs/alert.js +2 -0
- package/dist/cjs/calls/dialogs/chaynsDialog.js +8 -2
- package/dist/cjs/calls/dialogs/close.js +2 -0
- package/dist/cjs/calls/dialogs/communication.js +16 -1
- package/dist/cjs/calls/dialogs/confirm.js +4 -0
- package/dist/cjs/calls/dialogs/date.js +53 -36
- package/dist/cjs/calls/dialogs/dropUpAlert.js +3 -0
- package/dist/cjs/calls/dialogs/fileSelect.js +10 -0
- package/dist/cjs/calls/dialogs/iFrame.js +8 -0
- package/dist/cjs/calls/dialogs/index.js +27 -0
- package/dist/cjs/calls/dialogs/input.js +6 -0
- package/dist/cjs/calls/dialogs/mediaSelect.js +7 -0
- package/dist/cjs/calls/dialogs/open.js +2 -0
- package/dist/cjs/calls/dialogs/select.js +9 -0
- package/dist/cjs/calls/dialogs/signature.js +5 -0
- package/dist/cjs/calls/dialogs/toast.js +3 -0
- package/dist/cjs/calls/dialogs/utils/callback.js +2 -0
- package/dist/cjs/calls/dialogs/utils/is.js +4 -0
- package/dist/cjs/calls/getUserInfo.js +11 -0
- package/dist/cjs/calls/index.js +155 -3
- package/dist/cjs/calls/sendMessage.js +26 -0
- package/dist/cjs/calls/setVisibilityChangeListener.js +1 -0
- package/dist/cjs/calls/visibilityChangeListener.js +12 -1
- package/dist/cjs/calls/windowMetricsListener.js +18 -0
- package/dist/cjs/components/App.js +32 -0
- package/dist/cjs/components/App.spec.js +16 -0
- package/dist/cjs/components/Button.js +32 -0
- package/dist/cjs/components/ChaynsContext.js +4 -2
- package/dist/cjs/components/ChaynsProvider.js +28 -6
- package/dist/cjs/components/ChaynsProviderExposed.js +16 -0
- package/dist/cjs/components/TestProvider.js +236 -0
- package/dist/cjs/components/Title.js +162 -0
- package/dist/cjs/components/WaitUntil.js +5 -0
- package/dist/cjs/components/withCompatMode.js +16 -1
- package/dist/cjs/functions/addApiListener.js +37 -0
- package/dist/cjs/functions/addGeoLocationListener.js +26 -0
- package/dist/cjs/functions/addScrollListener.js +26 -0
- package/dist/cjs/functions/addWindowMetricsListener.js +37 -0
- package/dist/cjs/helper/apiListenerHelper.js +9 -0
- package/dist/cjs/helper/cssLoader.js +28 -0
- package/dist/cjs/hooks/addGeoLocationListener.js +26 -0
- package/dist/cjs/hooks/addScrollListener.js +26 -0
- package/dist/cjs/hooks/addWindowMetricsListener.js +37 -0
- package/dist/cjs/hooks/geoLocation.js +48 -0
- package/dist/cjs/hooks/geoLocationListener.js +11 -2
- package/dist/cjs/hooks/index.js +16 -0
- package/dist/cjs/hooks/scrollListener.js +23 -4
- package/dist/cjs/hooks/useAccessToken.js +5 -0
- package/dist/cjs/hooks/useAddGeoLocationListener.js +26 -0
- package/dist/cjs/hooks/useAddScrollListener.js +48 -0
- package/dist/cjs/hooks/useAddWindowMetricsListener.js +45 -0
- package/dist/cjs/hooks/useAdddScrollListener.js +26 -0
- package/dist/cjs/hooks/useCurrentPage.js +4 -0
- package/dist/cjs/hooks/useCustomData.js +4 -0
- package/dist/cjs/hooks/useDevice.js +4 -0
- package/dist/cjs/hooks/useEnvironment.js +4 -0
- package/dist/cjs/hooks/useFunctions.js +4 -0
- package/dist/cjs/hooks/useIsAdminMode.js +5 -0
- package/dist/cjs/hooks/useLanguage.js +4 -0
- package/dist/cjs/hooks/usePages.js +12 -0
- package/dist/cjs/hooks/useParameters.js +4 -0
- package/dist/cjs/hooks/useSite.js +4 -0
- package/dist/cjs/hooks/useUser.js +4 -0
- package/dist/cjs/hooks/useValues.js +4 -0
- package/dist/cjs/hooks/windowMetrics.js +45 -0
- package/dist/cjs/hooks/windowMetricsListener.js +12 -2
- package/dist/cjs/host/ChaynsHost.js +12 -0
- package/dist/cjs/host/{module/PagemakerFrame.js → HostIframe.js} +75 -23
- package/dist/cjs/host/ModuleHost.js +11 -0
- package/dist/cjs/host/iframe/HostIframe.js +30 -23
- package/dist/cjs/host/iframe/utils/useUpdateData.js +3 -0
- package/dist/cjs/host/module/ModuleHost.js +13 -3
- package/dist/cjs/host/module/utils/loadComponent.js +18 -1
- package/dist/cjs/host/module/utils/useDynamicScript.js +18 -0
- package/dist/cjs/host/module/utils.js +25 -0
- package/dist/cjs/index.example.js +7 -0
- package/dist/cjs/index.js +19 -0
- package/dist/cjs/index2.js +64 -0
- package/dist/cjs/types/DynamicImport.d.js +5 -0
- package/dist/cjs/types/IChaynsReact.js +47 -0
- package/dist/cjs/types/chayns-components.d.js +1 -0
- package/dist/cjs/types/chayns-logger.d.js +1 -0
- package/dist/cjs/types/chayns.d.js +1 -0
- package/dist/cjs/types/tobit-websocket-service-client.d.js +1 -0
- package/dist/cjs/types/toolkit-types.d.js +1 -0
- package/dist/cjs/util/appCall.js +4 -1
- package/dist/cjs/util/deviceHelper.js +17 -2
- package/dist/cjs/util/heightHelper.js +9 -0
- package/dist/cjs/util/postIframeForm.js +5 -0
- package/dist/cjs/util/useFunctionsContext.js +16 -0
- package/dist/cjs/util/useIsAdminMode.js +18 -0
- package/dist/cjs/util/useUser.js +16 -0
- package/dist/cjs/wrapper/AppWrapper.js +144 -119
- package/dist/cjs/wrapper/FrameWrapper.js +248 -215
- package/dist/cjs/wrapper/ModuleFederationWrapper.js +27 -2
- package/dist/cjs/wrapper/SsrWrapper.js +8 -0
- package/dist/esm/bootstrap.js +4 -0
- package/dist/esm/calls/dialogs/alert.js +4 -4
- package/dist/esm/calls/dialogs/chaynsDialog.js +11 -7
- package/dist/esm/calls/dialogs/communication.js +26 -15
- package/dist/esm/calls/dialogs/confirm.js +8 -5
- package/dist/esm/calls/dialogs/date.js +94 -85
- package/dist/esm/calls/dialogs/dropUpAlert.js +1 -1
- package/dist/esm/calls/dialogs/fileSelect.js +62 -23
- package/dist/esm/calls/dialogs/iFrame.js +10 -7
- package/dist/esm/calls/dialogs/input.js +5 -2
- package/dist/esm/calls/dialogs/mediaSelect.js +55 -18
- package/dist/esm/calls/dialogs/open.js +2 -2
- package/dist/esm/calls/dialogs/select.js +9 -5
- package/dist/esm/calls/dialogs/signature.js +2 -0
- package/dist/esm/calls/dialogs/toast.js +11 -6
- package/dist/esm/calls/dialogs/utils/callback.js +5 -3
- package/dist/esm/calls/dialogs/utils/is.js +3 -1
- package/dist/esm/calls/getUserInfo.js +92 -32
- package/dist/esm/calls/index.js +276 -124
- package/dist/esm/calls/sendMessage.js +221 -91
- package/dist/esm/calls/visibilityChangeListener.js +15 -10
- package/dist/esm/components/App.js +35 -0
- package/dist/esm/components/App.spec.js +9 -0
- package/dist/esm/components/Button.js +34 -0
- package/dist/esm/components/ChaynsContext.js +3 -3
- package/dist/esm/components/ChaynsProvider.js +86 -45
- package/dist/esm/components/ChaynsProviderExposed.js +3 -0
- package/dist/esm/components/TestProvider.js +308 -0
- package/dist/esm/components/Title.js +210 -0
- package/dist/esm/components/WaitUntil.js +86 -21
- package/dist/esm/components/withCompatMode.js +77 -35
- package/dist/esm/helper/apiListenerHelper.js +15 -10
- package/dist/esm/helper/cssLoader.js +21 -0
- package/dist/esm/hooks/geoLocationListener.js +46 -20
- package/dist/esm/hooks/scrollListener.js +86 -50
- package/dist/esm/hooks/useAccessToken.js +28 -6
- package/dist/esm/hooks/useAddGeoLocationListener.js +18 -0
- package/dist/esm/hooks/useAddScrollListener.js +18 -0
- package/dist/esm/hooks/useAddWindowMetricsListener.js +18 -0
- package/dist/esm/hooks/useCurrentPage.js +6 -2
- package/dist/esm/hooks/useCustomData.js +6 -2
- package/dist/esm/hooks/useDevice.js +6 -1
- package/dist/esm/hooks/useEnvironment.js +6 -1
- package/dist/esm/hooks/useFunctions.js +5 -2
- package/dist/esm/hooks/useIsAdminMode.js +6 -2
- package/dist/esm/hooks/useLanguage.js +6 -1
- package/dist/esm/hooks/usePages.js +27 -14
- package/dist/esm/hooks/useParameters.js +6 -1
- package/dist/esm/hooks/useSite.js +6 -1
- package/dist/esm/hooks/useUser.js +6 -1
- package/dist/esm/hooks/useValues.js +5 -2
- package/dist/esm/hooks/windowMetricsListener.js +44 -18
- package/dist/esm/host/ChaynsHost.js +30 -21
- package/dist/esm/host/HostIframe.js +153 -0
- package/dist/esm/host/iframe/HostIframe.js +142 -86
- package/dist/esm/host/iframe/utils/useUpdateData.js +6 -4
- package/dist/esm/host/module/ModuleHost.js +49 -42
- package/dist/esm/host/module/utils/loadComponent.js +85 -47
- package/dist/esm/host/module/utils/useDynamicScript.js +74 -27
- package/dist/esm/index.example.js +1 -0
- package/dist/esm/index2.js +5 -0
- package/dist/esm/types/DynamicImport.d.js +1 -0
- package/dist/esm/types/IChaynsReact.js +61 -14
- package/dist/esm/types/chayns-components.d.js +0 -0
- package/dist/esm/types/chayns-logger.d.js +0 -0
- package/dist/esm/types/chayns.d.js +0 -0
- package/dist/esm/types/tobit-websocket-service-client.d.js +0 -0
- package/dist/esm/types/toolkit-types.d.js +0 -0
- package/dist/esm/util/appCall.js +4 -2
- package/dist/esm/util/deviceHelper.js +33 -11
- package/dist/esm/util/heightHelper.js +13 -10
- package/dist/esm/util/postIframeForm.js +57 -25
- package/dist/esm/util/useIsAdminMode.js +9 -0
- package/dist/esm/util/useUser.js +7 -0
- package/dist/esm/wrapper/AppWrapper.js +762 -179
- package/dist/esm/wrapper/FrameWrapper.js +1509 -258
- package/dist/esm/wrapper/ModuleFederationWrapper.js +284 -47
- package/dist/esm/wrapper/SsrWrapper.js +65 -19
- package/dist/types/bootstrap.d.ts +1 -0
- package/dist/types/calls/dialogs/confirm.d.ts +1 -1
- package/dist/types/calls/dialogs/date.d.ts +4 -4
- package/dist/types/calls/dialogs/dropUpAlert.d.ts +1 -1
- package/dist/types/calls/dialogs/fileSelect.d.ts +1 -1
- package/dist/types/calls/dialogs/iFrame.d.ts +1 -1
- package/dist/types/calls/dialogs/input.d.ts +1 -1
- package/dist/types/calls/dialogs/mediaSelect.d.ts +1 -1
- package/dist/types/calls/dialogs/signature.d.ts +1 -1
- package/dist/types/components/App.d.ts +5 -0
- package/dist/types/components/Button.d.ts +8 -0
- package/dist/types/components/ChaynsProvider.d.ts +1 -1
- package/dist/types/components/ChaynsProviderExposed.d.ts +13 -0
- package/dist/types/components/Title.d.ts +3 -0
- package/dist/types/components/WaitUntil.d.ts +1 -1
- package/dist/types/components/withCompatMode.d.ts +1 -1
- package/dist/types/hooks/useAccessToken.d.ts +1 -1
- package/dist/types/host/ChaynsHost.d.ts +2 -1
- package/dist/types/host/{module/PagemakerFrame.d.ts → HostIframe.d.ts} +5 -7
- package/dist/types/host/iframe/HostIframe.d.ts +1 -1
- package/dist/types/host/module/ModuleHost.d.ts +2 -2
- package/dist/types/index.example.d.ts +0 -0
- package/dist/types/types/IChaynsReact.d.ts +14 -14
- package/package.json +1 -1
- package/dist/cjs/calls/dialogs/utils/environment.js +0 -10
- package/dist/esm/calls/dialogs/utils/environment.js +0 -3
- package/dist/esm/host/module/PagemakerFrame.js +0 -97
- package/dist/types/calls/dialogs/utils/environment.d.ts +0 -3
|
@@ -1,22 +1,59 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
+
|
|
3
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
+
|
|
1
5
|
import { buttonText, buttonType, dialogAction } from './chaynsDialog';
|
|
2
6
|
import { open } from './open';
|
|
3
7
|
import { getAccessToken, getUser, login } from "../index";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
export function mediaSelect() {
|
|
9
|
+
return _mediaSelect.apply(this, arguments);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function _mediaSelect() {
|
|
13
|
+
_mediaSelect = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
14
|
+
var dialog,
|
|
15
|
+
user,
|
|
16
|
+
_args = arguments;
|
|
17
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18
|
+
while (1) {
|
|
19
|
+
switch (_context.prev = _context.next) {
|
|
20
|
+
case 0:
|
|
21
|
+
dialog = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
22
|
+
|
|
23
|
+
if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
|
|
24
|
+
dialog.buttons = [{
|
|
25
|
+
'text': buttonText.OK,
|
|
26
|
+
'buttonType': buttonType.POSITIVE
|
|
27
|
+
}, {
|
|
28
|
+
'text': buttonText.CANCEL,
|
|
29
|
+
'buttonType': buttonType.NEGATIVE
|
|
30
|
+
}];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
dialog.callType = dialogAction.MEDIA_SELECT;
|
|
34
|
+
user = getUser();
|
|
35
|
+
|
|
36
|
+
if (user) {
|
|
37
|
+
_context.next = 6;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return _context.abrupt("return", login());
|
|
42
|
+
|
|
43
|
+
case 6:
|
|
44
|
+
_context.next = 8;
|
|
45
|
+
return getAccessToken();
|
|
46
|
+
|
|
47
|
+
case 8:
|
|
48
|
+
dialog.chaynsToken = _context.sent.accessToken;
|
|
49
|
+
return _context.abrupt("return", open(dialog));
|
|
50
|
+
|
|
51
|
+
case 10:
|
|
52
|
+
case "end":
|
|
53
|
+
return _context.stop();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, _callee);
|
|
57
|
+
}));
|
|
58
|
+
return _mediaSelect.apply(this, arguments);
|
|
22
59
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { invokeDialogCall } from "../index";
|
|
2
2
|
export function open(json) {
|
|
3
|
-
return new Promise((resolve, reject)
|
|
3
|
+
return new Promise(function (resolve, reject) {
|
|
4
4
|
invokeDialogCall({
|
|
5
5
|
action: 184,
|
|
6
6
|
value: {
|
|
7
7
|
'dialogContent': json
|
|
8
8
|
}
|
|
9
|
-
}, e
|
|
9
|
+
}, function (e) {
|
|
10
10
|
resolve(e);
|
|
11
11
|
});
|
|
12
12
|
});
|
|
@@ -2,9 +2,10 @@ import { buttonText, buttonType, dialogAction } from './chaynsDialog';
|
|
|
2
2
|
import { open } from './open';
|
|
3
3
|
import { isPresent } from "./utils/is";
|
|
4
4
|
export function select(config) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
var list = [];
|
|
6
|
+
|
|
7
|
+
for (var i = 0, l = config.list.length; i < l; i++) {
|
|
8
|
+
var item = config.list[i];
|
|
8
9
|
list.push({
|
|
9
10
|
name: item.name,
|
|
10
11
|
'value': isPresent(item.value) ? item.value : item.name,
|
|
@@ -15,9 +16,11 @@ export function select(config) {
|
|
|
15
16
|
'url': item.url
|
|
16
17
|
});
|
|
17
18
|
}
|
|
19
|
+
|
|
18
20
|
if (config.list.length === 0) {
|
|
19
21
|
return Promise.reject(new Error('Invalid Parameters'));
|
|
20
22
|
}
|
|
23
|
+
|
|
21
24
|
if (!config.buttons || !Array.isArray(config.buttons)) {
|
|
22
25
|
config.buttons = [{
|
|
23
26
|
'text': buttonText.OK,
|
|
@@ -27,6 +30,7 @@ export function select(config) {
|
|
|
27
30
|
'buttonType': buttonType.CANCEL
|
|
28
31
|
}];
|
|
29
32
|
}
|
|
33
|
+
|
|
30
34
|
return open({
|
|
31
35
|
'callType': dialogAction.SELECT,
|
|
32
36
|
'title': config.title || '',
|
|
@@ -38,10 +42,10 @@ export function select(config) {
|
|
|
38
42
|
'type': config.type,
|
|
39
43
|
'preventCloseOnClick': !!config.preventCloseOnClick,
|
|
40
44
|
'selectAllButton': config.selectAllButton,
|
|
41
|
-
list
|
|
45
|
+
list: list
|
|
42
46
|
});
|
|
43
47
|
}
|
|
44
|
-
export
|
|
48
|
+
export var selectType = {
|
|
45
49
|
'DEFAULT': 0,
|
|
46
50
|
'ICON': 1
|
|
47
51
|
};
|
|
@@ -2,6 +2,7 @@ import { buttonText, buttonType, dialogAction } from './chaynsDialog';
|
|
|
2
2
|
import { open } from './open';
|
|
3
3
|
export function signature(dialog) {
|
|
4
4
|
if (!dialog) dialog = {};
|
|
5
|
+
|
|
5
6
|
if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
|
|
6
7
|
dialog.buttons = [];
|
|
7
8
|
dialog.buttons.push({
|
|
@@ -13,6 +14,7 @@ export function signature(dialog) {
|
|
|
13
14
|
'buttonType': buttonType.NEGATIVE
|
|
14
15
|
});
|
|
15
16
|
}
|
|
17
|
+
|
|
16
18
|
dialog.callType = dialogAction.SIGNATURE;
|
|
17
19
|
return open(dialog);
|
|
18
20
|
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
1
7
|
import { getCallbackName } from "./utils/callback";
|
|
2
8
|
import { invokeDialogCall } from "../index";
|
|
3
9
|
export function toast() {
|
|
4
|
-
|
|
5
|
-
|
|
10
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11
|
+
var callbackName = 'toastCallback';
|
|
6
12
|
return invokeDialogCall({
|
|
7
13
|
action: 276,
|
|
8
|
-
value: {
|
|
9
|
-
'callback': getCallbackName(callbackName)
|
|
10
|
-
|
|
11
|
-
}
|
|
14
|
+
value: _objectSpread({
|
|
15
|
+
'callback': getCallbackName(callbackName)
|
|
16
|
+
}, config)
|
|
12
17
|
});
|
|
13
18
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export function getCallbackName(fnName) {
|
|
2
|
-
|
|
2
|
+
var framePrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
3
|
+
|
|
3
4
|
if (framePrefix !== '') {
|
|
4
|
-
return
|
|
5
|
+
return "window._chaynsCallbacks.".concat(framePrefix, ".").concat(fnName);
|
|
5
6
|
}
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
return "window._chaynsCallbacks.".concat(fnName);
|
|
7
9
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
|
+
|
|
1
3
|
export function isObject(value) {
|
|
2
|
-
return value !== null &&
|
|
4
|
+
return value !== null && _typeof(value) === 'object';
|
|
3
5
|
}
|
|
4
6
|
export function isNumber(value) {
|
|
5
7
|
return typeof value === 'number' && !isNaN(value);
|
|
@@ -1,33 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
+
|
|
3
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
+
|
|
5
|
+
var getUserInfo = /*#__PURE__*/function () {
|
|
6
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(api, value) {
|
|
7
|
+
var _value$personId;
|
|
8
|
+
|
|
9
|
+
var query, _yield$api$functions$, accessToken, res, data;
|
|
10
|
+
|
|
11
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
12
|
+
while (1) {
|
|
13
|
+
switch (_context.prev = _context.next) {
|
|
14
|
+
case 0:
|
|
15
|
+
query = (_value$personId = value.personId) !== null && _value$personId !== void 0 ? _value$personId : value.userId;
|
|
16
|
+
|
|
17
|
+
if (query) {
|
|
18
|
+
_context.next = 3;
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
throw new Error('Invalid Parameters - You have to provide at least one of these Parameters: userId, personId');
|
|
23
|
+
|
|
24
|
+
case 3:
|
|
25
|
+
_context.next = 5;
|
|
26
|
+
return api.functions.getAccessToken();
|
|
27
|
+
|
|
28
|
+
case 5:
|
|
29
|
+
_yield$api$functions$ = _context.sent;
|
|
30
|
+
accessToken = _yield$api$functions$.accessToken;
|
|
31
|
+
|
|
32
|
+
if (accessToken) {
|
|
33
|
+
_context.next = 9;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
throw new Error('get user info requires a user to be logged in');
|
|
38
|
+
|
|
39
|
+
case 9:
|
|
40
|
+
_context.next = 11;
|
|
41
|
+
return fetch("https://relations.chayns.net/relations/user/findUser?searchString=".concat(query), {
|
|
42
|
+
'headers': {
|
|
43
|
+
'authorization': "bearer ".concat(accessToken)
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
case 11:
|
|
48
|
+
res = _context.sent;
|
|
49
|
+
|
|
50
|
+
if (!res.ok) {
|
|
51
|
+
_context.next = 19;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
_context.next = 15;
|
|
56
|
+
return res.json();
|
|
57
|
+
|
|
58
|
+
case 15:
|
|
59
|
+
data = _context.sent;
|
|
60
|
+
|
|
61
|
+
if (!(data.length === 0)) {
|
|
62
|
+
_context.next = 18;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return _context.abrupt("return", null);
|
|
67
|
+
|
|
68
|
+
case 18:
|
|
69
|
+
return _context.abrupt("return", {
|
|
70
|
+
firstName: data[0].firstName,
|
|
71
|
+
lastName: data[0].lastName,
|
|
72
|
+
userId: data[0].userId,
|
|
73
|
+
personId: data[0].personId,
|
|
74
|
+
name: data[0].name
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
case 19:
|
|
78
|
+
throw new Error("getUserInfo failed with status ".concat(res.status));
|
|
79
|
+
|
|
80
|
+
case 20:
|
|
81
|
+
case "end":
|
|
82
|
+
return _context.stop();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, _callee);
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
return function getUserInfo(_x, _x2) {
|
|
89
|
+
return _ref.apply(this, arguments);
|
|
90
|
+
};
|
|
91
|
+
}();
|
|
92
|
+
|
|
33
93
|
export default getUserInfo;
|