# @kitmi/types

> JavaScript semantic data types

Latest version **1.3.5** (published 2025-03-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @kitmi/types
pnpm add @kitmi/types
yarn add @kitmi/types
bun add @kitmi/types
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.5 |
| Published | 2025-03-24 |
| First published | 2023-12-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 159.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Rockie Guo |
| Maintainers | rockie |
| Keywords | kit, kitmi, jacaranda, types, errors |

## Links

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

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [@kitmi/utils](https://npm.io/package/@kitmi/utils.md) ^1.3.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.3.5 (latest) — 2025-03-24
- 1.3.4 — 2024-11-04
- 1.3.3 — 2024-07-09
- 1.3.2 — 2024-07-03
- 1.3.1 — 2024-07-03
- 1.3.0 — 2024-06-11
- 1.2.0 — 2024-05-30
- 1.1.3 — 2024-04-10
- 1.1.2 — 2024-04-10
- 1.1.1 — 2024-04-10
- 1.1.0 — 2024-04-10
- 1.0.0 — 2023-12-07

## README

# @kitmi/types

## JavaScript Semantic Data Types

`@kitmi/types` defines semantic data types with validation and sanitization.

## Installation

To install `@kitmi/types`, run the following command:

```bash
bun install @kitmi/types
```

Or if you're using npm:

```bash
npm install @kitmi/types
```

## Conventions

### Types

-   any
-   array
-   bigint
-   binary
-   boolean
-   datetime
-   integer
-   number
-   object
-   text

### Type Interface

```
name: "type name",
alias: ["type alias"],
defaultValue: null,

sanitize: (value, meta, i18n, context) => sanitized,
serialize: (value, meta) => string
```

### Common Type Meta

-   {boolean} plain - Keep raw value, don't try to preProcess and type cast before post processing
-   {boolean} optional - No error throw if value is null and default is null
-   {any} default - Default value if value is null
-   {array} enum - An array of values which the value of a enumerable type should be one of it
-   {any} const - The constant value of this field

### Enumerable Types

-   bigint
-   integer
-   number
-   text

### Validation Error

-   message
-   status = 400
-   code = E_INVALID_DATA
-   info = { value, meta, [i18n], [path] }

### Plugins

-   datetimeParser
-   bigintWriter
-   preProcess - [sync/async] (value, meta, opts: { rawValue, i18n, path }) => [ finished, processedValue ] or [ false ]
-   postProcess - [sync/async] (value, meta, opts: { rawValue, i18n, path }) => processedValue

Note: if preProcess or postProcess is async function, sanitize\_ should be called instead of sanitize

See `@kitmi/validators` for semantic validation.

### Notes

-   Object sanitization

Use `keepUnsanitized` for keeping those entries not defined in the object schema.

## License

-   MIT
-   Copyright (c) 2023 KITMI PTY LTD

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