Utility functions for AIGNE AFS modules
npm install @aigne/afs-utilsUtility functions for AIGNE AFS modules.
This package provides shared utility functions used across AIGNE AFS modules, including:
- Type utilities: Type checking, validation, and manipulation helpers
- Schema utilities: Zod schema helpers for validation and transformation
- Camelize utilities: Object key transformation between camelCase and snake_case
``bash`
npm install @aigne/afs-utils
- Type checking and validation - Runtime type checking utilities
- Zod schema parsing - Parse and validate with human-readable error messages
- Synchronous and asynchronous validation support
- Optional error message prefix for better context
- Customizable error message formatting
- Object key transformation - Convert between camelCase and snake_case
- Shallow and deep conversion modes
- Zod schema preprocessing support
- isNil(value) - Check if value is null or undefinedisRecord(value)
- - Check if value is a plain objectisEmpty(obj)
- - Check if object/array/string is emptyisNonNullable(value)
- - Type guard for non-nullable valuesget(obj, path)
- - Safe nested property access
- zodParse(schema, data, options?) - Parse and validate data with Zod schema and human-readable error messagesoptions.prefix
- - Optional prefix for error messagesoptions.prefixSeparator
- - Separator between prefix and error message (default: ": ")options.async
- - Use async parsing with parseAsync for async refinements (default: false)optionalize(schema)
- - Make Zod schema optionalcamelizeSchema(schema, options)
- - Transform object keys to camelCasepreprocessSchema(fn, schema)
- - Apply preprocessing to schema
- camelize(obj, shallow?) - Convert object keys to camelCasesnakelize(obj, shallow?)` - Convert object keys to snake_case
-
Elastic-2.0