feat: add injectable StringFormatter + Slugify features (app-admin) - #5517
Open
adrians5j wants to merge 1 commit into
Open
feat: add injectable StringFormatter + Slugify features (app-admin)#5517adrians5j wants to merge 1 commit into
adrians5j wants to merge 1 commit into
Conversation
adrians5j
force-pushed
the
claude/slugify-feature
branch
from
July 30, 2026 11:19
6ed35d5 to
ac65689
Compare
…ings The `slugify` npm package was imported directly across many admin presenters, each repeating the same options object, so slug generation could drift and projects had no supported way to override it. Introduce two injectable, decoratable features in @webiny/app-admin: - StringFormatter — the consumer-facing string-transform API (parallel to DateFormatter). Its methods will grow over time; for now it exposes slugify(). - Slugify — a small, single-method feature (execute()) holding Webiny's canonical slug options. StringFormatter.slugify() delegates to Slugify.execute(). Consumers use StringFormatter. To change slug logic, a project decorates Slugify alone — a smaller surface than decorating the whole formatter. Both are registered with the core admin features (always available); StringFormatter's feature registers Slugify as its internal dependency. - @webiny/app-admin: new features/stringFormatter + features/slugify, registered in Admin core and exported from the package root. - Migrated the DI-connected, user-facing form-slug generators to StringFormatter: Roles/ApiKeys/Teams presenters (app-admin), FolderTreePresenter + folder create dialog (app-aco), ModelGroupPresenter (app-headless-cms). Dropped the now-unused slugify dependency from app-aco and app-headless-cms. - Documented the injectable-formatter convention in AGENTS.md. Left as-is on purpose: app-website-builder experiment `toKey` (internal keys must stay stable regardless of project overrides), the pure PagePath / pagePathFromTitle value utils (no DI seam, publicly exported), and @webiny/form's useGenerateSlug (base layer, cannot depend on app-admin). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
adrians5j
force-pushed
the
claude/slugify-feature
branch
from
July 31, 2026 10:45
ac65689 to
9c8fccb
Compare
adrians5j
added a commit
that referenced
this pull request
Jul 31, 2026
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>
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.
Problem
The
slugifynpm package was imported directly across many admin presenters, each repeating the same options object. Slug generation could drift, and projects had no supported way to override it — some resorted to intercepting it at the bundler level.Solution
Two injectable, decoratable features in
@webiny/app-admin:StringFormatter— the consumer-facing string-transform API (parallel toDateFormatter). Its methods will grow over time; today it exposesslugify().Slugify— a small, single-method feature (execute()) holding Webiny's canonical slug options.StringFormatter.slugify()delegates toSlugify.execute()internally. Consumers useStringFormatter; to change slug logic a project decoratesSlugifyalone — a smaller surface than decorating the whole formatter. Both register with the core admin features (always available);StringFormatterFeatureregistersSlugifyas its internal dependency.The abstractions take
(value) => string— no options bag. The canonical options are a private detail ofDefaultSlugify, so the contract stays independent of any specific slug library. A project changes behavior by decorating, not by passing per-call options.Design (per Slack thread)
Migrated (DI-connected, user-facing form-slug generation →
StringFormatter)RolesPresenter,ApiKeysPresenter,TeamsPresenterFolderTreePresenter, folder create dialog (useCreateDialog)ModelGroupPresenterslugifydependency from app-aco and app-headless-cms.Override (per project) — decorate the fine-grained seam
Left as-is on purpose
toKey— uses strict options ({ lower: true, strict: true }) to generate internal experiment keys; kept as directslugifyusage for now (see TODO).PagePath/pagePathFromTitle— pure value objects / publicly-exported utils with no DI seam.@webiny/formuseGenerateSlug— base-layer package that cannot depend on@webiny/app-admin.TODO / follow-ups
toKeycall site — bring the app-website-builder experimenttoKeyinto the feature system. It is a distinct transform (strict machine key, not a display slug), so it should become its own method onStringFormatter(e.g.toKey()) backed by its own fine-grained feature — not a bareslugifycall. Tracked as a follow-up so this PR stays focused.@webiny/api-core: recreateDateFormatterandStringFormatter/Slugifyusing api-core's DI, so backend code gets the same injectable, decoratable formatting.Testing
yarn check✓ for app-admin / app-aco / app-headless-cmsyarn lint/yarn format/yarn adio✓🤖 Generated with Claude Code