@accounter/server
Version:
Accounter GraphQL server
42 lines (41 loc) • 1.56 kB
TypeScript
/**
* Key generator utility for generating unique identifiers
* Used for fields 1004, 1103, and 1153 which require randomly generated unique IDs
*/
/**
* Generates a random numeric string of specified length
* @param length - The length of the numeric string to generate (max 15 digits)
* @returns A random numeric string padded with leading zeros if necessary
*/
export declare function generateRandomKey(length?: number): string;
/**
* Generates a primary identifier for fields 1004, 1103, and 1153
* These fields must have the same value across all records in a single file
* @returns A 15-digit numeric string
*/
export declare function generatePrimaryIdentifier(): string;
/**
* Key generator context to maintain consistent IDs across records
* This ensures that fields 1004, 1103, and 1153 use the same value within a single file
*/
export declare class KeyGeneratorContext {
private _primaryIdentifier;
/**
* Gets or generates the primary identifier for this context
* Ensures the same ID is used across all records that require it
*/
getPrimaryIdentifier(): string;
/**
* Resets the context, generating new IDs for the next file
*/
reset(): void;
/**
* Sets a specific primary identifier (useful for testing or when you have a specific ID requirement)
*/
setPrimaryIdentifier(id: string): void;
}
/**
* Default key generator context instance
* Use this for most cases to ensure consistency across records
*/
export declare const defaultKeyGenerator: KeyGeneratorContext;