@mongoosejs/studio 0.5.13 → 0.6.0

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 (86) hide show
  1. package/AGENTS.md +74 -0
  2. package/README.md +27 -0
  3. package/backend/actions/ChatMessage/executeScript.js +15 -5
  4. package/backend/actions/ChatThread/createChatMessage.js +7 -2
  5. package/backend/actions/ChatThread/getChatThread.js +8 -2
  6. package/backend/actions/ChatThread/listChatThreads.js +6 -1
  7. package/backend/actions/ChatThread/shareChatThread.js +8 -2
  8. package/backend/actions/ChatThread/streamChatMessage.js +7 -2
  9. package/backend/actions/ChatThread/toggleAgentMode.js +8 -2
  10. package/backend/actions/Dashboard/createDashboard.js +3 -0
  11. package/backend/actions/Dashboard/deleteDashboard.js +13 -3
  12. package/backend/actions/Dashboard/getDashboard.js +33 -10
  13. package/backend/actions/Dashboard/getDashboards.js +9 -1
  14. package/backend/actions/Dashboard/updateDashboard.js +9 -2
  15. package/backend/actions/Model/addField.js +9 -2
  16. package/backend/actions/Model/analyzeSchema.js +16 -4
  17. package/backend/actions/Model/createChatMessage.js +3 -0
  18. package/backend/actions/Model/createDocument.js +3 -0
  19. package/backend/actions/Model/deleteDocument.js +9 -3
  20. package/backend/actions/Model/deleteDocuments.js +9 -1
  21. package/backend/actions/Model/dropCollection.js +3 -0
  22. package/backend/actions/Model/dropIndex.js +3 -0
  23. package/backend/actions/Model/executeDocumentScript.js +33 -26
  24. package/backend/actions/Model/exportQueryResults.js +13 -1
  25. package/backend/actions/Model/getCollectionInfo.js +15 -3
  26. package/backend/actions/Model/getDocument.js +13 -2
  27. package/backend/actions/Model/getDocuments.js +25 -5
  28. package/backend/actions/Model/getDocumentsStream.js +38 -18
  29. package/backend/actions/Model/getEstimatedDocumentCounts.js +15 -2
  30. package/backend/actions/Model/getIndexes.js +3 -0
  31. package/backend/actions/Model/getSuggestedProjection.js +3 -0
  32. package/backend/actions/Model/listModels.js +3 -0
  33. package/backend/actions/Model/streamChatMessage.js +3 -0
  34. package/backend/actions/Model/streamDocumentChanges.js +3 -0
  35. package/backend/actions/Model/updateDocument.js +10 -2
  36. package/backend/actions/Model/updateDocuments.js +10 -2
  37. package/backend/actions/Model/validateDocument.js +15 -2
  38. package/backend/actions/Script/createScript.js +36 -0
  39. package/backend/actions/Script/executeScript.js +89 -0
  40. package/backend/actions/Script/getScript.js +43 -0
  41. package/backend/actions/Script/index.js +5 -0
  42. package/backend/actions/Task/cancelTask.js +9 -3
  43. package/backend/actions/Task/getTaskOverview.js +7 -3
  44. package/backend/actions/Task/getTasks.js +7 -3
  45. package/backend/actions/Task/getTasksOverTime.js +7 -3
  46. package/backend/actions/Task/rescheduleTask.js +9 -3
  47. package/backend/actions/Task/runTask.js +9 -3
  48. package/backend/actions/index.js +1 -0
  49. package/backend/authorize.js +6 -1
  50. package/backend/db/scriptSchema.js +29 -0
  51. package/backend/helpers/omitNullish.js +5 -0
  52. package/backend/helpers/operationOptions.js +26 -0
  53. package/backend/helpers/readOperationOptions.js +31 -0
  54. package/backend/index.js +6 -4
  55. package/backend/integrations/mothership.js +28 -0
  56. package/backend/mcp.js +140 -0
  57. package/backend/netlify.js +5 -3
  58. package/backend/next.js +5 -3
  59. package/backend/sandbox/createSandbox.js +2 -2
  60. package/backend/sandbox/createScriptDb.js +60 -20
  61. package/backend/util/archetypeToZodSchema.js +74 -0
  62. package/docs/mcp-oauth.md +106 -0
  63. package/eslint.config.js +1 -0
  64. package/eval/agent/run.js +1 -1
  65. package/express.js +183 -41
  66. package/frontend/index.js +3 -0
  67. package/frontend/public/app.js +740 -124
  68. package/frontend/public/tw.css +76 -0
  69. package/frontend/src/api.js +27 -1
  70. package/frontend/src/index.js +9 -1
  71. package/frontend/src/mcp/mcp.html +55 -0
  72. package/frontend/src/mcp/mcp.js +27 -0
  73. package/frontend/src/models/models.html +29 -8
  74. package/frontend/src/models/models.js +30 -2
  75. package/frontend/src/navbar/navbar.html +8 -0
  76. package/frontend/src/navbar/navbar.js +3 -0
  77. package/frontend/src/routes.js +16 -0
  78. package/frontend/src/script/script.html +105 -0
  79. package/frontend/src/script/script.js +98 -0
  80. package/frontend/src/tooltip/tooltip.html +28 -0
  81. package/frontend/src/tooltip/tooltip.js +94 -0
  82. package/index.d.ts +10 -1
  83. package/local.js +2 -1
  84. package/nest.d.ts +4 -0
  85. package/package.json +5 -3
  86. package/vercel.d.ts +4 -0
