@mongoosejs/studio 0.0.47 → 0.0.49

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.
@@ -2,4 +2,5 @@
2
2
 
3
3
  exports.Dashboard = require('./Dashboard');
4
4
  exports.Model = require('./Model');
5
- exports.Script = require('./Script');
5
+ exports.Script = require('./Script');
6
+ exports.status = require('./status');
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const nodeEnv = process.env.NODE_ENV;
4
+
5
+ module.exports = () => async function status() {
6
+ return { nodeEnv };
7
+ };
package/express.js CHANGED
@@ -3,7 +3,7 @@
3
3
  const Backend = require('./backend');
4
4
  const express = require('express');
5
5
  const frontend = require('./frontend');
6
- const { toRoute } = require('extrovert');
6
+ const { toRoute, objectRouter } = require('extrovert');
7
7
 
8
8
  module.exports = function(apiUrl, conn, options) {
9
9
  const router = express.Router();
@@ -11,26 +11,11 @@ module.exports = function(apiUrl, conn, options) {
11
11
  apiUrl = apiUrl || '/admin/api';
12
12
  const backend = Backend(conn);
13
13
 
14
- const apiRouter = express.Router();
15
- apiRouter.use(express.json());
16
- for (const [name, actions] of Object.entries(backend)) {
17
- const subrouter = express.Router();
18
- for (const [actionName, action] of Object.entries(actions)) {
19
- subrouter.options(`/${actionName}`, (req, res) => res.send(''));
20
- subrouter.get(`/${actionName}`, toRoute(action));
21
- subrouter.put(`/${actionName}`, toRoute(action));
22
- subrouter.post(`/${actionName}`, toRoute(action));
23
- subrouter.delete(`/${actionName}`, toRoute(action));
24
- }
25
-
26
- apiRouter.use(`/${name}`, subrouter);
27
- }
28
-
29
- router.use('/api', apiRouter);
14
+ router.use('/api', express.json(), objectRouter(backend, toRoute));
30
15
 
31
16
  frontend(apiUrl, false, options);
32
17
 
33
18
  router.use(express.static(`${__dirname}/frontend/public`));
34
19
 
35
20
  return router;
36
- }
21
+ }
@@ -23,7 +23,7 @@ if (typeof config__setAuthorizationHeaderFrom === 'string' && config__setAuthori
23
23
  if (accessToken) {
24
24
  req.headers.authorization = accessToken;
25
25
  }
26
-
26
+
27
27
  return req;
28
28
  });
29
29
  }
@@ -39,6 +39,9 @@ client.interceptors.response.use(
39
39
  );
40
40
 
