schemantic 0.3.0 → 0.4.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.
Files changed (124) hide show
  1. package/CHANGELOG.md +204 -174
  2. package/LICENSE +21 -21
  3. package/README.md +88 -830
  4. package/dist/cli/index.d.ts +4 -1
  5. package/dist/cli/index.d.ts.map +1 -1
  6. package/dist/cli/index.js +185 -61
  7. package/dist/cli/index.js.map +1 -1
  8. package/dist/core/configuration.d.ts +6 -0
  9. package/dist/core/configuration.d.ts.map +1 -0
  10. package/dist/core/configuration.js +64 -0
  11. package/dist/core/configuration.js.map +1 -0
  12. package/dist/core/index.d.ts +1 -0
  13. package/dist/core/index.d.ts.map +1 -1
  14. package/dist/core/index.js +1 -0
  15. package/dist/core/index.js.map +1 -1
  16. package/dist/core/output-writer.d.ts +7 -0
  17. package/dist/core/output-writer.d.ts.map +1 -0
  18. package/dist/core/output-writer.js +255 -0
  19. package/dist/core/output-writer.js.map +1 -0
  20. package/dist/core/schemantic.d.ts +8 -2
  21. package/dist/core/schemantic.d.ts.map +1 -1
  22. package/dist/core/schemantic.js +196 -71
  23. package/dist/core/schemantic.js.map +1 -1
  24. package/dist/generators/api-client-generator.d.ts +10 -20
  25. package/dist/generators/api-client-generator.d.ts.map +1 -1
  26. package/dist/generators/api-client-generator.js +374 -424
  27. package/dist/generators/api-client-generator.js.map +1 -1
  28. package/dist/generators/base.d.ts.map +1 -1
  29. package/dist/generators/base.js +7 -25
  30. package/dist/generators/base.js.map +1 -1
  31. package/dist/generators/enum-generator.d.ts.map +1 -1
  32. package/dist/generators/enum-generator.js +30 -3
  33. package/dist/generators/enum-generator.js.map +1 -1
  34. package/dist/generators/hook-generator.d.ts +3 -17
  35. package/dist/generators/hook-generator.d.ts.map +1 -1
  36. package/dist/generators/hook-generator.js +51 -445
  37. package/dist/generators/hook-generator.js.map +1 -1
  38. package/dist/generators/naming.d.ts +10 -0
  39. package/dist/generators/naming.d.ts.map +1 -0
  40. package/dist/generators/naming.js +331 -0
  41. package/dist/generators/naming.js.map +1 -0
  42. package/dist/generators/object-generator.d.ts +0 -4
  43. package/dist/generators/object-generator.d.ts.map +1 -1
  44. package/dist/generators/object-generator.js +13 -101
  45. package/dist/generators/object-generator.js.map +1 -1
  46. package/dist/generators/primitive-generator.d.ts +1 -13
  47. package/dist/generators/primitive-generator.d.ts.map +1 -1
  48. package/dist/generators/primitive-generator.js +11 -76
  49. package/dist/generators/primitive-generator.js.map +1 -1
  50. package/dist/generators/projections.d.ts +10 -0
  51. package/dist/generators/projections.d.ts.map +1 -0
  52. package/dist/generators/projections.js +65 -0
  53. package/dist/generators/projections.js.map +1 -0
  54. package/dist/generators/schema-type.d.ts +23 -0
  55. package/dist/generators/schema-type.d.ts.map +1 -0
  56. package/dist/generators/schema-type.js +233 -0
  57. package/dist/generators/schema-type.js.map +1 -0
  58. package/dist/parsers/base.d.ts +2 -0
  59. package/dist/parsers/base.d.ts.map +1 -1
  60. package/dist/parsers/base.js +12 -2
  61. package/dist/parsers/base.js.map +1 -1
  62. package/dist/parsers/factory.d.ts.map +1 -1
  63. package/dist/parsers/factory.js +2 -1
  64. package/dist/parsers/factory.js.map +1 -1
  65. package/dist/parsers/openapi.d.ts +4 -0
  66. package/dist/parsers/openapi.d.ts.map +1 -1
  67. package/dist/parsers/openapi.js +107 -20
  68. package/dist/parsers/openapi.js.map +1 -1
  69. package/dist/plugins/branded-types.d.ts.map +1 -1
  70. package/dist/plugins/branded-types.js +231 -365
  71. package/dist/plugins/branded-types.js.map +1 -1
  72. package/dist/plugins/builtin.d.ts.map +1 -1
  73. package/dist/plugins/builtin.js +6 -141
  74. package/dist/plugins/builtin.js.map +1 -1
  75. package/dist/plugins/index.d.ts +4 -0
  76. package/dist/plugins/index.d.ts.map +1 -1
  77. package/dist/plugins/index.js +17 -0
  78. package/dist/plugins/index.js.map +1 -1
  79. package/dist/plugins/loader.d.ts +5 -1
  80. package/dist/plugins/loader.d.ts.map +1 -1
  81. package/dist/plugins/loader.js +42 -5
  82. package/dist/plugins/loader.js.map +1 -1
  83. package/dist/plugins/manager.d.ts.map +1 -1
  84. package/dist/plugins/manager.js +7 -7
  85. package/dist/plugins/manager.js.map +1 -1
  86. package/dist/plugins/performance-monitoring.d.ts +31 -1
  87. package/dist/plugins/performance-monitoring.d.ts.map +1 -1
  88. package/dist/plugins/performance-monitoring.js +146 -207
  89. package/dist/plugins/performance-monitoring.js.map +1 -1
  90. package/dist/plugins/request-deduplication.d.ts.map +1 -1
  91. package/dist/plugins/request-deduplication.js +151 -586
  92. package/dist/plugins/request-deduplication.js.map +1 -1
  93. package/dist/plugins/zod-validation.d.ts +23 -15
  94. package/dist/plugins/zod-validation.d.ts.map +1 -1
  95. package/dist/plugins/zod-validation.js +392 -268
  96. package/dist/plugins/zod-validation.js.map +1 -1
  97. package/dist/types/core.d.ts +20 -3
  98. package/dist/types/core.d.ts.map +1 -1
  99. package/dist/types/core.js +2 -0
  100. package/dist/types/core.js.map +1 -1
  101. package/dist/types/openapi.d.ts +14 -1
  102. package/dist/types/openapi.d.ts.map +1 -1
  103. package/docs/ADVANCED_PLUGINS_IMPLEMENTATION.md +24 -355
  104. package/docs/ADVANCED_PLUGIN_DEVELOPMENT.md +33 -309
  105. package/docs/API.md +80 -601
  106. package/docs/AUDIT.md +49 -0
  107. package/docs/CONFIGURATION.md +81 -715
  108. package/docs/FASTAPI_TUTORIAL.md +109 -1497
  109. package/docs/NAMING_MIGRATION.md +59 -0
  110. package/docs/PLUGINS.md +49 -687
  111. package/docs/PLUGIN_DEVELOPMENT.md +53 -720
  112. package/docs/REAUDIT.md +399 -0
  113. package/docs/RELEASING.md +88 -0
  114. package/docs/REMEDIATION.md +58 -0
  115. package/docs/superpowers/plans/2026-10-10-audit-remediation.md +113 -0
  116. package/package.json +114 -95
  117. package/dist/__tests__/setup.d.ts +0 -6
  118. package/dist/__tests__/setup.d.ts.map +0 -1
  119. package/dist/__tests__/setup.js +0 -30
  120. package/dist/__tests__/setup.js.map +0 -1
  121. package/dist/__tests__/test-config.d.ts +0 -36
  122. package/dist/__tests__/test-config.d.ts.map +0 -1
  123. package/dist/__tests__/test-config.js +0 -562
  124. package/dist/__tests__/test-config.js.map +0 -1
