schemantic 0.1.0

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 (131) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/LICENSE +21 -0
  3. package/README.md +827 -0
  4. package/dist/__tests__/setup.d.ts +6 -0
  5. package/dist/__tests__/setup.d.ts.map +1 -0
  6. package/dist/__tests__/setup.js +30 -0
  7. package/dist/__tests__/setup.js.map +1 -0
  8. package/dist/__tests__/test-config.d.ts +36 -0
  9. package/dist/__tests__/test-config.d.ts.map +1 -0
  10. package/dist/__tests__/test-config.js +563 -0
  11. package/dist/__tests__/test-config.js.map +1 -0
  12. package/dist/cli/index.d.ts +118 -0
  13. package/dist/cli/index.d.ts.map +1 -0
  14. package/dist/cli/index.js +657 -0
  15. package/dist/cli/index.js.map +1 -0
  16. package/dist/core/index.d.ts +5 -0
  17. package/dist/core/index.d.ts.map +1 -0
  18. package/dist/core/index.js +21 -0
  19. package/dist/core/index.js.map +1 -0
  20. package/dist/core/schemantic.d.ts +95 -0
  21. package/dist/core/schemantic.d.ts.map +1 -0
  22. package/dist/core/schemantic.js +543 -0
  23. package/dist/core/schemantic.js.map +1 -0
  24. package/dist/generators/api-client-generator.d.ts +145 -0
  25. package/dist/generators/api-client-generator.d.ts.map +1 -0
  26. package/dist/generators/api-client-generator.js +856 -0
  27. package/dist/generators/api-client-generator.js.map +1 -0
  28. package/dist/generators/base.d.ts +117 -0
  29. package/dist/generators/base.d.ts.map +1 -0
  30. package/dist/generators/base.js +232 -0
  31. package/dist/generators/base.js.map +1 -0
  32. package/dist/generators/enum-generator.d.ts +52 -0
  33. package/dist/generators/enum-generator.d.ts.map +1 -0
  34. package/dist/generators/enum-generator.js +178 -0
  35. package/dist/generators/enum-generator.js.map +1 -0
  36. package/dist/generators/factory.d.ts +59 -0
  37. package/dist/generators/factory.d.ts.map +1 -0
  38. package/dist/generators/factory.js +127 -0
  39. package/dist/generators/factory.js.map +1 -0
  40. package/dist/generators/hook-generator.d.ts +36 -0
  41. package/dist/generators/hook-generator.d.ts.map +1 -0
  42. package/dist/generators/hook-generator.js +495 -0
  43. package/dist/generators/hook-generator.js.map +1 -0
  44. package/dist/generators/index.d.ts +10 -0
  45. package/dist/generators/index.d.ts.map +1 -0
  46. package/dist/generators/index.js +26 -0
  47. package/dist/generators/index.js.map +1 -0
  48. package/dist/generators/object-generator.d.ts +48 -0
  49. package/dist/generators/object-generator.d.ts.map +1 -0
  50. package/dist/generators/object-generator.js +280 -0
  51. package/dist/generators/object-generator.js.map +1 -0
  52. package/dist/generators/primitive-generator.d.ts +40 -0
  53. package/dist/generators/primitive-generator.d.ts.map +1 -0
  54. package/dist/generators/primitive-generator.js +150 -0
  55. package/dist/generators/primitive-generator.js.map +1 -0
  56. package/dist/index.d.ts +17 -0
  57. package/dist/index.d.ts.map +1 -0
  58. package/dist/index.js +42 -0
  59. package/dist/index.js.map +1 -0
  60. package/dist/parsers/base.d.ts +101 -0
  61. package/dist/parsers/base.d.ts.map +1 -0
  62. package/dist/parsers/base.js +77 -0
  63. package/dist/parsers/base.js.map +1 -0
  64. package/dist/parsers/factory.d.ts +64 -0
  65. package/dist/parsers/factory.d.ts.map +1 -0
  66. package/dist/parsers/factory.js +116 -0
  67. package/dist/parsers/factory.js.map +1 -0
  68. package/dist/parsers/index.d.ts +7 -0
  69. package/dist/parsers/index.d.ts.map +1 -0
  70. package/dist/parsers/index.js +23 -0
  71. package/dist/parsers/index.js.map +1 -0
  72. package/dist/parsers/openapi.d.ts +52 -0
  73. package/dist/parsers/openapi.d.ts.map +1 -0
  74. package/dist/parsers/openapi.js +396 -0
  75. package/dist/parsers/openapi.js.map +1 -0
  76. package/dist/plugins/branded-types.d.ts +28 -0
  77. package/dist/plugins/branded-types.d.ts.map +1 -0
  78. package/dist/plugins/branded-types.js +568 -0
  79. package/dist/plugins/branded-types.js.map +1 -0
  80. package/dist/plugins/builtin.d.ts +38 -0
  81. package/dist/plugins/builtin.d.ts.map +1 -0
  82. package/dist/plugins/builtin.js +283 -0
  83. package/dist/plugins/builtin.js.map +1 -0
  84. package/dist/plugins/index.d.ts +7 -0
  85. package/dist/plugins/index.d.ts.map +1 -0
  86. package/dist/plugins/index.js +23 -0
  87. package/dist/plugins/index.js.map +1 -0
  88. package/dist/plugins/loader.d.ts +92 -0
  89. package/dist/plugins/loader.d.ts.map +1 -0
  90. package/dist/plugins/loader.js +245 -0
  91. package/dist/plugins/loader.js.map +1 -0
  92. package/dist/plugins/manager.d.ts +99 -0
  93. package/dist/plugins/manager.d.ts.map +1 -0
  94. package/dist/plugins/manager.js +233 -0
  95. package/dist/plugins/manager.js.map +1 -0
  96. package/dist/plugins/performance-monitoring.d.ts +98 -0
  97. package/dist/plugins/performance-monitoring.d.ts.map +1 -0
  98. package/dist/plugins/performance-monitoring.js +596 -0
  99. package/dist/plugins/performance-monitoring.js.map +1 -0
  100. package/dist/plugins/request-deduplication.d.ts +27 -0
  101. package/dist/plugins/request-deduplication.d.ts.map +1 -0
  102. package/dist/plugins/request-deduplication.js +650 -0
  103. package/dist/plugins/request-deduplication.js.map +1 -0
  104. package/dist/plugins/zod-validation.d.ts +63 -0
  105. package/dist/plugins/zod-validation.d.ts.map +1 -0
  106. package/dist/plugins/zod-validation.js +743 -0
  107. package/dist/plugins/zod-validation.js.map +1 -0
  108. package/dist/types/core.d.ts +203 -0
  109. package/dist/types/core.d.ts.map +1 -0
  110. package/dist/types/core.js +24 -0
  111. package/dist/types/core.js.map +1 -0
  112. package/dist/types/index.d.ts +7 -0
  113. package/dist/types/index.d.ts.map +1 -0
  114. package/dist/types/index.js +23 -0
  115. package/dist/types/index.js.map +1 -0
  116. package/dist/types/openapi.d.ts +250 -0
  117. package/dist/types/openapi.d.ts.map +1 -0
  118. package/dist/types/openapi.js +8 -0
  119. package/dist/types/openapi.js.map +1 -0
  120. package/dist/types/schema.d.ts +68 -0
  121. package/dist/types/schema.d.ts.map +1 -0
  122. package/dist/types/schema.js +22 -0
  123. package/dist/types/schema.js.map +1 -0
  124. package/docs/ADVANCED_PLUGINS_IMPLEMENTATION.md +355 -0
  125. package/docs/ADVANCED_PLUGIN_DEVELOPMENT.md +309 -0
  126. package/docs/API.md +600 -0
  127. package/docs/CONFIGURATION.md +722 -0
  128. package/docs/FASTAPI_TUTORIAL.md +1497 -0
  129. package/docs/PLUGINS.md +683 -0
  130. package/docs/PLUGIN_DEVELOPMENT.md +720 -0
  131. package/package.json +90 -0
