/** * Copyright (c) 2026, Salesforce, Inc., * All rights reserved. * For full license text, see the LICENSE.txt file */ /** * FLS-safe field selection policy for the declarative MCP tools (W-22818723). * * Salesforce UIAPI hard-fails an ENTIRE GraphQL query when it selects a field * the running user lacks FLS for ("FieldUndefined … Field 'Gold__c'", data:{}). * The `@optional` directive is UIAPI's graceful-degradation mechanism: a field * marked `@optional` is silently omitted from the response instead of killing * the query. Proven at runtime against `Hero__c.Gold__c` in the W-22800643 QA. * * Decision (W-22818723): the declarative tools default to applying `@optional` * to every selected SObject field that FLS can actually gate, and select both * `value` and `displayValue` on value-wrapper fields wherever the wrapper * exposes a `displayValue`. There is no opt-in flag — degradation-by-default is * the safe behavior for an LLM driving queries across multi-user orgs where FLS * varies per user. Fields FLS can never hide (`Id`) are exempt — see * `FLS_EXEMPT_FIELDS`. * * This policy runs once on the assembled session inside `buildOutput` (the * shared finalizer for `buildList`/`buildDetail`/`buildAggregate`/ * `buildMutation`/`buildRaw`/`buildDelete`), so all six tools inherit it * uniformly. The interactive CLI does NOT route through `buildOutput`, so its * explicit `optional` verb keeps full manual control — this default is * MCP-surface-only. */ import { type GraphQLSchema } from "graphql"; import { type QuerySession } from "./session.js"; /** The UIAPI FLS-degradation directive name (matches the CLI `optional` verb). */ export declare const OPTIONAL_DIRECTIVE = "optional"; /** * Applies the global declarative-tool schema policies to a fully-assembled * session in place — both the FLS-safe `@optional` default and `displayValue` * selection on value wrappers: * - value-wrapper fields → `@optional` + `value` + `displayValue` (where exposed) * - bare record scalars → `@optional` (except `FLS_EXEMPT_FIELDS`, e.g. `Id`) * - structural plumbing → untouched (`pageInfo`, `edges`, `node`, cursors, * aggregate envelopes, the `value`/`displayValue` * leaves themselves) * * Unresolvable nodes are left as-is — the renderer/validator surfaces a clearer * error than this pass could. Never throws. */ export declare function applyGlobalSchemaPolicies(session: QuerySession, schema: GraphQLSchema): void;