UNPKG

@naturalcycles/scrubber-lib

Version:

Scrub data in JavaScript plain objects by using rules defined in a configuration object

126 lines (125 loc) 6.53 kB
import type { ScrubberFn, ScrubbersMap, ScrubberSQLFn, ScrubbersSQLMap } from './scrubber.model.js'; export type UndefinedScrubberFn = ScrubberFn<any, undefined>; export type UndefinedScrubberSQLFn = ScrubberSQLFn<undefined>; export declare const undefinedScrubber: UndefinedScrubberFn; export declare const undefinedScrubberSQL: UndefinedScrubberSQLFn; export type PreserveOriginalScrubberFn = ScrubberFn<any, undefined>; export type PreserveOriginalScrubberSQLFn = ScrubberSQLFn<undefined>; export declare const preserveOriginalScrubber: PreserveOriginalScrubberFn; export declare const preserveOriginalScrubberSQL: PreserveOriginalScrubberSQLFn; export interface StaticScrubberParams { /** * Only scrub if value matches given Regex */ ifMatch?: string; replacement: string | number; } export type StaticScrubberFn = ScrubberFn<any, StaticScrubberParams>; export type StaticScrubberSQLFn = ScrubberSQLFn<StaticScrubberParams>; export declare const staticScrubber: StaticScrubberFn; export declare const staticScrubberSQL: StaticScrubberSQLFn; export interface ISODateStringScrubberParams { excludeDay?: boolean; excludeMonth?: boolean; excludeYear?: boolean; } export type ISODateStringScrubberFn = ScrubberFn<string | undefined, ISODateStringScrubberParams>; export type ISODateStringScrubberSQLFn = ScrubberSQLFn<ISODateStringScrubberParams>; export declare const isoDateStringScrubber: ISODateStringScrubberFn; export declare const isoDateStringScrubberSQL: ISODateStringScrubberSQLFn; export interface UnixTimestampScrubberParams { excludeTime?: boolean; excludeDay?: boolean; excludeMonth?: boolean; excludeYear?: boolean; } export type UnixTimestampScrubberFn = ScrubberFn<number | string | undefined, UnixTimestampScrubberParams>; export type UnixTimestampScrubberSQLFn = ScrubberSQLFn<UnixTimestampScrubberParams>; export declare const unixTimestampScrubber: UnixTimestampScrubberFn; export declare const unixTimestampScrubberSQL: UnixTimestampScrubberSQLFn; export interface CharsFromRightScrubberParams { count: number; replacement: string; /** * Should replacement be for "full" replacement? default is false, each replaced char will be replaced with replacement. */ replaceFull?: boolean; } export type CharsFromRightScrubberFn = ScrubberFn<string | undefined, CharsFromRightScrubberParams>; export type CharsFromRightScrubberSQLFn = ScrubberSQLFn<CharsFromRightScrubberParams>; export declare const charsFromRightScrubber: CharsFromRightScrubberFn; export declare const charsFromRightScrubberSQL: CharsFromRightScrubberSQLFn; export interface KeepCharsFromLeftScrubberParams { count: number; replacement: string; /** * Should replacement be for "full" replacement? default is false, each replaced char will be replaced with replacement. */ replaceFull?: boolean; } export type KeepCharsFromLeftScrubberFn = ScrubberFn<string | undefined, KeepCharsFromLeftScrubberParams>; export type KeepCharsFromLeftScrubberSQLFn = ScrubberSQLFn<KeepCharsFromLeftScrubberParams>; export declare const keepCharsFromLeftScrubber: KeepCharsFromLeftScrubberFn; export declare const keepCharsFromLeftScrubberSQL: KeepCharsFromLeftScrubberSQLFn; export interface RandomScrubberParams { alphabet?: string; length?: number; } export type RandomScrubberFn = ScrubberFn<string, RandomScrubberParams>; export type RandomScrubberSQLFn = ScrubberSQLFn<RandomScrubberParams>; export declare const randomScrubber: RandomScrubberFn; export declare const randomScrubberSQL: RandomScrubberSQLFn; export interface RandomEmailScrubberParams { alphabet?: string; length?: number; domain?: string; } export type RandomEmailScrubberFn = ScrubberFn<string, RandomEmailScrubberParams>; export type RandomEmailScrubberSQLFn = ScrubberSQLFn<RandomEmailScrubberParams>; export declare const randomEmailScrubber: RandomEmailScrubberFn; export declare const randomEmailScrubberSQL: RandomEmailScrubberSQLFn; export interface RandomEmailInContentScrubberParams { alphabet?: string; length?: number; domain?: string; } export type RandomEmailInContentScrubberFn = ScrubberFn<string, RandomEmailInContentScrubberParams>; export type RandomEmailInContentScrubberSQLFn = ScrubberSQLFn<RandomEmailInContentScrubberParams>; export declare const randomEmailInContentScrubber: RandomEmailInContentScrubberFn; export declare const randomEmailInContentScrubberSQL: RandomEmailInContentScrubberSQLFn; export interface SaltedHashScrubberParams { initializationVector: string; } export type SaltedHashScrubberFn = ScrubberFn<string, SaltedHashScrubberParams>; export type SaltedHashScrubberSQLFn = ScrubberSQLFn<SaltedHashScrubberParams>; export declare const saltedHashScrubber: SaltedHashScrubberFn; export declare const saltedHashScrubberSQL: SaltedHashScrubberSQLFn; export interface SaltedHashEmailScrubberParams { initializationVector: string; domain?: string; } export type SaltedHashEmailScrubberFn = ScrubberFn<string, SaltedHashEmailScrubberParams>; export type SaltedHashEmailScrubberSQLFn = ScrubberSQLFn<SaltedHashEmailScrubberParams>; export declare const saltedHashEmailScrubber: SaltedHashEmailScrubberFn; export declare const saltedHashEmailScrubberSQL: SaltedHashEmailScrubberSQLFn; export type BcryptStringScrubberFn = ScrubberFn<string | undefined, BcryptStringScrubberParams>; export type BcryptStringScrubberSQLFn = ScrubberSQLFn<BcryptStringScrubberParams>; export interface BcryptStringScrubberParams { replacements: string; } export declare const bcryptStringScrubber: BcryptStringScrubberFn; export declare const bcryptStringScrubberSQL: BcryptStringScrubberSQLFn; export type SaltedHashSubstringScrubberFn = ScrubberFn<string | undefined, SaltedHashSubstringScrubberParams>; export type SaltedHashSubstringScrubberSQLFn = ScrubberSQLFn<SaltedHashSubstringScrubberParams>; export interface SaltedHashSubstringScrubberParams { initializationVector: string; regex: string; } export declare const saltedHashSubstringScrubber: SaltedHashSubstringScrubberFn; export declare const saltedHashSubstringScrubberSQL: SaltedHashSubstringScrubberSQLFn; export type ZipScrubberFn = ScrubberFn<string | undefined, undefined>; export type ZipScrubberSQLFn = ScrubberSQLFn<undefined>; export declare const zipScrubber: ZipScrubberFn; export declare const zipScrubberSQL: ZipScrubberSQLFn; export declare const defaultScrubbers: ScrubbersMap; export declare const defaultScrubbersSQL: ScrubbersSQLMap;