Skip to content

Conversation

@hajjarjoseph
Copy link
Contributor

@hajjarjoseph hajjarjoseph commented Jan 25, 2026

Pull Request

Issue

Related: parse-community/parse-server#10021

Approach

In Node.js builds, Parse.initialize is reassigned to Parse._initialize at
runtime (line 409 of src/Parse.ts), which accepts 4 parameters:
applicationId, javaScriptKey, masterKey, and maintenanceKey. However,
the TypeScript type definition only exposed the 2-parameter browser signature.

This became apparent after the type resolution fix in 8.0.1, which correctly
resolved parse/node types. Before that fix, TypeScript wasn't properly
checking the types for parse/node imports.

Changes:

  1. Added an exported Parse interface in src/Parse.ts that can be augmented
  2. Added type augmentation in types/node.d.ts to override initialize with
    the 4-parameter signature for Node.js builds
  3. Added type tests to verify browser rejects 3+ params and Node accepts 4
    params

This keeps browser types strict (2 params, no masterKey exposure) while giving
Node.js the correct 4-parameter signature matching runtime behavior.

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)

Summary by CodeRabbit

  • Refactor
    • Public SDK surface reworked into a typed interface with consistent getters/setters and clearer initialization semantics.
  • New Features
    • Expanded public API: richer lifecycle/configuration controls, storage/health APIs, EventuallyQueue accessors, datastore and encrypted-user controls, and LiveQuery/storage wiring.
  • Tests
    • Added type-level initialization tests for browser vs Node and corrected a unit test console-message expectation.

✏️ Tip: You can customize this high-level summary in your review settings.

@parse-github-assistant
Copy link

parse-github-assistant bot commented Jan 25, 2026

🚀 Thanks for opening this pull request!

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Jan 25, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link

coderabbitai bot commented Jan 25, 2026

📝 Walkthrough

Walkthrough

Add a typed public Parse interface and make the Parse constant conform to it; expand and refine the public API (initialize/_initialize, config accessors, controllers, storage/encode helpers, EventuallyQueue); update TypeScript declarations and Node initialization typings; add type tests and a small test message fix.

Changes

