dce-commonkit 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +93 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/lib/constants/DAY_IN_MS.d.ts +6 -0
- package/lib/constants/DAY_IN_MS.js +9 -0
- package/lib/constants/DAY_IN_MS.js.map +1 -0
- package/lib/constants/HOUR_IN_MS.d.ts +6 -0
- package/lib/constants/HOUR_IN_MS.js +9 -0
- package/lib/constants/HOUR_IN_MS.js.map +1 -0
- package/lib/constants/LOG_REVIEW_GET_LOGS_ROUTE.d.ts +6 -0
- package/lib/constants/LOG_REVIEW_GET_LOGS_ROUTE.js +13 -0
- package/lib/constants/LOG_REVIEW_GET_LOGS_ROUTE.js.map +1 -0
- package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.d.ts +6 -0
- package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.js +13 -0
- package/lib/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.js.map +1 -0
- package/lib/constants/LOG_REVIEW_STATUS_ROUTE.d.ts +7 -0
- package/lib/constants/LOG_REVIEW_STATUS_ROUTE.js +14 -0
- package/lib/constants/LOG_REVIEW_STATUS_ROUTE.js.map +1 -0
- package/lib/constants/LOG_ROUTE_PATH.d.ts +6 -0
- package/lib/constants/LOG_ROUTE_PATH.js +13 -0
- package/lib/constants/LOG_ROUTE_PATH.js.map +1 -0
- package/lib/constants/MINUTE_IN_MS.d.ts +6 -0
- package/lib/constants/MINUTE_IN_MS.js +9 -0
- package/lib/constants/MINUTE_IN_MS.js.map +1 -0
- package/lib/constants/ROUTE_PATH_PREFIX.d.ts +6 -0
- package/lib/constants/ROUTE_PATH_PREFIX.js +9 -0
- package/lib/constants/ROUTE_PATH_PREFIX.js.map +1 -0
- package/lib/constants/SELECT_ADMIN_CHECK_ROUTE.d.ts +6 -0
- package/lib/constants/SELECT_ADMIN_CHECK_ROUTE.js +9 -0
- package/lib/constants/SELECT_ADMIN_CHECK_ROUTE.js.map +1 -0
- package/lib/errors/ErrorWithCode.d.ts +9 -0
- package/lib/errors/ErrorWithCode.js +33 -0
- package/lib/errors/ErrorWithCode.js.map +1 -0
- package/lib/helpers/abbreviate.d.ts +10 -0
- package/lib/helpers/abbreviate.js +24 -0
- package/lib/helpers/abbreviate.js.map +1 -0
- package/lib/helpers/abbreviate.test.d.ts +5 -0
- package/lib/helpers/abbreviate.test.js +28 -0
- package/lib/helpers/abbreviate.test.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/everyAsync.d.ts +13 -0
- package/lib/helpers/asyncArrayFunctions/everyAsync.js +81 -0
- package/lib/helpers/asyncArrayFunctions/everyAsync.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/everyAsync.test.d.ts +1 -0
- package/lib/helpers/asyncArrayFunctions/everyAsync.test.js +219 -0
- package/lib/helpers/asyncArrayFunctions/everyAsync.test.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/filterAsync.d.ts +13 -0
- package/lib/helpers/asyncArrayFunctions/filterAsync.js +81 -0
- package/lib/helpers/asyncArrayFunctions/filterAsync.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/filterAsync.test.d.ts +1 -0
- package/lib/helpers/asyncArrayFunctions/filterAsync.test.js +244 -0
- package/lib/helpers/asyncArrayFunctions/filterAsync.test.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/forEachAsync.d.ts +10 -0
- package/lib/helpers/asyncArrayFunctions/forEachAsync.js +72 -0
- package/lib/helpers/asyncArrayFunctions/forEachAsync.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/forEachAsync.test.d.ts +1 -0
- package/lib/helpers/asyncArrayFunctions/forEachAsync.test.js +223 -0
- package/lib/helpers/asyncArrayFunctions/forEachAsync.test.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/mapAsync.d.ts +11 -0
- package/lib/helpers/asyncArrayFunctions/mapAsync.js +77 -0
- package/lib/helpers/asyncArrayFunctions/mapAsync.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/mapAsync.test.d.ts +1 -0
- package/lib/helpers/asyncArrayFunctions/mapAsync.test.js +219 -0
- package/lib/helpers/asyncArrayFunctions/mapAsync.test.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/someAsync.d.ts +13 -0
- package/lib/helpers/asyncArrayFunctions/someAsync.js +80 -0
- package/lib/helpers/asyncArrayFunctions/someAsync.js.map +1 -0
- package/lib/helpers/asyncArrayFunctions/someAsync.test.d.ts +1 -0
- package/lib/helpers/asyncArrayFunctions/someAsync.test.js +227 -0
- package/lib/helpers/asyncArrayFunctions/someAsync.test.js.map +1 -0
- package/lib/helpers/avg.d.ts +8 -0
- package/lib/helpers/avg.js +24 -0
- package/lib/helpers/avg.js.map +1 -0
- package/lib/helpers/avg.test.d.ts +5 -0
- package/lib/helpers/avg.test.js +25 -0
- package/lib/helpers/avg.test.js.map +1 -0
- package/lib/helpers/capitalize.d.ts +7 -0
- package/lib/helpers/capitalize.js +20 -0
- package/lib/helpers/capitalize.js.map +1 -0
- package/lib/helpers/ceilToNumDecimals.d.ts +9 -0
- package/lib/helpers/ceilToNumDecimals.js +15 -0
- package/lib/helpers/ceilToNumDecimals.js.map +1 -0
- package/lib/helpers/ceilToNumDecimals.test.d.ts +5 -0
- package/lib/helpers/ceilToNumDecimals.test.js +38 -0
- package/lib/helpers/ceilToNumDecimals.test.js.map +1 -0
- package/lib/helpers/cloneDeep.d.ts +8 -0
- package/lib/helpers/cloneDeep.js +15 -0
- package/lib/helpers/cloneDeep.js.map +1 -0
- package/lib/helpers/compareArraysByProp.d.ts +13 -0
- package/lib/helpers/compareArraysByProp.js +62 -0
- package/lib/helpers/compareArraysByProp.js.map +1 -0
- package/lib/helpers/compareArraysByProp.test.d.ts +5 -0
- package/lib/helpers/compareArraysByProp.test.js +140 -0
- package/lib/helpers/compareArraysByProp.test.js.map +1 -0
- package/lib/helpers/extractProp.d.ts +12 -0
- package/lib/helpers/extractProp.js +19 -0
- package/lib/helpers/extractProp.js.map +1 -0
- package/lib/helpers/extractProp.test.d.ts +5 -0
- package/lib/helpers/extractProp.test.js +36 -0
- package/lib/helpers/extractProp.test.js.map +1 -0
- package/lib/helpers/floorToNumDecimals.d.ts +9 -0
- package/lib/helpers/floorToNumDecimals.js +15 -0
- package/lib/helpers/floorToNumDecimals.js.map +1 -0
- package/lib/helpers/floorToNumDecimals.test.d.ts +5 -0
- package/lib/helpers/floorToNumDecimals.test.js +38 -0
- package/lib/helpers/floorToNumDecimals.test.js.map +1 -0
- package/lib/helpers/forceNumIntoBounds.d.ts +10 -0
- package/lib/helpers/forceNumIntoBounds.js +15 -0
- package/lib/helpers/forceNumIntoBounds.js.map +1 -0
- package/lib/helpers/forceNumIntoBounds.test.d.ts +5 -0
- package/lib/helpers/forceNumIntoBounds.test.js +34 -0
- package/lib/helpers/forceNumIntoBounds.test.js.map +1 -0
- package/lib/helpers/genCSV.d.ts +18 -0
- package/lib/helpers/genCSV.js +69 -0
- package/lib/helpers/genCSV.js.map +1 -0
- package/lib/helpers/genCSV.test.d.ts +5 -0
- package/lib/helpers/genCSV.test.js +75 -0
- package/lib/helpers/genCSV.test.js.map +1 -0
- package/lib/helpers/genCommaList.d.ts +12 -0
- package/lib/helpers/genCommaList.js +20 -0
- package/lib/helpers/genCommaList.js.map +1 -0
- package/lib/helpers/genCommaList.test.d.ts +1 -0
- package/lib/helpers/genCommaList.test.js +94 -0
- package/lib/helpers/genCommaList.test.js.map +1 -0
- package/lib/helpers/getHumanReadableDate.d.ts +8 -0
- package/lib/helpers/getHumanReadableDate.js +32 -0
- package/lib/helpers/getHumanReadableDate.js.map +1 -0
- package/lib/helpers/getHumanReadableDate.test.d.ts +5 -0
- package/lib/helpers/getHumanReadableDate.test.js +31 -0
- package/lib/helpers/getHumanReadableDate.test.js.map +1 -0
- package/lib/helpers/getLocalTimeInfo.d.ts +19 -0
- package/lib/helpers/getLocalTimeInfo.js +51 -0
- package/lib/helpers/getLocalTimeInfo.js.map +1 -0
- package/lib/helpers/getLocalTimeInfo.test.d.ts +6 -0
- package/lib/helpers/getLocalTimeInfo.test.js +50 -0
- package/lib/helpers/getLocalTimeInfo.test.js.map +1 -0
- package/lib/helpers/getMonthName.d.ts +14 -0
- package/lib/helpers/getMonthName.js +31 -0
- package/lib/helpers/getMonthName.js.map +1 -0
- package/lib/helpers/getMonthName.test.d.ts +5 -0
- package/lib/helpers/getMonthName.test.js +70 -0
- package/lib/helpers/getMonthName.test.js.map +1 -0
- package/lib/helpers/getOrdinal.d.ts +8 -0
- package/lib/helpers/getOrdinal.js +16 -0
- package/lib/helpers/getOrdinal.js.map +1 -0
- package/lib/helpers/getOrdinal.test.d.ts +5 -0
- package/lib/helpers/getOrdinal.test.js +74 -0
- package/lib/helpers/getOrdinal.test.js.map +1 -0
- package/lib/helpers/getPartOfDay.d.ts +7 -0
- package/lib/helpers/getPartOfDay.js +24 -0
- package/lib/helpers/getPartOfDay.js.map +1 -0
- package/lib/helpers/getPartOfDay.test.d.ts +5 -0
- package/lib/helpers/getPartOfDay.test.js +49 -0
- package/lib/helpers/getPartOfDay.test.js.map +1 -0
- package/lib/helpers/getTimeInfoInET.d.ts +21 -0
- package/lib/helpers/getTimeInfoInET.js +67 -0
- package/lib/helpers/getTimeInfoInET.js.map +1 -0
- package/lib/helpers/getTimeInfoInET.test.d.ts +5 -0
- package/lib/helpers/getTimeInfoInET.test.js +74 -0
- package/lib/helpers/getTimeInfoInET.test.js.map +1 -0
- package/lib/helpers/getTimestampFromTimeInfoInET.d.ts +20 -0
- package/lib/helpers/getTimestampFromTimeInfoInET.js +136 -0
- package/lib/helpers/getTimestampFromTimeInfoInET.js.map +1 -0
- package/lib/helpers/getWordCount.d.ts +10 -0
- package/lib/helpers/getWordCount.js +24 -0
- package/lib/helpers/getWordCount.js.map +1 -0
- package/lib/helpers/idify.d.ts +9 -0
- package/lib/helpers/idify.js +24 -0
- package/lib/helpers/idify.js.map +1 -0
- package/lib/helpers/onlyKeepLetters.d.ts +8 -0
- package/lib/helpers/onlyKeepLetters.js +13 -0
- package/lib/helpers/onlyKeepLetters.js.map +1 -0
- package/lib/helpers/padDecimalZeros.d.ts +10 -0
- package/lib/helpers/padDecimalZeros.js +30 -0
- package/lib/helpers/padDecimalZeros.js.map +1 -0
- package/lib/helpers/padZerosLeft.d.ts +9 -0
- package/lib/helpers/padZerosLeft.js +21 -0
- package/lib/helpers/padZerosLeft.js.map +1 -0
- package/lib/helpers/parallelLimit.d.ts +12 -0
- package/lib/helpers/parallelLimit.js +104 -0
- package/lib/helpers/parallelLimit.js.map +1 -0
- package/lib/helpers/prefixWithAOrAn.d.ts +10 -0
- package/lib/helpers/prefixWithAOrAn.js +28 -0
- package/lib/helpers/prefixWithAOrAn.js.map +1 -0
- package/lib/helpers/roundToNumDecimals.d.ts +9 -0
- package/lib/helpers/roundToNumDecimals.js +15 -0
- package/lib/helpers/roundToNumDecimals.js.map +1 -0
- package/lib/helpers/shuffleArray.d.ts +8 -0
- package/lib/helpers/shuffleArray.js +29 -0
- package/lib/helpers/shuffleArray.js.map +1 -0
- package/lib/helpers/startMinWait.d.ts +9 -0
- package/lib/helpers/startMinWait.js +79 -0
- package/lib/helpers/startMinWait.js.map +1 -0
- package/lib/helpers/stringsToHumanReadableList.d.ts +10 -0
- package/lib/helpers/stringsToHumanReadableList.js +37 -0
- package/lib/helpers/stringsToHumanReadableList.js.map +1 -0
- package/lib/helpers/sum.d.ts +8 -0
- package/lib/helpers/sum.js +15 -0
- package/lib/helpers/sum.js.map +1 -0
- package/lib/helpers/validators/ChicagoTitleCase.d.ts +9 -0
- package/lib/helpers/validators/ChicagoTitleCase.js +31 -0
- package/lib/helpers/validators/ChicagoTitleCase.js.map +1 -0
- package/lib/helpers/validators/ChicagoTitleCase.test.d.ts +0 -0
- package/lib/helpers/validators/ChicagoTitleCase.test.js +79 -0
- package/lib/helpers/validators/ChicagoTitleCase.test.js.map +1 -0
- package/lib/helpers/validators/findURL.d.ts +0 -0
- package/lib/helpers/validators/findURL.js +39 -0
- package/lib/helpers/validators/findURL.js.map +1 -0
- package/lib/helpers/validators/findURL.test.d.ts +0 -0
- package/lib/helpers/validators/findURL.test.js +77 -0
- package/lib/helpers/validators/findURL.test.js.map +1 -0
- package/lib/helpers/validators/shared/constants/ERROR_MESSAGES.d.ts +10 -0
- package/lib/helpers/validators/shared/constants/ERROR_MESSAGES.js +21 -0
- package/lib/helpers/validators/shared/constants/ERROR_MESSAGES.js.map +1 -0
- package/lib/helpers/validators/shared/helpers/validateRegex.d.ts +19 -0
- package/lib/helpers/validators/shared/helpers/validateRegex.js +34 -0
- package/lib/helpers/validators/shared/helpers/validateRegex.js.map +1 -0
- package/lib/helpers/validators/shared/types/ValidationResult.d.ts +12 -0
- package/lib/helpers/validators/shared/types/ValidationResult.js +3 -0
- package/lib/helpers/validators/shared/types/ValidationResult.js.map +1 -0
- package/lib/helpers/validators/validURL.d.ts +8 -0
- package/lib/helpers/validators/validURL.js +20 -0
- package/lib/helpers/validators/validURL.js.map +1 -0
- package/lib/helpers/validators/validURL.test.d.ts +0 -0
- package/lib/helpers/validators/validURL.test.js +83 -0
- package/lib/helpers/validators/validURL.test.js.map +1 -0
- package/lib/helpers/validators/validateEmail.d.ts +11 -0
- package/lib/helpers/validators/validateEmail.js +39 -0
- package/lib/helpers/validators/validateEmail.js.map +1 -0
- package/lib/helpers/validators/validateEmail.test.d.ts +1 -0
- package/lib/helpers/validators/validateEmail.test.js +140 -0
- package/lib/helpers/validators/validateEmail.test.js.map +1 -0
- package/lib/helpers/validators/validatePhoneNumber.d.ts +11 -0
- package/lib/helpers/validators/validatePhoneNumber.js +40 -0
- package/lib/helpers/validators/validatePhoneNumber.js.map +1 -0
- package/lib/helpers/validators/validatePhoneNumber.test.d.ts +1 -0
- package/lib/helpers/validators/validatePhoneNumber.test.js +123 -0
- package/lib/helpers/validators/validatePhoneNumber.test.js.map +1 -0
- package/lib/helpers/validators/validateString.d.ts +22 -0
- package/lib/helpers/validators/validateString.js +124 -0
- package/lib/helpers/validators/validateString.js.map +1 -0
- package/lib/helpers/validators/validateString.test.d.ts +1 -0
- package/lib/helpers/validators/validateString.test.js +163 -0
- package/lib/helpers/validators/validateString.test.js.map +1 -0
- package/lib/helpers/waitMs.d.ts +7 -0
- package/lib/helpers/waitMs.js +68 -0
- package/lib/helpers/waitMs.js.map +1 -0
- package/lib/index.d.ts +63 -0
- package/lib/index.js +124 -0
- package/lib/index.js.map +1 -0
- package/lib/types/CommonKitErrorCode.d.ts +10 -0
- package/lib/types/CommonKitErrorCode.js +15 -0
- package/lib/types/CommonKitErrorCode.js.map +1 -0
- package/lib/types/DayOfWeek.d.ts +14 -0
- package/lib/types/DayOfWeek.js +18 -0
- package/lib/types/DayOfWeek.js.map +1 -0
- package/lib/types/Log/LogMainInfo.d.ts +39 -0
- package/lib/types/Log/LogMainInfo.js +3 -0
- package/lib/types/Log/LogMainInfo.js.map +1 -0
- package/lib/types/Log/LogSourceSpecificInfo.d.ts +13 -0
- package/lib/types/Log/LogSourceSpecificInfo.js +3 -0
- package/lib/types/Log/LogSourceSpecificInfo.js.map +1 -0
- package/lib/types/Log/LogTypeSpecificInfo.d.ts +17 -0
- package/lib/types/Log/LogTypeSpecificInfo.js +3 -0
- package/lib/types/Log/LogTypeSpecificInfo.js.map +1 -0
- package/lib/types/Log/index.d.ts +10 -0
- package/lib/types/Log/index.js +3 -0
- package/lib/types/Log/index.js.map +1 -0
- package/lib/types/LogAction.d.ts +29 -0
- package/lib/types/LogAction.js +55 -0
- package/lib/types/LogAction.js.map +1 -0
- package/lib/types/LogBuiltInMetadata.d.ts +16 -0
- package/lib/types/LogBuiltInMetadata.js +21 -0
- package/lib/types/LogBuiltInMetadata.js.map +1 -0
- package/lib/types/LogFunction.d.ts +24 -0
- package/lib/types/LogFunction.js +3 -0
- package/lib/types/LogFunction.js.map +1 -0
- package/lib/types/LogLevel.d.ts +10 -0
- package/lib/types/LogLevel.js +14 -0
- package/lib/types/LogLevel.js.map +1 -0
- package/lib/types/LogMetadataContextMap.d.ts +11 -0
- package/lib/types/LogMetadataContextMap.js +3 -0
- package/lib/types/LogMetadataContextMap.js.map +1 -0
- package/lib/types/LogMetadataTagMap.d.ts +8 -0
- package/lib/types/LogMetadataTagMap.js +3 -0
- package/lib/types/LogMetadataTagMap.js.map +1 -0
- package/lib/types/LogMetadataTargetMap.d.ts +8 -0
- package/lib/types/LogMetadataTargetMap.js +3 -0
- package/lib/types/LogMetadataTargetMap.js.map +1 -0
- package/lib/types/LogMetadataType.d.ts +13 -0
- package/lib/types/LogMetadataType.js +3 -0
- package/lib/types/LogMetadataType.js.map +1 -0
- package/lib/types/LogSource.d.ts +9 -0
- package/lib/types/LogSource.js +15 -0
- package/lib/types/LogSource.js.map +1 -0
- package/lib/types/LogType.d.ts +9 -0
- package/lib/types/LogType.js +15 -0
- package/lib/types/LogType.js.map +1 -0
- package/lib/types/ParamType.d.ts +17 -0
- package/lib/types/ParamType.js +21 -0
- package/lib/types/ParamType.js.map +1 -0
- package/package.json +47 -0
- package/src/constants/DAY_IN_MS.ts +7 -0
- package/src/constants/HOUR_IN_MS.ts +7 -0
- package/src/constants/LOG_REVIEW_GET_LOGS_ROUTE.ts +9 -0
- package/src/constants/LOG_REVIEW_ROUTE_PATH_PREFIX.ts +9 -0
- package/src/constants/LOG_REVIEW_STATUS_ROUTE.ts +10 -0
- package/src/constants/LOG_ROUTE_PATH.ts +9 -0
- package/src/constants/MINUTE_IN_MS.ts +7 -0
- package/src/constants/ROUTE_PATH_PREFIX.ts +7 -0
- package/src/constants/SELECT_ADMIN_CHECK_ROUTE.ts +7 -0
- package/src/errors/ErrorWithCode.ts +15 -0
- package/src/helpers/abbreviate.test.ts +26 -0
- package/src/helpers/abbreviate.ts +25 -0
- package/src/helpers/asyncArrayFunctions/everyAsync.test.ts +114 -0
- package/src/helpers/asyncArrayFunctions/everyAsync.ts +51 -0
- package/src/helpers/asyncArrayFunctions/filterAsync.test.ts +126 -0
- package/src/helpers/asyncArrayFunctions/filterAsync.ts +50 -0
- package/src/helpers/asyncArrayFunctions/forEachAsync.test.ts +136 -0
- package/src/helpers/asyncArrayFunctions/forEachAsync.ts +40 -0
- package/src/helpers/asyncArrayFunctions/mapAsync.test.ts +125 -0
- package/src/helpers/asyncArrayFunctions/mapAsync.ts +46 -0
- package/src/helpers/asyncArrayFunctions/someAsync.test.ts +92 -0
- package/src/helpers/asyncArrayFunctions/someAsync.ts +49 -0
- package/src/helpers/avg.test.ts +24 -0
- package/src/helpers/avg.ts +22 -0
- package/src/helpers/capitalize.ts +20 -0
- package/src/helpers/ceilToNumDecimals.test.ts +39 -0
- package/src/helpers/ceilToNumDecimals.ts +13 -0
- package/src/helpers/cloneDeep.ts +11 -0
- package/src/helpers/compareArraysByProp.test.ts +147 -0
- package/src/helpers/compareArraysByProp.ts +56 -0
- package/src/helpers/extractProp.test.ts +34 -0
- package/src/helpers/extractProp.ts +17 -0
- package/src/helpers/floorToNumDecimals.test.ts +39 -0
- package/src/helpers/floorToNumDecimals.ts +13 -0
- package/src/helpers/forceNumIntoBounds.test.ts +34 -0
- package/src/helpers/forceNumIntoBounds.ts +19 -0
- package/src/helpers/genCSV.test.ts +77 -0
- package/src/helpers/genCSV.ts +87 -0
- package/src/helpers/genCommaList.test.ts +57 -0
- package/src/helpers/genCommaList.ts +21 -0
- package/src/helpers/getHumanReadableDate.test.ts +29 -0
- package/src/helpers/getHumanReadableDate.ts +36 -0
- package/src/helpers/getLocalTimeInfo.test.ts +48 -0
- package/src/helpers/getLocalTimeInfo.ts +58 -0
- package/src/helpers/getMonthName.test.ts +79 -0
- package/src/helpers/getMonthName.ts +29 -0
- package/src/helpers/getOrdinal.test.ts +84 -0
- package/src/helpers/getOrdinal.ts +14 -0
- package/src/helpers/getPartOfDay.test.ts +56 -0
- package/src/helpers/getPartOfDay.ts +20 -0
- package/src/helpers/getTimeInfoInET.test.ts +72 -0
- package/src/helpers/getTimeInfoInET.ts +79 -0
- package/src/helpers/getTimestampFromTimeInfoInET.ts +179 -0
- package/src/helpers/getWordCount.ts +26 -0
- package/src/helpers/idify.ts +24 -0
- package/src/helpers/onlyKeepLetters.ts +11 -0
- package/src/helpers/padDecimalZeros.ts +32 -0
- package/src/helpers/padZerosLeft.ts +21 -0
- package/src/helpers/parallelLimit.ts +63 -0
- package/src/helpers/prefixWithAOrAn.ts +29 -0
- package/src/helpers/roundToNumDecimals.ts +13 -0
- package/src/helpers/shuffleArray.ts +19 -0
- package/src/helpers/startMinWait.ts +33 -0
- package/src/helpers/stringsToHumanReadableList.ts +39 -0
- package/src/helpers/sum.ts +16 -0
- package/src/helpers/validators/ChicagoTitleCase.test.ts +85 -0
- package/src/helpers/validators/ChicagoTitleCase.ts +32 -0
- package/src/helpers/validators/findURL.test.ts +83 -0
- package/src/helpers/validators/findURL.ts +43 -0
- package/src/helpers/validators/shared/constants/ERROR_MESSAGES.ts +18 -0
- package/src/helpers/validators/shared/helpers/validateRegex.ts +47 -0
- package/src/helpers/validators/shared/types/ValidationResult.ts +20 -0
- package/src/helpers/validators/validURL.test.ts +90 -0
- package/src/helpers/validators/validURL.ts +18 -0
- package/src/helpers/validators/validateEmail.test.ts +110 -0
- package/src/helpers/validators/validateEmail.ts +47 -0
- package/src/helpers/validators/validatePhoneNumber.test.ts +94 -0
- package/src/helpers/validators/validatePhoneNumber.ts +49 -0
- package/src/helpers/validators/validateString.test.ts +173 -0
- package/src/helpers/validators/validateString.ts +171 -0
- package/src/helpers/waitMs.ts +12 -0
- package/src/index.ts +139 -0
- package/src/types/CommonKitErrorCode.ts +13 -0
- package/src/types/DayOfWeek.ts +15 -0
- package/src/types/Log/LogMainInfo.ts +69 -0
- package/src/types/Log/LogSourceSpecificInfo.ts +25 -0
- package/src/types/Log/LogTypeSpecificInfo.ts +33 -0
- package/src/types/Log/index.ts +17 -0
- package/src/types/LogAction.ts +52 -0
- package/src/types/LogBuiltInMetadata.ts +19 -0
- package/src/types/LogFunction.ts +46 -0
- package/src/types/LogLevel.ts +11 -0
- package/src/types/LogMetadataContextMap.ts +15 -0
- package/src/types/LogMetadataTagMap.ts +9 -0
- package/src/types/LogMetadataTargetMap.ts +9 -0
- package/src/types/LogMetadataType.ts +16 -0
- package/src/types/LogSource.ts +12 -0
- package/src/types/LogType.ts +12 -0
- package/src/types/ParamType.ts +18 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// Import helpers
|
|
2
|
+
import genCommaList from '../genCommaList';
|
|
3
|
+
|
|
4
|
+
// Import types
|
|
5
|
+
import ValidationResult from './shared/types/ValidationResult';
|
|
6
|
+
|
|
7
|
+
// Import constants
|
|
8
|
+
import { INVALID_STRING_ERRORS, INVALID_REGEX_ERROR } from './shared/constants/ERROR_MESSAGES';
|
|
9
|
+
|
|
10
|
+
// Import function
|
|
11
|
+
import validateString from './validateString';
|
|
12
|
+
|
|
13
|
+
/*------------------------------------------------------------------------*/
|
|
14
|
+
/* ---------------------------- Valid Tests --------------------------- */
|
|
15
|
+
/*------------------------------------------------------------------------*/
|
|
16
|
+
|
|
17
|
+
const validStrings: string[] = [
|
|
18
|
+
'users',
|
|
19
|
+
'username',
|
|
20
|
+
'MyValidString',
|
|
21
|
+
'HereisAnotherValidString',
|
|
22
|
+
'WoahAnotherValidStringIsHere',
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const validReqs: {
|
|
26
|
+
// whitespace is removed from input before checking and returning
|
|
27
|
+
ignoreWhitespace?: boolean,
|
|
28
|
+
// input length must be at least minLen
|
|
29
|
+
minLen?: number,
|
|
30
|
+
// input length must be at most maxLen
|
|
31
|
+
maxLen?: number,
|
|
32
|
+
// input must only contain letters
|
|
33
|
+
lettersOnly?: boolean,
|
|
34
|
+
// input must only contain numbers
|
|
35
|
+
numbersOnly?: boolean,
|
|
36
|
+
// input must match given regExp
|
|
37
|
+
regexTest?: RegExp,
|
|
38
|
+
// description of regExp test, used to customize error messages
|
|
39
|
+
regexDescription?: string,
|
|
40
|
+
}[] = [
|
|
41
|
+
{
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
minLen: 5,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
minLen: 5,
|
|
48
|
+
maxLen: 30,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
minLen: 5,
|
|
52
|
+
maxLen: 30,
|
|
53
|
+
lettersOnly: true,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
minLen: 5,
|
|
57
|
+
maxLen: 30,
|
|
58
|
+
lettersOnly: true,
|
|
59
|
+
numbersOnly: false,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
minLen: 5,
|
|
63
|
+
maxLen: 30,
|
|
64
|
+
lettersOnly: true,
|
|
65
|
+
numbersOnly: false,
|
|
66
|
+
ignoreWhitespace: false,
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
test(
|
|
71
|
+
'Returns true for a given valid string.',
|
|
72
|
+
async () => {
|
|
73
|
+
validStrings.forEach((validString) => {
|
|
74
|
+
validReqs.forEach((validReq) => {
|
|
75
|
+
const validResponse: ValidationResult<string> = {
|
|
76
|
+
isValid: true,
|
|
77
|
+
cleanedValue: validString,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
expect(validateString(validString, validReq)).toStrictEqual(validResponse);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const validString = 'A string with whitespace!';
|
|
85
|
+
|
|
86
|
+
const validResponse: ValidationResult<string> = {
|
|
87
|
+
isValid: true,
|
|
88
|
+
cleanedValue: 'Astringwithwhitespace!',
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const validOpt = {
|
|
92
|
+
maxLen: 22,
|
|
93
|
+
ignoreWhitespace: true,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
expect(validateString(validString, validOpt)).toStrictEqual(validResponse);
|
|
97
|
+
},
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
/*------------------------------------------------------------------------*/
|
|
101
|
+
/* ---------------------------- Invalid Tests --------------------------- */
|
|
102
|
+
/*------------------------------------------------------------------------*/
|
|
103
|
+
|
|
104
|
+
const invalidStrings: {
|
|
105
|
+
input: string,
|
|
106
|
+
reqs: {
|
|
107
|
+
// whitespace is removed from input before checking and returning
|
|
108
|
+
ignoreWhitespace?: boolean,
|
|
109
|
+
// input length must be at least minLen
|
|
110
|
+
minLen?: number,
|
|
111
|
+
// input length must be at most maxLen
|
|
112
|
+
maxLen?: number,
|
|
113
|
+
// input must only contain letters
|
|
114
|
+
lettersOnly?: boolean,
|
|
115
|
+
// input must only contain numbers
|
|
116
|
+
numbersOnly?: boolean,
|
|
117
|
+
// input must match given regExp
|
|
118
|
+
regexTest?: RegExp,
|
|
119
|
+
// description of regExp test, used to customize error messages
|
|
120
|
+
regexDescription?: string,
|
|
121
|
+
},
|
|
122
|
+
error: string[]
|
|
123
|
+
}[] = [
|
|
124
|
+
{
|
|
125
|
+
input: 'ûšër',
|
|
126
|
+
reqs: {
|
|
127
|
+
minLen: 5,
|
|
128
|
+
lettersOnly: true,
|
|
129
|
+
},
|
|
130
|
+
error: [INVALID_STRING_ERRORS.MIN_LEN(5)],
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
input: '123456789',
|
|
134
|
+
reqs: {
|
|
135
|
+
minLen: 10,
|
|
136
|
+
maxLen: 5,
|
|
137
|
+
lettersOnly: true,
|
|
138
|
+
},
|
|
139
|
+
error: [INVALID_STRING_ERRORS.MIN_LEN(10), INVALID_STRING_ERRORS.MAX_LEN(5), INVALID_STRING_ERRORS.LETTERS_ONLY],
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
input: 'String with non-letters!!',
|
|
143
|
+
reqs: {
|
|
144
|
+
lettersOnly: true,
|
|
145
|
+
numbersOnly: true,
|
|
146
|
+
ignoreWhitespace: true,
|
|
147
|
+
},
|
|
148
|
+
error: [INVALID_STRING_ERRORS.LETTERS_ONLY, INVALID_STRING_ERRORS.NUMBERS_ONLY],
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
input: '12345678',
|
|
152
|
+
reqs: {
|
|
153
|
+
lettersOnly: true,
|
|
154
|
+
regexTest: /^\s*(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?\s*$/,
|
|
155
|
+
regexDescription: 'should be a phone number',
|
|
156
|
+
},
|
|
157
|
+
error: [INVALID_STRING_ERRORS.LETTERS_ONLY, `${INVALID_REGEX_ERROR}: should be a phone number`],
|
|
158
|
+
},
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
test(
|
|
162
|
+
'Returns false for a given invalid string.',
|
|
163
|
+
async () => {
|
|
164
|
+
invalidStrings.forEach((triple) => {
|
|
165
|
+
const invalidResponse: ValidationResult<string> = {
|
|
166
|
+
isValid: false,
|
|
167
|
+
errorMessage: `${INVALID_STRING_ERRORS.MESSAGE_INTRO}${genCommaList(triple.error)}.`,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
expect(validateString(triple.input, triple.reqs)).toStrictEqual(invalidResponse);
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
);
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// Import helpers
|
|
2
|
+
import validateRegex from './shared/helpers/validateRegex';
|
|
3
|
+
import genCommaList from '../genCommaList';
|
|
4
|
+
|
|
5
|
+
// Import constants
|
|
6
|
+
import { INVALID_STRING_ERRORS } from './shared/constants/ERROR_MESSAGES';
|
|
7
|
+
|
|
8
|
+
// Import types
|
|
9
|
+
import ValidationResult from './shared/types/ValidationResult';
|
|
10
|
+
|
|
11
|
+
/*------------------------------------------------------------------------*/
|
|
12
|
+
/* ------------------------------ Constants ----------------------------- */
|
|
13
|
+
/*------------------------------------------------------------------------*/
|
|
14
|
+
|
|
15
|
+
// define minimum and maximum range for lowercase ASCII chars
|
|
16
|
+
const LOWERCASE_MIN = 65;
|
|
17
|
+
const LOWERCASE_MAX = 90;
|
|
18
|
+
|
|
19
|
+
// define minimum and maximum range for uppercase ASCII chars
|
|
20
|
+
const UPPERCASE_MIN = 97;
|
|
21
|
+
const UPPERCASE_MAX = 122;
|
|
22
|
+
|
|
23
|
+
// define minimum and maximum range for ASCII digits
|
|
24
|
+
const DIGIT_MIN = 48;
|
|
25
|
+
const DIGIT_MAX = 57;
|
|
26
|
+
|
|
27
|
+
/*------------------------------------------------------------------------*/
|
|
28
|
+
/* ---------------------------- Main Function --------------------------- */
|
|
29
|
+
/*------------------------------------------------------------------------*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Determines whether a given input string is considered valid based on
|
|
33
|
+
* the provided requirements.
|
|
34
|
+
* @author Austen Money
|
|
35
|
+
* @param input input string
|
|
36
|
+
* @param opts options for validation
|
|
37
|
+
* @returns whether input is considered valid according to reqs - if
|
|
38
|
+
* valid, returns a cleaned version of input; if invalid, returns
|
|
39
|
+
* a string containing error messages describing which requirements
|
|
40
|
+
* were not met.
|
|
41
|
+
*/
|
|
42
|
+
const validateString = (
|
|
43
|
+
input: string,
|
|
44
|
+
opts: {
|
|
45
|
+
// whitespace is removed from input before checking and returning
|
|
46
|
+
ignoreWhitespace?: boolean,
|
|
47
|
+
// input length must be at least minLen
|
|
48
|
+
minLen?: number,
|
|
49
|
+
// input length must be at most maxLen
|
|
50
|
+
maxLen?: number,
|
|
51
|
+
// input must only contain letters
|
|
52
|
+
// (future TODO: add option for passing in an array of permitted chars)
|
|
53
|
+
lettersOnly?: boolean,
|
|
54
|
+
// input must only contain numbers
|
|
55
|
+
numbersOnly?: boolean,
|
|
56
|
+
// input must match given regExp
|
|
57
|
+
regexTest?: RegExp,
|
|
58
|
+
// description of regExp test, used to customize error messages
|
|
59
|
+
regexDescription?: string,
|
|
60
|
+
},
|
|
61
|
+
): ValidationResult<string> => {
|
|
62
|
+
// stores all invalid input errors
|
|
63
|
+
const errorMessages: string[] = [];
|
|
64
|
+
|
|
65
|
+
// contains version of input that will be returned
|
|
66
|
+
let cleanedValue: string = input;
|
|
67
|
+
|
|
68
|
+
// remove whitespace if required
|
|
69
|
+
if (opts.ignoreWhitespace) {
|
|
70
|
+
cleanedValue = input.replace(/\s+/g, '');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// apply max char requirement
|
|
74
|
+
if (opts.minLen) {
|
|
75
|
+
if (cleanedValue.length < opts.minLen) {
|
|
76
|
+
errorMessages.push(INVALID_STRING_ERRORS.MIN_LEN(opts.minLen));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// apply max char requirement
|
|
81
|
+
if (opts.maxLen) {
|
|
82
|
+
if (cleanedValue.length > opts.maxLen) {
|
|
83
|
+
errorMessages.push(INVALID_STRING_ERRORS.MAX_LEN(opts.maxLen));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// apply alphabetical requirement
|
|
88
|
+
if (opts.lettersOnly) {
|
|
89
|
+
// remove diacritics
|
|
90
|
+
cleanedValue = cleanedValue.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
91
|
+
|
|
92
|
+
const containsNonLetters = (
|
|
93
|
+
cleanedValue
|
|
94
|
+
// split into characters
|
|
95
|
+
.split('')
|
|
96
|
+
// convert into character codes
|
|
97
|
+
.map((curr) => {
|
|
98
|
+
return curr.charCodeAt(0);
|
|
99
|
+
})
|
|
100
|
+
// check for non-letters
|
|
101
|
+
.some((currCode) => {
|
|
102
|
+
return (
|
|
103
|
+
!(currCode >= LOWERCASE_MIN && currCode <= LOWERCASE_MAX)
|
|
104
|
+
&& !(currCode >= UPPERCASE_MIN && currCode <= UPPERCASE_MAX)
|
|
105
|
+
);
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
if (containsNonLetters) {
|
|
110
|
+
errorMessages.push(INVALID_STRING_ERRORS.LETTERS_ONLY);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// apply numerical requirement
|
|
115
|
+
if (opts.numbersOnly) {
|
|
116
|
+
const containsNonNumbers = (
|
|
117
|
+
cleanedValue
|
|
118
|
+
// split into characters
|
|
119
|
+
.split('')
|
|
120
|
+
// convert into character codes
|
|
121
|
+
.map((curr) => {
|
|
122
|
+
return curr.charCodeAt(0);
|
|
123
|
+
})
|
|
124
|
+
// check for non-numbers
|
|
125
|
+
.some((currCode) => {
|
|
126
|
+
return (
|
|
127
|
+
!(currCode >= DIGIT_MIN && currCode <= DIGIT_MAX)
|
|
128
|
+
);
|
|
129
|
+
})
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
if (containsNonNumbers) {
|
|
133
|
+
errorMessages.push(INVALID_STRING_ERRORS.NUMBERS_ONLY);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// apply regex requirement
|
|
138
|
+
if (opts.regexTest) {
|
|
139
|
+
const regex = opts.regexTest;
|
|
140
|
+
|
|
141
|
+
// validate and create customized error message if description is provided
|
|
142
|
+
const result = validateRegex({
|
|
143
|
+
input: cleanedValue,
|
|
144
|
+
regex,
|
|
145
|
+
regexDescription: opts.regexDescription,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// if string did not pass regex validation, add error message
|
|
149
|
+
if (result.isValid === false) {
|
|
150
|
+
errorMessages.push(result.errorMessage);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// combine all error messages into one string to return
|
|
155
|
+
const errorMessage = `${INVALID_STRING_ERRORS.MESSAGE_INTRO}${genCommaList(errorMessages)}.`;
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
// if no error messages, string is valid; if not, it is invalid
|
|
159
|
+
errorMessages.length === 0
|
|
160
|
+
? {
|
|
161
|
+
isValid: true,
|
|
162
|
+
cleanedValue,
|
|
163
|
+
}
|
|
164
|
+
: {
|
|
165
|
+
isValid: false,
|
|
166
|
+
errorMessage,
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export default validateString;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Import errors
|
|
2
|
+
import ErrorWithCode from './errors/ErrorWithCode';
|
|
3
|
+
|
|
4
|
+
// Import constants
|
|
5
|
+
import MINUTE_IN_MS from './constants/MINUTE_IN_MS';
|
|
6
|
+
import HOUR_IN_MS from './constants/HOUR_IN_MS';
|
|
7
|
+
import DAY_IN_MS from './constants/DAY_IN_MS';
|
|
8
|
+
import LOG_REVIEW_ROUTE_PATH_PREFIX from './constants/LOG_REVIEW_ROUTE_PATH_PREFIX';
|
|
9
|
+
import LOG_ROUTE_PATH from './constants/LOG_ROUTE_PATH';
|
|
10
|
+
import LOG_REVIEW_STATUS_ROUTE from './constants/LOG_REVIEW_STATUS_ROUTE';
|
|
11
|
+
import LOG_REVIEW_GET_LOGS_ROUTE from './constants/LOG_REVIEW_GET_LOGS_ROUTE';
|
|
12
|
+
import SELECT_ADMIN_CHECK_ROUTE from './constants/SELECT_ADMIN_CHECK_ROUTE';
|
|
13
|
+
|
|
14
|
+
// Import helpers
|
|
15
|
+
import abbreviate from './helpers/abbreviate';
|
|
16
|
+
import avg from './helpers/avg';
|
|
17
|
+
import ceilToNumDecimals from './helpers/ceilToNumDecimals';
|
|
18
|
+
import floorToNumDecimals from './helpers/floorToNumDecimals';
|
|
19
|
+
import forceNumIntoBounds from './helpers/forceNumIntoBounds';
|
|
20
|
+
import padDecimalZeros from './helpers/padDecimalZeros';
|
|
21
|
+
import padZerosLeft from './helpers/padZerosLeft';
|
|
22
|
+
import roundToNumDecimals from './helpers/roundToNumDecimals';
|
|
23
|
+
import sum from './helpers/sum';
|
|
24
|
+
import waitMs from './helpers/waitMs';
|
|
25
|
+
import getOrdinal from './helpers/getOrdinal';
|
|
26
|
+
import getTimeInfoInET from './helpers/getTimeInfoInET';
|
|
27
|
+
import startMinWait from './helpers/startMinWait';
|
|
28
|
+
import getHumanReadableDate from './helpers/getHumanReadableDate';
|
|
29
|
+
import getPartOfDay from './helpers/getPartOfDay';
|
|
30
|
+
import stringsToHumanReadableList from './helpers/stringsToHumanReadableList';
|
|
31
|
+
import onlyKeepLetters from './helpers/onlyKeepLetters';
|
|
32
|
+
import parallelLimit from './helpers/parallelLimit';
|
|
33
|
+
import getMonthName from './helpers/getMonthName';
|
|
34
|
+
import genCSV from './helpers/genCSV';
|
|
35
|
+
import extractProp from './helpers/extractProp';
|
|
36
|
+
import compareArraysByProp from './helpers/compareArraysByProp';
|
|
37
|
+
import getLocalTimeInfo from './helpers/getLocalTimeInfo';
|
|
38
|
+
import genCommaList from './helpers/genCommaList';
|
|
39
|
+
import validateEmail from './helpers/validators/validateEmail';
|
|
40
|
+
import validatePhoneNumber from './helpers/validators/validatePhoneNumber';
|
|
41
|
+
import validateString from './helpers/validators/validateString';
|
|
42
|
+
import idify from './helpers/idify';
|
|
43
|
+
import prefixWithAOrAn from './helpers/prefixWithAOrAn';
|
|
44
|
+
import everyAsync from './helpers/asyncArrayFunctions/everyAsync';
|
|
45
|
+
import filterAsync from './helpers/asyncArrayFunctions/filterAsync';
|
|
46
|
+
import forEachAsync from './helpers/asyncArrayFunctions/forEachAsync';
|
|
47
|
+
import mapAsync from './helpers/asyncArrayFunctions/mapAsync';
|
|
48
|
+
import someAsync from './helpers/asyncArrayFunctions/someAsync';
|
|
49
|
+
import capitalize from './helpers/capitalize';
|
|
50
|
+
import shuffleArray from './helpers/shuffleArray';
|
|
51
|
+
import getWordCount from './helpers/getWordCount';
|
|
52
|
+
import cloneDeep from './helpers/cloneDeep';
|
|
53
|
+
import getTimestampFromTimeInfoInET from './helpers/getTimestampFromTimeInfoInET';
|
|
54
|
+
|
|
55
|
+
// Import types
|
|
56
|
+
import ParamType from './types/ParamType';
|
|
57
|
+
import DayOfWeek from './types/DayOfWeek';
|
|
58
|
+
import Log from './types/Log';
|
|
59
|
+
import LogType from './types/LogType';
|
|
60
|
+
import LogSource from './types/LogSource';
|
|
61
|
+
import LogAction from './types/LogAction';
|
|
62
|
+
import LogBuiltInMetadata from './types/LogBuiltInMetadata';
|
|
63
|
+
import LogMetadataType from './types/LogMetadataType';
|
|
64
|
+
import LogFunction from './types/LogFunction';
|
|
65
|
+
import LogTypeSpecificInfo from './types/Log/LogTypeSpecificInfo';
|
|
66
|
+
import LogMainInfo from './types/Log/LogMainInfo';
|
|
67
|
+
import LogSourceSpecificInfo from './types/Log/LogSourceSpecificInfo';
|
|
68
|
+
import LogLevel from './types/LogLevel';
|
|
69
|
+
import CommonKitErrorCode from './types/CommonKitErrorCode';
|
|
70
|
+
|
|
71
|
+
// Export each item
|
|
72
|
+
export {
|
|
73
|
+
// Errors
|
|
74
|
+
ErrorWithCode,
|
|
75
|
+
// Constants
|
|
76
|
+
MINUTE_IN_MS,
|
|
77
|
+
HOUR_IN_MS,
|
|
78
|
+
DAY_IN_MS,
|
|
79
|
+
LOG_REVIEW_ROUTE_PATH_PREFIX,
|
|
80
|
+
LOG_ROUTE_PATH,
|
|
81
|
+
LOG_REVIEW_STATUS_ROUTE,
|
|
82
|
+
LOG_REVIEW_GET_LOGS_ROUTE,
|
|
83
|
+
SELECT_ADMIN_CHECK_ROUTE,
|
|
84
|
+
// Types
|
|
85
|
+
CommonKitErrorCode,
|
|
86
|
+
ParamType,
|
|
87
|
+
DayOfWeek,
|
|
88
|
+
Log,
|
|
89
|
+
LogType,
|
|
90
|
+
LogSource,
|
|
91
|
+
LogAction,
|
|
92
|
+
LogBuiltInMetadata,
|
|
93
|
+
LogMetadataType,
|
|
94
|
+
LogFunction,
|
|
95
|
+
LogTypeSpecificInfo,
|
|
96
|
+
LogMainInfo,
|
|
97
|
+
LogSourceSpecificInfo,
|
|
98
|
+
LogLevel,
|
|
99
|
+
// Helpers
|
|
100
|
+
abbreviate,
|
|
101
|
+
avg,
|
|
102
|
+
ceilToNumDecimals,
|
|
103
|
+
floorToNumDecimals,
|
|
104
|
+
forceNumIntoBounds,
|
|
105
|
+
padDecimalZeros,
|
|
106
|
+
padZerosLeft,
|
|
107
|
+
roundToNumDecimals,
|
|
108
|
+
sum,
|
|
109
|
+
waitMs,
|
|
110
|
+
getOrdinal,
|
|
111
|
+
getTimeInfoInET,
|
|
112
|
+
startMinWait,
|
|
113
|
+
getHumanReadableDate,
|
|
114
|
+
getPartOfDay,
|
|
115
|
+
stringsToHumanReadableList,
|
|
116
|
+
onlyKeepLetters,
|
|
117
|
+
parallelLimit,
|
|
118
|
+
getMonthName,
|
|
119
|
+
genCSV,
|
|
120
|
+
extractProp,
|
|
121
|
+
compareArraysByProp,
|
|
122
|
+
genCommaList,
|
|
123
|
+
validateEmail,
|
|
124
|
+
validatePhoneNumber,
|
|
125
|
+
validateString,
|
|
126
|
+
getLocalTimeInfo,
|
|
127
|
+
idify,
|
|
128
|
+
prefixWithAOrAn,
|
|
129
|
+
everyAsync,
|
|
130
|
+
filterAsync,
|
|
131
|
+
forEachAsync,
|
|
132
|
+
mapAsync,
|
|
133
|
+
someAsync,
|
|
134
|
+
capitalize,
|
|
135
|
+
shuffleArray,
|
|
136
|
+
getWordCount,
|
|
137
|
+
cloneDeep,
|
|
138
|
+
getTimestampFromTimeInfoInET,
|
|
139
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Highest error code = DCK3
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* List of error codes built into the common kit
|
|
5
|
+
* @author Gabe Abrams
|
|
6
|
+
*/
|
|
7
|
+
enum CommonKitErrorCode {
|
|
8
|
+
SimpleDateChooserInvalidDateRange = 'DCK1',
|
|
9
|
+
SimpleDateChooserInvalidNumMonths = 'DCK2',
|
|
10
|
+
ETTimestampInvalid = 'DCK3',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default CommonKitErrorCode;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Import shared types
|
|
2
|
+
import LogLevel from '../LogLevel';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Main information in a log event
|
|
6
|
+
* @author Gabe Abrams
|
|
7
|
+
*/
|
|
8
|
+
type LogMainInfo = {
|
|
9
|
+
// Unique id of the log event
|
|
10
|
+
id: string,
|
|
11
|
+
// First name of the user
|
|
12
|
+
userFirstName: string,
|
|
13
|
+
// Last name of the user
|
|
14
|
+
userLastName: string,
|
|
15
|
+
// User email
|
|
16
|
+
userEmail: string,
|
|
17
|
+
// User Canvas Id
|
|
18
|
+
userId: number,
|
|
19
|
+
// If true, the user is a learner
|
|
20
|
+
isLearner: boolean,
|
|
21
|
+
// If true, the user is an admin
|
|
22
|
+
isAdmin: boolean,
|
|
23
|
+
// If true, the user is a ttm
|
|
24
|
+
isTTM: boolean,
|
|
25
|
+
// The id of the Canvas course that the user launched from
|
|
26
|
+
courseId: number,
|
|
27
|
+
// The name of the Canvas course
|
|
28
|
+
courseName: string,
|
|
29
|
+
// Browser info
|
|
30
|
+
browser: {
|
|
31
|
+
// Name of the browser
|
|
32
|
+
name: string,
|
|
33
|
+
// Version of the browser
|
|
34
|
+
version: string,
|
|
35
|
+
},
|
|
36
|
+
// Device info
|
|
37
|
+
device: {
|
|
38
|
+
// Name of the operating system
|
|
39
|
+
os: string,
|
|
40
|
+
// If true, device is a mobile device
|
|
41
|
+
isMobile: boolean,
|
|
42
|
+
},
|
|
43
|
+
// Calendar year that the event is from
|
|
44
|
+
year: number,
|
|
45
|
+
// Month that the event is from (1 = Jan, 12 = Dec)
|
|
46
|
+
month: number,
|
|
47
|
+
// Day of the month that the event is from
|
|
48
|
+
day: number,
|
|
49
|
+
// Hour of the day (24hr) when the event occurred
|
|
50
|
+
hour: number,
|
|
51
|
+
// Minute of the day when the event occurred
|
|
52
|
+
minute: number,
|
|
53
|
+
// Timestamp of event (ms since epoch)
|
|
54
|
+
timestamp: number,
|
|
55
|
+
// Context of the event (each app determines how to organize contexts)
|
|
56
|
+
context: string,
|
|
57
|
+
// Subcontext of the event (each app determines how to organize subcontexts)
|
|
58
|
+
subcontext: string,
|
|
59
|
+
// List of tags that apply to this action (each app determines tag usage)
|
|
60
|
+
tags: string[],
|
|
61
|
+
// Log level
|
|
62
|
+
level: LogLevel,
|
|
63
|
+
// Additional optional custom metadata
|
|
64
|
+
metadata?: {
|
|
65
|
+
[k: string]: any,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default LogMainInfo;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Import shared types
|
|
2
|
+
import LogSource from '../LogSource';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Log info that is specific to the type of source
|
|
6
|
+
* @author Gabe Abrams
|
|
7
|
+
*/
|
|
8
|
+
type LogSourceSpecificInfo = (
|
|
9
|
+
// Client
|
|
10
|
+
| {
|
|
11
|
+
// Source of the event
|
|
12
|
+
source: LogSource.Client,
|
|
13
|
+
}
|
|
14
|
+
// Server
|
|
15
|
+
| {
|
|
16
|
+
// Source of the event
|
|
17
|
+
source: LogSource.Server,
|
|
18
|
+
// Route path (e.g. /api/admin/courses/53450/blocks)
|
|
19
|
+
routePath: string,
|
|
20
|
+
// Route template (e.g. /api/admin/courses/:courseId/blocks)
|
|
21
|
+
routeTemplate: string,
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export default LogSourceSpecificInfo;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Import shared types
|
|
2
|
+
import LogAction from '../LogAction';
|
|
3
|
+
import LogType from '../LogType';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Log info that is specific to the type of log
|
|
7
|
+
* @author Gabe Abrams
|
|
8
|
+
*/
|
|
9
|
+
type LogTypeSpecificInfo = (
|
|
10
|
+
// Error
|
|
11
|
+
| {
|
|
12
|
+
// Type of the event
|
|
13
|
+
type: LogType.Error,
|
|
14
|
+
// The error message
|
|
15
|
+
errorMessage: string,
|
|
16
|
+
// The error code
|
|
17
|
+
errorCode: string,
|
|
18
|
+
// Error stack trace
|
|
19
|
+
errorStack: string,
|
|
20
|
+
}
|
|
21
|
+
// Action
|
|
22
|
+
| {
|
|
23
|
+
// Type of the event
|
|
24
|
+
type: LogType.Action,
|
|
25
|
+
// Target of the action (each app determines the list of targets)
|
|
26
|
+
// These are usually buttons, panels, elements, etc.
|
|
27
|
+
target: string,
|
|
28
|
+
// The type of action performed on the target
|
|
29
|
+
action: LogAction,
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export default LogTypeSpecificInfo;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Import shared types
|
|
2
|
+
import LogMainInfo from './LogMainInfo';
|
|
3
|
+
import LogSourceSpecificInfo from './LogSourceSpecificInfo';
|
|
4
|
+
import LogTypeSpecificInfo from './LogTypeSpecificInfo';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A single log event corresponding to an action performed by a user or an
|
|
8
|
+
* error encountered by a user
|
|
9
|
+
* @author Gabe Abrams
|
|
10
|
+
*/
|
|
11
|
+
type Log = (
|
|
12
|
+
LogMainInfo
|
|
13
|
+
& LogSourceSpecificInfo
|
|
14
|
+
& LogTypeSpecificInfo
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export default Log;
|