Skip to content

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Oct 18, 2024

This PR contains the following updates:

Package Change Age Confidence
kysely-codegen ^0.16.8 -> ^0.19.0 age confidence

Release Notes

RobinBlomberg/kysely-codegen (kysely-codegen)

v0.19.0

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: RobinBlomberg/kysely-codegen@0.18.0...0.19.0

v0.18.0

Compare Source

Migration to 0.18.0

The follow CLI options have been changed:

  • --schema has been renamed to --default-schema.
  • --singular has been renamed to --singularize.
  • --runtime-enums and --runtime-enums-style have been merged into a single CLI option --runtime-enums.

Configuration file

All codegen options can also be configured in a .kysely-codegenrc.json (or .js, .ts, .yaml etc.) file or the kysely-codegen property in package.json. See Cosmiconfig for all available configuration file formats.

The default configuration:

{
  "camelCase": false,
  "dateParser": "timestamp",
  "defaultSchemas": [], // ["public"] for PostgreSQL.
  "dialect": null,
  "domains": true,
  "envFile": null,
  "excludePattern": null,
  "includePattern": null,
  "logLevel": "warn",
  "numericParser": "string",
  "outFile": "./node_modules/kysely-codegen/dist/db.d.ts",
  "overrides": {},
  "partitions": false,
  "print": false,
  "runtimeEnums": false,
  "singularize": false,
  "typeOnlyImports": true,
  "url": "env(DATABASE_URL)",
  "verify": false
}

The configuration object adds support for more advanced options:

{
  "camelCase": true,
  "overrides": {
    "columns": {
      "users.settings": "{ theme: 'dark' }"
    }
  },
  "singularize": {
    "/^(.*?)s?$/": "$1_model",
    "/(bacch)(?:us|i)$/i": "$1us"
  }
}

The generated output:

export interface UserModel {
  settings: { theme: 'dark' };
}

// ...

export interface DB {
  bacchi: Bacchus;
  users: UserModel;
}

Custom serializers and dialects

The new configuration support also adds support for supplying custom serializers.

Here is a stub example of a basic Zod serializer (.kysely-codegenrc.ts):

import { toKyselyCamelCase } from '../../generator';
import type { Config } from '../config';

const config: Config = {
  logLevel: 'debug',
  outFile: null,
  serializer: {
    serializeFile: (metadata) => {
      let output = 'import { z } from "zod";\n\n';

      for (const table of metadata.tables) {
        output += 'export const ';
        output += toKyselyCamelCase(table.name);
        output += 'Schema = z.object({\n';

        for (const column of table.columns) {
          output += '  ';
          output += column.name;
          output += ': ';

          switch (column.dataType) {
            case 'int4':
              output += 'z.number().int()';
              break;
            default:
              output += 'z.unknown()';
          }

          output += ',\n';
        }

        output += '});\n\n';
      }

      return output;
    },
  },
  url: 'postgres://user:password@localhost:5433/database',
};

export default config;

Example output:

import { z } from "zod";

export const usersSchema = z.object({
  baz_qux: z.number().int(),
});

Similarly, it's also possible to supply a custom dialect value, allowing you to create a completely new kysely-codegen dialects or extending an existing one with extra logic.

What's Changed

  • feat!: Merge "runtime-enums" and "runtime-enums-style" options
  • feat!: Deprecate "schemas" option and rename it to "defaultSchemas"
  • feat!: Rename "singular" option to "singularize"
  • feat: Support kysely-codegen configuration files (using cosmiconfig)
  • feat: Add support for custom singularization rules
  • feat: Merge all ...IdentifierNode classes into a single IdentifierNode class
  • feat: Add skipAutogenerationFileComment serializer option
  • fix: Fix overrides not always applying to the correct column
  • fix: Fix test flakiness by running all tests in sequence
  • fix: Make bun sqlite codegen work again (re-introduce KyselyBunSqliteIntrospectorDialect using the sqlite database from bun:sqlite and the Kysely dialect from 'kysely-bun-sqlite') by @​meck93 in #​238
  • fix: Fix update function example @​ README. by @​igalklebanov in #​227
  • chore: Upgrade all dependencies
  • chore: Allow @​libsql/kysely-libsql@​^0.4.1 as a peer dependency @​alsiola in #​233

New Contributors

Full Changelog: RobinBlomberg/kysely-codegen@0.17.0...0.18.0

v0.17.0

What's Changed

New Contributors

Full Changelog: RobinBlomberg/kysely-codegen@0.16.7...0.17.0


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot requested a review from benjaminstrasser as a code owner October 18, 2024 10:50
@renovate renovate bot added the renovate label Oct 18, 2024
@renovate renovate bot requested review from jjnp, mledl and sjaghori as code owners October 18, 2024 10:50
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch from ab3e32f to 7204c02 Compare November 2, 2024 08:06
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch from 7204c02 to 1027c5f Compare January 29, 2025 05:56
@renovate renovate bot changed the title chore(deps): update dependency kysely-codegen to ^0.17.0 chore(deps): update dependency kysely-codegen to ^0.18.0 Mar 2, 2025
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch from 1027c5f to bb82e28 Compare March 2, 2025 14:28
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch 2 times, most recently from 124fa53 to 3fc8546 Compare March 24, 2025 02:24
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch from 3fc8546 to cf636af Compare May 5, 2025 16:42
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch 2 times, most recently from fafb08b to 7606061 Compare May 19, 2025 17:23
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch from 7606061 to a7c1093 Compare June 23, 2025 10:32
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch 3 times, most recently from bfbb606 to 204fb28 Compare August 13, 2025 11:58
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch from 204fb28 to e6748e1 Compare August 19, 2025 13:54
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch from e6748e1 to 0143cde Compare August 31, 2025 14:02
@renovate renovate bot changed the title chore(deps): update dependency kysely-codegen to ^0.18.0 chore(deps): update dependency kysely-codegen to ^0.19.0 Sep 3, 2025
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch from 0143cde to 8df74e0 Compare September 3, 2025 09:37
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch 6 times, most recently from dbcee67 to a3407b5 Compare September 29, 2025 09:06
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch 2 times, most recently from e50fcec to 9a5f17b Compare October 5, 2025 21:12
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch 5 times, most recently from c7cf780 to fc6030e Compare October 6, 2025 20:54
@renovate renovate bot force-pushed the renovate/kysely-codegen-0.x branch from fc6030e to 3bb48e2 Compare October 21, 2025 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants