import type { DependencyGraph } from "../graph/build.ts"; /** * Split walked parents + children into two user-facing buckets: * * WILL need — relationship-required. Master-detail or non-nillable * lookups whose target must be seeded for the child to * insert. Transitively closed: if A needs B, and B needs C, * then C is also mustInclude. * * MAYBE — user-optional. Nillable lookups on the root or in the * transitive parent chain, plus every 1-level child of the * root. The user decides whether to include these. * * Standard-root objects (User, RecordType, Profile, …) never appear in * either list. They're referenced by External ID / DeveloperName at * insert time, never seeded. * * The seeding root itself is always implicitly included and does not * appear in either bucket. * * Noise filtering — on real enterprise orgs, a raw 1-hop walk surfaces * hundreds of objects the user almost never wants to seed: * * - Managed-package objects (`APXTConga4__Contract__c`, `hed__Account__c`, * `smagicinteract__*`). Detected by the `__` pattern. * Hidden unless `includeManagedPackages: true`. * - System-automation children (`FeedComment`, `AgentWork`, * `FlowRecordRelation`, `ProcessInstance`, `NetworkActivity`, * `EntitySubscription`, `*History`, `*ChangeEvent`, `*Share`, `*Feed`, * `*Tag`, etc.). Detected by a curated pattern list. Hidden unless * `includeSystemChildren: true`. * * Filtering is a UX decision; these objects remain in the underlying graph * so the user can still opt them in explicitly via `select` — the hidden * names are returned in `hiddenManagedParents` / `hiddenSystemChildren` * counts so the agent can surface "N managed-package parents hidden". */ /** * Per-object hint that the optional object will silently drop records at * run time unless the FK target is also included in the seed. * * Generated when an optional parent/child has a required (master-detail * OR non-nillable) FK whose target is not already in `mustIncludeParents`. * `requiresStatus` tells the caller whether the target is at least * reachable as an optional (the user can add it via `select`) or absent * from this analyze pass entirely (deeper walk required). */ export type OptionalParentWarning = { /** The optional object whose required FK is unresolved. */ object: string; /** API name of the required reference field on `object`. */ fkField: string; /** * Object that `fkField` points to. For a polymorphic FK this is a * *representative* target (an in-scope optional object when one exists, * else the first alphabetically) — the FK needs any ONE of its targets, * and `requiresAnyOfCount` reports how many it can choose from. */ requiresObject: string; /** `optional` → user can add via `includeOptionalParents` on select. */ requiresStatus: "optional" | "missing"; /** * Present only when `fkField` is polymorphic (>1 possible target object). * The FK is satisfied by any single one of them, so this warning is * collapsed to one row regardless of how many objects the FK can address — * without this, a field like `Attachment.ParentId` (hundreds of targets) * would emit hundreds of warnings and blow the agent's context window. */ requiresAnyOfCount?: number; }; export type SeedClassification = { root: string; mustIncludeParents: string[]; optionalParents: string[]; optionalChildren: string[]; /** Objects referenced by the graph but unseedable (standard roots). */ standardRoots: string[]; /** Counts of objects hidden by noise filters (surfaced in analyze guidance). */ hiddenManagedParentCount: number; hiddenManagedChildCount: number; hiddenSystemChildCount: number; /** Present when the user explicitly opted in — the full name list. */ hiddenManagedParentNames?: string[]; hiddenManagedChildNames?: string[]; hiddenSystemChildNames?: string[]; /** * Per-object warnings: optional parents/children that carry a required * FK to an object the user hasn't necessarily picked. If left * unresolved, those records skip silently at run time. The agent (or * user) should add `requiresObject` to `includeOptionalParents` on * `select` when `requiresStatus === "optional"`, or rework the scope * when `requiresStatus === "missing"`. */ optionalParentWarnings: OptionalParentWarning[]; }; export type ClassifyInput = { graph: DependencyGraph; rootObject: string; parentObjects: Set | string[]; childObjects: Set | string[]; /** Include managed-package parents/children in the output. Default false. */ includeManagedPackages?: boolean; /** Include system-automation children (Feed*, *History, …). Default false. */ includeSystemChildren?: boolean; }; /** * Detect managed-package API names. Salesforce namespaces the API name as * `__` for managed objects. `__c` on its own is a * local custom object; `__` or `____c` is managed. */ export declare function isManagedPackageObject(name: string): boolean; export declare function isSystemChildObject(name: string): boolean; export declare function classifyForSeed(input: ClassifyInput): SeedClassification;