uql-codemod 0.41.0 → 0.43.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/README.md CHANGED
@@ -32,7 +32,7 @@ Only `--flag=value` is read, and anything unrecognised is an error. It exits `0`
32
32
  - A partial-index `where` string to `raw`, importing it, on entities and in the migration builder.
33
33
  - `col('cost')` to the ref it names, ``(product) => raw`${product.cost}` `` in a `computed` and `refs(Item).cost` in a statement, and `$lock: { wait: 'skip' }` to `{ $wait: 'skip' }`, or to `true` for `{}` and a `'block'` wait.
34
34
  - An aggregate's `$agg` to `$select`, and each field it or `$text`'s `$fields` names to a key: `{ $sum: { amount: true } }`.
35
- - Renamed exports, at the import and every use: `QueryWhereMap` to `QueryWhere`, `RelationKeyMap` to `KeyMap`, `FilterCondition` to `FilterWhere`, `SqlMigrationModuleOptions` to `MigrationModuleOptions`, `buildSqlQuerierMigrationModule` to `buildMigrationModule`, `QueryDialect` to `SqlQueryDialect`, `EngineFeatures` to `DialectFeatures`, `KnownMigratorDialect` to `DialectName`, `D1Preparer`/`D1Database` to `D1Queryable`, and the removed driver classes to the one each extended: `PgDialect`/`NeonDialect`/`PgliteDialect` to `PostgresDialect`, `CrdbQuerier`/`NeonQuerier` to `PgQuerier`, `LibsqlQuerier`/`TursoQuerier` to `HranaQuerier`, `TursoLocalQuerier` to `SqliteQuerier` and `TursoDatabase` to `SqliteDatabase`, `MySql2Dialect` to `MySqlDialect`, `MongodbNativeDialect` to `MongoDialect`, moving the import to the entry that exports it.
35
+ - Renamed exports, at the import and every use: `QueryWhereMap` to `QueryWhere`, `RelationKeyMap` to `KeyMap`, `FilterCondition` to `FilterWhere`, `SqlMigrationModuleOptions` to `MigrationModuleOptions`, `buildSqlQuerierMigrationModule` to `buildMigrationModule`, `QueryDialect` to `SqlQueryDialect`, `EngineFeatures` to `DialectFeatures`, `KnownMigratorDialect` to `DialectName`, `D1Preparer`/`D1Database` to `D1Queryable`, and the removed driver classes to the one each extended: `PgDialect`/`NeonDialect`/`PgliteDialect` to `PostgresDialect`, `CrdbQuerier`/`NeonQuerier` to `PgQuerier`, `LibsqlQuerier`/`TursoQuerier` to `HranaQuerier`, `TursoLocalQuerier` to `SqliteQuerier` and `TursoDatabase` to `SqliteDatabase`, `MySql2Dialect` to `MySqlDialect`, `MongodbNativeDialect` to `MongoDialect`, moving the import to the entry that exports it; and `MongoQuerier`, `isMongoQuerier`, `MongoMigrationStorage` and `MongoSchemaIntrospector` to `uql-orm/mongo`.
36
36
  - The `[idKey]?: '...'` brand, and its import, on a key not called `id`, `_id` or `uuid` and on every composite.
37
37
  - `import 'reflect-metadata'`, and `experimentalDecorators`/`emitDecoratorMetadata` in `tsconfig.json`, comments and formatting kept.
38
38
 
