dce-reactkit 3.2.2-beta.1 → 3.2.2-beta.2

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 (52) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/dist/cjs/index.js +1940 -259
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/types/components/CSVDownloadButton.d.ts +19 -0
  5. package/dist/cjs/types/components/IntelliTable.d.ts +17 -0
  6. package/dist/cjs/types/components/LogReviewer.d.ts +13 -0
  7. package/dist/cjs/types/components/SimpleDateChooser.d.ts +1 -0
  8. package/dist/cjs/types/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.d.ts +6 -0
  9. package/dist/cjs/types/constants/LOG_REVIEW_STATUS_ROUTE.d.ts +7 -0
  10. package/dist/cjs/types/helpers/canReviewLogs.d.ts +7 -0
  11. package/dist/cjs/types/helpers/genCSV.d.ts +14 -0
  12. package/dist/cjs/types/helpers/getMonthName.d.ts +14 -0
  13. package/dist/cjs/types/index.d.ts +8 -1
  14. package/dist/cjs/types/server/initServer.d.ts +8 -0
  15. package/dist/cjs/types/types/IntelliTableColumn.d.ts +12 -0
  16. package/dist/cjs/types/types/LogMetadataType.d.ts +19 -0
  17. package/dist/cjs/types/types/ReactKitErrorCode.d.ts +2 -1
  18. package/dist/esm/index.js +1937 -261
  19. package/dist/esm/index.js.map +1 -1
  20. package/dist/esm/types/components/CSVDownloadButton.d.ts +19 -0
  21. package/dist/esm/types/components/IntelliTable.d.ts +17 -0
  22. package/dist/esm/types/components/LogReviewer.d.ts +13 -0
  23. package/dist/esm/types/components/SimpleDateChooser.d.ts +1 -0
  24. package/dist/esm/types/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.d.ts +6 -0
  25. package/dist/esm/types/constants/LOG_REVIEW_STATUS_ROUTE.d.ts +7 -0
  26. package/dist/esm/types/helpers/canReviewLogs.d.ts +7 -0
  27. package/dist/esm/types/helpers/genCSV.d.ts +14 -0
  28. package/dist/esm/types/helpers/getMonthName.d.ts +14 -0
  29. package/dist/esm/types/index.d.ts +8 -1
  30. package/dist/esm/types/server/initServer.d.ts +8 -0
  31. package/dist/esm/types/types/IntelliTableColumn.d.ts +12 -0
  32. package/dist/esm/types/types/LogMetadataType.d.ts +19 -0
  33. package/dist/esm/types/types/ReactKitErrorCode.d.ts +2 -1
  34. package/dist/index.d.ts +162 -47
  35. package/package.json +1 -1
  36. package/sandbox.js +78 -17
  37. package/src/components/AppWrapper.tsx +5 -1
  38. package/src/components/CSVDownloadButton.tsx +102 -0
  39. package/src/components/IntelliTable.tsx +610 -0
  40. package/src/components/LogReviewer.tsx +2038 -0
  41. package/src/components/SimpleDateChooser.tsx +26 -27
  42. package/src/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.ts +9 -0
  43. package/src/constants/LOG_REVIEW_STATUS_ROUTE.ts +10 -0
  44. package/src/helpers/canReviewLogs.ts +33 -0
  45. package/src/helpers/genCSV.ts +59 -0
  46. package/src/helpers/getHumanReadableDate.ts +6 -17
  47. package/src/helpers/getMonthName.ts +29 -0
  48. package/src/index.ts +14 -0
  49. package/src/server/initServer.ts +105 -3
  50. package/src/types/IntelliTableColumn.ts +24 -0
  51. package/src/types/LogMetadataType.ts +23 -0
  52. package/src/types/ReactKitErrorCode.tsx +2 -1
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Path of the route for storing client-side logs
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const LOG_REVIEW_ROUTE_PATH_PREFIX: string;
6
+ export default LOG_REVIEW_ROUTE_PATH_PREFIX;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Route for checking the status of the current user's
3
+ * access to log review
4
+ * @author Gabe Abrams
5
+ */
6
+ declare const LOG_REVIEW_STATUS_ROUTE: string;
7
+ export default LOG_REVIEW_STATUS_ROUTE;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Check if the current user can review logs
3
+ * @author Gabe Abrams
4
+ * @returns true if current user can review logs
5
+ */
6
+ declare const canReviewLogs: () => Promise<boolean>;
7
+ export default canReviewLogs;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Generate a CSV file
3
+ * @author Gabe Abrams
4
+ * @param data list of row data in the form of json objects
5
+ * @param columns list of columns to include in the csv
6
+ * @returns multiline csv string
7
+ */
8
+ declare const genCSV: (data: {
9
+ [k: string]: any;
10
+ }[], columns: {
11
+ title: string;
12
+ param: string;
13
+ }[]) => string;
14
+ export default genCSV;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Get the name of a month given the month number (1 = January, etc.)
3
+ * If an invalid number is provided, we will treat it like January
4
+ * @author Gabe Abrams
5
+ * @param month the number of the month
6
+ * @returns object containing multiple month name formats:
7
+ * { short, full } where short will look like "Jan" and full will look like
8
+ * "January"
9
+ */
10
+ declare const getMonthName: (month: number) => {
11
+ short: string;
12
+ full: string;
13
+ };
14
+ export default getMonthName;
@@ -13,6 +13,9 @@ import PopFailureMark from './components/PopFailureMark';
13
13
  import PopPendingMark from './components/PopPendingMark';
