@inflector/optima 1.0.16 → 1.0.17
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/index.d.ts +1 -1
- package/dist/index.js +14 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ declare const Uuid: () => ColumnBuilder<string, SetFlag$1<Restrict<"defaultNow">
|
|
|
59
59
|
declare const DateType: () => ColumnBuilder<Date, SetFlag$1<Restrict<"default">, "SQlType">, never>;
|
|
60
60
|
declare const Timestamp: () => ColumnBuilder<Date, SetFlag$1<Restrict<"default">, "SQlType">, never>;
|
|
61
61
|
declare const Enum: <T extends string | number>(vals: readonly T[]) => ColumnBuilder<T, SetFlag$1<SetFlag$1<Restrict<"defaultNow">, "validate">, "SQlType">, never>;
|
|
62
|
-
declare const Json: <T extends z.ZodRawShape
|
|
62
|
+
declare const Json: <T extends z.ZodRawShape = Record<string, any>>(obj: T) => ColumnBuilder<[keyof T] extends [never] ? Record<string, any> : z.core.$InferObjectOutput<T, {}>, SetFlag$1<Restrict<"primaryKey" | "unique" | "defaultNow">, "SQlType">, never>;
|
|
63
63
|
declare const Array$1: <T extends z.ZodTypeAny>(schema: T) => ColumnBuilder<z.core.output<T>[], SetFlag$1<Restrict<"primaryKey" | "unique" | "defaultNow">, "SQlType">, never>;
|
|
64
64
|
declare const Email: () => ColumnBuilder<string, SetFlag$1<SetFlag$1<Restrict<"defaultNow">, "SQlType">, "validate">, never>;
|
|
65
65
|
declare const Slug: () => ColumnBuilder<string, SetFlag$1<SetFlag$1<Restrict<"defaultNow">, "SQlType">, "validate">, never>;
|
package/dist/index.js
CHANGED
|
@@ -146,7 +146,11 @@ var SQLBuilder = class {
|
|
|
146
146
|
const FieldConfig = GetFieldConfig(f);
|
|
147
147
|
let sql = `${name} ${FieldConfig.SQlType || "TEXT"}`;
|
|
148
148
|
if ((FieldConfig.SQlType == "STRUCT" || FieldConfig.SQlType == "LIST") && FieldConfig.STRUCTType) {
|
|
149
|
-
|
|
149
|
+
if (FieldConfig.STRUCTType == "STRUCT()") {
|
|
150
|
+
sql = `${name} JSON`;
|
|
151
|
+
} else {
|
|
152
|
+
sql = `${name} ${FieldConfig.STRUCTType}`;
|
|
153
|
+
}
|
|
150
154
|
}
|
|
151
155
|
if (FieldConfig.primaryKey) sql += " PRIMARY KEY";
|
|
152
156
|
if (FieldConfig.notnull) sql += " NOT NULL";
|
|
@@ -584,6 +588,9 @@ ${valuesBlock}${isReturning ? "\nRETURNING *" : ""};`;
|
|
|
584
588
|
}
|
|
585
589
|
return parsedObj;
|
|
586
590
|
}
|
|
591
|
+
if (type?.SQlType === "STRUCT" && type?.STRUCTType === "STRUCT()") {
|
|
592
|
+
return JSON.parse(value);
|
|
593
|
+
}
|
|
587
594
|
return value;
|
|
588
595
|
};
|
|
589
596
|
this.FormatOut = (data) => {
|
|
@@ -970,7 +977,12 @@ var SchemaMigrator = class {
|
|
|
970
977
|
if (colImpl?.config) {
|
|
971
978
|
const config = { ...colImpl.config };
|
|
972
979
|
if (config.SQlType === "STRUCT" && config.STRUCTType) {
|
|
973
|
-
config.
|
|
980
|
+
if (config.STRUCTType == "STRUCT()") {
|
|
981
|
+
config.SQlType = "JSON";
|
|
982
|
+
config.STRUCTType = "JSON";
|
|
983
|
+
} else {
|
|
984
|
+
config.SQlType = config.STRUCTType;
|
|
985
|
+
}
|
|
974
986
|
}
|
|
975
987
|
cleanSchema[realTableName][colName] = config;
|
|
976
988
|
}
|