Commit Graph

84 Commits

Author SHA1 Message Date
dblythy
c6dcad8d16 feat: align file trigger syntax with class trigger; use the new syntax Parse.Cloud.beforeSave(Parse.File, (request) => {}), the old syntax Parse.Cloud.beforeSaveFile((request) => {}) has been deprecated (#7966) 2022-05-29 20:48:55 +02:00
dblythy
47d796ea58 fix: afterSave trigger removes pointer in Parse object (#7913) 2022-05-20 10:47:38 +02:00
dblythy
19900fcdf8 fix: return correct response when revert is used in beforeSave (#7839) 2022-05-01 02:39:56 +02:00
yog27ray
315290d161 feat: add Cloud Code context to ParseObject.fetch (#7779) 2022-01-25 12:40:22 +01:00
Corey
c789f6c979 refactor: test moved to correct test group (#7717) 2021-11-25 19:16:46 +01:00
Manuel
b64640c570 revert: refactor: allow ES import for cloud string if package type is module
This reverts commit 0225340ccb.
2021-11-10 16:26:20 +01:00
Kingtous
174886e385 fix: combined and query with relational query condition returns incorrect results (#7593) 2021-10-29 19:03:50 +02:00
dblythy
12eb6c823b refactor: replace hardcoded error codes with references (#7546) 2021-10-18 20:19:47 +02:00
dblythy
ab1dddd406 fix: add deprecation warning for Parse.Cloud.httpRequest (#7595) 2021-10-09 05:04:12 +02:00
dblythy
68a3a87501 fix: set objects in afterFind triggers (#7311) 2021-10-09 02:34:09 +02:00
dblythy
0225340ccb refactor: allow ES import for cloud string if package type is module (#7560)
* allow module import for Parse Cloud

* Update .babelrc

* catch esm error

* Update ParseServer.js

* add tests

* Update CHANGELOG.md

* Update CloudCode.spec.js

Co-authored-by: Manuel <5673677+mtrezza@users.noreply.github.com>
2021-09-14 14:10:37 +02:00
Corey
c8e822b958 Accept context via header X-Parse-Cloud-Context (#7437)
* failing testcase

* add header

* switch to X-Parse-Cloud-Context header

* add back blank line that lint removed

* test replacing context header with body context. Add support for setting body with json string

* add back blank line

* cover error when _context body is wrong

* Update middlewares.js

* revert accidental status change

* make sure context always decodes to an object else throw error

* improve context object check

Co-authored-by: Antonio Davi Macedo Coelho de Castro <adavimacedo@gmail.com>
2021-07-25 21:17:03 -07:00
Diamond Lewis
9563793303 Allow single server instance in test suite (#7262)
* initial pass

* reconfigureServer when needed

* finish postgres tests

* mongo tests

* more tests

* clean up

* re-add skipped test

* Fix transaction tests

* handle batch

* AuthenticationAdapter fix

* More reconfiguration

* clean up

* properly terminate cli servers

* handle Parse.Push

* Flaky PushController

* ensure reconfigureServer when changed

* fix postgres tests

* remove console.log

* LiveQuery spec remove duplicates and listeners
2021-03-13 09:05:22 -06:00
Antonio Davi Macedo Coelho de Castro
603cc1ffbc Fix error when a not yet inserted job is updated (#7196)
* Fix error when a not yet inserted job is updated

* Add entry to changelog

* revert the upsert change and fix the test

* Revert the change so job execute a single time

* Fix other tests with potential similar problem
2021-02-18 11:27:59 -08:00
Kartal Kaan Bozdoğan
7224cde023 fix: Pass customObjectId in beforeSave (#7167)
* beforeSave custom object id fix

* Added regression test case for issue #6733
2021-02-12 15:57:22 -06:00
dblythy
d47891f7e3 Send email via Parse.Cloud.sendEmail (#7096)
* initial

* more tests

* Update CHANGELOG.md

* review

* log on error

* change logger to error

* rename

* Update Parse.Cloud.js
2020-12-30 10:23:44 -06:00
dblythy
41a052c2c3 Fix: context for afterFind (#7078)
* Fix: context for afterFind

* Update CHANGELOG.md

Co-authored-by: Manuel <trezza.m@gmail.com>
2020-12-18 14:54:48 +01:00
Diamond Lewis
ca1b78220f Prevent invalid column names (className and length) (#7053)
* Prevent invalid column names

* remove className as invalid

* remove className from beforeSave hook response

* improve tests
2020-12-09 12:19:15 -06:00
Antonio Davi Macedo Coelho de Castro
54a61b7694 GitHub actions (#7035)
* Trying to setup GitHub Actions

* Try to fix the workflow steps

* Fix NODE_VERSION

* Fix services

* Fix services 2

* Fix redis service, remove docker service

* Missing npm install

* Fix Use Node.js step name

* Remove greenkeeper

* I believe we do not need this command

* Try to include postgres

* Fix postgres script

* Remove before install script

* Fix postgres before script

* Try to fix connection to postgres

* Fix postgress port

* Postgres host

* Still trying to connect on postgres

* Still trying to connect on postgres - localhost

* Split postgres in a separate job

* Add postgres healthcheck

* Set postgres just like github example

* Fix postgres scripts with new credentials

* Still trying to fix postgres connection

* Now it looks only the username is wrong

* Passing postgres password in the right way

* try to install postgis

* New attempt to install postgis

* Fix postgis image name

* Try to output tests

* We need to start mongo

* Increase tests timeout

* Fix flaky test

* Add GitHub Actions badge

* Badge as html

* Fix badge link

* Remove Travis

* try to fix coverage

* Fix flaky test

* Improve ci workflow

* Change the mongo default test version

* Fix the job name in the if clause

* Ubuntu18.0.4

* Downgrade to 4.0.21

* Fix cache keys:

* Trying with mongo 4.0.4

* Rever os and mongo versions

* remove latest node
2020-12-03 08:15:48 -08:00
Diamond Lewis
c1971b2ab1 fix(beforeSave/afterSave): Return value instead of Parse.Op for nested fields (#7005)
* fix(beforeSave): Return value instead of Parse.Op

* afterSave test

* Improve Tests

* Fixed postgres test by saveArgumentsByValue
2020-11-12 13:14:44 -08:00
Diamond Lewis
a4c84c09be fix(beforeSave): Skip Sanitizing Database results (#7003)
* fix(beforeSave): Skip Sanitizing Database results

* fix test
2020-11-11 17:39:25 -08:00
dblythy
6fc3afce71 skipWithMasterKey on Built-In Validator (#6972)
* Initial Commit

* Change to resolveMasterKey

* Change to skipWithMasterKey
2020-10-26 12:49:30 -07:00
Diamond Lewis
74ba81104e Remove unused parameter in Cloud Function (#6969) 2020-10-25 22:41:23 -05:00
Diamond Lewis
e6ac3b6932 fix(prettier): Properly handle lint-stage files (#6970)
Now handles top level files and recursive files in folders.

Set max line length to be 100
2020-10-25 15:06:58 -05:00
dblythy
c2f2281e6d Validation Handler Update (#6968)
* Initial Commit

* Update FunctionsRouter.js

* Update FunctionsRouter.js

* Change params to fields

* Changes requested

* Fix failing tests

* More tests

* More tests

* Remove existing functionality

* Remove legacy tests

* fix array typo

* Update triggers.js

* Docs

* Allow requireUserKeys to be object

* validateMasterKey

* Improve documentation

Co-authored-by: Diamond Lewis <findlewis@gmail.com>
2020-10-25 12:36:54 -05:00
dblythy
68a1b30275 Show a message if cloud functions are duplicated (#6963)
* Update triggers.js

* Update CloudCode.spec.js

* Logger changes

* Update CloudCode.spec.js
2020-10-22 20:06:25 -05:00
dblythy
c68d05512f Pass request.query to afterFind (#6960)
* Initial Commit

* Update triggers.js
2020-10-21 21:40:40 -05:00
Diamond Lewis
72428dce0f fix(jobs): Add Error Message to JobStatus Failure (#6954) 2020-10-20 14:55:24 -07:00
Antoine Cormouls
62048260c9 GraphQL: Optimize queries, fixes some null returns (on object), fix stitched GraphQLUpload (#6709)
* Optimize query, fixes some null returns, fix stitched GraphQLUpload

* Fix authData key selection

* Prefer Iso string since other GraphQL solutions use this format

* fix tests

Co-authored-by: Antonio Davi Macedo Coelho de Castro <adavimacedo@gmail.com>
2020-10-01 15:19:26 -07:00
yog27ray
34614e0f78 Pass context in beforeDelete, afterDelete, beforeFind and Parse.Cloud.run. (#6666)
* add context for following hooks.
1. beforeDelete
2. afterDelete
3. beforeFind
4. Cloud Function

* revert un-necessary code change.

* fix: failing test cases.

* fix: failing test cases.

* fix: failing test cases.

* fix: failing test cases.

* fix: failing test cases.

* fix: failing test cases.

* fix: failing test cases.

* review changes

* revert changes

* revert changes

* review changes

* lint changes

* review changes
2020-07-10 22:47:27 +02:00
Manuel
f095dffcc3 fix context for cascade-saving and saving existing object (#6735)
* added test cases

* fixed unparsed context when updating object

* fixed context inheritance for cascade-saved objects

* upgraded parse dependecy to 2.14.0

* rebuild

* removed superfluous comments

* undo lint changes
2020-07-02 14:37:41 -05:00
Manuel
288e746888 add context to Parse.Object.save (#6626)
* added failing test

* added parsing of context in REST save request

* undo lint changes
2020-04-28 11:36:46 -07:00
stevestencil
a9dba442b1 Add file triggers and file meta data (#6344)
* added hint to aggregate

* added support for hint in query

* added else clause to aggregate

* fixed tests

* updated tests

* Add tests and clean up

* added beforeSaveFile and afterSaveFile triggers

* Add support for explain

* added some validation

* added support for metadata and tags

* tests?

* trying tests

* added tests

* fixed failing tests

* added some docs for fileObject

* updated hooks to use Parse.File

* added test for already saved file being returned in hook

* added beforeDeleteFile and afterDeleteFile hooks

* removed contentLength because it's already in the header

* added fileSize param to FileTriggerRequest

* added support for client side metadata and tags

* removed fit test

* removed unused import

* added loging to file triggers

* updated error message

* updated error message

* fixed tests

* fixed typos

* Update package.json

* fixed failing test

* fixed error message

* fixed failing tests (hopefully)

* TESTS!!!

* Update FilesAdapter.js

fixed comment

* added test for changing file name

* updated comments

Co-authored-by: Diamond Lewis <findlewis@gmail.com>
2020-04-02 16:00:15 -05:00
David Corona
09a1dca5e3 Add new afterLogin cloud code hook (#6387)
* add new afterLogin cloud code hook

* include user on req.user for afterLogin hook
2020-02-11 17:38:14 -06:00
Diamond Lewis
2f05d819f3 beforeFind: Improve request.query object (#6237)
* beforeFind: Improve request.query object

Closes: https://github.com/parse-community/parse-server/issues/6164

* can modify exclude query
2019-11-23 11:38:13 -06:00
Manuel Trezza
5ed0885440 added afterLogout trigger (#6217)
* added afterLogout trigger

* added verification of session object in tests

* removed obsolete code

* removed unsued code

* improved tests to verify user ID
2019-11-15 21:52:57 -06:00
Diamond Lewis
095164babd Prevent afterFind with saving objects (#6127)
Fixes: https://github.com/parse-community/parse-server/issues/6088
2019-10-15 15:50:25 -05:00
Antonio Davi Macedo Coelho de Castro
3ede1f68b2 Fix beforeLogin trigger when user has a file (#6001)
* Fix beforeLogin trigger when user has a file

* Add test case
2019-08-29 19:07:39 -07:00
Antonio Davi Macedo Coelho de Castro
893f1d376e Remove test delays (#5579)
* Changing __indexBuildCompletionCallbackForTests callback to serverStartComplete

* Improving serverStartComplete callback to avoid production unhandled promise rejection

* Add test to check inexistence of unhandled promise rejection on server fail

* Removing some hooks delays

* Removing delay after reconfigureServer

* Improving code style
2019-05-14 11:34:51 -07:00
Antonio Davi Macedo Coelho de Castro
90c81c1750 Validates permission before calling beforeSave trigger (#5546)
* Test to reproduce the problem

* Validating update before calling beforeSave trigger

* Fixing lint

* Commenting code

* Improving the code
2019-05-11 10:37:27 -07:00
Omair Vaiyani
a1e1cef6d2 Add beforeLogin trigger with support for auth providers (#5445)
* Add beforeLogin trigger with support for auth providers

* adjust comment that boxed off beforeLogin to a negative use-case only

* add internal error to help future maintainers regarding use of beforeLogin

* let beforeLogin accept className or constructor like other hook types

* add assertions for beforeLogin trigger className validation
2019-04-23 08:24:20 -07:00
Guido Ruiz
bf033becbd Properly handle return values in beforeSave (#5228)
* added failing test case to CloudCode.spec.js

a possible bug found where beforeSave does not apply changes to request
object if the beforeSave hook ends with 'true' returned

* moddified triggers to return null when beforeSave
also changed test cases to be more descriptive + added extra test case that returns promise in the beforeSave

* address original issue

* Revert "address original issue"

This reverts commit e01c57d1de5c4b2fe21e9ebd590211d21330cdda.

* fix promises and tests

* Add a test to verify that a failed beforeChange hook will
prevent updating the object.
2019-03-14 13:17:29 -05:00
Florent Vilmart
7c81290252 Live query CLP (#4387)
* Auth module refactoring in order to be reusable

* Ensure cache controller is properly forwarded from helpers

* Nits

* Adds support for static validation

* Adds support for CLP in Live query (no support for roles yet)

* Adds e2e test to validate liveQuery hooks is properly called

* Adds tests over LiveQueryController to ensure data is correctly transmitted

* nits

* Fixes for flow types

* Removes usage of Parse.Promise

* Use the Auth module for authentication and caches

* Cleaner implementation of getting auth

* Adds authCache that stores auth promises

* Proper testing of the caching

* nits
2018-10-17 17:53:49 -04:00
Florent Vilmart
045d941aef Remove request and request-promise from dev dependencies (#5077)
* removes from emailverificationtoken spec

* updates winston

* Updates ValidationAndPasswordsReset

* Use local request in schemas

* Removes request in rest.spec

* Removes request from PushRouter0

* removes request from public API

* removes request from index.spec

* Removes request form parse.push spec

* removes request from ParseInstallation spec

* Removes from ParseHooks

* removes request from ParseGlobalConfig.spec

* Removes request from ParseAPI.spec.js

* removes request from LogsRouter

* removes in features

* Filters undefined headers instead of crashing

* Removes request from ParseUser spec

* Removes usage of request in ParseFile.spec.js

* Removes request from AuthAdapters.js

* removes request-promise from ParseGeoPoint.spec

* Removes request-promise from ParseQuery spec

* remove request-promise from UserPII

* removes request-promise from EnableExpressErrorHandler

* Updates RevocableSessionUpgrade spec

* Update RestQuery

* Removes read preferenceOptionM

* ensure we forward auth from URL

* use request in CloudCode.spec.js

* Removes request-promise from JobSchedule.spec

* Removes rp from VerifyUserPassword.spec.js

* Removes rp from PasswordPolicy spec

* Removes rp from ParsePolygon spec

* Removes rp from fullTextSearch spec

* Removes rp from PArseQuery.Aggregate

* Ensure we properly forward errors

* Removes request and request-promise
2018-09-24 17:07:51 -04:00
Florent Vilmart
576779b69b Updates JS SDK to 2.1.0 (#5043) 2018-09-08 20:05:32 -04:00
Florent Vilmart
d83a0b6808 Use Prettier JS (#5017)
* Adds prettier

* Run lint before tests
2018-09-01 13:58:06 -04:00
Florent Vilmart
457d51a972 Adds context object in Cloud Code hooks (#4939)
* wip

* Refactors triggers a bit

- Adds testing for hooks and context

* comment nit

* nits
2018-08-15 10:47:21 -04:00
Florent Vilmart
488b2ff231 Migrate to new cloud code interfaces
removes job status object, moves messasge method on req object

Adds 3.0.0 migration guide

Fixes nits about 3.0.0 documentation

Adds update guide to README
2018-08-15 10:47:21 -04:00
Florent Vilmart
2ae603574c Auth module refactoring in order to be reusable (#4940)
* Auth module refactoring in order to be reusable

* Ensure cache controller is properly forwarded from helpers

* Nits
2018-08-09 13:02:06 -04:00
Florent Vilmart
ff25ae254d Update parse SDK to 2.0.0 (#4925)
* WIP: Integrate JS SDK v2

- Removes backbone style callbacks
- Use Promise instead of Parse.Promise

* Fixes ParseObject and ParseRelation

* Updates Parse.Query with promises

* Alls tests should pass

* Ensure a fresh user is used for each test

* Use REST implementation to avoid side effects for username/email duplicates

* Uses js sdk v2
2018-08-05 13:58:07 -04:00