studiokit-scaffolding-js 5.2.0-next.2.1 → 5.2.0-next.2.3
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/lib/components/HOC/ModelErrorRedirectComponent.js +2 -2
- package/lib/components/UserRoles/index.js +4 -4
- package/lib/redux/actionCreator.js +4 -4
- package/lib/redux/actions/AuthAction.d.ts +1 -1
- package/lib/redux/actions/AuthAction.js +1 -1
- package/lib/redux/actions/ModelAction.d.ts +15 -15
- package/lib/redux/actions/ModelAction.js +36 -36
- package/lib/redux/configureStore.js +13 -10
- package/lib/redux/reducers/modelsReducer.js +4 -4
- package/lib/redux/sagas/authSaga.js +15 -14
- package/lib/redux/sagas/downtimeApiErrorSaga.js +1 -1
- package/lib/redux/sagas/identityProviderSaga.js +9 -9
- package/lib/redux/sagas/lockDownBrowserErrorSaga.js +1 -1
- package/lib/redux/sagas/modelFetchSaga.d.ts +3 -4
- package/lib/redux/sagas/modelFetchSaga.js +108 -88
- package/lib/redux/sagas/noStoreSaga.js +3 -3
- package/lib/redux/sagas/rootSaga.js +4 -2
- package/lib/services/fetchService.d.ts +21 -17
- package/lib/services/fetchService.js +78 -64
- package/lib/services/windowService.d.ts +2 -0
- package/lib/services/windowService.js +6 -1
- package/lib/startup.js +1 -1
- package/lib/types/net/ErrorHandler.d.ts +2 -1
- package/lib/types/net/FetchErrorData.d.ts +6 -3
- package/lib/types/net/FetchErrorData.js +8 -8
- package/lib/types/net/TokenAccessFunction.d.ts +1 -1
- package/lib/utils/error.d.ts +1 -0
- package/lib/utils/error.js +20 -0
- package/lib/utils/prepareFetch.js +182 -0
- package/lib/utils/user.js +2 -2
- package/package.json +1 -1
- package/lib/utils/modelFetch.js +0 -175
- /package/lib/utils/{modelFetch.d.ts → prepareFetch.d.ts} +0 -0
|
@@ -71,13 +71,13 @@ function modelErrorRedirectComponent(WrappedComponent) {
|
|
|
71
71
|
model._metadata &&
|
|
72
72
|
model._metadata.hasError &&
|
|
73
73
|
model._metadata.lastFetchErrorData &&
|
|
74
|
-
model._metadata.lastFetchErrorData.
|
|
74
|
+
model._metadata.lastFetchErrorData.status === 404;
|
|
75
75
|
var errorRoute = previousModelStatus === modelStatus_1.MODEL_STATUS.UNINITIALIZED &&
|
|
76
76
|
modelStatus === modelStatus_1.MODEL_STATUS.ERROR &&
|
|
77
77
|
model._metadata &&
|
|
78
78
|
model._metadata.hasError &&
|
|
79
79
|
model._metadata.lastFetchErrorData &&
|
|
80
|
-
model._metadata.lastFetchErrorData.
|
|
80
|
+
model._metadata.lastFetchErrorData.status === 500;
|
|
81
81
|
if (notFoundRoute) {
|
|
82
82
|
var pathname = window.location.pathname;
|
|
83
83
|
return (react_1.default.createElement(react_router_dom_1.Redirect, { to: {
|
|
@@ -53,7 +53,7 @@ var baseActivity_1 = require("../../utils/baseActivity");
|
|
|
53
53
|
var baseRole_2 = require("../../utils/baseRole");
|
|
54
54
|
var domainIdentifier_1 = require("../../utils/domainIdentifier");
|
|
55
55
|
var entityUserRole_1 = require("../../utils/entityUserRole");
|
|
56
|
-
var
|
|
56
|
+
var prepareFetch_1 = require("../../utils/prepareFetch");
|
|
57
57
|
var sort_1 = require("../../utils/sort");
|
|
58
58
|
var user_1 = require("../../utils/user");
|
|
59
59
|
var userRole_1 = require("../../utils/userRole");
|
|
@@ -210,13 +210,13 @@ var UserRoles = /** @class */ (function (_super) {
|
|
|
210
210
|
var updatedModel_1 = lodash_1.cloneDeep(model);
|
|
211
211
|
addedUserRoles.forEach(function (userRole) { return (updatedModel_1[userRole.id] = lodash_1.cloneDeep(userRole)); });
|
|
212
212
|
// create a dummy action and call `prepareFetch` to get the final `modelPath`
|
|
213
|
-
var modelPath =
|
|
214
|
-
type: actions_1.
|
|
213
|
+
var modelPath = prepareFetch_1.prepareFetch({
|
|
214
|
+
type: actions_1.MODEL_FETCH_REQUEST_ACTION_TYPE.FETCH_REQUEST,
|
|
215
215
|
modelName: modelName,
|
|
216
216
|
pathParams: pathParams
|
|
217
217
|
}, constants_1.getEndpointMappings()).modelPath;
|
|
218
218
|
actionCreator_1.dispatchAction({
|
|
219
|
-
type: actions_1.
|
|
219
|
+
type: actions_1.MODEL_FETCH_RESULT_ACTION_TYPE.FETCH_RESULT_RECEIVED,
|
|
220
220
|
modelPath: modelPath,
|
|
221
221
|
data: updatedModel_1
|
|
222
222
|
});
|
|
@@ -25,19 +25,19 @@ var dispatchAction = function (action) {
|
|
|
25
25
|
};
|
|
26
26
|
exports.dispatchAction = dispatchAction;
|
|
27
27
|
var dispatchModelFetchRequest = function (action) {
|
|
28
|
-
exports.dispatchAction(__assign({ type: actions_1.
|
|
28
|
+
exports.dispatchAction(__assign({ type: actions_1.MODEL_FETCH_REQUEST_ACTION_TYPE.FETCH_REQUEST }, action));
|
|
29
29
|
};
|
|
30
30
|
exports.dispatchModelFetchRequest = dispatchModelFetchRequest;
|
|
31
31
|
var dispatchPeriodicModelFetchRequest = function (action) {
|
|
32
|
-
exports.dispatchAction(__assign({ type: actions_1.
|
|
32
|
+
exports.dispatchAction(__assign({ type: actions_1.MODEL_FETCH_REQUEST_ACTION_TYPE.PERIODIC_FETCH_REQUEST }, action));
|
|
33
33
|
};
|
|
34
34
|
exports.dispatchPeriodicModelFetchRequest = dispatchPeriodicModelFetchRequest;
|
|
35
35
|
var dispatchPeriodicModelFetchTerminateAction = function (action) {
|
|
36
|
-
exports.dispatchAction(__assign({ type: actions_1.
|
|
36
|
+
exports.dispatchAction(__assign({ type: actions_1.PERIODIC_MODEL_FETCH_TERMINATION_ACTION_TYPE.TERMINATE }, action));
|
|
37
37
|
};
|
|
38
38
|
exports.dispatchPeriodicModelFetchTerminateAction = dispatchPeriodicModelFetchTerminateAction;
|
|
39
39
|
var dispatchModelRemoveKeyAction = function (action) {
|
|
40
|
-
exports.dispatchAction(__assign({ type: actions_1.
|
|
40
|
+
exports.dispatchAction(__assign({ type: actions_1.MODEL_REMOVE_KEY_ACTION_TYPE }, action));
|
|
41
41
|
};
|
|
42
42
|
exports.dispatchModelRemoveKeyAction = dispatchModelRemoveKeyAction;
|
|
43
43
|
var addNotification = function (_a) {
|
|
@@ -35,7 +35,7 @@ export interface AuthTokenSuccessAction extends Action<AUTH_TOKEN_SUCCESS_ACTION
|
|
|
35
35
|
oauthToken: OAuthToken;
|
|
36
36
|
}
|
|
37
37
|
export declare enum AUTH_IDENTITY_PROVIDER_REQUEST_ACTION_TYPE {
|
|
38
|
-
|
|
38
|
+
IDENTITY_PROVIDER_LOGIN_REQUEST = "auth/IDENTITY_PROVIDER_LOGIN_REQUEST"
|
|
39
39
|
}
|
|
40
40
|
export interface AuthIdentityProviderRequestAction extends Action<AUTH_IDENTITY_PROVIDER_REQUEST_ACTION_TYPE> {
|
|
41
41
|
identityProvider: IdentityProvider;
|
|
@@ -20,7 +20,7 @@ var AUTH_TOKEN_SUCCESS_ACTION_TYPE;
|
|
|
20
20
|
})(AUTH_TOKEN_SUCCESS_ACTION_TYPE = exports.AUTH_TOKEN_SUCCESS_ACTION_TYPE || (exports.AUTH_TOKEN_SUCCESS_ACTION_TYPE = {}));
|
|
21
21
|
var AUTH_IDENTITY_PROVIDER_REQUEST_ACTION_TYPE;
|
|
22
22
|
(function (AUTH_IDENTITY_PROVIDER_REQUEST_ACTION_TYPE) {
|
|
23
|
-
AUTH_IDENTITY_PROVIDER_REQUEST_ACTION_TYPE["
|
|
23
|
+
AUTH_IDENTITY_PROVIDER_REQUEST_ACTION_TYPE["IDENTITY_PROVIDER_LOGIN_REQUEST"] = "auth/IDENTITY_PROVIDER_LOGIN_REQUEST";
|
|
24
24
|
})(AUTH_IDENTITY_PROVIDER_REQUEST_ACTION_TYPE = exports.AUTH_IDENTITY_PROVIDER_REQUEST_ACTION_TYPE || (exports.AUTH_IDENTITY_PROVIDER_REQUEST_ACTION_TYPE = {}));
|
|
25
25
|
var AUTH_CAS_V1_LOGIN_REQUEST_ACTION_TYPE;
|
|
26
26
|
(function (AUTH_CAS_V1_LOGIN_REQUEST_ACTION_TYPE) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Action, AnyAction } from 'redux';
|
|
2
2
|
import { FetchErrorData } from '../../types/net/FetchErrorData';
|
|
3
3
|
import { HTTPMethod } from '../../types/net/HTTPMethod';
|
|
4
|
-
export declare enum
|
|
4
|
+
export declare enum MODEL_FETCH_REQUEST_ACTION_TYPE {
|
|
5
5
|
FETCH_REQUEST = "models/FETCH_REQUEST",
|
|
6
6
|
PERIODIC_FETCH_REQUEST = "models/PERIODIC_FETCH_REQUEST"
|
|
7
7
|
}
|
|
@@ -15,7 +15,7 @@ export interface BaseModelFetchRequestAction<T> extends Action<T> {
|
|
|
15
15
|
* `"/collection/{}/subcollection/{}" => "/collection/1/subcollection/2"`
|
|
16
16
|
*/
|
|
17
17
|
pathParams?: Array<string | number | undefined | null>;
|
|
18
|
-
/** A unique identifier used for action dispatchers to correlate responses to requests. Will be attached to the corresponding `
|
|
18
|
+
/** A unique identifier used for action dispatchers to correlate responses to requests. Will be attached to the corresponding `ModelFetchResultAction.data`. */
|
|
19
19
|
guid?: string;
|
|
20
20
|
/** The HTTP Method to use for the fetch. Defaults to use value from EndpointMapping, or 'GET'. */
|
|
21
21
|
method?: HTTPMethod;
|
|
@@ -37,57 +37,57 @@ export interface BaseModelFetchRequestAction<T> extends Action<T> {
|
|
|
37
37
|
/**
|
|
38
38
|
* Action used to trigger a fetch request for a model. Uses `modelName` to find an `EndpointMapping`, and stores results in the corresponding location in redux under `state.models`.
|
|
39
39
|
*/
|
|
40
|
-
export interface ModelFetchRequestAction extends BaseModelFetchRequestAction<
|
|
40
|
+
export interface ModelFetchRequestAction extends BaseModelFetchRequestAction<MODEL_FETCH_REQUEST_ACTION_TYPE.FETCH_REQUEST> {
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Action used to trigger a recurring fetch request for a model. Uses `modelName` to find an `EndpointMapping`, and stores results in the corresponding location in redux under `state.models`.
|
|
44
44
|
*/
|
|
45
|
-
export interface PeriodicModelFetchRequestAction extends BaseModelFetchRequestAction<
|
|
45
|
+
export interface PeriodicModelFetchRequestAction extends BaseModelFetchRequestAction<MODEL_FETCH_REQUEST_ACTION_TYPE.PERIODIC_FETCH_REQUEST> {
|
|
46
46
|
/** How often in `ms` milliseconds to re-fetch when used in a recurring fetch scenario. */
|
|
47
47
|
period: number;
|
|
48
48
|
/** An id, from your application, used to cancel the recurring fetch task at a later time. */
|
|
49
49
|
taskId: string;
|
|
50
50
|
}
|
|
51
|
-
export declare enum
|
|
51
|
+
export declare enum PERIODIC_MODEL_FETCH_TERMINATION_ACTION_TYPE {
|
|
52
52
|
TERMINATE = "models/PERIODIC_MODEL_FETCH_REQUEST_TERMINATE",
|
|
53
53
|
SUCCEEDED = "models/PERIODIC_MODEL_FETCH_REQUEST_TERMINATE_SUCCEEDED"
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Action used to terminate a periodic model fetch request task, or notify of termination success.
|
|
57
57
|
*/
|
|
58
|
-
export interface PeriodicModelFetchTerminationAction extends Action<
|
|
58
|
+
export interface PeriodicModelFetchTerminationAction extends Action<PERIODIC_MODEL_FETCH_TERMINATION_ACTION_TYPE> {
|
|
59
59
|
/** The id, from your application, used to cancel a recurring task. */
|
|
60
60
|
taskId: string;
|
|
61
61
|
}
|
|
62
62
|
interface BaseModelStoreAction {
|
|
63
63
|
/** The full object path used to store the result in the redux store under 'state.models'. Includes keys and ids. */
|
|
64
64
|
modelPath: string;
|
|
65
|
-
/** The pre-generated GUID, from your application, that was provided to the
|
|
65
|
+
/** The pre-generated GUID, from your application, that was provided to the `ModelFetchRequestAction`. */
|
|
66
66
|
guid?: string;
|
|
67
67
|
}
|
|
68
|
-
export declare const
|
|
68
|
+
export declare const MODEL_REMOVE_KEY_ACTION_TYPE = "models/REMOVE_KEY";
|
|
69
69
|
/**
|
|
70
70
|
* Action used to remove the model at the target redux `modelPath` key.
|
|
71
71
|
*/
|
|
72
|
-
export interface ModelRemoveKeyAction extends Action<typeof
|
|
72
|
+
export interface ModelRemoveKeyAction extends Action<typeof MODEL_REMOVE_KEY_ACTION_TYPE>, Omit<BaseModelStoreAction, 'guid'> {
|
|
73
73
|
}
|
|
74
|
-
export declare enum
|
|
74
|
+
export declare enum MODEL_FETCH_START_ACTION_TYPE {
|
|
75
75
|
FETCH_START = "models/FETCH_START",
|
|
76
76
|
TRANSIENT_FETCH_START = "models/TRANSIENT_FETCH_START"
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Action used to update the target redux `modelPath` `_metadata` when a fetch is about to start.
|
|
80
80
|
*/
|
|
81
|
-
export interface ModelFetchStartAction extends Action<
|
|
81
|
+
export interface ModelFetchStartAction extends Action<MODEL_FETCH_START_ACTION_TYPE>, BaseModelStoreAction {
|
|
82
82
|
}
|
|
83
|
-
export declare enum
|
|
83
|
+
export declare enum MODEL_FETCH_RESULT_ACTION_TYPE {
|
|
84
84
|
FETCH_RESULT_RECEIVED = "models/FETCH_RESULT_RECEIVED",
|
|
85
85
|
TRANSIENT_FETCH_RESULT_RECEIVED = "models/TRANSIENT_FETCH_RESULT_RECEIVED"
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Action used to update the target redux `modelPath` when a successful fetch result is received.
|
|
89
89
|
*/
|
|
90
|
-
export interface ModelFetchResultAction extends Action<
|
|
90
|
+
export interface ModelFetchResultAction extends Action<MODEL_FETCH_RESULT_ACTION_TYPE>, BaseModelStoreAction {
|
|
91
91
|
/** If true, the `modelsReducer` will replace the existing value in redux, instead of merging the incoming with existing. */
|
|
92
92
|
replaceValue?: boolean;
|
|
93
93
|
/** The data returned from a request. */
|
|
@@ -95,7 +95,7 @@ export interface ModelFetchResultAction extends Action<MODEL_FETCH_RESULT_TYPE>,
|
|
|
95
95
|
}
|
|
96
96
|
export declare const isModelFetchResultAction: (action: AnyAction) => action is ModelFetchResultAction;
|
|
97
97
|
export declare const isTransientModelFetchResultAction: (action: AnyAction) => action is ModelFetchResultAction;
|
|
98
|
-
export declare enum
|
|
98
|
+
export declare enum MODEL_FETCH_ERROR_ACTION_TYPE {
|
|
99
99
|
FETCH_FAILED = "models/FETCH_FAILED",
|
|
100
100
|
TRANSIENT_FETCH_FAILED = "models/TRANSIENT_FETCH_FAILED",
|
|
101
101
|
TRY_FETCH_FAILED = "models/TRY_FETCH_FAILED"
|
|
@@ -103,7 +103,7 @@ export declare enum MODEL_FETCH_ERROR_TYPE {
|
|
|
103
103
|
/**
|
|
104
104
|
* Action used to update the target redux `modelPath` `_metadata` for a failed fetch.
|
|
105
105
|
*/
|
|
106
|
-
export interface ModelFetchErrorAction extends Action<
|
|
106
|
+
export interface ModelFetchErrorAction extends Action<MODEL_FETCH_ERROR_ACTION_TYPE>, BaseModelStoreAction {
|
|
107
107
|
/** The error data returned from a failed request. */
|
|
108
108
|
errorData?: FetchErrorData;
|
|
109
109
|
}
|
|
@@ -1,62 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isModelTryFetchErrorAction = exports.isTransientModelFetchErrorAction = exports.isModelFetchErrorAction = exports.
|
|
3
|
+
exports.isModelTryFetchErrorAction = exports.isTransientModelFetchErrorAction = exports.isModelFetchErrorAction = exports.MODEL_FETCH_ERROR_ACTION_TYPE = exports.isTransientModelFetchResultAction = exports.isModelFetchResultAction = exports.MODEL_FETCH_RESULT_ACTION_TYPE = exports.MODEL_FETCH_START_ACTION_TYPE = exports.MODEL_REMOVE_KEY_ACTION_TYPE = exports.PERIODIC_MODEL_FETCH_TERMINATION_ACTION_TYPE = exports.MODEL_FETCH_REQUEST_ACTION_TYPE = void 0;
|
|
4
4
|
//#region Model Fetch Requests
|
|
5
|
-
var
|
|
6
|
-
(function (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
})(
|
|
10
|
-
var
|
|
11
|
-
(function (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
})(
|
|
5
|
+
var MODEL_FETCH_REQUEST_ACTION_TYPE;
|
|
6
|
+
(function (MODEL_FETCH_REQUEST_ACTION_TYPE) {
|
|
7
|
+
MODEL_FETCH_REQUEST_ACTION_TYPE["FETCH_REQUEST"] = "models/FETCH_REQUEST";
|
|
8
|
+
MODEL_FETCH_REQUEST_ACTION_TYPE["PERIODIC_FETCH_REQUEST"] = "models/PERIODIC_FETCH_REQUEST";
|
|
9
|
+
})(MODEL_FETCH_REQUEST_ACTION_TYPE = exports.MODEL_FETCH_REQUEST_ACTION_TYPE || (exports.MODEL_FETCH_REQUEST_ACTION_TYPE = {}));
|
|
10
|
+
var PERIODIC_MODEL_FETCH_TERMINATION_ACTION_TYPE;
|
|
11
|
+
(function (PERIODIC_MODEL_FETCH_TERMINATION_ACTION_TYPE) {
|
|
12
|
+
PERIODIC_MODEL_FETCH_TERMINATION_ACTION_TYPE["TERMINATE"] = "models/PERIODIC_MODEL_FETCH_REQUEST_TERMINATE";
|
|
13
|
+
PERIODIC_MODEL_FETCH_TERMINATION_ACTION_TYPE["SUCCEEDED"] = "models/PERIODIC_MODEL_FETCH_REQUEST_TERMINATE_SUCCEEDED";
|
|
14
|
+
})(PERIODIC_MODEL_FETCH_TERMINATION_ACTION_TYPE = exports.PERIODIC_MODEL_FETCH_TERMINATION_ACTION_TYPE || (exports.PERIODIC_MODEL_FETCH_TERMINATION_ACTION_TYPE = {}));
|
|
15
15
|
//#region Model Remove Key
|
|
16
|
-
exports.
|
|
16
|
+
exports.MODEL_REMOVE_KEY_ACTION_TYPE = 'models/REMOVE_KEY';
|
|
17
17
|
//#endregion Model Remove Key
|
|
18
18
|
//#region Model Fetch Start
|
|
19
|
-
var
|
|
20
|
-
(function (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})(
|
|
19
|
+
var MODEL_FETCH_START_ACTION_TYPE;
|
|
20
|
+
(function (MODEL_FETCH_START_ACTION_TYPE) {
|
|
21
|
+
MODEL_FETCH_START_ACTION_TYPE["FETCH_START"] = "models/FETCH_START";
|
|
22
|
+
MODEL_FETCH_START_ACTION_TYPE["TRANSIENT_FETCH_START"] = "models/TRANSIENT_FETCH_START";
|
|
23
|
+
})(MODEL_FETCH_START_ACTION_TYPE = exports.MODEL_FETCH_START_ACTION_TYPE || (exports.MODEL_FETCH_START_ACTION_TYPE = {}));
|
|
24
24
|
//#endregion Model Fetch Start
|
|
25
25
|
//#region Model Fetch Result
|
|
26
|
-
var
|
|
27
|
-
(function (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
})(
|
|
26
|
+
var MODEL_FETCH_RESULT_ACTION_TYPE;
|
|
27
|
+
(function (MODEL_FETCH_RESULT_ACTION_TYPE) {
|
|
28
|
+
MODEL_FETCH_RESULT_ACTION_TYPE["FETCH_RESULT_RECEIVED"] = "models/FETCH_RESULT_RECEIVED";
|
|
29
|
+
MODEL_FETCH_RESULT_ACTION_TYPE["TRANSIENT_FETCH_RESULT_RECEIVED"] = "models/TRANSIENT_FETCH_RESULT_RECEIVED";
|
|
30
|
+
})(MODEL_FETCH_RESULT_ACTION_TYPE = exports.MODEL_FETCH_RESULT_ACTION_TYPE || (exports.MODEL_FETCH_RESULT_ACTION_TYPE = {}));
|
|
31
31
|
var isModelFetchResultAction = function (action) {
|
|
32
|
-
return action.type ===
|
|
33
|
-
action.type ===
|
|
32
|
+
return action.type === MODEL_FETCH_RESULT_ACTION_TYPE.FETCH_RESULT_RECEIVED ||
|
|
33
|
+
action.type === MODEL_FETCH_RESULT_ACTION_TYPE.TRANSIENT_FETCH_RESULT_RECEIVED;
|
|
34
34
|
};
|
|
35
35
|
exports.isModelFetchResultAction = isModelFetchResultAction;
|
|
36
36
|
var isTransientModelFetchResultAction = function (action) {
|
|
37
|
-
return action.type ===
|
|
37
|
+
return action.type === MODEL_FETCH_RESULT_ACTION_TYPE.TRANSIENT_FETCH_RESULT_RECEIVED;
|
|
38
38
|
};
|
|
39
39
|
exports.isTransientModelFetchResultAction = isTransientModelFetchResultAction;
|
|
40
40
|
//#endregion Model Fetch Result
|
|
41
41
|
//#region Model Fetch Error
|
|
42
|
-
var
|
|
43
|
-
(function (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})(
|
|
42
|
+
var MODEL_FETCH_ERROR_ACTION_TYPE;
|
|
43
|
+
(function (MODEL_FETCH_ERROR_ACTION_TYPE) {
|
|
44
|
+
MODEL_FETCH_ERROR_ACTION_TYPE["FETCH_FAILED"] = "models/FETCH_FAILED";
|
|
45
|
+
MODEL_FETCH_ERROR_ACTION_TYPE["TRANSIENT_FETCH_FAILED"] = "models/TRANSIENT_FETCH_FAILED";
|
|
46
|
+
MODEL_FETCH_ERROR_ACTION_TYPE["TRY_FETCH_FAILED"] = "models/TRY_FETCH_FAILED";
|
|
47
|
+
})(MODEL_FETCH_ERROR_ACTION_TYPE = exports.MODEL_FETCH_ERROR_ACTION_TYPE || (exports.MODEL_FETCH_ERROR_ACTION_TYPE = {}));
|
|
48
48
|
var isModelFetchErrorAction = function (action) {
|
|
49
|
-
return action.type ===
|
|
50
|
-
action.type ===
|
|
51
|
-
action.type ===
|
|
49
|
+
return action.type === MODEL_FETCH_ERROR_ACTION_TYPE.TRY_FETCH_FAILED ||
|
|
50
|
+
action.type === MODEL_FETCH_ERROR_ACTION_TYPE.FETCH_FAILED ||
|
|
51
|
+
action.type === MODEL_FETCH_ERROR_ACTION_TYPE.TRANSIENT_FETCH_FAILED;
|
|
52
52
|
};
|
|
53
53
|
exports.isModelFetchErrorAction = isModelFetchErrorAction;
|
|
54
54
|
var isTransientModelFetchErrorAction = function (action) {
|
|
55
|
-
return action.type ===
|
|
55
|
+
return action.type === MODEL_FETCH_ERROR_ACTION_TYPE.TRANSIENT_FETCH_FAILED;
|
|
56
56
|
};
|
|
57
57
|
exports.isTransientModelFetchErrorAction = isTransientModelFetchErrorAction;
|
|
58
58
|
var isModelTryFetchErrorAction = function (action) {
|
|
59
|
-
return action.type ===
|
|
59
|
+
return action.type === MODEL_FETCH_ERROR_ACTION_TYPE.TRY_FETCH_FAILED;
|
|
60
60
|
};
|
|
61
61
|
exports.isModelTryFetchErrorAction = isModelTryFetchErrorAction;
|
|
62
62
|
//#endregion Model Store Actions
|
|
@@ -43,7 +43,16 @@ var actionCreator_1 = require("./actionCreator");
|
|
|
43
43
|
var actions_1 = require("./actions");
|
|
44
44
|
var configureReducers_1 = __importDefault(require("./configureReducers"));
|
|
45
45
|
var rootSaga_1 = __importDefault(require("./sagas/rootSaga"));
|
|
46
|
-
var keysToFilter = [
|
|
46
|
+
var keysToFilter = [
|
|
47
|
+
'puid',
|
|
48
|
+
'employeeNumber',
|
|
49
|
+
'access_token',
|
|
50
|
+
'refresh_token',
|
|
51
|
+
'password',
|
|
52
|
+
'Password',
|
|
53
|
+
'content',
|
|
54
|
+
'data'
|
|
55
|
+
];
|
|
47
56
|
var filterData = function (obj) {
|
|
48
57
|
return lodash_1.transform(obj, function (result, value, key) {
|
|
49
58
|
if (keysToFilter.includes(key)) {
|
|
@@ -65,17 +74,11 @@ var stripState = function (obj, parentKey) {
|
|
|
65
74
|
};
|
|
66
75
|
exports.stripState = stripState;
|
|
67
76
|
var actionTransformer = function (action) {
|
|
68
|
-
var _a;
|
|
69
77
|
// action breadcrumb filtering
|
|
70
78
|
if (
|
|
71
|
-
// do not track
|
|
72
|
-
action.type === actions_1.
|
|
73
|
-
action.type === actions_1.
|
|
74
|
-
// do not track modal actions
|
|
75
|
-
action.type === actions_1.MODAL_ACTION_TYPE.MODAL_ENTERING ||
|
|
76
|
-
action.type === actions_1.MODAL_ACTION_TYPE.MODAL_EXITED ||
|
|
77
|
-
// do not track API requests for tokens
|
|
78
|
-
(action.type === actions_1.MODEL_FETCH_REQUEST_TYPE && ((_a = action.data) === null || _a === void 0 ? void 0 : _a.modelName) === 'getToken')) {
|
|
79
|
+
// do not track modal actions
|
|
80
|
+
action.type === actions_1.MODAL_ACTION_TYPE.MODAL_ENTERING ||
|
|
81
|
+
action.type === actions_1.MODAL_ACTION_TYPE.MODAL_EXITED) {
|
|
79
82
|
return null;
|
|
80
83
|
}
|
|
81
84
|
return filterData(action);
|
|
@@ -147,7 +147,7 @@ function modelsReducer(state, action) {
|
|
|
147
147
|
var metadata = getMetadata(state, path);
|
|
148
148
|
var metadataUpdate;
|
|
149
149
|
switch (action.type) {
|
|
150
|
-
case actions_1.
|
|
150
|
+
case actions_1.MODEL_FETCH_START_ACTION_TYPE.FETCH_START:
|
|
151
151
|
// Retain the entity data, update the metadata to reflect fetch in request state
|
|
152
152
|
metadataUpdate = {
|
|
153
153
|
isFetching: true,
|
|
@@ -159,7 +159,7 @@ function modelsReducer(state, action) {
|
|
|
159
159
|
valueAtPath.guid = action.guid;
|
|
160
160
|
}
|
|
161
161
|
return fp_1.default.setWith(Object, path, valueAtPath, state);
|
|
162
|
-
case actions_1.
|
|
162
|
+
case actions_1.MODEL_FETCH_RESULT_ACTION_TYPE.FETCH_RESULT_RECEIVED: {
|
|
163
163
|
// Update the metadata to reflect fetch is complete.
|
|
164
164
|
metadataUpdate = {
|
|
165
165
|
isFetching: false,
|
|
@@ -181,7 +181,7 @@ function modelsReducer(state, action) {
|
|
|
181
181
|
var result = fp_1.default.setWith(Object, path, valueAtPath, state);
|
|
182
182
|
return result;
|
|
183
183
|
}
|
|
184
|
-
case actions_1.
|
|
184
|
+
case actions_1.MODEL_FETCH_ERROR_ACTION_TYPE.FETCH_FAILED:
|
|
185
185
|
// Retain the object, update the metadata to reflect the fact that the request failed
|
|
186
186
|
metadataUpdate = {
|
|
187
187
|
isFetching: false,
|
|
@@ -193,7 +193,7 @@ function modelsReducer(state, action) {
|
|
|
193
193
|
valueAtPath.guid = action.guid;
|
|
194
194
|
}
|
|
195
195
|
return fp_1.default.setWith(Object, path, valueAtPath, state);
|
|
196
|
-
case actions_1.
|
|
196
|
+
case actions_1.MODEL_REMOVE_KEY_ACTION_TYPE:
|
|
197
197
|
// Completely remove the object at the path from the state
|
|
198
198
|
return fp_1.default.unset(path, state);
|
|
199
199
|
default:
|
|
@@ -68,7 +68,7 @@ var clientCredentials;
|
|
|
68
68
|
var oauthToken = null;
|
|
69
69
|
var tokenPersistenceService;
|
|
70
70
|
var refreshLock;
|
|
71
|
-
var logger
|
|
71
|
+
var logger;
|
|
72
72
|
//#endregion Local Variables
|
|
73
73
|
function getTokenFromCode(code) {
|
|
74
74
|
var getTokenModelName, formBody, formBodyString, _a, fetchResultAction, fetchErrorAction;
|
|
@@ -84,7 +84,7 @@ function getTokenFromCode(code) {
|
|
|
84
84
|
];
|
|
85
85
|
formBodyString = formBody.join('&');
|
|
86
86
|
return [4 /*yield*/, effects_1.put({
|
|
87
|
-
type: actions_1.
|
|
87
|
+
type: actions_1.MODEL_FETCH_REQUEST_ACTION_TYPE.FETCH_REQUEST,
|
|
88
88
|
modelName: getTokenModelName,
|
|
89
89
|
body: formBodyString,
|
|
90
90
|
noStore: true
|
|
@@ -120,7 +120,7 @@ function getTokenFromRefreshToken(oauthTokenParam) {
|
|
|
120
120
|
];
|
|
121
121
|
formBodyString = formBody.join('&');
|
|
122
122
|
return [4 /*yield*/, effects_1.put({
|
|
123
|
-
type: actions_1.
|
|
123
|
+
type: actions_1.MODEL_FETCH_REQUEST_ACTION_TYPE.FETCH_REQUEST,
|
|
124
124
|
modelName: getTokenModelName,
|
|
125
125
|
body: formBodyString,
|
|
126
126
|
noStore: true
|
|
@@ -138,8 +138,8 @@ function getTokenFromRefreshToken(oauthTokenParam) {
|
|
|
138
138
|
// any error response
|
|
139
139
|
if (fetchErrorAction) {
|
|
140
140
|
// ignore time outs and server errors
|
|
141
|
-
// TODO - how to ignore timeouts? which code?
|
|
142
|
-
if (((_b = fetchErrorAction.errorData) === null || _b === void 0 ? void 0 : _b.
|
|
141
|
+
// TODO - redux updates: how to ignore timeouts? which code?
|
|
142
|
+
if (((_b = fetchErrorAction.errorData) === null || _b === void 0 ? void 0 : _b.status) && fetchErrorAction.errorData.status >= 500) {
|
|
143
143
|
return [2 /*return*/, oauthTokenParam];
|
|
144
144
|
}
|
|
145
145
|
return [2 /*return*/, null];
|
|
@@ -237,7 +237,7 @@ function credentialsLoginFlow(action, modelName) {
|
|
|
237
237
|
case 0:
|
|
238
238
|
modelFetchRequestAction = __assign(__assign({}, action), {
|
|
239
239
|
// set required overrides
|
|
240
|
-
type: actions_1.
|
|
240
|
+
type: actions_1.MODEL_FETCH_REQUEST_ACTION_TYPE.FETCH_REQUEST, modelName: modelName, noStore: true });
|
|
241
241
|
return [4 /*yield*/, effects_1.call(loginFlow, modelFetchRequestAction)];
|
|
242
242
|
case 1: return [2 /*return*/, _a.sent()];
|
|
243
243
|
}
|
|
@@ -268,7 +268,7 @@ function casTicketLoginFlow(ticket, service) {
|
|
|
268
268
|
switch (_a.label) {
|
|
269
269
|
case 0:
|
|
270
270
|
modelFetchRequestAction = {
|
|
271
|
-
type: actions_1.
|
|
271
|
+
type: actions_1.MODEL_FETCH_REQUEST_ACTION_TYPE.FETCH_REQUEST,
|
|
272
272
|
modelName: 'codeFromCasTicket',
|
|
273
273
|
noStore: true,
|
|
274
274
|
queryParams: {
|
|
@@ -286,7 +286,7 @@ function handleAuthFailure(action) {
|
|
|
286
286
|
return __generator(this, function (_a) {
|
|
287
287
|
switch (_a.label) {
|
|
288
288
|
case 0:
|
|
289
|
-
if (!(oauthToken && action.errorData && action.errorData.
|
|
289
|
+
if (!(oauthToken && action.errorData && action.errorData.status === 401)) return [3 /*break*/, 2];
|
|
290
290
|
logger.debug('token expired - refreshing');
|
|
291
291
|
return [4 /*yield*/, effects_1.call(performTokenRefresh)];
|
|
292
292
|
case 1:
|
|
@@ -297,13 +297,13 @@ function handleAuthFailure(action) {
|
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
299
|
exports.handleAuthFailure = handleAuthFailure;
|
|
300
|
-
var getOAuthToken = function (
|
|
300
|
+
var getOAuthToken = function (modelName) {
|
|
301
301
|
var thirtySecondsFromNow;
|
|
302
302
|
return __generator(this, function (_a) {
|
|
303
303
|
switch (_a.label) {
|
|
304
304
|
case 0:
|
|
305
305
|
// Don't try to refresh the token if we're already in a request to refresh the token
|
|
306
|
-
if (
|
|
306
|
+
if (modelName === 'getToken') {
|
|
307
307
|
return [2 /*return*/, null];
|
|
308
308
|
}
|
|
309
309
|
if (!(oauthToken && oauthToken['.expires'])) return [3 /*break*/, 2];
|
|
@@ -329,6 +329,7 @@ function authSaga(clientCredentialsParam, tokenPersistenceServiceParam, ticketPr
|
|
|
329
329
|
return __generator(this, function (_b) {
|
|
330
330
|
switch (_b.label) {
|
|
331
331
|
case 0:
|
|
332
|
+
logger = logger_1.getLogger();
|
|
332
333
|
/* istanbul ignore if */
|
|
333
334
|
if (!clientCredentialsParam) {
|
|
334
335
|
throw new Error("'clientCredentialsParam' is required for authSaga");
|
|
@@ -355,7 +356,7 @@ function authSaga(clientCredentialsParam, tokenPersistenceServiceParam, ticketPr
|
|
|
355
356
|
if (!code) return [3 /*break*/, 7];
|
|
356
357
|
if (!oauthToken) return [3 /*break*/, 5];
|
|
357
358
|
return [4 /*yield*/, effects_1.all({
|
|
358
|
-
clearUserData: effects_1.put({ type: actions_1.
|
|
359
|
+
clearUserData: effects_1.put({ type: actions_1.MODEL_REMOVE_KEY_ACTION_TYPE, modelPath: 'user' }),
|
|
359
360
|
clearPersistentToken: effects_1.call(tokenPersistenceService.persistToken, null)
|
|
360
361
|
})];
|
|
361
362
|
case 4:
|
|
@@ -371,7 +372,7 @@ function authSaga(clientCredentialsParam, tokenPersistenceServiceParam, ticketPr
|
|
|
371
372
|
return [4 /*yield*/, effects_1.put({ type: actions_1.AUTH_TOKEN_ACTION_TYPE.AUTH_INITIALIZED, oauthToken: oauthToken })];
|
|
372
373
|
case 8:
|
|
373
374
|
_b.sent();
|
|
374
|
-
return [4 /*yield*/, effects_1.takeEvery(actions_1.
|
|
375
|
+
return [4 /*yield*/, effects_1.takeEvery(actions_1.MODEL_FETCH_ERROR_ACTION_TYPE.TRY_FETCH_FAILED, handleAuthFailure)];
|
|
375
376
|
case 9:
|
|
376
377
|
_b.sent();
|
|
377
378
|
_b.label = 10;
|
|
@@ -408,7 +409,7 @@ function authSaga(clientCredentialsParam, tokenPersistenceServiceParam, ticketPr
|
|
|
408
409
|
oauthToken: oauthToken
|
|
409
410
|
}),
|
|
410
411
|
getUserInfo: effects_1.put({
|
|
411
|
-
type: actions_1.
|
|
412
|
+
type: actions_1.MODEL_FETCH_REQUEST_ACTION_TYPE.FETCH_REQUEST,
|
|
412
413
|
modelName: 'user.userInfo'
|
|
413
414
|
}),
|
|
414
415
|
logOut: effects_1.take(actions_1.AUTH_ACTION_TYPE.LOG_OUT_REQUESTED)
|
|
@@ -421,7 +422,7 @@ function authSaga(clientCredentialsParam, tokenPersistenceServiceParam, ticketPr
|
|
|
421
422
|
_b.sent();
|
|
422
423
|
_b.label = 21;
|
|
423
424
|
case 21: return [4 /*yield*/, effects_1.all({
|
|
424
|
-
clearUserData: effects_1.put({ type: actions_1.
|
|
425
|
+
clearUserData: effects_1.put({ type: actions_1.MODEL_REMOVE_KEY_ACTION_TYPE, modelPath: 'user' }),
|
|
425
426
|
clearPersistentToken: effects_1.call(tokenPersistenceService.persistToken, null)
|
|
426
427
|
})];
|
|
427
428
|
case 22:
|
|
@@ -40,7 +40,7 @@ function downtimeApiErrorSaga(runIndefinitely) {
|
|
|
40
40
|
return [4 /*yield*/, effects_1.take(function (action) {
|
|
41
41
|
var _a, _b, _c;
|
|
42
42
|
return actions_1.isModelTryFetchErrorAction(action) &&
|
|
43
|
-
((_a = action.errorData) === null || _a === void 0 ? void 0 : _a.
|
|
43
|
+
((_a = action.errorData) === null || _a === void 0 ? void 0 : _a.status) === types_1.HTTP_STATUS_CODE.FORBIDDEN &&
|
|
44
44
|
!!((_c = (_b = action.errorData) === null || _b === void 0 ? void 0 : _b.title) === null || _c === void 0 ? void 0 : _c.includes("We'll be right back!"));
|
|
45
45
|
})
|
|
46
46
|
// redirect to downtime route
|
|
@@ -31,7 +31,7 @@ var effects_1 = require("redux-saga/effects");
|
|
|
31
31
|
var persistenceService_1 = require("../../services/persistenceService");
|
|
32
32
|
var actions_1 = require("../actions");
|
|
33
33
|
function identityProviderSaga() {
|
|
34
|
-
var oauthToken,
|
|
34
|
+
var oauthToken, identityProviderAction;
|
|
35
35
|
return __generator(this, function (_a) {
|
|
36
36
|
switch (_a.label) {
|
|
37
37
|
case 0: return [4 /*yield*/, effects_1.take(function (action) { return actions_1.isModelFetchResultAction(action) && action.modelPath === 'identityProviders'; })];
|
|
@@ -45,24 +45,24 @@ function identityProviderSaga() {
|
|
|
45
45
|
oauthToken = _a.sent();
|
|
46
46
|
return [4 /*yield*/, effects_1.call(persistenceService_1.persistenceService.getItem, persistenceService_1.identityProviderKey)];
|
|
47
47
|
case 4:
|
|
48
|
-
|
|
49
|
-
if (!(oauthToken &&
|
|
48
|
+
identityProviderAction = _a.sent();
|
|
49
|
+
if (!(oauthToken && identityProviderAction)) return [3 /*break*/, 7];
|
|
50
50
|
return [4 /*yield*/, effects_1.take(actions_1.AUTH_ACTION_TYPE.LOG_OUT_REQUESTED)];
|
|
51
51
|
case 5:
|
|
52
52
|
_a.sent();
|
|
53
53
|
return [4 /*yield*/, effects_1.call(persistenceService_1.persistenceService.removeItem, persistenceService_1.identityProviderKey)];
|
|
54
54
|
case 6:
|
|
55
55
|
_a.sent();
|
|
56
|
-
window.location.href =
|
|
56
|
+
window.location.href = identityProviderAction.identityProvider.logoutUrl;
|
|
57
57
|
_a.label = 7;
|
|
58
|
-
case 7: return [4 /*yield*/, effects_1.take(actions_1.AUTH_IDENTITY_PROVIDER_REQUEST_ACTION_TYPE.
|
|
58
|
+
case 7: return [4 /*yield*/, effects_1.take(actions_1.AUTH_IDENTITY_PROVIDER_REQUEST_ACTION_TYPE.IDENTITY_PROVIDER_LOGIN_REQUEST)];
|
|
59
59
|
case 8:
|
|
60
|
-
|
|
61
|
-
if (!
|
|
62
|
-
return [4 /*yield*/, effects_1.call(persistenceService_1.persistenceService.setItem, persistenceService_1.identityProviderKey,
|
|
60
|
+
identityProviderAction = _a.sent();
|
|
61
|
+
if (!identityProviderAction) return [3 /*break*/, 10];
|
|
62
|
+
return [4 /*yield*/, effects_1.call(persistenceService_1.persistenceService.setItem, persistenceService_1.identityProviderKey, identityProviderAction)];
|
|
63
63
|
case 9:
|
|
64
64
|
_a.sent();
|
|
65
|
-
window.location.href =
|
|
65
|
+
window.location.href = identityProviderAction.identityProvider.loginUrl;
|
|
66
66
|
_a.label = 10;
|
|
67
67
|
case 10: return [3 /*break*/, 2];
|
|
68
68
|
case 11: return [2 /*return*/];
|
|
@@ -48,7 +48,7 @@ function lockDownBrowserSaga(runIndefinitely) {
|
|
|
48
48
|
var _a;
|
|
49
49
|
if (!actions_1.isModelTryFetchErrorAction(action))
|
|
50
50
|
return false;
|
|
51
|
-
message = ((_a = action.errorData) === null || _a === void 0 ? void 0 : _a.
|
|
51
|
+
message = ((_a = action.errorData) === null || _a === void 0 ? void 0 : _a.detail) || '';
|
|
52
52
|
return message === null || message === void 0 ? void 0 : message.includes('LockDown Browser');
|
|
53
53
|
})
|
|
54
54
|
// redirect to known LDB error route
|
|
@@ -4,7 +4,6 @@ import { EndpointMappings, ErrorHandler, TokenAccessFunction } from '../../types
|
|
|
4
4
|
import { ModelFetchRequestAction, PeriodicModelFetchRequestAction } from '../actions';
|
|
5
5
|
/** The total number of tries for `fetchData`, including the initial request. */
|
|
6
6
|
export declare const TRY_LIMIT = 5;
|
|
7
|
-
export declare const getState: (state?: any) => any;
|
|
8
7
|
export declare const matchesTerminationAction: (incomingAction: AnyAction, dataRequestAction: PeriodicModelFetchRequestAction) => boolean;
|
|
9
8
|
export declare const takeMatchesTerminationAction: (dataRequestAction: PeriodicModelFetchRequestAction) => (incomingAction: AnyAction) => boolean;
|
|
10
9
|
export declare const defaultTokenAccessFunction: TokenAccessFunction;
|
|
@@ -17,20 +16,20 @@ export declare function setEndpointMappings(endpointMappingsParam: EndpointMappi
|
|
|
17
16
|
*
|
|
18
17
|
* @param modelFetchRequestAction A model fetch request action with the request configuration
|
|
19
18
|
*/
|
|
20
|
-
export declare function
|
|
19
|
+
export declare function modelFetch(modelFetchRequestAction: ModelFetchRequestAction | PeriodicModelFetchRequestAction): SagaIterator;
|
|
21
20
|
/**
|
|
22
21
|
* The loop saga that makes the request every {action.period} milliseconds until cancelled
|
|
23
22
|
*
|
|
24
23
|
* @param action An action with the request configuration
|
|
25
24
|
*/
|
|
26
|
-
export declare function
|
|
25
|
+
export declare function modelFetchLoop(action: PeriodicModelFetchRequestAction): SagaIterator;
|
|
27
26
|
/**
|
|
28
27
|
* Call the fetchData saga every {action.period} milliseconds. This saga requires the 'period' and 'taskId' properties
|
|
29
28
|
* on the action parameter.
|
|
30
29
|
*
|
|
31
30
|
* @param action An action with the request configuration
|
|
32
31
|
*/
|
|
33
|
-
export declare function
|
|
32
|
+
export declare function modelFetchRecurring(action: PeriodicModelFetchRequestAction): SagaIterator;
|
|
34
33
|
/**
|
|
35
34
|
* The main saga for fetching models. Must be initialized with an EndpointMappings object that can be fetched
|
|
36
35
|
* and an API root to prepend to any partial URLs specified in the EndpointMappings object. A logger should normally be provided
|