@uql/core 3.7.8 → 3.7.10
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/CHANGELOG.md +12 -6
- package/README.md +26 -7
- package/dist/migrate/bin.d.ts +1 -3
- package/dist/migrate/bin.d.ts.map +1 -1
- package/dist/migrate/bin.js +4 -14
- package/dist/migrate/bin.js.map +1 -1
- package/dist/migrate/cli-config.js +6 -7
- package/dist/migrate/cli-config.js.map +1 -1
- package/dist/migrate/cli.js +9 -9
- package/dist/migrate/migrator.js +2 -2
- package/dist/type/config.d.ts +29 -2
- package/dist/type/config.d.ts.map +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [3.7.
|
|
6
|
+
## [3.7.10](https://github.com/rogerpadilla/uql/compare/@uql/core@3.7.9...@uql/core@3.7.10) (2026-01-05)
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
### Features
|
|
10
10
|
|
|
11
|
-
*
|
|
11
|
+
* Integrate jiti for robust TypeScript configuration loading and update migration tool paths to `@uql/core/migrate`. ([8bc4971](https://github.com/rogerpadilla/uql/commit/8bc497128d4bc35c8dfdf01a48d7b1e3ac2d08d6))
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -20,9 +20,15 @@ All notable changes to this project will be documented in this file. Please add
|
|
|
20
20
|
|
|
21
21
|
date format is [yyyy-mm-dd]
|
|
22
22
|
|
|
23
|
-
## [3.7.
|
|
24
|
-
###
|
|
25
|
-
- **
|
|
23
|
+
## [3.7.10] - 2026-01-04
|
|
24
|
+
### Improvements
|
|
25
|
+
- **Robust Config Loading**: Integrated `jiti` into the CLI configuration loader. This allows `uql-migrate` to natively support TypeScript configuration files (`uql.config.ts`) and properly resolve ESM/CJS interop logic across all node environments (Node.js, Bun, etc.) without requiring custom runtime flags.
|
|
26
|
+
|
|
27
|
+
## [3.7.9] - 2026-01-04
|
|
28
|
+
- **Manual Migrations**: Updated the root README to explicitly document the `generate` command for creating manual incremental migrations (`npx uql-migrate generate <name>`), ensuring developers know how to create empty migration files efficiently.
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
- **CLI Entry Point**: Fixed a critical issue where the `uql-migrate` command would silently fail in certain environments (e.g., when run via `npx` or symlinks) due to brittle entry point detection. The CLI now reliably executes regardless of how it is invoked.
|
|
26
32
|
|
|
27
33
|
## [3.7.7] - 2026-01-04
|
|
28
34
|
### Refined Foreign Key Handling & Control
|
|
@@ -119,7 +125,7 @@ Reflect major changes in the package structure and dependencies.
|
|
|
119
125
|
- **Package Unification**: Unified all database adapters (`mysql`, `postgres`, `maria`, `sqlite`, `mongo`) and `express` middleware into a single core package: `@uql/core`.
|
|
120
126
|
- **Scoped Naming**:
|
|
121
127
|
- `@uql/core`: The main ORM engine and all database adapters.
|
|
122
|
-
- `@uql/migrate`: The database migration system (formerly `nukak-migrate`).
|
|
128
|
+
- `@uql/core/migrate`: The database migration system (formerly `nukak-migrate`).
|
|
123
129
|
- **Improved API Surface**:
|
|
124
130
|
- Database-specific logic is now accessible via sub-paths (e.g., `import { ... } from '@uql/core/postgres'`).
|
|
125
131
|
- Unified `NamingStrategy` and `QueryContext` across all unified adapters.
|
package/README.md
CHANGED
|
@@ -243,7 +243,7 @@ export const pool = new PgQuerierPool(
|
|
|
243
243
|
|
|
244
244
|
export default {
|
|
245
245
|
pool,
|
|
246
|
-
|
|
246
|
+
entities: [User, Profile, Post],
|
|
247
247
|
migrationsPath: './migrations',
|
|
248
248
|
} satisfies Config;
|
|
249
249
|
```
|
|
@@ -355,7 +355,7 @@ import type { Config } from '@uql/core';
|
|
|
355
355
|
|
|
356
356
|
export default {
|
|
357
357
|
pool: new PgQuerierPool({ /* ... */ }),
|
|
358
|
-
|
|
358
|
+
entities: [User, Profile, Post],
|
|
359
359
|
migrationsPath: './migrations',
|
|
360
360
|
} satisfies Config;
|
|
361
361
|
```
|
|
@@ -364,14 +364,33 @@ export default {
|
|
|
364
364
|
|
|
365
365
|
### 2. Manage via CLI
|
|
366
366
|
|
|
367
|
+
|
|
368
|
+
Use the CLI to manage your database schema evolution.
|
|
369
|
+
|
|
370
|
+
| Command | Description |
|
|
371
|
+
| :--- | :--- |
|
|
372
|
+
| `generate <name>` | Creates an empty timestamped file for **manual** SQL migrations (e.g., data backfills). |
|
|
373
|
+
| `generate:entities <name>` | **Auto-generates** a migration by diffing your entities against the current DB schema. |
|
|
374
|
+
| `up` | Applies all pending migrations. |
|
|
375
|
+
| `down` | Rolls back the last applied migration batch. |
|
|
376
|
+
| `status` | Shows which migrations have been executed and which are pending. |
|
|
377
|
+
|
|
378
|
+
#### Usage Examples
|
|
379
|
+
|
|
367
380
|
```bash
|
|
368
|
-
#
|
|
369
|
-
npx uql-migrate generate
|
|
370
|
-
|
|
381
|
+
# 1. Create a manual migration
|
|
382
|
+
npx uql-migrate generate seed_default_roles
|
|
383
|
+
|
|
384
|
+
# 2. Auto-generate schema changes from your code
|
|
385
|
+
npx uql-migrate generate:entities add_profile_table
|
|
386
|
+
|
|
387
|
+
# 3. Apply changes
|
|
371
388
|
npx uql-migrate up
|
|
372
|
-
|
|
389
|
+
|
|
390
|
+
# 4. Revert changes if needed
|
|
373
391
|
npx uql-migrate down
|
|
374
|
-
|
|
392
|
+
|
|
393
|
+
# 5. Run with custom config
|
|
375
394
|
npx uql-migrate up --config ./configs/uql.config.ts
|
|
376
395
|
```
|
|
377
396
|
|
package/dist/migrate/bin.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/migrate/bin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/migrate/bin.ts"],"names":[],"mappings":""}
|
package/dist/migrate/bin.js
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { pathToFileURL } from 'node:url';
|
|
3
2
|
import { main } from './cli.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const isMain = import.meta.url === pathToFileURL(process.argv[1]).href;
|
|
9
|
-
if (isMain) {
|
|
10
|
-
main(process.argv.slice(2)).catch((err) => {
|
|
11
|
-
console.error(err);
|
|
12
|
-
process.exit(1);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
// Export for testing
|
|
16
|
-
export const _scriptLogic = { isMain };
|
|
3
|
+
main(process.argv.slice(2)).catch((err) => {
|
|
4
|
+
console.error(err);
|
|
5
|
+
process.exit(1);
|
|
6
|
+
});
|
|
17
7
|
//# sourceMappingURL=bin.js.map
|
package/dist/migrate/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/migrate/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/migrate/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACxC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { stat } from 'node:fs/promises';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
-
import {
|
|
3
|
+
import { createJiti } from 'jiti';
|
|
4
4
|
export async function loadConfig(customPath) {
|
|
5
|
+
const jiti = createJiti(process.cwd());
|
|
5
6
|
if (customPath) {
|
|
6
7
|
const fullPath = resolve(process.cwd(), customPath);
|
|
7
8
|
const exists = await stat(fullPath)
|
|
@@ -10,10 +11,9 @@ export async function loadConfig(customPath) {
|
|
|
10
11
|
if (!exists) {
|
|
11
12
|
throw new Error(`Could not find uql configuration file at ${customPath}`);
|
|
12
13
|
}
|
|
13
|
-
const fileUrl = pathToFileURL(fullPath).href;
|
|
14
14
|
try {
|
|
15
|
-
const config = await import(
|
|
16
|
-
return config
|
|
15
|
+
const config = await jiti.import(fullPath, { default: true });
|
|
16
|
+
return config;
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
19
19
|
throw new Error(`Could not load configuration file at ${customPath}: ${error.message}`);
|
|
@@ -26,9 +26,8 @@ export async function loadConfig(customPath) {
|
|
|
26
26
|
.then(() => true)
|
|
27
27
|
.catch(() => false);
|
|
28
28
|
if (exists) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
return config.default ?? config;
|
|
29
|
+
const config = await jiti.import(fullPath, { default: true });
|
|
30
|
+
return config;
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
33
|
throw new Error('Could not find uql configuration file. Create a uql.config.ts or uql.config.js file in your project root.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-config.js","sourceRoot":"","sources":["../../src/migrate/cli-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cli-config.js","sourceRoot":"","sources":["../../src/migrate/cli-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGlC,MAAM,CAAC,KAAK,UAAU,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AAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9D,OAAO,MAAgB,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CACb,2GAA2G,CAC5G,CAAC;AACJ,CAAC"}
|
package/dist/migrate/cli.js
CHANGED
|
@@ -195,9 +195,9 @@ export async function runSync(migrator, args) {
|
|
|
195
195
|
}
|
|
196
196
|
export function printHelp() {
|
|
197
197
|
console.log(`
|
|
198
|
-
@uql/migrate - Database migration tool for uql ORM
|
|
198
|
+
@uql/core/migrate - Database migration tool for uql ORM
|
|
199
199
|
|
|
200
|
-
Usage: @uql/migrate <command> [options]
|
|
200
|
+
Usage: @uql/core/migrate <command> [options]
|
|
201
201
|
|
|
202
202
|
Commands:
|
|
203
203
|
up Run all pending migrations
|
|
@@ -235,13 +235,13 @@ Configuration:
|
|
|
235
235
|
};
|
|
236
236
|
|
|
237
237
|
Examples:
|
|
238
|
-
@uql/migrate up
|
|
239
|
-
@uql/migrate up --step 1
|
|
240
|
-
@uql/migrate down
|
|
241
|
-
@uql/migrate down --step 3
|
|
242
|
-
@uql/migrate status
|
|
243
|
-
@uql/migrate generate add_users_table
|
|
244
|
-
@uql/migrate generate:entities initial_schema
|
|
238
|
+
@uql/core/migrate up
|
|
239
|
+
@uql/core/migrate up --step 1
|
|
240
|
+
@uql/core/migrate down
|
|
241
|
+
@uql/core/migrate down --step 3
|
|
242
|
+
@uql/core/migrate status
|
|
243
|
+
@uql/core/migrate generate add_users_table
|
|
244
|
+
@uql/core/migrate generate:entities initial_schema
|
|
245
245
|
`);
|
|
246
246
|
}
|
|
247
247
|
//# sourceMappingURL=cli.js.map
|
package/dist/migrate/migrator.js
CHANGED
|
@@ -554,7 +554,7 @@ export class Migrator {
|
|
|
554
554
|
* Generate migration file content
|
|
555
555
|
*/
|
|
556
556
|
generateMigrationContent(name) {
|
|
557
|
-
return /*ts*/ `import type { SqlQuerier } from '@uql/migrate';
|
|
557
|
+
return /*ts*/ `import type { SqlQuerier } from '@uql/core/migrate';
|
|
558
558
|
|
|
559
559
|
/**
|
|
560
560
|
* Migration: ${name}
|
|
@@ -588,7 +588,7 @@ export default {
|
|
|
588
588
|
generateMigrationContentWithStatements(name, upStatements, downStatements) {
|
|
589
589
|
const upSql = upStatements.map((s) => /*ts*/ ` await querier.run(\`${s}\`);`).join('\n');
|
|
590
590
|
const downSql = downStatements.map((s) => /*ts*/ ` await querier.run(\`${s}\`);`).join('\n');
|
|
591
|
-
return /*ts*/ `import type { SqlQuerier } from '@uql/migrate';
|
|
591
|
+
return /*ts*/ `import type { SqlQuerier } from '@uql/core/migrate';
|
|
592
592
|
|
|
593
593
|
/**
|
|
594
594
|
* Migration: ${name}
|
package/dist/type/config.d.ts
CHANGED
|
@@ -2,12 +2,39 @@ import type { NamingStrategy } from './namingStrategy.js';
|
|
|
2
2
|
import type { Dialect } from './querier.js';
|
|
3
3
|
import type { QuerierPool } from './querierPool.js';
|
|
4
4
|
import type { Type } from './utility.js';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for the UQL ORM and Migrator.
|
|
7
|
+
*/
|
|
5
8
|
export interface Config {
|
|
6
|
-
|
|
9
|
+
/**
|
|
10
|
+
* The connection pool used to interact with the database.
|
|
11
|
+
* This is required for both the application and the migrations CLI.
|
|
12
|
+
*/
|
|
13
|
+
pool: QuerierPool;
|
|
14
|
+
/**
|
|
15
|
+
* List of entity classes to be managed by the ORM.
|
|
16
|
+
* If not provided, UQL will attempt to infer them from the `@Entity` decorators if `emitDecoratorMetadata` is enabled.
|
|
17
|
+
*/
|
|
18
|
+
entities?: Type<unknown>[];
|
|
19
|
+
/**
|
|
20
|
+
* The directory where migration files are stored.
|
|
21
|
+
* @default './migrations'
|
|
22
|
+
*/
|
|
7
23
|
migrationsPath?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The name of the table used to track executed migrations in the database.
|
|
26
|
+
* @default 'uql_migrations'
|
|
27
|
+
*/
|
|
8
28
|
tableName?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The SQL dialect to be used (e.g., 'postgres', 'mysql', 'sqlite').
|
|
31
|
+
* If not provided, it is inferred from the `pool` instance.
|
|
32
|
+
*/
|
|
9
33
|
dialect?: Dialect;
|
|
10
|
-
|
|
34
|
+
/**
|
|
35
|
+
* The naming strategy for mapping class/property names to database table/column names.
|
|
36
|
+
* @default DefaultNamingStrategy (camelCase -> camelCase)
|
|
37
|
+
*/
|
|
11
38
|
namingStrategy?: NamingStrategy;
|
|
12
39
|
}
|
|
13
40
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/type/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,WAAW,MAAM;IACrB,IAAI,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/type/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;;OAGG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;IAE3B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"homepage": "https://uql.app",
|
|
4
4
|
"description": "One Language. Frontend to Backend.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "3.7.
|
|
6
|
+
"version": "3.7.10",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/index.js",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"clean": "rimraf dist *.tsbuildinfo"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
+
"jiti": "^2.6.1",
|
|
54
55
|
"reflect-metadata": "^0.2.2",
|
|
55
56
|
"sqlstring": "^2.3.3",
|
|
56
57
|
"sqlstring-sqlite": "^0.1.1",
|
|
@@ -143,5 +144,5 @@
|
|
|
143
144
|
"publishConfig": {
|
|
144
145
|
"access": "public"
|
|
145
146
|
},
|
|
146
|
-
"gitHead": "
|
|
147
|
+
"gitHead": "53a8ef0e2eb62d6e236262a4552f998d77dbd5bb"
|
|
147
148
|
}
|