@digitalaidseattle/firebase 1.0.5 → 1.0.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.
@@ -9,4 +9,10 @@ export declare class FirebaseStorageService implements StorageService {
9
9
  storage: import("@firebase/storage").FirebaseStorage;
10
10
  decoder: TextDecoder;
11
11
  downloadFile: (filepath: string) => Promise<string>;
12
+ getUrlAsync(filepath: string): Promise<string>;
13
+ list(filepath?: string): Promise<any[]>;
14
+ getUrl(filepath: string): string;
15
+ upload(path: string, blob: any): Promise<any>;
16
+ downloadBlob(filepath: string): Promise<Blob | null>;
17
+ removeFile(fileName: string): Promise<any>;
12
18
  }
@@ -3,11 +3,11 @@ declare class FirestoreService<T extends Entity> implements EntityService<T> {
3
3
  collectionName: string;
4
4
  db: import("@firebase/firestore").Firestore;
5
5
  constructor(collectionName: string);
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>;
6
+ getAll(count?: number, select?: string, mapper?: (json: any) => T): Promise<T[]>;
7
+ getById(id: string, select?: string, mapper?: (json: any) => T): Promise<T>;
8
+ batchInsert(entities: T[], select?: string, mapper?: (json: any) => T, user?: User): Promise<T[]>;
9
+ insert(entity: T, select?: string, mapper?: (json: any) => T, user?: User): Promise<T>;
10
+ update(entityId: Identifier, updatedFields: T, select?: string, mapper?: (json: any) => T, user?: User): Promise<T>;
11
11
  delete(entityId: Identifier): Promise<void>;
12
12
  }
13
13
  export { FirestoreService };
@@ -132,32 +132,90 @@ var FirebaseAuthService = /*#__PURE__*/function () {
132
132
  }]);
133
133
  }();
134
134
 
135
- var FirebaseStorageService = /*#__PURE__*/_createClass(function FirebaseStorageService() {
136
- var _this = this;
137
- _classCallCheck(this, FirebaseStorageService);
138
- _defineProperty(this, "storage", storage.getStorage(firebaseClient));
139
- _defineProperty(this, "decoder", new TextDecoder("utf-8"));
140
- _defineProperty(this, "downloadFile", /*#__PURE__*/function () {
141
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(filepath) {
142
- var fileRef;
143
- return _regeneratorRuntime__default["default"].wrap(function (_context) {
144
- while (1) switch (_context.prev = _context.next) {
145
- case 0:
146
- fileRef = storage.ref(_this.storage, filepath);
147
- return _context.abrupt("return", storage.getBytes(fileRef).then(function (b) {
148
- return _this.decoder.decode(b);
149
- }));
150
- case 1:
151
- case "end":
152
- return _context.stop();
153
- }
154
- }, _callee);
155
- }));
156
- return function (_x) {
157
- return _ref.apply(this, arguments);
158
- };
159
- }());
160
- });
135
+ var FirebaseStorageService = /*#__PURE__*/function () {
136
+ function FirebaseStorageService() {
137
+ var _this = this;
138
+ _classCallCheck(this, FirebaseStorageService);
139
+ _defineProperty(this, "storage", storage.getStorage(firebaseClient));
140
+ _defineProperty(this, "decoder", new TextDecoder("utf-8"));
141
+ _defineProperty(this, "downloadFile", /*#__PURE__*/function () {
142
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(filepath) {
143
+ var fileRef;
144
+ return _regeneratorRuntime__default["default"].wrap(function (_context) {
145
+ while (1) switch (_context.prev = _context.next) {
146
+ case 0:
147
+ fileRef = storage.ref(_this.storage, filepath);
148
+ return _context.abrupt("return", storage.getBytes(fileRef).then(function (b) {
149
+ return _this.decoder.decode(b);
150
+ }));
151
+ case 1:
152
+ case "end":
153
+ return _context.stop();
154
+ }
155
+ }, _callee);
156
+ }));
157
+ return function (_x) {
158
+ return _ref.apply(this, arguments);
159
+ };
160
+ }());
161
+ }
162
+ return _createClass(FirebaseStorageService, [{
163
+ key: "getUrlAsync",
164
+ value: function () {
165
+ var _getUrlAsync = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(filepath) {
166
+ var storageRef, _t;
167
+ return _regeneratorRuntime__default["default"].wrap(function (_context2) {
168
+ while (1) switch (_context2.prev = _context2.next) {
169
+ case 0:
170
+ _context2.prev = 0;
171
+ storageRef = storage.ref(this.storage, filepath);
172
+ _context2.next = 1;
173
+ return storage.getDownloadURL(storageRef);
174
+ case 1:
175
+ return _context2.abrupt("return", _context2.sent);
176
+ case 2:
177
+ _context2.prev = 2;
178
+ _t = _context2["catch"](0);
179
+ console.error("Error getting download URL:", _t);
180
+ throw _t;
181
+ case 3:
182
+ case "end":
183
+ return _context2.stop();
184
+ }
185
+ }, _callee2, this, [[0, 2]]);
186
+ }));
187
+ function getUrlAsync(_x2) {
188
+ return _getUrlAsync.apply(this, arguments);
189
+ }
190
+ return getUrlAsync;
191
+ }()
192
+ }, {
193
+ key: "list",
194
+ value: function list(filepath) {
195
+ throw new Error("Method not implemented.");
196
+ }
197
+ }, {
198
+ key: "getUrl",
199
+ value: function getUrl(filepath) {
200
+ throw new Error("Method not supported.");
201
+ }
202
+ }, {
203
+ key: "upload",
204
+ value: function upload(path, blob) {
205
+ throw new Error("Method not implemented.");
206
+ }
207
+ }, {
208
+ key: "downloadBlob",
209
+ value: function downloadBlob(filepath) {
210
+ throw new Error("Method not implemented.");
211
+ }
212
+ }, {
213
+ key: "removeFile",
214
+ value: function removeFile(fileName) {
215
+ throw new Error("Method not implemented.");
216
+ }
217
+ }]);
218
+ }();
161
219
 
