@fairfox/polly 0.11.0 → 0.12.1
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/dist/src/client/index.d.ts +33 -0
- package/dist/src/client/index.js +586 -0
- package/dist/src/client/index.js.map +13 -0
- package/dist/src/client/wrapper.d.ts +54 -0
- package/dist/src/core/clock.d.ts +63 -0
- package/dist/src/elysia/index.d.ts +43 -0
- package/dist/src/elysia/index.js +241 -0
- package/dist/src/elysia/index.js.map +12 -0
- package/dist/src/elysia/plugin.d.ts +85 -0
- package/dist/src/elysia/tla-generator.d.ts +16 -0
- package/dist/src/elysia/types.d.ts +137 -0
- package/dist/src/utils/function-serialization.d.ts +14 -0
- package/dist/tools/analysis/src/extract/adr.d.ts +37 -0
- package/dist/tools/analysis/src/extract/architecture.d.ts +42 -0
- package/dist/tools/analysis/src/extract/contexts.d.ts +74 -0
- package/dist/tools/analysis/src/extract/flows.d.ts +68 -0
- package/dist/tools/analysis/src/extract/handlers.d.ts +330 -0
- package/dist/tools/analysis/src/extract/index.d.ts +9 -0
- package/dist/tools/analysis/src/extract/integrations.d.ts +77 -0
- package/dist/tools/analysis/src/extract/manifest.d.ts +64 -0
- package/dist/tools/analysis/src/extract/project-detector.d.ts +103 -0
- package/dist/tools/analysis/src/extract/relationships.d.ts +119 -0
- package/dist/tools/analysis/src/extract/types.d.ts +139 -0
- package/dist/tools/analysis/src/index.d.ts +2 -0
- package/dist/tools/analysis/src/types/adr.d.ts +39 -0
- package/dist/tools/analysis/src/types/architecture.d.ts +198 -0
- package/dist/tools/analysis/src/types/core.d.ts +178 -0
- package/dist/tools/analysis/src/types/index.d.ts +4 -0
- package/dist/tools/teach/src/cli.js +140 -69
- package/dist/tools/teach/src/cli.js.map +12 -12
- package/dist/tools/teach/src/index.d.ts +28 -0
- package/dist/tools/teach/src/index.js +145 -72
- package/dist/tools/teach/src/index.js.map +13 -13
- package/dist/tools/verify/src/cli.js +33 -11
- package/dist/tools/verify/src/cli.js.map +5 -5
- package/dist/tools/visualize/src/cli.js +125 -66
- package/dist/tools/visualize/src/cli.js.map +11 -11
- package/dist/tools/visualize/src/codegen/structurizr.d.ts +343 -0
- package/dist/tools/visualize/src/types/structurizr.d.ts +235 -0
- package/package.json +10 -5
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ManifestInfo } from "../types/architecture";
|
|
2
|
+
/**
|
|
3
|
+
* Parse manifest.json and extract context information
|
|
4
|
+
*/
|
|
5
|
+
export declare class ManifestParser {
|
|
6
|
+
private manifestPath;
|
|
7
|
+
private manifestData;
|
|
8
|
+
private baseDir;
|
|
9
|
+
constructor(projectRoot: string, optional?: boolean);
|
|
10
|
+
/**
|
|
11
|
+
* Check if manifest.json exists and was loaded
|
|
12
|
+
*/
|
|
13
|
+
hasManifest(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Parse manifest and extract all information
|
|
16
|
+
*/
|
|
17
|
+
parse(): ManifestInfo;
|
|
18
|
+
/**
|
|
19
|
+
* Get context entry points from manifest
|
|
20
|
+
*/
|
|
21
|
+
getContextEntryPoints(): Record<string, string>;
|
|
22
|
+
private addBackgroundEntryPoint;
|
|
23
|
+
private addContentScriptEntryPoint;
|
|
24
|
+
private addPopupEntryPoint;
|
|
25
|
+
private addOptionsEntryPoint;
|
|
26
|
+
private addDevtoolsEntryPoint;
|
|
27
|
+
/**
|
|
28
|
+
* Parse background configuration
|
|
29
|
+
*/
|
|
30
|
+
private parseBackground;
|
|
31
|
+
/**
|
|
32
|
+
* Parse content scripts configuration
|
|
33
|
+
*/
|
|
34
|
+
private parseContentScripts;
|
|
35
|
+
/**
|
|
36
|
+
* Parse popup configuration
|
|
37
|
+
*/
|
|
38
|
+
private parsePopup;
|
|
39
|
+
/**
|
|
40
|
+
* Parse options configuration
|
|
41
|
+
*/
|
|
42
|
+
private parseOptions;
|
|
43
|
+
/**
|
|
44
|
+
* Parse devtools configuration
|
|
45
|
+
*/
|
|
46
|
+
private parseDevtools;
|
|
47
|
+
/**
|
|
48
|
+
* Find source file from manifest reference
|
|
49
|
+
* Tries multiple locations: exact path, src/ directory, .ts extension
|
|
50
|
+
*/
|
|
51
|
+
private findSourceFile;
|
|
52
|
+
/**
|
|
53
|
+
* Find associated JavaScript/TypeScript file for an HTML file
|
|
54
|
+
*/
|
|
55
|
+
private findAssociatedJS;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Parse manifest.json and extract information
|
|
59
|
+
*/
|
|
60
|
+
export declare function parseManifest(projectRoot: string): ManifestInfo;
|
|
61
|
+
/**
|
|
62
|
+
* Get context entry points from manifest.json
|
|
63
|
+
*/
|
|
64
|
+
export declare function getContextEntryPoints(projectRoot: string): Record<string, string>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ProjectConfig } from "../types/architecture";
|
|
2
|
+
/**
|
|
3
|
+
* Detect project type and generate configuration
|
|
4
|
+
* Falls back to tsconfig.json when manifest.json is not available
|
|
5
|
+
*/
|
|
6
|
+
export declare class ProjectDetector {
|
|
7
|
+
private projectRoot;
|
|
8
|
+
constructor(projectRoot: string);
|
|
9
|
+
/**
|
|
10
|
+
* Detect project type and return configuration
|
|
11
|
+
*/
|
|
12
|
+
detect(): ProjectConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Detect Chrome extension from manifest.json
|
|
15
|
+
*/
|
|
16
|
+
private detectChromeExtension;
|
|
17
|
+
/**
|
|
18
|
+
* Detect background script entry point
|
|
19
|
+
*/
|
|
20
|
+
private detectBackgroundEntry;
|
|
21
|
+
/**
|
|
22
|
+
* Detect content script entry point
|
|
23
|
+
*/
|
|
24
|
+
private detectContentScriptEntry;
|
|
25
|
+
/**
|
|
26
|
+
* Detect popup entry point
|
|
27
|
+
*/
|
|
28
|
+
private detectPopupEntry;
|
|
29
|
+
/**
|
|
30
|
+
* Detect options page entry point
|
|
31
|
+
*/
|
|
32
|
+
private detectOptionsEntry;
|
|
33
|
+
/**
|
|
34
|
+
* Detect PWA from manifest.json
|
|
35
|
+
*/
|
|
36
|
+
private detectPWA;
|
|
37
|
+
/**
|
|
38
|
+
* Detect Electron app
|
|
39
|
+
*/
|
|
40
|
+
private detectElectron;
|
|
41
|
+
/**
|
|
42
|
+
* Detect WebSocket/server app with content analysis and confidence scoring
|
|
43
|
+
*/
|
|
44
|
+
private detectWebSocketApp;
|
|
45
|
+
/**
|
|
46
|
+
* Score server candidates based on content analysis
|
|
47
|
+
* Returns sorted array with highest confidence first
|
|
48
|
+
*/
|
|
49
|
+
private scoreServerCandidates;
|
|
50
|
+
/**
|
|
51
|
+
* Analyze server candidate content and return scoring details
|
|
52
|
+
*/
|
|
53
|
+
private analyzeServerCandidate;
|
|
54
|
+
/**
|
|
55
|
+
* Get regex patterns for server framework detection
|
|
56
|
+
*/
|
|
57
|
+
private getServerPatterns;
|
|
58
|
+
/**
|
|
59
|
+
* Detect frameworks in content and calculate score
|
|
60
|
+
*/
|
|
61
|
+
private detectFrameworksInContent;
|
|
62
|
+
/**
|
|
63
|
+
* Score Bun framework patterns
|
|
64
|
+
*/
|
|
65
|
+
private scoreBunFramework;
|
|
66
|
+
/**
|
|
67
|
+
* Score WebSocket library patterns
|
|
68
|
+
*/
|
|
69
|
+
private scoreWebSocketLibraries;
|
|
70
|
+
/**
|
|
71
|
+
* Score HTTP framework patterns
|
|
72
|
+
*/
|
|
73
|
+
private scoreHTTPFrameworks;
|
|
74
|
+
/**
|
|
75
|
+
* Score generic server patterns
|
|
76
|
+
*/
|
|
77
|
+
private scoreGenericPatterns;
|
|
78
|
+
/**
|
|
79
|
+
* Score entry point indicators in content
|
|
80
|
+
*/
|
|
81
|
+
private scoreEntryPointIndicators;
|
|
82
|
+
/**
|
|
83
|
+
* Score based on file name patterns
|
|
84
|
+
*/
|
|
85
|
+
private scoreFileName;
|
|
86
|
+
/**
|
|
87
|
+
* Fallback: Generic TypeScript project
|
|
88
|
+
* Uses tsconfig.json to find entry points
|
|
89
|
+
*/
|
|
90
|
+
private detectGenericProject;
|
|
91
|
+
/**
|
|
92
|
+
* Find source file from manifest reference
|
|
93
|
+
*/
|
|
94
|
+
private findSourceFile;
|
|
95
|
+
/**
|
|
96
|
+
* Find associated JavaScript/TypeScript file for an HTML file
|
|
97
|
+
*/
|
|
98
|
+
private findAssociatedJS;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Detect project configuration from project root
|
|
102
|
+
*/
|
|
103
|
+
export declare function detectProjectConfig(projectRoot: string): ProjectConfig;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Node, type SourceFile } from "ts-morph";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a relationship between components detected from code analysis
|
|
4
|
+
*/
|
|
5
|
+
export interface DetectedRelationship {
|
|
6
|
+
/** Source component (handler, service, etc.) */
|
|
7
|
+
from: string;
|
|
8
|
+
/** Target component being called/used */
|
|
9
|
+
to: string;
|
|
10
|
+
/** Description of the relationship */
|
|
11
|
+
description: string;
|
|
12
|
+
/** Technology/method used (e.g., "Function Call", "Import", "SQL", "HTTP") */
|
|
13
|
+
technology?: string;
|
|
14
|
+
/** Confidence level of this detection */
|
|
15
|
+
confidence: "high" | "medium" | "low";
|
|
16
|
+
/** Evidence supporting this detection */
|
|
17
|
+
evidence: string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Extracts component relationships from handler code
|
|
21
|
+
*/
|
|
22
|
+
export declare class RelationshipExtractor {
|
|
23
|
+
/**
|
|
24
|
+
* Extract relationships from a function/handler body
|
|
25
|
+
*/
|
|
26
|
+
extractFromHandler(handlerNode: Node, sourceFile: SourceFile, handlerName: string): DetectedRelationship[];
|
|
27
|
+
/**
|
|
28
|
+
* Recursively extract relationships from a node and follow function calls
|
|
29
|
+
*/
|
|
30
|
+
private extractFromNode;
|
|
31
|
+
/**
|
|
32
|
+
* Process a single descendant node for relationship extraction
|
|
33
|
+
*/
|
|
34
|
+
private processDescendantNode;
|
|
35
|
+
/**
|
|
36
|
+
* Process a call expression for relationship extraction
|
|
37
|
+
*/
|
|
38
|
+
private processCallExpression;
|
|
39
|
+
/**
|
|
40
|
+
* Process an identifier call (local or imported function)
|
|
41
|
+
*/
|
|
42
|
+
private processIdentifierCall;
|
|
43
|
+
/**
|
|
44
|
+
* Resolve function declaration from name
|
|
45
|
+
*/
|
|
46
|
+
private resolveFunctionDeclaration;
|
|
47
|
+
/**
|
|
48
|
+
* Follow a function call recursively
|
|
49
|
+
*/
|
|
50
|
+
private followFunctionCall;
|
|
51
|
+
/**
|
|
52
|
+
* Try to add a service call relationship based on function name
|
|
53
|
+
*/
|
|
54
|
+
private tryAddServiceCallRelationship;
|
|
55
|
+
/**
|
|
56
|
+
* Extract relationship from a function call
|
|
57
|
+
*/
|
|
58
|
+
private extractFromFunctionCall;
|
|
59
|
+
/**
|
|
60
|
+
* Extract relationship from property access chain
|
|
61
|
+
* Handles both simple (obj.method) and nested (obj.prop.method) patterns
|
|
62
|
+
*/
|
|
63
|
+
private extractFromPropertyAccess;
|
|
64
|
+
/**
|
|
65
|
+
* Extract relationship from database call
|
|
66
|
+
*/
|
|
67
|
+
private extractFromDatabaseCall;
|
|
68
|
+
/**
|
|
69
|
+
* Extract relationship from fetch/HTTP call
|
|
70
|
+
*/
|
|
71
|
+
private extractFromFetchCall;
|
|
72
|
+
/**
|
|
73
|
+
* Infer component name from object.method pattern
|
|
74
|
+
*/
|
|
75
|
+
private inferComponentFromCall;
|
|
76
|
+
/**
|
|
77
|
+
* Infer component name from function name patterns
|
|
78
|
+
* Detects patterns like getDatabase(), createRepositories(), etc.
|
|
79
|
+
*/
|
|
80
|
+
private inferComponentFromFunctionName;
|
|
81
|
+
/**
|
|
82
|
+
* Match component patterns for get/create functions
|
|
83
|
+
*/
|
|
84
|
+
private matchComponentPattern;
|
|
85
|
+
/**
|
|
86
|
+
* Match patterns for init/setup functions
|
|
87
|
+
*/
|
|
88
|
+
private matchInitPattern;
|
|
89
|
+
/**
|
|
90
|
+
* Resolve component from import statement
|
|
91
|
+
*/
|
|
92
|
+
private resolveComponentFromImport;
|
|
93
|
+
/**
|
|
94
|
+
* Infer component from module path
|
|
95
|
+
*/
|
|
96
|
+
private inferComponentFromModulePath;
|
|
97
|
+
/**
|
|
98
|
+
* Resolve imported function to its declaration in another file
|
|
99
|
+
* This enables cross-file relationship detection for architectures where
|
|
100
|
+
* handlers are separated from routing logic
|
|
101
|
+
*/
|
|
102
|
+
private resolveImportedFunction;
|
|
103
|
+
/**
|
|
104
|
+
* Find function declaration or arrow function in a module
|
|
105
|
+
*/
|
|
106
|
+
private findFunctionInModule;
|
|
107
|
+
/**
|
|
108
|
+
* Infer database operation type
|
|
109
|
+
*/
|
|
110
|
+
private inferDatabaseOperation;
|
|
111
|
+
/**
|
|
112
|
+
* Convert name to component ID format
|
|
113
|
+
*/
|
|
114
|
+
private toComponentId;
|
|
115
|
+
/**
|
|
116
|
+
* Remove duplicate relationships
|
|
117
|
+
*/
|
|
118
|
+
private deduplicateRelationships;
|
|
119
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { CodebaseAnalysis } from "../types";
|
|
2
|
+
export declare class TypeExtractor {
|
|
3
|
+
private project;
|
|
4
|
+
constructor(tsConfigPath: string);
|
|
5
|
+
/**
|
|
6
|
+
* Analyze the codebase and extract state types and message types
|
|
7
|
+
*/
|
|
8
|
+
analyzeCodebase(stateFilePath?: string): Promise<CodebaseAnalysis>;
|
|
9
|
+
/**
|
|
10
|
+
* Extract handler analysis from the project
|
|
11
|
+
*/
|
|
12
|
+
private extractHandlerAnalysis;
|
|
13
|
+
/**
|
|
14
|
+
* Filter and log message types, keeping only valid TLA+ identifiers
|
|
15
|
+
*/
|
|
16
|
+
private filterAndLogMessageTypes;
|
|
17
|
+
/**
|
|
18
|
+
* Log warnings about invalid message types
|
|
19
|
+
*/
|
|
20
|
+
private logInvalidMessageTypes;
|
|
21
|
+
/**
|
|
22
|
+
* Filter and log handlers, keeping only those with valid TLA+ identifier message types
|
|
23
|
+
*/
|
|
24
|
+
private filterAndLogHandlers;
|
|
25
|
+
/**
|
|
26
|
+
* Log warnings about filtered handlers
|
|
27
|
+
*/
|
|
28
|
+
private logInvalidHandlers;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a string is a valid TLA+ identifier
|
|
31
|
+
* TLA+ identifiers must:
|
|
32
|
+
* - Start with a letter (a-zA-Z)
|
|
33
|
+
* - Contain only letters, digits, and underscores
|
|
34
|
+
* - Not be empty
|
|
35
|
+
*/
|
|
36
|
+
private isValidTLAIdentifier;
|
|
37
|
+
/**
|
|
38
|
+
* Extract state type from a specific file
|
|
39
|
+
*/
|
|
40
|
+
private extractStateType;
|
|
41
|
+
/**
|
|
42
|
+
* Find state type by searching common patterns
|
|
43
|
+
*/
|
|
44
|
+
private findStateType;
|
|
45
|
+
/**
|
|
46
|
+
* Find message types by searching for type unions
|
|
47
|
+
* Handles:
|
|
48
|
+
* - Simple string literal unions
|
|
49
|
+
* - Discriminated unions ({ type: 'foo' } | { type: 'bar' })
|
|
50
|
+
* - Type aliases across files
|
|
51
|
+
* - Template literal types (with warning)
|
|
52
|
+
* - Conditional types (conservatively)
|
|
53
|
+
* - Mapped types
|
|
54
|
+
*/
|
|
55
|
+
private findMessageTypes;
|
|
56
|
+
/**
|
|
57
|
+
* Extract message types from a TypeScript type
|
|
58
|
+
* Recursively handles unions, discriminated unions, aliases, etc.
|
|
59
|
+
*/
|
|
60
|
+
private extractMessageTypesFromType;
|
|
61
|
+
/**
|
|
62
|
+
* Extract message types from union type
|
|
63
|
+
*/
|
|
64
|
+
private extractFromUnionType;
|
|
65
|
+
/**
|
|
66
|
+
* Extract message types from a single union member
|
|
67
|
+
*/
|
|
68
|
+
private extractFromUnionMember;
|
|
69
|
+
/**
|
|
70
|
+
* Extract message types from discriminated union
|
|
71
|
+
*/
|
|
72
|
+
private extractFromDiscriminatedUnion;
|
|
73
|
+
/**
|
|
74
|
+
* Extract message types from type alias
|
|
75
|
+
*/
|
|
76
|
+
private extractFromTypeAlias;
|
|
77
|
+
/**
|
|
78
|
+
* Extract message types from conditional type
|
|
79
|
+
*/
|
|
80
|
+
private extractFromConditionalType;
|
|
81
|
+
/**
|
|
82
|
+
* Extract string literal from conditional branch
|
|
83
|
+
*/
|
|
84
|
+
private extractStringLiteralFromBranch;
|
|
85
|
+
/**
|
|
86
|
+
* Extract message types from mapped type
|
|
87
|
+
*/
|
|
88
|
+
private extractFromMappedType;
|
|
89
|
+
/**
|
|
90
|
+
* Warn about template literal types
|
|
91
|
+
*/
|
|
92
|
+
private warnTemplateLiteral;
|
|
93
|
+
/**
|
|
94
|
+
* Convert ts-morph Type to our TypeInfo
|
|
95
|
+
*/
|
|
96
|
+
private convertType;
|
|
97
|
+
/**
|
|
98
|
+
* Convert union type to TypeInfo
|
|
99
|
+
*/
|
|
100
|
+
private convertUnionType;
|
|
101
|
+
/**
|
|
102
|
+
* Convert array type to TypeInfo
|
|
103
|
+
*/
|
|
104
|
+
private convertArrayType;
|
|
105
|
+
/**
|
|
106
|
+
* Try to convert Map or Set type to TypeInfo
|
|
107
|
+
*/
|
|
108
|
+
private tryConvertCollectionType;
|
|
109
|
+
/**
|
|
110
|
+
* Convert object type to TypeInfo
|
|
111
|
+
*/
|
|
112
|
+
private convertObjectType;
|
|
113
|
+
/**
|
|
114
|
+
* Analyze fields and determine confidence/bounds
|
|
115
|
+
*/
|
|
116
|
+
private analyzeFields;
|
|
117
|
+
/**
|
|
118
|
+
* Analyze a single field and determine configuration needs
|
|
119
|
+
*/
|
|
120
|
+
private analyzeField;
|
|
121
|
+
private analyzeBooleanField;
|
|
122
|
+
private analyzeEnumField;
|
|
123
|
+
private analyzeArrayField;
|
|
124
|
+
private analyzeNumberField;
|
|
125
|
+
private analyzeStringField;
|
|
126
|
+
private analyzeMapSetField;
|
|
127
|
+
/**
|
|
128
|
+
* Try to find array bounds by searching for length checks
|
|
129
|
+
*/
|
|
130
|
+
private findArrayBound;
|
|
131
|
+
/**
|
|
132
|
+
* Try to find number bounds by searching for comparisons
|
|
133
|
+
*/
|
|
134
|
+
private findNumberBound;
|
|
135
|
+
}
|
|
136
|
+
export declare function analyzeCodebase(options: {
|
|
137
|
+
tsConfigPath: string;
|
|
138
|
+
stateFilePath?: string;
|
|
139
|
+
}): Promise<CodebaseAnalysis>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Architecture Decision Record
|
|
3
|
+
* Based on Michael Nygard's ADR format
|
|
4
|
+
*/
|
|
5
|
+
export type ADR = {
|
|
6
|
+
/** ADR number/ID */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Decision title */
|
|
9
|
+
title: string;
|
|
10
|
+
/** Status: proposed, accepted, deprecated, superseded */
|
|
11
|
+
status: ADRStatus;
|
|
12
|
+
/** Date of decision */
|
|
13
|
+
date: string;
|
|
14
|
+
/** Context - what is the issue motivating this decision */
|
|
15
|
+
context: string;
|
|
16
|
+
/** Decision - what is the change we're proposing */
|
|
17
|
+
decision: string;
|
|
18
|
+
/** Consequences - what becomes easier or more difficult */
|
|
19
|
+
consequences: string;
|
|
20
|
+
/** Optional: Alternatives considered */
|
|
21
|
+
alternatives?: string[];
|
|
22
|
+
/** Optional: Links to superseding/superseded ADRs */
|
|
23
|
+
links?: ADRLink[];
|
|
24
|
+
/** Source file path */
|
|
25
|
+
source: string;
|
|
26
|
+
};
|
|
27
|
+
export type ADRStatus = "proposed" | "accepted" | "deprecated" | "superseded";
|
|
28
|
+
export type ADRLink = {
|
|
29
|
+
type: "supersedes" | "superseded-by" | "related-to";
|
|
30
|
+
adrId: string;
|
|
31
|
+
title?: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Collection of ADRs
|
|
35
|
+
*/
|
|
36
|
+
export type ADRCollection = {
|
|
37
|
+
adrs: ADR[];
|
|
38
|
+
directory: string;
|
|
39
|
+
};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import type { MessageHandler } from "./core";
|
|
2
|
+
/**
|
|
3
|
+
* Information about an execution context (background, content, popup, etc.)
|
|
4
|
+
*/
|
|
5
|
+
export type ContextInfo = {
|
|
6
|
+
/** Type of context */
|
|
7
|
+
type: string;
|
|
8
|
+
/** Entry point file path */
|
|
9
|
+
entryPoint: string;
|
|
10
|
+
/** Message handlers defined in this context */
|
|
11
|
+
handlers: MessageHandler[];
|
|
12
|
+
/** Chrome APIs used in this context */
|
|
13
|
+
chromeAPIs: string[];
|
|
14
|
+
/** External APIs called from this context */
|
|
15
|
+
externalAPIs: ExternalAPICall[];
|
|
16
|
+
/** UI components rendered (for popup/options/devtools) */
|
|
17
|
+
components?: ComponentInfo[];
|
|
18
|
+
/** Dependencies/imports */
|
|
19
|
+
dependencies: string[];
|
|
20
|
+
/** JSDoc description if available */
|
|
21
|
+
description?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Component information (for UI contexts)
|
|
25
|
+
*/
|
|
26
|
+
export type ComponentInfo = {
|
|
27
|
+
name: string;
|
|
28
|
+
type: "function" | "class";
|
|
29
|
+
filePath: string;
|
|
30
|
+
line: number;
|
|
31
|
+
props?: string[];
|
|
32
|
+
description?: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Represents a message flow between contexts
|
|
36
|
+
*/
|
|
37
|
+
export type MessageFlow = {
|
|
38
|
+
/** Message type identifier */
|
|
39
|
+
messageType: string;
|
|
40
|
+
/** Source context */
|
|
41
|
+
from: string;
|
|
42
|
+
/** Destination context(s) */
|
|
43
|
+
to: string[];
|
|
44
|
+
/** What triggers this flow (user action, event, etc.) */
|
|
45
|
+
trigger?: string;
|
|
46
|
+
/** Sequence of steps in this flow */
|
|
47
|
+
sequence: MessageStep[];
|
|
48
|
+
/** Flow name (from @flow annotation or inferred) */
|
|
49
|
+
flowName?: string;
|
|
50
|
+
/** Description (from JSDoc) */
|
|
51
|
+
description?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* A step in a message flow sequence
|
|
55
|
+
*/
|
|
56
|
+
export type MessageStep = {
|
|
57
|
+
/** Step number in sequence */
|
|
58
|
+
step: number;
|
|
59
|
+
/** Action description */
|
|
60
|
+
action: string;
|
|
61
|
+
/** Context where this step occurs */
|
|
62
|
+
context: string;
|
|
63
|
+
/** Source location */
|
|
64
|
+
location?: {
|
|
65
|
+
file: string;
|
|
66
|
+
line: number;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* External system integration
|
|
71
|
+
*/
|
|
72
|
+
export type ExternalIntegration = {
|
|
73
|
+
/** Type of integration */
|
|
74
|
+
type: "api" | "storage" | "browser-api" | "external-script" | "websocket";
|
|
75
|
+
/** Name/identifier */
|
|
76
|
+
name: string;
|
|
77
|
+
/** Technology/protocol */
|
|
78
|
+
technology?: string;
|
|
79
|
+
/** Base URL or endpoint */
|
|
80
|
+
url?: string;
|
|
81
|
+
/** Where it's used (file paths) */
|
|
82
|
+
usedIn: string[];
|
|
83
|
+
/** Description (from JSDoc or inferred) */
|
|
84
|
+
description?: string;
|
|
85
|
+
/** Specific API calls made */
|
|
86
|
+
calls?: ExternalAPICall[];
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* A specific API call
|
|
90
|
+
*/
|
|
91
|
+
export type ExternalAPICall = {
|
|
92
|
+
/** HTTP method or API method name */
|
|
93
|
+
method: string;
|
|
94
|
+
/** Endpoint or resource */
|
|
95
|
+
endpoint: string;
|
|
96
|
+
/** Where this call is made */
|
|
97
|
+
location: {
|
|
98
|
+
file: string;
|
|
99
|
+
line: number;
|
|
100
|
+
};
|
|
101
|
+
/** Description */
|
|
102
|
+
description?: string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Parsed manifest.json information
|
|
106
|
+
*/
|
|
107
|
+
export type ManifestInfo = {
|
|
108
|
+
/** Extension name */
|
|
109
|
+
name: string;
|
|
110
|
+
/** Version */
|
|
111
|
+
version: string;
|
|
112
|
+
/** Description */
|
|
113
|
+
description?: string;
|
|
114
|
+
/** Manifest version (2 or 3) */
|
|
115
|
+
manifestVersion: number;
|
|
116
|
+
/** Background script/service worker */
|
|
117
|
+
background?: {
|
|
118
|
+
type: "script" | "service_worker";
|
|
119
|
+
files: string[];
|
|
120
|
+
};
|
|
121
|
+
/** Content scripts */
|
|
122
|
+
contentScripts?: Array<{
|
|
123
|
+
matches: string[];
|
|
124
|
+
js: string[];
|
|
125
|
+
css?: string[];
|
|
126
|
+
}>;
|
|
127
|
+
/** Popup */
|
|
128
|
+
popup?: {
|
|
129
|
+
html: string;
|
|
130
|
+
default?: boolean;
|
|
131
|
+
};
|
|
132
|
+
/** Options page */
|
|
133
|
+
options?: {
|
|
134
|
+
page: string;
|
|
135
|
+
openInTab?: boolean;
|
|
136
|
+
};
|
|
137
|
+
/** DevTools page */
|
|
138
|
+
devtools?: {
|
|
139
|
+
page: string;
|
|
140
|
+
};
|
|
141
|
+
/** Permissions */
|
|
142
|
+
permissions?: string[];
|
|
143
|
+
/** Host permissions */
|
|
144
|
+
hostPermissions?: string[];
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Project type identifier
|
|
148
|
+
*/
|
|
149
|
+
export type ProjectType = "chrome-extension" | "pwa" | "websocket-app" | "electron" | "generic";
|
|
150
|
+
/**
|
|
151
|
+
* Project configuration with context mappings
|
|
152
|
+
* Allows visualization to work with any project type
|
|
153
|
+
*/
|
|
154
|
+
export type ProjectConfig = {
|
|
155
|
+
/** Type of project */
|
|
156
|
+
type: ProjectType;
|
|
157
|
+
/** Entry points for each context */
|
|
158
|
+
entryPoints: Record<string, string>;
|
|
159
|
+
/** Context type mapping (e.g., background → server, content → client) */
|
|
160
|
+
contextMapping?: Record<string, string>;
|
|
161
|
+
/** Project metadata */
|
|
162
|
+
metadata?: {
|
|
163
|
+
name?: string;
|
|
164
|
+
version?: string;
|
|
165
|
+
description?: string;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Complete architecture analysis result
|
|
170
|
+
*/
|
|
171
|
+
export type ArchitectureAnalysis = {
|
|
172
|
+
/** Project root directory (for relative paths) */
|
|
173
|
+
projectRoot: string;
|
|
174
|
+
/** Basic system information */
|
|
175
|
+
system: {
|
|
176
|
+
name: string;
|
|
177
|
+
version: string;
|
|
178
|
+
description?: string;
|
|
179
|
+
};
|
|
180
|
+
/** Project configuration (for non-extension projects) */
|
|
181
|
+
projectConfig?: ProjectConfig;
|
|
182
|
+
/** Manifest information (for Chrome extensions) */
|
|
183
|
+
manifest?: ManifestInfo;
|
|
184
|
+
/** All contexts found in the system */
|
|
185
|
+
contexts: Record<string, ContextInfo>;
|
|
186
|
+
/** Message flows between contexts */
|
|
187
|
+
messageFlows: MessageFlow[];
|
|
188
|
+
/** External integrations */
|
|
189
|
+
integrations: ExternalIntegration[];
|
|
190
|
+
/** Architecture Decision Records */
|
|
191
|
+
adrs?: ADRCollection;
|
|
192
|
+
/** Repository information */
|
|
193
|
+
repository?: {
|
|
194
|
+
url: string;
|
|
195
|
+
type: string;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
import type { ADRCollection } from "./adr";
|