import type { AgDataSource, AgDataSourcesDefinition, AgDataSourcesUpdate } from '../api/agDataSource'; import type { AgExpressionFieldDefinition } from '../api/agExpression'; import type { AgFormats } from '../api/agFormats'; import type { AgRelationDefinition } from '../api/agRelationDefinition'; import type { AgDataEngine, AgExecuteRequest } from '../api/engine/agDataEngine'; import type { AgExecuteResult } from '../api/engine/agStudioQuery'; import type { Schema } from '../shared/schema/schema'; import type { SchemaModel } from '../shared/schema/schemaModel'; import type { StudioError } from '../shared/validation'; import type { IEventListener } from 'ag-grid-enterprise'; import { DataModel } from './engine/model/dataModel'; /** * Studio-private schema-building context. Created by * {@link StudioEngineAdapter} during `initEngine()`: the adapter asks the * engine for its data source definitions, feeds each source and relation * into this context, and uses the resulting {@link SchemaModel} to drive * the query resolver. The engine itself never sees this type. */ export interface DataEngineInitContext { /** Register a data source. The context builds the corresponding fieldset and fields internally. */ addDataSource(source: AgDataSource): void; /** Register a relationship between two fields across data sources. */ addRelation(relation: AgRelationDefinition): void; /** Register expression (calculated) fields. */ addExpressions(expressions: AgExpressionFieldDefinition[]): void; /** * Finalise schema construction. Runs the sanitiser (which also fires * validation reporters), and returns any validation issues collected * since the context was created. Must be called exactly once before the * schema is consumed; calling it repeatedly is a no-op and returns an * empty list. */ finalize(): StudioError[]; /** Return the schema built from the registered data sources and relations. */ getViewSchema(): Schema | undefined; /** Return a {@link SchemaModel} view for Studio's query resolver. */ getSchemaModel(): SchemaModel; } /** * Create a Studio-private schema-building context. Internally constructs a * lightweight {@link DataModel} used only for schema building, never for * query execution. */ export declare function createInitContext(formats?: AgFormats): DataEngineInitContext; /** * Create a Data Engine from the provided data source definitions, * which can then be shared between multiple Studio instances. */ export declare function createDataEngine(data: AgDataSourcesDefinition): DataEngine; export declare class DataEngine implements AgDataEngine { private isFinalized; private queryEngine; private queryPlanner; private readonly declaredSources; private readonly aggregationService; private readonly dataModel; private readonly reporter; private readonly localEventSvc; private readonly validationHistory; private readonly activeListeners; private readonly listenerHighWaterMark; private currentValidationMode; private static readonly EMPTY_SOURCES; constructor(data?: AgDataSourcesDefinition); getDataSources(): AgDataSourcesDefinition; getDataSourcesDescription(): string | undefined; /** Schema model for the engine's declared sources. Used by standalone query helpers. */ getDataModel(): DataModel; private createReporter; finalize(): void; private createServiceContext; addEventListener(eventType: 'validation', listener: IEventListener<'validation'>, async?: boolean): void; removeEventListener(eventType: 'validation', listener: IEventListener<'validation'>, async?: boolean): void; /** * Execute one or more queries. Each request feeds into QueryEngine's * internal scheduler (10ms debounce, sort-by-width, inter-query yields) * which is the single batching mechanism. */ execute(...requests: AgExecuteRequest[]): Promise; private executeSingle; private toExecuteResult; addDataSource(source: AgDataSource): void; addRelation(relation: AgRelationDefinition): void; addExpressions(expressions?: AgExpressionFieldDefinition[]): void; update({ sources }: AgDataSourcesUpdate): void; reload(): void; /** * Release all large data structures so V8's concurrent marker can reclaim them sooner. * Called on page unload to reduce zombie-heap pressure on subsequent same-origin loads * (V8 reuses the isolate for same-origin navigations/reloads). */ dispose(): void; }