uql-codemod 0.23.0 → 0.24.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/README.md +20 -30
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # uql-codemod
2
2
 
3
- Migrates [uql-orm](https://uql-orm.dev) entities from the legacy TypeScript decorators to the TC39
4
- standard spec. One command, on your own source, with a dry run first:
3
+ Migrates [uql-orm](https://uql-orm.dev) entities from the legacy TypeScript decorators to the TC39 standard spec. One command, on your own source, with a dry run first:
5
4
 
6
5
  ```sh
7
6
  npx uql-codemod --project=tsconfig.json --dry-run
@@ -14,48 +13,39 @@ npx uql-codemod --project=tsconfig.json
14
13
  | `--dry-run` | Report what would change and touch nothing. |
15
14
  | `--include=<a,b>` | Only files whose path contains one of these fragments. |
16
15
 
17
- Only the `--flag=value` form is read, and anything unrecognised is an error: a misspelled `--dry-run`
18
- would otherwise rewrite the project for real. It exits `0` when nothing is left for you, `1` when
19
- something is, and `2` when it could not start at all - a bad argument, or a project it cannot read.
16
+ Only the `--flag=value` form is read, and anything unrecognised is an error: a misspelled `--dry-run` would otherwise rewrite the project for real. It exits `0` when nothing is left for you, `1` when something is, and `2` when it could not start at all - a bad argument, or a project it cannot read.
20
17
 
21
18
  ## What it rewrites
22
19
 
23
- - `@Field()` and `@Field({ ... })` with no `type`, and `@Id()`: inserts the `type` the property's
24
- declared TypeScript type implies. Skipped when `references` is present, because schema generation
25
- resolves that column from the referenced primary key.
20
+ - `@Field()` and `@Field({ ... })` with no `type`, and `@Id()`: inserts the `type` the property's declared TypeScript type implies. Skipped when `references` is present, because schema generation resolves that column from the referenced primary key.
26
21
  - Bare relation decorators: inserts `entity: () => X`, unwrapping arrays and the old `Relation<T>` alias.
27
- - `Relation<T>` becomes `T`, and its import goes with the last usage - `uql-orm` no longer exports it.
28
- A usage somewhere the codemod does not reach, such as a type alias, keeps the import and is reported.
29
- - `@Transactional()` methods: drops the `@InjectQuerier() querier?: Querier` parameter and rewrites the
30
- body to `currentQuerier()`.
22
+ - `Relation<T>` becomes `T`, and its import goes with the last usage - `uql-orm` no longer exports it. A usage somewhere the codemod does not reach, such as a type alias, keeps the import and is reported.
23
+ - `@Transactional()` methods: drops the `@InjectQuerier() querier?: Querier` parameter and rewrites the body to `currentQuerier()`.
31
24
  - `import 'reflect-metadata'` goes. Removing the package from your `package.json` is left to you.
32
- - `tsconfig.json`: removes `experimentalDecorators` and `emitDecoratorMetadata`, keeping the rest of the
33
- file - comments and formatting included - exactly as written.
25
+ - `tsconfig.json`: removes `experimentalDecorators` and `emitDecoratorMetadata`, keeping the rest of the file - comments and formatting included - exactly as written.
34
26
 
35
27
  ## What it refuses to do
36
28
 
37
29
  It reports rather than guesses, and exits non-zero when anything is left for you:
38
30
 
39
- - **`target: esnext`** is reported, not changed. Removing the line falls back to the compiler default
40
- (`es5` for `tsc`), and choosing a replacement means guessing which era the project targets. Any dated
41
- target works; `esnext` is the one where TypeScript emits decorator syntax untransformed.
31
+ - **`target: esnext`** is reported, not changed. Removing the line falls back to the compiler default (`es5` for `tsc`), and choosing a replacement means guessing which era the project targets. Any dated target works; `esnext` is the one where TypeScript emits decorator syntax untransformed.
42
32
  - **A value inherited through `extends`** cannot be edited here, so the base config is reported instead.
43
- - **`@Log()` and `@Serialized()`** are reported and left in place. They no longer exist, and what to do
44
- instead is a judgement call.
45
- - **Options it cannot read** (`@Field(sharedOptions)`, a spread, or a `@Field` never called at all) are
46
- left exactly as written. Replacing an argument it cannot parse would silently drop the options.
47
- - **A property whose type it cannot map to a column** (a `Json<T>`, a vector, a union that disagrees with
48
- itself) is reported as `needs a decision`. Those always had to declare `type` by hand anyway, because
49
- `design:type` reported the useless `Object`/`Array` for them.
50
- - **A branded string id**, e.g. `type UUID = \`${string}-${string}\``, gets `type: String` plus a
51
- `worth a look` note. That is a real fork: `String` generates a text column, `'uuid'` generates a native
52
- one, and only you know which the database has.
33
+ - **`@Log()` and `@Serialized()`** are reported and left in place. They no longer exist, and what to do instead is a judgement call.
34
+ - **Options it cannot read** (`@Field(sharedOptions)`, a spread, or a `@Field` never called at all) are left exactly as written. Replacing an argument it cannot parse would silently drop the options.
35
+ - **A property whose type it cannot map to a column** (a `Json<T>`, a vector, a union that disagrees with itself) is reported as `needs a decision`. Those always had to declare `type` by hand anyway, because `design:type` reported the useless `Object`/`Array` for them.
36
+ - **A branded string id**, e.g. `type UUID = \`${string}-${string}\``, gets `type: String` plus a `worth a look` note. That is a real fork: `String` generates a text column, `'uuid'` generates a native one, and only you know which the database has.
53
37
 
54
38
  ## After it runs
55
39
 
56
- `tsc` is the rest of the migration, and that is the point: the annotations the codemod inserts are now
57
- *checked* against the properties they describe, so anything it got wrong is a compile error rather than a
58
- silently wrong column. See the [upgrade guide](https://uql-orm.dev/upgrade-guide).
40
+ `tsc` is the rest of the migration, and that is the point: the annotations the codemod inserts are now *checked* against the properties they describe, so anything it got wrong is a compile error rather than a silently wrong column. See the [upgrade guide](https://uql-orm.dev/upgrade-guide).
41
+
42
+ ## Why TypeScript 6
43
+
44
+ TypeScript is a real dependency here, not a dev one: reading the types `design:type` used to report needs a checker, and that means shipping a compiler. Version 6 is pinned deliberately.
45
+
46
+ TypeScript 7 is not a version bump away. Its `typescript` entry point exports only the version number, and the compiler API moved to `typescript/unstable/*` in a different shape. The gap that matters is the parser: 7 has no standalone one, and `ts.parseJsonText` is what lets the `tsconfig.json` rewrite keep your comments and formatting instead of reserialising the file.
47
+
48
+ Staying on 6 costs nothing. This is a one-shot tool for a spec `uql-orm` no longer supports, so it never needs a new language feature, and 7 reads `experimentalDecorators` projects perfectly well when the time comes. Worth revisiting once that API drops the `unstable/` prefix and regains a parser.
59
49
 
60
50
  ## License
61
51
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "uql-codemod",
3
3
  "description": "Migrates uql-orm entities from legacy decorators to the TC39 standard spec",
4
4
  "license": "MIT",
5
- "version": "0.23.0",
5
+ "version": "0.24.0",
6
6
  "type": "module",
7
7
  "engines": {
8
8
  "node": ">=24"
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "3bfca5950ac564b8503fb2140726501b01825b9d"
45
+ "gitHead": "d9499a4b8c5ee866950b397fb87f55643d86fc39"
46
46
  }