dce-reactkit 2.0.3 → 2.0.4
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/AppWrapper.d.ts +19 -0
- package/lib/components/AppWrapper.js +127 -0
- package/lib/components/AppWrapper.js.map +1 -0
- package/lib/components/ErrorBox.d.ts +12 -0
- package/lib/components/ErrorBox.js +65 -0
- package/lib/components/ErrorBox.js.map +1 -0
- package/lib/helpers/handleError.d.ts +14 -0
- package/lib/helpers/handleError.js +54 -0
- package/lib/helpers/handleError.js.map +1 -0
- package/lib/helpers/handleSuccess.d.ts +8 -0
- package/lib/helpers/handleSuccess.js +20 -0
- package/lib/helpers/handleSuccess.js.map +1 -0
- package/lib/helpers/parseRequest.d.ts +21 -0
- package/lib/helpers/parseRequest.js +240 -0
- package/lib/helpers/parseRequest.js.map +1 -0
- package/lib/helpers/showFatalError.d.ts +2 -0
- package/lib/helpers/showFatalError.js +5 -0
- package/lib/helpers/showFatalError.js.map +1 -0
- package/lib/helpers/visitServerEndpoint.d.ts +7 -1
- package/lib/helpers/visitServerEndpoint.js +57 -6
- package/lib/helpers/visitServerEndpoint.js.map +1 -1
- package/lib/types/ParamType.d.ts +17 -0
- package/lib/types/ParamType.js +21 -0
- package/lib/types/ParamType.js.map +1 -0
- package/lib/types/ReactKitErrorCode.d.ts +5 -1
- package/lib/types/ReactKitErrorCode.js +4 -0
- package/lib/types/ReactKitErrorCode.js.map +1 -1
- package/package.json +2 -1
- package/src/components/AppWrapper.tsx +55 -5
- package/src/components/ErrorBox.tsx +4 -1
- package/src/helpers/handleError.ts +65 -0
- package/src/helpers/handleSuccess.ts +18 -0
- package/src/helpers/parseRequest.ts +299 -0
- package/src/helpers/visitServerEndpoint.tsx +52 -1
- package/src/types/ParamType.ts +18 -0
- package/src/types/ReactKitErrorCode.tsx +4 -0
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A wrapper for the entire React app that adds global functionality like
|
|
3
|
+
* handling for fatal error messages
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
declare type Props = {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
dark?: boolean;
|
|
10
|
+
sessionExpiredMessage?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Show a fatal error message
|
|
14
|
+
* @author Gabe Abrams
|
|
15
|
+
* @param error the error to show
|
|
16
|
+
*/
|
|
17
|
+
export declare const showFatalError: (error: any) => void;
|
|
18
|
+
declare const AppWrapper: (props: Props) => React.ReactNode;
|
|
19
|
+
export default AppWrapper;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.showFatalError = void 0;
|
|
18
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
/**
|
|
20
|
+
* A wrapper for the entire React app that adds global functionality like
|
|
21
|
+
* handling for fatal error messages
|
|
22
|
+
* @author Gabe Abrams
|
|
23
|
+
*/
|
|
24
|
+
// Import React
|
|
25
|
+
var react_1 = require("react");
|
|
26
|
+
// Import shared components
|
|
27
|
+
var ErrorBox_1 = __importDefault(require("./ErrorBox"));
|
|
28
|
+
// Import helpers
|
|
29
|
+
var visitServerEndpoint_1 = require("../helpers/visitServerEndpoint");
|
|
30
|
+
// Import shared types
|
|
31
|
+
var ReactKitErrorCode_1 = __importDefault(require("../types/ReactKitErrorCode"));
|
|
32
|
+
// Import custom errors
|
|
33
|
+
var ErrorWithCode_1 = __importDefault(require("../errors/ErrorWithCode"));
|
|
34
|
+
/*------------------------------------------------------------------------*/
|
|
35
|
+
/* Static Helpers */
|
|
36
|
+
/*------------------------------------------------------------------------*/
|
|
37
|
+
// Stored copies of setters
|
|
38
|
+
var setFatalErrorMessage;
|
|
39
|
+
var setFatalErrorCode;
|
|
40
|
+
/**
|
|
41
|
+
* Show a fatal error message
|
|
42
|
+
* @author Gabe Abrams
|
|
43
|
+
* @param error the error to show
|
|
44
|
+
*/
|
|
45
|
+
var showFatalError = function (error) {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
// Determine message and code
|
|
48
|
+
var message = (typeof error === 'string'
|
|
49
|
+
? error.trim()
|
|
50
|
+
: String((_a = error.message) !== null && _a !== void 0 ? _a : 'An unknown error occurred.'));
|
|
51
|
+
var code = (typeof error === 'string'
|
|
52
|
+
? ReactKitErrorCode_1.default.NoCode
|
|
53
|
+
: String((_b = error.code) !== null && _b !== void 0 ? _b : ReactKitErrorCode_1.default.NoCode));
|
|
54
|
+
// Handle case where app hasn't loaded
|
|
55
|
+
if (!setFatalErrorMessage || !setFatalErrorCode) {
|
|
56
|
+
return alert("An error has occurred: ".concat(message, " (code: ").concat(code, "). Please contact support."));
|
|
57
|
+
}
|
|
58
|
+
// Use setters
|
|
59
|
+
setFatalErrorMessage(message);
|
|
60
|
+
setFatalErrorCode(code);
|
|
61
|
+
};
|
|
62
|
+
exports.showFatalError = showFatalError;
|
|
63
|
+
/*------------------------------------------------------------------------*/
|
|
64
|
+
/* Component */
|
|
65
|
+
/*------------------------------------------------------------------------*/
|
|
66
|
+
var AppWrapper = function (props) {
|
|
67
|
+
/*------------------------------------------------------------------------*/
|
|
68
|
+
/* Setup */
|
|
69
|
+
/*------------------------------------------------------------------------*/
|
|
70
|
+
/* -------------- Props ------------- */
|
|
71
|
+
var children = props.children, dark = props.dark, _a = props.sessionExpiredMessage, sessionExpiredMessage = _a === void 0 ? 'Your session has expired. Please go back to Canvas and start over.' : _a;
|
|
72
|
+
/* -------------- State ------------- */
|
|
73
|
+
// Fatal error
|
|
74
|
+
var _b = (0, react_1.useState)(null), fatalErrorMessage = _b[0], setFatalErrorMessageInner = _b[1];
|
|
75
|
+
setFatalErrorMessage = setFatalErrorMessageInner;
|
|
76
|
+
var _c = (0, react_1.useState)(null), fatalErrorCode = _c[0], setFatalErrorCodeInner = _c[1];
|
|
77
|
+
setFatalErrorCode = setFatalErrorCodeInner;
|
|
78
|
+
// Session expired
|
|
79
|
+
var _d = (0, react_1.useState)(false), sessionHasExpired = _d[0], setSessionHasExpired = _d[1];
|
|
80
|
+
/*------------------------------------------------------------------------*/
|
|
81
|
+
/* Lifecycle Functions */
|
|
82
|
+
/*------------------------------------------------------------------------*/
|
|
83
|
+
/**
|
|
84
|
+
* Mount
|
|
85
|
+
* @author Gabe Abrams
|
|
86
|
+
*/
|
|
87
|
+
(0, react_1.useEffect)(function () {
|
|
88
|
+
// Add session expired handler
|
|
89
|
+
(0, visitServerEndpoint_1.setSessionExpiryHandler)(function () {
|
|
90
|
+
// Session expired!
|
|
91
|
+
setSessionHasExpired(true);
|
|
92
|
+
});
|
|
93
|
+
}, []);
|
|
94
|
+
/*------------------------------------------------------------------------*/
|
|
95
|
+
/* Render */
|
|
96
|
+
/*------------------------------------------------------------------------*/
|
|
97
|
+
/*----------------------------------------*/
|
|
98
|
+
/* Main UI */
|
|
99
|
+
/*----------------------------------------*/
|
|
100
|
+
// Show error
|
|
101
|
+
if (fatalErrorMessage || fatalErrorCode || sessionHasExpired) {
|
|
102
|
+
// Re-encapsulate in an error
|
|
103
|
+
var error = (sessionHasExpired
|
|
104
|
+
? new ErrorWithCode_1.default(fatalErrorMessage, fatalErrorCode)
|
|
105
|
+
: new ErrorWithCode_1.default(sessionExpiredMessage, ReactKitErrorCode_1.default.SessionExpired));
|
|
106
|
+
// Build error screen
|
|
107
|
+
return ((0, jsx_runtime_1.jsx)("div", __assign({ style: {
|
|
108
|
+
display: 'block',
|
|
109
|
+
width: '100vw',
|
|
110
|
+
minHeight: '100vh',
|
|
111
|
+
paddingTop: '10rem',
|
|
112
|
+
backgroundColor: (dark
|
|
113
|
+
? '#222'
|
|
114
|
+
: '#fff'),
|
|
115
|
+
} }, { children: (0, jsx_runtime_1.jsx)(ErrorBox_1.default, { title: (sessionHasExpired
|
|
116
|
+
? 'Session Expired'
|
|
117
|
+
: undefined), error: error }) })));
|
|
118
|
+
}
|
|
119
|
+
// Show the app itself
|
|
120
|
+
return children;
|
|
121
|
+
};
|
|
122
|
+
/*------------------------------------------------------------------------*/
|
|
123
|
+
/* Wrap Up */
|
|
124
|
+
/*------------------------------------------------------------------------*/
|
|
125
|
+
// Export component
|
|
126
|
+
exports.default = AppWrapper;
|
|
127
|
+
//# sourceMappingURL=AppWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppWrapper.js","sourceRoot":"","sources":["../../src/components/AppWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AAEH,eAAe;AACf,+BAAmD;AAEnD,2BAA2B;AAC3B,wDAAkC;AAElC,iBAAiB;AACjB,sEAAyE;AAEzE,sBAAsB;AACtB,iFAA2D;AAE3D,uBAAuB;AACvB,0EAAoD;AAepD,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,2BAA2B;AAC3B,IAAI,oBAA+C,CAAC;AACpD,IAAI,iBAAyC,CAAC;AAE9C;;;;GAIG;AACI,IAAM,cAAc,GAAG,UAAC,KAAU;;IACvC,6BAA6B;IAC7B,IAAM,OAAO,GAAW,CACtB,OAAO,KAAK,KAAK,QAAQ;QACvB,CAAC,CAAC,KAAK,CAAC,IAAI,EA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this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
+
// Import FontAwesome Icons
|
|
19
|
+
var react_fontawesome_1 = require("@fortawesome/react-fontawesome");
|
|
20
|
+
var free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
21
|
+
// Import shared types
|
|
22
|
+
var ReactKitErrorCode_1 = __importDefault(require("../types/ReactKitErrorCode"));
|
|
23
|
+
/*------------------------------------------------------------------------*/
|
|
24
|
+
/* Component */
|
|
25
|
+
/*------------------------------------------------------------------------*/
|
|
26
|
+
var ErrorBox = function (props) {
|
|
27
|
+
/*------------------------------------------------------------------------*/
|
|
28
|
+
/* Setup */
|
|
29
|
+
/*------------------------------------------------------------------------*/
|
|
30
|
+
var _a;
|
|
31
|
+
/* -------------- Props ------------- */
|
|
32
|
+
var error = props.error, _b = props.title, title = _b === void 0 ? 'An Error Occurred' : _b, onClose = props.onClose;
|
|
33
|
+
/*------------------------------------------------------------------------*/
|
|
34
|
+
/* Render */
|
|
35
|
+
/*------------------------------------------------------------------------*/
|
|
36
|
+
// Determine error text
|
|
37
|
+
var errorText = (typeof error === 'string'
|
|
38
|
+
? error.trim()
|
|
39
|
+
: String(error.message || 'An unknown error occurred. Please contact support.'));
|
|
40
|
+
// Error code box
|
|
41
|
+
var errorCodeBox;
|
|
42
|
+
if (error && error.code) {
|
|
43
|
+
errorCodeBox = ((0, jsx_runtime_1.jsxs)("span", { children: [' ', (0, jsx_runtime_1.jsxs)("span", __assign({ style: {
|
|
44
|
+
backgroundColor: 'white',
|
|
45
|
+
borderRadius: '5px',
|
|
46
|
+
paddingLeft: '3px',
|
|
47
|
+
paddingRight: '3px',
|
|
48
|
+
color: '#DC4150',
|
|
49
|
+
fontVariant: 'small-caps',
|
|
50
|
+
fontSize: '80%',
|
|
51
|
+
whiteSpace: 'nowrap',
|
|
52
|
+
} }, { children: ["code:", ' ', String((_a = error.code) !== null && _a !== void 0 ? _a : ReactKitErrorCode_1.default.NoCode).toUpperCase()] }))] }));
|
|
53
|
+
}
|
|
54
|
+
// Main UI
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)("div", __assign({ className: "alert alert-danger text-center", style: {
|
|
56
|
+
maxWidth: '650px',
|
|
57
|
+
margin: 'auto',
|
|
58
|
+
} }, { children: [(0, jsx_runtime_1.jsxs)("h4", __assign({ className: "mb-1" }, { children: [(0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faExclamationTriangle, className: "me-2" }), title] })), (0, jsx_runtime_1.jsxs)("div", { children: [errorText, errorCodeBox] }), onClose && ((0, jsx_runtime_1.jsx)("div", __assign({ className: "mt-2" }, { children: (0, jsx_runtime_1.jsx)("button", __assign({ type: "button", className: "btn btn-light", "aria-label": "dismiss error and close this activity or view", onClick: onClose }, { children: "Close" })) })))] })));
|
|
59
|
+
};
|
|
60
|
+
/*------------------------------------------------------------------------*/
|
|
61
|
+
/* Wrap Up */
|
|
62
|
+
/*------------------------------------------------------------------------*/
|
|
63
|
+
// Export component
|
|
64
|
+
exports.default = ErrorBox;
|
|
65
|
+
//# sourceMappingURL=ErrorBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBox.js","sourceRoot":"","sources":["../../src/components/ErrorBox.tsx"],"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ACf,iBAED,yCAAI,SAAS,EAAC,MAAM,iBAClB,uBAAC,mCAAe,IACd,IAAI,EAAE,4CAAqB,EAC3B,SAAS,EAAC,MAAM,GAChB,EACD,KAAK,KACH,EACL,4CACG,SAAS,EACT,YAAY,IACT,EACL,OAAO,IAAI,CACV,yCAAK,SAAS,EAAC,MAAM,gBACnB,4CACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,eAAe,gBACd,+CAA+C,EAC1D,OAAO,EAAE,OAAO,2BAGT,IACL,CACP,KACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,mBAAmB;AACnB,kBAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handle an error and respond to the client
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
* @param res express response
|
|
5
|
+
* @param error error info
|
|
6
|
+
* @param opts.err the error to send to the client
|
|
7
|
+
* or the error message
|
|
8
|
+
* @param [opts.code] an error code (only used if err.code is not
|
|
9
|
+
* included)
|
|
10
|
+
* @param [opts.status=500] the https status code to use
|
|
11
|
+
* defined)
|
|
12
|
+
*/
|
|
13
|
+
declare const handleError: (res: any, error: any) => undefined;
|
|
14
|
+
export default handleError;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
// Import shared types
|
|
7
|
+
var ReactKitErrorCode_1 = __importDefault(require("../types/ReactKitErrorCode"));
|
|
8
|
+
/**
|
|
9
|
+
* Handle an error and respond to the client
|
|
10
|
+
* @author Gabe Abrams
|
|
11
|
+
* @param res express response
|
|
12
|
+
* @param error error info
|
|
13
|
+
* @param opts.err the error to send to the client
|
|
14
|
+
* or the error message
|
|
15
|
+
* @param [opts.code] an error code (only used if err.code is not
|
|
16
|
+
* included)
|
|
17
|
+
* @param [opts.status=500] the https status code to use
|
|
18
|
+
* defined)
|
|
19
|
+
*/
|
|
20
|
+
var handleError = function (res, error) {
|
|
21
|
+
// Get the error message
|
|
22
|
+
var message;
|
|
23
|
+
if (error && error.message) {
|
|
24
|
+
message = (error.message || 'An unknown error occurred.');
|
|
25
|
+
}
|
|
26
|
+
else if (typeof error === 'string') {
|
|
27
|
+
message = (error.trim().length > 0
|
|
28
|
+
? error
|
|
29
|
+
: 'An unknown error occurred.');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
message = 'An unknown error occurred.';
|
|
33
|
+
}
|
|
34
|
+
// Get the error code
|
|
35
|
+
var code = (error.code || ReactKitErrorCode_1.default.NoCode);
|
|
36
|
+
// Get the status code
|
|
37
|
+
var status = (error.status || 500);
|
|
38
|
+
// Respond to user
|
|
39
|
+
res
|
|
40
|
+
// Set the http status code
|
|
41
|
+
.status(status)
|
|
42
|
+
// Send a JSON response
|
|
43
|
+
.json({
|
|
44
|
+
// Error message
|
|
45
|
+
message: message,
|
|
46
|
+
// Error code
|
|
47
|
+
code: code,
|
|
48
|
+
// Success = false flag so client can detect server-side errors
|
|
49
|
+
success: false,
|
|
50
|
+
});
|
|
51
|
+
return undefined;
|
|
52
|
+
};
|
|
53
|
+
exports.default = handleError;
|
|
54
|
+
//# sourceMappingURL=handleError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleError.js","sourceRoot":"","sources":["../../src/helpers/handleError.ts"],"names":[],"mappings":";;;;;AAAA,sBAAsB;AACtB,iFAA2D;AAE3D;;;;;;;;;;;GAWG;AACH,IAAM,WAAW,GAAG,UAClB,GAAQ,EACR,KASC;IAED,wBAAwB;IACxB,IAAI,OAAO,CAAC;IACZ,IAAI,KAAK,IAAK,KAAa,CAAC,OAAO,EAAE;QACnC,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,4BAA4B,CAAC,CAAC;KAC3D;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACpC,OAAO,GAAG,CACR,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;YACrB,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,4BAA4B,CACjC,CAAC;KACH;SAAM;QACL,OAAO,GAAG,4BAA4B,CAAC;KACxC;IAED,qBAAqB;IACrB,IAAM,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,2BAAiB,CAAC,MAAM,CAAC,CAAC;IAEtD,sBAAsB;IACtB,IAAM,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;IAErC,kBAAkB;IAClB,GAAG;QACD,2BAA2B;SAC1B,MAAM,CAAC,MAAM,CAAC;QACf,uBAAuB;SACtB,IAAI,CAAC;QACJ,gBAAgB;QAChB,OAAO,SAAA;QACP,aAAa;QACb,IAAI,MAAA;QACJ,+DAA+D;QAC/D,OAAO,EAAE,KAAK;KACf,CAAC,CAAC;IACL,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,kBAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Send successful API response
|
|
5
|
+
* @author Gabe Abrams
|
|
6
|
+
* @param res express response
|
|
7
|
+
* @param body the body of the response to send to the client
|
|
8
|
+
*/
|
|
9
|
+
var handleSuccess = function (res, body) {
|
|
10
|
+
// Send a http 200 json response
|
|
11
|
+
res.json({
|
|
12
|
+
// Include the body as a parameter
|
|
13
|
+
body: body,
|
|
14
|
+
// Success = true flag so client can detect successful responses
|
|
15
|
+
success: true,
|
|
16
|
+
});
|
|
17
|
+
return undefined;
|
|
18
|
+
};
|
|
19
|
+
exports.default = handleSuccess;
|
|
20
|
+
//# sourceMappingURL=handleSuccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleSuccess.js","sourceRoot":"","sources":["../../src/helpers/handleSuccess.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,IAAM,aAAa,GAAG,UAAC,GAAQ,EAAE,IAAS;IACxC,gCAAgC;IAChC,GAAG,CAAC,IAAI,CAAC;QACP,kCAAkC;QAClC,IAAI,MAAA;QACJ,gEAAgE;QAChE,OAAO,EAAE,IAAI;KACd,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import ParamType from '../types/ParamType';
|
|
2
|
+
/**
|
|
3
|
+
* Parse express request params and body
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
* @param opts object containing all arguments
|
|
6
|
+
* @param opts.req express request instance
|
|
7
|
+
* @param opts.res express response instance
|
|
8
|
+
* @param opts.params map of parameters that should be parsed out of the request
|
|
9
|
+
* @returns parsed params + user info from session (if it exists) or undefined
|
|
10
|
+
* if an error occurred
|
|
11
|
+
*/
|
|
12
|
+
declare const parseRequest: (opts: {
|
|
13
|
+
req: any;
|
|
14
|
+
res: any;
|
|
15
|
+
params: {
|
|
16
|
+
[x: string]: ParamType;
|
|
17
|
+
};
|
|
18
|
+
}) => {
|
|
19
|
+
[x: string]: any;
|
|
20
|
+
};
|
|
21
|
+
export default parseRequest;
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
// Import caccl libs
|
|
7
|
+
var caccl_lti_1 = require("caccl-lti");
|
|
8
|
+
// Import shared types
|
|
9
|
+
var ReactKitErrorCode_1 = __importDefault(require("../types/ReactKitErrorCode"));
|
|
10
|
+
var ParamType_1 = __importDefault(require("../types/ParamType"));
|
|
11
|
+
// Import helpers
|
|
12
|
+
var handleError_1 = __importDefault(require("./handleError"));
|
|
13
|
+
/**
|
|
14
|
+
* Parse express request params and body
|
|
15
|
+
* @author Gabe Abrams
|
|
16
|
+
* @param opts object containing all arguments
|
|
17
|
+
* @param opts.req express request instance
|
|
18
|
+
* @param opts.res express response instance
|
|
19
|
+
* @param opts.params map of parameters that should be parsed out of the request
|
|
20
|
+
* @returns parsed params + user info from session (if it exists) or undefined
|
|
21
|
+
* if an error occurred
|
|
22
|
+
*/
|
|
23
|
+
var parseRequest = function (opts) {
|
|
24
|
+
// Output
|
|
25
|
+
var output = {};
|
|
26
|
+
/*----------------------------------------*/
|
|
27
|
+
/* Parse Params */
|
|
28
|
+
/*----------------------------------------*/
|
|
29
|
+
// Process items one by one
|
|
30
|
+
var paramList = Object.entries(opts.params);
|
|
31
|
+
for (var i = 0; i < paramList.length; i++) {
|
|
32
|
+
var _a = paramList[i], name_1 = _a[0], type = _a[1];
|
|
33
|
+
// Find the value as a string
|
|
34
|
+
var value = (opts.req.params[name_1]
|
|
35
|
+
|| opts.req.query[name_1]
|
|
36
|
+
|| opts.req.body[name_1]);
|
|
37
|
+
// Parse
|
|
38
|
+
if (type === ParamType_1.default.Boolean || type === ParamType_1.default.BooleanOptional) {
|
|
39
|
+
// Boolean
|
|
40
|
+
// Handle case where value doesn't exist
|
|
41
|
+
if (value === undefined) {
|
|
42
|
+
if (type === ParamType_1.default.BooleanOptional) {
|
|
43
|
+
output[name_1] = undefined;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return (0, handleError_1.default)(opts.res, {
|
|
47
|
+
message: "Parameter ".concat(name_1, " is required, but it was not included."),
|
|
48
|
+
code: ReactKitErrorCode_1.default.MissingParameter,
|
|
49
|
+
status: 422,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// Value exists
|
|
55
|
+
// Simplify value
|
|
56
|
+
var simpleVal = (String(value)
|
|
57
|
+
.trim()
|
|
58
|
+
.toLowerCase());
|
|
59
|
+
// Parse
|
|
60
|
+
output[name_1] = ([
|
|
61
|
+
'true',
|
|
62
|
+
'yes',
|
|
63
|
+
'y',
|
|
64
|
+
'1',
|
|
65
|
+
't',
|
|
66
|
+
].indexOf(simpleVal) >= 0);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else if (type === ParamType_1.default.Float || type === ParamType_1.default.FloatOptional) {
|
|
70
|
+
// Float
|
|
71
|
+
// Handle case where value doesn't exist
|
|
72
|
+
if (value === undefined) {
|
|
73
|
+
if (type === ParamType_1.default.FloatOptional) {
|
|
74
|
+
output[name_1] = undefined;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return (0, handleError_1.default)(opts.res, {
|
|
78
|
+
message: "Parameter ".concat(name_1, " is required, but it was not included."),
|
|
79
|
+
code: ReactKitErrorCode_1.default.MissingParameter,
|
|
80
|
+
status: 422,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else if (!Number.isNaN(Number.parseFloat(String(value)))) {
|
|
85
|
+
// Value is a number
|
|
86
|
+
output[name_1] = Number.parseFloat(String(value));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Issue!
|
|
90
|
+
return (0, handleError_1.default)(opts.res, {
|
|
91
|
+
message: "Request data was malformed: ".concat(name_1, " was not a valid float."),
|
|
92
|
+
code: ReactKitErrorCode_1.default.InvalidParameter,
|
|
93
|
+
status: 422,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (type === ParamType_1.default.Int || type === ParamType_1.default.IntOptional) {
|
|
98
|
+
// Int
|
|
99
|
+
// Handle case where value doesn't exist
|
|
100
|
+
if (value === undefined) {
|
|
101
|
+
if (type === ParamType_1.default.IntOptional) {
|
|
102
|
+
output[name_1] = undefined;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return (0, handleError_1.default)(opts.res, {
|
|
106
|
+
message: "Parameter ".concat(name_1, " is required, but it was not included."),
|
|
107
|
+
code: ReactKitErrorCode_1.default.MissingParameter,
|
|
108
|
+
status: 422,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else if (!Number.isNaN(Number.parseInt(String(value), 10))) {
|
|
113
|
+
// Value is a number
|
|
114
|
+
output[name_1] = Number.parseInt(String(value), 10);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// Issue!
|
|
118
|
+
return (0, handleError_1.default)(opts.res, {
|
|
119
|
+
message: "Request data was malformed: ".concat(name_1, " was not a valid int."),
|
|
120
|
+
code: ReactKitErrorCode_1.default.InvalidParameter,
|
|
121
|
+
status: 422,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else if (type === ParamType_1.default.JSON || type === ParamType_1.default.JSONOptional) {
|
|
126
|
+
// Stringified JSON
|
|
127
|
+
// Handle case where value doesn't exist
|
|
128
|
+
if (value === undefined) {
|
|
129
|
+
if (type === ParamType_1.default.JSONOptional) {
|
|
130
|
+
output[name_1] = undefined;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
return (0, handleError_1.default)(opts.res, {
|
|
134
|
+
message: "Parameter ".concat(name_1, " is required, but it was not included."),
|
|
135
|
+
code: ReactKitErrorCode_1.default.MissingParameter,
|
|
136
|
+
status: 422,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
// Value exists
|
|
142
|
+
// Parse
|
|
143
|
+
try {
|
|
144
|
+
output[name_1] = JSON.parse(String(value));
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
return (0, handleError_1.default)(opts.res, {
|
|
148
|
+
message: "Request data was malformed: ".concat(name_1, " was not a valid JSON payload."),
|
|
149
|
+
code: ReactKitErrorCode_1.default.InvalidParameter,
|
|
150
|
+
status: 422,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else if (type === ParamType_1.default.String || type === ParamType_1.default.StringOptional) {
|
|
156
|
+
// String
|
|
157
|
+
// Handle case where value doesn't exist
|
|
158
|
+
if (value === undefined) {
|
|
159
|
+
if (type === ParamType_1.default.StringOptional) {
|
|
160
|
+
output[name_1] = undefined;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
return (0, handleError_1.default)(opts.res, {
|
|
164
|
+
message: "Parameter ".concat(name_1, " is required, but it was not included."),
|
|
165
|
+
code: ReactKitErrorCode_1.default.MissingParameter,
|
|
166
|
+
status: 422,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
// Value exists
|
|
172
|
+
// Leave as is
|
|
173
|
+
output[name_1] = value;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
// No valid data type
|
|
178
|
+
return (0, handleError_1.default)(opts.res, {
|
|
179
|
+
message: "An internal error occurred: we could not determine the type of ".concat(name_1, "."),
|
|
180
|
+
code: ReactKitErrorCode_1.default.InvalidParameter,
|
|
181
|
+
status: 422,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/*----------------------------------------*/
|
|
186
|
+
/* Launch Info */
|
|
187
|
+
/*----------------------------------------*/
|
|
188
|
+
// Get launch info
|
|
189
|
+
var _b = (0, caccl_lti_1.getLaunchInfo)(opts.req), launched = _b.launched, launchInfo = _b.launchInfo;
|
|
190
|
+
if (!launched || !launchInfo) {
|
|
191
|
+
return (0, handleError_1.default)(opts.res, {
|
|
192
|
+
message: 'Your session has expired. Please refresh the page and try again.',
|
|
193
|
+
code: ReactKitErrorCode_1.default.SessionExpired,
|
|
194
|
+
status: 440,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
// Error if user info cannot be found
|
|
198
|
+
if (!launchInfo.userId
|
|
199
|
+
|| !launchInfo.userFirstName
|
|
200
|
+
|| !launchInfo.userLastName
|
|
201
|
+
|| (launchInfo.notInCourse
|
|
202
|
+
&& !launchInfo.isAdmin)
|
|
203
|
+
|| (!launchInfo.isTTM
|
|
204
|
+
&& !launchInfo.isLearner
|
|
205
|
+
&& !launchInfo.isAdmin)) {
|
|
206
|
+
return (0, handleError_1.default)(opts.res, {
|
|
207
|
+
message: 'Your session was invalid. Please refresh the page and try again.',
|
|
208
|
+
code: ReactKitErrorCode_1.default.SessionExpired,
|
|
209
|
+
status: 440,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
// Add launch info to output
|
|
213
|
+
output.userId = launchInfo.userId;
|
|
214
|
+
output.userFirstName = launchInfo.userFirstName;
|
|
215
|
+
output.userLastName = launchInfo.userLastName;
|
|
216
|
+
output.isLearner = !!launchInfo.isLearner;
|
|
217
|
+
output.isTTM = !!launchInfo.isTTM;
|
|
218
|
+
output.isAdmin = !!launchInfo.isAdmin;
|
|
219
|
+
output.isWatchingInPrivate = !!(opts.req.session.isWatchingInPrivate);
|
|
220
|
+
/*----------------------------------------*/
|
|
221
|
+
/* Require Course Consistency */
|
|
222
|
+
/*----------------------------------------*/
|
|
223
|
+
// Make sure the user actually launched from the appropriate course
|
|
224
|
+
if (output.courseId
|
|
225
|
+
&& launchInfo.courseId
|
|
226
|
+
&& output.courseId !== launchInfo.courseId
|
|
227
|
+
&& !output.isTTM
|
|
228
|
+
&& !output.isAdmin) {
|
|
229
|
+
// Course of interest is not the launch course
|
|
230
|
+
return (0, handleError_1.default)(opts.res, {
|
|
231
|
+
message: 'You switched sessions by opening Immersive Classroom in another tab. Please refresh the page and try again.',
|
|
232
|
+
code: ReactKitErrorCode_1.default.WrongCourse,
|
|
233
|
+
status: 401,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
// Return processed params
|
|
237
|
+
return output;
|
|
238
|
+
};
|
|
239
|
+
exports.default = parseRequest;
|
|
240
|
+
//# sourceMappingURL=parseRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseRequest.js","sourceRoot":"","sources":["../../src/helpers/parseRequest.ts"],"names":[],"mappings":";;;;;AAAA,oBAAoB;AACpB,uCAA0C;AAE1C,sBAAsB;AACtB,iFAA2D;AAC3D,iEAA2C;AAE3C,iBAAiB;AACjB,8DAAwC;AAExC;;;;;;;;;GASG;AACH,IAAM,YAAY,GAAG,UACnB,IAMC;IAED,SAAS;IAET,IAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAE5C,2BAA2B;IAC3B,IAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACnC,IAAA,KAAe,SAAS,CAAC,CAAC,CAAC,EAA1B,MAAI,QAAA,EAAE,IAAI,QAAgB,CAAC;QAElC,6BAA6B;QAC7B,IAAM,KAAK,GAAG,CACZ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAI,CAAC;eAClB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAI,CAAC;eACpB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAI,CAAC,CACvB,CAAC;QAEF,QAAQ;QACR,IAAI,IAAI,KAAK,mBAAS,CAAC,OAAO,IAAI,IAAI,KAAK,mBAAS,CAAC,eAAe,EAAE;YACpE,UAAU;YAEV,wCAAwC;YACxC,IAAI,KAAK,KAAK,SAAS,EAAE;gBACvB,IAAI,IAAI,KAAK,mBAAS,CAAC,eAAe,EAAE;oBACtC,MAAM,CAAC,MAAI,CAAC,GAAG,SAAS,CAAC;iBAC1B;qBAAM;oBACL,OAAO,IAAA,qBAAW,EAChB,IAAI,CAAC,GAAG,EACR;wBAC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1C,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;IAClC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC;IACtC,MAAM,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEtE,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAE5C,mEAAmE;IACnE,IACE,MAAM,CAAC,QAAQ;WACZ,UAAU,CAAC,QAAQ;WACnB,MAAM,CAAC,QAAQ,KAAK,UAAU,CAAC,QAAQ;WACvC,CAAC,MAAM,CAAC,KAAK;WACb,CAAC,MAAM,CAAC,OAAO,EAClB;QACA,8CAA8C;QAC9C,OAAO,IAAA,qBAAW,EAChB,IAAI,CAAC,GAAG,EACR;YACE,OAAO,EAAE,6GAA6G;YACtH,IAAI,EAAE,2BAAiB,CAAC,WAAW;YACnC,MAAM,EAAE,GAAG;SACZ,CACF,CAAC;KACH;IAED,0BAA0B;IAC1B,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"showFatalError.js","sourceRoot":"","sources":["../../src/helpers/showFatalError.tsx"],"names":[],"mappings":";;AAAA,uDAA0D;AAE1D,kBAAe,2BAAc,CAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Set the session expiry handler
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
* @param handler new handler to use when session expires
|
|
5
|
+
*/
|
|
6
|
+
export declare const setSessionExpiryHandler: (handler: () => void) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Visit an endpoint on the server [for client only]
|
|
3
9
|
* @author Gabe Abrams
|
|
4
10
|
* @param opts object containing all arguments
|
|
5
11
|
* @param opts.path - the path of the server endpoint
|