@bleedingdev/modern-js-code-tools 3.9.0-ultramodern.23 → 3.9.0-ultramodern.24

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.
@@ -4,9 +4,13 @@ import traverse, { Hub, NodePath } from "@babel/traverse";
4
4
  import * as __rspack_external__babel_types_6e8337dd from "@babel/types";
5
5
  const consumerParserPlugins = (filePath)=>/\.[jt]sx$/u.test(filePath) ? [
6
6
  "typescript",
7
+ 'decorators',
8
+ 'decoratorAutoAccessors',
7
9
  'jsx'
8
10
  ] : [
9
- "typescript"
11
+ "typescript",
12
+ 'decorators',
13
+ 'decoratorAutoAccessors'
10
14
  ];
11
15
  class SourceSyntaxError extends Error {
12
16
  }
@@ -39,7 +43,7 @@ function traverseSource(file, visitor) {
39
43
  traverse(file, visitor, program.scope, void 0, program);
40
44
  }
41
45
  function unwrapExpression(node, includeAssertions = false) {
42
- while(__rspack_external__babel_types_6e8337dd.isTSAsExpression(node) || __rspack_external__babel_types_6e8337dd.isParenthesizedExpression(node) || __rspack_external__babel_types_6e8337dd.isTSSatisfiesExpression(node) || includeAssertions && (__rspack_external__babel_types_6e8337dd.isTSTypeAssertion(node) || __rspack_external__babel_types_6e8337dd.isTSNonNullExpression(node)))node = node.expression;
46
+ while(__rspack_external__babel_types_6e8337dd.isTSAsExpression(node) || __rspack_external__babel_types_6e8337dd.isParenthesizedExpression(node) || __rspack_external__babel_types_6e8337dd.isTSSatisfiesExpression(node) || includeAssertions && (__rspack_external__babel_types_6e8337dd.isTSTypeAssertion(node) || __rspack_external__babel_types_6e8337dd.isTSNonNullExpression(node) || __rspack_external__babel_types_6e8337dd.isTSInstantiationExpression(node)))node = node.expression;
43
47
  return node;
44
48
  }
45
49
  export { SourceSyntaxError, consumerParserPlugins, parseSource, traverseSource, unwrapExpression };
@@ -1,7 +1,7 @@
1
- import { type ModuleGraph } from './module-graph.js';
1
+ import { type ModuleGraph, type SourceModule } from './module-graph.js';
2
2
  export type { MicroVerticalApiBaselineExpectation, MicroVerticalTopologyEntry, } from './microvertical-api-baseline.js';
3
3
  export { configuredMicroVerticalApiStem, microVerticalApiBaselineViolation, } from './microvertical-api-baseline.js';
4
- export type { ModuleGraph, ModuleGraphHop, ResolvedBinding, SourceModule, } from './module-graph.js';
4
+ export type { GraphValue, ModuleGraph, ModuleGraphHop, ResolvedBinding, SourceModule, } from './module-graph.js';
5
5
  export { createModuleGraph } from './module-graph.js';
6
6
  export interface MicroVerticalConfiguredApp {
7
7
  readonly path: string;
@@ -18,22 +18,22 @@ export interface MicroVerticalConfiguredApp {
18
18
  readonly additionalPaths?: Readonly<Record<string, string>>;
19
19
  };
20
20
  }
