Repository navigation
refactor: keep internal helpers out of the public api - #1950
Conversation
Prefix internal helpers, session managers, timers and transport methods with an underscore so the capability check no longer counts them as public API. Register the remaining public names in sdk-compliance.yaml and remove the unused sanitize_pattern_param.
|
No actionable comments were generated in the recent review. Summary
Change: Refactor Merge Risk:
|
…ors (#1979) Resolves SDK-2725. Continues the work from #1950 (SDK-2694). ## What changed Every package now declares `__all__`, and every service's public error classes can be imported from the package itself and from `supabase`. | Package | Change | | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `supabase_auth` | Replaced the `X as X` re-exports with grouped imports and `__all__`. Now exports the error classes from `errors.py` and `ErrorCode`. | | `realtime` | Replaced the `X as X` re-exports with grouped imports and `__all__`. Dropped the internal `T_ParamSpec` and `T_Retval` type variables from the package. | | `storage3` | Exports `StorageException`, `StorageApiError`, `StorageApiErrorMessage` and `VectorBucketException`. | | `supabase_functions` | Exports `FunctionsError`, `FunctionsHttpError`, `FunctionsRelayError`, `FunctionsApiErrorDict` and `__version__`. | | `supabase_utils` | Declares an empty `__all__`. Its public API lives in the `http` and `types` submodules. | | `supabase` | Turns `__all__` into a list. Adds `StorageApiError`, `VectorBucketException`, `AuthInvalidJwtError`, `CustomAuthError` and `UserDoesntExist`. Imports them from the package roots. | | `supabase.client` | Keeps the same error exports as `supabase`. | ## Breaking changes `realtime.T_ParamSpec` and `realtime.T_Retval` are no longer importable from `realtime`. They are still available from `realtime.types`. ## Tests `src/supabase/tests/test_exports.py` checks that every package declares `__all__`, that each listed name exists, and that the error classes are the same objects in the package, in `supabase` and in `supabase.client`.
Adds a capability for retrieving a single vector bucket by name. The storage service has a `GetVectorBucket` route, and the SDKs already implement it, but the registry has no feature for it: - supabase-js has `getVectorBucket` in `VectorBucketApi`. - supabase-flutter registers `SupabaseVectorsClient.getBucket` under `storage.vector_buckets.list_vector_buckets`, because no better feature exists. - supabase-py registers `StorageVectorsClient.get_bucket` as a supporting name of `storage.vector_buckets.access_vector_index` for the same reason (supabase/supabase-py#1950). It mirrors `storage.vector_buckets.get_index` for indexes. `bun test`, `bun run format-and-lint`, `bun run knip` and `bun run validate` pass.
After
mainswitched to v3 in #1370, the capability check flagged 57 public names that are new compared with 2.x and missing fromsdk-compliance.yaml. Most of them are internals that were public by accident.Made private
These are only used inside their own package, and none of them existed in 2.x:
AsyncSessionManager,SyncSessionManager,SessionManagerCommon,AsyncTimer,SyncTimer,save_session_and_sign_in,is_implicit_grant_flowand the helpers module functionscan_retry,model_validate_jsonRealtimeClient.send,send_no_wait,get_message_or_raise,RealtimeChannel.send_event,send_event_no_waitvalidate_adapter,validate_model,maybe_read_file,VectorBucketScope.with_metadata,VectorIndexScope.with_metadataon_error_responseRealtimeClient.sendwas public onAsyncRealtimeClientin 2.x. In v3 it is the low-level transport underRealtimeChannel.send_broadcastand the other channel methods, and no capability covers raw sends.sanitize_pattern_paramin postgrest was unused, so it is removed.Registered in
sdk-compliance.yamlBaseRequestClientas a supporting name ofdatabase.configuration.auto_retry, sinceBaseRequestClient.retryis already registered there.BucketNameas a supporting name ofstorage.file_buckets.create_file_bucket, since it is the return type ofcreate_bucket.ChannelLeaveMessagenext to the other shared realtime message models.StorageVectorsClient.get_bucketas a supporting name ofstorage.vector_buckets.access_vector_index. The capability registry has no entry for getting a single vector bucket yet.auth.session.auto_refreshnow usesno_public_symbols: true. It listedstart_auto_refresh_tokenon the session managers, which are now private. Users control auto refresh through theauto_refresh_tokenconstructor option, as the entry's note already says.Resolves SDK-2694