|
| 1 | +/** |
| 2 | + * Centralized error messages and warnings for the DataSync MongoDB SDK |
| 3 | + * This file contains all user-facing messages for consistency and maintainability |
| 4 | + */ |
| 5 | + |
| 6 | +export const ErrorMessages = { |
| 7 | + // Configuration errors |
| 8 | + INVALID_MONGODB_URI: (uri: any) => `MongoDB connection URL: ${uri} must be of type string`, |
| 9 | + INVALID_DBNAME: 'Content store dbName should be of type string and not empty', |
| 10 | + |
| 11 | + // Sorting errors |
| 12 | + INVALID_ASCENDING_PARAMS: 'Invalid parameters for .ascending(). Expected a valid string field name', |
| 13 | + INVALID_DESCENDING_PARAMS: 'Invalid parameters for .descending(). Expected a valid string field name', |
| 14 | + |
| 15 | + // Language errors |
| 16 | + INVALID_LANGUAGE_PARAMS: 'Invalid parameters for .language(). Expected a valid language code string', |
| 17 | + |
| 18 | + // Logical operator errors |
| 19 | + INVALID_AND_PARAMS: 'Invalid parameters for .and(). Expected an array of query objects', |
| 20 | + INVALID_OR_PARAMS: 'Invalid parameters for .or(). Expected an array of query objects', |
| 21 | + |
| 22 | + // Comparison operator errors |
| 23 | + INVALID_LESSTHAN_PARAMS: 'Invalid key or value parameters for .lessThan(). Expected a string key and a value', |
| 24 | + INVALID_LESSTHAN_OR_EQUAL_PARAMS: 'Invalid key or value parameters for .lessThanOrEqualTo(). Expected a string key and a value', |
| 25 | + INVALID_GREATERTHAN_PARAMS: 'Invalid key or value parameters for .greaterThan(). Expected a string key and a value', |
| 26 | + INVALID_GREATERTHAN_OR_EQUAL_PARAMS: 'Invalid key or value parameters for .greaterThanOrEqualTo(). Expected a string key and a value', |
| 27 | + INVALID_NOTEQUAL_PARAMS: 'Invalid key or value parameters for .notEqualTo(). Expected a string key and a value', |
| 28 | + INVALID_CONTAINED_IN_PARAMS: 'Invalid key or value parameters for .containedIn(). Expected a string key and an array value', |
| 29 | + INVALID_NOT_CONTAINED_IN_PARAMS: 'Invalid key or value parameters for .notContainedIn(). Expected a string key and an array value', |
| 30 | + INVALID_EXISTS_PARAMS: 'Invalid key parameter for .exists(). Expected a valid string field name', |
| 31 | + INVALID_NOT_EXISTS_PARAMS: 'Invalid key parameter for .notExists(). Expected a valid string field name', |
| 32 | + |
| 33 | + // Content type errors |
| 34 | + MISSING_CONTENT_TYPE_UID: 'Content type UID is required. Please provide a valid content type UID', |
| 35 | + MISSING_CONTENT_TYPE_FOR_ENTRY: 'Please call .contentType() before .entry()', |
| 36 | + MISSING_CONTENT_TYPE_FOR_ENTRIES: 'Please call .contentType() before .entries()', |
| 37 | + |
| 38 | + // Pagination errors |
| 39 | + INVALID_LIMIT_VALUE: 'Invalid value for .limit(). Expected a positive numeric value', |
| 40 | + INVALID_SKIP_VALUE: 'Invalid value for .skip(). Expected a non-negative numeric value', |
| 41 | + |
| 42 | + // Projection errors |
| 43 | + INVALID_ONLY_PARAMS: 'Invalid field values for .only(). Expected a non-empty array of field names', |
| 44 | + INVALID_EXCEPT_PARAMS: 'Invalid field values for .except(). Expected a non-empty array of field names', |
| 45 | + |
| 46 | + // Query errors |
| 47 | + INVALID_REGEX_PARAMS: 'Invalid field or pattern parameters for .regex(). Expected string values for both field and pattern', |
| 48 | + INVALID_TAGS_PARAMS: 'Invalid field values for .tags(). Expected an array of tag values', |
| 49 | + INVALID_WHERE_PARAMS: 'Invalid expression for .where(). Expected a valid expression or function', |
| 50 | + INVALID_QUERY_REFERENCES_PARAMS: 'Invalid query object for .queryReferences(). Expected a valid query object', |
| 51 | + INVALID_INCLUDE_PARAMS: 'Invalid reference field path for .include(). Expected a valid string or array of strings', |
| 52 | + |
| 53 | + // Query validation errors |
| 54 | + INVALID_QUERY: 'Invalid query provided. Please ensure your query is properly formatted', |
| 55 | + INVALID_QUERIES: 'Invalid queries provided. Please ensure all queries are properly formatted', |
| 56 | +} as const |
| 57 | + |
| 58 | +export const WarningMessages = { |
| 59 | + // Performance warnings |
| 60 | + SLOW_INCLUDE_REFERENCES: '.includeReferences(...) is a relatively slow query. Consider limiting the depth or using .include() for specific references', |
| 61 | +} as const |
| 62 | + |
0 commit comments