feat(api-core): add injectable DateFormatter + StringFormatter/Slugify - #5526
Closed
adrians5j wants to merge 1 commit into
Closed
feat(api-core): add injectable DateFormatter + StringFormatter/Slugify#5526adrians5j wants to merge 1 commit into
adrians5j wants to merge 1 commit into
Conversation
Brings the same formatting utilities added on the admin side to the backend, so server code gets the same injectable, decoratable formatting via api-core's DI. - StringFormatter — consumer-facing string-transform API; exposes slugify() today, more methods later. Delegates to the fine-grained Slugify feature. - Slugify — single-method feature (execute()) holding Webiny's canonical slug options; the decorate seam behind StringFormatter.slugify(). - DateFormatter — deterministic absolute date/time formatting (UTC), decoratable. - All three register with ApiCoreFeature (always available) and are consumed by injecting the abstraction via a feature's `dependencies`. - Migrated the DI-connected backend slug caller: CreateGroupRepository now injects StringFormatter instead of importing the toSlug util. - Documented the new features in ai-context/core-features-reference.md. Left as-is on purpose: the contentModelGroup zod validation schema keeps using the toSlug util directly — it is a pure schema factory with no DI seam (mirrors the admin-side pure-util exceptions). Follows the admin-side PRs (#5512 DateFormatter, #5517 StringFormatter/Slugify). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
adrians5j
force-pushed
the
claude/api-core-formatters
branch
from
July 31, 2026 15:37
8206e2d to
51f603b
Compare
Member
Author
|
/vitest |
|
Vitest tests have been initiated (for more information, click here). ✨
❌ Failed packagesNo storage
|
adrians5j
force-pushed
the
release/6.5.0
branch
from
August 3, 2026 20:29
c087a46 to
58dec94
Compare
Open
1 task
Member
Author
|
Superseded by #5549, which targets |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backend counterpart to the admin-side formatting features (#5512, #5517). Brings
DateFormatter,StringFormatter, andSlugifyto@webiny/api-coreso server code gets the same injectable, decoratable formatting.Features (
@webiny/api-core)StringFormatter— consumer-facing string-transform API; exposesslugify()today, more methods later. Delegates toSlugify.Slugify— single-method (execute()) feature holding Webiny's canonical slug options; the decorate seam behindStringFormatter.slugify().DateFormatter— deterministic absolute date/time formatting (UTC,YYYY-MM-DD HH:mm), decoratable. No viewer-locale dependence, unlike the admin side.All three register with
ApiCoreFeature(always available). Same shape as the admin features, using api-core's@webiny/feature/apiDI. No hooks (no React) — backend consumers inject the abstraction via a feature'sdependencies.Usage
Override (per project) — decorate the fine-grained seam
Migrated
CreateGroupRepository(api-headless-cms) now injectsStringFormatterinstead of importing thetoSlugutil.Left as-is on purpose
contentModelGroupzod validation schema keeps using thetoSlugutil directly — it is a pure schema factory with no DI seam (mirrors the admin-side pure-util exceptions likePagePath).Docs
StringFormatter/Slugify/DateFormattertoai-context/core-features-reference.md.Testing
yarn check -p @webiny/api-core/-p @webiny/api-headless-cms✓contentModelGroup.crud.test.ts— 9 passed (exercises group create →CreateGroupRepositoryresolvingStringFormatterfrom the container and slugifying end-to-end).helpers/toSlug.test.ts— 2 passed (util retained for the validation schema).yarn lint/yarn format/yarn adio✓🤖 Generated with Claude Code