Commit Graph

21 Commits

Author SHA1 Message Date
Arthur Cinader
4cb6e7d209 Add lint rule space-infix-ops (#3237)
Disallows: 1+1.  Must be 1 + 1.
2017-01-11 12:31:40 -08:00
Arthur Cinader
ca286b7108 Enable prefer-const lint rule (#3202) 2016-12-07 18:17:05 -05:00
Arthur Cinader
7292fa7f11 Allow select (keys) to be altered in triggers (#3146)
Inspect the keys when a query is returned from a trigger and respect the new
value.
2016-12-01 10:04:47 -05:00
Florent Vilmart
8c2c76dd26 Adds liniting into the workflow (#3082)
* initial linting of src

* fix indent to 2 spaces

* Removes unnecessary rules

* ignore spec folder for now

* Spec linting

* Fix spec indent

* nits

* nits

* no no-empty rule
2016-11-24 15:47:41 -05:00
jb
19271fa1ef Adding support for AfterFind (#2968) 2016-11-12 12:35:34 -05:00
Florent Vilmart
3ba6e613b3 Adds repro for #1931 (#2735) 2016-09-24 13:53:04 -04:00
Florent Vilmart
263ca5e052 Adds CloudCode handler for beforeFind (#2715)
* Adds CloudCode handler for beforeFind

- Allows cloud code to modify a query before it is run
- Works with promises for a safer environment
- Supports modifiying the current query
- Supports issuing new queries

* Adds test for cornercase empty queries from rest

* Makes sure restOptions is always definied
2016-09-17 13:52:35 -07:00
Florent Vilmart
364604e181 Run Schema validations after beforeSave #2672 (#2677)
* Adds test to repro #2672

* Run schema validation after beforeSave is run

* Makes authData part of base _User object

* exclude flaky pg test
2016-09-09 14:41:03 -04:00
Florent Vilmart
10ace495d8 Adds jobs endpoint protected by masterKey (#2560)
* Adds jobs endpoint protected by masterKey

* Adds connection timeout for 15 minutes in jobs

* Refactors pushStatusHandler into StatusHandler

* Adds reporting of _JobStatus

* Only accept strings as messages

* Adds test for masterKey basic auth

* Adds CloudCodeRouter for cloud_code endpoint of job status, enable Jobs feature on dashboard

* xit racing test
2016-08-30 07:19:21 -04:00
Arthur Cinader
5f67caefde Make parse-server cloud code logging closer parse.com legacy (#2550)
* Make parse-server cloud code logging much to parse.com legacy. (fixes #2501)

1. More closely mimic the wording.  Include the user id.

2. Truncate input and result at 1k char.

3. Use more sensible metadata that would makes sense to index.  The guideline I used was: if it makes sense to filter on, put it in metadata.  If it makes sense to "free text" search on, then put it in the message.

  - file and console output, logging an object does not do what on might expect.  For example, logging a function's "params":

  ```
  expected:

    info: Ran cloud function aFunction for user qWHLVEsbEe with:
      Input: {"foo":"bar","bar":"baz"}
      Result: "it worked!" functionName=aFunction, params= { foo: "bar", "bar": baz }, user=qWHLVEsbEe

  what you actually get:

    info: Ran cloud function aFunction for user qWHLVEsbEe with:
      Input: {"foo":"bar","bar":"baz"}
      Result: "it worked!" functionName=aFunction, foo=bar, bar=baz, user=qWHLVEsbEe
  ```
  - logging highly variable metadata is pretty useless for indexing when logs are sent to a logging repository like elastic search.  In that use case, you want to index stuff you expect to filter on like user, hook type.

  - finally, putting the same input and result data in both the metadata and the message makes each message much larger with no additional value (that I know of anyway :).

4. Change some of the naming of functions in trigger.js to make future work easier.  I was confused about why there were three logging functions in trigger and it took me awhile to get that before hooks and after hooks are logged differently.  I just changed the names to make it obvious at first glance.

5. Add some try/catches to help any future futzers  see syntax errors, etc instead of just hanging.

Some log examples from unit test output:

```
info: Ran cloud function loggerTest for user YUD2os1i5B with:
  Input: {}
  Result: {} functionName=loggerTest, user=YUD2os1i5B

info: beforeSave triggered for MyObject for user nssehQ3wtz:
  Input: {}
  Result: {} className=MyObject, triggerType=beforeSave, user=nssehQ3wtz

info: afterSave triggered for MyObject for user XdznQgTD0p:
  Input: {"createdAt":"2016-08-19T01:11:31.249Z","updatedAt":"2016-08-19T01:11:31.249Z","objectId":"POoOOLL89U"} className=MyObject, triggerType=afterSave, user=XdznQgTD0p

error: beforeSave failed for MyObject for user 7JHqCZgnhf:
  Input: {}
  Error: {"code":141,"message":"uh oh!"} className=MyObject, triggerType=beforeSave, code=141, message=uh oh!, user=7JHqCZgnhf

info: Ran cloud function aFunction for user YR3nOoT3r9 with:
  Input: {"foo":"bar"}
  Result: "it worked!" functionName=aFunction, user=YR3nOoT3r9

error: Failed running cloud function aFunction for user Xm6NpOyuMC with:
  Input: {"foo":"bar"}
  Error: {"code":141,"message":"it failed!"} functionName=aFunction, code=141, message=it failed!, user=Xm6NpOyuMC

info: Ran cloud function aFunction for user CK1lvkmaLg with:
  Input: {"longString":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lobortis semper diam, ac euismod diam pharetra sed. Etiam eget efficitur neque. Proin nec diam mi. Sed ut purus dolor. Nulla nulla nibh, ornare vitae ornare et, scelerisque rutrum eros. Mauris venenatis tincidunt turpis a mollis. Donec gravida eget enim in luctus.\n\nSed porttitor commodo orci, ut pretium eros convallis eget. Curabitur pretium velit in odio dictum luctus. Vivamus ac tristique arcu, a semper tellus. Morbi euismod purus dapibus vestibulum sagittis. Nunc dapibus vehicula leo at scelerisque. Donec porta mauris quis nulla imperdiet consectetur. Curabitur sagittis eleifend arcu eget elementum. Aenean interdum tincidunt ornare. Pellentesque sit amet interdum tortor. Pellentesque blandit nisl eget euismod consequat. Etiam feugiat felis sit amet porta pulvinar. Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n\nNulla faucibus sem ipsum, at rhoncus diam pulvinar at. Vivamus consectetur, diam... (truncated)
  Result: {"longString":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lobortis semper diam, ac euismod diam pharetra sed. Etiam eget efficitur neque. Proin nec diam mi. Sed ut purus dolor. Nulla nulla nibh, ornare vitae ornare et, scelerisque rutrum eros. Mauris venenatis tincidunt turpis a mollis. Donec gravida eget enim in luctus.\n\nSed porttitor commodo orci, ut pretium eros convallis eget. Curabitur pretium velit in odio dictum luctus. Vivamus ac tristique arcu, a semper tellus. Morbi euismod purus dapibus vestibulum sagittis. Nunc dapibus vehicula leo at scelerisque. Donec porta mauris quis nulla imperdiet consectetur. Curabitur sagittis eleifend arcu eget elementum. Aenean interdum tincidunt ornare. Pellentesque sit amet interdum tortor. Pellentesque blandit nisl eget euismod consequat. Etiam feugiat felis sit amet porta pulvinar. Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n\nNulla faucibus sem ipsum, at rhoncus diam pulvinar at. Vivamus consectetur, diam... (truncated) functionName=aFunction, user=CK1lvkmaLg
```

* Implement PR comments:
- add back params to metadata and add back to the test
- use screaming snake case for conts

* fix typo
2016-08-19 16:39:51 -04:00
Marko Matić
3164b478ea Syncing afterSave/afterDelete trigger calls (Issue #2489) (#2499)
* Implemented syncing afterSave/afterDelete trigger calls with REST request execution flow (Issue 2489). After this change, afterSave and afterDelete triggers CAN return a promise, which needs to be resolved inside a trigger for REST request flow to continue. If trigger doesn't return a promise, request flow continues.

* Added {} to multiline if.

* Fixed bad commit.

* Fixed problem with beforeSave triggers becoming async.
2016-08-17 09:26:42 -04:00
Florent Vilmart
c0249283ac Advancements with postgres (#2510)
* Start DB runner from tests

* Connect GridstoreAdapter only when needed

* removes unused package

* better test errors reporting

* Adds support for __op.Delete

* Better test error reporting

* Makes sure all tests can run without crashing

* Use xdescribe to skip test suite

* Removes unused dependencies

* Let volatiles classes be created with PG on start

* Do not fail if class dont exist

* adds index.spec.js to the pg suite

* Use a new config each test to prevent side effects

* Enable EmailVerificationToken specs with pg

* Makes sure failure output is not cut

* Reduces number of ignored tests in ParseObject.spec

* Inspect reconfiguration errors

* Mark GlobalConfig is incompatible with PG

- Problem is with nested updates (param.prop = value)

* PG: Nested JSON queries and updates

- Adds support for nested json and . operator queries
- Adds debug support for PG adapter
- Adds loglevel support in helper

* Enable working specs in ParseUser

* Sets default logLevel in tests to undefined

* Adds File type support, retores purchaseValidation specs

* Adds support for updating jsonb objects

- Restores PushController tests

* Proper implementation of deleteByQuery and ORs

- Adds ParseInstallation spec to the test suite

* xit only failing tests

* Nit on ParseAPI spec

* add sorting operator

* properly bound order keys

* reverts describe_only_db behavior

* Enables passing tests

* Adds basic support for relations, upsertOneObject aliased to createObject

* progress on queries options

* Fix ACL update related problems

* Creates relation tables on class creation

* Adds Relation tests

* remove flaky tests

* use promises instead of CB

* disable flaky test

* nits

* Fixes on schema spec

- Next thing is to implemenet geopoint and files correctly

* fix failues

* Basic GeoPoint support

* Adds support for $nearSphere/$maxDistance geopoint queries

* enable passing tests

* drop tables afterEach for PG, clean up relation tables too

* Better initialization/dropTables
2016-08-15 16:48:39 -04:00
sud
e4c2e65263 Non trivial before save pointer clobber (#2406)
* test case to check beforeSave changes clobbers fetched pointer fields
Basically if beforeSave makes any changes to the object it is trying to save, the fetched pointer fields on the client gets clobbered to only pointer.

* propogate only changed fields to response.
Earlier we were returning all fields even if any changes happened in beforeSave. This causes the fetched pointer fields on the client to get clobbered to only pointers.
This fix returns only the changed fields thus avoiding pointer clobber.

* The goal of this comparision seems to be checking that the all returns the user correctly.
Also it is consistent with the hosted parse that user.username not returned from PUT request.
2016-08-05 08:53:54 -04:00
Florent Vilmart
8719afdc1b Parses correctly Parse.Files and Dates when sent to Cloud Code Functions (#2297)
* fix for #2294

* fail tests

* Makes sure dates are compatible with Parse.com CloudCode #2214

* Adds regression tests for #2204
2016-07-18 23:14:32 -07:00
Florent Vilmart
069275d3df Fix for #1840, Strip operations from results, forwards delete operations to SDKs (#1946)
* Adding a test demonstrating issue #1840.

* Fixes #1840

* Adds failing test with other use case

- That test fails on parse.com as well

* Bumps parse to 1.9.0

* exclude pg db

* Exclude pg on other test

* Adds clientSDK compatibility check for forward deletion

- Mark js1.9.0 as compatible

* Strips all operations from result

- fix for #1606
2016-07-15 09:24:53 -04:00
Drew
7e868b2dcc Unique indexes (#1971)
* Add unique indexing

* Add unique indexing for username/email

* WIP

* Finish unique indexes

* Notes on how to upgrade to 2.3.0 safely

* index on unique-indexes: c454180 Revert "Log objects rather than JSON stringified objects (#1922)"

* reconfigure username/email tests

* Start dealing with test shittyness

* Remove tests for files that we are removing

* most tests passing

* fix failing test

* Make specific server config for tests async

* Fix more tests

* fix more tests

* Fix another test

* fix more tests

* Fix email validation

* move some stuff around

* Destroy server to ensure all connections are gone

* Fix broken cloud code

* Save callback to variable

* no need to delete non existant cloud

* undo

* Fix all tests where connections are left open after server closes.

* Fix issues caused by missing gridstore adapter

* Update guide for 2.3.0 and fix final tests

* use strict

* don't use features that won't work in node 4

* Fix syntax error

* Fix typos

* Add duplicate finding command

* Update 2.3.0.md
2016-06-10 20:27:21 -07:00
Marco Cheung
2e50416cba Recursive parse date in cloud function (#2014)
* Recursive parse date in cloud function

* Use _.mapValues
2016-06-09 12:37:05 -07:00
Jeremy Pease
c6c9c97b54 Allow custom error codes with response.error from Cloud Code functions and before/after hooks (#1955) 2016-06-01 10:28:06 -04:00
Drew
3a96140103 Fix issue with pointers getting un-hydrated when there is a beforeSave (#1884)
* Add failing test and simplify RestWrite

* simplify and add test stubs

* Fix issue
2016-05-23 17:13:32 -07:00
Drew
392102eb97 Cache users by objectID, and clear cache when updated via master key (fixes #1836) (#1844)
* Cache users by objectID, and clear cache when updated via master key

* Go back to caching by session token. Clear out cache by querying _Session when user is modified with Master Key (ew, hopefully that can be improved later)

* Fix issue with user updates from different sessions causing stale reads

* Tests aren't transpiled...

* Still not transpiled
2016-05-22 09:59:36 -07:00
Drew
b2183680be Refactor cloud code tests (#1837)
* Move cloud code tests

* Remove _removeHook calls that are no longer necessary

* Use Strict
2016-05-19 13:38:16 -07:00