@mongoosejs/studio 0.0.20 → 0.0.22

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.
Files changed (39) hide show
  1. package/backend/actions/Dashboard/getDashboards.js +10 -0
  2. package/backend/actions/Dashboard/index.js +3 -0
  3. package/backend/actions/Model/createDocument.js +28 -0
  4. package/backend/actions/Model/getDocuments.js +2 -1
  5. package/backend/actions/Model/index.js +1 -0
  6. package/backend/actions/Model/listModels.js +3 -1
  7. package/backend/actions/Model/updateDocument.js +1 -1
  8. package/backend/actions/index.js +1 -0
  9. package/backend/db/dashboardSchema.js +16 -0
  10. package/backend/index.js +5 -1
  11. package/frontend/public/app.js +30567 -467
  12. package/frontend/public/images/json.svg +2 -0
  13. package/frontend/public/images/table.svg +1 -0
  14. package/frontend/public/tw.css +197 -22
  15. package/frontend/src/api.js +16 -0
  16. package/frontend/src/create-document/create-document.css +0 -0
  17. package/frontend/src/create-document/create-document.html +6 -0
  18. package/frontend/src/create-document/create-document.js +75 -0
  19. package/frontend/src/dashboard/dashboard.html +8 -0
  20. package/frontend/src/dashboard/dashboard.js +22 -0
  21. package/frontend/src/dashboard-details/dashboard-details.html +8 -0
  22. package/frontend/src/dashboard-details/dashboard-details.js +10 -0
  23. package/frontend/src/document/document.html +2 -1
  24. package/frontend/src/document/document.js +3 -1
  25. package/frontend/src/edit-date/edit-date.html +18 -1
  26. package/frontend/src/edit-date/edit-date.js +12 -0
  27. package/frontend/src/index.js +4 -0
  28. package/frontend/src/list-json/list-json.css +3 -0
  29. package/frontend/src/list-json/list-json.html +4 -0
  30. package/frontend/src/list-json/list-json.js +40 -0
  31. package/frontend/src/models/models.css +2 -6
  32. package/frontend/src/models/models.html +42 -10
  33. package/frontend/src/models/models.js +26 -1
  34. package/frontend/src/navbar/navbar.css +9 -0
  35. package/frontend/src/navbar/navbar.html +11 -3
  36. package/frontend/src/navbar/navbar.js +6 -1
  37. package/frontend/src/routes.js +5 -0
  38. package/package.json +8 -3
  39. package/tailwind.config.js +27 -1
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+
4
+ module.exports = ({ db }) => async function getDashboards() {
5
+ const Dashboard = db.model('__Studio_Dashboard');
6
+
7
+ const dashboards = await Dashboard.find();
8
+
9
+ return { dashboards }
10
+ };
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ exports.getDashboards = require('./getDashboards');
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ const Archetype = require('archetype');
4
+ const { EJSON } = require('bson');
5
+
6
+ const CreateDocumentParams = new Archetype({
7
+ model: {
8
+ $type: 'string',
9
+ $required: true
10
+ },
11
+ data: {
12
+ $type: Archetype.Any,
13
+ $required: true
14
+ }
15
+ }).compile('CreateDocumentParams');
16
+
17
+ module.exports = ({ db }) => async function CreateDocument(params) {
18
+ const { model, data } = new CreateDocumentParams(params);
19
+
20
+ const Model = db.models[model];
21
+ if (Model == null) {
22
+ throw new Error(`Model ${model} not found`);
23
+ }
24
+
25
+ const doc = await Model.create(EJSON.deserialize(data));
26
+
27
+ return { doc };
28
+ };
@@ -56,7 +56,8 @@ module.exports = ({ db }) => async function getDocuments(params) {
56
56
  schemaPaths[path] = {
57
57
  instance: Model.schema.paths[path].instance,
58
58
  path,
59
- ref: Model.schema.paths[path].options?.ref
59
+ ref: Model.schema.paths[path].options?.ref,
60
+ required: Model.schema.paths[path].options?.required
60
61
  };
61
62
  }
62
63
  removeSpecifiedPaths(schemaPaths, '.$*');
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  exports.createChart = require('./createChart');
4
+ exports.createDocument = require('./createDocument')
4
5
  exports.deleteDocument = require('./deleteDocument');
5
6
  exports.exportQueryResults = require('./exportQueryResults');
6
7
  exports.getDocument = require('./getDocument');
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports = ({ db }) => async function listModels() {
4
- return { models: Object.keys(db.models).sort() };
4
+ return {
5
+ models: Object.keys(db.models).filter(key => !key.startsWith('__Studio_')).sort()
6
+ };
5
7
  };
@@ -26,7 +26,7 @@ module.exports = ({ db }) => async function updateDocument(params) {
26
26
  }
27
27
 
28
28
  const doc = await Model.
29
- findByIdAndUpdate(_id, update, { sanitizeFilter: true, returnDocument: 'after' });
29
+ findByIdAndUpdate(_id, update, { sanitizeFilter: true, returnDocument: 'after', overwriteImmutable: true });
30
30
 
31
31
  return { doc };
32
32
  };
@@ -1,4 +1,5 @@
1
1
  'use strict';
2
2
 
3
+ exports.Dashboard = require('./Dashboard');
3
4
  exports.Model = require('./Model');
4
5
  exports.Script = require('./Script');
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ const mongoose = require('mongoose');
4
+
5
+ const dashboardSchema = new mongoose.Schema({
6
+ name: {
7
+ type: String,
8
+ required: true
9
+ },
10
+ code: {
11
+ type: String,
12
+ required: true
13
+ }
14
+ });
15
+
16
+ module.exports = dashboardSchema;
package/backend/index.js CHANGED
@@ -4,9 +4,13 @@ const Actions = require('./actions');
4
4
  const { applySpec } = require('extrovert');
5
5
  const mongoose = require('mongoose');
6
6
 
7
+ const dashboardSchema = require('./db/dashboardSchema');
8
+
7
9
  module.exports = function backend(db) {
8
10
  db = db || mongoose.connection;
9
-
11
+
12
+ db.model('__Studio_Dashboard', dashboardSchema, '__studio_dashboards');
13
+
10
14
  const actions = applySpec(Actions, { db });
11
15
  return actions;
12
16
  };