dce-reactkit 3.12.3 → 4.0.0-beta-logreviewer.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.
Files changed (88) hide show
  1. package/dist/cjs/index.js +8550 -8958
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/components/LoadingSpinner.d.ts +2 -2
  4. package/dist/cjs/types/components/Pagination.d.ts +9 -0
  5. package/dist/cjs/types/components/Tooltip.d.ts +1 -1
  6. package/dist/cjs/types/constants/LOG_REVIEW_GET_LOGS_ROUTE.d.ts +6 -0
  7. package/dist/cjs/types/helpers/cloneDeep.d.ts +8 -0
  8. package/dist/cjs/types/index.d.ts +14 -11
  9. package/dist/cjs/types/types/LogReviewerFilterState/ActionErrorFilterState.d.ts +13 -0
  10. package/dist/cjs/types/types/LogReviewerFilterState/AdvancedFilterState.d.ts +17 -0
  11. package/dist/cjs/types/types/LogReviewerFilterState/ContextFilterState.d.ts +6 -0
  12. package/dist/cjs/types/types/LogReviewerFilterState/DateFilterState.d.ts +13 -0
  13. package/dist/cjs/types/types/LogReviewerFilterState/TagFilterState.d.ts +4 -0
  14. package/dist/cjs/types/types/LogReviewerFilterState/index.d.ts +17 -0
  15. package/dist/cjs/types/types/ParamType.d.ts +10 -10
  16. package/dist/cjs/types/types/ReactKitErrorCode.d.ts +1 -15
  17. package/dist/esm/index.js +8544 -8950
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/types/components/LoadingSpinner.d.ts +2 -2
  20. package/dist/esm/types/components/Pagination.d.ts +9 -0
  21. package/dist/esm/types/components/Tooltip.d.ts +1 -1
  22. package/dist/esm/types/constants/LOG_REVIEW_GET_LOGS_ROUTE.d.ts +6 -0
  23. package/dist/esm/types/helpers/cloneDeep.d.ts +8 -0
  24. package/dist/esm/types/index.d.ts +14 -11
  25. package/dist/esm/types/types/LogReviewerFilterState/ActionErrorFilterState.d.ts +13 -0
  26. package/dist/esm/types/types/LogReviewerFilterState/AdvancedFilterState.d.ts +17 -0
  27. package/dist/esm/types/types/LogReviewerFilterState/ContextFilterState.d.ts +6 -0
  28. package/dist/esm/types/types/LogReviewerFilterState/DateFilterState.d.ts +13 -0
  29. package/dist/esm/types/types/LogReviewerFilterState/TagFilterState.d.ts +4 -0
  30. package/dist/esm/types/types/LogReviewerFilterState/index.d.ts +17 -0
  31. package/dist/esm/types/types/ParamType.d.ts +10 -10
  32. package/dist/esm/types/types/ReactKitErrorCode.d.ts +1 -15
  33. package/dist/index.d.ts +218 -336
  34. package/package.json +6 -8
  35. package/src/components/AppWrapper.tsx +3 -1
  36. package/src/components/CheckboxButton.tsx +1 -1
  37. package/src/components/Dropdown.tsx +1 -1
  38. package/src/components/LogReviewer.tsx +1133 -1307
  39. package/src/components/Modal/index.tsx +1 -1
  40. package/src/components/Pagination.tsx +162 -0
  41. package/src/components/RadioButton.tsx +3 -1
  42. package/src/components/Tooltip.tsx +1 -1
  43. package/src/constants/LOG_REVIEW_GET_LOGS_ROUTE.ts +9 -0
  44. package/src/helpers/cloneDeep.ts +11 -0
  45. package/src/{client → helpers}/initClient.tsx +5 -1
  46. package/src/helpers/logClientEvent.tsx +3 -1
  47. package/src/helpers/visitServerEndpoint.tsx +1 -1
  48. package/src/index.ts +24 -20
  49. package/src/types/LogReviewerFilterState/ActionErrorFilterState.ts +21 -0
  50. package/src/types/LogReviewerFilterState/AdvancedFilterState.ts +33 -0
  51. package/src/types/LogReviewerFilterState/ContextFilterState.ts +13 -0
  52. package/src/types/LogReviewerFilterState/DateFilterState.ts +23 -0
  53. package/src/types/LogReviewerFilterState/TagFilterState.ts +6 -0
  54. package/src/types/LogReviewerFilterState/index.ts +24 -0
  55. package/src/types/ParamType.ts +10 -10
  56. package/src/types/ReactKitErrorCode.tsx +1 -17
  57. package/dist/cjs/types/components/ItemPicker/index.test.d.ts +0 -1
  58. package/dist/cjs/types/helpers/addDBEditorEndpoints.d.ts +0 -41
  59. package/dist/cjs/types/helpers/genRouteHandler.d.ts +0 -76
  60. package/dist/cjs/types/helpers/handleError.d.ts +0 -18
  61. package/dist/cjs/types/helpers/handleSuccess.d.ts +0 -8
  62. package/dist/cjs/types/helpers/parseUserAgent.d.ts +0 -17
  63. package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/index.d.ts +0 -24
  64. package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +0 -33
  65. package/dist/cjs/types/server/initLogCollection.d.ts +0 -8
  66. package/dist/cjs/types/server/initServer.d.ts +0 -42
  67. package/dist/esm/types/components/ItemPicker/index.test.d.ts +0 -1
  68. package/dist/esm/types/helpers/addDBEditorEndpoints.d.ts +0 -41
  69. package/dist/esm/types/helpers/genRouteHandler.d.ts +0 -76
  70. package/dist/esm/types/helpers/handleError.d.ts +0 -18
  71. package/dist/esm/types/helpers/handleSuccess.d.ts +0 -8
  72. package/dist/esm/types/helpers/parseUserAgent.d.ts +0 -17
  73. package/dist/esm/types/helpers/visitEndpointOnAnotherServer/index.d.ts +0 -24
  74. package/dist/esm/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +0 -33
  75. package/dist/esm/types/server/initLogCollection.d.ts +0 -8
  76. package/dist/esm/types/server/initServer.d.ts +0 -42
  77. package/src/components/ItemPicker/index.test.tsx +0 -783
  78. package/src/helpers/addDBEditorEndpoints.ts +0 -128
  79. package/src/helpers/genRouteHandler.ts +0 -948
  80. package/src/helpers/handleError.ts +0 -65
  81. package/src/helpers/handleSuccess.ts +0 -18
  82. package/src/helpers/parseUserAgent.ts +0 -108
  83. package/src/helpers/visitEndpointOnAnotherServer/index.ts +0 -93
  84. package/src/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.ts +0 -164
  85. package/src/server/initLogCollection.ts +0 -27
  86. package/src/server/initServer.ts +0 -287
  87. /package/dist/cjs/types/{client → helpers}/initClient.d.ts +0 -0
  88. /package/dist/esm/types/{client → helpers}/initClient.d.ts +0 -0
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import React$1 from 'react';
3
3
  import { IconProp } from '@fortawesome/fontawesome-svg-core';
