Skip to content

chore(sdk): Implement @dotcms/types library - #31967

Merged
KevinDavilaDotCMS merged 17 commits into
mainfrom
31840-sdk-create-a-dotcmstypes
May 2, 2025
Merged

chore(sdk): Implement @dotcms/types library #31967
KevinDavilaDotCMS merged 17 commits into
mainfrom
31840-sdk-create-a-dotcmstypes

Conversation

@KevinDavilaDotCMS

@KevinDavilaDotCMS KevinDavilaDotCMS commented Apr 23, 2025

Copy link
Copy Markdown
Member

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_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] [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

@KevinDavilaDotCMS KevinDavilaDotCMS linked an issue Apr 23, 2025 that may be closed by this pull request
@dotcms-github-app

Copy link
Copy Markdown

Please use a Conventional Commit title format for this PR. For more information, see https://www.conventionalcommits.org/en/v1.0.0/

@KevinDavilaDotCMS KevinDavilaDotCMS changed the title WIP - Project created and configured. Pending define main export chore(sdk): Implement @dotcms/types library Apr 23, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@KevinDavilaDotCMS
KevinDavilaDotCMS marked this pull request as ready for review April 28, 2025 18:28

@rjvelazco rjvelazco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave this comment with some general feedback, let me know what can be done here and what can be a ticket:

Public

  1. Can we make UVEEventHandler generic for better type safety?
    Example: type UVEEventHandler<T = unknown> = (eventData?: T) => void;
    Reference

  2. It looks like DotCMSEditorConfig is a deprecated API. Should we mark it as @deprecated or avoid moving it to the new library?
    Reference

  3. In Contentlet<T> = T & ContentTypeMainFields, we should provide a basic DotCMSBasicContentlet interface 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>
  4. DotContainerAttributes and DotContentletAttributes seem 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

  5. Can we remove [key: string]: any; from DotCMSContentlet?
    If we provide a basic contentlet interface, users can extend it with their custom properties, helping us avoid any type errors.
    Reference

  6. What’s the code property in DotcmsNavigationItem? It’s currently typed as any. Should we refine its type?
    Reference

  7. Is DotCMSBasicGraphQLPage necessary? 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.

  8. Same goes for DotCMSGraphQLPageResponse. Also, this is tracked in #31965.
    Reference

  9. In DotCMSPageAsset, we should provide a separate basic URLContentMap interface.
    Reference

  10. The Block interface name isn’t very descriptive. Could we rename it to something more meaningful, like BlockEditorContent?
    Reference

Internals

  1. DotCMSCustomerParams is a deprecated API. Should we mark it as @deprecated or avoid moving it?
    Reference

  2. We could use generics in the DotCMSUVEFunction arguments for better type safety.
    Reference

  3. In DotCMSContentletBound, the documentation should clarify that the payload must be a stringified JSON, not just "JSON format."
    Reference

  4. DotCMSContentletBound and DotCMSContainerBound have very similar interfaces. Maybe we could unify them?
    Reference

  5. What about renaming ContentTypeMainFields to DotCMSBasicContentlet, since it represents the basic fields a contentlet has?
    Reference

cc: @zJaaal @KevinDavilaDotCMS @fmontes

Comment thread core-web/.verdaccio/config.yml

@fmontes fmontes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread core-web/libs/sdk/types/package.json Outdated
Comment thread core-web/libs/sdk/types/package.json
Comment thread core-web/libs/sdk/types/src/lib/page/public.ts Outdated
Comment thread core-web/libs/sdk/types/src/lib/page/public.ts
Comment thread core-web/libs/sdk/types/README.md

@zJaaal zJaaal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To correct myself. I think is devDependencies instead of devDependency.

Great job! Kev

Comment thread core-web/libs/sdk/types/package.json
Comment thread core-web/libs/sdk/types/jest.config.ts
Comment thread core-web/libs/sdk/types/project.json
Comment thread core-web/libs/sdk/types/src/lib/page/public.ts Outdated
Comment thread core-web/libs/sdk/types/tsconfig.json
Comment thread core-web/libs/sdk/uve/package.json Outdated
Comment thread core-web/package.json
Comment thread core-web/libs/sdk/angular/package.json Outdated
Comment thread core-web/libs/sdk/client/package.json Outdated
Comment thread core-web/libs/sdk/react/package.json Outdated
@KevinDavilaDotCMS

KevinDavilaDotCMS commented Apr 30, 2025

Copy link
Copy Markdown
Member Author

Public

  1. Can we make UVEEventHandler generic for better type safety?
    Example: type UVEEventHandler<T = unknown> = (eventData?: T) => void;
    Reference

Sure, added!

  1. It looks like DotCMSEditorConfig is a deprecated API. Should we mark it as @deprecated or avoid moving it to the new library?
    Reference

Removed!

  1. In Contentlet<T> = T & ContentTypeMainFields, we should provide a basic DotCMSBasicContentlet interface 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>

Sure! I put the BasicContentlet as public and test that approach to extend other interfaces, all work!
But we cannot remove yet the Contentlet<> because it is used in DotEditableText component

  1. DotContainerAttributes and DotContentletAttributes seem 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

Moved to internal

  1. Can we remove [key: string]: any; from DotCMSContentlet?
    If we provide a basic contentlet interface, users can extend it with their custom properties, helping us avoid any type errors.
    Reference

No :( it is used in dot-editable-text and we must to have this dynamical key

  1. What’s the code property in DotcmsNavigationItem? It’s currently typed as any. Should we refine its type?
    Reference

I change this to string | null, in our examples we dont use this property, and always return "null"

  1. Is DotCMSBasicGraphQLPage necessary? 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.

I add the type to the fetch responses, so now we are using it!

  1. Same goes for DotCMSGraphQLPageResponse. Also, this is tracked in SDK: Refactor page.get() to Always Use GraphQL with Stable Response #31965.
    Reference

In that PR probably this can change

  1. In DotCMSPageAsset, we should provide a separate basic URLContentMap interface.
    Reference

Added and exported!

  1. The Block interface name isn’t very descriptive. Could we rename it to something more meaningful, like BlockEditorContent?
    Reference

Agree! I change all BlockEditor interfaces and add the prefix

Internals

  1. DotCMSCustomerParams is a deprecated API. Should we mark it as @deprecated or avoid moving it?
    Reference

Deleted

  1. We could use generics in the DotCMSUVEFunction arguments for better type safety.
    Reference

Added!

  1. In DotCMSContentletBound, the documentation should clarify that the payload must be a stringified JSON, not just "JSON format."
    Reference

Fixed!

  1. DotCMSContentletBound and DotCMSContainerBound have very similar interfaces. Maybe we could unify them?
    Reference

I like to have both, is more simple and easy identify the "type" (Contentlet or Container) with the name

  1. What about renaming ContentTypeMainFields to DotCMSBasicContentlet, since it represents the basic fields a contentlet has?
    Reference

Changed! I like the name and we use a lot this interface in the new types, awesome suggestion!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Comment thread core-web/.verdaccio/config.yml
@KevinDavilaDotCMS
KevinDavilaDotCMS added this pull request to the merge queue May 2, 2025
Merged via the queue into main with commit f306af5 May 2, 2025
@KevinDavilaDotCMS
KevinDavilaDotCMS deleted the 31840-sdk-create-a-dotcmstypes branch May 2, 2025 17:06
spbolton pushed a commit that referenced this pull request Jun 20, 2025
### 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>
nicobytes added a commit that referenced this pull request Aug 7, 2026
`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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK: create a @dotcms/types

6 participants