21
- export interface MicroVerticalApiContractRuleContext {
22
- /** Workspace-relative app directory. */
23
- readonly appPath: string;
24
- readonly protocol: 'rest' | 'rpc';
25
- /** Graph rooted at the app's shared contract (`graph.root`). */
21
+ export interface MicroVerticalApiSourceRuleContext {
22
+ /** Workspace-relative path of `module`. */
23
+ readonly file: string;
24
+ readonly module: SourceModule;
25
+ /** One graph per check, shared by every rule and source file. */
26
26
  readonly graph: ModuleGraph;
27
27
  }
28
- /** A consumer-owned contract rule; each returned message is a violation. */
29
- export type MicroVerticalApiContractRule = (context: MicroVerticalApiContractRuleContext) => readonly string[];
28
+ /** A consumer-owned source rule; each returned message is a violation. */
29
+ export type MicroVerticalApiSourceRule = (context: MicroVerticalApiSourceRuleContext) => readonly string[];
30
30
  export interface MicroVerticalApiCheckOptions {
31
31
  readonly workspaceRoot: string;
32
32
  readonly configuredApps?: readonly MicroVerticalConfiguredApp[];
33
33
  /** Explicit expected installed owner, useful for isolated/non-hoisted installations. */
34
34
  readonly baselinePackageDirectory?: string;
35
- /** Rules run once per API app against its shared contract's module graph. */
36
- readonly contractRules?: readonly MicroVerticalApiContractRule[];
35
+ /** Rules run once per workspace TypeScript/JavaScript source file. */
36
+ readonly sourceRules?: readonly MicroVerticalApiSourceRule[];
37
37
  }
38
38
  export interface MicroVerticalApiCheckResult {
39
39
  readonly diagnostics: readonly string[];
@@ -1,11 +1,16 @@
1
1
  import * as t from '@babel/types';
2
- /** A parsed consumer module and the package directory it may traverse privately. */
2
+ /** A parsed workspace module and the package directory it may traverse privately. */
3
3
  export interface SourceModule {
4
4
  readonly file: t.File;
5
5
  /** Real absolute path. */
6
6
  readonly path: string;
7
7
  /** Real package directory; relative imports may not leave it. */
8
8
  readonly boundary: string;
9
+ /**
10
+ * Every assignment, update and namespace merge in the module. Validation
11
+ * that reads initializers directly must reject a module that has any.
12
+ */
13
+ readonly mutations: readonly t.Node[];
9
14
  }
10
15
  /** One `name` looked up in the module at `path`, in traversal order. */
11
16
  export interface ModuleGraphHop {
@@ -29,24 +34,59 @@ export type ResolvedBinding = {
29
34
  readonly name: string;
30
35
  readonly chain: readonly ModuleGraphHop[];
31
36
  };
37
+ /**
38
+ * One value an expression can evaluate to.
39
+ * - `external`: `name` imported from package `specifier`, then `members`
40
+ * accessed on it (`Schema.Unknown` is `effect` / `Schema` / `['Unknown']`;
41
+ * a namespace import of the package itself is `name: '*'`).
42
+ * - `node`: a workspace expression, function or class the source spells out
43
+ * (a call to an external factory, a literal, a function).
44
+ * - `unresolved`: a parameter, global, dynamic access or anything beyond the
45
+ * analysis budget. Rules that must be sound treat it as a violation.
46
+ */
47
+ export type GraphValue = {
48
+ readonly kind: 'external';
49
+ readonly specifier: string;
50
+ readonly name: string;
51
+ readonly members: readonly string[];
52
+ } | {
53
+ readonly kind: 'node' | 'unresolved';
54
+ readonly node: t.Node;
55
+ readonly module: SourceModule;
56
+ };
32
57
  export interface ModuleGraph {
33
- readonly root: SourceModule;
58
+ /**
59
+ * The parsed workspace module at `filePath`, parsed once per graph. Throws
60
+ * `SourceSyntaxError` when the file is not readable consumer source.
61
+ */
62
+ module(filePath: string): SourceModule;
34
63
  /**
35
64
  * Follow a local binding (`scope: 'local'`) or an export (`'export'`) of
36
65
  * `module` through relative imports, re-exports and public workspace
37
- * package exports. Unresolvable, cyclic or over-budget bindings return
38
- * undefined so callers fail closed.
66
+ * package exports to an unmutated `const`. Unresolvable, mutated, cyclic or
67
+ * over-budget bindings return undefined so callers fail closed.
39
68
  */
40
69
  resolve(module: SourceModule, name: string, scope: 'export' | 'local'): ResolvedBinding | undefined;
70
+ /**
71
+ * Every value `expression` (a node of `module`) can evaluate to, following
72
+ * any binding kind, destructuring, member access into object literals,
73
+ * member assignments (`obj.key = value`), reassignments, conditional
74
+ * branches, and calls into workspace functions through their returns.
75
+ */
76
+ evaluate(module: SourceModule, expression: t.Node): readonly GraphValue[];
77
+ /**
78
+ * Every `external` and `unresolved` value reachable from `expression`: each
79
+ * reference inside it is evaluated, and every workspace node it evaluates
80
+ * to is walked in turn, across modules. `Schema.Struct({ a: shared })`
81
+ * reaches `Schema.Struct` plus whatever `shared` is built from.
82
+ */
83
+ reachable(module: SourceModule, expression: t.Node): readonly GraphValue[];
41
84
  }
42
- /** Resolution follows `const` bindings, so a module that mutates them is unreadable. */
43
- export declare function parseConsumer(filePath: string): t.File;
44
85
  export declare const propertyName: (node: t.Node | undefined) => string | undefined;
45
86
  export declare const localConst: (sourceFile: t.File, name: string) => t.VariableDeclarator | undefined;
46
87
  export declare const exportedConst: (sourceFile: t.File, name: string) => t.VariableDeclarator | undefined;
47
88
  /**
48
- * The module graph rooted at `filePath`. Each module is parsed once per graph;
49
- * an unreadable module stays unresolved instead of assumed valid. Throws
50
- * `SourceSyntaxError` when the root itself is not a readable consumer module.
89
+ * The workspace module graph. Each module is parsed once per graph; an
90
+ * unreadable module stays unresolved instead of assumed valid.
51
91
  */
52
- export declare function createModuleGraph(filePath: string): ModuleGraph;
92
+ export declare function createModuleGraph(): ModuleGraph;
@@ -1,7 +1,10 @@
1
1
  import { type Visitor } from '@babel/traverse';
2
2
  import * as t from '@babel/types';
3
- /** Only JSX extensions enable JSX: generic arrows in .ts must remain valid. */
4
- export declare const consumerParserPlugins: (filePath: string) => ('typescript' | 'jsx')[];
3
+ /**
4
+ * Only JSX extensions enable JSX: generic arrows in .ts must remain valid.
5
+ * Decorators are standard TypeScript syntax.
6
+ */
7
+ export declare const consumerParserPlugins: (filePath: string) => ('typescript' | 'jsx' | 'decorators' | 'decoratorAutoAccessors')[];
5
8
  /** Only parser/binder diagnostics are policy violations; tool failures escape. */
6
9
  export declare class SourceSyntaxError extends Error {
7
10
  }
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "engines": {
24
24
  "node": ">=20"
25
25
  },
26
- "version": "3.9.0-ultramodern.23",
26
+ "version": "3.9.0-ultramodern.24",
27
27
  "types": "./dist/types/index.d.ts",
28
28
  "main": "./dist/esm-node/index.js",
29
29
  "typesVersions": {