14
14
  import CopiableBox from './components/CopiableBox';
15
15
  import ItemPicker from './components/ItemPicker';
16
+ import LogReviewer from './components/LogReviewer';
17
+ import IntelliTable from './components/IntelliTable';
18
+ import CSVDownloadButton from './components/CSVDownloadButton';
16
19
  import ErrorWithCode from './errors/ErrorWithCode';
17
20
  import MINUTE_IN_MS from './constants/MINUTE_IN_MS';
18
21
  import HOUR_IN_MS from './constants/HOUR_IN_MS';
@@ -43,6 +46,8 @@ import onlyKeepLetters from './helpers/onlyKeepLetters';
43
46
  import parallelLimit from './helpers/parallelLimit';
44
47
  import logClientEvent from './helpers/logClientEvent';
45
48
  import initLogCollection from './server/initLogCollection';
49
+ import getMonthName from './helpers/getMonthName';
50
+ import genCSV from './helpers/genCSV';
46
51
  import ModalButtonType from './types/ModalButtonType';
47
52
  import ModalSize from './types/ModalSize';
48
53
  import ModalType from './types/ModalType';
@@ -55,5 +60,7 @@ import LogType from './types/LogType';
55
60
  import LogSource from './types/LogSource';
56
61
  import LogAction from './types/LogAction';
57
62
  import LogBuiltInMetadata from './types/LogBuiltInMetadata';
63
+ import LogMetadataType from './types/LogMetadataType';
64
+ import IntelliTableColumn from './types/IntelliTableColumn';
58
65
  import PickableItem from './components/ItemPicker/types/PickableItem';
59
- export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, PickableItem, ParamType, };
66
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, ParamType, };
@@ -25,10 +25,18 @@ export declare const internalGetLogCollection: () => any;
25
25
  * @param opts.getLaunchInfo CACCL LTI's get launch info function
26
26
  * @param [opts.logCollection] mongo collection from dce-mango to use for
27
27
  * storing logs. If none is included, logs are written to the console
28
+ * @param [opts.logReviewAdmins=all admins] info on which admins can review
29
+ * logs from the client. If not included, all Canvas admins are allowed to
30
+ * review logs. If null, no Canvas admins are allowed to review logs.
31
+ * If an array of Canvas userIds (numbers), only Canvas admins with those
32
+ * userIds are allowed to review logs. If a dce-mango collection, only
33
+ * Canvas admins with entries in that collection ({ userId, ...}) are allowed
34
+ * to review logs
28
35
  */
29
36
  declare const initServer: (opts: {
30
37
  app: any;
31
38
  getLaunchInfo: GetLaunchInfoFunction;
32
39
  logCollection?: any;
40
+ logReviewAdmins?: (number[] | any);
33
41
  }) => void;
34
42
  export default initServer;
@@ -0,0 +1,12 @@
1
+ import ParamType from './ParamType';
2
+ /**
3
+ * Column description for a column in the IntelliTable
4
+ * @author Gabe Abrams
5
+ */
6
+ declare type IntelliTableColumn = {
7
+ title: string;
8
+ param: string;
9
+ type: (ParamType.Boolean | ParamType.Float | ParamType.Int | ParamType.String | ParamType.JSON);
10
+ startsHidden?: boolean;
11
+ };
12
+ export default IntelliTableColumn;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Type of a LogMetadata file
3
+ * @author Gabe Abrams
4
+ */
5
+ declare type LogMetadataType = {
6
+ Context?: {
7
+ [k: string]: (string | {
8
+ _: string;
9
+ [k: string]: string;
10
+ });
11
+ };
12
+ Tag?: {
13
+ [k: string]: string;
14
+ };
15
+ Target?: {
16
+ [k: string]: string;
17
+ };
18
+ };
19
+ export default LogMetadataType;
@@ -12,6 +12,7 @@ declare enum ReactKitErrorCode {
12
12
  NoCACCLSendRequestFunction = "DRK7",
13
13
  NoCACCLGetLaunchInfoFunction = "DRK8",
14
14
  NotTTM = "DRK9",
15
- NotAdmin = "DRK10"
15
+ NotAdmin = "DRK10",
16
+ NotAllowedToReviewLogs = "DRK11"
16
17
  }
17
18
  export default ReactKitErrorCode;