@data-weave/backend-firestore 0.4.22 → 0.4.24

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.
@@ -1,12 +1,9 @@
1
1
  import { Cache, DataManager, IdentifiableReference, List, ListPaginationParams, WithMetadata, WithoutId } from '@data-weave/datamanager';
2
- import { FirestoreListContext } from './FirestoreList';
2
+ import { FirestoreList, FirestoreListContext } from './FirestoreList';
3
3
  import { FirestoreSerializedMetadata } from './FirestoreMetadata';
4
- import { FirestoreReferenceContext } from './FirestoreReference';
4
+ import { FirestoreReference, FirestoreReferenceContext } from './FirestoreReference';
5
5
  import { FilterBy, FirebaseCreateOptions, Firestore, FirestoreDataConverter, FirestoreReadMode, FirestoreReadOptions, FirestoreTypes, FirestoreWriteOptions, OrderBy, WithFieldValue } from './firestoreTypes';
6
6
  export type FirebaseDataManagerDeleteMode = 'soft' | 'hard';
7
- type Constructor<T = {}> = new (...args: any[]) => T;
8
- export type FirestoreReferenceClass = Constructor<IdentifiableReference<any>>;
9
- export type FirestoreListClass = Constructor<List<any>>;
10
7
  export interface FirebaseDataManagerOptions {
11
8
  readonly idResolver?: () => string;
12
9
  readonly deleteMode?: FirebaseDataManagerDeleteMode;
@@ -14,12 +11,12 @@ export interface FirebaseDataManagerOptions {
14
11
  readonly preventOverwriteOnCreate?: boolean;
15
12
  readonly errorInterceptor?: (error: unknown, ctx: FirestoreReferenceContext | FirestoreListContext) => void;
16
13
  readonly snapshotOptions?: FirestoreTypes.SnapshotOptions;
17
- readonly Reference?: FirestoreReferenceClass;
18
- readonly List?: FirestoreListClass;
14
+ readonly Reference?: typeof FirestoreReference;
15
+ readonly List?: typeof FirestoreList;
19
16
  readonly listCache?: Cache;
20
17
  readonly refCache?: Cache;
21
18
  }
22
- export interface QueryParams<T extends FirestoreTypes.DocumentData> {
19
+ export interface QueryParams<T> {
23
20
  readonly filters?: Array<FilterBy<T & FirestoreSerializedMetadata>>;
24
21
  readonly orderBy?: Array<OrderBy<T & FirestoreSerializedMetadata>>;
25
22
  }
@@ -36,14 +33,13 @@ export declare class FirestoreDataManager<T extends FirestoreTypes.DocumentData,
36
33
  private listCache;
37
34
  constructor(firestore: Firestore, collectionPath: string, converter: FirestoreDataConverter<T, SerializedT>, opts?: FirebaseDataManagerOptions | undefined);
38
35
  read(id: string, options?: FirestoreReadOptions): Promise<WithMetadata<T> | undefined>;
39
- create(data: WithFieldValue<WithoutId<T>>, options?: FirebaseCreateOptions): Promise<IdentifiableReference<any>>;
36
+ create(data: WithFieldValue<WithoutId<T>>, options?: FirebaseCreateOptions): Promise<IdentifiableReference<WithMetadata<T>>>;
40
37
  private _update;
41
38
  update(id: string, data: WithoutId<Partial<WithFieldValue<T>>>, options?: FirestoreWriteOptions): Promise<void>;
42
39
  upsert(id: string, data: WithFieldValue<WithoutId<T>>, options?: FirestoreWriteOptions): Promise<void>;
43
40
  delete(id: string, options?: FirestoreWriteOptions): Promise<void>;
44
- getRef(id: string): IdentifiableReference<any>;
41
+ getRef(id: string): IdentifiableReference<WithMetadata<T>>;
45
42
  private _getFilteredQuery;
46
- getList(params?: QueryParams<SerializedT> & ListPaginationParams): List<any>;
43
+ getList(params?: QueryParams<SerializedT> & ListPaginationParams): List<WithMetadata<T>>;
47
44
  private preventOverwriteOnCreate;
48
45
  }
49
- export {};
@@ -23,13 +23,13 @@ class FirestoreMetadataConverter {
23
23
  };
24
24
  }
25
25
  fromFirestore(snapshot, options) {
26
- var _a, _b;
26
+ var _a, _b, _c, _d;
27
27
  const data = snapshot.data(options);
28
28
  return {
29
29
  id: snapshot.ref.id,
30
30
  // TODO: add warning in case data type is not as expected
31
- createdAt: (_a = data[FIRESTORE_INTERAL_KEYS.CREATED_AT]) === null || _a === void 0 ? void 0 : _a.toDate(),
32
- updatedAt: (_b = data[FIRESTORE_INTERAL_KEYS.UPDATED_AT]) === null || _b === void 0 ? void 0 : _b.toDate(),
31
+ createdAt: (_b = (_a = data[FIRESTORE_INTERAL_KEYS.CREATED_AT]) === null || _a === void 0 ? void 0 : _a.toDate()) !== null && _b !== void 0 ? _b : new Date(),
32
+ updatedAt: (_d = (_c = data[FIRESTORE_INTERAL_KEYS.UPDATED_AT]) === null || _c === void 0 ? void 0 : _c.toDate()) !== null && _d !== void 0 ? _d : new Date(),
33
33
  deleted: data[FIRESTORE_INTERAL_KEYS.DELETED],
34
34
  };
35
35
  }
package/lib/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  // Generated by genversion.
3
- module.exports = '0.4.22';
3
+ module.exports = '0.4.24';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-weave/backend-firestore",
3
- "version": "0.4.22",
3
+ "version": "0.4.24",
4
4
  "author": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -23,8 +23,8 @@
23
23
  "registry": "https://registry.npmjs.org/"
24
24
  },
25
25
  "peerDependencies": {
26
- "@data-weave/datamanager": "~0.4.21",
26
+ "@data-weave/datamanager": "~0.4.23",
27
27
  "firebase": ">=11.0.0"
28
28
  },
29
- "gitHead": "9072bd15da9565106e0641d6b78d67729689599e"
29
+ "gitHead": "6fed915392b808c1e4f737237d5a06b99a0b4ab6"
30
30
  }