dexie-cloud-addon 4.0.1-beta.45 → 4.0.1-beta.47
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/modern/dexie-cloud-addon.js +485 -317
- package/dist/modern/dexie-cloud-addon.js.map +1 -1
- package/dist/modern/dexie-cloud-addon.min.js +1 -1
- package/dist/modern/dexie-cloud-addon.min.js.map +1 -1
- package/dist/modern/service-worker.js +469 -249
- package/dist/modern/service-worker.js.map +1 -1
- package/dist/modern/service-worker.min.js +1 -1
- package/dist/modern/service-worker.min.js.map +1 -1
- package/dist/types/DexieCloudAPI.d.ts +3 -0
- package/dist/types/DexieCloudOptions.d.ts +1 -0
- package/dist/types/InvalidLicenseError.d.ts +5 -0
- package/dist/types/authentication/TokenErrorResponseError.d.ts +10 -0
- package/dist/types/authentication/authenticate.d.ts +3 -3
- package/dist/types/authentication/interactWithUser.d.ts +3 -0
- package/dist/types/authentication/logout.d.ts +5 -0
- package/dist/types/authentication/waitUntil.d.ts +3 -0
- package/dist/types/currentUserEmitter.d.ts +1 -1
- package/dist/types/db/entities/UserLogin.d.ts +6 -0
- package/dist/types/default-ui/LoginDialog.d.ts +2 -5
- package/dist/types/dexie-cloud-client.d.ts +2 -0
- package/dist/types/helpers/resolveText.d.ts +14 -0
- package/dist/types/isEagerSyncDisabled.d.ts +2 -0
- package/dist/types/middlewares/createMutationTrackingMiddleware.d.ts +1 -1
- package/dist/types/prodLog.d.ts +9 -0
- package/dist/types/sync/performGuardedJob.d.ts +2 -4
- package/dist/types/sync/ratelimit.d.ts +3 -0
- package/dist/types/sync/sync.d.ts +0 -1
- package/dist/types/types/DXCAlert.d.ts +1 -1
- package/dist/types/types/DXCUserInteraction.d.ts +40 -2
- package/dist/types/types/SyncState.d.ts +1 -0
- package/dist/umd/dexie-cloud-addon.js +484 -316
- package/dist/umd/dexie-cloud-addon.js.map +1 -1
- package/dist/umd/dexie-cloud-addon.min.js +1 -1
- package/dist/umd/dexie-cloud-addon.min.js.map +1 -1
- package/dist/umd/service-worker.js +467 -247
- package/dist/umd/service-worker.js.map +1 -1
- package/dist/umd/service-worker.min.js +1 -1
- package/dist/umd/service-worker.min.js.map +1 -1
- package/package.json +7 -6
- package/LICENSE +0 -202
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TokenErrorResponse } from 'dexie-cloud-common';
|
|
2
|
+
export declare class TokenErrorResponseError extends Error {
|
|
3
|
+
title: string;
|
|
4
|
+
messageCode: 'INVALID_OTP' | 'INVALID_EMAIL' | 'LICENSE_LIMIT_REACHED' | 'GENERIC_ERROR';
|
|
5
|
+
message: string;
|
|
6
|
+
messageParams?: {
|
|
7
|
+
[param: string]: string;
|
|
8
|
+
};
|
|
9
|
+
constructor({ title, message, messageCode, messageParams, }: TokenErrorResponse);
|
|
10
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TokenFinalResponse } from 'dexie-cloud-common';
|
|
1
|
+
import type { TokenErrorResponse, TokenFinalResponse } from 'dexie-cloud-common';
|
|
2
2
|
import { BehaviorSubject } from 'rxjs';
|
|
3
3
|
import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
4
4
|
import { UserLogin } from '../db/entities/UserLogin';
|
|
@@ -10,8 +10,8 @@ export type FetchTokenCallback = (tokenParams: {
|
|
|
10
10
|
email?: string;
|
|
11
11
|
grant_type?: string;
|
|
12
12
|
};
|
|
13
|
-
}) => Promise<TokenFinalResponse>;
|
|
14
|
-
export declare function loadAccessToken(db: DexieCloudDB): Promise<
|
|
13
|
+
}) => Promise<TokenFinalResponse | TokenErrorResponse>;
|
|
14
|
+
export declare function loadAccessToken(db: DexieCloudDB): Promise<UserLogin | null>;
|
|
15
15
|
export declare function authenticate(url: string, context: UserLogin, fetchToken: FetchTokenCallback, userInteraction: BehaviorSubject<DXCUserInteraction | undefined>, hints?: {
|
|
16
16
|
userId?: string;
|
|
17
17
|
email?: string;
|
|
@@ -6,6 +6,8 @@ export interface DXCUserInteractionRequest {
|
|
|
6
6
|
type: DXCUserInteraction['type'];
|
|
7
7
|
title: string;
|
|
8
8
|
alerts: DXCAlert[];
|
|
9
|
+
submitLabel?: string;
|
|
10
|
+
cancelLabel?: string | null;
|
|
9
11
|
fields: {
|
|
10
12
|
[name: string]: DXCInputField;
|
|
11
13
|
};
|
|
@@ -16,3 +18,4 @@ export declare function interactWithUser<T extends DXCUserInteractionRequest>(us
|
|
|
16
18
|
export declare function alertUser(userInteraction: BehaviorSubject<DXCUserInteraction | undefined>, title: string, ...alerts: DXCAlert[]): Promise<{}>;
|
|
17
19
|
export declare function promptForEmail(userInteraction: BehaviorSubject<DXCUserInteraction | undefined>, title: string, emailHint?: string): Promise<string>;
|
|
18
20
|
export declare function promptForOTP(userInteraction: BehaviorSubject<DXCUserInteraction | undefined>, email: string, alert?: DXCAlert): Promise<string>;
|
|
21
|
+
export declare function confirmLogout(userInteraction: BehaviorSubject<DXCUserInteraction | undefined>, currentUserId: string, numUnsyncedChanges: number): Promise<boolean>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import Dexie from "dexie";
|
|
2
2
|
import { BehaviorSubject } from "rxjs";
|
|
3
|
-
export declare const getCurrentUserEmitter: (x: Dexie) => BehaviorSubject<import("./
|
|
3
|
+
export declare const getCurrentUserEmitter: (x: Dexie) => BehaviorSubject<import("./dexie-cloud-client").UserLogin>;
|
|
@@ -5,6 +5,12 @@ export interface UserLogin {
|
|
|
5
5
|
claims: {
|
|
6
6
|
[claimName: string]: any;
|
|
7
7
|
};
|
|
8
|
+
license?: {
|
|
9
|
+
type: 'demo' | 'eval' | 'prod' | 'client';
|
|
10
|
+
status: 'ok' | 'expired' | 'deactivated';
|
|
11
|
+
validUntil?: Date;
|
|
12
|
+
evalDaysLeft?: number;
|
|
13
|
+
};
|
|
8
14
|
lastLogin: Date;
|
|
9
15
|
accessToken?: string;
|
|
10
16
|
accessTokenExpiration?: Date;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { h } from 'preact';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare function LoginDialog({ title, alerts, fields, onCancel, onSubmit, }: DXCGenericUserInteraction<string, {
|
|
5
|
-
[name: string]: DXCInputField;
|
|
6
|
-
}>): h.JSX.Element;
|
|
2
|
+
import { DXCUserInteraction } from '../types/DXCUserInteraction';
|
|
3
|
+
export declare function LoginDialog({ title, type, alerts, fields, submitLabel, cancelLabel, onCancel, onSubmit, }: DXCUserInteraction): h.JSX.Element;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import Dexie from 'dexie';
|
|
2
2
|
import './extend-dexie-interface';
|
|
3
|
+
import { UserLogin } from './db/entities/UserLogin';
|
|
3
4
|
export { DexieCloudTable } from './DexieCloudTable';
|
|
4
5
|
export * from './getTiedRealmId';
|
|
5
6
|
export { DBRealm, DBRealmMember, DBRealmRole, DBSyncedObject, DBPermissionSet, } from 'dexie-cloud-common';
|
|
6
7
|
export { Invite } from './Invite';
|
|
8
|
+
export { UserLogin };
|
|
7
9
|
export declare function dexieCloud(dexie: Dexie): void;
|
|
8
10
|
export declare namespace dexieCloud {
|
|
9
11
|
var version: string;
|
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
import { DXCAlert } from "../types/DXCAlert";
|
|
2
|
+
/** Resolve a message template with parameters.
|
|
3
|
+
*
|
|
4
|
+
* Example:
|
|
5
|
+
* resolveText({
|
|
6
|
+
* message: "Hello {name}!",
|
|
7
|
+
* messageCode: "HELLO",
|
|
8
|
+
* messageParams: {name: "David"}
|
|
9
|
+
* }) => "Hello David!"
|
|
10
|
+
*
|
|
11
|
+
* @param message Template message with {vars} in it.
|
|
12
|
+
* @param messageCode Unique code for the message. Can be used for translation.
|
|
13
|
+
* @param messageParams Parameters to be used in the message.
|
|
14
|
+
* @returns A final message where parameters have been replaced with values.
|
|
15
|
+
*/
|
|
2
16
|
export declare function resolveText({ message, messageCode, messageParams }: DXCAlert): string;
|
|
@@ -14,4 +14,4 @@ export interface MutationTrackingMiddlewareArgs {
|
|
|
14
14
|
* changes to server and cleanup the tracked mutations once the server has
|
|
15
15
|
* ackowledged that it got them.
|
|
16
16
|
*/
|
|
17
|
-
export declare function createMutationTrackingMiddleware({ currentUserObservable, db }: MutationTrackingMiddlewareArgs): Middleware<DBCore>;
|
|
17
|
+
export declare function createMutationTrackingMiddleware({ currentUserObservable, db, }: MutationTrackingMiddlewareArgs): Middleware<DBCore>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A way to log to console in production without terser stripping out
|
|
2
|
+
* it from the release bundle.
|
|
3
|
+
* This should be used very rarely and only in places where it's
|
|
4
|
+
* absolutely necessary to log something in production.
|
|
5
|
+
*
|
|
6
|
+
* @param level
|
|
7
|
+
* @param args
|
|
8
|
+
*/
|
|
9
|
+
export declare function prodLog(level: 'log' | 'warn' | 'error' | 'debug', ...args: any[]): void;
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { DexieCloudDB } from
|
|
2
|
-
export declare function performGuardedJob(db: DexieCloudDB, jobName: string,
|
|
3
|
-
awaitRemoteJob?: boolean;
|
|
4
|
-
}): Promise<void>;
|
|
1
|
+
import { DexieCloudDB } from "../db/DexieCloudDB";
|
|
2
|
+
export declare function performGuardedJob<T>(db: DexieCloudDB, jobName: string, job: () => Promise<T>): Promise<T>;
|
|
@@ -2,7 +2,6 @@ import { DexieCloudDB } from '../db/DexieCloudDB';
|
|
|
2
2
|
import { DexieCloudOptions } from '../DexieCloudOptions';
|
|
3
3
|
import { DBOperationsSet, DexieCloudSchema } from 'dexie-cloud-common';
|
|
4
4
|
export declare const CURRENT_SYNC_WORKER = "currentSyncWorker";
|
|
5
|
-
export declare let numberOfSyncRequests: number;
|
|
6
5
|
export interface SyncOptions {
|
|
7
6
|
isInitialSync?: boolean;
|
|
8
7
|
cancelToken?: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DXCAlert } from './DXCAlert';
|
|
2
2
|
import { DXCInputField } from './DXCInputField';
|
|
3
|
-
export type DXCUserInteraction = DXCGenericUserInteraction | DXCEmailPrompt | DXCOTPPrompt | DXCMessageAlert;
|
|
3
|
+
export type DXCUserInteraction = DXCGenericUserInteraction | DXCEmailPrompt | DXCOTPPrompt | DXCMessageAlert | DXCLogoutConfirmation;
|
|
4
4
|
export interface DXCGenericUserInteraction<Type extends string = "generic", TFields extends {
|
|
5
5
|
[name: string]: DXCInputField;
|
|
6
6
|
} = any> {
|
|
@@ -8,11 +8,16 @@ export interface DXCGenericUserInteraction<Type extends string = "generic", TFie
|
|
|
8
8
|
title: string;
|
|
9
9
|
alerts: DXCAlert[];
|
|
10
10
|
fields: TFields;
|
|
11
|
+
submitLabel: string;
|
|
12
|
+
cancelLabel: string | null;
|
|
11
13
|
onSubmit: (params: {
|
|
12
14
|
[P in keyof TFields]: string;
|
|
13
15
|
}) => void;
|
|
14
16
|
onCancel: () => void;
|
|
15
17
|
}
|
|
18
|
+
/** When the system needs to prompt for an email address for login.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
16
21
|
export interface DXCEmailPrompt {
|
|
17
22
|
type: 'email';
|
|
18
23
|
title: string;
|
|
@@ -23,11 +28,18 @@ export interface DXCEmailPrompt {
|
|
|
23
28
|
placeholder: string;
|
|
24
29
|
};
|
|
25
30
|
};
|
|
31
|
+
submitLabel: string;
|
|
32
|
+
cancelLabel: string;
|
|
26
33
|
onSubmit: (params: {
|
|
27
34
|
email: string;
|
|
35
|
+
} | {
|
|
36
|
+
[paramName: string]: string;
|
|
28
37
|
}) => void;
|
|
29
38
|
onCancel: () => void;
|
|
30
39
|
}
|
|
40
|
+
/** When the system needs to prompt for an OTP code.
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
31
43
|
export interface DXCOTPPrompt {
|
|
32
44
|
type: 'otp';
|
|
33
45
|
title: string;
|
|
@@ -38,16 +50,42 @@ export interface DXCOTPPrompt {
|
|
|
38
50
|
label: string;
|
|
39
51
|
};
|
|
40
52
|
};
|
|
53
|
+
submitLabel: string;
|
|
54
|
+
cancelLabel: string;
|
|
41
55
|
onSubmit: (params: {
|
|
42
56
|
otp: string;
|
|
57
|
+
} | {
|
|
58
|
+
[paramName: string]: string;
|
|
43
59
|
}) => void;
|
|
44
60
|
onCancel: () => void;
|
|
45
61
|
}
|
|
62
|
+
/** When the system must inform about errors, warnings or information */
|
|
46
63
|
export interface DXCMessageAlert {
|
|
47
64
|
type: 'message-alert';
|
|
48
65
|
title: string;
|
|
49
66
|
alerts: DXCAlert[];
|
|
50
|
-
fields: {
|
|
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;
|
|
51
89
|
onSubmit: (params: {
|
|
52
90
|
[paramName: string]: string;
|
|
53
91
|
}) => void;
|