carta-controller 5.0.3 → 5.1.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.
package/README.md CHANGED
@@ -1,12 +1,9 @@
1
1
  # CARTA Controller
2
- <!-- These badges should only be uncommented in release branches, and point to the appropriate tags: -->
3
- [![CARTA version](https://img.shields.io/badge/CARTA%20release-5.0.0-brightgreen)](https://github.com/CARTAvis/carta/releases/tag/v5.0.0)
4
- [![npm package](https://img.shields.io/npm/v/carta-controller/latest?style=flat)](https://www.npmjs.com/package/carta-controller/v/latest)
5
- <!-- These badges should only be uncommented in dev, and updated with the dev version: -->
6
- <!--[![CARTA backend version](https://img.shields.io/badge/CARTA%20backend%20version-6.0.0--dev-brightgreen)](https://github.com/CARTAvis/carta-backend/)
7
- [![CARTA frontend version](https://img.shields.io/badge/CARTA%20frontend%20version-6.0.0--dev-brightgreen)](https://github.com/CARTAvis/carta-frontend/)
2
+
3
+ [![latest stable release](https://img.shields.io/npm/v/carta-controller/latest?label=stable%20release)](https://www.npmjs.com/package/carta-controller/v/latest)
4
+ [![latest preview release](https://img.shields.io/npm/v/carta-controller/beta?label=preview%20release)](https://www.npmjs.com/package/carta-controller/v/beta)
8
5
  ![last commit](https://img.shields.io/github/last-commit/CARTAvis/carta-controller)
9
- ![commit activity](https://img.shields.io/github/commit-activity/m/CARTAvis/carta-controller)-->
6
+ ![commit activity](https://img.shields.io/github/commit-activity/m/CARTAvis/carta-controller)
10
7
 
11
8
  The CARTA controller provides a simple dashboard which authenticates users and allows them to manage their CARTA backend processes. It also serves static frontend code to clients, and dynamically redirects authenticated client connections to the appropriate backend processes. The controller can either handle authentication itself, or delegate it to an external OAuth2-based authentication server.
12
9
 
package/dist/database.js CHANGED
@@ -29,12 +29,14 @@ const preferenceSchema = require("../schemas/preferences_schema_2.json");
29
29
  const layoutSchema = require("../schemas/layout_schema_2.json");
30
30
  const snippetSchema = require("../schemas/snippet_schema_1.json");
31
31
  const workspaceSchema = require("../schemas/workspace_schema_1.json");
32
- const ajv = new ajv_1.default({ useDefaults: true, strictTypes: false });
32
+ const ajv = new ajv_1.default({ useDefaults: false, strictTypes: false });
33
+ const ajvWithDefaults = new ajv_1.default({ useDefaults: true, strictTypes: false });
33
34
  (0, ajv_formats_1.default)(ajv);
35
+ (0, ajv_formats_1.default)(ajvWithDefaults);
34
36
  const validatePreferences = ajv.compile(preferenceSchema);
35
- const validateLayout = ajv.compile(layoutSchema);
36
- const validateSnippet = ajv.compile(snippetSchema);
37
- const validateWorkspace = ajv.compile(workspaceSchema);
37
+ const validateLayout = ajvWithDefaults.compile(layoutSchema);
38
+ const validateSnippet = ajvWithDefaults.compile(snippetSchema);
39
+ const validateWorkspace = ajvWithDefaults.compile(workspaceSchema);
38
40
  let client;
39
41
  let preferenceCollection;
40
42
  let layoutsCollection;
@@ -111,7 +113,7 @@ function handleGetPreferences(req, res, next) {
111
113
  res.json({ success: true, preferences: doc });
112
114
  }
113
115
  else {
114
- return next({ statusCode: 500, message: "Problem retrieving preferences" });
116
+ res.json({ success: true, preferences: {} });
115
117
  }
116
118
  }
117
119
  catch (err) {
@@ -131,6 +133,7 @@ function handleSetPreferences(req, res, next) {
131
133
  const update = req.body;
132
134
  // Check for malformed update
133
135
  if (!update || !Object.keys(update).length || update.username || update._id) {
136
+ util_1.logger.warning("Malformed preference update received");
134
137
  return next({ statusCode: 400, message: "Malformed preference update" });
135
138
  }
136
139
  update.version = PREFERENCE_SCHEMA_VERSION;
@@ -142,9 +145,11 @@ function handleSetPreferences(req, res, next) {
142
145
  try {
143
146
  const updateResult = yield preferenceCollection.updateOne({ username: req.username }, { $set: update }, { upsert: true });
144
147
  if (updateResult.acknowledged) {
148
+ util_1.logger.debug("Preferences updated");
145
149
  res.json({ success: true });
146
150
  }
147
151
  else {
152
+ util_1.logger.warning("Error updating preferences");
148
153
  return next({ statusCode: 500, message: "Problem updating preferences" });
149
154
  }
150
155
  }
@@ -166,6 +171,7 @@ function handleClearPreferences(req, res, next) {
166
171
  const keys = (_a = req.body) === null || _a === void 0 ? void 0 : _a.keys;
167
172
  // Check for malformed update
168
173
  if (!keys || !Array.isArray(keys) || !keys.length) {
174
+ util_1.logger.debug("Malformed key list received for clearing preferences");
169
175
  return next({ statusCode: 400, message: "Malformed key list" });
170
176
  }
171
177
  const update = {};
@@ -175,13 +181,16 @@ function handleClearPreferences(req, res, next) {
175
181
  try {
176
182
  const updateResult = yield preferenceCollection.updateOne({ username: req.username }, { $unset: update });
177
183
  if (updateResult.acknowledged) {
184
+ util_1.logger.debug("Preferences cleared");
178
185
  res.json({ success: true });
179
186
  }
180
187
  else {
188
+ util_1.logger.debug("Error clearing preferences");
181
189
  return next({ statusCode: 500, message: "Problem clearing preferences" });
182
190
  }
183
191
  }
184
192
  catch (err) {
193
+ util_1.logger.debug("Error clearing preferences");
185
194
  util_1.logger.debug(err);
186
195
  return next({ statusCode: 500, message: "Problem clearing preferences" });
187
196
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carta-controller",
3
- "version": "5.0.3",
3
+ "version": "5.1.0",
4
4
  "description": "NodeJS-based controller for CARTA",
5
5
  "repository": "https://github.com/CARTAvis/carta-controller",
6
6
  "homepage": "https://www.cartavis.org",
@@ -25,7 +25,7 @@
25
25
  "ajv-formats": "^3.0.1",
26
26
  "axios": "^1.8.2",
27
27
  "body-parser": "^1.19.0",
28
- "carta-frontend": "^5.0.3",
28
+ "carta-frontend": "^5.1.0",
29
29
  "compression": "^1.8.0",
30
30
  "cookie-parser": "^1.4.7",
31
31
  "cors": "^2.8.5",
@@ -60,7 +60,7 @@
60
60
  "@types/cors": "^2.8.10",
61
61
  "@types/express": "^4.17.11",
62
62
  "@types/http-proxy": "^1.17.16",
63
- "@types/jsonwebtoken": "^9.0.7",
63
+ "@types/jsonwebtoken": "9.0.6",
64
64
  "@types/lodash": "^4.17.15",
65
65
  "@types/ms": "^0.7.31",
66
66
  "@types/node": "^22.13.1",