@adguard/agtree
Version:
Tool set for working with adblock filter lists
125 lines (124 loc) • 5.43 kB
TypeScript
/**
* @file Base compatibility data schema, which is commonly used in compatibility tables.
*/
import zod from 'zod';
/**
* Zod schema for boolean values. Accepts both boolean and string values.
*/
export declare const booleanSchema: zod.ZodUnion<[zod.ZodEffects<zod.ZodString, boolean, string>, zod.ZodBoolean]>;
/**
* Zod schema for non-empty string values.
*/
export declare const nonEmptyStringSchema: zod.ZodPipeline<zod.ZodEffects<zod.ZodString, string, string>, zod.ZodString>;
/**
* Zod schema for base compatibility data.
* Here we use snake_case properties because the compatibility data is stored in YAML files.
*/
export declare const baseCompatibilityDataSchema: zod.ZodObject<{
/**
* Name of the actual entity.
*/
name: zod.ZodPipeline<zod.ZodEffects<zod.ZodString, string, string>, zod.ZodString>;
/**
* List of aliases for the entity (if any).
*/
aliases: zod.ZodDefault<zod.ZodNullable<zod.ZodArray<zod.ZodPipeline<zod.ZodEffects<zod.ZodString, string, string>, zod.ZodString>, "many">>>;
/**
* Short description of the actual entity.
* If not specified or it's value is `null`, then the description is not available.
*/
description: zod.ZodDefault<zod.ZodNullable<zod.ZodPipeline<zod.ZodEffects<zod.ZodString, string, string>, zod.ZodString>>>;
/**
* Link to the documentation. If not specified or it's value is `null`, then the documentation is not available.
*/
docs: zod.ZodDefault<zod.ZodNullable<zod.ZodPipeline<zod.ZodEffects<zod.ZodString, string, string>, zod.ZodString>>>;
/**
* The version of the adblocker in which the entity was added.
* For AdGuard resources, the version of the library is specified.
*/
version_added: zod.ZodDefault<zod.ZodNullable<zod.ZodPipeline<zod.ZodEffects<zod.ZodString, string, string>, zod.ZodString>>>;
/**
* The version of the adblocker when the entity was removed.
*/
version_removed: zod.ZodDefault<zod.ZodNullable<zod.ZodPipeline<zod.ZodEffects<zod.ZodString, string, string>, zod.ZodString>>>;
/**
* Describes whether the entity is deprecated.
*/
deprecated: zod.ZodDefault<zod.ZodUnion<[zod.ZodEffects<zod.ZodString, boolean, string>, zod.ZodBoolean]>>;
/**
* Message that describes why the entity is deprecated.
* If not specified or it's value is `null`, then the message is not available.
* It's value is omitted if the entity is not marked as deprecated.
*/
deprecation_message: zod.ZodDefault<zod.ZodNullable<zod.ZodPipeline<zod.ZodEffects<zod.ZodString, string, string>, zod.ZodString>>>;
/**
* Describes whether the entity is removed; for *already removed* features.
*/
removed: zod.ZodDefault<zod.ZodUnion<[zod.ZodEffects<zod.ZodString, boolean, string>, zod.ZodBoolean]>>;
/**
* Message that describes why the entity is removed.
* If not specified or it's value is `null`, then the message is not available.
* It's value is omitted if the entity is not marked as deprecated.
*/
removal_message: zod.ZodDefault<zod.ZodNullable<zod.ZodPipeline<zod.ZodEffects<zod.ZodString, string, string>, zod.ZodString>>>;
}, "strip", zod.ZodTypeAny, {
name: string;
description: string | null;
aliases: string[] | null;
docs: string | null;
version_added: string | null;
version_removed: string | null;
deprecated: boolean;
deprecation_message: string | null;
removed: boolean;
removal_message: string | null;
}, {
name: string;
description?: string | null | undefined;
aliases?: string[] | null | undefined;
docs?: string | null | undefined;
version_added?: string | null | undefined;
version_removed?: string | null | undefined;
deprecated?: string | boolean | undefined;
deprecation_message?: string | null | undefined;
removed?: string | boolean | undefined;
removal_message?: string | null | undefined;
}>;
/**
* Zod schema for base compatibility data with camelCase properties.
*/
export declare const baseCompatibilityDataSchemaCamelCase: zod.ZodEffects<zod.ZodTypeAny, {
name: string;
description: string | null;
aliases: string[] | null;
docs: string | null;
versionAdded: string | null;
versionRemoved: string | null;
deprecated: boolean;
deprecationMessage: string | null;
removed: boolean;
removalMessage: string | null;
}, any>;
/**
* Type of the base compatibility data schema.
*/
export type BaseCompatibilityDataSchema = zod.infer<typeof baseCompatibilityDataSchemaCamelCase>;
/**
* Refinement logic for base compatibility data.
*
* @param data Base compatibility data.
* @param ctx Refinement context.
*/
export declare const baseRefineLogic: (data: zod.infer<typeof baseCompatibilityDataSchema>, ctx: zod.RefinementCtx) => void;
/**
* Creates a base file schema.
*
* @param dataSchema Data schema.
*
* @returns Base file schema.
*/
export declare const baseFileSchema: <T extends BaseCompatibilityDataSchema>(dataSchema: zod.ZodType<T>) => zod.ZodPipeline<zod.ZodEffects<zod.ZodRecord<zod.ZodAny, zod.ZodAny>, Record<any, any>, Record<any, any>>, zod.ZodRecord<zod.ZodEffects<zod.ZodString, number, string>, zod.ZodType<T, zod.ZodTypeDef, T>>>;
/**
* Type of the base file schema.
*/
export type BaseFileSchema<T extends BaseCompatibilityDataSchema> = zod.infer<ReturnType<typeof baseFileSchema<T>>>;