dexie-cloud-addon 4.0.0-beta.20 → 4.0.0-beta.21

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.
@@ -4,17 +4,17 @@ import { UserLogin } from './db/entities/UserLogin';
4
4
  import * as Rx from 'rxjs';
5
5
  import { PersistedSyncState } from './db/entities/PersistedSyncState';
6
6
  import { SyncState } from './types/SyncState';
7
- import { DexieCloudServerState } from './DexieCloudServerState';
8
7
  import { DXCUserInteraction } from './types/DXCUserInteraction';
9
8
  import { DXCWebSocketStatus } from './DXCWebSocketStatus';
10
9
  import { PermissionChecker } from './PermissionChecker';
11
10
  import { DexieCloudSyncOptions } from "./DexieCloudSyncOptions";
12
11
  import { Invite } from './Invite';
12
+ /** The API of db.cloud, where `db` is an instance of Dexie with dexie-cloud-addon active.
13
+ */
13
14
  export interface DexieCloudAPI {
14
15
  version: string;
15
16
  options: DexieCloudOptions | null;
16
17
  schema: DexieCloudSchema | null;
17
- serverState: DexieCloudServerState | null;
18
18
  currentUserId: string;
19
19
  currentUser: Rx.BehaviorSubject<UserLogin>;
20
20
  webSocketStatus: Rx.BehaviorSubject<DXCWebSocketStatus>;
@@ -30,6 +30,8 @@ export interface DexieCloudAPI {
30
30
  /** Login using Dexie Cloud OTP or Demo user.
31
31
  *
32
32
  * @param email Email to authenticate
33
+ * @param userId Optional userId to authenticate
34
+ * @param grant_type requested grant type
33
35
  */
34
36
  login(hint?: {
35
37
  email?: string;
@@ -40,14 +42,25 @@ export interface DexieCloudAPI {
40
42
  * Connect to given URL
41
43
  */
42
44
  configure(options: DexieCloudOptions): void;
43
- /** Wait until a full sync is done.
45
+ /** Trigger a sync
44
46
  *
45
47
  */
46
48
  sync(options?: DexieCloudSyncOptions): Promise<void>;
49
+ /** Method that returns an observable of the available permissions of given
50
+ * entity.
51
+ *
52
+ * @param entity Entity to check permission for
53
+ */
47
54
  permissions<T extends {
48
55
  owner: string;
49
56
  realmId: string;
50
57
  table: () => string;
51
58
  }>(entity: T): Rx.Observable<PermissionChecker<T>>;
59
+ /** Method that returns an observable of the available permissions of given
60
+ * object and table name.
61
+ *
62
+ * @param obj Object retrieved from a dexie query
63
+ * @param table Table name that the object was retrieved from
64
+ */
52
65
  permissions<T>(obj: T, table: string): Rx.Observable<PermissionChecker<T, string>>;
53
66
  }
@@ -6,9 +6,9 @@ export interface DexieCloudOptions {
6
6
  databaseUrl: string;
7
7
  requireAuth?: boolean;
8
8
  tryUseServiceWorker?: boolean;
9
+ periodicSync?: PeriodicSyncOptions;
9
10
  customLoginGui?: boolean;
10
11
  unsyncedTables?: string[];
11
- periodicSync?: PeriodicSyncOptions;
12
12
  nameSuffix?: boolean;
13
13
  disableWebSocket?: boolean;
14
14
  fetchTokens?: (tokenParams: {
@@ -3,4 +3,6 @@ export interface Invite extends DBRealmMember {
3
3
  realm?: DBRealm & {
4
4
  permissions: DBPermissionSet;
5
5
  };
6
+ accept(): Promise<void>;
7
+ reject(): Promise<void>;
6
8
  }
@@ -1,4 +1,3 @@
1
- import { DXCUserInteraction } from "../../types/DXCUserInteraction";
2
1
  export interface UserLogin {
3
2
  userId?: string;
4
3
  name?: string;
@@ -14,5 +13,4 @@ export interface UserLogin {
14
13
  nonExportablePrivateKey?: CryptoKey;
15
14
  publicKey?: CryptoKey;
16
15
  isLoggedIn?: boolean;
17
- interaction?: DXCUserInteraction;
18
16
  }
@@ -1,25 +1,3 @@
1
1
  import { Dexie } from 'dexie';
2
2
  import { Invite } from './Invite';
3
- export declare const getInvitesObservable: (x: Dexie) => import("./mapValueObservable").ObservableWithCurrentValue<(Invite | {
4
- realm: import("dexie-cloud-common").DBRealm & {
5
- permissions: import("dexie-cloud-common").DBPermissionSet;
6
- };
7
- id: string;
8
- userId?: string | undefined;
9
- email?: string | undefined;
10
- name?: string | undefined;
11
- invite?: boolean | undefined;
12
- invitedDate?: Date | undefined;
13
- invitedBy?: {
14
- name: string;
15
- email: string;
16
- userId: string;
17
- } | undefined;
18
- accepted?: Date | undefined;
19
- rejected?: Date | undefined;
20
- roles?: string[] | undefined;
21
- permissions?: import("dexie-cloud-common").DBPermissionSet | undefined;
22
- realmId: string;
23
- owner: string;
24
- $ts?: number | undefined;
25
- })[]>;
3
+ export declare const getInvitesObservable: (x: Dexie) => import("./mapValueObservable").ObservableWithCurrentValue<Invite[]>;
@@ -108,7 +108,7 @@
108
108
  *
109
109
  * ==========================================================================
110
110
  *
111
- * Version 4.0.0-beta.20, Tue May 24 2022
111
+ * Version 4.0.0-beta.21, Tue Jun 07 2022
112
112
  *
113
113
  * https://dexie.org
114
114
  *
@@ -6788,7 +6788,31 @@
6788
6788
  };
6789
6789
  var emailMembersById = membersByEmail.reduce(reducer, {});
6790
6790
  var membersById = accessControl.selfMembers.reduce(reducer, emailMembersById);
6791
- return Object.values(membersById).filter(function (m) { return !m.accepted; });
6791
+ return Object.values(membersById)
6792
+ .filter(function (invite) { return !invite.accepted && !invite.rejected; })
6793
+ .map(function (invite) { return (Object.assign(Object.assign({}, invite), { accept: function () {
6794
+ return __awaiter$1(this, void 0, void 0, function () {
6795
+ return __generator$1(this, function (_k) {
6796
+ switch (_k.label) {
6797
+ case 0: return [4 /*yield*/, db.members.update(invite.id, { accepted: new Date() })];
6798
+ case 1:
6799
+ _k.sent();
6800
+ return [2 /*return*/];
6801
+ }
6802
+ });
6803
+ });
6804
+ }, reject: function () {
6805
+ return __awaiter$1(this, void 0, void 0, function () {
6806
+ return __generator$1(this, function (_k) {
6807
+ switch (_k.label) {
6808
+ case 0: return [4 /*yield*/, db.members.update(invite.id, { rejected: new Date() })];
6809
+ case 1:
6810
+ _k.sent();
6811
+ return [2 /*return*/];
6812
+ }
6813
+ });
6814
+ });
6815
+ } })); });
6792
6816
  })), []);
6793
6817
  });
6794
6818
  function getTiedRealmId(objectId) {
@@ -6844,10 +6868,9 @@
6844
6868
  currentUserEmitter.next(UNAUTHORIZED_USER);
6845
6869
  });
6846
6870
  dexie.cloud = {
6847
- version: '4.0.0-beta.20',
6871
+ version: '4.0.0-beta.21',
6848
6872
  options: Object.assign({}, DEFAULT_OPTIONS),
6849
6873
  schema: null,
6850
- serverState: null,
6851
6874
  get currentUserId() {
6852
6875
  return currentUserEmitter.value.userId || UNAUTHORIZED_USER.userId;
6853
6876
  },
@@ -7176,7 +7199,7 @@
7176
7199
  });
7177
7200
  }
7178
7201
  }
7179
- dexieCloud.version = '4.0.0-beta.20';
7202
+ dexieCloud.version = '4.0.0-beta.21';
7180
7203
  Dexie__default["default"].Cloud = dexieCloud;
7181
7204
 
7182
7205
  exports["default"] = dexieCloud;