mutano 2.2.0 → 2.3.0
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/dist/main.d.ts +1 -1
- package/dist/main.js +20 -5
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface GenerateContentParams {
|
|
|
11
11
|
export declare function generateContent({ table, describes, config, destination, isCamelCase, enumDeclarations, defaultZodHeader, }: GenerateContentParams): string;
|
|
12
12
|
export declare const defaultKyselyHeader = "import { Generated, ColumnType, Selectable, Insertable, Updateable } from 'kysely';\n\n";
|
|
13
13
|
export declare const defaultZodHeader = "import { z } from 'zod';\n\n";
|
|
14
|
-
export declare function generate(config: Config): Promise<
|
|
14
|
+
export declare function generate(config: Config): Promise<Record<string, string>>;
|
|
15
15
|
type MySQLValidTypes = 'date' | 'datetime' | 'timestamp' | 'time' | 'year' | 'char' | 'varchar' | 'tinytext' | 'text' | 'mediumtext' | 'longtext' | 'json' | 'decimal' | 'tinyint' | 'smallint' | 'mediumint' | 'int' | 'bigint' | 'float' | 'double' | 'enum';
|
|
16
16
|
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';
|
|
17
17
|
type SQLiteValidTypes = 'datetime' | 'text' | 'character' | 'varchar' | 'varying character' | 'nchar' | 'native character' | 'nvarchar' | 'clob' | 'json' | 'int' | 'integer' | 'tinyint' | 'smallint' | 'mediumint' | 'bigint' | 'unsigned big int' | 'int2' | 'int8' | 'real' | 'double' | 'double precision' | 'float' | 'numeric' | 'decimal' | 'boolean';
|
package/dist/main.js
CHANGED
|
@@ -779,7 +779,8 @@ async function generate(config) {
|
|
|
779
779
|
const folder = destination.folder || ".";
|
|
780
780
|
const file = suffix !== "" ? `${table}.${suffix}.ts` : `${table}.ts`;
|
|
781
781
|
if (config.dryRun) {
|
|
782
|
-
|
|
782
|
+
const absolutePath = path.resolve(path.join(folder, file));
|
|
783
|
+
dryRunOutput[absolutePath] = content;
|
|
783
784
|
} else {
|
|
784
785
|
const dest = path.join(folder, file);
|
|
785
786
|
dests.push(dest);
|
|
@@ -806,7 +807,7 @@ async function generate(config) {
|
|
|
806
807
|
content
|
|
807
808
|
});
|
|
808
809
|
if (config.dryRun) {
|
|
809
|
-
const tempKey = `${table}.kysely.temp
|
|
810
|
+
const tempKey = path.resolve(`${table}.kysely.temp`);
|
|
810
811
|
dryRunOutput[tempKey] = content;
|
|
811
812
|
}
|
|
812
813
|
}
|
|
@@ -855,8 +856,8 @@ export interface ${schemaName} {
|
|
|
855
856
|
}
|
|
856
857
|
consolidatedContent += "}\n";
|
|
857
858
|
if (config.dryRun) {
|
|
858
|
-
const
|
|
859
|
-
dryRunOutput[
|
|
859
|
+
const absolutePath = path.resolve(outFile);
|
|
860
|
+
dryRunOutput[absolutePath] = consolidatedContent;
|
|
860
861
|
for (const key of Object.keys(dryRunOutput)) {
|
|
861
862
|
if (key.endsWith(".kysely.temp")) {
|
|
862
863
|
delete dryRunOutput[key];
|
|
@@ -869,7 +870,21 @@ export interface ${schemaName} {
|
|
|
869
870
|
fs.outputFileSync(dest, consolidatedContent);
|
|
870
871
|
}
|
|
871
872
|
}
|
|
872
|
-
|
|
873
|
+
if (!config.dryRun) {
|
|
874
|
+
const result2 = {};
|
|
875
|
+
for (const dest of dests) {
|
|
876
|
+
const absolutePath = path.resolve(dest);
|
|
877
|
+
const content = fs.readFileSync(dest, "utf8");
|
|
878
|
+
result2[absolutePath] = content;
|
|
879
|
+
}
|
|
880
|
+
return result2;
|
|
881
|
+
}
|
|
882
|
+
const result = {};
|
|
883
|
+
for (const [key, content] of Object.entries(dryRunOutput)) {
|
|
884
|
+
const absolutePath = path.resolve(key);
|
|
885
|
+
result[absolutePath] = content;
|
|
886
|
+
}
|
|
887
|
+
return result;
|
|
873
888
|
}
|
|
874
889
|
export {
|
|
875
890
|
defaultKyselyHeader,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mutano",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0",
|
|
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",
|