dce-reactkit 3.12.1-beta-cross-server.8 → 4.0.0-beta-date-and-time.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 (92) hide show
  1. package/.vscode/settings.json +3 -1
  2. package/README.md +0 -20
  3. package/dist/cjs/index.js +7838 -15905
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/types/components/ItemPicker/index.d.ts +1 -0
  6. package/dist/cjs/types/components/LoadingSpinner.d.ts +2 -2
  7. package/dist/cjs/types/components/Modal/ModalProps.d.ts +2 -0
  8. package/dist/cjs/types/components/SimpleDateChooser.d.ts +3 -1
  9. package/dist/cjs/types/components/SimpleTimeChooser.d.ts +20 -0
  10. package/dist/cjs/types/components/TabBox.d.ts +1 -0
  11. package/dist/cjs/types/components/Tooltip.d.ts +1 -1
  12. package/dist/cjs/types/helpers/getWordCount.d.ts +10 -0
  13. package/dist/cjs/types/index.d.ts +13 -13
  14. package/dist/cjs/types/types/ParamType.d.ts +10 -10
  15. package/dist/cjs/types/types/ReactKitErrorCode.d.ts +2 -28
  16. package/dist/esm/index.js +6661 -14723
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/types/components/ItemPicker/index.d.ts +1 -0
  19. package/dist/esm/types/components/LoadingSpinner.d.ts +2 -2
  20. package/dist/esm/types/components/Modal/ModalProps.d.ts +2 -0
  21. package/dist/esm/types/components/SimpleDateChooser.d.ts +3 -1
  22. package/dist/esm/types/components/SimpleTimeChooser.d.ts +20 -0
  23. package/dist/esm/types/components/TabBox.d.ts +1 -0
  24. package/dist/esm/types/components/Tooltip.d.ts +1 -1
  25. package/dist/esm/types/helpers/getWordCount.d.ts +10 -0
  26. package/dist/esm/types/index.d.ts +13 -13
  27. package/dist/esm/types/types/ParamType.d.ts +10 -10
  28. package/dist/esm/types/types/ReactKitErrorCode.d.ts +2 -28
  29. package/dist/index.d.ts +189 -379
  30. package/package.json +5 -11
  31. package/src/components/AppWrapper.tsx +3 -1
  32. package/src/components/CheckboxButton.tsx +1 -1
  33. package/src/components/Dropdown.tsx +1 -1
  34. package/src/components/IntelliTable.tsx +1 -1
  35. package/src/components/ItemPicker/NestableItemList.tsx +1 -0
  36. package/src/components/ItemPicker/index.tsx +96 -0
  37. package/src/components/LogReviewer.tsx +2 -2
  38. package/src/components/Modal/ModalProps.ts +4 -0
  39. package/src/components/Modal/index.tsx +60 -21
  40. package/src/components/RadioButton.tsx +3 -1
  41. package/src/components/SimpleDateChooser.tsx +62 -26
  42. package/src/components/SimpleTimeChooser.tsx +195 -0
  43. package/src/components/TabBox.tsx +27 -9
  44. package/src/components/Tooltip.tsx +1 -1
  45. package/src/helpers/getWordCount.ts +26 -0
  46. package/src/{client → helpers}/initClient.tsx +5 -1
  47. package/src/helpers/logClientEvent.tsx +3 -1
  48. package/src/helpers/visitServerEndpoint.tsx +1 -1
  49. package/src/index.ts +22 -24
  50. package/src/types/ParamType.ts +10 -10
  51. package/src/types/ReactKitErrorCode.tsx +3 -31
  52. package/dist/cjs/types/components/ItemPicker/index.test.d.ts +0 -1
  53. package/dist/cjs/types/helpers/addDBEditorEndpoints.d.ts +0 -41
  54. package/dist/cjs/types/helpers/dataSigner.d.ts +0 -40
  55. package/dist/cjs/types/helpers/genRouteHandler.d.ts +0 -76
  56. package/dist/cjs/types/helpers/handleError.d.ts +0 -18
  57. package/dist/cjs/types/helpers/handleSuccess.d.ts +0 -8
  58. package/dist/cjs/types/helpers/parseUserAgent.d.ts +0 -17
  59. package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/index.d.ts +0 -20
  60. package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +0 -27
  61. package/dist/cjs/types/server/initCrossServerCredentialCollection.d.ts +0 -8
  62. package/dist/cjs/types/server/initLogCollection.d.ts +0 -8
  63. package/dist/cjs/types/server/initServer.d.ts +0 -53
  64. package/dist/cjs/types/types/CrossServerCredential.d.ts +0 -11
  65. package/dist/esm/types/components/ItemPicker/index.test.d.ts +0 -1
  66. package/dist/esm/types/helpers/addDBEditorEndpoints.d.ts +0 -41
  67. package/dist/esm/types/helpers/dataSigner.d.ts +0 -40
  68. package/dist/esm/types/helpers/genRouteHandler.d.ts +0 -76
  69. package/dist/esm/types/helpers/handleError.d.ts +0 -18
  70. package/dist/esm/types/helpers/handleSuccess.d.ts +0 -8
  71. package/dist/esm/types/helpers/parseUserAgent.d.ts +0 -17
  72. package/dist/esm/types/helpers/visitEndpointOnAnotherServer/index.d.ts +0 -20
  73. package/dist/esm/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +0 -27
  74. package/dist/esm/types/server/initCrossServerCredentialCollection.d.ts +0 -8
  75. package/dist/esm/types/server/initLogCollection.d.ts +0 -8
  76. package/dist/esm/types/server/initServer.d.ts +0 -53
  77. package/dist/esm/types/types/CrossServerCredential.d.ts +0 -11
  78. package/src/components/ItemPicker/index.test.tsx +0 -783
  79. package/src/helpers/addDBEditorEndpoints.ts +0 -128
  80. package/src/helpers/dataSigner.ts +0 -342
  81. package/src/helpers/genRouteHandler.ts +0 -911
  82. package/src/helpers/handleError.ts +0 -65
  83. package/src/helpers/handleSuccess.ts +0 -18
  84. package/src/helpers/parseUserAgent.ts +0 -108
  85. package/src/helpers/visitEndpointOnAnotherServer/index.ts +0 -152
  86. package/src/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.ts +0 -162
  87. package/src/server/initCrossServerCredentialCollection.ts +0 -16
  88. package/src/server/initLogCollection.ts +0 -27
  89. package/src/server/initServer.ts +0 -305
  90. package/src/types/CrossServerCredential.ts +0 -16
  91. /package/dist/cjs/types/{client → helpers}/initClient.d.ts +0 -0
  92. /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
