forest-express-sequelize 8.5.0 → 8.5.3

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,24 @@
1
+ ## [8.5.3](https://github.com/ForestAdmin/forest-express-sequelize/compare/v8.5.2...v8.5.3) (2022-03-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * prevent deactivate count middleware to throw ([#924](https://github.com/ForestAdmin/forest-express-sequelize/issues/924)) ([9e4cc38](https://github.com/ForestAdmin/forest-express-sequelize/commit/9e4cc38e4962d2a58deefae4df59b9182e0a4795))
7
+
8
+ ## [8.5.2](https://github.com/ForestAdmin/forest-express-sequelize/compare/v8.5.1...v8.5.2) (2022-03-08)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **types:** serializers now take optional meta as second argument ([#922](https://github.com/ForestAdmin/forest-express-sequelize/issues/922)) ([f8c50cf](https://github.com/ForestAdmin/forest-express-sequelize/commit/f8c50cfac224a147015116fe093121b24ce38e1f))
14
+
15
+ ## [8.5.1](https://github.com/ForestAdmin/forest-express-sequelize/compare/v8.5.0...v8.5.1) (2022-03-02)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **count:** remove useless joins in basic count ([#900](https://github.com/ForestAdmin/forest-express-sequelize/issues/900)) ([86d30ef](https://github.com/ForestAdmin/forest-express-sequelize/commit/86d30ef2c74446de0f5e7e48d46c2f3d209a4c6b))
21
+
1
22
  # [8.5.0](https://github.com/ForestAdmin/forest-express-sequelize/compare/v8.4.10...v8.5.0) (2022-02-08)
2
23
 
3
24
 
@@ -67,7 +67,7 @@ function QueryBuilder() {
67
67
  return targetFields.includes(fieldName);
68
68
  });
69
69
 
70
- if (!fieldNamesRequested || fieldNamesRequested.includes(association.as) || explicitAttributes.length) {
70
+ if (fieldNamesRequested !== null && fieldNamesRequested !== void 0 && fieldNamesRequested.includes(association.as) || explicitAttributes.length) {
71
71
  // NOTICE: For performance reasons, we only request the keys
72
72
  // as they're the only needed fields for the interface
73
73
  const uniqueExplicitAttributes = uniqueValues([...getMandatoryFields(association), ...explicitAttributes].filter(Boolean));
@@ -107,16 +107,14 @@ class QueryOptions {
107
107
 
108
108
  get _sequelizeInclude() {
109
109
  const fields = [...this._requestedFields, ...this._requestedRelations, ...this._neededFields];
110
- const include = [...new _queryBuilder.default().getIncludes(this._model, fields.length ? fields : null), ...this._customerIncludes];
110
+ const include = [...new _queryBuilder.default().getIncludes(this._model, fields), ...this._customerIncludes];
111
111
  return include.length ? include : null;
112
112
  }
113
113
  /** Compute sequelize query `.order` property */
114
114
 
115
115
 
116
116
  get _sequelizeOrder() {
117
- var _this$_sequelizeInclu;
118
-
119
- if ((0, _database.isMSSQL)(this._model.sequelize) && (_this$_sequelizeInclu = this._sequelizeInclude) !== null && _this$_sequelizeInclu !== void 0 && _this$_sequelizeInclu.length) {
117
+ if ((0, _database.isMSSQL)(this._model.sequelize)) {
120
118
  // Work around sequelize bug: https://github.com/sequelize/sequelize/issues/11258
121
119
  const primaryKeys = Object.keys(this._model.primaryKeys);
122
120
  return this._order.filter(function (order) {
@@ -92,7 +92,8 @@ class ResourcesGetter {
92
92
  const scopeFilters = await _forestExpress.scopeManager.getScopeForUser(this._user, this._model.name, true);
93
93
  const requestedFields = (0, _requestedFieldsExtractor.default)(fields, this._model, _forestExpress.Schemas.schemas);
94
94
  const queryOptions = new _queryOptions.default(this._model, {
95
- tableAlias
95
+ tableAlias,
96
+ includeRelations: searchExtended
96
97
  });
97
98
  if (!forCount) await queryOptions.requireFields(requestedFields);
98
99
  await queryOptions.search(search, searchExtended);
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.5.0",
4
+ "version": "8.5.3",
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.4.0",
31
+ "forest-express": "9.4.1",
32
32
  "http-errors": "1.6.1",
33
33
  "lodash": "4.17.21",
34
34
  "moment": "2.19.4",
package/types/index.d.ts CHANGED
@@ -103,9 +103,14 @@ interface RecordsSerialized {
103
103
  included: Record<string, unknown>[],
104
104
  }
105
105
 
106
+ interface Meta {
107
+ count: number,
108
+ [k: string]: any,
109
+ }
110
+
106
111
  export class AbstractRecordTool<M extends Sequelize.Model> {
107
112
  constructor(model: Sequelize.ModelCtor<M>, user: User, query: Query)
108
- serialize(records: M | M[]): Promise<RecordsSerialized>;
113
+ serialize(records: M | M[], meta?: Meta): Promise<RecordsSerialized>;
109
114
  }
110
115
 
111
116
  export class RecordGetter<M extends Sequelize.Model> extends AbstractRecordTool<M> {
@@ -145,7 +150,7 @@ export class RecordsRemover<M extends Sequelize.Model> extends AbstractRecordToo
145
150
 
146
151
  export class RecordSerializer {
147
152
  constructor(model: { name: string } | Sequelize.ModelCtor<any>, user?: User, query?: Query);
148
- serialize(records: Record<string, any> | Record<string, any>[], meta: Record<string, any>): Promise<RecordsSerialized>;
153
+ serialize(records: Record<string, any> | Record<string, any>[], meta?: Meta): Promise<RecordsSerialized>;
149
154
  }
150
155
 
151
156
  // Everything related to Forest permissions