@aws-amplify/datastore 3.14.1-unstable.2 → 3.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/aws-amplify-datastore.js +2798 -1458
- package/dist/aws-amplify-datastore.js.map +1 -1
- package/dist/aws-amplify-datastore.min.js +10 -10
- package/dist/aws-amplify-datastore.min.js.map +1 -1
- package/lib/authModeStrategies/multiAuthStrategy.js +11 -0
- package/lib/authModeStrategies/multiAuthStrategy.js.map +1 -1
- package/lib/datastore/datastore.js +524 -323
- package/lib/datastore/datastore.js.map +1 -1
- package/lib/storage/adapter/IndexedDBAdapter.js +76 -25
- package/lib/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib/storage/storage.js +2 -2
- package/lib/storage/storage.js.map +1 -1
- package/lib/sync/datastoreConnectivity.js +45 -0
- package/lib/sync/datastoreConnectivity.js.map +1 -1
- package/lib/sync/index.js +518 -395
- package/lib/sync/index.js.map +1 -1
- package/lib/sync/merger.js +6 -0
- package/lib/sync/merger.js.map +1 -1
- package/lib/sync/outbox.js +66 -62
- package/lib/sync/outbox.js.map +1 -1
- package/lib/sync/processors/mutation.js +207 -165
- package/lib/sync/processors/mutation.js.map +1 -1
- package/lib/sync/processors/subscription.js +210 -175
- package/lib/sync/processors/subscription.js.map +1 -1
- package/lib/sync/processors/sync.js +95 -72
- package/lib/sync/processors/sync.js.map +1 -1
- package/lib/sync/utils.js +1 -3
- package/lib/sync/utils.js.map +1 -1
- package/lib/util.js +89 -0
- package/lib/util.js.map +1 -1
- package/lib-esm/authModeStrategies/multiAuthStrategy.d.ts +11 -0
- package/lib-esm/authModeStrategies/multiAuthStrategy.js +11 -0
- package/lib-esm/authModeStrategies/multiAuthStrategy.js.map +1 -1
- package/lib-esm/datastore/datastore.d.ts +95 -2
- package/lib-esm/datastore/datastore.js +524 -323
- package/lib-esm/datastore/datastore.js.map +1 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.d.ts +21 -0
- package/lib-esm/storage/adapter/IndexedDBAdapter.js +77 -26
- package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib-esm/storage/storage.js +2 -2
- package/lib-esm/storage/storage.js.map +1 -1
- package/lib-esm/sync/datastoreConnectivity.d.ts +1 -0
- package/lib-esm/sync/datastoreConnectivity.js +45 -0
- package/lib-esm/sync/datastoreConnectivity.js.map +1 -1
- package/lib-esm/sync/index.d.ts +9 -1
- package/lib-esm/sync/index.js +519 -396
- package/lib-esm/sync/index.js.map +1 -1
- package/lib-esm/sync/merger.d.ts +6 -0
- package/lib-esm/sync/merger.js +6 -0
- package/lib-esm/sync/merger.js.map +1 -1
- package/lib-esm/sync/outbox.js +66 -62
- package/lib-esm/sync/outbox.js.map +1 -1
- package/lib-esm/sync/processors/mutation.d.ts +2 -0
- package/lib-esm/sync/processors/mutation.js +208 -166
- package/lib-esm/sync/processors/mutation.js.map +1 -1
- package/lib-esm/sync/processors/subscription.d.ts +2 -0
- package/lib-esm/sync/processors/subscription.js +211 -176
- package/lib-esm/sync/processors/subscription.js.map +1 -1
- package/lib-esm/sync/processors/sync.d.ts +2 -0
- package/lib-esm/sync/processors/sync.js +96 -73
- package/lib-esm/sync/processors/sync.js.map +1 -1
- package/lib-esm/sync/utils.js +1 -3
- package/lib-esm/sync/utils.js.map +1 -1
- package/lib-esm/util.d.ts +11 -0
- package/lib-esm/util.js +89 -0
- package/lib-esm/util.js.map +1 -1
- package/package.json +7 -7
- package/src/authModeStrategies/multiAuthStrategy.ts +11 -0
- package/src/datastore/datastore.ts +572 -366
- package/src/storage/adapter/IndexedDBAdapter.ts +50 -9
- package/src/storage/storage.ts +2 -2
- package/src/sync/datastoreConnectivity.ts +6 -0
- package/src/sync/index.ts +492 -400
- package/src/sync/merger.ts +6 -0
- package/src/sync/outbox.ts +1 -1
- package/src/sync/processors/mutation.ts +139 -104
- package/src/sync/processors/subscription.ts +287 -250
- package/src/sync/processors/sync.ts +88 -60
- package/src/sync/utils.ts +1 -3
- package/src/util.ts +92 -2
- package/lib/authModeStrategies/defaultAuthStrategy.d.ts +0 -2
- package/lib/authModeStrategies/index.d.ts +0 -2
- package/lib/authModeStrategies/multiAuthStrategy.d.ts +0 -2
- package/lib/datastore/datastore.d.ts +0 -63
- package/lib/index.d.ts +0 -15
- package/lib/predicates/index.d.ts +0 -16
- package/lib/predicates/sort.d.ts +0 -8
- package/lib/ssr/index.d.ts +0 -3
- package/lib/storage/adapter/AsyncStorageAdapter.d.ts +0 -41
- package/lib/storage/adapter/AsyncStorageDatabase.d.ts +0 -39
- package/lib/storage/adapter/InMemoryStore.d.ts +0 -11
- package/lib/storage/adapter/InMemoryStore.native.d.ts +0 -1
- package/lib/storage/adapter/IndexedDBAdapter.d.ts +0 -38
- package/lib/storage/adapter/getDefaultAdapter/index.d.ts +0 -3
- package/lib/storage/adapter/getDefaultAdapter/index.native.d.ts +0 -3
- package/lib/storage/adapter/index.d.ts +0 -9
- package/lib/storage/storage.d.ts +0 -49
- package/lib/sync/datastoreConnectivity.d.ts +0 -15
- package/lib/sync/datastoreReachability/index.d.ts +0 -3
- package/lib/sync/datastoreReachability/index.native.d.ts +0 -3
- package/lib/sync/index.d.ts +0 -81
- package/lib/sync/merger.d.ts +0 -11
- package/lib/sync/outbox.d.ts +0 -27
- package/lib/sync/processors/errorMaps.d.ts +0 -17
- package/lib/sync/processors/mutation.d.ts +0 -56
- package/lib/sync/processors/subscription.d.ts +0 -31
- package/lib/sync/processors/sync.d.ts +0 -26
- package/lib/sync/utils.d.ts +0 -42
- package/lib/types.d.ts +0 -501
- package/lib/util.d.ts +0 -145
package/lib/storage/storage.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import Observable from 'zen-observable-ts';
|
|
2
|
-
import { Patch } from 'immer';
|
|
3
|
-
import { ModelInstanceCreator } from '../datastore/datastore';
|
|
4
|
-
import { InternalSchema, ModelInstanceMetadata, ModelPredicate, NamespaceResolver, OpType, PaginationInput, PersistentModel, PersistentModelConstructor, QueryOne, SchemaNamespace, InternalSubscriptionMessage, SubscriptionMessage } from '../types';
|
|
5
|
-
import { Adapter } from './adapter';
|
|
6
|
-
export declare type StorageSubscriptionMessage<T extends PersistentModel> = InternalSubscriptionMessage<T> & {
|
|
7
|
-
mutator?: Symbol;
|
|
8
|
-
};
|
|
9
|
-
export declare type StorageFacade = Omit<Adapter, 'setUp'>;
|
|
10
|
-
export declare type Storage = InstanceType<typeof StorageClass>;
|
|
11
|
-
declare class StorageClass implements StorageFacade {
|
|
12
|
-
private readonly schema;
|
|
13
|
-
private readonly namespaceResolver;
|
|
14
|
-
private readonly getModelConstructorByModelName;
|
|
15
|
-
private readonly modelInstanceCreator;
|
|
16
|
-
private readonly adapter?;
|
|
17
|
-
private readonly sessionId?;
|
|
18
|
-
private initialized;
|
|
19
|
-
private readonly pushStream;
|
|
20
|
-
constructor(schema: InternalSchema, namespaceResolver: NamespaceResolver, getModelConstructorByModelName: (namsespaceName: string, modelName: string) => PersistentModelConstructor<any>, modelInstanceCreator: ModelInstanceCreator, adapter?: Adapter, sessionId?: string);
|
|
21
|
-
static getNamespace(): SchemaNamespace;
|
|
22
|
-
init(): Promise<void>;
|
|
23
|
-
save<T extends PersistentModel>(model: T, condition?: ModelPredicate<T>, mutator?: Symbol, patchesTuple?: [Patch[], PersistentModel]): Promise<[T, OpType.INSERT | OpType.UPDATE][]>;
|
|
24
|
-
delete<T extends PersistentModel>(model: T, condition?: ModelPredicate<T>, mutator?: Symbol): Promise<[T[], T[]]>;
|
|
25
|
-
delete<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, condition?: ModelPredicate<T>, mutator?: Symbol): Promise<[T[], T[]]>;
|
|
26
|
-
query<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, predicate?: ModelPredicate<T>, pagination?: PaginationInput<T>): Promise<T[]>;
|
|
27
|
-
queryOne<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, firstOrLast?: QueryOne): Promise<T>;
|
|
28
|
-
observe<T extends PersistentModel>(modelConstructor?: PersistentModelConstructor<T>, predicate?: ModelPredicate<T>, skipOwn?: Symbol): Observable<SubscriptionMessage<T>>;
|
|
29
|
-
clear(completeObservable?: boolean): Promise<void>;
|
|
30
|
-
batchSave<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<any>, items: ModelInstanceMetadata[], mutator?: Symbol): Promise<[T, OpType][]>;
|
|
31
|
-
private getUpdateMutationInput;
|
|
32
|
-
}
|
|
33
|
-
declare class ExclusiveStorage implements StorageFacade {
|
|
34
|
-
private storage;
|
|
35
|
-
private readonly mutex;
|
|
36
|
-
constructor(schema: InternalSchema, namespaceResolver: NamespaceResolver, getModelConstructorByModelName: (namsespaceName: string, modelName: string) => PersistentModelConstructor<any>, modelInstanceCreator: ModelInstanceCreator, adapter?: Adapter, sessionId?: string);
|
|
37
|
-
runExclusive<T>(fn: (storage: StorageClass) => Promise<T>): Promise<T>;
|
|
38
|
-
save<T extends PersistentModel>(model: T, condition?: ModelPredicate<T>, mutator?: Symbol, patchesTuple?: [Patch[], PersistentModel]): Promise<[T, OpType.INSERT | OpType.UPDATE][]>;
|
|
39
|
-
delete<T extends PersistentModel>(model: T, condition?: ModelPredicate<T>, mutator?: Symbol): Promise<[T[], T[]]>;
|
|
40
|
-
delete<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, condition?: ModelPredicate<T>, mutator?: Symbol): Promise<[T[], T[]]>;
|
|
41
|
-
query<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, predicate?: ModelPredicate<T>, pagination?: PaginationInput<T>): Promise<T[]>;
|
|
42
|
-
queryOne<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, firstOrLast?: QueryOne): Promise<T>;
|
|
43
|
-
static getNamespace(): SchemaNamespace;
|
|
44
|
-
observe<T extends PersistentModel>(modelConstructor?: PersistentModelConstructor<T>, predicate?: ModelPredicate<T>, skipOwn?: Symbol): Observable<SubscriptionMessage<T>>;
|
|
45
|
-
clear(): Promise<void>;
|
|
46
|
-
batchSave<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, items: ModelInstanceMetadata[]): Promise<[T, OpType][]>;
|
|
47
|
-
init(): Promise<void>;
|
|
48
|
-
}
|
|
49
|
-
export { ExclusiveStorage };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import Observable from 'zen-observable-ts';
|
|
2
|
-
declare type ConnectionStatus = {
|
|
3
|
-
online: boolean;
|
|
4
|
-
};
|
|
5
|
-
export default class DataStoreConnectivity {
|
|
6
|
-
private connectionStatus;
|
|
7
|
-
private observer;
|
|
8
|
-
private subscription;
|
|
9
|
-
private timeout;
|
|
10
|
-
constructor();
|
|
11
|
-
status(): Observable<ConnectionStatus>;
|
|
12
|
-
unsubscribe(): void;
|
|
13
|
-
socketDisconnected(): void;
|
|
14
|
-
}
|
|
15
|
-
export {};
|
package/lib/sync/index.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import Observable from 'zen-observable-ts';
|
|
2
|
-
import { ModelInstanceCreator } from '../datastore/datastore';
|
|
3
|
-
import { ExclusiveStorage as Storage } from '../storage/storage';
|
|
4
|
-
import { ConflictHandler, ControlMessageType, ErrorHandler, InternalSchema, ModelInit, MutableModel, NamespaceResolver, PersistentModelConstructor, SchemaModel, SchemaNamespace, TypeConstructorMap, ModelPredicate, AuthModeStrategy, ManagedIdentifier, OptionallyManagedIdentifier, AmplifyContext } from '../types';
|
|
5
|
-
import type { __modelMeta__ } from '../types';
|
|
6
|
-
import { TransformerMutationType } from './utils';
|
|
7
|
-
declare type StartParams = {
|
|
8
|
-
fullSyncInterval: number;
|
|
9
|
-
};
|
|
10
|
-
export declare class MutationEvent {
|
|
11
|
-
readonly [__modelMeta__]: {
|
|
12
|
-
identifier: OptionallyManagedIdentifier<MutationEvent, 'id'>;
|
|
13
|
-
};
|
|
14
|
-
readonly id: string;
|
|
15
|
-
readonly model: string;
|
|
16
|
-
readonly operation: TransformerMutationType;
|
|
17
|
-
readonly modelId: string;
|
|
18
|
-
readonly condition: string;
|
|
19
|
-
readonly data: string;
|
|
20
|
-
constructor(init: ModelInit<MutationEvent>);
|
|
21
|
-
static copyOf(src: MutationEvent, mutator: (draft: MutableModel<MutationEvent>) => void | MutationEvent): MutationEvent;
|
|
22
|
-
}
|
|
23
|
-
export declare class ModelMetadata {
|
|
24
|
-
readonly [__modelMeta__]: {
|
|
25
|
-
identifier: ManagedIdentifier<ModelMetadata, 'id'>;
|
|
26
|
-
};
|
|
27
|
-
readonly id: string;
|
|
28
|
-
readonly namespace: string;
|
|
29
|
-
readonly model: string;
|
|
30
|
-
readonly fullSyncInterval: number;
|
|
31
|
-
readonly lastSync?: number;
|
|
32
|
-
readonly lastFullSync?: number;
|
|
33
|
-
readonly lastSyncPredicate?: null | string;
|
|
34
|
-
constructor(init: ModelInit<ModelMetadata>);
|
|
35
|
-
static copyOf(src: ModelMetadata, mutator: (draft: MutableModel<ModelMetadata>) => void | ModelMetadata): ModelMetadata;
|
|
36
|
-
}
|
|
37
|
-
export declare enum ControlMessage {
|
|
38
|
-
SYNC_ENGINE_STORAGE_SUBSCRIBED = "storageSubscribed",
|
|
39
|
-
SYNC_ENGINE_SUBSCRIPTIONS_ESTABLISHED = "subscriptionsEstablished",
|
|
40
|
-
SYNC_ENGINE_SYNC_QUERIES_STARTED = "syncQueriesStarted",
|
|
41
|
-
SYNC_ENGINE_SYNC_QUERIES_READY = "syncQueriesReady",
|
|
42
|
-
SYNC_ENGINE_MODEL_SYNCED = "modelSynced",
|
|
43
|
-
SYNC_ENGINE_OUTBOX_MUTATION_ENQUEUED = "outboxMutationEnqueued",
|
|
44
|
-
SYNC_ENGINE_OUTBOX_MUTATION_PROCESSED = "outboxMutationProcessed",
|
|
45
|
-
SYNC_ENGINE_OUTBOX_STATUS = "outboxStatus",
|
|
46
|
-
SYNC_ENGINE_NETWORK_STATUS = "networkStatus",
|
|
47
|
-
SYNC_ENGINE_READY = "ready"
|
|
48
|
-
}
|
|
49
|
-
export declare class SyncEngine {
|
|
50
|
-
private readonly schema;
|
|
51
|
-
private readonly namespaceResolver;
|
|
52
|
-
private readonly modelClasses;
|
|
53
|
-
private readonly userModelClasses;
|
|
54
|
-
private readonly storage;
|
|
55
|
-
private readonly modelInstanceCreator;
|
|
56
|
-
private readonly syncPredicates;
|
|
57
|
-
private readonly amplifyConfig;
|
|
58
|
-
private readonly authModeStrategy;
|
|
59
|
-
private readonly amplifyContext;
|
|
60
|
-
private online;
|
|
61
|
-
private readonly syncQueriesProcessor;
|
|
62
|
-
private readonly subscriptionsProcessor;
|
|
63
|
-
private readonly mutationsProcessor;
|
|
64
|
-
private readonly modelMerger;
|
|
65
|
-
private readonly outbox;
|
|
66
|
-
private readonly datastoreConnectivity;
|
|
67
|
-
private readonly modelSyncedStatus;
|
|
68
|
-
getModelSyncedStatus(modelConstructor: PersistentModelConstructor<any>): boolean;
|
|
69
|
-
constructor(schema: InternalSchema, namespaceResolver: NamespaceResolver, modelClasses: TypeConstructorMap, userModelClasses: TypeConstructorMap, storage: Storage, modelInstanceCreator: ModelInstanceCreator, conflictHandler: ConflictHandler, errorHandler: ErrorHandler, syncPredicates: WeakMap<SchemaModel, ModelPredicate<any>>, amplifyConfig: Record<string, any>, authModeStrategy: AuthModeStrategy, amplifyContext: AmplifyContext);
|
|
70
|
-
start(params: StartParams): Observable<ControlMessageType<ControlMessage>>;
|
|
71
|
-
private getModelsMetadataWithNextFullSync;
|
|
72
|
-
private syncQueriesObservable;
|
|
73
|
-
private disconnectionHandler;
|
|
74
|
-
unsubscribeConnectivity(): void;
|
|
75
|
-
private setupModels;
|
|
76
|
-
private getModelsMetadata;
|
|
77
|
-
private getModelMetadata;
|
|
78
|
-
private getModelDefinition;
|
|
79
|
-
static getNamespace(): SchemaNamespace;
|
|
80
|
-
}
|
|
81
|
-
export {};
|
package/lib/sync/merger.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Storage } from '../storage/storage';
|
|
2
|
-
import { ModelInstanceMetadata, OpType, PersistentModelConstructor, SchemaModel } from '../types';
|
|
3
|
-
import { MutationEventOutbox } from './outbox';
|
|
4
|
-
declare class ModelMerger {
|
|
5
|
-
private readonly outbox;
|
|
6
|
-
private readonly ownSymbol;
|
|
7
|
-
constructor(outbox: MutationEventOutbox, ownSymbol: Symbol);
|
|
8
|
-
merge<T extends ModelInstanceMetadata>(storage: Storage, model: T, modelDefinition: SchemaModel): Promise<OpType>;
|
|
9
|
-
mergePage(storage: Storage, modelConstructor: PersistentModelConstructor<any>, items: ModelInstanceMetadata[], modelDefinition: SchemaModel): Promise<[ModelInstanceMetadata, OpType][]>;
|
|
10
|
-
}
|
|
11
|
-
export { ModelMerger };
|
package/lib/sync/outbox.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { MutationEvent } from './index';
|
|
2
|
-
import { ExclusiveStorage as Storage, StorageFacade, Storage as StorageClass } from '../storage/storage';
|
|
3
|
-
import { ModelInstanceCreator } from '../datastore/datastore';
|
|
4
|
-
import { InternalSchema, PersistentModel, PersistentModelConstructor, SchemaModel } from '../types';
|
|
5
|
-
import { TransformerMutationType } from './utils';
|
|
6
|
-
declare class MutationEventOutbox {
|
|
7
|
-
private readonly schema;
|
|
8
|
-
private readonly MutationEvent;
|
|
9
|
-
private readonly modelInstanceCreator;
|
|
10
|
-
private readonly ownSymbol;
|
|
11
|
-
private inProgressMutationEventId;
|
|
12
|
-
constructor(schema: InternalSchema, MutationEvent: PersistentModelConstructor<MutationEvent>, modelInstanceCreator: ModelInstanceCreator, ownSymbol: Symbol);
|
|
13
|
-
enqueue(storage: Storage, mutationEvent: MutationEvent): Promise<void>;
|
|
14
|
-
dequeue(storage: StorageClass, record?: PersistentModel, recordOp?: TransformerMutationType): Promise<MutationEvent>;
|
|
15
|
-
/**
|
|
16
|
-
* Doing a peek() implies that the mutation goes "inProgress"
|
|
17
|
-
*
|
|
18
|
-
* @param storage
|
|
19
|
-
*/
|
|
20
|
-
peek(storage: StorageFacade): Promise<MutationEvent>;
|
|
21
|
-
getForModel<T extends PersistentModel>(storage: StorageFacade, model: T, userModelDefinition: SchemaModel): Promise<MutationEvent[]>;
|
|
22
|
-
getModelIds(storage: StorageFacade): Promise<Set<string>>;
|
|
23
|
-
private syncOutboxVersionsOnDequeue;
|
|
24
|
-
private mergeUserFields;
|
|
25
|
-
private removeTimestampFields;
|
|
26
|
-
}
|
|
27
|
-
export { MutationEventOutbox };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ErrorType } from '../../types';
|
|
2
|
-
export declare type ErrorMap = Partial<{
|
|
3
|
-
[key in ErrorType]: (error: Error) => boolean;
|
|
4
|
-
}>;
|
|
5
|
-
export declare const mutationErrorMap: ErrorMap;
|
|
6
|
-
export declare const subscriptionErrorMap: ErrorMap;
|
|
7
|
-
export declare const syncErrorMap: ErrorMap;
|
|
8
|
-
export declare function getMutationErrorType(error: Error): ErrorType;
|
|
9
|
-
export declare function getSubscriptionErrorType(error: Error): ErrorType;
|
|
10
|
-
export declare function getSyncErrorType(error: Error): ErrorType;
|
|
11
|
-
/**
|
|
12
|
-
* Categorizes an error with a broad error type, intended to make
|
|
13
|
-
* customer error handling code simpler.
|
|
14
|
-
* @param errorMap Error names and a list of patterns that indicate them (each pattern as a regex or function)
|
|
15
|
-
* @param error The underying error to categorize.
|
|
16
|
-
*/
|
|
17
|
-
export declare function mapErrorToType(errorMap: ErrorMap, error: Error): ErrorType;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import Observable from 'zen-observable-ts';
|
|
2
|
-
import { MutationEvent } from '../';
|
|
3
|
-
import { ModelInstanceCreator } from '../../datastore/datastore';
|
|
4
|
-
import { ExclusiveStorage as Storage } from '../../storage/storage';
|
|
5
|
-
import { AuthModeStrategy, ConflictHandler, ErrorHandler, InternalSchema, PersistentModel, PersistentModelConstructor, SchemaModel, TypeConstructorMap, AmplifyContext } from '../../types';
|
|
6
|
-
import { MutationEventOutbox } from '../outbox';
|
|
7
|
-
import { TransformerMutationType } from '../utils';
|
|
8
|
-
declare type MutationProcessorEvent = {
|
|
9
|
-
operation: TransformerMutationType;
|
|
10
|
-
modelDefinition: SchemaModel;
|
|
11
|
-
model: PersistentModel;
|
|
12
|
-
hasMore: boolean;
|
|
13
|
-
};
|
|
14
|
-
declare class MutationProcessor {
|
|
15
|
-
private readonly schema;
|
|
16
|
-
private readonly storage;
|
|
17
|
-
private readonly userClasses;
|
|
18
|
-
private readonly outbox;
|
|
19
|
-
private readonly modelInstanceCreator;
|
|
20
|
-
private readonly MutationEvent;
|
|
21
|
-
private readonly amplifyConfig;
|
|
22
|
-
private readonly authModeStrategy;
|
|
23
|
-
private readonly errorHandler;
|
|
24
|
-
private readonly conflictHandler;
|
|
25
|
-
private readonly amplifyContext;
|
|
26
|
-
private observer;
|
|
27
|
-
private readonly typeQuery;
|
|
28
|
-
private processing;
|
|
29
|
-
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);
|
|
30
|
-
private generateQueries;
|
|
31
|
-
private isReady;
|
|
32
|
-
start(): Observable<MutationProcessorEvent>;
|
|
33
|
-
resume(): Promise<void>;
|
|
34
|
-
private jitteredRetry;
|
|
35
|
-
private createQueryVariables;
|
|
36
|
-
private opTypeFromTransformerOperation;
|
|
37
|
-
pause(): void;
|
|
38
|
-
}
|
|
39
|
-
declare const originalJitteredBackoff: import("@aws-amplify/core/lib-esm/types").DelayFunction;
|
|
40
|
-
/**
|
|
41
|
-
* @private
|
|
42
|
-
* Internal use of Amplify only.
|
|
43
|
-
*
|
|
44
|
-
* Wraps the jittered backoff calculation to retry Network Errors indefinitely.
|
|
45
|
-
* Backs off according to original jittered retry logic until the original retry
|
|
46
|
-
* logic hits its max. After this occurs, if the error is a Network Error, we
|
|
47
|
-
* ignore the attempt count and return MAX_RETRY_DELAY_MS to retry forever (until
|
|
48
|
-
* the request succeeds).
|
|
49
|
-
*
|
|
50
|
-
* @param attempt ignored
|
|
51
|
-
* @param _args ignored
|
|
52
|
-
* @param error tested to see if `.message` is 'Network Error'
|
|
53
|
-
* @returns number | false :
|
|
54
|
-
*/
|
|
55
|
-
export declare const safeJitteredBackoff: typeof originalJitteredBackoff;
|
|
56
|
-
export { MutationProcessor };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import Observable from 'zen-observable-ts';
|
|
2
|
-
import { InternalSchema, PersistentModel, SchemaModel, ModelPredicate, AuthModeStrategy, ErrorHandler, AmplifyContext } from '../../types';
|
|
3
|
-
import { TransformerMutationType } from '../utils';
|
|
4
|
-
export declare enum CONTROL_MSG {
|
|
5
|
-
CONNECTED = "CONNECTED"
|
|
6
|
-
}
|
|
7
|
-
export declare enum USER_CREDENTIALS {
|
|
8
|
-
'none' = 0,
|
|
9
|
-
'unauth' = 1,
|
|
10
|
-
'auth' = 2
|
|
11
|
-
}
|
|
12
|
-
declare class SubscriptionProcessor {
|
|
13
|
-
private readonly schema;
|
|
14
|
-
private readonly syncPredicates;
|
|
15
|
-
private readonly amplifyConfig;
|
|
16
|
-
private readonly authModeStrategy;
|
|
17
|
-
private readonly errorHandler;
|
|
18
|
-
private readonly amplifyContext;
|
|
19
|
-
private readonly typeQuery;
|
|
20
|
-
private buffer;
|
|
21
|
-
private dataObserver;
|
|
22
|
-
constructor(schema: InternalSchema, syncPredicates: WeakMap<SchemaModel, ModelPredicate<any>>, amplifyConfig: Record<string, any>, authModeStrategy: AuthModeStrategy, errorHandler: ErrorHandler, amplifyContext?: AmplifyContext);
|
|
23
|
-
private buildSubscription;
|
|
24
|
-
private getAuthorizationInfo;
|
|
25
|
-
private hubQueryCompletionListener;
|
|
26
|
-
start(): [Observable<CONTROL_MSG>, Observable<[TransformerMutationType, SchemaModel, PersistentModel]>];
|
|
27
|
-
private passesPredicateValidation;
|
|
28
|
-
private pushToBuffer;
|
|
29
|
-
private drainBuffer;
|
|
30
|
-
}
|
|
31
|
-
export { SubscriptionProcessor };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import Observable from 'zen-observable-ts';
|
|
2
|
-
import { InternalSchema, ModelInstanceMetadata, SchemaModel, ModelPredicate, AuthModeStrategy, ErrorHandler, AmplifyContext } from '../../types';
|
|
3
|
-
declare class SyncProcessor {
|
|
4
|
-
private readonly schema;
|
|
5
|
-
private readonly syncPredicates;
|
|
6
|
-
private readonly amplifyConfig;
|
|
7
|
-
private readonly authModeStrategy;
|
|
8
|
-
private readonly errorHandler;
|
|
9
|
-
private readonly amplifyContext;
|
|
10
|
-
private readonly typeQuery;
|
|
11
|
-
constructor(schema: InternalSchema, syncPredicates: WeakMap<SchemaModel, ModelPredicate<any>>, amplifyConfig: Record<string, any>, authModeStrategy: AuthModeStrategy, errorHandler: ErrorHandler, amplifyContext: AmplifyContext);
|
|
12
|
-
private generateQueries;
|
|
13
|
-
private graphqlFilterFromPredicate;
|
|
14
|
-
private retrievePage;
|
|
15
|
-
private jitteredRetry;
|
|
16
|
-
start(typesLastSync: Map<SchemaModel, [string, number]>): Observable<SyncModelPage>;
|
|
17
|
-
}
|
|
18
|
-
export declare type SyncModelPage = {
|
|
19
|
-
namespace: string;
|
|
20
|
-
modelDefinition: SchemaModel;
|
|
21
|
-
items: ModelInstanceMetadata[];
|
|
22
|
-
startedAt: number;
|
|
23
|
-
done: boolean;
|
|
24
|
-
isFullSync: boolean;
|
|
25
|
-
};
|
|
26
|
-
export { SyncProcessor };
|
package/lib/sync/utils.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { GRAPHQL_AUTH_MODE } from '@aws-amplify/api-graphql';
|
|
2
|
-
import { GraphQLAuthError } from '@aws-amplify/api';
|
|
3
|
-
import { ModelInstanceCreator } from '../datastore/datastore';
|
|
4
|
-
import { AuthorizationRule, GraphQLCondition, GraphQLFilter, ModelInstanceMetadata, OpType, PersistentModel, PersistentModelConstructor, PredicatesGroup, RelationshipType, SchemaModel, SchemaNamespace, SchemaNonModel, ModelOperation, InternalSchema, AuthModeStrategy } from '../types';
|
|
5
|
-
import { MutationEvent } from './';
|
|
6
|
-
declare enum GraphQLOperationType {
|
|
7
|
-
LIST = "query",
|
|
8
|
-
CREATE = "mutation",
|
|
9
|
-
UPDATE = "mutation",
|
|
10
|
-
DELETE = "mutation",
|
|
11
|
-
GET = "query"
|
|
12
|
-
}
|
|
13
|
-
export declare enum TransformerMutationType {
|
|
14
|
-
CREATE = "Create",
|
|
15
|
-
UPDATE = "Update",
|
|
16
|
-
DELETE = "Delete",
|
|
17
|
-
GET = "Get"
|
|
18
|
-
}
|
|
19
|
-
export declare function getMetadataFields(): ReadonlyArray<string>;
|
|
20
|
-
export declare function generateSelectionSet(namespace: SchemaNamespace, modelDefinition: SchemaModel | SchemaNonModel): string;
|
|
21
|
-
export declare function getAuthorizationRules(modelDefinition: SchemaModel): AuthorizationRule[];
|
|
22
|
-
export declare function buildSubscriptionGraphQLOperation(namespace: SchemaNamespace, modelDefinition: SchemaModel, transformerMutationType: TransformerMutationType, isOwnerAuthorization: boolean, ownerField: string): [TransformerMutationType, string, string];
|
|
23
|
-
export declare function buildGraphQLOperation(namespace: SchemaNamespace, modelDefinition: SchemaModel, graphQLOpType: keyof typeof GraphQLOperationType): [TransformerMutationType, string, string][];
|
|
24
|
-
export declare function createMutationInstanceFromModelOperation<T extends PersistentModel>(relationships: RelationshipType, modelDefinition: SchemaModel, opType: OpType, model: PersistentModelConstructor<T>, element: T, condition: GraphQLCondition, MutationEventConstructor: PersistentModelConstructor<MutationEvent>, modelInstanceCreator: ModelInstanceCreator, id?: string): MutationEvent;
|
|
25
|
-
export declare function predicateToGraphQLCondition(predicate: PredicatesGroup<any>, modelDefinition: SchemaModel): GraphQLCondition;
|
|
26
|
-
export declare function predicateToGraphQLFilter(predicatesGroup: PredicatesGroup<any>): GraphQLFilter;
|
|
27
|
-
export declare function getUserGroupsFromToken(token: {
|
|
28
|
-
[field: string]: any;
|
|
29
|
-
}, rule: AuthorizationRule): string[];
|
|
30
|
-
export declare function getModelAuthModes({ authModeStrategy, defaultAuthMode, modelName, schema, }: {
|
|
31
|
-
authModeStrategy: AuthModeStrategy;
|
|
32
|
-
defaultAuthMode: GRAPHQL_AUTH_MODE;
|
|
33
|
-
modelName: string;
|
|
34
|
-
schema: InternalSchema;
|
|
35
|
-
}): Promise<{
|
|
36
|
-
[key in ModelOperation]: GRAPHQL_AUTH_MODE[];
|
|
37
|
-
}>;
|
|
38
|
-
export declare function getForbiddenError(error: any): any;
|
|
39
|
-
export declare function getClientSideAuthError(error: any): GraphQLAuthError;
|
|
40
|
-
export declare function getTokenForCustomAuth(authMode: GRAPHQL_AUTH_MODE, amplifyConfig?: Record<string, any>): Promise<string | undefined>;
|
|
41
|
-
export declare function getIdentifierValue(modelDefinition: SchemaModel, model: ModelInstanceMetadata | PersistentModel): string;
|
|
42
|
-
export {};
|