Skip to content

refactor(storage): move toQueryParams onto TransformOptions - #1672

Open
spydon wants to merge 1 commit into
mainfrom
refactor/remove-unnecessary-extension
Open

refactor(storage): move toQueryParams onto TransformOptions#1672
spydon wants to merge 1 commit into
mainfrom
refactor/remove-unnecessary-extension

Conversation

@spydon

@spydon spydon commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

ToQueryParams was an extension on TransformOptions declared in the same library as the class it extended, so it did not need to be an extension at all. It is now a plain getter on the class.

To keep it out of the public API (it was previously hidden via export 'src/types.dart' hide ToQueryParams;) the getter is marked @internal, which matches how DownloadBehavior.queryValue is handled in the same file. Since @internal symbols are skipped by the compliance matrix symbol check, no matrix update is needed.

I also checked the three other extensions in the repository, and all of them are necessary:

  • ToSnakeCase on Enum in supabase_common, extends a built-in type.
  • GoTrueClientPasskey on GoTrueClient in supabase_flutter, adds Flutter-only behavior to a class that lives in the pure Dart gotrue package.
  • GoTrueClientSignInProvider on GoTrueClient, same reason.

Testing

dart analyze and the full storage_client test suite pass. The existing TransformOptions.toQueryParams tests cover the getter unchanged.

Summary by CodeRabbit

  • New Features
    • Made the query-parameter conversion utility publicly available through the storage client package.
  • Documentation
    • Added documentation clarifying the utility’s role in converting transformation options into query parameters.

The ToQueryParams extension added a getter to a class in the same
library, so it can be a plain member instead. Marked @internal to keep
it out of the public API, matching DownloadBehavior.queryValue.
@spydon
spydon requested a review from a team as a code owner August 7, 2026 14:46
@github-actions github-actions Bot added the storage This issue or pull request is related to storage label Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change documents ToQueryParams as an internal API and makes it available through the storage client package export.

Changes

ToQueryParams visibility

Layer / File(s) Summary
Document and export ToQueryParams
packages/storage_client/lib/src/types.dart, packages/storage_client/lib/storage_client.dart
The ToQueryParams extension now has an @internal annotation and is exported by the package barrel.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: dshukertjr

🚥 Pre-merge checks | ✅ 5
✅ 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 clearly and concisely describes moving toQueryParams onto TransformOptions, which is the main change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/remove-unnecessary-extension

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/storage_client/lib/storage_client.dart`:
- Line 11: Update the storage_client package barrel export in
storage_client.dart so the internal TransformOptions.toQueryParams API is not
exposed publicly. Remove the broad src/types.dart export or use an export
restriction that hides toQueryParams while preserving the intended public types.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fe910085-e1ce-4ef9-80e2-a5e771a23fe2

📥 Commits

Reviewing files that changed from the base of the PR and between c6b5b35 and f81924d.

📒 Files selected for processing (2)
  • packages/storage_client/lib/src/types.dart
  • packages/storage_client/lib/storage_client.dart

export 'src/storage_client.dart';
export 'src/storage_file_api.dart';
export 'src/types.dart' hide ToQueryParams;
export 'src/types.dart';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Repository files matching storage_client.dart/types.dart:\n'
git ls-files | rg '(^packages/storage_client/lib/(storage_client|src/types)\.dart$|pubspec\.yaml$)'

printf '\nnearby storage_client.dart:\n'
cat -n packages/storage_client/lib/storage_client.dart | sed -n '1,40p'

printf '\nsrc/types.dart outline/header and relevant symbols:\n'
cat -n packages/storage_client/lib/src/types.dart | sed -n '1,220p'

printf '\nSearch for TransformOptions and toQueryParams usage/exports:\n'
rg -n "TransformOptions|toQueryParams|export .*types\.dart|`@internal`|pubspec" packages/storage_client -S

Repository: supabase/supabase-flutter

Length of output: 13125


🌐 Web query:

Dart meta package deprecated @internal exports library public API

💡 Result:

The @internal annotation in the Dart meta package is not deprecated; it remains the standard, supported way to mark declarations intended for use only within the package that defines them [1][2]. Contrary to the suggestion that @internal exports a public API, the annotation is specifically designed to prevent elements from being exposed as part of a package's public API [1][3]. The Dart analyzer enforces this by triggering diagnostics if you attempt to use it incorrectly [4][5]: 1. invalid_internal_annotation: This error occurs if you apply @internal to a declaration in a public library (a library outside of lib/src) or to an element with a private name [4]. It is intended only for private APIs within your package [6]. 2. invalid_export_of_internal_element: This error occurs if you try to export a declaration marked with @internal from a public library [5][7]. If you have code marked with @internal that is currently appearing in your public API, the analyzer expects you to either remove the @internal annotation (if it is meant to be public) or move the annotated declaration into a library inside the lib/src directory and hide it from your public exports using a hide clause [4][5]. It is not a mechanism for "internal exports" but a mechanism to guard against the accidental exposure of internal implementation details [1][8].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path

barrel = Path('packages/storage_client/lib/storage_client.dart')
src_types = Path('packages/storage_client/lib/src/types.dart')
to_query = Path('packages/storage_client/lib/src/types.dart').read_text()

# Parse only relevant directives and annotation context from the two files.
barrel_exports = [line.strip() for line in barrel.read_text().splitlines() if line.strip().startswith("export '")]
src_exports = [line.strip() for line in src_types.read_text().splitlines() if line.strip().startswith("export '")]

# Extract TransformOptions declaration and the toQueryParams block.
lines = to_query.splitlines()
start = None
for i, line in enumerate(lines, 1):
    if line.startswith('class TransformOptions'):
        start = i
        break
if start:
    block = '\\n'.join(lines[start-1:])
    block_lines = block.split('\\n')
    for j, bl in enumerate(block_lines):
        if 'Map<String, String> get toQueryParams {' in bl:
            context = block_lines[max(0, j-3):j+5]
            print('TransformOptions.get toQueryParams:')
            for idx_offset, cl in enumerate(context, max(0, j-3)):
                print(f'{start+j-1+idx_offset}: {cl}')
            print('contains_internal_annotation_on_block=' + str('`@internal`' in '\\n'.join(context)))

print('barrel_exports_contain_src/types.dart=' + str("export 'src/types.dart';" in barrel_exports))
print('export_uses_hide_clause_for_toQueryParams=' + str('toQueryParams' not in barrel.read_text()))
PY

Repository: supabase/supabase-flutter

Length of output: 633


Do not export TransformOptions.toQueryParams from the package barrel.

packages/storage_client/lib/storage_client.dart exports the whole src/types.dart library, so TransformOptions.toQueryParams is reachable through the public API despite its @internal annotation. Remove this export or hide toQueryParams from the export if the getter must remain internal.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/storage_client/lib/storage_client.dart` at line 11, Update the
storage_client package barrel export in storage_client.dart so the internal
TransformOptions.toQueryParams API is not exposed publicly. Remove the broad
src/types.dart export or use an export restriction that hides toQueryParams
while preserving the intended public types.

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

Labels

storage This issue or pull request is related to storage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant