bun-query-builder 0.1.54 → 0.1.55
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/bin/cli.js +58 -2
- package/dist/migrations.d.ts +1 -0
- package/dist/schema.d.ts +1 -0
- package/dist/src/index.js +57 -1
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -17932,6 +17932,8 @@ class MySQLDriver {
|
|
|
17932
17932
|
return "date";
|
|
17933
17933
|
case "datetime":
|
|
17934
17934
|
return "datetime";
|
|
17935
|
+
case "timestamptz":
|
|
17936
|
+
return "datetime";
|
|
17935
17937
|
case "json":
|
|
17936
17938
|
return "json";
|
|
17937
17939
|
case "enum":
|
|
@@ -18117,6 +18119,8 @@ class PostgresDriver {
|
|
|
18117
18119
|
return "date";
|
|
18118
18120
|
case "datetime":
|
|
18119
18121
|
return "timestamp";
|
|
18122
|
+
case "timestamptz":
|
|
18123
|
+
return "timestamptz";
|
|
18120
18124
|
case "json":
|
|
18121
18125
|
return "jsonb";
|
|
18122
18126
|
case "enum":
|
|
@@ -18346,6 +18350,8 @@ class SQLiteDriver {
|
|
|
18346
18350
|
return "TEXT";
|
|
18347
18351
|
case "datetime":
|
|
18348
18352
|
return "TEXT";
|
|
18353
|
+
case "timestamptz":
|
|
18354
|
+
return "TEXT";
|
|
18349
18355
|
case "json":
|
|
18350
18356
|
return "TEXT";
|
|
18351
18357
|
case "enum":
|
|
@@ -27982,6 +27988,9 @@ function detectTypeFromValidationRule(rule) {
|
|
|
27982
27988
|
case "datetime":
|
|
27983
27989
|
case "timestamp":
|
|
27984
27990
|
return "datetime";
|
|
27991
|
+
case "timestamptz":
|
|
27992
|
+
case "timestamp_tz":
|
|
27993
|
+
return "timestamptz";
|
|
27985
27994
|
case "json":
|
|
27986
27995
|
return "json";
|
|
27987
27996
|
case "enum":
|
|
@@ -28006,11 +28015,57 @@ function detectTypeFromValidationRule(rule) {
|
|
|
28006
28015
|
return "date";
|
|
28007
28016
|
if (type === "datetime")
|
|
28008
28017
|
return "datetime";
|
|
28018
|
+
if (type === "timestamptz" || type === "timestamp_tz")
|
|
28019
|
+
return "timestamptz";
|
|
28009
28020
|
if (type === "json")
|
|
28010
28021
|
return "json";
|
|
28011
28022
|
}
|
|
28012
28023
|
return;
|
|
28013
28024
|
}
|
|
28025
|
+
function normalizeAttributeType(value) {
|
|
28026
|
+
if (typeof value !== "string")
|
|
28027
|
+
return;
|
|
28028
|
+
const type = value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
28029
|
+
switch (type) {
|
|
28030
|
+
case "varchar":
|
|
28031
|
+
case "string":
|
|
28032
|
+
return "string";
|
|
28033
|
+
case "text":
|
|
28034
|
+
return "text";
|
|
28035
|
+
case "bool":
|
|
28036
|
+
case "boolean":
|
|
28037
|
+
return "boolean";
|
|
28038
|
+
case "int":
|
|
28039
|
+
case "integer":
|
|
28040
|
+
return "integer";
|
|
28041
|
+
case "bigint":
|
|
28042
|
+
return "bigint";
|
|
28043
|
+
case "float":
|
|
28044
|
+
return "float";
|
|
28045
|
+
case "double":
|
|
28046
|
+
return "double";
|
|
28047
|
+
case "number":
|
|
28048
|
+
case "numeric":
|
|
28049
|
+
case "decimal":
|
|
28050
|
+
return "decimal";
|
|
28051
|
+
case "date":
|
|
28052
|
+
return "date";
|
|
28053
|
+
case "datetime":
|
|
28054
|
+
case "timestamp":
|
|
28055
|
+
return "datetime";
|
|
28056
|
+
case "timestamp_tz":
|
|
28057
|
+
case "timestamptz":
|
|
28058
|
+
case "timestamp_with_time_zone":
|
|
28059
|
+
return "timestamptz";
|
|
28060
|
+
case "json":
|
|
28061
|
+
case "jsonb":
|
|
28062
|
+
return "json";
|
|
28063
|
+
case "enum":
|
|
28064
|
+
return "enum";
|
|
28065
|
+
default:
|
|
28066
|
+
return;
|
|
28067
|
+
}
|
|
28068
|
+
}
|
|
28014
28069
|
function buildMigrationPlan2(models, options) {
|
|
28015
28070
|
const meta = buildSchemaMeta(models);
|
|
28016
28071
|
const tables = [];
|
|
@@ -28040,7 +28095,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
28040
28095
|
let inferred;
|
|
28041
28096
|
let enumValues;
|
|
28042
28097
|
const isPk = attrName === primaryKey;
|
|
28043
|
-
inferred = detectTypeFromValidationRule(attr.validation?.rule);
|
|
28098
|
+
inferred = normalizeAttributeType(attr.type) ?? detectTypeFromValidationRule(attr.validation?.rule);
|
|
28044
28099
|
if (!inferred || inferred === "enum") {
|
|
28045
28100
|
const enumVals = detectEnumFromValidationRule(attr.validation?.rule);
|
|
28046
28101
|
if (enumVals && enumVals.length > 0) {
|
|
@@ -28463,6 +28518,7 @@ function canonicalStorageType(col, dialect) {
|
|
|
28463
28518
|
case "text":
|
|
28464
28519
|
case "date":
|
|
28465
28520
|
case "datetime":
|
|
28521
|
+
case "timestamptz":
|
|
28466
28522
|
case "json":
|
|
28467
28523
|
case "enum":
|
|
28468
28524
|
return "TEXT";
|
|
@@ -30956,7 +31012,7 @@ function getPrefix() {
|
|
|
30956
31012
|
}
|
|
30957
31013
|
var prefix = getPrefix();
|
|
30958
31014
|
// package.json
|
|
30959
|
-
var version2 = "0.1.
|
|
31015
|
+
var version2 = "0.1.55";
|
|
30960
31016
|
|
|
30961
31017
|
// bin/cli.ts
|
|
30962
31018
|
init_actions();
|
package/dist/migrations.d.ts
CHANGED
package/dist/schema.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -17931,6 +17931,8 @@ class MySQLDriver {
|
|
|
17931
17931
|
return "date";
|
|
17932
17932
|
case "datetime":
|
|
17933
17933
|
return "datetime";
|
|
17934
|
+
case "timestamptz":
|
|
17935
|
+
return "datetime";
|
|
17934
17936
|
case "json":
|
|
17935
17937
|
return "json";
|
|
17936
17938
|
case "enum":
|
|
@@ -18116,6 +18118,8 @@ class PostgresDriver {
|
|
|
18116
18118
|
return "date";
|
|
18117
18119
|
case "datetime":
|
|
18118
18120
|
return "timestamp";
|
|
18121
|
+
case "timestamptz":
|
|
18122
|
+
return "timestamptz";
|
|
18119
18123
|
case "json":
|
|
18120
18124
|
return "jsonb";
|
|
18121
18125
|
case "enum":
|
|
@@ -18345,6 +18349,8 @@ class SQLiteDriver {
|
|
|
18345
18349
|
return "TEXT";
|
|
18346
18350
|
case "datetime":
|
|
18347
18351
|
return "TEXT";
|
|
18352
|
+
case "timestamptz":
|
|
18353
|
+
return "TEXT";
|
|
18348
18354
|
case "json":
|
|
18349
18355
|
return "TEXT";
|
|
18350
18356
|
case "enum":
|
|
@@ -27981,6 +27987,9 @@ function detectTypeFromValidationRule(rule) {
|
|
|
27981
27987
|
case "datetime":
|
|
27982
27988
|
case "timestamp":
|
|
27983
27989
|
return "datetime";
|
|
27990
|
+
case "timestamptz":
|
|
27991
|
+
case "timestamp_tz":
|
|
27992
|
+
return "timestamptz";
|
|
27984
27993
|
case "json":
|
|
27985
27994
|
return "json";
|
|
27986
27995
|
case "enum":
|
|
@@ -28005,11 +28014,57 @@ function detectTypeFromValidationRule(rule) {
|
|
|
28005
28014
|
return "date";
|
|
28006
28015
|
if (type === "datetime")
|
|
28007
28016
|
return "datetime";
|
|
28017
|
+
if (type === "timestamptz" || type === "timestamp_tz")
|
|
28018
|
+
return "timestamptz";
|
|
28008
28019
|
if (type === "json")
|
|
28009
28020
|
return "json";
|
|
28010
28021
|
}
|
|
28011
28022
|
return;
|
|
28012
28023
|
}
|
|
28024
|
+
function normalizeAttributeType(value) {
|
|
28025
|
+
if (typeof value !== "string")
|
|
28026
|
+
return;
|
|
28027
|
+
const type = value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
28028
|
+
switch (type) {
|
|
28029
|
+
case "varchar":
|
|
28030
|
+
case "string":
|
|
28031
|
+
return "string";
|
|
28032
|
+
case "text":
|
|
28033
|
+
return "text";
|
|
28034
|
+
case "bool":
|
|
28035
|
+
case "boolean":
|
|
28036
|
+
return "boolean";
|
|
28037
|
+
case "int":
|
|
28038
|
+
case "integer":
|
|
28039
|
+
return "integer";
|
|
28040
|
+
case "bigint":
|
|
28041
|
+
return "bigint";
|
|
28042
|
+
case "float":
|
|
28043
|
+
return "float";
|
|
28044
|
+
case "double":
|
|
28045
|
+
return "double";
|
|
28046
|
+
case "number":
|
|
28047
|
+
case "numeric":
|
|
28048
|
+
case "decimal":
|
|
28049
|
+
return "decimal";
|
|
28050
|
+
case "date":
|
|
28051
|
+
return "date";
|
|
28052
|
+
case "datetime":
|
|
28053
|
+
case "timestamp":
|
|
28054
|
+
return "datetime";
|
|
28055
|
+
case "timestamp_tz":
|
|
28056
|
+
case "timestamptz":
|
|
28057
|
+
case "timestamp_with_time_zone":
|
|
28058
|
+
return "timestamptz";
|
|
28059
|
+
case "json":
|
|
28060
|
+
case "jsonb":
|
|
28061
|
+
return "json";
|
|
28062
|
+
case "enum":
|
|
28063
|
+
return "enum";
|
|
28064
|
+
default:
|
|
28065
|
+
return;
|
|
28066
|
+
}
|
|
28067
|
+
}
|
|
28013
28068
|
function buildMigrationPlan2(models, options) {
|
|
28014
28069
|
const meta = buildSchemaMeta(models);
|
|
28015
28070
|
const tables = [];
|
|
@@ -28039,7 +28094,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
28039
28094
|
let inferred;
|
|
28040
28095
|
let enumValues;
|
|
28041
28096
|
const isPk = attrName === primaryKey;
|
|
28042
|
-
inferred = detectTypeFromValidationRule(attr.validation?.rule);
|
|
28097
|
+
inferred = normalizeAttributeType(attr.type) ?? detectTypeFromValidationRule(attr.validation?.rule);
|
|
28043
28098
|
if (!inferred || inferred === "enum") {
|
|
28044
28099
|
const enumVals = detectEnumFromValidationRule(attr.validation?.rule);
|
|
28045
28100
|
if (enumVals && enumVals.length > 0) {
|
|
@@ -28462,6 +28517,7 @@ function canonicalStorageType(col, dialect) {
|
|
|
28462
28517
|
case "text":
|
|
28463
28518
|
case "date":
|
|
28464
28519
|
case "datetime":
|
|
28520
|
+
case "timestamptz":
|
|
28465
28521
|
case "json":
|
|
28466
28522
|
case "enum":
|
|
28467
28523
|
return "TEXT";
|
package/package.json
CHANGED