Skip to content

feat(client-generator-ts): [breaking] add support for mapped enums#28180

Merged
jkomyno merged 3 commits intonextfrom
feat/mapped-enums
Oct 1, 2025
Merged

feat(client-generator-ts): [breaking] add support for mapped enums#28180
jkomyno merged 3 commits intonextfrom
feat/mapped-enums

Conversation

@jkomyno
Copy link
Copy Markdown
Contributor

@jkomyno jkomyno commented Sep 29, 2025

Breaking change

This PR:

Before this PR

This Prisma enum definition

enum PaymentProvider {
  MixplatSMS    @map("mixplat/sms")
  InternalToken @map("internal/token")
  Offline       @map("offline")

  @@map("payment_provider")
}

would result into this TypeScript value

export const PaymentProvider: {
  MixplatSMS: 'MixplatSMS',
  InternalToken: 'InternalToken',
  Offline: 'Offline'
}

After this PR

This Prisma enum definition (same as the above one)

enum PaymentProvider {
  MixplatSMS    @map("mixplat/sms")
  InternalToken @map("internal/token")
  Offline       @map("offline")

  @@map("payment_provider")
}

would result into this TypeScript value

export const PaymentProvider: {
  MixplatSMS: 'mixplat/sms'
  InternalToken: 'internal/token'
  Offline: 'offline'
}

/integration

@jkomyno jkomyno added this to the 7.0.0 milestone Sep 29, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 29, 2025

size-limit report 📦

Path Size
packages/client/runtime/library.js 197.91 KB (+0.08% 🔺)
packages/client/runtime/library.d.ts 126.91 KB (+0.33% 🔺)
packages/client/runtime/binary.js 658.48 KB (+0.03% 🔺)
packages/client/runtime/binary.d.ts 26 B (0%)
packages/client/runtime/edge.js 166.8 KB (+0.09% 🔺)
packages/client/runtime/edge-esm.js 166.26 KB (+0.09% 🔺)
packages/client/runtime/wasm-engine-edge.js 128.92 KB (+0.11% 🔺)
packages/client/runtime/index-browser.js 34.5 KB (0%)
packages/client/runtime/index-browser.d.ts 11.64 KB (0%)
packages/cli/build/index.js 2.63 MB (+0.02% 🔺)
packages/client/prisma-client-0.0.0.tgz 26.06 MB (+0.01% 🔺)
packages/cli/prisma-0.0.0.tgz 16.76 MB (+0.02% 🔺)
packages/bundle-size/da-workers-libsql/output.tgz 932.71 KB (+0.01% 🔺)
packages/bundle-size/da-workers-neon/output.tgz 1007.52 KB (+0.01% 🔺)
packages/bundle-size/da-workers-pg/output.tgz 1006.78 KB (+0.01% 🔺)
packages/bundle-size/da-workers-planetscale/output.tgz 948.94 KB (+0.01% 🔺)
packages/bundle-size/da-workers-d1/output.tgz 914.57 KB (+0.01% 🔺)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 29, 2025

Client memory tests, node 24, library:

✅ Success

@jkomyno jkomyno marked this pull request as ready for review October 1, 2025 12:37
@jkomyno jkomyno merged commit 6741186 into next Oct 1, 2025
1213 of 1217 checks passed
@jkomyno jkomyno deleted the feat/mapped-enums branch October 1, 2025 12:38
aqrln pushed a commit that referenced this pull request Nov 17, 2025
…28180)

**Breaking change**

