feat: replace CpsDialogConfig class with interface + InjectionToken#700
Open
fateeand wants to merge 3 commits into
Open
Conversation
…o reduce bundle size
Contributor
Coverage report for library
Test suite run success2188 tests passing in 63 suites. Report generated by 🧪jest coverage report action from d2c5cfe |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the runtime cost of CpsDialogConfig by converting it from a DI-token-able class into a pure TypeScript interface, and introduces a dedicated CPS_DIALOG_CONFIG InjectionToken for dialog config injection. It also improves the composition docs site to render and deep-link injection tokens and more complex type expressions.
Changes:
- Replace
CpsDialogConfigclass with an interface and addCPS_DIALOG_CONFIGInjectionToken<CpsDialogConfig>, updating internal providers/injection sites accordingly. - Update unit tests and composition examples to provide/inject dialog config via
CPS_DIALOG_CONFIGand to stop instantiatingnew CpsDialogConfig(). - Extend docs-site generation/rendering to support “Tokens” blocks and improve type-link detection (including nested generics/unions) and link coverage.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| projects/cps-ui-kit/src/lib/services/cps-dialog/utils/cps-dialog-config.ts | Convert config to interface and add CPS_DIALOG_CONFIG InjectionToken. |
| projects/cps-ui-kit/src/lib/services/cps-dialog/internal/components/cps-dialog/cps-dialog.component.ts | Inject config via @Inject(CPS_DIALOG_CONFIG) instead of class token. |
| projects/cps-ui-kit/src/lib/services/cps-dialog/internal/components/cps-dialog/cps-dialog.component.spec.ts | Update test providers/config creation to use token + plain object. |
| projects/cps-ui-kit/src/lib/services/cps-dialog/internal/components/cps-confirmation/cps-confirmation.component.ts | Inject config via token in confirmation dialog component. |
| projects/cps-ui-kit/src/lib/services/cps-dialog/internal/components/cps-confirmation/cps-confirmation.component.spec.ts | Update confirmation test provider to use token. |
| projects/cps-ui-kit/src/lib/services/cps-dialog/cps-dialog.service.ts | Provide config via CPS_DIALOG_CONFIG when creating dialog component. |
| projects/cps-ui-kit/src/lib/services/cps-dialog/cps-dialog.service.spec.ts | Update service tests to pass plain config objects (no class instantiation). |
| projects/cps-ui-kit/src/lib/components/cps-radio-group/cps-radio-group.component.ts | Add @group Tokens metadata for CPS_RADIO_GROUP docs rendering. |
| projects/cps-ui-kit/src/lib/components/cps-icon/cps-icon.component.ts | Add @group Tokens metadata for ICONS_PATH docs rendering. |
| projects/composition/src/app/pipes/detect-type.pipe.ts | Replace generic-regex linking with identifier scanning for nested/union types. |
| projects/composition/src/app/components/shared/api-type/api-type.component.scss | Adjust spacing so union separators render cleanly with new segmentation. |
| projects/composition/src/app/components/service-docs-viewer/service-docs-viewer.component.html | Render “Tokens” section for services when present. |
| projects/composition/src/app/components/dialog-content/dialog-content.component.ts | Inject dialog config using CPS_DIALOG_CONFIG in composition example. |
| projects/composition/src/app/components/component-docs-viewer/component-docs-viewer.component.ts | Extend component viewer model to accept tokens data. |
| projects/composition/src/app/components/component-docs-viewer/component-docs-viewer.component.html | Render “Tokens” section for components when present. |
| projects/composition/src/app/api-data/types_map.json | Expand typesMap entries to include more components/services for deep links. |
| projects/composition/src/app/api-data/cps-radio-group.json | Add generated token docs block for radio group page. |
| projects/composition/src/app/api-data/cps-icon.json | Add generated token docs block for icon page. |
| projects/composition/src/app/api-data/cps-dialog.json | Add generated token docs block for dialog page. |
| projects/composition/src/app/api-data/cps-cron-validation.json | Normalize token description text to shared “component or service” wording. |
| api-generator/api-generator.js | Add tokens static message and route-aware service linkability for typesMap. |
| .github/workflows/check_pr_title_cc.yml | Run PR title check workflow on next-major as well as master. |
Contributor
Playwright test resultsDetails
|
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.
This PR targets the
next-majorbranch, rather thanmaster, as it is part of the next major version update.Summary
CpsDialogConfigwas a TypeScriptclassused both as a type annotation and — because Angular allows implicit class-based DI tokens — as the actual runtime provider token for injecting dialog config intoCpsDialogComponentandCpsConfirmationComponent. Being referenced as a DI token meant it couldn't be erased at compile time, so it emitted a real (empty) runtime constructor purely to support token identity.This PR:
CpsDialogConfigto a plaininterface(zero runtime cost — confirmed via the production FESM bundle,class CpsDialogConfigno longer appears anywhere in build output).CPS_DIALOG_CONFIG, a dedicatedInjectionToken<CpsDialogConfig>, and repoints all internal DI usages (theCpsDialogServiceprovider registration, and constructor injection inCpsDialogComponent/CpsConfirmationComponent) to use it instead of the class.Consumers who provided or injected
CpsDialogConfigas an Angular DI token must switch toCPS_DIALOG_CONFIG:Plain type annotations (
config: CpsDialogConfig) and object literals passed toCpsDialogService.open()/openConfirmationDialog()are unaffected — this only breaks consumers who usedCpsDialogConfigas a DI token.BREAKING CHANGE:
CpsDialogConfigis now an interface instead of a class and can no longer be used as an Angular DI token. InjectCPS_DIALOG_CONFIGinstead.Other changes: docs-site fixes
While verifying the new token rendered correctly on the API docs site, found and fixed a few pre-existing bugs in the shared docs infrastructure (
api-generator/api-generator.jsandprojects/composition):ServiceDocsViewerComponent(backs standalone-service pages like/dialog/api) had no "Tokens" rendering block at all, even though the data model already supported it — added one, matching the pattern already used byComponentDocsViewerComponent.ComponentDocsViewerComponent), and taggedCPS_RADIO_GROUP/ICONS_PATHwith@group Tokensso they now show up on/radio-group/apiand/icon/apitoo.typesMap(used to turn type names into clickable deep links) never included components or services, only interfaces/types/enums/classes — extended it to cover both, guarded by cross-referencing real routes inapp-routing.module.tsso services that are only ever embedded into another page (e.g.CpsCronValidationService, shown only on/scheduler/api) don't get linked to a non-existent route.DetectTypePipe's generic-type regex only handled one level of nesting with no unions, so types likeInjectionToken<CpsDialogConfig<any>>silently fell back to unlinked plain text. Replaced it with a general identifier scanner that links any recognized type name found anywhere inside an arbitrarily nested expression.Release notes: