import { type Logger, NowConfig } from '@servicenow/sdk-build-core'; import { type IConnector, type UnloadedRecord } from '../../connector'; import { Project } from '../../project'; type TableFetch = { table: string; ids: string[]; field?: string; }; type ScopedRecordsFetch = Map; export declare class ApplicationDependencies { private readonly project; private readonly connector; constructor(project: Project, connector: IConnector); /** * Normalizes the dependencies config from old format to new flat format. * Old format: { "applications": { "scope": { "tables": [...] } } } * New format: { "scope": { "tables": [...], "roles": [...] } } */ private static normalizeDependencies; /** * Converts the configuration object to a scope-based map of dependencies. * @param config The configuration object containing dependencies. * @param logger Logger for deprecation warnings. * @returns A Map of scope -> TableFetch[] to be fetched from the ServiceNow instance. */ static configurationToScopedFetch(config: NonNullable, logger?: Logger): ScopedRecordsFetch; /** * Adds only script type definitions (glide.*.d.ts) to the project */ addScriptDefinitions(): Promise; /** * Adds only fluent types from now.config.json dependencies to the project */ addFluentTypes(): Promise; /** * Adds the application dependencies defined in now.config.json to the current project * @deprecated Use addScriptDefinitions() and addFluentTypes() for granular control */ addToProject(): Promise; /** * Adds new dependency items and updates now.config.json * Uses transactional approach: fetch → generate → update config * This ensures config only reflects successfully installed dependencies */ addDependencyItems(table: string, ids: string[], scope: string): Promise; private updateConfigWithNewDependencies; /** * Gets the config key for a table (e.g., 'tables', 'roles', 'automation.actions') */ private getConfigKey; private buildScopedFetchForTable; /** * Fetches all record IDs from a specific scope with table-specific filters */ private fetchRecordIdsByScope; /** * Fetches records from ServiceNow and transforms them to TypeScript files. * Processes by scope (matching now.config.json structure) for cleaner organization. */ fetchScopedRecordsToProject(scopedRecords: ScopedRecordsFetch, transformOptions?: { saveToPath?: string; format?: boolean; }): Promise<{ success: false; error: Error; generatedFiles: string[]; } | { success: true; generatedFiles: string[]; }>; /** * Generates now.config.json for a scope directory */ private generateScopeConfig; /** * Generates tsconfig.json in the @types directory to suppress ambient context errors * for generated .d.now.ts files. Only creates if it doesn't already exist. */ private generateTypesTsConfig; /** * Fetches scope sys_ids for multiple scopes using getScopeInfo * @param scopes Array of scope names to look up * @returns Map of scope name to sys_id */ private fetchScopeSysIds; /** * Fetches related records for one or more table/sysId pairs. * Chunks into batches, deduplicates graphs, and runs concurrently. * Falls back to per-record fetching if the instance does not support the batch format. */ fetchRelatedRecords(input: { table: string; sysId: string; } | Array<{ table: string; sysId: string; }>, options?: { batchSize?: number; scopeId?: string; }): Promise; /** * Builds a batch request with deduplicated graphs. * Groups sysIds by table and assigns shared graph IDs to structurally identical graphs. */ private buildBatchUnloadRequest; private queryRecords; /** * Fetches sys_ids for multiple records by field values using a single unload API call * @returns Map of field value to sys_id */ private fetchSysIdsByField; /** * Fetches record XML from ServiceNow using unload API */ private fetchRecordXml; /** * Fallback: Fetches a record and its relationships using unload API when unloadDependentRecords is not available */ private fetchRecordWithRelationships; /** * Parses XML content and extracts records */ private parseRecordXml; /** * Fetches child records based on relationships */ private fetchChildRecords; /** * Builds a query for fetching related records */ private buildRelationshipQuery; } export {};