# @prisma-next/utils

> Shared utility functions for Prisma Next

Latest version **0.16.0** (published 2026-07-21) · Apache-2.0 license · 0 weekly downloads

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

## Install

```sh
npm install @prisma-next/utils
pnpm add @prisma-next/utils
yarn add @prisma-next/utils
bun add @prisma-next/utils
```

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.16.0 |
| Published | 2026-07-21 |
| First published | 2025-12-30 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM |
| Node | >=24 |
| Dependencies | 0 |
| Unpacked size | 102.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 414 |
| Maintainers | sevinf, tylerhogarth, aqrln, wmadden-prisma |

## Links

- npm: https://www.npmjs.com/package/@prisma-next/utils
- Repository: https://github.com/prisma/prisma-next
- Homepage: https://github.com/prisma/prisma-next#readme
- Issues: https://github.com/prisma/prisma-next/issues
- npm.io page: https://npm.io/package/@prisma-next/utils

## Recent versions

- 0.16.0 (latest) — 2026-07-21
- 0.16.0-dev.35 (dev) — 2026-08-24
- 0.3.0-pr.112.2 (pr) — 2026-01-13
- 0.16.0-dev.34 — 2026-07-27
- 0.16.0-dev.33 — 2026-07-27
- 0.16.0-dev.32 — 2026-07-27
- 0.16.0-dev.31 — 2026-07-27
- 0.16.0-dev.30 — 2026-07-27
- 0.16.0-dev.29 — 2026-07-27
- 0.16.0-dev.28 — 2026-07-24
- 0.16.0-dev.27 — 2026-07-24
- 0.16.0-dev.26 — 2026-07-24
- 0.16.0-dev.25 — 2026-07-24
- 0.16.0-dev.24 — 2026-07-24
- 0.16.0-dev.23 — 2026-07-24
- … 998 more at https://npm.io/package/@prisma-next/utils/versions

## README

# @prisma-next/utils

> **Internal package.** This package is an implementation detail of [`prisma-next`](https://www.npmjs.com/package/prisma-next)
> and is published only to support its runtime. Its API is unstable and may change
> without notice. Do not depend on this package directly; install `prisma-next` instead.

Shared utility functions for Prisma Next.

## Overview

This package provides general-purpose utility functions used across the Prisma Next codebase. These utilities are target-agnostic and have no dependencies on other Prisma Next packages.

## Utilities

### `ifDefined(key, value)`

Returns an object with the key/value if value is defined, otherwise an empty object. Use with spread to conditionally include optional properties while satisfying `exactOptionalPropertyTypes`.

```typescript
import { ifDefined } from '@prisma-next/utils/defined';

// Instead of:
const obj = {
  required: 'value',
  ...(optional ? { optional } : {}),
};

// Use:
const obj = {
  required: 'value',
  ...ifDefined('optional', optional),
};
```

**Why use this?**

1. **Explicit**: You name exactly which properties are optional
2. **Intentional**: Won't accidentally strip other properties
3. **Type-safe**: Returns `{}` or `{ key: V }` (without undefined)
4. **exactOptionalPropertyTypes compatible**: Properly handles TypeScript's strict optional property checking

### `Result<T, F>`, `ok()`, `notOk()`, `okVoid()`

Generic Result type for representing success or failure outcomes. This is the standard way to return "expected failures" as values rather than throwing exceptions.

```typescript
import { type Result, ok, notOk, okVoid } from '@prisma-next/utils/result';

// Success result with value
function divide(a: number, b: number): Result<number, string> {
  if (b === 0) {
    return notOk('Division by zero');
  }
  return ok(a / b);
}

// Using the result
const result = divide(10, 2);
if (result.ok) {
  console.log(result.value); // 5
} else {
  console.error(result.failure); // error message
}

// Void success for validation
function validate(value: unknown): Result<void, string> {
  if (!value) {
    return notOk('Value is required');
  }
  return okVoid();
}
```

**Types:**
- `Ok<T>` - Success with value: `{ ok: true, value: T }`
- `NotOk<F>` - Failure with details: `{ ok: false, failure: F }`
- `Result<T, F>` - Discriminated union of `Ok<T> | NotOk<F>`

See `docs/Error Handling.md` for the full error taxonomy.

## Package Location

This package is part of the **framework domain**, **foundation layer**:
- **Domain**: framework (target-agnostic)
- **Layer**: foundation
- **Path**: `packages/1-framework/0-foundation/utils`

## Dependencies

This package has **no dependencies** - it's part of the innermost core ring and provides foundational utilities.

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