dexie-cloud-addon 4.0.1-beta.47 → 4.0.1-beta.48
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/dist/{types → modern}/TSON.d.ts +1 -1
- package/dist/modern/dexie-cloud-addon.d.ts +3 -0
- package/dist/modern/dexie-cloud-addon.js +20 -57
- package/dist/modern/dexie-cloud-addon.js.map +1 -1
- package/dist/modern/dexie-cloud-addon.min.js +2 -2
- package/dist/modern/dexie-cloud-addon.min.js.map +1 -1
- package/dist/modern/service-worker.js +1568 -19
- package/dist/modern/service-worker.js.map +1 -1
- package/dist/modern/service-worker.min.js +2 -2
- package/dist/modern/service-worker.min.js.map +1 -1
- package/dist/umd/DISABLE_SERVICEWORKER_STRATEGY.d.ts +1 -0
- package/dist/umd/DXCWebSocketStatus.d.ts +1 -0
- package/dist/umd/DexieCloudAPI.d.ts +72 -0
- package/dist/umd/DexieCloudOptions.d.ts +22 -0
- package/dist/umd/DexieCloudSyncOptions.d.ts +4 -0
- package/dist/umd/DexieCloudTable.d.ts +18 -0
- package/dist/umd/InvalidLicenseError.d.ts +5 -0
- package/dist/umd/Invite.d.ts +8 -0
- package/dist/umd/PermissionChecker.d.ts +15 -0
- package/dist/umd/TSON.d.ts +17 -0
- package/dist/umd/WSObservable.d.ts +68 -0
- package/dist/umd/associate.d.ts +1 -0
- package/dist/umd/authentication/AuthPersistedContext.d.ts +9 -0
- package/dist/umd/authentication/TokenErrorResponseError.d.ts +10 -0
- package/dist/umd/authentication/TokenExpiredError.d.ts +3 -0
- package/dist/umd/authentication/UNAUTHORIZED_USER.d.ts +2 -0
- package/dist/umd/authentication/authenticate.d.ts +20 -0
- package/dist/umd/authentication/currentUserObservable.d.ts +1 -0
- package/dist/umd/authentication/interactWithUser.d.ts +21 -0
- package/dist/umd/authentication/login.d.ts +6 -0
- package/dist/umd/authentication/logout.d.ts +5 -0
- package/dist/umd/authentication/otpFetchTokenCallback.d.ts +3 -0
- package/dist/umd/authentication/setCurrentUser.d.ts +14 -0
- package/dist/umd/authentication/waitUntil.d.ts +3 -0
- package/dist/umd/computeSyncState.d.ts +4 -0
- package/dist/umd/createSharedValueObservable.d.ts +3 -0
- package/dist/umd/currentUserEmitter.d.ts +3 -0
- package/dist/umd/db/DexieCloudDB.d.ts +59 -0
- package/dist/umd/db/entities/BaseRevisionMapEntry.d.ts +5 -0
- package/dist/umd/db/entities/EntityCommon.d.ts +5 -0
- package/dist/umd/db/entities/GuardedJob.d.ts +5 -0
- package/dist/umd/db/entities/Member.d.ts +19 -0
- package/dist/umd/db/entities/PersistedSyncState.d.ts +14 -0
- package/dist/umd/db/entities/Realm.d.ts +16 -0
- package/dist/umd/db/entities/Role.d.ts +11 -0
- package/dist/umd/db/entities/UserLogin.d.ts +22 -0
- package/dist/umd/default-ui/Dialog.d.ts +5 -0
- package/dist/umd/default-ui/LoginDialog.d.ts +3 -0
- package/dist/umd/default-ui/Styles.d.ts +3 -0
- package/dist/umd/default-ui/index.d.ts +24 -0
- package/dist/umd/dexie-cloud-addon.d.ts +3 -0
- package/dist/umd/dexie-cloud-addon.js +40 -81
- package/dist/umd/dexie-cloud-addon.js.map +1 -1
- package/dist/umd/dexie-cloud-client.d.ts +13 -0
- package/dist/umd/errors/HttpError.d.ts +5 -0
- package/dist/umd/extend-dexie-interface.d.ts +23 -0
- package/dist/umd/getGlobalRolesObservable.d.ts +5 -0
- package/dist/umd/getInternalAccessControlObservable.d.ts +12 -0
- package/dist/umd/getInvitesObservable.d.ts +23 -0
- package/dist/umd/getPermissionsLookupObservable.d.ts +16 -0
- package/dist/umd/getTiedRealmId.d.ts +2 -0
- package/dist/umd/helpers/BroadcastedAndLocalEvent.d.ts +8 -0
- package/dist/umd/helpers/CancelToken.d.ts +4 -0
- package/dist/umd/helpers/IS_SERVICE_WORKER.d.ts +1 -0
- package/dist/umd/helpers/SWBroadcastChannel.d.ts +12 -0
- package/dist/umd/helpers/allSettled.d.ts +1 -0
- package/dist/umd/helpers/bulkUpdate.d.ts +4 -0
- package/dist/umd/helpers/computeRealmSetHash.d.ts +2 -0
- package/dist/umd/helpers/date-constants.d.ts +5 -0
- package/dist/umd/helpers/dbOnClosed.d.ts +2 -0
- package/dist/umd/helpers/flatten.d.ts +1 -0
- package/dist/umd/helpers/getMutationTable.d.ts +1 -0
- package/dist/umd/helpers/getSyncableTables.d.ts +4 -0
- package/dist/umd/helpers/getTableFromMutationTable.d.ts +1 -0
- package/dist/umd/helpers/makeArray.d.ts +1 -0
- package/dist/umd/helpers/randomString.d.ts +1 -0
- package/dist/umd/helpers/resolveText.d.ts +16 -0
- package/dist/umd/helpers/throwVersionIncrementNeeded.d.ts +1 -0
- package/dist/umd/helpers/visibilityState.d.ts +1 -0
- package/dist/umd/isEagerSyncDisabled.d.ts +2 -0
- package/dist/umd/isFirefox.d.ts +1 -0
- package/dist/umd/isSafari.d.ts +2 -0
- package/dist/umd/mapValueObservable.d.ts +5 -0
- package/dist/umd/mergePermissions.d.ts +2 -0
- package/dist/umd/middleware-helpers/guardedTable.d.ts +11 -0
- package/dist/umd/middleware-helpers/idGenerationHelpers.d.ts +18 -0
- package/dist/umd/middlewares/createIdGenerationMiddleware.d.ts +3 -0
- package/dist/umd/middlewares/createImplicitPropSetterMiddleware.d.ts +3 -0
- package/dist/umd/middlewares/createMutationTrackingMiddleware.d.ts +17 -0
- package/dist/umd/middlewares/outstandingTransaction.d.ts +4 -0
- package/dist/umd/overrideParseStoresSpec.d.ts +4 -0
- package/dist/umd/performInitialSync.d.ts +4 -0
- package/dist/umd/permissions.d.ts +9 -0
- package/dist/umd/prodLog.d.ts +9 -0
- package/dist/umd/service-worker.d.ts +1 -0
- package/dist/umd/service-worker.js +1624 -78
- package/dist/umd/service-worker.js.map +1 -1
- package/dist/umd/sync/LocalSyncWorker.d.ts +7 -0
- package/dist/umd/sync/SyncRequiredError.d.ts +3 -0
- package/dist/umd/sync/applyServerChanges.d.ts +3 -0
- package/dist/umd/sync/connectWebSocket.d.ts +2 -0
- package/dist/umd/sync/encodeIdsForServer.d.ts +4 -0
- package/dist/umd/sync/extractRealm.d.ts +2 -0
- package/dist/umd/sync/getLatestRevisionsPerTable.d.ts +6 -0
- package/dist/umd/sync/getTablesToSyncify.d.ts +3 -0
- package/dist/umd/sync/isOnline.d.ts +1 -0
- package/dist/umd/sync/isSyncNeeded.d.ts +2 -0
- package/dist/umd/sync/listClientChanges.d.ts +9 -0
- package/dist/umd/sync/listSyncifiedChanges.d.ts +5 -0
- package/dist/umd/sync/messageConsumerIsReady.d.ts +2 -0
- package/dist/umd/sync/messagesFromServerQueue.d.ts +8 -0
- package/dist/umd/sync/modifyLocalObjectsWithNewUserId.d.ts +4 -0
- package/dist/umd/sync/myId.d.ts +1 -0
- package/dist/umd/sync/numUnsyncedMutations.d.ts +2 -0
- package/dist/umd/sync/old_startSyncingClientChanges.d.ts +39 -0
- package/dist/umd/sync/performGuardedJob.d.ts +2 -0
- package/dist/umd/sync/ratelimit.d.ts +3 -0
- package/dist/umd/sync/registerSyncEvent.d.ts +3 -0
- package/dist/umd/sync/sync.d.ts +15 -0
- package/dist/umd/sync/syncIfPossible.d.ts +5 -0
- package/dist/umd/sync/syncWithServer.d.ts +6 -0
- package/dist/umd/sync/triggerSync.d.ts +2 -0
- package/dist/umd/sync/updateBaseRevs.d.ts +5 -0
- package/dist/umd/types/DXCAlert.d.ts +25 -0
- package/dist/umd/types/DXCInputField.d.ts +11 -0
- package/dist/umd/types/DXCUserInteraction.d.ts +93 -0
- package/dist/umd/types/NewIdOptions.d.ts +3 -0
- package/dist/umd/types/SWMessageEvent.d.ts +3 -0
- package/dist/umd/types/SWSyncEvent.d.ts +4 -0
- package/dist/umd/types/SyncState.d.ts +9 -0
- package/dist/umd/types/TXExpandos.d.ts +11 -0
- package/dist/umd/updateSchemaFromOptions.d.ts +3 -0
- package/dist/umd/userIsActive.d.ts +7 -0
- package/dist/umd/verifyConfig.d.ts +2 -0
- package/dist/umd/verifySchema.d.ts +2 -0
- package/package.json +12 -47
- package/copydts.sh +0 -5
- package/dist/umd/dexie-cloud-addon.min.js +0 -2
- package/dist/umd/dexie-cloud-addon.min.js.map +0 -1
- package/dist/umd/service-worker.min.js +0 -2
- package/dist/umd/service-worker.min.js.map +0 -1
- /package/dist/{types → modern}/DISABLE_SERVICEWORKER_STRATEGY.d.ts +0 -0
- /package/dist/{types → modern}/DXCWebSocketStatus.d.ts +0 -0
- /package/dist/{types → modern}/DexieCloudAPI.d.ts +0 -0
- /package/dist/{types → modern}/DexieCloudOptions.d.ts +0 -0
- /package/dist/{types → modern}/DexieCloudSyncOptions.d.ts +0 -0
- /package/dist/{types → modern}/DexieCloudTable.d.ts +0 -0
- /package/dist/{types → modern}/InvalidLicenseError.d.ts +0 -0
- /package/dist/{types → modern}/Invite.d.ts +0 -0
- /package/dist/{types → modern}/PermissionChecker.d.ts +0 -0
- /package/dist/{types → modern}/WSObservable.d.ts +0 -0
- /package/dist/{types → modern}/associate.d.ts +0 -0
- /package/dist/{types → modern}/authentication/AuthPersistedContext.d.ts +0 -0
- /package/dist/{types → modern}/authentication/TokenErrorResponseError.d.ts +0 -0
- /package/dist/{types → modern}/authentication/TokenExpiredError.d.ts +0 -0
- /package/dist/{types → modern}/authentication/UNAUTHORIZED_USER.d.ts +0 -0
- /package/dist/{types → modern}/authentication/authenticate.d.ts +0 -0
- /package/dist/{types → modern}/authentication/currentUserObservable.d.ts +0 -0
- /package/dist/{types → modern}/authentication/interactWithUser.d.ts +0 -0
- /package/dist/{types → modern}/authentication/login.d.ts +0 -0
- /package/dist/{types → modern}/authentication/logout.d.ts +0 -0
- /package/dist/{types → modern}/authentication/otpFetchTokenCallback.d.ts +0 -0
- /package/dist/{types → modern}/authentication/setCurrentUser.d.ts +0 -0
- /package/dist/{types → modern}/authentication/waitUntil.d.ts +0 -0
- /package/dist/{types → modern}/computeSyncState.d.ts +0 -0
- /package/dist/{types → modern}/createSharedValueObservable.d.ts +0 -0
- /package/dist/{types → modern}/currentUserEmitter.d.ts +0 -0
- /package/dist/{types → modern}/db/DexieCloudDB.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/BaseRevisionMapEntry.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/EntityCommon.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/GuardedJob.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/Member.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/PersistedSyncState.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/Realm.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/Role.d.ts +0 -0
- /package/dist/{types → modern}/db/entities/UserLogin.d.ts +0 -0
- /package/dist/{types → modern}/default-ui/Dialog.d.ts +0 -0
- /package/dist/{types → modern}/default-ui/LoginDialog.d.ts +0 -0
- /package/dist/{types → modern}/default-ui/Styles.d.ts +0 -0
- /package/dist/{types → modern}/default-ui/index.d.ts +0 -0
- /package/dist/{types → modern}/dexie-cloud-client.d.ts +0 -0
- /package/dist/{types → modern}/errors/HttpError.d.ts +0 -0
- /package/dist/{types → modern}/extend-dexie-interface.d.ts +0 -0
- /package/dist/{types → modern}/getGlobalRolesObservable.d.ts +0 -0
- /package/dist/{types → modern}/getInternalAccessControlObservable.d.ts +0 -0
- /package/dist/{types → modern}/getInvitesObservable.d.ts +0 -0
- /package/dist/{types → modern}/getPermissionsLookupObservable.d.ts +0 -0
- /package/dist/{types → modern}/getTiedRealmId.d.ts +0 -0
- /package/dist/{types → modern}/helpers/BroadcastedAndLocalEvent.d.ts +0 -0
- /package/dist/{types → modern}/helpers/CancelToken.d.ts +0 -0
- /package/dist/{types → modern}/helpers/IS_SERVICE_WORKER.d.ts +0 -0
- /package/dist/{types → modern}/helpers/SWBroadcastChannel.d.ts +0 -0
- /package/dist/{types → modern}/helpers/allSettled.d.ts +0 -0
- /package/dist/{types → modern}/helpers/bulkUpdate.d.ts +0 -0
- /package/dist/{types → modern}/helpers/computeRealmSetHash.d.ts +0 -0
- /package/dist/{types → modern}/helpers/date-constants.d.ts +0 -0
- /package/dist/{types → modern}/helpers/dbOnClosed.d.ts +0 -0
- /package/dist/{types → modern}/helpers/flatten.d.ts +0 -0
- /package/dist/{types → modern}/helpers/getMutationTable.d.ts +0 -0
- /package/dist/{types → modern}/helpers/getSyncableTables.d.ts +0 -0
- /package/dist/{types → modern}/helpers/getTableFromMutationTable.d.ts +0 -0
- /package/dist/{types → modern}/helpers/makeArray.d.ts +0 -0
- /package/dist/{types → modern}/helpers/randomString.d.ts +0 -0
- /package/dist/{types → modern}/helpers/resolveText.d.ts +0 -0
- /package/dist/{types → modern}/helpers/throwVersionIncrementNeeded.d.ts +0 -0
- /package/dist/{types → modern}/helpers/visibilityState.d.ts +0 -0
- /package/dist/{types → modern}/isEagerSyncDisabled.d.ts +0 -0
- /package/dist/{types → modern}/isFirefox.d.ts +0 -0
- /package/dist/{types → modern}/isSafari.d.ts +0 -0
- /package/dist/{types → modern}/mapValueObservable.d.ts +0 -0
- /package/dist/{types → modern}/mergePermissions.d.ts +0 -0
- /package/dist/{types → modern}/middleware-helpers/guardedTable.d.ts +0 -0
- /package/dist/{types → modern}/middleware-helpers/idGenerationHelpers.d.ts +0 -0
- /package/dist/{types → modern}/middlewares/createIdGenerationMiddleware.d.ts +0 -0
- /package/dist/{types → modern}/middlewares/createImplicitPropSetterMiddleware.d.ts +0 -0
- /package/dist/{types → modern}/middlewares/createMutationTrackingMiddleware.d.ts +0 -0
- /package/dist/{types → modern}/middlewares/outstandingTransaction.d.ts +0 -0
- /package/dist/{types → modern}/overrideParseStoresSpec.d.ts +0 -0
- /package/dist/{types → modern}/performInitialSync.d.ts +0 -0
- /package/dist/{types → modern}/permissions.d.ts +0 -0
- /package/dist/{types → modern}/prodLog.d.ts +0 -0
- /package/dist/{types → modern}/service-worker.d.ts +0 -0
- /package/dist/{types → modern}/sync/LocalSyncWorker.d.ts +0 -0
- /package/dist/{types → modern}/sync/SyncRequiredError.d.ts +0 -0
- /package/dist/{types → modern}/sync/applyServerChanges.d.ts +0 -0
- /package/dist/{types → modern}/sync/connectWebSocket.d.ts +0 -0
- /package/dist/{types → modern}/sync/encodeIdsForServer.d.ts +0 -0
- /package/dist/{types → modern}/sync/extractRealm.d.ts +0 -0
- /package/dist/{types → modern}/sync/getLatestRevisionsPerTable.d.ts +0 -0
- /package/dist/{types → modern}/sync/getTablesToSyncify.d.ts +0 -0
- /package/dist/{types → modern}/sync/isOnline.d.ts +0 -0
- /package/dist/{types → modern}/sync/isSyncNeeded.d.ts +0 -0
- /package/dist/{types → modern}/sync/listClientChanges.d.ts +0 -0
- /package/dist/{types → modern}/sync/listSyncifiedChanges.d.ts +0 -0
- /package/dist/{types → modern}/sync/messageConsumerIsReady.d.ts +0 -0
- /package/dist/{types → modern}/sync/messagesFromServerQueue.d.ts +0 -0
- /package/dist/{types → modern}/sync/modifyLocalObjectsWithNewUserId.d.ts +0 -0
- /package/dist/{types → modern}/sync/myId.d.ts +0 -0
- /package/dist/{types → modern}/sync/numUnsyncedMutations.d.ts +0 -0
- /package/dist/{types → modern}/sync/old_startSyncingClientChanges.d.ts +0 -0
- /package/dist/{types → modern}/sync/performGuardedJob.d.ts +0 -0
- /package/dist/{types → modern}/sync/ratelimit.d.ts +0 -0
- /package/dist/{types → modern}/sync/registerSyncEvent.d.ts +0 -0
- /package/dist/{types → modern}/sync/sync.d.ts +0 -0
- /package/dist/{types → modern}/sync/syncIfPossible.d.ts +0 -0
- /package/dist/{types → modern}/sync/syncWithServer.d.ts +0 -0
- /package/dist/{types → modern}/sync/triggerSync.d.ts +0 -0
- /package/dist/{types → modern}/sync/updateBaseRevs.d.ts +0 -0
- /package/dist/{types → modern}/types/DXCAlert.d.ts +0 -0
- /package/dist/{types → modern}/types/DXCInputField.d.ts +0 -0
- /package/dist/{types → modern}/types/DXCUserInteraction.d.ts +0 -0
- /package/dist/{types → modern}/types/NewIdOptions.d.ts +0 -0
- /package/dist/{types → modern}/types/SWMessageEvent.d.ts +0 -0
- /package/dist/{types → modern}/types/SWSyncEvent.d.ts +0 -0
- /package/dist/{types → modern}/types/SyncState.d.ts +0 -0
- /package/dist/{types → modern}/types/TXExpandos.d.ts +0 -0
- /package/dist/{types → modern}/updateSchemaFromOptions.d.ts +0 -0
- /package/dist/{types → modern}/userIsActive.d.ts +0 -0
- /package/dist/{types → modern}/verifyConfig.d.ts +0 -0
- /package/dist/{types → modern}/verifySchema.d.ts +0 -0
|
@@ -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,4 @@
|
|
|
1
|
+
import { DBCoreSchema } from 'dexie';
|
|
2
|
+
import { DBOperationsSet } from 'dexie-cloud-common';
|
|
3
|
+
import { UserLogin } from '../db/entities/UserLogin';
|
|
4
|
+
export declare function encodeIdsForServer(schema: DBCoreSchema, currentUser: UserLogin, changes: DBOperationsSet): DBOperationsSet;
|
|
@@ -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, any, import("../db/entities/EntityCommon").EntityCommon>[];
|
|
@@ -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 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,15 @@
|
|
|
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 interface SyncOptions {
|
|
6
|
+
isInitialSync?: boolean;
|
|
7
|
+
cancelToken?: {
|
|
8
|
+
cancelled: boolean;
|
|
9
|
+
};
|
|
10
|
+
justCheckIfNeeded?: boolean;
|
|
11
|
+
retryImmediatelyOnFetchError?: boolean;
|
|
12
|
+
purpose?: 'pull' | 'push';
|
|
13
|
+
}
|
|
14
|
+
export declare function sync(db: DexieCloudDB, options: DexieCloudOptions, schema: DexieCloudSchema, syncOptions?: SyncOptions): Promise<boolean>;
|
|
15
|
+
export declare function filterServerChangesThroughAddedClientChanges(serverChanges: DBOperationsSet<string>, addedClientChanges: DBOperationsSet): DBOperationsSet<string>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
2
|
+
import { SyncOptions } from './sync';
|
|
3
|
+
import { DexieCloudOptions } from '../DexieCloudOptions';
|
|
4
|
+
import { DexieCloudSchema } from 'dexie-cloud-common';
|
|
5
|
+
export declare function syncIfPossible(db: DexieCloudDB, cloudOptions: DexieCloudOptions, cloudSchema: DexieCloudSchema, options?: SyncOptions): any;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
2
|
+
import { PersistedSyncState } from '../db/entities/PersistedSyncState';
|
|
3
|
+
import { BaseRevisionMapEntry } from '../db/entities/BaseRevisionMapEntry';
|
|
4
|
+
import { DBOperationsSet, DexieCloudSchema, SyncResponse } from 'dexie-cloud-common';
|
|
5
|
+
import { UserLogin } from '../db/entities/UserLogin';
|
|
6
|
+
export declare function syncWithServer(changes: DBOperationsSet, syncState: PersistedSyncState | undefined, baseRevs: BaseRevisionMapEntry[], db: DexieCloudDB, databaseUrl: string, schema: DexieCloudSchema | null, clientIdentity: string, currentUser: UserLogin): Promise<SyncResponse>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
2
|
+
import { DexieCloudSchema } from 'dexie-cloud-common';
|
|
3
|
+
export declare function updateBaseRevs(db: DexieCloudDB, schema: DexieCloudSchema, latestRevisions: {
|
|
4
|
+
[table: string]: number;
|
|
5
|
+
}, serverRev: any): Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type DXCAlert = DXCErrorAlert | DXCWarningAlert | DXCInfoAlert;
|
|
2
|
+
export interface DXCErrorAlert {
|
|
3
|
+
type: 'error';
|
|
4
|
+
messageCode: 'INVALID_OTP' | 'INVALID_EMAIL' | 'LICENSE_LIMIT_REACHED' | 'GENERIC_ERROR';
|
|
5
|
+
message: string;
|
|
6
|
+
messageParams: {
|
|
7
|
+
[paramName: string]: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface DXCWarningAlert {
|
|
11
|
+
type: 'warning';
|
|
12
|
+
messageCode: 'GENERIC_WARNING' | 'LOGOUT_CONFIRMATION';
|
|
13
|
+
message: string;
|
|
14
|
+
messageParams: {
|
|
15
|
+
[paramName: string]: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface DXCInfoAlert {
|
|
19
|
+
type: 'info';
|
|
20
|
+
messageCode: 'GENERIC_INFO' | 'OTP_SENT';
|
|
21
|
+
message: string;
|
|
22
|
+
messageParams: {
|
|
23
|
+
[paramName: string]: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type DXCInputField = DXCTextField | DXCPasswordField;
|
|
2
|
+
export interface DXCTextField {
|
|
3
|
+
type: 'text' | 'email' | 'otp';
|
|
4
|
+
label?: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DXCPasswordField {
|
|
8
|
+
type: 'password';
|
|
9
|
+
label?: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { DXCAlert } from './DXCAlert';
|
|
2
|
+
import { DXCInputField } from './DXCInputField';
|
|
3
|
+
export type DXCUserInteraction = DXCGenericUserInteraction | DXCEmailPrompt | DXCOTPPrompt | DXCMessageAlert | DXCLogoutConfirmation;
|
|
4
|
+
export interface DXCGenericUserInteraction<Type extends string = "generic", TFields extends {
|
|
5
|
+
[name: string]: DXCInputField;
|
|
6
|
+
} = any> {
|
|
7
|
+
type: Type;
|
|
8
|
+
title: string;
|
|
9
|
+
alerts: DXCAlert[];
|
|
10
|
+
fields: TFields;
|
|
11
|
+
submitLabel: string;
|
|
12
|
+
cancelLabel: string | null;
|
|
13
|
+
onSubmit: (params: {
|
|
14
|
+
[P in keyof TFields]: string;
|
|
15
|
+
}) => void;
|
|
16
|
+
onCancel: () => void;
|
|
17
|
+
}
|
|
18
|
+
/** When the system needs to prompt for an email address for login.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export interface DXCEmailPrompt {
|
|
22
|
+
type: 'email';
|
|
23
|
+
title: string;
|
|
24
|
+
alerts: DXCAlert[];
|
|
25
|
+
fields: {
|
|
26
|
+
email: {
|
|
27
|
+
type: 'text';
|
|
28
|
+
placeholder: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
submitLabel: string;
|
|
32
|
+
cancelLabel: string;
|
|
33
|
+
onSubmit: (params: {
|
|
34
|
+
email: string;
|
|
35
|
+
} | {
|
|
36
|
+
[paramName: string]: string;
|
|
37
|
+
}) => void;
|
|
38
|
+
onCancel: () => void;
|
|
39
|
+
}
|
|
40
|
+
/** When the system needs to prompt for an OTP code.
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
export interface DXCOTPPrompt {
|
|
44
|
+
type: 'otp';
|
|
45
|
+
title: string;
|
|
46
|
+
alerts: DXCAlert[];
|
|
47
|
+
fields: {
|
|
48
|
+
otp: {
|
|
49
|
+
type: 'text';
|
|
50
|
+
label: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
submitLabel: string;
|
|
54
|
+
cancelLabel: string;
|
|
55
|
+
onSubmit: (params: {
|
|
56
|
+
otp: string;
|
|
57
|
+
} | {
|
|
58
|
+
[paramName: string]: string;
|
|
59
|
+
}) => void;
|
|
60
|
+
onCancel: () => void;
|
|
61
|
+
}
|
|
62
|
+
/** When the system must inform about errors, warnings or information */
|
|
63
|
+
export interface DXCMessageAlert {
|
|
64
|
+
type: 'message-alert';
|
|
65
|
+
title: string;
|
|
66
|
+
alerts: DXCAlert[];
|
|
67
|
+
fields: {
|
|
68
|
+
[name: string]: DXCInputField;
|
|
69
|
+
};
|
|
70
|
+
submitLabel: string;
|
|
71
|
+
cancelLabel?: null;
|
|
72
|
+
onSubmit: (params: {
|
|
73
|
+
[paramName: string]: string;
|
|
74
|
+
}) => void;
|
|
75
|
+
onCancel: () => void;
|
|
76
|
+
}
|
|
77
|
+
/** When the system needs confirmation to logout current user when
|
|
78
|
+
* there are unsynced changes that would be lost.
|
|
79
|
+
*/
|
|
80
|
+
export interface DXCLogoutConfirmation {
|
|
81
|
+
type: 'logout-confirmation';
|
|
82
|
+
title: string;
|
|
83
|
+
alerts: DXCAlert[];
|
|
84
|
+
fields: {
|
|
85
|
+
[name: string]: DXCInputField;
|
|
86
|
+
};
|
|
87
|
+
submitLabel: string;
|
|
88
|
+
cancelLabel: string;
|
|
89
|
+
onSubmit: (params: {
|
|
90
|
+
[paramName: string]: string;
|
|
91
|
+
}) => void;
|
|
92
|
+
onCancel: () => void;
|
|
93
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type SyncStatePhase = "initial" | "not-in-sync" | "pushing" | "pulling" | "in-sync" | 'error' | 'offline';
|
|
2
|
+
export type SyncStatus = "not-started" | "connecting" | "connected" | "disconnected" | "error" | "offline";
|
|
3
|
+
export interface SyncState {
|
|
4
|
+
status: SyncStatus;
|
|
5
|
+
phase: SyncStatePhase;
|
|
6
|
+
progress?: number;
|
|
7
|
+
error?: Error;
|
|
8
|
+
license?: 'ok' | 'expired' | 'deactivated';
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DexieCloudSchema } from "dexie-cloud-common";
|
|
2
|
+
import { UserLogin } from '../db/entities/UserLogin';
|
|
3
|
+
export interface TXExpandos {
|
|
4
|
+
txid: string;
|
|
5
|
+
currentUser: UserLogin;
|
|
6
|
+
schema: DexieCloudSchema;
|
|
7
|
+
disableChangeTracking?: boolean;
|
|
8
|
+
disableAccessControl?: boolean;
|
|
9
|
+
mutationsAdded?: boolean;
|
|
10
|
+
opCount: number;
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
export declare const userIsActive: BehaviorSubject<boolean>;
|
|
3
|
+
export declare const userIsReallyActive: BehaviorSubject<boolean>;
|
|
4
|
+
export declare const visibilityStateIsChanged: import("rxjs").Observable<{}>;
|
|
5
|
+
export declare const documentBecomesHidden: import("rxjs").Observable<{}>;
|
|
6
|
+
export declare const documentBecomesVisible: import("rxjs").Observable<{}>;
|
|
7
|
+
export declare const userDoesSomething: import("rxjs").Observable<Event | {}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dexie-cloud-addon",
|
|
3
|
-
"version": "4.0.1-beta.
|
|
3
|
+
"version": "4.0.1-beta.48",
|
|
4
4
|
"description": "Dexie addon that syncs with to Dexie Cloud",
|
|
5
5
|
"main": "dist/umd/dexie-cloud-addon.js",
|
|
6
6
|
"type": "module",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
|
-
"types": "dist/
|
|
45
|
+
"types": "dist/modern/dexie-cloud-client.d.ts",
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=14"
|
|
48
48
|
},
|
|
@@ -52,37 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"just-build": {
|
|
54
54
|
"default": [
|
|
55
|
-
"
|
|
56
|
-
],
|
|
57
|
-
"release": [
|
|
58
|
-
"# Build outputs",
|
|
59
|
-
"just-build src",
|
|
60
|
-
"just-build dexie-cloud service-worker",
|
|
61
|
-
"#dts-bundle-generator --external-inlines=dexie-cloud-common --external-imports=rxjs dexie --project src/tsconfig.json -o dist/types/dexie-cloud-addon.d.ts tools/tmp/modern/dexie-cloud-client.d.ts",
|
|
62
|
-
"# Minify modern bundle",
|
|
63
|
-
"terser --comments false --module --config-file tools/build-configs/terser-config.json --source-map url=dexie-cloud-addon.min.js.map -o dist/modern/dexie-cloud-addon.min.js -- dist/modern/dexie-cloud-addon.js",
|
|
64
|
-
"# Minify umd bundle",
|
|
65
|
-
"terser --comments false --config-file tools/build-configs/terser-config.json --source-map url=dexie-cloud-addon.min.js.map -o dist/umd/dexie-cloud-addon.min.js -- dist/umd/dexie-cloud-addon.js",
|
|
66
|
-
"# Minify modern service-worker",
|
|
67
|
-
"terser --comments false --module --config-file tools/build-configs/terser-config.json --source-map url=service-worker.min.js.map -o dist/modern/service-worker.min.js -- dist/modern/service-worker.js",
|
|
68
|
-
"# Minify umd service-worker",
|
|
69
|
-
"terser --comments false --config-file tools/build-configs/terser-config.json --source-map url=service-worker.min.js.map -o dist/umd/service-worker.min.js -- dist/umd/service-worker.js"
|
|
70
|
-
],
|
|
71
|
-
"src": [
|
|
72
|
-
"# Build the entire typescript source into modern JS",
|
|
73
|
-
"tsc -p src -t es2016 --outDir tools/tmp/modern [--watch 'Watching for file changes.']"
|
|
74
|
-
],
|
|
75
|
-
"dexie-cloud": [
|
|
76
|
-
"# Create a modern bundle in dist/modern",
|
|
77
|
-
"rollup -c tools/build-configs/rollup.modern.config.js",
|
|
78
|
-
"# Replace {version} and {date} in output files",
|
|
79
|
-
"node tools/replaceVersionAndDate.cjs dist/umd/dexie-cloud-addon.js dist/modern/dexie-cloud-addon.js"
|
|
80
|
-
],
|
|
81
|
-
"service-worker": [
|
|
82
|
-
"# Create a modern bundle in dist/modern",
|
|
83
|
-
"rollup -c tools/build-configs/rollup.sw.modern.config.js",
|
|
84
|
-
"# Replace {version} and {date} in output files",
|
|
85
|
-
"node tools/replaceVersionAndDate.cjs dist/umd/service-worker.js dist/modern/service-worker.js"
|
|
55
|
+
"rollup -c tools/build-configs/rollup.config.mjs"
|
|
86
56
|
],
|
|
87
57
|
"test": [
|
|
88
58
|
"just-build test-unit"
|
|
@@ -95,11 +65,12 @@
|
|
|
95
65
|
"author": "david.fahlander@gmail.com",
|
|
96
66
|
"license": "Apache-2.0",
|
|
97
67
|
"devDependencies": {
|
|
98
|
-
"@rollup/plugin-commonjs": "^
|
|
99
|
-
"@rollup/plugin-node-resolve": "^
|
|
68
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
69
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
70
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
71
|
+
"@rollup/plugin-typescript": "^11.1.5",
|
|
100
72
|
"@types/node": "^18.11.18",
|
|
101
|
-
"dreambase-library": "^1.0.
|
|
102
|
-
"dts-bundle-generator": "^8.0.1",
|
|
73
|
+
"dreambase-library": "^1.0.21",
|
|
103
74
|
"just-build": "*",
|
|
104
75
|
"karma": "*",
|
|
105
76
|
"karma-browserstack-launcher": "*",
|
|
@@ -107,12 +78,7 @@
|
|
|
107
78
|
"karma-firefox-launcher": "*",
|
|
108
79
|
"karma-qunit": "*",
|
|
109
80
|
"preact": "*",
|
|
110
|
-
"rollup": "^
|
|
111
|
-
"rollup-plugin-alias": "*",
|
|
112
|
-
"rollup-plugin-commonjs": "*",
|
|
113
|
-
"rollup-plugin-dts": "^4.0.1",
|
|
114
|
-
"rollup-plugin-node-resolve": "*",
|
|
115
|
-
"rollup-plugin-sourcemaps": "*",
|
|
81
|
+
"rollup": "^4.1.4",
|
|
116
82
|
"terser": "^5.20.0",
|
|
117
83
|
"tslib": "*",
|
|
118
84
|
"typescript": "^4.9.4"
|
|
@@ -127,9 +93,8 @@
|
|
|
127
93
|
"scripts": {
|
|
128
94
|
"test": "just-build test && pnpm run test-unit",
|
|
129
95
|
"test-unit": "karma start test/unit/karma.conf.js --single-run",
|
|
130
|
-
"build": "
|
|
131
|
-
"watch": "
|
|
132
|
-
"clean": "rm -rf tools/tmp dist test/unit/bundle.*"
|
|
133
|
-
"copydts": "bash ./copydts.sh"
|
|
96
|
+
"build": "rollup -c tools/build-configs/rollup.config.mjs",
|
|
97
|
+
"watch": "rollup -c tools/build-configs/rollup.config.mjs --watch",
|
|
98
|
+
"clean": "rm -rf tools/tmp dist test/unit/bundle.*"
|
|
134
99
|
}
|
|
135
100
|
}
|