@mongoosejs/studio 0.0.21 → 0.0.23

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 (56) hide show
  1. package/backend/actions/Dashboard/getDashboard.js +18 -0
  2. package/backend/actions/Dashboard/getDashboards.js +10 -0
  3. package/backend/actions/Dashboard/index.js +5 -0
  4. package/backend/actions/Dashboard/updateDashboard.js +25 -0
  5. package/backend/actions/Model/createDocument.js +28 -0
  6. package/backend/actions/Model/getDocuments.js +2 -1
  7. package/backend/actions/Model/index.js +1 -0
  8. package/backend/actions/Model/listModels.js +3 -1
  9. package/backend/actions/Model/updateDocument.js +1 -1
  10. package/backend/actions/index.js +1 -0
  11. package/backend/db/dashboardSchema.js +16 -0
  12. package/backend/index.js +9 -1
  13. package/frontend/public/app.js +1172 -473
  14. package/frontend/public/images/json.svg +2 -0
  15. package/frontend/public/images/table.svg +1 -0
  16. package/frontend/public/index.html +3 -0
  17. package/frontend/public/tw.css +298 -18
  18. package/frontend/src/api.js +28 -0
  19. package/frontend/src/create-document/create-document.css +0 -0
  20. package/frontend/src/create-document/create-document.html +25 -0
  21. package/frontend/src/create-document/create-document.js +61 -0
  22. package/frontend/src/dashboard/dashboard.html +17 -0
  23. package/frontend/src/dashboard/dashboard.js +36 -0
  24. package/frontend/src/dashboard/edit-dashboard/edit-dashboard.html +5 -0
  25. package/frontend/src/dashboard/edit-dashboard/edit-dashboard.js +48 -0
  26. package/frontend/src/dashboards/dashboards.html +5 -0
  27. package/frontend/src/dashboards/dashboards.js +20 -0
  28. package/frontend/src/document/document.html +5 -4
  29. package/frontend/src/document/document.js +7 -1
  30. package/frontend/src/edit-array/edit-array.html +1 -7
  31. package/frontend/src/edit-array/edit-array.js +27 -9
  32. package/frontend/src/edit-date/edit-date.html +18 -1
  33. package/frontend/src/edit-date/edit-date.js +12 -0
  34. package/frontend/src/edit-default/edit-default.html +1 -1
  35. package/frontend/src/index.js +5 -0
  36. package/frontend/src/list-json/list-json.css +3 -0
  37. package/frontend/src/list-json/list-json.html +4 -0
  38. package/frontend/src/list-json/list-json.js +40 -0
  39. package/frontend/src/models/models.css +2 -8
  40. package/frontend/src/models/models.html +42 -10
  41. package/frontend/src/models/models.js +22 -1
  42. package/frontend/src/navbar/navbar.css +9 -0
  43. package/frontend/src/navbar/navbar.html +11 -3
  44. package/frontend/src/navbar/navbar.js +6 -1
  45. package/frontend/src/routes.js +10 -0
  46. package/mongoosejs-studio-0.0.16.tgz +0 -0
  47. package/package.json +2 -2
  48. package/tailwind.config.js +27 -1
  49. package/frontend/dist/app.js +0 -160
  50. package/frontend/dist/tw.css +0 -595
  51. package/logs/COUNT_20230524-154120-151469/operation.log +0 -8
  52. package/logs/COUNT_20230524-154408-077670/operation.log +0 -22
  53. package/logs/COUNT_20230524-154414-431706/operation.log +0 -8
  54. package/logs/COUNT_20230524-155000-297076/operation.log +0 -8
  55. package/logs/LOAD_20230524-155832-351763/checkpoint.csv +0 -1
  56. package/logs/LOAD_20230524-155832-351763/operation.log +0 -23
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+ const Archetype = require('archetype');
3
+
4
+ const GetDashboardParams = new Archetype({
5
+ dashboardId: {
6
+ $type: 'string',
7
+ $required: true
8
+ }
9
+ }).compile('GetDashboardParams');
10
+
11
+ module.exports = ({ db }) => async function getDashboard(params) {
12
+ const { dashboardId } = new GetDashboardParams(params);
13
+ const Dashboard = db.model('__Studio_Dashboard');
14
+
15
+ const dashboard = await Dashboard.findOne({ _id: dashboardId });
16
+
17
+ return { dashboard }
18
+ };
@@ -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,5 @@
1
+ 'use strict';
2
+
3
+ exports.getDashboard = require('./getDashboard');
4
+ exports.getDashboards = require('./getDashboards');
5
+ exports.updateDashboard = require('./updateDashboard');
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ const Archetype = require('archetype');
4
+
5
+ const UpdateDashboardParams = new Archetype({
6
+ dashboardId: {
7
+ $type: 'string',
8
+ $required: true
9
+ },
10
+ code: {
11
+ $type: 'string',
12
+ $required: true
13
+ }
14
+ }).compile('UpdateDashboardParams');
15
+
16
+ module.exports = ({ db }) => async function updateDashboard(params) {
17
+ const { dashboardId, code } = new UpdateDashboardParams(params);
18
+
19
+ const Dashboard = db.models[`__Studio_Dashboard`];
20
+
21
+ const doc = await Dashboard.
22
+ findByIdAndUpdate(dashboardId, { code }, { sanitizeFilter: true, returnDocument: 'after', overwriteImmutable: true });
23
+
24
+ return { doc };
25
+ };
@@ -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,17 @@ 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
+ const Dashboard = db.model('__Studio_Dashboard', dashboardSchema, '__studio_dashboards');
13
+ const doc = new Dashboard({
14
+ name: 'Test',
15
+ code: 'Test Code'
16
+ });
17
+ doc.save().then(res => console.log(res))
10
18
  const actions = applySpec(Actions, { db });
11
19
  return actions;
12
20
  };