dce-reactkit 4.3.4 → 5.0.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.
- package/dist/cjs/index.js +338 -2316
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/LogReviewer.d.ts +1 -1
- package/dist/cjs/types/helpers/logClientEvent.d.ts +1 -1
- package/dist/cjs/types/html/genErrorPage.d.ts +1 -1
- package/dist/cjs/types/index.d.ts +2 -64
- package/dist/cjs/types/types/IntelliTableColumn.d.ts +1 -1
- package/dist/esm/index.js +78 -2223
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/LogReviewer.d.ts +1 -1
- package/dist/esm/types/helpers/logClientEvent.d.ts +1 -1
- package/dist/esm/types/html/genErrorPage.d.ts +1 -1
- package/dist/esm/types/index.d.ts +2 -64
- package/dist/esm/types/types/IntelliTableColumn.d.ts +1 -1
- package/dist/index.d.ts +3 -835
- package/package.json +4 -3
- package/src/components/AppWrapper.tsx +12 -10
- package/src/components/AutoscrollToBottomContainer.tsx +5 -3
- package/src/components/CopiableBox.tsx +5 -1
- package/src/components/DBEntryManagerPanel/helpers/generateEndpointPath.ts +2 -2
- package/src/components/ErrorBox.tsx +6 -2
- package/src/components/IntelliTable.tsx +7 -5
- package/src/components/LogReviewer.tsx +23 -21
- package/src/components/Modal/index.tsx +5 -3
- package/src/components/MultiSwitch.tsx +5 -1
- package/src/components/Shimmer.tsx +4 -2
- package/src/components/SimpleDateChooser.tsx +11 -13
- package/src/components/SimpleTimeChooser.tsx +4 -2
- package/src/helpers/canReviewLogs.test.ts +5 -3
- package/src/helpers/canReviewLogs.ts +5 -3
- package/src/helpers/initClient.tsx +8 -8
- package/src/helpers/isMobileOrTablet.tsx +2 -1
- package/src/helpers/isSelectAdmin.ts +4 -2
- package/src/helpers/logClientEvent.tsx +7 -5
- package/src/helpers/stubServerEndpoint.tsx +1 -1
- package/src/helpers/visitServerEndpoint.tsx +10 -7
- package/src/html/genErrorPage.ts +6 -4
- package/src/index.ts +105 -98
- package/src/types/IntelliTableColumn.ts +4 -1
- package/dist/cjs/types/constants/DAY_IN_MS.d.ts +0 -6
- package/dist/cjs/types/constants/HOUR_IN_MS.d.ts +0 -6
- package/dist/cjs/types/constants/LOG_REVIEW_GET_LOGS_ROUTE.d.ts +0 -6
- package/dist/cjs/types/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.d.ts +0 -6
- package/dist/cjs/types/constants/LOG_REVIEW_STATUS_ROUTE.d.ts +0 -7
- package/dist/cjs/types/constants/LOG_ROUTE_PATH.d.ts +0 -6
- package/dist/cjs/types/constants/MINUTE_IN_MS.d.ts +0 -6
- package/dist/cjs/types/constants/ROUTE_PATH_PREFIX.d.ts +0 -6
- package/dist/cjs/types/constants/SELECT_ADMIN_CHECK_ROUTE.d.ts +0 -6
- package/dist/cjs/types/errors/ErrorWithCode.d.ts +0 -9
- package/dist/cjs/types/helpers/abbreviate.d.ts +0 -10
- package/dist/cjs/types/helpers/abbreviate.test.d.ts +0 -5
- package/dist/cjs/types/helpers/asyncArrayFunctions/everyAsync.d.ts +0 -13
- package/dist/cjs/types/helpers/asyncArrayFunctions/everyAsync.test.d.ts +0 -1
- package/dist/cjs/types/helpers/asyncArrayFunctions/filterAsync.d.ts +0 -13
- package/dist/cjs/types/helpers/asyncArrayFunctions/filterAsync.test.d.ts +0 -1
- package/dist/cjs/types/helpers/asyncArrayFunctions/forEachAsync.d.ts +0 -10
- package/dist/cjs/types/helpers/asyncArrayFunctions/forEachAsync.test.d.ts +0 -1
- package/dist/cjs/types/helpers/asyncArrayFunctions/mapAsync.d.ts +0 -11
- package/dist/cjs/types/helpers/asyncArrayFunctions/mapAsync.test.d.ts +0 -1
- package/dist/cjs/types/helpers/asyncArrayFunctions/someAsync.d.ts +0 -13
- package/dist/cjs/types/helpers/asyncArrayFunctions/someAsync.test.d.ts +0 -1
- package/dist/cjs/types/helpers/avg.d.ts +0 -8
- package/dist/cjs/types/helpers/avg.test.d.ts +0 -5
- package/dist/cjs/types/helpers/capitalize.d.ts +0 -7
- package/dist/cjs/types/helpers/ceilToNumDecimals.d.ts +0 -9
- package/dist/cjs/types/helpers/ceilToNumDecimals.test.d.ts +0 -5
- package/dist/cjs/types/helpers/cloneDeep.d.ts +0 -8
- package/dist/cjs/types/helpers/compareArraysByProp.d.ts +0 -13
- package/dist/cjs/types/helpers/compareArraysByProp.test.d.ts +0 -5
- package/dist/cjs/types/helpers/extractProp.d.ts +0 -12
- package/dist/cjs/types/helpers/extractProp.test.d.ts +0 -5
- package/dist/cjs/types/helpers/floorToNumDecimals.d.ts +0 -9
- package/dist/cjs/types/helpers/floorToNumDecimals.test.d.ts +0 -5
- package/dist/cjs/types/helpers/forceNumIntoBounds.d.ts +0 -10
- package/dist/cjs/types/helpers/forceNumIntoBounds.test.d.ts +0 -5
- package/dist/cjs/types/helpers/genCSV.d.ts +0 -18
- package/dist/cjs/types/helpers/genCSV.test.d.ts +0 -5
- package/dist/cjs/types/helpers/genCommaList.d.ts +0 -12
- package/dist/cjs/types/helpers/genCommaList.test.d.ts +0 -1
- package/dist/cjs/types/helpers/getHumanReadableDate.d.ts +0 -8
- package/dist/cjs/types/helpers/getHumanReadableDate.test.d.ts +0 -5
- package/dist/cjs/types/helpers/getLocalTimeInfo.d.ts +0 -19
- package/dist/cjs/types/helpers/getLocalTimeInfo.test.d.ts +0 -6
- package/dist/cjs/types/helpers/getMonthName.d.ts +0 -14
- package/dist/cjs/types/helpers/getMonthName.test.d.ts +0 -5
- package/dist/cjs/types/helpers/getOrdinal.d.ts +0 -8
- package/dist/cjs/types/helpers/getOrdinal.test.d.ts +0 -5
- package/dist/cjs/types/helpers/getPartOfDay.d.ts +0 -7
- package/dist/cjs/types/helpers/getPartOfDay.test.d.ts +0 -5
- package/dist/cjs/types/helpers/getTimeInfoInET.d.ts +0 -21
- package/dist/cjs/types/helpers/getTimeInfoInET.test.d.ts +0 -5
- package/dist/cjs/types/helpers/getTimestampFromTimeInfoInET.d.ts +0 -20
- package/dist/cjs/types/helpers/getWordCount.d.ts +0 -10
- package/dist/cjs/types/helpers/idify.d.ts +0 -9
- package/dist/cjs/types/helpers/onlyKeepLetters.d.ts +0 -8
- package/dist/cjs/types/helpers/padDecimalZeros.d.ts +0 -10
- package/dist/cjs/types/helpers/padZerosLeft.d.ts +0 -9
- package/dist/cjs/types/helpers/parallelLimit.d.ts +0 -12
- package/dist/cjs/types/helpers/prefixWithAOrAn.d.ts +0 -10
- package/dist/cjs/types/helpers/roundToNumDecimals.d.ts +0 -9
- package/dist/cjs/types/helpers/shuffleArray.d.ts +0 -8
- package/dist/cjs/types/helpers/startMinWait.d.ts +0 -9
- package/dist/cjs/types/helpers/stringsToHumanReadableList.d.ts +0 -10
- package/dist/cjs/types/helpers/sum.d.ts +0 -8
- package/dist/cjs/types/helpers/validators/ChicagoTitleCase.d.ts +0 -9
- package/dist/cjs/types/helpers/validators/shared/constants/ERROR_MESSAGES.d.ts +0 -10
- package/dist/cjs/types/helpers/validators/shared/helpers/validateRegex.d.ts +0 -19
- package/dist/cjs/types/helpers/validators/shared/types/ValidationResult.d.ts +0 -12
- package/dist/cjs/types/helpers/validators/validURL.d.ts +0 -8
- package/dist/cjs/types/helpers/validators/validateEmail.d.ts +0 -11
- package/dist/cjs/types/helpers/validators/validateEmail.test.d.ts +0 -1
- package/dist/cjs/types/helpers/validators/validatePhoneNumber.d.ts +0 -11
- package/dist/cjs/types/helpers/validators/validatePhoneNumber.test.d.ts +0 -1
- package/dist/cjs/types/helpers/validators/validateString.d.ts +0 -22
- package/dist/cjs/types/helpers/validators/validateString.test.d.ts +0 -1
- package/dist/cjs/types/helpers/waitMs.d.ts +0 -7
- package/dist/cjs/types/types/DayOfWeek.d.ts +0 -14
- package/dist/cjs/types/types/Log/LogMainInfo.d.ts +0 -39
- package/dist/cjs/types/types/Log/LogSourceSpecificInfo.d.ts +0 -13
- package/dist/cjs/types/types/Log/LogTypeSpecificInfo.d.ts +0 -17
- package/dist/cjs/types/types/Log/index.d.ts +0 -10
- package/dist/cjs/types/types/LogAction.d.ts +0 -29
- package/dist/cjs/types/types/LogBuiltInMetadata.d.ts +0 -16
- package/dist/cjs/types/types/LogFunction.d.ts +0 -24
- package/dist/cjs/types/types/LogLevel.d.ts +0 -10
- package/dist/cjs/types/types/LogMetadataContextMap.d.ts +0 -11
- package/dist/cjs/types/types/LogMetadataTagMap.d.ts +0 -8
- package/dist/cjs/types/types/LogMetadataTargetMap.d.ts +0 -8
- package/dist/cjs/types/types/LogMetadataType.d.ts +0 -13
- package/dist/cjs/types/types/LogReviewerFilterState/ActionErrorFilterState.d.ts +0 -17
- package/dist/cjs/types/types/LogReviewerFilterState/AdvancedFilterState.d.ts +0 -21
- package/dist/cjs/types/types/LogReviewerFilterState/ContextFilterState.d.ts +0 -10
- package/dist/cjs/types/types/LogReviewerFilterState/DateFilterState.d.ts +0 -17
- package/dist/cjs/types/types/LogReviewerFilterState/TagFilterState.d.ts +0 -8
- package/dist/cjs/types/types/LogReviewerFilterState/index.d.ts +0 -17
- package/dist/cjs/types/types/LogSource.d.ts +0 -9
- package/dist/cjs/types/types/LogType.d.ts +0 -9
- package/dist/cjs/types/types/ParamType.d.ts +0 -17
- package/dist/cjs/types/types/ReactKitErrorCode.d.ts +0 -14
- package/dist/esm/types/constants/DAY_IN_MS.d.ts +0 -6
- package/dist/esm/types/constants/HOUR_IN_MS.d.ts +0 -6
- package/dist/esm/types/constants/LOG_REVIEW_GET_LOGS_ROUTE.d.ts +0 -6
- package/dist/esm/types/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.d.ts +0 -6
- package/dist/esm/types/constants/LOG_REVIEW_STATUS_ROUTE.d.ts +0 -7
- package/dist/esm/types/constants/LOG_ROUTE_PATH.d.ts +0 -6
- package/dist/esm/types/constants/MINUTE_IN_MS.d.ts +0 -6
- package/dist/esm/types/constants/ROUTE_PATH_PREFIX.d.ts +0 -6
- package/dist/esm/types/constants/SELECT_ADMIN_CHECK_ROUTE.d.ts +0 -6
- package/dist/esm/types/errors/ErrorWithCode.d.ts +0 -9
- package/dist/esm/types/helpers/abbreviate.d.ts +0 -10
- package/dist/esm/types/helpers/abbreviate.test.d.ts +0 -5
- package/dist/esm/types/helpers/asyncArrayFunctions/everyAsync.d.ts +0 -13
- package/dist/esm/types/helpers/asyncArrayFunctions/everyAsync.test.d.ts +0 -1
- package/dist/esm/types/helpers/asyncArrayFunctions/filterAsync.d.ts +0 -13
- package/dist/esm/types/helpers/asyncArrayFunctions/filterAsync.test.d.ts +0 -1
- package/dist/esm/types/helpers/asyncArrayFunctions/forEachAsync.d.ts +0 -10
- package/dist/esm/types/helpers/asyncArrayFunctions/forEachAsync.test.d.ts +0 -1
- package/dist/esm/types/helpers/asyncArrayFunctions/mapAsync.d.ts +0 -11
- package/dist/esm/types/helpers/asyncArrayFunctions/mapAsync.test.d.ts +0 -1
- package/dist/esm/types/helpers/asyncArrayFunctions/someAsync.d.ts +0 -13
- package/dist/esm/types/helpers/asyncArrayFunctions/someAsync.test.d.ts +0 -1
- package/dist/esm/types/helpers/avg.d.ts +0 -8
- package/dist/esm/types/helpers/avg.test.d.ts +0 -5
- package/dist/esm/types/helpers/capitalize.d.ts +0 -7
- package/dist/esm/types/helpers/ceilToNumDecimals.d.ts +0 -9
- package/dist/esm/types/helpers/ceilToNumDecimals.test.d.ts +0 -5
- package/dist/esm/types/helpers/cloneDeep.d.ts +0 -8
- package/dist/esm/types/helpers/compareArraysByProp.d.ts +0 -13
- package/dist/esm/types/helpers/compareArraysByProp.test.d.ts +0 -5
- package/dist/esm/types/helpers/extractProp.d.ts +0 -12
- package/dist/esm/types/helpers/extractProp.test.d.ts +0 -5
- package/dist/esm/types/helpers/floorToNumDecimals.d.ts +0 -9
- package/dist/esm/types/helpers/floorToNumDecimals.test.d.ts +0 -5
- package/dist/esm/types/helpers/forceNumIntoBounds.d.ts +0 -10
- package/dist/esm/types/helpers/forceNumIntoBounds.test.d.ts +0 -5
- package/dist/esm/types/helpers/genCSV.d.ts +0 -18
- package/dist/esm/types/helpers/genCSV.test.d.ts +0 -5
- package/dist/esm/types/helpers/genCommaList.d.ts +0 -12
- package/dist/esm/types/helpers/genCommaList.test.d.ts +0 -1
- package/dist/esm/types/helpers/getHumanReadableDate.d.ts +0 -8
- package/dist/esm/types/helpers/getHumanReadableDate.test.d.ts +0 -5
- package/dist/esm/types/helpers/getLocalTimeInfo.d.ts +0 -19
- package/dist/esm/types/helpers/getLocalTimeInfo.test.d.ts +0 -6
- package/dist/esm/types/helpers/getMonthName.d.ts +0 -14
- package/dist/esm/types/helpers/getMonthName.test.d.ts +0 -5
- package/dist/esm/types/helpers/getOrdinal.d.ts +0 -8
- package/dist/esm/types/helpers/getOrdinal.test.d.ts +0 -5
- package/dist/esm/types/helpers/getPartOfDay.d.ts +0 -7
- package/dist/esm/types/helpers/getPartOfDay.test.d.ts +0 -5
- package/dist/esm/types/helpers/getTimeInfoInET.d.ts +0 -21
- package/dist/esm/types/helpers/getTimeInfoInET.test.d.ts +0 -5
- package/dist/esm/types/helpers/getTimestampFromTimeInfoInET.d.ts +0 -20
- package/dist/esm/types/helpers/getWordCount.d.ts +0 -10
- package/dist/esm/types/helpers/idify.d.ts +0 -9
- package/dist/esm/types/helpers/onlyKeepLetters.d.ts +0 -8
- package/dist/esm/types/helpers/padDecimalZeros.d.ts +0 -10
- package/dist/esm/types/helpers/padZerosLeft.d.ts +0 -9
- package/dist/esm/types/helpers/parallelLimit.d.ts +0 -12
- package/dist/esm/types/helpers/prefixWithAOrAn.d.ts +0 -10
- package/dist/esm/types/helpers/roundToNumDecimals.d.ts +0 -9
- package/dist/esm/types/helpers/shuffleArray.d.ts +0 -8
- package/dist/esm/types/helpers/startMinWait.d.ts +0 -9
- package/dist/esm/types/helpers/stringsToHumanReadableList.d.ts +0 -10
- package/dist/esm/types/helpers/sum.d.ts +0 -8
- package/dist/esm/types/helpers/validators/ChicagoTitleCase.d.ts +0 -9
- package/dist/esm/types/helpers/validators/shared/constants/ERROR_MESSAGES.d.ts +0 -10
- package/dist/esm/types/helpers/validators/shared/helpers/validateRegex.d.ts +0 -19
- package/dist/esm/types/helpers/validators/shared/types/ValidationResult.d.ts +0 -12
- package/dist/esm/types/helpers/validators/validURL.d.ts +0 -8
- package/dist/esm/types/helpers/validators/validateEmail.d.ts +0 -11
- package/dist/esm/types/helpers/validators/validateEmail.test.d.ts +0 -1
- package/dist/esm/types/helpers/validators/validatePhoneNumber.d.ts +0 -11
- package/dist/esm/types/helpers/validators/validatePhoneNumber.test.d.ts +0 -1
- package/dist/esm/types/helpers/validators/validateString.d.ts +0 -22
- package/dist/esm/types/helpers/validators/validateString.test.d.ts +0 -1
- package/dist/esm/types/helpers/waitMs.d.ts +0 -7
- package/dist/esm/types/types/DayOfWeek.d.ts +0 -14
- package/dist/esm/types/types/Log/LogMainInfo.d.ts +0 -39
- package/dist/esm/types/types/Log/LogSourceSpecificInfo.d.ts +0 -13
- package/dist/esm/types/types/Log/LogTypeSpecificInfo.d.ts +0 -17
- package/dist/esm/types/types/Log/index.d.ts +0 -10
- package/dist/esm/types/types/LogAction.d.ts +0 -29
- package/dist/esm/types/types/LogBuiltInMetadata.d.ts +0 -16
- package/dist/esm/types/types/LogFunction.d.ts +0 -24
- package/dist/esm/types/types/LogLevel.d.ts +0 -10
- package/dist/esm/types/types/LogMetadataContextMap.d.ts +0 -11
- package/dist/esm/types/types/LogMetadataTagMap.d.ts +0 -8
- package/dist/esm/types/types/LogMetadataTargetMap.d.ts +0 -8
- package/dist/esm/types/types/LogMetadataType.d.ts +0 -13
- package/dist/esm/types/types/LogReviewerFilterState/ActionErrorFilterState.d.ts +0 -17
- package/dist/esm/types/types/LogReviewerFilterState/AdvancedFilterState.d.ts +0 -21
- package/dist/esm/types/types/LogReviewerFilterState/ContextFilterState.d.ts +0 -10
- package/dist/esm/types/types/LogReviewerFilterState/DateFilterState.d.ts +0 -17
- package/dist/esm/types/types/LogReviewerFilterState/TagFilterState.d.ts +0 -8
- package/dist/esm/types/types/LogReviewerFilterState/index.d.ts +0 -17
- package/dist/esm/types/types/LogSource.d.ts +0 -9
- package/dist/esm/types/types/LogType.d.ts +0 -9
- package/dist/esm/types/types/ParamType.d.ts +0 -17
- package/dist/esm/types/types/ReactKitErrorCode.d.ts +0 -14
- package/src/constants/DAY_IN_MS.ts +0 -7
- package/src/constants/HOUR_IN_MS.ts +0 -7
- package/src/constants/LOG_REVIEW_GET_LOGS_ROUTE.ts +0 -9
- package/src/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.ts +0 -9
- package/src/constants/LOG_REVIEW_STATUS_ROUTE.ts +0 -10
- package/src/constants/LOG_ROUTE_PATH.ts +0 -9
- package/src/constants/MINUTE_IN_MS.ts +0 -7
- package/src/constants/ROUTE_PATH_PREFIX.ts +0 -7
- package/src/constants/SELECT_ADMIN_CHECK_ROUTE.ts +0 -7
- package/src/errors/ErrorWithCode.tsx +0 -15
- package/src/helpers/abbreviate.test.ts +0 -26
- package/src/helpers/abbreviate.ts +0 -25
- package/src/helpers/asyncArrayFunctions/everyAsync.test.ts +0 -114
- package/src/helpers/asyncArrayFunctions/everyAsync.ts +0 -51
- package/src/helpers/asyncArrayFunctions/filterAsync.test.ts +0 -126
- package/src/helpers/asyncArrayFunctions/filterAsync.ts +0 -50
- package/src/helpers/asyncArrayFunctions/forEachAsync.test.ts +0 -136
- package/src/helpers/asyncArrayFunctions/forEachAsync.ts +0 -40
- package/src/helpers/asyncArrayFunctions/mapAsync.test.ts +0 -125
- package/src/helpers/asyncArrayFunctions/mapAsync.ts +0 -46
- package/src/helpers/asyncArrayFunctions/someAsync.test.ts +0 -92
- package/src/helpers/asyncArrayFunctions/someAsync.ts +0 -49
- package/src/helpers/avg.test.ts +0 -24
- package/src/helpers/avg.ts +0 -22
- package/src/helpers/capitalize.ts +0 -20
- package/src/helpers/ceilToNumDecimals.test.ts +0 -39
- package/src/helpers/ceilToNumDecimals.ts +0 -13
- package/src/helpers/cloneDeep.ts +0 -11
- package/src/helpers/compareArraysByProp.test.ts +0 -147
- package/src/helpers/compareArraysByProp.ts +0 -56
- package/src/helpers/extractProp.test.ts +0 -34
- package/src/helpers/extractProp.ts +0 -17
- package/src/helpers/floorToNumDecimals.test.ts +0 -39
- package/src/helpers/floorToNumDecimals.ts +0 -13
- package/src/helpers/forceNumIntoBounds.test.ts +0 -34
- package/src/helpers/forceNumIntoBounds.ts +0 -19
- package/src/helpers/genCSV.test.ts +0 -75
- package/src/helpers/genCSV.ts +0 -87
- package/src/helpers/genCommaList.test.ts +0 -57
- package/src/helpers/genCommaList.ts +0 -21
- package/src/helpers/getHumanReadableDate.test.ts +0 -29
- package/src/helpers/getHumanReadableDate.ts +0 -36
- package/src/helpers/getLocalTimeInfo.test.ts +0 -48
- package/src/helpers/getLocalTimeInfo.ts +0 -58
- package/src/helpers/getMonthName.test.ts +0 -79
- package/src/helpers/getMonthName.ts +0 -29
- package/src/helpers/getOrdinal.test.ts +0 -84
- package/src/helpers/getOrdinal.ts +0 -14
- package/src/helpers/getPartOfDay.test.ts +0 -56
- package/src/helpers/getPartOfDay.ts +0 -20
- package/src/helpers/getTimeInfoInET.test.ts +0 -72
- package/src/helpers/getTimeInfoInET.ts +0 -79
- package/src/helpers/getTimestampFromTimeInfoInET.ts +0 -179
- package/src/helpers/getWordCount.ts +0 -26
- package/src/helpers/idify.ts +0 -24
- package/src/helpers/onlyKeepLetters.ts +0 -11
- package/src/helpers/padDecimalZeros.tsx +0 -32
- package/src/helpers/padZerosLeft.tsx +0 -21
- package/src/helpers/parallelLimit.ts +0 -63
- package/src/helpers/prefixWithAOrAn.ts +0 -29
- package/src/helpers/roundToNumDecimals.tsx +0 -13
- package/src/helpers/shuffleArray.ts +0 -19
- package/src/helpers/startMinWait.ts +0 -33
- package/src/helpers/stringsToHumanReadableList.ts +0 -39
- package/src/helpers/sum.tsx +0 -16
- package/src/helpers/validators/ChicagoTitleCase.test.ts +0 -85
- package/src/helpers/validators/ChicagoTitleCase.ts +0 -32
- package/src/helpers/validators/findURL.test.ts +0 -83
- package/src/helpers/validators/findURL.ts +0 -43
- package/src/helpers/validators/shared/constants/ERROR_MESSAGES.ts +0 -18
- package/src/helpers/validators/shared/helpers/validateRegex.ts +0 -47
- package/src/helpers/validators/shared/types/ValidationResult.ts +0 -20
- package/src/helpers/validators/validURL.test.ts +0 -90
- package/src/helpers/validators/validURL.ts +0 -18
- package/src/helpers/validators/validateEmail.test.ts +0 -110
- package/src/helpers/validators/validateEmail.ts +0 -47
- package/src/helpers/validators/validatePhoneNumber.test.ts +0 -94
- package/src/helpers/validators/validatePhoneNumber.ts +0 -49
- package/src/helpers/validators/validateString.test.ts +0 -173
- package/src/helpers/validators/validateString.ts +0 -171
- package/src/helpers/waitMs.tsx +0 -12
- package/src/types/DayOfWeek.ts +0 -15
- package/src/types/Log/LogMainInfo.ts +0 -69
- package/src/types/Log/LogSourceSpecificInfo.ts +0 -25
- package/src/types/Log/LogTypeSpecificInfo.ts +0 -33
- package/src/types/Log/index.ts +0 -17
- package/src/types/LogAction.ts +0 -52
- package/src/types/LogBuiltInMetadata.ts +0 -19
- package/src/types/LogFunction.ts +0 -46
- package/src/types/LogLevel.ts +0 -11
- package/src/types/LogMetadataContextMap.ts +0 -15
- package/src/types/LogMetadataTagMap.ts +0 -9
- package/src/types/LogMetadataTargetMap.ts +0 -9
- package/src/types/LogMetadataType.ts +0 -16
- package/src/types/LogReviewerFilterState/ActionErrorFilterState.ts +0 -24
- package/src/types/LogReviewerFilterState/AdvancedFilterState.ts +0 -36
- package/src/types/LogReviewerFilterState/ContextFilterState.ts +0 -16
- package/src/types/LogReviewerFilterState/DateFilterState.ts +0 -26
- package/src/types/LogReviewerFilterState/TagFilterState.ts +0 -9
- package/src/types/LogReviewerFilterState/index.ts +0 -24
- package/src/types/LogSource.ts +0 -12
- package/src/types/LogType.ts +0 -12
- package/src/types/ParamType.ts +0 -18
- package/src/types/ReactKitErrorCode.tsx +0 -17
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test file for the extractProp helper
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Import main helper
|
|
7
|
-
import extractProp from './extractProp';
|
|
8
|
-
|
|
9
|
-
describe('extractProp', () => {
|
|
10
|
-
it('should return an empty array if the input array is empty', () => {
|
|
11
|
-
const result = extractProp([], 'age');
|
|
12
|
-
expect(result).toEqual([]);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should extract the correct property from each object in the array', () => {
|
|
16
|
-
const users = [
|
|
17
|
-
{ name: 'Alice', age: 25 },
|
|
18
|
-
{ name: 'Bob', age: 30 },
|
|
19
|
-
{ name: 'Charlie', age: 35 },
|
|
20
|
-
];
|
|
21
|
-
const result = extractProp(users, 'age');
|
|
22
|
-
expect(result).toEqual([25, 30, 35]);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should return undefined for objects that do not have the specified property', () => {
|
|
26
|
-
const users = [
|
|
27
|
-
{ name: 'Alice', age: 25 },
|
|
28
|
-
{ name: 'Bob' },
|
|
29
|
-
{ name: 'Charlie', age: 35 },
|
|
30
|
-
];
|
|
31
|
-
const result = extractProp(users, 'age');
|
|
32
|
-
expect(result).toEqual([25, undefined, 35]);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* For every element in an array, extract the value of a prop
|
|
3
|
-
* (e.g. for all user objects, extract their ages and put that into a new
|
|
4
|
-
* ages array)
|
|
5
|
-
* @author Gabe Abrams
|
|
6
|
-
* @param arr the array of objects to operate on
|
|
7
|
-
* @param prop the property to extract from each object
|
|
8
|
-
* @returns new array containing the corresponding values, in order, of each
|
|
9
|
-
* object in the original array
|
|
10
|
-
*/
|
|
11
|
-
const extractProp = (arr: any[], prop: string) => {
|
|
12
|
-
return arr.map((item) => {
|
|
13
|
-
return item[prop];
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default extractProp;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test file for the floorToNumDecimals helper
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Import main function
|
|
7
|
-
import floorToNumDecimals from './floorToNumDecimals';
|
|
8
|
-
|
|
9
|
-
describe('floorToNumDecimals', () => {
|
|
10
|
-
it('should return 0 for 0 with 0 decimals', () => {
|
|
11
|
-
const result = floorToNumDecimals(0, 0);
|
|
12
|
-
expect(result).toEqual(0);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should return 1 for 1 with 0 decimals', () => {
|
|
16
|
-
const result = floorToNumDecimals(1, 0);
|
|
17
|
-
expect(result).toEqual(1);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should return 1.23 for 1.234 with 2 decimals', () => {
|
|
21
|
-
const result = floorToNumDecimals(1.234, 2);
|
|
22
|
-
expect(result).toEqual(1.23);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should return -1.24 for -1.234 with 2 decimals', () => {
|
|
26
|
-
const result = floorToNumDecimals(-1.234, 2);
|
|
27
|
-
expect(result).toEqual(-1.24);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('should return 1234 for 1234 with 0 decimals', () => {
|
|
31
|
-
const result = floorToNumDecimals(1234, 0);
|
|
32
|
-
expect(result).toEqual(1234);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should return 0.001 for 0.00123 with 3 decimals', () => {
|
|
36
|
-
const result = floorToNumDecimals(0.00123, 3);
|
|
37
|
-
expect(result).toEqual(0.001);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Round a number (floor) to a certain number of decimals
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
* @param num the number to round
|
|
5
|
-
* @param numDecimals the number of decimals to round to
|
|
6
|
-
* @returns rounded number
|
|
7
|
-
*/
|
|
8
|
-
const floorToNumDecimals = (num: number, numDecimals: number): number => {
|
|
9
|
-
const rounder = 10 ** numDecimals;
|
|
10
|
-
return (Math.floor(num * rounder) / rounder);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default floorToNumDecimals;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test file for the forceNumIntoBounds helper
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Import main helper
|
|
7
|
-
import forceNumIntoBounds from './forceNumIntoBounds';
|
|
8
|
-
|
|
9
|
-
describe('forceNumIntoBounds', () => {
|
|
10
|
-
it('should return the number if it is within the bounds', () => {
|
|
11
|
-
const result = forceNumIntoBounds(5, 0, 10);
|
|
12
|
-
expect(result).toEqual(5);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should return the minimum bound if the number is less than the minimum', () => {
|
|
16
|
-
const result = forceNumIntoBounds(-5, 0, 10);
|
|
17
|
-
expect(result).toEqual(0);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should return the maximum bound if the number is greater than the maximum', () => {
|
|
21
|
-
const result = forceNumIntoBounds(15, 0, 10);
|
|
22
|
-
expect(result).toEqual(10);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should return the minimum bound if the number is equal to the minimum', () => {
|
|
26
|
-
const result = forceNumIntoBounds(0, 0, 10);
|
|
27
|
-
expect(result).toEqual(0);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('should return the maximum bound if the number is equal to the maximum', () => {
|
|
31
|
-
const result = forceNumIntoBounds(10, 0, 10);
|
|
32
|
-
expect(result).toEqual(10);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Force a number to stay within specific bounds
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
* @param num the number to move into the bounds
|
|
5
|
-
* @param min the minimum number in the bound
|
|
6
|
-
* @param max the maximum number in the bound
|
|
7
|
-
* @returns bounded number
|
|
8
|
-
*/
|
|
9
|
-
const forceNumIntoBounds = (num: number, min: number, max: number): number => {
|
|
10
|
-
return Math.max(
|
|
11
|
-
min,
|
|
12
|
-
Math.min(
|
|
13
|
-
max,
|
|
14
|
-
num,
|
|
15
|
-
),
|
|
16
|
-
);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default forceNumIntoBounds;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test file for the genCSV helper
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Import main helper
|
|
7
|
-
import genCSV from './genCSV';
|
|
8
|
-
|
|
9
|
-
describe('genCSV', () => {
|
|
10
|
-
it('should return an empty string for empty data', () => {
|
|
11
|
-
const result = genCSV([], []);
|
|
12
|
-
expect(result).toEqual('');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should generate a CSV with the correct headers and data', () => {
|
|
16
|
-
const columns = [
|
|
17
|
-
{ title: 'Name', param: 'name' },
|
|
18
|
-
{ title: 'Age', param: 'age' },
|
|
19
|
-
{ title: 'Email', param: 'email' },
|
|
20
|
-
];
|
|
21
|
-
const data = [
|
|
22
|
-
{ name: 'Alice', age: 25, email: 'alice@example.com' },
|
|
23
|
-
{ name: 'Bob', age: 30, email: 'bob@example.com' },
|
|
24
|
-
{ name: 'Charlie', age: 35, email: 'charlie@example.com' },
|
|
25
|
-
];
|
|
26
|
-
const expected = 'Name,Age,Email\nAlice,25,alice@example.com\nBob,30,bob@example.com\nCharlie,35,charlie@example.com';
|
|
27
|
-
const result = genCSV(data, columns);
|
|
28
|
-
expect(result).toEqual(expected);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should handle undefined and null values correctly', () => {
|
|
32
|
-
const columns = [
|
|
33
|
-
{ title: 'Name', param: 'name' },
|
|
34
|
-
{ title: 'Age', param: 'age' },
|
|
35
|
-
{ title: 'Email', param: 'email' },
|
|
36
|
-
];
|
|
37
|
-
const data = [
|
|
38
|
-
{ name: 'Alice', age: undefined, email: null },
|
|
39
|
-
{ name: 'Bob', age: null, email: 'bob@example.com' },
|
|
40
|
-
{ name: 'Charlie', age: 35, email: undefined },
|
|
41
|
-
];
|
|
42
|
-
const expected = 'Name,Age,Email\nAlice,,\nBob,,bob@example.com\nCharlie,35,';
|
|
43
|
-
const result = genCSV(data, columns);
|
|
44
|
-
expect(result).toEqual(expected);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should handle objects in cells correctly', () => {
|
|
48
|
-
const columns = [
|
|
49
|
-
{ title: 'Name', param: 'name' },
|
|
50
|
-
{ title: 'Data', param: 'data' },
|
|
51
|
-
];
|
|
52
|
-
const data = [
|
|
53
|
-
{ name: 'Alice', data: { foo: 'bar' } },
|
|
54
|
-
{ name: 'Bob', data: [1, 2, 3] },
|
|
55
|
-
{ name: 'Charlie', data: null },
|
|
56
|
-
];
|
|
57
|
-
const expected = 'Name,Data\nAlice,"{""foo"":""bar""}"\nBob,"[1,2,3]"\nCharlie,';
|
|
58
|
-
const result = genCSV(data, columns);
|
|
59
|
-
expect(result).toEqual(expected);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('should use textIfUndefined for undefined values', () => {
|
|
63
|
-
const columns = [
|
|
64
|
-
{ title: 'Name', param: 'name' },
|
|
65
|
-
{ title: 'Age', param: 'age', textIfUndefined: 'N/A' },
|
|
66
|
-
];
|
|
67
|
-
const data = [
|
|
68
|
-
{ name: 'Alice', age: undefined },
|
|
69
|
-
{ name: 'Bob', age: 30 },
|
|
70
|
-
];
|
|
71
|
-
const expected = 'Name,Age\nAlice,N/A\nBob,30';
|
|
72
|
-
const result = genCSV(data, columns);
|
|
73
|
-
expect(result).toEqual(expected);
|
|
74
|
-
});
|
|
75
|
-
});
|
package/src/helpers/genCSV.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Escape a CSV cell if needed
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
* @param text the cell contents
|
|
5
|
-
* @returns escaped cell text
|
|
6
|
-
*/
|
|
7
|
-
const escapeCellText = (text: string): string => {
|
|
8
|
-
if (
|
|
9
|
-
!String(text).includes(',')
|
|
10
|
-
&& !String(text).includes('"')
|
|
11
|
-
) {
|
|
12
|
-
// No need to escape
|
|
13
|
-
return String(text);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Perform escape
|
|
17
|
-
return `"${String(text).replace(/"/g, '""')}"`;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Generate a CSV file
|
|
22
|
-
* @author Gabe Abrams
|
|
23
|
-
* @param data list of row data in the form of json objects
|
|
24
|
-
* @param columns list of columns to include in the csv where each column is an object with:
|
|
25
|
-
* - title: the column title
|
|
26
|
-
* - param: the key in the data object to use for this column
|
|
27
|
-
* - textIfUndefined: optional text to use if the value is undefined (defaults to empty string)
|
|
28
|
-
* @returns multiline csv string
|
|
29
|
-
*/
|
|
30
|
-
const genCSV = (
|
|
31
|
-
data: {
|
|
32
|
-
[k: string]: any
|
|
33
|
-
}[],
|
|
34
|
-
columns: {
|
|
35
|
-
title: string,
|
|
36
|
-
param: string,
|
|
37
|
-
textIfUndefined?: string,
|
|
38
|
-
}[],
|
|
39
|
-
): string => {
|
|
40
|
-
let csv = '';
|
|
41
|
-
|
|
42
|
-
// Add header
|
|
43
|
-
csv += (
|
|
44
|
-
columns
|
|
45
|
-
.map((column) => {
|
|
46
|
-
return escapeCellText(column.title);
|
|
47
|
-
})
|
|
48
|
-
.join(',')
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
// Add each row
|
|
52
|
-
data.forEach((datum) => {
|
|
53
|
-
csv += '\n';
|
|
54
|
-
csv += (
|
|
55
|
-
columns
|
|
56
|
-
.map((column) => {
|
|
57
|
-
let contents: string;
|
|
58
|
-
const cell = datum[column.param];
|
|
59
|
-
if (
|
|
60
|
-
typeof cell === 'string'
|
|
61
|
-
|| typeof cell === 'number'
|
|
62
|
-
|| typeof cell === 'boolean'
|
|
63
|
-
) {
|
|
64
|
-
contents = String(cell);
|
|
65
|
-
} else if (cell === null) {
|
|
66
|
-
contents = '';
|
|
67
|
-
} else if (typeof cell === 'undefined') {
|
|
68
|
-
contents = (
|
|
69
|
-
column.textIfUndefined
|
|
70
|
-
?? ''
|
|
71
|
-
);
|
|
72
|
-
} else if (typeof cell === 'object') {
|
|
73
|
-
contents = JSON.stringify(cell);
|
|
74
|
-
} else {
|
|
75
|
-
contents = '';
|
|
76
|
-
}
|
|
77
|
-
return escapeCellText(contents);
|
|
78
|
-
})
|
|
79
|
-
.join(',')
|
|
80
|
-
);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// Return
|
|
84
|
-
return csv;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export default genCSV;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// Import function
|
|
2
|
-
import genCommaList from './genCommaList';
|
|
3
|
-
|
|
4
|
-
test(
|
|
5
|
-
'Empty list.',
|
|
6
|
-
async () => {
|
|
7
|
-
const emptyList: string[] = [];
|
|
8
|
-
const emptyListResponse: string = '';
|
|
9
|
-
|
|
10
|
-
const result = genCommaList(emptyList);
|
|
11
|
-
expect(result).toStrictEqual(emptyListResponse);
|
|
12
|
-
},
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
test(
|
|
16
|
-
'One word list.',
|
|
17
|
-
async () => {
|
|
18
|
-
const oneList: string[] = ['apples'];
|
|
19
|
-
const oneListResponse: string = 'apples';
|
|
20
|
-
|
|
21
|
-
const result = genCommaList(oneList);
|
|
22
|
-
expect(result).toStrictEqual(oneListResponse);
|
|
23
|
-
},
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
test(
|
|
27
|
-
'Two word list.',
|
|
28
|
-
async () => {
|
|
29
|
-
const twoList: string[] = ['apples', 'oranges'];
|
|
30
|
-
const twoListResponse: string = 'apples and oranges';
|
|
31
|
-
|
|
32
|
-
const result = genCommaList(twoList);
|
|
33
|
-
expect(result).toStrictEqual(twoListResponse);
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
test(
|
|
38
|
-
'Three word list.',
|
|
39
|
-
async () => {
|
|
40
|
-
const threeList: string[] = ['apples', 'oranges', 'bananas'];
|
|
41
|
-
const threeListResponse: string = 'apples, oranges, and bananas';
|
|
42
|
-
|
|
43
|
-
const result = genCommaList(threeList);
|
|
44
|
-
expect(result).toStrictEqual(threeListResponse);
|
|
45
|
-
},
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
test(
|
|
49
|
-
'Four word list.',
|
|
50
|
-
async () => {
|
|
51
|
-
const fourList: string[] = ['apples', 'oranges', 'bananas', 'grapes'];
|
|
52
|
-
const fourListResponse: string = 'apples, oranges, bananas, and grapes';
|
|
53
|
-
|
|
54
|
-
const result = genCommaList(fourList);
|
|
55
|
-
expect(result).toStrictEqual(fourListResponse);
|
|
56
|
-
},
|
|
57
|
-
);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Given an array of strings, create a single comma-separated string that includes
|
|
3
|
-
* 'and' as well as an oxford comma.
|
|
4
|
-
* Ex: ['apples'] => 'apples'
|
|
5
|
-
* Ex: ['apples', 'bananas'] => 'apples and bananas'
|
|
6
|
-
* Ex: ['apples', 'bananas', 'grapes'] => 'apples, bananas, and grapes'
|
|
7
|
-
* @author Austen Money
|
|
8
|
-
* @param list an array of elements to be made into a single comma-separated string.
|
|
9
|
-
* @returns a comma-separated string.
|
|
10
|
-
*/
|
|
11
|
-
const genCommaList = (list: string[]): string => {
|
|
12
|
-
const { length } = list;
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
length < 2
|
|
16
|
-
? list.join('')
|
|
17
|
-
: `${list.slice(0, length - 1).join(', ')}${length < 3 ? ' and ' : ', and '}${list[length - 1]}`
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default genCommaList;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test file for the getHumanReadableDate helper
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Import helpers
|
|
7
|
-
import getHumanReadableDate from './getHumanReadableDate';
|
|
8
|
-
import getOrdinal from './getOrdinal';
|
|
9
|
-
|
|
10
|
-
describe('getHumanReadableDate', () => {
|
|
11
|
-
it('should return the current date if no argument is passed', () => {
|
|
12
|
-
const result = getHumanReadableDate();
|
|
13
|
-
const now = new Date();
|
|
14
|
-
const expected = `${now.toLocaleString('default', { month: 'short' })} ${now.getDate()}${getOrdinal(now.getDate())}`;
|
|
15
|
-
expect(result).toEqual(expected);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should return the correct date for a given timestamp', () => {
|
|
19
|
-
const timestamp = 1629822000000; // 2021-08-24T12:20:00.000Z
|
|
20
|
-
const result = getHumanReadableDate(timestamp);
|
|
21
|
-
expect(result).toEqual('Aug 24th 2021');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should return the correct date for a given Date object', () => {
|
|
25
|
-
const date = new Date('2021-08-24T12:20:00.000Z');
|
|
26
|
-
const result = getHumanReadableDate(date);
|
|
27
|
-
expect(result).toEqual('Aug 24th 2021');
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// Import shared helpers
|
|
2
|
-
import getTimeInfoInET from './getTimeInfoInET';
|
|
3
|
-
import getOrdinal from './getOrdinal';
|
|
4
|
-
import getMonthName from './getMonthName';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Get a human-readable description of a date (all in ET)
|
|
8
|
-
* @author Gabe Abrams
|
|
9
|
-
* @param [dateOrTimestamp=today] the date or timestamp for the date to describe
|
|
10
|
-
* @returns human-readable description of the date
|
|
11
|
-
*/
|
|
12
|
-
const getHumanReadableDate = (dateOrTimestamp?: Date | number) => {
|
|
13
|
-
// Get the date info
|
|
14
|
-
const {
|
|
15
|
-
month,
|
|
16
|
-
day,
|
|
17
|
-
year,
|
|
18
|
-
} = getTimeInfoInET(dateOrTimestamp);
|
|
19
|
-
const currYear = getTimeInfoInET().year;
|
|
20
|
-
|
|
21
|
-
// Get the short month description
|
|
22
|
-
const monthName = getMonthName(month).short;
|
|
23
|
-
|
|
24
|
-
// Create start of description
|
|
25
|
-
let description = `${monthName} ${day}${getOrdinal(day)}`;
|
|
26
|
-
|
|
27
|
-
// Add on year if it's different
|
|
28
|
-
if (year !== currYear) {
|
|
29
|
-
description += ` ${year}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Return description
|
|
33
|
-
return description;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default getHumanReadableDate;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test for getLocalTimeInfo helper function
|
|
3
|
-
* NOTE: only works if this test is run on a machine in ET
|
|
4
|
-
* @author Gabe Abrams
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// Import main function
|
|
8
|
-
import getLocalTimeInfo from './getLocalTimeInfo';
|
|
9
|
-
|
|
10
|
-
describe('getLocalTimeInfo', () => {
|
|
11
|
-
it('should return current time info if no argument is passed', () => {
|
|
12
|
-
const result = getLocalTimeInfo();
|
|
13
|
-
const now = new Date();
|
|
14
|
-
expect(result.timestamp).toBeCloseTo(now.getTime(), -3);
|
|
15
|
-
expect(result.year).toEqual(now.getFullYear());
|
|
16
|
-
expect(result.month).toEqual(now.getMonth() + 1);
|
|
17
|
-
expect(result.day).toEqual(now.getDate());
|
|
18
|
-
expect(result.hour).toEqual(now.getHours());
|
|
19
|
-
expect(result.minute).toEqual(now.getMinutes());
|
|
20
|
-
expect(result.isPM).toEqual(now.getHours() >= 12);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should return correct time info for a given timestamp', () => {
|
|
24
|
-
const timestamp = 1629822000000; // 2021-08-24T12:20:00.000Z
|
|
25
|
-
const result = getLocalTimeInfo(timestamp);
|
|
26
|
-
expect(result.timestamp).toEqual(timestamp);
|
|
27
|
-
expect(result.year).toEqual(2021);
|
|
28
|
-
expect(result.month).toEqual(8);
|
|
29
|
-
expect(result.day).toEqual(24);
|
|
30
|
-
expect(result.hour).toEqual(12);
|
|
31
|
-
expect(result.hour12).toEqual(12);
|
|
32
|
-
expect(result.minute).toEqual(20);
|
|
33
|
-
expect(result.isPM).toEqual(true);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should return correct time info for a given Date object', () => {
|
|
37
|
-
const date = new Date('2021-08-24T12:20:00.000Z');
|
|
38
|
-
const result = getLocalTimeInfo(date);
|
|
39
|
-
expect(result.timestamp).toEqual(date.getTime());
|
|
40
|
-
expect(result.year).toEqual(2021);
|
|
41
|
-
expect(result.month).toEqual(8);
|
|
42
|
-
expect(result.day).toEqual(24);
|
|
43
|
-
expect(result.hour).toEqual(8);
|
|
44
|
-
expect(result.hour12).toEqual(8);
|
|
45
|
-
expect(result.minute).toEqual(20);
|
|
46
|
-
expect(result.isPM).toEqual(false);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get current time info in local time
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
* @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
|
|
5
|
-
* @returns object with timestamp (ms since epoch) and numbers
|
|
6
|
-
* corresponding to time values for year, month, day, hour, hour12, minute, isPM
|
|
7
|
-
* where hour is in 24hr time and hour12 is in 12hr time.
|
|
8
|
-
*/
|
|
9
|
-
const getLocalTimeInfo = (dateOrTimestamp?: Date | number): {
|
|
10
|
-
timestamp: number,
|
|
11
|
-
year: number,
|
|
12
|
-
month: number,
|
|
13
|
-
day: number,
|
|
14
|
-
hour: number,
|
|
15
|
-
hour12: number,
|
|
16
|
-
minute: number,
|
|
17
|
-
isPM: boolean,
|
|
18
|
-
} => {
|
|
19
|
-
// Create a time string
|
|
20
|
-
let d: Date;
|
|
21
|
-
if (!dateOrTimestamp) {
|
|
22
|
-
// Use now
|
|
23
|
-
d = new Date();
|
|
24
|
-
} else if (typeof dateOrTimestamp === 'number') {
|
|
25
|
-
// Convert to date
|
|
26
|
-
d = new Date(dateOrTimestamp);
|
|
27
|
-
} else {
|
|
28
|
-
// Already a date
|
|
29
|
-
d = dateOrTimestamp;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Create all time numbers
|
|
33
|
-
const timestamp = d.getTime();
|
|
34
|
-
const year = d.getFullYear();
|
|
35
|
-
const month = d.getMonth() + 1;
|
|
36
|
-
const day = d.getDate();
|
|
37
|
-
const hour = d.getHours();
|
|
38
|
-
const isPM = hour >= 12;
|
|
39
|
-
let hour12 = hour % 12;
|
|
40
|
-
if (hour12 === 0) {
|
|
41
|
-
hour12 = 12;
|
|
42
|
-
}
|
|
43
|
-
const minute = d.getMinutes();
|
|
44
|
-
|
|
45
|
-
// Return
|
|
46
|
-
return {
|
|
47
|
-
timestamp,
|
|
48
|
-
year,
|
|
49
|
-
month,
|
|
50
|
-
day,
|
|
51
|
-
hour,
|
|
52
|
-
hour12,
|
|
53
|
-
isPM,
|
|
54
|
-
minute,
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default getLocalTimeInfo;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test for getMonthName helper
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Import main helper
|
|
7
|
-
import getMonthName from './getMonthName';
|
|
8
|
-
|
|
9
|
-
describe('getMonthName', () => {
|
|
10
|
-
it('should return January for 1', () => {
|
|
11
|
-
const result = getMonthName(1);
|
|
12
|
-
expect(result).toEqual({ short: 'Jan', full: 'January' });
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should return February for 2', () => {
|
|
16
|
-
const result = getMonthName(2);
|
|
17
|
-
expect(result).toEqual({ short: 'Feb', full: 'February' });
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should return March for 3', () => {
|
|
21
|
-
const result = getMonthName(3);
|
|
22
|
-
expect(result).toEqual({ short: 'Mar', full: 'March' });
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should return April for 4', () => {
|
|
26
|
-
const result = getMonthName(4);
|
|
27
|
-
expect(result).toEqual({ short: 'Apr', full: 'April' });
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('should return May for 5', () => {
|
|
31
|
-
const result = getMonthName(5);
|
|
32
|
-
expect(result).toEqual({ short: 'May', full: 'May' });
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should return June for 6', () => {
|
|
36
|
-
const result = getMonthName(6);
|
|
37
|
-
expect(result).toEqual({ short: 'Jun', full: 'June' });
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should return July for 7', () => {
|
|
41
|
-
const result = getMonthName(7);
|
|
42
|
-
expect(result).toEqual({ short: 'Jul', full: 'July' });
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should return August for 8', () => {
|
|
46
|
-
const result = getMonthName(8);
|
|
47
|
-
expect(result).toEqual({ short: 'Aug', full: 'August' });
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('should return September for 9', () => {
|
|
51
|
-
const result = getMonthName(9);
|
|
52
|
-
expect(result).toEqual({ short: 'Sep', full: 'September' });
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should return October for 10', () => {
|
|
56
|
-
const result = getMonthName(10);
|
|
57
|
-
expect(result).toEqual({ short: 'Oct', full: 'October' });
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('should return November for 11', () => {
|
|
61
|
-
const result = getMonthName(11);
|
|
62
|
-
expect(result).toEqual({ short: 'Nov', full: 'November' });
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should return December for 12', () => {
|
|
66
|
-
const result = getMonthName(12);
|
|
67
|
-
expect(result).toEqual({ short: 'Dec', full: 'December' });
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should return January for 0', () => {
|
|
71
|
-
const result = getMonthName(0);
|
|
72
|
-
expect(result).toEqual({ short: 'Jan', full: 'January' });
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should return January for 13', () => {
|
|
76
|
-
const result = getMonthName(13);
|
|
77
|
-
expect(result).toEqual({ short: 'Jan', full: 'January' });
|
|
78
|
-
});
|
|
79
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const monthNames = [
|
|
2
|
-
{ short: 'Jan', full: 'January' },
|
|
3
|
-
{ short: 'Feb', full: 'February' },
|
|
4
|
-
{ short: 'Mar', full: 'March' },
|
|
5
|
-
{ short: 'Apr', full: 'April' },
|
|
6
|
-
{ short: 'May', full: 'May' },
|
|
7
|
-
{ short: 'Jun', full: 'June' },
|
|
8
|
-
{ short: 'Jul', full: 'July' },
|
|
9
|
-
{ short: 'Aug', full: 'August' },
|
|
10
|
-
{ short: 'Sep', full: 'September' },
|
|
11
|
-
{ short: 'Oct', full: 'October' },
|
|
12
|
-
{ short: 'Nov', full: 'November' },
|
|
13
|
-
{ short: 'Dec', full: 'December' },
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Get the name of a month given the month number (1 = January, etc.)
|
|
18
|
-
* If an invalid number is provided, we will treat it like January
|
|
19
|
-
* @author Gabe Abrams
|
|
20
|
-
* @param month the number of the month
|
|
21
|
-
* @returns object containing multiple month name formats:
|
|
22
|
-
* { short, full } where short will look like "Jan" and full will look like
|
|
23
|
-
* "January"
|
|
24
|
-
*/
|
|
25
|
-
const getMonthName = (month: number) => {
|
|
26
|
-
return (monthNames[month - 1] ?? monthNames[0]);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default getMonthName;
|