dce-reactkit 3.6.24 → 3.6.26
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/index.js +31 -14
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/helpers/genRouteHandler.d.ts +7 -1
- package/dist/cjs/types/html/genInfoPage.d.ts +12 -0
- package/dist/esm/index.js +31 -14
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/helpers/genRouteHandler.d.ts +7 -1
- package/dist/esm/types/html/genInfoPage.d.ts +12 -0
- package/dist/index.d.ts +7 -1
- package/package.json +1 -1
- package/src/helpers/genRouteHandler.ts +35 -1
- package/src/html/genInfoPage.ts +100 -0
package/dist/cjs/index.js
CHANGED
|
@@ -42187,16 +42187,18 @@ const parseUserAgent = (userAgent) => {
|
|
|
42187
42187
|
* send (a function that sends a string to the client),
|
|
42188
42188
|
* redirect (takes a url and redirects the user to that url),
|
|
42189
42189
|
* renderErrorPage (shows a static error page to the user),
|
|
42190
|
+
* renderInfoPage (shows a static info page to the user),
|
|
42190
42191
|
* and returns the value to send to the client as a JSON API response, or
|
|
42191
42192
|
* calls next() or redirect(...) or send(...) or renderErrorPage(...).
|
|
42192
42193
|
* Note: params also has userId, userFirstName,
|
|
42193
|
-
* userLastName, isLearner, isTTM, isAdmin,
|
|
42194
|
+
* userLastName, userEmail, userAvatarURL, isLearner, isTTM, isAdmin,
|
|
42195
|
+
* and any other variables that
|
|
42194
42196
|
* are directly added to the session, if the user does have a session.
|
|
42195
42197
|
*/
|
|
42196
42198
|
const genRouteHandler = (opts) => {
|
|
42197
42199
|
// Return a route handler
|
|
42198
42200
|
return (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42199
|
-
var _a, _b;
|
|
42201
|
+
var _a, _b, _c;
|
|
42200
42202
|
// Output params
|
|
42201
42203
|
const output = {};
|
|
42202
42204
|
/*----------------------------------------*/
|
|
@@ -42407,6 +42409,9 @@ const genRouteHandler = (opts) => {
|
|
|
42407
42409
|
output.userEmail = (launchInfo
|
|
42408
42410
|
? launchInfo.userEmail
|
|
42409
42411
|
: undefined);
|
|
42412
|
+
output.userAvatarURL = (launchInfo
|
|
42413
|
+
? ((_b = launchInfo.userImage) !== null && _b !== void 0 ? _b : 'http://www.gravatar.com/avatar/?d=identicon')
|
|
42414
|
+
: undefined);
|
|
42410
42415
|
output.isLearner = (launchInfo
|
|
42411
42416
|
? !!launchInfo.isLearner
|
|
42412
42417
|
: undefined);
|
|
@@ -42417,7 +42422,7 @@ const genRouteHandler = (opts) => {
|
|
|
42417
42422
|
? !!launchInfo.isAdmin
|
|
42418
42423
|
: undefined);
|
|
42419
42424
|
output.courseId = (launchInfo
|
|
42420
|
-
? ((
|
|
42425
|
+
? ((_c = output.courseId) !== null && _c !== void 0 ? _c : launchInfo.courseId)
|
|
42421
42426
|
: undefined);
|
|
42422
42427
|
output.courseName = (launchInfo
|
|
42423
42428
|
? launchInfo.contextLabel
|
|
@@ -42495,7 +42500,7 @@ const genRouteHandler = (opts) => {
|
|
|
42495
42500
|
* @author Gabe Abrams
|
|
42496
42501
|
*/
|
|
42497
42502
|
const logServerEvent = (logOpts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42498
|
-
var
|
|
42503
|
+
var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
42499
42504
|
// NOTE: internally, we slip through an opts.overrideAsClientEvent boolean
|
|
42500
42505
|
// that indicates that this is actually a client event, but we don't
|
|
42501
42506
|
// include that in the LogFunction type because this is internal and
|
|
@@ -42527,24 +42532,24 @@ const genRouteHandler = (opts) => {
|
|
|
42527
42532
|
timestamp,
|
|
42528
42533
|
context: (typeof logOpts.context === 'string'
|
|
42529
42534
|
? logOpts.context
|
|
42530
|
-
: ((
|
|
42531
|
-
subcontext: ((
|
|
42532
|
-
tags: ((
|
|
42533
|
-
level: ((
|
|
42534
|
-
metadata: ((
|
|
42535
|
+
: ((_e = ((_d = logOpts.context) !== null && _d !== void 0 ? _d : {})._) !== null && _e !== void 0 ? _e : LogBuiltInMetadata.Context.Uncategorized)),
|
|
42536
|
+
subcontext: ((_f = logOpts.subcontext) !== null && _f !== void 0 ? _f : LogBuiltInMetadata.Context.Uncategorized),
|
|
42537
|
+
tags: ((_g = logOpts.tags) !== null && _g !== void 0 ? _g : []),
|
|
42538
|
+
level: ((_h = logOpts.level) !== null && _h !== void 0 ? _h : LogLevel$1.Info),
|
|
42539
|
+
metadata: ((_j = logOpts.metadata) !== null && _j !== void 0 ? _j : {}),
|
|
42535
42540
|
};
|
|
42536
42541
|
// Type-specific info
|
|
42537
42542
|
const typeSpecificInfo = (('error' in opts && opts.error)
|
|
42538
42543
|
? {
|
|
42539
42544
|
type: LogType$1.Error,
|
|
42540
|
-
errorMessage: (
|
|
42541
|
-
errorCode: (
|
|
42542
|
-
errorStack: (
|
|
42545
|
+
errorMessage: (_k = logOpts.error.message) !== null && _k !== void 0 ? _k : 'Unknown message',
|
|
42546
|
+
errorCode: (_l = logOpts.error.code) !== null && _l !== void 0 ? _l : ReactKitErrorCode$1.NoCode,
|
|
42547
|
+
errorStack: (_m = logOpts.error.stack) !== null && _m !== void 0 ? _m : 'No stack',
|
|
42543
42548
|
}
|
|
42544
42549
|
: {
|
|
42545
42550
|
type: LogType$1.Action,
|
|
42546
|
-
target: ((
|
|
42547
|
-
action: ((
|
|
42551
|
+
target: ((_o = logOpts.target) !== null && _o !== void 0 ? _o : LogBuiltInMetadata.Target.NoTarget),
|
|
42552
|
+
action: ((_p = logOpts.action) !== null && _p !== void 0 ? _p : LogAction$1.Unknown),
|
|
42548
42553
|
});
|
|
42549
42554
|
// Source-specific info
|
|
42550
42555
|
const sourceSpecificInfo = (logOpts.overrideAsClientEvent
|
|
@@ -42683,6 +42688,17 @@ const genRouteHandler = (opts) => {
|
|
|
42683
42688
|
},
|
|
42684
42689
|
});
|
|
42685
42690
|
};
|
|
42691
|
+
/**
|
|
42692
|
+
* Render an info page
|
|
42693
|
+
* @author Gabe Abrams
|
|
42694
|
+
* @param renderOpts object containing all arguments
|
|
42695
|
+
* @param renderOpts.title title of the info box
|
|
42696
|
+
* @param renderOpts.body a human-readable text body for the info alert
|
|
42697
|
+
*/
|
|
42698
|
+
const renderInfoPage = (renderOpts) => {
|
|
42699
|
+
const html = genErrorPage(renderOpts);
|
|
42700
|
+
send(html, 200);
|
|
42701
|
+
};
|
|
42686
42702
|
// Call the handler
|
|
42687
42703
|
try {
|
|
42688
42704
|
const results = yield opts.handler({
|
|
@@ -42695,6 +42711,7 @@ const genRouteHandler = (opts) => {
|
|
|
42695
42711
|
},
|
|
42696
42712
|
redirect,
|
|
42697
42713
|
renderErrorPage,
|
|
42714
|
+
renderInfoPage,
|
|
42698
42715
|
logServerEvent,
|
|
42699
42716
|
});
|
|
42700
42717
|
// Send results to client (only if next wasn't called)
|