@@ -0,0 +1,98 @@
1
+ /* global Prism */
2
+ 'use strict';
3
+
4
+ const api = require('../api');
5
+ const baseComponent = require('../_util/baseComponent');
6
+ const template = require('./script.html');
7
+
8
+ module.exports = {
9
+ template,
10
+ extends: baseComponent,
11
+ props: ['scriptId'],
12
+ inject: ['state'],
13
+ data() {
14
+ return {
15
+ status: 'loading',
16
+ script: null,
17
+ editedScript: '',
18
+ isEditing: false,
19
+ activeTab: 'code',
20
+ selectedRunMode: 'run',
21
+ showRunDropdown: false
22
+ };
23
+ },
24
+ computed: {
25
+ canUseDryRun() {
26
+ return this.state.capabilities?.supportsTransactions !== false;
27
+ },
28
+ selectedRunLabel() {
29
+ return this.selectedRunMode === 'dryRun' ? 'Dry Run' : 'Run';
30
+ },
31
+ isDryRunResult() {
32
+ return this.script?.executionFinishedAt != null && this.script?.dryRun === true;
33
+ }
34
+ },
35
+ methods: {
36
+ async loadScript() {
37
+ this.status = 'loading';
38
+ try {
39
+ const { script } = await api.Script.getScript({ scriptId: this.scriptId });
40
+ this.script = script;
41
+ this.editedScript = script.script;
42
+ this.activeTab = script.executionResult == null ? 'code' : 'output';
43
+ } finally {
44
+ this.status = 'loaded';
45
+ this.highlightCode();
46
+ }
47
+ },
48
+ startEditing() {
49
+ this.editedScript = this.script.script;
50
+ this.isEditing = true;
51
+ this.activeTab = 'code';
52
+ },
53
+ cancelEditing() {
54
+ this.editedScript = this.script.script;
55
+ this.isEditing = false;
56
+ this.highlightCode();
57
+ },
58
+ selectRunMode(mode) {
59
+ if (mode === 'dryRun' && !this.canUseDryRun) {
60
+ return;
61
+ }
62
+ this.selectedRunMode = mode;
63
+ this.showRunDropdown = false;
64
+ },
65
+ async executeScript() {
66
+ this.showRunDropdown = false;
67
+ try {
68
+ const { script } = await api.Script.executeScript({
69
+ scriptId: this.scriptId,
70
+ script: this.isEditing ? this.editedScript : this.script.script,
71
+ dryRun: this.selectedRunMode === 'dryRun'
72
+ });
73
+ this.script = script;
74
+ this.editedScript = script.script;
75
+ this.isEditing = false;
76
+ this.activeTab = 'output';
77
+ this.$toast.success(this.script.dryRun ? 'Dry run completed!' : 'Script executed successfully!');
78
+ } catch (err) {
79
+ const { script } = await api.Script.getScript({ scriptId: this.scriptId });
80
+ this.script = script;
81
+ this.editedScript = script.script;
82
+ this.isEditing = false;
83
+ this.activeTab = 'output';
84
+ throw err;
85
+ }
86
+ },
87
+ highlightCode() {
88
+ this.$nextTick(() => {
89
+ if (this.$refs.code) {
90
+ Prism.highlightElement(this.$refs.code);
91
+ }
92
+ });
93
+ }
94
+ },
95
+ mounted() {
96
+ return this.loadScript();
97
+ }
98
+ };
@@ -0,0 +1,28 @@
1
+ <span
2
+ ref="trigger"
3
+ class="inline-flex outline-none focus-visible:rounded-md focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600"
4
+ tabindex="0"
5
+ :aria-describedby="isOpen ? tooltipId : null"
6
+ @mouseenter="show"
7
+ @mouseleave="hideUnlessPinned"
8
+ @focusin="show"
9
+ @focusout="handleFocusOut"
10
+ @click="toggle"
11
+ @keydown.esc.stop="hide"
12
+ >
13
+ <slot></slot>
14
+ <span
15
+ v-show="isOpen"
16
+ ref="tooltip"
17
+ :id="tooltipId"
18
+ class="pointer-events-none fixed z-[1000] w-max max-w-[min(20rem,calc(100vw-1rem))] whitespace-normal rounded-md bg-gray-900 px-2.5 py-1.5 text-xs font-normal leading-4 text-white shadow-lg"
19
+ :style="tooltipStyle"
20
+ role="tooltip"
21
+ >
22
+ {{ text }}
23
+ <span
24
+ class="absolute left-1/2 h-2 w-2 -translate-x-1/2 rotate-45 bg-gray-900"
25
+ :class="placement === 'bottom' ? '-top-1' : '-bottom-1'"
26
+ ></span>
27
+ </span>
28
+ </span>
@@ -0,0 +1,94 @@
1
+ 'use strict';
2
+
3
+ const template = require('./tooltip.html');
4
+
5
+ let nextTooltipId = 0;
6
+
7
+ module.exports = app => app.component('tooltip', {
8
+ props: {
9
+ text: {
10
+ type: String,
11
+ required: true
12
+ }
13
+ },
14
+ template,
15
+ data() {
16
+ return {
17
+ isOpen: false,
18
+ isPinned: false,
19
+ placement: 'bottom',
20
+ tooltipId: `tooltip-${++nextTooltipId}`,
21
+ tooltipStyle: {
22
+ visibility: 'hidden'
23
+ }
24
+ };
25
+ },
26
+ mounted() {
27
+ document.addEventListener('click', this.handleOutsideClick);
28
+ window.addEventListener('resize', this.updatePosition);
29
+ window.addEventListener('scroll', this.updatePosition, true);
30
+ },
31
+ beforeUnmount() {
32
+ document.removeEventListener('click', this.handleOutsideClick);
33
+ window.removeEventListener('resize', this.updatePosition);
34
+ window.removeEventListener('scroll', this.updatePosition, true);
35
+ },
36
+ methods: {
37
+ show() {
38
+ this.isOpen = true;
39
+ this.tooltipStyle = { visibility: 'hidden' };
40
+ this.$nextTick(this.updatePosition);
41
+ },
42
+ hide() {
43
+ this.isOpen = false;
44
+ this.isPinned = false;
45
+ },
46
+ hideUnlessPinned() {
47
+ if (!this.isPinned) {
48
+ this.isOpen = false;
49
+ }
50
+ },
51
+ toggle() {
52
+ if (this.isPinned) {
53
+ this.hide();
54
+ return;
55
+ }
56
+
57
+ this.isPinned = true;
58
+ this.show();
59
+ },
60
+ handleFocusOut(event) {
61
+ if (!this.$el.contains(event.relatedTarget)) {
62
+ this.hideUnlessPinned();
63
+ }
64
+ },
65
+ handleOutsideClick(event) {
66
+ if (!this.$el.contains(event.target)) {
67
+ this.hide();
68
+ }
69
+ },
70
+ updatePosition() {
71
+ if (!this.isOpen || !this.$refs.trigger || !this.$refs.tooltip) {
72
+ return;
73
+ }
74
+
75
+ const gap = 8;
76
+ const viewportPadding = 8;
77
+ const triggerRect = this.$refs.trigger.getBoundingClientRect();
78
+ const tooltipRect = this.$refs.tooltip.getBoundingClientRect();
79
+ const fitsBelow = triggerRect.bottom + gap + tooltipRect.height <= window.innerHeight - viewportPadding;
80
+ const top = fitsBelow ?
81
+ triggerRect.bottom + gap :
82
+ Math.max(viewportPadding, triggerRect.top - gap - tooltipRect.height);
83
+ const centeredLeft = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;
84
+ const maxLeft = Math.max(viewportPadding, window.innerWidth - tooltipRect.width - viewportPadding);
85
+ const left = Math.min(Math.max(viewportPadding, centeredLeft), maxLeft);
86
+
87
+ this.placement = fitsBelow ? 'bottom' : 'top';
88
+ this.tooltipStyle = {
89
+ left: `${Math.round(left)}px`,
90
+ top: `${Math.round(top)}px`
91
+ };
92
+ }
93
+ }
94
+ });
package/index.d.ts CHANGED
@@ -5,7 +5,16 @@ declare module '@mongoosejs/studio' {
5
5
  const express: (
6
6
  path?: string,
7
7
  connOrMongoose?: Connection | Mongoose,
8
- options?: { apiKey?: string; bindIp?: string | string[] | null }
8
+ options?: {
9
+ apiKey?: string;
10
+ bindIp?: string | string[] | null;
11
+ maxTimeMS?: number;
12
+ /** Serve the MCP endpoint at `<mount>/mcp`. Defaults to true. */
13
+ mcp?: boolean;
14
+ readPreference?: 'primary' | 'secondaryPreferred' | 'secondary';
15
+ /** Public base URL Mongoose Studio is mounted on. Required when MCP and apiKey are enabled. */
16
+ publicUrl?: string;
17
+ }
9
18
  ) => Promise<RequestHandler>;
10
19
 
11
20
  const studio: {
package/local.js CHANGED
@@ -30,7 +30,8 @@ async function run() {
30
30
  _mothershipUrl: 'http://localhost:7777/.netlify/functions',
31
31
  // apiKey: 'TACO',
32
32
  openAIAPIKey: process.env.OPENAI_API_KEY,
33
- googleGeminiAPIKey: process.env.GEMINI_API_KEY
33
+ googleGeminiAPIKey: process.env.GEMINI_API_KEY,
34
+ maxTimeMS: 1000
34
35
  })
35
36
  );
