mutano 1.0.4 → 1.0.6
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.js +7 -2
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -232,9 +232,14 @@ async function generate(config) {
|
|
|
232
232
|
describes = prismaTable.properties.filter(
|
|
233
233
|
(p) => p.type === "field" && p.array !== true && !p.attributes?.find((a) => a.name === "relation")
|
|
234
234
|
).map((field) => {
|
|
235
|
+
let defaultGenerated = false;
|
|
235
236
|
const defaultValueField = field.attributes ? field.attributes.find((a) => a.name === "default") : null;
|
|
236
237
|
const defaultValue = defaultValueField?.args?.[0].value;
|
|
237
|
-
|
|
238
|
+
if (typeof defaultValue === "object" && // @ts-ignore
|
|
239
|
+
defaultValue?.type === "function") {
|
|
240
|
+
defaultGenerated = true;
|
|
241
|
+
}
|
|
242
|
+
const parsedDefaultValue = defaultValue !== void 0 && typeof defaultValue !== "object" ? defaultValue.toString().replace(/"/g, "") : null;
|
|
238
243
|
let fieldType = field.fieldType.toString();
|
|
239
244
|
if (!prismaValidTypes.includes(fieldType)) {
|
|
240
245
|
enumOptions = schema.findAllByType("enum", {
|
|
@@ -248,7 +253,7 @@ async function generate(config) {
|
|
|
248
253
|
Field: field.name,
|
|
249
254
|
Default: parsedDefaultValue,
|
|
250
255
|
EnumOptions: enumOptions,
|
|
251
|
-
Extra:
|
|
256
|
+
Extra: defaultGenerated ? "DEFAULT_GENERATED" : "",
|
|
252
257
|
Type: fieldType,
|
|
253
258
|
Null: field.optional ? "YES" : "NO",
|
|
254
259
|
Comment: field.comment ?? ""
|
package/package.json
CHANGED