Cohort / File(s) Summary
Parse implementation & API surface
src/Parse.ts
Introduced exported Parse interface and changed const Parse to const Parse: Parse. Added typed getters/setters (applicationId, javaScriptKey, masterKey, maintenanceKey, serverURL, LiveQuery, liveQueryServerURL, encryptedUser, secret, idempotency, allowCustomObjectId, nodeLogging), EventuallyQueue accessor, initialize/_initialize implementations, storage/health APIs (setAsyncStorage, setLocalDatastoreController, getServerHealth), core helpers (_request, _ajax, _encode, _decode, _getInstallationId), local datastore/encryption controls, and controller wiring (LiveQuery, CryptoController, EventuallyQueue, InstallationController, LocalDatastoreController, StorageController, WebSocketController).
Type declarations
types/Parse.d.ts
Replaced inline Parse surface with export interface Parse and declare const Parse: Parse; export default Parse;. Tightened property/method types (string
Node augmentation
types/node.d.ts
Added Node-specific overload: initialize(applicationId: string, javaScriptKey?: string, masterKey?: string, maintenanceKey?: string): void to reflect expanded Node initialization signature.
Type tests
types/tests.ts
Added testInitialize() to exercise Browser vs Node initialize signatures, including a ts-expect-error case to assert typings differences.
Tests (small fix)
src/__tests__/Parse-test.js
Fixed expected console message text to match actual message ('enableLocalDatastore' must be called after 'initialize').

Sequence Diagram(s)

sequenceDiagram
  participant App as Consumer
  participant Parse as Parse
  participant Core as CoreManager
  participant Controllers as "Controllers\n(LiveQuery, Crypto,\nEventuallyQueue, Installation,\nLocalDatastore, Storage, WebSocket)"

  App->>Parse: call Parse._initialize(config)
  Parse->>Core: set applicationId / keys / serverURL / flags
  Parse->>Core: set controller bindings (LiveQuery, Crypto, EventuallyQueue, Installation, LocalDatastore, Storage, WebSocket)
  Core->>Controllers: instantiate/configure controllers
  Controllers-->>Core: controllers ready
  Core-->>Parse: core configured
  Parse-->>App: initialization complete
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • mtrezza
  • dplewis
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description comprehensively covers the issue, approach, and changes made, with a clear explanation of the type signature mismatch and the solution.
Title check ✅ Passed The title accurately describes the main change: adding Node.js type signatures for Parse.initialize with masterKey and maintenanceKey parameters.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (85877dc) to head (b3a4089).
⚠️ Report is 9 commits behind head on alpha.

Additional details and impacted files
@@            Coverage Diff            @@
##             alpha     #2884   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           64        64           
  Lines         6222      6222           
  Branches      1477      1473    -4     
=========================================
  Hits          6222      6222           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 25, 2026
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.

Quite a lot of changes; are they all valid and related to the issue?

@hajjarjoseph
Copy link
Contributor Author

hajjarjoseph commented Jan 25, 2026

Quite a lot of changes; are they all valid and related to the issue?

@mtrezza

The changes look large but are actually minimal:

Manual changes:

  • src/Parse.ts: Added export interface Parse { ... } (~80 lines)
  • types/node.d.ts: Added augmentation for initialize (~12 lines)
  • types/tests.ts: Added type tests (~15 lines)

Auto-generated:

  • types/Parse.d.ts: Regenerated by tsc - same content, different structure

The large diff in types/Parse.d.ts is because I extracted the inline object
type into a named interface. The actual properties and methods are identical.

Running now npm run build:types on parse-server works. I tried also running a parse-server with no issue

mtrezza
mtrezza previously approved these changes Jan 26, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/Parse.ts (1)

557-561: Typo in log message: method name casing mismatch.

The log message references 'enableLocalDataStore' but the actual method name is enableLocalDatastore (lowercase 's').

Proposed fix
     if (!this.applicationId) {
-      console.log("'enableLocalDataStore' must be called after 'initialize'");
+      console.log("'enableLocalDatastore' must be called after 'initialize'");
       return;
     }
🧹 Nitpick comments (3)
types/Parse.d.ts (1)

75-83: JSDoc indicates optional parameter but type signature requires it.

The JSDoc on line 79 uses brackets [javaScriptKey] indicating an optional parameter, but the type signature on line 83 declares javaScriptKey: string as required. Consider aligning these:

Option 1: Make javaScriptKey optional in the signature (if runtime allows)
-    initialize(applicationId: string, javaScriptKey: string): void;
+    initialize(applicationId: string, javaScriptKey?: string): void;
Option 2: Update JSDoc to reflect required parameter
-   * `@param` {string} [javaScriptKey] Your Parse JavaScript Key (Not needed for parse-server)
+   * `@param` {string} javaScriptKey Your Parse JavaScript Key (Not needed for parse-server)
src/Parse.ts (2)

90-98: JSDoc/signature mismatch (same as in types/Parse.d.ts).

The JSDoc indicates [javaScriptKey] is optional (line 94), but the signature requires it (line 98). This should be consistent with the declaration file fix.


588-595: Inconsistent reference: this.LocalDatastore vs Parse.LocalDatastore.

Line 589 uses this.LocalDatastore while line 593 uses Parse.LocalDatastore. Consider using this consistently for clarity.

Proposed fix
   dumpLocalDatastore() {
     if (!this.LocalDatastore.isEnabled) {
       console.log('Parse.enableLocalDatastore() must be called first');
       return Promise.resolve({});
     } else {
-      return Parse.LocalDatastore._getAllContents();
+      return this.LocalDatastore._getAllContents();
     }
   },

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 26, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 26, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/Parse.ts`:
- Around line 90-98: The JSDoc for initialize is out of sync with the browser
signature: update the comment for the initialize(applicationId: string,
javaScriptKey: string) method to reflect that the browser API accepts two
required args (applicationId and javaScriptKey) and remove or mark masterKey as
Node-only/optional (or describe it separately) so generated docs aren't
misleading; locate the initialize declaration in Parse.ts and adjust the param
annotations and description accordingly.

@mtrezza mtrezza changed the title fix: Add Node.js type signature for Parse.initialize with masterKey a… fix: Missing Node.js type signature for Parse.initialize with masterKey, maintenanceKey Jan 26, 2026
@mtrezza mtrezza merged commit ce8c907 into parse-community:alpha Jan 27, 2026
13 checks passed
parseplatformorg pushed a commit that referenced this pull request Jan 27, 2026
## [8.0.3-alpha.1](8.0.2...8.0.3-alpha.1) (2026-01-27)

### Bug Fixes

* Missing Node.js type signature for `Parse.initialize` with `masterKey`, `maintenanceKey` ([#2884](#2884)) ([ce8c907](ce8c907))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 8.0.3-alpha.1

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Jan 27, 2026
parseplatformorg pushed a commit that referenced this pull request Jan 27, 2026
## [8.0.3](8.0.2...8.0.3) (2026-01-27)

### Bug Fixes

* Missing Node.js type signature for `Parse.initialize` with `masterKey`, `maintenanceKey` ([#2884](#2884)) ([ce8c907](ce8c907))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 8.0.3

@parseplatformorg parseplatformorg added the state:released Released as stable version label Jan 27, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants