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,29 +0,0 @@
|
|
|
1
|
-
// Constants
|
|
2
|
-
const VOWELS = ['a', 'e', 'i', 'o', 'u'];
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Prefix a word or name with "a" or "an" depending on whether it starts with a
|
|
6
|
-
* vowel or not
|
|
7
|
-
* @author Gabe Abrams
|
|
8
|
-
* @param text the text to prefix
|
|
9
|
-
* @param capitalize whether to capitalize the "A" or "An"
|
|
10
|
-
* @returns the text prefixed with "a" or "an"
|
|
11
|
-
*/
|
|
12
|
-
const prefixWithAOrAn = (text: string, capitalize = false): string => {
|
|
13
|
-
// Get the first letter
|
|
14
|
-
const firstLetter = text.charAt(0).toLowerCase();
|
|
15
|
-
|
|
16
|
-
// Check if starts with vowel
|
|
17
|
-
const startsWithVowel = VOWELS.includes(firstLetter);
|
|
18
|
-
|
|
19
|
-
// Determine prefix
|
|
20
|
-
let prefix = startsWithVowel ? 'an' : 'a';
|
|
21
|
-
if (capitalize) {
|
|
22
|
-
prefix = prefix.charAt(0).toUpperCase() + prefix.substring(1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Return the text prefixed with "a" or "an"
|
|
26
|
-
return `${prefix} ${text}`;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default prefixWithAOrAn;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Round a number 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 roundToNumDecimals = (num: number, numDecimals: number): number => {
|
|
9
|
-
const rounder = 10 ** numDecimals;
|
|
10
|
-
return (Math.round(num * rounder) / rounder);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default roundToNumDecimals;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shuffle a given array
|
|
3
|
-
* @author Austen Money
|
|
4
|
-
* @param arr the array to shuffle
|
|
5
|
-
* @returns the shuffled array
|
|
6
|
-
*/
|
|
7
|
-
const shuffleArray = <T>(arr: T[]): T[] => {
|
|
8
|
-
const newArr = [...arr];
|
|
9
|
-
|
|
10
|
-
// Shuffle using Durstenfeld algorithm
|
|
11
|
-
for (let i = arr.length - 1; i > 0; i--) {
|
|
12
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
13
|
-
[newArr[i], newArr[j]] = [newArr[j], newArr[i]];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return newArr;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default shuffleArray;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Import other helpers
|
|
2
|
-
import waitMs from './waitMs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Start a dynamic wait, call the function once the operation has completed and
|
|
6
|
-
* the dynamic wait will continue waiting for the rest of the minimum time
|
|
7
|
-
* @author Gabe Abrams
|
|
8
|
-
* @param minWaitMs the minimum number of ms to wait
|
|
9
|
-
* @returns async function to call to finish the wait
|
|
10
|
-
*/
|
|
11
|
-
const startMinWait = (minWaitMs: number): () => Promise<void> => {
|
|
12
|
-
const startTimestamp = Date.now();
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Finish the remaining time to wait
|
|
16
|
-
* @author Gabe Abrams
|
|
17
|
-
*/
|
|
18
|
-
return async () => {
|
|
19
|
-
const endTimestamp = Date.now();
|
|
20
|
-
|
|
21
|
-
// Calculate remaining time to wait
|
|
22
|
-
const elapsedTimeMs = (endTimestamp - startTimestamp);
|
|
23
|
-
const remainingTimeToWaitMs = minWaitMs - elapsedTimeMs;
|
|
24
|
-
if (remainingTimeToWaitMs <= 0) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Perform wait
|
|
29
|
-
await waitMs(remainingTimeToWaitMs);
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default startMinWait;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a human readable list from an array of strings.
|
|
3
|
-
* For example, ['apple', 'orange'] becomes "apple and orange"
|
|
4
|
-
* and ['apple', 'orange', 'mango'] becomes "apple, orange, and mango"
|
|
5
|
-
* @author Gabe Abrams
|
|
6
|
-
* @param items list of items in the list
|
|
7
|
-
* @returns human-readable list
|
|
8
|
-
*/
|
|
9
|
-
const stringsToHumanReadableList = (items: string[]): string => {
|
|
10
|
-
// Handle 0-item case
|
|
11
|
-
if (items.length === 0) {
|
|
12
|
-
return '';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Handle 1-item case
|
|
16
|
-
if (items.length === 1) {
|
|
17
|
-
return items[0];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Handle 2-item case
|
|
21
|
-
if (items.length === 2) {
|
|
22
|
-
return `${items[0]} and ${items[1]}`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Handle 3+ item case
|
|
26
|
-
let list = '';
|
|
27
|
-
items.forEach((item, i) => {
|
|
28
|
-
if (i === items.length - 1) {
|
|
29
|
-
// Last item
|
|
30
|
-
list += `, and ${item}`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Previous items
|
|
34
|
-
list += `, ${item}`;
|
|
35
|
-
});
|
|
36
|
-
return list;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export default stringsToHumanReadableList;
|
package/src/helpers/sum.tsx
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sum the numbers in an array
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
* @param nums the numbers to sum
|
|
5
|
-
* @returns the sum of the numbers
|
|
6
|
-
*/
|
|
7
|
-
const sum = (nums: number[]): number => {
|
|
8
|
-
return nums.reduce(
|
|
9
|
-
(a: number, b: number) => {
|
|
10
|
-
return (a + b);
|
|
11
|
-
},
|
|
12
|
-
0,
|
|
13
|
-
);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default sum;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// Importing the testing function
|
|
2
|
-
// import chicagoTitleCase from './chicagoTitleCase';
|
|
3
|
-
|
|
4
|
-
// // Import constants
|
|
5
|
-
// import { INVALID_STRING_ERRORS, INVALID_REGEX_ERROR } from './shared/constants/ERROR_MESSAGES';
|
|
6
|
-
|
|
7
|
-
// /*------------------------------------------------------------------------*/
|
|
8
|
-
// /* ---------------------------- Valid Tests --------------------------- */
|
|
9
|
-
// /*------------------------------------------------------------------------*/
|
|
10
|
-
|
|
11
|
-
// const validTests: { input: string, expected: string }[] = [
|
|
12
|
-
// {
|
|
13
|
-
// input: 'this is the american language',
|
|
14
|
-
// expected: 'This the American language',
|
|
15
|
-
// },
|
|
16
|
-
// {
|
|
17
|
-
// input: 'to kill a mockingbird',
|
|
18
|
-
// expected: 'To Kill a Mockingbird',
|
|
19
|
-
// },
|
|
20
|
-
// {
|
|
21
|
-
// input: 'the lord of the rings',
|
|
22
|
-
// expected: 'The Lord of the Rings',
|
|
23
|
-
// },
|
|
24
|
-
// {
|
|
25
|
-
// input: 'pride and prejudice',
|
|
26
|
-
// expected: 'Pride and Prejudice',
|
|
27
|
-
// },
|
|
28
|
-
// {
|
|
29
|
-
// input: 'the road not taken',
|
|
30
|
-
// expected: 'The Road Not Taken',
|
|
31
|
-
// },
|
|
32
|
-
// ];
|
|
33
|
-
|
|
34
|
-
// test(
|
|
35
|
-
// 'Converts strings to Chicago title case correctly.',
|
|
36
|
-
// async () => {
|
|
37
|
-
// validTests.forEach(({ input, expected }) => {
|
|
38
|
-
// expect(chicagoTitleCase(input)).toBe(expected);
|
|
39
|
-
// });
|
|
40
|
-
// },
|
|
41
|
-
// );
|
|
42
|
-
|
|
43
|
-
// /*------------------------------------------------------------------------*/
|
|
44
|
-
// /* ---------------------------- Edge Cases ---------------------------- */
|
|
45
|
-
// /*------------------------------------------------------------------------*/
|
|
46
|
-
|
|
47
|
-
// const edgeCases: { input: string, expected: string }[] = [
|
|
48
|
-
// {
|
|
49
|
-
// input: 'x',
|
|
50
|
-
// expected: 'X',
|
|
51
|
-
// },
|
|
52
|
-
// {
|
|
53
|
-
// input: ' ',
|
|
54
|
-
// expected: ' ',
|
|
55
|
-
// },
|
|
56
|
-
// {
|
|
57
|
-
// input: '',
|
|
58
|
-
// expected: '',
|
|
59
|
-
// },
|
|
60
|
-
// {
|
|
61
|
-
// input: 'the',
|
|
62
|
-
// expected: 'The',
|
|
63
|
-
// },
|
|
64
|
-
// {
|
|
65
|
-
// input: 'THE ROAD NOT TAKEN',
|
|
66
|
-
// expected: 'The Road Not Taken',
|
|
67
|
-
// },
|
|
68
|
-
// {
|
|
69
|
-
// input: 'tO kiLL A mOckingBirD',
|
|
70
|
-
// expected: 'To Kill a Mockingbird',
|
|
71
|
-
// },
|
|
72
|
-
// {
|
|
73
|
-
// input: 'pRiDe And pReduJiCe',
|
|
74
|
-
// expected: 'Pride and Prejudice',
|
|
75
|
-
// },
|
|
76
|
-
// ];
|
|
77
|
-
|
|
78
|
-
// test(
|
|
79
|
-
// 'Handles the edge cases for the function that converts a string to Chicago Title Case.',
|
|
80
|
-
// async () => {
|
|
81
|
-
// edgeCases.forEach(({ input, expected }) => {
|
|
82
|
-
// expect(chicagoTitleCase(input)).toBe(expected);
|
|
83
|
-
// });
|
|
84
|
-
// },
|
|
85
|
-
// );
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This function converts a string to title case based on Chicago Title Case
|
|
3
|
-
* Style rules.
|
|
4
|
-
* @author Leisha Bhandari
|
|
5
|
-
* @param input: The input string that needs to be converted to Chicago title
|
|
6
|
-
* case.
|
|
7
|
-
* @returns Input string converted to title case
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const chicagoTitleCase = (input: string): string => {
|
|
12
|
-
// List of lowercase words according to Chicago Manual of Style
|
|
13
|
-
const lowerCaseWords: string[] = [
|
|
14
|
-
'in', 'nor', 'of', 'on', 'or', 'as', 'at', 'but', 'by',
|
|
15
|
-
'for', 'if', 'so', 'the', 'a', 'an', 'and', 'to', 'up',
|
|
16
|
-
'yet'
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
return input
|
|
20
|
-
// Converts given input string to lowercase
|
|
21
|
-
.toLowerCase()
|
|
22
|
-
// Splits the given string into separate words
|
|
23
|
-
.split(' ')
|
|
24
|
-
.map((word, index, words) =>
|
|
25
|
-
// Capitalize the first word, last word, and the words that aren't
|
|
26
|
-
// in lowerCaseWords
|
|
27
|
-
index === 0 || !lowerCaseWords.includes(word) || index === words.length - 1
|
|
28
|
-
? `${word.charAt(0).toUpperCase()}${word.slice(1)}` // Capitalize the first letter
|
|
29
|
-
: word // Nothing happens to the word
|
|
30
|
-
)
|
|
31
|
-
.join(' '); // Joins the words back
|
|
32
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// Import the function to be tested
|
|
2
|
-
// import findURLs from './findURL';
|
|
3
|
-
|
|
4
|
-
// // Import constants
|
|
5
|
-
// import { INVALID_STRING_ERRORS, INVALID_REGEX_ERROR } from './shared/constants/ERROR_MESSAGES';
|
|
6
|
-
|
|
7
|
-
// /*------------------------------------------------------------------------*/
|
|
8
|
-
// /* ---------------------------- Valid Tests --------------------------- */
|
|
9
|
-
// /*------------------------------------------------------------------------*/
|
|
10
|
-
|
|
11
|
-
// const validTests: { block: string, expected: { start: number, end: number }[] }[] = [
|
|
12
|
-
// {
|
|
13
|
-
// block: 'Visit http://example.com for more information.',
|
|
14
|
-
// expected: [{ start: 6, end: 23 }],
|
|
15
|
-
// },
|
|
16
|
-
// {
|
|
17
|
-
// block: 'Multiple URLs: http://one.com and http://two.com.',
|
|
18
|
-
// expected: [
|
|
19
|
-
// { start: 15, end: 29 },
|
|
20
|
-
// { start: 34, end: 48 },
|
|
21
|
-
// ],
|
|
22
|
-
// },
|
|
23
|
-
// {
|
|
24
|
-
// block: 'Localhost URLs: http://localhost and http://127.0.0.1.',
|
|
25
|
-
// expected: [
|
|
26
|
-
// { start: 16, end: 31 },
|
|
27
|
-
// { start: 36, end: 52 },
|
|
28
|
-
// ],
|
|
29
|
-
// },
|
|
30
|
-
// {
|
|
31
|
-
// block: 'Embedded URL: text https://embedded-url.com?query=1&value=2.',
|
|
32
|
-
// expected: [{ start: 13, end: 51 }],
|
|
33
|
-
// },
|
|
34
|
-
// {
|
|
35
|
-
// block: 'Secure site: https://secure-site.com/path?query=string#fragment',
|
|
36
|
-
// expected: [{ start: 13, end: 58 }],
|
|
37
|
-
// },
|
|
38
|
-
// ];
|
|
39
|
-
|
|
40
|
-
// test(
|
|
41
|
-
// 'Returns correct start and end indices for valid URLs within a string.',
|
|
42
|
-
// async () => {
|
|
43
|
-
// validTests.forEach(({ block, expected }) => {
|
|
44
|
-
// expect(findURLs(block)).toStrictEqual(expected);
|
|
45
|
-
// });
|
|
46
|
-
// },
|
|
47
|
-
// );
|
|
48
|
-
|
|
49
|
-
// /*------------------------------------------------------------------------*/
|
|
50
|
-
// /* ---------------------------- Invalid Tests --------------------------- */
|
|
51
|
-
// /*------------------------------------------------------------------------*/
|
|
52
|
-
|
|
53
|
-
// const invalidTests: { block: string, expected: { start: number, end: number }[] }[] = [
|
|
54
|
-
// {
|
|
55
|
-
// block: 'No URL.',
|
|
56
|
-
// expected: [],
|
|
57
|
-
// },
|
|
58
|
-
// {
|
|
59
|
-
// block: 'URL format is wrong: http:/example.com and htt://example.com.',
|
|
60
|
-
// expected: [],
|
|
61
|
-
// },
|
|
62
|
-
// {
|
|
63
|
-
// block: 'Any punctuation after the URL http://example.com, should not count.',
|
|
64
|
-
// expected: [{ start: 20, end: 37 }],
|
|
65
|
-
// },
|
|
66
|
-
// {
|
|
67
|
-
// block: 'Starting punctuation ,http://example.com should not count.',
|
|
68
|
-
// expected: [{ start: 22, end: 39 }],
|
|
69
|
-
// },
|
|
70
|
-
// {
|
|
71
|
-
// block: 'Spaces in the middle http://exa mple.com is invalid.',
|
|
72
|
-
// expected: [],
|
|
73
|
-
// },
|
|
74
|
-
// ];
|
|
75
|
-
|
|
76
|
-
// test(
|
|
77
|
-
// 'Returns empty array for strings without valid URLs.',
|
|
78
|
-
// async () => {
|
|
79
|
-
// invalidTests.forEach(({ block, expected }) => {
|
|
80
|
-
// expect(findURLs(block)).toStrictEqual(expected);
|
|
81
|
-
// });
|
|
82
|
-
// },
|
|
83
|
-
// );
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// /**
|
|
2
|
-
// * This function finds URLs within a given string and returns an array of
|
|
3
|
-
// * their locations.
|
|
4
|
-
// * @author Leisha Bhandari
|
|
5
|
-
// * @param block: The block of text to search for URLs
|
|
6
|
-
// * @returns Arrays where each of them contain the start and end index of the URL
|
|
7
|
-
// */
|
|
8
|
-
// function findURLs(block: string): { start: number, end: number }[] {
|
|
9
|
-
// // Expression representing the skeleton of a URL to help match and find the
|
|
10
|
-
// // URLs within the block of text (Also takes care of Unicode characters)
|
|
11
|
-
// const urlSkeleton = /(https?:\/\/[^\s\u0000-\u001F.,]+[^\s\u0000-\u001F.,]?(?:\?[^\s\u0000-\u001F]+)?(?:#[^\s\u0000-\u001F]+)?)/g;
|
|
12
|
-
// const found: { start: number, end: number }[] = [];
|
|
13
|
-
// let match: RegExpExecArray | null;
|
|
14
|
-
|
|
15
|
-
// // While loop to find the URLs in the given block of texts using the URL
|
|
16
|
-
// // skeleton
|
|
17
|
-
// while ((match === urlSkeleton.exec(block))
|
|
18
|
-
// && match !== null) {
|
|
19
|
-
// // To find the beginning index of the URL
|
|
20
|
-
// let start = match.index;
|
|
21
|
-
// // To find the last index of the URL
|
|
22
|
-
// let end = match.index + match[0].length;
|
|
23
|
-
|
|
24
|
-
// // If statements to check whether the URL is followed by some kind of
|
|
25
|
-
// // punctuation mark
|
|
26
|
-
// if (block.charAt(end) === '.' || /[,;:!?"]/.test(block.charAt(end))) {
|
|
27
|
-
// end--;
|
|
28
|
-
// }
|
|
29
|
-
|
|
30
|
-
// // While statement to make sure that the URL does not start with a
|
|
31
|
-
// // punctuation mark
|
|
32
|
-
// while (start > 0 && /[.,:;!?]/.test(block.charAt(start - 1))) {
|
|
33
|
-
// start--;
|
|
34
|
-
// }
|
|
35
|
-
|
|
36
|
-
// // The object with start and end index of the URL is found and pushed to
|
|
37
|
-
// // the found array
|
|
38
|
-
// found.push({ start, end });
|
|
39
|
-
// }
|
|
40
|
-
|
|
41
|
-
// // Returns the array of the found URLs location
|
|
42
|
-
// return found;
|
|
43
|
-
// }
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/*------------------------------------------------------------------------*/
|
|
2
|
-
/* ------------------------------ Constants ----------------------------- */
|
|
3
|
-
/*------------------------------------------------------------------------*/
|
|
4
|
-
|
|
5
|
-
export const INVALID_REGEX_ERROR = 'input does not follow the requested format';
|
|
6
|
-
export const INVALID_EMAIL_ERROR = 'Please provide a valid email address.';
|
|
7
|
-
export const INVALID_PHONE_ERROR = 'Please provide a valid phone number.';
|
|
8
|
-
export const INVALID_STRING_ERRORS = {
|
|
9
|
-
MIN_LEN: (minLen: number) => {
|
|
10
|
-
return `input must not be under ${minLen} character(s)`;
|
|
11
|
-
},
|
|
12
|
-
MAX_LEN: (maxLen: number) => {
|
|
13
|
-
return `input must not be over ${maxLen} character(s)`;
|
|
14
|
-
},
|
|
15
|
-
LETTERS_ONLY: 'input must only contain letters',
|
|
16
|
-
NUMBERS_ONLY: 'input must only contain numbers',
|
|
17
|
-
MESSAGE_INTRO: 'The following error(s) occurred: ',
|
|
18
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// Import types
|
|
2
|
-
import ValidationResult from '../types/ValidationResult';
|
|
3
|
-
|
|
4
|
-
// Import constants
|
|
5
|
-
import { INVALID_REGEX_ERROR } from '../constants/ERROR_MESSAGES';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Determines whether a given input string is considered valid based on
|
|
9
|
-
* the provided regex.
|
|
10
|
-
* @author Austen Money
|
|
11
|
-
* @param opts object containing all args
|
|
12
|
-
* @param opts.input user-provided input to validate
|
|
13
|
-
* @param opts.regex regular expression to check against input
|
|
14
|
-
* @param [opts.regexDescription] description of what regexString is checking
|
|
15
|
-
* for, used to customize error message
|
|
16
|
-
* @returns the unchanged input if valid, or a customized error message if
|
|
17
|
-
* invalid
|
|
18
|
-
*/
|
|
19
|
-
const validateRegex = (
|
|
20
|
-
opts: {
|
|
21
|
-
input: string,
|
|
22
|
-
regex: RegExp,
|
|
23
|
-
regexDescription?: string,
|
|
24
|
-
},
|
|
25
|
-
): ValidationResult<string> => {
|
|
26
|
-
// customize error message in case of invalid input
|
|
27
|
-
const errorMessage = `${INVALID_REGEX_ERROR}${
|
|
28
|
-
opts.regexDescription
|
|
29
|
-
? ': '
|
|
30
|
-
: ''
|
|
31
|
-
}${opts.regexDescription}`;
|
|
32
|
-
|
|
33
|
-
// return error message if test is invalid, or input string if valid
|
|
34
|
-
return (
|
|
35
|
-
opts.regex.test(opts.input)
|
|
36
|
-
? {
|
|
37
|
-
isValid: true,
|
|
38
|
-
cleanedValue: opts.input,
|
|
39
|
-
}
|
|
40
|
-
: {
|
|
41
|
-
isValid: false,
|
|
42
|
-
errorMessage,
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default validateRegex;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Result of a validation function.
|
|
3
|
-
* @author Austen Money
|
|
4
|
-
*/
|
|
5
|
-
type ValidationResult<CleanedValueType> = (
|
|
6
|
-
| {
|
|
7
|
-
// if true, the validation was successful
|
|
8
|
-
isValid: true,
|
|
9
|
-
// the cleaned version of the value
|
|
10
|
-
cleanedValue: CleanedValueType,
|
|
11
|
-
}
|
|
12
|
-
| {
|
|
13
|
-
// if false, the validation was not successful
|
|
14
|
-
isValid: false,
|
|
15
|
-
// describes why the validation failed
|
|
16
|
-
errorMessage: string,
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
export default ValidationResult;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// Import the function to be tested
|
|
3
|
-
// import isValid from './validURL';
|
|
4
|
-
|
|
5
|
-
// // Import constants
|
|
6
|
-
// import { INVALID_STRING_ERRORS, INVALID_REGEX_ERROR } from './shared/constants/ERROR_MESSAGES';
|
|
7
|
-
|
|
8
|
-
// /*------------------------------------------------------------------------*/
|
|
9
|
-
// /* ---------------------------- Valid Tests --------------------------- */
|
|
10
|
-
// /*------------------------------------------------------------------------*/
|
|
11
|
-
|
|
12
|
-
// const validUrls: string[] = [
|
|
13
|
-
// 'http://example.com',
|
|
14
|
-
// 'https://example.com',
|
|
15
|
-
// 'http://www.example.com',
|
|
16
|
-
// 'https://www.example.com',
|
|
17
|
-
// 'https://example.com/path',
|
|
18
|
-
// 'http://example.com/path',
|
|
19
|
-
// 'https://example.com?query=string',
|
|
20
|
-
// 'http://example.com?query=string',
|
|
21
|
-
// 'https://example.com#fragment',
|
|
22
|
-
// 'http://example.com#fragment',
|
|
23
|
-
// 'http://localhost',
|
|
24
|
-
// 'https://localhost:3000',
|
|
25
|
-
// 'http://localhost:3000',
|
|
26
|
-
// 'http://127.0.0.1',
|
|
27
|
-
// 'http://127.0.0.1:3000',
|
|
28
|
-
// 'ftp://example.com/path',
|
|
29
|
-
// 'ftp://example.com',
|
|
30
|
-
// 'https://127.0.0.1:3000',
|
|
31
|
-
// 'file:///C:/path/to/file'
|
|
32
|
-
// ];
|
|
33
|
-
|
|
34
|
-
// test(
|
|
35
|
-
// 'Returns true for a given valid URL.',
|
|
36
|
-
// async () => {
|
|
37
|
-
// validUrls.forEach((url) => {
|
|
38
|
-
// expect(isValid(url)).toBe(true);
|
|
39
|
-
// });
|
|
40
|
-
// },
|
|
41
|
-
// );
|
|
42
|
-
|
|
43
|
-
// /*------------------------------------------------------------------------*/
|
|
44
|
-
// /* ---------------------------- Invalid Tests --------------------------- */
|
|
45
|
-
// /*------------------------------------------------------------------------*/
|
|
46
|
-
|
|
47
|
-
// const invalidUrls: string[] = [
|
|
48
|
-
// '',
|
|
49
|
-
// ' ',
|
|
50
|
-
// 'example',
|
|
51
|
-
// 'http://',
|
|
52
|
-
// 'http://.',
|
|
53
|
-
// 'http://..',
|
|
54
|
-
// 'http://##/',
|
|
55
|
-
// 'http://../',
|
|
56
|
-
// 'http://??/',
|
|
57
|
-
// 'http://#',
|
|
58
|
-
// 'http://##',
|
|
59
|
-
// '//',
|
|
60
|
-
// '//a',
|
|
61
|
-
// '///a',
|
|
62
|
-
// '///',
|
|
63
|
-
// 'http:///a',
|
|
64
|
-
// 'http://www.foo.bar./',
|
|
65
|
-
// 'http://foo.bar/foo(bar)baz quux',
|
|
66
|
-
// 'http://3628126748',
|
|
67
|
-
// 'http://.www.foo.bar/',
|
|
68
|
-
// 'http://.www.foo.bar./',
|
|
69
|
-
// 'http://123.123.123',
|
|
70
|
-
// 'http://1.1.1.1.1',
|
|
71
|
-
// 'http://example.com:99999',
|
|
72
|
-
// 'http://example.com:80:80',
|
|
73
|
-
// 'http://example.com::80',
|
|
74
|
-
// 'http://example.com:-80',
|
|
75
|
-
// 'http://-example.com',
|
|
76
|
-
// 'http://example.com-',
|
|
77
|
-
// 'http://example.com_',
|
|
78
|
-
// 'http://example..com',
|
|
79
|
-
// 'http://example.com.',
|
|
80
|
-
// 'http://.example.com'
|
|
81
|
-
// ];
|
|
82
|
-
|
|
83
|
-
// test(
|
|
84
|
-
// 'Returns false for a given invalid URL.',
|
|
85
|
-
// async () => {
|
|
86
|
-
// invalidUrls.forEach((url) => {
|
|
87
|
-
// expect(isValid(url)).toBe(false);
|
|
88
|
-
// });
|
|
89
|
-
// },
|
|
90
|
-
// );
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This function checks if a given input string is a valid URL.
|
|
3
|
-
* @author Leisha Bhandari
|
|
4
|
-
* @param URL: The input string that needs checked as a URL or not.
|
|
5
|
-
* @returns A true boolean value if the input string is a valid URL, and a false
|
|
6
|
-
* boolean value if the input string is a invalid URL
|
|
7
|
-
*/
|
|
8
|
-
function isValid(url: string): boolean {
|
|
9
|
-
// Uses the input URL to create a URL object
|
|
10
|
-
try {
|
|
11
|
-
new URL(url);
|
|
12
|
-
// URL constructor does not throw an error, so input URL is valid
|
|
13
|
-
return true;
|
|
14
|
-
} catch (err) {
|
|
15
|
-
// URL constructor throws an error, so input URL is invalid
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|