162
220
  var FirestoreService = /*#__PURE__*/function () {
163
221
  function FirestoreService(collectionName) {
@@ -171,7 +229,7 @@ var FirestoreService = /*#__PURE__*/function () {
171
229
  return _createClass(FirestoreService, [{
172
230
  key: "getAll",
173
231
  value: function () {
174
- var _getAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(count, select) {
232
+ var _getAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(count, select, mapper) {
175
233
  var querySnapshot;
176
234
  return _regeneratorRuntime__default["default"].wrap(function (_context) {
177
235
  while (1) switch (_context.prev = _context.next) {
@@ -191,7 +249,7 @@ var FirestoreService = /*#__PURE__*/function () {
191
249
  }
192
250
  }, _callee, this);
193
251
  }));
194
- function getAll(_x, _x2) {
252
+ function getAll(_x, _x2, _x3) {
195
253
  return _getAll.apply(this, arguments);
196
254
  }
197
255
  return getAll;
@@ -199,7 +257,7 @@ var FirestoreService = /*#__PURE__*/function () {
199
257
  }, {
200
258
  key: "getById",
201
259
  value: function () {
202
- var _getById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(id, select) {
260
+ var _getById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(id, select, mapper) {
203
261
  var docRef, _t;
204
262
  return _regeneratorRuntime__default["default"].wrap(function (_context2) {
205
263
  while (1) switch (_context2.prev = _context2.next) {
@@ -232,7 +290,7 @@ var FirestoreService = /*#__PURE__*/function () {
232
290
  }
233
291
  }, _callee2, this, [[0, 4]]);
234
292
  }));
235
- function getById(_x3, _x4) {
293
+ function getById(_x4, _x5, _x6) {
236
294
  return _getById.apply(this, arguments);
237
295
  }
238
296
  return getById;
@@ -240,7 +298,7 @@ var FirestoreService = /*#__PURE__*/function () {
240
298
  }, {
241
299
  key: "batchInsert",
242
300
  value: function () {
243
- var _batchInsert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(entities, select, user) {
301
+ var _batchInsert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(entities, select, mapper, user) {
244
302
  var _t2;
245
303
  return _regeneratorRuntime__default["default"].wrap(function (_context3) {
246
304
  while (1) switch (_context3.prev = _context3.next) {
@@ -262,7 +320,7 @@ var FirestoreService = /*#__PURE__*/function () {
262
320
  }
263
321
  }, _callee3, this, [[0, 2]]);
264
322
  }));
265
- function batchInsert(_x5, _x6, _x7) {
323
+ function batchInsert(_x7, _x8, _x9, _x0) {
266
324
  return _batchInsert.apply(this, arguments);
267
325
  }
268
326
  return batchInsert;
@@ -270,7 +328,7 @@ var FirestoreService = /*#__PURE__*/function () {
270
328
  }, {
271
329
  key: "insert",
272
330
  value: function () {
273
- var _insert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(entity, select, user) {
331
+ var _insert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(entity, select, mapper, user) {
274
332
  var docRef, _t3;
275
333
  return _regeneratorRuntime__default["default"].wrap(function (_context4) {
276
334
  while (1) switch (_context4.prev = _context4.next) {
@@ -294,7 +352,7 @@ var FirestoreService = /*#__PURE__*/function () {
294
352
  }
295
353
  }, _callee4, this, [[0, 2]]);
296
354
  }));
297
- function insert(_x8, _x9, _x0) {
355
+ function insert(_x1, _x10, _x11, _x12) {
298
356
  return _insert.apply(this, arguments);
299
357
  }
300
358
  return insert;
@@ -302,7 +360,7 @@ var FirestoreService = /*#__PURE__*/function () {
302
360
  }, {
303
361
  key: "update",
304
362
  value: function () {
305
- var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(entityId, updatedFields, select, user) {
363
+ var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(entityId, updatedFields, select, mapper, user) {
306
364
  var docRef, _t4;
307
365
  return _regeneratorRuntime__default["default"].wrap(function (_context5) {
308
366
  while (1) switch (_context5.prev = _context5.next) {
@@ -322,7 +380,7 @@ var FirestoreService = /*#__PURE__*/function () {
322
380
  }
323
381
  }, _callee5, this, [[0, 1]]);
324
382
  }));
325
- function update(_x1, _x10, _x11, _x12) {
383
+ function update(_x13, _x14, _x15, _x16, _x17) {
326
384
  return _update.apply(this, arguments);
327
385
  }
328
386
  return update;
@@ -342,7 +400,7 @@ var FirestoreService = /*#__PURE__*/function () {
342
400
  }
343
401
  }, _callee6, this);
344
402
  }));
345
- function _delete(_x13) {
403
+ function _delete(_x18) {
346
404
  return _delete2.apply(this, arguments);
347
405
  }
348
406
  return _delete;
@@ -132,32 +132,90 @@ var FirebaseAuthService = /*#__PURE__*/function () {
132
132
  }]);
133
133
  }();
134
134
 
135
- var FirebaseStorageService = /*#__PURE__*/_createClass(function FirebaseStorageService() {
136
- var _this = this;
137
- _classCallCheck(this, FirebaseStorageService);
138
- _defineProperty(this, "storage", storage.getStorage(firebaseClient));
139
- _defineProperty(this, "decoder", new TextDecoder("utf-8"));
140
- _defineProperty(this, "downloadFile", /*#__PURE__*/function () {
141
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(filepath) {
142
- var fileRef;
143
- return _regeneratorRuntime__default["default"].wrap(function (_context) {
144
- while (1) switch (_context.prev = _context.next) {
145
- case 0:
146
- fileRef = storage.ref(_this.storage, filepath);
147
- return _context.abrupt("return", storage.getBytes(fileRef).then(function (b) {
148
- return _this.decoder.decode(b);
149
- }));
150
- case 1:
151
- case "end":
152
- return _context.stop();
153
- }
154
- }, _callee);
155
- }));
156
- return function (_x) {
157
- return _ref.apply(this, arguments);
158
- };
159
- }());
160
- });
135
+ var FirebaseStorageService = /*#__PURE__*/function () {
136
+ function FirebaseStorageService() {
137
+ var _this = this;
138
+ _classCallCheck(this, FirebaseStorageService);
139
+ _defineProperty(this, "storage", storage.getStorage(firebaseClient));
140
+ _defineProperty(this, "decoder", new TextDecoder("utf-8"));
141
+ _defineProperty(this, "downloadFile", /*#__PURE__*/function () {
142
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(filepath) {
143
+ var fileRef;
144
+ return _regeneratorRuntime__default["default"].wrap(function (_context) {
145
+ while (1) switch (_context.prev = _context.next) {
146
+ case 0:
147
+ fileRef = storage.ref(_this.storage, filepath);
148
+ return _context.abrupt("return", storage.getBytes(fileRef).then(function (b) {
149
+ return _this.decoder.decode(b);
150
+ }));
151
+ case 1:
152
+ case "end":
153
+ return _context.stop();
154
+ }
155
+ }, _callee);
156
+ }));
157
+ return function (_x) {
158
+ return _ref.apply(this, arguments);
159
+ };
160
+ }());
161
+ }
162
+ return _createClass(FirebaseStorageService, [{
163
+ key: "getUrlAsync",
164
+ value: function () {
165
+ var _getUrlAsync = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(filepath) {
166
+ var storageRef, _t;
167
+ return _regeneratorRuntime__default["default"].wrap(function (_context2) {
168
+ while (1) switch (_context2.prev = _context2.next) {
169
+ case 0:
170
+ _context2.prev = 0;
171
+ storageRef = storage.ref(this.storage, filepath);
172
+ _context2.next = 1;
173
+ return storage.getDownloadURL(storageRef);
174
+ case 1:
175
+ return _context2.abrupt("return", _context2.sent);
176
+ case 2:
177
+ _context2.prev = 2;
178
+ _t = _context2["catch"](0);
179
+ console.error("Error getting download URL:", _t);
180
+ throw _t;
181
+ case 3:
182
+ case "end":
183
+ return _context2.stop();
184
+ }
185
+ }, _callee2, this, [[0, 2]]);
186
+ }));
187
+ function getUrlAsync(_x2) {
188
+ return _getUrlAsync.apply(this, arguments);
189
+ }
190
+ return getUrlAsync;
191
+ }()
192
+ }, {
193
+ key: "list",
194
+ value: function list(filepath) {
195
+ throw new Error("Method not implemented.");
196
+ }
197
+ }, {
198
+ key: "getUrl",
199
+ value: function getUrl(filepath) {
200
+ throw new Error("Method not supported.");
201
+ }
202
+ }, {
203
+ key: "upload",
204
+ value: function upload(path, blob) {
205
+ throw new Error("Method not implemented.");
206
+ }
207
+ }, {
208
+ key: "downloadBlob",
209
+ value: function downloadBlob(filepath) {
210
+ throw new Error("Method not implemented.");
211
+ }
212
+ }, {
213
+ key: "removeFile",
214
+ value: function removeFile(fileName) {
215
+ throw new Error("Method not implemented.");
216
+ }
217
+ }]);
218
+ }();
161
219
 
162
220
  var FirestoreService = /*#__PURE__*/function () {
163
221
  function FirestoreService(collectionName) {
@@ -171,7 +229,7 @@ var FirestoreService = /*#__PURE__*/function () {
171
229
  return _createClass(FirestoreService, [{
172
230
  key: "getAll",
173
231
  value: function () {
174
- var _getAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(count, select) {
232
+ var _getAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(count, select, mapper) {
175
233
  var querySnapshot;
176
234
  return _regeneratorRuntime__default["default"].wrap(function (_context) {
177
235
  while (1) switch (_context.prev = _context.next) {
@@ -191,7 +249,7 @@ var FirestoreService = /*#__PURE__*/function () {
191
249
  }
192
250
  }, _callee, this);
193
251
  }));
194
- function getAll(_x, _x2) {
252
+ function getAll(_x, _x2, _x3) {
195
253
  return _getAll.apply(this, arguments);
196
254
  }
197
255
  return getAll;
@@ -199,7 +257,7 @@ var FirestoreService = /*#__PURE__*/function () {
199
257
  }, {
200
258
  key: "getById",
201
259
  value: function () {
202
- var _getById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(id, select) {
260
+ var _getById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(id, select, mapper) {
203
261
  var docRef, _t;
204
262
  return _regeneratorRuntime__default["default"].wrap(function (_context2) {
205
263
  while (1) switch (_context2.prev = _context2.next) {
@@ -232,7 +290,7 @@ var FirestoreService = /*#__PURE__*/function () {
232
290
  }
233
291
  }, _callee2, this, [[0, 4]]);
234
292
  }));
235
- function getById(_x3, _x4) {
293
+ function getById(_x4, _x5, _x6) {
236
294
  return _getById.apply(this, arguments);
237
295
  }
238
296
  return getById;
@@ -240,7 +298,7 @@ var FirestoreService = /*#__PURE__*/function () {
240
298
  }, {
241
299
  key: "batchInsert",
242
300
  value: function () {
243
- var _batchInsert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(entities, select, user) {
301
+ var _batchInsert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(entities, select, mapper, user) {
244
302
  var _t2;
245
303
  return _regeneratorRuntime__default["default"].wrap(function (_context3) {
246
304
  while (1) switch (_context3.prev = _context3.next) {
@@ -262,7 +320,7 @@ var FirestoreService = /*#__PURE__*/function () {
262
320
  }
263
321
  }, _callee3, this, [[0, 2]]);
264
322
  }));
265
- function batchInsert(_x5, _x6, _x7) {
323
+ function batchInsert(_x7, _x8, _x9, _x0) {
266
324
  return _batchInsert.apply(this, arguments);
267
325
  }
268
326
  return batchInsert;
@@ -270,7 +328,7 @@ var FirestoreService = /*#__PURE__*/function () {
270
328
  }, {
271
329
  key: "insert",
272
330
  value: function () {
273
- var _insert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(entity, select, user) {
331
+ var _insert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(entity, select, mapper, user) {
274
332
  var docRef, _t3;
275
333
  return _regeneratorRuntime__default["default"].wrap(function (_context4) {
276
334
  while (1) switch (_context4.prev = _context4.next) {
@@ -294,7 +352,7 @@ var FirestoreService = /*#__PURE__*/function () {
294
352
  }
295
353
  }, _callee4, this, [[0, 2]]);
296
354
  }));
297
- function insert(_x8, _x9, _x0) {
355
+ function insert(_x1, _x10, _x11, _x12) {
298
356
  return _insert.apply(this, arguments);
299
357
  }
300
358
  return insert;
@@ -302,7 +360,7 @@ var FirestoreService = /*#__PURE__*/function () {
302
360
  }, {
303
361
  key: "update",
304
362
  value: function () {
305
- var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(entityId, updatedFields, select, user) {
363
+ var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee5(entityId, updatedFields, select, mapper, user) {
306
364
  var docRef, _t4;
307
365
  return _regeneratorRuntime__default["default"].wrap(function (_context5) {
308
366
  while (1) switch (_context5.prev = _context5.next) {
@@ -322,7 +380,7 @@ var FirestoreService = /*#__PURE__*/function () {
322
380
  }
323
381
  }, _callee5, this, [[0, 1]]);
324
382
  }));
325
- function update(_x1, _x10, _x11, _x12) {
383
+ function update(_x13, _x14, _x15, _x16, _x17) {
326
384
  return _update.apply(this, arguments);
327
385
  }
328
386
  return update;
@@ -342,7 +400,7 @@ var FirestoreService = /*#__PURE__*/function () {
342
400
  }
343
401
  }, _callee6, this);
344
402
  }));
345
- function _delete(_x13) {
403
+ function _delete(_x18) {
346
404
  return _delete2.apply(this, arguments);
347
405
  }
348
406
  return _delete;
@@ -5,7 +5,7 @@ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
5
5
  import _regeneratorRuntime from '@babel/runtime/regenerator';
6
6
  import { getAuth, GoogleAuthProvider, signInWithPopup } from 'firebase/auth';
7
7
  import { initializeApp } from 'firebase/app';
8
- import { getStorage, ref, getBytes } from 'firebase/storage';
8
+ import { ref, getDownloadURL, getStorage, getBytes } from 'firebase/storage';
9
9
  import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
10
10
  import { getDocs, collection, getDoc, doc, addDoc, updateDoc, deleteDoc, getFirestore } from 'firebase/firestore';
11
11
 
@@ -124,32 +124,90 @@ var FirebaseAuthService = /*#__PURE__*/function () {
124
124
  }]);
125
125
  }();
126
126
 
127
- var FirebaseStorageService = /*#__PURE__*/_createClass(function FirebaseStorageService() {
128
- var _this = this;
129
- _classCallCheck(this, FirebaseStorageService);
130
- _defineProperty(this, "storage", getStorage(firebaseClient));
131
- _defineProperty(this, "decoder", new TextDecoder("utf-8"));
132
- _defineProperty(this, "downloadFile", /*#__PURE__*/function () {
133
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(filepath) {
134
- var fileRef;
135
- return _regeneratorRuntime.wrap(function (_context) {
136
- while (1) switch (_context.prev = _context.next) {
137
- case 0:
138
- fileRef = ref(_this.storage, filepath);
139
- return _context.abrupt("return", getBytes(fileRef).then(function (b) {
140
- return _this.decoder.decode(b);
141
- }));
142
- case 1:
143
- case "end":
144
- return _context.stop();
145
- }
146
- }, _callee);
147
- }));
148
- return function (_x) {
149
- return _ref.apply(this, arguments);
150
- };
151
- }());
152
- });
127
+ var FirebaseStorageService = /*#__PURE__*/function () {
128
+ function FirebaseStorageService() {
129
+ var _this = this;
130
+ _classCallCheck(this, FirebaseStorageService);
131
+ _defineProperty(this, "storage", getStorage(firebaseClient));
132
+ _defineProperty(this, "decoder", new TextDecoder("utf-8"));
133
+ _defineProperty(this, "downloadFile", /*#__PURE__*/function () {
134
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(filepath) {
135
+ var fileRef;
136
+ return _regeneratorRuntime.wrap(function (_context) {
137
+ while (1) switch (_context.prev = _context.next) {
138
+ case 0:
139
+ fileRef = ref(_this.storage, filepath);
140
+ return _context.abrupt("return", getBytes(fileRef).then(function (b) {
141
+ return _this.decoder.decode(b);
142
+ }));
143
+ case 1:
144
+ case "end":
145
+ return _context.stop();
146
+ }
147
+ }, _callee);
148
+ }));
149
+ return function (_x) {
150
+ return _ref.apply(this, arguments);
151
+ };
152
+ }());
153
+ }
154
+ return _createClass(FirebaseStorageService, [{
155
+ key: "getUrlAsync",
156
+ value: function () {
157
+ var _getUrlAsync = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(filepath) {
158
+ var storageRef, _t;
159
+ return _regeneratorRuntime.wrap(function (_context2) {
160
+ while (1) switch (_context2.prev = _context2.next) {
161
+ case 0:
162
+ _context2.prev = 0;
163
+ storageRef = ref(this.storage, filepath);
164
+ _context2.next = 1;
165
+ return getDownloadURL(storageRef);
166
+ case 1:
167
+ return _context2.abrupt("return", _context2.sent);
168
+ case 2:
169
+ _context2.prev = 2;
170
+ _t = _context2["catch"](0);
171
+ console.error("Error getting download URL:", _t);
172
+ throw _t;
173
+ case 3:
174
+ case "end":
175
+ return _context2.stop();
176
+ }
177
+ }, _callee2, this, [[0, 2]]);
178
+ }));
179
+ function getUrlAsync(_x2) {
180
+ return _getUrlAsync.apply(this, arguments);
181
+ }
182
+ return getUrlAsync;
183
+ }()
184
+ }, {
185
+ key: "list",
186
+ value: function list(filepath) {
187
+ throw new Error("Method not implemented.");
188
+ }
189
+ }, {
190
+ key: "getUrl",
191
+ value: function getUrl(filepath) {
192
+ throw new Error("Method not supported.");
193
+ }
194
+ }, {
195
+ key: "upload",
196
+ value: function upload(path, blob) {
197
+ throw new Error("Method not implemented.");
198
+ }
199
+ }, {
200
+ key: "downloadBlob",
201
+ value: function downloadBlob(filepath) {
202
+ throw new Error("Method not implemented.");
203
+ }
204
+ }, {
205
+ key: "removeFile",
206
+ value: function removeFile(fileName) {
207
+ throw new Error("Method not implemented.");
208
+ }
209
+ }]);
210
+ }();
153
211
 
154
212
  var FirestoreService = /*#__PURE__*/function () {
155
213
  function FirestoreService(collectionName) {
@@ -163,7 +221,7 @@ var FirestoreService = /*#__PURE__*/function () {
163
221
  return _createClass(FirestoreService, [{
164
222
  key: "getAll",
165
223
  value: function () {
166
- var _getAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(count, select) {
224
+ var _getAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(count, select, mapper) {
167
225
  var querySnapshot;
168
226
  return _regeneratorRuntime.wrap(function (_context) {
169
227
  while (1) switch (_context.prev = _context.next) {
@@ -183,7 +241,7 @@ var FirestoreService = /*#__PURE__*/function () {
183
241
  }
184
242
  }, _callee, this);
185
243
  }));
186
- function getAll(_x, _x2) {
244
+ function getAll(_x, _x2, _x3) {
187
245
  return _getAll.apply(this, arguments);
188
246
  }
189
247
  return getAll;
@@ -191,7 +249,7 @@ var FirestoreService = /*#__PURE__*/function () {
191
249
  }, {
192
250
  key: "getById",
193
251
  value: function () {
194
- var _getById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, select) {
252
+ var _getById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, select, mapper) {
195
253
  var docRef, _t;
196
254
  return _regeneratorRuntime.wrap(function (_context2) {
197
255
  while (1) switch (_context2.prev = _context2.next) {
@@ -224,7 +282,7 @@ var FirestoreService = /*#__PURE__*/function () {
224
282
  }
225
283
  }, _callee2, this, [[0, 4]]);
226
284
  }));
227
- function getById(_x3, _x4) {
285
+ function getById(_x4, _x5, _x6) {
228
286
  return _getById.apply(this, arguments);
229
287
  }
230
288
  return getById;
@@ -232,7 +290,7 @@ var FirestoreService = /*#__PURE__*/function () {
232
290
  }, {
233
291
  key: "batchInsert",
234
292
  value: function () {
235
- var _batchInsert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(entities, select, user) {
293
+ var _batchInsert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(entities, select, mapper, user) {
236
294
  var _t2;
237
295
  return _regeneratorRuntime.wrap(function (_context3) {
238
296
  while (1) switch (_context3.prev = _context3.next) {
@@ -254,7 +312,7 @@ var FirestoreService = /*#__PURE__*/function () {
254
312
  }
255
313
  }, _callee3, this, [[0, 2]]);
256
314
  }));
257
- function batchInsert(_x5, _x6, _x7) {
315
+ function batchInsert(_x7, _x8, _x9, _x0) {
258
316
  return _batchInsert.apply(this, arguments);
259
317
  }
260
318
  return batchInsert;
@@ -262,7 +320,7 @@ var FirestoreService = /*#__PURE__*/function () {
262
320
  }, {
263
321
  key: "insert",
264
322
  value: function () {
265
- var _insert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(entity, select, user) {
323
+ var _insert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(entity, select, mapper, user) {
266
324
  var docRef, _t3;
267
325
  return _regeneratorRuntime.wrap(function (_context4) {
268
326
  while (1) switch (_context4.prev = _context4.next) {
@@ -286,7 +344,7 @@ var FirestoreService = /*#__PURE__*/function () {
286
344
  }
287
345
  }, _callee4, this, [[0, 2]]);
288
346
  }));
289
- function insert(_x8, _x9, _x0) {
347
+ function insert(_x1, _x10, _x11, _x12) {
290
348
  return _insert.apply(this, arguments);
291
349
  }
292
350
  return insert;
@@ -294,7 +352,7 @@ var FirestoreService = /*#__PURE__*/function () {
294
352
  }, {
295
353
  key: "update",
296
354
  value: function () {
297
- var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(entityId, updatedFields, select, user) {
355
+ var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(entityId, updatedFields, select, mapper, user) {
298
356
  var docRef, _t4;
299
357
  return _regeneratorRuntime.wrap(function (_context5) {
300
358
  while (1) switch (_context5.prev = _context5.next) {
@@ -314,7 +372,7 @@ var FirestoreService = /*#__PURE__*/function () {
314
372
  }
315
373
  }, _callee5, this, [[0, 1]]);
316
374
  }));
317
- function update(_x1, _x10, _x11, _x12) {
375
+ function update(_x13, _x14, _x15, _x16, _x17) {
318
376
  return _update.apply(this, arguments);
319
377
  }
320
378
  return update;
@@ -334,7 +392,7 @@ var FirestoreService = /*#__PURE__*/function () {
334
392
  }
335
393
  }, _callee6, this);
336
394
  }));
337
- function _delete(_x13) {
395
+ function _delete(_x18) {
338
396
  return _delete2.apply(this, arguments);
339
397
  }
340
398
  return _delete;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalaidseattle/firebase",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
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.9",
11
+ "@digitalaidseattle/core": "1.0.12",
12
12
  "firebase": "^11.2.0",
13
13
  "react": "^18.3.1",
14
14
  "uuid": "^11.0.5"