@mongoosejs/studio 0.0.36 → 0.0.38

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.
@@ -2582,7 +2582,7 @@ module.exports = "<div>\n <div v-if=\"Array.isArray(result)\">\n <div v-for=
2582
2582
  /***/ ((module) => {
2583
2583
 
2584
2584
  "use strict";
2585
- module.exports = "<div class=\"dashboard px-1\">\n <div v-if=\"dashboard\" class=\"max-w-5xl mx-auto\">\n <div class=\"flex items-center w-full\">\n <h2 class=\"mt-4 mb-4 text-gray-900 font-semibold text-xl grow shrink\">{{title}}</h2>\n <div>\n <button\n v-if=\"!showEditor\"\n @click=\"showEditor = true\"\n type=\"button\"\n class=\"rounded-md bg-teal-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-teal-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-600\">\n <img src=\"images/edit.svg\" class=\"inline h-[1em]\" /> Edit\n </button>\n </div>\n </div>\n <div v-if=\"!showEditor\" class=\"mt-4 mb-4\">\n <dashboard-result :result=\"result\"></dashboard-result>\n </div>\n <div v-if=\"showEditor\">\n <edit-dashboard\n :dashboardId=\"dashboard._id\"\n :code=\"code\"\n :currentDescription=\"description\"\n :currentTitle=\"title\"\n @close=\"showEditor=false;\"\n @update=\"updateCode\"></edit-dashboard>\n </div>\n \n </div>\n <div v-if=\"!dashboard && status === 'loaded'\">\n No dashboard with the given id could be found.\n </div>\n</div>";
2585
+ module.exports = "<div class=\"dashboard px-1\">\n <div v-if=\"status === 'loading'\" class=\"max-w-5xl mx-auto text-center\">\n <img src=\"images/loader.gif\" class=\"inline\">\n </div>\n <div v-if=\"dashboard && status === 'loaded'\" class=\"max-w-5xl mx-auto\">\n <div class=\"flex items-center w-full\">\n <h2 class=\"mt-4 mb-4 text-gray-900 font-semibold text-xl grow shrink\">{{title}}</h2>\n <div>\n <button\n v-if=\"!showEditor\"\n @click=\"showEditor = true\"\n type=\"button\"\n class=\"rounded-md bg-teal-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-teal-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-600\">\n <img src=\"images/edit.svg\" class=\"inline h-[1em]\" /> Edit\n </button>\n </div>\n </div>\n <div v-if=\"!showEditor\" class=\"mt-4 mb-4\">\n <dashboard-result :result=\"result\"></dashboard-result>\n </div>\n <div v-if=\"showEditor\">\n <edit-dashboard\n :dashboardId=\"dashboard._id\"\n :code=\"code\"\n :currentDescription=\"description\"\n :currentTitle=\"title\"\n @close=\"showEditor=false;\"\n @update=\"updateCode\"></edit-dashboard>\n </div>\n \n </div>\n <div v-if=\"!dashboard && status === 'loaded'\">\n No dashboard with the given id could be found.\n </div>\n</div>\n";
2586
2586
 
2587
2587
  /***/ }),
2588
2588
 
@@ -1227,11 +1227,6 @@ video {
1227
1227
  color: rgb(153 27 27 / var(--tw-text-opacity));
1228
1228
  }
1229
1229
 
