Skip to content

refactor(api): migrate Annotations from Flow to TypeScript - #4987

Open
bonchevskyi wants to merge 1 commit into
box:masterfrom
bonchevskyi:refactor/flow-to-ts-api-annotations
Open

bonchevskyi wants to merge 1 commit into
box:masterfrom
bonchevskyi:refactor/flow-to-ts-api-annotations

Conversation

@bonchevskyi

@bonchevskyi bonchevskyi commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Convert Annotations API to TypeScript

This PR converts src/api/Annotations from JavaScript with Flow to TypeScript.

Changes

  • Converted src/api/Annotations.js to src/api/Annotations.ts with explicit return types
  • Converted src/api/__tests__/Annotations.test.js to Annotations.test.ts
  • Created src/api/Annotations.js.flow (original Flow source) for remaining Flow importers (Feed, APIFactory)

Contract

  • Declared Flow contract preserved (method signatures, requiredness, exports, runtime behavior)
  • getAnnotations fileVersionId is typed string | undefined because TypeScript does not allow an optional parameter before required ones; callers still pass it positionally, as with Flow's fileVersionId?: string

Summary by CodeRabbit

  • New Features
    • Added support for creating, viewing, updating, and deleting file annotations.
    • Added support for reading and posting replies to annotations, with optional rich-text content.
    • Annotation listings can include replies and support pagination, including retrieving all pages.

@bonchevskyi
bonchevskyi requested a review from a team as a code owner November 30, 2026 13:36
@mergify

mergify Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

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

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Adds an Annotations API client for creating, updating, deleting, and fetching annotations and replies. The client checks permissions, supports rich-text requests and paginated annotation fetching, and formats responses. The test setup now casts its options object to APIOptions.

Changes

Annotations API

Layer / File(s) Summary
Response handling and URL helpers
src/api/Annotations.ts
Adds response formatting for annotation and reply data, plus URL builders for annotation and reply endpoints.
Annotation operations
src/api/Annotations.ts, src/api/__tests__/Annotations.test.ts
Adds annotation creation, update, deletion, and fetching. Operations check permissions before making requests. Listing supports pagination options. The test setup casts its options object to APIOptions.
Reply operations
src/api/Annotations.ts
Adds reply fetching and creation. Both operations check permissions before making requests.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant Annotations
  participant MarkerBasedApi
  participant successCallback
  Annotations->>Annotations: Check can_create_annotations
  Annotations->>MarkerBasedApi: Send annotation request
  MarkerBasedApi-->>Annotations: Return annotation response
  Annotations->>successCallback: Return formatted annotation
Loading

Possibly related PRs

Suggested reviewers: vitali-usik, tjiang-box, jfox-box

Merge Risk: Minimal · up to 497a1

This change converts the Annotations API client and its tests from Flow to TypeScript while keeping behavior and method signatures the same. No concrete user or production risk was identified, so it looks ready to merge once normal CI passes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the primary change: migrating the Annotations API from Flow to TypeScript. The raw summary shows the new src/api/Annotations.ts and the renamed test file, which match this title. The …
Description check Passed The description follows the repository's general intent. It states what changed (Annotations.js converted to Annotations.ts, test file converted, Annotations.js.flow added for remaining Flow importers…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the primary change: migrating the Annotations API from Flow to TypeScript. The raw summary shows the new src/api/Annotations.ts and the renamed test file, which match this title. The title uses the conventional refactor(api) prefix and is concise and specific.

Full details: Description check

Explanation

The description follows the repository's general intent. It states what changed (Annotations.js converted to Annotations.ts, test file converted, Annotations.js.flow added for remaining Flow importers) and records the contract decision about getAnnotations fileVersionId typing. The description template is a merge-process checklist with HTML comments and no required content sections, so the description does not need to fill any template section. The description is clear and specific.

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.

Share

A rabbit checks the notes with care,
Then sends a comment through the air.
Replies arrive, all neatly shown,
New pages join the list as grown.
Rich text hops along the way,
And permissions guard the day.

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: 9fed4689-3e08-46b9-a151-95ab51cf52e8
Commits

Reviewing files that changed from the base of the PR and between fcd5d5b and 497a122.

Files selected for processing: 3

  • src/api/Annotations.js.flow
  • src/api/Annotations.ts
  • src/api/__tests__/Annotations.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant