@rvoh/psychic 1.2.2 → 1.5.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/CHANGELOG.md ADDED
@@ -0,0 +1,104 @@
1
+ ## 1.2.3
2
+
3
+ - add support for the connectionName argument when generating a resource
4
+
5
+ ## 1.2.2
6
+
7
+ - bump supertest and express-session to close dependabot issues [53](https://github.com/rvohealth/psychic/security/dependabot/53), [56](https://github.com/rvohealth/psychic/security/dependabot/56), and [57](https://github.com/rvohealth/psychic/security/dependabot/57)
8
+
9
+ ## 1.2.1
10
+
11
+ - add ability to set custom import extension, which will be used when generating new files for your application
12
+
13
+ ## 1.2.0
14
+
15
+ - update for Dream 1.4.0
16
+
17
+ ## 1.1.11
18
+
19
+ - 400 is more appropriate than 422 for `DataTypeColumnTypeMismatch`
20
+
21
+ ## 1.1.10
22
+
23
+ - Don't include deletedAt in generated create/update actions in resource specs since deletedAt is for deleting
24
+
25
+ - return 422 if Dream throws `NotNullViolation` or `CheckConstraintViolation`
26
+
27
+ ## 1.1.9
28
+
29
+ - return 422 if dream throws `DataTypeColumnTypeMismatch`, 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.
30
+
31
+ - 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.
32
+
33
+ ## 1.1.8
34
+
35
+ - 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.
36
+
37
+ ## 1.1.7
38
+
39
+ - Add support for middleware arrays, enabling express plugins like passport
40
+
41
+ ## 1.1.6
42
+
43
+ - fix regression caused by missing --schema-only option in psychic cli
44
+
45
+ ## 1.1.5
46
+
47
+ - pass packageManager through to dream, now that it accepts a packageManager setting.
48
+ - 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.
49
+
50
+ ## 1.1.4
51
+
52
+ - fix regressions to redux bindings caused by default openapi path location changes
53
+ - resource generator can handle prefixing slashes
54
+
55
+ ## 1.1.3
56
+
57
+ - fix more minor issues with redux openapi bindings
58
+
59
+ ## 1.1.2
60
+
61
+ - Fix various issues with openapi redux bindings
62
+ - raise hard exception if accidentally using openapi route params in an expressjs route path
63
+
64
+ ## 1.1.1
65
+
66
+ Fix route printing regression causing route printouts to show the path instead of the action
67
+
68
+ ## v1.1.0
69
+
70
+ 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.
71
+
72
+ ```ts
73
+ psy.use((_, res) => {
74
+ res.send(
75
+ 'this will be run after psychic middleware (i.e. cors and bodyParser) are processed, but before routes are processed',
76
+ )
77
+ })
78
+ ```
79
+
80
+ Some middleware needs to be run before other middleware, so we expose an optional first argument which can be provided so explicitly send your middleware into express at various stages of the psychic configuration process. For example, to inject your middleware before cors and bodyParser are configured, provide `before-middleware` as the first argument. To initialize your middleware after the psychic default middleware, but before your routes have been processed, provide `after-middleware` as the first argument (or simply provide a callback function directly, since this is the default). To run after routes have been processed, provide `after-routes` as the first argument.
81
+
82
+ ```ts
83
+ psy.use('before-middleware', (_, res) => {
84
+ res.send('this will be run before psychic has configured any default middleware')
85
+ })
86
+
87
+ psy.use('after-middleware', (_, res) => {
88
+ res.send('this will be run after psychic has configured default middleware')
89
+ })
90
+
91
+ psy.use('after-routes', (_, res) => {
92
+ res.send('this will be run after psychic has processed all the routes in your conf/routes.ts file')
93
+ })
94
+ ```
95
+
96
+ Additionally, a new overload has been added to all CRUD methods on the PsychicRouter class, enabling you to provide RequestHandler middleware directly to psychic, like so:
97
+
98
+ ```ts
99
+ // conf/routes.ts
100
+
101
+ r.get('helloworld', (req, res, next) => {
102
+ res.json({ hello: 'world' })
103
+ })
104
+ ```
@@ -67,6 +67,7 @@ class PsychicCLI {
67
67
  - delete`)
68
68
  .option('--sti-base-serializer', 'omits the serializer from the dream model, but does create the serializer so it can be extended by STI children')
69
69
  .option('--owning-model <modelName>', 'the model class of the object that `associationQuery`/`createAssociation` will be performed on in the created controller and spec (e.g., "Host", "Guest") (simply to save time making changes to the generated code). Defaults to User')
70
+ .option('--connection-name <connectionName>', 'the name of the db connection you would like to use for your model. Defaults to "default"', 'default')
70
71
  .argument('<path>', 'URL path from root domain')
71
72
  .argument('<modelName>', 'the name of the model to create, e.g. Post or Settings/CommunicationPreferences')
72
73
  .argument('[columnsWithTypes...]', columnsWithTypesDescription)
@@ -28,6 +28,7 @@ async function generateResource({ route, fullyQualifiedModelName, options, colum
28
28
  serializer: true,
29
29
  stiBaseSerializer: options.stiBaseSerializer,
30
30
  includeAdminSerializers: forAdmin,
31
+ connectionName: options.connectionName,
31
32
  },
32
33
  });
33
34
  route = (0, pluralize_esm_1.default)(route);
@@ -62,6 +62,7 @@ export default class PsychicCLI {
62
62
  - delete`)
63
63
  .option('--sti-base-serializer', 'omits the serializer from the dream model, but does create the serializer so it can be extended by STI children')
64
64
  .option('--owning-model <modelName>', 'the model class of the object that `associationQuery`/`createAssociation` will be performed on in the created controller and spec (e.g., "Host", "Guest") (simply to save time making changes to the generated code). Defaults to User')
65
+ .option('--connection-name <connectionName>', 'the name of the db connection you would like to use for your model. Defaults to "default"', 'default')
65
66
  .argument('<path>', 'URL path from root domain')
66
67
  .argument('<modelName>', 'the name of the model to create, e.g. Post or Settings/CommunicationPreferences')
67
68
  .argument('[columnsWithTypes...]', columnsWithTypesDescription)
@@ -21,6 +21,7 @@ export default async function generateResource({ route, fullyQualifiedModelName,
21
21
  serializer: true,
22
22
  stiBaseSerializer: options.stiBaseSerializer,
23
23
  includeAdminSerializers: forAdmin,
24
+ connectionName: options.connectionName,
24
25
  },
25
26
  });
