@digitalaidseattle/firebase 1.0.1 → 1.0.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/dist/declarations/src/FirebaseAuthService.d.ts +2 -1
- package/dist/declarations/src/FirestoreService.d.ts +8 -9
- package/dist/digitalaidseattle-firebase.cjs.dev.js +212 -161
- package/dist/digitalaidseattle-firebase.cjs.prod.js +212 -161
- package/dist/digitalaidseattle-firebase.esm.js +213 -162
- package/package.json +2 -2
@@ -3,12 +3,13 @@ declare class FirebaseAuthService implements AuthService {
|
|
3
3
|
currentUser: User | undefined;
|
4
4
|
auth: import("@firebase/auth").Auth;
|
5
5
|
constructor();
|
6
|
+
getProviders(): string[];
|
7
|
+
signInWith(provider: string): Promise<OAuthResponse>;
|
6
8
|
hasUser(): Promise<boolean>;
|
7
9
|
getUser: () => Promise<any | null>;
|
8
10
|
signOut: () => Promise<{
|
9
11
|
error: AuthError | null;
|
10
12
|
}>;
|
11
13
|
signInWithGoogle: () => Promise<any>;
|
12
|
-
signInWithAzure(): Promise<OAuthResponse>;
|
13
14
|
}
|
14
15
|
export { FirebaseAuthService };
|
@@ -1,15 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
};
|
4
|
-
declare class FirestoreService<T extends Entity> {
|
1
|
+
import { Entity, EntityService, Identifier, User } from "@digitalaidseattle/core";
|
2
|
+
declare class FirestoreService<T extends Entity> implements EntityService<T> {
|
5
3
|
collectionName: string;
|
6
4
|
db: import("@firebase/firestore").Firestore;
|
7
5
|
constructor(collectionName: string);
|
8
|
-
|
9
|
-
getById
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
getAll(count?: number, select?: string): Promise<T[]>;
|
7
|
+
getById(id: string, select?: string): Promise<T>;
|
8
|
+
batchInsert(entities: T[], select?: string, user?: User): Promise<T[]>;
|
9
|
+
insert(entity: T, select?: string, user?: User): Promise<T>;
|
10
|
+
update(entityId: Identifier, updatedFields: T, select?: string, user?: User): Promise<T>;
|
11
|
+
delete(entityId: Identifier): Promise<void>;
|
13
12
|
addBatch: (entities: T[]) => Promise<void>;
|
14
13
|
}
|
15
14
|
export { FirestoreService };
|
@@ -111,16 +111,25 @@ var FirebaseAuthService = /*#__PURE__*/function () {
|
|
111
111
|
});
|
112
112
|
}
|
113
113
|
return _createClass(FirebaseAuthService, [{
|
114
|
+
key: "getProviders",
|
115
|
+
value: function getProviders() {
|
116
|
+
return ["google"];
|
117
|
+
}
|
118
|
+
}, {
|
119
|
+
key: "signInWith",
|
120
|
+
value: function signInWith(provider) {
|
121
|
+
switch (provider) {
|
122
|
+
case 'google':
|
123
|
+
return this.signInWithGoogle();
|
124
|
+
default:
|
125
|
+
throw new Error('Unrecognized provider ' + provider);
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}, {
|
114
129
|
key: "hasUser",
|
115
130
|
value: function hasUser() {
|
116
131
|
return Promise.resolve(this.currentUser !== null);
|
117
132
|
}
|
118
|
-
}, {
|
119
|
-
key: "signInWithAzure",
|
120
|
-
value: function signInWithAzure() {
|
121
|
-
// Placeholder implementation, as Azure sign-in is not implemented
|
122
|
-
return Promise.reject(new Error('Method not implemented.'));
|
123
|
-
}
|
124
133
|
}]);
|
125
134
|
}();
|
126
135
|
|
@@ -151,164 +160,206 @@ var FirebaseStorageService = /*#__PURE__*/_createClass(function FirebaseStorageS
|
|
151
160
|
}());
|
152
161
|
});
|
153
162
|
|
154
|
-
var FirestoreService = /*#__PURE__*/
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
163
|
+
var FirestoreService = /*#__PURE__*/function () {
|
164
|
+
function FirestoreService(collectionName) {
|
165
|
+
var _this = this;
|
166
|
+
_classCallCheck(this, FirestoreService);
|
167
|
+
_defineProperty(this, "collectionName", "player");
|
168
|
+
_defineProperty(this, "db", firestore.getFirestore(firebaseClient));
|
169
|
+
_defineProperty(this, "addBatch", function (entities) {
|
170
|
+
var batch = firestore.writeBatch(_this.db);
|
171
|
+
entities.forEach(function (e) {
|
172
|
+
e.id = uuid.v4();
|
173
|
+
var docRef = firestore.doc(_this.db, _this.collectionName, e.id);
|
174
|
+
batch.set(docRef, e);
|
175
|
+
});
|
176
|
+
return batch.commit();
|
177
|
+
});
|
178
|
+
this.collectionName = collectionName;
|
179
|
+
}
|
180
|
+
|
181
|
+
// Get all documents from a collection
|
182
|
+
return _createClass(FirestoreService, [{
|
183
|
+
key: "getAll",
|
184
|
+
value: function () {
|
185
|
+
var _getAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(count, select) {
|
186
|
+
var querySnapshot;
|
187
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
188
|
+
while (1) switch (_context.prev = _context.next) {
|
189
|
+
case 0:
|
190
|
+
_context.next = 2;
|
191
|
+
return firestore.getDocs(firestore.collection(this.db, this.collectionName));
|
192
|
+
case 2:
|
193
|
+
querySnapshot = _context.sent;
|
194
|
+
return _context.abrupt("return", querySnapshot.docs.map(function (doc) {
|
195
|
+
return _objectSpread(_objectSpread({}, doc.data()), {}, {
|
196
|
+
id: doc.id
|
197
|
+
});
|
198
|
+
}));
|
199
|
+
case 4:
|
200
|
+
case "end":
|
201
|
+
return _context.stop();
|
202
|
+
}
|
203
|
+
}, _callee, this);
|
204
|
+
}));
|
205
|
+
function getAll(_x, _x2) {
|
206
|
+
return _getAll.apply(this, arguments);
|
207
|
+
}
|
208
|
+
return getAll;
|
209
|
+
}() // Update a document to a collection
|
210
|
+
}, {
|
211
|
+
key: "getById",
|
212
|
+
value: function () {
|
213
|
+
var _getById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(id, select) {
|
214
|
+
var docRef;
|
215
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
216
|
+
while (1) switch (_context2.prev = _context2.next) {
|
217
|
+
case 0:
|
218
|
+
_context2.prev = 0;
|
219
|
+
_context2.next = 3;
|
220
|
+
return firestore.getDoc(firestore.doc(this.db, this.collectionName, id));
|
221
|
+
case 3:
|
222
|
+
docRef = _context2.sent;
|
223
|
+
if (!docRef.exists()) {
|
224
|
+
_context2.next = 8;
|
225
|
+
break;
|
226
|
+
}
|
227
|
+
return _context2.abrupt("return", _objectSpread(_objectSpread({}, docRef.data()), {}, {
|
228
|
+
id: docRef.id
|
229
|
+
}));
|
230
|
+
case 8:
|
231
|
+
throw Error("entity with id: ".concat(id, ", does not exist"));
|
232
|
+
case 9:
|
233
|
+
_context2.next = 15;
|
203
234
|
break;
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
var docRef;
|
232
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
|
233
|
-
while (1) switch (_context3.prev = _context3.next) {
|
234
|
-
case 0:
|
235
|
-
_context3.prev = 0;
|
236
|
-
if (!entity.id) {
|
235
|
+
case 11:
|
236
|
+
_context2.prev = 11;
|
237
|
+
_context2.t0 = _context2["catch"](0);
|
238
|
+
console.error("Error getting document: ", _context2.t0);
|
239
|
+
throw _context2.t0;
|
240
|
+
case 15:
|
241
|
+
case "end":
|
242
|
+
return _context2.stop();
|
243
|
+
}
|
244
|
+
}, _callee2, this, [[0, 11]]);
|
245
|
+
}));
|
246
|
+
function getById(_x3, _x4) {
|
247
|
+
return _getById.apply(this, arguments);
|
248
|
+
}
|
249
|
+
return getById;
|
250
|
+
}() // Add a document to a collection
|
251
|
+
}, {
|
252
|
+
key: "batchInsert",
|
253
|
+
value: function () {
|
254
|
+
var _batchInsert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(entities, select, user) {
|
255
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
|
256
|
+
while (1) switch (_context3.prev = _context3.next) {
|
257
|
+
case 0:
|
258
|
+
_context3.prev = 0;
|
259
|
+
entities.forEach(function (entity) {
|
260
|
+
return entity.id = uuid.v4();
|
261
|
+
});
|
237
262
|
_context3.next = 4;
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
}
|
252
|
-
}
|
253
|
-
|
254
|
-
|
255
|
-
return _ref3.apply(this, arguments);
|
256
|
-
};
|
257
|
-
}());
|
258
|
-
_defineProperty(this, "delete", /*#__PURE__*/function () {
|
259
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(entity) {
|
260
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
|
261
|
-
while (1) switch (_context4.prev = _context4.next) {
|
262
|
-
case 0:
|
263
|
-
if (!entity.id) {
|
264
|
-
_context4.next = 2;
|
265
|
-
break;
|
266
|
-
}
|
267
|
-
return _context4.abrupt("return", firestore.deleteDoc(firestore.doc(_this.db, _this.collectionName, entity.id)));
|
268
|
-
case 2:
|
269
|
-
throw new Error('Entity does not have an id.');
|
270
|
-
case 3:
|
271
|
-
case "end":
|
272
|
-
return _context4.stop();
|
273
|
-
}
|
274
|
-
}, _callee4);
|
275
|
-
}));
|
276
|
-
return function (_x4) {
|
277
|
-
return _ref4.apply(this, arguments);
|
278
|
-
};
|
279
|
-
}());
|
280
|
-
// Get all documents from a collection
|
281
|
-
_defineProperty(this, "getAll", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5() {
|
282
|
-
var querySnapshot;
|
283
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context5) {
|
284
|
-
while (1) switch (_context5.prev = _context5.next) {
|
285
|
-
case 0:
|
286
|
-
_context5.next = 2;
|
287
|
-
return firestore.getDocs(firestore.collection(_this.db, _this.collectionName));
|
288
|
-
case 2:
|
289
|
-
querySnapshot = _context5.sent;
|
290
|
-
return _context5.abrupt("return", querySnapshot.docs.map(function (doc) {
|
291
|
-
return _objectSpread(_objectSpread({}, doc.data()), {}, {
|
292
|
-
id: doc.id
|
293
|
-
});
|
294
|
-
}));
|
295
|
-
case 4:
|
296
|
-
case "end":
|
297
|
-
return _context5.stop();
|
263
|
+
return firestore.addDoc(firestore.collection(this.db, this.collectionName), entities);
|
264
|
+
case 4:
|
265
|
+
_context3.sent;
|
266
|
+
return _context3.abrupt("return", entities);
|
267
|
+
case 8:
|
268
|
+
_context3.prev = 8;
|
269
|
+
_context3.t0 = _context3["catch"](0);
|
270
|
+
console.error("Error adding document: ", _context3.t0);
|
271
|
+
throw _context3.t0;
|
272
|
+
case 12:
|
273
|
+
case "end":
|
274
|
+
return _context3.stop();
|
275
|
+
}
|
276
|
+
}, _callee3, this, [[0, 8]]);
|
277
|
+
}));
|
278
|
+
function batchInsert(_x5, _x6, _x7) {
|
279
|
+
return _batchInsert.apply(this, arguments);
|
298
280
|
}
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
281
|
+
return batchInsert;
|
282
|
+
}() // Add a document to a collection
|
283
|
+
}, {
|
284
|
+
key: "insert",
|
285
|
+
value: function () {
|
286
|
+
var _insert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(entity, select, user) {
|
287
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
|
288
|
+
while (1) switch (_context4.prev = _context4.next) {
|
289
|
+
case 0:
|
290
|
+
_context4.prev = 0;
|
291
|
+
entity.id = uuid.v4();
|
292
|
+
_context4.next = 4;
|
293
|
+
return firestore.addDoc(firestore.collection(this.db, this.collectionName), entity);
|
294
|
+
case 4:
|
295
|
+
_context4.sent;
|
296
|
+
return _context4.abrupt("return", entity);
|
297
|
+
case 8:
|
298
|
+
_context4.prev = 8;
|
299
|
+
_context4.t0 = _context4["catch"](0);
|
300
|
+
console.error("Error adding document: ", _context4.t0);
|
301
|
+
throw _context4.t0;
|
302
|
+
case 12:
|
303
|
+
case "end":
|
304
|
+
return _context4.stop();
|
305
|
+
}
|
306
|
+
}, _callee4, this, [[0, 8]]);
|
307
|
+
}));
|
308
|
+
function insert(_x8, _x9, _x10) {
|
309
|
+
return _insert.apply(this, arguments);
|
310
|
+
}
|
311
|
+
return insert;
|
312
|
+
}() // Update a document to a collection
|
313
|
+
}, {
|
314
|
+
key: "update",
|
315
|
+
value: function () {
|
316
|
+
var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(entityId, updatedFields, select, user) {
|
317
|
+
var docRef;
|
318
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context5) {
|
319
|
+
while (1) switch (_context5.prev = _context5.next) {
|
320
|
+
case 0:
|
321
|
+
_context5.prev = 0;
|
322
|
+
docRef = firestore.doc(this.db, this.collectionName, entityId);
|
323
|
+
firestore.updateDoc(docRef, updatedFields);
|
324
|
+
return _context5.abrupt("return", updatedFields);
|
325
|
+
case 6:
|
326
|
+
_context5.prev = 6;
|
327
|
+
_context5.t0 = _context5["catch"](0);
|
328
|
+
console.error("Error updating document: ", _context5.t0);
|
329
|
+
throw _context5.t0;
|
330
|
+
case 10:
|
331
|
+
case "end":
|
332
|
+
return _context5.stop();
|
333
|
+
}
|
334
|
+
}, _callee5, this, [[0, 6]]);
|
335
|
+
}));
|
336
|
+
function update(_x11, _x12, _x13, _x14) {
|
337
|
+
return _update.apply(this, arguments);
|
338
|
+
}
|
339
|
+
return update;
|
340
|
+
}()
|
341
|
+
}, {
|
342
|
+
key: "delete",
|
343
|
+
value: function () {
|
344
|
+
var _delete2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6(entityId) {
|
345
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context6) {
|
346
|
+
while (1) switch (_context6.prev = _context6.next) {
|
347
|
+
case 0:
|
348
|
+
console.log('delete', entityId);
|
349
|
+
return _context6.abrupt("return", firestore.deleteDoc(firestore.doc(this.db, this.collectionName, entityId)));
|
350
|
+
case 2:
|
351
|
+
case "end":
|
352
|
+
return _context6.stop();
|
353
|
+
}
|
354
|
+
}, _callee6, this);
|
355
|
+
}));
|
356
|
+
function _delete(_x15) {
|
357
|
+
return _delete2.apply(this, arguments);
|
358
|
+
}
|
359
|
+
return _delete;
|
360
|
+
}()
|
361
|
+
}]);
|
362
|
+
}();
|
312
363
|
|
313
364
|
exports.FirebaseAuthService = FirebaseAuthService;
|
314
365
|
exports.FirebaseStorageService = FirebaseStorageService;
|
@@ -111,16 +111,25 @@ var FirebaseAuthService = /*#__PURE__*/function () {
|
|
111
111
|
});
|
112
112
|
}
|
113
113
|
return _createClass(FirebaseAuthService, [{
|
114
|
+
key: "getProviders",
|
115
|
+
value: function getProviders() {
|
116
|
+
return ["google"];
|
117
|
+
}
|
118
|
+
}, {
|
119
|
+
key: "signInWith",
|
120
|
+
value: function signInWith(provider) {
|
121
|
+
switch (provider) {
|
122
|
+
case 'google':
|
123
|
+
return this.signInWithGoogle();
|
124
|
+
default:
|
125
|
+
throw new Error('Unrecognized provider ' + provider);
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}, {
|
114
129
|
key: "hasUser",
|
115
130
|
value: function hasUser() {
|
116
131
|
return Promise.resolve(this.currentUser !== null);
|
117
132
|
}
|
118
|
-
}, {
|
119
|
-
key: "signInWithAzure",
|
120
|
-
value: function signInWithAzure() {
|
121
|
-
// Placeholder implementation, as Azure sign-in is not implemented
|
122
|
-
return Promise.reject(new Error('Method not implemented.'));
|
123
|
-
}
|
124
133
|
}]);
|
125
134
|
}();
|
126
135
|
|
@@ -151,164 +160,206 @@ var FirebaseStorageService = /*#__PURE__*/_createClass(function FirebaseStorageS
|
|
151
160
|
}());
|
152
161
|
});
|
153
162
|
|
154
|
-
var FirestoreService = /*#__PURE__*/
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
163
|
+
var FirestoreService = /*#__PURE__*/function () {
|
164
|
+
function FirestoreService(collectionName) {
|
165
|
+
var _this = this;
|
166
|
+
_classCallCheck(this, FirestoreService);
|
167
|
+
_defineProperty(this, "collectionName", "player");
|
168
|
+
_defineProperty(this, "db", firestore.getFirestore(firebaseClient));
|
169
|
+
_defineProperty(this, "addBatch", function (entities) {
|
170
|
+
var batch = firestore.writeBatch(_this.db);
|
171
|
+
entities.forEach(function (e) {
|
172
|
+
e.id = uuid.v4();
|
173
|
+
var docRef = firestore.doc(_this.db, _this.collectionName, e.id);
|
174
|
+
batch.set(docRef, e);
|
175
|
+
});
|
176
|
+
return batch.commit();
|
177
|
+
});
|
178
|
+
this.collectionName = collectionName;
|
179
|
+
}
|
180
|
+
|
181
|
+
// Get all documents from a collection
|
182
|
+
return _createClass(FirestoreService, [{
|
183
|
+
key: "getAll",
|
184
|
+
value: function () {
|
185
|
+
var _getAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(count, select) {
|
186
|
+
var querySnapshot;
|
187
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
188
|
+
while (1) switch (_context.prev = _context.next) {
|
189
|
+
case 0:
|
190
|
+
_context.next = 2;
|
191
|
+
return firestore.getDocs(firestore.collection(this.db, this.collectionName));
|
192
|
+
case 2:
|
193
|
+
querySnapshot = _context.sent;
|
194
|
+
return _context.abrupt("return", querySnapshot.docs.map(function (doc) {
|
195
|
+
return _objectSpread(_objectSpread({}, doc.data()), {}, {
|
196
|
+
id: doc.id
|
197
|
+
});
|
198
|
+
}));
|
199
|
+
case 4:
|
200
|
+
case "end":
|
201
|
+
return _context.stop();
|
202
|
+
}
|
203
|
+
}, _callee, this);
|
204
|
+
}));
|
205
|
+
function getAll(_x, _x2) {
|
206
|
+
return _getAll.apply(this, arguments);
|
207
|
+
}
|
208
|
+
return getAll;
|
209
|
+
}() // Update a document to a collection
|
210
|
+
}, {
|
211
|
+
key: "getById",
|
212
|
+
value: function () {
|
213
|
+
var _getById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(id, select) {
|
214
|
+
var docRef;
|
215
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
|
216
|
+
while (1) switch (_context2.prev = _context2.next) {
|
217
|
+
case 0:
|
218
|
+
_context2.prev = 0;
|
219
|
+
_context2.next = 3;
|
220
|
+
return firestore.getDoc(firestore.doc(this.db, this.collectionName, id));
|
221
|
+
case 3:
|
222
|
+
docRef = _context2.sent;
|
223
|
+
if (!docRef.exists()) {
|
224
|
+
_context2.next = 8;
|
225
|
+
break;
|
226
|
+
}
|
227
|
+
return _context2.abrupt("return", _objectSpread(_objectSpread({}, docRef.data()), {}, {
|
228
|
+
id: docRef.id
|
229
|
+
}));
|
230
|
+
case 8:
|
231
|
+
throw Error("entity with id: ".concat(id, ", does not exist"));
|
232
|
+
case 9:
|
233
|
+
_context2.next = 15;
|
203
234
|
break;
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
var docRef;
|
232
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
|
233
|
-
while (1) switch (_context3.prev = _context3.next) {
|
234
|
-
case 0:
|
235
|
-
_context3.prev = 0;
|
236
|
-
if (!entity.id) {
|
235
|
+
case 11:
|
236
|
+
_context2.prev = 11;
|
237
|
+
_context2.t0 = _context2["catch"](0);
|
238
|
+
console.error("Error getting document: ", _context2.t0);
|
239
|
+
throw _context2.t0;
|
240
|
+
case 15:
|
241
|
+
case "end":
|
242
|
+
return _context2.stop();
|
243
|
+
}
|
244
|
+
}, _callee2, this, [[0, 11]]);
|
245
|
+
}));
|
246
|
+
function getById(_x3, _x4) {
|
247
|
+
return _getById.apply(this, arguments);
|
248
|
+
}
|
249
|
+
return getById;
|
250
|
+
}() // Add a document to a collection
|
251
|
+
}, {
|
252
|
+
key: "batchInsert",
|
253
|
+
value: function () {
|
254
|
+
var _batchInsert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(entities, select, user) {
|
255
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
|
256
|
+
while (1) switch (_context3.prev = _context3.next) {
|
257
|
+
case 0:
|
258
|
+
_context3.prev = 0;
|
259
|
+
entities.forEach(function (entity) {
|
260
|
+
return entity.id = uuid.v4();
|
261
|
+
});
|
237
262
|
_context3.next = 4;
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
}
|
252
|
-
}
|
253
|
-
|
254
|
-
|
255
|
-
return _ref3.apply(this, arguments);
|
256
|
-
};
|
257
|
-
}());
|
258
|
-
_defineProperty(this, "delete", /*#__PURE__*/function () {
|
259
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(entity) {
|
260
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
|
261
|
-
while (1) switch (_context4.prev = _context4.next) {
|
262
|
-
case 0:
|
263
|
-
if (!entity.id) {
|
264
|
-
_context4.next = 2;
|
265
|
-
break;
|
266
|
-
}
|
267
|
-
return _context4.abrupt("return", firestore.deleteDoc(firestore.doc(_this.db, _this.collectionName, entity.id)));
|
268
|
-
case 2:
|
269
|
-
throw new Error('Entity does not have an id.');
|
270
|
-
case 3:
|
271
|
-
case "end":
|
272
|
-
return _context4.stop();
|
273
|
-
}
|
274
|
-
}, _callee4);
|
275
|
-
}));
|
276
|
-
return function (_x4) {
|
277
|
-
return _ref4.apply(this, arguments);
|
278
|
-
};
|
279
|
-
}());
|
280
|
-
// Get all documents from a collection
|
281
|
-
_defineProperty(this, "getAll", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5() {
|
282
|
-
var querySnapshot;
|
283
|
-
return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context5) {
|
284
|
-
while (1) switch (_context5.prev = _context5.next) {
|
285
|
-
case 0:
|
286
|
-
_context5.next = 2;
|
287
|
-
return firestore.getDocs(firestore.collection(_this.db, _this.collectionName));
|
288
|
-
case 2:
|
289
|
-
querySnapshot = _context5.sent;
|
290
|
-
return _context5.abrupt("return", querySnapshot.docs.map(function (doc) {
|
291
|
-
return _objectSpread(_objectSpread({}, doc.data()), {}, {
|
292
|
-
id: doc.id
|
293
|
-
});
|
294
|
-
}));
|
295
|
-
case 4:
|
296
|
-
case "end":
|
297
|
-
return _context5.stop();
|
263
|
+
return firestore.addDoc(firestore.collection(this.db, this.collectionName), entities);
|
264
|
+
case 4:
|
265
|
+
_context3.sent;
|
266
|
+
return _context3.abrupt("return", entities);
|
267
|
+
case 8:
|
268
|
+
_context3.prev = 8;
|
269
|
+
_context3.t0 = _context3["catch"](0);
|
270
|
+
console.error("Error adding document: ", _context3.t0);
|
271
|
+
throw _context3.t0;
|
272
|
+
case 12:
|
273
|
+
case "end":
|
274
|
+
return _context3.stop();
|
275
|
+
}
|
276
|
+
}, _callee3, this, [[0, 8]]);
|
277
|
+
}));
|
278
|
+
function batchInsert(_x5, _x6, _x7) {
|
279
|
+
return _batchInsert.apply(this, arguments);
|
298
280
|
}
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
281
|
+
return batchInsert;
|
282
|
+
}() // Add a document to a collection
|
283
|
+
}, {
|
284
|
+
key: "insert",
|
285
|
+
value: function () {
|
286
|
+
var _insert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(entity, select, user) {
|
287
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
|
288
|
+
while (1) switch (_context4.prev = _context4.next) {
|
289
|
+
case 0:
|
290
|
+
_context4.prev = 0;
|
291
|
+
entity.id = uuid.v4();
|
292
|
+
_context4.next = 4;
|
293
|
+
return firestore.addDoc(firestore.collection(this.db, this.collectionName), entity);
|
294
|
+
case 4:
|
295
|
+
_context4.sent;
|
296
|
+
return _context4.abrupt("return", entity);
|
297
|
+
case 8:
|
298
|
+
_context4.prev = 8;
|
299
|
+
_context4.t0 = _context4["catch"](0);
|
300
|
+
console.error("Error adding document: ", _context4.t0);
|
301
|
+
throw _context4.t0;
|
302
|
+
case 12:
|
303
|
+
case "end":
|
304
|
+
return _context4.stop();
|
305
|
+
}
|
306
|
+
}, _callee4, this, [[0, 8]]);
|
307
|
+
}));
|
308
|
+
function insert(_x8, _x9, _x10) {
|
309
|
+
return _insert.apply(this, arguments);
|
310
|
+
}
|
311
|
+
return insert;
|
312
|
+
}() // Update a document to a collection
|
313
|
+
}, {
|
314
|
+
key: "update",
|
315
|
+
value: function () {
|
316
|
+
var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(entityId, updatedFields, select, user) {
|
317
|
+
var docRef;
|
318
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee5$(_context5) {
|
319
|
+
while (1) switch (_context5.prev = _context5.next) {
|
320
|
+
case 0:
|
321
|
+
_context5.prev = 0;
|
322
|
+
docRef = firestore.doc(this.db, this.collectionName, entityId);
|
323
|
+
firestore.updateDoc(docRef, updatedFields);
|
324
|
+
return _context5.abrupt("return", updatedFields);
|
325
|
+
case 6:
|
326
|
+
_context5.prev = 6;
|
327
|
+
_context5.t0 = _context5["catch"](0);
|
328
|
+
console.error("Error updating document: ", _context5.t0);
|
329
|
+
throw _context5.t0;
|
330
|
+
case 10:
|
331
|
+
case "end":
|
332
|
+
return _context5.stop();
|
333
|
+
}
|
334
|
+
}, _callee5, this, [[0, 6]]);
|
335
|
+
}));
|
336
|
+
function update(_x11, _x12, _x13, _x14) {
|
337
|
+
return _update.apply(this, arguments);
|
338
|
+
}
|
339
|
+
return update;
|
340
|
+
}()
|
341
|
+
}, {
|
342
|
+
key: "delete",
|
343
|
+
value: function () {
|
344
|
+
var _delete2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee6(entityId) {
|
345
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee6$(_context6) {
|
346
|
+
while (1) switch (_context6.prev = _context6.next) {
|
347
|
+
case 0:
|
348
|
+
console.log('delete', entityId);
|
349
|
+
return _context6.abrupt("return", firestore.deleteDoc(firestore.doc(this.db, this.collectionName, entityId)));
|
350
|
+
case 2:
|
351
|
+
case "end":
|
352
|
+
return _context6.stop();
|
353
|
+
}
|
354
|
+
}, _callee6, this);
|
355
|
+
}));
|
356
|
+
function _delete(_x15) {
|
357
|
+
return _delete2.apply(this, arguments);
|
358
|
+
}
|
359
|
+
return _delete;
|
360
|
+
}()
|
361
|
+
}]);
|
362
|
+
}();
|
312
363
|
|
313
364
|
exports.FirebaseAuthService = FirebaseAuthService;
|
314
365
|
exports.FirebaseStorageService = FirebaseStorageService;
|
@@ -7,7 +7,7 @@ import { getAuth, GoogleAuthProvider, signInWithPopup } from 'firebase/auth';
|
|
7
7
|
import { initializeApp } from 'firebase/app';
|
8
8
|
import { getStorage, ref, getBytes } from 'firebase/storage';
|
9
9
|
import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
|
10
|
-
import {
|
10
|
+
import { getDocs, collection, getDoc, doc, addDoc, updateDoc, deleteDoc, getFirestore, writeBatch } from 'firebase/firestore';
|
11
11
|
import { v4 } from 'uuid';
|
12
12
|
|
13
13
|
var firebaseConfig = {
|
@@ -103,16 +103,25 @@ var FirebaseAuthService = /*#__PURE__*/function () {
|
|
103
103
|
});
|
104
104
|
}
|
105
105
|
return _createClass(FirebaseAuthService, [{
|
106
|
+
key: "getProviders",
|
107
|
+
value: function getProviders() {
|
108
|
+
return ["google"];
|
109
|
+
}
|
110
|
+
}, {
|
111
|
+
key: "signInWith",
|
112
|
+
value: function signInWith(provider) {
|
113
|
+
switch (provider) {
|
114
|
+
case 'google':
|
115
|
+
return this.signInWithGoogle();
|
116
|
+
default:
|
117
|
+
throw new Error('Unrecognized provider ' + provider);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}, {
|
106
121
|
key: "hasUser",
|
107
122
|
value: function hasUser() {
|
108
123
|
return Promise.resolve(this.currentUser !== null);
|
109
124
|
}
|
110
|
-
}, {
|
111
|
-
key: "signInWithAzure",
|
112
|
-
value: function signInWithAzure() {
|
113
|
-
// Placeholder implementation, as Azure sign-in is not implemented
|
114
|
-
return Promise.reject(new Error('Method not implemented.'));
|
115
|
-
}
|
116
125
|
}]);
|
117
126
|
}();
|
118
127
|
|
@@ -143,163 +152,205 @@ var FirebaseStorageService = /*#__PURE__*/_createClass(function FirebaseStorageS
|
|
143
152
|
}());
|
144
153
|
});
|
145
154
|
|
146
|
-
var FirestoreService = /*#__PURE__*/
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
155
|
+
var FirestoreService = /*#__PURE__*/function () {
|
156
|
+
function FirestoreService(collectionName) {
|
157
|
+
var _this = this;
|
158
|
+
_classCallCheck(this, FirestoreService);
|
159
|
+
_defineProperty(this, "collectionName", "player");
|
160
|
+
_defineProperty(this, "db", getFirestore(firebaseClient));
|
161
|
+
_defineProperty(this, "addBatch", function (entities) {
|
162
|
+
var batch = writeBatch(_this.db);
|
163
|
+
entities.forEach(function (e) {
|
164
|
+
e.id = v4();
|
165
|
+
var docRef = doc(_this.db, _this.collectionName, e.id);
|
166
|
+
batch.set(docRef, e);
|
167
|
+
});
|
168
|
+
return batch.commit();
|
169
|
+
});
|
170
|
+
this.collectionName = collectionName;
|
171
|
+
}
|
172
|
+
|
173
|
+
// Get all documents from a collection
|
174
|
+
return _createClass(FirestoreService, [{
|
175
|
+
key: "getAll",
|
176
|
+
value: function () {
|
177
|
+
var _getAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(count, select) {
|
178
|
+
var querySnapshot;
|
179
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
180
|
+
while (1) switch (_context.prev = _context.next) {
|
181
|
+
case 0:
|
182
|
+
_context.next = 2;
|
183
|
+
return getDocs(collection(this.db, this.collectionName));
|
184
|
+
case 2:
|
185
|
+
querySnapshot = _context.sent;
|
186
|
+
return _context.abrupt("return", querySnapshot.docs.map(function (doc) {
|
187
|
+
return _objectSpread(_objectSpread({}, doc.data()), {}, {
|
188
|
+
id: doc.id
|
189
|
+
});
|
190
|
+
}));
|
191
|
+
case 4:
|
192
|
+
case "end":
|
193
|
+
return _context.stop();
|
194
|
+
}
|
195
|
+
}, _callee, this);
|
196
|
+
}));
|
197
|
+
function getAll(_x, _x2) {
|
198
|
+
return _getAll.apply(this, arguments);
|
199
|
+
}
|
200
|
+
return getAll;
|
201
|
+
}() // Update a document to a collection
|
202
|
+
}, {
|
203
|
+
key: "getById",
|
204
|
+
value: function () {
|
205
|
+
var _getById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, select) {
|
206
|
+
var docRef;
|
207
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
208
|
+
while (1) switch (_context2.prev = _context2.next) {
|
209
|
+
case 0:
|
210
|
+
_context2.prev = 0;
|
211
|
+
_context2.next = 3;
|
212
|
+
return getDoc(doc(this.db, this.collectionName, id));
|
213
|
+
case 3:
|
214
|
+
docRef = _context2.sent;
|
215
|
+
if (!docRef.exists()) {
|
216
|
+
_context2.next = 8;
|
217
|
+
break;
|
218
|
+
}
|
219
|
+
return _context2.abrupt("return", _objectSpread(_objectSpread({}, docRef.data()), {}, {
|
220
|
+
id: docRef.id
|
221
|
+
}));
|
222
|
+
case 8:
|
223
|
+
throw Error("entity with id: ".concat(id, ", does not exist"));
|
224
|
+
case 9:
|
225
|
+
_context2.next = 15;
|
195
226
|
break;
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
var docRef;
|
224
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
225
|
-
while (1) switch (_context3.prev = _context3.next) {
|
226
|
-
case 0:
|
227
|
-
_context3.prev = 0;
|
228
|
-
if (!entity.id) {
|
227
|
+
case 11:
|
228
|
+
_context2.prev = 11;
|
229
|
+
_context2.t0 = _context2["catch"](0);
|
230
|
+
console.error("Error getting document: ", _context2.t0);
|
231
|
+
throw _context2.t0;
|
232
|
+
case 15:
|
233
|
+
case "end":
|
234
|
+
return _context2.stop();
|
235
|
+
}
|
236
|
+
}, _callee2, this, [[0, 11]]);
|
237
|
+
}));
|
238
|
+
function getById(_x3, _x4) {
|
239
|
+
return _getById.apply(this, arguments);
|
240
|
+
}
|
241
|
+
return getById;
|
242
|
+
}() // Add a document to a collection
|
243
|
+
}, {
|
244
|
+
key: "batchInsert",
|
245
|
+
value: function () {
|
246
|
+
var _batchInsert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(entities, select, user) {
|
247
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
248
|
+
while (1) switch (_context3.prev = _context3.next) {
|
249
|
+
case 0:
|
250
|
+
_context3.prev = 0;
|
251
|
+
entities.forEach(function (entity) {
|
252
|
+
return entity.id = v4();
|
253
|
+
});
|
229
254
|
_context3.next = 4;
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
}
|
244
|
-
}
|
245
|
-
|
246
|
-
|
247
|
-
return _ref3.apply(this, arguments);
|
248
|
-
};
|
249
|
-
}());
|
250
|
-
_defineProperty(this, "delete", /*#__PURE__*/function () {
|
251
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(entity) {
|
252
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
253
|
-
while (1) switch (_context4.prev = _context4.next) {
|
254
|
-
case 0:
|
255
|
-
if (!entity.id) {
|
256
|
-
_context4.next = 2;
|
257
|
-
break;
|
258
|
-
}
|
259
|
-
return _context4.abrupt("return", deleteDoc(doc(_this.db, _this.collectionName, entity.id)));
|
260
|
-
case 2:
|
261
|
-
throw new Error('Entity does not have an id.');
|
262
|
-
case 3:
|
263
|
-
case "end":
|
264
|
-
return _context4.stop();
|
265
|
-
}
|
266
|
-
}, _callee4);
|
267
|
-
}));
|
268
|
-
return function (_x4) {
|
269
|
-
return _ref4.apply(this, arguments);
|
270
|
-
};
|
271
|
-
}());
|
272
|
-
// Get all documents from a collection
|
273
|
-
_defineProperty(this, "getAll", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
274
|
-
var querySnapshot;
|
275
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
276
|
-
while (1) switch (_context5.prev = _context5.next) {
|
277
|
-
case 0:
|
278
|
-
_context5.next = 2;
|
279
|
-
return getDocs(collection(_this.db, _this.collectionName));
|
280
|
-
case 2:
|
281
|
-
querySnapshot = _context5.sent;
|
282
|
-
return _context5.abrupt("return", querySnapshot.docs.map(function (doc) {
|
283
|
-
return _objectSpread(_objectSpread({}, doc.data()), {}, {
|
284
|
-
id: doc.id
|
285
|
-
});
|
286
|
-
}));
|
287
|
-
case 4:
|
288
|
-
case "end":
|
289
|
-
return _context5.stop();
|
255
|
+
return addDoc(collection(this.db, this.collectionName), entities);
|
256
|
+
case 4:
|
257
|
+
_context3.sent;
|
258
|
+
return _context3.abrupt("return", entities);
|
259
|
+
case 8:
|
260
|
+
_context3.prev = 8;
|
261
|
+
_context3.t0 = _context3["catch"](0);
|
262
|
+
console.error("Error adding document: ", _context3.t0);
|
263
|
+
throw _context3.t0;
|
264
|
+
case 12:
|
265
|
+
case "end":
|
266
|
+
return _context3.stop();
|
267
|
+
}
|
268
|
+
}, _callee3, this, [[0, 8]]);
|
269
|
+
}));
|
270
|
+
function batchInsert(_x5, _x6, _x7) {
|
271
|
+
return _batchInsert.apply(this, arguments);
|
290
272
|
}
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
273
|
+
return batchInsert;
|
274
|
+
}() // Add a document to a collection
|
275
|
+
}, {
|
276
|
+
key: "insert",
|
277
|
+
value: function () {
|
278
|
+
var _insert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(entity, select, user) {
|
279
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
280
|
+
while (1) switch (_context4.prev = _context4.next) {
|
281
|
+
case 0:
|
282
|
+
_context4.prev = 0;
|
283
|
+
entity.id = v4();
|
284
|
+
_context4.next = 4;
|
285
|
+
return addDoc(collection(this.db, this.collectionName), entity);
|
286
|
+
case 4:
|
287
|
+
_context4.sent;
|
288
|
+
return _context4.abrupt("return", entity);
|
289
|
+
case 8:
|
290
|
+
_context4.prev = 8;
|
291
|
+
_context4.t0 = _context4["catch"](0);
|
292
|
+
console.error("Error adding document: ", _context4.t0);
|
293
|
+
throw _context4.t0;
|
294
|
+
case 12:
|
295
|
+
case "end":
|
296
|
+
return _context4.stop();
|
297
|
+
}
|
298
|
+
}, _callee4, this, [[0, 8]]);
|
299
|
+
}));
|
300
|
+
function insert(_x8, _x9, _x10) {
|
301
|
+
return _insert.apply(this, arguments);
|
302
|
+
}
|
303
|
+
return insert;
|
304
|
+
}() // Update a document to a collection
|
305
|
+
}, {
|
306
|
+
key: "update",
|
307
|
+
value: function () {
|
308
|
+
var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(entityId, updatedFields, select, user) {
|
309
|
+
var docRef;
|
310
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
311
|
+
while (1) switch (_context5.prev = _context5.next) {
|
312
|
+
case 0:
|
313
|
+
_context5.prev = 0;
|
314
|
+
docRef = doc(this.db, this.collectionName, entityId);
|
315
|
+
updateDoc(docRef, updatedFields);
|
316
|
+
return _context5.abrupt("return", updatedFields);
|
317
|
+
case 6:
|
318
|
+
_context5.prev = 6;
|
319
|
+
_context5.t0 = _context5["catch"](0);
|
320
|
+
console.error("Error updating document: ", _context5.t0);
|
321
|
+
throw _context5.t0;
|
322
|
+
case 10:
|
323
|
+
case "end":
|
324
|
+
return _context5.stop();
|
325
|
+
}
|
326
|
+
}, _callee5, this, [[0, 6]]);
|
327
|
+
}));
|
328
|
+
function update(_x11, _x12, _x13, _x14) {
|
329
|
+
return _update.apply(this, arguments);
|
330
|
+
}
|
331
|
+
return update;
|
332
|
+
}()
|
333
|
+
}, {
|
334
|
+
key: "delete",
|
335
|
+
value: function () {
|
336
|
+
var _delete2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(entityId) {
|
337
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
338
|
+
while (1) switch (_context6.prev = _context6.next) {
|
339
|
+
case 0:
|
340
|
+
console.log('delete', entityId);
|
341
|
+
return _context6.abrupt("return", deleteDoc(doc(this.db, this.collectionName, entityId)));
|
342
|
+
case 2:
|
343
|
+
case "end":
|
344
|
+
return _context6.stop();
|
345
|
+
}
|
346
|
+
}, _callee6, this);
|
347
|
+
}));
|
348
|
+
function _delete(_x15) {
|
349
|
+
return _delete2.apply(this, arguments);
|
350
|
+
}
|
351
|
+
return _delete;
|
352
|
+
}()
|
353
|
+
}]);
|
354
|
+
}();
|
304
355
|
|
305
356
|
export { FirebaseAuthService, FirebaseStorageService, FirestoreService, firebaseClient };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@digitalaidseattle/firebase",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.3",
|
4
4
|
"description": "Wrapper for firebase that works with DAS Component library",
|
5
5
|
"repository": "null//github.com/null/github.com/tree/master/packages/firebase",
|
6
6
|
"main": "dist/digitalaidseattle-firebase.cjs.js",
|
@@ -8,7 +8,7 @@
|
|
8
8
|
"types": "dist/declarations/src/index.d.ts",
|
9
9
|
"dependencies": {
|
10
10
|
"@babel/runtime": "^7.25.0",
|
11
|
-
"@digitalaidseattle/core": "1.0.
|
11
|
+
"@digitalaidseattle/core": "1.0.8",
|
12
12
|
"firebase": "^11.2.0",
|
13
13
|
"react": "^18.3.1",
|
14
14
|
"uuid": "^11.0.5"
|