@mongoosejs/studio 0.3.7 → 0.3.9

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.
@@ -3,6 +3,7 @@
3
3
  const Archetype = require('archetype');
4
4
  const vm = require('vm');
5
5
  const authorize = require('../../authorize');
6
+ const { defaultMothershipURL } = require('../../../constants');
6
7
 
7
8
  const GetDashboardParams = new Archetype({
8
9
  dashboardId: {
@@ -26,7 +27,7 @@ const GetDashboardParams = new Archetype({
26
27
  module.exports = ({ db, options }) => async function getDashboard(params) {
27
28
  const { $workspaceId, authorization, dashboardId, evaluate, roles } = new GetDashboardParams(params);
28
29
  const Dashboard = db.model('__Studio_Dashboard');
29
- const mothershipUrl = options?._mothershipUrl ?? 'https://mongoose-js.netlify.app/.netlify/functions';
30
+ const mothershipUrl = options?._mothershipUrl ?? defaultMothershipURL;
30
31
 
31
32
  await authorize('Dashboard.getDashboard', roles);
32
33
 
@@ -4,6 +4,7 @@ const { createAnthropic } = require('@ai-sdk/anthropic');
4
4
  const { createGoogleGenerativeAI } = require('@ai-sdk/google');
5
5
  const { createOpenAI } = require('@ai-sdk/openai');
6
6
  const { generateText } = require('ai');
7
+ const { defaultMothershipURL } = require('../../constants');
7
8
 
8
9
  module.exports = async function callLLM(messages, system, options) {
9
10
  let provider = null;
@@ -50,7 +51,7 @@ module.exports = async function callLLM(messages, system, options) {
50
51
  }
51
52
 
52
53
  const headers = { 'Content-Type': 'application/json' };
53
- const response = await fetch('https://mongoose-js.netlify.app/.netlify/functions/getChatCompletion', {
54
+ const response = await fetch(`${defaultMothershipURL}/getChatCompletion`, {
54
55
  method: 'POST',
55
56
  headers,
56
57
  body: JSON.stringify({
@@ -4,6 +4,7 @@ const { createAnthropic } = require('@ai-sdk/anthropic');
4
4
  const { createGoogleGenerativeAI } = require('@ai-sdk/google');
5
5
  const { createOpenAI } = require('@ai-sdk/openai');
6
6
  const { streamText } = require('ai');
7
+ const { defaultMothershipURL } = require('../../constants');
7
8
 
8
9
  module.exports = async function* streamLLM(messages, system, options) {
9
10
  let provider = null;
@@ -62,7 +63,7 @@ module.exports = async function* streamLLM(messages, system, options) {
62
63
 
63
64
  // If not using OpenAI, Anthropic, or Google Gemini, fallback to Mongoose (no streaming)
64
65
  const headers = { 'Content-Type': 'application/json' };
65
- const response = await fetch('https://mongoose-js.netlify.app/.netlify/functions/getChatCompletion', {
66
+ const response = await fetch(`${defaultMothershipURL}/getChatCompletion`, {
66
67
  method: 'POST',
67
68
  headers,
68
69
  body: JSON.stringify({
@@ -2,10 +2,11 @@
2
2
 
3
3
  const Backend = require('./');
4
4
  const { toNetlifyFunction } = require('extrovert');
5
+ const { defaultMothershipURL } = require('../constants');
5
6
 
6
7
  module.exports = function netlify(conn, options) {
7
8
  const backend = Backend(conn, options?.studioConnection, options);
8
- const mothershipUrl = options?._mothershipUrl || 'https://mongoose-js.netlify.app/.netlify/functions';
9
+ const mothershipUrl = options?._mothershipUrl || defaultMothershipURL;
9
10
 
10
11
  let workspace = null;
11
12
 
package/backend/next.js CHANGED
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  const Backend = require('./');
4
+ const { defaultMothershipURL } = require('../constants');
4
5
 
5
6
  module.exports = function next(conn, options) {
6
7
  const backend = Backend(conn, options?.studioConnection, options);
7
8
 
8
- const mothershipUrl = options?._mothershipUrl || 'https://mongoose-js.netlify.app/.netlify/functions';
9
+ const mothershipUrl = options?._mothershipUrl || defaultMothershipURL;
9
10
  let workspace = null;
10
11
 
11
12
  return async function wrappedNextJSFunction(req, res) {
package/constants.js ADDED
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const defaultMothershipURL = 'https://mothership.mongoosestudio.app/.netlify/functions';
4
+
5
+ module.exports = {
6
+ defaultMothershipURL
7
+ };
package/express.js CHANGED
@@ -4,12 +4,13 @@ const Backend = require('./backend');
4
4
  const express = require('express');
5
5
  const frontend = require('./frontend');
6
6
  const { toRoute, objectRouter } = require('extrovert');
7
+ const { defaultMothershipURL } = require('./constants');
7
8
 
8
9
  module.exports = async function mongooseStudioExpressApp(apiUrl, conn, options) {
9
10
  const router = express.Router();
10
11
  options = options ? { changeStream: true, ...options } : { changeStream: true };
11
12
 
12
- const mothershipUrl = options._mothershipUrl || 'https://mongoose-js.netlify.app/.netlify/functions';
13
+ const mothershipUrl = options._mothershipUrl || defaultMothershipURL;
13
14
  let workspace = null;
14
15
  if (options?.apiKey) {
15
16
  ({ workspace } = await fetch(`${mothershipUrl}/getWorkspace`, {
package/frontend/index.js CHANGED
@@ -4,10 +4,11 @@ const { execSync, exec } = require('child_process');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
  const webpack = require('webpack');
7
+ const { defaultMothershipURL } = require('../constants');
7
8
  const webpackConfig = require('./webpack.config');
8
9
 
9
10
  module.exports = async function frontend(apiUrl, isLambda, options, workspace) {
10
- const mothershipUrl = options?._mothershipUrl || 'https://mongoose-js.netlify.app/.netlify/functions';
11
+ const mothershipUrl = options?._mothershipUrl || defaultMothershipURL;
11
12
 
12
13
  if (workspace == null && options?.apiKey) {
13
14
  ({ workspace } = await fetch(`${mothershipUrl}/getWorkspace`, {
@@ -10023,13 +10023,13 @@ const { DATE_FILTERS, getDateRangeForRange } = __webpack_require__(/*! ../_util/
10023
10023
  /** Returns the bucket size in ms for the given date range. */
10024
10024
  function getBucketSizeMs(range) {
10025
10025
  switch (range) {
10026
- case 'last_hour': return 5 * 60 * 1000; // 5 minutes
10026
+ case 'last_hour': return 5 * 60 * 1000; // 5 minutes
10027
10027
  case 'today':
10028
- case 'yesterday': return 60 * 60 * 1000; // 1 hour
10028
+ case 'yesterday': return 60 * 60 * 1000; // 1 hour
10029
10029
  case 'thisWeek':
10030
- case 'lastWeek': return 24 * 60 * 60 * 1000; // 1 day
10030
+ case 'lastWeek': return 24 * 60 * 60 * 1000; // 1 day
10031
10031
  case 'thisMonth':
10032
- case 'lastMonth': return 24 * 60 * 60 * 1000; // 1 day
10032
+ case 'lastMonth': return 24 * 60 * 60 * 1000; // 1 day
10033
10033
  default: return 5 * 60 * 1000;
10034
10034
  }
10035
10035
  }
@@ -62835,7 +62835,7 @@ var src_default = VueToastificationPlugin;
62835
62835
  (module) {
62836
62836
 
62837
62837
  "use strict";
62838
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@mongoosejs/studio","version":"0.3.7","description":"A Mongoose-native MongoDB UI with schema-aware autocomplete, AI-assisted queries, and dashboards that understand your models - not just your data.","homepage":"https://mongoosestudio.app/","repository":{"type":"git","url":"https://github.com/mongoosejs/studio"},"license":"Apache-2.0","dependencies":{"@ai-sdk/anthropic":"2.x","@ai-sdk/google":"2.x","@ai-sdk/openai":"2.x","ace-builds":"^1.43.6","ai":"5.x","archetype":"0.13.1","csv-stringify":"6.3.0","ejson":"^2.2.3","extrovert":"^0.2.0","marked":"15.0.12","node-inspect-extracted":"3.x","regexp.escape":"^2.0.1","tailwindcss":"3.4.0","vue":"3.x","vue-toastification":"^2.0.0-rc.5","webpack":"5.x","time-commando":"1.0.1","xss":"^1.0.15"},"peerDependencies":{"mongoose":"7.x || 8.x || ^9.0.0"},"optionalPeerDependencies":{"@mongoosejs/task":"0.5.x || 0.6.x"},"devDependencies":{"@masteringjs/eslint-config":"0.1.1","axios":"1.2.2","dedent":"^1.6.0","eslint":"9.30.0","express":"4.x","mocha":"10.2.0","mongodb-memory-server":"^11.0.1","mongoose":"9.x","sinon":"^21.0.1"},"scripts":{"lint":"eslint .","seed":"node seed/index.js","start":"node ./local.js","tailwind":"tailwindcss -o ./frontend/public/tw.css","tailwind:watch":"tailwindcss -o ./frontend/public/tw.css --watch","test":"mocha test/*.test.js","test:frontend":"mocha test/frontend/*.test.js"}}');
62838
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@mongoosejs/studio","version":"0.3.9","description":"A Mongoose-native MongoDB UI with schema-aware autocomplete, AI-assisted queries, and dashboards that understand your models - not just your data.","homepage":"https://mongoosestudio.app/","repository":{"type":"git","url":"https://github.com/mongoosejs/studio"},"license":"Apache-2.0","dependencies":{"@ai-sdk/anthropic":"2.x","@ai-sdk/google":"2.x","@ai-sdk/openai":"2.x","ace-builds":"^1.43.6","ai":"5.x","archetype":"0.13.1","csv-stringify":"6.3.0","ejson":"^2.2.3","extrovert":"^0.2.0","marked":"15.0.12","node-inspect-extracted":"3.x","regexp.escape":"^2.0.1","tailwindcss":"3.4.0","vue":"3.x","vue-toastification":"^2.0.0-rc.5","webpack":"5.x","time-commando":"1.0.1","xss":"^1.0.15"},"peerDependencies":{"mongoose":"7.x || 8.x || ^9.0.0"},"optionalPeerDependencies":{"@mongoosejs/task":"0.5.x || 0.6.x"},"devDependencies":{"@masteringjs/eslint-config":"0.1.1","axios":"1.2.2","dedent":"^1.6.0","eslint":"9.30.0","express":"4.x","mocha":"10.2.0","mongodb-memory-server":"^11.0.1","mongoose":"9.x","sinon":"^21.0.1"},"scripts":{"lint":"eslint .","seed":"node seed/index.js","start":"node ./local.js","tailwind":"tailwindcss -o ./frontend/public/tw.css","tailwind:watch":"tailwindcss -o ./frontend/public/tw.css --watch","test":"mocha test/*.test.js","test:frontend":"mocha test/frontend/*.test.js"}}');
62839
62839
 
62840
62840
  /***/ }
62841
62841
 
@@ -7,13 +7,13 @@ const { DATE_FILTERS, getDateRangeForRange } = require('../_util/dateRange');
7
7
  /** Returns the bucket size in ms for the given date range. */
8
8
  function getBucketSizeMs(range) {
9
9
  switch (range) {
10
- case 'last_hour': return 5 * 60 * 1000; // 5 minutes
10
+ case 'last_hour': return 5 * 60 * 1000; // 5 minutes
11
11
  case 'today':
12
- case 'yesterday': return 60 * 60 * 1000; // 1 hour
12
+ case 'yesterday': return 60 * 60 * 1000; // 1 hour
13
13
  case 'thisWeek':
14
- case 'lastWeek': return 24 * 60 * 60 * 1000; // 1 day
14
+ case 'lastWeek': return 24 * 60 * 60 * 1000; // 1 day
15
15
  case 'thisMonth':
16
- case 'lastMonth': return 24 * 60 * 60 * 1000; // 1 day
16
+ case 'lastMonth': return 24 * 60 * 60 * 1000; // 1 day
17
17
  default: return 5 * 60 * 1000;
18
18
  }
19
19
  }
package/index.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  declare module '@mongoosejs/studio' {
2
2
  import { RequestHandler } from 'express';
3
+ import { Connection, Mongoose } from 'mongoose';
3
4
 
4
- const express: (path: string) => RequestHandler;
5
+ const express: (
6
+ path: string,
7
+ connOrMongoose?: Connection | Mongoose,
8
+ options?: { apiKey?: string }
9
+ ) => RequestHandler;
5
10
 
6
11
  const studio: {
7
12
  express: typeof express;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "A Mongoose-native MongoDB UI with schema-aware autocomplete, AI-assisted queries, and dashboards that understand your models - not just your data.",
5
5
  "homepage": "https://mongoosestudio.app/",
6
6
  "repository": {