4
- import express from 'express';
5
4
 
6
5
  /**
7
6
  * Bootstrap variants
@@ -113,7 +112,8 @@ declare const AppWrapper: React$1.FC<Props$l>;
113
112
  * Loading spinner/indicator
114
113
  * @author Gabe Abrams
115
114
  */
116
- declare const LoadingSpinner: () => JSX.Element;
115
+
116
+ declare const LoadingSpinner: () => React$1.JSX.Element;
117
117
 
118
118
  /**
119
119
  * Displays an error
@@ -473,16 +473,16 @@ declare const LogReviewer: React$1.FC<Props$8>;
473
473
  * @author Gabe Abrams
474
474
  */
475
475
  declare enum ParamType {
476
- Boolean = "boolean",
477
- BooleanOptional = "boolean-optional",
478
- Float = "float",
479
- FloatOptional = "float-optional",
480
- Int = "int",
481
- IntOptional = "int-optional",
482
- JSON = "json",
483
- JSONOptional = "json-optional",
484
- String = "string",
485
- StringOptional = "string-optional"
476
+ Boolean = "Boolean",
477
+ BooleanOptional = "BooleanOptional",
478
+ Float = "Float",
479
+ FloatOptional = "FloatOptional",
480
+ Int = "Int",
481
+ IntOptional = "IntOptional",
482
+ JSON = "JSON",
483
+ JSONOptional = "JSONOptional",
484
+ String = "String",
485
+ StringOptional = "StringOptional"
486
486
  }
487
487
 
488
488
  /**
@@ -641,7 +641,7 @@ declare const DBEntryManagerPanel: React$1.FC<Props$5>;
641
641
 
642
642
  type Props$4 = {
643
643
  text: string;
644
- children: JSX.Element;
644
+ children: any;
645
645
  };
646
646
  declare const Tooltip: React$1.FC<Props$4>;
647
647
 
@@ -774,6 +774,31 @@ declare const HOUR_IN_MS = 3600000;
774
774
  */
