@designliquido/delegua-entidades 0.0.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 (206) hide show
  1. package/README.md +96 -0
  2. package/fontes/analisador-dicas.d.ts +49 -0
  3. package/fontes/analisador-dicas.d.ts.map +1 -0
  4. package/fontes/analisador-dicas.js +145 -0
  5. package/fontes/analisador-dicas.js.map +1 -0
  6. package/fontes/cache-consultas.d.ts +39 -0
  7. package/fontes/cache-consultas.d.ts.map +1 -0
  8. package/fontes/cache-consultas.js +98 -0
  9. package/fontes/cache-consultas.js.map +1 -0
  10. package/fontes/carregador-lotes.d.ts +64 -0
  11. package/fontes/carregador-lotes.d.ts.map +1 -0
  12. package/fontes/carregador-lotes.js +148 -0
  13. package/fontes/carregador-lotes.js.map +1 -0
  14. package/fontes/carregador-preguicoso.d.ts +34 -0
  15. package/fontes/carregador-preguicoso.d.ts.map +1 -0
  16. package/fontes/carregador-preguicoso.js +157 -0
  17. package/fontes/carregador-preguicoso.js.map +1 -0
  18. package/fontes/colecao.d.ts +74 -0
  19. package/fontes/colecao.d.ts.map +1 -0
  20. package/fontes/colecao.js +374 -0
  21. package/fontes/colecao.js.map +1 -0
  22. package/fontes/construtor-consulta.d.ts +129 -0
  23. package/fontes/construtor-consulta.d.ts.map +1 -0
  24. package/fontes/construtor-consulta.js +446 -0
  25. package/fontes/construtor-consulta.js.map +1 -0
  26. package/fontes/contexto-entidades.d.ts +119 -0
  27. package/fontes/contexto-entidades.d.ts.map +1 -0
  28. package/fontes/contexto-entidades.js +329 -0
  29. package/fontes/contexto-entidades.js.map +1 -0
  30. package/fontes/detector-n-mais-um.d.ts +87 -0
  31. package/fontes/detector-n-mais-um.d.ts.map +1 -0
  32. package/fontes/detector-n-mais-um.js +225 -0
  33. package/fontes/detector-n-mais-um.js.map +1 -0
  34. package/fontes/entidade.d.ts +82 -0
  35. package/fontes/entidade.d.ts.map +1 -0
  36. package/fontes/entidade.js +467 -0
  37. package/fontes/entidade.js.map +1 -0
  38. package/fontes/erros/erro-concorrencia.d.ts +11 -0
  39. package/fontes/erros/erro-concorrencia.d.ts.map +1 -0
  40. package/fontes/erros/erro-concorrencia.js +18 -0
  41. package/fontes/erros/erro-concorrencia.js.map +1 -0
  42. package/fontes/erros/erro-tabela-nao-encontrada.d.ts +4 -0
  43. package/fontes/erros/erro-tabela-nao-encontrada.d.ts.map +1 -0
  44. package/fontes/erros/erro-tabela-nao-encontrada.js +11 -0
  45. package/fontes/erros/erro-tabela-nao-encontrada.js.map +1 -0
  46. package/fontes/erros/erro-validacao.d.ts +9 -0
  47. package/fontes/erros/erro-validacao.d.ts.map +1 -0
  48. package/fontes/erros/erro-validacao.js +13 -0
  49. package/fontes/erros/erro-validacao.js.map +1 -0
  50. package/fontes/erros/index.d.ts +4 -0
  51. package/fontes/erros/index.d.ts.map +1 -0
  52. package/fontes/erros/index.js +20 -0
  53. package/fontes/erros/index.js.map +1 -0
  54. package/fontes/gerenciador-cache.d.ts +87 -0
  55. package/fontes/gerenciador-cache.d.ts.map +1 -0
  56. package/fontes/gerenciador-cache.js +147 -0
  57. package/fontes/gerenciador-cache.js.map +1 -0
  58. package/fontes/ilc/gerador-definicoes.d.ts +13 -0
  59. package/fontes/ilc/gerador-definicoes.d.ts.map +1 -0
  60. package/fontes/ilc/gerador-definicoes.js +96 -0
  61. package/fontes/ilc/gerador-definicoes.js.map +1 -0
  62. package/fontes/ilc/gerador-entidades.d.ts +10 -0
  63. package/fontes/ilc/gerador-entidades.d.ts.map +1 -0
  64. package/fontes/ilc/gerador-entidades.js +318 -0
  65. package/fontes/ilc/gerador-entidades.js.map +1 -0
  66. package/fontes/ilc/leitor-configuracao.d.ts +32 -0
  67. package/fontes/ilc/leitor-configuracao.d.ts.map +1 -0
  68. package/fontes/ilc/leitor-configuracao.js +124 -0
  69. package/fontes/ilc/leitor-configuracao.js.map +1 -0
  70. package/fontes/ilc/migracoes.d.ts +3 -0
  71. package/fontes/ilc/migracoes.d.ts.map +1 -0
  72. package/fontes/ilc/migracoes.js +215 -0
  73. package/fontes/ilc/migracoes.js.map +1 -0
  74. package/fontes/ilc/semeadura.d.ts +2 -0
  75. package/fontes/ilc/semeadura.d.ts.map +1 -0
  76. package/fontes/ilc/semeadura.js +50 -0
  77. package/fontes/ilc/semeadura.js.map +1 -0
  78. package/fontes/indicadores-performance/executor-analise-performance.d.ts +80 -0
  79. package/fontes/indicadores-performance/executor-analise-performance.d.ts.map +1 -0
  80. package/fontes/indicadores-performance/executor-analise-performance.js +212 -0
  81. package/fontes/indicadores-performance/executor-analise-performance.js.map +1 -0
  82. package/fontes/indicadores-performance/index.d.ts +26 -0
  83. package/fontes/indicadores-performance/index.d.ts.map +1 -0
  84. package/fontes/indicadores-performance/index.js +199 -0
  85. package/fontes/indicadores-performance/index.js.map +1 -0
  86. package/fontes/interfaces-tipos/analise-n1-interface.d.ts +13 -0
  87. package/fontes/interfaces-tipos/analise-n1-interface.d.ts.map +1 -0
  88. package/fontes/interfaces-tipos/analise-n1-interface.js +3 -0
  89. package/fontes/interfaces-tipos/analise-n1-interface.js.map +1 -0
  90. package/fontes/interfaces-tipos/atributo-interface.d.ts +30 -0
  91. package/fontes/interfaces-tipos/atributo-interface.d.ts.map +1 -0
  92. package/fontes/interfaces-tipos/atributo-interface.js +3 -0
  93. package/fontes/interfaces-tipos/atributo-interface.js.map +1 -0
  94. package/fontes/interfaces-tipos/coluna-computada-interface.d.ts +16 -0
  95. package/fontes/interfaces-tipos/coluna-computada-interface.d.ts.map +1 -0
  96. package/fontes/interfaces-tipos/coluna-computada-interface.js +3 -0
  97. package/fontes/interfaces-tipos/coluna-computada-interface.js.map +1 -0
  98. package/fontes/interfaces-tipos/configuracao-banco-dados-interface.d.ts +48 -0
  99. package/fontes/interfaces-tipos/configuracao-banco-dados-interface.d.ts.map +1 -0
  100. package/fontes/interfaces-tipos/configuracao-banco-dados-interface.js +3 -0
  101. package/fontes/interfaces-tipos/configuracao-banco-dados-interface.js.map +1 -0
  102. package/fontes/interfaces-tipos/entidade-interface.d.ts +37 -0
  103. package/fontes/interfaces-tipos/entidade-interface.d.ts.map +1 -0
  104. package/fontes/interfaces-tipos/entidade-interface.js +3 -0
  105. package/fontes/interfaces-tipos/entidade-interface.js.map +1 -0
  106. package/fontes/interfaces-tipos/ganchos.d.ts +12 -0
  107. package/fontes/interfaces-tipos/ganchos.d.ts.map +1 -0
  108. package/fontes/interfaces-tipos/ganchos.js +3 -0
  109. package/fontes/interfaces-tipos/ganchos.js.map +1 -0
  110. package/fontes/interfaces-tipos/index.d.ts +17 -0
  111. package/fontes/interfaces-tipos/index.d.ts.map +1 -0
  112. package/fontes/interfaces-tipos/index.js +33 -0
  113. package/fontes/interfaces-tipos/index.js.map +1 -0
  114. package/fontes/interfaces-tipos/indice-interface.d.ts +16 -0
  115. package/fontes/interfaces-tipos/indice-interface.d.ts.map +1 -0
  116. package/fontes/interfaces-tipos/indice-interface.js +3 -0
  117. package/fontes/interfaces-tipos/indice-interface.js.map +1 -0
  118. package/fontes/interfaces-tipos/informacao-consulta-interface.d.ts +12 -0
  119. package/fontes/interfaces-tipos/informacao-consulta-interface.d.ts.map +1 -0
  120. package/fontes/interfaces-tipos/informacao-consulta-interface.js +3 -0
  121. package/fontes/interfaces-tipos/informacao-consulta-interface.js.map +1 -0
  122. package/fontes/interfaces-tipos/muito-para-muitos-interface.d.ts +33 -0
  123. package/fontes/interfaces-tipos/muito-para-muitos-interface.d.ts.map +1 -0
  124. package/fontes/interfaces-tipos/muito-para-muitos-interface.js +3 -0
  125. package/fontes/interfaces-tipos/muito-para-muitos-interface.js.map +1 -0
  126. package/fontes/interfaces-tipos/opcoes-serializacao-interface.d.ts +14 -0
  127. package/fontes/interfaces-tipos/opcoes-serializacao-interface.d.ts.map +1 -0
  128. package/fontes/interfaces-tipos/opcoes-serializacao-interface.js +3 -0
  129. package/fontes/interfaces-tipos/opcoes-serializacao-interface.js.map +1 -0
  130. package/fontes/interfaces-tipos/polimorfico-interface.d.ts +32 -0
  131. package/fontes/interfaces-tipos/polimorfico-interface.d.ts.map +1 -0
  132. package/fontes/interfaces-tipos/polimorfico-interface.js +3 -0
  133. package/fontes/interfaces-tipos/polimorfico-interface.js.map +1 -0
  134. package/fontes/interfaces-tipos/relacionamento-interface.d.ts +23 -0
  135. package/fontes/interfaces-tipos/relacionamento-interface.d.ts.map +1 -0
  136. package/fontes/interfaces-tipos/relacionamento-interface.js +3 -0
  137. package/fontes/interfaces-tipos/relacionamento-interface.js.map +1 -0
  138. package/fontes/interfaces-tipos/restricao-interface.d.ts +14 -0
  139. package/fontes/interfaces-tipos/restricao-interface.d.ts.map +1 -0
  140. package/fontes/interfaces-tipos/restricao-interface.js +3 -0
  141. package/fontes/interfaces-tipos/restricao-interface.js.map +1 -0
  142. package/fontes/interfaces-tipos/semente-interface.d.ts +7 -0
  143. package/fontes/interfaces-tipos/semente-interface.d.ts.map +1 -0
  144. package/fontes/interfaces-tipos/semente-interface.js +3 -0
  145. package/fontes/interfaces-tipos/semente-interface.js.map +1 -0
  146. package/fontes/interfaces-tipos/tabela-interface.d.ts +12 -0
  147. package/fontes/interfaces-tipos/tabela-interface.d.ts.map +1 -0
  148. package/fontes/interfaces-tipos/tabela-interface.js +3 -0
  149. package/fontes/interfaces-tipos/tabela-interface.js.map +1 -0
  150. package/fontes/interfaces-tipos/transacao-interface.d.ts +35 -0
  151. package/fontes/interfaces-tipos/transacao-interface.d.ts.map +1 -0
  152. package/fontes/interfaces-tipos/transacao-interface.js +3 -0
  153. package/fontes/interfaces-tipos/transacao-interface.js.map +1 -0
  154. package/fontes/migracoes/executor-migracoes.d.ts +14 -0
  155. package/fontes/migracoes/executor-migracoes.d.ts.map +1 -0
  156. package/fontes/migracoes/executor-migracoes.js +177 -0
  157. package/fontes/migracoes/executor-migracoes.js.map +1 -0
  158. package/fontes/migracoes/gerador-migracoes.d.ts +15 -0
  159. package/fontes/migracoes/gerador-migracoes.d.ts.map +1 -0
  160. package/fontes/migracoes/gerador-migracoes.js +108 -0
  161. package/fontes/migracoes/gerador-migracoes.js.map +1 -0
  162. package/fontes/migracoes/migracao.d.ts +35 -0
  163. package/fontes/migracoes/migracao.d.ts.map +1 -0
  164. package/fontes/migracoes/migracao.js +66 -0
  165. package/fontes/migracoes/migracao.js.map +1 -0
  166. package/fontes/migracoes/semeador.d.ts +18 -0
  167. package/fontes/migracoes/semeador.d.ts.map +1 -0
  168. package/fontes/migracoes/semeador.js +109 -0
  169. package/fontes/migracoes/semeador.js.map +1 -0
  170. package/fontes/rastreador-mudancas.d.ts +27 -0
  171. package/fontes/rastreador-mudancas.d.ts.map +1 -0
  172. package/fontes/rastreador-mudancas.js +94 -0
  173. package/fontes/rastreador-mudancas.js.map +1 -0
  174. package/fontes/relacionamento.d.ts +11 -0
  175. package/fontes/relacionamento.d.ts.map +1 -0
  176. package/fontes/relacionamento.js +15 -0
  177. package/fontes/relacionamento.js.map +1 -0
  178. package/fontes/roteador-bancos.d.ts +50 -0
  179. package/fontes/roteador-bancos.d.ts.map +1 -0
  180. package/fontes/roteador-bancos.js +90 -0
  181. package/fontes/roteador-bancos.js.map +1 -0
  182. package/fontes/serializador.d.ts +46 -0
  183. package/fontes/serializador.d.ts.map +1 -0
  184. package/fontes/serializador.js +79 -0
  185. package/fontes/serializador.js.map +1 -0
  186. package/fontes/taquigrafia.d.ts +41 -0
  187. package/fontes/taquigrafia.d.ts.map +1 -0
  188. package/fontes/taquigrafia.js +96 -0
  189. package/fontes/taquigrafia.js.map +1 -0
  190. package/fontes/tipos.d.ts +3 -0
  191. package/fontes/tipos.d.ts.map +1 -0
  192. package/fontes/tipos.js +3 -0
  193. package/fontes/tipos.js.map +1 -0
  194. package/fontes/transacao.d.ts +81 -0
  195. package/fontes/transacao.d.ts.map +1 -0
  196. package/fontes/transacao.js +243 -0
  197. package/fontes/transacao.js.map +1 -0
  198. package/fontes/validacoes/validador.d.ts +19 -0
  199. package/fontes/validacoes/validador.d.ts.map +1 -0
  200. package/fontes/validacoes/validador.js +157 -0
  201. package/fontes/validacoes/validador.js.map +1 -0
  202. package/index.d.ts +36 -0
  203. package/index.d.ts.map +1 -0
  204. package/index.js +59 -0
  205. package/index.js.map +1 -0
  206. package/package.json +55 -0
