Skip to content

Conversation

@SoulPancake
Copy link
Member

@SoulPancake SoulPancake commented Nov 18, 2025

Fixes #286

Description

This PR fixes issue #286 where the ClientWriteRequestOnDuplicateWrites and ClientWriteRequestOnMissingDeletes enums were not accessible to client code despite being documented in the README.

What problem is being solved?

Users were unable to import and use the ClientWriteRequestOnDuplicateWrites and ClientWriteRequestOnMissingDeletes enums in their code, even though the README documentation shows these enums should be importable and usable with the client.write() method's conflict options. When users attempted to import these enums from @openfga/sdk, they would receive undefined at runtime because the const value declarations were not being re-exported by the root module.

How is it being solved?

What changes are made to solve it?

The issue stems from TypeScript's export * statement behavior. In client.ts, both enums are declared as both const values and types:

export const ClientWriteRequestOnDuplicateWrites = WriteRequestWritesOnDuplicate;
export type ClientWriteRequestOnDuplicateWrites = WriteRequestWritesOnDuplicate;

TypeScript's export * from "./client" statement only re-exports type declarations, not const value declarations. This means while the type was available for TypeScript type checking, the actual runtime enum objects with their .Error and .Ignore properties were not accessible to users.
What changes are made to solve it?
Added explicit named exports in index.ts:
export { ClientWriteRequestOnDuplicateWrites, ClientWriteRequestOnMissingDeletes } from "./client";

References

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

Summary by CodeRabbit

  • New Features
    • Expanded the public API with new exports for client write request handling, providing developers access to configuration options for managing duplicate writes and missing deletes in client operations.

Copilot AI review requested due to automatic review settings November 18, 2025 11:40
@SoulPancake SoulPancake requested a review from a team as a code owner November 18, 2025 11:40
@coderabbitai
Copy link

coderabbitai bot commented Nov 18, 2025

Walkthrough

The PR adds re-exports for ClientWriteRequestOnDuplicateWrites and ClientWriteRequestOnMissingDeletes types from the "./client" module to index.ts, making these enumerations available at the root module level for public API consumption without modifying existing runtime behavior.

Changes

Cohort / File(s) Change Summary
API Export Additions
index.ts
Added re-exports for ClientWriteRequestOnDuplicateWrites and ClientWriteRequestOnMissingDeletes from "./client" module to expand public API surface

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested reviewers

  • ewanharris
  • rhamzeh

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: write conflicts enum export' accurately summarizes the main change: fixing the export of write conflict enums (ClientWriteRequestOnDuplicateWrites and ClientWriteRequestOnMissingDeletes) from the package root.
Linked Issues check ✅ Passed The PR fully addresses issue #286 by adding explicit named exports for ClientWriteRequestOnDuplicateWrites and ClientWriteRequestOnMissingDeletes in index.ts, enabling runtime availability of these enums when imported from @openfga/sdk.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the enum export issue; only index.ts is modified with two targeted named exports re-exporting the conflict enums from './client'.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/write-conflicts-enum

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 847b9ff and d73ca17.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • index.ts (1 hunks)
🔇 Additional comments (2)
index.ts (2)

17-21: The fix follows established patterns in this file.

The explicit named export on line 21 is consistent with the existing approach used for Configuration and Credentials (lines 19-20), where specific exports are called out explicitly alongside wildcard exports. This pattern ensures both type and runtime value availability.


21-21: No issues found. The explicit export is correct.

The verification confirms that:

  1. ClientWriteRequestOnDuplicateWrites and ClientWriteRequestOnMissingDeletes are properly declared as const values in client.ts (lines 180–181) with corresponding type declarations (lines 183–184)
  2. The explicit named export on line 21 of index.ts correctly re-exports these const values, which is necessary because wildcard exports don't re-export const value declarations
  3. No other similar enum/const declarations in client.ts require the same treatment
  4. The exports are functioning correctly and used throughout the test suite

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.46%. Comparing base (847b9ff) to head (d73ca17).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #288   +/-   ##
=======================================
  Coverage   89.45%   89.46%           
=======================================
  Files          24       24           
  Lines        1299     1300    +1     
  Branches      234      213   -21     
=======================================
+ Hits         1162     1163    +1     
  Misses         81       81           
  Partials       56       56           

☔ 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.

Copilot finished reviewing on behalf of SoulPancake November 18, 2025 11:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes issue #286 by adding explicit named exports for the ClientWriteRequestOnDuplicateWrites and ClientWriteRequestOnMissingDeletes enum values to the root module. While these enums were previously exported as types through the wildcard export statement, TypeScript's export * only re-exports type declarations, not const value declarations, preventing users from accessing the runtime enum objects needed to use the conflict options documented in the README.

Key Changes:

  • Added explicit named exports in index.ts for both ClientWriteRequestOnDuplicateWrites and ClientWriteRequestOnMissingDeletes enum values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.



export * from "./api";
export * from "./client";
Copy link
Member

@ewanharris ewanharris Nov 18, 2025

Choose a reason for hiding this comment

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

Should this not export them?

Edit: never mind didn't read the PR body properly

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly my thoughts initially but I tried it doesn't work

Copy link
Member

@ewanharris ewanharris Nov 18, 2025

Choose a reason for hiding this comment

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

Hmm are we sure about this, I did the following with the latest SDK and it works just fine:

import { ClientWriteRequestOnDuplicateWrites, ClientWriteRequestOnMissingDeletes } from '@openfga/sdk';

console.log(ClientWriteRequestOnDuplicateWrites);
console.log(ClientWriteRequestOnMissingDeletes);

Outputs

node index.mjs 
{ Error: 'error', Ignore: 'ignore' }
{ Error: 'error', Ignore: 'ignore' }

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep it does seem to work now, I am not sure how I was able to reproduce it
Let me traceback and see I'll close this for now

@ewanharris ewanharris self-requested a review November 18, 2025 12:34
@SoulPancake SoulPancake deleted the fix/write-conflicts-enum branch November 18, 2025 13:18
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.

WriteRequestWritesOnDuplicate enum not re-exported by root module for use in client code

4 participants