26
27
  route = pluralize(route);
@@ -5,6 +5,7 @@ export default class PsychicBin {
5
5
  onlyActions?: string;
6
6
  stiBaseSerializer: boolean;
7
7
  owningModel?: string;
8
+ connectionName: string;
8
9
  }): Promise<void>;
9
10
  static routes(): Promise<void>;
10
11
  static sync({ bypassDreamSync, schemaOnly, }?: {
@@ -8,6 +8,7 @@ export default function generateResource({ route, fullyQualifiedModelName, optio
8
8
  only?: string;
9
9
  stiBaseSerializer: boolean;
10
10
  owningModel?: string;
11
+ connectionName: string;
11
12
  };
12
13
  columnsWithTypes: string[];
13
14
  }): Promise<void>;
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.2.2",
5
+ "version": "1.5.0",
6
6
  "author": "RVOHealth",
7
7
  "repository": {
8
8
  "type": "git",
@@ -59,8 +59,8 @@
59
59
  "devDependencies": {
60
60
  "@eslint/js": "^9.19.0",
61
61
  "@jest-mock/express": "^3.0.0",
62
- "@rvoh/dream": "^1.4.0",
63
- "@rvoh/dream-spec-helpers": "^1.1.0",
62
+ "@rvoh/dream": "^1.5.0",
63
+ "@rvoh/dream-spec-helpers": "^1.1.1",
64
64
  "@rvoh/psychic-spec-helpers": "^1.0.0",
65
65
  "@types/express": "^5.0.1",
66
66
  "@types/express-session": "^1.18.2",
@@ -93,4 +93,4 @@
93
93
  "winston": "^3.14.2"
94
94
  },
95
95
  "packageManager": "yarn@4.7.0"
96
- }
96
+ }