chore(sdk): Implement @dotcms/types library - #31967
Conversation
|
Please use a Conventional Commit title format for this PR. For more information, see https://www.conventionalcommits.org/en/v1.0.0/ |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the code to integrate the new @dotcms/types library by updating the import paths for UVE_MODE (and DOTCMS_UVE_EVENT) across various modules. Additionally, a new Verdaccio configuration file has been added.
- Updated UVE_MODE and related import references in both production and test files.
- Added a new configuration file for Verdaccio.
- Ensured consistency in the new library usage while preserving existing functionality.
Reviewed Changes
Copilot reviewed 119 out of 119 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/track/withTrack.spec.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/track/models.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.spec.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withUVEToolbar.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withUVEToolbar.spec.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/dot-uve.store.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/dot-uve.store.spec.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/services/dot-page-api.service.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/services/dot-page-api.service.spec.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/edit-ema-editor.component.ts | Updated DOTCMS_UVE_EVENT import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/edit-ema-editor.component.spec.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/dot-uve-toolbar.component.spec.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/components/dot-editor-mode-selector/dot-editor-mode-selector.component.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-toolbar/components/dot-editor-mode-selector/dot-editor-mode-selector.component.spec.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/dot-ema-shell/dot-ema-shell.component.ts | Updated UVE_MODE import reference |
| core-web/libs/portlets/edit-ema/portlet/src/lib/dot-ema-shell/dot-ema-shell.component.spec.ts | Updated UVE_MODE import reference |
| core-web/libs/edit-content/src/lib/utils/functions.util.ts | Updated UVE_MODE import reference |
| core-web/.verdaccio/config.yml | Added new Verdaccio configuration file |
There was a problem hiding this comment.
I'll leave this comment with some general feedback, let me know what can be done here and what can be a ticket:
Public
-
Can we make
UVEEventHandlergeneric for better type safety?
Example:type UVEEventHandler<T = unknown> = (eventData?: T) => void;
Reference -
It looks like
DotCMSEditorConfigis a deprecated API. Should we mark it as@deprecatedor avoid moving it to the new library?
Reference -
In
Contentlet<T> = T & ContentTypeMainFields, we should provide a basicDotCMSBasicContentletinterface that developers can extend to create their custom contentlet types.
Reference
Example:interface MyCustomContentlet extends DotCMSBasicContentlet { customProperty1: string; customProperty2: number; // Extend as needed }
In our components, we could type like this:
<T extends DotCMSBasicContentlet = DotCMSBasicContentlet>
-
DotContainerAttributesandDotContentletAttributesseem related specifically to Edit Mode. Should we make it clear these are only for making elements editable? Also, should they be public or internal? They feel more internal.
Reference -
Can we remove
[key: string]: any;fromDotCMSContentlet?
If we provide a basic contentlet interface, users can extend it with their custom properties, helping us avoidanytype errors.
Reference -
What’s the
codeproperty inDotcmsNavigationItem? It’s currently typed asany. Should we refine its type?
Reference -
Is
DotCMSBasicGraphQLPagenecessary? If so, should it be internal?
Since we parse the GraphQL response before exposing it to the user, maybe this should not be public.
Reference. -
Same goes for
DotCMSGraphQLPageResponse. Also, this is tracked in #31965.
Reference -
In
DotCMSPageAsset, we should provide a separate basicURLContentMapinterface.
Reference -
The
Blockinterface name isn’t very descriptive. Could we rename it to something more meaningful, likeBlockEditorContent?
Reference
Internals
-
DotCMSCustomerParamsis a deprecated API. Should we mark it as@deprecatedor avoid moving it?
Reference -
We could use generics in the
DotCMSUVEFunctionarguments for better type safety.
Reference -
In
DotCMSContentletBound, the documentation should clarify that the payload must be a stringified JSON, not just "JSON format."
Reference -
DotCMSContentletBoundandDotCMSContainerBoundhave very similar interfaces. Maybe we could unify them?
Reference -
What about renaming
ContentTypeMainFieldstoDotCMSBasicContentlet, since it represents the basic fields a contentlet has?
Reference
fmontes
left a comment
There was a problem hiding this comment.
We need to talk about the categorization of this types I think we can do better to separate data coming from the APIs vs events for UVE and also fields.
zJaaal
left a comment
There was a problem hiding this comment.
To correct myself. I think is devDependencies instead of devDependency.
Great job! Kev
Public
Sure, added!
Removed!
Sure! I put the BasicContentlet as public and test that approach to extend other interfaces, all work!
Moved to internal
No :( it is used in dot-editable-text and we must to have this dynamical key
I change this to string | null, in our examples we dont use this property, and always return "null"
I add the type to the fetch responses, so now we are using it!
In that PR probably this can change
Added and exported!
Agree! I change all BlockEditor interfaces and add the prefix Internals
Deleted
Added!
Fixed!
I like to have both, is more simple and easy identify the "type" (Contentlet or Container) with the name
Changed! I like the name and we use a lot this interface in the new types, awesome suggestion! |
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces the adoption of the new @dotcms/types library by consolidating UVE_MODE imports and configuring a local package registry using Verdaccio. Key changes include:
- Replacing UVE_MODE imports from '@dotcms/uve/types' with '@dotcms/types' in multiple files.
- Adding a new Verdaccio configuration file at core-web/.verdaccio/config.yml.
- Updating internal event imports accordingly.
Reviewed Changes
Copilot reviewed 125 out of 125 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/track/models.ts | UVE_MODE import is updated to use the new library. |
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.ts | UVE_MODE import updated; removal of legacy import is shown. |
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.spec.ts | UVE_MODE import updated in unit tests. |
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withUVEToolbar.ts | UVE_MODE import updated in toolbar feature. |
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withUVEToolbar.spec.ts | UVE_MODE change in toolbar tests. |
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/dot-uve.store.ts | UVE_MODE import updated; ensures consistency across stores. |
| core-web/libs/portlets/edit-ema/portlet/src/lib/store/dot-uve.store.spec.ts | UVE_MODE import updated in test files. |
| core-web/libs/portlets/edit-ema/portlet/src/lib/services/dot-page-api.service.ts | UVE_MODE and internal types updated; explicit type cast added. |
| core-web/libs/portlets/edit-ema/portlet/src/lib/services/dot-page-api.service.spec.ts | UVE_MODE import update in service tests. |
| core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/* | Various UVE_MODE related imports updated in components and tests. |
| core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-shell/dot-experiments-shell.component.spec.ts | UVE_MODE import updated in experiments shell tests. |
| core-web/libs/edit-content/src/lib/utils/functions.util.ts | UVE_MODE import updated in utility functions. |
| core-web/.verdaccio/config.yml | New configuration file to support a local package registry using Verdaccio. |
Comments suppressed due to low confidence (1)
core-web/libs/portlets/edit-ema/portlet/src/lib/services/dot-page-api.service.ts:202
- Consider verifying that the explicit type cast to DotCMSGraphQLPageResponse is safe and that the resulting object fully conforms to the expected structure, to avoid future runtime type errors.
const pageEntity = graphqlToPageEntity({ page } as DotCMSGraphQLPageResponse);
### Note I prepare this both examples to test the libraries in local (use npm pack) You can use this or create our projects [examples.zip](https://github.com/user-attachments/files/19984602/examples.zip) This pull request introduces two main changes: the addition of a configuration file for a local package registry and the consolidation of imports for the `UVE_MODE` type. Below is a summary of the most important changes grouped by theme. ### Local Package Registry Configuration * Added a new configuration file, `core-web/.verdaccio/config.yml`, to set up a local package registry using Verdaccio. This file specifies storage paths, uplink to an external registry, package access and proxy settings, logging configurations, and offline publishing capabilities. ### Import Consolidation for `UVE_MODE` * Replaced all imports of `UVE_MODE` from `@dotcms/uve/types` with imports from `@dotcms/types` across multiple files. This change standardizes the import path for `UVE_MODE` and simplifies dependency management. Affected files include: - `core-web/libs/edit-content/src/lib/utils/functions.util.ts` - `core-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-shell/dot-experiments-shell.component.spec.ts` - Various files in the `core-web/libs/portlets/edit-ema/portlet` directory, including components, services, and store-related files. [[1]](diffhunk://#diff-8843e3a4ce8c16e83408b1a6dcc3ad54eaddd17f8e986bbdb502e11bd4446ab4R35) [[2]](diffhunk://#diff-8843e3a4ce8c16e83408b1a6dcc3ad54eaddd17f8e986bbdb502e11bd4446ab4L44) [[3]](diffhunk://#diff-677330662fea6dadc7e48fd8455ec2a6fe60d624c7ed1f01f0a3e985aacd05c6R26-L28) [[4]](diffhunk://#diff-15ea49d517da2919b00a29c3db20ded2e0e19d0a2b0ef65f65e63b36f252e2fdL6-R6) [[5]](diffhunk://#diff-6f27ece37ce65b48ea79f5a4ffc71c4885dbb2edde6783e16d1810c42b5ae92dR16-L17) [[6]](diffhunk://#diff-3eaa147616a5d1ff374a5fa27b0f38f0159a9039ef7e8d672dec43631f48a9e1R23-L30) [[7]](diffhunk://#diff-217a9e619d6590c4f652e85353b9637ba5e464ddeb0424be35aef39bb8dceb30R41-L42) [[8]](diffhunk://#diff-34ddc5fbacaf04b962f2037385ed284310d5faf35ba409d5705b2caadd5d796aR63) [[9]](diffhunk://#diff-34ddc5fbacaf04b962f2037385ed284310d5faf35ba409d5705b2caadd5d796aL82) [[10]](diffhunk://#diff-24dc496db1eb6feb3e10a031baa4b4b63c20f1cd02ade574065f6b967f11c365R49-L51) [[11]](diffhunk://#diff-1dad8c8d685da624eaecb75a9607377dfa7168120d182df479ffceaed1a87858L3-R3) [[12]](diffhunk://#diff-9acb0e7dc2619395c49047164381778d2b6d6c41f58b30aa3cd6a798044007c6L20-R20) [[13]](diffhunk://#diff-9acb0e7dc2619395c49047164381778d2b6d6c41f58b30aa3cd6a798044007c6L202-R202) [[14]](diffhunk://#diff-900c5f83c0b1dea02a19ae54db7857ee3d11ce7ed9b2df4bf19000b9fe0d6f2bR25) [[15]](diffhunk://#diff-900c5f83c0b1dea02a19ae54db7857ee3d11ce7ed9b2df4bf19000b9fe0d6f2bL35) [[16]](diffhunk://#diff-42fdc01a4da73b6ecede38045c03fd631badeb73e299fbb4ed6442eb1f3ad963L5-R5) [[17]](diffhunk://#diff-7a5de702ac1dc81304f4c31816f5c0363aa56141f8afa583a87856e7a0d8482dR9-L10) [[18]](diffhunk://#diff-e6d3fb6319626fa85a4fc6894b57935843713366be593de6dd1dc5ed68bf6afcL18-R18) [[19]](diffhunk://#diff-48915538475425e5656151bb2a73df7a99b4c80c2817c085f96352ef3252d5cbR9-L11) [[20]](diffhunk://#diff-86e692578757ed7f4f6cba5d0aeb07641312f3b17885825d1a45987153ae87f0R13-L14) [[21]](diffhunk://#diff-5059cad5a5fc6dd068ce3c4c052fb2c1e46c7033530f14f519c0dbc32f491458L1-R1) These changes improve local development workflows and ensure consistency in type usage across the codebase. --------- Co-authored-by: Kevin Davila <56242609+kevindaviladev@users.noreply.github.com>
`sdk-types` needs no code change: `libs/sdk/types/tsconfig.json` has carried `strict: true` plus the four extra safety flags since the library was created (#31967), and `tsc -p tsconfig.lib.json --noEmit` passes with zero errors. It is already enforced too. Because `tsconfig.lib.json` sets `"declaration": true`, `@rollup/plugin-typescript` sits in the Rollup chain and reports type diagnostics, so `sdk-types:build` fails on a strict violation — verified by removing a constructor assignment and watching the build report TS2564. CI builds every project via the `build-test` execution in `core-web/pom.xml`, so the gate already runs on each PR. A dedicated `typecheck` target would be redundant. `lint` does not catch this: ESLint reports lint rules, not TS diagnostics. What was actually missing is documentation, so the remaining 42 projects in epic #35932 have a pattern to follow: - Add a `## TypeScript Strict Mode` section covering the per-project flags, what enforces them, and the Vite exception (esbuild skips type checking, which is why the Nx Vite plugin infers a separate `typecheck` target). - Fix the line that forbade `"strict": true` in project tsconfigs. It sat under the Jest config guidance but read as a blanket ban, contradicted `docs/frontend/TYPESCRIPT_STANDARDS.md`, and blocked the epic outright. The restriction now points at `tsconfig.spec.json`, which is what it meant. Closes #35935 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Note
I prepare this both examples to test the libraries in local (use npm pack)
You can use this or create our projects
examples.zip
This pull request introduces two main changes: the addition of a configuration file for a local package registry and the consolidation of imports for the
UVE_MODEtype. Below is a summary of the most important changes grouped by theme.Local Package Registry Configuration
core-web/.verdaccio/config.yml, to set up a local package registry using Verdaccio. This file specifies storage paths, uplink to an external registry, package access and proxy settings, logging configurations, and offline publishing capabilities.Import Consolidation for
UVE_MODEUVE_MODEfrom@dotcms/uve/typeswith imports from@dotcms/typesacross multiple files. This change standardizes the import path forUVE_MODEand simplifies dependency management. Affected files include:core-web/libs/edit-content/src/lib/utils/functions.util.tscore-web/libs/portlets/dot-experiments/portlet/src/lib/dot-experiments-shell/dot-experiments-shell.component.spec.tscore-web/libs/portlets/edit-ema/portletdirectory, including components, services, and store-related files. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21]These changes improve local development workflows and ensure consistency in type usage across the codebase.
This PR fixes: #31840