mutano 2.6.5 → 2.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -505,6 +505,7 @@ export type UserUpdate = Updateable<UserTable>;
505
505
  | destinations[].useDateType | (Zod only) Use a specialized Zod type for date-like fields instead of string |
506
506
  | destinations[].useTrim | (Zod only) Use `z.string().trim()` instead of `z.string()` |
507
507
  | destinations[].nullish | (Zod only) Use `nullish()` instead of `nullable()` for nullable fields. In updateable schemas, fields that were already nullable will become nullish |
508
+ | destinations[].version | (Zod only) Zod version to use. Defaults to 3. Set to 4 to use Zod v4 |
508
509
  | destinations[].requiredString | (Zod only) Add `min(1)` for non-nullable string fields |
509
510
  | destinations[].enumType | (TypeScript only) How to represent enum types: "union" (default) or "enum" |
510
511
  | destinations[].modelType | (TypeScript only) How to represent models: "interface" (default) or "type" |
package/dist/main.d.ts CHANGED
@@ -10,11 +10,11 @@ export interface GenerateContentParams {
10
10
  destination: Destination;
11
11
  isCamelCase: boolean;
12
12
  enumDeclarations: Record<string, string[]>;
13
- defaultZodHeader: string;
13
+ defaultZodHeader: (version: 3 | 4) => string;
14
14
  }
15
15
  export declare function generateContent({ table, describes, config, destination, isCamelCase, enumDeclarations, defaultZodHeader, }: GenerateContentParams): string;
16
16
  export declare const defaultKyselyHeader = "import { ColumnType, Selectable, Insertable, Updateable } from 'kysely';\n\n";
17
- export declare const defaultZodHeader = "import { z } from 'zod';\n\n";
17
+ export declare const defaultZodHeader: (version: 3 | 4) => string;
18
18
  export declare function generate(config: Config): Promise<Record<string, string>>;
19
19
  type MySQLValidTypes = 'date' | 'datetime' | 'timestamp' | 'time' | 'year' | 'char' | 'varchar' | 'tinytext' | 'text' | 'mediumtext' | 'longtext' | 'json' | 'decimal' | 'tinyint' | 'smallint' | 'mediumint' | 'int' | 'bigint' | 'float' | 'double' | 'enum';
20
20
  type PostgresValidTypes = 'date' | 'timestamp' | 'timestamptz' | 'timestamp without time zone' | 'timestamp with time zone' | 'time' | 'timetz' | 'interval' | 'character' | 'varchar' | 'character varying' | 'text' | 'json' | 'jsonb' | 'uuid' | 'name' | 'citext' | 'numeric' | 'decimal' | 'smallint' | 'integer' | 'bigint' | 'real' | 'double precision' | 'serial' | 'bigserial' | 'boolean' | 'bool' | 'USER-DEFINED';
@@ -31,6 +31,7 @@ export interface Desc {
31
31
  }
32
32
  export type Destination = {
33
33
  type: 'zod';
34
+ version?: 3 | 4;
34
35
  header?: string;
35
36
  useDateType?: boolean;
36
37
  useTrim?: boolean;
package/dist/main.js CHANGED
@@ -506,9 +506,7 @@ export type ${camelCase(table, { pascalCase: true })} = {`;
506
506
  `;
507
507
  } else if (destination.type === "zod") {
508
508
  const header = destination.header;
509
- content = header ? `${header}
510
-
511
- ` : defaultZodHeader2;
509
+ content = header ? header + "\n\n" : defaultZodHeader2(destination.version || 3);
512
510
  content += `export const ${table} = z.object({`;
513
511
  for (const desc of describes) {
514
512
  const field = isCamelCase ? camelCase(desc.Field) : desc.Field;
@@ -574,7 +572,7 @@ export type Selectable${camelCase(`${table}Type`, {
574
572
  return content;
575
573
  }
576
574
  const defaultKyselyHeader = "import { ColumnType, Selectable, Insertable, Updateable } from 'kysely';\n\n";
577
- const defaultZodHeader = "import { z } from 'zod';\n\n";
575
+ const defaultZodHeader = (version) => "import { z } from 'zod" + (version === 3 ? "" : "/v4") + "';\n\n";
578
576
  async function generate(config) {
579
577
  let tables = [];
580
578
  let prismaTables = [];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mutano",
3
3
  "type": "module",
4
- "version": "2.6.5",
4
+ "version": "2.6.7",
5
5
  "description": "Converts Prisma/MySQL/PostgreSQL/SQLite schemas to Zod/TS/Kysely interfaces",
6
6
  "author": "Alisson Cavalcante Agiani <thelinuxlich@gmail.com>",
7
7
  "license": "MIT",