trade360-nodejs-sdk
Version:
LSports Trade360 SDK for Node.js
36 lines (35 loc) • 1.43 kB
TypeScript
import { BaseEntity } from '../entities/core-entities/index.js';
/**
* JSON parser that preserves large integers as strings in ID fields to prevent precision loss.
*
* Specifically targets field names that are exactly "id" (case-insensitive) and converts
* large numbers that exceed JavaScript's safe integer range to strings.
*/
export declare class IdSafeJsonParser {
private static readonly ID_FIELD_REGEX;
private static readonly SAFE_INTEGER_DIGIT_THRESHOLD;
private static readonly isLargeNumberSchema;
/**
* Core parsing logic that validates input, transforms large IDs, and parses JSON.
*
* @param jsonString The JSON string to process
* @returns Parsed object with large ID numbers preserved as strings
* @throws Error if input validation or JSON parsing fails
*/
private static parseInternal;
/**
* Primary parser method that preserves large numbers as strings for ID fields.
*
* @param jsonString The JSON string to parse
* @returns Parsed object with large ID numbers preserved as strings
* @throws Error with detailed error information if validation fails
*/
static parse<T extends BaseEntity>(jsonString: string): T;
/**
* Formats Zod errors into user-friendly messages.
*
* @param error The ZodError to format
* @returns Formatted error message string
*/
private static formatZodError;
}