You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(api): migrate Folder from Flow to TypeScript - #4990
This PR converts src/api/Folder from JavaScript with Flow to TypeScript.
Changes
Converted src/api/Folder.js to src/api/Folder.ts
Converted src/api/__tests__/Folder.test.js to Folder.test.ts
Created src/api/Folder.js.flow (original Flow source) for backward compatibility with remaining Flow importers (APIFactory, Recents, uploads/FolderUploadNode)
Updated src/utils/__tests__/flatten.test.ts to cast its constructor options to APIOptions, now that Folder is typed
In Folder.test.ts, replaced toThrow(Error, /Bad box item/) with toThrow(Error); Jest ignores the second argument, so the assertions are unchanged
Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.
Queue this pull request once it meets the queue conditions
No actionable comments were generated in the recent review.
Walkthrough
This change adds a Folder API class for fetching folder details and items, serving cached collections, and creating folders. It also updates tests to use APIOptions types and to assert errors without requiring a specific message.
Changes
Folder API
Layer / File(s)
Summary
Folder fetch and cache lookup src/api/Folder.ts, src/api/__tests__/Folder.test.ts
The new Folder class stores request parameters and callbacks, builds detail and item requests, and returns cached collections unless forceFetch is set.
Folder responses and collections src/api/Folder.ts, src/api/__tests__/Folder.test.ts, src/utils/__tests__/flatten.test.ts
The class validates folder and collection data, flattens item entries into the cache, and builds collections with pagination and sorting metadata. Tests use APIOptions and check for errors without matching a message.
The class posts a folder name and parent ID. If the parent collection is cached, it adds the child and increments total_count; otherwise, it returns the created folder.
This migrates the Folder API and its tests to TypeScript, with a Flow declaration kept for existing importers. No runtime behavior change or merge-blocking issue was found.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "refactor(api): migrate Folder from Flow to TypeScript" names the main change: the Folder API and its tests move from Flow-typed JavaScript to TypeScript. The raw summary and the PR objectiv…
Description check
The description states the purpose (converting src/api/Folder from Flow to TypeScript) and lists the changes: file conversions, the new Folder.js.flow for backward compatibility with remaining Flow im…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "refactor(api): migrate Folder from Flow to TypeScript" names the main change: the Folder API and its tests move from Flow-typed JavaScript to TypeScript. The raw summary and the PR objectives both confirm this as the primary change. The title is specific and follows a conventional commit style.
Full details: Description check
Explanation
The description states the purpose (converting src/api/Folder from Flow to TypeScript) and lists the changes: file conversions, the new Folder.js.flow for backward compatibility with remaining Flow importers, the flatten test cast, and the toThrow assertion change. It also covers the contract preservation and the folderRequest return type narrowing. It does not follow the repository template, which is a merge-queue checklist with no fields to fill in, so the author's content is complete for the change itself.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
A rabbit checks the folder’s trail, Then gathers cached items without fail. New entries hop into the view, A child folder joins the queue. The API’s paths are clear and bright, As carrots rest beneath moonlight.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 2e6c43b7-bc51-4a61-b21d-7e1fa7b4141f
Commits
Reviewing files that changed from the base of the PR and between fcd5d5b and a2e8fe6.
Files selected for processing: 4
src/api/Folder.js.flow
src/api/Folder.ts
src/api/__tests__/Folder.test.ts
src/utils/__tests__/flatten.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Convert
FolderAPI to TypeScriptThis PR converts
src/api/Folderfrom JavaScript with Flow to TypeScript.Changes
src/api/Folder.jstosrc/api/Folder.tssrc/api/__tests__/Folder.test.jstoFolder.test.tssrc/api/Folder.js.flow(original Flow source) for backward compatibility with remaining Flow importers (APIFactory,Recents,uploads/FolderUploadNode)src/utils/__tests__/flatten.test.tsto cast its constructor options toAPIOptions, now thatFolderis typedFolder.test.ts, replacedtoThrow(Error, /Bad box item/)withtoThrow(Error); Jest ignores the second argument, so the assertions are unchangedContract
folderRequestreturn type narrowed fromPromise<any>toPromise<void>to match its actual return paths; no runtime changeSummary by CodeRabbit