@mnemonica/tactica 0.3.12 → 0.4.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 +15 -13
- package/lib/analyzer.js +52 -11
- package/lib/cli.js +19 -3
- package/lib/topologica-analyzer.js +4 -6
- package/lib/writer.d.ts +11 -1
- package/lib/writer.js +60 -17
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -41,6 +41,8 @@ npm install --save-dev @mnemonica/tactica
|
|
|
41
41
|
|
|
42
42
|
`mnemonica` is a peer dependency (>= 1.0.1).
|
|
43
43
|
|
|
44
|
+
Tactica bundles its own TypeScript compiler (6.x) as a regular dependency, so it installs and runs regardless of the TypeScript version your project uses — including TypeScript 7, whose npm package no longer exposes the classic compiler API. Your `tsconfig.json` is only ever *parsed* (never emitted), so TS5-era options like `baseUrl` keep working even though TS6 marks them deprecated.
|
|
45
|
+
|
|
44
46
|
## Usage
|
|
45
47
|
|
|
46
48
|
### CLI
|
|
@@ -125,7 +127,7 @@ EDS tracking is **auto-enabled** when `@mnemonica/dive` is present in `package.j
|
|
|
125
127
|
|
|
126
128
|
## Generated Files
|
|
127
129
|
|
|
128
|
-
Tactica writes everything under the `--output` directory (default `.tactica/`)
|
|
130
|
+
Tactica writes everything under the `--output` directory (default `.tactica/`). All file paths inside the JSON files are emitted **project-relative** (anchored at the tsconfig directory) so the output is portable across machines; consumers resolve them against the directory holding `.tactica`. Earlier versions emitted absolute paths, so consumers should accept both.
|
|
129
131
|
|
|
130
132
|
| File | When | Purpose |
|
|
131
133
|
|---|---|---|
|
|
@@ -359,7 +361,7 @@ Tactica then emits:
|
|
|
359
361
|
- Prefixed instance types in `.tactica/types.ts`, e.g. `AppCollectionRegistry_UserType` and `AppCollectionRegistry_UserType_AdminType`.
|
|
360
362
|
- A `declare module '<relative path to this file>'` block in `.tactica/registry.ts` that augments `AppCollectionRegistry` with `'UserType'` and `'UserType.AdminType'` entries.
|
|
361
363
|
|
|
362
|
-
Once `.tactica/registry.ts` is part of your `tsc` compilation, `AppCollection.lookup('UserType')` and `AppCollection.lookup('UserType.AdminType')` are fully typed.
|
|
364
|
+
Once `.tactica/registry.ts` is part of your `tsc` compilation, `AppCollection.lookup('UserType')` and `AppCollection.lookup('UserType.AdminType')` are fully typed. Constructor-relative lookups resolve too: a variable bound to `AppCollection.lookup('UserType')` resolves `.lookup('AdminType')` relative-first (the type's own subtypes, then the collection root) — the same law as for default-collection types.
|
|
363
365
|
|
|
364
366
|
Custom collections also support `decorate()` for root types:
|
|
365
367
|
|
|
@@ -473,7 +475,7 @@ The analyzer infers property types from constructor bodies and class members. Su
|
|
|
473
475
|
| `this.x = []` / `new Array()` | `Array<…>` |
|
|
474
476
|
| `this.x = {}` | `object` |
|
|
475
477
|
| `this.x = new Date()` | `Date` |
|
|
476
|
-
| `this.x = new Map()` / `new Set()` | `Map
|
|
478
|
+
| `this.x = new Map()` / `new Set()` | `Map<unknown, unknown>` / `Set<unknown>` — a bare generic is never emitted (TS2314); explicit arguments survive: `new Map<string, number>()` → `Map<string, number>` |
|
|
477
479
|
| `this.x = Date.now()` | `number` |
|
|
478
480
|
| `this.x = parseInt(…)` / `parseFloat(…)` | `number` |
|
|
479
481
|
| `this.x = String(…)` / `Number(…)` / `Boolean(…)` | `string` / `number` / `boolean` |
|
|
@@ -705,7 +707,7 @@ class ModuleGraphBuilder {
|
|
|
705
707
|
|
|
706
708
|
`ModuleGraph` = `{ modules: Map<absPath, ModuleInfo>, edges: CrossModuleUsage[], cycles: string[][] }`.
|
|
707
709
|
Each `ModuleBinding` carries `{ name, kind: 'function'|'class'|'const'|'type'|'unknown',
|
|
708
|
-
sourceModule (resolved
|
|
710
|
+
sourceModule (resolved project-relative path), importKind?, importAlias?, isReExport, external? }`.
|
|
709
711
|
Node.js builtins (`'path'`, `'node:fs'`, …) are skipped entirely and recorded
|
|
710
712
|
only in the module's `builtinSpecifiers`; bindings resolved into `node_modules`
|
|
711
713
|
carry `external: true` and never enter `dependencies`. Re-export chains
|
|
@@ -789,7 +791,7 @@ When enabled, tactica detects execution-flow patterns alongside type definitions
|
|
|
789
791
|
"eds": {
|
|
790
792
|
"UserEntity": [
|
|
791
793
|
{
|
|
792
|
-
"location": "
|
|
794
|
+
"location": "src/queue.ts:45:12",
|
|
793
795
|
"kind": "wrap",
|
|
794
796
|
"code": "wrap(process)",
|
|
795
797
|
"targetType": "UserEntity"
|
|
@@ -859,7 +861,7 @@ When a referenced class is declared in the analyzed project, the point's `locati
|
|
|
859
861
|
{
|
|
860
862
|
"kind": "pipe",
|
|
861
863
|
"className": "PayloadPipe",
|
|
862
|
-
"location": "
|
|
864
|
+
"location": "src/user.controller.ts:49:2",
|
|
863
865
|
"code": "@RegisterPipe(new PayloadPipe({ transform: true }))",
|
|
864
866
|
"scope": "method:UserController.createUser",
|
|
865
867
|
"targets": ["UserController"]
|
|
@@ -868,21 +870,21 @@ When a referenced class is declared in the analyzed project, the point's `locati
|
|
|
868
870
|
"creationGraph": {
|
|
869
871
|
"nodes": [
|
|
870
872
|
{
|
|
871
|
-
"scopeId": "
|
|
872
|
-
"name": "
|
|
873
|
+
"scopeId": "src/main.ts",
|
|
874
|
+
"name": "src/main.ts",
|
|
873
875
|
"kind": "module",
|
|
874
|
-
"filePath": "
|
|
875
|
-
"location": "
|
|
876
|
+
"filePath": "src/main.ts",
|
|
877
|
+
"location": "src/main.ts:1:1",
|
|
876
878
|
"starter": true
|
|
877
879
|
}
|
|
878
880
|
],
|
|
879
881
|
"edges": [
|
|
880
|
-
{ "caller": "
|
|
882
|
+
{ "caller": "src/main.ts", "callee": "src/user.service.ts:26:2" }
|
|
881
883
|
],
|
|
882
884
|
"anchors": [
|
|
883
885
|
{
|
|
884
|
-
"location": "
|
|
885
|
-
"holderScopeId": "
|
|
886
|
+
"location": "src/user.service.ts:29:24",
|
|
887
|
+
"holderScopeId": "src/user.service.ts:26:2",
|
|
886
888
|
"typePath": "UserEntity.UserResponse",
|
|
887
889
|
"constructorText": "user.UserResponse",
|
|
888
890
|
"variable": "userResponse"
|