utilitify-core 1.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/LICENSE +21 -0
- package/README.md +338 -0
- package/dist/async.cjs +25 -0
- package/dist/async.cjs.map +1 -0
- package/dist/async.d.cts +104 -0
- package/dist/async.d.ts +104 -0
- package/dist/async.js +4 -0
- package/dist/async.js.map +1 -0
- package/dist/chunk-2ICNRTSN.cjs +346 -0
- package/dist/chunk-2ICNRTSN.cjs.map +1 -0
- package/dist/chunk-3DPF72DY.js +170 -0
- package/dist/chunk-3DPF72DY.js.map +1 -0
- package/dist/chunk-4CV4JOE5.js +24 -0
- package/dist/chunk-4CV4JOE5.js.map +1 -0
- package/dist/chunk-4SLYNSLH.cjs +783 -0
- package/dist/chunk-4SLYNSLH.cjs.map +1 -0
- package/dist/chunk-5WP7DWCG.js +1285 -0
- package/dist/chunk-5WP7DWCG.js.map +1 -0
- package/dist/chunk-BMQ6YPKV.js +876 -0
- package/dist/chunk-BMQ6YPKV.js.map +1 -0
- package/dist/chunk-BZCMWUKS.cjs +479 -0
- package/dist/chunk-BZCMWUKS.cjs.map +1 -0
- package/dist/chunk-C5R744DY.cjs +173 -0
- package/dist/chunk-C5R744DY.cjs.map +1 -0
- package/dist/chunk-C75J62CV.cjs +913 -0
- package/dist/chunk-C75J62CV.cjs.map +1 -0
- package/dist/chunk-CZLDE2OZ.cjs +28 -0
- package/dist/chunk-CZLDE2OZ.cjs.map +1 -0
- package/dist/chunk-DSMB6AF6.cjs +193 -0
- package/dist/chunk-DSMB6AF6.cjs.map +1 -0
- package/dist/chunk-ETWGPOPY.js +426 -0
- package/dist/chunk-ETWGPOPY.js.map +1 -0
- package/dist/chunk-FQBPVN63.cjs +403 -0
- package/dist/chunk-FQBPVN63.cjs.map +1 -0
- package/dist/chunk-G4GYQGTW.cjs +178 -0
- package/dist/chunk-G4GYQGTW.cjs.map +1 -0
- package/dist/chunk-GFDMZDMI.js +486 -0
- package/dist/chunk-GFDMZDMI.js.map +1 -0
- package/dist/chunk-HOTOYIPB.js +171 -0
- package/dist/chunk-HOTOYIPB.js.map +1 -0
- package/dist/chunk-HYADH4ZX.js +176 -0
- package/dist/chunk-HYADH4ZX.js.map +1 -0
- package/dist/chunk-JBN7C5WE.js +255 -0
- package/dist/chunk-JBN7C5WE.js.map +1 -0
- package/dist/chunk-JNCTPFTD.cjs +25 -0
- package/dist/chunk-JNCTPFTD.cjs.map +1 -0
- package/dist/chunk-N3BH3BV7.js +21 -0
- package/dist/chunk-N3BH3BV7.js.map +1 -0
- package/dist/chunk-NFPGAVRQ.js +749 -0
- package/dist/chunk-NFPGAVRQ.js.map +1 -0
- package/dist/chunk-OFFRGRBN.cjs +1332 -0
- package/dist/chunk-OFFRGRBN.cjs.map +1 -0
- package/dist/chunk-OZLKYIZL.cjs +490 -0
- package/dist/chunk-OZLKYIZL.cjs.map +1 -0
- package/dist/chunk-P3NUK46X.js +145 -0
- package/dist/chunk-P3NUK46X.js.map +1 -0
- package/dist/chunk-P7P2B7ZI.cjs +429 -0
- package/dist/chunk-P7P2B7ZI.cjs.map +1 -0
- package/dist/chunk-PB6SKSJN.cjs +150 -0
- package/dist/chunk-PB6SKSJN.cjs.map +1 -0
- package/dist/chunk-R3IXCJR7.js +378 -0
- package/dist/chunk-R3IXCJR7.js.map +1 -0
- package/dist/chunk-SD6P3WEJ.js +324 -0
- package/dist/chunk-SD6P3WEJ.js.map +1 -0
- package/dist/chunk-YSCHP26P.js +451 -0
- package/dist/chunk-YSCHP26P.js.map +1 -0
- package/dist/chunk-ZLMPRPCY.cjs +274 -0
- package/dist/chunk-ZLMPRPCY.cjs.map +1 -0
- package/dist/common-CBDYNJeh.d.cts +48 -0
- package/dist/common-CBDYNJeh.d.ts +48 -0
- package/dist/constants.cjs +42 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +60 -0
- package/dist/constants.d.ts +60 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/country/index.cjs +154 -0
- package/dist/country/index.cjs.map +1 -0
- package/dist/country/index.d.cts +1 -0
- package/dist/country/index.d.ts +1 -0
- package/dist/country/index.js +5 -0
- package/dist/country/index.js.map +1 -0
- package/dist/date/index.cjs +117 -0
- package/dist/date/index.cjs.map +1 -0
- package/dist/date/index.d.cts +283 -0
- package/dist/date/index.d.ts +283 -0
- package/dist/date/index.js +4 -0
- package/dist/date/index.js.map +1 -0
- package/dist/environment/index.cjs +73 -0
- package/dist/environment/index.cjs.map +1 -0
- package/dist/environment/index.d.cts +127 -0
- package/dist/environment/index.d.ts +127 -0
- package/dist/environment/index.js +4 -0
- package/dist/environment/index.js.map +1 -0
- package/dist/form/index.cjs +81 -0
- package/dist/form/index.cjs.map +1 -0
- package/dist/form/index.d.cts +227 -0
- package/dist/form/index.d.ts +227 -0
- package/dist/form/index.js +4 -0
- package/dist/form/index.js.map +1 -0
- package/dist/i18n.cjs +37 -0
- package/dist/i18n.cjs.map +1 -0
- package/dist/i18n.d.cts +102 -0
- package/dist/i18n.d.ts +102 -0
- package/dist/i18n.js +4 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index-BXBmBHyL.d.ts +718 -0
- package/dist/index-BYsUCP3u.d.cts +718 -0
- package/dist/index-Cl26FrAZ.d.cts +362 -0
- package/dist/index-Cl26FrAZ.d.ts +362 -0
- package/dist/index.cjs +1265 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +205 -0
- package/dist/index.d.ts +205 -0
- package/dist/index.js +277 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.cjs +13 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.cts +84 -0
- package/dist/schema.d.ts +84 -0
- package/dist/schema.js +4 -0
- package/dist/schema.js.map +1 -0
- package/dist/security/index.cjs +94 -0
- package/dist/security/index.cjs.map +1 -0
- package/dist/security/index.d.cts +216 -0
- package/dist/security/index.d.ts +216 -0
- package/dist/security/index.js +5 -0
- package/dist/security/index.js.map +1 -0
- package/dist/string/index.cjs +153 -0
- package/dist/string/index.cjs.map +1 -0
- package/dist/string/index.d.cts +471 -0
- package/dist/string/index.d.ts +471 -0
- package/dist/string/index.js +4 -0
- package/dist/string/index.js.map +1 -0
- package/dist/transform/index.cjs +105 -0
- package/dist/transform/index.cjs.map +1 -0
- package/dist/transform/index.d.cts +271 -0
- package/dist/transform/index.d.ts +271 -0
- package/dist/transform/index.js +4 -0
- package/dist/transform/index.js.map +1 -0
- package/dist/validators/index.cjs +195 -0
- package/dist/validators/index.cjs.map +1 -0
- package/dist/validators/index.d.cts +2 -0
- package/dist/validators/index.d.ts +2 -0
- package/dist/validators/index.js +6 -0
- package/dist/validators/index.js.map +1 -0
- package/package.json +229 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/unified/validateUser.ts","../src/cache/index.ts","../src/middleware/index.ts","../src/errors/index.ts"],"names":["errors","validateName","validateEmail","validatePhone","validateUsername","checkPasswordStrength","calculateAge"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA,IAAM,eAAA,GAAyC;AAAA,EAC3C,UAAU;AACd,CAAA;AA6BO,SAAS,YAAA,CACZ,QAAA,EACA,OAAA,GAAiC,EAAC,EACd;AACpB,EAAA,MAAM,IAAA,GAAO,EAAE,GAAG,eAAA,EAAiB,GAAG,OAAA,EAAQ;AAC9C,EAAA,MAAMA,UAA6B,EAAC;AACpC,EAAA,MAAM,OAAqC,EAAC;AAC5C,EAAA,MAAM,YAA+B,EAAC;AAGtC,EAAA,KAAA,MAAW,KAAA,IAAS,IAAA,CAAK,QAAA,IAAY,EAAC,EAAG;AACrC,IAAA,MAAM,KAAA,GAAQ,SAAS,KAAK,CAAA;AAC5B,IAAA,IAAI,KAAA,KAAU,MAAA,IAAa,KAAA,KAAU,IAAA,IAAQ,UAAU,EAAA,EAAI;AACvD,MAAAA,QAAO,IAAA,CAAK;AAAA,QACR,KAAA;AAAA,QACA,IAAA,EAAM,UAAA;AAAA,QAC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B,OAAA,EAAe;AACxC,IAAA,KAAA,CAAM,OAAA,EAAS,kBAAkB,OAAO,CAAA;AACxC,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AAAA,EAChB;AACJ;AAKO,IAAM,kBAAA,GAAN,cAAiC,cAAA,CAAe;AAAA,EACnD,WAAA,CAAY,SAAiB,OAAA,EAAe;AACxC,IAAA,KAAA,CAAM,OAAA,EAAS,uBAAuB,OAAO,CAAA;AAC7C,IAAA,IAAA,CAAK,IAAA,GAAO,oBAAA;AAAA,EAChB;AACJ;AAKO,IAAM,YAAA,GAAN,cAA2B,cAAA,CAAe;AAAA,EAC7C,WAAA,CAAY,OAAA,GAAkB,qBAAA,EAAuB,OAAA,EAAe;AAChE,IAAA,KAAA,CAAM,OAAA,EAAS,iBAAiB,OAAO,CAAA;AACvC,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AAAA,EAChB;AACJ;AAKO,SAAS,iBAAiB,KAAA,EAAyC;AACtE,EAAA,OAAO,KAAA,YAAiB,cAAA;AAC5B","file":"index.cjs","sourcesContent":["import type {\r\n UserData,\r\n UserValidationOptions,\r\n UserValidationResult,\r\n IValidationError,\r\n} from '../types';\r\nimport { validateEmail } from '../validators/email';\r\nimport { validateName } from '../validators/name';\r\nimport { validatePhone } from '../validators/phone';\r\nimport { validateUsername } from '../validators/username';\r\nimport { checkPasswordStrength } from '../security/password';\r\nimport { calculateAge } from '../date/age';\r\n\r\n/**\r\n * Default validation options\r\n */\r\nconst DEFAULT_OPTIONS: UserValidationOptions = {\r\n required: [],\r\n};\r\n\r\n/**\r\n * Validate user data with automatic field detection\r\n *\r\n * This is the unified validation function that validates all provided\r\n * user fields and returns standardized errors.\r\n *\r\n * @param userData - User data to validate\r\n * @param options - Validation options\r\n * @returns Validation result with all errors\r\n *\r\n * @example\r\n * ```typescript\r\n * import { validateUser } from 'utilitify';\r\n *\r\n * const result = validateUser({\r\n * name: 'John Doe',\r\n * email: 'john@example.com',\r\n * phone: '+1 555-123-4567',\r\n * country: 'US',\r\n * password: 'MyP@ssw0rd!'\r\n * });\r\n *\r\n * if (!result.isValid) {\r\n * console.log(result.errors);\r\n * }\r\n * ```\r\n */\r\nexport function validateUser(\r\n userData: UserData,\r\n options: UserValidationOptions = {}\r\n): UserValidationResult {\r\n const opts = { ...DEFAULT_OPTIONS, ...options };\r\n const errors: IValidationError[] = [];\r\n const data: UserValidationResult['data'] = {};\r\n const sanitized: Partial<UserData> = {};\r\n\r\n // Check required fields\r\n for (const field of opts.required || []) {\r\n const value = userData[field];\r\n if (value === undefined || value === null || value === '') {\r\n errors.push({\r\n field,\r\n code: 'REQUIRED',\r\n message: `${field} is required`,\r\n });\r\n }\r\n }\r\n\r\n // Validate name\r\n if (userData.name !== undefined) {\r\n const nameResult = validateName(userData.name, opts.name);\r\n data.name = nameResult;\r\n sanitized.name = nameResult.sanitized;\r\n\r\n if (!nameResult.isValid) {\r\n errors.push(...nameResult.errors);\r\n }\r\n }\r\n\r\n // Validate email\r\n if (userData.email !== undefined) {\r\n const emailResult = validateEmail(userData.email, opts.email);\r\n data.email = emailResult;\r\n sanitized.email = emailResult.normalized;\r\n\r\n if (!emailResult.isValid) {\r\n errors.push(...emailResult.errors);\r\n }\r\n }\r\n\r\n // Validate phone (use country if provided)\r\n if (userData.phone !== undefined) {\r\n const phoneOptions = {\r\n ...opts.phone,\r\n countryCode: opts.phone?.countryCode || userData.country,\r\n };\r\n const phoneResult = validatePhone(userData.phone, phoneOptions);\r\n data.phone = phoneResult;\r\n sanitized.phone = phoneResult.formatted.e164 || userData.phone;\r\n\r\n if (!phoneResult.isValid) {\r\n errors.push(...phoneResult.errors);\r\n }\r\n }\r\n\r\n // Validate username\r\n if (userData.username !== undefined) {\r\n const usernameResult = validateUsername(userData.username, opts.username);\r\n data.username = usernameResult;\r\n sanitized.username = usernameResult.sanitized;\r\n\r\n if (!usernameResult.isValid) {\r\n errors.push(...usernameResult.errors);\r\n }\r\n }\r\n\r\n // Check password strength (doesn't add to errors, just provides info)\r\n if (userData.password !== undefined) {\r\n const passwordResult = checkPasswordStrength(userData.password);\r\n\r\n // Only add error if password is very weak\r\n if (passwordResult.score < 2) {\r\n errors.push({\r\n field: 'password',\r\n code: 'WEAK_PASSWORD',\r\n message: 'Password is too weak. ' + (passwordResult.suggestions[0] || ''),\r\n });\r\n }\r\n }\r\n\r\n // Validate date of birth / calculate age\r\n if (userData.dateOfBirth !== undefined) {\r\n const ageResult = calculateAge(userData.dateOfBirth);\r\n\r\n if (ageResult.years === 0 && typeof userData.dateOfBirth === 'string') {\r\n errors.push({\r\n field: 'dateOfBirth',\r\n code: 'INVALID_DATE',\r\n message: 'Invalid date of birth',\r\n });\r\n }\r\n }\r\n\r\n // Copy unvalidated fields\r\n if (userData.country !== undefined) {\r\n sanitized.country = userData.country.toUpperCase();\r\n }\r\n\r\n return {\r\n isValid: errors.length === 0,\r\n errors,\r\n data,\r\n sanitized,\r\n };\r\n}\r\n\r\n/**\r\n * Quick validate - returns boolean only\r\n *\r\n * @param userData - User data to validate\r\n * @param options - Validation options\r\n * @returns true if all validations pass\r\n */\r\nexport function isValidUser(\r\n userData: UserData,\r\n options: UserValidationOptions = {}\r\n): boolean {\r\n return validateUser(userData, options).isValid;\r\n}\r\n\r\n/**\r\n * Get validation errors as simple object\r\n *\r\n * @param userData - User data to validate\r\n * @param options - Validation options\r\n * @returns Object with field names as keys and array of error messages as values\r\n */\r\nexport function getUserErrors(\r\n userData: UserData,\r\n options: UserValidationOptions = {}\r\n): Record<string, string[]> {\r\n const result = validateUser(userData, options);\r\n const errorsByField: Record<string, string[]> = {};\r\n\r\n for (const error of result.errors) {\r\n if (!errorsByField[error.field]) {\r\n errorsByField[error.field] = [];\r\n }\r\n errorsByField[error.field].push(error.message);\r\n }\r\n\r\n return errorsByField;\r\n}\r\n","/**\r\n * Simple LRU (Least Recently Used) Cache implementation\r\n * Used for caching expensive validation results or country data lookups.\r\n *\r\n * @packageDocumentation\r\n * @since 1.2.0\r\n */\r\n\r\nexport interface CacheOptions {\r\n /** Maximum number of items to store (default: 100) */\r\n maxSize?: number;\r\n /** Time to live in milliseconds (default: Infinity) */\r\n ttl?: number;\r\n}\r\n\r\ninterface CacheEntry<T> {\r\n value: T;\r\n expiry: number;\r\n}\r\n\r\n/**\r\n * LRU Cache class\r\n */\r\nexport class Cache<T = any> {\r\n private items: Map<string, CacheEntry<T>>;\r\n private maxSize: number;\r\n private ttl: number;\r\n\r\n /**\r\n * Create a new Cache instance\r\n * @param options - Cache options\r\n */\r\n constructor(options: CacheOptions = {}) {\r\n this.items = new Map();\r\n this.maxSize = options.maxSize || 100;\r\n this.ttl = options.ttl || Infinity;\r\n }\r\n\r\n /**\r\n * Get an item from the cache\r\n * @param key - Cache key\r\n * @returns Cached value or undefined\r\n */\r\n get(key: string): T | undefined {\r\n const item = this.items.get(key);\r\n\r\n if (!item) return undefined;\r\n\r\n // Check expiry\r\n if (Date.now() > item.expiry) {\r\n this.items.delete(key);\r\n return undefined;\r\n }\r\n\r\n // Refresh position (LRU) - delete and re-insert makes it the \"newest\"\r\n this.items.delete(key);\r\n this.items.set(key, item);\r\n\r\n return item.value;\r\n }\r\n\r\n /**\r\n * Set an item in the cache\r\n * @param key - Cache key\r\n * @param value - Value to cache\r\n */\r\n set(key: string, value: T): void {\r\n // Evict oldest if full\r\n if (this.items.size >= this.maxSize) {\r\n const firstKey = this.items.keys().next().value;\r\n if (firstKey) this.items.delete(firstKey);\r\n }\r\n\r\n const expiry = this.ttl === Infinity ? Infinity : Date.now() + this.ttl;\r\n this.items.set(key, { value, expiry });\r\n }\r\n\r\n /**\r\n * Check if item exists and is valid\r\n * @param key - Cache key\r\n */\r\n has(key: string): boolean {\r\n const item = this.items.get(key);\r\n if (!item) return false;\r\n if (Date.now() > item.expiry) {\r\n this.items.delete(key);\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Clear the cache\r\n */\r\n clear(): void {\r\n this.items.clear();\r\n }\r\n\r\n /**\r\n * Get current size\r\n */\r\n get size(): number {\r\n return this.items.size;\r\n }\r\n}\r\n\r\n/**\r\n * Global default cache instance\r\n */\r\nexport const defaultCache = new Cache({ maxSize: 1000, ttl: 60 * 60 * 1000 });\r\n","/**\r\n * Middleware Pattern for data processing and validation pipelines\r\n * Allows composition of multiple functions into a single executable pipeline.\r\n *\r\n * @packageDocumentation\r\n * @since 1.2.0\r\n */\r\n\r\n/**\r\n * Middleware function type\r\n * @param context - The context/data being processed\r\n * @param next - Function to call the next middleware\r\n */\r\nexport type Middleware<T = any> = (context: T, next: () => Promise<void> | void) => Promise<void> | void;\r\n\r\n/**\r\n * Pipeline class for managing middleware execution\r\n */\r\nexport class Pipeline<T = any> {\r\n private middlewares: Middleware<T>[] = [];\r\n\r\n /**\r\n * Add a middleware to the pipeline\r\n * @param middleware - Middleware function\r\n * @returns The pipeline instance for chaining\r\n */\r\n use(middleware: Middleware<T>): this {\r\n this.middlewares.push(middleware);\r\n return this;\r\n }\r\n\r\n /**\r\n * Execute the pipeline with the given context\r\n * @param context - Initial context data\r\n * @returns The processed context\r\n */\r\n async execute(context: T): Promise<T> {\r\n let index = -1;\r\n\r\n const dispatch = async (i: number): Promise<void> => {\r\n if (i <= index) throw new Error('next() called multiple times');\r\n index = i;\r\n\r\n const fn = this.middlewares[i];\r\n if (i === this.middlewares.length) return;\r\n\r\n if (!fn) return;\r\n\r\n await fn(context, () => dispatch(i + 1));\r\n };\r\n\r\n await dispatch(0);\r\n return context;\r\n }\r\n}\r\n\r\n/**\r\n * Compose multiple functions into a single function (L-to-R)\r\n * @param fns - Functions to compose\r\n * @returns Composed function\r\n */\r\nexport function compose<T>(...fns: Array<(arg: T) => T>): (arg: T) => T {\r\n return (arg: T) => fns.reduce((acc, fn) => fn(acc), arg);\r\n}\r\n\r\n/**\r\n * Async compose for Promise-returning functions\r\n * @param fns - Async functions to compose\r\n * @returns Composed async function\r\n */\r\nexport function composeAsync<T>(...fns: Array<(arg: T) => Promise<T> | T>): (arg: T) => Promise<T> {\r\n return async (arg: T) => {\r\n let result = arg;\r\n for (const fn of fns) {\r\n result = await fn(result);\r\n }\r\n return result;\r\n };\r\n}\r\n","/**\r\n * Standardized Error Handling Module\r\n * Provides a hierarchy of error classes for consistent error reporting.\r\n *\r\n * @packageDocumentation\r\n * @since 1.2.0\r\n */\r\n\r\n/**\r\n * Base error class for all utility errors\r\n */\r\nexport class UtilitifyError extends Error {\r\n public code: string;\r\n public details?: any;\r\n\r\n constructor(message: string, code: string = 'UNKNOWN_ERROR', details?: any) {\r\n super(message);\r\n this.name = 'UtilitifyError';\r\n this.code = code;\r\n this.details = details;\r\n Object.setPrototypeOf(this, new.target.prototype);\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when validation fails\r\n */\r\nexport class ValidationError extends UtilitifyError {\r\n constructor(message: string, details?: any) {\r\n super(message, 'VALIDATION_ERROR', details);\r\n this.name = 'ValidationError';\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when a security check fails\r\n */\r\nexport class SecurityError extends UtilitifyError {\r\n constructor(message: string, details?: any) {\r\n super(message, 'SECURITY_ERROR', details);\r\n this.name = 'SecurityError';\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when configuration is invalid\r\n */\r\nexport class ConfigurationError extends UtilitifyError {\r\n constructor(message: string, details?: any) {\r\n super(message, 'CONFIGURATION_ERROR', details);\r\n this.name = 'ConfigurationError';\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when an operation times out\r\n */\r\nexport class TimeoutError extends UtilitifyError {\r\n constructor(message: string = 'Operation timed out', details?: any) {\r\n super(message, 'TIMEOUT_ERROR', details);\r\n this.name = 'TimeoutError';\r\n }\r\n}\r\n\r\n/**\r\n * Helper to check if an error is a specific Utilitify error\r\n */\r\nexport function isUtilitifyError(error: unknown): error is UtilitifyError {\r\n return error instanceof UtilitifyError;\r\n}\r\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
export { B as BaseOptions, D as DeepPartial, I as IValidationError, O as OptionalKeys, a as PlainObject, P as Primitive, R as RequireKeys, V as ValidationResult } from './common-CBDYNJeh.cjs';
|
|
2
|
+
import { U as UserData, a as UserValidationOptions, b as UserValidationResult } from './index-BYsUCP3u.cjs';
|
|
3
|
+
export { Z as CardType, X as CreditCardOptions, Y as CreditCardValidationResult, E as EmailOptions, d as EmailValidationResult, aa as IbanOptions, a6 as IpOptions, a7 as IpValidationResult, N as NameOptions, c as NameValidationResult, P as PhoneOptions, e as PhoneValidationResult, J as UrlOptions, K as UrlValidationResult, f as UsernameOptions, g as UsernameValidationResult, ab as VatOptions, O as detectCardType, m as detectScript, T as formatCardNumber, o as formatName, t as formatPhone, Q as getCardTypeFromPrefix, j as getEmailDomain, a4 as getIpVersion, F as getUrlDomain, I as isDangerousUrl, H as isDataUrl, h as isDisposableEmail, D as isHttpsUrl, a3 as isLoopbackIp, a2 as isPrivateIp, y as isReservedUsername, V as isValidCVV, a5 as isValidCidr, M as isValidCreditCard, i as isValidEmail, W as isValidExpiry, a1 as isValidIP, $ as isValidIPv4, a0 as isValidIPv6, l as isValidName, r as isValidPhone, C as isValidUrl, x as isValidUsername, R as luhnCheck, S as maskCardNumber, n as normalizeEmail, G as normalizeUrl, u as parsePhone, s as sanitizeName, z as sanitizeUsername, p as splitName, A as suggestUsernames, L as validateCreditCard, v as validateEmail, a8 as validateIBAN, _ as validateIp, k as validateName, q as validatePhone, B as validateUrl, w as validateUsername, a9 as validateVAT } from './index-BYsUCP3u.cjs';
|
|
4
|
+
export { I as COUNTRIES, J as CURRENCIES, C as Country, b as CountryCodeFormat, a as CurrencyInfo, K as PHONE_FORMATS, P as PhoneFormat, T as TimezoneInfo, f as convertCountryCode, y as convertCurrency, p as convertTimeBetweenCountries, u as formatCurrency, q as formatTimeForCountry, G as formatWithDialingCode, h as getAllCountries, w as getAllCurrencies, D as getAllFlags, i as getCountriesByContinent, F as getCountriesByDialingCode, j as getCountriesByLanguage, e as getCountry, g as getCountryByAlpha2, c as getCountryByAlpha3, d as getCountryByNumeric, A as getCountryFromEmoji, r as getCurrency, t as getCurrencyByCountry, x as getCurrencySymbol, n as getCurrentTimeInCountry, m as getDefaultTimezone, E as getDialingCode, z as getFlagEmoji, L as getPhoneFormat, M as getSupportedPhoneCountries, o as getTimezoneOffset, l as getTimezonesByCountry, H as hasValidDialingCode, B as isFlagEmoji, k as isValidCountryCode, v as parseCurrency, s as searchCountries } from './index-Cl26FrAZ.cjs';
|
|
5
|
+
export { MaskOptions, PasswordOptions, SlugOptions, TruncateOptions, capitalize, ellipsis, generateBase64String, generateHexString, generateOTP, generatePassphrase, generatePassword, generateRandomString, generateUrlSafeString, isValidSlug, maskCreditCard, maskEmail, maskIP, maskName, maskPhone, maskString, needsTruncation, slugify, swapCase, toCamelCase, toConstantCase, toDotCase, toKebabCase, toPascalCase, toSentenceCase, toSlug, toSnakeCase, toTitleCase, transliterate, truncate, truncateFilename, truncateHtml, truncateSentences, truncateWords, uncapitalize, uniqueSlug } from './string/index.cjs';
|
|
6
|
+
export { AgeResult, DateFormatOptions, TimeDiff, addTime, calculateAge, diffIn, endOf, formatDate, formatDateByLocale, formatRelativeTime, getAgeBracket, getAgeInYears, getDaysInMonth, getMinAgeDOB, getTimeDiff, isAdult, isAgeInRange, isBetween, isInFuture, isInPast, isLeapYear, isMinor, isToday, isValidDate, isWeekday, isWeekend, parseDate, startOf, subtractTime, toISODate } from './date/index.cjs';
|
|
7
|
+
export { PasswordStrength, PasswordStrengthOptions, checkPasswordStrength, generateBase64Token, generateNanoId, generateSecureToken, generateShortId, generateToken, generateUUID, generateUUIDv7, generateUrlSafeToken, getPasswordFeedback, getUUIDv7Timestamp, hashBcrypt, hashMD5, hashSHA256, hashSHA512, hmacSHA256, isStrongPassword, isValidUUID, meetsRequirements, timingSafeCompare, verifyBcrypt } from './security/index.cjs';
|
|
8
|
+
export { FlattenOptions, MergeOptions, SanitizeOptions, cloneDeep, compact, compactDeep, deepMerge, deepMergeWith, escapeHtml, flattenObject, get, getAllKeys, invert, mapKeys, mapValues, omit, omitBy, pick, pickBy, removeControlChars, sanitizeObject, sanitizeString, sanitizeUrl, set, stripHtml, unescapeHtml, unflattenObject } from './transform/index.cjs';
|
|
9
|
+
export { ConditionalRule, ErrorMessages, createErrorMessages, errors, formatMessage, formatValidationResult, inRange, isEmpty, isPresent, matchesPattern, maxLength, minLength, mustMatch, oneOf, requireAllOrNone, requireOneOf, required, requiredIf, requiredUnless, validateConditional } from './form/index.cjs';
|
|
10
|
+
export { ClientInfo, EnvSchema, EnvValidationResult, detectClient, getEnv, getEnvBoolean, getEnvNumber, getRequiredEnv, getScreenSize, isBrowser, isDevelopment, isMobile, isNode, isProduction, isTest, isTouchDevice, prefersDarkMode, prefersReducedMotion, validateEnv } from './environment/index.cjs';
|
|
11
|
+
export { AsyncValidationOptions, AsyncValidationResult, AsyncValidator, composeValidators, createDebouncedValidator, validateAllAsync, validateAsync } from './async.cjs';
|
|
12
|
+
export { Locale, MessageTemplates, addLocale, getAvailableLocales, getLocale, getMessage, setCustomMessages, setLocale, withLocalization } from './i18n.cjs';
|
|
13
|
+
export { COMMON_PASSWORD_PATTERNS, CORPORATE_EMAIL_DOMAINS, DISPOSABLE_EMAIL_DOMAINS, FREE_EMAIL_DOMAINS, RESERVED_USERNAMES, addDisposableDomains, addFreeEmailDomains, addReservedUsernames } from './constants.cjs';
|
|
14
|
+
export { ParseResult, z } from './schema.cjs';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Validate user data with automatic field detection
|
|
18
|
+
*
|
|
19
|
+
* This is the unified validation function that validates all provided
|
|
20
|
+
* user fields and returns standardized errors.
|
|
21
|
+
*
|
|
22
|
+
* @param userData - User data to validate
|
|
23
|
+
* @param options - Validation options
|
|
24
|
+
* @returns Validation result with all errors
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { validateUser } from 'utilitify';
|
|
29
|
+
*
|
|
30
|
+
* const result = validateUser({
|
|
31
|
+
* name: 'John Doe',
|
|
32
|
+
* email: 'john@example.com',
|
|
33
|
+
* phone: '+1 555-123-4567',
|
|
34
|
+
* country: 'US',
|
|
35
|
+
* password: 'MyP@ssw0rd!'
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* if (!result.isValid) {
|
|
39
|
+
* console.log(result.errors);
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function validateUser(userData: UserData, options?: UserValidationOptions): UserValidationResult;
|
|
44
|
+
/**
|
|
45
|
+
* Quick validate - returns boolean only
|
|
46
|
+
*
|
|
47
|
+
* @param userData - User data to validate
|
|
48
|
+
* @param options - Validation options
|
|
49
|
+
* @returns true if all validations pass
|
|
50
|
+
*/
|
|
51
|
+
declare function isValidUser(userData: UserData, options?: UserValidationOptions): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Get validation errors as simple object
|
|
54
|
+
*
|
|
55
|
+
* @param userData - User data to validate
|
|
56
|
+
* @param options - Validation options
|
|
57
|
+
* @returns Object with field names as keys and array of error messages as values
|
|
58
|
+
*/
|
|
59
|
+
declare function getUserErrors(userData: UserData, options?: UserValidationOptions): Record<string, string[]>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Simple LRU (Least Recently Used) Cache implementation
|
|
63
|
+
* Used for caching expensive validation results or country data lookups.
|
|
64
|
+
*
|
|
65
|
+
* @packageDocumentation
|
|
66
|
+
* @since 1.2.0
|
|
67
|
+
*/
|
|
68
|
+
interface CacheOptions {
|
|
69
|
+
/** Maximum number of items to store (default: 100) */
|
|
70
|
+
maxSize?: number;
|
|
71
|
+
/** Time to live in milliseconds (default: Infinity) */
|
|
72
|
+
ttl?: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* LRU Cache class
|
|
76
|
+
*/
|
|
77
|
+
declare class Cache<T = any> {
|
|
78
|
+
private items;
|
|
79
|
+
private maxSize;
|
|
80
|
+
private ttl;
|
|
81
|
+
/**
|
|
82
|
+
* Create a new Cache instance
|
|
83
|
+
* @param options - Cache options
|
|
84
|
+
*/
|
|
85
|
+
constructor(options?: CacheOptions);
|
|
86
|
+
/**
|
|
87
|
+
* Get an item from the cache
|
|
88
|
+
* @param key - Cache key
|
|
89
|
+
* @returns Cached value or undefined
|
|
90
|
+
*/
|
|
91
|
+
get(key: string): T | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Set an item in the cache
|
|
94
|
+
* @param key - Cache key
|
|
95
|
+
* @param value - Value to cache
|
|
96
|
+
*/
|
|
97
|
+
set(key: string, value: T): void;
|
|
98
|
+
/**
|
|
99
|
+
* Check if item exists and is valid
|
|
100
|
+
* @param key - Cache key
|
|
101
|
+
*/
|
|
102
|
+
has(key: string): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Clear the cache
|
|
105
|
+
*/
|
|
106
|
+
clear(): void;
|
|
107
|
+
/**
|
|
108
|
+
* Get current size
|
|
109
|
+
*/
|
|
110
|
+
get size(): number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Global default cache instance
|
|
114
|
+
*/
|
|
115
|
+
declare const defaultCache: Cache<any>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Middleware Pattern for data processing and validation pipelines
|
|
119
|
+
* Allows composition of multiple functions into a single executable pipeline.
|
|
120
|
+
*
|
|
121
|
+
* @packageDocumentation
|
|
122
|
+
* @since 1.2.0
|
|
123
|
+
*/
|
|
124
|
+
/**
|
|
125
|
+
* Middleware function type
|
|
126
|
+
* @param context - The context/data being processed
|
|
127
|
+
* @param next - Function to call the next middleware
|
|
128
|
+
*/
|
|
129
|
+
type Middleware<T = any> = (context: T, next: () => Promise<void> | void) => Promise<void> | void;
|
|
130
|
+
/**
|
|
131
|
+
* Pipeline class for managing middleware execution
|
|
132
|
+
*/
|
|
133
|
+
declare class Pipeline<T = any> {
|
|
134
|
+
private middlewares;
|
|
135
|
+
/**
|
|
136
|
+
* Add a middleware to the pipeline
|
|
137
|
+
* @param middleware - Middleware function
|
|
138
|
+
* @returns The pipeline instance for chaining
|
|
139
|
+
*/
|
|
140
|
+
use(middleware: Middleware<T>): this;
|
|
141
|
+
/**
|
|
142
|
+
* Execute the pipeline with the given context
|
|
143
|
+
* @param context - Initial context data
|
|
144
|
+
* @returns The processed context
|
|
145
|
+
*/
|
|
146
|
+
execute(context: T): Promise<T>;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Compose multiple functions into a single function (L-to-R)
|
|
150
|
+
* @param fns - Functions to compose
|
|
151
|
+
* @returns Composed function
|
|
152
|
+
*/
|
|
153
|
+
declare function compose<T>(...fns: Array<(arg: T) => T>): (arg: T) => T;
|
|
154
|
+
/**
|
|
155
|
+
* Async compose for Promise-returning functions
|
|
156
|
+
* @param fns - Async functions to compose
|
|
157
|
+
* @returns Composed async function
|
|
158
|
+
*/
|
|
159
|
+
declare function composeAsync<T>(...fns: Array<(arg: T) => Promise<T> | T>): (arg: T) => Promise<T>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Standardized Error Handling Module
|
|
163
|
+
* Provides a hierarchy of error classes for consistent error reporting.
|
|
164
|
+
*
|
|
165
|
+
* @packageDocumentation
|
|
166
|
+
* @since 1.2.0
|
|
167
|
+
*/
|
|
168
|
+
/**
|
|
169
|
+
* Base error class for all utility errors
|
|
170
|
+
*/
|
|
171
|
+
declare class UtilitifyError extends Error {
|
|
172
|
+
code: string;
|
|
173
|
+
details?: any;
|
|
174
|
+
constructor(message: string, code?: string, details?: any);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Error thrown when validation fails
|
|
178
|
+
*/
|
|
179
|
+
declare class ValidationError extends UtilitifyError {
|
|
180
|
+
constructor(message: string, details?: any);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Error thrown when a security check fails
|
|
184
|
+
*/
|
|
185
|
+
declare class SecurityError extends UtilitifyError {
|
|
186
|
+
constructor(message: string, details?: any);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Error thrown when configuration is invalid
|
|
190
|
+
*/
|
|
191
|
+
declare class ConfigurationError extends UtilitifyError {
|
|
192
|
+
constructor(message: string, details?: any);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Error thrown when an operation times out
|
|
196
|
+
*/
|
|
197
|
+
declare class TimeoutError extends UtilitifyError {
|
|
198
|
+
constructor(message?: string, details?: any);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Helper to check if an error is a specific Utilitify error
|
|
202
|
+
*/
|
|
203
|
+
declare function isUtilitifyError(error: unknown): error is UtilitifyError;
|
|
204
|
+
|
|
205
|
+
export { Cache, type CacheOptions, ConfigurationError, type Middleware, Pipeline, SecurityError, TimeoutError, UserData, UserValidationOptions, UserValidationResult, UtilitifyError, ValidationError, compose, composeAsync, defaultCache, getUserErrors, isUtilitifyError, isValidUser, validateUser };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
export { B as BaseOptions, D as DeepPartial, I as IValidationError, O as OptionalKeys, a as PlainObject, P as Primitive, R as RequireKeys, V as ValidationResult } from './common-CBDYNJeh.js';
|
|
2
|
+
import { U as UserData, a as UserValidationOptions, b as UserValidationResult } from './index-BXBmBHyL.js';
|
|
3
|
+
export { Z as CardType, X as CreditCardOptions, Y as CreditCardValidationResult, E as EmailOptions, d as EmailValidationResult, aa as IbanOptions, a6 as IpOptions, a7 as IpValidationResult, N as NameOptions, c as NameValidationResult, P as PhoneOptions, e as PhoneValidationResult, J as UrlOptions, K as UrlValidationResult, f as UsernameOptions, g as UsernameValidationResult, ab as VatOptions, O as detectCardType, m as detectScript, T as formatCardNumber, o as formatName, t as formatPhone, Q as getCardTypeFromPrefix, j as getEmailDomain, a4 as getIpVersion, F as getUrlDomain, I as isDangerousUrl, H as isDataUrl, h as isDisposableEmail, D as isHttpsUrl, a3 as isLoopbackIp, a2 as isPrivateIp, y as isReservedUsername, V as isValidCVV, a5 as isValidCidr, M as isValidCreditCard, i as isValidEmail, W as isValidExpiry, a1 as isValidIP, $ as isValidIPv4, a0 as isValidIPv6, l as isValidName, r as isValidPhone, C as isValidUrl, x as isValidUsername, R as luhnCheck, S as maskCardNumber, n as normalizeEmail, G as normalizeUrl, u as parsePhone, s as sanitizeName, z as sanitizeUsername, p as splitName, A as suggestUsernames, L as validateCreditCard, v as validateEmail, a8 as validateIBAN, _ as validateIp, k as validateName, q as validatePhone, B as validateUrl, w as validateUsername, a9 as validateVAT } from './index-BXBmBHyL.js';
|
|
4
|
+
export { I as COUNTRIES, J as CURRENCIES, C as Country, b as CountryCodeFormat, a as CurrencyInfo, K as PHONE_FORMATS, P as PhoneFormat, T as TimezoneInfo, f as convertCountryCode, y as convertCurrency, p as convertTimeBetweenCountries, u as formatCurrency, q as formatTimeForCountry, G as formatWithDialingCode, h as getAllCountries, w as getAllCurrencies, D as getAllFlags, i as getCountriesByContinent, F as getCountriesByDialingCode, j as getCountriesByLanguage, e as getCountry, g as getCountryByAlpha2, c as getCountryByAlpha3, d as getCountryByNumeric, A as getCountryFromEmoji, r as getCurrency, t as getCurrencyByCountry, x as getCurrencySymbol, n as getCurrentTimeInCountry, m as getDefaultTimezone, E as getDialingCode, z as getFlagEmoji, L as getPhoneFormat, M as getSupportedPhoneCountries, o as getTimezoneOffset, l as getTimezonesByCountry, H as hasValidDialingCode, B as isFlagEmoji, k as isValidCountryCode, v as parseCurrency, s as searchCountries } from './index-Cl26FrAZ.js';
|
|
5
|
+
export { MaskOptions, PasswordOptions, SlugOptions, TruncateOptions, capitalize, ellipsis, generateBase64String, generateHexString, generateOTP, generatePassphrase, generatePassword, generateRandomString, generateUrlSafeString, isValidSlug, maskCreditCard, maskEmail, maskIP, maskName, maskPhone, maskString, needsTruncation, slugify, swapCase, toCamelCase, toConstantCase, toDotCase, toKebabCase, toPascalCase, toSentenceCase, toSlug, toSnakeCase, toTitleCase, transliterate, truncate, truncateFilename, truncateHtml, truncateSentences, truncateWords, uncapitalize, uniqueSlug } from './string/index.js';
|
|
6
|
+
export { AgeResult, DateFormatOptions, TimeDiff, addTime, calculateAge, diffIn, endOf, formatDate, formatDateByLocale, formatRelativeTime, getAgeBracket, getAgeInYears, getDaysInMonth, getMinAgeDOB, getTimeDiff, isAdult, isAgeInRange, isBetween, isInFuture, isInPast, isLeapYear, isMinor, isToday, isValidDate, isWeekday, isWeekend, parseDate, startOf, subtractTime, toISODate } from './date/index.js';
|
|
7
|
+
export { PasswordStrength, PasswordStrengthOptions, checkPasswordStrength, generateBase64Token, generateNanoId, generateSecureToken, generateShortId, generateToken, generateUUID, generateUUIDv7, generateUrlSafeToken, getPasswordFeedback, getUUIDv7Timestamp, hashBcrypt, hashMD5, hashSHA256, hashSHA512, hmacSHA256, isStrongPassword, isValidUUID, meetsRequirements, timingSafeCompare, verifyBcrypt } from './security/index.js';
|
|
8
|
+
export { FlattenOptions, MergeOptions, SanitizeOptions, cloneDeep, compact, compactDeep, deepMerge, deepMergeWith, escapeHtml, flattenObject, get, getAllKeys, invert, mapKeys, mapValues, omit, omitBy, pick, pickBy, removeControlChars, sanitizeObject, sanitizeString, sanitizeUrl, set, stripHtml, unescapeHtml, unflattenObject } from './transform/index.js';
|
|
9
|
+
export { ConditionalRule, ErrorMessages, createErrorMessages, errors, formatMessage, formatValidationResult, inRange, isEmpty, isPresent, matchesPattern, maxLength, minLength, mustMatch, oneOf, requireAllOrNone, requireOneOf, required, requiredIf, requiredUnless, validateConditional } from './form/index.js';
|
|
10
|
+
export { ClientInfo, EnvSchema, EnvValidationResult, detectClient, getEnv, getEnvBoolean, getEnvNumber, getRequiredEnv, getScreenSize, isBrowser, isDevelopment, isMobile, isNode, isProduction, isTest, isTouchDevice, prefersDarkMode, prefersReducedMotion, validateEnv } from './environment/index.js';
|
|
11
|
+
export { AsyncValidationOptions, AsyncValidationResult, AsyncValidator, composeValidators, createDebouncedValidator, validateAllAsync, validateAsync } from './async.js';
|
|
12
|
+
export { Locale, MessageTemplates, addLocale, getAvailableLocales, getLocale, getMessage, setCustomMessages, setLocale, withLocalization } from './i18n.js';
|
|
13
|
+
export { COMMON_PASSWORD_PATTERNS, CORPORATE_EMAIL_DOMAINS, DISPOSABLE_EMAIL_DOMAINS, FREE_EMAIL_DOMAINS, RESERVED_USERNAMES, addDisposableDomains, addFreeEmailDomains, addReservedUsernames } from './constants.js';
|
|
14
|
+
export { ParseResult, z } from './schema.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Validate user data with automatic field detection
|
|
18
|
+
*
|
|
19
|
+
* This is the unified validation function that validates all provided
|
|
20
|
+
* user fields and returns standardized errors.
|
|
21
|
+
*
|
|
22
|
+
* @param userData - User data to validate
|
|
23
|
+
* @param options - Validation options
|
|
24
|
+
* @returns Validation result with all errors
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { validateUser } from 'utilitify';
|
|
29
|
+
*
|
|
30
|
+
* const result = validateUser({
|
|
31
|
+
* name: 'John Doe',
|
|
32
|
+
* email: 'john@example.com',
|
|
33
|
+
* phone: '+1 555-123-4567',
|
|
34
|
+
* country: 'US',
|
|
35
|
+
* password: 'MyP@ssw0rd!'
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* if (!result.isValid) {
|
|
39
|
+
* console.log(result.errors);
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function validateUser(userData: UserData, options?: UserValidationOptions): UserValidationResult;
|
|
44
|
+
/**
|
|
45
|
+
* Quick validate - returns boolean only
|
|
46
|
+
*
|
|
47
|
+
* @param userData - User data to validate
|
|
48
|
+
* @param options - Validation options
|
|
49
|
+
* @returns true if all validations pass
|
|
50
|
+
*/
|
|
51
|
+
declare function isValidUser(userData: UserData, options?: UserValidationOptions): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Get validation errors as simple object
|
|
54
|
+
*
|
|
55
|
+
* @param userData - User data to validate
|
|
56
|
+
* @param options - Validation options
|
|
57
|
+
* @returns Object with field names as keys and array of error messages as values
|
|
58
|
+
*/
|
|
59
|
+
declare function getUserErrors(userData: UserData, options?: UserValidationOptions): Record<string, string[]>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Simple LRU (Least Recently Used) Cache implementation
|
|
63
|
+
* Used for caching expensive validation results or country data lookups.
|
|
64
|
+
*
|
|
65
|
+
* @packageDocumentation
|
|
66
|
+
* @since 1.2.0
|
|
67
|
+
*/
|
|
68
|
+
interface CacheOptions {
|
|
69
|
+
/** Maximum number of items to store (default: 100) */
|
|
70
|
+
maxSize?: number;
|
|
71
|
+
/** Time to live in milliseconds (default: Infinity) */
|
|
72
|
+
ttl?: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* LRU Cache class
|
|
76
|
+
*/
|
|
77
|
+
declare class Cache<T = any> {
|
|
78
|
+
private items;
|
|
79
|
+
private maxSize;
|
|
80
|
+
private ttl;
|
|
81
|
+
/**
|
|
82
|
+
* Create a new Cache instance
|
|
83
|
+
* @param options - Cache options
|
|
84
|
+
*/
|
|
85
|
+
constructor(options?: CacheOptions);
|
|
86
|
+
/**
|
|
87
|
+
* Get an item from the cache
|
|
88
|
+
* @param key - Cache key
|
|
89
|
+
* @returns Cached value or undefined
|
|
90
|
+
*/
|
|
91
|
+
get(key: string): T | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Set an item in the cache
|
|
94
|
+
* @param key - Cache key
|
|
95
|
+
* @param value - Value to cache
|
|
96
|
+
*/
|
|
97
|
+
set(key: string, value: T): void;
|
|
98
|
+
/**
|
|
99
|
+
* Check if item exists and is valid
|
|
100
|
+
* @param key - Cache key
|
|
101
|
+
*/
|
|
102
|
+
has(key: string): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Clear the cache
|
|
105
|
+
*/
|
|
106
|
+
clear(): void;
|
|
107
|
+
/**
|
|
108
|
+
* Get current size
|
|
109
|
+
*/
|
|
110
|
+
get size(): number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Global default cache instance
|
|
114
|
+
*/
|
|
115
|
+
declare const defaultCache: Cache<any>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Middleware Pattern for data processing and validation pipelines
|
|
119
|
+
* Allows composition of multiple functions into a single executable pipeline.
|
|
120
|
+
*
|
|
121
|
+
* @packageDocumentation
|
|
122
|
+
* @since 1.2.0
|
|
123
|
+
*/
|
|
124
|
+
/**
|
|
125
|
+
* Middleware function type
|
|
126
|
+
* @param context - The context/data being processed
|
|
127
|
+
* @param next - Function to call the next middleware
|
|
128
|
+
*/
|
|
129
|
+
type Middleware<T = any> = (context: T, next: () => Promise<void> | void) => Promise<void> | void;
|
|
130
|
+
/**
|
|
131
|
+
* Pipeline class for managing middleware execution
|
|
132
|
+
*/
|
|
133
|
+
declare class Pipeline<T = any> {
|
|
134
|
+
private middlewares;
|
|
135
|
+
/**
|
|
136
|
+
* Add a middleware to the pipeline
|
|
137
|
+
* @param middleware - Middleware function
|
|
138
|
+
* @returns The pipeline instance for chaining
|
|
139
|
+
*/
|
|
140
|
+
use(middleware: Middleware<T>): this;
|
|
141
|
+
/**
|
|
142
|
+
* Execute the pipeline with the given context
|
|
143
|
+
* @param context - Initial context data
|
|
144
|
+
* @returns The processed context
|
|
145
|
+
*/
|
|
146
|
+
execute(context: T): Promise<T>;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Compose multiple functions into a single function (L-to-R)
|
|
150
|
+
* @param fns - Functions to compose
|
|
151
|
+
* @returns Composed function
|
|
152
|
+
*/
|
|
153
|
+
declare function compose<T>(...fns: Array<(arg: T) => T>): (arg: T) => T;
|
|
154
|
+
/**
|
|
155
|
+
* Async compose for Promise-returning functions
|
|
156
|
+
* @param fns - Async functions to compose
|
|
157
|
+
* @returns Composed async function
|
|
158
|
+
*/
|
|
159
|
+
declare function composeAsync<T>(...fns: Array<(arg: T) => Promise<T> | T>): (arg: T) => Promise<T>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Standardized Error Handling Module
|
|
163
|
+
* Provides a hierarchy of error classes for consistent error reporting.
|
|
164
|
+
*
|
|
165
|
+
* @packageDocumentation
|
|
166
|
+
* @since 1.2.0
|
|
167
|
+
*/
|
|
168
|
+
/**
|
|
169
|
+
* Base error class for all utility errors
|
|
170
|
+
*/
|
|
171
|
+
declare class UtilitifyError extends Error {
|
|
172
|
+
code: string;
|
|
173
|
+
details?: any;
|
|
174
|
+
constructor(message: string, code?: string, details?: any);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Error thrown when validation fails
|
|
178
|
+
*/
|
|
179
|
+
declare class ValidationError extends UtilitifyError {
|
|
180
|
+
constructor(message: string, details?: any);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Error thrown when a security check fails
|
|
184
|
+
*/
|
|
185
|
+
declare class SecurityError extends UtilitifyError {
|
|
186
|
+
constructor(message: string, details?: any);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Error thrown when configuration is invalid
|
|
190
|
+
*/
|
|
191
|
+
declare class ConfigurationError extends UtilitifyError {
|
|
192
|
+
constructor(message: string, details?: any);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Error thrown when an operation times out
|
|
196
|
+
*/
|
|
197
|
+
declare class TimeoutError extends UtilitifyError {
|
|
198
|
+
constructor(message?: string, details?: any);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Helper to check if an error is a specific Utilitify error
|
|
202
|
+
*/
|
|
203
|
+
declare function isUtilitifyError(error: unknown): error is UtilitifyError;
|
|
204
|
+
|
|
205
|
+
export { Cache, type CacheOptions, ConfigurationError, type Middleware, Pipeline, SecurityError, TimeoutError, UserData, UserValidationOptions, UserValidationResult, UtilitifyError, ValidationError, compose, composeAsync, defaultCache, getUserErrors, isUtilitifyError, isValidUser, validateUser };
|