diff --git a/CHANGELOG.md b/CHANGELOG.md index 0229d25604..38cd9fa871 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ ___ - NEW: Supporting patterns in LiveQuery server's config parameter `classNames` [#7131](https://github.com/parse-community/parse-server/pull/7131). Thanks to [Nes-si](https://github.com/Nes-si) - NEW: `requireAnyUserRoles` and `requireAllUserRoles` for Parse Cloud validator. [#7097](https://github.com/parse-community/parse-server/pull/7097). Thanks to [dblythy](https://github.com/dblythy) - NEW: Support Facebook Limited Login [#7219](https://github.com/parse-community/parse-server/pull/7219). Thanks to [miguel-s](https://github.com/miguel-s) +- IMPROVE: Removed Stage name check on aggregate pipelines [#7237](https://github.com/parse-community/parse-server/pull/7237). Thanks to [BRETT71](https://github.com/BRETT71) - IMPROVE: Retry transactions on MongoDB when it fails due to transient error [#7187](https://github.com/parse-community/parse-server/pull/7187). Thanks to [Antonio Davi Macedo Coelho de Castro](https://github.com/davimacedo). - IMPROVE: Bump tests to use Mongo 4.4.4 [#7184](https://github.com/parse-community/parse-server/pull/7184). Thanks to [Antonio Davi Macedo Coelho de Castro](https://github.com/davimacedo). - IMPROVE: Added new account lockout policy option `accountLockout.unlockOnPasswordReset` to automatically unlock account on password reset. [#7146](https://github.com/parse-community/parse-server/pull/7146). Thanks to [Manuel Trezza](https://github.com/mtrezza). diff --git a/spec/AggregateRouter.spec.js b/spec/AggregateRouter.spec.js index 665c51e8c1..aaedd11aa7 100644 --- a/spec/AggregateRouter.spec.js +++ b/spec/AggregateRouter.spec.js @@ -74,4 +74,15 @@ describe('AggregateRouter', () => { expect(e.message).toBe('Pipeline stages should only have one key found group, match'); } }); + + it('get search pipeline from Pipeline Operator (Array)', () => { + const body = { + pipeline: { + search: {}, + }, + }; + const expected = [{ $search: {} }]; + const result = AggregateRouter.getPipeline(body); + expect(result).toEqual(expected); + }); }); diff --git a/spec/ParseQuery.Aggregate.spec.js b/spec/ParseQuery.Aggregate.spec.js index 598ed51a38..60b04b1fad 100644 --- a/spec/ParseQuery.Aggregate.spec.js +++ b/spec/ParseQuery.Aggregate.spec.js @@ -83,18 +83,6 @@ describe('Parse.Query Aggregate testing', () => { ); }); - it('invalid query invalid key', done => { - const options = Object.assign({}, masterKeyOptions, { - body: { - unknown: {}, - }, - }); - get(Parse.serverURL + '/aggregate/TestObject', options).catch(error => { - expect(error.error.code).toEqual(Parse.Error.INVALID_QUERY); - done(); - }); - }); - it('invalid query group _id', done => { const options = Object.assign({}, masterKeyOptions, { body: { diff --git a/src/Routers/AggregateRouter.js b/src/Routers/AggregateRouter.js index b994f5a6cc..2faa9e4c41 100644 --- a/src/Routers/AggregateRouter.js +++ b/src/Routers/AggregateRouter.js @@ -4,38 +4,6 @@ import * as middleware from '../middlewares'; import Parse from 'parse/node'; import UsersRouter from './UsersRouter'; -const BASE_KEYS = ['where', 'distinct', 'pipeline', 'hint', 'explain']; - -const PIPELINE_KEYS = [ - 'addFields', - 'bucket', - 'bucketAuto', - 'collStats', - 'count', - 'currentOp', - 'facet', - 'geoNear', - 'graphLookup', - 'group', - 'indexStats', - 'limit', - 'listLocalSessions', - 'listSessions', - 'lookup', - 'match', - 'out', - 'project', - 'redact', - 'replaceRoot', - 'sample', - 'skip', - 'sort', - 'sortByCount', - 'unwind', -]; - -const ALLOWED_KEYS = [...BASE_KEYS, ...PIPELINE_KEYS]; - export class AggregateRouter extends ClassesRouter { handleFind(req) { const body = Object.assign(req.body, ClassesRouter.JSONFromQuery(req.query)); @@ -122,9 +90,6 @@ export class AggregateRouter extends ClassesRouter { } static transformStage(stageName, stage) { - if (ALLOWED_KEYS.indexOf(stageName) === -1) { - throw new Parse.Error(Parse.Error.INVALID_QUERY, `Invalid parameter for query: ${stageName}`); - } if (stageName === 'group') { if (Object.prototype.hasOwnProperty.call(stage[stageName], '_id')) { throw new Parse.Error(