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.
- package/.vscode/settings.json +3 -1
- package/README.md +0 -20
- package/dist/cjs/index.js +7838 -15905
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/ItemPicker/index.d.ts +1 -0
- package/dist/cjs/types/components/LoadingSpinner.d.ts +2 -2
- package/dist/cjs/types/components/Modal/ModalProps.d.ts +2 -0
- package/dist/cjs/types/components/SimpleDateChooser.d.ts +3 -1
- package/dist/cjs/types/components/SimpleTimeChooser.d.ts +20 -0
- package/dist/cjs/types/components/TabBox.d.ts +1 -0
- package/dist/cjs/types/components/Tooltip.d.ts +1 -1
- package/dist/cjs/types/helpers/getWordCount.d.ts +10 -0
- package/dist/cjs/types/index.d.ts +13 -13
- package/dist/cjs/types/types/ParamType.d.ts +10 -10
- package/dist/cjs/types/types/ReactKitErrorCode.d.ts +2 -28
- package/dist/esm/index.js +6661 -14723
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/ItemPicker/index.d.ts +1 -0
- package/dist/esm/types/components/LoadingSpinner.d.ts +2 -2
- package/dist/esm/types/components/Modal/ModalProps.d.ts +2 -0
- package/dist/esm/types/components/SimpleDateChooser.d.ts +3 -1
- package/dist/esm/types/components/SimpleTimeChooser.d.ts +20 -0
- package/dist/esm/types/components/TabBox.d.ts +1 -0
- package/dist/esm/types/components/Tooltip.d.ts +1 -1
- package/dist/esm/types/helpers/getWordCount.d.ts +10 -0
- package/dist/esm/types/index.d.ts +13 -13
- package/dist/esm/types/types/ParamType.d.ts +10 -10
- package/dist/esm/types/types/ReactKitErrorCode.d.ts +2 -28
- package/dist/index.d.ts +189 -379
- package/package.json +5 -11
- package/src/components/AppWrapper.tsx +3 -1
- package/src/components/CheckboxButton.tsx +1 -1
- package/src/components/Dropdown.tsx +1 -1
- package/src/components/IntelliTable.tsx +1 -1
- package/src/components/ItemPicker/NestableItemList.tsx +1 -0
- package/src/components/ItemPicker/index.tsx +96 -0
- package/src/components/LogReviewer.tsx +2 -2
- package/src/components/Modal/ModalProps.ts +4 -0
- package/src/components/Modal/index.tsx +60 -21
- package/src/components/RadioButton.tsx +3 -1
- package/src/components/SimpleDateChooser.tsx +62 -26
- package/src/components/SimpleTimeChooser.tsx +195 -0
- package/src/components/TabBox.tsx +27 -9
- package/src/components/Tooltip.tsx +1 -1
- package/src/helpers/getWordCount.ts +26 -0
- package/src/{client → helpers}/initClient.tsx +5 -1
- package/src/helpers/logClientEvent.tsx +3 -1
- package/src/helpers/visitServerEndpoint.tsx +1 -1
- package/src/index.ts +22 -24
- package/src/types/ParamType.ts +10 -10
- package/src/types/ReactKitErrorCode.tsx +3 -31
- package/dist/cjs/types/components/ItemPicker/index.test.d.ts +0 -1
- package/dist/cjs/types/helpers/addDBEditorEndpoints.d.ts +0 -41
- package/dist/cjs/types/helpers/dataSigner.d.ts +0 -40
- package/dist/cjs/types/helpers/genRouteHandler.d.ts +0 -76
- package/dist/cjs/types/helpers/handleError.d.ts +0 -18
- package/dist/cjs/types/helpers/handleSuccess.d.ts +0 -8
- package/dist/cjs/types/helpers/parseUserAgent.d.ts +0 -17
- package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/index.d.ts +0 -20
- package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +0 -27
- package/dist/cjs/types/server/initCrossServerCredentialCollection.d.ts +0 -8
- package/dist/cjs/types/server/initLogCollection.d.ts +0 -8
- package/dist/cjs/types/server/initServer.d.ts +0 -53
- package/dist/cjs/types/types/CrossServerCredential.d.ts +0 -11
- package/dist/esm/types/components/ItemPicker/index.test.d.ts +0 -1
- package/dist/esm/types/helpers/addDBEditorEndpoints.d.ts +0 -41
- package/dist/esm/types/helpers/dataSigner.d.ts +0 -40
- package/dist/esm/types/helpers/genRouteHandler.d.ts +0 -76
- package/dist/esm/types/helpers/handleError.d.ts +0 -18
- package/dist/esm/types/helpers/handleSuccess.d.ts +0 -8
- package/dist/esm/types/helpers/parseUserAgent.d.ts +0 -17
- package/dist/esm/types/helpers/visitEndpointOnAnotherServer/index.d.ts +0 -20
- package/dist/esm/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +0 -27
- package/dist/esm/types/server/initCrossServerCredentialCollection.d.ts +0 -8
- package/dist/esm/types/server/initLogCollection.d.ts +0 -8
- package/dist/esm/types/server/initServer.d.ts +0 -53
- package/dist/esm/types/types/CrossServerCredential.d.ts +0 -11
- package/src/components/ItemPicker/index.test.tsx +0 -783
- package/src/helpers/addDBEditorEndpoints.ts +0 -128
- package/src/helpers/dataSigner.ts +0 -342
- package/src/helpers/genRouteHandler.ts +0 -911
- package/src/helpers/handleError.ts +0 -65
- package/src/helpers/handleSuccess.ts +0 -18
- package/src/helpers/parseUserAgent.ts +0 -108
- package/src/helpers/visitEndpointOnAnotherServer/index.ts +0 -152
- package/src/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.ts +0 -162
- package/src/server/initCrossServerCredentialCollection.ts +0 -16
- package/src/server/initLogCollection.ts +0 -27
- package/src/server/initServer.ts +0 -305
- package/src/types/CrossServerCredential.ts +0 -16
- /package/dist/cjs/types/{client → helpers}/initClient.d.ts +0 -0
- /package/dist/esm/types/{client → helpers}/initClient.d.ts +0 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A very simple, lightweight time chooser
|
|
3
|
+
* @author Gardenia Liu
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Import React
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
// Import helpers
|
|
10
|
+
import padZerosLeft from '../helpers/padZerosLeft';
|
|
11
|
+
|
|
12
|
+
/*------------------------------------------------------------------------*/
|
|
13
|
+
/* -------------------------------- Types ------------------------------- */
|
|
14
|
+
/*------------------------------------------------------------------------*/
|
|
15
|
+
|
|
16
|
+
type Props = {
|
|
17
|
+
// Aria label
|
|
18
|
+
ariaLabel: string,
|
|
19
|
+
// Name of the chooser (machine-readable, hyphenated)
|
|
20
|
+
name: string,
|
|
21
|
+
// Currently selected hour of the day (24hr)
|
|
22
|
+
hour: number,
|
|
23
|
+
// Currently selected minute within the hour
|
|
24
|
+
minute: number,
|
|
25
|
+
/**
|
|
26
|
+
* Handler for when time changes
|
|
27
|
+
* @param hour new 24hr hour number
|
|
28
|
+
* @param minute new minute number
|
|
29
|
+
*/
|
|
30
|
+
onChange: (hour: number, minute: number) => void,
|
|
31
|
+
// Interval in minutes between each choice
|
|
32
|
+
// Allowed options: 15, 30, 60, defaults to 15
|
|
33
|
+
// If an unsupported interval is passed in, it will default to 15
|
|
34
|
+
intervalMin?: number,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/*------------------------------------------------------------------------*/
|
|
38
|
+
/* ------------------------------ Constants ----------------------------- */
|
|
39
|
+
/*------------------------------------------------------------------------*/
|
|
40
|
+
|
|
41
|
+
// Allowed intervals between options
|
|
42
|
+
const ALLOWED_INTERVALS = [15, 30, 60]; // min
|
|
43
|
+
|
|
44
|
+
// Default interval to use if an unsupported interval is passed in
|
|
45
|
+
const DEFAULT_INTERVAL = ALLOWED_INTERVALS[0]; // min
|
|
46
|
+
|
|
47
|
+
/*------------------------------------------------------------------------*/
|
|
48
|
+
/* ------------------------------ Component ----------------------------- */
|
|
49
|
+
/*------------------------------------------------------------------------*/
|
|
50
|
+
|
|
51
|
+
const SimpleTimeChooser: React.FC<Props> = (props) => {
|
|
52
|
+
/*------------------------------------------------------------------------*/
|
|
53
|
+
/* -------------------------------- Setup ------------------------------- */
|
|
54
|
+
/*------------------------------------------------------------------------*/
|
|
55
|
+
|
|
56
|
+
/* -------------- Props ------------- */
|
|
57
|
+
|
|
58
|
+
const {
|
|
59
|
+
ariaLabel,
|
|
60
|
+
name,
|
|
61
|
+
hour,
|
|
62
|
+
minute,
|
|
63
|
+
onChange,
|
|
64
|
+
} = props;
|
|
65
|
+
let {
|
|
66
|
+
intervalMin = DEFAULT_INTERVAL,
|
|
67
|
+
} = props;
|
|
68
|
+
|
|
69
|
+
// Use default interval if not supported
|
|
70
|
+
if (ALLOWED_INTERVALS.includes(intervalMin)) {
|
|
71
|
+
intervalMin = DEFAULT_INTERVAL;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/*------------------------------------------------------------------------*/
|
|
75
|
+
/* ------------------------- Component Functions ------------------------ */
|
|
76
|
+
/*------------------------------------------------------------------------*/
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Convert number of minutes since midnight into 24hour and minute format
|
|
80
|
+
* @author Gabe Abrams
|
|
81
|
+
* @param minSinceMidnight total minutes since midnight
|
|
82
|
+
* @returns hours (24) and minutes
|
|
83
|
+
*/
|
|
84
|
+
const convertMinSinceMidnightToHoursAndMin = (minSinceMidnight: number): {
|
|
85
|
+
hours: number,
|
|
86
|
+
minutes: number,
|
|
87
|
+
} => {
|
|
88
|
+
return {
|
|
89
|
+
hours: Math.floor(minSinceMidnight / 60),
|
|
90
|
+
minutes: minSinceMidnight % 60,
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Convert time in minutes into HH:MM format
|
|
96
|
+
* @author Gardenia Liu
|
|
97
|
+
* @param totalMinutes total minutes since midnight
|
|
98
|
+
* @returns formatted time string
|
|
99
|
+
*/
|
|
100
|
+
const formatTime = (totalMinutes: number): string => {
|
|
101
|
+
// Handle special cases
|
|
102
|
+
if (totalMinutes === 0) {
|
|
103
|
+
return '12:00 Midnight';
|
|
104
|
+
}
|
|
105
|
+
if (totalMinutes === 12 * 60) {
|
|
106
|
+
return '12:00 Noon';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// All normal cases:
|
|
110
|
+
const timeInfo = convertMinSinceMidnightToHoursAndMin(totalMinutes);
|
|
111
|
+
let { hours } = timeInfo;
|
|
112
|
+
const { minutes } = timeInfo;
|
|
113
|
+
|
|
114
|
+
// Process 24hr -> 12hr
|
|
115
|
+
const isAM = (hours < 12);
|
|
116
|
+
if (hours === 0) {
|
|
117
|
+
hours = 12;
|
|
118
|
+
} else if (hours > 12) {
|
|
119
|
+
hours %= 12;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Pad with zeros
|
|
123
|
+
const paddedMinutes = padZerosLeft(minutes, 2);
|
|
124
|
+
|
|
125
|
+
// Assemble time string
|
|
126
|
+
return `${hours}:${paddedMinutes} ${isAM ? 'AM' : 'PM'}`;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/*------------------------------------------------------------------------*/
|
|
130
|
+
/* ------------------------------- Render ------------------------------- */
|
|
131
|
+
/*------------------------------------------------------------------------*/
|
|
132
|
+
|
|
133
|
+
/*----------------------------------------*/
|
|
134
|
+
/* --------------- Main UI -------------- */
|
|
135
|
+
/*----------------------------------------*/
|
|
136
|
+
|
|
137
|
+
// Generate list of time options
|
|
138
|
+
const times: string[] = [];
|
|
139
|
+
for (let time = 0; time < 24 * 60; time += intervalMin) {
|
|
140
|
+
times.push(formatTime(time));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Create choice options
|
|
144
|
+
const selectedTimeMin = hour * 60 + minute; // minutes since midnight
|
|
145
|
+
const timeOptions: React.ReactNode[] = times.map((timeString, timeIndex) => {
|
|
146
|
+
// Create time option
|
|
147
|
+
const numMinutesForChoice = timeIndex * intervalMin;
|
|
148
|
+
|
|
149
|
+
// Render the option
|
|
150
|
+
return (
|
|
151
|
+
<option
|
|
152
|
+
key={numMinutesForChoice}
|
|
153
|
+
value={numMinutesForChoice}
|
|
154
|
+
aria-label={`choose ${timeString}`}
|
|
155
|
+
>
|
|
156
|
+
{timeString}
|
|
157
|
+
</option>
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
<div
|
|
163
|
+
className="SimpleTimeChooser-container"
|
|
164
|
+
aria-label={`time chooser with selected time: ${formatTime(selectedTimeMin)}`}
|
|
165
|
+
>
|
|
166
|
+
{/* Time Chooser */}
|
|
167
|
+
<select
|
|
168
|
+
aria-label={`time for ${ariaLabel}`}
|
|
169
|
+
className="custom-select d-inline-block"
|
|
170
|
+
style={{ width: 'auto' }}
|
|
171
|
+
id={`SimpleTimeChooser-${name}-time`}
|
|
172
|
+
value={selectedTimeMin}
|
|
173
|
+
onChange={(e) => {
|
|
174
|
+
// Parse selector value (string)
|
|
175
|
+
const newTime = Number.parseInt(e.target.value, 10);
|
|
176
|
+
|
|
177
|
+
// Convert minutes since midnight to hour and minute
|
|
178
|
+
const timeInfo = convertMinSinceMidnightToHoursAndMin(newTime);
|
|
179
|
+
|
|
180
|
+
// Notify parent of change
|
|
181
|
+
onChange(timeInfo.hours, timeInfo.minutes);
|
|
182
|
+
}}
|
|
183
|
+
>
|
|
184
|
+
{timeOptions}
|
|
185
|
+
</select>
|
|
186
|
+
</div>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/*------------------------------------------------------------------------*/
|
|
191
|
+
/* ------------------------------- Wrap Up ------------------------------ */
|
|
192
|
+
/*------------------------------------------------------------------------*/
|
|
193
|
+
|
|
194
|
+
// Export component
|
|
195
|
+
export default SimpleTimeChooser;
|
|
@@ -15,6 +15,8 @@ type Props = {
|
|
|
15
15
|
title: React.ReactNode,
|
|
16
16
|
// Children/contents inside the box
|
|
17
17
|
children: React.ReactNode,
|
|
18
|
+
// Children to display on the top right of the tab box
|
|
19
|
+
topRightChildren?: React.ReactNode,
|
|
18
20
|
// If true, don't add margin below the tab box
|
|
19
21
|
noBottomMargin?: boolean,
|
|
20
22
|
// If true, don't add padding to bottom of tab box
|
|
@@ -49,7 +51,9 @@ const style = `
|
|
|
49
51
|
|
|
50
52
|
/* Container for Title */
|
|
51
53
|
.TabBox-title-container {
|
|
52
|
-
|
|
54
|
+
display: flex;
|
|
55
|
+
justify-content: space-between;
|
|
56
|
+
align-items: center;
|
|
53
57
|
position: relative;
|
|
54
58
|
left: 0;
|
|
55
59
|
text-align: left;
|
|
@@ -82,6 +86,19 @@ const style = `
|
|
|
82
86
|
background: #fdfdfd;
|
|
83
87
|
}
|
|
84
88
|
|
|
89
|
+
.TabBox-title-right-container {
|
|
90
|
+
display: flex;
|
|
91
|
+
flex-direction: row;
|
|
92
|
+
align-items: bottom;
|
|
93
|
+
height: 2.4rem;
|
|
94
|
+
overflow: visible;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.TabBox-title-right-contents {
|
|
98
|
+
margin-right: 0.5rem;
|
|
99
|
+
margin-bottom: 0.2rem;
|
|
100
|
+
}
|
|
101
|
+
|
|
85
102
|
/* Make the TabBox's Children Appear Above Title if Overlap Occurs */
|
|
86
103
|
.TabBox-children {
|
|
87
104
|
position: relative;
|
|
@@ -98,11 +115,10 @@ const TabBox: React.FC<Props> = (props) => {
|
|
|
98
115
|
/* -------------------------------- Setup ------------------------------- */
|
|
99
116
|
/*------------------------------------------------------------------------*/
|
|
100
117
|
|
|
101
|
-
/* -------------- Props ------------- */
|
|
102
|
-
|
|
103
118
|
const {
|
|
104
119
|
title,
|
|
105
120
|
children,
|
|
121
|
+
topRightChildren,
|
|
106
122
|
noBottomPadding,
|
|
107
123
|
noBottomMargin,
|
|
108
124
|
} = props;
|
|
@@ -111,21 +127,23 @@ const TabBox: React.FC<Props> = (props) => {
|
|
|
111
127
|
/* ------------------------------- Render ------------------------------- */
|
|
112
128
|
/*------------------------------------------------------------------------*/
|
|
113
129
|
|
|
114
|
-
/*----------------------------------------*/
|
|
115
|
-
/* --------------- Main UI -------------- */
|
|
116
|
-
/*----------------------------------------*/
|
|
117
|
-
|
|
118
|
-
// Full UI
|
|
119
130
|
return (
|
|
120
131
|
<div className={`TabBox-container ${noBottomMargin ? '' : 'mb-2'}`}>
|
|
121
132
|
{/* Style */}
|
|
122
133
|
<style>{style}</style>
|
|
123
134
|
|
|
124
|
-
{/* Title */}
|
|
135
|
+
{/* Title Row with Left and Right sections */}
|
|
125
136
|
<div className="TabBox-title-container">
|
|
126
137
|
<div className="TabBox-title">
|
|
127
138
|
{title}
|
|
128
139
|
</div>
|
|
140
|
+
{topRightChildren && (
|
|
141
|
+
<div className="TabBox-title-right-container">
|
|
142
|
+
<div className="TabBox-title-right-contents">
|
|
143
|
+
{topRightChildren}
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
)}
|
|
129
147
|
</div>
|
|
130
148
|
|
|
131
149
|
{/* Contents */}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const punctuationRegex = /[!@#$%^&*(),.?\/;:'"\-\[\]]/g;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get number of words in string
|
|
5
|
+
* @author Gardenia Liu
|
|
6
|
+
* @author Allison Zhang
|
|
7
|
+
* @author Gabe Abrams
|
|
8
|
+
* @param text the string to check
|
|
9
|
+
* @returns number of words in the string
|
|
10
|
+
*/
|
|
11
|
+
const getWordCount = (text: string): number => {
|
|
12
|
+
const trimmedTextWithoutPunctuation = (
|
|
13
|
+
text
|
|
14
|
+
// Remove leading and trailing whitespace
|
|
15
|
+
.trim()
|
|
16
|
+
// Remove punctuation
|
|
17
|
+
.replace(punctuationRegex, '')
|
|
18
|
+
);
|
|
19
|
+
if (trimmedTextWithoutPunctuation.length === 0) {
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return trimmedTextWithoutPunctuation.split(/\s+/g).length;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default getWordCount;
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
// eslint-disable-next-line import/no-cycle
|
|
4
4
|
import { showFatalError } from '../components/AppWrapper';
|
|
5
5
|
|
|
6
|
+
// Import other helpers
|
|
7
|
+
import waitMs from './waitMs';
|
|
8
|
+
|
|
6
9
|
// Import shared types
|
|
7
10
|
import ErrorWithCode from '../errors/ErrorWithCode';
|
|
8
|
-
import waitMs from '../helpers/waitMs';
|
|
9
11
|
import ReactKitErrorCode from '../types/ReactKitErrorCode';
|
|
10
12
|
|
|
11
13
|
/*----------------------------------------*/
|
|
@@ -164,10 +166,12 @@ const initClient = (
|
|
|
164
166
|
storedSendRequest = async () => {
|
|
165
167
|
throw new Error('Cannot send requests because there is no server');
|
|
166
168
|
};
|
|
169
|
+
noServer = true;
|
|
167
170
|
} else {
|
|
168
171
|
// Store values
|
|
169
172
|
storedSendRequest = opts.sendRequest;
|
|
170
173
|
sessionExpiredMessage = opts.sessionExpiredMessage;
|
|
174
|
+
noServer = false;
|
|
171
175
|
}
|
|
172
176
|
|
|
173
177
|
// Handle universal parts
|
|
@@ -5,10 +5,12 @@ import LogFunction from '../types/LogFunction';
|
|
|
5
5
|
import LogLevel from '../types/LogLevel';
|
|
6
6
|
|
|
7
7
|
// Import shared functions
|
|
8
|
+
// TODO: fix dependency cycle
|
|
9
|
+
// eslint-disable-next-line import/no-cycle
|
|
8
10
|
import visitServerEndpoint from './visitServerEndpoint';
|
|
9
11
|
|
|
10
12
|
// Import status
|
|
11
|
-
import { appHasNoServer } from '
|
|
13
|
+
import { appHasNoServer } from './initClient';
|
|
12
14
|
|
|
13
15
|
/* ------- Metadata Populator ------- */
|
|
14
16
|
|
|
@@ -7,7 +7,7 @@ import ReactKitErrorCode from '../types/ReactKitErrorCode';
|
|
|
7
7
|
// Import helpers
|
|
8
8
|
// TODO: fix dependency cycle
|
|
9
9
|
// eslint-disable-next-line import/no-cycle
|
|
10
|
-
import { getSendRequest } from '
|
|
10
|
+
import { getSendRequest } from './initClient';
|
|
11
11
|
import { showSessionExpiredMessage } from '../components/AppWrapper';
|
|
12
12
|
|
|
13
13
|
/*------------------------------------------------------------------------*/
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ import RadioButton from './components/RadioButton';
|
|
|
15
15
|
import CheckboxButton from './components/CheckboxButton';
|
|
16
16
|
import ButtonInputGroup from './components/ButtonInputGroup';
|
|
17
17
|
import SimpleDateChooser from './components/SimpleDateChooser';
|
|
18
|
+
import SimpleTimeChooser from './components/SimpleTimeChooser';
|
|
18
19
|
import Drawer from './components/Drawer';
|
|
19
20
|
import PopSuccessMark from './components/PopSuccessMark';
|
|
20
21
|
import PopFailureMark from './components/PopFailureMark';
|
|
@@ -38,12 +39,15 @@ import ErrorWithCode from './errors/ErrorWithCode';
|
|
|
38
39
|
import MINUTE_IN_MS from './constants/MINUTE_IN_MS';
|
|
39
40
|
import HOUR_IN_MS from './constants/HOUR_IN_MS';
|
|
40
41
|
import DAY_IN_MS from './constants/DAY_IN_MS';
|
|
42
|
+
import LOG_REVIEW_ROUTE_PATH_PREFIX from './constants/LOG_REVIEW_ROUTE_PATH_PREFIX';
|
|
43
|
+
import LOG_ROUTE_PATH from './constants/LOG_ROUTE_PATH';
|
|
44
|
+
import LOG_REVIEW_STATUS_ROUTE from './constants/LOG_REVIEW_STATUS_ROUTE';
|
|
41
45
|
|
|
42
46
|
// Import dynamic constants
|
|
43
47
|
import DynamicWord from './dynamicConstants/DynamicWord';
|
|
44
48
|
|
|
45
49
|
// Import helpers
|
|
46
|
-
import initClient from './
|
|
50
|
+
import initClient from './helpers/initClient';
|
|
47
51
|
import abbreviate from './helpers/abbreviate';
|
|
48
52
|
import avg from './helpers/avg';
|
|
49
53
|
import ceilToNumDecimals from './helpers/ceilToNumDecimals';
|
|
@@ -55,10 +59,6 @@ import roundToNumDecimals from './helpers/roundToNumDecimals';
|
|
|
55
59
|
import sum from './helpers/sum';
|
|
56
60
|
import waitMs from './helpers/waitMs';
|
|
57
61
|
import visitServerEndpoint from './helpers/visitServerEndpoint';
|
|
58
|
-
import genRouteHandler from './helpers/genRouteHandler';
|
|
59
|
-
import handleError from './helpers/handleError';
|
|
60
|
-
import handleSuccess from './helpers/handleSuccess';
|
|
61
|
-
import initServer from './server/initServer';
|
|
62
62
|
import getOrdinal from './helpers/getOrdinal';
|
|
63
63
|
import getTimeInfoInET from './helpers/getTimeInfoInET';
|
|
64
64
|
import stubServerEndpoint from './helpers/stubServerEndpoint';
|
|
@@ -69,8 +69,6 @@ import stringsToHumanReadableList from './helpers/stringsToHumanReadableList';
|
|
|
69
69
|
import onlyKeepLetters from './helpers/onlyKeepLetters';
|
|
70
70
|
import parallelLimit from './helpers/parallelLimit';
|
|
71
71
|
import logClientEvent, { setClientEventMetadataPopulator } from './helpers/logClientEvent';
|
|
72
|
-
import initLogCollection from './server/initLogCollection';
|
|
73
|
-
import initCrossServerCredentialCollection from './server/initCrossServerCredentialCollection';
|
|
74
72
|
import getMonthName from './helpers/getMonthName';
|
|
75
73
|
import genCSV from './helpers/genCSV';
|
|
76
74
|
import canReviewLogs from './helpers/canReviewLogs';
|
|
@@ -78,7 +76,6 @@ import isMobileOrTablet from './helpers/isMobileOrTablet';
|
|
|
78
76
|
import extractProp from './helpers/extractProp';
|
|
79
77
|
import compareArraysByProp from './helpers/compareArraysByProp';
|
|
80
78
|
import getLocalTimeInfo from './helpers/getLocalTimeInfo';
|
|
81
|
-
import addDBEditorEndpoints from './helpers/addDBEditorEndpoints';
|
|
82
79
|
import genCommaList from './helpers/genCommaList';
|
|
83
80
|
import validateEmail from './helpers/validators/validateEmail';
|
|
84
81
|
import validatePhoneNumber from './helpers/validators/validatePhoneNumber';
|
|
@@ -95,15 +92,14 @@ import mapAsync from './helpers/asyncArrayFunctions/mapAsync';
|
|
|
95
92
|
import someAsync from './helpers/asyncArrayFunctions/someAsync';
|
|
96
93
|
import capitalize from './helpers/capitalize';
|
|
97
94
|
import shuffleArray from './helpers/shuffleArray';
|
|
98
|
-
import
|
|
95
|
+
import getWordCount from './helpers/getWordCount';
|
|
99
96
|
|
|
100
97
|
// Import types
|
|
98
|
+
import ParamType from './types/ParamType';
|
|
101
99
|
import ModalButtonType from './types/ModalButtonType';
|
|
102
100
|
import ModalSize from './types/ModalSize';
|
|
103
101
|
import ModalType from './types/ModalType';
|
|
104
|
-
import ReactKitErrorCode from './types/ReactKitErrorCode';
|
|
105
102
|
import Variant from './types/Variant';
|
|
106
|
-
import ParamType from './types/ParamType';
|
|
107
103
|
import DayOfWeek from './types/DayOfWeek';
|
|
108
104
|
import Log from './types/Log';
|
|
109
105
|
import LogType from './types/LogType';
|
|
@@ -112,9 +108,13 @@ import LogAction from './types/LogAction';
|
|
|
112
108
|
import LogBuiltInMetadata from './types/LogBuiltInMetadata';
|
|
113
109
|
import LogMetadataType from './types/LogMetadataType';
|
|
114
110
|
import LogFunction from './types/LogFunction';
|
|
111
|
+
import LogTypeSpecificInfo from './types/Log/LogTypeSpecificInfo';
|
|
112
|
+
import LogMainInfo from './types/Log/LogMainInfo';
|
|
113
|
+
import LogSourceSpecificInfo from './types/Log/LogSourceSpecificInfo';
|
|
114
|
+
import LogLevel from './types/LogLevel';
|
|
115
115
|
import IntelliTableColumn from './types/IntelliTableColumn';
|
|
116
116
|
import DropdownItemType from './types/DropdownItemType';
|
|
117
|
-
import
|
|
117
|
+
import ReactKitErrorCode from './types/ReactKitErrorCode';
|
|
118
118
|
|
|
119
119
|
// Component-specific-types
|
|
120
120
|
import PickableItem from './components/ItemPicker/types/PickableItem';
|
|
@@ -134,6 +134,7 @@ export {
|
|
|
134
134
|
CheckboxButton,
|
|
135
135
|
ButtonInputGroup,
|
|
136
136
|
SimpleDateChooser,
|
|
137
|
+
SimpleTimeChooser,
|
|
137
138
|
Drawer,
|
|
138
139
|
PopSuccessMark,
|
|
139
140
|
PopFailureMark,
|
|
@@ -160,6 +161,9 @@ export {
|
|
|
160
161
|
MINUTE_IN_MS,
|
|
161
162
|
HOUR_IN_MS,
|
|
162
163
|
DAY_IN_MS,
|
|
164
|
+
LOG_REVIEW_ROUTE_PATH_PREFIX,
|
|
165
|
+
LOG_ROUTE_PATH,
|
|
166
|
+
LOG_REVIEW_STATUS_ROUTE,
|
|
163
167
|
// Dynamic Constants
|
|
164
168
|
DynamicWord,
|
|
165
169
|
// Helpers
|
|
@@ -203,6 +207,7 @@ export {
|
|
|
203
207
|
someAsync,
|
|
204
208
|
capitalize,
|
|
205
209
|
shuffleArray,
|
|
210
|
+
getWordCount,
|
|
206
211
|
// Client helpers
|
|
207
212
|
initClient,
|
|
208
213
|
visitServerEndpoint,
|
|
@@ -212,16 +217,8 @@ export {
|
|
|
212
217
|
combineClassNames,
|
|
213
218
|
useForceRender,
|
|
214
219
|
setClientEventMetadataPopulator,
|
|
215
|
-
// Server helpers
|
|
216
|
-
initServer,
|
|
217
|
-
genRouteHandler,
|
|
218
|
-
handleError,
|
|
219
|
-
handleSuccess,
|
|
220
|
-
initLogCollection,
|
|
221
|
-
initCrossServerCredentialCollection,
|
|
222
|
-
addDBEditorEndpoints,
|
|
223
|
-
visitEndpointOnAnotherServer,
|
|
224
220
|
// Types
|
|
221
|
+
ParamType,
|
|
225
222
|
ModalButtonType,
|
|
226
223
|
ModalSize,
|
|
227
224
|
ModalType,
|
|
@@ -235,14 +232,15 @@ export {
|
|
|
235
232
|
LogBuiltInMetadata,
|
|
236
233
|
LogMetadataType,
|
|
237
234
|
LogFunction,
|
|
235
|
+
LogTypeSpecificInfo,
|
|
236
|
+
LogMainInfo,
|
|
237
|
+
LogSourceSpecificInfo,
|
|
238
|
+
LogLevel,
|
|
238
239
|
IntelliTableColumn,
|
|
239
240
|
DropdownItemType,
|
|
240
|
-
CrossServerCredential,
|
|
241
241
|
// Component-specific-types
|
|
242
242
|
PickableItem,
|
|
243
243
|
DBEntry,
|
|
244
244
|
DBEntryField,
|
|
245
245
|
DBEntryFieldType,
|
|
246
|
-
// Server types
|
|
247
|
-
ParamType,
|
|
248
246
|
};
|
package/src/types/ParamType.ts
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* @author Gabe Abrams
|
|
4
4
|
*/
|
|
5
5
|
enum ParamType {
|
|
6
|
-
Boolean = '
|
|
7
|
-
BooleanOptional = '
|
|
8
|
-
Float = '
|
|
9
|
-
FloatOptional = '
|
|
10
|
-
Int = '
|
|
11
|
-
IntOptional = '
|
|
12
|
-
JSON = '
|
|
13
|
-
JSONOptional = '
|
|
14
|
-
String = '
|
|
15
|
-
StringOptional = '
|
|
6
|
+
Boolean = 'Boolean', // Boolean
|
|
7
|
+
BooleanOptional = 'BooleanOptional', // Optional boolean
|
|
8
|
+
Float = 'Float', // Float Number
|
|
9
|
+
FloatOptional = 'FloatOptional', // Optional Float Number
|
|
10
|
+
Int = 'Int', // Integer Number
|
|
11
|
+
IntOptional = 'IntOptional', // Optional Integer Number
|
|
12
|
+
JSON = 'JSON', // JSONified object
|
|
13
|
+
JSONOptional = 'JSONOptional', // Optional JSONified object
|
|
14
|
+
String = 'String', // String
|
|
15
|
+
StringOptional = 'StringOptional', // Optional string
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export default ParamType;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Highest error code =
|
|
1
|
+
// Highest error code = DRK36
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* List of error codes built into the react kit
|
|
@@ -8,37 +8,9 @@ enum ReactKitErrorCode {
|
|
|
8
8
|
NoResponse = 'DRK1',
|
|
9
9
|
NoCode = 'DRK2',
|
|
10
10
|
SessionExpired = 'DRK3',
|
|
11
|
-
MissingParameter = 'DRK4',
|
|
12
|
-
InvalidParameter = 'DRK5',
|
|
13
|
-
HostNotAllowed = 'DRK17',
|
|
14
|
-
HostBanned = 'DRK18',
|
|
15
|
-
WrongCourse = 'DRK6',
|
|
16
11
|
NoCACCLSendRequestFunction = 'DRK7',
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
NotAdmin = 'DRK10',
|
|
20
|
-
NotAllowedToReviewLogs = 'DRK11',
|
|
21
|
-
ThemeCheckedBeforeReactKitReady = 'DRK12',
|
|
22
|
-
SessionExpiredMessageGottenBeforeReactKitReady = 'DRK13',
|
|
23
|
-
|
|
24
|
-
// Server-to-server requests
|
|
25
|
-
NotConnected = 'DRK14',
|
|
26
|
-
SelfSigned = 'DRK15',
|
|
27
|
-
ResponseParseError = 'DRK16',
|
|
28
|
-
SignedRequestUnparseable = 'DRK28',
|
|
29
|
-
SignedRequestInvalidCollection = 'DRK21',
|
|
30
|
-
SignedRequestInvalidCredential = 'DRK23',
|
|
31
|
-
SignedRequestInvalidScope = 'DRK22',
|
|
32
|
-
SignedRequestInvalidTimestamp = 'DRK24',
|
|
33
|
-
SignedRequestInvalidSignature = 'DRK25',
|
|
34
|
-
SignedRequestInvalidBody = 'DRK26',
|
|
35
|
-
CrossServerNoCredentialsToSignWith = 'DRK27',
|
|
36
|
-
CrossServerMissingSignedRequestInfo = 'DRK29',
|
|
37
|
-
CrossServerNoCredentialEncodingSalt = 'DRK30',
|
|
38
|
-
NoOauthLib = 'DRK31',
|
|
39
|
-
NoCryptoLib = 'DRK32',
|
|
40
|
-
InvalidCrossServerCredentialsFormat = 'DRK33',
|
|
41
|
-
UnknownCrossServerError = 'DRK34',
|
|
12
|
+
SimpleDateChooserInvalidDateRange = 'DRK35',
|
|
13
|
+
SimpleDateChooserInvalidNumMonths = 'DRK36',
|
|
42
14
|
}
|
|
43
15
|
|
|
44
16
|
export default ReactKitErrorCode;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
/**
|
|
3
|
-
* Interface for a collection in the database
|
|
4
|
-
* @author Yuen Ler Chow
|
|
5
|
-
*/
|
|
6
|
-
type DCEMangoCollection = {
|
|
7
|
-
/**
|
|
8
|
-
* Find all items in the collection that match the filter query
|
|
9
|
-
* @param filterQuery query for the filter
|
|
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
|
-
* @param opts.collection dce-mango db collection
|
|
34
|
-
*/
|
|
35
|
-
declare const addDBEditorEndpoints: (opts: {
|
|
36
|
-
app: express.Application;
|
|
37
|
-
collectionName: string;
|
|
38
|
-
adminsOnly: boolean;
|
|
39
|
-
collection: DCEMangoCollection;
|
|
40
|
-
}) => void;
|
|
41
|
-
export default addDBEditorEndpoints;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sign a request and get the new request params
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
* @param opts object containing all arguments
|
|
5
|
-
* @param opts.method the method to sign
|
|
6
|
-
* @param opts.path the http request path
|
|
7
|
-
* @param opts.params the data in the body to sign
|
|
8
|
-
* @param opts.key the reactkit key to sign with
|
|
9
|
-
* @param opts.secret the reactkit secret to sign with
|
|
10
|
-
* @return augmented params for the request, including a signature, timestamp, and key
|
|
11
|
-
*/
|
|
12
|
-
export declare const signRequest: (opts: {
|
|
13
|
-
method: string;
|
|
14
|
-
path: string;
|
|
15
|
-
params: {
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
};
|
|
18
|
-
key: string;
|
|
19
|
-
secret: string;
|
|
20
|
-
}) => Promise<{
|
|
21
|
-
[key: string]: any;
|
|
22
|
-
}>;
|
|
23
|
-
/**
|
|
24
|
-
* Validate a signed request. Throws an error if invalid
|
|
25
|
-
* @author Gabe Abrams
|
|
26
|
-
* @param opts object containing all arguments
|
|
27
|
-
* @param opts.method the method of the data validate
|
|
28
|
-
* @param opts.path the http request path to validate
|
|
29
|
-
* @param opts.scope the name of the scope to validate
|
|
30
|
-
* @param opts.params the request data to validate
|
|
31
|
-
* @returns parsed and validated params
|
|
32
|
-
*/
|
|
33
|
-
export declare const validateSignedRequest: (opts: {
|
|
34
|
-
method: string;
|
|
35
|
-
path: string;
|
|
36
|
-
scope: string;
|
|
37
|
-
params: {
|
|
38
|
-
[key: string]: any;
|
|
39
|
-
};
|
|
40
|
-
}) => Promise<void>;
|