Skip to content

refactor(client)!: move Client and the streaming interface under Utopia\Client - #331

Merged
ChiragAgg5k merged 2 commits into
mainfrom
feat/client-namespace
Sep 23, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
feat/client-namespace

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Moves client's two classes that sit outside its own namespace, so the package can take the standard Utopia\Client\ shape before it is absorbed into appwrite/appwrite. This is step B of rfc/monorepo.md for client, released first so the absorb needs no interim handling. That handling is why appwrite/appwrite#13850 was closed.

Before After
Utopia\Client Utopia\Client\Client
Utopia\Psr18\StreamingClientInterface Utopia\Client\Psr18\StreamingClientInterface
  • src/Client/* is flattened into src/, and the manifest declares Utopia\Client\ → src/ instead of the bare Utopia\.
  • Tests move to Utopia\Client\Tests and tests/Client/* is flattened. README, docs and CHANGELOG use the new names.
  • src/compat.php (autoload files) registers class_alias for both old names at load time and keeps them until the next major. The aliases have to exist up front: PHP never autoloads a name while checking a declared type, so a lazy alias left storage's S3 device, typed against the old interface, rejecting the moved Retry decorator. The first CI run caught this. CompatTest pins both aliases, and in a fresh process it checks a consumer typed only against the old names.

This is the breaking change for a 0.5.0 release: bin/monorepo release client 0.5.0 once merged. Consumers on the old names keep working through the aliases.

Validation

  • bin/monorepo validate: all packages valid
  • bin/monorepo check client: Pint, PHPStan and Rector pass
  • bin/monorepo test client: 188 tests (185 existing plus three compat tests)
  • Dependents keep working through the aliases. Run linked against this client: span 108 tests, cdn 91, domains 52 plus 54 skipped e2e-style, storage 119 unit plus 32 S3 e2e. CI runs every dependent linked.

Follow-up

After client/0.5.0 is published: span, cdn, domains, messaging and storage here, plus agents in appwrite/appwrite, move to ^0.5 and the new names. The aliases are removed at client's next major.

…ia\Client

Utopia\Client and Utopia\Psr18\StreamingClientInterface sat outside the
package's own namespace, so client declared the bare Utopia\ prefix and
could not take the standard Utopia\<Ns>\ shape. They are now
Utopia\Client\Client and Utopia\Client\Psr18\StreamingClientInterface,
src/Client is flattened, and tests move to Utopia\Client\Tests.

src/compat.php keeps the old names working through a lazy autoloader
until the next major, so span, cdn, domains, messaging and storage keep
working unchanged; CompatTest pins both aliases.
@ChiragAgg5k
ChiragAgg5k requested a review from loks0n as a code owner September 23, 2026 10:38
@greptile-apps

greptile-apps Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The code appears safe to merge, although the existing non-blocking test-quality finding should still be cleaned up.

Fix All in Claude CodeFindings

  1. P2 Tests Mirror Alias Implementation ▶
Fix with agent prompt
### Issue 1
packages/client/tests/CompatTest.php:undefined-22
These reflection assertions repeat the alias mapping from `compat.php` instead of testing the promised compatibility behavior. They do not show that consumers can instantiate `Utopia\Client`, implement the old streaming interface, or use either legacy name in type checks. This violates the repository directive to test observable behavior rather than mirror source code. Replace both reflection assertions, including the same pattern on line 30, with construction and contract checks through the legacy names. This repository requirement must be satisfied before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR reorganizes the client package beneath the Utopia\Client\ namespace and preserves its former public names through Composer-loaded aliases.

  • Flattens the source and test directory structures and updates their namespaces.
  • Moves the streaming interface under Utopia\Client\Psr18.
  • Updates package documentation and autoload configuration.
  • Adds eager compatibility aliases and an observable legacy-consumer type-declaration test.

Reviews (2) · Last reviewed commit: "fix(client): register the old names befo..."

Comment thread packages/client/tests/CompatTest.php Resolved
PHP never autoloads a name while checking a declared type, so the lazy
aliases left storage's S3 device, whose property is typed against
Utopia\Psr18\StreamingClientInterface, rejecting the moved Retry
decorator. compat.php now calls class_alias up front, and CompatTest
checks a consumer typed only against the old names in a fresh process.
@ChiragAgg5k
ChiragAgg5k merged commit 0789301 into main Sep 23, 2026
13 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the feat/client-namespace branch September 23, 2026 10:53
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