41
41
  if (false) {} else {
42
+ exports.status = function status() {
43
+ return client.get('/status').then(res => res.data);
44
+ };
42
45
  exports.Dashboard = {
43
46
  createDashboard: function createDashboard(params) {
44
47
  return client.post('/Dashboard/createDashboard', params).then(res => res.data);
@@ -902,7 +905,7 @@ module.exports = app => app.component('document', {
902
905
  const { doc, schemaPaths } = await api.Model.getDocument({ model: this.model, documentId: this.documentId });
903
906
  window.doc = doc;
904
907
  this.document = doc;
905
- this.schemaPaths = await Object.keys(schemaPaths).sort((k1, k2) => {
908
+ this.schemaPaths = Object.keys(schemaPaths).sort((k1, k2) => {
906
909
  if (k1 === '_id' && k2 !== '_id') {
907
910
  return -1;
908
911
  }
@@ -952,6 +955,7 @@ module.exports = app => app.component('document', {
952
955
  }
953
956
  });
954
957
 
958
+
955
959
  /***/ }),
956
960
 
957
961
  /***/ "./frontend/src/edit-array/edit-array.js":
@@ -979,7 +983,7 @@ appendCSS(__webpack_require__(/*! ./edit-array.css */ "./frontend/src/edit-array
979
983
  module.exports = app => app.component('edit-array', {
980
984
  template: template,
981
985
  props: ['value'],
982
- data: () => ({ currentValue: null, status: 'init' }),
986
+ data: () => ({ currentValue: -1 }),
983
987
  mounted() {
984
988
  this.currentValue = this.value == null
985
989
  ? '' + this.value
@@ -996,10 +1000,9 @@ module.exports = app => app.component('edit-array', {
996
1000
  watch: {
997
1001
  currentValue(newValue, oldValue) {
998
1002
  // Hacky way of skipping initial trigger because `immediate: false` doesn't work in Vue 3
999
- if (this.status === 'init') {
1003
+ if (oldValue === -1) {
1000
1004
  return;
1001
1005
  }
1002
- this.status = 'loaded';
1003
1006
  try {
1004
1007
  const array = eval(`(${this.currentValue})`);
1005
1008
  this.$emit('input', array);
@@ -1860,6 +1863,7 @@ module.exports = app => app.component('models', {
1860
1863
  "use strict";
1861
1864
 
1862
1865
 
1866
+ const api = __webpack_require__(/*! ../api */ "./frontend/src/api.js");
1863
1867
  const template = __webpack_require__(/*! ./navbar.html */ "./frontend/src/navbar/navbar.html");
1864
1868
 
1865
1869
  const appendCSS = __webpack_require__(/*! ../appendCSS */ "./frontend/src/appendCSS.js");
@@ -1868,13 +1872,22 @@ appendCSS(__webpack_require__(/*! ./navbar.css */ "./frontend/src/navbar/navbar.
1868
1872
 
1869
1873
  module.exports = app => app.component('navbar', {
1870
1874
  template: template,
1875
+ data: () => ({ nodeEnv: null }),
1871
1876
  computed: {
1872
1877
  routeName() {
1873
1878
  return this.$route.name;
1879
+ },
1880
+ warnEnv() {
1881
+ return this.nodeEnv === 'prod' || this.nodeEnv === 'production';
1874
1882
  }
1883
+ },
1884
+ async mounted() {
1885
+ const { nodeEnv } = await api.status();
1886
+ this.nodeEnv = nodeEnv;
1875
1887
  }
1876
1888
  });
1877
1889
 
1890
+
1878
1891
  /***/ }),
1879
1892
 
1880
1893
  /***/ "./frontend/src/routes.js":
@@ -3040,7 +3053,7 @@ module.exports = ".navbar {\n width: 100%;\n background-color: #eee;\n}\n\n.ac
3040
3053
  /***/ ((module) => {
3041
3054
 
3042
3055
  "use strict";
3043
- module.exports = "<div class=\"navbar\">\n <div class=\"nav-left\">\n <router-link to=\"/\">\n <img src=\"images/logo.svg\" alt=\"Mongoose Studio Logo\" />\n </router-link>\n </div>\n <div class=\"nav-right h-full\">\n <div class=\"sm:ml-6 sm:flex sm:space-x-8 h-full\">\n <a\n href=\"#/\"\n class=\"inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium\"\n :class=\"routeName === 'root' ? 'text-gray-900 border-teal-500' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700'\">Documents</a>\n <a\n href=\"#/dashboards\"\n class=\"inline-flex items-center border-b-2 px-1 pt-1 text-sm font-medium\"\n :class=\"routeName === 'dashboards' ? 'text-gray-900 border-teal-500' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700'\">Dashboards</a>\n </div>\n </div>\n <div style=\"clear: both\"></div>\n</div>\n";
3056
+ module.exports = "<div class=\"navbar\">\n <div class=\"nav-left flex items-center gap-4 h-full\">\n <router-link to=\"/\">\n <img src=\"images/logo.svg\" alt=\"Mongoose Studio Logo\" />\n </router-link>\n <div v-if=\"!!nodeEnv\" class=\"inline-flex items-center rounded-md px-2 py-1 text-sm font-medium text-gray-900\" :class=\"warnEnv ? 'bg-red-300' : 'bg-yellow-300'\">\n {{nodeEnv}}\n </div>\n </div>\n <div class=\"nav-right h-full\">\n <div class=\"sm:ml-6 sm:flex sm:space-x-8 h-full\">\n <a\n href=\"#/\"\n class=\"inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium\"\n :class=\"routeName === 'root' ? 'text-gray-900 border-teal-500' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700'\">Documents</a>\n <a\n href=\"#/dashboards\"\n class=\"inline-flex items-center border-b-2 px-1 pt-1 text-sm font-medium\"\n :class=\"routeName === 'dashboards' ? 'text-gray-900 border-teal-500' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700'\">Dashboards</a>\n </div>\n </div>\n <div style=\"clear: both\"></div>\n</div>\n";
3044
3057
 
3045
3058
  /***/ }),
3046
3059
 
@@ -810,6 +810,10 @@ video {
810
810
  gap: 0.5rem;
811
811
  }
812
812
 
813
+ .gap-4 {
814
+ gap: 1rem;
815
+ }
816
+
813
817
  .gap-y-5 {
814
818
  row-gap: 1.25rem;
815
819
  }
@@ -1015,6 +1019,16 @@ video {
1015
1019
  background-color: rgb(255 255 255 / var(--tw-bg-opacity));
1016
1020
  }
1017
1021
 
1022
+ .bg-red-300 {
1023
+ --tw-bg-opacity: 1;
1024
+ background-color: rgb(252 165 165 / var(--tw-bg-opacity));
1025
+ }
1026
+
1027
+ .bg-yellow-300 {
1028
+ --tw-bg-opacity: 1;
1029
+ background-color: rgb(253 224 71 / var(--tw-bg-opacity));
1030
+ }
1031
+
1018
1032
  .p-1 {
1019
1033
  padding: 0.25rem;
1020
1034
  }
@@ -13,7 +13,7 @@ if (typeof config__setAuthorizationHeaderFrom === 'string' && config__setAuthori
13
13
  if (accessToken) {
14
14
  req.headers.authorization = accessToken;
15
15
  }
16
-
16
+
17
17
  return req;
18
18
  });
19
19
  }
@@ -29,6 +29,9 @@ client.interceptors.response.use(
29
29
  );
30
30
 
31
31
  if (config__isLambda) {
32
+ exports.status = function status() {
33
+ return client.get('', { action: 'status' }).then(res => res.data);
34
+ };
32
35
  exports.Dashboard = {
33
36
  createDashboard(params) {
34
37
  return client.post('', { action: 'Dashboard.createDashboard', ...params }).then(res => res.data);
@@ -70,6 +73,9 @@ if (config__isLambda) {
70
73
  }
71
74
  };
72
75
  } else {
76
+ exports.status = function status() {
77
+ return client.get('/status').then(res => res.data);
78
+ };
73
79
  exports.Dashboard = {
74
80
  createDashboard: function createDashboard(params) {
75
81
  return client.post('/Dashboard/createDashboard', params).then(res => res.data);
@@ -28,7 +28,7 @@ module.exports = app => app.component('document', {
28
28
  const { doc, schemaPaths } = await api.Model.getDocument({ model: this.model, documentId: this.documentId });
29
29
  window.doc = doc;
30
30
  this.document = doc;
31
- this.schemaPaths = await Object.keys(schemaPaths).sort((k1, k2) => {
31
+ this.schemaPaths = Object.keys(schemaPaths).sort((k1, k2) => {
32
32
  if (k1 === '_id' && k2 !== '_id') {
33
33
  return -1;
34
34
  }
@@ -76,4 +76,4 @@ module.exports = app => app.component('document', {
76
76
  }
77
77
  }
78
78
  }
79
- });
79
+ });
@@ -16,7 +16,7 @@ appendCSS(require('./edit-array.css'));
16
16
  module.exports = app => app.component('edit-array', {
17
17
  template: template,
18
18
  props: ['value'],
19
- data: () => ({ currentValue: null, status: 'init' }),
19
+ data: () => ({ currentValue: -1 }),
20
20
  mounted() {
21
21
  this.currentValue = this.value == null
22
22
  ? '' + this.value
@@ -33,10 +33,9 @@ module.exports = app => app.component('edit-array', {
33
33
  watch: {
34
34
  currentValue(newValue, oldValue) {
35
35
  // Hacky way of skipping initial trigger because `immediate: false` doesn't work in Vue 3
36
- if (this.status === 'init') {
36
+ if (oldValue === -1) {
37
37
  return;
38
38
  }
39
- this.status = 'loaded';
40
39
  try {
41
40
  const array = eval(`(${this.currentValue})`);
42
41
  this.$emit('input', array);
@@ -1,8 +1,11 @@
1
1
  <div class="navbar">
2
- <div class="nav-left">
2
+ <div class="nav-left flex items-center gap-4 h-full">
3
3
  <router-link to="/">
4
4
  <img src="images/logo.svg" alt="Mongoose Studio Logo" />
5
5
  </router-link>
6
+ <div v-if="!!nodeEnv" class="inline-flex items-center rounded-md px-2 py-1 text-sm font-medium text-gray-900" :class="warnEnv ? 'bg-red-300' : 'bg-yellow-300'">
7
+ {{nodeEnv}}
8
+ </div>
6
9
  </div>
7
10
  <div class="nav-right h-full">
8
11
  <div class="sm:ml-6 sm:flex sm:space-x-8 h-full">
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const api = require('../api');
3
4
  const template = require('./navbar.html');
4
5
 
5
6
  const appendCSS = require('../appendCSS');
@@ -8,9 +9,17 @@ appendCSS(require('./navbar.css'));
8
9
 
9
10
  module.exports = app => app.component('navbar', {
10
11
  template: template,
12
+ data: () => ({ nodeEnv: null }),
11
13
  computed: {
12
14
  routeName() {
13
15
  return this.$route.name;
16
+ },
17
+ warnEnv() {
18
+ return this.nodeEnv === 'prod' || this.nodeEnv === 'production';
14
19
  }
20
+ },
21
+ async mounted() {
22
+ const { nodeEnv } = await api.status();
23
+ this.nodeEnv = nodeEnv;
15
24
  }
16
- });
25
+ });
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.0.47",
3
+ "version": "0.0.49",
4
4
  "dependencies": {
5
5
  "archetype": "0.13.1",
6
6
  "csv-stringify": "6.3.0",
7
7
  "ejson": "^2.2.3",
8
- "extrovert": "0.0.24",
8
+ "extrovert": "0.0.25",
9
9
  "node-inspect-extracted": "3.x",
10
10
  "tailwindcss": "3.4.0",
11
11
  "vanillatoasts": "^1.6.0",