@@ -1,355 +1,24 @@
1
- # Advanced Plugin Architecture Implementation
2
-
3
- ## Overview
4
-
5
- This document outlines the implementation of sophisticated plugins for Schemantic that address critical production requirements identified through strategic analysis of API code generation challenges. The advanced plugin system implements cutting-edge patterns for performance optimization, type safety, and developer experience enhancement.
6
-
7
- ## Strategic Implementation Summary
8
-
9
- ### 1. ✅ **Schema-Driven Validation Enhancement**
10
-
11
- **Plugin: `zod-validation`**
12
-
13
- Implements comprehensive runtime validation pipeline with sophisticated optimization patterns:
14
-
15
- - **Type-Level Validation Mapping**: Generates Zod schemas from OpenAPI specifications with full type preservation
16
- - **Performance-Optimized Caching**: Memoized schema transformation with LRU eviction and TTL management
17
- - **Branded Type Integration**: Seamless integration with compile-time branded types for dual validation layers
18
- - **Request/Response Pipeline**: Automatic validation middleware with configurable strict/permissive modes
19
-
20
- **Key Innovations:**
21
-
22
- ```typescript
23
- // Generated validation with branded type integration
24
- export const UserSchema = z
25
- .object({
26
- id: z.string().uuid(),
27
- email: z.string().email(),
28
- })
29
- .strict();
30
-
31
- export type BrandedUser = User & { __brand: "UserBrand" };
32
-
33
- // Performance-optimized validation with caching
34
- export const validateUser = memoizedValidation(UserSchema, "user-validation");
35
- ```
36
-
37
- ### 2. ✅ **Performance Monitoring & Optimization**
38
-
39
- **Plugin: `performance-monitoring`**
40
-
41
- Implements enterprise-grade performance instrumentation with statistical analysis:
42
-
43
- - **Request Timing Collection**: Comprehensive timing metrics with percentile calculations (P95, P99)
44
- - **Bundle Size Analysis**: Automated analysis with optimization recommendations
45
- - **Memory Usage Profiling**: Real-time memory tracking with leak detection capabilities
46
- - **Performance Regression Detection**: Automated threshold monitoring with alerting
47
-
48
- **Key Innovations:**
49
-
50
- ```typescript
51
- // Auto-generated performance wrapper
52
- export const performanceMonitored = withDeduplication(apiClient.getUser, {
53
- method: "GET",
54
- urlExtractor: (id) => `/users/${id}`,
55
- enableProfiling: true,
56
- });
57
-
58
- // Statistical analysis with actionable insights
59
- const stats = getPerformanceStats();
60
- // { count: 1000, mean: 125.5ms, p95: 250ms, p99: 500ms }
61
- ```
62
-
63
- ### 3. ✅ **Request Deduplication & Caching**
64
-
65
- **Plugin: `request-deduplication`**
66
-
67
- Implements sophisticated request deduplication with intelligent caching strategies:
68
-
69
- - **Content-Based Fingerprinting**: Advanced request fingerprinting with header normalization
70
- - **LRU Cache with TTL**: Memory-efficient caching with configurable eviction policies
71
- - **Request Coalescing**: Automatic deduplication of identical concurrent requests
72
- - **Stale-While-Revalidate**: Background revalidation for optimal performance/freshness balance
73
-
74
- **Key Innovations:**
75
-
76
- ```typescript
77
- // Intelligent request deduplication
78
- const deduplicatedClient = withDeduplication(apiClient.getUser, {
79
- method: "GET",
80
- urlExtractor: (id) => `/users/${id}`,
81
- cachePolicy: {
82
- ttl: 5 * 60 * 1000, // 5 minutes
83
- staleWhileRevalidate: true,
84
- },
85
- });
86
-
87
- // Automatic request coalescing for identical requests
88
- Promise.all([
89
- deduplicatedClient.getUser(123), // Executes request
90
- deduplicatedClient.getUser(123), // Returns cached promise
91
- deduplicatedClient.getUser(123), // Returns cached promise
92
- ]);
93
- ```
94
-
95
- ### 4. ✅ **Type System Sophistication**
96
-
97
- **Plugin: `branded-types`**
98
-
99
- Implements advanced type system patterns for compile-time safety:
100
-
101
- - **Branded Types**: Compile-time safety guarantees preventing primitive obsession
102
- - **Phantom Type Parameters**: Authentication state management at the type level
103
- - **Discriminated Unions**: Exhaustive pattern matching with compile-time completeness
104
- - **Runtime Type Guards**: Brand-preserving runtime validation
105
-
106
- **Key Innovations:**
107
-
108
- ```typescript
109
- // Branded types for compile-time safety
110
- export type UserId = string & { __brand: "UserIdBrand" };
111
- export type Email = string & { __brand: "EmailBrand" };
112
-
113
- // Phantom types for authentication state
114
- export type UserWithAuth<TAuth extends AuthState = "unauthenticated"> =
115
- BrandedUser & { __auth: TAuth };
116
-
117
- // Discriminated unions with exhaustive matching
118
- export type UserResult =
119
- | { type: "success"; data: BrandedUser }
120
- | { type: "error"; message: string }
121
- | { type: "loading"; progress: number };
122
-
123
- export function handleUser(result: UserResult): string {
124
- return match(result, {
125
- success: (data) => `User: ${data.name}`,
126
- error: (message) => `Error: ${message}`,
127
- loading: (progress) => `Loading: ${progress}%`,
128
- });
129
- }
130
- ```
131
-
132
- ## Architectural Achievements
133
-
134
- ### Performance Architecture
135
-
136
- **Memory Management Excellence:**
137
-
138
- - LRU cache with TTL for optimal memory usage
139
- - WeakMap-based cleanup for automatic garbage collection
140
- - Configurable memory bounds with intelligent eviction
141
- - Zero-memory-leak request deduplication
142
-
143
- **Computational Efficiency:**
144
-
145
- - Memoized schema transformation with content-based keys
146
- - Lazy evaluation patterns for expensive operations
147
- - Statistical analysis with O(1) amortized performance
148
- - Bundle size optimization through tree-shaking support
149
-
150
- ### Type Safety Architecture
151
-
152
- **Compile-Time Guarantees:**
153
-
154
- - Branded types prevent runtime type confusion
155
- - Phantom types enable authentication state tracking
156
- - Discriminated unions with exhaustive checking
157
- - Type-level validation rule composition
158
-
159
- **Runtime Safety Integration:**
160
-
161
- - Seamless integration between compile-time and runtime validation
162
- - Performance-optimized runtime type guards
163
- - Assertion functions with detailed error messages
164
- - Brand preservation through validation pipelines
165
-
166
- ### Developer Experience Architecture
167
-
168
- **Intelligent Code Generation:**
169
-
170
- - Context-aware plugin composition
171
- - Configurable generation policies per endpoint
172
- - Automatic optimization recommendation generation
173
- - Comprehensive error reporting with actionable suggestions
174
-
175
- **Workflow Integration:**
176
-
177
- - Plugin-based architecture enabling ecosystem partnerships
178
- - Configurable plugin activation and composition
179
- - Performance profiling with statistical insights
180
- - Bundle analysis with optimization guidance
181
-
182
- ## Advanced Plugin Composition Patterns
183
-
184
- ### Plugin Pipeline Composition
185
-
186
- ```typescript
187
- // Advanced plugin composition for production environments
188
- const productionPlugins = [
189
- {
190
- name: "zod-validation",
191
- enabled: true,
192
- options: {
193
- strictMode: true,
194
- cacheSchemas: true,
195
- generateBrandedTypes: true,
196
- customErrorMessages: {
197
- "User ID validation": "Invalid user identifier format",
198
- },
199
- },
200
- },
201
- {
202
- name: "performance-monitoring",
203
- enabled: true,
204
- options: {
205
- enableRequestTiming: true,
206
- enableBundleAnalysis: true,
207
- warningThresholds: {
208
- requestTime: 500, // 500ms warning threshold
209
- bundleSize: 50000, // 50KB bundle size warning
210
- },
211
- generateReports: true,
212
- reportFormat: "markdown",
213
- },
214
- },
215
- {
216
- name: "request-deduplication",
217
- enabled: true,
218
- options: {
219
- defaultTTL: 2 * 60 * 1000, // 2 minutes
220
- enableStaleWhileRevalidate: true,
221
- endpointPolicies: {
222
- "/users": { ttl: 5 * 60 * 1000 }, // 5 minute cache for users
223
- "/posts": { ttl: 30 * 1000 }, // 30 second cache for posts
224
- },
225
- },
226
- },
227
- {
228
- name: "branded-types",
229
- enabled: true,
230
- options: {
231
- enablePhantomTypes: true,
232
- enableDiscriminatedUnions: true,
233
- brandNamingConvention: "suffix",
234
- brandIdentifier: "Brand",
235
- },
236
- },
237
- ];
238
- ```
239
-
240
- ### Performance Impact Analysis
241
-
242
- **Before Advanced Plugins:**
243
-
244
- - No request deduplication → redundant network calls
245
- - No runtime validation → runtime type errors
246
- - No performance monitoring → blind performance optimization
247
- - No branded types → primitive obsession and type confusion
248
-
249
- **After Advanced Plugins:**
250
-
251
- - ✅ 60-80% reduction in redundant requests through intelligent deduplication
252
- - ✅ 95% reduction in runtime type errors through validation pipelines
253
- - ✅ Real-time performance insights with P95/P99 tracking
254
- - ✅ Compile-time type safety preventing entire classes of bugs
255
-
256
- ## Production Readiness Assessment
257
-
258
- ### Enterprise Features Implemented
259
-
260
- 1. **Scalability:**
261
-
262
- - Memory-efficient caching with configurable bounds
263
- - Performance profiling with statistical analysis
264
- - Bundle optimization recommendations
265
-
266
- 2. **Reliability:**
267
-
268
- - Comprehensive error handling with graceful degradation
269
- - Request retry logic with exponential backoff
270
- - Type safety guarantees at compile and runtime
271
-
272
- 3. **Observability:**
273
-
274
- - Performance metrics with percentile calculations
275
- - Bundle analysis with optimization recommendations
276
- - Real-time memory usage monitoring
277
-
278
- 4. **Developer Experience:**
279
- - Intelligent code generation with context awareness
280
- - Comprehensive documentation generation
281
- - Plugin composition with conflict detection
282
-
283
- ### Integration Ecosystem Potential
284
-
285
- The advanced plugin architecture enables:
286
-
287
- - **Vite/Webpack Integration**: Bundle analysis and optimization recommendations
288
- - **Next.js/React Integration**: Server-side rendering compatibility with branded types
289
- - **Storybook Integration**: Automatic story generation from OpenAPI schemas
290
- - **Testing Framework Integration**: Type-safe mock generation with branded types
291
- - **CI/CD Pipeline Integration**: Performance regression detection and reporting
292
-
293
- ## Strategic Market Positioning
294
-
295
- ### Competitive Differentiation
296
-
297
- **Technical Sophistication:**
298
-
299
- - Advanced type system patterns not found in competing solutions
300
- - Performance optimization beyond basic code generation
301
- - Enterprise-grade monitoring and analytics capabilities
302
-
303
- **Developer Workflow Integration:**
304
-
305
- - Plugin ecosystem enabling third-party extensions
306
- - Intelligent optimization recommendations
307
- - Real-time performance feedback loops
308
-
309
- **Production-Ready Features:**
310
-
311
- - Memory-efficient request deduplication
312
- - Comprehensive error handling and recovery
313
- - Statistical performance analysis with actionable insights
314
-
315
- ### Network Effects Enablement
316
-
317
- The plugin architecture creates multiple integration opportunities:
318
-
319
- 1. **Tool Ecosystem Partnerships**: Vite, Webpack, Next.js, Storybook
320
- 2. **Framework Integrations**: React Query, SWR, Apollo Client
321
- 3. **Testing Tool Integration**: Jest, Cypress, Playwright
322
- 4. **CI/CD Platform Integration**: GitHub Actions, GitLab CI, Azure DevOps
323
-
324
- ## Future Enhancement Roadmap
325
-
326
- ### Phase 1 Extensions (Q1)
327
-
328
- - **GraphQL Bridge Plugin**: Transform REST endpoints to GraphQL resolvers
329
- - **State Machine Plugin**: Generate XState machines for complex workflows
330
- - **AI Optimization Plugin**: Machine learning-based performance recommendations
331
-
332
- ### Phase 2 Advanced Features (Q2)
333
-
334
- - **Real-time Schema Sync**: WebSocket-based live schema updates
335
- - **Security Scanning Plugin**: Automated security vulnerability detection
336
- - **Cross-Platform Generation**: Additional target language support
337
-
338
- ### Phase 3 Ecosystem Integration (Q3)
339
-
340
- - **IDE Integration Plugin**: Deep VS Code/IntelliJ integration
341
- - **Cloud Platform Plugins**: AWS/Azure/GCP-specific optimizations
342
- - **Enterprise Security Plugin**: SSO, audit logging, compliance features
343
-
344
- ## Conclusion
345
-
346
- The advanced plugin architecture transforms Schemantic from a basic code generator into a comprehensive development environment integration tool. The implementation addresses all strategic recommendations:
347
-
348
- ✅ **Schema-driven validation** with performance optimization
349
- ✅ **Type system sophistication** with branded types and phantom parameters
350
- ✅ **Performance monitoring** with statistical analysis and optimization
351
- ✅ **Developer experience enhancement** through intelligent automation
352
-
353
- This positions Schemantic for ecosystem leadership through technical excellence and developer workflow integration, enabling the network effects necessary for sustained market growth.
354
-
355
- The plugin architecture provides the foundation for partnerships, integrations, and community contributions that extend far beyond basic OpenAPI type generation, establishing Schemantic as an essential tool in the modern development workflow.
1
+ # Advanced plugin capability boundaries
2
+
3
+ This page describes observable interfaces and known limits. Earlier claims of universal production readiness, automatic middleware, and percentage improvements were not supported by package evidence.
4
+
5
+ | Capability | Contract |
6
+ | --- | --- |
7
+ | Zod validation | Generates schema/helper output; install Zod 4 and call helpers explicitly |
8
+ | Branded types | Schema-backed Zod guards/assertions/create helpers and nominal/auth metadata; auth metadata does not authorize server actions |
9
+ | Request deduplication | Manual helper calls, canonical request identity, explicit session scope, custom runtime key callback |
10
+ | Cache expiry/stale policy | Applies to helper calls and endpoint policies; not automatic client middleware |
11
+ | Cache invalidation/statistics | String/regex URL invalidation and measured counters |
12
+ | Performance timing | Optional generated wrappers/helpers; instrument calls explicitly |
13
+ | Performance reports | `generateReports` writes a format-selected performance-report artifact; public report utility also returns a string |
14
+ | Bundle/dependency analysis | Generated-source byte counts and estimates; not a real bundled artifact |
15
+ | Memory observation | Generator-process observation; not continuous client/browser monitoring |
16
+ | Regression thresholds | Current observed durations; no guaranteed historical baseline comparison |
17
+
18
+ The `strict-mode` plugin is retired: active use fails with a diagnostic to use core strict defaults. React hooks are generated by `generateHooks`/`--hooks`. `generateQueries` and a TanStack adapter are unavailable.
19
+
20
+ Some historical plugin options remain experimental or unsupported: `optimizeBundle` does not establish bundle optimization, description metadata does not customize Zod error messages, and enabling monitoring does not instrument every endpoint automatically. Do not claim bounded generation memoization based on a separate runtime cache. Configuration or option combinations that lack an observable supported behavior should produce a diagnostic, or be omitted from application configuration.
21
+
22
+ Supported helper factories and utilities are exported from the package root. Generated runtime classes live in generated output. Use [plugin integration](PLUGINS.md), [development](PLUGIN_DEVELOPMENT.md), and [advanced design contracts](ADVANCED_PLUGIN_DEVELOPMENT.md); do not use undocumented deep imports.
23
+
24
+ Evidence needed for broader claims includes compiled consumer modules, runtime validator inputs, actual request identity/expiry assertions, and measurements of real bundled applications. A generator build, output string check, or unexecuted CI configuration does not establish those claims.