775
775
  declare const DAY_IN_MS = 86400000;
776
776
 
777
+ /**
778
+ * Path of the route for storing client-side logs
779
+ * @author Gabe Abrams
780
+ */
781
+ declare const LOG_REVIEW_ROUTE_PATH_PREFIX: string;
782
+
783
+ /**
784
+ * Path of the route for storing client-side logs
785
+ * @author Gabe Abrams
786
+ */
787
+ declare const LOG_ROUTE_PATH: string;
788
+
789
+ /**
790
+ * Route for checking the status of the current user's
791
+ * access to log review
792
+ * @author Gabe Abrams
793
+ */
794
+ declare const LOG_REVIEW_STATUS_ROUTE: string;
795
+
796
+ /**
797
+ * Path of the route for getting logs for log review
798
+ * @author Gabe Abrams
799
+ */
800
+ declare const LOG_REVIEW_GET_LOGS_ROUTE: string;
801
+
777
802
  /**
778
803
  * Dynamic words determined by the user's platform
779
804
  * @author Gabe Abrams
@@ -935,6 +960,106 @@ declare const visitServerEndpoint: (opts: {
935
960
  } | undefined;
936
961
  }) => Promise<any>;
937
962
 
963
+ /**
964
+ * Get a number's ordinal
965
+ * @author Gabe Abrams
966
+ * @param num the number being analyzed
967
+ * @returns ordinal
968
+ */
969
+ declare const getOrdinal: (num: number) => string;
970
+
971
+ /**
972
+ * Get current time info in US Boston Eastern Time, independent of machine
973
+ * timezone
974
+ * @author Gabe Abrams
975
+ * @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
976
+ * @returns object with timestamp (ms since epoch) and numbers
977
+ * corresponding to ET time values for year, month, day, hour, hour12, minute, isPM
978
+ * where hour is in 24hr time and hour12 is in 12hr time.
979
+ */
980
+ declare const getTimeInfoInET: (dateOrTimestamp?: Date | number) => {
981
+ timestamp: number;
982
+ year: number;
983
+ month: number;
984
+ day: number;
985
+ hour: number;
986
+ hour12: number;
987
+ minute: number;
988
+ isPM: boolean;
989
+ };
990
+
991
+ /**
992
+ * Stub a server endpoint response
993
+ * @author Gabe Abrams
994
+ * @param opts object containing all arguments
995
+ * @param [opts.method=GET] http method to stub
996
+ * @param opts.path full pathname to stub
997
+ * @param opts.body body of response if stubbing a successful response
998
+ * @param opts.errorMessage message of error if stubbing a failed response
999
+ * @param [opts.errorCode] error code if stubbing a failed response
1000
+ */
1001
+ declare const stubServerEndpoint: (opts: {
1002
+ method?: string | undefined;
1003
+ path: string;
1004
+ body?: any;
1005
+ errorMessage?: string | undefined;
1006
+ errorCode?: string | undefined;
1007
+ }) => void;
1008
+
1009
+ /**
1010
+ * Start a dynamic wait, call the function once the operation has completed and
1011
+ * the dynamic wait will continue waiting for the rest of the minimum time
1012
+ * @author Gabe Abrams
1013
+ * @param minWaitMs the minimum number of ms to wait
1014
+ * @returns async function to call to finish the wait
1015
+ */
1016
+ declare const startMinWait: (minWaitMs: number) => () => Promise<void>;
1017
+
1018
+ /**
1019
+ * Get a human-readable description of a date (all in ET)
1020
+ * @author Gabe Abrams
1021
+ * @param [dateOrTimestamp=today] the date or timestamp for the date to describe
1022
+ * @returns human-readable description of the date
1023
+ */
1024
+ declare const getHumanReadableDate: (dateOrTimestamp?: Date | number) => string;
1025
+
1026
+ /**
1027
+ * Get the current part of day (morning, evening, etc.)
1028
+ * @author Gabe Abrams
1029
+ * @returns the part of day (morning, evening, etc.)
1030
+ */
1031
+ declare const getPartOfDay: () => string;
1032
+
1033
+ /**
1034
+ * Create a human readable list from an array of strings.
1035
+ * For example, ['apple', 'orange'] becomes "apple and orange"
1036
+ * and ['apple', 'orange', 'mango'] becomes "apple, orange, and mango"
1037
+ * @author Gabe Abrams
1038
+ * @param items list of items in the list
1039
+ * @returns human-readable list
1040
+ */
1041
+ declare const stringsToHumanReadableList: (items: string[]) => string;
1042
+
1043
+ /**
1044
+ * Given a string, only keep the letters inside it
1045
+ * @author Gabe Abrams
1046
+ * @param str the string to parse
1047
+ * @returns only the letters inside of the string
1048
+ */
1049
+ declare const onlyKeepLetters: (str: string) => string;
1050
+
1051
+ /**
1052
+ * Run tasks in parallel with a limit on how many tasks can execute at once.
1053
+ * No guarantees are made about the order of task execution
1054
+ * @author Gabe Abrams
1055
+ * @param taskFunctions functions that start asynchronous tasks and optionally
1056
+ * resolve with values
1057
+ * @param [limit=no limit] maximum number of asynchronous tasks to permit to run at
1058
+ * once
1059
+ * @returns array of resolved values in the same order as the task functions
1060
+ */
1061
+ declare const parallelLimit: (taskFunctions: (() => Promise<any>)[], limit?: number) => Promise<any[]>;
1062
+
938
1063
  /**
939
1064
  * Allowed log levels
940
1065
  * @author Gabe Abrams
@@ -1083,234 +1208,6 @@ type LogFunction = (opts: ({
1083
1208
  target?: string;
1084
1209
  }))) => Promise<Log>;
1085
1210
 
1086
- /**
1087
- * Generate an express API route handler
1088
- * @author Gabe Abrams
1089
- * @param opts object containing all arguments
1090
- * @param opts.paramTypes map containing the types for each parameter that is
1091
- * included in the request (map: param name => type)
1092
- * @param opts.handler function that processes the request
1093
- * @param [opts.skipSessionCheck] if true, skip the session check (allow users
1094
- * to not be logged in and launched via LTI)
1095
- * @param [opts.allowedHosts] if included, only allow requests from these hosts
1096
- * (start a hostname with a "*" to only check the end of the hostname)
1097
- * you can include just one string instead of an array
1098
- * @param [opts.bannedHosts] if included, do not allow requests from these hosts
1099
- * (start a hostname with a "*" to only check the end of the hostname)
1100
- * you can include just one string instead of an array
1101
- * @param [opts.unhandledErrorMessagePrefix] if included, when an error that
1102
- * is not of type ErrorWithCode is thrown, the client will receive an error
1103
- * where the error message is prefixed with this string. For example,
1104
- * if unhandledErrorMessagePrefix is
1105
- * 'While saving progress, we encountered an error:'
1106
- * and the error is 'progressInfo is not an object',
1107
- * the client will receive an error with the message
1108
- * 'While saving progress, we encountered an error: progressInfo is not an object'
1109
- * @returns express route handler that takes the following arguments:
1110
- * params (map: param name => value),
1111
- * req (express request object),
1112
- * next (express next function),
1113
- * send (a function that sends a string to the client),
1114
- * redirect (takes a url and redirects the user to that url),
1115
- * renderErrorPage (shows a static error page to the user),
1116
- * renderInfoPage (shows a static info page to the user),
1117
- * renderCustomHTML (renders custom html and sends it to the user),
1118
- * and returns the value to send to the client as a JSON API response, or
1119
- * calls next() or redirect(...) or send(...) or renderErrorPage(...).
1120
- * Note: params also has userId, userFirstName,
1121
- * userLastName, userEmail, userAvatarURL, isLearner, isTTM, isAdmin,
1122
- * and any other variables that
1123
- * are directly added to the session, if the user does have a session.
1124
- */
1125
- declare const genRouteHandler: (opts: {
1126
- paramTypes?: {
1127
- [k: string]: ParamType;
1128
- } | undefined;
1129
- handler: (opts: {
1130
- params: {
1131
- [k: string]: any;
1132
- };
1133
- req: any;
1134
- next: () => void;
1135
- redirect: (pathOrURL: string) => void;
1136
- send: (text: string, status?: number) => void;
1137
- renderErrorPage: (opts?: {
1138
- title?: string;
1139
- description?: string;
1140
- code?: string;
1141
- pageTitle?: string;
1142
- status?: number;
1143
- }) => void;
1144
- renderInfoPage: (opts: {
1145
- title: string;
1146
- body: string;
1147
- }) => void;
1148
- renderCustomHTML: (opts: {
1149
- html: string;
1150
- status?: number;
1151
- }) => void;
1152
- logServerEvent: LogFunction;
1153
- }) => any;
1154
- skipSessionCheck?: boolean | undefined;
1155
- allowedHosts?: string | string[] | undefined;
1156
- bannedHosts?: string | string[] | undefined;
1157
- unhandledErrorMessagePrefix?: string | undefined;
1158
- }) => (req: any, res: any, next: () => void) => Promise<undefined>;
1159
-
1160
- /**
1161
- * Handle an error and respond to the client
1162
- * @author Gabe Abrams
1163
- * @param res express response
1164
- * @param error error info
1165
- * @param opts.err the error to send to the client
1166
- * or the error message
1167
- * @param [opts.code] an error code (only used if err.code is not
1168
- * included)
1169
- * @param [opts.status=500] the https status code to use
1170
- * defined)
1171
- */
1172
- declare const handleError: (res: any, error: ({
1173
- message: any;
1174
- code?: string;
1175
- status?: number;
1176
- } | Error | string | any)) => undefined;
1177
-
1178
- /**
1179
- * Send successful API response
1180
- * @author Gabe Abrams
1181
- * @param res express response
1182
- * @param body the body of the response to send to the client
1183
- */
1184
- declare const handleSuccess: (res: any, body: any) => undefined;
1185
-
1186
- type GetLaunchInfoFunction = (req: any) => {
1187
- launched: boolean;
1188
- launchInfo?: any;
1189
- };
1190
- /**
1191
- * Prepare dce-reactkit to run on the server
1192
- * @author Gabe Abrams
1193
- * @param opts object containing all arguments
1194
- * @param opts.app express app from inside of the postprocessor function that
1195
- * we will add routes to
1196
- * @param opts.getLaunchInfo CACCL LTI's get launch info function
1197
- * @param [opts.logCollection] mongo collection from dce-mango to use for
1198
- * storing logs. If none is included, logs are written to the console
1199
- * @param [opts.logReviewAdmins=all] info on which admins can review
1200
- * logs from the client. If not included, all Canvas admins are allowed to
1201
- * review logs. If null, no Canvas admins are allowed to review logs.
1202
- * If an array of Canvas userIds (numbers), only Canvas admins with those
1203
- * userIds are allowed to review logs. If a dce-mango collection, only
1204
- * Canvas admins with entries in that collection ({ userId, ...}) are allowed
1205
- * to review logs
1206
- */
1207
- declare const initServer: (opts: {
1208
- app: any;
1209
- getLaunchInfo: GetLaunchInfoFunction;
1210
- logCollection?: any;
1211
- logReviewAdmins?: (number[] | any);
1212
- }) => void;
1213
-
1214
- /**
1215
- * Get a number's ordinal
1216
- * @author Gabe Abrams
1217
- * @param num the number being analyzed
1218
- * @returns ordinal
1219
- */
1220
- declare const getOrdinal: (num: number) => string;
1221
-
1222
- /**
1223
- * Get current time info in US Boston Eastern Time, independent of machine
1224
- * timezone
1225
- * @author Gabe Abrams
1226
- * @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
1227
- * @returns object with timestamp (ms since epoch) and numbers
1228
- * corresponding to ET time values for year, month, day, hour, hour12, minute, isPM
1229
- * where hour is in 24hr time and hour12 is in 12hr time.
1230
- */
1231
- declare const getTimeInfoInET: (dateOrTimestamp?: Date | number) => {
1232
- timestamp: number;
1233
- year: number;
1234
- month: number;
1235
- day: number;
1236
- hour: number;
1237
- hour12: number;
1238
- minute: number;
1239
- isPM: boolean;
1240
- };
1241
-
1242
- /**
1243
- * Stub a server endpoint response
1244
- * @author Gabe Abrams
1245
- * @param opts object containing all arguments
1246
- * @param [opts.method=GET] http method to stub
1247
- * @param opts.path full pathname to stub
1248
- * @param opts.body body of response if stubbing a successful response
1249
- * @param opts.errorMessage message of error if stubbing a failed response
1250
- * @param [opts.errorCode] error code if stubbing a failed response
1251
- */
1252
- declare const stubServerEndpoint: (opts: {
1253
- method?: string | undefined;
1254
- path: string;
1255
- body?: any;
1256
- errorMessage?: string | undefined;
1257
- errorCode?: string | undefined;
1258
- }) => void;
1259
-
1260
- /**
1261
- * Start a dynamic wait, call the function once the operation has completed and
1262
- * the dynamic wait will continue waiting for the rest of the minimum time
1263
- * @author Gabe Abrams
1264
- * @param minWaitMs the minimum number of ms to wait
1265
- * @returns async function to call to finish the wait
1266
- */
1267
- declare const startMinWait: (minWaitMs: number) => () => Promise<void>;
1268
-
1269
- /**
1270
- * Get a human-readable description of a date (all in ET)
1271
- * @author Gabe Abrams
1272
- * @param [dateOrTimestamp=today] the date or timestamp for the date to describe
1273
- * @returns human-readable description of the date
1274
- */
1275
- declare const getHumanReadableDate: (dateOrTimestamp?: Date | number) => string;
1276
-
1277
- /**
1278
- * Get the current part of day (morning, evening, etc.)
1279
- * @author Gabe Abrams
1280
- * @returns the part of day (morning, evening, etc.)
1281
- */
1282
- declare const getPartOfDay: () => string;
1283
-
1284
- /**
1285
- * Create a human readable list from an array of strings.
1286
- * For example, ['apple', 'orange'] becomes "apple and orange"
1287
- * and ['apple', 'orange', 'mango'] becomes "apple, orange, and mango"
1288
- * @author Gabe Abrams
1289
- * @param items list of items in the list
1290
- * @returns human-readable list
1291
- */
1292
- declare const stringsToHumanReadableList: (items: string[]) => string;
1293
-
1294
- /**
1295
- * Given a string, only keep the letters inside it
1296
- * @author Gabe Abrams
1297
- * @param str the string to parse
1298
- * @returns only the letters inside of the string
1299
- */
1300
- declare const onlyKeepLetters: (str: string) => string;
1301
-
1302
- /**
1303
- * Run tasks in parallel with a limit on how many tasks can execute at once.
1304
- * No guarantees are made about the order of task execution
1305
- * @author Gabe Abrams
1306
- * @param taskFunctions functions that start asynchronous tasks and optionally
1307
- * resolve with values
1308
- * @param [limit=no limit] maximum number of asynchronous tasks to permit to run at
1309
- * once
1310
- * @returns array of resolved values in the same order as the task functions
1311
- */
1312
- declare const parallelLimit: (taskFunctions: (() => Promise<any>)[], limit?: number) => Promise<any[]>;
1313
-
1314
1211
  type MetadataPopulator = () => {
1315
1212
  [k: string]: any;
1316
1213
  } | Promise<{
@@ -1331,14 +1228,6 @@ declare const setClientEventMetadataPopulator: (newMetadataPopulator: MetadataPo
1331
1228
  */
1332
1229
  declare const logClientEvent: LogFunction;
1333
1230
 
1334
- /**
1335
- * Initialize a log collection given the dce-mango Collection class
1336
- * @author Gabe Abrams
1337
- * @param Collection the Collection class from dce-mango
1338
- * @returns initialized logCollection
1339
- */
1340
- declare const initLogCollection: (Collection: any) => any;
1341
-
1342
1231
  /**
1343
1232
  * Get the name of a month given the month number (1 = January, etc.)
1344
1233
  * If an invalid number is provided, we will treat it like January
@@ -1425,46 +1314,6 @@ declare const getLocalTimeInfo: (dateOrTimestamp?: Date | number) => {
1425
1314
  isPM: boolean;
1426
1315
  };
1427
1316
 
1428
- /**
1429
- * Interface for a collection in the database
1430
- * @author Yuen Ler Chow
1431
- */
1432
- type DCEMangoCollection = {
1433
- /**
1434
- * Find all items in the collection that match the filter query
1435
- * @param filterQuery query for the filter
1436
- * @returns list of items that match the filter query
1437
- */
1438
- find: (filterQuery: any) => Promise<any[]>;
1439
- /**
1440
- * Insert an item into the collection
1441
- * @param item the item to insert
1442
- */
1443
- insert: (item: any) => Promise<void>;
1444
- /**
1445
- * Delete an item in the collection
1446
- * @param id the id of the item to delete
1447
- */
1448
- delete: (filterQuery: {
1449
- id: string;
1450
- }) => Promise<void>;
1451
- };
1452
- /**
1453
- * Add all routes for the DBEditor
1454
- * @author Yuen Ler Chow
1455
- * @param opts object containing all arguments
1456
- * @param opts.app express app to add routes too
1457
- * @param opts.collectionName the name of the collection
1458
- * @param opts.adminsOnly true if the endpoint is for admins only
1459
- * @param opts.collection dce-mango db collection
1460
- */
1461
- declare const addDBEditorEndpoints: (opts: {
1462
- app: express.Application;
1463
- collectionName: string;
1464
- adminsOnly: boolean;
1465
- collection: DCEMangoCollection;
1466
- }) => void;
1467
-
1468
1317
  /**
1469
1318
  * Given an array of strings, create a single comma-separated string that includes
1470
1319
  * 'and' as well as an oxford comma.
@@ -1659,30 +1508,6 @@ declare const capitalize: (str: string) => string;
1659
1508
  */
1660
1509
  declare const shuffleArray: <T>(arr: T[]) => T[];
1661
1510
 
1662
- /**
1663
- * Send a server-to-server request from this sever to another server that uses
1664
- * dce-reactkit [for server only]
1665
- * @author Gabe Abrams
1666
- * @param opts object containing all arguments
1667
- * @param opts.host - the host of the other server
1668
- * @param opts.path - the path of the other server's endpoint
1669
- * @param [opts.method=GET] - the method of the endpoint
1670
- * @param [opts.params] - query/body parameters to include
1671
- * @param [opts.headers] - headers to include
1672
- * @returns response from server
1673
- */
1674
- declare const visitEndpointOnAnotherServer: (opts: {
1675
- host: string;
1676
- path: string;
1677
- method?: "GET" | "POST" | "DELETE" | "PUT" | undefined;
1678
- params?: {
1679
- [x: string]: any;
1680
- } | undefined;
1681
- headers?: {
1682
- [x: string]: any;
1683
- } | undefined;
1684
- }) => Promise<any>;
1685
-
1686
1511
  /**
1687
1512
  * Get number of words in string
1688
1513
  * @author Gardenia Liu
@@ -1694,29 +1519,12 @@ declare const visitEndpointOnAnotherServer: (opts: {
1694
1519
  declare const getWordCount: (text: string) => number;
1695
1520
 
1696
1521
  /**
1697
- * List of error codes built into the react kit
1698
- * @author Gabe Abrams
1522
+ * Deeply clones an object
1523
+ * @author Yuen Ler Chow
1524
+ * @param obj the object to clone
1525
+ * @returns a deep clone of the object
1699
1526
  */
1700
- declare enum ReactKitErrorCode {
1701
- NoResponse = "DRK1",
1702
- NoCode = "DRK2",
1703
- SessionExpired = "DRK3",
1704
- MissingParameter = "DRK4",
1705
- InvalidParameter = "DRK5",
1706
- HostNotAllowed = "DRK17",
1707
- HostBanned = "DRK18",
1708
- WrongCourse = "DRK6",
1709
- NoCACCLSendRequestFunction = "DRK7",
1710
- NoCACCLGetLaunchInfoFunction = "DRK8",
1711
- NotTTM = "DRK9",
1712
- NotAdmin = "DRK10",
1713
- NotAllowedToReviewLogs = "DRK11",
1714
- ThemeCheckedBeforeReactKitReady = "DRK12",
1715
- SessionExpiredMessageGottenBeforeReactKitReady = "DRK13",
1716
- NotConnected = "DRK14",
1717
- SelfSigned = "DRK15",
1718
- ResponseParseError = "DRK16"
1719
- }
1527
+ declare const cloneDeep: <T>(obj: T) => T;
1720
1528
 
1721
1529
  /**
1722
1530
  * Days of the week
@@ -1748,4 +1556,78 @@ declare const LogBuiltInMetadata: {
1748
1556
  };
1749
1557
  };
1750
1558
 
1751
- export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, Dropdown, DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogFunction, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, MultiSwitch, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getWordCount, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitEndpointOnAnotherServer, visitServerEndpoint, waitMs };
1559
+ /**
1560
+ * List of error codes built into the react kit
1561
+ * @author Gabe Abrams
1562
+ */
1563
+ declare enum ReactKitErrorCode {
1564
+ NoResponse = "DRK1",
1565
+ NoCode = "DRK2",
1566
+ SessionExpired = "DRK3",
1567
+ NoCACCLSendRequestFunction = "DRK7"
1568
+ }
1569
+
1570
+ type DateFilterState = {
1571
+ startDate: {
1572
+ year: number;
1573
+ month: number;
1574
+ day: number;
1575
+ };
1576
+ endDate: {
1577
+ year: number;
1578
+ month: number;
1579
+ day: number;
1580
+ };
1581
+ };
1582
+
1583
+ type ContextFilterState = {
1584
+ [k: string]: (boolean | {
1585
+ [k: string]: boolean;
1586
+ });
1587
+ };
1588
+
1589
+ type TagFilterState = {
1590
+ [k: string]: boolean;
1591
+ };
1592
+
1593
+ type ActionErrorFilterState = {
1594
+ type: LogType | undefined;
1595
+ errorMessage: string;
1596
+ errorCode: string;
1597
+ target: {
1598
+ [k: string]: boolean;
1599
+ };
1600
+ action: {
1601
+ [k: string]: boolean;
1602
+ };
1603
+ };
1604
+
1605
+ type AdvancedFilterState = {
1606
+ userFirstName: string;
1607
+ userLastName: string;
1608
+ userEmail: string;
1609
+ userId: string;
1610
+ includeLearners: boolean;
1611
+ includeTTMs: boolean;
1612
+ includeAdmins: boolean;
1613
+ courseId: string;
1614
+ courseName: string;
1615
+ isMobile: (true | false | undefined);
1616
+ source: LogSource | undefined;
1617
+ routePath: string;
1618
+ routeTemplate: string;
1619
+ };
1620
+
1621
+ /**
1622
+ * A bundle of filter state objects for each type of filter
1623
+ * @author Gabe Abrams
1624
+ */
1625
+ type LogReviewerFilterState = {
1626
+ dateFilterState: DateFilterState;
1627
+ contextFilterState: ContextFilterState;
1628
+ tagFilterState: TagFilterState;
1629
+ actionErrorFilterState: ActionErrorFilterState;
1630
+ advancedFilterState: AdvancedFilterState;
1631
+ };
1632
+
1633
+ export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, Dropdown, DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogFunction, LogLevel, LogMainInfo, LogMetadataType, LogReviewer, LogReviewerFilterState, LogSource, LogSourceSpecificInfo, LogType, LogTypeSpecificInfo, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, MultiSwitch, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant, abbreviate, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, cloneDeep, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getWordCount, idify, initClient, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.12.3",
3
+ "version": "4.0.0-beta-logreviewer.1",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "homepage": "https://github.com/harvard-edtech/dce-reactkit#readme",
26
26
  "dependencies": {
27
- "qs": "^6.x.x",
27
+ "nanoclone": "^1.0.2",
28
28
  "react-select": "^5.7.3"
29
29
  },
30
30
  "peerDependencies": {
@@ -33,20 +33,19 @@
33
33
  "@fortawesome/free-solid-svg-icons": "^x.x.x",
34
34
  "@fortawesome/react-fontawesome": "^x.x.x",
35
35
  "bootstrap": "^5.x.x",
36
- "express": "^x.x.x",
37
- "react": "^x.x.x",
38
- "react-dom": "^x.x.x"
36
+ "react": "^x.x.x"
39
37
  },
40
38
  "devDependencies": {
41
39
  "@rollup/plugin-commonjs": "^22.0.0",
42
40
  "@rollup/plugin-json": "^4.1.0",
43
41
  "@rollup/plugin-node-resolve": "^13.2.1",
44
- "@rollup/plugin-typescript": "^8.3.2",
42
+ "@rollup/plugin-typescript": "^10.0.1",
45
43
  "@types/bootstrap": "^5.2.8",
46
44
  "@types/express": "^4.17.17",
47
45
  "@types/jest": "^28.1.7",
48
46
  "@types/node": "^20.2.5",
49
- "@types/react": "^17.0.7",
47
+ "@types/react": "^19.0.10",
48
+ "@types/react-dom": "^19.0.4",
50
49
  "@typescript-eslint/eslint-plugin": "^5.59.9",
51
50
  "@typescript-eslint/parser": "^5.59.9",
52
51
  "eslint": "^8.42.0",
@@ -58,7 +57,6 @@
58
57
  "eslint-plugin-react-hooks": "^4.6.0",
59
58
  "jest": "^28.1.3",
60
59
  "jest-environment-jsdom": "^28.1.3",
61
- "raixa": "^1.0.21",
62
60
  "rollup": "^2.70.2",
63
61
  "rollup-plugin-dts": "^4.2.1",
64
62
  "rollup-plugin-sourcemaps": "^0.6.3",
@@ -32,10 +32,12 @@ import ErrorWithCode from '../errors/ErrorWithCode';
32
32
  // TODO: fix dependency cycle
33
33
  // eslint-disable-next-line import/no-cycle
34
34
  import logClientEvent from '../helpers/logClientEvent';
35
+ // TODO: fix dependency cycle
36
+ // eslint-disable-next-line import/no-cycle
35
37
  import {
36
38
  getSessionExpiredMessage,
37
39
  isDarkModeOn,
38
- } from '../client/initClient';
40
+ } from '../helpers/initClient';
39
41
  import waitMs from '../helpers/waitMs';
40
42
 
41
43
  // Import constants