adminmate-express-mongoose 1.2.5 → 1.2.6

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/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Adminmate (Express.js + Mongoose)
2
+
3
+ Adminmate is a powerful & flexible back-office solution build for small to big teams. ✌️
4
+
5
+ It provides an extremely flexible API developed in NodeJS that communicate with a powerful frontend back-office we host.
6
+
7
+ As the security & privacy of your data is our main focus, the Data API is host by yourself and secured by your own credentials.
8
+
9
+ ## Getting started
10
+
11
+ [https://adminmate.io](https://adminmate.io)
12
+
13
+ ## Databases compatibility
14
+
15
+ Adminmate is compatible with the most famous database systems like **MySQL**, **PostgreSQL**, **SQLite** and **MongoDB**. We are working hard on adding more soon!
16
+
17
+ ## Features
18
+
19
+ Adminmate comes with all the features you need for your back-office:
20
+ * **Data**: Data Explorer, CRUD, Filters, Segments, Actions
21
+ * **Dashboards & Charts**: Unlimited Dashboards & Charts
22
+ * **Collaboration**: Powerful collaboration tool
23
+ * **Activity**: Track everything that happening on your database data
24
+ * **Access Control**: Team-based Access Control
25
+
26
+ ### Data explorer
27
+
28
+ ![Alt text](https://adminmate.io/github/list-screen.svg)
29
+
30
+ ### Dashboards & Charts
31
+
32
+ ![Alt text](https://adminmate.io/github/homepage-screen.svg)
33
+
34
+ ### Activity
35
+
36
+ ![Alt text](https://adminmate.io/github/activity-screen.svg)
37
+
38
+ ## Who are the contributors ?
39
+
40
+ Adminmate is a bootstrapped project tailored by **Marc Delalonde** and aims to stay an *independent project, driven by the community*.
package/package.json CHANGED
@@ -1,8 +1,19 @@
1
1
  {
2
2
  "name": "adminmate-express-mongoose",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "Adminmate Express/Mongoose connector",
5
5
  "author": "Marc Delalonde",
6
+ "homepage": "http://adminmate.io",
7
+ "license": "GPL-3.0",
8
+ "keywords": [
9
+ "adminmate",
10
+ "admin",
11
+ "panel",
12
+ "interface",
13
+ "back-office",
14
+ "mongodb",
15
+ "mongoose"
16
+ ],
6
17
  "scripts": {
7
18
  "start": "node ./index",
8
19
  "test": "jest --runInBand",
@@ -13,7 +24,7 @@
13
24
  "url": "https://github.com/Adminmate/adminmate-express-mongoose.git"
14
25
  },
15
26
  "dependencies": {
16
- "adminmate-express-core": "^1.1.4",
27
+ "adminmate-express-core": "^1.1.5",
17
28
  "lodash": "^4.17.21",
18
29
  "moment": "^2.29.1",
19
30
  "mongoose": "^5.9.7",
@@ -3,8 +3,8 @@ const fnHelper = require('../helpers/functions');
3
3
 
4
4
  module.exports.getAutocomplete = async (req, res) => {
5
5
  const modelName = req.params.model;
6
- const search = (req.body.search || '').trim();
7
- const refFields = req.body.refFields;
6
+ const search = (req.query.s || '').trim();
7
+ const refFields = req.headers['am-ref-fields'] || {};
8
8
  const maxItem = 10;
9
9
 
10
10
  const currentModel = fnHelper.getModelObject(modelName);
@@ -3,16 +3,16 @@ const fnHelper = require('../helpers/functions');
3
3
 
4
4
  module.exports.getAll = async (req, res) => {
5
5
  const modelName = req.params.model;
6
- const segment = req.body.segment;
7
- const search = (req.body.search || '').trim();
8
- const filters = req.body.filters;
9
- const fieldsToFetch = req.body.fields || [];
10
- const refFields = req.body.refFields;
11
- const fieldsToSearchIn = req.body.fieldsToSearchIn || [];
12
- const page = parseInt(req.body.page || 1);
6
+ const segment = req.query.segment;
7
+ const search = (req.query.search || '').trim();
8
+ const filters = req.query.filters;
9
+ const fieldsToFetch = req.headers['am-model-fields'] || [];
10
+ const refFields = req.headers['am-ref-fields'] || {};
11
+ const fieldsToSearchIn = req.query.fieldsToSearchIn || [];
12
+ const page = parseInt(req.query.page || 1);
13
13
  const nbItemPerPage = 10;
14
14
  const defaultOrdering = [ ['_id', 'DESC'] ];
15
- const order = req.body.order || null;
15
+ const order = req.query.order || null;
16
16
 
17
17
  const currentModel = fnHelper.getModelObject(modelName);
18
18
  if (!currentModel) {
@@ -4,7 +4,8 @@ const fnHelper = require('../helpers/functions');
4
4
  module.exports.getOne = async (req, res) => {
5
5
  const modelName = req.params.model;
6
6
  const modelItemId = req.params.id;
7
- const refFields = req.body.refFields || {};
7
+ const fieldsToFetch = req.headers['am-model-fields'] || [];
8
+ const refFields = req.headers['am-ref-fields'] || {};
8
9
 
9
10
  const currentModel = fnHelper.getModelObject(modelName);
10
11
  if (!currentModel) {
@@ -13,14 +14,14 @@ module.exports.getOne = async (req, res) => {
13
14
 
14
15
  const keys = fnHelper.getModelProperties(currentModel);
15
16
  const defaultFieldsToFetch = keys.map(key => key.path);
16
- const fieldsToFetch = req.body.fields ? req.body.fields : defaultFieldsToFetch;
17
+ const fieldsToFetchSafe = Array.isArray(fieldsToFetch) && fieldsToFetch.length ? fieldsToFetch : defaultFieldsToFetch;
17
18
 
18
19
  // Build ref fields for the model (for mongoose population purpose)
19
- const fieldsToPopulate = fnHelper.getFieldsToPopulate(keys, fieldsToFetch, refFields);
20
+ const fieldsToPopulate = fnHelper.getFieldsToPopulate(keys, fieldsToFetchSafe, refFields);
20
21
 
21
22
  let data = await currentModel
22
23
  .findById(modelItemId)
23
- .select(fieldsToFetch)
24
+ .select(fieldsToFetchSafe)
24
25
  .populate(fieldsToPopulate)
25
26
  .lean()
26
27
  .catch(e => {
@@ -1,389 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Bar/Lines chart - Simple day 1`] = `
4
- Object {
5
- "chart": Object {
6
- "config": Object {
7
- "xaxis": Array [
8
- Object {
9
- "dataKey": "key",
10
- },
11
- ],
12
- "yaxis": Array [
13
- Object {
14
- "dataKey": "value",
15
- },
16
- ],
17
- },
18
- "data": Array [
19
- Object {
20
- "key": "04/10",
21
- "value": 0,
22
- },
23
- Object {
24
- "key": "05/10",
25
- "value": 0,
26
- },
27
- Object {
28
- "key": "06/10",
29
- "value": 0,
30
- },
31
- Object {
32
- "key": "07/10",
33
- "value": 0,
34
- },
35
- Object {
36
- "key": "08/10",
37
- "value": 0,
38
- },
39
- Object {
40
- "key": "09/10",
41
- "value": 0,
42
- },
43
- Object {
44
- "key": "10/10",
45
- "value": 0,
46
- },
47
- Object {
48
- "key": "11/10",
49
- "value": 0,
50
- },
51
- Object {
52
- "key": "12/10",
53
- "value": 0,
54
- },
55
- Object {
56
- "key": "13/10",
57
- "value": 0,
58
- },
59
- Object {
60
- "key": "14/10",
61
- "value": 0,
62
- },
63
- Object {
64
- "key": "15/10",
65
- "value": 0,
66
- },
67
- Object {
68
- "key": "16/10",
69
- "value": 0,
70
- },
71
- Object {
72
- "key": "17/10",
73
- "value": 0,
74
- },
75
- Object {
76
- "key": "18/10",
77
- "value": 0,
78
- },
79
- Object {
80
- "key": "19/10",
81
- "value": 0,
82
- },
83
- Object {
84
- "key": "20/10",
85
- "value": 0,
86
- },
87
- Object {
88
- "key": "21/10",
89
- "value": 0,
90
- },
91
- Object {
92
- "key": "22/10",
93
- "value": 0,
94
- },
95
- Object {
96
- "key": "23/10",
97
- "value": 0,
98
- },
99
- Object {
100
- "key": "24/10",
101
- "value": 0,
102
- },
103
- Object {
104
- "key": "25/10",
105
- "value": 0,
106
- },
107
- Object {
108
- "key": "26/10",
109
- "value": 0,
110
- },
111
- Object {
112
- "key": "27/10",
113
- "value": 0,
114
- },
115
- Object {
116
- "key": "28/10",
117
- "value": 0,
118
- },
119
- Object {
120
- "key": "29/10",
121
- "value": 0,
122
- },
123
- Object {
124
- "key": "30/10",
125
- "value": 0,
126
- },
127
- Object {
128
- "key": "31/10",
129
- "value": 0,
130
- },
131
- Object {
132
- "key": "01/11",
133
- "value": 0,
134
- },
135
- Object {
136
- "key": "02/11",
137
- "value": 0,
138
- },
139
- ],
140
- },
141
- }
142
- `;
143
-
144
- exports[`Bar/Lines chart - Simple month 1`] = `
145
- Object {
146
- "chart": Object {
147
- "config": Object {
148
- "xaxis": Array [
149
- Object {
150
- "dataKey": "key",
151
- },
152
- ],
153
- "yaxis": Array [
154
- Object {
155
- "dataKey": "value",
156
- },
157
- ],
158
- },
159
- "data": Array [
160
- Object {
161
- "key": "Nov",
162
- "value": 0,
163
- },
164
- Object {
165
- "key": "Dec",
166
- "value": 0,
167
- },
168
- Object {
169
- "key": "Jan",
170
- "value": 0,
171
- },
172
- Object {
173
- "key": "Feb",
174
- "value": 0,
175
- },
176
- Object {
177
- "key": "Mar",
178
- "value": 0,
179
- },
180
- Object {
181
- "key": "Apr",
182
- "value": 2,
183
- },
184
- Object {
185
- "key": "May",
186
- "value": 0,
187
- },
188
- Object {
189
- "key": "Jun",
190
- "value": 0,
191
- },
192
- Object {
193
- "key": "Jul",
194
- "value": 0,
195
- },
196
- Object {
197
- "key": "Aug",
198
- "value": 0,
199
- },
200
- Object {
201
- "key": "Sep",
202
- "value": 0,
203
- },
204
- Object {
205
- "key": "Oct",
206
- "value": 0,
207
- },
208
- ],
209
- },
210
- }
211
- `;
212
-
213
- exports[`Bar/Lines chart - Simple week 1`] = `
214
- Object {
215
- "chart": Object {
216
- "config": Object {
217
- "xaxis": Array [
218
- Object {
219
- "dataKey": "key",
220
- },
221
- ],
222
- "yaxis": Array [
223
- Object {
224
- "dataKey": "value",
225
- },
226
- ],
227
- },
228
- "data": Array [
229
- Object {
230
- "key": "02/05",
231
- "value": 0,
232
- },
233
- Object {
234
- "key": "09/05",
235
- "value": 0,
236
- },
237
- Object {
238
- "key": "16/05",
239
- "value": 0,
240
- },
241
- Object {
242
- "key": "23/05",
243
- "value": 0,
244
- },
245
- Object {
246
- "key": "30/05",
247
- "value": 0,
248
- },
249
- Object {
250
- "key": "06/06",
251
- "value": 0,
252
- },
253
- Object {
254
- "key": "13/06",
255
- "value": 0,
256
- },
257
- Object {
258
- "key": "20/06",
259
- "value": 0,
260
- },
261
- Object {
262
- "key": "27/06",
263
- "value": 0,
264
- },
265
- Object {
266
- "key": "04/07",
267
- "value": 0,
268
- },
269
- Object {
270
- "key": "11/07",
271
- "value": 0,
272
- },
273
- Object {
274
- "key": "18/07",
275
- "value": 0,
276
- },
277
- Object {
278
- "key": "25/07",
279
- "value": 0,
280
- },
281
- Object {
282
- "key": "01/08",
283
- "value": 0,
284
- },
285
- Object {
286
- "key": "08/08",
287
- "value": 0,
288
- },
289
- Object {
290
- "key": "15/08",
291
- "value": 0,
292
- },
293
- Object {
294
- "key": "22/08",
295
- "value": 0,
296
- },
297
- Object {
298
- "key": "29/08",
299
- "value": 0,
300
- },
301
- Object {
302
- "key": "05/09",
303
- "value": 0,
304
- },
305
- Object {
306
- "key": "12/09",
307
- "value": 0,
308
- },
309
- Object {
310
- "key": "19/09",
311
- "value": 0,
312
- },
313
- Object {
314
- "key": "26/09",
315
- "value": 0,
316
- },
317
- Object {
318
- "key": "03/10",
319
- "value": 0,
320
- },
321
- Object {
322
- "key": "10/10",
323
- "value": 0,
324
- },
325
- Object {
326
- "key": "17/10",
327
- "value": 0,
328
- },
329
- Object {
330
- "key": "24/10",
331
- "value": 0,
332
- },
333
- ],
334
- },
335
- }
336
- `;
337
-
338
- exports[`Bar/Lines chart - Simple year 1`] = `
339
- Object {
340
- "chart": Object {
341
- "config": Object {
342
- "xaxis": Array [
343
- Object {
344
- "dataKey": "key",
345
- },
346
- ],
347
- "yaxis": Array [
348
- Object {
349
- "dataKey": "value",
350
- },
351
- ],
352
- },
353
- "data": Array [
354
- Object {
355
- "key": "2013",
356
- "value": 0,
357
- },
358
- Object {
359
- "key": "2014",
360
- "value": 0,
361
- },
362
- Object {
363
- "key": "2015",
364
- "value": 0,
365
- },
366
- Object {
367
- "key": "2016",
368
- "value": 0,
369
- },
370
- Object {
371
- "key": "2017",
372
- "value": 0,
373
- },
374
- Object {
375
- "key": "2018",
376
- "value": 0,
377
- },
378
- Object {
379
- "key": "2019",
380
- "value": 0,
381
- },
382
- Object {
383
- "key": "2020",
384
- "value": 0,
385
- },
386
- ],
387
- },
388
- }
389
- `;
@@ -1,19 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Pie chart - Count 1`] = `
4
- Object {
5
- "chart": Object {
6
- "config": null,
7
- "data": Array [
8
- Object {
9
- "key": 4,
10
- "value": 1,
11
- },
12
- Object {
13
- "key": 5,
14
- "value": 1,
15
- },
16
- ],
17
- },
18
- }
19
- `;