@@ -0,0 +1,596 @@
1
+ "use strict";
2
+ /**
3
+ * Advanced Performance Monitoring Plugin
4
+ *
5
+ * Implements sophisticated performance tracking, bundle size optimization,
6
+ * and intelligent monitoring for generated API clients and types.
7
+ *
8
+ * Key Features:
9
+ * - Request timing collection with statistical analysis
10
+ * - Bundle size analysis and optimization recommendations
11
+ * - Memory usage profiling and leak detection
12
+ * - Performance regression detection
13
+ * - Automated optimization suggestions
14
+ *
15
+ * Architecture:
16
+ * - Non-intrusive performance instrumentation
17
+ * - Statistical analysis with percentile calculations
18
+ * - Memory-efficient metrics storage with TTL
19
+ * - Configurable monitoring thresholds
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.performanceAnalyzer = exports.performanceMonitoringPlugin = void 0;
23
+ exports.getPerformanceMonitoringStats = getPerformanceMonitoringStats;
24
+ exports.clearPerformanceMonitoringCache = clearPerformanceMonitoringCache;
25
+ exports.generatePerformanceReport = generatePerformanceReport;
26
+ /**
27
+ * Performance monitoring storage
28
+ */
29
+ const performanceMetrics = new Map();
30
+ const bundleAnalysisCache = new Map();
31
+ const memorySnapshots = [];
32
+ /**
33
+ * Performance statistics calculator
34
+ */
35
+ class PerformanceAnalyzer {
36
+ constructor(maxSnapshots = 1000) {
37
+ this.maxSnapshots = maxSnapshots;
38
+ }
39
+ recordMetric(metric) {
40
+ const key = metric.operation;
41
+ if (!performanceMetrics.has(key)) {
42
+ performanceMetrics.set(key, []);
43
+ }
44
+ const metrics = performanceMetrics.get(key);
45
+ metrics.push(metric);
46
+ // Maintain memory bounds
47
+ if (metrics.length > this.maxSnapshots) {
48
+ metrics.splice(0, metrics.length - this.maxSnapshots);
49
+ }
50
+ }
51
+ getStatistics(operation) {
52
+ const metrics = performanceMetrics.get(operation);
53
+ if (!metrics || metrics.length === 0) {
54
+ return null;
55
+ }
56
+ const durations = metrics.map((m) => m.duration).sort((a, b) => a - b);
57
+ const count = durations.length;
58
+ return {
59
+ count,
60
+ min: durations[0],
61
+ max: durations[count - 1],
62
+ mean: durations.reduce((sum, d) => sum + d, 0) / count,
63
+ median: this.getPercentile(durations, 50),
64
+ p95: this.getPercentile(durations, 95),
65
+ p99: this.getPercentile(durations, 99),
66
+ standardDeviation: this.calculateStandardDeviation(durations),
67
+ };
68
+ }
69
+ getPercentile(sortedArray, percentile) {
70
+ const index = (percentile / 100) * (sortedArray.length - 1);
71
+ const lower = Math.floor(index);
72
+ const upper = Math.ceil(index);
73
+ const weight = index % 1;
74
+ return sortedArray[lower] * (1 - weight) + sortedArray[upper] * weight;
75
+ }
76
+ calculateStandardDeviation(values) {
77
+ const mean = values.reduce((sum, val) => sum + val, 0) / values.length;
78
+ const squaredDifferences = values.map((val) => Math.pow(val - mean, 2));
79
+ const variance = squaredDifferences.reduce((sum, val) => sum + val, 0) / values.length;
80
+ return Math.sqrt(variance);
81
+ }
82
+ recordMemorySnapshot() {
83
+ if (typeof process !== "undefined" && process.memoryUsage) {
84
+ const usage = process.memoryUsage();
85
+ memorySnapshots.push({
86
+ heapUsed: usage.heapUsed,
87
+ heapTotal: usage.heapTotal,
88
+ external: usage.external,
89
+ arrayBuffers: usage.arrayBuffers || 0,
90
+ });
91
+ // Maintain memory bounds
92
+ if (memorySnapshots.length > this.maxSnapshots) {
93
+ memorySnapshots.splice(0, memorySnapshots.length - this.maxSnapshots);
94
+ }
95
+ }
96
+ }
97
+ analyzeBundleSize(generatedContent, dependencies) {
98
+ const totalSize = Buffer.byteLength(generatedContent, "utf8");
99
+ const chunks = dependencies.map((dep) => ({
100
+ name: dep,
101
+ size: Math.floor(totalSize * 0.1), // Estimate
102
+ dependencies: [],
103
+ }));
104
+ const recommendations = [];
105
+ if (totalSize > 100000) {
106
+ // 100KB
107
+ recommendations.push("Consider code splitting for large bundles");
108
+ }
109
+ if (dependencies.length > 20) {
110
+ recommendations.push("High dependency count may impact bundle size");
111
+ }
112
+ return {
113
+ totalSize,
114
+ chunks,
115
+ recommendations,
116
+ };
117
+ }
118
+ generateReport(format = "json") {
119
+ const data = {
120
+ timestamp: new Date().toISOString(),
121
+ metrics: this.getAllStatistics(),
122
+ memory: this.getMemoryAnalysis(),
123
+ bundles: Array.from(bundleAnalysisCache.entries()),
124
+ };
125
+ switch (format) {
126
+ case "html":
127
+ return this.generateHTMLReport(data);
128
+ case "markdown":
129
+ return this.generateMarkdownReport(data);
130
+ default:
131
+ return JSON.stringify(data, null, 2);
132
+ }
133
+ }
134
+ getAllStatistics() {
135
+ const stats = {};
136
+ for (const operation of performanceMetrics.keys()) {
137
+ const stat = this.getStatistics(operation);
138
+ if (stat) {
139
+ stats[operation] = stat;
140
+ }
141
+ }
142
+ return stats;
143
+ }
144
+ /**
145
+ * Get all statistics (public method)
146
+ */
147
+ getAllStats() {
148
+ return this.getAllStatistics();
149
+ }
150
+ getMemoryAnalysis() {
151
+ if (memorySnapshots.length === 0) {
152
+ return {
153
+ current: { heapUsed: 0, heapTotal: 0, external: 0, arrayBuffers: 0 },
154
+ peak: { heapUsed: 0, heapTotal: 0, external: 0, arrayBuffers: 0 },
155
+ trend: "stable",
156
+ };
157
+ }
158
+ const current = memorySnapshots[memorySnapshots.length - 1];
159
+ const peak = memorySnapshots.reduce((max, snapshot) => ({
160
+ heapUsed: Math.max(max.heapUsed, snapshot.heapUsed),
161
+ heapTotal: Math.max(max.heapTotal, snapshot.heapTotal),
162
+ external: Math.max(max.external, snapshot.external),
163
+ arrayBuffers: Math.max(max.arrayBuffers, snapshot.arrayBuffers),
164
+ }));
165
+ // Calculate trend (simplified)
166
+ const recent = memorySnapshots.slice(-10);
167
+ const trend = recent.length > 5
168
+ ? recent[recent.length - 1].heapUsed > recent[0].heapUsed
169
+ ? "increasing"
170
+ : "decreasing"
171
+ : "stable";
172
+ return { current, peak, trend };
173
+ }
174
+ generateHTMLReport(data) {
175
+ return `
176
+ <!DOCTYPE html>
177
+ <html>
178
+ <head>
179
+ <title>Schemantic Performance Report</title>
180
+ <style>
181
+ body { font-family: Arial, sans-serif; margin: 20px; }
182
+ .metric { background: #f5f5f5; padding: 10px; margin: 10px 0; border-radius: 5px; }
183
+ .warning { background: #fff3cd; border-left: 4px solid #ffc107; }
184
+ .success { background: #d1edff; border-left: 4px solid #0066cc; }
185
+ </style>
186
+ </head>
187
+ <body>
188
+ <h1>Schemantic Performance Report</h1>
189
+ <p>Generated: ${data.timestamp}</p>
190
+ <pre>${JSON.stringify(data, null, 2)}</pre>
191
+ </body>
192
+ </html>`;
193
+ }
194
+ generateMarkdownReport(data) {
195
+ let markdown = `# Schemantic Performance Report\n\n`;
196
+ markdown += `Generated: ${data.timestamp}\n\n`;
197
+ markdown += `## Performance Metrics\n\n`;
198
+ for (const [operation, stats] of Object.entries(data.metrics)) {
199
+ markdown += `### ${operation}\n`;
200
+ markdown += `- Count: ${stats.count}\n`;
201
+ markdown += `- Mean: ${stats.mean.toFixed(2)}ms\n`;
202
+ markdown += `- P95: ${stats.p95.toFixed(2)}ms\n`;
203
+ markdown += `- P99: ${stats.p99.toFixed(2)}ms\n\n`;
204
+ }
205
+ return markdown;
206
+ }
207
+ clearMetrics() {
208
+ performanceMetrics.clear();
209
+ bundleAnalysisCache.clear();
210
+ memorySnapshots.length = 0;
211
+ }
212
+ }
213
+ /**
214
+ * Global performance analyzer instance
215
+ */
216
+ const performanceAnalyzer = new PerformanceAnalyzer();
217
+ exports.performanceAnalyzer = performanceAnalyzer;
218
+ /**
219
+ * Advanced Performance Monitoring Plugin Implementation
220
+ */
221
+ exports.performanceMonitoringPlugin = {
222
+ name: "performance-monitoring",
223
+ version: "2.0.0",
224
+ description: "Advanced performance monitoring with statistical analysis and optimization recommendations",
225
+ /**
226
+ * Initialize performance monitoring before generation
227
+ */
228
+ beforeGeneration: async (context) => {
229
+ const startTime = performance.now();
230
+ const options = getPluginOptions(context);
231
+ try {
232
+ if (options.enableMemoryProfiling) {
233
+ performanceAnalyzer.recordMemorySnapshot();
234
+ }
235
+ // Initialize monitoring context
236
+ context.generatedTypes.set("__performance_context__", {
237
+ name: "__performance_context__",
238
+ content: "",
239
+ dependencies: [],
240
+ exports: [],
241
+ isInterface: false,
242
+ isEnum: false,
243
+ isUnion: false,
244
+ sourceSchema: {},
245
+ });
246
+ }
247
+ catch (error) {
248
+ console.warn("Performance monitoring plugin beforeGeneration failed:", error);
249
+ }
250
+ finally {
251
+ const endTime = performance.now();
252
+ performanceAnalyzer.recordMetric({
253
+ timestamp: Date.now(),
254
+ operation: "beforeGeneration",
255
+ duration: endTime - startTime,
256
+ metadata: { totalSchemas: context.resolvedSchemas.size },
257
+ });
258
+ }
259
+ },
260
+ /**
261
+ * Monitor type generation performance
262
+ */
263
+ afterTypeGeneration: async (typeName, generatedType, context) => {
264
+ const startTime = performance.now();
265
+ const options = getPluginOptions(context);
266
+ try {
267
+ if (options.enableBundleAnalysis) {
268
+ const analysis = performanceAnalyzer.analyzeBundleSize(generatedType.content, generatedType.dependencies);
269
+ bundleAnalysisCache.set(typeName, analysis);
270
+ }
271
+ // Add performance monitoring code to generated types
272
+ if (options.enableRequestTiming) {
273
+ const monitoringCode = generateTypeMonitoringCode(typeName, options);
274
+ generatedType.content += monitoringCode;
275
+ }
276
+ // Check for performance warnings
277
+ const contentSize = Buffer.byteLength(generatedType.content, "utf8");
278
+ if (options.warningThresholds?.bundleSize &&
279
+ contentSize > options.warningThresholds.bundleSize) {
280
+ console.warn(`Type ${typeName} exceeds bundle size threshold: ${contentSize} bytes`);
281
+ }
282
+ }
283
+ catch (error) {
284
+ console.warn(`Performance monitoring plugin afterTypeGeneration failed for ${typeName}:`, error);
285
+ }
286
+ finally {
287
+ const endTime = performance.now();
288
+ performanceAnalyzer.recordMetric({
289
+ timestamp: Date.now(),
290
+ operation: "typeGeneration",
291
+ duration: endTime - startTime,
292
+ metadata: {
293
+ typeName,
294
+ contentSize: Buffer.byteLength(generatedType.content, "utf8"),
295
+ dependencyCount: generatedType.dependencies.length,
296
+ },
297
+ });
298
+ }
299
+ },
300
+ /**
301
+ * Monitor API client generation performance and add instrumentation
302
+ */
303
+ afterClientGeneration: async (generatedClient, context) => {
304
+ const startTime = performance.now();
305
+ const options = getPluginOptions(context);
306
+ try {
307
+ if (options.enableRequestTiming) {
308
+ // Add performance monitoring middleware to client
309
+ const monitoringMiddleware = generateClientMonitoringCode(generatedClient, options);
310
+ generatedClient.content += monitoringMiddleware;
311
+ }
312
+ // Analyze bundle and generate recommendations
313
+ if (options.enableBundleAnalysis) {
314
+ const analysis = performanceAnalyzer.analyzeBundleSize(generatedClient.content, generatedClient.dependencies);
315
+ bundleAnalysisCache.set(generatedClient.name, analysis);
316
+ // Add recommendations as comments
317
+ if (analysis.recommendations.length > 0) {
318
+ const recommendationsComment = `\n/**\n * Performance Recommendations:\n${analysis.recommendations
319
+ .map((rec) => ` * - ${rec}`)
320
+ .join("\n")}\n */\n`;
321
+ generatedClient.content =
322
+ recommendationsComment + generatedClient.content;
323
+ }
324
+ }
325
+ // Update dependencies with monitoring tools
326
+ if (!generatedClient.dependencies.includes("performance-hooks")) {
327
+ generatedClient.dependencies.push("performance-hooks");
328
+ }
329
+ // Add performance exports
330
+ generatedClient.exports.push("PerformanceMonitor", "getPerformanceStats", "clearPerformanceStats");
331
+ }
332
+ catch (error) {
333
+ console.warn("Performance monitoring plugin afterClientGeneration failed:", error);
334
+ }
335
+ finally {
336
+ const endTime = performance.now();
337
+ performanceAnalyzer.recordMetric({
338
+ timestamp: Date.now(),
339
+ operation: "clientGeneration",
340
+ duration: endTime - startTime,
341
+ metadata: {
342
+ clientName: generatedClient.name,
343
+ endpointCount: generatedClient.endpoints.length,
344
+ contentSize: Buffer.byteLength(generatedClient.content, "utf8"),
345
+ },
346
+ });
347
+ }
348
+ },
349
+ /**
350
+ * Generate final performance report after generation
351
+ */
352
+ afterGeneration: async (context) => {
353
+ const options = getPluginOptions(context);
354
+ try {
355
+ if (options.generateReports) {
356
+ const report = performanceAnalyzer.generateReport(options.reportFormat);
357
+ if (!report) {
358
+ // console.log("No performance data to generate report.");
359
+ }
360
+ // Output report (in a real implementation, this would write to file)
361
+ // console.log("Performance Report Generated:", {
362
+ // format: options.reportFormat,
363
+ // size: report.length,
364
+ // });
365
+ }
366
+ // Record final memory snapshot
367
+ if (options.enableMemoryProfiling) {
368
+ performanceAnalyzer.recordMemorySnapshot();
369
+ }
370
+ // Detect performance regressions
371
+ if (options.enableRegressionDetection) {
372
+ detectPerformanceRegressions(options);
373
+ }
374
+ }
375
+ catch (error) {
376
+ console.warn("Performance monitoring plugin afterGeneration failed:", error);
377
+ }
378
+ },
379
+ };
380
+ /**
381
+ * Get plugin options from generation context
382
+ */
383
+ function getPluginOptions(context) {
384
+ const pluginConfig = context.config.plugins?.find((p) => p.name === "performance-monitoring");
385
+ return {
386
+ enableRequestTiming: true,
387
+ enableBundleAnalysis: true,
388
+ enableMemoryProfiling: true,
389
+ enableRegressionDetection: false,
390
+ maxMetricsStorage: 1000,
391
+ metricsTTL: 24 * 60 * 60 * 1000, // 24 hours
392
+ warningThresholds: {
393
+ requestTime: 1000, // 1 second
394
+ bundleSize: 100000, // 100KB
395
+ memoryUsage: 50 * 1024 * 1024, // 50MB
396
+ },
397
+ generateReports: true,
398
+ reportFormat: "json",
399
+ ...(pluginConfig?.options || {}),
400
+ };
401
+ }
402
+ /**
403
+ * Generate performance monitoring code for types
404
+ */
405
+ function generateTypeMonitoringCode(typeName, _options) {
406
+ return `
407
+
408
+ /**
409
+ * Performance monitoring for ${typeName}
410
+ */
411
+ export const ${typeName}PerformanceMonitor = {
412
+ /**
413
+ * Record validation performance
414
+ */
415
+ recordValidation: (duration: number): void => {
416
+ if (typeof performance !== 'undefined') {
417
+ console.debug(\`${typeName} validation took \${duration}ms\`);
418
+ }
419
+ },
420
+
421
+ /**
422
+ * Measure validation performance
423
+ */
424
+ measureValidation: <T>(fn: () => T): T => {
425
+ const start = performance.now();
426
+ const result = fn();
427
+ const end = performance.now();
428
+ console.debug(\`${typeName} validation took \${end - start}ms\`);
429
+ return result;
430
+ }
431
+ };`;
432
+ }
433
+ /**
434
+ * Generate performance monitoring middleware for API client
435
+ */
436
+ function generateClientMonitoringCode(_generatedClient, options) {
437
+ return `
438
+
439
+ /**
440
+ * Performance monitoring middleware and utilities
441
+ */
442
+ export class PerformanceMonitor {
443
+ private static metrics = new Map<string, number[]>();
444
+ private static readonly maxMetrics = ${options.maxMetricsStorage || 1000};
445
+
446
+ /**
447
+ * Record request performance metric
448
+ */
449
+ static recordRequest(endpoint: string, duration: number): void {
450
+ if (!this.metrics.has(endpoint)) {
451
+ this.metrics.set(endpoint, []);
452
+ }
453
+
454
+ const metrics = this.metrics.get(endpoint)!;
455
+ metrics.push(duration);
456
+
457
+ // Maintain memory bounds
458
+ if (metrics.length > this.maxMetrics) {
459
+ metrics.splice(0, metrics.length - this.maxMetrics);
460
+ }
461
+ }
462
+
463
+ /**
464
+ * Wrap request function with performance monitoring
465
+ */
466
+ static wrapRequest<T>(
467
+ endpoint: string,
468
+ requestFn: () => Promise<T>
469
+ ): Promise<T> {
470
+ const start = performance.now();
471
+
472
+ return requestFn()
473
+ .then(result => {
474
+ const end = performance.now();
475
+ this.recordRequest(endpoint, end - start);
476
+
477
+ // Performance warning
478
+ const duration = end - start;
479
+ if (duration > ${options.warningThresholds?.requestTime || 1000}) {
480
+ console.warn(\`Slow request detected for \${endpoint}: \${duration}ms\`);
481
+ }
482
+
483
+ return result;
484
+ })
485
+ .catch(error => {
486
+ const end = performance.now();
487
+ this.recordRequest(endpoint, end - start);
488
+ throw error;
489
+ });
490
+ }
491
+
492
+ /**
493
+ * Get performance statistics for an endpoint
494
+ */
495
+ static getStats(endpoint: string): PerformanceStats | null {
496
+ const metrics = this.metrics.get(endpoint);
497
+ if (!metrics || metrics.length === 0) {
498
+ return null;
499
+ }
500
+
501
+ const sorted = [...metrics].sort((a, b) => a - b);
502
+ const count = sorted.length;
503
+ const sum = sorted.reduce((acc, val) => acc + val, 0);
504
+
505
+ return {
506
+ count,
507
+ min: sorted[0]!,
508
+ max: sorted[count - 1]!,
509
+ mean: sum / count,
510
+ median: sorted[Math.floor(count / 2)]!,
511
+ p95: sorted[Math.floor(count * 0.95)]!
512
+ };
513
+ }
514
+
515
+ /**
516
+ * Get all performance statistics
517
+ */
518
+ static getAllStats(): Record<string, PerformanceStats> {
519
+ const stats: Record<string, PerformanceStats> = {};
520
+ for (const endpoint of this.metrics.keys()) {
521
+ const stat = this.getStats(endpoint);
522
+ if (stat) {
523
+ stats[endpoint] = stat;
524
+ }
525
+ }
526
+ return stats;
527
+ }
528
+
529
+ /**
530
+ * Clear all performance metrics
531
+ */
532
+ static clearStats(): void {
533
+ this.metrics.clear();
534
+ }
535
+ }
536
+
537
+ interface PerformanceStats {
538
+ count: number;
539
+ min: number;
540
+ max: number;
541
+ mean: number;
542
+ median: number;
543
+ p95: number;
544
+ }
545
+
546
+ /**
547
+ * Global performance monitoring functions
548
+ */
549
+ export function getPerformanceStats(): Record<string, PerformanceStats> {
550
+ return PerformanceMonitor.getAllStats();
551
+ }
552
+
553
+ export function clearPerformanceStats(): void {
554
+ PerformanceMonitor.clearStats();
555
+ }
556
+
557
+ /**
558
+ * Performance-aware request decorator
559
+ */
560
+ export function performanceMonitored<T extends (...args: any[]) => Promise<any>>(
561
+ endpoint: string,
562
+ fn: T
563
+ ): T {
564
+ return ((...args: any[]) => {
565
+ return PerformanceMonitor.wrapRequest(endpoint, () => fn(...args));
566
+ }) as T;
567
+ }`;
568
+ }
569
+ /**
570
+ * Detect performance regressions by comparing current metrics with baselines
571
+ */
572
+ function detectPerformanceRegressions(options) {
573
+ const currentStats = performanceAnalyzer.getAllStats();
574
+ for (const [operation, stats] of Object.entries(currentStats)) {
575
+ // Simple regression detection - compare with thresholds
576
+ if (options.warningThresholds?.requestTime &&
577
+ stats.mean > options.warningThresholds.requestTime) {
578
+ console.warn(`Performance regression detected in ${operation}: ${stats.mean}ms (threshold: ${options.warningThresholds.requestTime}ms)`);
579
+ }
580
+ }
581
+ }
582
+ /**
583
+ * Export utility functions
584
+ */
585
+ function getPerformanceMonitoringStats() {
586
+ return performanceAnalyzer.getAllStats();
587
+ }
588
+ function clearPerformanceMonitoringCache() {
589
+ performanceAnalyzer.clearMetrics();
590
+ }
591
+ function generatePerformanceReport(format = "json") {
592
+ return performanceAnalyzer.generateReport(format);
593
+ }
594
+ // Export plugin for registration
595
+ exports.default = exports.performanceMonitoringPlugin;
596
+ //# sourceMappingURL=performance-monitoring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"performance-monitoring.js","sourceRoot":"","sources":["../../src/plugins/performance-monitoring.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAwwBH,sEAKC;AAED,0EAEC;AAED,8DAIC;AA/sBD;;GAEG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAA+B,CAAC;AAClE,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAA0B,CAAC;AAC9D,MAAM,eAAe,GAAkB,EAAE,CAAC;AAE1C;;GAEG;AACH,MAAM,mBAAmB;IAGvB,YAAY,YAAY,GAAG,IAAI;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED,YAAY,CAAC,MAAyB;QACpC,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC;QAC7B,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAClC,CAAC;QAED,MAAM,OAAO,GAAG,kBAAkB,CAAC,GAAG,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,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9D,wDAAwD;QACxD,IACE,OAAO,CAAC,iBAAiB,EAAE,WAAW;YACtC,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC,WAAW,EAClD,CAAC;YACD,OAAO,CAAC,IAAI,CACV,sCAAsC,SAAS,KAAK,KAAK,CAAC,IAAI,kBAAkB,OAAO,CAAC,iBAAiB,CAAC,WAAW,KAAK,CAC3H,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAOD;;GAEG;AACH,SAAgB,6BAA6B;IAI3C,OAAO,mBAAmB,CAAC,WAAW,EAAE,CAAC;AAC3C,CAAC;AAED,SAAgB,+BAA+B;IAC7C,mBAAmB,CAAC,YAAY,EAAE,CAAC;AACrC,CAAC;AAED,SAAgB,yBAAyB,CACvC,SAAuC,MAAM;IAE7C,OAAO,mBAAmB,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC;AAED,iCAAiC;AACjC,kBAAe,mCAA2B,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Advanced Request Deduplication Plugin
3
+ *
4
+ * Implements intelligent request deduplication at the client level with
5
+ * sophisticated caching strategies, memory management, and performance optimization.
6
+ *
7
+ * Key Features:
8
+ * - Request fingerprinting with content-based hashing
9
+ * - Intelligent cache invalidation strategies
10
+ * - Memory-efficient pending request management
11
+ * - Configurable TTL and size limits
12
+ * - Request coalescing for identical concurrent requests
13
+ * - Stale-while-revalidate patterns
14
+ *
15
+ * Architecture:
16
+ * - Non-blocking request deduplication
17
+ * - LRU cache with TTL support
18
+ * - WeakMap-based cleanup for memory efficiency
19
+ * - Configurable cache policies per endpoint
20
+ */
21
+ import { SchemanticPlugin } from "../types/core";
22
+ /**
23
+ * Advanced Request Deduplication Plugin Implementation
24
+ */
25
+ export declare const requestDeduplicationPlugin: SchemanticPlugin;
26
+ export default requestDeduplicationPlugin;
27
+ //# sourceMappingURL=request-deduplication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-deduplication.d.ts","sourceRoot":"","sources":["../../src/plugins/request-deduplication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,gBAAgB,EAGjB,MAAM,eAAe,CAAC;AAiCvB;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,gBA6CxC,CAAC;AAmnBF,eAAe,0BAA0B,CAAC"}