Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: align file trigger syntax with class trigger #7966

Merged
merged 15 commits into from
May 29, 2022

Conversation

dblythy
Copy link
Member

@dblythy dblythy commented May 2, 2022

New Pull Request Checklist

Issue Description

Currently, File Triggers have their own unique syntax. This is unnecessary, and they should follow the same syntax for other file triggers.

Related issue: #7928

Approach

Add new file trigger method, depreciate old syntax to be removed in V7.

TODOs before merging

  • Add tests
  • Add changes to documentation (guides, repository pages, in-code descriptions)
  • A changelog entry is created automatically using the pull request title (do not manually add a changelog entry)

@parse-github-assistant
Copy link

parse-github-assistant bot commented May 2, 2022

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!

@codecov
Copy link

codecov bot commented May 2, 2022

Codecov Report

Merging #7966 (03faa8a) into alpha (c1e808f) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##            alpha    #7966      +/-   ##
==========================================
- Coverage   94.13%   94.13%   -0.01%     
==========================================
  Files         182      182              
  Lines       13635    13634       -1     
==========================================
- Hits        12835    12834       -1     
  Misses        800      800              
Impacted Files Coverage Δ
src/Routers/FilesRouter.js 88.54% <100.00%> (ø)
src/cloud-code/Parse.Cloud.js 99.20% <100.00%> (ø)
src/triggers.js 95.34% <100.00%> (-0.02%) ⬇️
src/Adapters/Files/GridFSBucketAdapter.js 79.50% <0.00%> (-0.82%) ⬇️
src/batch.js 94.73% <0.00%> (+1.75%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac283d3...03faa8a. Read the comment docs.

@dblythy dblythy requested a review from a team May 2, 2022 22:18
@mtrezza
Copy link
Member

mtrezza commented May 3, 2022

Could you give this PR a more descriptive title?

DEPRECATIONS.md Outdated Show resolved Hide resolved
src/cloud-code/Parse.Cloud.js Outdated Show resolved Hide resolved
src/triggers.js Show resolved Hide resolved
@dblythy dblythy changed the title feat: add Parse.Cloud.beforeSave(Parse.File, (req) => {}) feat: allow file triggers to be trigged by Parse.Cloud.beforeSave(Parse.File, (request) => {}), deprecate Parse.Cloud.beforeSaveFile((request) => {}) May 5, 2022
@mtrezza
Copy link
Member

mtrezza commented May 5, 2022

We shouldn't use code to explain code changes - could you just explain the PR in prose form in the title?

Copy link
Member

@Moumouls Moumouls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @dblythy

I'm just blocking the PR because of the deprecation, we should have the docs PR ready also.
Then both could be merged at the same time.

Feel free @dblythy to link the docs pr here 👍

@mtrezza mtrezza changed the title feat: allow file triggers to be trigged by Parse.Cloud.beforeSave(Parse.File, (request) => {}), deprecate Parse.Cloud.beforeSaveFile((request) => {}) 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 and will be removed in a future version May 10, 2022
DEPRECATIONS.md Outdated Show resolved Hide resolved
@mtrezza mtrezza changed the title 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 and will be removed in a future version 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 May 10, 2022
@mtrezza mtrezza changed the title 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 feat: align file trigger syntax with class trigger; use the new syntax Parse.Cloud.beforeSave(Parse.File, (request) => {}), the previous syntax Parse.Cloud.beforeSaveFile((request) => {}) has been deprecated May 10, 2022
@mtrezza mtrezza changed the title feat: align file trigger syntax with class trigger; use the new syntax Parse.Cloud.beforeSave(Parse.File, (request) => {}), the previous syntax Parse.Cloud.beforeSaveFile((request) => {}) has been deprecated 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 May 10, 2022
DEPRECATIONS.md Outdated Show resolved Hide resolved
Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I think we can merge this, as the deprecation warning is self-descriptive and the API reference should indicate what is deprecated and which syntax should be used instead.

There is still time to write the docs PR. The docs will be updated on stable release which is planned for in ~1 month when this feature goes out of beta phase.

@dblythy
Copy link
Member Author

dblythy commented May 29, 2022

I'd be happy to do the docs

@mtrezza
Copy link
Member

mtrezza commented May 29, 2022

That'd be great! Re-running the failed tests; once they pass we can merge.

@mtrezza mtrezza merged commit c6dcad8 into parse-community:alpha May 29, 2022
parseplatformorg pushed a commit that referenced this pull request May 29, 2022
# [5.3.0-alpha.14](5.3.0-alpha.13...5.3.0-alpha.14) (2022-05-29)

### Features

* 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](#7966)) ([c6dcad8](c6dcad8))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.3.0-alpha.14

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label May 29, 2022
parseplatformorg pushed a commit that referenced this pull request Jun 17, 2022
# [5.3.0-beta.1](5.2.1...5.3.0-beta.1) (2022-06-17)

### Bug Fixes

* afterSave trigger removes pointer in Parse object ([#7913](#7913)) ([47d796e](47d796e))
* auto-release process may fail if optional back-merging task fails ([#8051](#8051)) ([cf925e7](cf925e7))
* custom database options are not passed to MongoDB GridFS ([#7911](#7911)) ([b1e5565](b1e5565))
* depreciate allowClientClassCreation defaulting to true ([#7925](#7925)) ([38ed96a](38ed96a))
* errors in GraphQL do not show the original error but a general `Unexpected Error` ([#8045](#8045)) ([0d81887](0d81887))
* interrupted WebSocket connection not closed by LiveQuery server ([#8012](#8012)) ([2d5221e](2d5221e))
* live query role cache does not clear when a user is added to a role ([#8026](#8026)) ([199dfc1](199dfc1))
* peer dependency mismatch for GraphQL dependencies ([#7934](#7934)) ([0a6faa8](0a6faa8))
* return correct response when revert is used in beforeSave ([#7839](#7839)) ([19900fc](19900fc))
* security upgrade @parse/fs-files-adapter from 1.2.1 to 1.2.2 ([#7948](#7948)) ([3a70fda](3a70fda))
* security upgrade moment from 2.29.1 to 2.29.2 ([#7931](#7931)) ([731c550](731c550))
* security upgrade parse push adapter from 4.1.0 to 4.1.2 ([#7893](#7893)) ([93667b4](93667b4))
* websocket connection of LiveQuery interrupts frequently ([#8048](#8048)) ([03caae1](03caae1))

### Features

* add MongoDB 5.1 compatibility ([#7682](#7682)) ([022a856](022a856))
* add MongoDB 5.2 support ([#7894](#7894)) ([5bfa716](5bfa716))
* add support for Node 17 and 18 ([#7896](#7896)) ([3e9f292](3e9f292))
* 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](#7966)) ([c6dcad8](c6dcad8))
* replace GraphQL Apollo with GraphQL Yoga ([#7967](#7967)) ([1aa2204](1aa2204))
* selectively enable / disable default authentication adapters ([#7953](#7953)) ([c1e808f](c1e808f))
* upgrade mongodb from 4.4.1 to 4.5.0 ([#7991](#7991)) ([e692b5d](e692b5d))

### Performance Improvements

* reduce database operations when using the constant parameter in Cloud Function validation ([#7892](#7892)) ([041197f](041197f))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.3.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Jun 17, 2022
@mtrezza mtrezza changed the title 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 feat: align file trigger syntax with class trigger Oct 15, 2022
@mtrezza
Copy link
Member

mtrezza commented Oct 15, 2022

@dblythy Do you have a docs PR for that? This will go into stable release in few days.

parseplatformorg pushed a commit that referenced this pull request Oct 29, 2022
# [5.3.0](5.2.8...5.3.0) (2022-10-29)

### Bug Fixes

* afterSave trigger removes pointer in Parse object ([#7913](#7913)) ([47d796e](47d796e))
* authentication adapter app ID validation may be circumvented; this fixes a vulnerability that affects configurations which allow users to authenticate using the Parse Server authentication adapter for *Facebook* or *Spotify* and where the server-side authentication adapter configuration `appIds` is set as a string (e.g. `abc`) instead of an array of strings (e.g. `["abc"]`) ([GHSA-r657-33vp-gp22](GHSA-r657-33vp-gp22)) [skip release] ([#8188](#8188)) ([1a2b1b9](1a2b1b9))
* auto-release process may fail if optional back-merging task fails ([#8051](#8051)) ([cf925e7](cf925e7))
* brute force guessing of user sensitive data via search patterns (GHSA-2m6g-crv8-p3c6) ([#8145](#8145)) [skip release] ([f0db4ca](f0db4ca))
* certificate in Apple Game Center auth adapter not validated [skip release] ([#8055](#8055)) ([4c2aa63](4c2aa63))
* custom database options are not passed to MongoDB GridFS ([#7911](#7911)) ([b1e5565](b1e5565))
* depreciate allowClientClassCreation defaulting to true ([#7925](#7925)) ([38ed96a](38ed96a))
* errors in GraphQL do not show the original error but a general `Unexpected Error` ([#8045](#8045)) ([0d81887](0d81887))
* interrupted WebSocket connection not closed by LiveQuery server ([#8012](#8012)) ([2d5221e](2d5221e))
* invalid file request not properly handled [skip release] ([#8061](#8061)) ([1a04a34](1a04a34))
* live query role cache does not clear when a user is added to a role ([#8026](#8026)) ([199dfc1](199dfc1))
* peer dependency mismatch for GraphQL dependencies ([#7934](#7934)) ([0a6faa8](0a6faa8))
* protected fields exposed via LiveQuery (GHSA-crrq-vr9j-fxxh) [skip release] ([#8075](#8075)) ([636d16e](636d16e))
* return correct response when revert is used in beforeSave ([#7839](#7839)) ([19900fc](19900fc))
* security upgrade @parse/fs-files-adapter from 1.2.1 to 1.2.2 ([#7948](#7948)) ([3a70fda](3a70fda))
* security upgrade moment from 2.29.1 to 2.29.2 ([#7931](#7931)) ([731c550](731c550))
* security upgrade parse push adapter from 4.1.0 to 4.1.2 ([#7893](#7893)) ([93667b4](93667b4))
* server crashes when receiving file download request with invalid byte range; this fixes a security vulnerability that allows an attacker to impact the availability of the server instance; the fix improves parsing of the range parameter to properly handle invalid range requests ([GHSA-h423-w6qv-2wj3](GHSA-h423-w6qv-2wj3)) [skip release] ([#8237](#8237)) ([4c1befa](4c1befa))
* session object properties can be updated by foreign user; this fixes a security vulnerability in which a foreign user can write to the session object of another user if the session object ID is known; the fix prevents writing to foreign session objects ([GHSA-6w4q-23cf-j9jp](GHSA-6w4q-23cf-j9jp)) [skip release] ([#8181](#8181)) ([83cdc89](83cdc89))
* websocket connection of LiveQuery interrupts frequently ([#8048](#8048)) ([03caae1](03caae1))

### Features

* add MongoDB 5.1 compatibility ([#7682](#7682)) ([022a856](022a856))
* add MongoDB 5.2 support ([#7894](#7894)) ([5bfa716](5bfa716))
* add support for Node 17 and 18 ([#7896](#7896)) ([3e9f292](3e9f292))
* 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](#7966)) ([c6dcad8](c6dcad8))
* replace GraphQL Apollo with GraphQL Yoga ([#7967](#7967)) ([1aa2204](1aa2204))
* selectively enable / disable default authentication adapters ([#7953](#7953)) ([c1e808f](c1e808f))
* upgrade mongodb from 4.4.1 to 4.5.0 ([#7991](#7991)) ([e692b5d](e692b5d))

### Performance Improvements

* reduce database operations when using the constant parameter in Cloud Function validation ([#7892](#7892)) ([041197f](041197f))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Depreciate Parse.Cloud.beforeSaveFile(() => {}) in preference to Parse.Cloud.beforeSave(Parse.File, () => {})
4 participants