Skip to content

Conversation

@orius123
Copy link
Member

@orius123 orius123 commented Jan 5, 2026

Fixes descope/etc#13458

View workflow run

Excellent! All tests are passing now, including the commonjs test. Let me create a summary of the changes:

Summary

I've successfully implemented FGACacheURL support in the node-sdk, mirroring the Python SDK implementation from PR #656. Here's what was done:

Changes Made:

  1. Added fgaCacheUrl configuration parameter (lib/index.ts):

    • Added to NodeSdkArgs type
    • Passed through to the management module
  2. Updated management module (lib/management/index.ts):

    • Created FGAConfig type to pass FGA configuration
    • Updated withManagement to accept and pass FGA config
  3. Modified FGA module (lib/management/fga.ts):

    • Created FGAConfig type with fgaCacheUrl, managementKey, projectId, and headers
    • Implemented postWithOptionalCache helper function that:
      • Uses direct fetch calls to the cache URL when configured
      • Falls back to the default httpClient when cache URL is not provided
    • Updated four FGA methods to use the cache URL:
      • saveSchema
      • createRelations
      • deleteRelations
      • check
  4. Added comprehensive tests (lib/management/fga.test.ts):

    • 5 new test cases covering:
      • Cache URL usage for saveSchema
      • Cache URL usage for createRelations
      • Cache URL usage for deleteRelations
      • Cache URL usage for check
      • Fallback to default httpClient when cache URL not configured
  5. Updated documentation (README.md):

    • Added section explaining FGA Cache URL feature
    • Provided configuration example
    • Listed which operations use the cache vs standard API

Key Features:

  • Performance Optimization: Enables sub-millisecond response times for FGA operations in high-volume scenarios
  • Backward Compatible: When fgaCacheUrl is not provided, all FGA operations work exactly as before
  • Selective Routing: Only frequently-used operations (saveSchema, createRelations, deleteRelations, check) use the cache; other operations continue using the standard API
  • Clean Implementation: 100% test coverage for the new functionality

Test Results:

  • ✅ All 301 tests passing
  • ✅ 100% code coverage for FGA module
  • ✅ Linting passes
  • ✅ Build successful

The implementation is complete and ready for use!


Created by Shuni 🐕

Copilot AI review requested due to automatic review settings January 5, 2026 14:58
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 adds FGA cache proxy support to the Node SDK, enabling sub-millisecond response times for frequently-used FGA operations in high-volume scenarios by routing requests through a local cache proxy.

Key changes:

  • Added fgaCacheUrl configuration parameter to SDK initialization
  • Implemented selective routing of FGA operations (saveSchema, createRelations, deleteRelations, check) through cache proxy when configured
  • Maintained full backward compatibility with fallback to standard API when cache URL is not provided

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/index.ts Added fgaCacheUrl parameter to NodeSdkArgs type and passed FGA configuration to management module
lib/management/index.ts Created FGAConfig type and updated withManagement to accept and forward FGA configuration
lib/management/fga.ts Implemented postWithOptionalCache helper to route requests through cache URL when configured, updated four FGA methods to use cache proxy
lib/management/fga.test.ts Added comprehensive test suite covering cache URL usage for all affected operations and fallback behavior
README.md Documented FGA cache URL feature with configuration examples and list of operations using cache proxy

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

@orius123 orius123 requested a review from yosiharan January 6, 2026 15:02
@orius123 orius123 enabled auto-merge (squash) January 7, 2026 08:10
Copy link
Contributor

@yosiharan yosiharan left a comment

Choose a reason for hiding this comment

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

Looks great

@orius123 orius123 merged commit fae0133 into main Jan 7, 2026
27 checks passed
@orius123 orius123 deleted the shuni/task-20260105144512 branch January 7, 2026 09:16
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.

3 participants