dce-reactkit 3.4.0 → 3.5.1-beta.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 (129) hide show
  1. package/.eslintrc.js +2 -0
  2. package/.vscode/settings.json +1 -0
  3. package/dist/cjs/index.js +36372 -191
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/types/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.d.ts +10 -0
  6. package/dist/cjs/types/components/DBEntryManagerPanel/AddOrEditDBEntry/index.d.ts +34 -0
  7. package/dist/cjs/types/components/DBEntryManagerPanel/helpers/generateEndpointPath.d.ts +9 -0
  8. package/dist/cjs/types/components/DBEntryManagerPanel/index.d.ts +25 -0
  9. package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntry.d.ts +8 -0
  10. package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntryField.d.ts +49 -0
  11. package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntryFieldType.d.ts +12 -0
  12. package/dist/cjs/types/helpers/addDBEditorEndpoints.d.ts +40 -0
  13. package/dist/cjs/types/helpers/canReviewLogs.d.ts +0 -5
  14. package/dist/cjs/types/index.d.ts +6 -1
  15. package/dist/esm/index.js +36587 -427
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/types/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.d.ts +10 -0
  18. package/dist/esm/types/components/DBEntryManagerPanel/AddOrEditDBEntry/index.d.ts +34 -0
  19. package/dist/esm/types/components/DBEntryManagerPanel/helpers/generateEndpointPath.d.ts +9 -0
  20. package/dist/esm/types/components/DBEntryManagerPanel/index.d.ts +25 -0
  21. package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntry.d.ts +8 -0
  22. package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntryField.d.ts +49 -0
  23. package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntryFieldType.d.ts +12 -0
  24. package/dist/esm/types/helpers/addDBEditorEndpoints.d.ts +40 -0
  25. package/dist/esm/types/helpers/canReviewLogs.d.ts +0 -5
  26. package/dist/esm/types/index.d.ts +6 -1
  27. package/dist/index.d.ts +166 -35
  28. package/package.json +16 -12
  29. package/src/client/initClient.tsx +23 -31
  30. package/src/components/AppWrapper.tsx +1 -1
  31. package/src/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.tsx +303 -0
  32. package/src/components/DBEntryManagerPanel/AddOrEditDBEntry/index.tsx +737 -0
  33. package/src/components/DBEntryManagerPanel/helpers/generateEndpointPath.ts +16 -0
  34. package/src/components/DBEntryManagerPanel/index.tsx +522 -0
  35. package/src/components/DBEntryManagerPanel/types/DBEntry.ts +7 -0
  36. package/src/components/DBEntryManagerPanel/types/DBEntryField.ts +94 -0
  37. package/src/components/DBEntryManagerPanel/types/DBEntryFieldType.ts +18 -0
  38. package/src/components/ItemPicker/index.test.tsx +10 -10
  39. package/src/helpers/addDBEditorEndpoints.ts +128 -0
  40. package/src/helpers/canReviewLogs.ts +0 -20
  41. package/src/helpers/genCSV.ts +2 -5
  42. package/src/helpers/{getOrdinal.ts → getOrdinal.tsx} +0 -1
  43. package/src/index.ts +11 -9
  44. package/tsconfig.json +2 -6
  45. package/dist/cjs/types/helpers/abbreviate.test.d.ts +0 -5
  46. package/dist/cjs/types/helpers/avg.test.d.ts +0 -5
  47. package/dist/cjs/types/helpers/canReviewLogs.test.d.ts +0 -5
  48. package/dist/cjs/types/helpers/ceilToNumDecimals.test.d.ts +0 -5
  49. package/dist/cjs/types/helpers/compareArraysByProp.test.d.ts +0 -5
  50. package/dist/cjs/types/helpers/extractProp.test.d.ts +0 -5
  51. package/dist/cjs/types/helpers/floorToNumDecimals.test.d.ts +0 -5
  52. package/dist/cjs/types/helpers/forceNumIntoBounds.test.d.ts +0 -5
  53. package/dist/cjs/types/helpers/genCSV.test.d.ts +0 -5
  54. package/dist/cjs/types/helpers/genCommaList.d.ts +0 -12
  55. package/dist/cjs/types/helpers/genCommaList.test.d.ts +0 -1
  56. package/dist/cjs/types/helpers/getHumanReadableDate.test.d.ts +0 -5
  57. package/dist/cjs/types/helpers/getLocalTimeInfo.test.d.ts +0 -6
  58. package/dist/cjs/types/helpers/getMonthName.test.d.ts +0 -5
  59. package/dist/cjs/types/helpers/getOrdinal.test.d.ts +0 -5
  60. package/dist/cjs/types/helpers/getPartOfDay.test.d.ts +0 -5
  61. package/dist/cjs/types/helpers/getTimeInfoInET.test.d.ts +0 -5
  62. package/dist/cjs/types/helpers/validators/shared/constants/ERROR_MESSAGES.d.ts +0 -10
  63. package/dist/cjs/types/helpers/validators/shared/helpers/validateRegex.d.ts +0 -19
  64. package/dist/cjs/types/helpers/validators/shared/types/ValidationResult.d.ts +0 -12
  65. package/dist/cjs/types/helpers/validators/validateEmail.d.ts +0 -11
  66. package/dist/cjs/types/helpers/validators/validateEmail.test.d.ts +0 -1
  67. package/dist/cjs/types/helpers/validators/validatePhoneNumber.d.ts +0 -11
  68. package/dist/cjs/types/helpers/validators/validatePhoneNumber.test.d.ts +0 -1
  69. package/dist/cjs/types/helpers/validators/validateString.d.ts +0 -22
  70. package/dist/cjs/types/helpers/validators/validateString.test.d.ts +0 -1
  71. package/dist/esm/types/helpers/abbreviate.test.d.ts +0 -5
  72. package/dist/esm/types/helpers/avg.test.d.ts +0 -5
  73. package/dist/esm/types/helpers/canReviewLogs.test.d.ts +0 -5
  74. package/dist/esm/types/helpers/ceilToNumDecimals.test.d.ts +0 -5
  75. package/dist/esm/types/helpers/compareArraysByProp.test.d.ts +0 -5
  76. package/dist/esm/types/helpers/extractProp.test.d.ts +0 -5
  77. package/dist/esm/types/helpers/floorToNumDecimals.test.d.ts +0 -5
  78. package/dist/esm/types/helpers/forceNumIntoBounds.test.d.ts +0 -5
  79. package/dist/esm/types/helpers/genCSV.test.d.ts +0 -5
  80. package/dist/esm/types/helpers/genCommaList.d.ts +0 -12
  81. package/dist/esm/types/helpers/genCommaList.test.d.ts +0 -1
  82. package/dist/esm/types/helpers/getHumanReadableDate.test.d.ts +0 -5
  83. package/dist/esm/types/helpers/getLocalTimeInfo.test.d.ts +0 -6
  84. package/dist/esm/types/helpers/getMonthName.test.d.ts +0 -5
  85. package/dist/esm/types/helpers/getOrdinal.test.d.ts +0 -5
  86. package/dist/esm/types/helpers/getPartOfDay.test.d.ts +0 -5
  87. package/dist/esm/types/helpers/getTimeInfoInET.test.d.ts +0 -5
  88. package/dist/esm/types/helpers/validators/shared/constants/ERROR_MESSAGES.d.ts +0 -10
  89. package/dist/esm/types/helpers/validators/shared/helpers/validateRegex.d.ts +0 -19
  90. package/dist/esm/types/helpers/validators/shared/types/ValidationResult.d.ts +0 -12
  91. package/dist/esm/types/helpers/validators/validateEmail.d.ts +0 -11
  92. package/dist/esm/types/helpers/validators/validateEmail.test.d.ts +0 -1
  93. package/dist/esm/types/helpers/validators/validatePhoneNumber.d.ts +0 -11
  94. package/dist/esm/types/helpers/validators/validatePhoneNumber.test.d.ts +0 -1
  95. package/dist/esm/types/helpers/validators/validateString.d.ts +0 -22
  96. package/dist/esm/types/helpers/validators/validateString.test.d.ts +0 -1
  97. package/src/helpers/abbreviate.test.ts +0 -26
  98. package/src/helpers/avg.test.ts +0 -24
  99. package/src/helpers/canReviewLogs.test.ts +0 -67
  100. package/src/helpers/ceilToNumDecimals.test.ts +0 -39
  101. package/src/helpers/compareArraysByProp.test.ts +0 -102
  102. package/src/helpers/extractProp.test.ts +0 -34
  103. package/src/helpers/floorToNumDecimals.test.ts +0 -39
  104. package/src/helpers/forceNumIntoBounds.test.ts +0 -34
  105. package/src/helpers/genCSV.test.ts +0 -61
  106. package/src/helpers/genCommaList.test.ts +0 -57
  107. package/src/helpers/genCommaList.ts +0 -21
  108. package/src/helpers/getHumanReadableDate.test.ts +0 -29
  109. package/src/helpers/getLocalTimeInfo.test.ts +0 -48
  110. package/src/helpers/getMonthName.test.ts +0 -79
  111. package/src/helpers/getOrdinal.test.ts +0 -84
  112. package/src/helpers/getPartOfDay.test.ts +0 -56
  113. package/src/helpers/getTimeInfoInET.test.ts +0 -72
  114. package/src/helpers/validators/shared/constants/ERROR_MESSAGES.ts +0 -18
  115. package/src/helpers/validators/shared/helpers/validateRegex.ts +0 -47
  116. package/src/helpers/validators/shared/types/ValidationResult.ts +0 -20
  117. package/src/helpers/validators/validateEmail.test.ts +0 -110
  118. package/src/helpers/validators/validateEmail.ts +0 -47
  119. package/src/helpers/validators/validatePhoneNumber.test.ts +0 -94
  120. package/src/helpers/validators/validatePhoneNumber.ts +0 -49
  121. package/src/helpers/validators/validateString.test.ts +0 -175
  122. package/src/helpers/validators/validateString.ts +0 -171
  123. /package/src/helpers/{abbreviate.ts → abbreviate.tsx} +0 -0
  124. /package/src/helpers/{avg.ts → avg.tsx} +0 -0
  125. /package/src/helpers/{ceilToNumDecimals.ts → ceilToNumDecimals.tsx} +0 -0
  126. /package/src/helpers/{floorToNumDecimals.ts → floorToNumDecimals.tsx} +0 -0
  127. /package/src/helpers/{forceNumIntoBounds.ts → forceNumIntoBounds.tsx} +0 -0
  128. /package/src/helpers/{getLocalTimeInfo.ts → getLocalTimeInfo.tsx} +0 -0
  129. /package/src/helpers/{getTimeInfoInET.ts → getTimeInfoInET.tsx} +0 -0
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import DBEntryFieldType from '../types/DBEntryFieldType';
3
+ declare type Props = {
4
+ type: DBEntryFieldType.StringArray | DBEntryFieldType.NumberArray;
5
+ values: string[] | number[];
6
+ onChange: (values: string[] | number[]) => void;
7
+ disabled?: boolean;
8
+ };
9
+ declare const CreatableMultiselect: React.FC<Props>;
10
+ export default CreatableMultiselect;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Panel for adding a DBEntry to the database
3
+ * @author Yuen Ler Chow
4
+ */
5
+ import React from 'react';
6
+ import DBEntry from '../types/DBEntry';
7
+ import DBEntryField from '../types/DBEntryField';
8
+ declare type Props = {
9
+ /**
10
+ * Handler for when the user finishes adding the DBEntry
11
+ * (if no DBEntry is returned, process was cancelled)
12
+ * @param DBEntry the DBEntry that was just created
13
+ */
14
+ onFinished: (dbEntry?: DBEntry) => void;
15
+ /**
16
+ * Function to validate the DBEntry before saving
17
+ * @param dbEntry
18
+ */
19
+ validateEntry?: (dbEntry: DBEntry) => Promise<void>;
20
+ /**
21
+ * Function to modify the DBEntry before saving
22
+ * @param dbEntry
23
+ * @returns the modified DBEntry
24
+ */
25
+ modifyEntry?: (dbEntry: DBEntry) => DBEntry;
26
+ entryFields: DBEntryField[];
27
+ dbEntryToEdit?: DBEntry;
28
+ idPropName: string;
29
+ itemName: string;
30
+ saveEndpointPath: string;
31
+ entries: DBEntry[];
32
+ };
33
+ declare const AddOrEditDBEntry: React.FC<Props>;
34
+ export default AddOrEditDBEntry;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generates the endpoint path for the given collection name
3
+ * @author Yuen Ler Chow
4
+ * @param collectionName the name of the collection
5
+ * @param [adminsOnly] true if the endpoint is for admins only
6
+ * @returns the endpoint path
7
+ */
8
+ declare const generateEndpointPath: (collectionName: string, adminsOnly?: boolean | undefined) => string;
9
+ export default generateEndpointPath;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * DB Entry Manager Panel
3
+ * @author Yuen Ler Chow
4
+ */
5
+ import React from 'react';
6
+ import DBEntry from './types/DBEntry';
7
+ import DBEntryField from './types/DBEntryField';
8
+ declare type Props = {
9
+ entryFields: DBEntryField[];
10
+ idPropName: string;
11
+ titlePropName: string;
12
+ descriptionPropName: string;
13
+ itemListTitle: string;
14
+ itemName: string;
15
+ validateEntry?: (dbEntry: DBEntry) => Promise<void>;
16
+ modifyEntry?: (dbEntry: DBEntry) => Promise<DBEntry>;
17
+ disableEdit?: boolean;
18
+ collectionName: string;
19
+ adminsOnly?: boolean;
20
+ filterQuery?: {
21
+ [k: string]: any;
22
+ };
23
+ };
24
+ declare const DBEntryManagerPanel: React.FC<Props>;
25
+ export default DBEntryManagerPanel;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Generic type for an object
3
+ * @author Yuen Ler Chow
4
+ */
5
+ declare type DBEntry = {
6
+ [k: string]: any;
7
+ };
8
+ export default DBEntry;
@@ -0,0 +1,49 @@
1
+ import DBEntryFieldType from './DBEntryFieldType';
2
+ /**
3
+ * A database entry input field
4
+ * @author Yuen Ler Chow
5
+ */
6
+ declare type DBEntryField = ({
7
+ label: string;
8
+ objectKey: string;
9
+ placeholder: string;
10
+ lockAfterCreation?: boolean;
11
+ required?: boolean;
12
+ } & ({
13
+ type: DBEntryFieldType.String;
14
+ minNumChars?: number;
15
+ maxNumChars?: number;
16
+ defaultValue?: string;
17
+ choices?: {
18
+ title: string;
19
+ value: string;
20
+ }[];
21
+ } | {
22
+ type: DBEntryFieldType.Number;
23
+ minNumber?: number;
24
+ maxNumber?: number;
25
+ defaultValue?: number;
26
+ } | {
27
+ type: DBEntryFieldType.StringArray;
28
+ minNumElements?: number;
29
+ maxNumElements?: number;
30
+ defaultValue?: string[];
31
+ choices?: {
32
+ title: string;
33
+ value: string;
34
+ }[];
35
+ } | {
36
+ type: DBEntryFieldType.NumberArray;
37
+ minNumElements?: number;
38
+ maxNumElements?: number;
39
+ minNumber?: number;
40
+ maxNumber?: number;
41
+ defaultValue?: number[];
42
+ } | {
43
+ type: DBEntryFieldType.Object;
44
+ defaultValue?: {
45
+ [k: string]: any;
46
+ };
47
+ subfields: DBEntryField[];
48
+ }));
49
+ export default DBEntryField;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Options for field types
3
+ * @author Yuen Ler Chow
4
+ */
5
+ declare enum DBEntryFieldType {
6
+ String = "String",
7
+ Number = "Number",
8
+ Object = "Object",
9
+ StringArray = "StringArray",
10
+ NumberArray = "NumberArray"
11
+ }
12
+ export default DBEntryFieldType;
@@ -0,0 +1,40 @@
1
+ import express from 'express';
2
+ /**
3
+ * Interface for a collection in the database
4
+ * @author Yuen Ler Chow
5
+ */
6
+ interface Collection {
7
+ /**
8
+ * Find all items in the collection that match the filter query
9
+ * @param filterQuery
10
+ * @returns list of items that match the filter query
11
+ */
12
+ find: (filterQuery: any) => Promise<any[]>;
13
+ /**
14
+ * Insert an item into the collection
15
+ * @param item the item to insert
16
+ */
17
+ insert: (item: any) => Promise<void>;
18
+ /**
19
+ * Delete an item in the collection
20
+ * @param id the id of the item to delete
21
+ */
22
+ delete: (filterQuery: {
23
+ id: string;
24
+ }) => Promise<void>;
25
+ }
26
+ /**
27
+ * Add all routes for the DBEditor
28
+ * @author Yuen Ler Chow
29
+ * @param opts object containing all arguments
30
+ * @param opts.app express app to add routes too
31
+ * @param opts.collectionName the name of the collection
32
+ * @param opts.adminsOnly true if the endpoint is for admins only
33
+ */
34
+ declare const addDBEditorEndpoints: (opts: {
35
+ app: express.Application;
36
+ collectionName: string;
37
+ adminsOnly: boolean;
38
+ collection: Collection;
39
+ }) => void;
40
+ export default addDBEditorEndpoints;
@@ -1,8 +1,3 @@
1
- /**
2
- * Reset the cached version of canReview
3
- * @author Gabe Abrams
4
- */
5
- export declare const resetCanReviewCache: () => void;
6
1
  /**
7
2
  * Check if the current user can review logs
8
3
  * @author Gabe Abrams
@@ -16,6 +16,7 @@ import ItemPicker from './components/ItemPicker';
16
16
  import LogReviewer from './components/LogReviewer';
17
17
  import IntelliTable from './components/IntelliTable';
18
18
  import CSVDownloadButton from './components/CSVDownloadButton';
19
+ import DBEntryManagerPanel from './components/DBEntryManagerPanel';
19
20
  import ErrorWithCode from './errors/ErrorWithCode';
20
21
  import MINUTE_IN_MS from './constants/MINUTE_IN_MS';
21
22
  import HOUR_IN_MS from './constants/HOUR_IN_MS';
@@ -55,6 +56,7 @@ import isMobileOrTablet from './helpers/isMobileOrTablet';
55
56
  import extractProp from './helpers/extractProp';
56
57
  import compareArraysByProp from './helpers/compareArraysByProp';
57
58
  import getLocalTimeInfo from './helpers/getLocalTimeInfo';
59
+ import addDBEditorEndpoints from './helpers/addDBEditorEndpoints';
58
60
  import ModalButtonType from './types/ModalButtonType';
59
61
  import ModalSize from './types/ModalSize';
60
62
  import ModalType from './types/ModalType';
@@ -70,4 +72,7 @@ import LogBuiltInMetadata from './types/LogBuiltInMetadata';
70
72
  import LogMetadataType from './types/LogMetadataType';
71
73
  import IntelliTableColumn from './types/IntelliTableColumn';
72
74
  import PickableItem from './components/ItemPicker/types/PickableItem';
73
- 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, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, getLocalTimeInfo, initClient, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, ParamType, };
75
+ import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
76
+ import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
77
+ import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
78
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, getLocalTimeInfo, initClient, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import React from 'react';
3
+ import express from 'express';
3
4
 
4
5
  /**
5
6
  * Bootstrap variants
@@ -22,7 +23,7 @@ declare enum Variant {
22
23
  * @author Gabe Abrams
23
24
  */
