mutano 3.0.0 → 3.0.2

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.
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Core types and interfaces for Mutano
3
+ */
4
+ export interface Desc {
5
+ Field: string;
6
+ Default: string | null;
7
+ Extra: string;
8
+ Null: string;
9
+ Type: string;
10
+ Comment: string;
11
+ EnumOptions?: string[];
12
+ }
13
+ export type Destination = {
14
+ type: 'zod';
15
+ useDateType?: boolean;
16
+ useTrim?: boolean;
17
+ nullish?: boolean;
18
+ requiredString?: boolean;
19
+ version?: 3 | 4;
20
+ header?: string;
21
+ folder?: string;
22
+ suffix?: string;
23
+ } | {
24
+ type: 'ts';
25
+ enumType?: 'union' | 'enum';
26
+ modelType?: 'interface' | 'type';
27
+ header?: string;
28
+ folder?: string;
29
+ suffix?: string;
30
+ } | {
31
+ type: 'kysely';
32
+ schemaName?: string;
33
+ header?: string;
34
+ folder?: string;
35
+ suffix?: string;
36
+ outFile?: string;
37
+ };
38
+ export interface Config {
39
+ origin: {
40
+ type: 'prisma';
41
+ path: string;
42
+ overrideTypes?: {
43
+ [k in PrismaValidTypes]?: string;
44
+ };
45
+ } | {
46
+ type: 'mysql';
47
+ host: string;
48
+ port: number;
49
+ user: string;
50
+ password: string;
51
+ database: string;
52
+ overrideTypes?: {
53
+ [k in MySQLValidTypes]?: string;
54
+ };
55
+ ssl?: Record<string, any>;
56
+ } | {
57
+ type: 'postgres';
58
+ host: string;
59
+ port: number;
60
+ user: string;
61
+ password: string;
62
+ database: string;
63
+ schema?: string;
64
+ overrideTypes?: {
65
+ [k in PostgresValidTypes]?: string;
66
+ };
67
+ ssl?: Record<string, any>;
68
+ } | {
69
+ type: 'sqlite';
70
+ path: string;
71
+ overrideTypes?: {
72
+ [k in SQLiteValidTypes]?: string;
73
+ };
74
+ };
75
+ destinations: Destination[];
76
+ tables?: string[];
77
+ views?: string[];
78
+ ignore?: string[];
79
+ ignoreViews?: string[];
80
+ camelCase?: boolean;
81
+ silent?: boolean;
82
+ dryRun?: boolean;
83
+ magicComments?: boolean;
84
+ includeViews?: boolean;
85
+ }
86
+ export interface GenerateContentParams {
87
+ table: string;
88
+ describes: Desc[];
89
+ config: Config;
90
+ destination: Destination;
91
+ isCamelCase: boolean;
92
+ enumDeclarations: Record<string, string[]>;
93
+ defaultZodHeader: (version: 3 | 4) => string;
94
+ }
95
+ export interface GenerateViewContentParams {
96
+ view: string;
97
+ describes: Desc[];
98
+ config: Config;
99
+ destination: Destination;
100
+ isCamelCase: boolean;
101
+ enumDeclarations: Record<string, string[]>;
102
+ defaultZodHeader: (version: 3 | 4) => string;
103
+ }
104
+ export type MySQLValidTypes = 'tinyint' | 'smallint' | 'mediumint' | 'int' | 'bigint' | 'decimal' | 'float' | 'double' | 'bit' | 'char' | 'varchar' | 'binary' | 'varbinary' | 'tinyblob' | 'blob' | 'mediumblob' | 'longblob' | 'tinytext' | 'text' | 'mediumtext' | 'longtext' | 'enum' | 'set' | 'date' | 'time' | 'datetime' | 'timestamp' | 'year' | 'json';
105
+ export type PostgresValidTypes = 'smallint' | 'integer' | 'bigint' | 'decimal' | 'numeric' | 'real' | 'double precision' | 'smallserial' | 'serial' | 'bigserial' | 'money' | 'character varying' | 'varchar' | 'character' | 'char' | 'text' | 'bytea' | 'timestamp' | 'timestamp with time zone' | 'timestamp without time zone' | 'date' | 'time' | 'time with time zone' | 'time without time zone' | 'interval' | 'boolean' | 'enum' | 'point' | 'line' | 'lseg' | 'box' | 'path' | 'polygon' | 'circle' | 'cidr' | 'inet' | 'macaddr' | 'bit' | 'bit varying' | 'uuid' | 'xml' | 'json' | 'jsonb' | 'int4range' | 'int8range' | 'numrange' | 'tsrange' | 'tstzrange' | 'daterange' | 'name' | 'citext';
106
+ export type SQLiteValidTypes = 'integer' | 'real' | 'text' | 'blob' | 'numeric' | 'boolean' | 'date' | 'datetime' | 'character' | 'varchar' | 'varying character' | 'nchar' | 'native character' | 'nvarchar' | 'clob' | 'double' | 'double precision' | 'float' | 'int' | 'int2' | 'int8' | 'bigint' | 'unsigned big int' | 'mediumint' | 'tinyint' | 'smallint' | 'decimal' | 'json';
107
+ export type PrismaValidTypes = 'String' | 'Boolean' | 'Int' | 'BigInt' | 'Float' | 'Decimal' | 'DateTime' | 'Json' | 'Bytes' | 'Unsupported';
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Database type mappings for different database systems
3
+ */
4
+ export declare const prismaValidTypes: readonly ["String", "Boolean", "Int", "BigInt", "Float", "Decimal", "DateTime", "Json", "Bytes", "Unsupported"];
5
+ export declare const dateTypes: {
6
+ mysql: string[];
7
+ postgres: string[];
8
+ sqlite: string[];
9
+ prisma: string[];
10
+ };
11
+ export declare const stringTypes: {
12
+ mysql: string[];
13
+ postgres: string[];
14
+ sqlite: string[];
15
+ prisma: string[];
16
+ };
17
+ export declare const bigIntTypes: {
18
+ mysql: string[];
19
+ postgres: string[];
20
+ sqlite: string[];
21
+ prisma: string[];
22
+ };
23
+ export declare const numberTypes: {
24
+ mysql: string[];
25
+ postgres: string[];
26
+ sqlite: string[];
27
+ prisma: string[];
28
+ };
29
+ export declare const decimalTypes: {
30
+ mysql: string[];
31
+ postgres: string[];
32
+ sqlite: string[];
33
+ prisma: string[];
34
+ };
35
+ export declare const booleanTypes: {
36
+ mysql: string[];
37
+ postgres: string[];
38
+ sqlite: string[];
39
+ prisma: string[];
40
+ };
41
+ export declare const enumTypes: {
42
+ mysql: string[];
43
+ postgres: string[];
44
+ sqlite: string[];
45
+ prisma: string[];
46
+ };
47
+ export declare const enumRegex: RegExp;
48
+ /**
49
+ * Get the appropriate type mappings for a database type
50
+ */
51
+ export declare function getTypeMappings(dbType: 'mysql' | 'postgres' | 'sqlite' | 'prisma'): {
52
+ dateTypes: string[];
53
+ stringTypes: string[];
54
+ bigIntTypes: string[];
55
+ numberTypes: string[];
56
+ decimalTypes: string[];
57
+ booleanTypes: string[];
58
+ enumTypes: string[];
59
+ };
60
+ /**
61
+ * Check if a type is a JSON type
62
+ */
63
+ export declare function isJsonType(type: string): boolean;
64
+ /**
65
+ * Check if a type is a date type for a specific database
66
+ */
67
+ export declare function isDateType(type: string, dbType: 'mysql' | 'postgres' | 'sqlite' | 'prisma'): boolean;
68
+ /**
69
+ * Check if a type is a string type for a specific database
70
+ */
71
+ export declare function isStringType(type: string, dbType: 'mysql' | 'postgres' | 'sqlite' | 'prisma'): boolean;
72
+ /**
73
+ * Check if a type is a number type for a specific database
74
+ */
75
+ export declare function isNumberType(type: string, dbType: 'mysql' | 'postgres' | 'sqlite' | 'prisma'): boolean;
76
+ /**
77
+ * Check if a type is a bigint type for a specific database
78
+ */
79
+ export declare function isBigIntType(type: string, dbType: 'mysql' | 'postgres' | 'sqlite' | 'prisma'): boolean;
80
+ /**
81
+ * Check if a type is a decimal type for a specific database
82
+ */
83
+ export declare function isDecimalType(type: string, dbType: 'mysql' | 'postgres' | 'sqlite' | 'prisma'): boolean;
84
+ /**
85
+ * Check if a type is a boolean type for a specific database
86
+ */
87
+ export declare function isBooleanType(type: string, dbType: 'mysql' | 'postgres' | 'sqlite' | 'prisma'): boolean;
88
+ /**
89
+ * Check if a type is an enum type for a specific database
90
+ */
91
+ export declare function isEnumType(type: string, dbType: 'mysql' | 'postgres' | 'sqlite' | 'prisma'): boolean;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Utilities for filtering tables and views
3
+ */
4
+ /**
5
+ * Filter entities (tables or views) based on include/exclude patterns
6
+ */
7
+ export declare function filterEntities(entities: string[], included?: string[], ignored?: string[]): string[];
8
+ /**
9
+ * Filter tables based on configuration
10
+ */
11
+ export declare function filterTables(tables: string[], includedTables?: string[], ignoredTables?: string[]): string[];
12
+ /**
13
+ * Filter views based on configuration
14
+ */
15
+ export declare function filterViews(views: string[], includedViews?: string[], ignoredViews?: string[]): string[];
16
+ /**
17
+ * Create entity objects with type information
18
+ */
19
+ export interface EntityInfo {
20
+ name: string;
21
+ type: 'table' | 'view';
22
+ }
23
+ export declare function createEntityList(tables: string[], views: string[]): EntityInfo[];
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Utilities for parsing magic comments (@zod, @ts, @kysely)
3
+ */
4
+ /**
5
+ * Extract type expression from a comment with a given prefix
6
+ * Handles nested parentheses, brackets, and braces
7
+ */
8
+ export declare const extractTypeExpression: (comment: string, prefix: string) => string | null;
9
+ /**
10
+ * Extract TypeScript type expression from @ts() comment
11
+ */
12
+ export declare const extractTSExpression: (comment: string) => string | null;
13
+ /**
14
+ * Extract Kysely type expression from @kysely() comment
15
+ */
16
+ export declare const extractKyselyExpression: (comment: string) => string | null;
17
+ /**
18
+ * Extract Zod type expression from @zod() comment
19
+ */
20
+ export declare const extractZodExpression: (comment: string) => string | null;
21
+ /**
22
+ * Check if a comment contains any magic comment
23
+ */
24
+ export declare const hasMagicComment: (comment: string) => boolean;
25
+ /**
26
+ * Parse all magic comments from a comment string
27
+ */
28
+ export interface MagicComments {
29
+ zod?: string;
30
+ ts?: string;
31
+ kysely?: string;
32
+ }
33
+ export declare const parseMagicComments: (comment: string) => MagicComments;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mutano",
3
3
  "type": "module",
4
- "version": "3.0.0",
4
+ "version": "3.0.2",
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",