backend-manager 2.4.11 → 2.4.14

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": "2.4.11",
3
+ "version": "2.4.14",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -67,4 +67,4 @@
67
67
  "src/",
68
68
  "templates/"
69
69
  ]
70
- }
70
+ }
@@ -45,13 +45,16 @@ Module.prototype.main = function () {
45
45
  // or set to a list of collection IDs to export,
46
46
  collectionIds: []
47
47
  })
48
- .then(responses => {
48
+ .then(async (responses) => {
49
+
50
+ await self._setMetaStats();
51
+
49
52
  const response = responses[0];
50
- // assistant.log('Saved backup successfully', response['name'], {environment: 'development'})
51
53
  assistant.log('Saved backup successfully:', response.metadata.outputUriPrefix, {environment: 'development'})
52
54
  return resolve(response['name']);
53
55
  })
54
- .catch(e => {
56
+ .catch(async (e) => {
57
+ await self._setMetaStats(e);
55
58
  return reject(assistant.errorManager(e, {code: 500, sentry: false, send: false, log: true}).error)
56
59
  });
57
60
 
@@ -60,6 +63,40 @@ Module.prototype.main = function () {
60
63
 
61
64
  };
62
65
 
66
+ Module.prototype._setMetaStats = function (error) {
67
+ const self = this;
68
+ const Manager = self.Manager;
69
+ const Api = self.Api;
70
+ const assistant = self.assistant;
71
+ const payload = self.payload;
72
+
73
+ return new Promise(async function(resolve, reject) {
74
+ error = error || null;
75
+ const isError = error instanceof Error;
76
+
77
+ await self.libraries.admin.firestore().doc('meta/stats')
78
+ .set({
79
+ backups: {
80
+ lastBackup: {
81
+ date: {
82
+ timestamp: assistant.meta.startTime.timestamp,
83
+ timestampUNIX: assistant.meta.startTime.timestampUNIX,
84
+ },
85
+ status: {
86
+ success: !isError,
87
+ error: error,
88
+ }
89
+ }
90
+ }
91
+ }, {merge: true})
92
+ .catch(e => {
93
+ assistant.errorManager(e, {code: 500, sentry: false, send: false, log: true});
94
+ })
95
+
96
+ return resolve();
97
+ });
98
+ };
99
+
63
100
  Module.prototype.createBucket = function (bucketName, resourceZone) {
64
101
  const self = this;
65
102
  const Manager = self.Manager;
@@ -30,7 +30,7 @@ Module.prototype.main = function() {
30
30
  }
31
31
  })
32
32
  .then(response => {
33
- assistant.log(`Successfully executed backup: ${response}`, {environment: 'production'})
33
+ assistant.log(`Successfully executed backup:`, response, {environment: 'production'})
34
34
  return resolve(response);
35
35
  })
36
36
  .catch(e => {
@@ -57,13 +57,13 @@ service cloud.firestore {
57
57
  }
58
58
 
59
59
  function isWritingProtectedUserField() {
60
- return isWritingField('firebase')
60
+ return isWritingField('auth')
61
61
  || isWritingField('roles')
62
62
  || isWritingField('plan')
63
63
  || isWritingField('affiliate')
64
64
  || isWritingField('api')
65
65
  || isWritingField('link')
66
- || isWritingField('verifications')
66
+ || isWritingField('usage')
67
67
  || isWritingField('view');
68
68
  }
69
69