@rvoh/psychic 1.1.8 → 1.1.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,43 @@
1
+ ## 1.1.9
2
+
3
+ - Throw a 422 if dream raises the `DataTypeColumnTypeMismatch` exception, which happens when a dream is saved to the database with data that cannot be inserted into the respective columns, usually because of a type mismatch.
4
+ - castParam will now encase params in an array when being explicitly casted as an array type, bypassing a known bug in express from causing arrays with single items in them to be treated as non-arrays.
5
+
6
+ ## 1.1.8
7
+
8
+ - Tap into CliFileWriter provided by dream to tap into file reversion for sync files, since the auto-sync function in psychic can fail and leave your file tree in a bad state.
9
+
10
+ ## 1.1.7
11
+
12
+ - Add support for middleware arrays, enabling express plugins like passport
13
+
14
+ ## 1.1.6
15
+
16
+ - fix regression caused by missing --schema-only option in psychic cli
17
+
18
+ ## 1.1.5
19
+
20
+ - pass packageManager through to dream, now that it accepts a packageManager setting.
21
+ - update dream shadowing within psychic application initialization to take place after initializers and plugins are processed, so that those initializers and plugins have an opportunity to adjust the settings.
22
+
23
+ ## 1.1.4
24
+
25
+ - fix regressions to redux bindings caused by default openapi path location changes
26
+ - resource generator can handle prefixing slashes
27
+
28
+ ## 1.1.3
29
+
30
+ - fix more minor issues with redux openapi bindings
31
+
32
+ ## 1.1.2
33
+
34
+ - Fix various issues with openapi redux bindings
35
+ - raise hard exception if accidentally using openapi route params in an expressjs route path
36
+
37
+ ## 1.1.1
38
+
39
+ Fix route printing regression causing route printouts to show the path instead of the action
40
+
1
41
  ## v1.1.0
2
42
 
3
43
  Provides easier access to express middleware by exposing `PsychicApp#use`, which enables a developer to provide express middleware directly through the psychcic application, without tapping into any hooks.
@@ -35,38 +75,3 @@ r.get('helloworld', (req, res, next) => {
35
75
  res.json({ hello: 'world' })
36
76
  })
37
77
  ```
38
-
39
- ## 1.1.1
40
-
41
- Fix route printing regression causing route printouts to show the path instead of the action
42
-
43
- ## 1.1.2
44
-
45
- - Fix various issues with openapi redux bindings
46
- - raise hard exception if accidentally using openapi route params in an expressjs route path
47
-
48
- ## 1.1.3
49
-
50
- - fix more minor issues with redux openapi bindings
51
-
52
- ## 1.1.4
53
-
54
- - fix regressions to redux bindings caused by default openapi path location changes
55
- - resource generator can handle prefixing slashes
56
-
57
- ## 1.1.5
58
-
59
- - pass packageManager through to dream, now that it accepts a packageManager setting.
60
- - update dream shadowing within psychic application initialization to take place after initializers and plugins are processed, so that those initializers and plugins have an opportunity to adjust the settings.
61
-
62
- ## 1.1.6
63
-
64
- - fix regression caused by missing --schema-only option in psychic cli
65
-
66
- ## 1.1.7
67
-
68
- - Add support for middleware arrays, enabling express plugins like passport
69
-
70
- ## 1.1.8
71
-
72
- - Tap into CliFileWriter provided by dream to tap into file reversion for sync files, since the auto-sync function in psychic can fail and leave your file tree in a bad state.
@@ -245,6 +245,9 @@ suggested fix: "${(0, helpers_js_1.convertRouteParams)(path)}"
245
245
  else if (err instanceof dream_1.RecordNotFound) {
246
246
  res.sendStatus(404);
247
247
  }
248
+ else if (err instanceof dream_1.DataTypeColumnTypeMismatch) {
249
+ res.status(422).json();
250
+ }
248
251
  else if (err instanceof dream_1.ValidationError) {
249
252
  res.status(422).json({ errors: err.errors || {} });
250
253
  }
@@ -287,8 +287,9 @@ class Params {
287
287
  case 'number[]':
288
288
  case 'string[]':
289
289
  case 'uuid[]':
290
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
290
291
  if (!Array.isArray(paramValue))
291
- throw new ParamValidationError_js_1.default(paramName, [typeToError(expectedType)]);
292
+ paramValue = [paramValue];
292
293
  return (0, dream_1.compact)(paramValue.map(param => this.cast(paramName, param, arrayTypeToNonArrayType(expectedType), { ...opts, allowNull: true })));
293
294
  case 'null[]':
294
295
  if (!Array.isArray(paramValue))
@@ -1,4 +1,4 @@
1
- import { RecordNotFound, ValidationError, camelize } from '@rvoh/dream';
1
+ import { DataTypeColumnTypeMismatch, RecordNotFound, ValidationError, camelize } from '@rvoh/dream';
2
2
  import { Router } from 'express';
3
3
  import pluralize from 'pluralize-esm';
4
4
  import ParamValidationError from '../error/controller/ParamValidationError.js';
@@ -239,6 +239,9 @@ suggested fix: "${convertRouteParams(path)}"
239
239
  else if (err instanceof RecordNotFound) {
240
240
  res.sendStatus(404);
241
241
  }
242
+ else if (err instanceof DataTypeColumnTypeMismatch) {
243
+ res.status(422).json();
244
+ }
242
245
  else if (err instanceof ValidationError) {
243
246
  res.status(422).json({ errors: err.errors || {} });
244
247
  }
@@ -282,8 +282,9 @@ export default class Params {
282
282
  case 'number[]':
283
283
  case 'string[]':
284
284
  case 'uuid[]':
285
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
285
286
  if (!Array.isArray(paramValue))
286
- throw new ParamValidationError(paramName, [typeToError(expectedType)]);
287
+ paramValue = [paramValue];
287
288
  return compact(paramValue.map(param => this.cast(paramName, param, arrayTypeToNonArrayType(expectedType), { ...opts, allowNull: true })));
288
289
  case 'null[]':
289
290
  if (!Array.isArray(paramValue))
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "name": "@rvoh/psychic",
4
4
  "description": "Typescript web framework",
5
- "version": "1.1.8",
5
+ "version": "1.1.9",
6
6
  "author": "RVOHealth",
7
7
  "repository": {
8
8
  "type": "git",
@@ -59,7 +59,7 @@
59
59
  "devDependencies": {
60
60
  "@eslint/js": "^9.19.0",
61
61
  "@jest-mock/express": "^3.0.0",
62
- "@rvoh/dream": "^1.1.2",
62
+ "@rvoh/dream": "^1.2.1",
63
63
  "@rvoh/dream-spec-helpers": "^1.0.0",
64
64
  "@rvoh/psychic-spec-helpers": "^1.0.0",
65
65
  "@types/express": "^5.0.1",