refactor: Isolate Parse.Query SDK usage behind a QueryAdapter#10486
refactor: Isolate Parse.Query SDK usage behind a QueryAdapter#10486dblythy wants to merge 3 commits into
Conversation
Towards parse-community#8787. Auth's session/role resolution and LiveQuery's _clearCachedRoles now always go through RestQuery instead of the Parse JS SDK's Parse.Query. The !config SDK fallback branches in Auth (getAuthForSessionToken, getRolesForUser, getRolesByIds) are removed — all real callers already pass a config, so a config is now required. Threads config into the LiveQuery getAuthForSessionToken calls. Deletes the dead SessionTokenCache (exported but never used in src). Drops the obsolete no-config Auth/Role specs and rewrites the role-based ACL LiveQuery specs to mock the auth seam instead of the removed Parse.Query.
Introduce src/cloud-code/QueryAdapter.js as the single boundary between parse-server's internal REST/JSON query format and the Parse JS SDK's Parse.Query. Core code (triggers, rest, RestQuery, LiveQuery) now calls inflateQuery/deflateQuery/isQuery/applyQueryToRest instead of constructing or inspecting Parse.Query directly, so the SDK query type lives in one place. Towards parse-community#8787.
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a QueryAdapter to convert between REST query JSON and Parse.Query, replaces config-dependent query/role/session branches with RestQuery-based flows in Auth and LiveQuery, integrates the adapter into triggers and REST, and updates tests to the new behavior. ChangesQuery Adapter and Unified Query Resolution
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 OpenGrep (1.22.0)OpenGrep fatal error (exit code 2): [00.10][ERROR]: Error: exception Unix_error: No such file or directory stat spec/CloudCode.spec.js Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/cloud-code/QueryAdapter.js`:
- Around line 59-62: The loop in applyQueryToRest that assigns restOptions only
when jsonQuery[key] is truthy drops intentional falsy overrides (e.g., limit(0),
skip(0), explain(false)); change the condition to test for the presence of the
key instead (e.g., Object.prototype.hasOwnProperty.call(jsonQuery, key) or key
in jsonQuery) so you still initialize restOptions when needed and assign
restOptions[key] = jsonQuery[key], preserving falsy values; update the code that
iterates REST_OPTION_KEYS and uses jsonQuery and restOptions accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cb02caa6-ffec-4d8a-87c7-0cd783972b51
📒 Files selected for processing (12)
spec/Auth.spec.jsspec/ParseLiveQueryServer.spec.jsspec/ParseRole.spec.jsspec/SessionTokenCache.spec.jssrc/Auth.jssrc/LiveQuery/ParseLiveQueryServer.tssrc/LiveQuery/QueryTools.jssrc/LiveQuery/SessionTokenCache.jssrc/RestQuery.jssrc/cloud-code/QueryAdapter.jssrc/rest.jssrc/triggers.js
💤 Files with no reviewable changes (4)
- src/LiveQuery/SessionTokenCache.js
- spec/ParseRole.spec.js
- spec/SessionTokenCache.spec.js
- spec/Auth.spec.js
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## alpha #10486 +/- ##
==========================================
+ Coverage 92.60% 92.62% +0.02%
==========================================
Files 193 193
Lines 16893 16845 -48
Branches 234 234
==========================================
- Hits 15643 15602 -41
+ Misses 1227 1220 -7
Partials 23 23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
applyQueryToRest tested option truthiness, so an explicit falsy override from a beforeFind trigger (e.g. query.limit(0)) was silently dropped. Test presence with hasOwnProperty instead. Parse.Query#toJSON only emits keys that were set, so no default values leak in. Adds a regression test.
Towards #8787.
Removes parse-server's internal use of the Parse JS SDK's
Parse.Queryand isolates the remaining trigger-facing usage behind a single adapter module.Changes
src/cloud-code/QueryAdapter.js(new) — the single boundary between parse-server's internal REST/JSON query format and the SDK'sParse.Query. ExposesinflateQuery/deflateQuery/isQuery/applyQueryToRest. This is the only place insrc/that constructs or inspects aParse.Query.!configSDK fallback branches insrc/Auth.js(getAuthForSessionToken,getRolesForUser,getRolesByIds), threaded a real config into the two LiveQuerygetAuthForSessionTokencalls, and converted LiveQuery role-cache invalidation fromnew Parse.Query(...)toRestQuery. Deleted the dead, never-instantiatedSessionTokenCache.triggers.js,rest.js,RestQuery.js, andParseLiveQueryServer.ts(beforeSubscribe) go through the adapter instead of touchingParse.Querydirectly.No behavior change: cloud-code triggers (
beforeFind/afterFind/beforeSubscribe) still receive and may return a realParse.Query. TheParse.Objectside of the trigger contract is intentionally out of scope and will follow in a separate PR.Test plan
CloudCode,ParseLiveQuery,ParseLiveQueryServer,QueryTools— 387 specs, 0 failuresParseQuery— 226 specs, 0 failuresAuth,ParseRoleregressionSummary by CodeRabbit
Bug Fixes
Refactor
Tests