@@ -0,0 +1,329 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContextoEntidades = void 0;
4
+ const colecao_1 = require("./colecao");
5
+ const entidade_1 = require("./entidade");
6
+ const rastreador_mudancas_1 = require("./rastreador-mudancas");
7
+ const transacao_1 = require("./transacao");
8
+ const roteador_bancos_1 = require("./roteador-bancos");
9
+ const gerenciador_cache_1 = require("./gerenciador-cache");
10
+ /**
11
+ * O contexto de entidades é usado para manter todas as entidades e seus relacionamentos
12
+ * em um só lugar. Suporta múltiplos bancos de dados com roteamento automático.
13
+ * Também gerencia cache L1 (identity map) e L2 (cache persistente).
14
+ */
15
+ class ContextoEntidades {
16
+ constructor(tecnologia, logger, opcoesCacheL2) {
17
+ this.transacao = null;
18
+ this.tecnologia = tecnologia;
19
+ this.colecoes = {};
20
+ this.logger = logger;
21
+ this.rastreador = new rastreador_mudancas_1.RastreadorMudancas();
22
+ this.cache = new gerenciador_cache_1.GerenciadorCache(opcoesCacheL2);
23
+ // Inicializar roteador com o banco padrão
24
+ this.roteador = new roteador_bancos_1.RoteadorBancos();
25
+ this.roteador.registrarBanco('padrão', tecnologia, true);
26
+ }
27
+ registrarColecao(entidade) {
28
+ const nome = entidade.obterNome();
29
+ // Obter a tecnologia para o banco da entidade
30
+ const tecnologiaEntidade = this.roteador.obterTecnologiaParaEntidade(entidade);
31
+ const colecao = new colecao_1.Colecao(entidade, tecnologiaEntidade, this.logger);
32
+ this.colecoes[nome] = colecao;
33
+ return colecao;
34
+ }
35
+ colecao(tipoModelo) {
36
+ const nome = tipoModelo.simboloOriginal.lexema;
37
+ if (!this.colecoes[nome]) {
38
+ const entidade = new entidade_1.Entidade(tipoModelo);
39
+ this.registrarColecao(entidade);
40
+ }
41
+ return this.colecoes[nome];
42
+ }
43
+ novo(nomeEntidade, registro) {
44
+ this.rastreador.rastrear(registro, nomeEntidade, 'novo');
45
+ }
46
+ excluirRegistro(nomeEntidade, registro) {
47
+ const estado = this.rastreador.obterEstado(registro);
48
+ if (estado === null) {
49
+ this.rastreador.rastrear(registro, nomeEntidade, 'excluido');
50
+ }
51
+ else {
52
+ this.rastreador.marcarExcluido(registro);
53
+ }
54
+ }
55
+ async buscarTodos(nomeEntidade) {
56
+ const col = this.colecoes[nomeEntidade];
57
+ if (!col) {
58
+ throw new Error(`Coleção '${nomeEntidade}' não registrada.`);
59
+ }
60
+ const registros = await col.buscarTodos();
61
+ for (const registro of registros) {
62
+ this.rastreador.rastrear(registro, nomeEntidade, 'inalterado');
63
+ }
64
+ return registros;
65
+ }
66
+ async buscarPorId(nomeEntidade, valorId) {
67
+ const col = this.colecoes[nomeEntidade];
68
+ if (!col) {
69
+ throw new Error(`Coleção '${nomeEntidade}' não registrada.`);
70
+ }
71
+ const registro = await col.buscarPorId(valorId);
72
+ if (registro) {
73
+ this.rastreador.rastrear(registro, nomeEntidade, 'inalterado');
74
+ }
75
+ return registro;
76
+ }
77
+ async salvarMudancas() {
78
+ this.rastreador.detectarMudancas();
79
+ const alterados = this.rastreador.obterAlterados();
80
+ for (const rastreado of alterados) {
81
+ const col = this.colecoes[rastreado.nomeEntidade];
82
+ if (!col) {
83
+ throw new Error(`Coleção '${rastreado.nomeEntidade}' não registrada.`);
84
+ }
85
+ switch (rastreado.estado) {
86
+ case 'novo':
87
+ await col.salvar(rastreado.registro);
88
+ // Processar cascata de inserção
89
+ await this.processarCascataInserir(rastreado.nomeEntidade, rastreado.registro);
90
+ break;
91
+ case 'modificado':
92
+ await col.modificar(rastreado.registro, rastreado.camposAlterados);
93
+ // Processar cascata de atualização
94
+ await this.processarCascataAtualizar(rastreado.nomeEntidade, rastreado.registro);
95
+ break;
96
+ case 'excluido':
97
+ // Processar cascata de exclusão antes de remover
98
+ await this.processarCascataExcluir(rastreado.nomeEntidade, rastreado.registro);
99
+ await col.remover(rastreado.registro);
100
+ break;
101
+ }
102
+ }
103
+ this.rastreador.limpar();
104
+ }
105
+ /**
106
+ * Processa cascata de inserção para relacionamentos.
107
+ */
108
+ async processarCascataInserir(nomeEntidade, registro) {
109
+ const col = this.colecoes[nomeEntidade];
110
+ if (!col)
111
+ return;
112
+ const relacionamentos = col.tipoEntidade.obterRelacionamentos();
113
+ for (const rel of relacionamentos) {
114
+ if (!rel.cascata || !rel.cascata.includes('inserir'))
115
+ continue;
116
+ const filhos = registro.propriedades[rel.nomePropriedade];
117
+ if (!filhos)
118
+ continue;
119
+ const colFilha = this.colecoes[rel.entidadeDestino];
120
+ if (!colFilha)
121
+ continue;
122
+ const listaFilhos = Array.isArray(filhos) ? filhos : [filhos];
123
+ for (const filho of listaFilhos) {
124
+ if (filho && typeof filho === 'object') {
125
+ // Definir a chave estrangeira no filho
126
+ if (filho.propriedades) {
127
+ // É um ObjetoDeleguaClasse
128
+ filho.propriedades[rel.colunaDestino] = registro.propriedades[rel.colunaOrigem];
129
+ }
130
+ else {
131
+ // É um objeto plain
132
+ filho[rel.colunaDestino] = registro.propriedades[rel.colunaOrigem];
133
+ }
134
+ // Salvar o filho
135
+ await colFilha.salvar(filho);
136
+ }
137
+ }
138
+ }
139
+ }
140
+ /**
141
+ * Processa cascata de atualização para relacionamentos.
142
+ */
143
+ async processarCascataAtualizar(nomeEntidade, registro) {
144
+ const col = this.colecoes[nomeEntidade];
145
+ if (!col)
146
+ return;
147
+ const relacionamentos = col.tipoEntidade.obterRelacionamentos();
148
+ for (const rel of relacionamentos) {
149
+ if (!rel.cascata || !rel.cascata.includes('atualizar'))
150
+ continue;
151
+ const filhos = registro.propriedades[rel.nomePropriedade];
152
+ if (!filhos)
153
+ continue;
154
+ const colFilha = this.colecoes[rel.entidadeDestino];
155
+ if (!colFilha)
156
+ continue;
157
+ const listaFilhos = Array.isArray(filhos) ? filhos : [filhos];
158
+ for (const filho of listaFilhos) {
159
+ if (filho && typeof filho === 'object') {
160
+ const filhoId = filho.propriedades ? filho.propriedades.id : filho.id;
161
+ if (filhoId) {
162
+ // Atualizar o filho
163
+ await colFilha.modificar(filho);
164
+ }
165
+ }
166
+ }
167
+ }
168
+ }
169
+ /**
170
+ * Processa cascata de exclusão para relacionamentos.
171
+ */
172
+ async processarCascataExcluir(nomeEntidade, registro) {
173
+ const col = this.colecoes[nomeEntidade];
174
+ if (!col)
175
+ return;
176
+ const relacionamentos = col.tipoEntidade.obterRelacionamentos();
177
+ for (const rel of relacionamentos) {
178
+ if (!rel.cascata || !rel.cascata.includes('excluir'))
179
+ continue;
180
+ const colFilha = this.colecoes[rel.entidadeDestino];
181
+ if (!colFilha)
182
+ continue;
183
+ // Verificar se os filhos estão carregados
184
+ const filhos = registro.propriedades[rel.nomePropriedade];
185
+ if (filhos) {
186
+ // Filhos estão carregados, excluí-los diretamente
187
+ const listaFilhos = Array.isArray(filhos) ? filhos : [filhos];
188
+ for (const filho of listaFilhos) {
189
+ if (filho && typeof filho === 'object') {
190
+ await colFilha.remover(filho);
191
+ }
192
+ }
193
+ }
194
+ else {
195
+ // Filhos não estão carregados, executar DELETE WHERE
196
+ const valorId = registro.propriedades[rel.colunaOrigem];
197
+ if (valorId !== undefined && valorId !== null) {
198
+ const sql = `DELETE FROM ${rel.entidadeDestino} WHERE ${rel.colunaDestino} = ${typeof valorId === 'string' ? `'${valorId}'` : valorId}`;
199
+ await this.tecnologia.executar(null, sql, []);
200
+ }
201
+ }
202
+ }
203
+ }
204
+ async iniciar(caminho) {
205
+ await this.tecnologia.iniciar(caminho);
206
+ for (const nome in this.colecoes) {
207
+ const criar = this.colecoes[nome].tipoEntidade.gerarComandoCriarTabela();
208
+ await this.tecnologia.executarComando(criar);
209
+ }
210
+ }
211
+ /**
212
+ * Inicia uma nova transação.
213
+ * Retorna a transação criada.
214
+ */
215
+ iniciarTransacao() {
216
+ if (this.transacao && this.transacao.estaAtiva()) {
217
+ throw new Error('Já existe uma transação ativa neste contexto');
218
+ }
219
+ this.transacao = new transacao_1.Transacao(this.tecnologia);
220
+ this.logger?.info('Transação iniciada');
221
+ return this.transacao;
222
+ }
223
+ /**
224
+ * Obtém a transação atual, se houver.
225
+ */
226
+ obterTransacao() {
227
+ return this.transacao;
228
+ }
229
+ /**
230
+ * Indica se existe uma transação ativa.
231
+ */
232
+ possuiTransacao() {
233
+ return this.transacao !== null && this.transacao.estaAtiva();
234
+ }
235
+ /**
236
+ * Confirma a transação atual.
237
+ */
238
+ async confirmarTransacao() {
239
+ if (!this.transacao) {
240
+ throw new Error('Nenhuma transação ativa');
241
+ }
242
+ await this.transacao.confirmar();
243
+ this.logger?.info('Transação confirmada');
244
+ this.transacao = null;
245
+ }
246
+ /**
247
+ * Reverte a transação atual.
248
+ */
249
+ async reverterTransacao() {
250
+ if (!this.transacao) {
251
+ throw new Error('Nenhuma transação ativa');
252
+ }
253
+ await this.transacao.reverter();
254
+ this.logger?.info('Transação revertida');
255
+ this.transacao = null;
256
+ }
257
+ /**
258
+ * Registra um novo banco de dados.
259
+ */
260
+ registrarBanco(nome, tecnologia, ehPadrao = false) {
261
+ this.roteador.registrarBanco(nome, tecnologia, ehPadrao);
262
+ if (ehPadrao) {
263
+ this.tecnologia = tecnologia;
264
+ }
265
+ }
266
+ /**
267
+ * Registra múltiplos bancos a partir de configurações.
268
+ */
269
+ registrarBancos(configuracoes, tecnologias) {
270
+ this.roteador.registrarBancos(configuracoes, tecnologias);
271
+ }
272
+ /**
273
+ * Obtém a tecnologia para um banco específico.
274
+ */
275
+ obterTecnologia(nomeBanco = 'padrão') {
276
+ return this.roteador.obterTecnologia(nomeBanco);
277
+ }
278
+ /**
279
+ * Obtém a tecnologia padrão.
280
+ */
281
+ obterTecnologiaPadrao() {
282
+ return this.roteador.obterTecnologiaPadrao();
283
+ }
284
+ /**
285
+ * Obtém o roteador de bancos para acesso avançado.
286
+ */
287
+ obterRoteador() {
288
+ return this.roteador;
289
+ }
290
+ // --- Métodos de Cache ---
291
+ /**
292
+ * Obtém um registro do cache.
293
+ */
294
+ obterDoCache(nomeEntidade, id) {
295
+ return this.cache.obterNivel1(nomeEntidade, id);
296
+ }
297
+ /**
298
+ * Armazena um registro no cache.
299
+ */
300
+ armazenarenCache(nomeEntidade, id, registro) {
301
+ this.cache.armazenarNivel1(nomeEntidade, id, registro);
302
+ }
303
+ /**
304
+ * Remove um registro do cache.
305
+ */
306
+ removerDoCache(nomeEntidade, id) {
307
+ this.cache.remover(nomeEntidade, id);
308
+ }
309
+ /**
310
+ * Limpa o cache de uma entidade.
311
+ */
312
+ limparCacheEntidade(nomeEntidade) {
313
+ this.cache.limparEntidade(nomeEntidade);
314
+ }
315
+ /**
316
+ * Limpa todo o cache.
317
+ */
318
+ limparCacheTudo() {
319
+ this.cache.limparTudo();
320
+ }
321
+ /**
322
+ * Obtém estatísticas do cache.
323
+ */
324
+ obterEstatisticasCache() {
325
+ return this.cache.obterEstatisticas();
326
+ }
327
+ }
328
+ exports.ContextoEntidades = ContextoEntidades;
329
+ //# sourceMappingURL=contexto-entidades.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contexto-entidades.js","sourceRoot":"","sources":["../../fontes/contexto-entidades.ts"],"names":[],"mappings":";;;AAGA,uCAAoC;AACpC,yCAAsC;AAGtC,+DAA2D;AAC3D,2CAAwC;AAExC,uDAAmD;AAEnD,2DAAsE;AAEtE;;;;GAIG;AACH,MAAa,iBAAiB;IAS1B,YAAY,UAAuC,EAAE,MAAmB,EAAE,aAA6B;QAJ/F,cAAS,GAAqB,IAAI,CAAC;QAKvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,wCAAkB,EAAE,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,IAAI,oCAAgB,CAAC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,EAAE,EAAE,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,YAAoB,EAAE,EAAO,EAAE,QAA6B;QACzE,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,YAAY,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,YAAoB,EAAE,EAAO;QACxC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,mBAAmB,CAAC,YAAqB;QACrC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,eAAe;QACX,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,sBAAsB;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAC1C,CAAC;CACJ;AA1WD,8CA0WC"}
@@ -0,0 +1,87 @@
1
+ import { InformacaoConsulta } from "./interfaces-tipos";
2
+ import { AnaliseN1 } from "./interfaces-tipos/analise-n1-interface";
3
+ /**
4
+ * Detector de padrão N+1 em queries. Monitora consultas executadas
5
+ * e identifica quando um único resultado desencadeia N consultas adicionais.
6
+ *
7
+ * Padrão N+1:
8
+ * 1. consulta principal retorna N registros
9
+ * 2. Seguida imediatamente por N consultas idênticas ou similares
10
+ * 3. Geralmente ocorre ao carregar relacionamentos sem eager loading
11
+ *
12
+ * Exemplo:
13
+ * ```
14
+ * // 1 query
15
+ * const usuarios = await colecao.todos(); // Retorna 100 usuários
16
+ *
17
+ * // 100 consultas (1 por usuário)
18
+ * for (const usuario of usuarios) {
19
+ * const pedidos = await usuario.pedidos.todos(); // N+1!
20
+ * }
21
+ * ```
22
+ *
23
+ * Solução: Usar eager loading
24
+ * ```
25
+ * const usuarios = await colecao.consulta()
26
+ * .incluirRelacionados('pedidos')
27
+ * .todos(); // 1 ou 2 consultas apenas
28
+ * ```
29
+ */
30
+ export declare class DetectorConsultasN1 {
31
+ private consultas;
32
+ private limiteJanela;
33
+ private limiarN1;
34
+ /**
35
+ * Registra uma consulta executada.
36
+ */
37
+ registrarConsulta(sql: string, quantidadeRegistros: number, tempoExecucao?: number, nomeEntidade?: string): void;
38
+ /**
39
+ * Analisa as consultas recentes procurando por padrão N+1.
40
+ */
41
+ analisar(): AnaliseN1;
42
+ /**
43
+ * Verifica se duas consultas são similares (mesmo padrão).
44
+ * Para N+1, duas consultas são similares se vêm da mesma tabela.
45
+ */
46
+ private saoConsultasSimilares;
47
+ /**
48
+ * Extrai o nome da tabela principal de uma consulta SQL.
49
+ */
50
+ private extrairTabela;
51
+ /**
52
+ * Normaliza SQL para comparação.
53
+ */
54
+ private normalizarSQL;
55
+ /**
56
+ * Retorna todas as consultas registradas.
57
+ */
58
+ obterConsultas(): InformacaoConsulta[];
59
+ /**
60
+ * Retorna as últimas N consultas.
61
+ */
62
+ obterUltimasConsultas(quantidade?: number): InformacaoConsulta[];
63
+ /**
64
+ * Retorna estatísticas de consultas.
65
+ */
66
+ obterEstatisticas(): {
67
+ totalConsultas: number;
68
+ tempoTotalMs: number;
69
+ tempoMedioMs: number;
70
+ totalRegistros: number;
71
+ };
72
+ /**
73
+ * Limpa o histórico de consultas.
74
+ */
75
+ limpar(): void;
76
+ /**
77
+ * Define o limiar para considerar padrão N+1.
78
+ * Padrão mínimo: se houver pelo menos N consultas similares.
79
+ */
80
+ definirLimiar(limiar: number): void;
81
+ /**
82
+ * Define o tamanho máximo da janela de monitoramento.
83
+ */
84
+ definirLimiteJanela(limite: number): void;
85
+ }
86
+ export type { InformacaoConsulta, AnaliseN1 };
87
+ //# sourceMappingURL=detector-n-mais-um.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detector-n-mais-um.d.ts","sourceRoot":"","sources":["../../fontes/detector-n-mais-um.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAa;IAE7B;;OAEG;IACH,iBAAiB,CACb,GAAG,EAAE,MAAM,EACX,mBAAmB,EAAE,MAAM,EAC3B,aAAa,GAAE,MAAU,EACzB,YAAY,CAAC,EAAE,MAAM,GACtB,IAAI;IAkBP;;OAEG;IACH,QAAQ,IAAI,SAAS;IA2GrB;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAS7B;;OAEG;IACH,OAAO,CAAC,aAAa;IAYrB;;OAEG;IACH,OAAO,CAAC,aAAa;IAOrB;;OAEG;IACH,cAAc,IAAI,kBAAkB,EAAE;IAItC;;OAEG;IACH,qBAAqB,CAAC,UAAU,GAAE,MAAW,GAAG,kBAAkB,EAAE;IAIpE;;OAEG;IACH,iBAAiB,IAAI;QACjB,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,EAAE,MAAM,CAAC;KAC1B;IAaD;;OAEG;IACH,MAAM,IAAI,IAAI;IAId;;;OAGG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAInC;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAG5C;AAED,YAAY,EAAE,kBAAkB,EAAE,SAAS,EAAE,CAAC"}
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DetectorConsultasN1 = void 0;
4
+ /**
5
+ * Detector de padrão N+1 em queries. Monitora consultas executadas
6
+ * e identifica quando um único resultado desencadeia N consultas adicionais.
7
+ *
8
+ * Padrão N+1:
9
+ * 1. consulta principal retorna N registros
10
+ * 2. Seguida imediatamente por N consultas idênticas ou similares
11
+ * 3. Geralmente ocorre ao carregar relacionamentos sem eager loading
12
+ *
13
+ * Exemplo:
14
+ * ```
15
+ * // 1 query
16
+ * const usuarios = await colecao.todos(); // Retorna 100 usuários
17
+ *
18
+ * // 100 consultas (1 por usuário)
19
+ * for (const usuario of usuarios) {
20
+ * const pedidos = await usuario.pedidos.todos(); // N+1!
21
+ * }
22
+ * ```
23
+ *
24
+ * Solução: Usar eager loading
25
+ * ```
26
+ * const usuarios = await colecao.consulta()
27
+ * .incluirRelacionados('pedidos')
28
+ * .todos(); // 1 ou 2 consultas apenas
29
+ * ```
30
+ */
31
+ class DetectorConsultasN1 {
32
+ constructor() {
33
+ this.consultas = [];
34
+ this.limiteJanela = 500; // Número de consultas a manter em memória
35
+ this.limiarN1 = 2; // Mínimo de consultas similares para considerar N+1
36
+ }
37
+ /**
38
+ * Registra uma consulta executada.
39
+ */
40
+ registrarConsulta(sql, quantidadeRegistros, tempoExecucao = 0, nomeEntidade) {
41
+ const informacao = {
42
+ sql: this.normalizarSQL(sql),
43
+ linhaExecucao: new Error(),
44
+ carimboTempo: new Date(),
45
+ tempoExecucao,
46
+ quantidadeRegistros,
47
+ nomeEntidade
48
+ };
49
+ this.consultas.push(informacao);
50
+ // Manter apenas as últimas N queries
51
+ if (this.consultas.length > this.limiteJanela) {
52
+ this.consultas.shift();
53
+ }
54
+ }
55
+ /**
56
+ * Analisa as consultas recentes procurando por padrão N+1.
57
+ */
58
+ analisar() {
59
+ if (this.consultas.length < 2) {
60
+ return { detectado: false };
61
+ }
62
+ // Analisar último conjunto de consultas (último 100)
63
+ const ultimasConsultas = this.consultas.slice(-100);
64
+ // Variáveis para rastrear as melhores análises de cada tipo
65
+ let melhorAnaliseSameTable = null;
66
+ let melhorRazaoSameTable = 0;
67
+ let melhorAnaliseCrossTable = null;
68
+ let melhorRazaoCrossTable = 0;
69
+ for (let i = 0; i < ultimasConsultas.length - 1; i++) {
70
+ const consultaAtual = ultimasConsultas[i];
71
+ // Se a consulta atual retornou múltiplos registros
72
+ if (consultaAtual.quantidadeRegistros >= 2) {
73
+ // Estratégia 1: Procurar por consultas similares (mesmo SELECT pattern, mesma tabela)
74
+ const consultasSimilares = ultimasConsultas.slice(i + 1).filter(q => this.saoConsultasSimilares(consultaAtual.sql, q.sql));
75
+ // Se encontrada quantidade significativa de consultas similares
76
+ if (consultasSimilares.length >= this.limiarN1) {
77
+ const razaoN1 = consultasSimilares.length / consultaAtual.quantidadeRegistros;
78
+ if (razaoN1 > melhorRazaoSameTable) {
79
+ melhorRazaoSameTable = razaoN1;
80
+ melhorAnaliseSameTable = {
81
+ detectado: true,
82
+ consultaPrincipal: consultaAtual,
83
+ consultasRelacionadas: consultasSimilares.slice(0, Math.min(consultasSimilares.length, 20)),
84
+ quantidadeRegistros: consultaAtual.quantidadeRegistros,
85
+ quantidadeConsultas: 1 + consultasSimilares.length,
86
+ sugestao: `Detectado padrão N+1: 1 consulta retornou ${consultaAtual.quantidadeRegistros} registros, ` +
87
+ `seguida por ${consultasSimilares.length} consultas similares. ` +
88
+ `Use incluirRelacionados() para carregamento antecipado (eager loading).`
89
+ };
90
+ }
91
+ }
92
+ // Estratégia 2: Procurar por padrão N+1 cross-table
93
+ // Uma consulta retorna N registros, seguida por ~N consultas de tabela diferente
94
+ const proximasConsultas = ultimasConsultas.slice(i + 1);
95
+ const tabelaAtual = this.extrairTabela(consultaAtual.sql);
96
+ if (proximasConsultas.length >= 2 && tabelaAtual) {
97
+ // Coletar as próximas consultas de uma tabela diferente
98
+ const clusterQueries = [];
99
+ const tabelasPrincipais = new Map();
100
+ for (const proximaQuery of proximasConsultas) {
101
+ const tabelaProxima = this.extrairTabela(proximaQuery.sql);
102
+ // Se for de tabela diferente, pode ser N+1 cross-table
103
+ if (tabelaProxima && tabelaProxima !== tabelaAtual) {
104
+ clusterQueries.push(proximaQuery);
105
+ tabelasPrincipais.set(tabelaProxima, (tabelasPrincipais.get(tabelaProxima) || 0) + 1);
106
+ }
107
+ else if (tabelaProxima === tabelaAtual) {
108
+ // Se voltar para a mesma tabela original, para aqui
109
+ break;
110
+ }
111
+ }
112
+ // Se encontrou um cluster de consultas de uma única tabela diferente
113
+ // com tamanho próximo a N (entre 70% e 120% de N)
114
+ if (clusterQueries.length >= consultaAtual.quantidadeRegistros * 0.7 &&
115
+ clusterQueries.length <= consultaAtual.quantidadeRegistros * 1.2 &&
116
+ tabelasPrincipais.size === 1) {
117
+ const razaoN1Cross = clusterQueries.length / consultaAtual.quantidadeRegistros;
118
+ if (razaoN1Cross > melhorRazaoCrossTable) {
119
+ melhorRazaoCrossTable = razaoN1Cross;
120
+ melhorAnaliseCrossTable = {
121
+ detectado: true,
122
+ consultaPrincipal: consultaAtual,
123
+ consultasRelacionadas: clusterQueries.slice(0, Math.min(clusterQueries.length, 20)),
124
+ quantidadeRegistros: consultaAtual.quantidadeRegistros,
125
+ quantidadeConsultas: 1 + clusterQueries.length,
126
+ sugestao: `Detectado padrão N+1 (cross-table): 1 consulta retornou ${consultaAtual.quantidadeRegistros} registros, ` +
127
+ `seguida por ${clusterQueries.length} consultas de tabela relacionada. ` +
128
+ `Use incluirRelacionados() para carregamento antecipado (eager loading).`
129
+ };
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
135
+ // Retornar a melhor análise, preferindo cross-table quando existe
136
+ // Cross-table com ratio >= 0.7 é considerado válido (70% dos N registros foram obtidos em N queries)
137
+ if (melhorAnaliseCrossTable && melhorRazaoCrossTable >= 0.7) {
138
+ return melhorAnaliseCrossTable;
139
+ }
140
+ // Caso contrário, retornar same-table se encontrado
141
+ if (melhorAnaliseSameTable) {
142
+ return melhorAnaliseSameTable;
143
+ }
144
+ return { detectado: false };
145
+ }
146
+ /**
147
+ * Verifica se duas consultas são similares (mesmo padrão).
148
+ * Para N+1, duas consultas são similares se vêm da mesma tabela.
149
+ */
150
+ saoConsultasSimilares(sql1, sql2) {
151
+ // Extrair tabela principal de cada consulta
152
+ const tabela1 = this.extrairTabela(sql1);
153
+ const tabela2 = this.extrairTabela(sql2);
154
+ // Se ambas consultam a mesma tabela, são potencialmente similares
155
+ return tabela1 !== null && tabela1 === tabela2;
156
+ }
157
+ /**
158
+ * Extrai o nome da tabela principal de uma consulta SQL.
159
+ */
160
+ extrairTabela(sql) {
161
+ const sqlLower = sql.toLowerCase();
162
+ // Procurar por "FROM tabela"
163
+ const match = sqlLower.match(/from\s+([a-z_][a-z0-9_]*)/i);
164
+ if (match && match[1]) {
165
+ return match[1].toLowerCase();
166
+ }
167
+ return null;
168
+ }
169
+ /**
170
+ * Normaliza SQL para comparação.
171
+ */
172
+ normalizarSQL(sql) {
173
+ return sql
174
+ .replace(/\s+/g, ' ')
175
+ .trim()
176
+ .toUpperCase();
177
+ }
178
+ /**
179
+ * Retorna todas as consultas registradas.
180
+ */
181
+ obterConsultas() {
182
+ return [...this.consultas];
183
+ }
184
+ /**
185
+ * Retorna as últimas N consultas.
186
+ */
187
+ obterUltimasConsultas(quantidade = 10) {
188
+ return this.consultas.slice(-quantidade);
189
+ }
190
+ /**
191
+ * Retorna estatísticas de consultas.
192
+ */
193
+ obterEstatisticas() {
194
+ const totalConsultas = this.consultas.length;
195
+ const tempoTotal = this.consultas.reduce((sum, q) => sum + q.tempoExecucao, 0);
196
+ const totalRegistros = this.consultas.reduce((sum, q) => sum + q.quantidadeRegistros, 0);
197
+ return {
198
+ totalConsultas,
199
+ tempoTotalMs: tempoTotal,
200
+ tempoMedioMs: totalConsultas > 0 ? tempoTotal / totalConsultas : 0,
201
+ totalRegistros
202
+ };
203
+ }
204
+ /**
205
+ * Limpa o histórico de consultas.
206
+ */
207
+ limpar() {
208
+ this.consultas = [];
209
+ }
210
+ /**
211
+ * Define o limiar para considerar padrão N+1.
212
+ * Padrão mínimo: se houver pelo menos N consultas similares.
213
+ */
214
+ definirLimiar(limiar) {
215
+ this.limiarN1 = Math.max(1, limiar);
216
+ }
217
+ /**
218
+ * Define o tamanho máximo da janela de monitoramento.
219
+ */
220
+ definirLimiteJanela(limite) {
221
+ this.limiteJanela = Math.max(10, limite);
222
+ }
223
+ }
224
+ exports.DetectorConsultasN1 = DetectorConsultasN1;
225
+ //# sourceMappingURL=detector-n-mais-um.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detector-n-mais-um.js","sourceRoot":"","sources":["../../fontes/detector-n-mais-um.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,mBAAmB;IAAhC;QACY,cAAS,GAAyB,EAAE,CAAC;QACrC,iBAAY,GAAW,GAAG,CAAC,CAAC,0CAA0C;QACtE,aAAQ,GAAW,CAAC,CAAC,CAAC,oDAAoD;IAwOtF,CAAC;IAtOG;;OAEG;IACH,iBAAiB,CACb,GAAW,EACX,mBAA2B,EAC3B,gBAAwB,CAAC,EACzB,YAAqB;QAErB,MAAM,UAAU,GAAuB;YACnC,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;YAC5B,aAAa,EAAE,IAAI,KAAK,EAAE;YAC1B,YAAY,EAAE,IAAI,IAAI,EAAE;YACxB,aAAa;YACb,mBAAmB;YACnB,YAAY;SACf,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEhC,qCAAqC;QACrC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAC5C,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAC3B,CAAC;IACL,CAAC;IAED;;OAEG;IACH,QAAQ;QACJ,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QAChC,CAAC;QAED,qDAAqD;QACrD,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,KAA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