@nx-ddd/firestore 1.0.13 → 4.20.7
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/README.md +5 -1
- package/adapters/admin/admin.adapter.d.ts +22 -0
- package/adapters/admin/admin.adapter.js +60 -0
- package/adapters/admin/admin.adapter.js.map +1 -0
- package/adapters/admin/index.d.ts +1 -0
- package/adapters/admin/index.js +5 -0
- package/adapters/admin/index.js.map +1 -0
- package/adapters/base/base.adapter.d.ts +20 -0
- package/adapters/base/base.adapter.js +13 -0
- package/adapters/base/base.adapter.js.map +1 -0
- package/adapters/base/index.d.ts +1 -0
- package/adapters/base/index.js +5 -0
- package/adapters/base/index.js.map +1 -0
- package/adapters/firebase/firebase.adapter.d.ts +22 -0
- package/adapters/firebase/firebase.adapter.js +89 -0
- package/adapters/firebase/firebase.adapter.js.map +1 -0
- package/adapters/firebase/index.d.ts +1 -0
- package/adapters/firebase/index.js +5 -0
- package/adapters/firebase/index.js.map +1 -0
- package/adapters/index.d.ts +3 -0
- package/adapters/index.js +7 -0
- package/adapters/index.js.map +1 -0
- package/converter/converter.d.ts +11 -0
- package/converter/converter.js +36 -0
- package/converter/converter.js.map +1 -0
- package/converter/index.d.ts +1 -0
- package/{common/utilities → converter}/index.js +1 -1
- package/converter/index.js.map +1 -0
- package/dao/firestore.dao.d.ts +18 -0
- package/dao/firestore.dao.js +23 -0
- package/dao/firestore.dao.js.map +1 -0
- package/dao/index.d.ts +1 -0
- package/dao/index.js +5 -0
- package/dao/index.js.map +1 -0
- package/decorators/decorators.d.ts +34 -0
- package/decorators/decorators.js +27 -0
- package/decorators/decorators.js.map +1 -0
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +5 -0
- package/decorators/index.js.map +1 -0
- package/index.d.ts +8 -0
- package/index.js +12 -0
- package/index.js.map +1 -0
- package/interfaces/index.d.ts +1 -0
- package/{admin → interfaces}/index.js +0 -2
- package/interfaces/index.js.map +1 -0
- package/interfaces/interfaces.d.ts +57 -0
- package/interfaces/interfaces.js.map +1 -0
- package/package.json +14 -8
- package/path-builder/index.d.ts +1 -0
- package/path-builder/index.js +5 -0
- package/path-builder/index.js.map +1 -0
- package/path-builder/path-builder.d.ts +21 -0
- package/path-builder/path-builder.js +34 -0
- package/path-builder/path-builder.js.map +1 -0
- package/query/firestore.query.d.ts +26 -0
- package/query/firestore.query.js +50 -0
- package/query/firestore.query.js.map +1 -0
- package/query/index.d.ts +1 -0
- package/query/index.js +5 -0
- package/query/index.js.map +1 -0
- package/repository/decorator.d.ts +8 -0
- package/repository/decorator.js +41 -0
- package/repository/decorator.js.map +1 -0
- package/{nest → repository}/index.d.ts +1 -1
- package/{nest → repository}/index.js +1 -1
- package/repository/index.js.map +1 -0
- package/repository/repository.d.ts +38 -0
- package/repository/repository.js +107 -0
- package/repository/repository.js.map +1 -0
- package/testing/common.d.ts +5 -0
- package/testing/common.js +19 -0
- package/testing/common.js.map +1 -0
- package/testing/domain.d.ts +12 -0
- package/testing/domain.js +22 -0
- package/testing/domain.js.map +1 -0
- package/testing/index.d.ts +3 -0
- package/{client → testing}/index.js +2 -2
- package/testing/index.js.map +1 -0
- package/testing/repository.d.ts +6 -0
- package/testing/repository.js +26 -0
- package/testing/repository.js.map +1 -0
- package/admin/adapter.d.ts +0 -20
- package/admin/adapter.js +0 -62
- package/admin/adapter.js.map +0 -1
- package/admin/index.d.ts +0 -3
- package/admin/index.js.map +0 -1
- package/admin/interfaces.d.ts +0 -8
- package/admin/interfaces.js +0 -3
- package/admin/interfaces.js.map +0 -1
- package/admin/repository.d.ts +0 -9
- package/admin/repository.js +0 -21
- package/admin/repository.js.map +0 -1
- package/client/adapter.d.ts +0 -13
- package/client/adapter.js +0 -35
- package/client/adapter.js.map +0 -1
- package/client/index.d.ts +0 -3
- package/client/index.js.map +0 -1
- package/client/interfaces.d.ts +0 -8
- package/client/interfaces.js +0 -3
- package/client/interfaces.js.map +0 -1
- package/client/repository.d.ts +0 -8
- package/client/repository.js +0 -9
- package/client/repository.js.map +0 -1
- package/common/adapter.d.ts +0 -17
- package/common/adapter.js +0 -24
- package/common/adapter.js.map +0 -1
- package/common/entity.d.ts +0 -24
- package/common/entity.js +0 -27
- package/common/entity.js.map +0 -1
- package/common/index.d.ts +0 -5
- package/common/index.js +0 -9
- package/common/index.js.map +0 -1
- package/common/interfaces.d.ts +0 -51
- package/common/interfaces.js.map +0 -1
- package/common/repository.d.ts +0 -41
- package/common/repository.js +0 -108
- package/common/repository.js.map +0 -1
- package/common/utilities/generate-id.d.ts +0 -1
- package/common/utilities/generate-id.js +0 -22
- package/common/utilities/generate-id.js.map +0 -1
- package/common/utilities/index.d.ts +0 -1
- package/common/utilities/index.js.map +0 -1
- package/nest/adapter.d.ts +0 -21
- package/nest/adapter.js +0 -63
- package/nest/adapter.js.map +0 -1
- package/nest/index.js.map +0 -1
- package/nest/repository.d.ts +0 -9
- package/nest/repository.js +0 -21
- package/nest/repository.js.map +0 -1
- /package/{common → interfaces}/interfaces.js +0 -0
package/README.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# firestore
|
|
2
2
|
|
|
3
3
|
This library was generated with [Nx](https://nx.dev).
|
|
4
4
|
|
|
5
5
|
## Running unit tests
|
|
6
6
|
|
|
7
7
|
Run `nx test firestore` to execute the unit tests via [Jest](https://jestjs.io).
|
|
8
|
+
|
|
9
|
+
## Running lint
|
|
10
|
+
|
|
11
|
+
Run `nx lint firestore` to execute the lint via [ESLint](https://eslint.org/).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { firestore } from 'firebase-admin';
|
|
3
|
+
import { DocumentReference, FirestoreCollection, FirestoreCollectionGroup } from '../../interfaces';
|
|
4
|
+
import { FirestoreAdapter, QueryFn } from '../base';
|
|
5
|
+
export declare class AdminFirestoreAdapter extends FirestoreAdapter<dayjs.Dayjs> {
|
|
6
|
+
private firestore;
|
|
7
|
+
constructor(firestore?: any);
|
|
8
|
+
get FieldValue(): typeof firestore.FieldValue;
|
|
9
|
+
get Timestamp(): typeof firestore.Timestamp;
|
|
10
|
+
protected isTimestamp: (v: any) => v is firestore.Timestamp;
|
|
11
|
+
protected isDate: (v: any) => v is dayjs.Dayjs;
|
|
12
|
+
protected convertDateToTimestamp(date: dayjs.Dayjs): firestore.Timestamp;
|
|
13
|
+
protected convertTimestampToDate(timestamp: firestore.Timestamp): dayjs.Dayjs;
|
|
14
|
+
doc(path: string): DocumentReference<any, firestore.DocumentReference>;
|
|
15
|
+
collection(path: string): FirestoreCollection<any, firestore.CollectionReference>;
|
|
16
|
+
collectionGroup(collectionId: string): FirestoreCollectionGroup<any>;
|
|
17
|
+
runTransaction(fn: any): any;
|
|
18
|
+
query<Data>(collection: FirestoreCollection<Data>, ...queryFnArray: QueryFn<Data>[]): any;
|
|
19
|
+
orderBy<Data>(key: string, order?: 'asc' | 'desc'): QueryFn<Data>;
|
|
20
|
+
limit<Data>(n: number): QueryFn<Data>;
|
|
21
|
+
batch(): any;
|
|
22
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdminFirestoreAdapter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
6
|
+
const firebase_admin_1 = require("firebase-admin");
|
|
7
|
+
const base_1 = require("../base");
|
|
8
|
+
class AdminFirestoreAdapter extends base_1.FirestoreAdapter {
|
|
9
|
+
constructor(firestore = firestore()) {
|
|
10
|
+
super();
|
|
11
|
+
this.firestore = firestore;
|
|
12
|
+
this.isTimestamp = (v) => v instanceof this.Timestamp;
|
|
13
|
+
this.isDate = (v) => dayjs_1.default.isDayjs(v);
|
|
14
|
+
}
|
|
15
|
+
get FieldValue() {
|
|
16
|
+
return firebase_admin_1.firestore.FieldValue;
|
|
17
|
+
}
|
|
18
|
+
get Timestamp() {
|
|
19
|
+
return firebase_admin_1.firestore.Timestamp;
|
|
20
|
+
}
|
|
21
|
+
convertDateToTimestamp(date) {
|
|
22
|
+
return firebase_admin_1.firestore.Timestamp.fromDate(date.toDate());
|
|
23
|
+
}
|
|
24
|
+
convertTimestampToDate(timestamp) {
|
|
25
|
+
return (0, dayjs_1.default)(timestamp.toDate());
|
|
26
|
+
}
|
|
27
|
+
doc(path) {
|
|
28
|
+
const docRef = this.firestore.doc(path);
|
|
29
|
+
return {
|
|
30
|
+
__ref: docRef,
|
|
31
|
+
set: (data, options) => docRef.set(data, options),
|
|
32
|
+
get: () => docRef.get(),
|
|
33
|
+
update: (data) => docRef.update(data),
|
|
34
|
+
delete: () => docRef.delete(),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
collection(path) {
|
|
38
|
+
return this.firestore.collection(path);
|
|
39
|
+
}
|
|
40
|
+
collectionGroup(collectionId) {
|
|
41
|
+
return this.firestore.collectionGroup(collectionId);
|
|
42
|
+
}
|
|
43
|
+
runTransaction(fn) {
|
|
44
|
+
return this.firestore.runTransaction(fn);
|
|
45
|
+
}
|
|
46
|
+
query(collection, ...queryFnArray) {
|
|
47
|
+
return queryFnArray.reduce((collectionOrQuery, queryFn) => queryFn(collectionOrQuery), collection);
|
|
48
|
+
}
|
|
49
|
+
orderBy(key, order = 'asc') {
|
|
50
|
+
return (collection) => collection.orderBy(key, order);
|
|
51
|
+
}
|
|
52
|
+
limit(n) {
|
|
53
|
+
return (collection) => collection.limit(n);
|
|
54
|
+
}
|
|
55
|
+
batch() {
|
|
56
|
+
return this.firestore.batch();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.AdminFirestoreAdapter = AdminFirestoreAdapter;
|
|
60
|
+
//# sourceMappingURL=admin.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.adapter.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/firestore/src/l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ACJ,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,eAAe,CAAC,YAAoB;QAClC,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IACtD,CAAC;IAED,cAAc,CAAC,EAAO;QACpB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAO,UAAqC,EAAE,GAAG,YAA6B;QACjF,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,iBAAiB,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC,CAAC;IACrG,CAAC;IAED,OAAO,CAAO,GAAW,EAAE,QAAwB,KAAK;QACtD,OAAO,CAAC,UAAuE,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACrH,CAAC;IAED,KAAK,CAAO,CAAS;QACnB,OAAO,CAAC,UAAuE,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1G,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;CACF;AA7DD,sDA6DC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './admin.adapter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/firestore/src/lib/adapters/admin/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FirestoreCollection, FirestoreCollectionGroup, FirestoreDocument, ToFirestoreData, Timestamp } from '../../interfaces';
|
|
2
|
+
export declare type QueryFn<Data> = (collection?: any) => any;
|
|
3
|
+
export declare abstract class FirestoreAdapter<Date = any> {
|
|
4
|
+
protected abstract isTimestamp: (v: any) => v is Timestamp;
|
|
5
|
+
protected abstract isDate(v: any): v is Date;
|
|
6
|
+
protected abstract convertTimestampToDate(timestamp: Timestamp): Date;
|
|
7
|
+
protected abstract convertDateToTimestamp(date: Date): Timestamp;
|
|
8
|
+
abstract get Timestamp(): any;
|
|
9
|
+
abstract get FieldValue(): any;
|
|
10
|
+
abstract doc<Data>(path: string): FirestoreDocument<Data>;
|
|
11
|
+
abstract collection<Data>(path: string): FirestoreCollection<Data>;
|
|
12
|
+
abstract collectionGroup<Data>(collectionId: string): FirestoreCollectionGroup<Data>;
|
|
13
|
+
abstract runTransaction(fn: any): any;
|
|
14
|
+
abstract batch(): any;
|
|
15
|
+
abstract query<Data>(collection: FirestoreCollection<Data>, ...queryFnArray: QueryFn<Data>[]): any;
|
|
16
|
+
abstract orderBy<Data>(key: string, order: 'asc' | 'desc'): QueryFn<Data>;
|
|
17
|
+
abstract limit<Data>(n: number): QueryFn<Data>;
|
|
18
|
+
toFirestoreData<Entity>(entity: Entity): ToFirestoreData<Entity, Date>;
|
|
19
|
+
fromFirestoreData<Entity>(data: ToFirestoreData<Entity, Date>): Entity;
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FirestoreAdapter = void 0;
|
|
4
|
+
class FirestoreAdapter {
|
|
5
|
+
toFirestoreData(entity) {
|
|
6
|
+
return Object.entries(entity).reduce((pre, [k, v]) => (Object.assign(Object.assign({}, pre), { [k]: this.isDate(v) ? this.convertDateToTimestamp(v) : v })), {});
|
|
7
|
+
}
|
|
8
|
+
fromFirestoreData(data) {
|
|
9
|
+
return Object.entries(data).reduce((pre, [k, v]) => (Object.assign(Object.assign({}, pre), { [k]: this.isTimestamp(v) ? this.convertTimestampToDate(v) : v })), {});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.FirestoreAdapter = FirestoreAdapter;
|
|
13
|
+
//# sourceMappingURL=base.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.adapter.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/firestore/src/lib/adapters/base/base.adapter.ts"],"names":[],"mappings":";;;AAOA,MAAsB,gBAAgB;IAmBpC,eAAe,CAAS,MAAc;QACpC,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,iCACjD,GAAG,KAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IACjE,EAAE,EAAmC,CAAC,CAAC;IAC3C,CAAC;IAED,iBAAiB,CAAS,IAAmC;QAC3D,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,iCAC/C,GAAG,KAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IACrE,EAAE,EAAY,CAAC,CAAC;IACpB,CAAC;CAEF;AA/BD,4CA+BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './base.adapter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/firestore/src/lib/adapters/base/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FieldValue, Timestamp } from 'firebase/firestore';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { FirestoreAdapter, QueryFn } from '../base';
|
|
4
|
+
import { FirestoreCollection, FirestoreCollectionGroup, FirestoreDocument } from '../../interfaces';
|
|
5
|
+
export declare class FirebaseFirestoreAdapter extends FirestoreAdapter<dayjs.Dayjs> {
|
|
6
|
+
firestore: import("@firebase/firestore").Firestore;
|
|
7
|
+
constructor(firestore?: import("@firebase/firestore").Firestore);
|
|
8
|
+
get FieldValue(): typeof FieldValue;
|
|
9
|
+
get Timestamp(): typeof Timestamp;
|
|
10
|
+
protected isTimestamp: (v: any) => v is Timestamp;
|
|
11
|
+
protected isDate: (v: any) => v is dayjs.Dayjs;
|
|
12
|
+
protected convertDateToTimestamp(date: dayjs.Dayjs): Timestamp;
|
|
13
|
+
protected convertTimestampToDate(timestamp: Timestamp): dayjs.Dayjs;
|
|
14
|
+
doc(path: string): FirestoreDocument<any>;
|
|
15
|
+
collection(path: string): FirestoreCollection<any>;
|
|
16
|
+
collectionGroup(collectionId: string): FirestoreCollectionGroup<any>;
|
|
17
|
+
runTransaction(): void;
|
|
18
|
+
query<Data>(collection: FirestoreCollection<Data>, ...queryFnArray: QueryFn<Data>[]): any;
|
|
19
|
+
orderBy<Data>(key: string, order?: 'asc' | 'desc'): QueryFn<Data>;
|
|
20
|
+
limit<Data>(n: number): QueryFn<Data>;
|
|
21
|
+
batch(): import("@firebase/firestore").WriteBatch;
|
|
22
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FirebaseFirestoreAdapter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const firestore_1 = require("firebase/firestore");
|
|
6
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
7
|
+
const rxjs_1 = require("rxjs");
|
|
8
|
+
const base_1 = require("../base");
|
|
9
|
+
const firestore_2 = require("@angular/fire/firestore");
|
|
10
|
+
class FirebaseFirestoreAdapter extends base_1.FirestoreAdapter {
|
|
11
|
+
constructor(firestore = (0, firestore_1.getFirestore)()) {
|
|
12
|
+
super();
|
|
13
|
+
this.firestore = firestore;
|
|
14
|
+
this.isTimestamp = (v) => v instanceof firestore_1.Timestamp;
|
|
15
|
+
this.isDate = (v) => dayjs_1.default.isDayjs(v);
|
|
16
|
+
}
|
|
17
|
+
get FieldValue() {
|
|
18
|
+
return firestore_1.FieldValue;
|
|
19
|
+
}
|
|
20
|
+
get Timestamp() {
|
|
21
|
+
return firestore_1.Timestamp;
|
|
22
|
+
}
|
|
23
|
+
convertDateToTimestamp(date) {
|
|
24
|
+
return firestore_1.Timestamp.fromDate(date.toDate());
|
|
25
|
+
}
|
|
26
|
+
convertTimestampToDate(timestamp) {
|
|
27
|
+
return (0, dayjs_1.default)(timestamp.toDate());
|
|
28
|
+
}
|
|
29
|
+
doc(path) {
|
|
30
|
+
const docRef = (0, firestore_1.doc)(this.firestore, path);
|
|
31
|
+
return {
|
|
32
|
+
__ref: docRef,
|
|
33
|
+
set: (data) => (0, firestore_1.setDoc)(docRef, data),
|
|
34
|
+
get: () => (0, firestore_1.getDoc)(docRef),
|
|
35
|
+
update: (data) => (0, firestore_2.updateDoc)(docRef, data),
|
|
36
|
+
delete: () => (0, firestore_1.deleteDoc)(docRef),
|
|
37
|
+
stateChanges: () => {
|
|
38
|
+
const subject = new rxjs_1.Subject();
|
|
39
|
+
(0, firestore_1.onSnapshot)(docRef, (doc) => subject.next({ id: doc.id, ref: doc.ref, data: () => doc.data() }));
|
|
40
|
+
return subject.asObservable();
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
collection(path) {
|
|
45
|
+
const ref = (0, firestore_1.collection)(this.firestore, path);
|
|
46
|
+
return {
|
|
47
|
+
__ref: ref,
|
|
48
|
+
stateChanges: () => {
|
|
49
|
+
const subject = new rxjs_1.Subject();
|
|
50
|
+
(0, firestore_1.onSnapshot)(ref, (snapshot) => subject.next(snapshot.docChanges().map(change => ({
|
|
51
|
+
type: change.type, payload: { doc: change.doc },
|
|
52
|
+
}))));
|
|
53
|
+
return subject.asObservable();
|
|
54
|
+
},
|
|
55
|
+
get: () => (0, firestore_1.getDocs)(ref),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
collectionGroup(collectionId) {
|
|
59
|
+
const ref = (0, firestore_1.collectionGroup)(this.firestore, collectionId);
|
|
60
|
+
return {
|
|
61
|
+
__ref: ref,
|
|
62
|
+
stateChanges: () => {
|
|
63
|
+
const subject = new rxjs_1.Subject();
|
|
64
|
+
(0, firestore_1.onSnapshot)(ref, (snapshot) => subject.next(snapshot.docChanges().map(change => ({
|
|
65
|
+
type: change.type, payload: { doc: change.doc },
|
|
66
|
+
}))));
|
|
67
|
+
return subject.asObservable();
|
|
68
|
+
},
|
|
69
|
+
get: () => (0, firestore_1.getDocs)(ref),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
runTransaction() {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
query(collection, ...queryFnArray) {
|
|
76
|
+
return (0, firestore_1.query)(collection.__ref, ...queryFnArray.map(queryFn => queryFn()));
|
|
77
|
+
}
|
|
78
|
+
orderBy(key, order = 'asc') {
|
|
79
|
+
return () => (0, firestore_1.orderBy)(key, order);
|
|
80
|
+
}
|
|
81
|
+
limit(n) {
|
|
82
|
+
return () => (0, firestore_1.limit)(n);
|
|
83
|
+
}
|
|
84
|
+
batch() {
|
|
85
|
+
return (0, firestore_1.writeBatch)(this.firestore);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.FirebaseFirestoreAdapter = FirebaseFirestoreAdapter;
|
|
89
|
+
//# sourceMappingURL=firebase.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firebase.adapter.js","sourceRoot":"","sources":["../../../../../../packages/@nx-ddd/firestore/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/src/lib/adapters/firebase/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./admin"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./base"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./firebase"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/firestore/src/lib/adapters/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,iDAAuB;AACvB,qDAA2B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
import { FirestoreAdapter } from '../adapters/base';
|
|
3
|
+
import { DocumentSnapshot, ToFirestoreData } from '../interfaces';
|
|
4
|
+
export declare class FirestoreConverter<Entity = any, Data = ToFirestoreData<Entity, Dayjs>> {
|
|
5
|
+
protected Entity: any;
|
|
6
|
+
protected adapter: FirestoreAdapter<any>;
|
|
7
|
+
private get fields();
|
|
8
|
+
fromRecord<Data>(doc: DocumentSnapshot<Data>): Entity;
|
|
9
|
+
toRecord<Entity>(entity: Entity): Data;
|
|
10
|
+
}
|
|
11
|
+
export declare function createConverter<E = any>(Entity: any, adapter: FirestoreAdapter): FirestoreConverter<E>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createConverter = exports.FirestoreConverter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@nx-ddd/core");
|
|
6
|
+
const lodash_pick_1 = tslib_1.__importDefault(require("lodash.pick"));
|
|
7
|
+
const decorators_1 = require("../decorators");
|
|
8
|
+
let FirestoreConverter = class FirestoreConverter {
|
|
9
|
+
get fields() {
|
|
10
|
+
const annotations = this.Entity[decorators_1.FIRESTORE_ANNOTATIONS];
|
|
11
|
+
return annotations.map(a => a.fieldName);
|
|
12
|
+
}
|
|
13
|
+
fromRecord(doc) {
|
|
14
|
+
return this.Entity.fromObj(this.adapter.fromFirestoreData(Object.assign(Object.assign({}, doc.data()), { id: doc.id })));
|
|
15
|
+
}
|
|
16
|
+
toRecord(entity) {
|
|
17
|
+
const data = this.adapter.toFirestoreData(this.Entity.toObj(entity));
|
|
18
|
+
return (0, lodash_pick_1.default)(data, this.fields);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
FirestoreConverter = tslib_1.__decorate([
|
|
22
|
+
(0, core_1.Injectable)()
|
|
23
|
+
], FirestoreConverter);
|
|
24
|
+
exports.FirestoreConverter = FirestoreConverter;
|
|
25
|
+
function createConverter(Entity, adapter) {
|
|
26
|
+
class Converter extends FirestoreConverter {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.Entity = Entity;
|
|
30
|
+
this.adapter = adapter;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return new Converter();
|
|
34
|
+
}
|
|
35
|
+
exports.createConverter = createConverter;
|
|
36
|
+
//# sourceMappingURL=converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/firestore/src/lib/converter/converter.ts"],"names":[],"mappings":";;;;AACA,uCAA0C;AAC1C,sEAA+B;AAG/B,8CAA2E;AAIpE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAI7B,IAAY,MAAM;QAChB,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,kCAAqB,CAA0B,CAAC;QAChF,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC3C,CAAC;IAED,UAAU,CAAO,GAA2B;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,iBAAiB,iCACpD,GAAG,CAAC,IAAI,EAAE,KACb,EAAE,EAAE,GAAG,CAAC,EAAE,IACV,CAAC,CAAC;IACN,CAAC;IAED,QAAQ,CAAS,MAAc;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAS,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7E,OAAO,IAAA,qBAAI,EAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAS,CAAC;IACzC,CAAC;CACF,CAAA;AApBY,kBAAkB;IAD9B,IAAA,iBAAU,GAAE;GACA,kBAAkB,CAoB9B;AApBY,gDAAkB;AAsB/B,SAAgB,eAAe,CAC7B,MAAW,EACX,OAAyB;IAEzB,MAAM,SAAU,SAAQ,kBAAqB;QAA7C;;YACY,WAAM,GAAG,MAAM,CAAC;YAChB,YAAO,GAAG,OAAO,CAAC;QAC9B,CAAC;KAAA;IAED,OAAO,IAAI,SAAS,EAAE,CAAC;AACzB,CAAC;AAVD,0CAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './converter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/firestore/src/lib/converter/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { FirestoreAdapter } from '../adapters/base';
|
|
3
|
+
import { FirestoreConverter } from '../converter';
|
|
4
|
+
import { FirestoreCollection, FirestoreCollectionGroup, FirestoreDocument, ToFirestoreData } from '../interfaces';
|
|
5
|
+
import { FirestorePathBuilder } from '../path-builder';
|
|
6
|
+
export declare abstract class FirestoreDAO<Entity extends {
|
|
7
|
+
id: string;
|
|
8
|
+
}, FirestoreData = ToFirestoreData<Entity, dayjs.Dayjs>> {
|
|
9
|
+
protected adapter: FirestoreAdapter;
|
|
10
|
+
protected converter: FirestoreConverter<Entity>;
|
|
11
|
+
protected abstract pathBuilder: FirestorePathBuilder<Entity>;
|
|
12
|
+
constructor(adapter: FirestoreAdapter, converter: FirestoreConverter<Entity>);
|
|
13
|
+
protected collection(paramMap?: Partial<Entity>): FirestoreCollection<FirestoreData>;
|
|
14
|
+
protected collectionGroup(): FirestoreCollectionGroup<FirestoreData>;
|
|
15
|
+
protected doc(paramMap: Partial<Entity> & {
|
|
16
|
+
id: string;
|
|
17
|
+
}): FirestoreDocument<FirestoreData>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FirestoreDAO = void 0;
|
|
4
|
+
class FirestoreDAO {
|
|
5
|
+
constructor(adapter, converter) {
|
|
6
|
+
this.adapter = adapter;
|
|
7
|
+
this.converter = converter;
|
|
8
|
+
}
|
|
9
|
+
collection(paramMap) {
|
|
10
|
+
const path = this.pathBuilder.collection(paramMap);
|
|
11
|
+
return this.adapter.collection(path);
|
|
12
|
+
}
|
|
13
|
+
collectionGroup() {
|
|
14
|
+
const path = this.pathBuilder.collectionGroup();
|
|
15
|
+
return this.adapter.collectionGroup(path);
|
|
16
|
+
}
|
|
17
|
+
doc(paramMap) {
|
|
18
|
+
const path = this.pathBuilder.doc(paramMap);
|
|
19
|
+
return this.adapter.doc(path);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.FirestoreDAO = FirestoreDAO;
|
|
23
|
+
//# sourceMappingURL=firestore.dao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore.dao.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/firestore/src/lib/dao/firestore.dao.ts"],"names":[],"mappings":";;;AAOA,MAAsB,YAAY;IAMhC,YACY,OAAyB,EACzB,SAAqC;QADrC,YAAO,GAAP,OAAO,CAAkB;QACzB,cAAS,GAAT,SAAS,CAA4B;IAC7C,CAAC;IAEK,UAAU,CAAC,QAA0B;QAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAgB,IAAI,CAAC,CAAC;IACtD,CAAC;IAES,eAAe;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAgB,IAAI,CAAC,CAAC;IAC3D,CAAC;IAES,GAAG,CAAC,QAAwC;QACpD,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAgB,IAAI,CAAC,CAAC;IAC/C,CAAC;CACF;AAzBD,oCAyBC"}
|
package/dao/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './firestore.dao';
|
package/dao/index.js
ADDED
package/dao/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/firestore/src/lib/dao/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const FIRESTORE_ANNOTATIONS = "firestore_annotations";
|
|
2
|
+
export declare type FirestoreFieldType = 'boolean' | 'number' | 'timestamp' | 'string' | 'geopoint' | 'null' | 'map' | 'array' | 'reference';
|
|
3
|
+
export interface FirestoreAnnotation {
|
|
4
|
+
type: FirestoreFieldType;
|
|
5
|
+
fieldName: string;
|
|
6
|
+
propName: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const String: (props?: {
|
|
9
|
+
name?: string;
|
|
10
|
+
}) => (target: any, propName: string) => void;
|
|
11
|
+
export declare const Null: (props?: {
|
|
12
|
+
name?: string;
|
|
13
|
+
}) => (target: any, propName: string) => void;
|
|
14
|
+
export declare const Geopoint: (props?: {
|
|
15
|
+
name?: string;
|
|
16
|
+
}) => (target: any, propName: string) => void;
|
|
17
|
+
export declare const Boolean: (props?: {
|
|
18
|
+
name?: string;
|
|
19
|
+
}) => (target: any, propName: string) => void;
|
|
20
|
+
export declare const Timestamp: (props?: {
|
|
21
|
+
name?: string;
|
|
22
|
+
}) => (target: any, propName: string) => void;
|
|
23
|
+
export declare const Number: (props?: {
|
|
24
|
+
name?: string;
|
|
25
|
+
}) => (target: any, propName: string) => void;
|
|
26
|
+
export declare const Map: (props?: {
|
|
27
|
+
name?: string;
|
|
28
|
+
}) => (target: any, propName: string) => void;
|
|
29
|
+
export declare const Array: (props?: {
|
|
30
|
+
name?: string;
|
|
31
|
+
}) => (target: any, propName: string) => void;
|
|
32
|
+
export declare const Reference: (props?: {
|
|
33
|
+
name?: string;
|
|
34
|
+
}) => (target: any, propName: string) => void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Reference = exports.Array = exports.Map = exports.Number = exports.Timestamp = exports.Boolean = exports.Geopoint = exports.Null = exports.String = exports.FIRESTORE_ANNOTATIONS = void 0;
|
|
4
|
+
exports.FIRESTORE_ANNOTATIONS = 'firestore_annotations';
|
|
5
|
+
;
|
|
6
|
+
function createDecorator(type) {
|
|
7
|
+
return (props) => {
|
|
8
|
+
return (target, propName) => {
|
|
9
|
+
var _a;
|
|
10
|
+
var _b;
|
|
11
|
+
const fieldName = (props === null || props === void 0 ? void 0 : props.name) || propName;
|
|
12
|
+
const ANNOTATION = { type, fieldName, propName };
|
|
13
|
+
(_a = (_b = target.constructor)[exports.FIRESTORE_ANNOTATIONS]) !== null && _a !== void 0 ? _a : (_b[exports.FIRESTORE_ANNOTATIONS] = []);
|
|
14
|
+
target.constructor[exports.FIRESTORE_ANNOTATIONS].push(ANNOTATION);
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.String = createDecorator('string');
|
|
19
|
+
exports.Null = createDecorator('null');
|
|
20
|
+
exports.Geopoint = createDecorator('geopoint');
|
|
21
|
+
exports.Boolean = createDecorator('boolean');
|
|
22
|
+
exports.Timestamp = createDecorator('timestamp');
|
|
23
|
+
exports.Number = createDecorator('number');
|
|
24
|
+
exports.Map = createDecorator('map');
|
|
25
|
+
exports.Array = createDecorator('array');
|
|
26
|
+
exports.Reference = createDecorator('reference');
|
|
27
|
+
//# sourceMappingURL=decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/firestore/src/lib/decorators/decorators.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,uBAAuB,CAAC;AAQ5D,CAAC;AAEF,SAAS,eAAe,CAAC,IAAwB;IAC/C,OAAO,CAAC,KAAuB,EAAE,EAAE;QACjC,OAAO,CAAC,MAAW,EAAE,QAAgB,EAAE,EAAE;;;YACvC,MAAM,SAAS,GAAG,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,KAAI,QAAQ,CAAC;YAC1C,MAAM,UAAU,GAAwB,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAC,CAAC;YACpE,YAAA,MAAM,CAAC,WAAW,EAAC,6BAAqB,wCAArB,6BAAqB,IAAM,EAAE,EAAC;YACjD,MAAM,CAAC,WAAW,CAAC,6BAAqB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7D,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAEY,QAAA,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAC/B,QAAA,QAAQ,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;AACvC,QAAA,OAAO,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;AACrC,QAAA,SAAS,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;AACzC,QAAA,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;AACnC,QAAA,GAAG,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;AAC7B,QAAA,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;AACjC,QAAA,SAAS,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './decorators';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/firestore/src/lib/decorators/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B"}
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./adapters"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./converter"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./dao"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./decorators"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./path-builder"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./query"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./repository"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./testing"), exports);
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/@nx-ddd/firestore/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,sDAA4B;AAC5B,gDAAsB;AACtB,uDAA6B;AAC7B,yDAA+B;AAC/B,kDAAwB;AACxB,uDAA6B;AAC7B,oDAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './interfaces';
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./adapter"), exports);
|
|
5
4
|
tslib_1.__exportStar(require("./interfaces"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./repository"), exports);
|
|
7
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/@nx-ddd/firestore/src/lib/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B"}
|