uql-codemod 0.32.0 → 0.34.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.
Files changed (2) hide show
  1. package/dist/transform.js +21 -6
  2. 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) {
@@ -171,7 +181,7 @@ function dropDeclare(node, ctx) {
171
181
  // break left the rest behind.
172
182
  const text = node.getSourceFile().text;
173
183
  let end = modifier.getEnd();
174
- while (/\s/.test(text[end] ?? '')) {
184
+ while (/\s/.test(text[end])) {
175
185
  end += 1;
176
186
  }
177
187
  ctx.edits.push({ start: modifier.getStart(), end, text: '' });
@@ -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
- /** What the file imports from `uql-orm` by name, which is every import this codemod reads or writes. */
345
- function uqlImports(source) {
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
- if (statement.moduleSpecifier.text !== 'uql-orm') {
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;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "uql-codemod",
3
3
  "description": "Upgrade uql-orm across versions that introduce breaking changes",
4
4
  "license": "MIT",
5
- "version": "0.32.0",
5
+ "version": "0.34.0",
6
6
  "type": "module",
7
7
  "engines": {
8
8
  "node": ">=24"