dce-reactkit 3.4.0-beta.8 → 3.4.0

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 (128) hide show
  1. package/.eslintrc.js +0 -2
  2. package/dist/cjs/index.js +190 -36371
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/types/helpers/abbreviate.test.d.ts +5 -0
  5. package/dist/cjs/types/helpers/avg.test.d.ts +5 -0
  6. package/dist/cjs/types/helpers/canReviewLogs.d.ts +5 -0
  7. package/dist/cjs/types/helpers/canReviewLogs.test.d.ts +5 -0
  8. package/dist/cjs/types/helpers/ceilToNumDecimals.test.d.ts +5 -0
  9. package/dist/cjs/types/helpers/compareArraysByProp.test.d.ts +5 -0
  10. package/dist/cjs/types/helpers/extractProp.test.d.ts +5 -0
  11. package/dist/cjs/types/helpers/floorToNumDecimals.test.d.ts +5 -0
  12. package/dist/cjs/types/helpers/forceNumIntoBounds.test.d.ts +5 -0
  13. package/dist/cjs/types/helpers/genCSV.test.d.ts +5 -0
  14. package/dist/cjs/types/helpers/genCommaList.d.ts +12 -0
  15. package/dist/cjs/types/helpers/genCommaList.test.d.ts +1 -0
  16. package/dist/cjs/types/helpers/getHumanReadableDate.test.d.ts +5 -0
  17. package/dist/cjs/types/helpers/getLocalTimeInfo.test.d.ts +6 -0
  18. package/dist/cjs/types/helpers/getMonthName.test.d.ts +5 -0
  19. package/dist/cjs/types/helpers/getOrdinal.test.d.ts +5 -0
  20. package/dist/cjs/types/helpers/getPartOfDay.test.d.ts +5 -0
  21. package/dist/cjs/types/helpers/getTimeInfoInET.test.d.ts +5 -0
  22. package/dist/cjs/types/helpers/validators/shared/constants/ERROR_MESSAGES.d.ts +10 -0
  23. package/dist/cjs/types/helpers/validators/shared/helpers/validateRegex.d.ts +19 -0
  24. package/dist/cjs/types/helpers/validators/shared/types/ValidationResult.d.ts +12 -0
  25. package/dist/cjs/types/helpers/validators/validateEmail.d.ts +11 -0
  26. package/dist/cjs/types/helpers/validators/validateEmail.test.d.ts +1 -0
  27. package/dist/cjs/types/helpers/validators/validatePhoneNumber.d.ts +11 -0
  28. package/dist/cjs/types/helpers/validators/validatePhoneNumber.test.d.ts +1 -0
  29. package/dist/cjs/types/helpers/validators/validateString.d.ts +22 -0
  30. package/dist/cjs/types/helpers/validators/validateString.test.d.ts +1 -0
  31. package/dist/cjs/types/index.d.ts +1 -6
  32. package/dist/esm/index.js +419 -36579
  33. package/dist/esm/index.js.map +1 -1
  34. package/dist/esm/types/helpers/abbreviate.test.d.ts +5 -0
  35. package/dist/esm/types/helpers/avg.test.d.ts +5 -0
  36. package/dist/esm/types/helpers/canReviewLogs.d.ts +5 -0
  37. package/dist/esm/types/helpers/canReviewLogs.test.d.ts +5 -0
  38. package/dist/esm/types/helpers/ceilToNumDecimals.test.d.ts +5 -0
  39. package/dist/esm/types/helpers/compareArraysByProp.test.d.ts +5 -0
  40. package/dist/esm/types/helpers/extractProp.test.d.ts +5 -0
  41. package/dist/esm/types/helpers/floorToNumDecimals.test.d.ts +5 -0
  42. package/dist/esm/types/helpers/forceNumIntoBounds.test.d.ts +5 -0
  43. package/dist/esm/types/helpers/genCSV.test.d.ts +5 -0
  44. package/dist/esm/types/helpers/genCommaList.d.ts +12 -0
  45. package/dist/esm/types/helpers/genCommaList.test.d.ts +1 -0
  46. package/dist/esm/types/helpers/getHumanReadableDate.test.d.ts +5 -0
  47. package/dist/esm/types/helpers/getLocalTimeInfo.test.d.ts +6 -0
  48. package/dist/esm/types/helpers/getMonthName.test.d.ts +5 -0
  49. package/dist/esm/types/helpers/getOrdinal.test.d.ts +5 -0
  50. package/dist/esm/types/helpers/getPartOfDay.test.d.ts +5 -0
  51. package/dist/esm/types/helpers/getTimeInfoInET.test.d.ts +5 -0
  52. package/dist/esm/types/helpers/validators/shared/constants/ERROR_MESSAGES.d.ts +10 -0
  53. package/dist/esm/types/helpers/validators/shared/helpers/validateRegex.d.ts +19 -0
  54. package/dist/esm/types/helpers/validators/shared/types/ValidationResult.d.ts +12 -0
  55. package/dist/esm/types/helpers/validators/validateEmail.d.ts +11 -0
  56. package/dist/esm/types/helpers/validators/validateEmail.test.d.ts +1 -0
  57. package/dist/esm/types/helpers/validators/validatePhoneNumber.d.ts +11 -0
  58. package/dist/esm/types/helpers/validators/validatePhoneNumber.test.d.ts +1 -0
  59. package/dist/esm/types/helpers/validators/validateString.d.ts +22 -0
  60. package/dist/esm/types/helpers/validators/validateString.test.d.ts +1 -0
  61. package/dist/esm/types/index.d.ts +1 -6
  62. package/dist/index.d.ts +35 -166
  63. package/package.json +13 -17
  64. package/src/client/initClient.tsx +20 -12
  65. package/src/components/AppWrapper.tsx +1 -1
  66. package/src/components/ItemPicker/index.test.tsx +10 -10
  67. package/src/helpers/abbreviate.test.ts +26 -0
  68. package/src/helpers/avg.test.ts +24 -0
  69. package/src/helpers/canReviewLogs.test.ts +67 -0
  70. package/src/helpers/canReviewLogs.ts +20 -0
  71. package/src/helpers/ceilToNumDecimals.test.ts +39 -0
  72. package/src/helpers/compareArraysByProp.test.ts +102 -0
  73. package/src/helpers/extractProp.test.ts +34 -0
  74. package/src/helpers/floorToNumDecimals.test.ts +39 -0
  75. package/src/helpers/forceNumIntoBounds.test.ts +34 -0
  76. package/src/helpers/genCSV.test.ts +61 -0
  77. package/src/helpers/genCSV.ts +5 -2
  78. package/src/helpers/genCommaList.test.ts +57 -0
  79. package/src/helpers/genCommaList.ts +21 -0
  80. package/src/helpers/getHumanReadableDate.test.ts +29 -0
  81. package/src/helpers/getLocalTimeInfo.test.ts +48 -0
  82. package/src/helpers/getMonthName.test.ts +79 -0
  83. package/src/helpers/getOrdinal.test.ts +84 -0
  84. package/src/helpers/{getOrdinal.tsx → getOrdinal.ts} +1 -0
  85. package/src/helpers/getPartOfDay.test.ts +56 -0
  86. package/src/helpers/getTimeInfoInET.test.ts +72 -0
  87. package/src/helpers/validators/shared/constants/ERROR_MESSAGES.ts +18 -0
  88. package/src/helpers/validators/shared/helpers/validateRegex.ts +47 -0
  89. package/src/helpers/validators/shared/types/ValidationResult.ts +20 -0
  90. package/src/helpers/validators/validateEmail.test.ts +110 -0
  91. package/src/helpers/validators/validateEmail.ts +47 -0
  92. package/src/helpers/validators/validatePhoneNumber.test.ts +94 -0
  93. package/src/helpers/validators/validatePhoneNumber.ts +49 -0
  94. package/src/helpers/validators/validateString.test.ts +175 -0
  95. package/src/helpers/validators/validateString.ts +171 -0
  96. package/src/index.ts +10 -12
  97. package/tsconfig.json +6 -2
  98. package/dist/cjs/types/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.d.ts +0 -10
  99. package/dist/cjs/types/components/DBEntryManagerPanel/AddOrEditDBEntry/index.d.ts +0 -34
  100. package/dist/cjs/types/components/DBEntryManagerPanel/helpers/generateEndpointPath.d.ts +0 -9
  101. package/dist/cjs/types/components/DBEntryManagerPanel/index.d.ts +0 -25
  102. package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntry.d.ts +0 -8
  103. package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntryField.d.ts +0 -49
  104. package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntryFieldType.d.ts +0 -12
  105. package/dist/cjs/types/helpers/addDBEditorEndpoints.d.ts +0 -40
  106. package/dist/esm/types/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.d.ts +0 -10
  107. package/dist/esm/types/components/DBEntryManagerPanel/AddOrEditDBEntry/index.d.ts +0 -34
  108. package/dist/esm/types/components/DBEntryManagerPanel/helpers/generateEndpointPath.d.ts +0 -9
  109. package/dist/esm/types/components/DBEntryManagerPanel/index.d.ts +0 -25
  110. package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntry.d.ts +0 -8
  111. package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntryField.d.ts +0 -49
  112. package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntryFieldType.d.ts +0 -12
  113. package/dist/esm/types/helpers/addDBEditorEndpoints.d.ts +0 -40
  114. package/src/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.tsx +0 -286
  115. package/src/components/DBEntryManagerPanel/AddOrEditDBEntry/index.tsx +0 -722
  116. package/src/components/DBEntryManagerPanel/helpers/generateEndpointPath.ts +0 -15
  117. package/src/components/DBEntryManagerPanel/index.tsx +0 -511
  118. package/src/components/DBEntryManagerPanel/types/DBEntry.ts +0 -7
  119. package/src/components/DBEntryManagerPanel/types/DBEntryField.ts +0 -94
  120. package/src/components/DBEntryManagerPanel/types/DBEntryFieldType.ts +0 -18
  121. package/src/helpers/addDBEditorEndpoints.ts +0 -124
  122. /package/src/helpers/{abbreviate.tsx → abbreviate.ts} +0 -0
  123. /package/src/helpers/{avg.tsx → avg.ts} +0 -0
  124. /package/src/helpers/{ceilToNumDecimals.tsx → ceilToNumDecimals.ts} +0 -0
  125. /package/src/helpers/{floorToNumDecimals.tsx → floorToNumDecimals.ts} +0 -0
  126. /package/src/helpers/{forceNumIntoBounds.tsx → forceNumIntoBounds.ts} +0 -0
  127. /package/src/helpers/{getLocalTimeInfo.tsx → getLocalTimeInfo.ts} +0 -0
  128. /package/src/helpers/{getTimeInfoInET.tsx → getTimeInfoInET.ts} +0 -0
