feat: injectable StringFormatter + Slugify (app-admin & api-core) + api-core DateFormatter - #5549
Open
adrians5j wants to merge 7 commits into
Open
feat: injectable StringFormatter + Slugify (app-admin & api-core) + api-core DateFormatter#5549adrians5j wants to merge 7 commits into
adrians5j wants to merge 7 commits into
Conversation
…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>
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>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Aug 4, 2026
Member
Author
|
/vitest |
|
Vitest tests have been initiated (for more information, click here). ✨
❌ Failed packagesDDB
|
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Member
Author
|
/e2e |
|
Cypress E2E tests have been initiated (for more information, click here). ✨
|
…biny-js into claude/formatters-next
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.
Injectable, decoratable formatting features on both admin and backend. Combines #5517 (admin) and #5526 (api-core), rebased from
release/6.5.0ontonext.Features
@webiny/app-adminStringFormatter— consumer-facing string-transform API (parallel to the existingDateFormatter). Exposesslugify()today; methods grow over time.Slugify— single-method (execute()) feature holding Webiny's canonical slug options; the fine-grained decorate seam behindStringFormatter.slugify().@webiny/api-coreStringFormatter/Slugify— backend counterparts using api-core's@webiny/feature/apiDI. No hooks (no React).DateFormatter— deterministic absolute date/time formatting (UTC,YYYY-MM-DD HH:mm), decoratable. No viewer-locale dependence, unlike the admin side.Consumers use
StringFormatter; to change slug logic a project decoratesSlugifyalone — a smaller surface than decorating the whole formatter. The canonical slug options are a private detail of the default impl, so the contract stays independent of any specific slug library.Override (per project) — decorate the fine-grained seam
Migrated
RolesPresenter,ApiKeysPresenter,TeamsPresenterFolderTreePresenter, folder create dialog (useCreateDialog)ModelGroupPresenterCreateGroupRepositorynow injectsStringFormatterinstead of importing thetoSlugutil.slugifydependency from app-aco and app-headless-cms.Left as-is on purpose
toKey— strict machine-key transform ({ lower: true, strict: true }), not a display slug; kept as directslugifyfor now (follow-up).PagePath/pagePathFromTitle— pure value objects / exported utils with no DI seam.@webiny/formuseGenerateSlug— base-layer package that cannot depend on@webiny/app-admin.contentModelGroupzod validation schema — pure schema factory with no DI seam; keeps using thetoSlugutil directly.Docs
ai-context/core-features-reference.md— addedStringFormatter/Slugify/DateFormatter.TODO / follow-ups
toKeyinto the feature system as its ownStringFormattermethod backed by its own fine-grained feature.Notes
release/6.5.0; closed in favor of this).🤖 Generated with Claude Code