@dereekb/firebase 4.0.0 → 5.0.0
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/CHANGELOG.md +37 -0
- package/LICENSE +21 -0
- package/package.json +13 -6
- package/src/lib/client/firestore/driver.accessor.batch.d.ts +2 -2
- package/src/lib/client/firestore/driver.accessor.batch.js.map +1 -1
- package/src/lib/client/firestore/driver.accessor.default.d.ts +1 -1
- package/src/lib/client/firestore/driver.accessor.default.js.map +1 -1
- package/src/lib/client/firestore/driver.accessor.js.map +1 -1
- package/src/lib/client/firestore/driver.accessor.transaction.d.ts +2 -2
- package/src/lib/client/firestore/driver.accessor.transaction.js.map +1 -1
- package/src/lib/client/firestore/driver.d.ts +1 -2
- package/src/lib/client/firestore/driver.query.d.ts +3 -3
- package/src/lib/client/firestore/driver.query.js.map +1 -1
- package/src/lib/client/function/function.d.ts +2 -2
- package/src/lib/client/function/function.factory.d.ts +1 -1
- package/src/lib/client/function/function.factory.js.map +1 -1
- package/src/lib/common/firestore/accessor/accessor.d.ts +9 -8
- package/src/lib/common/firestore/accessor/accessor.js.map +1 -1
- package/src/lib/common/firestore/accessor/accessor.transaction.d.ts +1 -1
- package/src/lib/common/firestore/accessor/document.js +2 -0
- package/src/lib/common/firestore/accessor/document.js.map +1 -1
- package/src/lib/common/firestore/context.d.ts +1 -2
- package/src/lib/common/firestore/context.js.map +1 -1
- package/src/lib/common/firestore/driver/transaction.d.ts +4 -1
- package/src/lib/common/firestore/query/accumulator.d.ts +1 -1
- package/src/lib/common/firestore/query/accumulator.js.map +1 -1
- package/src/lib/common/firestore/query/constraint.d.ts +12 -8
- package/src/lib/common/firestore/query/constraint.js +1 -1
- package/src/lib/common/firestore/query/constraint.js.map +1 -1
- package/src/lib/common/firestore/query/iterator.d.ts +4 -4
- package/src/lib/common/firestore/query/iterator.js.map +1 -1
- package/src/lib/common/firestore/query/query.util.d.ts +1 -1
- package/src/lib/common/firestore/query/watcher.d.ts +6 -6
- package/src/lib/common/firestore/query/watcher.js +12 -8
- package/src/lib/common/firestore/query/watcher.js.map +1 -1
- package/src/lib/common/firestore/snapshot/snapshot.d.ts +61 -12
- package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +37 -20
- package/src/lib/common/firestore/snapshot/snapshot.field.js +57 -19
- package/src/lib/common/firestore/snapshot/snapshot.field.js.map +1 -1
- package/src/lib/common/firestore/snapshot/snapshot.js +12 -5
- package/src/lib/common/firestore/snapshot/snapshot.js.map +1 -1
- package/src/lib/common/firestore/types.d.ts +12 -7
- package/src/lib/common/firestore/types.js +2 -0
- package/src/lib/common/firestore/types.js.map +1 -1
- package/src/lib/model/user.d.ts +1 -2
- package/test/CHANGELOG.md +22 -0
- package/test/package.json +7 -8
- package/test/src/lib/common/firestore.mock.item.d.ts +44 -20
- package/test/src/lib/common/firestore.mock.item.fixture.d.ts +1 -1
- package/test/src/lib/common/firestore.mock.item.fixture.js +2 -2
- package/test/src/lib/common/firestore.mock.item.fixture.js.map +1 -1
- package/test/src/lib/common/firestore.mock.item.js +24 -26
- package/test/src/lib/common/firestore.mock.item.js.map +1 -1
- package/test/src/lib/common/test.driver.accessor.js +32 -30
- package/test/src/lib/common/test.driver.accessor.js.map +1 -1
- package/test/src/lib/common/test.driver.query.js +30 -5
- package/test/src/lib/common/test.driver.query.js.map +1 -1
|
@@ -16,15 +16,19 @@ function iterationQueryDocChangeWatcher(config) {
|
|
|
16
16
|
)));
|
|
17
17
|
}), (0, rxjs_1.shareReplay)(1));
|
|
18
18
|
const event$ = stream$.pipe((0, rxjs_1.map)(event => {
|
|
19
|
-
var _a, _b, _c;
|
|
20
19
|
const changes = event.docChanges();
|
|
21
|
-
const results = (0, util_1.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
const results = (0, util_1.build)({
|
|
21
|
+
base: (0, util_1.groupValues)(changes, (x) => x.type),
|
|
22
|
+
build: (x) => {
|
|
23
|
+
var _a, _b, _c;
|
|
24
|
+
x.time = new Date();
|
|
25
|
+
x.changes = changes;
|
|
26
|
+
x.added = (_a = x.added) !== null && _a !== void 0 ? _a : [];
|
|
27
|
+
x.removed = (_b = x.removed) !== null && _b !== void 0 ? _b : [];
|
|
28
|
+
x.modified = (_c = x.modified) !== null && _c !== void 0 ? _c : [];
|
|
29
|
+
x.type = iterationQueryDocChangeWatcherChangeTypeForGroup(x);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
28
32
|
return results;
|
|
29
33
|
}), (0, rxjs_1.shareReplay)(1));
|
|
30
34
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watcher.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/query/watcher.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"watcher.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/query/watcher.ts"],"names":[],"mappings":";;;AAAA,wCAA6D;AAC7D,wCAA0C;AAC1C,+BAA4E;AAK/D,QAAA,kCAAkC,GAAG,CAAC,CAAC;AAsCpD,SAAgB,8BAA8B,CAAc,MAA+C;IACzG,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,GAAG,0CAAkC,EAAE,GAAG,MAAM,CAAC;IAEzF,MAAM,OAAO,GAAG,QAAQ,CAAC,iBAAiB,CAAC,2BAA2B,CAAC,IAAI,CACzE,IAAA,gBAAS,EAAC,CAAC,KAAK,EAAE,EAAE;;QAClB,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAI,KAAK,CAAC,KAAiE,CAAC,KAAwC,CAAC;QAC3I,MAAM,eAAe,GAAG,IAAA,gBAAS,EAAC,IAAI,EAAE,eAAe,CAAC,CAAC;QAEzD,gDAAgD;QAChD,OAAO,IAAA,YAAK,EAAC,MAAA,eAAe,CAAC,SAAS,mCAAI,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAA,gBAAS,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,CACtF,IAAA,WAAI,EAAC,CAAC,CAAC,CAAE,+EAA+E;SACzF,CAAC,CAAC,CAAC;IACN,CAAC,CAAC,EACF,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;IAEF,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CACzB,IAAA,UAAG,EAAC,KAAK,CAAC,EAAE;QACV,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC;QAEnC,MAAM,OAAO,GAAG,IAAA,YAAK,EAAC;YACpB,IAAI,EAAE,IAAA,kBAAW,EAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAqD;YAC7F,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;;gBACX,CAAC,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;gBACpB,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC;gBACpB,CAAC,CAAC,KAAK,GAAG,MAAA,CAAC,CAAC,KAAK,mCAAI,EAAE,CAAC;gBACxB,CAAC,CAAC,OAAO,GAAG,MAAA,CAAC,CAAC,OAAO,mCAAI,EAAE,CAAC;gBAC5B,CAAC,CAAC,QAAQ,GAAG,MAAA,CAAC,CAAC,QAAQ,mCAAI,EAAE,CAAC;gBAC9B,CAAC,CAAC,IAAI,GAAG,gDAAgD,CAAC,CAA2C,CAAC,CAAC;YACzG,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,EACF,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;IAEF,OAAO;QACL,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC;AAzCD,wEAyCC;AAED,SAAgB,gDAAgD,CAAc,KAAmD;IAC/H,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IACxC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5C,IAAI,IAA8C,CAAC;IAEnD,IAAI,QAAQ,IAAI,UAAU,EAAE;QAC1B,IAAI,GAAG,iBAAiB,CAAC;KAC1B;SAAM,IAAI,QAAQ,EAAE;QACnB,IAAI,GAAG,OAAO,CAAC;KAChB;SAAM,IAAI,UAAU,EAAE;QACrB,IAAI,GAAG,SAAS,CAAC;KAClB;SAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACpC,IAAI,GAAG,UAAU,CAAC;KACnB;SAAM;QACL,IAAI,GAAG,MAAM,CAAC;KACf;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAlBD,4GAkBC"}
|
|
@@ -1,13 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { MaybeMap, ModelFieldConversions, ApplyMapFunctionWithOptions, ModelFieldConversionsConfig, TypedMappedModelData } from "@dereekb/util";
|
|
2
|
+
import { SnapshotOptions, SetOptions, DocumentSnapshot, FirestoreDataConverter } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* The default "empty" value in the Firestore.
|
|
5
|
+
*/
|
|
6
|
+
export declare const FIRESTORE_EMPTY_VALUE: null;
|
|
7
|
+
/**
|
|
8
|
+
* The expected firestore document data for a specific type.
|
|
9
|
+
*
|
|
10
|
+
* This declaration allows a second type to defined overrides for how the data is stored within Firestore. For example, since by default
|
|
11
|
+
* this library choses to store dates as an ISO8601String, you can strictly specify that, and gain the type checking benefits.
|
|
12
|
+
*/
|
|
13
|
+
export declare type ExpectedFirestoreModelData<T extends object, R extends object = object> = TypedMappedModelData<T, R>;
|
|
14
|
+
/**
|
|
15
|
+
* What is considered the typings for the true "stored" data.
|
|
16
|
+
*
|
|
17
|
+
* All items are marked as partial and Maybe. This is because by design the firestore has no schema and has no obligation to require fields.
|
|
18
|
+
* It is better to be cognizant of this fact in our typings, and let the Snapshot conversions handle this.
|
|
19
|
+
*
|
|
20
|
+
* Fields that existing on the database type can only replace typings on the specific type, and not declare new typings.
|
|
21
|
+
* This is to prevent accidents related to adding/removing fields but not adding the correct conversions.
|
|
22
|
+
*
|
|
23
|
+
* This declaration allows a second type to defined overrides for how the data is stored within Firestore. For example, since by default
|
|
24
|
+
* this library choses to store dates as an ISO8601String, you can strictly specify that, and gain the type checking benefits. For other data types
|
|
25
|
+
* that are the same in the datastore as they are here, they are considered "any".
|
|
26
|
+
*
|
|
27
|
+
* The reason for this is that FirestoreModelData types are typically never used directly, execept for our snapshotConverterFunctions(),
|
|
28
|
+
* and using the built-in snapshot firestore field converters. Unless we have specified a strict new type that we expect in the data,
|
|
29
|
+
* most of the time we are unconcerned with the final type of our ExpectedFirestoreModelData.
|
|
30
|
+
*
|
|
31
|
+
* This is a more lose type that takes the above into account. You will only see typing information for fields of R that override the converted type T.
|
|
32
|
+
* If you find yourself needing full typings, extend ExpectedFirestoreModelData instead.
|
|
33
|
+
*
|
|
34
|
+
* Example:
|
|
35
|
+
*
|
|
36
|
+
* export interface MockItem {
|
|
37
|
+
* string: string;
|
|
38
|
+
* date: Date;
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* export type MockItemData = ExpectedFirestoreModelData<MockItem, {
|
|
42
|
+
* // string field is not defined directly, will be treated as any.
|
|
43
|
+
* date: string; // we want typescript typing help for this in our converters.
|
|
44
|
+
* }>;
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
export declare type FirestoreModelData<T extends object, R extends object = object> = Partial<ExpectedFirestoreModelData<T, MaybeMap<R>>>;
|
|
48
|
+
export declare type SnapshotConverterConfigWithFields<T extends object, O extends object = FirestoreModelData<T>> = {
|
|
49
|
+
fields: ModelFieldConversionsConfig<T, O>;
|
|
50
|
+
};
|
|
51
|
+
export declare type SnapshotConverterConfigWithConversions<T extends object, O extends object = FirestoreModelData<T>> = {
|
|
52
|
+
fieldConversions: ModelFieldConversions<T, O>;
|
|
53
|
+
};
|
|
54
|
+
export declare type SnapshotConverterConfig<T extends object, O extends object = FirestoreModelData<T>> = SnapshotConverterConfigWithFields<T, O> | SnapshotConverterConfigWithConversions<T, O>;
|
|
55
|
+
export interface SnapshotConverterFunctions<T extends object, O extends object = FirestoreModelData<T>> extends FirestoreDataConverter<T, O> {
|
|
56
|
+
from: SnapshotConverterFromFunction<T, O>;
|
|
57
|
+
to: SnapshotConverterToFunction<T, O>;
|
|
5
58
|
}
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare type SnapshotConverterFromFirestoreFunction<T extends object> = (snapshot: DocumentSnapshot, options?: SnapshotOptions) => T;
|
|
11
|
-
export declare type SnapshotConverterFromFunction<T extends object> = ApplyMapFunctionWithOptions<DocumentSnapshot, T, SnapshotOptions>;
|
|
12
|
-
export declare type SnapshotConverterToFunction<T extends object> = ApplyMapFunctionWithOptions<T, DocumentData, SetOptions>;
|
|
13
|
-
export declare function makeSnapshotConverterFunctions<T extends object>(config: SnapshotConverterConfig<T>): SnapshotConverterFunctions<T>;
|
|
59
|
+
export declare type SnapshotConverterFromFirestoreFunction<T extends object, O extends object = FirestoreModelData<T>> = (snapshot: DocumentSnapshot<O>, options?: SnapshotOptions) => T;
|
|
60
|
+
export declare type SnapshotConverterFromFunction<T extends object, O extends object = FirestoreModelData<T>> = ApplyMapFunctionWithOptions<DocumentSnapshot<O>, T, SnapshotOptions>;
|
|
61
|
+
export declare type SnapshotConverterToFunction<T extends object, O extends object = FirestoreModelData<T>> = ApplyMapFunctionWithOptions<T, O, SetOptions>;
|
|
62
|
+
export declare function snapshotConverterFunctions<T extends object, O extends object = FirestoreModelData<T>>(config: SnapshotConverterConfig<T, O>): SnapshotConverterFunctions<T, O>;
|
|
@@ -1,25 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ModelFieldMapFunctionsConfig, GetterOrValue, Maybe, ModelFieldMapConvertFunction } from '@dereekb/util';
|
|
2
|
+
export interface BaseFirestoreFieldConfig<V, D = unknown> {
|
|
3
|
+
fromData: ModelFieldMapConvertFunction<D, V>;
|
|
4
|
+
toData: ModelFieldMapConvertFunction<V, D>;
|
|
5
5
|
defaultBeforeSave?: GetterOrValue<D | null>;
|
|
6
|
-
fromData: MapFunction<D, V>;
|
|
7
|
-
toData: MapFunction<V, D>;
|
|
8
6
|
}
|
|
9
|
-
export interface
|
|
7
|
+
export interface FirestoreFieldConfigWithDefault<V, D = unknown> extends BaseFirestoreFieldConfig<V, D> {
|
|
8
|
+
default: GetterOrValue<V>;
|
|
10
9
|
}
|
|
11
|
-
export
|
|
12
|
-
|
|
10
|
+
export interface FirestoreFieldConfigWithDefaultData<V, D = unknown> extends BaseFirestoreFieldConfig<V, D> {
|
|
11
|
+
defaultData: GetterOrValue<D>;
|
|
13
12
|
}
|
|
14
|
-
export declare
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
export declare type FirestoreFieldConfig<V, D = unknown> = FirestoreFieldConfigWithDefault<V, D> | FirestoreFieldConfigWithDefaultData<V, D>;
|
|
14
|
+
/**
|
|
15
|
+
* All firebase ModelFieldMapFunctionsConfig are configured to handle the read field value as null/undefined. This implies that
|
|
16
|
+
* by design, the firebase database documents do not need to be fully intact for the system to handle them properly.
|
|
17
|
+
*/
|
|
18
|
+
export declare type FirestoreModelFieldMapFunctionsConfig<V, D> = ModelFieldMapFunctionsConfig<V, Maybe<D>>;
|
|
19
|
+
export declare function firestoreField<V, D = unknown>(config: FirestoreFieldConfig<V, D>): FirestoreModelFieldMapFunctionsConfig<V, D>;
|
|
20
|
+
export declare const FIRESTORE_PASSTHROUGH_FIELD: FirestoreModelFieldMapFunctionsConfig<unknown, unknown>;
|
|
21
|
+
export declare function firestorePassThroughField<T>(): ModelFieldMapFunctionsConfig<T, T>;
|
|
22
|
+
export declare type MapConfiguredFirestoreFieldConfigWithDefault<V, D = unknown> = Omit<FirestoreFieldConfigWithDefault<V, D>, 'fromData' | 'toData'>;
|
|
23
|
+
export declare type MapConfiguredFirestoreFieldConfigWithDefaultData<V, D = unknown> = Omit<FirestoreFieldConfigWithDefaultData<V, D>, 'fromData' | 'toData'>;
|
|
24
|
+
export declare type MapConfiguredFirestoreFieldConfig<V, D = unknown> = MapConfiguredFirestoreFieldConfigWithDefault<V, D> | MapConfiguredFirestoreFieldConfigWithDefaultData<V, D>;
|
|
25
|
+
export declare type DefaultMapConfiguredFirestoreFieldConfig<V, D = unknown> = Omit<FirestoreFieldConfigWithDefault<V, D>, 'fromData' | 'toData' | 'default'> & Partial<Pick<FirestoreFieldConfigWithDefault<V, D>, 'default'>>;
|
|
26
|
+
export declare type OptionalMapConfiguredFirestoreFieldConfig<V, D = unknown> = Omit<BaseFirestoreFieldConfig<V, D>, 'fromData' | 'toData' | 'defaultBeforeSave'>;
|
|
27
|
+
export declare type FirestoreStringConfig = DefaultMapConfiguredFirestoreFieldConfig<string, string>;
|
|
28
|
+
export declare function firestoreString(config: FirestoreStringConfig): FirestoreModelFieldMapFunctionsConfig<string, string>;
|
|
29
|
+
export declare function optionalFirestoreString(): ModelFieldMapFunctionsConfig<Maybe<string>, Maybe<string>>;
|
|
30
|
+
export declare function firestoreUID(): FirestoreModelFieldMapFunctionsConfig<string, string>;
|
|
31
|
+
export declare function optionalFirestoreUID(): ModelFieldMapFunctionsConfig<Maybe<string>, Maybe<string>>;
|
|
32
|
+
export declare type FirestoreDateFieldConfig = DefaultMapConfiguredFirestoreFieldConfig<Date, string> & {
|
|
17
33
|
saveDefaultAsNow?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export declare function firestoreDate(config?: FirestoreDateFieldConfig):
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
export declare function firestoreBoolean(config
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
export declare function firestoreNumber(config
|
|
34
|
+
};
|
|
35
|
+
export declare function firestoreDate(config?: FirestoreDateFieldConfig): FirestoreModelFieldMapFunctionsConfig<Date, string>;
|
|
36
|
+
export declare function optionalFirestoreDate(): FirestoreModelFieldMapFunctionsConfig<Maybe<Date>, Maybe<string>>;
|
|
37
|
+
export declare type FirestoreBooleanFieldConfig = MapConfiguredFirestoreFieldConfigWithDefault<boolean, boolean>;
|
|
38
|
+
export declare function firestoreBoolean(config: FirestoreBooleanFieldConfig): FirestoreModelFieldMapFunctionsConfig<boolean, boolean>;
|
|
39
|
+
export declare function optionalFirestoreBoolean(): ModelFieldMapFunctionsConfig<Maybe<boolean>, Maybe<boolean>>;
|
|
40
|
+
export declare type FirestoreNumberFieldConfig = MapConfiguredFirestoreFieldConfigWithDefault<number, number>;
|
|
41
|
+
export declare function firestoreNumber(config: FirestoreNumberFieldConfig): FirestoreModelFieldMapFunctionsConfig<number, number>;
|
|
42
|
+
export declare function optionalFirestoreNumber(): ModelFieldMapFunctionsConfig<Maybe<number>, Maybe<number>>;
|
|
@@ -1,57 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.firestoreNumber = exports.firestoreBoolean = exports.firestoreDate = exports.firestoreUID = exports.firestoreString = exports.firestoreField = void 0;
|
|
3
|
+
exports.optionalFirestoreNumber = exports.firestoreNumber = exports.optionalFirestoreBoolean = exports.firestoreBoolean = exports.optionalFirestoreDate = exports.firestoreDate = exports.optionalFirestoreUID = exports.firestoreUID = exports.optionalFirestoreString = exports.firestoreString = exports.firestorePassThroughField = exports.FIRESTORE_PASSTHROUGH_FIELD = exports.firestoreField = void 0;
|
|
4
4
|
const date_1 = require("@dereekb/date");
|
|
5
|
+
const util_1 = require("@dereekb/util");
|
|
6
|
+
const snapshot_1 = require("./snapshot");
|
|
7
|
+
;
|
|
8
|
+
;
|
|
5
9
|
function firestoreField(config) {
|
|
6
10
|
var _a;
|
|
7
11
|
return {
|
|
8
|
-
from: {
|
|
12
|
+
from: (config.default) ? {
|
|
9
13
|
default: config.default,
|
|
10
14
|
convert: config.fromData
|
|
15
|
+
} : {
|
|
16
|
+
defaultInput: config.defaultData,
|
|
17
|
+
convert: config.fromData
|
|
11
18
|
},
|
|
12
19
|
to: {
|
|
13
|
-
default: (_a = config.defaultBeforeSave) !== null && _a !== void 0 ? _a :
|
|
20
|
+
default: (_a = config.defaultBeforeSave) !== null && _a !== void 0 ? _a : snapshot_1.FIRESTORE_EMPTY_VALUE,
|
|
14
21
|
convert: config.toData
|
|
15
22
|
}
|
|
16
23
|
};
|
|
17
24
|
}
|
|
18
25
|
exports.firestoreField = firestoreField;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
exports.FIRESTORE_PASSTHROUGH_FIELD = firestoreField({
|
|
27
|
+
default: null,
|
|
28
|
+
fromData: util_1.passThrough,
|
|
29
|
+
toData: util_1.passThrough,
|
|
30
|
+
});
|
|
31
|
+
function firestorePassThroughField() {
|
|
32
|
+
return exports.FIRESTORE_PASSTHROUGH_FIELD;
|
|
33
|
+
}
|
|
34
|
+
exports.firestorePassThroughField = firestorePassThroughField;
|
|
35
|
+
function firestoreString(config) {
|
|
36
|
+
return firestoreField(Object.assign(Object.assign({ default: '' }, config), { fromData: util_1.passThrough, toData: util_1.passThrough }));
|
|
25
37
|
}
|
|
26
38
|
exports.firestoreString = firestoreString;
|
|
39
|
+
function optionalFirestoreString() {
|
|
40
|
+
return firestorePassThroughField();
|
|
41
|
+
}
|
|
42
|
+
exports.optionalFirestoreString = optionalFirestoreString;
|
|
27
43
|
function firestoreUID() {
|
|
28
|
-
return firestoreString({
|
|
44
|
+
return firestoreString({
|
|
45
|
+
default: ''
|
|
46
|
+
});
|
|
29
47
|
}
|
|
30
48
|
exports.firestoreUID = firestoreUID;
|
|
49
|
+
function optionalFirestoreUID() {
|
|
50
|
+
return optionalFirestoreString();
|
|
51
|
+
}
|
|
52
|
+
exports.optionalFirestoreUID = optionalFirestoreUID;
|
|
31
53
|
function firestoreDate(config = {}) {
|
|
32
|
-
var _a;
|
|
54
|
+
var _a, _b;
|
|
33
55
|
return firestoreField({
|
|
34
|
-
default: config.default,
|
|
35
|
-
defaultBeforeSave: (
|
|
56
|
+
default: (_a = config.default) !== null && _a !== void 0 ? _a : (() => new Date()),
|
|
57
|
+
defaultBeforeSave: (_b = config.defaultBeforeSave) !== null && _b !== void 0 ? _b : (config.saveDefaultAsNow ? date_1.nowISODateString : null),
|
|
36
58
|
fromData: (input) => (0, date_1.toJsDate)(input),
|
|
37
59
|
toData: (input) => (0, date_1.toISODateString)(input)
|
|
38
60
|
});
|
|
39
61
|
}
|
|
40
62
|
exports.firestoreDate = firestoreDate;
|
|
41
|
-
function
|
|
63
|
+
function optionalFirestoreDate() {
|
|
64
|
+
return firestoreField({
|
|
65
|
+
default: null,
|
|
66
|
+
fromData: (input) => (0, date_1.toJsDate)(input),
|
|
67
|
+
toData: (input) => (0, date_1.toISODateString)(input)
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
exports.optionalFirestoreDate = optionalFirestoreDate;
|
|
71
|
+
function firestoreBoolean(config) {
|
|
42
72
|
return firestoreField({
|
|
43
73
|
default: config.default,
|
|
44
|
-
fromData:
|
|
45
|
-
toData:
|
|
74
|
+
fromData: util_1.passThrough,
|
|
75
|
+
toData: util_1.passThrough,
|
|
46
76
|
});
|
|
47
77
|
}
|
|
48
78
|
exports.firestoreBoolean = firestoreBoolean;
|
|
49
|
-
function
|
|
79
|
+
function optionalFirestoreBoolean() {
|
|
80
|
+
return firestorePassThroughField();
|
|
81
|
+
}
|
|
82
|
+
exports.optionalFirestoreBoolean = optionalFirestoreBoolean;
|
|
83
|
+
function firestoreNumber(config) {
|
|
50
84
|
return firestoreField({
|
|
51
85
|
default: config.default,
|
|
52
|
-
fromData:
|
|
53
|
-
toData:
|
|
86
|
+
fromData: util_1.passThrough,
|
|
87
|
+
toData: util_1.passThrough,
|
|
54
88
|
});
|
|
55
89
|
}
|
|
56
90
|
exports.firestoreNumber = firestoreNumber;
|
|
91
|
+
function optionalFirestoreNumber() {
|
|
92
|
+
return firestorePassThroughField();
|
|
93
|
+
}
|
|
94
|
+
exports.optionalFirestoreNumber = optionalFirestoreNumber;
|
|
57
95
|
//# sourceMappingURL=snapshot.field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.field.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/snapshot/snapshot.field.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"snapshot.field.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/snapshot/snapshot.field.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.snapshotConverterFunctions = exports.FIRESTORE_EMPTY_VALUE = void 0;
|
|
4
4
|
const util_1 = require("@dereekb/util");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
// MARK: Type
|
|
7
|
+
/**
|
|
8
|
+
* The default "empty" value in the Firestore.
|
|
9
|
+
*/
|
|
10
|
+
exports.FIRESTORE_EMPTY_VALUE = null;
|
|
11
|
+
function snapshotConverterFunctions(config) {
|
|
12
|
+
var _a;
|
|
13
|
+
const conversions = (_a = config.fieldConversions) !== null && _a !== void 0 ? _a : (0, util_1.modelFieldConversions)(config.fields);
|
|
14
|
+
const { from: fromData, to: toData } = (0, util_1.makeModelMapFunctions)(conversions);
|
|
15
|
+
const from = (input, target) => {
|
|
9
16
|
const data = input.data();
|
|
10
17
|
return fromData(data, target);
|
|
11
18
|
};
|
|
@@ -31,5 +38,5 @@ function makeSnapshotConverterFunctions(config) {
|
|
|
31
38
|
toFirestore: (modelObject, options) => to(modelObject, undefined, options)
|
|
32
39
|
};
|
|
33
40
|
}
|
|
34
|
-
exports.
|
|
41
|
+
exports.snapshotConverterFunctions = snapshotConverterFunctions;
|
|
35
42
|
//# sourceMappingURL=snapshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/snapshot/snapshot.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/snapshot/snapshot.ts"],"names":[],"mappings":";;;AAAA,wCAA6N;AAC7N,oCAAsM;AAEtM,aAAa;AACb;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAiE1C,SAAgB,0BAA0B,CAA6D,MAAqC;;IAC1I,MAAM,WAAW,GACf,MAAC,MAAuD,CAAC,gBAAgB,mCAAI,IAAA,4BAAqB,EAAQ,MAAkD,CAAC,MAAM,CAAC,CAAC;IACvK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,IAAA,4BAAqB,EAAO,WAAW,CAAC,CAAC;IAEhF,MAAM,IAAI,GAAwC,CAAC,KAAuB,EAAE,MAA0B,EAAE,EAAE;QACxG,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC1B,OAAO,QAAQ,CAAC,IAAS,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,MAAM,EAAE,GAAsC,CAAC,KAAQ,EAAE,MAA0B,EAAE,OAA2B,EAAE,EAAE;QAClH,IAAI,SAA2C,CAAC;QAEhD,IAAI,OAAO,EAAE;YACX,MAAM,WAAW,GAAI,OAAiC,CAAC,WAAW,CAAC;YAEnE,IAAK,OAA2B,CAAC,KAAK,EAAE;gBACtC,SAAS,GAAG;oBACV,WAAW,EAAE,IAAI;iBAClB,CAAC;aACH;YAED,IAAI,WAAW,EAAE;gBACf,SAAS,mCACJ,SAAS,KACZ,MAAM,EAAE,IAAA,4BAAoB,EAAC,WAAW,CAAgB,GACzD,CAAC;aACH;SACF;QAED,OAAO,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC,CAAC;IAEF,OAAO;QACL,IAAI;QACJ,EAAE;QACF,aAAa,EAAE,CAAC,QAA6B,EAAE,OAAyB,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;QAC/G,WAAW,EAAE,CAAC,WAAyD,EAAE,OAAoB,EAAE,EAAE,CAAC,EAAE,CAAC,WAAgB,EAAE,SAAS,EAAE,OAAO,CAAC;KAC3I,CAAA;AACH,CAAC;AAvCD,gEAuCC"}
|
|
@@ -73,10 +73,10 @@ export interface SnapshotListenOptions {
|
|
|
73
73
|
/**
|
|
74
74
|
* Mirrors the types/methods of FirestoreDataConverter.
|
|
75
75
|
*/
|
|
76
|
-
export interface FirestoreDataConverter<T> {
|
|
77
|
-
toFirestore(modelObject: WithFieldValue<T>):
|
|
78
|
-
toFirestore(modelObject: PartialWithFieldValue<T>, options: SetOptions):
|
|
79
|
-
fromFirestore(snapshot: QueryDocumentSnapshot<
|
|
76
|
+
export interface FirestoreDataConverter<T, O = DocumentData> {
|
|
77
|
+
toFirestore(modelObject: WithFieldValue<T>): O;
|
|
78
|
+
toFirestore(modelObject: PartialWithFieldValue<T>, options: SetOptions): O;
|
|
79
|
+
fromFirestore(snapshot: QueryDocumentSnapshot<O>, options?: SnapshotOptions): T;
|
|
80
80
|
}
|
|
81
81
|
export interface DocumentReference<T = DocumentData> {
|
|
82
82
|
readonly converter?: FirestoreDataConverter<T> | null;
|
|
@@ -96,8 +96,13 @@ export interface CollectionReference<T = DocumentData> extends Query<T> {
|
|
|
96
96
|
withConverter<U>(converter: FirestoreDataConverter<U>): CollectionReference<U>;
|
|
97
97
|
withConverter(converter: null): CollectionReference<DocumentData>;
|
|
98
98
|
}
|
|
99
|
-
export
|
|
100
|
-
|
|
99
|
+
export interface WriteBatch {
|
|
100
|
+
/**
|
|
101
|
+
* Commits the changes.
|
|
102
|
+
*/
|
|
103
|
+
commit(): Promise<WriteResult[] | void>;
|
|
104
|
+
}
|
|
105
|
+
export declare type Transaction = object;
|
|
101
106
|
export interface Query<T = DocumentData> {
|
|
102
107
|
readonly converter?: FirestoreDataConverter<T> | null;
|
|
103
108
|
readonly type?: 'query' | 'collection';
|
|
@@ -114,7 +119,7 @@ export interface QuerySnapshot<T = DocumentData> {
|
|
|
114
119
|
readonly docs: Array<QueryDocumentSnapshot<T>>;
|
|
115
120
|
readonly size: number;
|
|
116
121
|
readonly empty: boolean;
|
|
117
|
-
forEach(callback: (result: QueryDocumentSnapshot<T>) => void, thisArg?:
|
|
122
|
+
forEach(callback: (result: QueryDocumentSnapshot<T>) => void, thisArg?: unknown): void;
|
|
118
123
|
docChanges(): DocumentChange<T>[];
|
|
119
124
|
}
|
|
120
125
|
export interface QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<T> {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// A set of copied types from @google-cloud/firestore and firebase/firestore to allow cross-compatability.
|
|
3
|
+
/* eslint-disable */
|
|
3
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
5
|
exports.asTopLevelFieldPath = exports.asTopLevelFieldPaths = void 0;
|
|
5
6
|
function asTopLevelFieldPaths(input) {
|
|
@@ -20,4 +21,5 @@ function asTopLevelFieldPath(input) {
|
|
|
20
21
|
exports.asTopLevelFieldPath = asTopLevelFieldPath;
|
|
21
22
|
;
|
|
22
23
|
;
|
|
24
|
+
;
|
|
23
25
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/firestore/types.ts"],"names":[],"mappings":";AAAA,0GAA0G;;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/firestore/types.ts"],"names":[],"mappings":";AAAA,0GAA0G;AAC1G,oBAAoB;;;AA6CpB,SAAgB,oBAAoB,CAAC,KAA6B;IAChE,OAAO,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AACxC,CAAC;AAFD,oDAEC;AAED,SAAgB,mBAAmB,CAAC,KAA2B;IAC7D,IAAI,IAAY,CAAC;IAEjB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,IAAI,GAAG,KAAK,CAAC;KACd;SAAM;QACL,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAClC,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/B;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAXD,kDAWC;AAgCA,CAAC;AAID,CAAC;AAkDD,CAAC"}
|
package/src/lib/model/user.d.ts
CHANGED
package/test/CHANGELOG.md
CHANGED
|
@@ -2,4 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [5.0.0](https://github.com/dereekb/dbx-components/compare/v4.1.0-dev...v5.0.0) (2022-05-25)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Code Refactoring
|
|
9
|
+
|
|
10
|
+
* refactored @dereekb/firebase snapshot field ([c88d278](https://github.com/dereekb/dbx-components/commit/c88d2780d66f965a41ae299e013109f6860e9496))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### BREAKING CHANGES
|
|
14
|
+
|
|
15
|
+
* refactored @dereekb/firebase SnapshotConverterFunction and related components and @dereekb/util model conversion components to have better type safety and inference
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# [4.1.0](https://github.com/dereekb/dbx-components/compare/v4.0.1-dev...v4.1.0) (2022-05-17)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [4.0.1](https://github.com/dereekb/dbx-components/compare/v4.0.0-dev...v4.0.1) (2022-05-14)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
5
27
|
# [4.0.0](https://github.com/dereekb/dbx-components/compare/v3.0.0...v4.0.0) (2022-05-14)
|
package/test/package.json
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase/test",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"typings": "./src/index.d.ts",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@dereekb/util/test": "
|
|
9
|
-
"@dereekb/util": "
|
|
8
|
+
"@dereekb/util/test": "5.0.0",
|
|
9
|
+
"@dereekb/util": "5.0.0",
|
|
10
10
|
"make-error": "^1.3.0",
|
|
11
11
|
"extra-set": "^2.2.11",
|
|
12
|
-
"
|
|
13
|
-
"@dereekb/firebase": "4.0.0",
|
|
12
|
+
"@dereekb/firebase": "5.0.0",
|
|
14
13
|
"rxjs": "^7.0.0",
|
|
15
14
|
"rxfire": "^6.0.3",
|
|
16
15
|
"firebase": "^9.8.0",
|
|
17
|
-
"@dereekb/rxjs": "
|
|
16
|
+
"@dereekb/rxjs": "5.0.0",
|
|
18
17
|
"ms": "^3.0.0-canary.1",
|
|
19
|
-
"@dereekb/date": "
|
|
18
|
+
"@dereekb/date": "5.0.0",
|
|
20
19
|
"class-transformer": "^0.5.1",
|
|
21
20
|
"date-fns": "^2.28.0",
|
|
22
21
|
"class-validator": "^0.13.2",
|
|
23
22
|
"date-fns-tz": "^1.3.0",
|
|
24
23
|
"rrule": "git+https://git@github.com/dereekb/rrule.git#17adf5708d6567b4d01a3a8afd106261421ea492",
|
|
25
|
-
"@dereekb/model": "
|
|
24
|
+
"@dereekb/model": "5.0.0",
|
|
26
25
|
"tslib": "^2.0.0"
|
|
27
26
|
}
|
|
28
27
|
}
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
import { Maybe } from '@dereekb/util';
|
|
2
|
-
import { CollectionReference, FirestoreCollection, FirestoreContext, AbstractFirestoreDocument, SingleItemFirestoreCollection, FirestoreCollectionWithParent, AbstractFirestoreDocumentWithParent } from '@dereekb/firebase';
|
|
2
|
+
import { CollectionReference, FirestoreCollection, FirestoreContext, AbstractFirestoreDocument, SingleItemFirestoreCollection, FirestoreCollectionWithParent, AbstractFirestoreDocumentWithParent, ExpectedFirestoreModelData, FirestoreModelData } from '@dereekb/firebase';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Converted data for a test item in our firestore collection.
|
|
5
5
|
*/
|
|
6
6
|
export interface MockItem {
|
|
7
|
-
test?: boolean;
|
|
8
7
|
value?: Maybe<string>;
|
|
8
|
+
/**
|
|
9
|
+
* The test value is alway present.
|
|
10
|
+
*/
|
|
11
|
+
test: boolean;
|
|
9
12
|
}
|
|
10
|
-
/**
|
|
11
|
-
* FirestoreDocument for MockItem
|
|
12
|
-
*/
|
|
13
13
|
export declare class MockItemDocument extends AbstractFirestoreDocument<MockItem, MockItemDocument> {
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* MockItem as it is stored into the database.
|
|
17
|
+
*
|
|
18
|
+
* Test is optional.
|
|
19
|
+
*/
|
|
20
|
+
export declare type MockItemData = FirestoreModelData<MockItem, {
|
|
21
|
+
/**
|
|
22
|
+
* The test value may not be defined in the database.
|
|
23
|
+
*/
|
|
24
|
+
test?: Maybe<boolean>;
|
|
25
|
+
}>;
|
|
15
26
|
/**
|
|
16
27
|
* Firestore collection path name.
|
|
17
28
|
*/
|
|
@@ -19,7 +30,12 @@ export declare const mockItemCollectionPath = "test";
|
|
|
19
30
|
/**
|
|
20
31
|
* Used to build a FirestoreDataConverter. Fields are configured via configuration. See the SnapshotConverterFunctions for more info.
|
|
21
32
|
*/
|
|
22
|
-
export declare const mockItemConverter: import("@dereekb/firebase").SnapshotConverterFunctions<MockItem
|
|
33
|
+
export declare const mockItemConverter: import("@dereekb/firebase").SnapshotConverterFunctions<MockItem, Partial<import("@dereekb/util").ReplaceType<MockItem, import("@dereekb/util").MaybeMap<{
|
|
34
|
+
/**
|
|
35
|
+
* The test value may not be defined in the database.
|
|
36
|
+
*/
|
|
37
|
+
test?: Maybe<boolean>;
|
|
38
|
+
}>, any>>>;
|
|
23
39
|
/**
|
|
24
40
|
* Used to build a mockItemCollection from a firestore instance with a converter setup.
|
|
25
41
|
*
|
|
@@ -34,34 +50,41 @@ export declare function mockItemFirestoreCollection(firestoreContext: FirestoreC
|
|
|
34
50
|
*
|
|
35
51
|
* There is only a single private data item per each MockItem.
|
|
36
52
|
*/
|
|
37
|
-
export interface
|
|
38
|
-
comments?: string
|
|
39
|
-
createdAt
|
|
53
|
+
export interface MockItemPrivate {
|
|
54
|
+
comments?: Maybe<string>;
|
|
55
|
+
createdAt: Date;
|
|
40
56
|
}
|
|
41
57
|
/**
|
|
42
58
|
* FirestoreDocument for MockItem
|
|
43
59
|
*/
|
|
44
|
-
export declare class
|
|
60
|
+
export declare class MockItemPrivateDocument extends AbstractFirestoreDocument<MockItemPrivate, MockItemPrivateDocument> {
|
|
45
61
|
}
|
|
62
|
+
export declare type MockItemPrivateData = FirestoreModelData<MockItemPrivate, {}>;
|
|
46
63
|
/**
|
|
47
64
|
* Firestore collection path name.
|
|
48
65
|
*/
|
|
49
|
-
export declare const
|
|
50
|
-
export declare const
|
|
66
|
+
export declare const mockItemPrivateCollectionPath = "private";
|
|
67
|
+
export declare const mockItemPrivateIdentifier = "0";
|
|
51
68
|
/**
|
|
52
69
|
* Used to build a FirestoreDataConverter. Fields are configured via configuration. See the SnapshotConverterFunctions for more info.
|
|
53
70
|
*/
|
|
54
|
-
export declare const
|
|
71
|
+
export declare const mockItemPrivateConverter: import("@dereekb/firebase").SnapshotConverterFunctions<{
|
|
72
|
+
comments?: Maybe<string>;
|
|
73
|
+
createdAt: Date;
|
|
74
|
+
}, Partial<import("@dereekb/util").ReplaceType<{
|
|
75
|
+
comments?: Maybe<string>;
|
|
76
|
+
createdAt: Date;
|
|
77
|
+
}, import("@dereekb/util").MaybeMap<object>, any>>>;
|
|
55
78
|
/**
|
|
56
79
|
* Used to build a mockItemCollection from a firestore instance with a converter setup.
|
|
57
80
|
*
|
|
58
81
|
* @param firestore
|
|
59
82
|
* @returns
|
|
60
83
|
*/
|
|
61
|
-
export declare function
|
|
62
|
-
export declare type
|
|
63
|
-
export declare type
|
|
64
|
-
export declare function
|
|
84
|
+
export declare function mockItemPrivateCollectionReferenceFactory(context: FirestoreContext): (parent: MockItemDocument) => CollectionReference<MockItemPrivate>;
|
|
85
|
+
export declare type MockItemPrivateFirestoreCollection = SingleItemFirestoreCollection<MockItemPrivate, MockItem, MockItemPrivateDocument>;
|
|
86
|
+
export declare type MockItemPrivateFirestoreCollectionFactory = (parent: MockItemDocument) => MockItemPrivateFirestoreCollection;
|
|
87
|
+
export declare function mockItemPrivateFirestoreCollection(firestoreContext: FirestoreContext): MockItemPrivateFirestoreCollectionFactory;
|
|
65
88
|
/**
|
|
66
89
|
* Data for a sub item in our firestore collection.
|
|
67
90
|
*
|
|
@@ -75,6 +98,7 @@ export interface MockItemSubItem {
|
|
|
75
98
|
*/
|
|
76
99
|
export declare class MockItemSubItemDocument extends AbstractFirestoreDocumentWithParent<MockItem, MockItemSubItem, MockItemSubItemDocument> {
|
|
77
100
|
}
|
|
101
|
+
export declare type MockItemSubItemData = ExpectedFirestoreModelData<MockItemSubItem>;
|
|
78
102
|
/**
|
|
79
103
|
* Firestore collection path name.
|
|
80
104
|
*/
|
|
@@ -82,14 +106,14 @@ export declare const mockItemSubItemCollectionPath = "sub";
|
|
|
82
106
|
/**
|
|
83
107
|
* Used to build a FirestoreDataConverter. Fields are configured via configuration. See the SnapshotConverterFunctions for more info.
|
|
84
108
|
*/
|
|
85
|
-
export declare const mockItemSubItemConverter: import("@dereekb/firebase").SnapshotConverterFunctions<MockItemSubItem
|
|
109
|
+
export declare const mockItemSubItemConverter: import("@dereekb/firebase").SnapshotConverterFunctions<MockItemSubItem, import("@dereekb/util").ReplaceType<MockItemSubItem, object, any>>;
|
|
86
110
|
export declare function mockItemSubItemCollectionReferenceFactory(context: FirestoreContext): (parent: MockItemDocument) => CollectionReference<MockItemSubItem>;
|
|
87
111
|
export declare type MockItemSubItemFirestoreCollection = FirestoreCollectionWithParent<MockItemSubItem, MockItem, MockItemSubItemDocument, MockItemDocument>;
|
|
88
112
|
export declare type MockItemSubItemFirestoreCollectionFactory = (parent: MockItemDocument) => MockItemSubItemFirestoreCollection;
|
|
89
113
|
export declare function mockItemSubItemFirestoreCollection(firestoreContext: FirestoreContext): MockItemSubItemFirestoreCollectionFactory;
|
|
90
114
|
export declare abstract class MockItemCollections {
|
|
91
115
|
abstract readonly mockItem: MockItemFirestoreCollection;
|
|
92
|
-
abstract readonly
|
|
116
|
+
abstract readonly mockItemPrivate: MockItemPrivateFirestoreCollectionFactory;
|
|
93
117
|
abstract readonly mockItemSubItem: MockItemSubItemFirestoreCollectionFactory;
|
|
94
118
|
}
|
|
95
119
|
export declare function makeMockItemCollections(firestoreContext: FirestoreContext): MockItemCollections;
|
|
@@ -7,7 +7,7 @@ export declare class MockItemCollectionFixtureInstance {
|
|
|
7
7
|
readonly collections: import("./firestore.mock.item").MockItemCollections;
|
|
8
8
|
get collection(): CollectionReference<MockItem>;
|
|
9
9
|
get firestoreCollection(): MockItemFirestoreCollection;
|
|
10
|
-
get
|
|
10
|
+
get mockItemPrivateCollection(): import("./firestore.mock.item").MockItemPrivateFirestoreCollectionFactory;
|
|
11
11
|
get mockItemSubItemCollection(): import("./firestore.mock.item").MockItemSubItemFirestoreCollectionFactory;
|
|
12
12
|
constructor(fixture: MockItemCollectionFixture);
|
|
13
13
|
}
|