npm kysely-codegen 0.19.0

6 days ago

New features

Thanks to amazing contributions from @kevinmichaelchen in #274, you can now override types on a global level:

.kysely-codegenrc.json

{
  "customImports": {
    "InstantRange": "./custom-types",
    "CustomDuration": "@my-org/custom-types#Duration",
    "Temporal": "@js-temporal/polyfill",
  },
  "typeMapping": {
    "timestamptz": "Temporal.Instant",
    "tstzrange": "InstantRange",
    "date": "Temporal.PlainDate",
    "interval": "CustomDuration"
  }
}

Example of generated output:

import type { InstantRange } from './custom-types';
import type { Duration as CustomDuration } from '@my-org/custom-types';
import type { Temporal } from '@js-temporal/polyfill';

export interface EventModel {
  createdAt: Temporal.Instant;
  dateRange: ColumnType<InstantRange, InstantRange, never>;
  eventDate: Temporal.PlainDate;
  interval: CustomDuration;
}

export interface DB {
  events: EventModel;
}

What's Changed

New Contributors

Full Changelog: 0.18.0...0.19.0

Don't miss a new kysely-codegen release

NewReleases is sending notifications on new releases.