backend-manager 5.0.55 → 5.0.56

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "5.0.55",
3
+ "version": "5.0.56",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -1,3 +1,5 @@
1
+ const { FieldValue } = require('firebase-admin/firestore');
2
+
1
3
  const MAX_RETRIES = 3;
2
4
  const RETRY_DELAY_MS = 1000;
3
5
 
@@ -41,7 +43,7 @@ module.exports = async ({ Manager, assistant, user, context, libraries }) => {
41
43
 
42
44
  // Decrement user count
43
45
  batch.update(admin.firestore().doc('meta/stats'), {
44
- 'users.total': admin.firestore.FieldValue.increment(-1),
46
+ 'users.total': FieldValue.increment(-1),
45
47
  });
46
48
 
47
49
  await batch.commit();
@@ -1,3 +1,5 @@
1
+ const { FieldValue } = require('firebase-admin/firestore');
2
+
1
3
  /**
2
4
  * Notification subscription write handler
3
5
  *
@@ -34,7 +36,7 @@ module.exports = async ({ Manager, assistant, change, context, libraries }) => {
34
36
  if (eventType === 'delete') {
35
37
  await admin.firestore().doc('meta/stats')
36
38
  .update({
37
- 'notifications.total': admin.firestore.FieldValue.increment(-1),
39
+ 'notifications.total': FieldValue.increment(-1),
38
40
  });
39
41
 
40
42
  Manager.Analytics({
@@ -59,7 +61,7 @@ module.exports = async ({ Manager, assistant, change, context, libraries }) => {
59
61
  if (eventType === 'create') {
60
62
  await admin.firestore().doc('meta/stats')
61
63
  .update({
62
- 'notifications.total': admin.firestore.FieldValue.increment(1),
64
+ 'notifications.total': FieldValue.increment(1),
63
65
  });
64
66
 
65
67
  Manager.Analytics({
@@ -1,3 +1,4 @@
1
+ const { FieldValue } = require('firebase-admin/firestore');
1
2
  const _ = require('lodash');
2
3
  const moment = require('moment');
3
4
  const powertools = require('node-powertools');
@@ -457,7 +458,7 @@ Module.prototype.ensureFirstInstance = function (email) {
457
458
  if (isFirstInstance) {
458
459
  // Delete email from temporary storage
459
460
  await admin.firestore().doc(`temporary/email-queue`).set({
460
- [hash]: admin.firestore.FieldValue.delete(),
461
+ [hash]: FieldValue.delete(),
461
462
  }, { merge: true })
462
463
  .then((doc) => {
463
464
  assistant.log(`ensureFirstInstance(): Deleted email from temporary storage`, hash);
@@ -2,6 +2,7 @@
2
2
  * POST /admin/email - Send email via SendGrid
3
3
  * Admin-only endpoint to send transactional emails
4
4
  */
5
+ const { FieldValue } = require('firebase-admin/firestore');
5
6
  const _ = require('lodash');
6
7
  const moment = require('moment');
7
8
  const powertools = require('node-powertools');
@@ -420,7 +421,7 @@ async function ensureFirstInstance(Manager, assistant, admin, settings, email) {
420
421
  if (isFirstInstance) {
421
422
  // Delete email from temporary storage
422
423
  await admin.firestore().doc(`temporary/email-queue`).set({
423
- [hash]: admin.firestore.FieldValue.delete(),
424
+ [hash]: FieldValue.delete(),
424
425
  }, { merge: true })
425
426
  .then(() => {
426
427
  assistant.log(`ensureFirstInstance(): Deleted email from temporary storage`, hash);
@@ -1,3 +1,4 @@
1
+ const { FieldValue } = require('firebase-admin/firestore');
1
2
  const {
2
3
  buildContext,
3
4
  } = require('./_helpers.js');
@@ -34,7 +35,7 @@ module.exports = async ({ assistant, Manager, user, settings, libraries }) => {
34
35
 
35
36
  // Delete OAuth data from user document
36
37
  await admin.firestore().doc(`users/${targetUid}`).update({
37
- [`oauth2.${settings.provider}`]: admin.firestore.FieldValue.delete(),
38
+ [`oauth2.${settings.provider}`]: FieldValue.delete(),
38
39
  metadata: Manager.Metadata().set({ tag: 'user/oauth2' }),
39
40
  });
40
41
 
@@ -1,3 +1,4 @@
1
+ const { FieldValue } = require('firebase-admin/firestore');
1
2
  const {
2
3
  buildContext,
3
4
  generateCsrfToken,
@@ -119,7 +120,7 @@ async function processStatus(context) {
119
120
 
120
121
  if ((status === 'disconnected' || status === 'error') && settings.removeInvalidTokens) {
121
122
  await admin.firestore().doc(`users/${targetUid}`).update({
122
- [`oauth2.${settings.provider}`]: admin.firestore.FieldValue.delete(),
123
+ [`oauth2.${settings.provider}`]: FieldValue.delete(),
123
124
  metadata: Manager.Metadata().set({ tag: 'user/oauth2' }),
124
125
  });
125
126
  assistant.log(`Removed invalid token for user: ${targetUid}`);
@@ -1,3 +1,4 @@
1
+ const { FieldValue } = require('firebase-admin/firestore');
1
2
  const {
2
3
  buildContext,
3
4
  loadProvider,
@@ -160,7 +161,7 @@ async function processTokenize({ assistant, Manager, admin, settings }) {
160
161
 
161
162
  // Delete CSRF token (cleanup)
162
163
  await usageDocRef.update({
163
- [`oauth2.${stateData.provider}`]: admin.firestore.FieldValue.delete(),
164
+ [`oauth2.${stateData.provider}`]: FieldValue.delete(),
164
165
  });
165
166
 
166
167
  assistant.log('OAuth2 tokenize complete');