# enonic-types

> TypeScript types for Enonic XP

Latest version **7.15.3** (published 2025-08-06) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install enonic-types
pnpm add enonic-types
yarn add enonic-types
bun add enonic-types
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 7.15.3 |
| Published | 2025-08-06 |
| First published | 2019-11-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 44 |
| Unpacked size | 15.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Tom Arild Jakobsen |
| Maintainers | tajakobsen |
| Keywords | enonic |

## Links

- npm: https://www.npmjs.com/package/enonic-types
- Repository: https://github.com/ItemConsulting/enonic-types
- Homepage: https://github.com/ItemConsulting/enonic-types#readme
- Issues: https://github.com/ItemConsulting/enonic-types/issues
- npm.io page: https://npm.io/package/enonic-types

## Dependencies (44)

- [@enonic-types/core](https://npm.io/package/@enonic-types/core.md) ^7.15.3
- [@enonic-types/global](https://npm.io/package/@enonic-types/global.md) ^7.15.3
- [@enonic-types/lib-io](https://npm.io/package/@enonic-types/lib-io.md) ^7.15.3
- [@enonic-types/lib-app](https://npm.io/package/@enonic-types/lib-app.md) ^7.15.3
- [@enonic-types/lib-auth](https://npm.io/package/@enonic-types/lib-auth.md) ^7.15.3
- [@enonic-types/lib-grid](https://npm.io/package/@enonic-types/lib-grid.md) ^7.15.3
- [@enonic-types/lib-i18n](https://npm.io/package/@enonic-types/lib-i18n.md) ^7.15.3
- [@enonic-types/lib-mail](https://npm.io/package/@enonic-types/lib-mail.md) ^7.15.3
- [@enonic-types/lib-node](https://npm.io/package/@enonic-types/lib-node.md) ^7.15.3
- [@enonic-types/lib-repo](https://npm.io/package/@enonic-types/lib-repo.md) ^7.15.3
- [@enonic-types/lib-task](https://npm.io/package/@enonic-types/lib-task.md) ^7.15.3
- [@enonic-types/lib-admin](https://npm.io/package/@enonic-types/lib-admin.md) ^7.15.3
- [@enonic-types/lib-event](https://npm.io/package/@enonic-types/lib-event.md) ^7.15.3
- [@enonic-types/lib-value](https://npm.io/package/@enonic-types/lib-value.md) ^7.15.3
- [@enonic-types/lib-vhost](https://npm.io/package/@enonic-types/lib-vhost.md) ^7.15.3
- [@enonic-types/lib-common](https://npm.io/package/@enonic-types/lib-common.md) ^7.15.3
- [@enonic-types/lib-export](https://npm.io/package/@enonic-types/lib-export.md) ^7.15.3
- [@enonic-types/lib-portal](https://npm.io/package/@enonic-types/lib-portal.md) ^7.15.3
- [@enonic-types/lib-schema](https://npm.io/package/@enonic-types/lib-schema.md) ^7.15.3
- [@enonic-types/lib-cluster](https://npm.io/package/@enonic-types/lib-cluster.md) ^7.15.3
- [@enonic-types/lib-content](https://npm.io/package/@enonic-types/lib-content.md) ^7.15.3
- [@enonic-types/lib-context](https://npm.io/package/@enonic-types/lib-context.md) ^7.15.3
- [@enonic-types/lib-project](https://npm.io/package/@enonic-types/lib-project.md) ^7.15.3
- [@item-enonic-types/global](https://npm.io/package/@item-enonic-types/global.md) ^7.15.0
- [@enonic-types/lib-auditlog](https://npm.io/package/@enonic-types/lib-auditlog.md) ^7.15.3
- [@item-enonic-types/lib-sql](https://npm.io/package/@item-enonic-types/lib-sql.md) ^1.0.0
- [@enonic-types/lib-scheduler](https://npm.io/package/@enonic-types/lib-scheduler.md) ^7.15.3
- [@enonic-types/lib-websocket](https://npm.io/package/@enonic-types/lib-websocket.md) ^7.15.3
- [@item-enonic-types/lib-cron](https://npm.io/package/@item-enonic-types/lib-cron.md) ^1.1.4
- [@item-enonic-types/lib-menu](https://npm.io/package/@item-enonic-types/lib-menu.md) ^4.2.1
- [@item-enonic-types/lib-xslt](https://npm.io/package/@item-enonic-types/lib-xslt.md) ^2.1.1
- [@item-enonic-types/lib-cache](https://npm.io/package/@item-enonic-types/lib-cache.md) ^2.2.1
- [@item-enonic-types/lib-qrcode](https://npm.io/package/@item-enonic-types/lib-qrcode.md) ^2.0.2
- [@item-enonic-types/lib-router](https://npm.io/package/@item-enonic-types/lib-router.md) ^3.1.0
- [@item-enonic-types/lib-graphql](https://npm.io/package/@item-enonic-types/lib-graphql.md) ^2.1.0
- [@item-enonic-types/lib-testing](https://npm.io/package/@item-enonic-types/lib-testing.md) ^7.13.0
- [@item-enonic-types/lib-explorer](https://npm.io/package/@item-enonic-types/lib-explorer.md) ^3.20.6-patch1
- [@item-enonic-types/lib-mustache](https://npm.io/package/@item-enonic-types/lib-mustache.md) ^2.1.0
- [@item-enonic-types/lib-recaptcha](https://npm.io/package/@item-enonic-types/lib-recaptcha.md) ^3.0.1
- [@item-enonic-types/lib-thymeleaf](https://npm.io/package/@item-enonic-types/lib-thymeleaf.md) ^2.1.0
- [@item-enonic-types/lib-freemarker](https://npm.io/package/@item-enonic-types/lib-freemarker.md) ^2.0.2
- [@item-enonic-types/lib-http-client](https://npm.io/package/@item-enonic-types/lib-http-client.md) 3.2.2-patch1
- [@item-enonic-types/lib-notifications](https://npm.io/package/@item-enonic-types/lib-notifications.md) ^2.0.0
- [@item-enonic-types/lib-text-encoding](https://npm.io/package/@item-enonic-types/lib-text-encoding.md) ^2.1.0

## Recent versions

- 7.15.3 (latest) — 2025-08-06
- 0.5.0-next.1 (next) — 2022-07-01
- 7.13.0 — 2023-07-26
- 7.12.2 — 2023-04-14
- 7.12.1 — 2023-03-22
- 7.11.3 — 2023-01-19
- 7.11.2 — 2023-01-19
- 7.11.1 — 2022-12-06
- 7.11.0 — 2022-11-07
- 7.11.0-RC4 — 2022-11-04
- 7.11.0-RC3 — 2022-11-02
- 0.4.12 — 2022-10-24
- 0.5.0 — 2022-08-15
- 0.4.11 — 2022-06-29
- 0.4.10 — 2022-06-27
- … 165 more at https://npm.io/package/enonic-types/versions

## README

# TypeScript types for Enonic XP

> [!NOTE]
> There now exists [official TypeScript-types](https://www.npmjs.com/org/enonic-types) from Enonic.
> The new purpose of this library will be to provide types for all the libraries that doesn't have official support yet.

## Installing individual packages

You can install individual packages with support for Enonic libraries like this:

You can find the [complete list of supported packages on npm](https://www.npmjs.com/org/item-enonic-types).

```bash
npm i --save-dev @item-enonic-types/global
npm i --save-dev @item-enonic-types/lib-menu
```

## Update tsconfig.json

We recommend using [starter-tsup](https://github.com/enonic/starter-tsup) as the base of your XP-project.

To add the TypeScript-types you need to update your *tsconfig.json* with the following:

```json
{
  "compilerOptions": {
    "target": "es5",
    "strict": true,
    "sourceMap": true,
    "allowJs": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "strictNullChecks": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "types": ["@item-enonic-types/global"],
    "rootDirs": [
      "./src/main/resources",
      "./.xp-codegen"
    ],
    "paths": {
      "/lib/xp/*": ["./node_modules/@enonic-types/lib-*"],
      "/lib/*": [ "./node_modules/@item-enonic-types/lib-*" ,"./src/main/resources/lib/*"],
      "/site/*": ["./src/main/resources/site/*" ,"./.xp-codegen/site/*"]
    }
  },
  "include": [
    "./.xp-codegen/**/*",
    "./src/main/resources/**/*"
  ],
  "exclude": ["./build/*"]
}
```

Note that individual packages that are not directly under `"/lib/..."` needs to be mapped separately.

An example is Freemarker:

```diff
{
  "compilerOptions": {
    "paths": {
+     "/lib/tineikt/freemarker": ["./node_modules/@item-enonic-types/lib-freemarker"]
    }
  }
}
```

## Code generation

We recommend using this library together with the [xp-codegen-plugin](https://github.com/ItemConsulting/xp-codegen-plugin) Gradle plugin. *xp-codegen-plugin* will create a TypeScript `type` for your content-types. Those interfaces will be very useful together with this library.

## Example

We have an Enonic service that returns an article by id.

```typescript
import type { Article } from "../../site/content-types"; // 1
import { get as getOne, type Content } from "/lib/xp/content"; // 2

type ContentArticle = Content<Article, "my.awesome.project:Article">;

export function get(req: XP.Request): XP.Response { // 3
  const content = getOne<ContentArticle>({ 
    key: req.params.id!
  });

  assertIsDefined(content); // 4

  const article: Article = content.data;
  
  return {
    status: 200,
    body: article
  }
}

/** 
 * Create this function in a utilities file of your choice... 
 */
function assertIsDefined<T>(value: T): asserts value is NonNullable<T> {
  if (value === undefined || value === null) {
    throw new Error(`${value} is not defined`);
  }
}
```

 1. We import an `type Article = { ... }` generated by [xp-codegen-plugin](https://github.com/ItemConsulting/xp-codegen-plugin).
 2. The standard XP-libraries are mapped to their paths by the change to *tsconfig.json*.
 3. We use `XP.Request` and `XP.Response` to control the shape of our controller.
 4. `content` is of the type `Content<Article> | null`, but we can "assert" that it is not nullable (or throw an exception here if it is).
 
## Supported libraries

 * [CacheLibrary](./packages/cache)
 * [CronLibrary](./packages/cron)
 * [ExplorerLibrary](./packages/explorer)
 * [FreeMarkerLibrary](./packages/freemarker)
 * [GraphQLLibrary](./packages/graphql)
 * [HttpClientLibrary](./packages/http-client)
 * [MenuLibrary](./packages/menu)
 * [MustacheLibrary](./packages/mustache)
 * [NotificationsLibrary](./packages/notifications)
 * [QRCodeLibrary](./packages/qrcode)
 * [RecaptchaLibrary](./packages/recaptcha)
 * [RouterLibrary](./packages/router) 
 * [SqlLibrary](./packages/sql) 
 * [TestingLibrary](./packages/testing)
 * [TextEncodingLibrary](./packages/text-encoding)
 * [ThymeleafLibrary](./packages/thymeleaf)
 * [XsltLibrary](./packages/xslt)

---
_Source: https://npm.io/package/enonic-types · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
