beddel 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 (236) hide show
  1. package/README.md +297 -0
  2. package/dist/agents/agentRegistry.d.ts +68 -0
  3. package/dist/agents/agentRegistry.d.ts.map +1 -0
  4. package/dist/agents/agentRegistry.js +222 -0
  5. package/dist/agents/agentRegistry.js.map +1 -0
  6. package/dist/agents/formatter-agent.d.ts +10 -0
  7. package/dist/agents/formatter-agent.d.ts.map +1 -0
  8. package/dist/agents/formatter-agent.js +49 -0
  9. package/dist/agents/formatter-agent.js.map +1 -0
  10. package/dist/agents/genkit-agent.d.ts +12 -0
  11. package/dist/agents/genkit-agent.d.ts.map +1 -0
  12. package/dist/agents/genkit-agent.js +119 -0
  13. package/dist/agents/genkit-agent.js.map +1 -0
  14. package/dist/agents/i18n-messages.d.ts +17 -0
  15. package/dist/agents/i18n-messages.d.ts.map +1 -0
  16. package/dist/agents/i18n-messages.js +92 -0
  17. package/dist/agents/i18n-messages.js.map +1 -0
  18. package/dist/agents/index.d.ts +10 -0
  19. package/dist/agents/index.d.ts.map +1 -0
  20. package/dist/agents/index.js +26 -0
  21. package/dist/agents/index.js.map +1 -0
  22. package/dist/agents/pipeline.d.ts +15 -0
  23. package/dist/agents/pipeline.d.ts.map +1 -0
  24. package/dist/agents/pipeline.js +45 -0
  25. package/dist/agents/pipeline.js.map +1 -0
  26. package/dist/agents/schema-factory.d.ts +40 -0
  27. package/dist/agents/schema-factory.d.ts.map +1 -0
  28. package/dist/agents/schema-factory.js +121 -0
  29. package/dist/agents/schema-factory.js.map +1 -0
  30. package/dist/agents/translation-validators.d.ts +26 -0
  31. package/dist/agents/translation-validators.d.ts.map +1 -0
  32. package/dist/agents/translation-validators.js +77 -0
  33. package/dist/agents/translation-validators.js.map +1 -0
  34. package/dist/agents/translator-agents.d.ts +184 -0
  35. package/dist/agents/translator-agents.d.ts.map +1 -0
  36. package/dist/agents/translator-agents.js +613 -0
  37. package/dist/agents/translator-agents.js.map +1 -0
  38. package/dist/agents/types/translation.types.d.ts +100 -0
  39. package/dist/agents/types/translation.types.d.ts.map +1 -0
  40. package/dist/agents/types/translation.types.js +3 -0
  41. package/dist/agents/types/translation.types.js.map +1 -0
  42. package/dist/agents/validator-agent.d.ts +42 -0
  43. package/dist/agents/validator-agent.d.ts.map +1 -0
  44. package/dist/agents/validator-agent.js +122 -0
  45. package/dist/agents/validator-agent.js.map +1 -0
  46. package/dist/audit/auditTrail.d.ts +55 -0
  47. package/dist/audit/auditTrail.d.ts.map +1 -0
  48. package/dist/audit/auditTrail.js +93 -0
  49. package/dist/audit/auditTrail.js.map +1 -0
  50. package/dist/compliance/gdprEngine.d.ts +44 -0
  51. package/dist/compliance/gdprEngine.d.ts.map +1 -0
  52. package/dist/compliance/gdprEngine.js +178 -0
  53. package/dist/compliance/gdprEngine.js.map +1 -0
  54. package/dist/compliance/lgpdEngine.d.ts +51 -0
  55. package/dist/compliance/lgpdEngine.d.ts.map +1 -0
  56. package/dist/compliance/lgpdEngine.js +221 -0
  57. package/dist/compliance/lgpdEngine.js.map +1 -0
  58. package/dist/config.d.ts +78 -0
  59. package/dist/config.d.ts.map +1 -0
  60. package/dist/config.js +77 -0
  61. package/dist/config.js.map +1 -0
  62. package/dist/errors.d.ts +17 -0
  63. package/dist/errors.d.ts.map +1 -0
  64. package/dist/errors.js +40 -0
  65. package/dist/errors.js.map +1 -0
  66. package/dist/firebase/tenantManager.d.ts +84 -0
  67. package/dist/firebase/tenantManager.d.ts.map +1 -0
  68. package/dist/firebase/tenantManager.js +378 -0
  69. package/dist/firebase/tenantManager.js.map +1 -0
  70. package/dist/index.d.ts +36 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +118 -0
  73. package/dist/index.js.map +1 -0
  74. package/dist/integration/secure-yaml-runtime.d.ts +68 -0
  75. package/dist/integration/secure-yaml-runtime.d.ts.map +1 -0
  76. package/dist/integration/secure-yaml-runtime.js +245 -0
  77. package/dist/integration/secure-yaml-runtime.js.map +1 -0
  78. package/dist/parser/secure-yaml-parser.d.ts +62 -0
  79. package/dist/parser/secure-yaml-parser.d.ts.map +1 -0
  80. package/dist/parser/secure-yaml-parser.js +234 -0
  81. package/dist/parser/secure-yaml-parser.js.map +1 -0
  82. package/dist/performance/autoscaling.d.ts +100 -0
  83. package/dist/performance/autoscaling.d.ts.map +1 -0
  84. package/dist/performance/autoscaling.js +339 -0
  85. package/dist/performance/autoscaling.js.map +1 -0
  86. package/dist/performance/benchmark.d.ts +104 -0
  87. package/dist/performance/benchmark.d.ts.map +1 -0
  88. package/dist/performance/benchmark.js +514 -0
  89. package/dist/performance/benchmark.js.map +1 -0
  90. package/dist/performance/index.d.ts +14 -0
  91. package/dist/performance/index.d.ts.map +1 -0
  92. package/dist/performance/index.js +35 -0
  93. package/dist/performance/index.js.map +1 -0
  94. package/dist/performance/monitor.d.ts +126 -0
  95. package/dist/performance/monitor.d.ts.map +1 -0
  96. package/dist/performance/monitor.js +324 -0
  97. package/dist/performance/monitor.js.map +1 -0
  98. package/dist/performance/streaming.d.ts +82 -0
  99. package/dist/performance/streaming.d.ts.map +1 -0
  100. package/dist/performance/streaming.js +287 -0
  101. package/dist/performance/streaming.js.map +1 -0
  102. package/dist/runtime/audit.d.ts +240 -0
  103. package/dist/runtime/audit.d.ts.map +1 -0
  104. package/dist/runtime/audit.js +641 -0
  105. package/dist/runtime/audit.js.map +1 -0
  106. package/dist/runtime/declarativeAgentRuntime.d.ts +123 -0
  107. package/dist/runtime/declarativeAgentRuntime.d.ts.map +1 -0
  108. package/dist/runtime/declarativeAgentRuntime.js +576 -0
  109. package/dist/runtime/declarativeAgentRuntime.js.map +1 -0
  110. package/dist/runtime/isolatedRuntime.d.ts +119 -0
  111. package/dist/runtime/isolatedRuntime.d.ts.map +1 -0
  112. package/dist/runtime/isolatedRuntime.js +425 -0
  113. package/dist/runtime/isolatedRuntime.js.map +1 -0
  114. package/dist/runtime/schemaCompiler.d.ts +35 -0
  115. package/dist/runtime/schemaCompiler.d.ts.map +1 -0
  116. package/dist/runtime/schemaCompiler.js +151 -0
  117. package/dist/runtime/schemaCompiler.js.map +1 -0
  118. package/dist/runtime/simpleRuntime.d.ts +57 -0
  119. package/dist/runtime/simpleRuntime.d.ts.map +1 -0
  120. package/dist/runtime/simpleRuntime.js +187 -0
  121. package/dist/runtime/simpleRuntime.js.map +1 -0
  122. package/dist/security/dashboard.d.ts +89 -0
  123. package/dist/security/dashboard.d.ts.map +1 -0
  124. package/dist/security/dashboard.js +300 -0
  125. package/dist/security/dashboard.js.map +1 -0
  126. package/dist/security/hardening.d.ts +130 -0
  127. package/dist/security/hardening.d.ts.map +1 -0
  128. package/dist/security/hardening.js +414 -0
  129. package/dist/security/hardening.js.map +1 -0
  130. package/dist/security/index.d.ts +128 -0
  131. package/dist/security/index.d.ts.map +1 -0
  132. package/dist/security/index.js +353 -0
  133. package/dist/security/index.js.map +1 -0
  134. package/dist/security/monitor.d.ts +88 -0
  135. package/dist/security/monitor.d.ts.map +1 -0
  136. package/dist/security/monitor.js +356 -0
  137. package/dist/security/monitor.js.map +1 -0
  138. package/dist/security/scanner.d.ts +104 -0
  139. package/dist/security/scanner.d.ts.map +1 -0
  140. package/dist/security/scanner.js +298 -0
  141. package/dist/security/scanner.js.map +1 -0
  142. package/dist/security/score.d.ts +150 -0
  143. package/dist/security/score.d.ts.map +1 -0
  144. package/dist/security/score.js +983 -0
  145. package/dist/security/score.js.map +1 -0
  146. package/dist/security/test-security.d.ts +22 -0
  147. package/dist/security/test-security.d.ts.map +1 -0
  148. package/dist/security/test-security.js +154 -0
  149. package/dist/security/test-security.js.map +1 -0
  150. package/dist/security/threatDetector.d.ts +39 -0
  151. package/dist/security/threatDetector.d.ts.map +1 -0
  152. package/dist/security/threatDetector.js +354 -0
  153. package/dist/security/threatDetector.js.map +1 -0
  154. package/dist/security/validation.d.ts +69 -0
  155. package/dist/security/validation.d.ts.map +1 -0
  156. package/dist/security/validation.js +286 -0
  157. package/dist/security/validation.js.map +1 -0
  158. package/dist/server/api/clientsRoute.d.ts +9 -0
  159. package/dist/server/api/clientsRoute.d.ts.map +1 -0
  160. package/dist/server/api/clientsRoute.js +71 -0
  161. package/dist/server/api/clientsRoute.js.map +1 -0
  162. package/dist/server/api/endpointsRoute.d.ts +8 -0
  163. package/dist/server/api/endpointsRoute.d.ts.map +1 -0
  164. package/dist/server/api/endpointsRoute.js +76 -0
  165. package/dist/server/api/endpointsRoute.js.map +1 -0
  166. package/dist/server/api/graphql.d.ts +9 -0
  167. package/dist/server/api/graphql.d.ts.map +1 -0
  168. package/dist/server/api/graphql.js +180 -0
  169. package/dist/server/api/graphql.js.map +1 -0
  170. package/dist/server/errors.d.ts +19 -0
  171. package/dist/server/errors.d.ts.map +1 -0
  172. package/dist/server/errors.js +42 -0
  173. package/dist/server/errors.js.map +1 -0
  174. package/dist/server/index.d.ts +7 -0
  175. package/dist/server/index.d.ts.map +1 -0
  176. package/dist/server/index.js +24 -0
  177. package/dist/server/index.js.map +1 -0
  178. package/dist/server/kvStore.d.ts +27 -0
  179. package/dist/server/kvStore.d.ts.map +1 -0
  180. package/dist/server/kvStore.js +128 -0
  181. package/dist/server/kvStore.js.map +1 -0
  182. package/dist/server/runtimeSecurity.d.ts +28 -0
  183. package/dist/server/runtimeSecurity.d.ts.map +1 -0
  184. package/dist/server/runtimeSecurity.js +85 -0
  185. package/dist/server/runtimeSecurity.js.map +1 -0
  186. package/dist/server/types.d.ts +53 -0
  187. package/dist/server/types.d.ts.map +1 -0
  188. package/dist/server/types.js +8 -0
  189. package/dist/server/types.js.map +1 -0
  190. package/dist/types/executionContext.d.ts +16 -0
  191. package/dist/types/executionContext.d.ts.map +1 -0
  192. package/dist/types/executionContext.js +3 -0
  193. package/dist/types/executionContext.js.map +1 -0
  194. package/package.json +77 -0
  195. package/src/agents/agentRegistry.ts +272 -0
  196. package/src/agents/image-agent.yaml +86 -0
  197. package/src/agents/joker-agent.yaml +47 -0
  198. package/src/agents/translator-agent.yaml +80 -0
  199. package/src/audit/auditTrail.ts +134 -0
  200. package/src/compliance/gdprEngine.ts +209 -0
  201. package/src/compliance/lgpdEngine.ts +268 -0
  202. package/src/config.ts +179 -0
  203. package/src/errors.ts +35 -0
  204. package/src/firebase/tenantManager.ts +443 -0
  205. package/src/index.ts +125 -0
  206. package/src/integration/secure-yaml-runtime.ts +341 -0
  207. package/src/parser/secure-yaml-parser.ts +273 -0
  208. package/src/performance/autoscaling.ts +495 -0
  209. package/src/performance/benchmark.ts +644 -0
  210. package/src/performance/index.ts +34 -0
  211. package/src/performance/monitor.ts +469 -0
  212. package/src/performance/streaming.ts +317 -0
  213. package/src/runtime/audit.ts +907 -0
  214. package/src/runtime/declarativeAgentRuntime.ts +836 -0
  215. package/src/runtime/isolatedRuntime.ts +572 -0
  216. package/src/runtime/schemaCompiler.ts +228 -0
  217. package/src/runtime/simpleRuntime.ts +201 -0
  218. package/src/security/dashboard.ts +462 -0
  219. package/src/security/hardening.ts +560 -0
  220. package/src/security/index.ts +439 -0
  221. package/src/security/monitor.ts +490 -0
  222. package/src/security/scanner.ts +368 -0
  223. package/src/security/score.ts +1138 -0
  224. package/src/security/threatDetector.ts +481 -0
  225. package/src/security/validation.ts +365 -0
  226. package/src/server/api/clientsRoute.ts +92 -0
  227. package/src/server/api/endpointsRoute.ts +97 -0
  228. package/src/server/api/graphql.ts +249 -0
  229. package/src/server/errors.ts +38 -0
  230. package/src/server/index.ts +6 -0
  231. package/src/server/kvStore.ts +152 -0
  232. package/src/server/runtimeSecurity.ts +102 -0
  233. package/src/server/types.ts +60 -0
  234. package/src/types/executionContext.ts +16 -0
  235. package/tools/seed.ts +365 -0
  236. package/tools/test-endpoints.ts +174 -0
@@ -0,0 +1,317 @@
1
+ import { createReadStream } from 'fs';
2
+ import { Readable } from 'stream';
3
+ import { load, FAILSAFE_SCHEMA } from 'js-yaml';
4
+ import { YAMLParseError, YAMLSecurityError } from '../errors';
5
+ import { SecureYamlParser } from '../parser/secure-yaml-parser';
6
+
7
+ /**
8
+ * Interface para opções de streaming
9
+ */
10
+ export interface StreamingOptions {
11
+ chunkSize?: number;
12
+ maxChunkSize?: number;
13
+ validateChunkSize?: boolean;
14
+ enableStreaming?: boolean;
15
+ lazyParsing?: boolean;
16
+ parallelProcessing?: boolean;
17
+ }
18
+
19
+ /**
20
+ * Parser YAML com suporte a streaming para arquivos grandes
21
+ */
22
+ export class StreamingYamlParser extends SecureYamlParser {
23
+ private readonly streamingOptions: Required<StreamingOptions>;
24
+
25
+ constructor(options: { config?: any; streaming?: StreamingOptions } = {}) {
26
+ super(options.config);
27
+
28
+ this.streamingOptions = {
29
+ chunkSize: options.streaming?.chunkSize ?? 64 * 1024, // 64KB default
30
+ maxChunkSize: options.streaming?.maxChunkSize ?? 1024 * 1024, // 1MB max
31
+ validateChunkSize: options.streaming?.validateChunkSize ?? true,
32
+ enableStreaming: options.streaming?.enableStreaming ?? true,
33
+ lazyParsing: options.streaming?.lazyParsing ?? true,
34
+ parallelProcessing: options.streaming?.parallelProcessing ?? false
35
+ };
36
+ }
37
+
38
+ /**
39
+ * Parse arquivo YAML via streaming
40
+ */
41
+ async parseFileStreaming(filePath: string): Promise<any> {
42
+ if (!this.streamingOptions.enableStreaming) {
43
+ throw new Error('Streaming desabilitado nas opções');
44
+ }
45
+
46
+ const stream = createReadStream(filePath, {
47
+ encoding: 'utf8',
48
+ highWaterMark: this.streamingOptions.chunkSize
49
+ });
50
+
51
+ return this.parseStream(stream);
52
+ }
53
+
54
+ /**
55
+ * Parse YAML a partir de stream
56
+ */
57
+ async parseStream(stream: Readable): Promise<any> {
58
+ let buffer = '';
59
+ let chunks = 0;
60
+ let totalSize = 0;
61
+
62
+ return new Promise((resolve, reject) => {
63
+ const startTime = performance.now();
64
+
65
+ stream.on('data', (chunk: Buffer | string) => {
66
+ buffer += chunk.toString();
67
+ chunks++;
68
+ totalSize += chunk.length;
69
+
70
+ // Validação de tamanho do chunk
71
+ if (this.streamingOptions.validateChunkSize) {
72
+ if (chunk.length > this.streamingOptions.maxChunkSize) {
73
+ reject(new YAMLSecurityError(
74
+ `Chunk ${chunks} excedeu tamanho máximo: ${chunk.length} > ${this.streamingOptions.maxChunkSize}`
75
+ ));
76
+ }
77
+ }
78
+ });
79
+
80
+ stream.on('end', () => {
81
+ try {
82
+ const metrics = {
83
+ chunks,
84
+ totalSize,
85
+ chunkSize: this.streamingOptions.chunkSize,
86
+ parseTime: performance.now() - startTime
87
+ };
88
+
89
+ console.log(`[StreamingYamlParser] Processamento via streaming concluído:`, metrics);
90
+
91
+ const result = super.parseSecure(buffer);
92
+ resolve(result);
93
+
94
+ } catch (error) {
95
+ reject(error);
96
+ }
97
+ });
98
+
99
+ stream.on('error', (error: Error) => {
100
+ reject(new YAMLParseError(`Erro durante streaming: ${error.message}`));
101
+ });
102
+ });
103
+ }
104
+
105
+ /**
106
+ * Parse YAML com lazy loading e streaming
107
+ */
108
+ async parseStreamingLazy(yamlContent: string): Promise<any> {
109
+ if (this.streamingOptions.lazyParsing) {
110
+ // Lazy parsing - criar Promise que só processa quando necessário
111
+ return new Promise((resolve, reject) => {
112
+ setTimeout(() => {
113
+ try {
114
+ const result = this.parseSecureChunked(yamlContent);
115
+ resolve(result);
116
+ } catch (error) {
117
+ reject(error);
118
+ }
119
+ }, 0);
120
+ });
121
+ } else {
122
+ return this.parseSecureChunked(yamlContent);
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Parse YAML em chunks para não bloquear o event loop
128
+ */
129
+ private async parseSecureChunked(yamlContent: string, chunkSize?: number): Promise<any> {
130
+ const effectiveChunkSize = chunkSize ?? this.streamingOptions.chunkSize;
131
+ const chunks = [];
132
+ let position = 0;
133
+
134
+ while (position < yamlContent.length) {
135
+ const endPosition = Math.min(position + effectiveChunkSize, yamlContent.length);
136
+ chunks.push(yamlContent.slice(position, endPosition));
137
+ position = endPosition;
138
+
139
+ // Permitir que o event loop processe outros eventos
140
+ if (position < yamlContent.length) {
141
+ await new Promise(resolve => setImmediate(resolve));
142
+ }
143
+ }
144
+
145
+ // Juntar todos os chunks e processar como um único documento
146
+ const completeContent = chunks.join('');
147
+ return super.parseSecure(completeContent);
148
+ }
149
+
150
+ /**
151
+ * Parser otimizado para streams de entrada com configurações pré-definidas
152
+ */
153
+ async parseStreamOptimized(content: string | Readable): Promise<any> {
154
+ if (typeof content === 'string') {
155
+ return this.parseStreamingLarge(content);
156
+ } else {
157
+ return this.parseStream(content);
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Otimização para arquivos grandes (> 1MB)
163
+ */
164
+ private async parseStreamingLarge(content: string): Promise<any> {
165
+ const startTime = performance.now();
166
+
167
+ if (content.length < 1024 * 1024) {
168
+ // Para arquivos pequenos, usar parsing direto
169
+ return super.parseSecure(content);
170
+ }
171
+
172
+ // Para arquivos grandes, usar parsing segmentado
173
+ let segments = this.segmentLargeContent(content);
174
+ const results = [];
175
+
176
+ if (this.streamingOptions.parallelProcessing) {
177
+ // Processamento paralelo de segmentos (experimental)
178
+ results.push(...await Promise.all(
179
+ segments.map(segment => this.parseSegmentAsync(segment))
180
+ ));
181
+ } else {
182
+ // Processamento sequencial (mais seguro para YAML)
183
+ for (const segment of segments) {
184
+ results.push(await this.parseSegmentAsync(segment));
185
+ }
186
+ }
187
+
188
+ const endTime = performance.now();
189
+ console.log(`[StreamingYamlParser] Arquivo grande processado: ${content.length} bytes em ${endTime - startTime}ms`);
190
+
191
+ return this.mergeResults(results);
192
+ }
193
+
194
+ /**
195
+ * Segmenta conteúdo grande em partes manejáveis
196
+ */
197
+ private segmentLargeContent(content: string): string[] {
198
+ const segmentSize = Math.floor(content.length / 4); // Dividir em 4 partes
199
+ const segments = [];
200
+
201
+ for (let i = 0; i < content.length; i += segmentSize) {
202
+ segments.push(content.slice(i, Math.min(i + segmentSize, content.length)));
203
+ }
204
+
205
+ return segments;
206
+ }
207
+
208
+ /**
209
+ * Processa segmento de forma assíncrona
210
+ */
211
+ private async parseSegmentAsync(segment: string): Promise<any> {
212
+ return new Promise((resolve, reject) => {
213
+ setTimeout(() => {
214
+ try {
215
+ const result = load(segment, { schema: FAILSAFE_SCHEMA });
216
+ resolve(result);
217
+ } catch (error) {
218
+ reject(new YAMLParseError(`Erro ao processar segmento: ${error}`));
219
+ }
220
+ }, 0);
221
+ });
222
+ }
223
+
224
+ /**
225
+ * Merge resultados de múltiplos segmentos (simplificado)
226
+ */
227
+ private mergeResults(results: any[]): any {
228
+ if (results.length === 1) return results[0];
229
+
230
+ // Para YAML simples, retornar o primeiro resultado completo
231
+ // Isso é uma simplificação - YAML completo requer lógica mais complexa
232
+ return results.find(result => result !== null && result !== undefined) ?? null;
233
+ }
234
+
235
+ /**
236
+ * Wrapper com monitoramento de performance para parsing de arquivos grandes
237
+ */
238
+ async parseFileWithMonitoring(filePath: string): Promise<{ result: any; metrics: any }> {
239
+ const startTime = performance.now();
240
+ const startMemory = process.memoryUsage();
241
+
242
+ try {
243
+ const result = await this.parseFileStreaming(filePath);
244
+
245
+ const endTime = performance.now();
246
+ const endMemory = process.memoryUsage();
247
+
248
+ const metrics = {
249
+ parseTime: endTime - startTime,
250
+ memoryUsage: endMemory.heapUsed - startMemory.heapUsed,
251
+ fileSize: (await import('fs')).statSync(filePath).size,
252
+ chunksProcessed: Math.ceil((await import('fs')).statSync(filePath).size / this.streamingOptions.chunkSize),
253
+ streaming: true,
254
+ timestamp: Date.now()
255
+ };
256
+
257
+ return { result, metrics };
258
+
259
+ } catch (error) {
260
+ throw error;
261
+ }
262
+ }
263
+ }
264
+
265
+ /**
266
+ * Wrapper para parsing com streaming
267
+ */
268
+ export async function parseYamlStreaming(
269
+ content: string | Readable,
270
+ config?: { streaming?: StreamingOptions; parser?: any }
271
+ ): Promise<any> {
272
+ const parser = new StreamingYamlParser(config);
273
+
274
+ if (typeof content === 'string') {
275
+ return parser.parseStreamingLazy(content);
276
+ } else {
277
+ return parser.parseStream(content);
278
+ }
279
+ }
280
+
281
+ /**
282
+ * Benchmark compartivo entre parsing normal e streaming
283
+ */
284
+ export async function benchmarkStreamingComparison(
285
+ content: string,
286
+ iterations: number = 100
287
+ ): Promise<{ normal: any; streaming: any }> {
288
+ const { PerformanceMonitor } = await import('./monitor');
289
+ const monitor = new PerformanceMonitor();
290
+
291
+ // Normal parser benchmark
292
+ const normalResult = await monitor.benchmark(
293
+ () => parseSecureYaml(content),
294
+ 'Normal Parser',
295
+ iterations,
296
+ content.length
297
+ );
298
+
299
+ // Streaming parser benchmark
300
+ const streamingResult = await monitor.benchmark(
301
+ () => {
302
+ const parser = new StreamingYamlParser({ streaming: { enableStreaming: true } });
303
+ return parser.parseStreamingLazy(content);
304
+ },
305
+ 'Streaming Parser',
306
+ iterations,
307
+ content.length
308
+ );
309
+
310
+ return { normal: normalResult, streaming: streamingResult };
311
+ }
312
+
313
+ // Import dinâmico para evitar circular dependencies
314
+ export async function parseSecureYaml(content: string): Promise<any> {
315
+ const { parseSecureYaml } = await import('../parser/secure-yaml-parser');
316
+ return parseSecureYaml(content);
317
+ }