package/dist/transform.js CHANGED
@@ -29,6 +29,7 @@ const REMOVED_EXPORTS = new Map([
29
29
  ],
30
30
  ['getQuerierPool', 'take the pool from the module that builds it, or from Nest DI'],
31
31
  ['getQuerier', 'use `pool.withQuerier(...)` / `pool.transaction(...)`, which release the connection'],
32
+ ['ClientQuerierPool', "construct the `HttpQuerier` where it is used, `new HttpQuerier('/api')`"],
32
33
  ['QueryWhereFieldMap', 'use `QueryWhere`'],
33
34
  ['QueryStreamProjected', 'use `QueryProjected`'],
34
35
  ['RelationMappedBy', "a 'mappedBy' is `(keys: KeyMap<E>) => Key<E>` now"],
@@ -61,8 +62,8 @@ const REMOVED_EXPORTS = new Map([
61
62
  ['createSchemaGenerator', 'use `new SqlSchemaGenerator(dialect)`, or `migrator.getSchemaGenerator()`'],
62
63
  ]);
63
64
  /**
64
- * Exports renamed and nothing else - the driver classes were empty subclasses - so the import and every
65
- * use follow, the import moving to `from` where the new name lives in another entry.
65
+ * Exports renamed or moved and nothing else - the driver classes were empty subclasses - so the import and
66
+ * every use follow, the import moving to `from` where the name lives in another entry.
66
67
  */
67
68
  const RENAMED_EXPORTS = new Map([
68
69
  ['QueryWhereMap', { to: 'QueryWhere' }],
@@ -86,6 +87,10 @@ const RENAMED_EXPORTS = new Map([
86
87
  ['KnownMigratorDialect', { to: 'DialectName', from: 'uql-orm' }],
87
88
  ['D1Preparer', { to: 'D1Queryable' }],
88
89
  ['D1Database', { to: 'D1Queryable', from: 'uql-orm/d1' }],
90
+ ['MongoQuerier', { to: 'MongoQuerier', from: 'uql-orm/mongo' }],
91
+ ['isMongoQuerier', { to: 'isMongoQuerier', from: 'uql-orm/mongo' }],
92
+ ['MongoMigrationStorage', { to: 'MongoMigrationStorage', from: 'uql-orm/mongo' }],
93
+ ['MongoSchemaIntrospector', { to: 'MongoSchemaIntrospector', from: 'uql-orm/mongo' }],
89
94
  ]);
90
95
  /** A node's decorators, or none where it is a kind that cannot carry them. */
91
96
  function decoratorsOf(node) {
@@ -785,16 +790,16 @@ function reportRemovedExports(source, ctx) {
785
790
  */
786
791
  function renameExports(source, dead, ctx) {
787
792
  const imports = uqlImportDeclarations(source, true);
788
- const kept = imports.flatMap(({ elements }) => elements).filter((element) => !renamedTo(element));
793
+ const kept = imports.flatMap(({ entry, elements }) => elements.filter((element) => !renamedTo(element, entry)));
789
794
  const bound = new Set(kept.map((element) => element.name.text));
790
795
  const rewritten = new Set();
791
796
  for (const { declaration, entry, elements } of imports) {
792
- if (!elements.some(renamedTo)) {
797
+ if (!elements.some((element) => renamedTo(element, entry))) {
793
798
  continue;
794
799
  }
795
800
  const byEntry = new Map([[entry, []]]);
796
801
  for (const element of elements.filter(({ name }) => !dead.has(name.text))) {
797
- const rename = renamedTo(element);
802
+ const rename = renamedTo(element, entry);
798
803
  const local = element.propertyName || !rename ? element.name.text : rename.to;
799
804
  if (rename && !element.propertyName) {
800
805
  ctx.edits.push(...usesOf(source, element.name, ctx.checker).map((use) => replaced(use, rename.to)));
@@ -820,8 +825,11 @@ function renameExports(source, dead, ctx) {
820
825
  }
821
826
  return rewritten;
822
827
  }
823
- function renamedTo(element) {
824
- return RENAMED_EXPORTS.get(importedName(element));
828
+ /** The rename `element` still needs, none where it already names the export at its entry. */
829
+ function renamedTo(element, entry) {
830
+ const name = importedName(element);
831
+ const rename = RENAMED_EXPORTS.get(name);
832
+ return rename?.to === name && (rename.from ?? entry) === entry ? undefined : rename;
825
833
  }
826
834
  /** Every identifier in the file bound to the same symbol as `name`, besides `name` itself. */
827
835
  function usesOf(source, name, checker) {
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.41.0",
5
+ "version": "0.43.0",
6
6
  "type": "module",
7
7
  "engines": {
8
8
  "node": ">=24"