This PR:
- closes #8446
- closes #273
- closes
[TML-1438](https://linear.app/prisma-company/issue/TML-1438/add-support-for-mapped-enums)
- translates PSL mapped enums into TS mapped enums

## Before this PR

This Prisma enum definition

```prisma
enum PaymentProvider {
  MixplatSMS    @Map("mixplat/sms")
  InternalToken @Map("internal/token")
  Offline       @Map("offline")

  @@Map("payment_provider")
}
```

would result into this TypeScript value

```typescript
export const PaymentProvider: {
  MixplatSMS: 'MixplatSMS',
  InternalToken: 'InternalToken',
  Offline: 'Offline'
}
```

## After this PR

This Prisma enum definition (same as the above one)

```prisma
enum PaymentProvider {
  MixplatSMS    @Map("mixplat/sms")
  InternalToken @Map("internal/token")
  Offline       @Map("offline")

  @@Map("payment_provider")
}
```

would result into this TypeScript value

```
export const PaymentProvider: {
  MixplatSMS: 'mixplat/sms'
  InternalToken: 'internal/token'
  Offline: 'offline'
}
```

/integration

---------

Co-authored-by: jkomyno <12381818+jkomyno@users.noreply.github.com>
aqrln pushed a commit that referenced this pull request Nov 17, 2025
…28180)

**Breaking change**

This PR:
- closes #8446
- closes #273
- closes
[TML-1438](https://linear.app/prisma-company/issue/TML-1438/add-support-for-mapped-enums)
- translates PSL mapped enums into TS mapped enums

## Before this PR

This Prisma enum definition

```prisma
enum PaymentProvider {
  MixplatSMS    @Map("mixplat/sms")
  InternalToken @Map("internal/token")
  Offline       @Map("offline")

  @@Map("payment_provider")
}
```

would result into this TypeScript value

```typescript
export const PaymentProvider: {
  MixplatSMS: 'MixplatSMS',
  InternalToken: 'InternalToken',
  Offline: 'Offline'
}
```

## After this PR

This Prisma enum definition (same as the above one)

```prisma
enum PaymentProvider {
  MixplatSMS    @Map("mixplat/sms")
  InternalToken @Map("internal/token")
  Offline       @Map("offline")

  @@Map("payment_provider")
}
```

would result into this TypeScript value

```
export const PaymentProvider: {
  MixplatSMS: 'mixplat/sms'
  InternalToken: 'internal/token'
  Offline: 'offline'
}
```

/integration

---------

Co-authored-by: jkomyno <12381818+jkomyno@users.noreply.github.com>
aqrln pushed a commit that referenced this pull request Nov 17, 2025
…28180)

**Breaking change**

This PR:
- closes #8446
- closes #273
- closes
[TML-1438](https://linear.app/prisma-company/issue/TML-1438/add-support-for-mapped-enums)
- translates PSL mapped enums into TS mapped enums

## Before this PR

This Prisma enum definition

```prisma
enum PaymentProvider {
  MixplatSMS    @Map("mixplat/sms")
  InternalToken @Map("internal/token")
  Offline       @Map("offline")

  @@Map("payment_provider")
}
```

would result into this TypeScript value

```typescript
export const PaymentProvider: {
  MixplatSMS: 'MixplatSMS',
  InternalToken: 'InternalToken',
  Offline: 'Offline'
}
```

## After this PR

This Prisma enum definition (same as the above one)

```prisma
enum PaymentProvider {
  MixplatSMS    @Map("mixplat/sms")
  InternalToken @Map("internal/token")
  Offline       @Map("offline")

  @@Map("payment_provider")
}
```

would result into this TypeScript value

```
export const PaymentProvider: {
  MixplatSMS: 'mixplat/sms'
  InternalToken: 'internal/token'
  Offline: 'offline'
}
```

/integration

---------

Co-authored-by: jkomyno <12381818+jkomyno@users.noreply.github.com>
@mbsanchez01
Copy link
Copy Markdown

mbsanchez01 commented Dec 10, 2025

I can still reproduce this issue using Prisma 7.1.0. The type generated is correct, it has good mapping values, but when in execution time, the value is not mapped. I mean I should get mixplat/sms and i'm getting MixplatSMS as value.

jacek-prisma added a commit that referenced this pull request Jan 6, 2026
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.

3 participants