36
37
 
package/nest.d.ts CHANGED
@@ -9,6 +9,10 @@ declare module '@mongoosejs/studio/nest' {
9
9
  connectionToken?: string | symbol | Function;
10
10
  apiKey?: string;
11
11
  bindIp?: string | string[] | null;
12
+ maxTimeMS?: number;
13
+ mcp?: boolean;
14
+ readPreference?: 'primary' | 'secondaryPreferred' | 'secondary';
15
+ publicUrl?: string;
12
16
  [key: string]: any;
13
17
  }
14
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.5.13",
3
+ "version": "0.6.0",
4
4
  "description": "AI-Powered Data Workspace for MongoDB: Turn your MongoDB data into dashboards, maps, and interactive workflows - powered by your Mongoose models and AI.",
5
5
  "homepage": "https://mongoosestudio.app/",
6
6
  "repository": {
@@ -12,12 +12,13 @@
12
12
  "@ai-sdk/anthropic": "2.x",
13
13
  "@ai-sdk/google": "2.x",
14
14
  "@ai-sdk/openai": "2.x",
15
+ "@modelcontextprotocol/sdk": "^1.30.1",
15
16
  "ace-builds": "^1.43.6",
16
17
  "ai": "5.x",
17
18
  "archetype": "0.13.1",
18
19
  "csv-stringify": "6.3.0",
19
20
  "ejson": "^2.2.3",
20
- "extrovert": "^0.2.0",
21
+ "extrovert": "^0.2.1",
21
22
  "marked": "15.0.12",
22
23
  "mpath": "^0.9.0",
23
24
  "node-inspect-extracted": "3.x",
@@ -28,7 +29,8 @@
28
29
  "vue": "3.x",
29
30
  "vue-toastification": "^2.0.0-rc.5",
30
31
  "webpack": "5.x",
31
- "xss": "^1.0.15"
32
+ "xss": "^1.0.15",
33
+ "zod": "^4.6.5"
32
34
  },
33
35
  "peerDependencies": {
34
36
  "@nestjs/common": "10.x || 11.x",
package/vercel.d.ts CHANGED
@@ -8,6 +8,10 @@ declare module '@mongoosejs/studio/vercel' {
8
8
  studioConnection?: Connection;
9
9
  /** Watch the connection for changes and stream them to the Studio frontend. */
10
10
  changeStream?: boolean;
11
+ /** Maximum execution time in milliseconds for MongoDB operations. */
12
+ maxTimeMS?: number;
13
+ /** Read preference for Studio reads against the application database. */
14
+ readPreference?: 'primary' | 'secondaryPreferred' | 'secondary';
11
15
  /** Chat model name, e.g. 'gpt-4o-mini' */
12
16
  model?: string;
13
17
  openAIAPIKey?: string;