uql-codemod 0.32.0 → 0.33.0
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/transform.js +20 -5
- package/package.json +1 -1
package/dist/transform.js
CHANGED
|
@@ -26,6 +26,16 @@ const REMOVED_EXPORTS = new Map([
|
|
|
26
26
|
['QueryWhereFieldMap', 'use `QueryWhere`'],
|
|
27
27
|
['augmentWhere', 'spread the two maps: `{ ...where, ...extra }`'],
|
|
28
28
|
['buildQueryWhereAsMap', 'a `$where` is a map already; name the key for ids: `{ id: [1, 2] }`'],
|
|
29
|
+
['PgDialect', 'the pools build `PostgresDialect` (`uql-orm/postgres`); name that where a dialect is typed'],
|
|
30
|
+
['NeonDialect', 'the pools build `PostgresDialect` (`uql-orm/postgres`); name that where a dialect is typed'],
|
|
31
|
+
['PgliteDialect', 'the pools build `PostgresDialect` (`uql-orm/postgres`); name that where a dialect is typed'],
|
|
32
|
+
['MySql2Dialect', 'the pool builds `MySqlDialect` (`uql-orm/mysql`)'],
|
|
33
|
+
['MongodbNativeDialect', 'the pool builds `MongoDialect` (`uql-orm/mongo`)'],
|
|
34
|
+
['AbstractPgQuerier', 'every pg-compatible pool returns `PgQuerier` (`uql-orm/postgres`), which is concrete'],
|
|
35
|
+
['CrdbQuerier', 'every pg-compatible pool returns `PgQuerier` (`uql-orm/postgres`)'],
|
|
36
|
+
['NeonQuerier', 'every pg-compatible pool returns `PgQuerier` (`uql-orm/postgres`)'],
|
|
37
|
+
['LibsqlQuerier', 'the libSQL and Turso pools return `HranaQuerier` (`uql-orm/sqlite`)'],
|
|
38
|
+
['TursoQuerier', 'the libSQL and Turso pools return `HranaQuerier` (`uql-orm/sqlite`)'],
|
|
29
39
|
]);
|
|
30
40
|
/** A node's decorators, or none where it is a kind that cannot carry them. */
|
|
31
41
|
function decoratorsOf(node) {
|
|
@@ -331,9 +341,9 @@ function reportRemovedDecorators(node, ctx) {
|
|
|
331
341
|
}
|
|
332
342
|
}
|
|
333
343
|
}
|
|
334
|
-
/** Names an export that no longer exists, where it is imported from the package. */
|
|
344
|
+
/** Names an export that no longer exists, where it is imported from the package or one of its entries. */
|
|
335
345
|
function reportRemovedExports(source, ctx) {
|
|
336
|
-
for (const element of uqlImports(source)) {
|
|
346
|
+
for (const element of uqlImports(source, true)) {
|
|
337
347
|
const name = importedName(element);
|
|
338
348
|
const advice = REMOVED_EXPORTS.get(name);
|
|
339
349
|
if (advice) {
|
|
@@ -341,13 +351,18 @@ function reportRemovedExports(source, ctx) {
|
|
|
341
351
|
}
|
|
342
352
|
}
|
|
343
353
|
}
|
|
344
|
-
/**
|
|
345
|
-
|
|
354
|
+
/**
|
|
355
|
+
* What the file imports from `uql-orm` by name, which is every import this codemod reads or writes.
|
|
356
|
+
* `entries` adds the driver entries (`uql-orm/postgres`, ...), for reporting only: an import written
|
|
357
|
+
* into one of those would land on an entry that may not export it.
|
|
358
|
+
*/
|
|
359
|
+
function uqlImports(source, entries = false) {
|
|
346
360
|
return source.statements.flatMap((statement) => {
|
|
347
361
|
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) {
|
|
348
362
|
return [];
|
|
349
363
|
}
|
|
350
|
-
|
|
364
|
+
const specifier = statement.moduleSpecifier.text;
|
|
365
|
+
if (specifier !== 'uql-orm' && !(entries && specifier.startsWith('uql-orm/'))) {
|
|
351
366
|
return [];
|
|
352
367
|
}
|
|
353
368
|
const bindings = statement.importClause?.namedBindings;
|