@mongoosejs/studio 0.0.48 → 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);
@@ -980,7 +983,7 @@ appendCSS(__webpack_require__(/*! ./edit-array.css */ "./frontend/src/edit-array
980
983
  module.exports = app => app.component('edit-array', {
981
984
  template: template,
982
985
  props: ['value'],
983
- data: () => ({ currentValue: -1, status: 'init' }),
986
+ data: () => ({ currentValue: -1 }),
984
987
  mounted() {
985
988
  this.currentValue = this.value == null
986
989
  ? '' + this.value
@@ -993,9 +996,6 @@ module.exports = app => app.component('edit-array', {
993
996
  this.editor.on('change', ev => {
994
997
  this.currentValue = this.editor.getValue();
995
998
  });
996
- this.$nextTick(() => {
997
- this.status = 'init';
998
- })
999
999
  },
1000
1000
  watch: {
1001
1001
  currentValue(newValue, oldValue) {
@@ -1863,6 +1863,7 @@ module.exports = app => app.component('models', {
1863
1863
  "use strict";
1864
1864
 
1865
1865
 
1866
+ const api = __webpack_require__(/*! ../api */ "./frontend/src/api.js");
1866
1867
  const template = __webpack_require__(/*! ./navbar.html */ "./frontend/src/navbar/navbar.html");
1867
1868
 
1868
1869
  const appendCSS = __webpack_require__(/*! ../appendCSS */ "./frontend/src/appendCSS.js");
@@ -1871,13 +1872,22 @@ appendCSS(__webpack_require__(/*! ./navbar.css */ "./frontend/src/navbar/navbar.
1871
1872
 
1872
1873
  module.exports = app => app.component('navbar', {
1873
1874
  template: template,
1875
+ data: () => ({ nodeEnv: null }),
1874
1876
  computed: {
1875
1877
  routeName() {
1876
1878
  return this.$route.name;
1879
+ },
1880
+ warnEnv() {
1881
+ return this.nodeEnv === 'prod' || this.nodeEnv === 'production';
1877
1882
  }
1883
+ },
1884
+ async mounted() {
1885
+ const { nodeEnv } = await api.status();
1886
+ this.nodeEnv = nodeEnv;
1878
1887
  }
1879
1888
  });
1880
1889
 
1890
+
1881
1891
  /***/ }),
1882
1892
 
1883
1893
  /***/ "./frontend/src/routes.js":
@@ -3043,7 +3053,7 @@ module.exports = ".navbar {\n width: 100%;\n background-color: #eee;\n}\n\n.ac
3043
3053
  /***/ ((module) => {
3044
3054
 
3045
3055
  "use strict";
3046
- 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";
3047
3057
 
3048
3058
  /***/ }),
3049
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);
@@ -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.48",
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",