forest-express-sequelize 9.0.0-beta.3 → 9.0.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 +28 -0
- package/dist/services/query-stat-getter.js +7 -9
- package/package.json +2 -2
- package/test/databases.test.js +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
# [9.0.0](https://github.com/ForestAdmin/forest-express-sequelize/compare/v8.5.14...v9.0.0) (2022-11-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **chart:** improve security on chart and rename charts' properties ([#1027](https://github.com/ForestAdmin/forest-express-sequelize/issues/1027)) ([2e4c54e](https://github.com/ForestAdmin/forest-express-sequelize/commit/2e4c54e4b66295451e97c873b3cfa3043e1864e3))
|
|
7
|
+
* **security:** validate that smart action approvals are launched with the same parameters than the initial trigger ([#1026](https://github.com/ForestAdmin/forest-express-sequelize/issues/1026)) ([928865e](https://github.com/ForestAdmin/forest-express-sequelize/commit/928865e9299d1ef9680e9b33ce33ecd8f4c9d077))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **chart:** add support for context variables inside SQL query ([#1028](https://github.com/ForestAdmin/forest-express-sequelize/issues/1028)) ([6bf678e](https://github.com/ForestAdmin/forest-express-sequelize/commit/6bf678ead766a202908c0bf8f5376e9c45d9ef6f))
|
|
13
|
+
* **chart:** add support for context variables used by Workspaces ([#1029](https://github.com/ForestAdmin/forest-express-sequelize/issues/1029)) ([dc3009a](https://github.com/ForestAdmin/forest-express-sequelize/commit/dc3009acf395292cf28a8d7b481d36f78bb9d829))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### BREAKING CHANGES
|
|
17
|
+
|
|
18
|
+
* **security:** drop support of projects that are not using roles
|
|
19
|
+
|
|
20
|
+
Co-authored-by: Guillaume Gautreau <guillaumeg@forestadmin.com>, Morgan Perre <morganperre@gmail.com>
|
|
21
|
+
|
|
22
|
+
# [9.0.0-beta.4](https://github.com/ForestAdmin/forest-express-sequelize/compare/v9.0.0-beta.3...v9.0.0-beta.4) (2022-11-09)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **chart:** add support for context variables inside SQL query ([#1028](https://github.com/ForestAdmin/forest-express-sequelize/issues/1028)) ([6bf678e](https://github.com/ForestAdmin/forest-express-sequelize/commit/6bf678ead766a202908c0bf8f5376e9c45d9ef6f))
|
|
28
|
+
|
|
1
29
|
# [9.0.0-beta.3](https://github.com/ForestAdmin/forest-express-sequelize/compare/v9.0.0-beta.2...v9.0.0-beta.3) (2022-11-02)
|
|
2
30
|
|
|
3
31
|
|
|
@@ -6,23 +6,21 @@ require("core-js/modules/es.regexp.exec.js");
|
|
|
6
6
|
|
|
7
7
|
require("core-js/modules/es.string.replace.js");
|
|
8
8
|
|
|
9
|
-
require("core-js/modules/es.regexp.constructor.js");
|
|
10
|
-
|
|
11
9
|
function QueryStatGetter(params, opts) {
|
|
12
|
-
const QUERY_OPTIONS_SELECT = {
|
|
13
|
-
type: opts.Sequelize.QueryTypes.SELECT
|
|
14
|
-
};
|
|
15
|
-
|
|
16
10
|
this.perform = function perform() {
|
|
17
11
|
let rawQuery = params.query.trim();
|
|
12
|
+
const bind = params.contextVariables || {};
|
|
18
13
|
|
|
19
|
-
if (
|
|
20
|
-
rawQuery = rawQuery.replace(
|
|
14
|
+
if (bind.recordId && !rawQuery.includes('$recordId')) {
|
|
15
|
+
rawQuery = rawQuery.replace(/\?/g, '$recordId');
|
|
21
16
|
} // WARNING: Choosing the first connection might generate issues if the model
|
|
22
17
|
// does not belongs to this database.
|
|
23
18
|
|
|
24
19
|
|
|
25
|
-
return Object.values(opts.connections)[0].query(rawQuery,
|
|
20
|
+
return Object.values(opts.connections)[0].query(rawQuery, {
|
|
21
|
+
type: opts.Sequelize.QueryTypes.SELECT,
|
|
22
|
+
bind
|
|
23
|
+
});
|
|
26
24
|
};
|
|
27
25
|
}
|
|
28
26
|
|
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": "9.0.0
|
|
4
|
+
"version": "9.0.0",
|
|
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": "10.0.0
|
|
31
|
+
"forest-express": "10.0.0",
|
|
32
32
|
"http-errors": "1.6.1",
|
|
33
33
|
"lodash": "4.17.21",
|
|
34
34
|
"moment": "2.29.4",
|
package/test/databases.test.js
CHANGED
|
@@ -17,6 +17,7 @@ const BelongsToUpdater = require('../src/services/belongs-to-updater');
|
|
|
17
17
|
const ResourceRemover = require('../src/services/resource-remover');
|
|
18
18
|
const HasManyGetter = require('../src/services/has-many-getter');
|
|
19
19
|
const HasManyDissociator = require('../src/services/has-many-dissociator');
|
|
20
|
+
const QueryStatGetter = require('../src/services/query-stat-getter');
|
|
20
21
|
|
|
21
22
|
const baseParams = { timezone: 'Europe/Paris' };
|
|
22
23
|
const user = { renderingId: 1 };
|
|
@@ -798,6 +799,28 @@ const user = { renderingId: 1 };
|
|
|
798
799
|
});
|
|
799
800
|
});
|
|
800
801
|
|
|
802
|
+
describe('stats > query stat getter', () => {
|
|
803
|
+
it('should give correct answer with recordId filtering', async () => {
|
|
804
|
+
expect.assertions(2);
|
|
805
|
+
const { options } = initializeSequelize();
|
|
806
|
+
|
|
807
|
+
try {
|
|
808
|
+
const contextVariables = { recordId: 102 };
|
|
809
|
+
// eslint-disable-next-line jest/no-if
|
|
810
|
+
const escapeQuote = connectionManager === sequelizePostgres ? '"' : '`';
|
|
811
|
+
const stat = await new QueryStatGetter({
|
|
812
|
+
contextVariables,
|
|
813
|
+
query: `SELECT count(*) as value FROM ${escapeQuote}users${escapeQuote} WHERE ${escapeQuote}primaryId${escapeQuote} != ?`,
|
|
814
|
+
}, options).perform();
|
|
815
|
+
|
|
816
|
+
expect(stat).toHaveLength(1);
|
|
817
|
+
expect(`${stat[0].value}`).toStrictEqual('2');
|
|
818
|
+
} finally {
|
|
819
|
+
connectionManager.closeConnection();
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
});
|
|
823
|
+
|
|
801
824
|
describe('resources > resources creator', () => {
|
|
802
825
|
describe('create a record on a simple collection', () => {
|
|
803
826
|
it('should create a record', async () => {
|