dexie-cloud-addon 1.0.0-alpha.6 → 1.0.0-beta.11
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/copydts.sh +5 -0
- package/dist/modern/dexie-cloud-addon.js +5954 -0
- package/dist/modern/dexie-cloud-addon.js.map +1 -0
- package/dist/modern/dexie-cloud-addon.min.js +1 -0
- package/dist/modern/dexie-cloud-addon.min.js.map +1 -0
- package/dist/modern/service-worker.js +6054 -0
- package/dist/modern/service-worker.js.map +1 -0
- package/dist/modern/service-worker.min.js +1 -0
- package/dist/modern/service-worker.min.js.map +1 -0
- package/dist/module-es5/dexie-cloud-addon.js +6908 -0
- package/dist/module-es5/dexie-cloud-addon.js.map +1 -0
- package/dist/module-es5/dexie-cloud-addon.min.js +1 -0
- package/dist/module-es5/dexie-cloud-addon.min.js.map +1 -0
- package/dist/types/DISABLE_SERVICEWORKER_STRATEGY.d.ts +1 -0
- package/dist/types/DXCWebSocketStatus.d.ts +1 -0
- package/dist/types/DexieCloudOptions.d.ts +19 -0
- package/dist/types/DexieCloudServerState.d.ts +5 -0
- package/dist/types/TSON.d.ts +17 -0
- package/dist/types/WSObservable.d.ts +62 -0
- package/dist/types/WebSocketStatus.d.ts +1 -0
- package/dist/types/authentication/AuthPersistedContext.d.ts +9 -0
- package/dist/types/authentication/TokenExpiredError.d.ts +3 -0
- package/dist/types/authentication/UNAUTHORIZED_USER.d.ts +2 -0
- package/dist/types/authentication/authenticate.d.ts +20 -0
- package/dist/types/authentication/currentUserObservable.d.ts +1 -0
- package/dist/types/authentication/interactWithUser.d.ts +18 -0
- package/dist/types/authentication/login.d.ts +6 -0
- package/dist/types/authentication/otpFetchTokenCallback.d.ts +3 -0
- package/dist/types/authentication/setCurrentUser.d.ts +14 -0
- package/dist/types/computeSyncState.d.ts +4 -0
- package/dist/types/db/DexieCloudDB.d.ts +58 -0
- package/dist/types/db/entities/BaseRevisionMapEntry.d.ts +5 -0
- package/dist/types/db/entities/EntityCommon.d.ts +4 -0
- package/dist/types/db/entities/GuardedJob.d.ts +5 -0
- package/dist/types/db/entities/Member.d.ts +19 -0
- package/dist/types/db/entities/PersistedSyncState.d.ts +14 -0
- package/dist/types/db/entities/Realm.d.ts +16 -0
- package/dist/types/db/entities/Role.d.ts +11 -0
- package/dist/types/db/entities/UserLogin.d.ts +18 -0
- package/dist/types/default-ui/Dialog.d.ts +4 -0
- package/dist/types/default-ui/LoginDialog.d.ts +6 -0
- package/dist/types/default-ui/Styles.d.ts +3 -0
- package/dist/types/default-ui/index.d.ts +24 -0
- package/dist/types/dexie-cloud-client.d.ts +8 -0
- package/dist/types/errors/HttpError.d.ts +5 -0
- package/dist/types/extend-dexie-interface.d.ts +59 -0
- package/dist/types/helpers/BroadcastedAndLocalEvent.d.ts +8 -0
- package/dist/types/helpers/BroadcastedLocalEvent.d.ts +8 -0
- package/dist/types/helpers/CancelToken.d.ts +4 -0
- package/dist/types/helpers/IS_SERVICE_WORKER.d.ts +1 -0
- package/dist/types/helpers/SWBroadcastChannel.d.ts +6 -0
- package/dist/types/helpers/allSettled.d.ts +1 -0
- package/dist/types/helpers/bulkUpdate.d.ts +4 -0
- package/dist/types/helpers/computeRealmSetHash.d.ts +2 -0
- package/dist/types/helpers/date-constants.d.ts +5 -0
- package/dist/types/helpers/dbOnClosed.d.ts +2 -0
- package/dist/types/helpers/getMutationTable.d.ts +1 -0
- package/dist/types/helpers/getSyncableTables.d.ts +4 -0
- package/dist/types/helpers/getTableFromMutationTable.d.ts +1 -0
- package/dist/types/helpers/makeArray.d.ts +1 -0
- package/dist/types/helpers/randomString.d.ts +1 -0
- package/dist/types/helpers/resolveText.d.ts +2 -0
- package/dist/types/helpers/throwVersionIncrementNeeded.d.ts +1 -0
- package/dist/types/helpers/visibilityState.d.ts +1 -0
- package/dist/types/helpers/visibleState.d.ts +1 -0
- package/dist/types/isFirefox.d.ts +1 -0
- package/dist/types/isSafari.d.ts +2 -0
- package/dist/types/middleware-helpers/guardedTable.d.ts +11 -0
- package/dist/types/middlewares/createIdGenerationMiddleware.d.ts +8 -0
- package/dist/types/middlewares/createImplicitPropSetterMiddleware.d.ts +3 -0
- package/dist/types/middlewares/createMutationTrackingMiddleware.d.ts +17 -0
- package/dist/types/middlewares/outstandingTransaction.d.ts +4 -0
- package/dist/types/overrideParseStoresSpec.d.ts +4 -0
- package/dist/types/performInitialSync.d.ts +4 -0
- package/dist/types/service-worker.d.ts +1 -0
- package/dist/types/sync/LocalSyncWorker.d.ts +7 -0
- package/dist/types/sync/SyncRequiredError.d.ts +3 -0
- package/dist/types/sync/connectWebSocket.d.ts +2 -0
- package/dist/types/sync/extractRealm.d.ts +2 -0
- package/dist/types/sync/getLatestRevisionsPerTable.d.ts +6 -0
- package/dist/types/sync/getTablesToSyncify.d.ts +3 -0
- package/dist/types/sync/isOnline.d.ts +1 -0
- package/dist/types/sync/isSyncNeeded.d.ts +2 -0
- package/dist/types/sync/listClientChanges.d.ts +9 -0
- package/dist/types/sync/listSyncifiedChanges.d.ts +5 -0
- package/dist/types/sync/messageConsumerIsReady.d.ts +2 -0
- package/dist/types/sync/messagesFromServerQueue.d.ts +8 -0
- package/dist/types/sync/modifyLocalObjectsWithNewUserId.d.ts +4 -0
- package/dist/types/sync/myId.d.ts +1 -0
- package/dist/types/sync/numUnsyncedMutations.d.ts +2 -0
- package/dist/types/sync/old_startSyncingClientChanges.d.ts +39 -0
- package/dist/types/sync/performGuardedJob.d.ts +4 -0
- package/dist/types/sync/registerSyncEvent.d.ts +3 -0
- package/dist/types/sync/sync.d.ts +17 -0
- package/dist/types/sync/syncIfPossible.d.ts +5 -0
- package/dist/types/sync/syncServerToClientOnly.d.ts +3 -0
- package/dist/types/sync/syncWithServer.d.ts +5 -0
- package/dist/types/sync/triggerSync.d.ts +2 -0
- package/dist/types/sync/updateBaseRevs.d.ts +5 -0
- package/dist/types/types/CloudConnectionStatus.d.ts +0 -0
- package/dist/types/types/ConnectionStatus.d.ts +0 -0
- package/dist/types/types/DXCAlert.d.ts +25 -0
- package/dist/types/types/DXCInputField.d.ts +11 -0
- package/dist/types/types/DXCUserInteraction.d.ts +55 -0
- package/dist/types/types/LoginState.d.ts +41 -0
- package/dist/types/types/SWMessageEvent.d.ts +3 -0
- package/dist/types/types/SWSyncEvent.d.ts +4 -0
- package/dist/types/types/SyncConnectionStatus.d.ts +1 -0
- package/dist/types/types/SyncFlowStatus.d.ts +6 -0
- package/dist/types/types/SyncState.d.ts +8 -0
- package/dist/types/types/SyncStatus.d.ts +6 -0
- package/dist/types/types/TXExpandos.d.ts +10 -0
- package/dist/types/updateSchemaFromOptions.d.ts +3 -0
- package/dist/types/userIsActive.d.ts +7 -0
- package/dist/types/verifyConfig.d.ts +2 -0
- package/dist/types/verifySchema.d.ts +2 -0
- package/dist/umd/dexie-cloud-addon.js +6919 -0
- package/dist/umd/dexie-cloud-addon.js.map +1 -0
- package/dist/umd/dexie-cloud-addon.min.js +1 -0
- package/dist/umd/dexie-cloud-addon.min.js.map +1 -0
- package/dist/umd/service-worker.js +6063 -0
- package/dist/umd/service-worker.js.map +1 -0
- package/dist/umd/service-worker.min.js +1 -0
- package/dist/umd/service-worker.min.js.map +1 -0
- package/dist/umd-modern/dexie-cloud-addon.js +5965 -0
- package/dist/umd-modern/dexie-cloud-addon.js.map +1 -0
- package/package.json +71 -39
- package/dist/dexie-cloud.d.ts +0 -27
- package/dist/dexie-cloud.js +0 -285
- package/dist/dexie-cloud.js.map +0 -1
- package/dist/dexie-cloud.min.js +0 -1
- package/dist/dexie-cloud.min.js.map +0 -1
- package/dist/dexie-cloud.mjs +0 -273
- package/dist/dexie-cloud.mjs.map +0 -1
- package/esnext/dexie-cloud.js +0 -278
- package/esnext/dexie-cloud.js.map +0 -1
- package/esnext/dexie-cloud.min.js +0 -1
- package/esnext/dexie-cloud.min.js.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import Dexie, { Table } from 'dexie';
|
|
2
|
+
import { GuardedJob } from './entities/GuardedJob';
|
|
3
|
+
import { UserLogin } from './entities/UserLogin';
|
|
4
|
+
import { PersistedSyncState } from './entities/PersistedSyncState';
|
|
5
|
+
import { DexieCloudOptions } from '../DexieCloudOptions';
|
|
6
|
+
import { BehaviorSubject } from 'rxjs';
|
|
7
|
+
import { BaseRevisionMapEntry } from './entities/BaseRevisionMapEntry';
|
|
8
|
+
import { DBRealm, DBRealmMember, DBRealmRole, DexieCloudSchema } from 'dexie-cloud-common';
|
|
9
|
+
import { BroadcastedAndLocalEvent } from '../helpers/BroadcastedAndLocalEvent';
|
|
10
|
+
import { SyncStatePhase } from '../types/SyncState';
|
|
11
|
+
import { MessagesFromServerConsumer } from '../sync/messagesFromServerQueue';
|
|
12
|
+
export interface SyncStateChangedEventData {
|
|
13
|
+
phase: SyncStatePhase;
|
|
14
|
+
error?: Error;
|
|
15
|
+
progress?: number;
|
|
16
|
+
}
|
|
17
|
+
declare type SyncStateTable = Table<PersistedSyncState | DexieCloudSchema | DexieCloudOptions, 'syncState' | 'options' | 'schema'>;
|
|
18
|
+
export interface DexieCloudDBBase {
|
|
19
|
+
readonly name: Dexie['name'];
|
|
20
|
+
readonly close: Dexie['close'];
|
|
21
|
+
transaction: Dexie['transaction'];
|
|
22
|
+
table: Dexie['table'];
|
|
23
|
+
readonly tables: Dexie['tables'];
|
|
24
|
+
readonly cloud: Dexie['cloud'];
|
|
25
|
+
readonly $jobs: Table<GuardedJob, string>;
|
|
26
|
+
readonly $logins: Table<UserLogin, string>;
|
|
27
|
+
readonly $syncState: SyncStateTable;
|
|
28
|
+
readonly $baseRevs: Table<BaseRevisionMapEntry, [string, number]>;
|
|
29
|
+
readonly realms: Table<DBRealm, string>;
|
|
30
|
+
readonly members: Table<DBRealmMember, string>;
|
|
31
|
+
readonly roles: Table<DBRealmRole, [string, string]>;
|
|
32
|
+
readonly localSyncEvent: BehaviorSubject<{
|
|
33
|
+
purpose?: 'pull' | 'push';
|
|
34
|
+
}>;
|
|
35
|
+
readonly syncStateChangedEvent: BroadcastedAndLocalEvent<SyncStateChangedEventData>;
|
|
36
|
+
readonly dx: Dexie;
|
|
37
|
+
readonly initiallySynced: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface DexieCloudDB extends DexieCloudDBBase {
|
|
40
|
+
getCurrentUser(): Promise<UserLogin>;
|
|
41
|
+
getSchema(): Promise<DexieCloudSchema | undefined>;
|
|
42
|
+
getOptions(): Promise<DexieCloudOptions | undefined>;
|
|
43
|
+
getPersistedSyncState(): Promise<PersistedSyncState | undefined>;
|
|
44
|
+
setInitiallySynced(initiallySynced: boolean): void;
|
|
45
|
+
reconfigure(): void;
|
|
46
|
+
messageConsumer: MessagesFromServerConsumer;
|
|
47
|
+
}
|
|
48
|
+
export declare const DEXIE_CLOUD_SCHEMA: {
|
|
49
|
+
realms: string;
|
|
50
|
+
members: string;
|
|
51
|
+
roles: string;
|
|
52
|
+
$jobs: string;
|
|
53
|
+
$syncState: string;
|
|
54
|
+
$baseRevs: string;
|
|
55
|
+
$logins: string;
|
|
56
|
+
};
|
|
57
|
+
export declare function DexieCloudDB(dx: Dexie): DexieCloudDB;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface Member {
|
|
2
|
+
id?: string;
|
|
3
|
+
realmId: string;
|
|
4
|
+
userId?: string;
|
|
5
|
+
email?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
invite?: boolean;
|
|
8
|
+
invited?: Date;
|
|
9
|
+
accepted?: Date;
|
|
10
|
+
rejected?: Date;
|
|
11
|
+
roles?: string[];
|
|
12
|
+
permissions?: {
|
|
13
|
+
add?: string[] | "*";
|
|
14
|
+
update?: {
|
|
15
|
+
[tableName: string]: string[] | "*";
|
|
16
|
+
};
|
|
17
|
+
manage?: string[] | "*";
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PersistedSyncState {
|
|
2
|
+
serverRevision?: any;
|
|
3
|
+
latestRevisions: {
|
|
4
|
+
[tableName: string]: number;
|
|
5
|
+
};
|
|
6
|
+
realms: string[];
|
|
7
|
+
inviteRealms: string[];
|
|
8
|
+
clientIdentity: string;
|
|
9
|
+
initiallySynced?: boolean;
|
|
10
|
+
remoteDbId?: string;
|
|
11
|
+
syncedTables: string[];
|
|
12
|
+
timestamp?: Date;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Realm {
|
|
2
|
+
/** Primary key of the realm.
|
|
3
|
+
*/
|
|
4
|
+
realmId: string;
|
|
5
|
+
/** The name of the realm.
|
|
6
|
+
*
|
|
7
|
+
* This property is optional but it can be a good practice to name a realm for what it represents.
|
|
8
|
+
*/
|
|
9
|
+
name?: string;
|
|
10
|
+
/** Contains the user-ID of the owner. An owner has implicit full write-access to the realm
|
|
11
|
+
* and all obejcts connected to it. Ownership does not imply read (sync) access though,
|
|
12
|
+
* so realm owners still needs to add themself as a member if they are going to use the realm
|
|
13
|
+
* themselves.
|
|
14
|
+
*/
|
|
15
|
+
owner?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DXCUserInteraction } from "../../types/DXCUserInteraction";
|
|
2
|
+
export interface UserLogin {
|
|
3
|
+
userId?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
email?: string;
|
|
6
|
+
claims: {
|
|
7
|
+
[claimName: string]: any;
|
|
8
|
+
};
|
|
9
|
+
lastLogin: Date;
|
|
10
|
+
accessToken?: string;
|
|
11
|
+
accessTokenExpiration?: Date;
|
|
12
|
+
refreshToken?: string;
|
|
13
|
+
refreshTokenExpiration?: Date;
|
|
14
|
+
nonExportablePrivateKey?: CryptoKey;
|
|
15
|
+
publicKey?: CryptoKey;
|
|
16
|
+
isLoggedIn?: boolean;
|
|
17
|
+
interaction?: DXCUserInteraction;
|
|
18
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { h } from 'preact';
|
|
2
|
+
import { DXCGenericUserInteraction } from '../types/DXCUserInteraction';
|
|
3
|
+
import { DXCInputField } from '../types/DXCInputField';
|
|
4
|
+
export declare function LoginDialog({ title, alerts, fields, onCancel, onSubmit, }: DXCGenericUserInteraction<string, {
|
|
5
|
+
[name: string]: DXCInputField;
|
|
6
|
+
}>): h.JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Dexie from "dexie";
|
|
2
|
+
import "../extend-dexie-interface";
|
|
3
|
+
import { h, Component } from "preact";
|
|
4
|
+
import { Subscription } from "rxjs";
|
|
5
|
+
import { DXCUserInteraction } from "../types/DXCUserInteraction";
|
|
6
|
+
export interface Props {
|
|
7
|
+
db: Dexie;
|
|
8
|
+
}
|
|
9
|
+
interface State {
|
|
10
|
+
userInteraction: DXCUserInteraction | undefined;
|
|
11
|
+
}
|
|
12
|
+
export default class LoginGui extends Component<Props, State> {
|
|
13
|
+
subscription?: Subscription;
|
|
14
|
+
observer: (userInteraction: DXCUserInteraction | undefined) => void;
|
|
15
|
+
constructor(props: Props);
|
|
16
|
+
componentDidMount(): void;
|
|
17
|
+
componentWillUnmount(): void;
|
|
18
|
+
render(props: Props, { userInteraction }: State): h.JSX.Element | null;
|
|
19
|
+
}
|
|
20
|
+
export declare function setupDefaultGUI(db: Dexie): {
|
|
21
|
+
unsubscribe(): void;
|
|
22
|
+
readonly closed: boolean;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Dexie from 'dexie';
|
|
2
|
+
import './extend-dexie-interface';
|
|
3
|
+
export { DexieCloudTable } from './extend-dexie-interface';
|
|
4
|
+
export declare function dexieCloud(dexie: Dexie): void;
|
|
5
|
+
export declare namespace dexieCloud {
|
|
6
|
+
var version: string;
|
|
7
|
+
}
|
|
8
|
+
export default dexieCloud;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Table } from 'dexie';
|
|
2
|
+
import { DexieCloudOptions } from './DexieCloudOptions';
|
|
3
|
+
import { DBRealm, DBRealmMember, DBRealmRole, DexieCloudSchema } from 'dexie-cloud-common';
|
|
4
|
+
import { UserLogin } from './db/entities/UserLogin';
|
|
5
|
+
import * as Rx from 'rxjs';
|
|
6
|
+
import { PersistedSyncState } from './db/entities/PersistedSyncState';
|
|
7
|
+
import { SyncState } from './types/SyncState';
|
|
8
|
+
import { DexieCloudServerState } from './DexieCloudServerState';
|
|
9
|
+
import { EntityCommon } from './db/entities/EntityCommon';
|
|
10
|
+
import { DXCUserInteraction } from './types/DXCUserInteraction';
|
|
11
|
+
import { DXCWebSocketStatus } from './DXCWebSocketStatus';
|
|
12
|
+
export interface DexieCloudSyncOptions {
|
|
13
|
+
wait: boolean;
|
|
14
|
+
purpose: "push" | "pull";
|
|
15
|
+
}
|
|
16
|
+
export declare type DexieCloudTable<T = any> = Table<T & EntityCommon, string>;
|
|
17
|
+
declare module 'dexie' {
|
|
18
|
+
interface Dexie {
|
|
19
|
+
cloud: {
|
|
20
|
+
version: string;
|
|
21
|
+
options: DexieCloudOptions | null;
|
|
22
|
+
schema: DexieCloudSchema | null;
|
|
23
|
+
serverState: DexieCloudServerState | null;
|
|
24
|
+
currentUserId: string;
|
|
25
|
+
currentUser: Rx.BehaviorSubject<UserLogin>;
|
|
26
|
+
webSocketStatus: Rx.BehaviorSubject<DXCWebSocketStatus>;
|
|
27
|
+
syncState: Rx.BehaviorSubject<SyncState>;
|
|
28
|
+
persistedSyncState: Rx.BehaviorSubject<PersistedSyncState | undefined>;
|
|
29
|
+
userInteraction: Rx.BehaviorSubject<DXCUserInteraction | undefined>;
|
|
30
|
+
usingServiceWorker?: boolean;
|
|
31
|
+
/** Login using Dexie Cloud OTP or Demo user.
|
|
32
|
+
*
|
|
33
|
+
* @param email Email to authenticate
|
|
34
|
+
*/
|
|
35
|
+
login(hint?: {
|
|
36
|
+
email?: string;
|
|
37
|
+
userId?: string;
|
|
38
|
+
grant_type?: 'demo' | 'otp';
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Connect to given URL
|
|
42
|
+
*/
|
|
43
|
+
configure(options: DexieCloudOptions): void;
|
|
44
|
+
/** Wait until a full sync is done.
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
sync(options?: DexieCloudSyncOptions): Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
realms: Table<Partial<DBRealm>, string>;
|
|
50
|
+
members: Table<Partial<DBRealmMember>, string>;
|
|
51
|
+
roles: Table<DBRealmRole, [string, string]>;
|
|
52
|
+
}
|
|
53
|
+
interface DexieConstructor {
|
|
54
|
+
Cloud: {
|
|
55
|
+
(db: Dexie): void;
|
|
56
|
+
version: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { SWBroadcastChannel } from "./SWBroadcastChannel";
|
|
3
|
+
export declare class BroadcastedAndLocalEvent<T> extends Observable<T> {
|
|
4
|
+
name: string;
|
|
5
|
+
bc: BroadcastChannel | SWBroadcastChannel;
|
|
6
|
+
constructor(name: string);
|
|
7
|
+
next(message: T): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { SWBroadcastChannel } from "./SWBroadcastChannel";
|
|
3
|
+
export declare class BroadcastedAndLocalEvent<T> extends Observable<T> {
|
|
4
|
+
name: string;
|
|
5
|
+
bc: BroadcastChannel | SWBroadcastChannel;
|
|
6
|
+
constructor(name: string);
|
|
7
|
+
next(message: T): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const IS_SERVICE_WORKER: false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function allSettled(possiblePromises: any[]): Promise<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getMutationTable(tableName: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getTableFromMutationTable(mutationTable: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makeArray<T>(iterable: Iterable<T>): T[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function randomString(bytes: number): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function throwVersionIncrementNeeded(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createVisibilityStateObservable(): import("rxjs").Observable<VisibilityState>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getVisibilityStateObservable(): import("rxjs").Observable<VisibilityState>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isFirefox: boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DBCoreTable } from "dexie";
|
|
2
|
+
export declare function guardedTable(table: DBCoreTable): {
|
|
3
|
+
count: (req: import("dexie").DBCoreCountRequest) => Promise<number>;
|
|
4
|
+
get: (req: import("dexie").DBCoreGetRequest) => Promise<any>;
|
|
5
|
+
getMany: (req: import("dexie").DBCoreGetManyRequest) => Promise<any[]>;
|
|
6
|
+
openCursor: (req: import("dexie").DBCoreOpenCursorRequest) => Promise<import("dexie").DBCoreCursor | null>;
|
|
7
|
+
query: (req: import("dexie").DBCoreQueryRequest) => Promise<import("dexie").DBCoreQueryResponse>;
|
|
8
|
+
mutate: (req: import("dexie").DBCoreMutateRequest) => Promise<import("dexie").DBCoreMutateResponse>;
|
|
9
|
+
name: string;
|
|
10
|
+
schema: import("dexie").DBCoreTableSchema;
|
|
11
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DBCore, DBCoreAddRequest, DBCoreDeleteRequest, DBCoreIndex, DBCorePutRequest, Middleware } from 'dexie';
|
|
2
|
+
import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
3
|
+
export declare function toStringTag(o: Object): any;
|
|
4
|
+
export declare function getEffectiveKeys(primaryKey: DBCoreIndex, req: (Pick<DBCoreAddRequest | DBCorePutRequest, 'type' | 'values'> & {
|
|
5
|
+
keys?: any[];
|
|
6
|
+
}) | Pick<DBCoreDeleteRequest, 'keys' | 'type'>): any[];
|
|
7
|
+
export declare function generateTablePrefix(tableName: string, allPrefixes: Set<string>): string;
|
|
8
|
+
export declare function createIdGenerationMiddleware(db: DexieCloudDB): Middleware<DBCore>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DBCore, Middleware } from 'dexie';
|
|
2
|
+
import { BehaviorSubject } from 'rxjs';
|
|
3
|
+
import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
4
|
+
import { UserLogin } from '../db/entities/UserLogin';
|
|
5
|
+
export interface MutationTrackingMiddlewareArgs {
|
|
6
|
+
currentUserObservable: BehaviorSubject<UserLogin>;
|
|
7
|
+
db: DexieCloudDB;
|
|
8
|
+
}
|
|
9
|
+
/** Tracks all mutations in the same transaction as the mutations -
|
|
10
|
+
* so it is guaranteed that no mutation goes untracked - and if transaction
|
|
11
|
+
* aborts, the mutations won't be tracked.
|
|
12
|
+
*
|
|
13
|
+
* The sync job will use the tracked mutations as the source of truth when pushing
|
|
14
|
+
* changes to server and cleanup the tracked mutations once the server has
|
|
15
|
+
* ackowledged that it got them.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createMutationTrackingMiddleware({ currentUserObservable, db }: MutationTrackingMiddlewareArgs): Middleware<DBCore>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DexieCloudSchema } from 'dexie-cloud-common';
|
|
2
|
+
import { DexieCloudDB } from './db/DexieCloudDB';
|
|
3
|
+
import { DexieCloudOptions } from './DexieCloudOptions';
|
|
4
|
+
export declare function performInitialSync(db: DexieCloudDB, cloudOptions: DexieCloudOptions, cloudSchema: DexieCloudSchema): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
2
|
+
import { DexieCloudOptions } from '../DexieCloudOptions';
|
|
3
|
+
import { DexieCloudSchema } from 'dexie-cloud-common';
|
|
4
|
+
export declare function LocalSyncWorker(db: DexieCloudDB, cloudOptions: DexieCloudOptions, cloudSchema: DexieCloudSchema): {
|
|
5
|
+
start: () => void;
|
|
6
|
+
stop: () => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { DexieCloudDB } from "../db/DexieCloudDB";
|
|
2
|
+
import { PersistedSyncState } from "../db/entities/PersistedSyncState";
|
|
3
|
+
export declare function getTablesToSyncify(db: DexieCloudDB, syncState: PersistedSyncState | undefined): import("dexie").Table<import("../db/entities/EntityCommon").EntityCommon, import("dexie").IndexableType>[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare let isOnline: boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Table } from "dexie";
|
|
2
|
+
import { DexieCloudDB } from "../db/DexieCloudDB";
|
|
3
|
+
import { DBOperationsSet } from "dexie-cloud-common";
|
|
4
|
+
export declare function listClientChanges(mutationTables: Table[], db: DexieCloudDB, { since, limit }?: {
|
|
5
|
+
since?: {
|
|
6
|
+
[table: string]: number;
|
|
7
|
+
} | undefined;
|
|
8
|
+
limit?: number | undefined;
|
|
9
|
+
}): Promise<DBOperationsSet>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { UserLogin } from "../db/entities/UserLogin";
|
|
2
|
+
import { EntityCommon } from "../db/entities/EntityCommon";
|
|
3
|
+
import { Table } from "dexie";
|
|
4
|
+
import { DBOperationsSet, DexieCloudSchema } from "dexie-cloud-common";
|
|
5
|
+
export declare function listSyncifiedChanges(tablesToSyncify: Table<EntityCommon>[], currentUser: UserLogin, schema: DexieCloudSchema, alreadySyncedRealms?: string[]): Promise<DBOperationsSet>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
3
|
+
import { WSConnectionMsg } from '../WSObservable';
|
|
4
|
+
export declare type MessagesFromServerConsumer = ReturnType<typeof MessagesFromServerConsumer>;
|
|
5
|
+
export declare function MessagesFromServerConsumer(db: DexieCloudDB): {
|
|
6
|
+
enqueue: (msg: WSConnectionMsg) => void;
|
|
7
|
+
readyToServe: BehaviorSubject<boolean>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Table } from "dexie";
|
|
2
|
+
import { EntityCommon } from "../db/entities/EntityCommon";
|
|
3
|
+
import { UserLogin } from "../db/entities/UserLogin";
|
|
4
|
+
export declare function modifyLocalObjectsWithNewUserId(syncifiedTables: Table<EntityCommon>[], currentUser: UserLogin, alreadySyncedRealms?: string[]): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const myId: string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** TODO:
|
|
2
|
+
* 1. Convert these unsynced changes into sync mutations by resolving values from ordinaryTables.
|
|
3
|
+
* 2. Append a convertion of mutReqs[table].muts into sync mutations.
|
|
4
|
+
* 3. Send all this using fetch
|
|
5
|
+
* 4. if successful response, delete muts from mutTables by
|
|
6
|
+
* 1. a new rw-transaction where we start by finding revs above those we generated.
|
|
7
|
+
* 2. for tables where none such found, clear the table. if some of those found, deleteRange on the table.
|
|
8
|
+
*
|
|
9
|
+
* Tankar att följa upp:
|
|
10
|
+
* * Varje DOM environmnet får en MutationSyncer
|
|
11
|
+
* * Håller koll på huruvida den tror att en sync redan pågår eller inte.
|
|
12
|
+
* * Bro
|
|
13
|
+
*
|
|
14
|
+
* Leader election
|
|
15
|
+
* * IDB persisted value: leaderId
|
|
16
|
+
* * Varje browsing-env får en nodeId (random string).
|
|
17
|
+
* * db.open: Kolla om det finns en leader. Om inte, sätt dig själv som leader.
|
|
18
|
+
* * Leaders: Ha sync consumer uppe.
|
|
19
|
+
* * Service worker: Ta ledarskap. Spara även en prop som säger att detta är service worker (för att workaround BroadCastChannel props)
|
|
20
|
+
* * Om det finns en non-service worker ledare, försök kontakta den (via BroadCastChannel)
|
|
21
|
+
* * Om ledaren inte svarar inom 1 sekund, ta ledarskap.
|
|
22
|
+
* * Ledare: Lyssna på ändring av ledarskap och sluta vara ledare i så fall.
|
|
23
|
+
* * Följare: Lyssna på ändring av ledarskap så att du alltid kontaktar rätt ledare.
|
|
24
|
+
* * När man postar något till non-SW ledaren så ska den ACKa inom 1 sek. Annars, ta ledarskapet.
|
|
25
|
+
*
|
|
26
|
+
*
|
|
27
|
+
* Enklare:
|
|
28
|
+
* * Vi har en som leker service worker per window. Två aktiva flikar:
|
|
29
|
+
* * Båda vaknar upp och låser tabellen X för skrivning, om ingen annan tagit jobbet, skriver timestamp till X och
|
|
30
|
+
* börjar sedan synka. Under tiden för sync, uppdaterar den timestamp kontinuerligt för att signallera att den
|
|
31
|
+
* jobbar. När klar, clearar ut timestampen och avslutar jobbet.
|
|
32
|
+
* - Om det inte fanns nåt att göra så clearas timestamp ut och man schedulerar inget mer uppvaknande.
|
|
33
|
+
* * Den som kom sist ser att annan tagit jobbet inom rimlig timestamp och väljer då att polla igen ifall timestampet
|
|
34
|
+
* skulle timat ut.
|
|
35
|
+
* * Om jobbaren verkar tajma ut: gör nytt försök från början. Kan leda till att du blir ledare denna gång.
|
|
36
|
+
* * Om jobbaren clearar ut timestampen pga avslutat jobb så kan väntaren ädnå för säkerhets-skull göra om'et från början.
|
|
37
|
+
*
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
2
|
+
import { DexieCloudOptions } from '../DexieCloudOptions';
|
|
3
|
+
import { DBOperationsSet, DexieCloudSchema } from 'dexie-cloud-common';
|
|
4
|
+
export declare const CURRENT_SYNC_WORKER = "currentSyncWorker";
|
|
5
|
+
export declare let numberOfSyncRequests: number;
|
|
6
|
+
export interface SyncOptions {
|
|
7
|
+
isInitialSync?: boolean;
|
|
8
|
+
cancelToken?: {
|
|
9
|
+
cancelled: boolean;
|
|
10
|
+
};
|
|
11
|
+
justCheckIfNeeded?: boolean;
|
|
12
|
+
retryImmediatelyOnFetchError?: boolean;
|
|
13
|
+
purpose?: 'pull' | 'push';
|
|
14
|
+
}
|
|
15
|
+
export declare function sync(db: DexieCloudDB, options: DexieCloudOptions, schema: DexieCloudSchema, syncOptions?: SyncOptions): Promise<boolean>;
|
|
16
|
+
export declare function applyServerChanges(changes: DBOperationsSet, db: DexieCloudDB): Promise<void>;
|
|
17
|
+
export declare function filterServerChangesThroughAddedClientChanges(serverChanges: DBOperationsSet, addedClientChanges: DBOperationsSet): DBOperationsSet;
|