import { DataServiceAdapter, AjaxAdapter, ChangeRequestInterceptorCtor, ChangeRequestInterceptor } from './interface-registry'; import { MappingContext } from './mapping-context'; import { DataService, JsonResultsAdapter } from './data-service'; import { SaveContext, SaveBundle, ServerError, SaveResult, QueryResult } from './entity-manager'; import { MetadataStore } from './entity-metadata'; /** For use by breeze plugin authors only. The class is used as the base class for most [[IDataServiceAdapter]] implementations @adapter (see [[IDataServiceAdapter]]) @hidden */ export declare abstract class AbstractDataServiceAdapter implements DataServiceAdapter { /** @hidden @internal */ _$impl?: any; /** The name of this adapter. */ name: string; /** The [[IAjaxAdapter]] used by this [[IDataServiceAdapter]]. */ ajaxImpl: AjaxAdapter; checkForRecomposition(interfaceInitializedArgs: any): void; initialize(): void; fetchMetadata(metadataStore: MetadataStore, dataService: DataService): Promise; /** Execute the query in the mappingContext using the ajaxImpl. */ executeQuery(mappingContext: MappingContext): Promise; /** Set up ajax parameters for query GET. This puts the query into the request querystring in either JSON or OData-style syntax, depending upon the UriBuilder. */ _makeQueryGetParams(mappingContext: MappingContext): { type: string; url: string; params: Object; dataType: string; crossDomain: boolean; }; /** Set up ajax parameters for query POST. This put the query into the request body as JSON. */ _makeQueryPostParams(mappingContext: MappingContext): { type: string; url: string; params: Object; dataType: string; processData: boolean; contentType: string; data: string; crossDomain: boolean; }; saveChanges(saveContext: SaveContext, saveBundle: SaveBundle): Promise; /** Abstract method that needs to be overwritten in any concrete DataServiceAdapter subclass. The return value from this method should be a serializable object that will be sent to the server after calling JSON.stringify on it. */ _prepareSaveBundle(saveContext: SaveContext, saveBundle: SaveBundle): any; /** Returns a constructor function for a "ChangeRequestInterceptor" that can tweak the saveBundle both as it is built and when it is completed by a concrete DataServiceAdapater. Initialized with a default, no-op implementation that developers can replace with a substantive implementation that changes the individual entity change requests or aspects of the entire 'saveBundle' without having to write their own DataService adapters. > let adapter = breeze.config.getAdapterInstance('dataService'); > adapter.changeRequestInterceptor = function (saveContext, saveBundle) { > this.getRequest = function (request, entity, index) { > // alter the request that the adapter prepared for this entity > // based on the entity, saveContext, and saveBundle > // e.g., add a custom header or prune the originalValuesMap > return request; > }; > this.done = function (requests) { > // alter the array of requests representing the entire change-set > // based on the saveContext and saveBundle > }; > } @param saveContext - The BreezeJS "context" for the save operation. @param saveBundle - Contains the array of entities-to-be-saved (AKA, the entity change-set). @return Constructor for a "ChangeRequestInterceptor". **/ changeRequestInterceptor: ChangeRequestInterceptorCtor; /** @hidden @internal */ _createChangeRequestInterceptor(saveContext: SaveContext, saveBundle: SaveBundle): ChangeRequestInterceptor; /** Abstract method that needs to be overwritten in any concrete DataServiceAdapter sublclass. This method needs to take the result returned the server and convert it into an ISaveResult. */ _prepareSaveResult(saveContext: SaveContext, data: any): SaveResult; /** Utility method that may be used in any concrete DataServiceAdapter sublclass to handle any http connection issues. */ static _catchNoConnectionError(err: ServerError): void; jsonResultsAdapter: JsonResultsAdapter; }