import type { OrgAuth } from "../auth/sf-auth.ts"; /** * Tooling API client, scoped to exactly what the validation-rule * toggle feature needs. * * We deliberately do NOT extend DescribeClient — that one is for the * regular `/sobjects/*` REST surface, and mixing the tooling endpoints * into it would blur the caching model. This client is stateless. * * Endpoints (relative to `instanceUrl`): * GET /services/data/v/tooling/query?q= * PATCH /services/data/v/tooling/sobjects/ValidationRule/ * * Why the Metadata blob round-trip: * `ValidationRule.Active` is read-only on the plain `sobjects/` surface. * The mutable state lives in the `Metadata` field (a JSON blob with * `active`, `errorConditionFormula`, `errorMessage`, `description`). * To flip a rule off we PATCH the SAME metadata blob with `active: false` * — preserving every other field so reactivation is byte-equivalent. */ export type ValidationRuleRecord = { /** Tooling-API record ID (03d…). */ id: string; /** Short developer name, e.g. `SSN_Must_Be_9_Digits`. */ validationName: string; /** Object the rule runs on, e.g. `Contact` or `MyCustom__c`. */ entityApiName: string; /** Fully-qualified name, e.g. `Contact.SSN_Must_Be_9_Digits`. */ fullName: string; /** Was the rule active at snapshot time? We only ever snapshot `true`. */ active: boolean; /** Opaque metadata blob — we round-trip this untouched except for `active`. */ metadata: Record; }; /** * Query every validation rule on the given objects that is currently * active in `auth`'s org. Rules on objects we don't seed are not returned. * * Two-phase because Salesforce Tooling API refuses SOQL results with * `Metadata` or `FullName` selected when there's more than one row — * it fails with `MALFORMED_QUERY: "the query qualifications must * specify no more than one row for retrieval"`. So: * * 1. Filter query — pulls `Id, ValidationName, Active, * EntityDefinition.QualifiedApiName` (no Metadata/FullName). This * returns N rows fine. * 2. Per-ID detail GET — `/tooling/sobjects/ValidationRule/` * returns the full record including `FullName` and the `Metadata` * blob. One GET per rule. Done sequentially; Salesforce rate-limits * parallel describes and we're already I/O-bound during run. */ export declare function queryActiveValidationRules(opts: { auth: OrgAuth; objects: string[]; fetchFn?: typeof fetch; }): Promise; /** * PATCH a validation rule's Metadata blob, toggling `active`. The rest of * the blob is preserved byte-for-byte from the snapshot — so reactivation * restores the exact prior state. */ export declare function setValidationRuleActive(opts: { auth: OrgAuth; rule: ValidationRuleRecord; active: boolean; fetchFn?: typeof fetch; }): Promise;