@entropic-bond/firebase 1.6.0 → 1.6.3
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/lib/auth/firebase-auth.js +100 -191
- package/lib/auth/firebase-auth.js.map +1 -1
- package/lib/auth/firebase-auth.spec.js +2 -2
- package/lib/auth/firebase-auth.spec.js.map +1 -1
- package/lib/cloud-storage/firebase-cloud-storage.js +35 -57
- package/lib/cloud-storage/firebase-cloud-storage.js.map +1 -1
- package/lib/cloud-storage/firebase-cloud-storage.spec.js +76 -198
- package/lib/cloud-storage/firebase-cloud-storage.spec.js.map +1 -1
- package/lib/firebase-helper.js +25 -45
- package/lib/firebase-helper.js.map +1 -1
- package/lib/mocks/test-user.js +110 -178
- package/lib/mocks/test-user.js.map +1 -1
- package/lib/store/firebase-datasource.js +48 -123
- package/lib/store/firebase-datasource.js.map +1 -1
- package/lib/store/firebase-datasource.spec.js +311 -691
- package/lib/store/firebase-datasource.spec.js.map +1 -1
- package/package.json +9 -9
package/lib/mocks/test-user.js
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -22,170 +7,117 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
22
7
|
};
|
|
23
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
9
|
exports.DerivedUser = exports.TestUser = exports.SubClass = void 0;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
__decorate([
|
|
42
|
-
entropic_bond_1.persistent
|
|
43
|
-
], SubClass.prototype, "_year", void 0);
|
|
44
|
-
SubClass = __decorate([
|
|
45
|
-
(0, entropic_bond_1.registerPersistentClass)('SubClass')
|
|
46
|
-
], SubClass);
|
|
47
|
-
return SubClass;
|
|
48
|
-
}(entropic_bond_1.Persistent));
|
|
10
|
+
const entropic_bond_1 = require("entropic-bond");
|
|
11
|
+
let 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
|
+
SubClass = __decorate([
|
|
23
|
+
(0, entropic_bond_1.registerPersistentClass)('SubClass')
|
|
24
|
+
], SubClass);
|
|
49
25
|
exports.SubClass = SubClass;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
set: function (value) {
|
|
132
|
-
this._manyDerived = value;
|
|
133
|
-
},
|
|
134
|
-
enumerable: false,
|
|
135
|
-
configurable: true
|
|
136
|
-
});
|
|
137
|
-
__decorate([
|
|
138
|
-
entropic_bond_1.persistent
|
|
139
|
-
], TestUser.prototype, "_name", void 0);
|
|
140
|
-
__decorate([
|
|
141
|
-
entropic_bond_1.persistent
|
|
142
|
-
], TestUser.prototype, "_age", void 0);
|
|
143
|
-
__decorate([
|
|
144
|
-
entropic_bond_1.persistent
|
|
145
|
-
], TestUser.prototype, "_admin", void 0);
|
|
146
|
-
__decorate([
|
|
147
|
-
entropic_bond_1.persistent
|
|
148
|
-
], TestUser.prototype, "_skills", void 0);
|
|
149
|
-
__decorate([
|
|
150
|
-
entropic_bond_1.persistentReference
|
|
151
|
-
], TestUser.prototype, "_documentRef", void 0);
|
|
152
|
-
__decorate([
|
|
153
|
-
entropic_bond_1.persistentReference
|
|
154
|
-
], TestUser.prototype, "_manyRefs", void 0);
|
|
155
|
-
__decorate([
|
|
156
|
-
(0, entropic_bond_1.persistentReferenceAt)('TestUser')
|
|
157
|
-
], TestUser.prototype, "_derived", void 0);
|
|
158
|
-
__decorate([
|
|
159
|
-
(0, entropic_bond_1.persistentReferenceAt)('TestUser')
|
|
160
|
-
], TestUser.prototype, "_manyDerived", void 0);
|
|
161
|
-
TestUser = __decorate([
|
|
162
|
-
(0, entropic_bond_1.registerPersistentClass)('TestUser')
|
|
163
|
-
], TestUser);
|
|
164
|
-
return TestUser;
|
|
165
|
-
}(entropic_bond_1.Persistent));
|
|
26
|
+
let TestUser = class TestUser extends entropic_bond_1.Persistent {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this._manyRefs = [];
|
|
30
|
+
}
|
|
31
|
+
set name(value) {
|
|
32
|
+
this._name = value;
|
|
33
|
+
}
|
|
34
|
+
get name() {
|
|
35
|
+
return this._name;
|
|
36
|
+
}
|
|
37
|
+
set age(value) {
|
|
38
|
+
this._age = value;
|
|
39
|
+
}
|
|
40
|
+
get age() {
|
|
41
|
+
return this._age;
|
|
42
|
+
}
|
|
43
|
+
set admin(value) {
|
|
44
|
+
this._admin = value;
|
|
45
|
+
}
|
|
46
|
+
get admin() {
|
|
47
|
+
return this._admin;
|
|
48
|
+
}
|
|
49
|
+
set skills(value) {
|
|
50
|
+
this._skills = value;
|
|
51
|
+
}
|
|
52
|
+
get skills() {
|
|
53
|
+
return this._skills;
|
|
54
|
+
}
|
|
55
|
+
set documentRef(value) {
|
|
56
|
+
this._documentRef = value;
|
|
57
|
+
}
|
|
58
|
+
get documentRef() {
|
|
59
|
+
return this._documentRef;
|
|
60
|
+
}
|
|
61
|
+
set manyRefs(value) {
|
|
62
|
+
this._manyRefs = value;
|
|
63
|
+
}
|
|
64
|
+
get manyRefs() {
|
|
65
|
+
return this._manyRefs;
|
|
66
|
+
}
|
|
67
|
+
set derived(value) {
|
|
68
|
+
this._derived = value;
|
|
69
|
+
}
|
|
70
|
+
get derived() {
|
|
71
|
+
return this._derived;
|
|
72
|
+
}
|
|
73
|
+
set manyDerived(value) {
|
|
74
|
+
this._manyDerived = value;
|
|
75
|
+
}
|
|
76
|
+
get manyDerived() {
|
|
77
|
+
return this._manyDerived;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
__decorate([
|
|
81
|
+
entropic_bond_1.persistent
|
|
82
|
+
], TestUser.prototype, "_name", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
entropic_bond_1.persistent
|
|
85
|
+
], TestUser.prototype, "_age", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
entropic_bond_1.persistent
|
|
88
|
+
], TestUser.prototype, "_admin", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
entropic_bond_1.persistent
|
|
91
|
+
], TestUser.prototype, "_skills", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
entropic_bond_1.persistentReference
|
|
94
|
+
], TestUser.prototype, "_documentRef", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
entropic_bond_1.persistentReference
|
|
97
|
+
], TestUser.prototype, "_manyRefs", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, entropic_bond_1.persistentReferenceAt)('TestUser')
|
|
100
|
+
], TestUser.prototype, "_derived", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, entropic_bond_1.persistentReferenceAt)('TestUser')
|
|
103
|
+
], TestUser.prototype, "_manyDerived", void 0);
|
|
104
|
+
TestUser = __decorate([
|
|
105
|
+
(0, entropic_bond_1.registerPersistentClass)('TestUser')
|
|
106
|
+
], TestUser);
|
|
166
107
|
exports.TestUser = TestUser;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
});
|
|
182
|
-
__decorate([
|
|
183
|
-
entropic_bond_1.persistent
|
|
184
|
-
], DerivedUser.prototype, "_salary", void 0);
|
|
185
|
-
DerivedUser = __decorate([
|
|
186
|
-
(0, entropic_bond_1.registerPersistentClass)('DerivedUser')
|
|
187
|
-
], DerivedUser);
|
|
188
|
-
return DerivedUser;
|
|
189
|
-
}(TestUser));
|
|
108
|
+
let DerivedUser = class DerivedUser extends TestUser {
|
|
109
|
+
set salary(value) {
|
|
110
|
+
this._salary = value;
|
|
111
|
+
}
|
|
112
|
+
get salary() {
|
|
113
|
+
return this._salary;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
__decorate([
|
|
117
|
+
entropic_bond_1.persistent
|
|
118
|
+
], DerivedUser.prototype, "_salary", void 0);
|
|
119
|
+
DerivedUser = __decorate([
|
|
120
|
+
(0, entropic_bond_1.registerPersistentClass)('DerivedUser')
|
|
121
|
+
], DerivedUser);
|
|
190
122
|
exports.DerivedUser = DerivedUser;
|
|
191
123
|
//# sourceMappingURL=test-user.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-user.js","sourceRoot":"","sources":["../../src/mocks/test-user.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-user.js","sourceRoot":"","sources":["../../src/mocks/test-user.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iDAA2H;AAY3H,IAAa,QAAQ,GAArB,MAAa,QAAS,SAAQ,0BAAU;IACvC,IAAI,IAAI,CAA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AAA;IACtB,CAAC;IAED,IAAI,OAAO,CAAE,KAAkB;QAC9B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;IACtB,CAAC;IAED,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,QAAQ,CAAA;IACrB,CAAC;IAED,IAAI,WAAW,CAAE,KAAoB;QACpC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;IAC1B,CAAC;IAED,IAAI,WAAW;QACd,OAAO,IAAI,CAAC,YAAY,CAAA;IACzB,CAAC;CAUD,CAAA;AARY;IAAX,0BAAU;uCAAoB;AACnB;IAAX,0BAAU;sCAAqB;AACpB;IAAX,0BAAU;wCAAwB;AACvB;IAAX,0BAAU;yCAA0B;AAChB;IAApB,mCAAmB;8CAA+B;AAC9B;IAApB,mCAAmB;2CAAmC;AACpB;IAAlC,IAAA,qCAAqB,EAAC,UAAU,CAAC;0CAA8B;AAC7B;IAAlC,IAAA,qCAAqB,EAAC,UAAU,CAAC;8CAAoC;AAxE1D,QAAQ;IADpB,IAAA,uCAAuB,EAAE,UAAU,CAAE;GACzB,QAAQ,CAyEpB;AAzEY,4BAAQ;AA4ErB,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,QAAQ;IACxC,IAAI,MAAM,CAAC,KAAa;QACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,OAAO,CAAA;IACpB,CAAC;CAGD,CAAA;AADY;IAAX,0BAAU;4CAAwB;AATvB,WAAW;IADvB,IAAA,uCAAuB,EAAE,aAAa,CAAE;GAC5B,WAAW,CAUvB;AAVY,kCAAW"}
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -23,99 +8,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
9
|
});
|
|
25
10
|
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
54
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
55
|
-
if (ar || !(i in from)) {
|
|
56
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
57
|
-
ar[i] = from[i];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
61
|
-
};
|
|
62
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
12
|
exports.FirebaseDatasource = void 0;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
function FirebaseDatasource(emulator) {
|
|
70
|
-
var _this = this;
|
|
13
|
+
const firestore_1 = require("firebase/firestore");
|
|
14
|
+
const entropic_bond_1 = require("entropic-bond");
|
|
15
|
+
const firebase_helper_1 = require("../firebase-helper");
|
|
16
|
+
class FirebaseDatasource extends entropic_bond_1.DataSource {
|
|
17
|
+
constructor(emulator) {
|
|
71
18
|
var _a;
|
|
72
|
-
|
|
19
|
+
super();
|
|
73
20
|
if (emulator)
|
|
74
21
|
firebase_helper_1.FirebaseHelper.useEmulator(emulator);
|
|
75
22
|
if ((_a = firebase_helper_1.FirebaseHelper.emulator) === null || _a === void 0 ? void 0 : _a.emulate) {
|
|
76
|
-
|
|
23
|
+
const { host, firestorePort } = firebase_helper_1.FirebaseHelper.emulator;
|
|
77
24
|
(0, firestore_1.connectFirestoreEmulator)(firebase_helper_1.FirebaseHelper.instance.firestore(), host, firestorePort);
|
|
78
25
|
}
|
|
79
|
-
return _this;
|
|
80
26
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}); });
|
|
103
|
-
};
|
|
104
|
-
FirebaseDatasource.prototype.save = function (collections) {
|
|
105
|
-
var db = firebase_helper_1.FirebaseHelper.instance.firestore();
|
|
106
|
-
var batch = (0, firestore_1.writeBatch)(db);
|
|
107
|
-
Object.entries(collections).forEach(function (_a) {
|
|
108
|
-
var collectionName = _a[0], collection = _a[1];
|
|
109
|
-
collection.forEach(function (document) {
|
|
110
|
-
var ref = (0, firestore_1.doc)(db, collectionName, document.id);
|
|
27
|
+
findById(id, collectionName) {
|
|
28
|
+
const db = firebase_helper_1.FirebaseHelper.instance.firestore();
|
|
29
|
+
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
try {
|
|
31
|
+
const docSnap = yield (0, firestore_1.getDoc)((0, firestore_1.doc)(db, collectionName, id));
|
|
32
|
+
resolve(docSnap.data());
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.log(error);
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
save(collections) {
|
|
41
|
+
const db = firebase_helper_1.FirebaseHelper.instance.firestore();
|
|
42
|
+
const batch = (0, firestore_1.writeBatch)(db);
|
|
43
|
+
Object.entries(collections).forEach(([collectionName, collection]) => {
|
|
44
|
+
collection.forEach(document => {
|
|
45
|
+
const ref = (0, firestore_1.doc)(db, collectionName, document.id);
|
|
111
46
|
batch.set(ref, document);
|
|
112
47
|
});
|
|
113
48
|
});
|
|
114
49
|
return batch.commit();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
50
|
+
}
|
|
51
|
+
find(queryObject, collectionName) {
|
|
52
|
+
const db = firebase_helper_1.FirebaseHelper.instance.firestore();
|
|
53
|
+
const constraints = entropic_bond_1.DataSource.toPropertyPathOperations(queryObject.operations).map(operation => (0, firestore_1.where)(operation.property, operation.operator, operation.value));
|
|
119
54
|
if (queryObject.sort) {
|
|
120
55
|
constraints.push((0, firestore_1.orderBy)(queryObject.sort.propertyName, queryObject.sort.order));
|
|
121
56
|
}
|
|
@@ -125,40 +60,30 @@ var FirebaseDatasource = /** @class */ (function (_super) {
|
|
|
125
60
|
this._lastLimit = queryObject.limit;
|
|
126
61
|
constraints.push((0, firestore_1.limit)(queryObject.limit));
|
|
127
62
|
}
|
|
128
|
-
return this.getFromQuery(
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
63
|
+
return this.getFromQuery((0, firestore_1.query)((0, firestore_1.collection)(db, collectionName), ...constraints));
|
|
64
|
+
}
|
|
65
|
+
delete(id, collectionName) {
|
|
66
|
+
const db = firebase_helper_1.FirebaseHelper.instance.firestore();
|
|
132
67
|
return (0, firestore_1.deleteDoc)((0, firestore_1.doc)(db, collectionName, id));
|
|
133
|
-
}
|
|
134
|
-
|
|
68
|
+
}
|
|
69
|
+
next(maxDocs) {
|
|
135
70
|
if (!this._lastConstraints)
|
|
136
71
|
throw new Error('You should perform a query prior to using method next');
|
|
137
|
-
|
|
72
|
+
const db = firebase_helper_1.FirebaseHelper.instance.firestore();
|
|
138
73
|
this._lastLimit = maxDocs || this._lastLimit;
|
|
139
|
-
|
|
140
|
-
return this.getFromQuery(
|
|
141
|
-
}
|
|
74
|
+
const constraints = this._lastConstraints.concat((0, firestore_1.limit)(this._lastLimit), (0, firestore_1.startAfter)(this._lastDocRetrieved));
|
|
75
|
+
return this.getFromQuery((0, firestore_1.query)((0, firestore_1.collection)(db, this._lastCollectionName), ...constraints));
|
|
76
|
+
}
|
|
142
77
|
// prev should be used with next in reverse order
|
|
143
78
|
// prev( limit?: number ): Promise< DocumentObject[] > {
|
|
144
79
|
// }
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
doc = _a.sent();
|
|
154
|
-
this._lastDocRetrieved = doc.docs[doc.docs.length - 1];
|
|
155
|
-
resolve(doc.docs.map(function (doc) { return doc.data(); }));
|
|
156
|
-
return [2 /*return*/];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}); });
|
|
160
|
-
};
|
|
161
|
-
return FirebaseDatasource;
|
|
162
|
-
}(entropic_bond_1.DataSource));
|
|
80
|
+
getFromQuery(query) {
|
|
81
|
+
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const doc = yield (0, firestore_1.getDocs)(query);
|
|
83
|
+
this._lastDocRetrieved = doc.docs[doc.docs.length - 1];
|
|
84
|
+
resolve(doc.docs.map(doc => doc.data()));
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
163
88
|
exports.FirebaseDatasource = FirebaseDatasource;
|
|
164
89
|
//# sourceMappingURL=firebase-datasource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebase-datasource.js","sourceRoot":"","sources":["../../src/store/firebase-datasource.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"firebase-datasource.js","sourceRoot":"","sources":["../../src/store/firebase-datasource.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAsN;AACtN,iDAAoF;AACpF,wDAAkF;AAElF,MAAa,kBAAmB,SAAQ,0BAAU;IACjD,YAAa,QAAyB;;QACrC,KAAK,EAAE,CAAA;QACP,IAAK,QAAQ;YAAG,gCAAc,CAAC,WAAW,CAAE,QAAQ,CAAE,CAAA;QAEtD,IAAK,MAAA,gCAAc,CAAC,QAAQ,0CAAE,OAAO,EAAG;YACvC,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,gCAAc,CAAC,QAAQ,CAAA;YACvD,IAAA,oCAAwB,EAAE,gCAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,aAAa,CAAE,CAAA;SACpF;IACF,CAAC;IAED,QAAQ,CAAE,EAAU,EAAE,cAAsB;QAC3C,MAAM,EAAE,GAAG,gCAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAA;QAE9C,OAAO,IAAI,OAAO,CAAkB,CAAM,OAAO,EAAC,EAAE;YACnD,IAAI;gBACH,MAAM,OAAO,GAAG,MAAM,IAAA,kBAAM,EAAE,IAAA,eAAG,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,CAAE,CAAE,CAAA;gBAC7D,OAAO,CAAE,OAAO,CAAC,IAAI,EAAE,CAAE,CAAA;aACzB;YACD,OAAO,KAAK,EAAG;gBACd,OAAO,CAAC,GAAG,CAAE,KAAK,CAAE,CAAA;gBACpB,OAAO,IAAI,CAAA;aACX;QACF,CAAC,CAAA,CAAC,CAAA;IACH,CAAC;IAED,IAAI,CAAE,WAAwB;QAC7B,MAAM,EAAE,GAAG,gCAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAA;QAC9C,MA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