bun-query-builder 0.2.7 → 0.2.9
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 +19 -11
- package/dist/src/index.js +18 -10
- package/dist/types.d.ts +1 -0
- package/dist/workspace.d.ts +8 -0
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -11725,6 +11725,7 @@ var init_config = __esm(() => {
|
|
|
11725
11725
|
defaultConfig4 = {
|
|
11726
11726
|
verbose: true,
|
|
11727
11727
|
snapshotDir: ".qb",
|
|
11728
|
+
migrationDir: "database/migrations",
|
|
11728
11729
|
dialect: "postgres",
|
|
11729
11730
|
database: {
|
|
11730
11731
|
database: "test_db",
|
|
@@ -18803,7 +18804,7 @@ var init_drivers = __esm(() => {
|
|
|
18803
18804
|
|
|
18804
18805
|
// src/workspace.ts
|
|
18805
18806
|
import { existsSync as existsSync16 } from "fs";
|
|
18806
|
-
import { dirname as dirname8, join as join9 } from "path";
|
|
18807
|
+
import { dirname as dirname8, isAbsolute as isAbsolute3, join as join9 } from "path";
|
|
18807
18808
|
import process24 from "process";
|
|
18808
18809
|
function findWorkspaceRoot2(startPath = process24.cwd()) {
|
|
18809
18810
|
let currentPath = startPath;
|
|
@@ -18814,8 +18815,9 @@ function findWorkspaceRoot2(startPath = process24.cwd()) {
|
|
|
18814
18815
|
}
|
|
18815
18816
|
return process24.cwd();
|
|
18816
18817
|
}
|
|
18817
|
-
function getSqlDirectory(workspaceRoot) {
|
|
18818
|
-
|
|
18818
|
+
function getSqlDirectory(workspaceRoot, migrationDir = "database/migrations") {
|
|
18819
|
+
const configured = migrationDir || "database/migrations";
|
|
18820
|
+
return isAbsolute3(configured) ? configured : join9(workspaceRoot ?? findWorkspaceRoot2(), configured);
|
|
18819
18821
|
}
|
|
18820
18822
|
var init_workspace = () => {};
|
|
18821
18823
|
|
|
@@ -18924,7 +18926,7 @@ function getWorkspaceRoot() {
|
|
|
18924
18926
|
return findWorkspaceRoot2();
|
|
18925
18927
|
}
|
|
18926
18928
|
function ensureSqlDirectory(workspaceRoot) {
|
|
18927
|
-
const sqlDir = getSqlDirectory(workspaceRoot);
|
|
18929
|
+
const sqlDir = getSqlDirectory(workspaceRoot, config5.migrationDir);
|
|
18928
18930
|
if (!existsSync17(sqlDir)) {
|
|
18929
18931
|
mkdirSync8(sqlDir, { recursive: true });
|
|
18930
18932
|
info(`-- Created SQL directory: ${sqlDir}`);
|
|
@@ -19177,7 +19179,7 @@ async function deleteMigrationFiles(dir, workspaceRoot, opts = {}) {
|
|
|
19177
19179
|
unlinkSync(statePath);
|
|
19178
19180
|
info(`-- Removed legacy migration state file: ${statePath}`);
|
|
19179
19181
|
}
|
|
19180
|
-
removeGeneratedMigrationFiles(getSqlDirectory(workspaceRoot));
|
|
19182
|
+
removeGeneratedMigrationFiles(getSqlDirectory(workspaceRoot, config5.migrationDir));
|
|
19181
19183
|
}
|
|
19182
19184
|
function removeGeneratedMigrationFiles(sqlDir) {
|
|
19183
19185
|
if (!existsSync17(sqlDir))
|
|
@@ -19372,7 +19374,7 @@ async function migrateRollback(options = {}) {
|
|
|
19372
19374
|
console.log(` - ${migration.migration}`);
|
|
19373
19375
|
}
|
|
19374
19376
|
console.log();
|
|
19375
|
-
const sqlDir = getSqlDirectory();
|
|
19377
|
+
const sqlDir = getSqlDirectory(undefined, config5.migrationDir);
|
|
19376
19378
|
let reversedAny = false;
|
|
19377
19379
|
for (const migration of migrationsToRollback) {
|
|
19378
19380
|
try {
|
|
@@ -19422,7 +19424,7 @@ import { existsSync as existsSync19, readdirSync as readdirSync8 } from "fs";
|
|
|
19422
19424
|
async function migrateStatus() {
|
|
19423
19425
|
const dialect = config5.dialect || "postgres";
|
|
19424
19426
|
const driver = getDialectDriver(dialect);
|
|
19425
|
-
const sqlDir = getSqlDirectory();
|
|
19427
|
+
const sqlDir = getSqlDirectory(undefined, config5.migrationDir);
|
|
19426
19428
|
console.log("-- Migration Status");
|
|
19427
19429
|
console.log(`-- Dialect: ${dialect}`);
|
|
19428
19430
|
console.log(`-- SQL directory: ${sqlDir}`);
|
|
@@ -28117,7 +28119,7 @@ var init_factory = () => {};
|
|
|
28117
28119
|
|
|
28118
28120
|
// src/loader.ts
|
|
28119
28121
|
import { readdirSync as readdirSync12 } from "fs";
|
|
28120
|
-
import { basename, extname as extname4, isAbsolute as
|
|
28122
|
+
import { basename, extname as extname4, isAbsolute as isAbsolute5, join as join17 } from "path";
|
|
28121
28123
|
import process30 from "process";
|
|
28122
28124
|
function isModelFile(name) {
|
|
28123
28125
|
const ext = extname4(name);
|
|
@@ -28150,7 +28152,7 @@ function collectModelFiles(dir) {
|
|
|
28150
28152
|
}
|
|
28151
28153
|
async function loadModels(options) {
|
|
28152
28154
|
const cwd = options.cwd ?? process30.cwd();
|
|
28153
|
-
const dir =
|
|
28155
|
+
const dir = isAbsolute5(options.modelsDir) ? options.modelsDir : join17(cwd, options.modelsDir);
|
|
28154
28156
|
const result = {};
|
|
28155
28157
|
for (const full of collectModelFiles(dir)) {
|
|
28156
28158
|
const cacheBuster = `?t=${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
@@ -28284,7 +28286,7 @@ function findWorkspaceRoot5(startPath) {
|
|
|
28284
28286
|
}
|
|
28285
28287
|
function ensureSqlDirectory2() {
|
|
28286
28288
|
const workspaceRoot = findWorkspaceRoot5(process31.cwd());
|
|
28287
|
-
const sqlDir =
|
|
28289
|
+
const sqlDir = getSqlDirectory(workspaceRoot, config5.migrationDir);
|
|
28288
28290
|
if (!existsSync23(sqlDir)) {
|
|
28289
28291
|
mkdirSync10(sqlDir, { recursive: true });
|
|
28290
28292
|
info2(`-- Created SQL directory: ${sqlDir}`);
|
|
@@ -28559,6 +28561,11 @@ function buildMigrationPlan2(models, options) {
|
|
|
28559
28561
|
let enumValues;
|
|
28560
28562
|
const isPk = attrName === primaryKey;
|
|
28561
28563
|
inferred = normalizeAttributeType(attr.type) ?? detectTypeFromValidationRule(attr.validation?.rule);
|
|
28564
|
+
if (inferred === "string") {
|
|
28565
|
+
const maxLength = extractMaxFromRules(attr.validation?.rule);
|
|
28566
|
+
if (maxLength && maxLength > 255)
|
|
28567
|
+
inferred = "text";
|
|
28568
|
+
}
|
|
28562
28569
|
if (!inferred || inferred === "enum") {
|
|
28563
28570
|
const enumVals = detectEnumFromValidationRule(attr.validation?.rule);
|
|
28564
28571
|
if (enumVals && enumVals.length > 0) {
|
|
@@ -29446,6 +29453,7 @@ var init_migrations = __esm(() => {
|
|
|
29446
29453
|
init_drivers();
|
|
29447
29454
|
init_sqlite();
|
|
29448
29455
|
init_meta();
|
|
29456
|
+
init_workspace();
|
|
29449
29457
|
createdMigrationFiles = [];
|
|
29450
29458
|
});
|
|
29451
29459
|
|
|
@@ -31528,7 +31536,7 @@ function getPrefix() {
|
|
|
31528
31536
|
}
|
|
31529
31537
|
var prefix = getPrefix();
|
|
31530
31538
|
// package.json
|
|
31531
|
-
var version2 = "0.2.
|
|
31539
|
+
var version2 = "0.2.9";
|
|
31532
31540
|
|
|
31533
31541
|
// bin/cli.ts
|
|
31534
31542
|
init_actions();
|
package/dist/src/index.js
CHANGED
|
@@ -11724,6 +11724,7 @@ var init_config = __esm(() => {
|
|
|
11724
11724
|
defaultConfig4 = {
|
|
11725
11725
|
verbose: true,
|
|
11726
11726
|
snapshotDir: ".qb",
|
|
11727
|
+
migrationDir: "database/migrations",
|
|
11727
11728
|
dialect: "postgres",
|
|
11728
11729
|
database: {
|
|
11729
11730
|
database: "test_db",
|
|
@@ -18802,7 +18803,7 @@ var init_drivers = __esm(() => {
|
|
|
18802
18803
|
|
|
18803
18804
|
// src/workspace.ts
|
|
18804
18805
|
import { existsSync as existsSync16 } from "fs";
|
|
18805
|
-
import { dirname as dirname8, join as join9 } from "path";
|
|
18806
|
+
import { dirname as dirname8, isAbsolute as isAbsolute3, join as join9 } from "path";
|
|
18806
18807
|
import process24 from "process";
|
|
18807
18808
|
function findWorkspaceRoot2(startPath = process24.cwd()) {
|
|
18808
18809
|
let currentPath = startPath;
|
|
@@ -18813,8 +18814,9 @@ function findWorkspaceRoot2(startPath = process24.cwd()) {
|
|
|
18813
18814
|
}
|
|
18814
18815
|
return process24.cwd();
|
|
18815
18816
|
}
|
|
18816
|
-
function getSqlDirectory(workspaceRoot) {
|
|
18817
|
-
|
|
18817
|
+
function getSqlDirectory(workspaceRoot, migrationDir = "database/migrations") {
|
|
18818
|
+
const configured = migrationDir || "database/migrations";
|
|
18819
|
+
return isAbsolute3(configured) ? configured : join9(workspaceRoot ?? findWorkspaceRoot2(), configured);
|
|
18818
18820
|
}
|
|
18819
18821
|
var init_workspace = () => {};
|
|
18820
18822
|
|
|
@@ -18923,7 +18925,7 @@ function getWorkspaceRoot() {
|
|
|
18923
18925
|
return findWorkspaceRoot2();
|
|
18924
18926
|
}
|
|
18925
18927
|
function ensureSqlDirectory(workspaceRoot) {
|
|
18926
|
-
const sqlDir = getSqlDirectory(workspaceRoot);
|
|
18928
|
+
const sqlDir = getSqlDirectory(workspaceRoot, config5.migrationDir);
|
|
18927
18929
|
if (!existsSync17(sqlDir)) {
|
|
18928
18930
|
mkdirSync8(sqlDir, { recursive: true });
|
|
18929
18931
|
info(`-- Created SQL directory: ${sqlDir}`);
|
|
@@ -19176,7 +19178,7 @@ async function deleteMigrationFiles(dir, workspaceRoot, opts = {}) {
|
|
|
19176
19178
|
unlinkSync(statePath);
|
|
19177
19179
|
info(`-- Removed legacy migration state file: ${statePath}`);
|
|
19178
19180
|
}
|
|
19179
|
-
removeGeneratedMigrationFiles(getSqlDirectory(workspaceRoot));
|
|
19181
|
+
removeGeneratedMigrationFiles(getSqlDirectory(workspaceRoot, config5.migrationDir));
|
|
19180
19182
|
}
|
|
19181
19183
|
function removeGeneratedMigrationFiles(sqlDir) {
|
|
19182
19184
|
if (!existsSync17(sqlDir))
|
|
@@ -19371,7 +19373,7 @@ async function migrateRollback(options = {}) {
|
|
|
19371
19373
|
console.log(` - ${migration.migration}`);
|
|
19372
19374
|
}
|
|
19373
19375
|
console.log();
|
|
19374
|
-
const sqlDir = getSqlDirectory();
|
|
19376
|
+
const sqlDir = getSqlDirectory(undefined, config5.migrationDir);
|
|
19375
19377
|
let reversedAny = false;
|
|
19376
19378
|
for (const migration of migrationsToRollback) {
|
|
19377
19379
|
try {
|
|
@@ -19421,7 +19423,7 @@ import { existsSync as existsSync19, readdirSync as readdirSync8 } from "fs";
|
|
|
19421
19423
|
async function migrateStatus() {
|
|
19422
19424
|
const dialect = config5.dialect || "postgres";
|
|
19423
19425
|
const driver = getDialectDriver(dialect);
|
|
19424
|
-
const sqlDir = getSqlDirectory();
|
|
19426
|
+
const sqlDir = getSqlDirectory(undefined, config5.migrationDir);
|
|
19425
19427
|
console.log("-- Migration Status");
|
|
19426
19428
|
console.log(`-- Dialect: ${dialect}`);
|
|
19427
19429
|
console.log(`-- SQL directory: ${sqlDir}`);
|
|
@@ -28116,7 +28118,7 @@ var init_factory = () => {};
|
|
|
28116
28118
|
|
|
28117
28119
|
// src/loader.ts
|
|
28118
28120
|
import { readdirSync as readdirSync12 } from "fs";
|
|
28119
|
-
import { basename, extname as extname4, isAbsolute as
|
|
28121
|
+
import { basename, extname as extname4, isAbsolute as isAbsolute5, join as join17 } from "path";
|
|
28120
28122
|
import process30 from "process";
|
|
28121
28123
|
function isModelFile(name) {
|
|
28122
28124
|
const ext = extname4(name);
|
|
@@ -28149,7 +28151,7 @@ function collectModelFiles(dir) {
|
|
|
28149
28151
|
}
|
|
28150
28152
|
async function loadModels(options) {
|
|
28151
28153
|
const cwd = options.cwd ?? process30.cwd();
|
|
28152
|
-
const dir =
|
|
28154
|
+
const dir = isAbsolute5(options.modelsDir) ? options.modelsDir : join17(cwd, options.modelsDir);
|
|
28153
28155
|
const result = {};
|
|
28154
28156
|
for (const full of collectModelFiles(dir)) {
|
|
28155
28157
|
const cacheBuster = `?t=${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
@@ -28283,7 +28285,7 @@ function findWorkspaceRoot5(startPath) {
|
|
|
28283
28285
|
}
|
|
28284
28286
|
function ensureSqlDirectory2() {
|
|
28285
28287
|
const workspaceRoot = findWorkspaceRoot5(process31.cwd());
|
|
28286
|
-
const sqlDir =
|
|
28288
|
+
const sqlDir = getSqlDirectory(workspaceRoot, config5.migrationDir);
|
|
28287
28289
|
if (!existsSync23(sqlDir)) {
|
|
28288
28290
|
mkdirSync10(sqlDir, { recursive: true });
|
|
28289
28291
|
info2(`-- Created SQL directory: ${sqlDir}`);
|
|
@@ -28558,6 +28560,11 @@ function buildMigrationPlan2(models, options) {
|
|
|
28558
28560
|
let enumValues;
|
|
28559
28561
|
const isPk = attrName === primaryKey;
|
|
28560
28562
|
inferred = normalizeAttributeType(attr.type) ?? detectTypeFromValidationRule(attr.validation?.rule);
|
|
28563
|
+
if (inferred === "string") {
|
|
28564
|
+
const maxLength = extractMaxFromRules(attr.validation?.rule);
|
|
28565
|
+
if (maxLength && maxLength > 255)
|
|
28566
|
+
inferred = "text";
|
|
28567
|
+
}
|
|
28561
28568
|
if (!inferred || inferred === "enum") {
|
|
28562
28569
|
const enumVals = detectEnumFromValidationRule(attr.validation?.rule);
|
|
28563
28570
|
if (enumVals && enumVals.length > 0) {
|
|
@@ -29445,6 +29452,7 @@ var init_migrations = __esm(() => {
|
|
|
29445
29452
|
init_drivers();
|
|
29446
29453
|
init_sqlite();
|
|
29447
29454
|
init_meta();
|
|
29455
|
+
init_workspace();
|
|
29448
29456
|
createdMigrationFiles = [];
|
|
29449
29457
|
});
|
|
29450
29458
|
|
package/dist/types.d.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The nearest ancestor of `startPath` containing a `package.json`, or the
|
|
3
|
+
* working directory when there is none — which keeps a bare directory (a test
|
|
4
|
+
* fixture, a scratch folder) working as its own workspace.
|
|
5
|
+
*/
|
|
6
|
+
export declare function findWorkspaceRoot(startPath?: string): string;
|
|
7
|
+
/** The configured migration corpus, resolved from the workspace root. */
|
|
8
|
+
export declare function getSqlDirectory(workspaceRoot?: string, migrationDir?: string): string;
|
package/package.json
CHANGED