forest-express-sequelize 8.4.4 → 8.4.8

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.
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npx --no-install commitlint --edit "$1"
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ node ./.eslint-bin/pre-commit-hook.js
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## [8.4.8](https://github.com/ForestAdmin/forest-express-sequelize/compare/v8.4.7...v8.4.8) (2021-11-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add searchFields type in the collection options ([#875](https://github.com/ForestAdmin/forest-express-sequelize/issues/875)) ([8a9a84a](https://github.com/ForestAdmin/forest-express-sequelize/commit/8a9a84a263741fc3ed1814eb954dec6ca8bb5626))
7
+
8
+ ## [8.4.7](https://github.com/ForestAdmin/forest-express-sequelize/compare/v8.4.6...v8.4.7) (2021-10-25)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add warning message when connections does not have any models ([#866](https://github.com/ForestAdmin/forest-express-sequelize/issues/866)) ([4c41bd7](https://github.com/ForestAdmin/forest-express-sequelize/commit/4c41bd765f156234053634e98df59c779c8ecd0e))
14
+
15
+ ## [8.4.6](https://github.com/ForestAdmin/forest-express-sequelize/compare/v8.4.5...v8.4.6) (2021-10-25)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **smart-actions:** skip scope validation for smart action on smart collection ([#865](https://github.com/ForestAdmin/forest-express-sequelize/issues/865)) ([785511b](https://github.com/ForestAdmin/forest-express-sequelize/commit/785511bfbc07ec3d0d72f74dd5444ff65447bc2b))
21
+
22
+ ## [8.4.5](https://github.com/ForestAdmin/forest-express-sequelize/compare/v8.4.4...v8.4.5) (2021-10-21)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * nested include duplication in smart field search ([#863](https://github.com/ForestAdmin/forest-express-sequelize/issues/863)) ([d61da0c](https://github.com/ForestAdmin/forest-express-sequelize/commit/d61da0c2b9dbf337e26ac1f2d816855787023afe))
28
+
1
29
  ## [8.4.4](https://github.com/ForestAdmin/forest-express-sequelize/compare/v8.4.3...v8.4.4) (2021-10-20)
2
30
 
3
31
 
@@ -119,7 +119,7 @@ function SearchBuilder(model, opts, params, fieldNamesRequested) {
119
119
  try {
120
120
  await field.search(query, params.search);
121
121
  } catch (error) {
122
- const errorMessage = `Cannot search properly on Smart Field ${field.field}`;
122
+ const errorMessage = `Cannot search properly on Smart Field ${field.field}: `;
123
123
  Interface.logger.error(errorMessage, error);
124
124
  }
125
125
 
@@ -156,8 +156,9 @@ function removeDuplicateAssociations(model, includeList) {
156
156
 
157
157
 
158
158
  includeList.forEach(function (include) {
159
- if (include.include) {
160
- const association = model.associations[include.as];
159
+ const association = model.associations[include.as];
160
+
161
+ if (include.include && association) {
161
162
  removeDuplicateAssociations(association.target, include.include);
162
163
  }
163
164
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "forest-express-sequelize",
3
3
  "description": "Official Express/Sequelize Liana for Forest",
4
- "version": "8.4.4",
4
+ "version": "8.4.8",
5
5
  "author": "Sandro Munda <sandro@munda.me>",
6
6
  "contributors": [
7
7
  "Arnaud Besnier <arnaudibesnier@gmail.com>",
@@ -28,7 +28,7 @@
28
28
  "@babel/runtime": "7.15.4",
29
29
  "bluebird": "2.9.25",
30
30
  "core-js": "3.6.5",
31
- "forest-express": "9.3.0",
31
+ "forest-express": "9.3.2",
32
32
  "http-errors": "1.6.1",
33
33
  "lodash": "4.17.21",
34
34
  "moment": "2.19.4",
@@ -57,7 +57,7 @@
57
57
  "eslint-plugin-import": "2.18.2",
58
58
  "eslint-plugin-jest": "23.0.4",
59
59
  "eslint-plugin-sonarjs": "0.5.0",
60
- "husky": "4.2.5",
60
+ "husky": "7.0.4",
61
61
  "jest": "26.6.3",
62
62
  "jest-extended": "0.11.5",
63
63
  "mysql2": "2.1.0",
@@ -76,6 +76,7 @@
76
76
  "build": "babel src --out-dir dist",
77
77
  "build:watch": "onchange 'src/**/*.js' 'node_modules/forest-express/dist/*' --no-exclude -i -- babel --source-maps inline --out-dir dist src",
78
78
  "lint": "./node_modules/eslint/bin/eslint.js .eslint-bin src test types/index.d.ts",
79
+ "prepare": "husky install",
79
80
  "test": "jest",
80
81
  "test:coverage": "jest --coverage"
81
82
  }
@@ -84,7 +84,7 @@ describe('services > query-options', () => {
84
84
 
85
85
  const options = new QueryOptions(model);
86
86
  await options.search('search string', null);
87
- expect(loggerErrorSpy).toHaveBeenCalledWith('Cannot search properly on Smart Field smartField', errorThrown);
87
+ expect(loggerErrorSpy).toHaveBeenCalledWith('Cannot search properly on Smart Field smartField: ', errorThrown);
88
88
 
89
89
  loggerErrorSpy.mockClear();
90
90
  resetSchema();
@@ -122,7 +122,7 @@ describe('services > query-options', () => {
122
122
 
123
123
  const options = new QueryOptions(model);
124
124
  await options.search('search string', null);
125
- expect(loggerErrorSpy).toHaveBeenCalledWith('Cannot search properly on Smart Field smartField', errorThrown);
125
+ expect(loggerErrorSpy).toHaveBeenCalledWith('Cannot search properly on Smart Field smartField: ', errorThrown);
126
126
 
127
127
  loggerErrorSpy.mockClear();
128
128
  resetSchema();
@@ -252,4 +252,26 @@ describe('utils > sequelize-compatibility', () => {
252
252
  });
253
253
  });
254
254
  });
255
+
256
+ describe('postProcess -> removeDuplicateAssociations', () => {
257
+ describe('when include alias is not valid', () => {
258
+ it('should not throw an error', () => {
259
+ expect.assertions(1);
260
+
261
+ const include = [{ model: SubModel, as: 'notAValidAlias', include: SubModel }];
262
+
263
+ expect(() => postProcess(Model, { include })).not.toThrow();
264
+ });
265
+ });
266
+
267
+ describe('when the main model is reincluded', () => {
268
+ it('should not throw an error', () => {
269
+ expect.assertions(1);
270
+
271
+ const include = [{ model: Model, include: SubSubModel1 }];
272
+
273
+ expect(() => postProcess(Model, { include })).not.toThrow();
274
+ });
275
+ });
276
+ });
255
277
  });
package/types/index.d.ts CHANGED
@@ -321,6 +321,7 @@ export interface CollectionOptions {
321
321
  fields?: SmartFieldOptions[];
322
322
  actions?: SmartActionOptions[];
323
323
  segments?: SmartSegmentOptions[];
324
+ searchFields?: string[];
324
325
  }
325
326
 
326
327
  export function collection(name: string, options: CollectionOptions): void;
package/husky.config.js DELETED
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- hooks: {
3
- 'pre-commit': 'node ./.eslint-bin/pre-commit-hook.js',
4
- 'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
5
- },
6
- };