24
25
 
25
- declare type Props$g = {
26
+ declare type Props$h = {
26
27
  children: React.ReactNode;
27
28
  dark?: boolean;
28
29
  };
@@ -61,7 +62,7 @@ declare const confirm: (title: string, text: string, opts?: {
61
62
  * @param [errorTitle] title of the error box
62
63
  */
63
64
  declare const showFatalError: (error: any, errorTitle?: string) => undefined;
64
- declare const AppWrapper: React.FC<Props$g>;
65
+ declare const AppWrapper: React.FC<Props$h>;
65
66
 
66
67
  /**
67
68
  * Loading spinner/indicator
@@ -74,12 +75,12 @@ declare const LoadingSpinner: () => JSX.Element;
74
75
  * @author Gabe Abrams
75
76
  */
76
77
 
77
- declare type Props$f = {
78
+ declare type Props$g = {
78
79
  error: any;
79
80
  title?: string;
80
81
  onClose?: () => void;
81
82
  };
82
- declare const ErrorBox: React.FC<Props$f>;
83
+ declare const ErrorBox: React.FC<Props$g>;
83
84
 
84
85
  /**
85
86
  * Types of buttons in the modal
@@ -130,7 +131,7 @@ declare enum ModalType {
130
131
  * @author Gabe Abrams
131
132
  */
132
133
 
133
- declare type Props$e = {
134
+ declare type Props$f = {
134
135
  type?: ModalType;
135
136
  size?: ModalSize;
136
137
  title?: React.ReactNode;
@@ -159,27 +160,27 @@ declare type Props$e = {
159
160
  confirmVariant?: Variant;
160
161
  onTopOfOtherModals?: boolean;
161
162
  };
162
- declare const Modal: React.FC<Props$e>;
163
+ declare const Modal: React.FC<Props$f>;
163
164
 
164
165
  /**
165
166
  * A box with a tab on the top that holds buttons and other content
166
167
  * @author Gabe Abrams
167
168
  */
168
169
 
169
- declare type Props$d = {
170
+ declare type Props$e = {
170
171
  title: React.ReactNode;
171
172
  children: React.ReactNode;
172
173
  noBottomMargin?: boolean;
173
174
  noBottomPadding?: boolean;
174
175
  };
175
- declare const TabBox: React.FC<Props$d>;
176
+ declare const TabBox: React.FC<Props$e>;
176
177
 
177
178
  /**
178
179
  * A radio selection button
179
180
  * @author Gabe Abrams
180
181
  */
181
182
 
182
- declare type Props$c = {
183
+ declare type Props$d = {
183
184
  text: string;
184
185
  onSelected: () => void;
185
186
  ariaLabel: string;
@@ -191,14 +192,14 @@ declare type Props$c = {
191
192
  unselectedVariant?: Variant;
192
193
  small?: boolean;
193
194
  };
194
- declare const RadioButton: React.FC<Props$c>;
195
+ declare const RadioButton: React.FC<Props$d>;
195
196
 
196
197
  /**
197
198
  * A checkbox button
198
199
  * @author Gabe Abrams
199
200
  */
200
201
 
201
- declare type Props$b = {
202
+ declare type Props$c = {
202
203
  text: string;
203
204
  onChanged: (checked: boolean) => void;
204
205
  ariaLabel: string;
@@ -212,28 +213,28 @@ declare type Props$b = {
212
213
  small?: boolean;
213
214
  dashed?: boolean;
214
215
  };
215
- declare const CheckboxButton: React.FC<Props$b>;
216
+ declare const CheckboxButton: React.FC<Props$c>;
216
217
 
217
218
  /**
218
219
  * Input group with a title and space for buttons
219
220
  * @author Gabe Abrams
220
221
  */
221
222
 
222
- declare type Props$a = {
223
+ declare type Props$b = {
223
224
  label: string;
224
225
  minLabelWidth?: string;
225
226
  children: React.ReactNode;
226
227
  className?: string;
227
228
  wrapButtonsAndAddGaps?: boolean;
228
229
  };
229
- declare const ButtonInputGroup: React.FC<Props$a>;
230
+ declare const ButtonInputGroup: React.FC<Props$b>;
230
231
 
231
232
  /**
232
233
  * A very simple, lightweight date chooser
233
234
  * @author Gabe Abrams
234
235
  */
235
236
 
236
- declare type Props$9 = {
237
+ declare type Props$a = {
237
238
  ariaLabel: string;
238
239
  name: string;
239
240
  month: number;
@@ -249,61 +250,61 @@ declare type Props$9 = {
249
250
  numMonthsToShow?: number;
250
251
  chooseFromPast?: boolean;
251
252
  };
252
- declare const SimpleDateChooser: React.FC<Props$9>;
253
+ declare const SimpleDateChooser: React.FC<Props$a>;
253
254
 
254
255
  /**
255
256
  * Drawer container
256
257
  * @author Gabe Abrams
257
258
  */
258
259
 
259
- declare type Props$8 = {
260
+ declare type Props$9 = {
260
261
  customBackgroundColor?: string;
261
262
  children: React.ReactNode;
262
263
  };
263
- declare const Drawer: React.FC<Props$8>;
264
+ declare const Drawer: React.FC<Props$9>;
264
265
 
265
266
  /**
266
267
  * Success checkmark that pops into view
267
268
  * @author Gabe Abrams
268
269
  */
269
270
 
270
- declare type Props$7 = {
271
+ declare type Props$8 = {
271
272
  sizeRem?: number;
272
273
  circleVariant?: string;
273
274
  checkVariant?: string;
274
275
  };
275
- declare const PopSuccessMark: React.FC<Props$7>;
276
+ declare const PopSuccessMark: React.FC<Props$8>;
276
277
 
277
278
  /**
278
279
  * Failure x mark that pops into view
279
280
  * @author Gabe Abrams
280
281
  */
281
282
 
282
- declare type Props$6 = {
283
+ declare type Props$7 = {
283
284
  sizeRem?: number;
284
285
  circleVariant?: string;
285
286
  xVariant?: string;
286
287
  };
287
- declare const PopFailureMark: React.FC<Props$6>;
288
+ declare const PopFailureMark: React.FC<Props$7>;
288
289
 
289
290
  /**
290
291
  * Failure pending that pops into view
291
292
  * @author Gabe Abrams
292
293
  */
293
294
 
294
- declare type Props$5 = {
295
+ declare type Props$6 = {
295
296
  sizeRem?: number;
296
297
  circleVariant?: string;
297
298
  hourglassVariant?: string;
298
299
  };
299
- declare const PopPendingMark: React.FC<Props$5>;
300
+ declare const PopPendingMark: React.FC<Props$6>;
300
301
 
301
302
  /**
302
303
  * Copiable text box
303
304
  * @author Gabe Abrams
304
305
  */
305
306
 
306
- declare type Props$4 = {
307
+ declare type Props$5 = {
307
308
  text: string;
308
309
  maxTextWidthRem?: number;
309
310
  label?: string;
@@ -315,7 +316,7 @@ declare type Props$4 = {
315
316
  textAreaId?: string;
316
317
  copyButtonId?: string;
317
318
  };
318
- declare const CopiableBox: React.FC<Props$4>;
319
+ declare const CopiableBox: React.FC<Props$5>;
319
320
 
320
321
  /**
321
322
  * An item that can be chosen (for use within ItemPicker)
@@ -338,7 +339,7 @@ declare type PickableItem = ({
338
339
  * @author Yuen Ler Chow
339
340
  */
340
341
 
341
- declare type Props$3 = {
342
+ declare type Props$4 = {
342
343
  title: string;
343
344
  items: PickableItem[];
344
345
  /**
@@ -349,7 +350,7 @@ declare type Props$3 = {
349
350
  onChanged: (updatedItems: PickableItem[]) => void;
350
351
  noBottomMargin?: boolean;
351
352
  };
352
- declare const ItemPicker: React.FC<Props$3>;
353
+ declare const ItemPicker: React.FC<Props$4>;
353
354
 
354
355
  /**
355
356
  * Type of the context map in a LogMetadata file
@@ -394,11 +395,11 @@ declare type LogMetadataType = {
394
395
  * @author Gabe Abrams
395
396
  */
396
397
 
397
- declare type Props$2 = {
398
+ declare type Props$3 = {
398
399
  LogMetadata: LogMetadataType;
399
400
  onClose: () => void;
400
401
  };
401
- declare const LogReviewer: React.FC<Props$2>;
402
+ declare const LogReviewer: React.FC<Props$3>;
402
403
 
403
404
  /**
404
405
  * Server-side API param types
@@ -433,7 +434,7 @@ declare type IntelliTableColumn = {
433
434
  * @author Gabe Abrams
434
435
  */
435
436
 
436
- declare type Props$1 = {
437
+ declare type Props$2 = {
437
438
  title: string;
438
439
  id: string;
439
440
  data: {
@@ -443,14 +444,14 @@ declare type Props$1 = {
443
444
  columns: IntelliTableColumn[];
444
445
  csvName?: string;
445
446
  };
446
- declare const IntelliTable: React.FC<Props$1>;
447
+ declare const IntelliTable: React.FC<Props$2>;
447
448
 
448
449
  /**
449
450
  * Button for downloading a csv file
450
451
  * @author Gabe Abrams
451
452
  */
452
453
 
453
- declare type Props = {
454
+ declare type Props$1 = {
454
455
  filename: string;
455
456
  csv: string;
456
457
  id?: string;
@@ -462,7 +463,98 @@ declare type Props = {
462
463
  onClick?: () => void;
463
464
  children?: React.ReactNode;
464
465
  };
465
- declare const CSVDownloadButton: React.FC<Props>;
466
+ declare const CSVDownloadButton: React.FC<Props$1>;
467
+
468
+ /**
469
+ * Generic type for an object
470
+ * @author Yuen Ler Chow
471
+ */
472
+ declare type DBEntry = {
473
+ [k: string]: any;
474
+ };
475
+
476
+ /**
477
+ * Options for field types
478
+ * @author Yuen Ler Chow
479
+ */
480
+ declare enum DBEntryFieldType {
481
+ String = "String",
482
+ Number = "Number",
483
+ Object = "Object",
484
+ StringArray = "StringArray",
485
+ NumberArray = "NumberArray"
486
+ }
487
+
488
+ /**
489
+ * A database entry input field
490
+ * @author Yuen Ler Chow
491
+ */
492
+ declare type DBEntryField = ({
493
+ label: string;
494
+ objectKey: string;
495
+ placeholder: string;
496
+ lockAfterCreation?: boolean;
497
+ required?: boolean;
498
+ } & ({
499
+ type: DBEntryFieldType.String;
500
+ minNumChars?: number;
501
+ maxNumChars?: number;
502
+ defaultValue?: string;
503
+ choices?: {
504
+ title: string;
505
+ value: string;
506
+ }[];
507
+ } | {
508
+ type: DBEntryFieldType.Number;
509
+ minNumber?: number;
510
+ maxNumber?: number;
511
+ defaultValue?: number;
512
+ } | {
513
+ type: DBEntryFieldType.StringArray;
514
+ minNumElements?: number;
515
+ maxNumElements?: number;
516
+ defaultValue?: string[];
517
+ choices?: {
518
+ title: string;
519
+ value: string;
520
+ }[];
521
+ } | {
522
+ type: DBEntryFieldType.NumberArray;
523
+ minNumElements?: number;
524
+ maxNumElements?: number;
525
+ minNumber?: number;
526
+ maxNumber?: number;
527
+ defaultValue?: number[];
528
+ } | {
529
+ type: DBEntryFieldType.Object;
530
+ defaultValue?: {
531
+ [k: string]: any;
532
+ };
533
+ subfields: DBEntryField[];
534
+ }));
535
+
536
+ /**
537
+ * DB Entry Manager Panel
538
+ * @author Yuen Ler Chow
539
+ */
540
+
541
+ declare type Props = {
542
+ entryFields: DBEntryField[];
543
+ idPropName: string;
544
+ titlePropName: string;
545
+ descriptionPropName: string;
546
+ itemListTitle: string;
547
+ itemName: string;
548
+ validateEntry?: (dbEntry: DBEntry) => Promise<void>;
549
+ modifyEntry?: (dbEntry: DBEntry) => Promise<DBEntry>;
550
+ disableEdit?: boolean;
551
+ collectionName: string;
552
+ adminsOnly?: boolean;
553
+ filterQuery?: {
554
+ [k: string]: any;
555
+ };
556
+ };
557
+ declare const DBEntryManagerPanel: React.FC<Props>;
466
558
 
467
559
  /**
468
560
  * An error with a code
@@ -1085,6 +1177,45 @@ declare const getLocalTimeInfo: (dateOrTimestamp?: number | Date | undefined) =>
1085
1177
  isPM: boolean;
1086
1178
  };
1087
1179
 
1180
+ /**
1181
+ * Interface for a collection in the database
1182
+ * @author Yuen Ler Chow
1183
+ */
1184
+ interface Collection {
1185
+ /**
1186
+ * Find all items in the collection that match the filter query
1187
+ * @param filterQuery
1188
+ * @returns list of items that match the filter query
1189
+ */
1190
+ find: (filterQuery: any) => Promise<any[]>;
1191
+ /**
1192
+ * Insert an item into the collection
1193
+ * @param item the item to insert
1194
+ */
1195
+ insert: (item: any) => Promise<void>;
1196
+ /**
1197
+ * Delete an item in the collection
1198
+ * @param id the id of the item to delete
1199
+ */
1200
+ delete: (filterQuery: {
1201
+ id: string;
1202
+ }) => Promise<void>;
1203
+ }
1204
+ /**
1205
+ * Add all routes for the DBEditor
1206
+ * @author Yuen Ler Chow
1207
+ * @param opts object containing all arguments
1208
+ * @param opts.app express app to add routes too
1209
+ * @param opts.collectionName the name of the collection
1210
+ * @param opts.adminsOnly true if the endpoint is for admins only
1211
+ */
1212
+ declare const addDBEditorEndpoints: (opts: {
1213
+ app: express.Application;
1214
+ collectionName: string;
1215
+ adminsOnly: boolean;
1216
+ collection: Collection;
1217
+ }) => void;
1218
+
1088
1219
  /**
1089
1220
  * List of error codes built into the react kit
1090
1221
  * @author Gabe Abrams
@@ -1135,4 +1266,4 @@ declare const LogBuiltInMetadata: {
1135
1266
  };
1136
1267
  };
1137
1268
 
1138
- export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initClient, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
1269
+ export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, addDBEditorEndpoints, alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initClient, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };