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,287 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.StreamingYamlParser = void 0;
37
+ exports.parseYamlStreaming = parseYamlStreaming;
38
+ exports.benchmarkStreamingComparison = benchmarkStreamingComparison;
39
+ exports.parseSecureYaml = parseSecureYaml;
40
+ const fs_1 = require("fs");
41
+ const js_yaml_1 = require("js-yaml");
42
+ const errors_1 = require("../errors");
43
+ const secure_yaml_parser_1 = require("../parser/secure-yaml-parser");
44
+ /**
45
+ * Parser YAML com suporte a streaming para arquivos grandes
46
+ */
47
+ class StreamingYamlParser extends secure_yaml_parser_1.SecureYamlParser {
48
+ constructor(options = {}) {
49
+ super(options.config);
50
+ this.streamingOptions = {
51
+ chunkSize: options.streaming?.chunkSize ?? 64 * 1024, // 64KB default
52
+ maxChunkSize: options.streaming?.maxChunkSize ?? 1024 * 1024, // 1MB max
53
+ validateChunkSize: options.streaming?.validateChunkSize ?? true,
54
+ enableStreaming: options.streaming?.enableStreaming ?? true,
55
+ lazyParsing: options.streaming?.lazyParsing ?? true,
56
+ parallelProcessing: options.streaming?.parallelProcessing ?? false
57
+ };
58
+ }
59
+ /**
60
+ * Parse arquivo YAML via streaming
61
+ */
62
+ async parseFileStreaming(filePath) {
63
+ if (!this.streamingOptions.enableStreaming) {
64
+ throw new Error('Streaming desabilitado nas opções');
65
+ }
66
+ const stream = (0, fs_1.createReadStream)(filePath, {
67
+ encoding: 'utf8',
68
+ highWaterMark: this.streamingOptions.chunkSize
69
+ });
70
+ return this.parseStream(stream);
71
+ }
72
+ /**
73
+ * Parse YAML a partir de stream
74
+ */
75
+ async parseStream(stream) {
76
+ let buffer = '';
77
+ let chunks = 0;
78
+ let totalSize = 0;
79
+ return new Promise((resolve, reject) => {
80
+ const startTime = performance.now();
81
+ stream.on('data', (chunk) => {
82
+ buffer += chunk.toString();
83
+ chunks++;
84
+ totalSize += chunk.length;
85
+ // Validação de tamanho do chunk
86
+ if (this.streamingOptions.validateChunkSize) {
87
+ if (chunk.length > this.streamingOptions.maxChunkSize) {
88
+ reject(new errors_1.YAMLSecurityError(`Chunk ${chunks} excedeu tamanho máximo: ${chunk.length} > ${this.streamingOptions.maxChunkSize}`));
89
+ }
90
+ }
91
+ });
92
+ stream.on('end', () => {
93
+ try {
94
+ const metrics = {
95
+ chunks,
96
+ totalSize,
97
+ chunkSize: this.streamingOptions.chunkSize,
98
+ parseTime: performance.now() - startTime
99
+ };
100
+ console.log(`[StreamingYamlParser] Processamento via streaming concluído:`, metrics);
101
+ const result = super.parseSecure(buffer);
102
+ resolve(result);
103
+ }
104
+ catch (error) {
105
+ reject(error);
106
+ }
107
+ });
108
+ stream.on('error', (error) => {
109
+ reject(new errors_1.YAMLParseError(`Erro durante streaming: ${error.message}`));
110
+ });
111
+ });
112
+ }
113
+ /**
114
+ * Parse YAML com lazy loading e streaming
115
+ */
116
+ async parseStreamingLazy(yamlContent) {
117
+ if (this.streamingOptions.lazyParsing) {
118
+ // Lazy parsing - criar Promise que só processa quando necessário
119
+ return new Promise((resolve, reject) => {
120
+ setTimeout(() => {
121
+ try {
122
+ const result = this.parseSecureChunked(yamlContent);
123
+ resolve(result);
124
+ }
125
+ catch (error) {
126
+ reject(error);
127
+ }
128
+ }, 0);
129
+ });
130
+ }
131
+ else {
132
+ return this.parseSecureChunked(yamlContent);
133
+ }
134
+ }
135
+ /**
136
+ * Parse YAML em chunks para não bloquear o event loop
137
+ */
138
+ async parseSecureChunked(yamlContent, chunkSize) {
139
+ const effectiveChunkSize = chunkSize ?? this.streamingOptions.chunkSize;
140
+ const chunks = [];
141
+ let position = 0;
142
+ while (position < yamlContent.length) {
143
+ const endPosition = Math.min(position + effectiveChunkSize, yamlContent.length);
144
+ chunks.push(yamlContent.slice(position, endPosition));
145
+ position = endPosition;
146
+ // Permitir que o event loop processe outros eventos
147
+ if (position < yamlContent.length) {
148
+ await new Promise(resolve => setImmediate(resolve));
149
+ }
150
+ }
151
+ // Juntar todos os chunks e processar como um único documento
152
+ const completeContent = chunks.join('');
153
+ return super.parseSecure(completeContent);
154
+ }
155
+ /**
156
+ * Parser otimizado para streams de entrada com configurações pré-definidas
157
+ */
158
+ async parseStreamOptimized(content) {
159
+ if (typeof content === 'string') {
160
+ return this.parseStreamingLarge(content);
161
+ }
162
+ else {
163
+ return this.parseStream(content);
164
+ }
165
+ }
166
+ /**
167
+ * Otimização para arquivos grandes (> 1MB)
168
+ */
169
+ async parseStreamingLarge(content) {
170
+ const startTime = performance.now();
171
+ if (content.length < 1024 * 1024) {
172
+ // Para arquivos pequenos, usar parsing direto
173
+ return super.parseSecure(content);
174
+ }
175
+ // Para arquivos grandes, usar parsing segmentado
176
+ let segments = this.segmentLargeContent(content);
177
+ const results = [];
178
+ if (this.streamingOptions.parallelProcessing) {
179
+ // Processamento paralelo de segmentos (experimental)
180
+ results.push(...await Promise.all(segments.map(segment => this.parseSegmentAsync(segment))));
181
+ }
182
+ else {
183
+ // Processamento sequencial (mais seguro para YAML)
184
+ for (const segment of segments) {
185
+ results.push(await this.parseSegmentAsync(segment));
186
+ }
187
+ }
188
+ const endTime = performance.now();
189
+ console.log(`[StreamingYamlParser] Arquivo grande processado: ${content.length} bytes em ${endTime - startTime}ms`);
190
+ return this.mergeResults(results);
191
+ }
192
+ /**
193
+ * Segmenta conteúdo grande em partes manejáveis
194
+ */
195
+ segmentLargeContent(content) {
196
+ const segmentSize = Math.floor(content.length / 4); // Dividir em 4 partes
197
+ const segments = [];
198
+ for (let i = 0; i < content.length; i += segmentSize) {
199
+ segments.push(content.slice(i, Math.min(i + segmentSize, content.length)));
200
+ }
201
+ return segments;
202
+ }
203
+ /**
204
+ * Processa segmento de forma assíncrona
205
+ */
206
+ async parseSegmentAsync(segment) {
207
+ return new Promise((resolve, reject) => {
208
+ setTimeout(() => {
209
+ try {
210
+ const result = (0, js_yaml_1.load)(segment, { schema: js_yaml_1.FAILSAFE_SCHEMA });
211
+ resolve(result);
212
+ }
213
+ catch (error) {
214
+ reject(new errors_1.YAMLParseError(`Erro ao processar segmento: ${error}`));
215
+ }
216
+ }, 0);
217
+ });
218
+ }
219
+ /**
220
+ * Merge resultados de múltiplos segmentos (simplificado)
221
+ */
222
+ mergeResults(results) {
223
+ if (results.length === 1)
224
+ return results[0];
225
+ // Para YAML simples, retornar o primeiro resultado completo
226
+ // Isso é uma simplificação - YAML completo requer lógica mais complexa
227
+ return results.find(result => result !== null && result !== undefined) ?? null;
228
+ }
229
+ /**
230
+ * Wrapper com monitoramento de performance para parsing de arquivos grandes
231
+ */
232
+ async parseFileWithMonitoring(filePath) {
233
+ const startTime = performance.now();
234
+ const startMemory = process.memoryUsage();
235
+ try {
236
+ const result = await this.parseFileStreaming(filePath);
237
+ const endTime = performance.now();
238
+ const endMemory = process.memoryUsage();
239
+ const metrics = {
240
+ parseTime: endTime - startTime,
241
+ memoryUsage: endMemory.heapUsed - startMemory.heapUsed,
242
+ fileSize: (await Promise.resolve().then(() => __importStar(require('fs')))).statSync(filePath).size,
243
+ chunksProcessed: Math.ceil((await Promise.resolve().then(() => __importStar(require('fs')))).statSync(filePath).size / this.streamingOptions.chunkSize),
244
+ streaming: true,
245
+ timestamp: Date.now()
246
+ };
247
+ return { result, metrics };
248
+ }
249
+ catch (error) {
250
+ throw error;
251
+ }
252
+ }
253
+ }
254
+ exports.StreamingYamlParser = StreamingYamlParser;
255
+ /**
256
+ * Wrapper para parsing com streaming
257
+ */
258
+ async function parseYamlStreaming(content, config) {
259
+ const parser = new StreamingYamlParser(config);
260
+ if (typeof content === 'string') {
261
+ return parser.parseStreamingLazy(content);
262
+ }
263
+ else {
264
+ return parser.parseStream(content);
265
+ }
266
+ }
267
+ /**
268
+ * Benchmark compartivo entre parsing normal e streaming
269
+ */
270
+ async function benchmarkStreamingComparison(content, iterations = 100) {
271
+ const { PerformanceMonitor } = await Promise.resolve().then(() => __importStar(require('./monitor')));
272
+ const monitor = new PerformanceMonitor();
273
+ // Normal parser benchmark
274
+ const normalResult = await monitor.benchmark(() => parseSecureYaml(content), 'Normal Parser', iterations, content.length);
275
+ // Streaming parser benchmark
276
+ const streamingResult = await monitor.benchmark(() => {
277
+ const parser = new StreamingYamlParser({ streaming: { enableStreaming: true } });
278
+ return parser.parseStreamingLazy(content);
279
+ }, 'Streaming Parser', iterations, content.length);
280
+ return { normal: normalResult, streaming: streamingResult };
281
+ }
282
+ // Import dinâmico para evitar circular dependencies
283
+ async function parseSecureYaml(content) {
284
+ const { parseSecureYaml } = await Promise.resolve().then(() => __importStar(require('../parser/secure-yaml-parser')));
285
+ return parseSecureYaml(content);
286
+ }
287
+ //# sourceMappingURL=streaming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streaming.js","sourceRoot":"","sources":["../../src/performance/streaming.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2QA,gDAWC;AAKD,oEA2BC;AAGD,0CAGC;AA5TD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IAEF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AAC9D,CAAC;AAED,oDAAoD;AAC7C,KAAK,UAAU,eAAe,CAAC,OAAe;IACnD,MAAM,EAAE,eAAe,EAAE,GAAG,wDAAa,8BAA8B,GAAC,CAAC;IACzE,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Audit service for Isolated Runtime - comprehensive audit trail
3
+ * Integration with story 1.1 SHA-256 logging system
4
+ */
5
+ declare class EventEmitterBase {
6
+ private listeners;
7
+ emit(event: string, ...args: any[]): void;
8
+ on(event: string, listener: (...args: any[]) => any): void;
9
+ }
10
+ export interface AuditEvent {
11
+ id: string;
12
+ timestamp: number;
13
+ type: AuditEventType;
14
+ executionId: string;
15
+ tenantId: string;
16
+ userId?: string;
17
+ action: string;
18
+ resource: string;
19
+ details: Record<string, any>;
20
+ result: "success" | "failure";
21
+ severity: "low" | "medium" | "high" | "critical";
22
+ sourceIp?: string;
23
+ userAgent?: string;
24
+ checksum: string;
25
+ signature?: string;
26
+ }
27
+ export type AuditEventType = "EXECUTION_START" | "EXECUTION_END" | "SECURITY_VIOLATION" | "PERFORMANCE_VIOLATION" | "MEMORY_VIOLATION" | "TIMEOUT_VIOLATION" | "SECURITY_SCAN" | "COMPLIANCE_CHECK" | "DATA_EXPORT" | "INTERNAL_ERROR" | "TENANT_ISOLATION_BREACH" | "VM_ESCAPE_ATTEMPT";
28
+ export interface ComplianceReport {
29
+ tenantId: string;
30
+ period: {
31
+ start: number;
32
+ end: number;
33
+ };
34
+ totalExecutions: number;
35
+ successfulExecutions: number;
36
+ failedExecutions: number;
37
+ securityViolations: number;
38
+ performanceViolations: number;
39
+ complianceStatus: "PASSED" | "FAILED" | "WARNING";
40
+ auditTrailHash: string;
41
+ nonRepudiationStatus: boolean;
42
+ exportFormat: "JSON" | "CSV" | "PDF" | "XML";
43
+ }
44
+ export interface AuditLog {
45
+ events: AuditEvent[];
46
+ metadata: {
47
+ tenantId: string;
48
+ period: {
49
+ start: number;
50
+ end: number;
51
+ };
52
+ totalEvents: number;
53
+ hashAlgorithm: "SHA-256";
54
+ chainOfCustody: true;
55
+ };
56
+ checksum: string;
57
+ }
58
+ export declare class AuditService extends EventEmitterBase {
59
+ private static instance;
60
+ private events;
61
+ private retentionPeriod;
62
+ private maxEventsPerTenant;
63
+ private enableNonRepudiation;
64
+ private enableComplianceExport;
65
+ private complianceStandards;
66
+ private constructor();
67
+ /**
68
+ * Obtém instância singleton do serviço
69
+ */
70
+ static getInstance(): AuditService;
71
+ /**
72
+ * Registra um evento de auditoria com SHA-256 hashing
73
+ */
74
+ logEvent(event: AuditEvent): void;
75
+ /**
76
+ * Gera hash SHA-256 para registro de auditoria
77
+ */
78
+ private generateChecksum;
79
+ /**
80
+ * Aplica política de retenção (limpeza de eventos antigos)
81
+ */
82
+ private applyRetentionPolicy;
83
+ /**
84
+ * Garante que não exceda limite de eventos por tenant
85
+ */
86
+ private enforceEventLimit;
87
+ /**
88
+ * Limpa eventos antigos do tenant
89
+ */
90
+ private cleanOldEvents;
91
+ /**
92
+ * Registra eventos críticos com informações adicionais
93
+ */
94
+ private logCriticalEvent;
95
+ /**
96
+ * Inicializa política de retenção
97
+ */
98
+ private initializeRetentionPolicy;
99
+ /**
100
+ * Recupera eventos para auditoria específica
101
+ */
102
+ getAuditLog(tenantId: string, startTime?: number, endTime?: number): AuditLog;
103
+ /**
104
+ * Gera hash global SHA-256 para o conjunto de eventos
105
+ */
106
+ private generateGlobalChecksum;
107
+ /**
108
+ * Gera relatório de compliance detalhado
109
+ */
110
+ generateComplianceReport(tenantId: string, period?: {
111
+ start: number;
112
+ end: number;
113
+ }): ComplianceReport;
114
+ /**
115
+ * Exporta dados de compliance em formato específico
116
+ */
117
+ exportComplianceData(tenantId: string, format?: "JSON" | "CSV" | "XML", period?: {
118
+ start: number;
119
+ end: number;
120
+ }): string;
121
+ /**
122
+ * Converte relatório para CSV
123
+ */
124
+ private convertToCSV;
125
+ /**
126
+ * Converte relatório para XML
127
+ */
128
+ private convertToXML;
129
+ /**
130
+ * Cria instância conveniente de evento de auditoria
131
+ */
132
+ createEvent(data: Omit<AuditEvent, "id" | "checksum" | "timestamp">): AuditEvent;
133
+ /**
134
+ * Análise estatística de eventos
135
+ */
136
+ getStatistics(tenantId: string, period?: {
137
+ start: number;
138
+ end: number;
139
+ }): {
140
+ totalEvents: number;
141
+ eventsByType: Record<AuditEventType, number>;
142
+ eventsBySeverity: Record<"low" | "medium" | "high" | "critical", number>;
143
+ eventsByResult: {
144
+ success: number;
145
+ failure: number;
146
+ };
147
+ averageComplianceScore: number;
148
+ };
149
+ /**
150
+ * Valida integridade do audit trail
151
+ */
152
+ validateIntegrity(tenantId: string): {
153
+ isValid: boolean;
154
+ message: string;
155
+ corruptedEventCount: number;
156
+ };
157
+ /**
158
+ * Função de conveniência para eventos de segurança
159
+ */
160
+ logSecurityEvent(executionId: string, tenantId: string, action: string, result: "success" | "failure", details: Record<string, any>): void;
161
+ /**
162
+ * Função de conveniência para eventos de desempenho
163
+ */
164
+ logPerformanceEvent(executionId: string, tenantId: string, timing: number, memory?: number, details?: Record<string, any>): void;
165
+ /**
166
+ * Função de conveniência para eventos de memória
167
+ */
168
+ logMemoryEvent(executionId: string, tenantId: string, memoryUsage: number, targetMemory?: number): void;
169
+ /**
170
+ * Exporta dados de auditoria para backup/restore
171
+ */
172
+ exportAuditData(tenantId: string): string;
173
+ /**
174
+ * Importa dados de auditoria (restauração)
175
+ */
176
+ importAuditData(data: string): void;
177
+ /**
178
+ * Valida dados de auditoria importados
179
+ */
180
+ private validateImportedAudit;
181
+ /**
182
+ * Configurações principais
183
+ */
184
+ configure(options: Partial<{
185
+ retentionDays: number;
186
+ maxEventsPerTenant: number;
187
+ enableNonRepudiation: boolean;
188
+ enableComplianceExport: boolean;
189
+ complianceStandards: string[];
190
+ }>): void;
191
+ /**
192
+ * Limpa todos os eventos de auditoria (uso em testes e manutenção)
193
+ */
194
+ clearAuditLog(tenantId: string): void;
195
+ /**
196
+ * Limpa todos os eventos de todos os tenants (uso com extrema cautela)
197
+ */
198
+ clearAllAuditLogs(): void;
199
+ /**
200
+ * Desabilita logging de auditoria para testes
201
+ */
202
+ disableAuditLogging(): void;
203
+ /**
204
+ * Reabilita logging de auditoria
205
+ */
206
+ enableAuditLogging(): void;
207
+ /**
208
+ * Obtém estatísticas de uso do serviço
209
+ */
210
+ getServiceStats(): {
211
+ totalTenants: number;
212
+ totalEvents: number;
213
+ memoryUsage: number;
214
+ uptime: number;
215
+ lastCleanup: number;
216
+ retentionPolicyActive: boolean;
217
+ };
218
+ }
219
+ /**
220
+ * Exporta serviço singleton global
221
+ */
222
+ export declare const auditService: AuditService;
223
+ /**
224
+ * Funções de conveniência para logging rápido
225
+ */
226
+ export declare function logRuntimeEvent(executionId: string, tenantId: string, action: string, result: "success" | "failure", details?: Record<string, any>): void;
227
+ export declare function logSecurityViolation(executionId: string, tenantId: string, violationType: string, details: Record<string, any>): void;
228
+ export declare function logPerformanceViolation(executionId: string, tenantId: string, executionTime: number, memoryUsage: number): void;
229
+ export declare function logMemoryViolation(executionId: string, tenantId: string, memoryUsage: number): void;
230
+ export declare function generateComplianceReportAsync(tenantId: string, period?: {
231
+ start: number;
232
+ end: number;
233
+ }): Promise<ComplianceReport>;
234
+ export declare function exportComplianceData(tenantId: string, format?: "JSON" | "CSV" | "XML", period?: {
235
+ start: number;
236
+ end: number;
237
+ }): string;
238
+ export { AuditService as AuditLogger };
239
+ export type { ComplianceReport as AuditReport };
240
+ //# sourceMappingURL=audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/runtime/audit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAM,gBAAgB;IACpB,OAAO,CAAC,SAAS,CAAyD;IAE1E,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,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