@@ -0,0 +1,175 @@
1
+ // Import helpers
2
+ import genCommaList from '../genCommaList';
3
+
4
+ // Import types
5
+ import ValidationResult from './shared/types/ValidationResult';
6
+
7
+ // Import constants
8
+ import { INVALID_STRING_ERRORS, INVALID_REGEX_ERROR } from './shared/constants/ERROR_MESSAGES';
9
+
10
+ // Import function
11
+ import validateString from './validateString';
12
+
13
+ /*------------------------------------------------------------------------*/
14
+ /* ---------------------------- Valid Tests --------------------------- */
15
+ /*------------------------------------------------------------------------*/
16
+
17
+ const validStrings: string[] = [
18
+ 'users',
19
+ 'username',
20
+ 'MyValidString',
21
+ 'HereisAnotherValidString',
22
+ 'WoahAnotherValidStringIsHere',
23
+ ];
24
+
25
+ const validReqs: {
26
+ // whitespace is removed from input before checking and returning
27
+ ignoreWhitespace?: boolean,
28
+ // input length must be at least minLen
29
+ minLen?: number,
30
+ // input length must be at most maxLen
31
+ maxLen?: number,
32
+ // input must only contain letters
33
+ lettersOnly?: boolean,
34
+ // input must only contain numbers
35
+ numbersOnly?: boolean,
36
+ // input must match given regExp
37
+ regexTest?: RegExp,
38
+ // description of regExp test, used to customize error messages
39
+ regexDescription?: string,
40
+ }[] = [
41
+ {
42
+ },
43
+ {
44
+ minLen: 5,
45
+ },
46
+ {
47
+ minLen: 5,
48
+ maxLen: 30,
49
+ },
50
+ {
51
+ minLen: 5,
52
+ maxLen: 30,
53
+ lettersOnly: true,
54
+ },
55
+ {
56
+ minLen: 5,
57
+ maxLen: 30,
58
+ lettersOnly: true,
59
+ numbersOnly: false,
60
+ },
61
+ {
62
+ minLen: 5,
63
+ maxLen: 30,
64
+ lettersOnly: true,
65
+ numbersOnly: false,
66
+ ignoreWhitespace: false,
67
+ },
68
+ ];
69
+
70
+ test(
71
+ 'Returns true for a given valid string.',
72
+ async () => {
73
+ validStrings.forEach((validString) => {
74
+ validReqs.forEach((validReq) => {
75
+ const validResponse: ValidationResult<string> = {
76
+ isValid: true,
77
+ cleanedValue: validString,
78
+ };
79
+
80
+ expect(validateString(validString, validReq)).toStrictEqual(validResponse);
81
+ });
82
+ });
83
+
84
+ const validString = 'A string with whitespace!';
85
+
86
+ const validResponse: ValidationResult<string> = {
87
+ isValid: true,
88
+ cleanedValue: 'Astringwithwhitespace!',
89
+ };
90
+
91
+ const validOpt = {
92
+ maxLen: 22,
93
+ ignoreWhitespace: true,
94
+ };
95
+
96
+ expect(validateString(validString, validOpt)).toStrictEqual(validResponse);
97
+ },
98
+ );
99
+
100
+ /*------------------------------------------------------------------------*/
101
+ /* ---------------------------- Invalid Tests --------------------------- */
102
+ /*------------------------------------------------------------------------*/
103
+
104
+ const invalidStrings: {
105
+ input: string,
106
+ reqs: {
107
+ // whitespace is removed from input before checking and returning
108
+ ignoreWhitespace?: boolean,
109
+ // input length must be at least minLen
110
+ minLen?: number,
111
+ // input length must be at most maxLen
112
+ maxLen?: number,
113
+ // input must only contain letters
114
+ lettersOnly?: boolean,
115
+ // input must only contain numbers
116
+ numbersOnly?: boolean,
117
+ // input must match given regExp
118
+ regexTest?: RegExp,
119
+ // description of regExp test, used to customize error messages
120
+ regexDescription?: string,
121
+ },
122
+ error: string[]
123
+ }[] = [
124
+ {
125
+ input: 'ûšër',
126
+ reqs: {
127
+ minLen: 5,
128
+ lettersOnly: true,
129
+ },
130
+ error: [INVALID_STRING_ERRORS.MIN_LEN(5)],
131
+ },
132
+ {
133
+ input: '123456789',
134
+ reqs: {
135
+ minLen: 10,
136
+ maxLen: 5,
137
+ lettersOnly: true,
138
+ },
139
+ error: [INVALID_STRING_ERRORS.MIN_LEN(10), INVALID_STRING_ERRORS.MAX_LEN(5), INVALID_STRING_ERRORS.LETTERS_ONLY],
140
+ },
141
+ {
142
+ input: 'String with non-letters!!',
143
+ reqs: {
144
+ lettersOnly: true,
145
+ numbersOnly: true,
146
+ ignoreWhitespace: true,
147
+ },
148
+ error: [INVALID_STRING_ERRORS.LETTERS_ONLY, INVALID_STRING_ERRORS.NUMBERS_ONLY],
149
+ },
150
+ {
151
+ input: '12345678',
152
+ reqs: {
153
+ lettersOnly: true,
154
+ regexTest: /^\s*(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?\s*$/,
155
+ regexDescription: 'should be a phone number',
156
+ },
157
+ error: [INVALID_STRING_ERRORS.LETTERS_ONLY, `${INVALID_REGEX_ERROR}: should be a phone number`],
158
+ },
159
+ ];
160
+
161
+ test(
162
+ 'Returns false for a given invalid string.',
163
+ async () => {
164
+ invalidStrings.forEach((triple) => {
165
+ const invalidResponse: ValidationResult<string> = {
166
+ isValid: false,
167
+ errorMessage: `${INVALID_STRING_ERRORS.MESSAGE_INTRO}${genCommaList(triple.error)}.`,
168
+ };
169
+
170
+ console.log(invalidResponse.errorMessage);
171
+
172
+ expect(validateString(triple.input, triple.reqs)).toStrictEqual(invalidResponse);
173
+ });
174
+ },
175
+ );
@@ -0,0 +1,171 @@
1
+ // Import helpers
2
+ import validateRegex from './shared/helpers/validateRegex';
3
+ import genCommaList from '../genCommaList';
4
+
5
+ // Import constants
6
+ import { INVALID_STRING_ERRORS } from './shared/constants/ERROR_MESSAGES';
7
+
8
+ // Import types
9
+ import ValidationResult from './shared/types/ValidationResult';
10
+
11
+ /*------------------------------------------------------------------------*/
12
+ /* ------------------------------ Constants ----------------------------- */
13
+ /*------------------------------------------------------------------------*/
14
+
15
+ // define minimum and maximum range for lowercase ASCII chars
16
+ const LOWERCASE_MIN = 65;
17
+ const LOWERCASE_MAX = 90;
18
+
19
+ // define minimum and maximum range for uppercase ASCII chars
20
+ const UPPERCASE_MIN = 97;
21
+ const UPPERCASE_MAX = 122;
22
+
23
+ // define minimum and maximum range for ASCII digits
24
+ const DIGIT_MIN = 48;
25
+ const DIGIT_MAX = 57;
26
+
27
+ /*------------------------------------------------------------------------*/
28
+ /* ---------------------------- Main Function --------------------------- */
29
+ /*------------------------------------------------------------------------*/
30
+
31
+ /**
32
+ * Determines whether a given input string is considered valid based on
33
+ * the provided requirements.
34
+ * @author Austen Money
35
+ * @param input input string
36
+ * @param opts options for validation
37
+ * @returns whether input is considered valid according to reqs - if
38
+ * valid, returns a cleaned version of input; if invalid, returns
39
+ * a string containing error messages describing which requirements
40
+ * were not met.
41
+ */
42
+ const validateString = (
43
+ input: string,
44
+ opts: {
45
+ // whitespace is removed from input before checking and returning
46
+ ignoreWhitespace?: boolean,
47
+ // input length must be at least minLen
48
+ minLen?: number,
49
+ // input length must be at most maxLen
50
+ maxLen?: number,
51
+ // input must only contain letters
52
+ // (future TODO: add option for passing in an array of permitted chars)
53
+ lettersOnly?: boolean,
54
+ // input must only contain numbers
55
+ numbersOnly?: boolean,
56
+ // input must match given regExp
57
+ regexTest?: RegExp,
58
+ // description of regExp test, used to customize error messages
59
+ regexDescription?: string,
60
+ },
61
+ ): ValidationResult<string> => {
62
+ // stores all invalid input errors
63
+ const errorMessages: string[] = [];
64
+
65
+ // contains version of input that will be returned
66
+ let cleanedValue: string = input;
67
+
68
+ // remove whitespace if required
69
+ if (opts.ignoreWhitespace) {
70
+ cleanedValue = input.replace(/\s+/g, '');
71
+ }
72
+
73
+ // apply max char requirement
74
+ if (opts.minLen) {
75
+ if (cleanedValue.length < opts.minLen) {
76
+ errorMessages.push(INVALID_STRING_ERRORS.MIN_LEN(opts.minLen));
77
+ }
78
+ }
79
+
80
+ // apply max char requirement
81
+ if (opts.maxLen) {
82
+ if (cleanedValue.length > opts.maxLen) {
83
+ errorMessages.push(INVALID_STRING_ERRORS.MAX_LEN(opts.maxLen));
84
+ }
85
+ }
86
+
87
+ // apply alphabetical requirement
88
+ if (opts.lettersOnly) {
89
+ // remove diacritics
90
+ cleanedValue = cleanedValue.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
91
+
92
+ const containsNonLetters = (
93
+ cleanedValue
94
+ // split into characters
95
+ .split('')
96
+ // convert into character codes
97
+ .map((curr) => {
98
+ return curr.charCodeAt(0);
99
+ })
100
+ // check for non-letters
101
+ .some((currCode) => {
102
+ return (
103
+ !(currCode >= LOWERCASE_MIN && currCode <= LOWERCASE_MAX)
104
+ && !(currCode >= UPPERCASE_MIN && currCode <= UPPERCASE_MAX)
105
+ );
106
+ })
107
+ );
108
+
109
+ if (containsNonLetters) {
110
+ errorMessages.push(INVALID_STRING_ERRORS.LETTERS_ONLY);
111
+ }
112
+ }
113
+
114
+ // apply numerical requirement
115
+ if (opts.numbersOnly) {
116
+ const containsNonNumbers = (
117
+ cleanedValue
118
+ // split into characters
119
+ .split('')
120
+ // convert into character codes
121
+ .map((curr) => {
122
+ return curr.charCodeAt(0);
123
+ })
124
+ // check for non-numbers
125
+ .some((currCode) => {
126
+ return (
127
+ !(currCode >= DIGIT_MIN && currCode <= DIGIT_MAX)
128
+ );
129
+ })
130
+ );
131
+
132
+ if (containsNonNumbers) {
133
+ errorMessages.push(INVALID_STRING_ERRORS.NUMBERS_ONLY);
134
+ }
135
+ }
136
+
137
+ // apply regex requirement
138
+ if (opts.regexTest) {
139
+ const regex = opts.regexTest;
140
+
141
+ // validate and create customized error message if description is provided
142
+ const result = validateRegex({
143
+ input: cleanedValue,
144
+ regex,
145
+ regexDescription: opts.regexDescription,
146
+ });
147
+
148
+ // if string did not pass regex validation, add error message
149
+ if (result.isValid === false) {
150
+ errorMessages.push(result.errorMessage);
151
+ }
152
+ }
153
+
154
+ // combine all error messages into one string to return
155
+ const errorMessage = `${INVALID_STRING_ERRORS.MESSAGE_INTRO}${genCommaList(errorMessages)}.`;
156
+
157
+ return (
158
+ // if no error messages, string is valid; if not, it is invalid
159
+ errorMessages.length === 0
160
+ ? {
161
+ isValid: true,
162
+ cleanedValue,
163
+ }
164
+ : {
165
+ isValid: false,
166
+ errorMessage,
167
+ }
168
+ );
169
+ };
170
+
171
+ export default validateString;
package/src/index.ts CHANGED
@@ -17,7 +17,7 @@ import ItemPicker from './components/ItemPicker';
17
17
  import LogReviewer from './components/LogReviewer';
18
18
  import IntelliTable from './components/IntelliTable';
19
19
  import CSVDownloadButton from './components/CSVDownloadButton';
20
- import DBEntryManagerPanel from './components/DBEntryManagerPanel';
20
+
21
21
  // Import errors
22
22
  import ErrorWithCode from './errors/ErrorWithCode';
23
23
 
@@ -63,8 +63,11 @@ import canReviewLogs from './helpers/canReviewLogs';
63
63
  import isMobileOrTablet from './helpers/isMobileOrTablet';
64
64
  import extractProp from './helpers/extractProp';
65
65
  import compareArraysByProp from './helpers/compareArraysByProp';
66
- import getLocalTimeInfo from './helpers/getLocalTimeInfo';
67
- import addDBEditorEndpoints from './helpers/addDBEditorEndpoints';
66
+ import genCommaList from './helpers/genCommaList';
67
+ import validateEmail from './helpers/validators/validateEmail';
68
+ import validatePhoneNumber from './helpers/validators/validatePhoneNumber';
69
+ import validateString from './helpers/validators/validateString';
70
+ import getLocalTimeInfo from './helpers/getLocalTimeInfo';
68
71
 
69
72
  // Import types
70
73
  import ModalButtonType from './types/ModalButtonType';
@@ -84,10 +87,6 @@ import IntelliTableColumn from './types/IntelliTableColumn';
84
87
 
85
88
  // Component-specific-types
86
89
  import PickableItem from './components/ItemPicker/types/PickableItem';
87
- import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
88
- import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
89
- import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
90
-
91
90
 
92
91
  // Export each item
93
92
  export {
@@ -110,7 +109,6 @@ export {
110
109
  LogReviewer,
111
110
  IntelliTable,
112
111
  CSVDownloadButton,
113
- DBEntryManagerPanel,
114
112
  // Global functions
115
113
  alert,
116
114
  confirm,
@@ -149,6 +147,10 @@ export {
149
147
  isMobileOrTablet,
150
148
  extractProp,
151
149
  compareArraysByProp,
150
+ genCommaList,
151
+ validateEmail,
152
+ validatePhoneNumber,
153
+ validateString,
152
154
  getLocalTimeInfo,
153
155
  // Client helpers
154
156
  initClient,
@@ -160,7 +162,6 @@ export {
160
162
  handleError,
161
163
  handleSuccess,
162
164
  initLogCollection,
163
- addDBEditorEndpoints,
164
165
  // Types
165
166
  ModalButtonType,
166
167
  ModalSize,
@@ -177,9 +178,6 @@ export {
177
178
  IntelliTableColumn,
178
179
  // Component-specific-types
179
180
  PickableItem,
180
- DBEntry,
181
- DBEntryField,
182
- DBEntryFieldType,
183
181
  // Server types
184
182
  ParamType,
185
183
  };
package/tsconfig.json CHANGED
@@ -15,8 +15,12 @@
15
15
  "allowSyntheticDefaultImports": true,
16
16
  "emitDeclarationOnly": true
17
17
  },
18
-
19
18
  "include": [
20
19
  "./src/**/*"
21
- ]
20
+ ],
21
+ "ts-node": {
22
+ "compilerOptions": {
23
+ "module": "commonjs"
24
+ }
25
+ },
22
26
  }
@@ -1,10 +0,0 @@
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;
@@ -1,34 +0,0 @@
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;
@@ -1,9 +0,0 @@
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;
@@ -1,25 +0,0 @@
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;
@@ -1,8 +0,0 @@
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;
@@ -1,49 +0,0 @@
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;
@@ -1,12 +0,0 @@
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;
@@ -1,40 +0,0 @@
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,10 +0,0 @@
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;
@@ -1,34 +0,0 @@
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;
@@ -1,9 +0,0 @@
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;