backend-manager 2.6.0 → 3.0.1
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/CHANGELOG.md +54 -1
- package/package.json +12 -9
- package/src/cli/cli.js +42 -54
- package/src/manager/functions/core/actions/api/general/send-email.js +5 -5
- package/src/manager/functions/core/actions/api/special/setup-electron-manager-client.js +2 -2
- package/src/manager/functions/core/actions/api/user/sign-up.js +2 -16
- package/src/manager/functions/core/events/auth/before-create.js +2 -0
- package/src/manager/functions/core/events/auth/before-signin.js +2 -0
- package/src/manager/helpers/analytics.js +3 -3
- package/src/manager/helpers/api-manager.js +3 -3
- package/src/manager/helpers/assistant.js +733 -0
- package/src/manager/helpers/user.js +7 -3
- package/src/manager/index.js +7 -7
- package/src/cli/config.json +0 -3
- package/src/manager/index-bu.js +0 -235
|
@@ -90,12 +90,16 @@ function User(Manager, settings, options) {
|
|
|
90
90
|
ip: _.get(settings, 'activity.geolocation.ip', defaults ? '' : null),
|
|
91
91
|
continent: _.get(settings, 'activity.geolocation.continent', defaults ? '' : null),
|
|
92
92
|
country: _.get(settings, 'activity.geolocation.country', defaults ? '' : null),
|
|
93
|
+
region: _.get(settings, 'activity.geolocation.region', defaults ? '' : null),
|
|
93
94
|
city: _.get(settings, 'activity.geolocation.city', defaults ? '' : null),
|
|
94
95
|
latitude: _.get(settings, 'activity.geolocation.latitude', defaults ? 0 : null),
|
|
95
96
|
longitude: _.get(settings, 'activity.geolocation.longitude', defaults ? 0 : null),
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
},
|
|
98
|
+
client: {
|
|
99
|
+
userAgent: _.get(settings, 'activity.client.userAgent', defaults ? '' : null),
|
|
100
|
+
language: _.get(settings, 'activity.client.language', defaults ? '' : null),
|
|
101
|
+
platform: _.get(settings, 'activity.client.platform', defaults ? '' : null),
|
|
102
|
+
mobile: _.get(settings, 'activity.client.mobile', defaults ? '' : null),
|
|
99
103
|
},
|
|
100
104
|
},
|
|
101
105
|
api: {
|
package/src/manager/index.js
CHANGED
|
@@ -37,7 +37,7 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
37
37
|
options.initialize = typeof options.initialize === 'undefined' ? true : options.initialize;
|
|
38
38
|
options.log = typeof options.log === 'undefined' ? false : options.log;
|
|
39
39
|
options.setupFunctions = typeof options.setupFunctions === 'undefined' ? true : options.setupFunctions;
|
|
40
|
-
options.setupFunctionsLegacy = typeof options.setupFunctionsLegacy === 'undefined' ?
|
|
40
|
+
options.setupFunctionsLegacy = typeof options.setupFunctionsLegacy === 'undefined' ? false : options.setupFunctionsLegacy;
|
|
41
41
|
options.setupFunctionsIdentity = typeof options.setupFunctionsIdentity === 'undefined' ? true : options.setupFunctionsIdentity;
|
|
42
42
|
options.initializeLocalStorage = typeof options.initializeLocalStorage === 'undefined' ? false : options.initializeLocalStorage;
|
|
43
43
|
options.resourceZone = typeof options.resourceZone === 'undefined' ? 'us-central1' : options.resourceZone;
|
|
@@ -62,7 +62,7 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
62
62
|
sentry: null,
|
|
63
63
|
|
|
64
64
|
// First-party
|
|
65
|
-
Assistant: require('
|
|
65
|
+
Assistant: require('./helpers/assistant.js'),
|
|
66
66
|
localDatabase: null,
|
|
67
67
|
User: null,
|
|
68
68
|
Analytics: null,
|
|
@@ -97,9 +97,9 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
97
97
|
process.env.ENVIRONMENT = !process.env.ENVIRONMENT ? self.assistant.meta.environment : process.env.ENVIRONMENT;
|
|
98
98
|
|
|
99
99
|
// Use the working Firebase logger that they disabled for whatever reason
|
|
100
|
-
if (process.env.GCLOUD_PROJECT && self.assistant.meta.environment !== 'development' && options.useFirebaseLogger) {
|
|
101
|
-
|
|
102
|
-
}
|
|
100
|
+
// if (process.env.GCLOUD_PROJECT && self.assistant.meta.environment !== 'development' && options.useFirebaseLogger) {
|
|
101
|
+
// require('firebase-functions/lib/logger/compat');
|
|
102
|
+
// }
|
|
103
103
|
|
|
104
104
|
// Handle dev environments
|
|
105
105
|
if (self.assistant.meta.environment === 'development') {
|
|
@@ -660,8 +660,8 @@ Manager.prototype.storage = function (options) {
|
|
|
660
660
|
const low = require('lowdb');
|
|
661
661
|
const FileSync = require('lowdb/adapters/FileSync');
|
|
662
662
|
const dbPath = options.temporary
|
|
663
|
-
? `${require('os').tmpdir()}/${options.name}.json`
|
|
664
|
-
: `./.data/${options.name}.json`;
|
|
663
|
+
? `${require('os').tmpdir()}/storage/${options.name}.json`
|
|
664
|
+
: `./.data/storage/${options.name}.json`;
|
|
665
665
|
const adapter = new FileSync(dbPath);
|
|
666
666
|
|
|
667
667
|
if (
|
package/src/cli/config.json
DELETED
package/src/manager/index-bu.js
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
if (options.setupFunctions) {
|
|
2
|
-
// exporter.bm_api =
|
|
3
|
-
// self.libraries.functions
|
|
4
|
-
// .runWith({memory: '256MB', timeoutSeconds: 60})
|
|
5
|
-
// .https.onRequest(async (req, res) => {
|
|
6
|
-
// const Module = (new (require(`${core}/actions/api.js`))()).init(self, { req: req, res: res, });
|
|
7
|
-
//
|
|
8
|
-
// return self._preProcess(Module)
|
|
9
|
-
// .then(r => Module.main())
|
|
10
|
-
// .catch(e => {
|
|
11
|
-
// self.assistant.error(e, {environment: 'production'});
|
|
12
|
-
// return res.status(500).send(e.message);
|
|
13
|
-
// });
|
|
14
|
-
// });
|
|
15
|
-
exporter.bm_api =
|
|
16
|
-
self.libraries.functions
|
|
17
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
18
|
-
.https.onRequest(async (req, res) => {
|
|
19
|
-
return self._process((new (require(`${core}/actions/api.js`))()).init(self, { req: req, res: res, }))
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
if (options.setupFunctionsLegacy) {
|
|
23
|
-
exporter.bm_signUpHandler =
|
|
24
|
-
self.libraries.functions
|
|
25
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
26
|
-
.https.onRequest(async (req, res) => {
|
|
27
|
-
const Module = require(`${core}/actions/sign-up-handler.js`);
|
|
28
|
-
Module.init(self, { req: req, res: res, });
|
|
29
|
-
|
|
30
|
-
return self._preProcess(Module)
|
|
31
|
-
.then(r => Module.main())
|
|
32
|
-
.catch(e => {
|
|
33
|
-
self.assistant.error(e, {environment: 'production'});
|
|
34
|
-
return res.status(500).send(e.message);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Admin
|
|
39
|
-
exporter.bm_createPost =
|
|
40
|
-
self.libraries.functions
|
|
41
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
42
|
-
.https.onRequest(async (req, res) => {
|
|
43
|
-
const Module = require(`${core}/admin/create-post.js`);
|
|
44
|
-
Module.init(self, { req: req, res: res, });
|
|
45
|
-
|
|
46
|
-
return self._preProcess(Module)
|
|
47
|
-
.then(r => Module.main())
|
|
48
|
-
.catch(e => {
|
|
49
|
-
self.assistant.error(e, {environment: 'production'});
|
|
50
|
-
return res.status(500).send(e.message);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
exporter.bm_firestoreWrite =
|
|
55
|
-
self.libraries.functions
|
|
56
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
57
|
-
.https.onRequest(async (req, res) => {
|
|
58
|
-
const Module = require(`${core}/admin/firestore-write.js`);
|
|
59
|
-
Module.init(self, { req: req, res: res, });
|
|
60
|
-
|
|
61
|
-
return self._preProcess(Module)
|
|
62
|
-
.then(r => Module.main())
|
|
63
|
-
.catch(e => {
|
|
64
|
-
self.assistant.error(e, {environment: 'production'});
|
|
65
|
-
return res.status(500).send(e.message);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
exporter.bm_getStats =
|
|
70
|
-
self.libraries.functions
|
|
71
|
-
.runWith({memory: '256MB', timeoutSeconds: 420})
|
|
72
|
-
.https.onRequest(async (req, res) => {
|
|
73
|
-
const Module = require(`${core}/admin/get-stats.js`);
|
|
74
|
-
Module.init(self, { req: req, res: res, });
|
|
75
|
-
|
|
76
|
-
return self._preProcess(Module)
|
|
77
|
-
.then(r => Module.main())
|
|
78
|
-
.catch(e => {
|
|
79
|
-
self.assistant.error(e, {environment: 'production'});
|
|
80
|
-
return res.status(500).send(e.message);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
exporter.bm_sendNotification =
|
|
85
|
-
self.libraries.functions
|
|
86
|
-
.runWith({memory: '1GB', timeoutSeconds: 420})
|
|
87
|
-
.https.onRequest(async (req, res) => {
|
|
88
|
-
const Module = require(`${core}/admin/send-notification.js`);
|
|
89
|
-
Module.init(self, { req: req, res: res, });
|
|
90
|
-
|
|
91
|
-
return self._preProcess(Module)
|
|
92
|
-
.then(r => Module.main())
|
|
93
|
-
.catch(e => {
|
|
94
|
-
self.assistant.error(e, {environment: 'production'});
|
|
95
|
-
return res.status(500).send(e.message);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
exporter.bm_query =
|
|
100
|
-
self.libraries.functions
|
|
101
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
102
|
-
.https.onRequest(async (req, res) => {
|
|
103
|
-
const Module = require(`${core}/admin/query.js`);
|
|
104
|
-
Module.init(self, { req: req, res: res, });
|
|
105
|
-
|
|
106
|
-
return self._preProcess(Module)
|
|
107
|
-
.then(r => Module.main())
|
|
108
|
-
.catch(e => {
|
|
109
|
-
self.assistant.error(e, {environment: 'production'});
|
|
110
|
-
return res.status(500).send(e.message);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
exporter.bm_createPostHandler =
|
|
115
|
-
self.libraries.functions
|
|
116
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
117
|
-
.https.onRequest(async (req, res) => {
|
|
118
|
-
const Module = require(`${core}/actions/create-post-handler.js`);
|
|
119
|
-
Module.init(self, { req: req, res: res, });
|
|
120
|
-
|
|
121
|
-
return self._preProcess(Module)
|
|
122
|
-
.then(r => Module.main())
|
|
123
|
-
.catch(e => {
|
|
124
|
-
self.assistant.error(e, {environment: 'production'});
|
|
125
|
-
return res.status(500).send(e.message);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
exporter.bm_generateUuid =
|
|
130
|
-
self.libraries.functions
|
|
131
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
132
|
-
.https.onRequest(async (req, res) => {
|
|
133
|
-
const Module = require(`${core}/actions/generate-uuid.js`);
|
|
134
|
-
Module.init(self, { req: req, res: res, });
|
|
135
|
-
|
|
136
|
-
return self._preProcess(Module)
|
|
137
|
-
.then(r => Module.main())
|
|
138
|
-
.catch(e => {
|
|
139
|
-
self.assistant.error(e, {environment: 'production'});
|
|
140
|
-
return res.status(500).send(e.message);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
// Test
|
|
145
|
-
exporter.bm_test_authenticate =
|
|
146
|
-
self.libraries.functions
|
|
147
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
148
|
-
.https.onRequest(async (req, res) => {
|
|
149
|
-
const Module = require(`${test}/authenticate.js`);
|
|
150
|
-
Module.init(self, { req: req, res: res, });
|
|
151
|
-
|
|
152
|
-
return self._preProcess(Module)
|
|
153
|
-
.then(r => Module.main())
|
|
154
|
-
.catch(e => {
|
|
155
|
-
self.assistant.error(e, {environment: 'production'});
|
|
156
|
-
return res.status(500).send(e.message);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
exporter.bm_test_createTestAccounts =
|
|
161
|
-
self.libraries.functions
|
|
162
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
163
|
-
.https.onRequest(async (req, res) => {
|
|
164
|
-
const Module = require(`${test}/create-test-accounts.js`);
|
|
165
|
-
Module.init(self, { req: req, res: res, });
|
|
166
|
-
|
|
167
|
-
return self._preProcess(Module)
|
|
168
|
-
.then(r => Module.main())
|
|
169
|
-
.catch(e => {
|
|
170
|
-
self.assistant.error(e, {environment: 'production'});
|
|
171
|
-
return res.status(500).send(e.message);
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
exporter.bm_test_webhook =
|
|
176
|
-
self.libraries.functions
|
|
177
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
178
|
-
.https.onRequest(async (req, res) => {
|
|
179
|
-
const Module = require(`${test}/webhook.js`);
|
|
180
|
-
Module.init(self, { req: req, res: res, });
|
|
181
|
-
|
|
182
|
-
return self._preProcess(Module)
|
|
183
|
-
.then(r => Module.main())
|
|
184
|
-
.catch(e => {
|
|
185
|
-
self.assistant.error(e, {environment: 'production'});
|
|
186
|
-
return res.status(500).send(e.message);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Events
|
|
192
|
-
exporter.bm_authOnCreate =
|
|
193
|
-
self.libraries.functions
|
|
194
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
195
|
-
.auth.user().onCreate(async (user) => {
|
|
196
|
-
const Module = require(`${core}/events/auth/on-create.js`);
|
|
197
|
-
Module.init(self, { user: user });
|
|
198
|
-
|
|
199
|
-
return self._preProcess(Module)
|
|
200
|
-
.then(r => Module.main())
|
|
201
|
-
.catch(e => {
|
|
202
|
-
self.assistant.error(e, {environment: 'production'});
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
exporter.bm_authOnDelete =
|
|
207
|
-
self.libraries.functions
|
|
208
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
209
|
-
.auth.user().onDelete(async (user) => {
|
|
210
|
-
const Module = require(`${core}/events/auth/on-delete.js`);
|
|
211
|
-
Module.init(self, { user: user });
|
|
212
|
-
|
|
213
|
-
return self._preProcess(Module)
|
|
214
|
-
.then(r => Module.main())
|
|
215
|
-
.catch(e => {
|
|
216
|
-
self.assistant.error(e, {environment: 'production'});
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
exporter.bm_subOnWrite =
|
|
221
|
-
self.libraries.functions
|
|
222
|
-
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
223
|
-
.firestore
|
|
224
|
-
.document('notifications/subscriptions/all/{token}')
|
|
225
|
-
.onWrite(async (change, context) => {
|
|
226
|
-
const Module = require(`${core}/events/firestore/on-subscription.js`);
|
|
227
|
-
Module.init(self, { change: change, context: context, });
|
|
228
|
-
|
|
229
|
-
return self._preProcess(Module)
|
|
230
|
-
.then(r => Module.main())
|
|
231
|
-
.catch(e => {
|
|
232
|
-
self.assistant.error(e, {environment: 'production'});
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
}
|