@@ -24,7 +23,7 @@ declare enum Variant {
24
23
  * @author Gabe Abrams
25
24
  */
26
25
 
27
- type Props$l = {
26
+ type Props$m = {
28
27
  children: React$1.ReactNode;
29
28
  };
30
29
  /**
@@ -107,27 +106,28 @@ declare const showFatalError: (error: any, errorTitle?: string) => Promise<void>
107
106
  * @author Gabe Abrams
108
107
  */
109
108
  declare const addFatalErrorHandler: (handler: () => void) => void;
110
- declare const AppWrapper: React$1.FC<Props$l>;
109
+ declare const AppWrapper: React$1.FC<Props$m>;
111
110
 
112
111
  /**
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
120
120
  * @author Gabe Abrams
121
121
  */
122
122
 
123
- type Props$k = {
123
+ type Props$l = {
124
124
  error: any;
125
125
  title?: string;
126
126
  onClose?: () => void;
127
127
  variant?: Variant;
128
128
  icon?: IconProp;
129
129
  };
130
- declare const ErrorBox: React$1.FC<Props$k>;
130
+ declare const ErrorBox: React$1.FC<Props$l>;
131
131
 
132
132
  /**
133
133
  * Types of buttons in the modal
@@ -209,6 +209,8 @@ type ModalProps = {
209
209
  confirmLabel?: string;
210
210
  confirmVariant?: Variant;
211
211
  onTopOfOtherModals?: boolean;
212
+ isLoading?: boolean;
213
+ isLoadingCancelable?: boolean;
212
214
  };
213
215
 
214
216
  /**
@@ -224,20 +226,21 @@ declare const Modal: React$1.FC<ModalProps>;
224
226
  * @author Gabe Abrams
225
227
  */
226
228
 
227
- type Props$j = {
229
+ type Props$k = {
228
230
  title: React$1.ReactNode;
229
231
  children: React$1.ReactNode;
232
+ topRightChildren?: React$1.ReactNode;
230
233
  noBottomMargin?: boolean;
231
234
  noBottomPadding?: boolean;
232
235
  };
233
- declare const TabBox: React$1.FC<Props$j>;
236
+ declare const TabBox: React$1.FC<Props$k>;
234
237
 
235
238
  /**
236
239
  * A radio selection button
237
240
  * @author Gabe Abrams
238
241
  */
239
242
 
240
- type Props$i = {
243
+ type Props$j = {
241
244
  text: React$1.ReactNode;
242
245
  onSelected: () => void;
243
246
  ariaLabel: string;
@@ -251,14 +254,14 @@ type Props$i = {
251
254
  small?: boolean;
252
255
  useComplexFormatting?: boolean;
253
256
  };
254
- declare const RadioButton: React$1.FC<Props$i>;
257
+ declare const RadioButton: React$1.FC<Props$j>;
255
258
 
256
259
  /**
257
260
  * A checkbox button
258
261
  * @author Gabe Abrams
259
262
  */
260
263
 
261
- type Props$h = {
264
+ type Props$i = {
262
265
  text: React$1.ReactNode;
263
266
  onChanged: (checked: boolean) => void;
264
267
  ariaLabel: string;
@@ -273,14 +276,14 @@ type Props$h = {
273
276
  dashed?: boolean;
274
277
  useComplexFormatting?: boolean;
275
278
  };
276
- declare const CheckboxButton: React$1.FC<Props$h>;
279
+ declare const CheckboxButton: React$1.FC<Props$i>;
277
280
 
278
281
  /**
279
282
  * Input group with a title and space for buttons
280
283
  * @author Gabe Abrams
281
284
  */
282
285
 
283
- type Props$g = {
286
+ type Props$h = {
284
287
  label: React$1.ReactNode;
285
288
  minLabelWidth?: string;
286
289
  children: React$1.ReactNode;
@@ -289,14 +292,15 @@ type Props$g = {
289
292
  isAdminFeature?: boolean;
290
293
  noMarginOnBottom?: boolean;
291
294
  };
292
- declare const ButtonInputGroup: React$1.FC<Props$g>;
295
+ declare const ButtonInputGroup: React$1.FC<Props$h>;
293
296
 
294
297
  /**
295
298
  * A very simple, lightweight date chooser
296
299
  * @author Gabe Abrams
300
+ * @author Gardeniu Liu
297
301
  */
298
302
 
299
- type Props$f = {
303
+ type Props$g = {
300
304
  ariaLabel: string;
301
305
  name: string;
302
306
  month: number;
@@ -310,9 +314,30 @@ type Props$f = {
310
314
  */
311
315
  onChange: (month: number, day: number, year: number) => void;
312
316
  numMonthsToShow?: number;
313
- chooseFromPast?: boolean;
317
+ dontAllowPast?: boolean;
318
+ dontAllowFuture?: boolean;
319
+ };
320
+ declare const SimpleDateChooser: React$1.FC<Props$g>;
321
+
322
+ /**
323
+ * A very simple, lightweight time chooser
324
+ * @author Gardenia Liu
325
+ */
326
+
327
+ type Props$f = {
328
+ ariaLabel: string;
329
+ name: string;
330
+ hour: number;
331
+ minute: number;
332
+ /**
333
+ * Handler for when time changes
334
+ * @param hour new 24hr hour number
335
+ * @param minute new minute number
336
+ */
337
+ onChange: (hour: number, minute: number) => void;
338
+ intervalMin?: number;
314
339
  };
315
- declare const SimpleDateChooser: React$1.FC<Props$f>;
340
+ declare const SimpleTimeChooser: React$1.FC<Props$f>;
316
341
 
317
342
  /**
318
343
  * Drawer container
@@ -412,6 +437,7 @@ type Props$9 = {
412
437
  */
413
438
  onChanged: (updatedItems: PickableItem[]) => void;
414
439
  noBottomMargin?: boolean;
440
+ hideSelectAllOrNoneButtons?: boolean;
415
441
  };
416
442
  declare const ItemPicker: React$1.FC<Props$9>;
417
443
 
@@ -469,16 +495,16 @@ declare const LogReviewer: React$1.FC<Props$8>;
469
495
  * @author Gabe Abrams
470
496
  */
471
497
  declare enum ParamType {
472
- Boolean = "boolean",
473
- BooleanOptional = "boolean-optional",
474
- Float = "float",
475
- FloatOptional = "float-optional",
476
- Int = "int",
477
- IntOptional = "int-optional",
478
- JSON = "json",
479
- JSONOptional = "json-optional",
480
- String = "string",
481
- StringOptional = "string-optional"
498
+ Boolean = "Boolean",
499
+ BooleanOptional = "BooleanOptional",
500
+ Float = "Float",
501
+ FloatOptional = "FloatOptional",
502
+ Int = "Int",
503
+ IntOptional = "IntOptional",
504
+ JSON = "JSON",
505
+ JSONOptional = "JSONOptional",
506
+ String = "String",
507
+ StringOptional = "StringOptional"
482
508
  }
483
509
 
484
510
  /**
@@ -637,7 +663,7 @@ declare const DBEntryManagerPanel: React$1.FC<Props$5>;
637
663
 
638
664
  type Props$4 = {
639
665
  text: string;
640
- children: JSX.Element;
666
+ children: any;
641
667
  };
642
668
  declare const Tooltip: React$1.FC<Props$4>;
643
669
 
@@ -770,6 +796,25 @@ declare const HOUR_IN_MS = 3600000;
770
796
  */
771
797
  declare const DAY_IN_MS = 86400000;
772
798
 
799
+ /**
800
+ * Path of the route for storing client-side logs
801
+ * @author Gabe Abrams
802
+ */
803
+ declare const LOG_REVIEW_ROUTE_PATH_PREFIX: string;
804
+
805
+ /**
806
+ * Path of the route for storing client-side logs
807
+ * @author Gabe Abrams
808
+ */
809
+ declare const LOG_ROUTE_PATH: string;
810
+
811
+ /**
812
+ * Route for checking the status of the current user's
813
+ * access to log review
814
+ * @author Gabe Abrams
815
+ */
816
+ declare const LOG_REVIEW_STATUS_ROUTE: string;
817
+
773
818
  /**
774
819
  * Dynamic words determined by the user's platform
775
820
  * @author Gabe Abrams
@@ -931,6 +976,106 @@ declare const visitServerEndpoint: (opts: {
931
976
  } | undefined;
932
977
  }) => Promise<any>;
933
978
 
979
+ /**
980
+ * Get a number's ordinal
981
+ * @author Gabe Abrams
982
+ * @param num the number being analyzed
983
+ * @returns ordinal
984
+ */
985
+ declare const getOrdinal: (num: number) => string;
986
+
987
+ /**
988
+ * Get current time info in US Boston Eastern Time, independent of machine
989
+ * timezone
990
+ * @author Gabe Abrams
991
+ * @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
992
+ * @returns object with timestamp (ms since epoch) and numbers
993
+ * corresponding to ET time values for year, month, day, hour, hour12, minute, isPM
994
+ * where hour is in 24hr time and hour12 is in 12hr time.
995
+ */
996
+ declare const getTimeInfoInET: (dateOrTimestamp?: Date | number) => {
997
+ timestamp: number;
998
+ year: number;
999
+ month: number;
1000
+ day: number;
1001
+ hour: number;
1002
+ hour12: number;
1003
+ minute: number;
1004
+ isPM: boolean;
1005
+ };
1006
+
1007
+ /**
1008
+ * Stub a server endpoint response
1009
+ * @author Gabe Abrams
1010
+ * @param opts object containing all arguments
1011
+ * @param [opts.method=GET] http method to stub
1012
+ * @param opts.path full pathname to stub
1013
+ * @param opts.body body of response if stubbing a successful response
1014
+ * @param opts.errorMessage message of error if stubbing a failed response
1015
+ * @param [opts.errorCode] error code if stubbing a failed response
1016
+ */
1017
+ declare const stubServerEndpoint: (opts: {
1018
+ method?: string | undefined;
1019
+ path: string;
1020
+ body?: any;
1021
+ errorMessage?: string | undefined;
1022
+ errorCode?: string | undefined;
1023
+ }) => void;
1024
+
1025
+ /**
1026
+ * Start a dynamic wait, call the function once the operation has completed and
1027
+ * the dynamic wait will continue waiting for the rest of the minimum time
1028
+ * @author Gabe Abrams
1029
+ * @param minWaitMs the minimum number of ms to wait
1030
+ * @returns async function to call to finish the wait
1031
+ */
1032
+ declare const startMinWait: (minWaitMs: number) => () => Promise<void>;
1033
+
1034
+ /**
1035
+ * Get a human-readable description of a date (all in ET)
1036
+ * @author Gabe Abrams
1037
+ * @param [dateOrTimestamp=today] the date or timestamp for the date to describe
1038
+ * @returns human-readable description of the date
1039
+ */
1040
+ declare const getHumanReadableDate: (dateOrTimestamp?: Date | number) => string;
1041
+
1042
+ /**
1043
+ * Get the current part of day (morning, evening, etc.)
1044
+ * @author Gabe Abrams
1045
+ * @returns the part of day (morning, evening, etc.)
1046
+ */
1047
+ declare const getPartOfDay: () => string;
1048
+
1049
+ /**
1050
+ * Create a human readable list from an array of strings.
1051
+ * For example, ['apple', 'orange'] becomes "apple and orange"
1052
+ * and ['apple', 'orange', 'mango'] becomes "apple, orange, and mango"
1053
+ * @author Gabe Abrams
1054
+ * @param items list of items in the list
1055
+ * @returns human-readable list
1056
+ */
1057
+ declare const stringsToHumanReadableList: (items: string[]) => string;
1058
+
1059
+ /**
1060
+ * Given a string, only keep the letters inside it
1061
+ * @author Gabe Abrams
1062
+ * @param str the string to parse
1063
+ * @returns only the letters inside of the string
1064
+ */
1065
+ declare const onlyKeepLetters: (str: string) => string;
1066
+
1067
+ /**
1068
+ * Run tasks in parallel with a limit on how many tasks can execute at once.
1069
+ * No guarantees are made about the order of task execution
1070
+ * @author Gabe Abrams
1071
+ * @param taskFunctions functions that start asynchronous tasks and optionally
1072
+ * resolve with values
1073
+ * @param [limit=no limit] maximum number of asynchronous tasks to permit to run at
1074
+ * once
1075
+ * @returns array of resolved values in the same order as the task functions
1076
+ */
1077
+ declare const parallelLimit: (taskFunctions: (() => Promise<any>)[], limit?: number) => Promise<any[]>;
1078
+
934
1079
  /**
935
1080
  * Allowed log levels
936
1081
  * @author Gabe Abrams
@@ -1079,238 +1224,6 @@ type LogFunction = (opts: ({
1079
1224
  target?: string;
1080
1225
  }))) => Promise<Log>;
1081
1226
 
1082
- /**
1083
- * Generate an express API route handler
1084
- * @author Gabe Abrams
1085
- * @param opts object containing all arguments
1086
- * @param opts.paramTypes map containing the types for each parameter that is
1087
- * included in the request (map: param name => type)
1088
- * @param opts.handler function that processes the request
1089
- * @param [opts.crossServerScope] the scope associated with this endpoint.
1090
- * If defined, this is a cross-server endpoint, which will never
1091
- * have any launch data, will never check Canvas roles or launch status, and will
1092
- * instead use scopes and reactkit credentials to sign and validate requests.
1093
- * Never start the path with /api/ttm or /api/admin if the endpoint is a cross-server
1094
- * endpoint because those roles will not be validated
1095
- * @param [opts.skipSessionCheck=true if crossServerScope defined] if true, skip
1096
- * the session check (allow users to not be logged in and launched via LTI).
1097
- * If crossServerScope is defined, this is always true
1098
- * @param [opts.unhandledErrorMessagePrefix] if included, when an error that
1099
- * is not of type ErrorWithCode is thrown, the client will receive an error
1100
- * where the error message is prefixed with this string. For example,
1101
- * if unhandledErrorMessagePrefix is
1102
- * 'While saving progress, we encountered an error:'
1103
- * and the error is 'progressInfo is not an object',
1104
- * the client will receive an error with the message
1105
- * 'While saving progress, we encountered an error: progressInfo is not an object'
1106
- * @returns express route handler that takes the following arguments:
1107
- * params (map: param name => value),
1108
- * req (express request object),
1109
- * next (express next function),
1110
- * send (a function that sends a string to the client),
1111
- * redirect (takes a url and redirects the user to that url),
1112
- * renderErrorPage (shows a static error page to the user),
1113
- * renderInfoPage (shows a static info page to the user),
1114
- * renderCustomHTML (renders custom html and sends it to the user),
1115
- * and returns the value to send to the client as a JSON API response, or
1116
- * calls next() or redirect(...) or send(...) or renderErrorPage(...).
1117
- * Note: params also has userId, userFirstName,
1118
- * userLastName, userEmail, userAvatarURL, isLearner, isTTM, isAdmin,
1119
- * and any other variables that
1120
- * are directly added to the session, if the user does have a session.
1121
- */
1122
- declare const genRouteHandler: (opts: {
1123
- paramTypes?: {
1124
- [k: string]: ParamType;
1125
- } | undefined;
1126
- handler: (opts: {
1127
- params: {
1128
- [k: string]: any;
1129
- };
1130
- req: any;
1131
- next: () => void;
1132
- redirect: (pathOrURL: string) => void;
1133
- send: (text: string, status?: number) => void;
1134
- renderErrorPage: (opts?: {
1135
- title?: string;
1136
- description?: string;
1137
- code?: string;
1138
- pageTitle?: string;
1139
- status?: number;
1140
- }) => void;
1141
- renderInfoPage: (opts: {
1142
- title: string;
1143
- body: string;
1144
- }) => void;
1145
- renderCustomHTML: (opts: {
1146
- html: string;
1147
- status?: number;
1148
- }) => void;
1149
- logServerEvent: LogFunction;
1150
- }) => any;
1151
- crossServerScope?: string | undefined;
1152
- skipSessionCheck?: boolean | undefined;
1153
- unhandledErrorMessagePrefix?: string | undefined;
1154
- }) => (req: any, res: any, next: () => void) => Promise<undefined>;
1155
-
1156
- /**
1157
- * Handle an error and respond to the client
1158
- * @author Gabe Abrams
1159
- * @param res express response
1160
- * @param error error info
1161
- * @param opts.err the error to send to the client
1162
- * or the error message
1163
- * @param [opts.code] an error code (only used if err.code is not
1164
- * included)
1165
- * @param [opts.status=500] the https status code to use
1166
- * defined)
1167
- */
1168
- declare const handleError: (res: any, error: ({
1169
- message: any;
1170
- code?: string;
1171
- status?: number;
1172
- } | Error | string | any)) => undefined;
1173
-
1174
- /**
1175
- * Send successful API response
1176
- * @author Gabe Abrams
1177
- * @param res express response
1178
- * @param body the body of the response to send to the client
1179
- */
1180
- declare const handleSuccess: (res: any, body: any) => undefined;
1181
-
1182
- type GetLaunchInfoFunction = (req: any) => {
1183
- launched: boolean;
1184
- launchInfo?: any;
1185
- };
1186
- /**
1187
- * Prepare dce-reactkit to run on the server
1188
- * @author Gabe Abrams
1189
- * @param opts object containing all arguments
1190
- * @param opts.app express app from inside of the postprocessor function that
1191
- * we will add routes to
1192
- * @param opts.getLaunchInfo CACCL LTI's get launch info function
1193
- * @param [opts.logCollection] mongo collection from dce-mango to use for
1194
- * storing logs. If none is included, logs are written to the console
1195
- * @param [opts.logReviewAdmins=all] info on which admins can review
1196
- * logs from the client. If not included, all Canvas admins are allowed to
1197
- * review logs. If null, no Canvas admins are allowed to review logs.
1198
- * If an array of Canvas userIds (numbers), only Canvas admins with those
1199
- * userIds are allowed to review logs. If a dce-mango collection, only
1200
- * Canvas admins with entries in that collection ({ userId, ...}) are allowed
1201
- * to review logs
1202
- * @param [opts.crossServerCredentialCollection] mongo collection from dce-mango to use for
1203
- * storing cross-server credentials. If none is included, cross-server credentials
1204
- * are not supported
1205
- */
1206
- declare const initServer: (opts: {
1207
- app: any;
1208
- getLaunchInfo: GetLaunchInfoFunction;
1209
- logCollection?: any;
1210
- logReviewAdmins?: (number[] | any);
1211
- crossServerCredentialCollection?: 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
1227
  type MetadataPopulator = () => {
1315
1228
  [k: string]: any;
1316
1229
  } | Promise<{
@@ -1331,22 +1244,6 @@ declare const setClientEventMetadataPopulator: (newMetadataPopulator: MetadataPo
1331
1244
  */
1332
1245
  declare const logClientEvent: LogFunction;
1333
1246
 
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
- /**
1343
- * Initialize a cross-server credential collection given the dce-mango Collection class
1344
- * @author Gabe Abrams
1345
- * @param Collection the Collection class from dce-mango
1346
- * @returns initialized logCollection
1347
- */
1348
- declare const initCrossServerCredentialCollection: (Collection: any) => any;
1349
-
1350
1247
  /**
1351
1248
  * Get the name of a month given the month number (1 = January, etc.)
1352
1249
  * If an invalid number is provided, we will treat it like January
@@ -1433,46 +1330,6 @@ declare const getLocalTimeInfo: (dateOrTimestamp?: Date | number) => {
1433
1330
  isPM: boolean;
1434
1331
  };
1435
1332
 
1436
- /**
1437
- * Interface for a collection in the database
1438
- * @author Yuen Ler Chow
1439
- */
1440
- type DCEMangoCollection = {
1441
- /**
1442
- * Find all items in the collection that match the filter query
1443
- * @param filterQuery query for the filter
1444
- * @returns list of items that match the filter query
1445
- */
1446
- find: (filterQuery: any) => Promise<any[]>;
1447
- /**
1448
- * Insert an item into the collection
1449
- * @param item the item to insert
1450
- */
1451
- insert: (item: any) => Promise<void>;
1452
- /**
1453
- * Delete an item in the collection
1454
- * @param id the id of the item to delete
1455
- */
1456
- delete: (filterQuery: {
1457
- id: string;
1458
- }) => Promise<void>;
1459
- };
1460
- /**
1461
- * Add all routes for the DBEditor
1462
- * @author Yuen Ler Chow
1463
- * @param opts object containing all arguments
1464
- * @param opts.app express app to add routes too
1465
- * @param opts.collectionName the name of the collection
1466
- * @param opts.adminsOnly true if the endpoint is for admins only
1467
- * @param opts.collection dce-mango db collection
1468
- */
1469
- declare const addDBEditorEndpoints: (opts: {
1470
- app: express.Application;
1471
- collectionName: string;
1472
- adminsOnly: boolean;
1473
- collection: DCEMangoCollection;
1474
- }) => void;
1475
-
1476
1333
  /**
1477
1334
  * Given an array of strings, create a single comma-separated string that includes
1478
1335
  * 'and' as well as an oxford comma.
@@ -1668,63 +1525,14 @@ declare const capitalize: (str: string) => string;
1668
1525
  declare const shuffleArray: <T>(arr: T[]) => T[];
1669
1526
 
1670
1527
  /**
1671
- * Visit an endpoint on another server
1672
- * @author Gabe Abrams
1673
- * @param opts object containing all arguments
1674
- * @param opts.method the method of the endpoint
1675
- * @param opts.path the path of the other server's endpoint
1676
- * @param opts.host the host of the other server
1677
- * @param [opts.params={}] query/body parameters to include
1678
- * @param [opts.responseType=JSON] the response type from the other server
1679
- */
1680
- declare const visitEndpointOnAnotherServer: (opts: {
1681
- method: 'GET' | 'POST' | 'DELETE' | 'PUT';
1682
- path: string;
1683
- host: string;
1684
- params?: {
1685
- [x: string]: any;
1686
- } | undefined;
1687
- responseType?: "Text" | "JSON" | undefined;
1688
- }) => Promise<any>;
1689
-
1690
- /**
1691
- * List of error codes built into the react kit
1528
+ * Get number of words in string
1529
+ * @author Gardenia Liu
1530
+ * @author Allison Zhang
1692
1531
  * @author Gabe Abrams
1532
+ * @param text the string to check
1533
+ * @returns number of words in the string
1693
1534
  */
1694
- declare enum ReactKitErrorCode {
1695
- NoResponse = "DRK1",
1696
- NoCode = "DRK2",
1697
- SessionExpired = "DRK3",
1698
- MissingParameter = "DRK4",
1699
- InvalidParameter = "DRK5",
1700
- HostNotAllowed = "DRK17",
1701
- HostBanned = "DRK18",
1702
- WrongCourse = "DRK6",
1703
- NoCACCLSendRequestFunction = "DRK7",
1704
- NoCACCLGetLaunchInfoFunction = "DRK8",
1705
- NotTTM = "DRK9",
1706
- NotAdmin = "DRK10",
1707
- NotAllowedToReviewLogs = "DRK11",
1708
- ThemeCheckedBeforeReactKitReady = "DRK12",
1709
- SessionExpiredMessageGottenBeforeReactKitReady = "DRK13",
1710
- NotConnected = "DRK14",
1711
- SelfSigned = "DRK15",
1712
- ResponseParseError = "DRK16",
1713
- SignedRequestUnparseable = "DRK28",
1714
- SignedRequestInvalidCollection = "DRK21",
1715
- SignedRequestInvalidCredential = "DRK23",
1716
- SignedRequestInvalidScope = "DRK22",
1717
- SignedRequestInvalidTimestamp = "DRK24",
1718
- SignedRequestInvalidSignature = "DRK25",
1719
- SignedRequestInvalidBody = "DRK26",
1720
- CrossServerNoCredentialsToSignWith = "DRK27",
1721
- CrossServerMissingSignedRequestInfo = "DRK29",
1722
- CrossServerNoCredentialEncodingSalt = "DRK30",
1723
- NoOauthLib = "DRK31",
1724
- NoCryptoLib = "DRK32",
1725
- InvalidCrossServerCredentialsFormat = "DRK33",
1726
- UnknownCrossServerError = "DRK34"
1727
- }
1535
+ declare const getWordCount: (text: string) => number;
1728
1536
 
1729
1537
  /**
1730
1538
  * Days of the week
@@ -1757,14 +1565,16 @@ declare const LogBuiltInMetadata: {
1757
1565
  };
1758
1566
 
1759
1567
  /**
1760
- * Single cross-server credential
1568
+ * List of error codes built into the react kit
1761
1569
  * @author Gabe Abrams
1762
1570
  */
1763
- type CrossServerCredential = {
1764
- description: string;
1765
- key: string;
1766
- encodedeSecret: string;
1767
- scopes: string[];
1768
- };
1571
+ declare enum ReactKitErrorCode {
1572
+ NoResponse = "DRK1",
1573
+ NoCode = "DRK2",
1574
+ SessionExpired = "DRK3",
1575
+ NoCACCLSendRequestFunction = "DRK7",
1576
+ SimpleDateChooserInvalidDateRange = "DRK35",
1577
+ SimpleDateChooserInvalidNumMonths = "DRK36"
1578
+ }
1769
1579
 
1770
- export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, CrossServerCredential, 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, handleError, handleSuccess, idify, initClient, initCrossServerCredentialCollection, 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 };
1580
+ 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_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogFunction, LogLevel, LogMainInfo, LogMetadataType, LogReviewer, LogSource, LogSourceSpecificInfo, LogType, LogTypeSpecificInfo, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, MultiSwitch, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, SimpleTimeChooser, TabBox, ToggleSwitch, Tooltip, Variant, abbreviate, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, 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 };