import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; import type { OriginationRule, RuleCondition } from "@repositories/customers/originations/OriginationsTypes.js"; import { ToolBase } from "../../../shared/index.js"; import { z } from "zod"; declare const leafConditionSchema: z.ZodObject<{ identifier: z.ZodString; operator: z.ZodEnum<{ contains: "contains"; eq: "eq"; neq: "neq"; gt: "gt"; gte: "gte"; lt: "lt"; lte: "lte"; not_contains: "not_contains"; }>; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>; declare const paramsSchema: z.ZodObject<{ realmUid: z.ZodString; originationUid: z.ZodString; rules: z.ZodArray; action: z.ZodEnum<{ show: "show"; hide: "hide"; }>; }, z.core.$strip>; conditions: z.ZodUnion; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ and: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ and: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>]>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ and: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>]>>; }, z.core.$strip>]>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ and: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ and: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>]>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ and: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>]>>; }, z.core.$strip>]>>; }, z.core.$strip>]>; }, z.core.$strip>>; strategy: z.ZodDefault>; }, z.core.$strip>; export type ParamsSchema = z.infer; type LeafInput = z.infer; /** Árbol de condiciones de la entrada: hoja o grupo `and`/`or`, a cualquier nivel. */ export type ConditionTree = LeafInput | { and: ConditionTree[]; } | { or: ConditionTree[]; }; /** * La API admin solo persiste `conditions` como un AND de grupos OR: * `{ and: [ { or: [hoja, …] }, … ] }`, con exactamente esos dos niveles. * Cualquier otro nodo (una hoja directa bajo `and`, una raíz `or`, un grupo * más profundo) lo guarda como `{}` con 200 y la regla se dispara siempre * (#140, medido en `testazure` el 2026-10-25). */ export type PersistedConditions = { and: Array<{ or: RuleCondition[]; }>; }; /** * Tope de grupos OR por regla tras la traducción. Distribuir un `and` que * cuelga de un `or` multiplica los grupos, y el schema no acota el largo de * los arreglos. */ export declare const MAX_CONDITION_GROUPS = 64; /** * Cuántos grupos OR produce `toAndOfOr` para el árbol, sin construirlos: así * el tope se comprueba antes de materializar un producto enorme. */ export declare function countConditionGroups(node: ConditionTree): number; /** * Traduce el árbol de la entrada a la forma que persiste la API, sin cambiar * su significado lógico: * - una hoja es un grupo de una hoja; * - `and` concatena los grupos de sus hijos; * - `or` distribuye: cada grupo resultante une un grupo de cada hijo. * * Dentro de un grupo se quitan las hojas repetidas (mismo `id`, `operator` y * `operand`), lo que no cambia el resultado del OR. */ export declare function toAndOfOr(root: ConditionTree, resolveLeaf: (leaf: LeafInput) => RuleCondition): PersistedConditions; /** * Post-condición (epic #209): compara las reglas enviadas con las releídas, * en el mismo orden. Por regla: el target completo (`id`, `type`, `action`) * y las condiciones grupo por grupo, con las hojas de cada grupo `or` * (`id`, `operator`, `operand`) en orden. Devuelve una línea por regla perdida. */ export declare function checkPersistedRules(sent: OriginationRule[], persisted: OriginationRule[]): string[]; declare class RulesManageTool extends ToolBase { protected config: { name: string; description: string; annotations: { title: string; readOnlyHint: boolean; idempotentHint: boolean; destructiveHint: boolean; }; }; protected getParamsSchema(): z.ZodObject<{ realmUid: z.ZodString; originationUid: z.ZodString; rules: z.ZodArray; action: z.ZodEnum<{ show: "show"; hide: "hide"; }>; }, z.core.$strip>; conditions: z.ZodUnion; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ and: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ and: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>]>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ and: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>]>>; }, z.core.$strip>]>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ and: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ and: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>]>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ and: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>, z.ZodObject<{ or: z.ZodArray; operand: z.ZodUnion; subtype: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>]>>; }, z.core.$strip>]>>; }, z.core.$strip>]>; }, z.core.$strip>>; strategy: z.ZodDefault>; }, z.core.$strip>; protected getOutputSchema(): z.ZodObject<{ originationId: z.ZodOptional; originationUid: z.ZodOptional; rulesCount: z.ZodOptional; strategy: z.ZodOptional; rules: z.ZodOptional>>; }, z.core.$strip>; protected execute(params: ParamsSchema): Promise; /** * Resolve a rule's identifiers to UUIDs */ private resolveRule; /** * Hoja con la forma que guarda la consola: `subtype` es el tipo real de la * pregunta, `operand` el `uuid` de la alternativa si la pregunta las tiene, * y `operand_key` va en `null`. */ private resolveLeaf; } export declare const RulesManage: RulesManageTool; export {}; //# sourceMappingURL=RulesManage.d.ts.map