Parse.Coud incomplete typings
New Issue Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am not just asking a question.
- [x] I have searched through existing issues.
- [x] I can reproduce the issue with the latest versions of Parse Server and the Parse JS SDK.
Issue Description
All Parse.Cloud triggers types are missing : Parse.Cloud.afterSave, Parse.Cloud.beforeSave, Parse.Cloud.afterFind, Parse.Cloud.afterLogout...
Theses types are all presents in previous types package @types/parse and worked well.
Steps to reproduce
Juste try to add a line like Parse.Cloud.afterLogout((request) => mdcModule.afterLogout(request)); and look TypeScript sreaming at you :)
Server
- Parse Server version:
8.2.1 - Operating system:
Windows 10 - Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
Local
Database
- System (MongoDB or Postgres):
Postgres - Database version:
18 - Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
Local
Client
- Parse JS SDK version:
6.1.1
🚀 Thanks for opening this issue!
ℹ️ You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.
I’m not sure if we should add these typing to the JS SDK or the Server.
Considering https://github.com/parse-community/parse-server/issues/8787, I imagine it would be possible to use Cloud Code without Parse JS SDK. In that case the namespace Parse.Cloud should move to the Parse Server repository, and the type definitions as well. Should I move this issue to the server repository?
@mtrezza The issue isn't so much that. I'm personally struggling with the new type definitions. To the point where I've gone back to my bastardised @types/parse 3.0.9 and Parse JS SDK 5.3.0 (plus custom namespaces).
In my scenario I use a shared package for all type definitions across 23 other packages. This includes both front end and backend frameworks, ESM and CJS. If I need to install parse-server in my shared package just to get Parse.Cloud it feels like overkill.
Is there any documentation on new typescript definitions for Parse Server and Parse JS SDK types and how to access them or any best practices.
If I need to install parse-server in my shared package just to get Parse.Cloud it feels like overkill.
You are right, namespaces that are used outside of Cloud Code (i.e. Parse Server), should be available in the SDK. For example, Parse.Cloud.run. But I don't think that APIs that are unusable outside of Cloud Code, like Parse.Cloud.afterLogout or the job or triggers need to be available in the SDK. They require Parse Server after all.
The issue seems to the Parse.Cloud is a shared namespace. Some methods are needed in the SDK, others make sense only with Parse Server Cloud Code. Not sure what the best solution is, or whether the namespace can be split between the two, like extended by Parse Server with the methods that are used in Cloud Code? Maybe for now just add all missing types to the SDK?
In fact, we're planning to remove Parse Server's dependency on the JS SDK. But that will take time.
Should we re-add the typings for now? I can attempt a PR for that.