1230
- .text-sky-600 {
1231
- --tw-text-opacity: 1;
1232
- color: rgb(2 132 199 / var(--tw-text-opacity));
1233
- }
1234
-
1235
1230
  .text-sky-800 {
1236
1231
  --tw-text-opacity: 1;
1237
1232
  color: rgb(7 89 133 / var(--tw-text-opacity));
@@ -1,5 +1,8 @@
1
1
  <div class="dashboard px-1">
2
- <div v-if="dashboard" class="max-w-5xl mx-auto">
2
+ <div v-if="status === 'loading'" class="max-w-5xl mx-auto text-center">
3
+ <img src="images/loader.gif" class="inline mt-10">
4
+ </div>
5
+ <div v-if="dashboard && status === 'loaded'" class="max-w-5xl mx-auto">
3
6
  <div class="flex items-center w-full">
4
7
  <h2 class="mt-4 mb-4 text-gray-900 font-semibold text-xl grow shrink">{{title}}</h2>
5
8
  <div>
@@ -29,4 +32,4 @@
29
32
  <div v-if="!dashboard && status === 'loaded'">
30
33
  No dashboard with the given id could be found.
31
34
  </div>
32
- </div>
35
+ </div>
@@ -1,10 +1,13 @@
1
1
  <div class="document-details">
2
- <document-property
3
- :document="document"
4
- :schemaPaths="schemaPaths"
5
- :editting="editting"
6
- :changes="changes"
7
- :invalid="invalid"></document-property>
2
+ <div v-for="path in schemaPaths" class="value">
3
+ <document-property
4
+ :path="path"
5
+ :document="document"
6
+ :schemaPaths="schemaPaths"
7
+ :editting="editting"
8
+ :changes="changes"
9
+ :invalid="invalid"></document-property>
10
+ </div>
8
11
  <div v-for="path in virtuals" class="mb-2">
9
12
  <div class="p-1 mb-1 bg-slate-100">
10
13
  {{path.name}}
@@ -1,47 +1,45 @@
1
1
  <div>
2
- <div v-for="path in schemaPaths" class="value">
3
- <div class="relative path-key p-1 flex">
4
- <div class="grow">
5
- {{path.path}}
6
- <span class="path-type">
7
- ({{(path.instance || 'unknown').toLowerCase()}})
8
- </span>
9
- </div>
10
- <div v-if="editting && path.instance === 'Date'" class="flex gap-1.5">
2
+ <div class="relative path-key p-1 flex">
3
+ <div class="grow">
4
+ {{path.path}}
5
+ <span class="path-type">
6
+ ({{(path.instance || 'unknown').toLowerCase()}})
7
+ </span>
8
+ </div>
9
+ <div v-if="editting && path.instance === 'Date'" class="flex gap-1.5">
10
+ <div
11
+ @click="dateType = 'picker'"
12
+ :class="dateType === 'picker' ? 'bg-teal-600' : ''"
13
+ class="self-stretch px-2 py-1 rounded-sm justify-center items-center gap-1.5 flex cursor-pointer">
11
14
  <div
12
- @click="dateType = 'picker'"
13
- :class="dateType === 'picker' ? 'bg-white' : ''"
14
- class="self-stretch px-2 py-1 rounded-sm justify-center items-center gap-1.5 flex cursor-pointer">
15
- <div
16
- :class="dateType === 'picker' ? 'text-sky-600' : 'text-black'"
17
- class="text-xs font-medium font-['Lato'] capitalize leading-tight">
18
- Date Picker
19
- </div>
15
+ :class="dateType === 'picker' ? 'text-white' : ''"
16
+ class="text-xs font-medium font-['Lato'] capitalize leading-tight">
17
+ Date Picker
20
18
  </div>
19
+ </div>
20
+ <div
21
+ @click="dateType = 'iso'"
22
+ :class="dateType === 'iso' ? 'bg-teal-600' : ''"
23
+ class="self-stretch px-2 py-1 rounded-sm justify-center items-center gap-1.5 flex cursor-pointer">
21
24
  <div
22
- @click="dateType = 'iso'"
23
- :class="dateType === 'iso' ? 'bg-white' : ''"
24
- class="self-stretch px-2 py-1 rounded-sm justify-center items-center gap-1.5 flex cursor-pointer">
25
- <div
26
- :class="dateType === 'iso' ? 'text-sky-600' : 'text-black'"
27
- class="text-xs font-medium font-['Lato'] capitalize leading-tight">
28
- ISO String
29
- </div>
25
+ :class="dateType === 'iso' ? 'text-white' : ''"
26
+ class="text-xs font-medium font-['Lato'] capitalize leading-tight">
27
+ ISO String
30
28
  </div>
31
29
  </div>
32
30
  </div>
33
- <div v-if="editting && path.path !== '_id'" class="pl-1">
34
- <component
35
- :is="getEditComponentForPath(path)"
36
- :value="getEditValueForPath(path)"
37
- :format="dateType"
38
- @input="changes[path.path] = $event; delete invalid[path.path];"
39
- @error="invalid[path.path] = $event;"
40
- >
41
- </component>
42
- </div>
43
- <div v-else class="pl-1">
44
- <component :is="getComponentForPath(path)" :value="getValueForPath(path.path)"></component>
45
- </div>
31
+ </div>
32
+ <div v-if="editting && path.path !== '_id'" class="pl-1">
33
+ <component
34
+ :is="getEditComponentForPath(path)"
35
+ :value="getEditValueForPath(path)"
36
+ :format="dateType"
37
+ @input="changes[path.path] = $event; delete invalid[path.path];"
38
+ @error="invalid[path.path] = $event;"
39
+ >
40
+ </component>
41
+ </div>
42
+ <div v-else class="pl-1">
43
+ <component :is="getComponentForPath(path)" :value="getValueForPath(path.path)"></component>
46
44
  </div>
47
45
  </div>
@@ -14,7 +14,7 @@ module.exports = app => app.component('document-property', {
14
14
  dateType: 'picker' // picker, iso
15
15
  }
16
16
  },
17
- props: ['document', 'schemaPaths', 'editting', 'changes', 'invalid'],
17
+ props: ['path', 'document', 'schemaPaths', 'editting', 'changes', 'invalid'],
18
18
  methods: {
19
19
  getComponentForPath(schemaPath) {
20
20
  if (schemaPath.instance === 'Array') {
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "dependencies": {
5
5
  "archetype": "0.13.0",
6
6
  "csv-stringify": "6.3.0",
7
7
  "ejson": "^2.2.3",
8
8
  "extrovert": "0.0.24",
9
9
  "node-inspect-extracted": "3.x",
10
- "openai": "3.2.1",
11
10
  "vanillatoasts": "^1.6.0"
12
11
  },
13
12
  "peerDependencies": {
@@ -1,60 +0,0 @@
1
- 'use strict';
2
-
3
- const Archetype = require('archetype');
4
- const { Configuration, OpenAIApi } = require('openai');
5
-
6
- const apiKey = process.env.OPEN_AI_KEY;
7
-
8
- let openai;
9
- if (apiKey) {
10
- const configuration = new Configuration({
11
- apiKey
12
- });
13
- openai = new OpenAIApi(configuration);
14
- }
15
-
16
- const prePrompt = `
17
- You are a software developer answering user queries using Mongoose.
18
- Write Node.js code using Mongoose that answers the user's query.
19
- Do not write any import statements.
20
-
21
- Input:
22
- How many users where created yesterday?
23
- Output:
24
- const yesterday = new Date();
25
- yesterday.setHours(0, 0, 0);
26
- yesterday.setDate(yesterday.getDate() - 1);
27
- await User.countDocuments({ createdAt: { $gte: yesterday } });
28
- `.trim();
29
-
30
- const CreateChartParams = new Archetype({
31
- description: {
32
- $type: 'string',
33
- $required: true
34
- }
35
- }).compile('CreateChartParams');
36
-
37
- module.exports = ({ db }) => async function createChart(params) {
38
- const { description } = new CreateChartParams(params);
39
-
40
- const response = await openai.createChatCompletion({
41
- model: 'gpt-4',
42
- messages: [
43
- {
44
- role: 'system',
45
- content: prePrompt
46
- },
47
- {
48
- role: 'user',
49
- content: description
50
- }
51
- ],
52
- temperature: 0.1
53
- });
54
-
55
- console.log('F', response.data.choices[0].message.content);
56
-
57
- return {
58
- content: response.data.choices[0].message.content
59
- };
60
- };
@@ -1,17 +0,0 @@
1
- .charts {
2
- padding: 10px;
3
- }
4
-
5
- .charts .chart-description textarea {
6
- width: 100%;
7
- height: 4em;
8
- border-radius: 4px;
9
- border: 1px solid #ddd;
10
- margin-top: 0.5em;
11
- padding: 0.5em;
12
- line-height: 1.5em;
13
- }
14
-
15
- .charts .chart-description button {
16
- margin-top: 0.5em;
17
- }
@@ -1,14 +0,0 @@
1
- <div class="charts">
2
- <h1>Charts</h1>
3
- <div>
4
- Describe your chart
5
- </div>
6
- <div class="chart-description">
7
- <textarea
8
- v-model="description"
9
- placeholder="Please create a bar chart showing users createdAt per day" />
10
- <div>
11
- <async-button @click="createChart">Create Chart</async-button>
12
- </div>
13
- </div>
14
- </div>
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- const api = require('../api');
4
- const template = require('./charts.html');
5
-
6
- const appendCSS = require('../appendCSS');
7
-
8
- appendCSS(require('./charts.css'));
9
-
10
- module.exports = app => app.component('charts', {
11
- template: template,
12
- data: () => ({ description: '', code: '' }),
13
- methods: {
14
- async createChart() {
15
- const data = await api.Model.createChart({ description: this.description });
16
- this.code = data.content;
17
- }
18
- }
19
- });