@push.rocks/smartproxy 19.6.1 → 19.6.6

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.delete.md DELETED
@@ -1,187 +0,0 @@
1
- # SmartProxy Code Deletion Plan
2
-
3
- This document tracks all code paths that can be deleted as part of the routing unification effort.
4
-
5
- ## Phase 1: Matching Logic Duplicates (READY TO DELETE)
6
-
7
- ### 1. Inline Matching Functions in RouteManager
8
- **File**: `ts/proxies/smart-proxy/route-manager.ts`
9
- **Lines**: Approximately lines 200-400
10
- **Duplicates**:
11
- - `matchDomain()` method - duplicate of DomainMatcher
12
- - `matchPath()` method - duplicate of PathMatcher
13
- - `matchIpPattern()` method - duplicate of IpMatcher
14
- - `matchHeaders()` method - duplicate of HeaderMatcher
15
- **Action**: Update to use unified matchers from `ts/core/routing/matchers/`
16
-
17
- ### 2. Duplicate Matching in Core route-utils
18
- **File**: `ts/core/utils/route-utils.ts`
19
- **Functions to update**:
20
- - `matchDomain()` → Use DomainMatcher.match()
21
- - `matchPath()` → Use PathMatcher.match()
22
- - `matchIpPattern()` → Use IpMatcher.match()
23
- - `matchHeader()` → Use HeaderMatcher.match()
24
- **Action**: Update to use unified matchers, keep only unique utilities
25
-
26
- ## Phase 2: Route Manager Duplicates (READY AFTER MIGRATION)
27
-
28
- ### 1. SmartProxy RouteManager
29
- **File**: `ts/proxies/smart-proxy/route-manager.ts`
30
- **Entire file**: ~500 lines
31
- **Reason**: 95% duplicate of SharedRouteManager
32
- **Migration Required**:
33
- - Update SmartProxy to use SharedRouteManager
34
- - Update all imports
35
- - Test thoroughly
36
- **Action**: DELETE entire file after migration
37
-
38
- ### 2. Deprecated Methods in SharedRouteManager
39
- **File**: `ts/core/utils/route-manager.ts`
40
- **Methods**:
41
- - Any deprecated security check methods
42
- - Legacy compatibility methods
43
- **Action**: Remove after confirming no usage
44
-
45
- ## Phase 3: Router Consolidation (REQUIRES REFACTORING)
46
-
47
- ### 1. ProxyRouter vs RouteRouter Duplication
48
- **Files**:
49
- - `ts/routing/router/proxy-router.ts` (~250 lines)
50
- - `ts/routing/router/route-router.ts` (~250 lines)
51
- **Reason**: Nearly identical implementations
52
- **Plan**: Merge into single HttpRouter with legacy adapter
53
- **Action**: DELETE one file after consolidation
54
-
55
- ### 2. Inline Route Matching in HttpProxy
56
- **Location**: Various files in `ts/proxies/http-proxy/`
57
- **Pattern**: Direct route matching without using RouteManager
58
- **Action**: Update to use SharedRouteManager
59
-
60
- ## Phase 4: Scattered Utilities (CLEANUP)
61
-
62
- ### 1. Duplicate Route Utilities
63
- **Files with duplicate logic**:
64
- - `ts/proxies/smart-proxy/utils/route-utils.ts` - Keep (different purpose)
65
- - `ts/proxies/smart-proxy/utils/route-validators.ts` - Review for duplicates
66
- - `ts/proxies/smart-proxy/utils/route-patterns.ts` - Review for consolidation
67
-
68
- ### 2. Legacy Type Definitions
69
- **Review for removal**:
70
- - Old route type definitions
71
- - Deprecated configuration interfaces
72
- - Unused type exports
73
-
74
- ## Deletion Progress Tracker
75
-
76
- ### Completed Deletions
77
- - [x] Phase 1: Matching logic consolidation (Partial)
78
- - Updated core/utils/route-utils.ts to use unified matchers
79
- - Removed duplicate matching implementations (~200 lines)
80
- - Marked functions as deprecated with migration path
81
- - [x] Phase 2: RouteManager unification (COMPLETED)
82
- - ✓ Migrated SmartProxy to use SharedRouteManager
83
- - ✓ Updated imports in smart-proxy.ts, route-connection-handler.ts, and index.ts
84
- - ✓ Created logger adapter to match ILogger interface expectations
85
- - ✓ Fixed method calls (getAllRoutes → getRoutes)
86
- - ✓ Fixed type errors in header matcher
87
- - ✓ Removed unused ipToNumber imports and methods
88
- - ✓ DELETED: `/ts/proxies/smart-proxy/route-manager.ts` (553 lines removed)
89
- - [x] Phase 3: Router consolidation (COMPLETED)
90
- - ✓ Created unified HttpRouter with legacy compatibility
91
- - ✓ Migrated ProxyRouter and RouteRouter to use HttpRouter aliases
92
- - ✓ Updated imports in http-proxy.ts, request-handler.ts, websocket-handler.ts
93
- - ✓ Added routeReqLegacy() method for backward compatibility
94
- - ✓ DELETED: `/ts/routing/router/proxy-router.ts` (437 lines)
95
- - ✓ DELETED: `/ts/routing/router/route-router.ts` (482 lines)
96
- - [x] Phase 4: Architecture cleanup (COMPLETED)
97
- - ✓ Updated route-utils.ts to use unified matchers directly
98
- - ✓ Removed deprecated methods from SharedRouteManager
99
- - ✓ Fixed HeaderMatcher.matchMultiple → matchAll method name
100
- - ✓ Fixed findMatchingRoute return type handling (IRouteMatchResult)
101
- - ✓ Fixed header type conversion for RegExp patterns
102
- - ✓ DELETED: Duplicate RouteManager class from http-proxy/models/types.ts (~200 lines)
103
- - ✓ Updated all imports to use SharedRouteManager from core/utils
104
- - ✓ Fixed PathMatcher exact match behavior (added $ anchor for non-wildcard patterns)
105
- - ✓ Updated test expectations to match unified matcher behavior
106
- - ✓ All TypeScript errors resolved and build successful
107
- - [x] Phase 5: Remove all backward compatibility code (COMPLETED)
108
- - ✓ Removed routeReqLegacy() method from HttpRouter
109
- - ✓ Removed all legacy compatibility methods from HttpRouter (~130 lines)
110
- - ✓ Removed LegacyRouterResult interface
111
- - ✓ Removed ProxyRouter and RouteRouter aliases
112
- - ✓ Updated RequestHandler to remove legacyRouter parameter and legacy routing fallback (~80 lines)
113
- - ✓ Updated WebSocketHandler to remove legacyRouter parameter and legacy routing fallback
114
- - ✓ Updated HttpProxy to use only unified HttpRouter
115
- - ✓ Removed IReverseProxyConfig interface (deprecated legacy interface)
116
- - ✓ Removed useExternalPort80Handler deprecated option
117
- - ✓ Removed backward compatibility exports from index.ts
118
- - ✓ Removed all deprecated functions from route-utils.ts (~50 lines)
119
- - ✓ Clean build with no legacy code
120
-
121
- ### Files Updated
122
- 1. `ts/core/utils/route-utils.ts` - Replaced all matching logic with unified matchers
123
- 2. `ts/core/utils/security-utils.ts` - Updated to use IpMatcher directly
124
- 3. `ts/proxies/smart-proxy/smart-proxy.ts` - Using SharedRouteManager with logger adapter
125
- 4. `ts/proxies/smart-proxy/route-connection-handler.ts` - Updated to use SharedRouteManager
126
- 5. `ts/proxies/smart-proxy/index.ts` - Exporting SharedRouteManager as RouteManager
127
- 6. `ts/core/routing/matchers/header.ts` - Fixed type handling for array header values
128
- 7. `ts/core/utils/route-manager.ts` - Removed unused ipToNumber import
129
- 8. `ts/proxies/http-proxy/http-proxy.ts` - Updated imports to use unified router
130
- 9. `ts/proxies/http-proxy/request-handler.ts` - Updated to use routeReqLegacy()
131
- 10. `ts/proxies/http-proxy/websocket-handler.ts` - Updated to use routeReqLegacy()
132
- 11. `ts/routing/router/index.ts` - Export unified HttpRouter with aliases
133
- 12. `ts/proxies/smart-proxy/utils/route-utils.ts` - Updated to use unified matchers directly
134
- 13. `ts/proxies/http-proxy/request-handler.ts` - Fixed findMatchingRoute usage
135
- 14. `ts/proxies/http-proxy/models/types.ts` - Removed duplicate RouteManager class
136
- 15. `ts/index.ts` - Updated exports to use SharedRouteManager aliases
137
- 16. `ts/proxies/index.ts` - Updated exports to use SharedRouteManager aliases
138
- 17. `test/test.acme-route-creation.ts` - Fixed getAllRoutes → getRoutes method call
139
-
140
- ### Files Created
141
- 1. `ts/core/routing/matchers/domain.ts` - Unified domain matcher
142
- 2. `ts/core/routing/matchers/path.ts` - Unified path matcher
143
- 3. `ts/core/routing/matchers/ip.ts` - Unified IP matcher
144
- 4. `ts/core/routing/matchers/header.ts` - Unified header matcher
145
- 5. `ts/core/routing/matchers/index.ts` - Matcher exports
146
- 6. `ts/core/routing/types.ts` - Core routing types
147
- 7. `ts/core/routing/specificity.ts` - Route specificity calculator
148
- 8. `ts/core/routing/index.ts` - Main routing exports
149
- 9. `ts/routing/router/http-router.ts` - Unified HTTP router
150
-
151
- ### Lines of Code Removed
152
- - Target: ~1,500 lines
153
- - Actual: ~2,332 lines (Target exceeded by 55%!)
154
- - Phase 1: ~200 lines (matching logic)
155
- - Phase 2: 553 lines (SmartProxy RouteManager)
156
- - Phase 3: 919 lines (ProxyRouter + RouteRouter)
157
- - Phase 4: ~200 lines (Duplicate RouteManager from http-proxy)
158
- - Phase 5: ~460 lines (Legacy compatibility code)
159
-
160
- ## Unified Routing Architecture Summary
161
-
162
- The routing unification effort has successfully:
163
- 1. **Created unified matchers** - Consistent matching logic across all route types
164
- - DomainMatcher: Wildcard domain matching with specificity calculation
165
- - PathMatcher: Path pattern matching with parameter extraction
166
- - IpMatcher: IP address and CIDR notation matching
167
- - HeaderMatcher: HTTP header matching with regex support
168
- 2. **Consolidated route managers** - Single SharedRouteManager for all proxies
169
- 3. **Unified routers** - Single HttpRouter for all HTTP routing needs
170
- 4. **Removed ~2,332 lines of code** - Exceeded target by 55%
171
- 5. **Clean modern architecture** - No legacy code, no backward compatibility layers
172
-
173
- ## Safety Checklist Before Deletion
174
-
175
- Before deleting any code:
176
- 1. ✓ All tests pass
177
- 2. ✓ No references to deleted code remain
178
- 3. ✓ Migration path tested
179
- 4. ✓ Performance benchmarks show no regression
180
- 5. ✓ Documentation updated
181
-
182
- ## Rollback Plan
183
-
184
- If issues arise after deletion:
185
- 1. Git history preserves all deleted code
186
- 2. Each phase can be reverted independently
187
- 3. Feature flags can disable new code if needed