@entropic-bond/firebase-admin 1.4.0 → 1.6.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.
@@ -5,7 +5,7 @@ export declare class FirebaseAdminHelper {
5
5
  private constructor();
6
6
  static get instance(): FirebaseAdminHelper;
7
7
  firestore(): admin.firestore.Firestore;
8
- auth(): import("firebase-admin/lib/auth/auth").Auth;
8
+ auth(): admin.auth.Auth;
9
9
  private static _instance;
10
10
  private static _firebaseConfig;
11
11
  }
@@ -29,6 +29,9 @@ export declare class TestUser extends Persistent {
29
29
  get derived(): DerivedUser | undefined;
30
30
  set manyDerived(value: DerivedUser[] | undefined);
31
31
  get manyDerived(): DerivedUser[] | undefined;
32
+ set colleagues(value: TestUser[]);
33
+ get colleagues(): TestUser[];
34
+ private _colleagues;
32
35
  private _name;
33
36
  private _age;
34
37
  private _admin;
@@ -1,4 +1,5 @@
1
- import { Collections, DataSource, DocumentObject, QueryObject } from 'entropic-bond';
1
+ import { Collections, DataSource, DocumentObject, QueryObject, QueryOperator } from 'entropic-bond';
2
+ import { WhereFilterOp } from 'firebase-admin/firestore';
2
3
  export declare class FirebaseAdminDatasource extends DataSource {
3
4
  findById(id: string, collectionName: string): Promise<DocumentObject>;
4
5
  save(collections: Collections): Promise<void>;
@@ -8,6 +9,7 @@ export declare class FirebaseAdminDatasource extends DataSource {
8
9
  next(maxDocs?: number): Promise<DocumentObject[]>;
9
10
  private getFromQuery;
10
11
  private queryObjectToFirebaseQuery;
12
+ toFirebaseOperator(operator: QueryOperator): WhereFilterOp;
11
13
  private _lastQuery;
12
14
  private _lastLimit;
13
15
  private _lastDocRetrieved;
package/package.json CHANGED
@@ -1,6 +1,21 @@
1
1
  {
2
2
  "name": "@entropic-bond/firebase-admin",
3
- "version": "1.4.0",
3
+ "type": "module",
4
+ "version": "1.6.0",
5
+ "description": "Firebase Admin plugins for Entropic Bond",
6
+ "main": "lib/entropic-bond-firebase-admin.umd.cjs",
7
+ "module": "lib/entropic-bond-firebase-admin.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./lib/entropic-bond-firebase-admin.js",
11
+ "require": "./lib/entropic-bond-firebase-admin.umd.cjs",
12
+ "types": "./lib/index.d.ts"
13
+ }
14
+ },
15
+ "types": "./lib/index.d.ts",
16
+ "files": [
17
+ "lib"
18
+ ],
4
19
  "publishConfig": {
5
20
  "access": "public",
6
21
  "branches": [
@@ -16,18 +31,10 @@
16
31
  "@semantic-release/github"
17
32
  ]
18
33
  },
19
- "description": "Firebase Admin plugins for Entropic Bond",
20
- "main": "lib/index.js",
21
- "types": "lib/index.d.ts",
22
- "files": [
23
- "lib"
24
- ],
25
34
  "scripts": {
26
- "test": "firebase emulators:exec --project demo-test 'jest --forceExit'",
27
- "build": "npm run build-cjs",
35
+ "test": "firebase emulators:exec --project demo-test 'vitest'",
36
+ "build": "tsc -p tsconfig-build.json && vite build",
28
37
  "prepare": "npm run build",
29
- "build-ts": "cp -r ./src/ ./lib",
30
- "build-cjs": "tsc -p tsconfig-cjs.json",
31
38
  "emulators": "firebase emulators:start --project demo-test"
32
39
  },
33
40
  "repository": {
@@ -47,17 +54,17 @@
47
54
  "devDependencies": {
48
55
  "@semantic-release/changelog": "^6.0.3",
49
56
  "@semantic-release/git": "^10.0.1",
50
- "@types/jest": "^29.5.2",
51
57
  "git-branch-is": "^4.0.0",
52
- "husky": "^8.0.3",
53
- "jest": "^29.5.0",
54
- "semantic-release": "^21.0.5",
55
- "ts-jest": "^29.1.0",
56
- "typescript": "^5.1.3"
58
+ "husky": "^9.0.10",
59
+ "semantic-release": "^23.0.2",
60
+ "typescript": "^5.3.3",
61
+ "vite": "^5.0.12",
62
+ "vite-plugin-dts": "^3.7.2",
63
+ "vitest": "^1.2.2"
57
64
  },
58
65
  "dependencies": {
59
- "entropic-bond": "^1.43.1",
60
- "firebase-admin": "^11.9.0"
66
+ "entropic-bond": "^1.50.3",
67
+ "firebase-admin": "^12.0.0"
61
68
  },
62
69
  "husky": {
63
70
  "hooks": {
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FirebaseAdminHelper = void 0;
7
- const firebase_admin_1 = __importDefault(require("firebase-admin"));
8
- class FirebaseAdminHelper {
9
- static setFirebaseConfig(config) {
10
- FirebaseAdminHelper._firebaseConfig = config;
11
- }
12
- constructor() {
13
- firebase_admin_1.default.initializeApp(FirebaseAdminHelper._firebaseConfig);
14
- }
15
- static get instance() {
16
- return this._instance || (this._instance = new FirebaseAdminHelper());
17
- }
18
- firestore() {
19
- return firebase_admin_1.default.firestore();
20
- }
21
- auth() {
22
- return firebase_admin_1.default.auth();
23
- }
24
- }
25
- exports.FirebaseAdminHelper = FirebaseAdminHelper;
26
- //# sourceMappingURL=firebase-admin-helper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"firebase-admin-helper.js","sourceRoot":"","sources":["../src/firebase-admin-helper.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAkC;AAGlC,MAAa,mBAAmB;IAE/B,MAAM,CAAC,iBAAiB,CAAE,MAAmB;QAC5C,mBAAmB,CAAC,eAAe,GAAG,MAAM,CAAA;IAC7C,CAAC;IAED;QACC,wBAAK,CAAC,aAAa,CAAE,mBAAmB,CAAC,eAAe,CAAE,CAAA;IAC3D,CAAC;IAED,MAAM,KAAK,QAAQ;QAClB,OAAO,IAAI,CAAC,SAAS,IAAI,CAAE,IAAI,CAAC,SAAS,GAAG,IAAI,mBAAmB,EAAE,CAAE,CAAA;IACxE,CAAC;IAED,SAAS;QACR,OAAO,wBAAK,CAAC,SAAS,EAAE,CAAA;IACzB,CAAC;IAED,IAAI;QACH,OAAO,wBAAK,CAAC,IAAI,EAAE,CAAA;IACpB,CAAC;CAID;AAxBD,kDAwBC"}
package/lib/index.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./store/firebase-admin-datasource"), exports);
18
- __exportStar(require("./firebase-admin-helper"), exports);
19
- __exportStar(require("./server-auth/firebase-server-auth"), exports);
20
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oEAAiD;AACjD,0DAAuC;AACvC,qEAAkD"}
@@ -1,108 +0,0 @@
1
- {
2
- "TestUser": {
3
- "user1": {
4
- "__className": "TestUser",
5
- "id": "user1",
6
- "name": {
7
- "firstName": "userFirstName1",
8
- "lastName": "userLastName1"
9
- },
10
- "age": 23,
11
- "admin": true,
12
- "skills": ["skill1", "skill2", "skill3"]
13
- },
14
- "user2": {
15
- "__className": "TestUser",
16
- "id": "user2",
17
- "name": {
18
- "firstName": "userFirstName2",
19
- "lastName": "userLastName2",
20
- "ancestorName": {
21
- "father": "user2Father"
22
- }
23
- },
24
- "age": 21,
25
- "admin": false,
26
- "skills": ["skill1", "skill2", "skill3"]
27
- },
28
- "user3": {
29
- "__className": "TestUser",
30
- "id": "user3",
31
- "name": {
32
- "firstName": "userFirstName3",
33
- "lastName": "userLastName3",
34
- "ancestorName": {
35
- "father": "user3Father"
36
- }
37
- },
38
- "age": 56,
39
- "admin": true,
40
- "skills": ["skill21", "skill22", "skill23"]
41
- },
42
- "user4": {
43
- "__className": "DerivedUser",
44
- "id": "user4",
45
- "name": {
46
- "firstName": "userFirstName4",
47
- "lastName": "userLastName4"
48
- },
49
- "age": 35,
50
- "admin": false,
51
- "skills": ["skill41", "skill42", "skill43"],
52
- "salary": 2800
53
- },
54
- "user5": {
55
- "__className": "TestUser",
56
- "id": "user5",
57
- "name": {
58
- "firstName": "userFirstName5",
59
- "lastName": "userLastName5",
60
- "ancestorName": {
61
- "father": "user5Father"
62
- }
63
- },
64
- "age": 41,
65
- "skills": ["skill21", "skill22", "skill23"],
66
- "derived": {
67
- "id": "user3",
68
- "__className": "DerivedUser",
69
- "__documentReference": {
70
- "storedInCollection": "DerivedUser"
71
- }
72
- }
73
- },
74
- "user6": {
75
- "__className": "TestUser",
76
- "id": "user6",
77
- "name": {
78
- "firstName": "userFirstName6",
79
- "lastName": "userLastName6",
80
- "ancestorName": {
81
- "father": "user6Father"
82
- }
83
- },
84
- "age": 40,
85
- "skills": ["skill21", "skill22", "skill23"],
86
- "derived": {
87
- "id": "user4",
88
- "__className": "DerivedUser",
89
- "__documentReference": {
90
- "storedInCollection": "TestUser"
91
- }
92
- }
93
- }
94
- },
95
- "DerivedUser": {
96
- "user4": {
97
- "__className": "DerivedUser",
98
- "id": "user5",
99
- "name": {
100
- "firstName": "userFirstName5",
101
- "lastName": "userLastName5"
102
- },
103
- "age": 35,
104
- "admin": false,
105
- "salary": 2300
106
- }
107
- }
108
- }
@@ -1,120 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.DerivedUser = exports.TestUser = exports.SubClass = void 0;
10
- const entropic_bond_1 = require("entropic-bond");
11
- let SubClass = exports.SubClass = class SubClass extends entropic_bond_1.Persistent {
12
- set year(value) {
13
- this._year = value;
14
- }
15
- get year() {
16
- return this._year;
17
- }
18
- };
19
- __decorate([
20
- entropic_bond_1.persistent
21
- ], SubClass.prototype, "_year", void 0);
22
- exports.SubClass = SubClass = __decorate([
23
- (0, entropic_bond_1.registerPersistentClass)('SubClass')
24
- ], SubClass);
25
- let TestUser = exports.TestUser = class TestUser extends entropic_bond_1.Persistent {
26
- constructor() {
27
- super(...arguments);
28
- this._manyRefs = [];
29
- }
30
- set name(value) {
31
- this._name = value;
32
- }
33
- get name() {
34
- return this._name;
35
- }
36
- set age(value) {
37
- this._age = value;
38
- }
39
- get age() {
40
- return this._age;
41
- }
42
- set admin(value) {
43
- this._admin = value;
44
- }
45
- get admin() {
46
- return this._admin;
47
- }
48
- set skills(value) {
49
- this._skills = value;
50
- }
51
- get skills() {
52
- return this._skills;
53
- }
54
- set documentRef(value) {
55
- this._documentRef = value;
56
- }
57
- get documentRef() {
58
- return this._documentRef;
59
- }
60
- set manyRefs(value) {
61
- this._manyRefs = value;
62
- }
63
- get manyRefs() {
64
- return this._manyRefs;
65
- }
66
- set derived(value) {
67
- this._derived = value;
68
- }
69
- get derived() {
70
- return this._derived;
71
- }
72
- set manyDerived(value) {
73
- this._manyDerived = value;
74
- }
75
- get manyDerived() {
76
- return this._manyDerived;
77
- }
78
- };
79
- __decorate([
80
- entropic_bond_1.persistent
81
- ], TestUser.prototype, "_name", void 0);
82
- __decorate([
83
- entropic_bond_1.persistent
84
- ], TestUser.prototype, "_age", void 0);
85
- __decorate([
86
- entropic_bond_1.persistent
87
- ], TestUser.prototype, "_admin", void 0);
88
- __decorate([
89
- entropic_bond_1.persistent
90
- ], TestUser.prototype, "_skills", void 0);
91
- __decorate([
92
- entropic_bond_1.persistentReference
93
- ], TestUser.prototype, "_documentRef", void 0);
94
- __decorate([
95
- entropic_bond_1.persistentReference
96
- ], TestUser.prototype, "_manyRefs", void 0);
97
- __decorate([
98
- (0, entropic_bond_1.persistentReferenceAt)('TestUser')
99
- ], TestUser.prototype, "_derived", void 0);
100
- __decorate([
101
- (0, entropic_bond_1.persistentReferenceAt)('TestUser')
102
- ], TestUser.prototype, "_manyDerived", void 0);
103
- exports.TestUser = TestUser = __decorate([
104
- (0, entropic_bond_1.registerPersistentClass)('TestUser')
105
- ], TestUser);
106
- let DerivedUser = exports.DerivedUser = class DerivedUser extends TestUser {
107
- set salary(value) {
108
- this._salary = value;
109
- }
110
- get salary() {
111
- return this._salary;
112
- }
113
- };
114
- __decorate([
115
- entropic_bond_1.persistent
116
- ], DerivedUser.prototype, "_salary", void 0);
117
- exports.DerivedUser = DerivedUser = __decorate([
118
- (0, entropic_bond_1.registerPersistentClass)('DerivedUser')
119
- ], DerivedUser);
120
- //# sourceMappingURL=test-user.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-user.js","sourceRoot":"","sources":["../../src/mocks/test-user.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iDAA2H;AAYpH,IAAM,QAAQ,sBAAd,MAAM,QAAS,SAAQ,0BAAU;IACvC,IAAI,IAAI,CAAE,KAAyB;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACnB,CAAC;IAED,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,KAAK,CAAA;IAClB,CAAC;CAGD,CAAA;AADoB;IAAnB,0BAAU;uCAAkC;mBATjC,QAAQ;IADpB,IAAA,uCAAuB,EAAE,UAAU,CAAE;GACzB,QAAQ,CAUpB;AAGM,IAAM,QAAQ,sBAAd,MAAM,QAAS,SAAQ,0BAAU;IAAjC;;QAsEuB,cAAS,GAAe,EAAE,C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;IAAnB,0BAAU;uCAAgC;AACvB;IAAnB,0BAAU;sCAAiC;AACxB;IAAnB,0BAAU;wCAAoC;AAC3B;IAAnB,0BAAU;yCAAsC;AACpB;IAA5B,mCAAmB;8CAA2C;AAClC;IAA5B,mCAAmB;2CAAmC;AACZ;IAA1C,IAAA,qCAAqB,EAAC,UAAU,CAAC;0CAA0C;AACjC;IAA1C,IAAA,qCAAqB,EAAC,UAAU,CAAC;8CAAgD;mBAxEtE,QAAQ;IADpB,IAAA,uCAAuB,EAAE,UAAU,CAAE;GACzB,QAAQ,CAyEpB;AAGM,IAAM,WAAW,yBAAjB,MAAM,WAAY,SAAQ,QAAQ;IACxC,IAAI,MAAM,CAAC,KAAyB;QACnC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,OAAO,CAAA;IACpB,CAAC;CAGD,CAAA;AADoB;IAAnB,0BAAU;4CAAoC;sBATnC,WAAW;IADvB,IAAA,uCAAuB,EAAE,aAAa,CAAE;GAC5B,WAAW,CAUvB"}
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FirebaseServerAuth = void 0;
4
- const entropic_bond_1 = require("entropic-bond");
5
- const firebase_admin_helper_1 = require("../firebase-admin-helper");
6
- class FirebaseServerAuth extends entropic_bond_1.ServerAuthService {
7
- async getUser(userId) {
8
- try {
9
- return this.convertToUserCredentials(await firebase_admin_helper_1.FirebaseAdminHelper.instance.auth().getUser(userId));
10
- }
11
- catch (error) {
12
- if (error.code === 'auth/user-not-found')
13
- return undefined;
14
- else
15
- throw new Error(error);
16
- }
17
- }
18
- setCustomCredentials(userId, customCredentials) {
19
- return firebase_admin_helper_1.FirebaseAdminHelper.instance.auth().setCustomUserClaims(userId, customCredentials);
20
- }
21
- async updateUser(userId, credentials) {
22
- return this.convertToUserCredentials(await firebase_admin_helper_1.FirebaseAdminHelper.instance.auth().updateUser(userId, credentials));
23
- }
24
- async deleteUser(userId) {
25
- try {
26
- await firebase_admin_helper_1.FirebaseAdminHelper.instance.auth().deleteUser(userId);
27
- }
28
- catch (error) {
29
- if (error.code === 'auth/user-not-found')
30
- return undefined;
31
- else
32
- throw new Error(error);
33
- }
34
- }
35
- convertToUserCredentials(userData) {
36
- return {
37
- id: userData.uid,
38
- email: userData.email ?? '',
39
- emailVerified: userData.emailVerified ?? undefined,
40
- creationDate: userData.metadata.creationTime ? new Date(userData.metadata.creationTime).getTime() : undefined,
41
- lastLogin: userData.metadata.lastSignInTime ? new Date(userData.metadata.lastSignInTime).getTime() : undefined,
42
- name: userData.displayName,
43
- phoneNumber: userData.phoneNumber ?? undefined,
44
- pictureUrl: userData.photoURL ?? undefined,
45
- customData: userData.customClaims
46
- };
47
- }
48
- }
49
- exports.FirebaseServerAuth = FirebaseServerAuth;
50
- //# sourceMappingURL=firebase-server-auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"firebase-server-auth.js","sourceRoot":"","sources":["../../src/server-auth/firebase-server-auth.ts"],"names":[],"mappings":";;;AAAA,iDAAqF;AAErF,oEAA8D;AAE9D,MAAa,kBAAmB,SAAQ,iCAAiB;IAExD,KAAK,CAAC,OAAO,CAAgB,MAAc;QAC1C,IAAI;YACH,OAAO,IAAI,CAAC,wBAAwB,CACnC,MAAM,2CAAmB,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,CAAE,MAAM,CAAE,CAC3D,CAAA;SACD;QAAC,OAAQ,KAAK,EAAG;YACjB,IAAK,KAAK,CAAC,IAAI,KAAK,qBAAqB;gBAAG,OAAO,SAAS,CAAA;;gBACvD,MAAM,IAAI,KAAK,CAAE,KAAK,CAAE,CAAA;SAC7B;IACF,CAAC;IAED,oBAAoB,CAA+B,MAAc,EAAE,iBAAoB;QACtF,OAAO,2CAAmB,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,mBAAmB,CAAE,MAAM,EAAE,iBAAiB,CAAE,CAAA;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;CACD;AA9CD,gDA8CC"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const entropic_bond_1 = require("entropic-bond");
4
- const firebase_admin_helper_1 = require("../firebase-admin-helper");
5
- const firebase_server_auth_1 = require("./firebase-server-auth");
6
- describe('Firebase Server Auth', () => {
7
- firebase_admin_helper_1.FirebaseAdminHelper.setFirebaseConfig({
8
- projectId: "demo-test",
9
- });
10
- beforeEach(() => {
11
- entropic_bond_1.ServerAuth.useServerAuthService(new firebase_server_auth_1.FirebaseServerAuth());
12
- });
13
- it('should not throw if user not found', async () => {
14
- expect.assertions(1);
15
- await expect(entropic_bond_1.ServerAuth.instance.getUser('non-existing-user-id')).resolves.toBeUndefined();
16
- });
17
- it('should not throw if user not found in deleteUser', async () => {
18
- expect.assertions(1);
19
- await expect(entropic_bond_1.ServerAuth.instance.deleteUser('non-existing-user-id')).resolves.toBeUndefined();
20
- });
21
- });
22
- //# sourceMappingURL=firebase-server-auth.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"firebase-server-auth.spec.js","sourceRoot":"","sources":["../../src/server-auth/firebase-server-auth.spec.ts"],"names":[],"mappings":";;AAAA,iDAA0C;AAC1C,oEAA8D;AAC9D,iEAA2D;AAE3D,QAAQ,CAAE,sBAAsB,EAAE,GAAE,EAAE;IACrC,2CAAmB,CAAC,iBAAiB,CAAC;QACrC,SAAS,EAAE,WAAW;KACtB,CAAC,CAAA;IAEF,UAAU,CAAC,GAAE,EAAE;QACd,0BAAU,CAAC,oBAAoB,CAAE,IAAI,yCAAkB,EAAE,CAAE,CAAA;IAC5D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAE,oCAAoC,EAAE,KAAK,IAAG,EAAE;QACnD,MAAM,CAAC,UAAU,CAAE,CAAC,CAAE,CAAA;QACtB,MAAM,MAAM,CACX,0BAAU,CAAC,QAAQ,CAAC,OAAO,CAAE,sBAAsB,CAAE,CACrD,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAA;IAC3B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAE,kDAAkD,EAAE,KAAK,IAAG,EAAE;QACjE,MAAM,CAAC,UAAU,CAAE,CAAC,CAAE,CAAA;QACtB,MAAM,MAAM,CACX,0BAAU,CAAC,QAAQ,CAAC,UAAU,CAAE,sBAAsB,CAAE,CACxD,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAA;IAC3B,CAAC,CAAC,CAAA;AAEH,CAAC,CAAC,CAAA"}
@@ -1,90 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FirebaseAdminDatasource = void 0;
4
- const entropic_bond_1 = require("entropic-bond");
5
- const firebase_admin_helper_1 = require("../firebase-admin-helper");
6
- const firestore_1 = require("firebase-admin/firestore");
7
- class FirebaseAdminDatasource extends entropic_bond_1.DataSource {
8
- constructor() {
9
- super(...arguments);
10
- this._lastLimit = 0;
11
- }
12
- findById(id, collectionName) {
13
- const db = firebase_admin_helper_1.FirebaseAdminHelper.instance.firestore();
14
- return new Promise(async (resolve) => {
15
- try {
16
- const docSnap = db.doc(`${collectionName}/${id}`);
17
- const retrievedObj = await docSnap.get();
18
- resolve(retrievedObj.data());
19
- }
20
- catch (error) {
21
- console.log(error);
22
- return null;
23
- }
24
- });
25
- }
26
- save(collections) {
27
- const db = firebase_admin_helper_1.FirebaseAdminHelper.instance.firestore();
28
- const batch = db.batch();
29
- Object.entries(collections).forEach(([collectionName, collection]) => {
30
- collection?.forEach(document => {
31
- const ref = db.doc(`${collectionName}/${document.id}`);
32
- batch.set(ref, document);
33
- });
34
- });
35
- return batch.commit();
36
- }
37
- find(queryObject, collectionName) {
38
- const query = this.queryObjectToFirebaseQuery(queryObject, collectionName);
39
- this._lastQuery = query;
40
- return this.getFromQuery(query);
41
- }
42
- async count(queryObject, collectionName) {
43
- const query = this.queryObjectToFirebaseQuery(queryObject, collectionName);
44
- const snapShot = await query.count().get();
45
- return snapShot.data().count;
46
- }
47
- delete(id, collectionName) {
48
- const db = firebase_admin_helper_1.FirebaseAdminHelper.instance.firestore();
49
- return db.recursiveDelete(db.doc(`${collectionName}/${id}`));
50
- }
51
- next(maxDocs) {
52
- if (!this._lastQuery)
53
- throw new Error('You should perform a query prior to using method next');
54
- this._lastLimit = maxDocs || this._lastLimit;
55
- const query = this._lastQuery.limit(this._lastLimit).startAfter(this._lastDocRetrieved);
56
- return this.getFromQuery(query);
57
- }
58
- // prev should be used with next in reverse order
59
- // prev( limit?: number ): Promise< DocumentObject[] > {
60
- // }
61
- getFromQuery(query) {
62
- return new Promise(async (resolve) => {
63
- const doc = await query.get();
64
- this._lastDocRetrieved = doc.docs[doc.docs.length - 1];
65
- resolve(doc.docs.map(doc => doc.data()));
66
- });
67
- }
68
- queryObjectToFirebaseQuery(queryObject, collectionName) {
69
- const db = firebase_admin_helper_1.FirebaseAdminHelper.instance.firestore();
70
- const andConstraints = [];
71
- const orConstraints = [];
72
- entropic_bond_1.DataSource.toPropertyPathOperations(queryObject.operations).forEach(operation => {
73
- if (operation.aggregate)
74
- orConstraints.push(firestore_1.Filter.where(operation.property, operation.operator, operation.value));
75
- else
76
- andConstraints.push(firestore_1.Filter.where(operation.property, operation.operator, operation.value));
77
- });
78
- let query = db.collection(collectionName).where(firestore_1.Filter.or(...orConstraints, firestore_1.Filter.and(...andConstraints)));
79
- if (queryObject.sort?.propertyName) {
80
- query = query.orderBy(queryObject.sort.propertyName, queryObject.sort.order);
81
- }
82
- if (queryObject.limit) {
83
- this._lastLimit = queryObject.limit;
84
- query = query.limit(queryObject.limit);
85
- }
86
- return query;
87
- }
88
- }
89
- exports.FirebaseAdminDatasource = FirebaseAdminDatasource;
90
- //# sourceMappingURL=firebase-admin-datasource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"firebase-admin-datasource.js","sourceRoot":"","sources":["../../src/store/firebase-admin-datasource.ts"],"names":[],"mappings":";;;AAAA,iDAAoF;AACpF,oEAA8D;AAC9D,wDAAiD;AA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