backend-manager 2.5.124 → 3.0.0
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 +76 -0
- package/package.json +13 -10
- 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 +18 -15
- 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
|
@@ -38,6 +38,7 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
38
38
|
options.log = typeof options.log === 'undefined' ? false : options.log;
|
|
39
39
|
options.setupFunctions = typeof options.setupFunctions === 'undefined' ? true : options.setupFunctions;
|
|
40
40
|
options.setupFunctionsLegacy = typeof options.setupFunctionsLegacy === 'undefined' ? true : options.setupFunctionsLegacy;
|
|
41
|
+
options.setupFunctionsIdentity = typeof options.setupFunctionsIdentity === 'undefined' ? true : options.setupFunctionsIdentity;
|
|
41
42
|
options.initializeLocalStorage = typeof options.initializeLocalStorage === 'undefined' ? false : options.initializeLocalStorage;
|
|
42
43
|
options.resourceZone = typeof options.resourceZone === 'undefined' ? 'us-central1' : options.resourceZone;
|
|
43
44
|
options.sentry = typeof options.sentry === 'undefined' ? true : options.sentry;
|
|
@@ -61,7 +62,7 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
61
62
|
sentry: null,
|
|
62
63
|
|
|
63
64
|
// First-party
|
|
64
|
-
Assistant: require('
|
|
65
|
+
Assistant: require('./helpers/assistant.js'),
|
|
65
66
|
localDatabase: null,
|
|
66
67
|
User: null,
|
|
67
68
|
Analytics: null,
|
|
@@ -371,21 +372,23 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
371
372
|
}
|
|
372
373
|
|
|
373
374
|
// Events
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
375
|
+
if (options.setupFunctionsIdentity) {
|
|
376
|
+
exporter.bm_authBeforeCreate =
|
|
377
|
+
self.libraries.functions
|
|
378
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
379
|
+
.auth.user()
|
|
380
|
+
.beforeCreate(async (user, context) => {
|
|
381
|
+
return self._process((new (require(`${core}/events/auth/before-create.js`))()).init(self, { user: user, context: context}))
|
|
382
|
+
});
|
|
381
383
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
384
|
+
exporter.bm_authBeforeSignIn =
|
|
385
|
+
self.libraries.functions
|
|
386
|
+
.runWith({memory: '256MB', timeoutSeconds: 60})
|
|
387
|
+
.auth.user()
|
|
388
|
+
.beforeSignIn(async (user, context) => {
|
|
389
|
+
return self._process((new (require(`${core}/events/auth/before-signin.js`))()).init(self, { user: user, context: context}))
|
|
390
|
+
});
|
|
391
|
+
}
|
|
389
392
|
|
|
390
393
|
exporter.bm_authOnCreate =
|
|
391
394
|
self.libraries.functions
|
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
|
-
}
|