Repository navigation
refactor(api-headless-cms-ddb,api-headless-cms-ddb-es,api-headless-cms-sql): fold CMS storage back into one root feature - #5970
Conversation
…s-sql): fold CMS storage back into one root feature #5933 split each CMS storage package into a root feature and a request feature, because @webiny/di had no per-request lifetime: the only way to get one instance per request was to register in the child container. The event handlers then had to know which feature goes where, through registerRequestStorage. @webiny/di 2.0 adds inContainerScope(): registered once in the root, built and cached per resolving (request) container. So each storage package is one feature again, registered once in the root, and declares per-request state itself: - entry DataLoaders, the CMS filter registries, and the OpenSearch field indexes, field index registry and model index provider are container scoped; - DbRegistry is container scoped, and the DDB+OS storage adds its entities to each request's registry through a decorator registered in the root; - the *RequestFeature features (unreleased) and the registerRequestStorage hook are removed. Extension decorators keep applying, because 2.0 collects decorators from the resolving container for transient and container-scoped registrations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/vitest |
|
Vitest tests have been initiated (for more information, click here). ✨
|
|
🚓 Slop Cop ✅ Nothing worth flagging. The diff looks consistent with the PR's stated intent and the code-style rules. Coherent refactor matching its stated intent, with no leaked secrets, debug code, or style violations in the added/changed lines. Automated, non-blocking heads-up from an LLM. It can be wrong — use your judgment. Regenerates on every push. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughCMS storage operations and registries now register through the main storage features instead of separate request features. Handler configuration no longer provides request-phase storage registration. Container-scoped registries and per-request tests reflect the updated registration model. ChangesCMS storage registration and request state
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to The CMS entity registration change has no identified merge-blocking issue; merge after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
|
/e2e |
|
/vitest |
|
Cypress E2E tests have been initiated (for more information, click here). ✨
|
|
Vitest tests have been initiated (for more information, click here). ✨
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Why
#5933 split each CMS storage package in two: a feature registered in the root container (tables, entities) and a
*RequestFeatureregistered per request (storage operations, DataLoaders, filter registries, OpenSearch extension points). That was the only way to get one instance per request. The catch was that every event handler had to know which feature to register where, throughregisterRequestStorage.@webiny/di2.0 (webiny/di#19, adopted in #5969) addsinContainerScope(): registered once in the root, but built and cached in each container that resolves it, which means once per request. So the split is no longer needed.What changes
Each CMS storage package is one feature again, registered once in the root. Each package now declares its own per-request state:
inContainerScope()api-headless-cms-ddb,api-headless-cms-ddb-esapi-headless-cms-storageapi-headless-cms-utils-osDbRegistry@webiny/dbThe filter registries were built with
newand registered as instances. Each now has a smallDefault*Registrysubclass that registers its defaults in the constructor, so the registries can be container scoped. They're mutable (extensions callregister()), so one shared instance would collect every request's registrations.DbRegistryis public (webiny/api/db) and has always been per request, so it stays per request throughinContainerScope(). The DDB+OpenSearch storage used to add its two entities from inside the request feature. Now it does that through a decorator registered once in the root (CmsEntitiesDbRegistryDecorator). That works because 2.0 applies decorators to every container-scoped instance.Removed:
HeadlessCmsDdbRequestFeature,HeadlessCmsDdbEsRequestFeatureandHeadlessCmsSqlRequestFeature. They only ever existed onnext; refactor(api-headless-cms-ddb,api-headless-cms-ddb-es,api-headless-cms-sql): register CMS storage operations per request #5933 hasn't been released.registerRequestStorage, from the AWS base, the standalone base,registerApiRequestStack, and the DDB, DDB+OpenSearch and SQL handlers. The DDB+OpenSearch handler now registersDbRegistryFeaturein the root.What stays the same
cmsStorageDecorators.test.tscovers this through the real DDB handler.cmsDataLoadersPerRequest.test.tscovers this through the real handler.Tests
cmsDataLoadersPerRequest,cmsStorageDecorators,freshInstall,featureFlagsBuildParam) pass with no request features registered anywhere.dataLoadersScope.test.tsis rewritten for the new setup. Storage is registered only in the root. It checks one DataLoaders instance per request and per container, and that each request gets its own filter registries.api-headless-cms-ddb-es/__tests__/perRequestState.test.ts: each request gets its ownDbRegistrywith the CMS entities, items registered in one request don't show up in the next, and the field index registry is built per request.api-headless-cms-ddb43,api-headless-cms-sql4,api-headless-cms-storage15,api-core267. The full CMS suites (DDB and SQL) and ACO were still running when I opened this. We'll check those in CI with/vitest.Next
Step 2 from the design doc: check ACO, audit logs and websockets storage. They're root factories. Under 2.0, a factory's decorators come from the resolving container, so extension decorators may already reach them. I'll test that before changing anything.
Workspace: wby-next11 · STORAGE PER REQ
🤖 Generated with Claude Code
Summary by CodeRabbit