mutano 3.0.5 → 3.0.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/dist/main.d.ts +1 -0
- package/dist/main.js +8 -4
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
package/dist/main.js
CHANGED
|
@@ -263,7 +263,8 @@ function getType(op, desc, config, destination) {
|
|
|
263
263
|
}
|
|
264
264
|
const enumTypesForSchema = typeMappings.enumTypes[schemaType] || [];
|
|
265
265
|
const isEnum = enumTypesForSchema.includes(type);
|
|
266
|
-
|
|
266
|
+
const isPrismaEnum = schemaType === "prisma" && config.enumDeclarations && config.enumDeclarations[type];
|
|
267
|
+
if (isEnum || isPrismaEnum) {
|
|
267
268
|
let enumValues = [];
|
|
268
269
|
if (schemaType === "mysql" && type === "enum") {
|
|
269
270
|
const match = Type.match(enumRegex);
|
|
@@ -272,6 +273,8 @@ function getType(op, desc, config, destination) {
|
|
|
272
273
|
}
|
|
273
274
|
} else if (schemaType === "postgres" && EnumOptions) {
|
|
274
275
|
enumValues = EnumOptions;
|
|
276
|
+
} else if (isPrismaEnum && config.enumDeclarations) {
|
|
277
|
+
enumValues = config.enumDeclarations[type];
|
|
275
278
|
}
|
|
276
279
|
if (enumValues.length > 0) {
|
|
277
280
|
const shouldBeNullable = isNull || ["insertable", "updateable"].includes(op) && (hasDefaultValue || isGenerated) || op === "updateable" && !isNull && !hasDefaultValue;
|
|
@@ -557,11 +560,11 @@ function generateKyselyContent({
|
|
|
557
560
|
content += "}\n\n";
|
|
558
561
|
content += `// Use these types for inserting, selecting and updating the table
|
|
559
562
|
`;
|
|
560
|
-
content += `export type ${pascalTable} = Selectable<${pascalTable}Table>;
|
|
563
|
+
content += `export type Selectable${pascalTable} = Selectable<${pascalTable}Table>;
|
|
561
564
|
`;
|
|
562
|
-
content += `export type
|
|
565
|
+
content += `export type Insertable${pascalTable} = Insertable<${pascalTable}Table>;
|
|
563
566
|
`;
|
|
564
|
-
content += `export type ${pascalTable}
|
|
567
|
+
content += `export type Updateable${pascalTable} = Updateable<${pascalTable}Table>;
|
|
565
568
|
`;
|
|
566
569
|
return content;
|
|
567
570
|
}
|
|
@@ -896,6 +899,7 @@ async function generate(config) {
|
|
|
896
899
|
tables = prismaEntities.tables;
|
|
897
900
|
views = prismaEntities.views;
|
|
898
901
|
enumDeclarations = prismaEntities.enumDeclarations;
|
|
902
|
+
config.enumDeclarations = enumDeclarations;
|
|
899
903
|
} else {
|
|
900
904
|
db = createDatabaseConnection(config);
|
|
901
905
|
tables = await extractTables(db, config);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mutano",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.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",
|