@anarchitects/governance-adapter-typescript 0.0.2 → 0.0.3

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
@@ -51,8 +51,12 @@ import {
51
51
  discoverTypeScriptProjects,
52
52
  deriveProjectTags,
53
53
  mapTypeScriptImportsToGovernanceDependencies,
54
+ normalizeTypeScriptPathAliases,
54
55
  parsePackageManagerWorkspace,
56
+ parseTsconfig,
55
57
  parseTsConfigResolution,
58
+ resolveTsconfigExtends,
59
+ resolveWorkspacePackages,
56
60
  type TsConfigResolutionModel,
57
61
  type TypeScriptImportGraph,
58
62
  type TypeScriptProjectDiscoveryResult,
@@ -67,7 +71,13 @@ The root export currently includes:
67
71
  - `createGovernanceWorkspaceAdapter(...)`
68
72
  - `detectTypeScriptWorkspace(...)`
69
73
  - `parsePackageManagerWorkspace(...)`
74
+ - `resolveWorkspacePackages(...)`
70
75
  - `parseTsConfigResolution(...)`
76
+ - `parseTsconfig(...)`
77
+ - `resolveTsConfigExtendsChain(...)`
78
+ - `resolveTsconfigExtends(...)`
79
+ - `normalizePathAliasesFromConfigs(...)`
80
+ - `normalizeTypeScriptPathAliases(...)`
71
81
  - `discoverTypeScriptProjects(...)`
72
82
  - `buildTypeScriptImportGraph(...)`
73
83
  - `mapTypeScriptImportsToGovernanceDependencies(...)`
@@ -85,6 +95,19 @@ Parity already covered inside this package includes:
85
95
  - static import graph extraction
86
96
  - normalization into Governance Core adapter result inputs
87
97
 
98
+ The package-root API now exposes the exact reusable parity helpers that host
99
+ packages can consume directly:
100
+
101
+ - `detectTypeScriptWorkspace(...)`
102
+ - `parseTsconfig(...)`
103
+ - `resolveTsconfigExtends(...)`
104
+ - `normalizeTypeScriptPathAliases(...)`
105
+ - `parsePackageManagerWorkspace(...)`
106
+ - `resolveWorkspacePackages(...)`
107
+ - `discoverTypeScriptProjects(...)`
108
+ - `buildTypeScriptImportGraph(...)`
109
+ - `mapTypeScriptImportsToGovernanceDependencies(...)`
110
+
88
111
  ## Usage
89
112
 
90
113
  The typical workflow is:
@@ -103,7 +126,7 @@ import {
103
126
  discoverTypeScriptProjects,
104
127
  mapTypeScriptImportsToGovernanceDependencies,
105
128
  parsePackageManagerWorkspace,
106
- parseTsConfigResolution,
129
+ parseTsconfig,
107
130
  } from '@anarchitects/governance-adapter-typescript';
108
131
 
109
132
  const detection = detectTypeScriptWorkspace(process.cwd());
@@ -117,7 +140,7 @@ const projectDiscovery = discoverTypeScriptProjects({
117
140
  workspaceRoot: workspacePackages.workspaceRoot,
118
141
  packageRoots: workspacePackages.packageRoots,
119
142
  });
120
- const tsconfig = parseTsConfigResolution(detection.workspaceRoot);
143
+ const tsconfig = parseTsconfig(detection.workspaceRoot);
121
144
  const importGraph = buildTypeScriptImportGraph({
122
145
  workspaceRoot: detection.workspaceRoot,
123
146
  projects: projectDiscovery.projects,
@@ -1,3 +1,3 @@
1
- import { TypeScriptWorkspaceDetectionResult } from './types.js';
1
+ import type { TypeScriptWorkspaceDetectionResult } from './types.js';
2
2
  export declare function detectTypeScriptWorkspace(workspacePath: string): TypeScriptWorkspaceDetectionResult;
3
3
  //# sourceMappingURL=detect-typescript-workspace.d.ts.map
@@ -1,4 +1,4 @@
1
- import { TypeScriptWorkspaceDetectionDiagnostic, TypeScriptWorkspaceIndicators } from './types.js';
1
+ import type { TypeScriptWorkspaceDetectionDiagnostic, TypeScriptWorkspaceIndicators } from './types.js';
2
2
  export declare function invalidPackageJsonDiagnostic(filePath: string): TypeScriptWorkspaceDetectionDiagnostic;
3
3
  export declare function partialWorkspaceDetectionDiagnostic(indicators: TypeScriptWorkspaceIndicators): TypeScriptWorkspaceDetectionDiagnostic;
4
4
  export declare function noWorkspaceIndicatorsDiagnostic(): TypeScriptWorkspaceDetectionDiagnostic;
@@ -1,5 +1,5 @@
1
- import { GovernanceProjectInput } from '@anarchitects/governance-core';
2
- import { TsConfigResolutionModel, TypeScriptImportGraph } from './types.js';
1
+ import type { GovernanceProjectInput } from '@anarchitects/governance-core';
2
+ import type { TsConfigResolutionModel, TypeScriptImportGraph } from './types.js';
3
3
  export declare function buildTypeScriptImportGraph(options: {
4
4
  workspaceRoot: string;
5
5
  projects: readonly GovernanceProjectInput[];
package/dist/index.d.ts CHANGED
@@ -2,9 +2,12 @@ export { detectTypeScriptWorkspace } from './detect-typescript-workspace.js';
2
2
  export { buildTypeScriptImportGraph } from './import-graph.js';
3
3
  export { DEFAULT_TYPESCRIPT_PROJECT_DISCOVERY_CONFIG, createGovernanceWorkspaceAdapter, createTypeScriptWorkspaceAdapter, governanceWorkspaceAdapter, type CreateGovernanceWorkspaceAdapterOptions, type CreateTypeScriptWorkspaceAdapterOptions, } from './workspace-adapter.js';
4
4
  export { mapTypeScriptImportsToGovernanceDependencies } from './map-imports-to-projects.js';
5
+ export { normalizePathAliasesFromConfigs, normalizePathAliasesFromConfigs as normalizeTypeScriptPathAliases, } from './normalize-path-aliases.js';
5
6
  export { parsePackageManagerWorkspace } from './parse-package-manager-workspace.js';
6
- export { parseTsConfigResolution } from './parse-tsconfig.js';
7
+ export { parseTsConfigResolution, parseTsConfigResolution as parseTsconfig, } from './parse-tsconfig.js';
7
8
  export { discoverTypeScriptProjects } from './project-discovery.js';
9
+ export { resolveTsConfigExtendsChain, resolveTsConfigExtendsChain as resolveTsconfigExtends, } from './resolve-tsconfig-extends.js';
10
+ export { resolveWorkspacePackages } from './resolve-workspace-packages.js';
8
11
  export { deriveProjectTags, type DerivedProjectTags } from './tag-mapping.js';
9
12
  export type { TsConfigResolutionModel, TypeScriptImportEdge, TypeScriptImportGraph, TypeScriptImportKind, TypeScriptProjectDependencyMappingResult, TypeScriptProjectDiscoveryConfig, TypeScriptProjectDiscoveryResult, TypeScriptProjectDiscoveryRule, TypeScriptSourceFileNode, TypeScriptWorkspaceDetectionDiagnostic, TypeScriptWorkspaceDetectionResult, TypeScriptWorkspaceDetectionStatus, TypeScriptWorkspaceIndicators, TypeScriptWorkspacePackageManager, WorkspacePackageResolution, } from './types.js';
10
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,2CAA2C,EAC3C,gCAAgC,EAChC,gCAAgC,EAChC,0BAA0B,EAC1B,KAAK,uCAAuC,EAC5C,KAAK,uCAAuC,GAC7C,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4CAA4C,EAAE,MAAM,8BAA8B,CAAC;AAC5F,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,YAAY,EACV,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,wCAAwC,EACxC,gCAAgC,EAChC,gCAAgC,EAChC,8BAA8B,EAC9B,wBAAwB,EACxB,sCAAsC,EACtC,kCAAkC,EAClC,kCAAkC,EAClC,6BAA6B,EAC7B,iCAAiC,EACjC,0BAA0B,GAC3B,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,2CAA2C,EAC3C,gCAAgC,EAChC,gCAAgC,EAChC,0BAA0B,EAC1B,KAAK,uCAAuC,EAC5C,KAAK,uCAAuC,GAC7C,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4CAA4C,EAAE,MAAM,8BAA8B,CAAC;AAC5F,OAAO,EACL,+BAA+B,EAC/B,+BAA+B,IAAI,8BAA8B,GAClE,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EACL,uBAAuB,EACvB,uBAAuB,IAAI,aAAa,GACzC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,IAAI,sBAAsB,GACtD,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,YAAY,EACV,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,wCAAwC,EACxC,gCAAgC,EAChC,gCAAgC,EAChC,8BAA8B,EAC9B,wBAAwB,EACxB,sCAAsC,EACtC,kCAAkC,EAClC,kCAAkC,EAClC,6BAA6B,EAC7B,iCAAiC,EACjC,0BAA0B,GAC3B,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -194,7 +194,7 @@ function je(t, e, r) {
194
194
  path: t
195
195
  };
196
196
  }
197
- function w(t, e, r) {
197
+ function T(t, e, r) {
198
198
  return {
199
199
  code: "governance.typescript_adapter.ambiguous_project_match",
200
200
  message: `File "${e}" matched multiple discovered projects.`,
@@ -273,7 +273,7 @@ function We(t, e) {
273
273
  return o.push(
274
274
  ...i.map(
275
275
  (a) => he(
276
- T(e),
276
+ w(e),
277
277
  `Failed to parse source file "${e}": ${g.flattenDiagnosticMessageText(
278
278
  a.messageText,
279
279
  `
@@ -303,7 +303,7 @@ function We(t, e) {
303
303
  if (g.isImportEqualsDeclaration(a) && g.isExternalModuleReference(a.moduleReference)) {
304
304
  o.push(
305
305
  ye(
306
- T(e),
306
+ w(e),
307
307
  `Import-equals syntax is not supported for deterministic analysis in "${e}".`
308
308
  )
309
309
  );
@@ -329,13 +329,13 @@ function xe(t, e) {
329
329
  diagnostics: []
330
330
  } : {
331
331
  imports: [],
332
- diagnostics: [ve(T(e))]
332
+ diagnostics: [ve(w(e))]
333
333
  };
334
334
  }
335
335
  function Ae(t) {
336
336
  return t.endsWith(".tsx") ? g.ScriptKind.TSX : t.endsWith(".jsx") ? g.ScriptKind.JSX : t.endsWith(".js") ? g.ScriptKind.JS : g.ScriptKind.TS;
337
337
  }
338
- function T(t) {
338
+ function w(t) {
339
339
  return `/${Ce(t)}`;
340
340
  }
341
341
  function Ce(t) {
@@ -348,7 +348,7 @@ const Fe = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx"]), De = /* @__P
348
348
  "node_modules",
349
349
  "out"
350
350
  ]);
351
- function we(t, e) {
351
+ function Te(t, e) {
352
352
  const r = [], n = /* @__PURE__ */ new Set(), o = [...e].sort(
353
353
  (i, s) => (i.root ?? "").localeCompare(s.root ?? "") || (i.name ?? i.id).localeCompare(s.name ?? s.id)
354
354
  );
@@ -391,7 +391,7 @@ function Z({
391
391
  });
392
392
  continue;
393
393
  }
394
- if (!s.isFile() || !Te(s.name))
394
+ if (!s.isFile() || !we(s.name))
395
395
  continue;
396
396
  const a = p.join(e, s.name), c = Ie(
397
397
  t,
@@ -403,7 +403,7 @@ function Z({
403
403
  }));
404
404
  }
405
405
  }
406
- function Te(t) {
406
+ function we(t) {
407
407
  return t.endsWith(".d.ts") ? !1 : Fe.has(p.extname(t).toLowerCase());
408
408
  }
409
409
  function Ie(t, e) {
@@ -411,7 +411,7 @@ function Ie(t, e) {
411
411
  }
412
412
  const K = [".ts", ".tsx", ".js", ".jsx"];
413
413
  function Re(t) {
414
- const e = p.resolve(t.workspaceRoot), r = we(e, t.projects), n = [], o = [];
414
+ const e = p.resolve(t.workspaceRoot), r = Te(e, t.projects), n = [], o = [];
415
415
  for (const i of r) {
416
416
  const s = p.resolve(e, i.filePath), a = k(s, "utf8"), c = We(a, i.filePath);
417
417
  n.push(...c.diagnostics);
@@ -590,7 +590,7 @@ function Be(t) {
590
590
  a.filePath
591
591
  )
592
592
  ) : c.status === "ambiguous" && r.push(
593
- w(
593
+ T(
594
594
  X(a.filePath),
595
595
  a.filePath,
596
596
  c.projects.map((u) => u.id)
@@ -647,7 +647,7 @@ function Ve({
647
647
  return;
648
648
  }
649
649
  o.push(
650
- w(
650
+ T(
651
651
  _(e.sourceFile, e.specifier),
652
652
  e.resolvedFile,
653
653
  c.projects.map((u) => u.id)
@@ -673,7 +673,7 @@ function Ve({
673
673
  return;
674
674
  if (s.length > 1) {
675
675
  o.push(
676
- w(
676
+ T(
677
677
  _(e.sourceFile, e.specifier),
678
678
  e.specifier,
679
679
  s.map((c) => c.id)
@@ -1578,7 +1578,7 @@ function Ct(t) {
1578
1578
  importGraph: s
1579
1579
  });
1580
1580
  return {
1581
- workspaceId: wt(r),
1581
+ workspaceId: Tt(r),
1582
1582
  workspaceName: ae(r),
1583
1583
  workspaceRoot: ".",
1584
1584
  projects: o.projects,
@@ -1606,7 +1606,7 @@ function Dt(t) {
1606
1606
  const e = [];
1607
1607
  return t.indicators.pnpmWorkspace && e.push("pnpm-workspace.yaml is present"), t.indicators.packageManagerWorkspaces && e.push("package.json declares package-manager workspaces"), t.indicators.tsconfig && e.push("tsconfig.json is present"), t.indicators.tsconfigBase && e.push("tsconfig.base.json is present"), e.length === 0 && e.push("no TypeScript workspace indicators were found"), e;
1608
1608
  }
1609
- function wt(t) {
1609
+ function Tt(t) {
1610
1610
  return ae(t);
1611
1611
  }
1612
1612
  function ae(t) {
@@ -1632,6 +1632,12 @@ export {
1632
1632
  $t as discoverTypeScriptProjects,
1633
1633
  Nt as governanceWorkspaceAdapter,
1634
1634
  Be as mapTypeScriptImportsToGovernanceDependencies,
1635
+ dt as normalizePathAliasesFromConfigs,
1636
+ dt as normalizeTypeScriptPathAliases,
1635
1637
  ot as parsePackageManagerWorkspace,
1636
- yt as parseTsConfigResolution
1638
+ yt as parseTsConfigResolution,
1639
+ yt as parseTsconfig,
1640
+ mt as resolveTsConfigExtendsChain,
1641
+ mt as resolveTsconfigExtends,
1642
+ tt as resolveWorkspacePackages
1637
1643
  };
@@ -1,5 +1,5 @@
1
- import { GovernanceProjectInput } from '@anarchitects/governance-core';
2
- import { TypeScriptImportGraph, TypeScriptProjectDependencyMappingResult } from './types.js';
1
+ import type { GovernanceProjectInput } from '@anarchitects/governance-core';
2
+ import type { TypeScriptImportGraph, TypeScriptProjectDependencyMappingResult } from './types.js';
3
3
  export declare function mapTypeScriptImportsToGovernanceDependencies(options: {
4
4
  workspaceRoot: string;
5
5
  projects: readonly GovernanceProjectInput[];
@@ -1,4 +1,4 @@
1
- import { TsConfigResolutionModel, TypeScriptWorkspaceDetectionDiagnostic } from './types.js';
1
+ import type { TsConfigResolutionModel, TypeScriptWorkspaceDetectionDiagnostic } from './types.js';
2
2
  interface ResolvedTsConfigFile {
3
3
  filePath: string;
4
4
  jsonPath: string;
@@ -1,4 +1,4 @@
1
- import { TypeScriptWorkspaceDetectionDiagnostic } from './types.js';
1
+ import type { TypeScriptWorkspaceDetectionDiagnostic } from './types.js';
2
2
  export interface NormalizedWorkspacePatterns {
3
3
  patterns: string[];
4
4
  diagnostics: TypeScriptWorkspaceDetectionDiagnostic[];
@@ -1,4 +1,4 @@
1
- import { TypeScriptImportKind, TypeScriptWorkspaceDetectionDiagnostic } from './types.js';
1
+ import type { TypeScriptImportKind, TypeScriptWorkspaceDetectionDiagnostic } from './types.js';
2
2
  export interface ParsedImportReference {
3
3
  specifier: string;
4
4
  kind: TypeScriptImportKind;
@@ -1,3 +1,3 @@
1
- import { WorkspacePackageResolution } from './types.js';
1
+ import type { WorkspacePackageResolution } from './types.js';
2
2
  export declare function parsePackageManagerWorkspace(workspacePath: string): WorkspacePackageResolution;
3
3
  //# sourceMappingURL=parse-package-manager-workspace.d.ts.map
@@ -1,3 +1,3 @@
1
- import { TsConfigResolutionModel } from './types.js';
1
+ import type { TsConfigResolutionModel } from './types.js';
2
2
  export declare function parseTsConfigResolution(workspacePath: string, configFilePath?: string): TsConfigResolutionModel;
3
3
  //# sourceMappingURL=parse-tsconfig.d.ts.map
@@ -1,3 +1,3 @@
1
- import { TypeScriptProjectDiscoveryConfig, TypeScriptProjectDiscoveryResult, WorkspacePackageResolution } from './types.js';
1
+ import type { TypeScriptProjectDiscoveryConfig, TypeScriptProjectDiscoveryResult, WorkspacePackageResolution } from './types.js';
2
2
  export declare function discoverTypeScriptProjects(workspace: WorkspacePackageResolution, config: TypeScriptProjectDiscoveryConfig): TypeScriptProjectDiscoveryResult;
3
3
  //# sourceMappingURL=project-discovery.d.ts.map
@@ -1,4 +1,4 @@
1
- import { TypeScriptWorkspaceDetectionDiagnostic } from './types.js';
1
+ import type { TypeScriptWorkspaceDetectionDiagnostic } from './types.js';
2
2
  interface RenderTemplateResult {
3
3
  value?: string;
4
4
  diagnostics: TypeScriptWorkspaceDetectionDiagnostic[];
@@ -1,4 +1,4 @@
1
- import { TypeScriptWorkspaceDetectionDiagnostic } from './types.js';
1
+ import type { TypeScriptWorkspaceDetectionDiagnostic } from './types.js';
2
2
  interface ParsedTsConfig {
3
3
  filePath: string;
4
4
  jsonPath: string;
@@ -1,4 +1,4 @@
1
- import { GovernanceProjectInput } from '@anarchitects/governance-core';
2
- import { TypeScriptSourceFileNode } from './types.js';
1
+ import type { GovernanceProjectInput } from '@anarchitects/governance-core';
2
+ import type { TypeScriptSourceFileNode } from './types.js';
3
3
  export declare function discoverTypeScriptSourceFiles(workspaceRoot: string, projects: readonly GovernanceProjectInput[]): TypeScriptSourceFileNode[];
4
4
  //# sourceMappingURL=source-file-discovery.d.ts.map
@@ -1,4 +1,4 @@
1
- import { TypeScriptWorkspaceDetectionDiagnostic } from './types.js';
1
+ import type { TypeScriptWorkspaceDetectionDiagnostic } from './types.js';
2
2
  export interface DerivedProjectTags {
3
3
  tags: string[];
4
4
  domain?: string;
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { GovernanceDiagnostic, GovernanceDependencyInput, GovernanceProjectInput } from '@anarchitects/governance-core';
1
+ import type { GovernanceDiagnostic, GovernanceDependencyInput, GovernanceProjectInput } from '@anarchitects/governance-core';
2
2
  export type TypeScriptWorkspaceDetectionStatus = 'supported' | 'partial' | 'unsupported';
3
3
  export interface TypeScriptWorkspaceIndicators {
4
4
  packageJson: boolean;
@@ -1,5 +1,5 @@
1
- import { GovernanceWorkspaceAdapter } from '@anarchitects/governance-core';
2
- import { TypeScriptProjectDiscoveryConfig } from './types.js';
1
+ import type { GovernanceWorkspaceAdapter } from '@anarchitects/governance-core';
2
+ import type { TypeScriptProjectDiscoveryConfig } from './types.js';
3
3
  export interface CreateTypeScriptWorkspaceAdapterOptions {
4
4
  discoveryConfig: TypeScriptProjectDiscoveryConfig;
5
5
  tsconfigPath?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anarchitects/governance-adapter-typescript",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Platform-independent Governance TypeScript workspace adapter that normalizes discovery into Governance Core contracts.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -52,7 +52,7 @@
52
52
  }
53
53
  },
54
54
  "dependencies": {
55
- "@anarchitects/governance-core": "^0.0.2",
55
+ "@anarchitects/governance-core": "^0.0.3",
56
56
  "minimatch": "^10.1.1",
57
57
  "typescript": "~5.9.2",
58
58
  "yaml": "^2.8.1"