@mongoosejs/studio 0.0.94 → 0.0.95
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.
- package/.github/workflows/lint.yml +18 -0
- package/backend/actions/ChatThread/createChatMessage.js +1 -1
- package/backend/actions/ChatThread/createChatThread.js +2 -2
- package/backend/actions/Dashboard/getDashboards.js +1 -1
- package/backend/actions/Dashboard/updateDashboard.js +1 -1
- package/backend/actions/Model/createDocument.js +1 -1
- package/backend/actions/Model/deleteDocument.js +3 -3
- package/backend/actions/Model/deleteDocuments.js +2 -2
- package/backend/actions/Model/exportQueryResults.js +1 -1
- package/backend/actions/Model/getDocument.js +1 -1
- package/backend/actions/Model/getDocuments.js +2 -2
- package/backend/actions/Model/getIndexes.js +1 -1
- package/backend/actions/Model/index.js +1 -1
- package/backend/actions/Model/updateDocument.js +1 -1
- package/backend/actions/Model/updateDocuments.js +1 -1
- package/backend/authorize.js +1 -3
- package/backend/db/dashboardSchema.js +2 -2
- package/backend/helpers/removeSpecifiedPaths.js +1 -1
- package/backend/netlify.js +3 -3
- package/backend/next.js +1 -1
- package/eslint.config.js +46 -0
- package/frontend/index.js +1 -1
- package/frontend/public/app.js +104 -104
- package/frontend/src/api.js +16 -16
- package/frontend/src/chat/chat-message/chat-message.js +1 -1
- package/frontend/src/chat/chat.js +1 -1
- package/frontend/src/clone-document/clone-document.js +8 -8
- package/frontend/src/create-dashboard/create-dashboard.js +7 -7
- package/frontend/src/create-document/create-document.js +10 -10
- package/frontend/src/dashboard/dashboard.js +1 -1
- package/frontend/src/dashboard/edit-dashboard/edit-dashboard.js +3 -3
- package/frontend/src/dashboards/dashboards.js +1 -1
- package/frontend/src/document/confirm-changes/confirm-changes.js +2 -2
- package/frontend/src/document/confirm-delete/confirm-delete.js +2 -2
- package/frontend/src/document/document.js +2 -2
- package/frontend/src/document-details/document-details.js +3 -3
- package/frontend/src/document-details/document-property/document-property.js +3 -3
- package/frontend/src/edit-array/edit-array.js +1 -1
- package/frontend/src/edit-subdocument/edit-subdocument.js +1 -1
- package/frontend/src/list-default/list-default.js +3 -3
- package/frontend/src/models/models.js +11 -11
- package/frontend/src/navbar/navbar.js +3 -3
- package/frontend/src/update-document/update-document.js +25 -25
- package/package.json +4 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: Lint
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
push:
|
|
5
|
+
jobs:
|
|
6
|
+
lint:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v3
|
|
10
|
+
- name: Setting up the node version
|
|
11
|
+
uses: actions/setup-node@v3
|
|
12
|
+
with:
|
|
13
|
+
node-version: 20.19.0
|
|
14
|
+
- name: setup project
|
|
15
|
+
run: npm i
|
|
16
|
+
- name: run lint
|
|
17
|
+
run: |
|
|
18
|
+
npm run lint
|
|
@@ -9,12 +9,12 @@ const CreateChatThreadParams = new Archetype({
|
|
|
9
9
|
$type: mongoose.Types.ObjectId
|
|
10
10
|
},
|
|
11
11
|
roles: {
|
|
12
|
-
$type: ['string']
|
|
12
|
+
$type: ['string']
|
|
13
13
|
}
|
|
14
14
|
}).compile('CreateChatThreadParams');
|
|
15
15
|
|
|
16
16
|
module.exports = ({ studioConnection }) => async function createChatThread(params) {
|
|
17
|
-
const { userId } = new CreateChatThreadParams(params);
|
|
17
|
+
const { userId, roles } = new CreateChatThreadParams(params);
|
|
18
18
|
const ChatThread = studioConnection.model('__Studio_ChatThread');
|
|
19
19
|
|
|
20
20
|
await authorize('ChatThread.createChatThread', roles);
|
|
@@ -26,7 +26,7 @@ const UpdateDashboardParams = new Archetype({
|
|
|
26
26
|
module.exports = ({ db }) => async function updateDashboard(params) {
|
|
27
27
|
const { dashboardId, code, title, description, roles } = new UpdateDashboardParams(params);
|
|
28
28
|
|
|
29
|
-
const Dashboard = db.models[
|
|
29
|
+
const Dashboard = db.models['__Studio_Dashboard'];
|
|
30
30
|
|
|
31
31
|
await authorize('Dashboard.updateDashboard', roles);
|
|
32
32
|
|
|
@@ -13,7 +13,7 @@ const DeleteDocumentParams = new Archetype({
|
|
|
13
13
|
$required: true
|
|
14
14
|
},
|
|
15
15
|
roles: {
|
|
16
|
-
$type: ['string']
|
|
16
|
+
$type: ['string']
|
|
17
17
|
}
|
|
18
18
|
}).compile('DeleteDocumentParams');
|
|
19
19
|
|
|
@@ -29,10 +29,10 @@ module.exports = ({ db }) => async function DeleteDocument(params) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const doc = await Model.
|
|
32
|
-
deleteOne({_id: documentId}).
|
|
32
|
+
deleteOne({ _id: documentId }).
|
|
33
33
|
setOptions({ sanitizeFilter: true }).
|
|
34
34
|
orFail();
|
|
35
|
-
|
|
35
|
+
console.log('what is doc', doc);
|
|
36
36
|
|
|
37
37
|
return { doc };
|
|
38
38
|
};
|
|
@@ -13,7 +13,7 @@ const DeleteDocumentsParams = new Archetype({
|
|
|
13
13
|
$required: true
|
|
14
14
|
},
|
|
15
15
|
roles: {
|
|
16
|
-
$type: ['string']
|
|
16
|
+
$type: ['string']
|
|
17
17
|
}
|
|
18
18
|
}).compile('DeleteDocumentsParams');
|
|
19
19
|
|
|
@@ -29,7 +29,7 @@ module.exports = ({ db }) => async function DeleteDocuments(params) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
await Model.
|
|
32
|
-
deleteMany({_id: { $in: documentIds }}).
|
|
32
|
+
deleteMany({ _id: { $in: documentIds } }).
|
|
33
33
|
setOptions({ sanitizeFilter: true }).
|
|
34
34
|
orFail();
|
|
35
35
|
|
|
@@ -66,7 +66,7 @@ module.exports = ({ db }) => async function exportQueryResults(params, req, res)
|
|
|
66
66
|
|
|
67
67
|
res.set({
|
|
68
68
|
'Content-Type': 'text/csv',
|
|
69
|
-
'Content-Disposition': `attachment; filename="${model.toLowerCase()}-export.csv"
|
|
69
|
+
'Content-Disposition': `attachment; filename="${model.toLowerCase()}-export.csv"`
|
|
70
70
|
});
|
|
71
71
|
return csv;
|
|
72
72
|
};
|
|
@@ -32,7 +32,7 @@ module.exports = ({ db }) => async function getDocument(params) {
|
|
|
32
32
|
findById(documentId).
|
|
33
33
|
setOptions({ sanitizeFilter: true }).
|
|
34
34
|
orFail();
|
|
35
|
-
|
|
35
|
+
const schemaPaths = {};
|
|
36
36
|
for (const path of Object.keys(Model.schema.paths)) {
|
|
37
37
|
schemaPaths[path] = {
|
|
38
38
|
instance: Model.schema.paths[path].instance,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const Archetype = require('archetype');
|
|
4
4
|
const removeSpecifiedPaths = require('../../helpers/removeSpecifiedPaths');
|
|
5
|
-
const { EJSON } = require('bson')
|
|
5
|
+
const { EJSON } = require('bson');
|
|
6
6
|
const authorize = require('../../authorize');
|
|
7
7
|
|
|
8
8
|
const GetDocumentsParams = new Archetype({
|
|
@@ -58,7 +58,7 @@ module.exports = ({ db }) => async function getDocuments(params) {
|
|
|
58
58
|
skip(skip).
|
|
59
59
|
sort(hasSort ? sort : { _id: -1 });
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
const schemaPaths = {};
|
|
62
62
|
for (const path of Object.keys(Model.schema.paths)) {
|
|
63
63
|
schemaPaths[path] = {
|
|
64
64
|
instance: Model.schema.paths[path].instance,
|
|
@@ -26,7 +26,7 @@ module.exports = ({ db }) => async function getIndexes(params) {
|
|
|
26
26
|
const mongoDBIndexes = await Model.listIndexes();
|
|
27
27
|
const schemaIndexes = Model.schema.indexes().map(([fields, options]) => ({
|
|
28
28
|
key: fields,
|
|
29
|
-
name: Object.keys(fields).map(key => `${key}_${fields[key]}`).join(
|
|
29
|
+
name: Object.keys(fields).map(key => `${key}_${fields[key]}`).join('_')
|
|
30
30
|
}));
|
|
31
31
|
const diffIndexes = await Model.diffIndexes();
|
|
32
32
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
exports.createDocument = require('./createDocument')
|
|
3
|
+
exports.createDocument = require('./createDocument');
|
|
4
4
|
exports.deleteDocument = require('./deleteDocument');
|
|
5
5
|
exports.deleteDocuments = require('./deleteDocuments');
|
|
6
6
|
exports.dropIndex = require('./dropIndex');
|
package/backend/authorize.js
CHANGED
|
@@ -10,7 +10,6 @@ const actionsToRequiredRoles = {
|
|
|
10
10
|
'Dashboard.deleteDashboard': ['owner', 'admin', 'member'],
|
|
11
11
|
'Dashboard.getDashboard': ['owner', 'admin', 'member', 'readonly', 'dashboards'],
|
|
12
12
|
'Dashboard.getDashboards': ['owner', 'admin', 'member', 'readonly', 'dashboards'],
|
|
13
|
-
'Dashboard.getDashboard': ['owner', 'admin', 'member', 'readonly', 'dashboards'],
|
|
14
13
|
'Dashboard.updateDashboard': ['owner', 'admin', 'member'],
|
|
15
14
|
'Model.createDocument': ['owner', 'admin', 'member'],
|
|
16
15
|
'Model.updateDocument': ['owner', 'admin', 'member'],
|
|
@@ -21,7 +20,6 @@ const actionsToRequiredRoles = {
|
|
|
21
20
|
'Model.getDocuments': ['owner', 'admin', 'member', 'readonly'],
|
|
22
21
|
'Model.getIndexes': ['owner', 'admin', 'member', 'readonly'],
|
|
23
22
|
'Model.listModels': ['owner', 'admin', 'member', 'readonly'],
|
|
24
|
-
'Model.updateDocument': ['owner', 'admin', 'member'],
|
|
25
23
|
'Model.updateDocuments': ['owner', 'admin', 'member']
|
|
26
24
|
};
|
|
27
25
|
|
|
@@ -33,4 +31,4 @@ module.exports = function authorize(action, roles) {
|
|
|
33
31
|
if (!authorized) {
|
|
34
32
|
throw new Error(`Unauthorized to take action ${action}`);
|
|
35
33
|
}
|
|
36
|
-
}
|
|
34
|
+
};
|
|
@@ -22,7 +22,7 @@ dashboardSchema.methods.evaluate = async function evaluate() {
|
|
|
22
22
|
let result = null;
|
|
23
23
|
result = await vm.runInContext(formatFunction(this.code), context);
|
|
24
24
|
if (result.$document?.constructor?.modelName) {
|
|
25
|
-
|
|
25
|
+
const schemaPaths = {};
|
|
26
26
|
const Model = this.constructor.db.model(result.$document?.constructor?.modelName);
|
|
27
27
|
for (const path of Object.keys(Model.schema.paths)) {
|
|
28
28
|
schemaPaths[path] = {
|
|
@@ -42,4 +42,4 @@ module.exports = dashboardSchema;
|
|
|
42
42
|
|
|
43
43
|
const formatFunction = code => `(async function() {
|
|
44
44
|
${code}
|
|
45
|
-
})()
|
|
45
|
+
})();`;
|
package/backend/netlify.js
CHANGED
|
@@ -22,7 +22,7 @@ module.exports = function netlify(conn, options) {
|
|
|
22
22
|
method: 'POST',
|
|
23
23
|
body: JSON.stringify({ apiKey: options.apiKey }),
|
|
24
24
|
headers: {
|
|
25
|
-
|
|
25
|
+
Authorization: `Bearer ${options.apiKey}`,
|
|
26
26
|
'Content-Type': 'application/json'
|
|
27
27
|
}
|
|
28
28
|
})
|
|
@@ -41,7 +41,7 @@ module.exports = function netlify(conn, options) {
|
|
|
41
41
|
method: 'POST',
|
|
42
42
|
body: JSON.stringify({ workspaceId: workspace._id }),
|
|
43
43
|
headers: {
|
|
44
|
-
|
|
44
|
+
Authorization: authorization,
|
|
45
45
|
'Content-Type': 'application/json'
|
|
46
46
|
}
|
|
47
47
|
})
|
|
@@ -79,4 +79,4 @@ module.exports = function netlify(conn, options) {
|
|
|
79
79
|
|
|
80
80
|
return actionFn(params);
|
|
81
81
|
});
|
|
82
|
-
}
|
|
82
|
+
};
|
package/backend/next.js
CHANGED
package/eslint.config.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const config = require('@masteringjs/eslint-config');
|
|
4
|
+
const { defineConfig } = require('eslint/config');
|
|
5
|
+
|
|
6
|
+
module.exports = defineConfig([
|
|
7
|
+
{
|
|
8
|
+
ignores: ['frontend/public/*', 'frontend/public/**']
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
files: ['backend/**/*.js'],
|
|
12
|
+
languageOptions: {
|
|
13
|
+
sourceType: 'commonjs',
|
|
14
|
+
globals: {
|
|
15
|
+
fetch: true,
|
|
16
|
+
setTimeout: true,
|
|
17
|
+
process: true,
|
|
18
|
+
console: true
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
extends: [config]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
files: ['frontend/src/**/*.js', 'frontend/src/*.js', 'frontend/index.js'],
|
|
25
|
+
languageOptions: {
|
|
26
|
+
globals: {
|
|
27
|
+
Prism: true,
|
|
28
|
+
window: true,
|
|
29
|
+
document: true,
|
|
30
|
+
console: true,
|
|
31
|
+
Vue: true,
|
|
32
|
+
VueRouter: true,
|
|
33
|
+
CodeMirror: true,
|
|
34
|
+
Chart: true,
|
|
35
|
+
URLSearchParams: true,
|
|
36
|
+
fetch: true,
|
|
37
|
+
__dirname: true,
|
|
38
|
+
process: true,
|
|
39
|
+
setTimeout: true,
|
|
40
|
+
navigator: true
|
|
41
|
+
},
|
|
42
|
+
sourceType: 'commonjs'
|
|
43
|
+
},
|
|
44
|
+
extends: [config]
|
|
45
|
+
}
|
|
46
|
+
]);
|
package/frontend/index.js
CHANGED
|
@@ -14,7 +14,7 @@ module.exports = async function frontend(apiUrl, isLambda, options, workspace) {
|
|
|
14
14
|
method: 'POST',
|
|
15
15
|
body: JSON.stringify({ apiKey: options.apiKey }),
|
|
16
16
|
headers: {
|
|
17
|
-
|
|
17
|
+
Authorization: `Bearer ${options.apiKey}`,
|
|
18
18
|
'Content-Type': 'application/json'
|
|
19
19
|
}
|
|
20
20
|
})
|