@aws-amplify/datastore
Version:
AppSyncLocal support for aws-amplify
68 lines (67 loc) • 2.96 kB
TypeScript
import { Observable } from 'rxjs';
import { MutationEvent } from '../';
import { ModelInstanceCreator } from '../../datastore/datastore';
import { ExclusiveStorage as Storage } from '../../storage/storage';
import { AmplifyContext, AuthModeStrategy, ConflictHandler, ErrorHandler, InternalSchema, PersistentModel, PersistentModelConstructor, SchemaModel, TypeConstructorMap } from '../../types';
import { MutationEventOutbox } from '../outbox';
import { TransformerMutationType } from '../utils';
interface MutationProcessorEvent {
operation: TransformerMutationType;
modelDefinition: SchemaModel;
model: PersistentModel;
hasMore: boolean;
}
declare class MutationProcessor {
private readonly schema;
private readonly storage;
private readonly userClasses;
private readonly outbox;
private readonly modelInstanceCreator;
private readonly _MutationEvent;
private readonly amplifyConfig;
private readonly authModeStrategy;
private readonly errorHandler;
private readonly conflictHandler;
private readonly amplifyContext;
/**
* The observer that receives messages when mutations are successfully completed
* against cloud storage.
*
* A value of `undefined` signals that the sync has either been stopped or has not
* yet started. In this case, `isReady()` will be `false` and `resume()` will exit
* early.
*/
private observer?;
private readonly typeQuery;
private processing;
private runningProcesses;
constructor(schema: InternalSchema, storage: Storage, userClasses: TypeConstructorMap, outbox: MutationEventOutbox, modelInstanceCreator: ModelInstanceCreator, _MutationEvent: PersistentModelConstructor<MutationEvent>, amplifyConfig: Record<string, any>, authModeStrategy: AuthModeStrategy, errorHandler: ErrorHandler, conflictHandler: ConflictHandler, amplifyContext: AmplifyContext);
private generateQueries;
private isReady;
start(): Observable<MutationProcessorEvent>;
stop(): Promise<void>;
removeObserver(): void;
resume(): Promise<void>;
private jitteredRetry;
private createQueryVariables;
private opTypeFromTransformerOperation;
pause(): void;
}
declare const originalJitteredBackoff: import("@aws-amplify/core/dist/esm/types").DelayFunction;
/**
* @private
* Internal use of Amplify only.
*
* Wraps the jittered backoff calculation to retry Network Errors indefinitely.
* Backs off according to original jittered retry logic until the original retry
* logic hits its max. After this occurs, if the error is a Network Error, we
* ignore the attempt count and return MAX_RETRY_DELAY_MS to retry forever (until
* the request succeeds).
*
* @param attempt ignored
* @param _args ignored
* @param error tested to see if `.message` is 'Network Error'
* @returns number | false :
*/
export declare const safeJitteredBackoff: typeof originalJitteredBackoff;
export { MutationProcessor };