@semacode/cli 1.5.29 → 1.5.31
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.
- package/dist/comandos.js +69 -0
- package/dist/comandos.js.map +1 -1
- package/dist/dev/index.d.ts +18 -0
- package/dist/dev/index.js +143 -0
- package/dist/dev/index.js.map +1 -0
- package/dist/guard.d.ts +35 -0
- package/dist/guard.js +164 -0
- package/dist/guard.js.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/init/index.d.ts +23 -0
- package/dist/init/index.js +112 -0
- package/dist/init/index.js.map +1 -0
- package/dist/init/templates.d.ts +11 -0
- package/dist/init/templates.js +660 -0
- package/dist/init/templates.js.map +1 -0
- package/dist/sync/index.d.ts +24 -0
- package/dist/sync/index.js +174 -0
- package/dist/sync/index.js.map +1 -0
- package/exemplos/.prepack-generated +1 -0
- package/node_modules/@sema/gerador-css/package.json +14 -7
- package/node_modules/@sema/gerador-css/src/index.ts +605 -0
- package/node_modules/@sema/gerador-css/tsconfig.json +13 -0
- package/node_modules/@sema/gerador-css/tsconfig.tsbuildinfo +1 -0
- package/node_modules/@sema/gerador-dart/package.json +14 -7
- package/node_modules/@sema/gerador-dart/src/index.ts +52 -0
- package/node_modules/@sema/gerador-dart/tsconfig.json +13 -0
- package/node_modules/@sema/gerador-dart/tsconfig.tsbuildinfo +1 -0
- package/node_modules/@sema/gerador-html/package.json +14 -7
- package/node_modules/@sema/gerador-html/src/index.ts +185 -0
- package/node_modules/@sema/gerador-html/tsconfig.json +13 -0
- package/node_modules/@sema/gerador-html/tsconfig.tsbuildinfo +1 -0
- package/node_modules/@sema/gerador-javascript/package.json +14 -7
- package/node_modules/@sema/gerador-javascript/src/index.ts +461 -0
- package/node_modules/@sema/gerador-javascript/tsconfig.json +13 -0
- package/node_modules/@sema/gerador-javascript/tsconfig.tsbuildinfo +1 -0
- package/node_modules/@sema/gerador-lua/package.json +14 -7
- package/node_modules/@sema/gerador-lua/src/index.ts +359 -0
- package/node_modules/@sema/gerador-lua/tsconfig.json +13 -0
- package/node_modules/@sema/gerador-lua/tsconfig.tsbuildinfo +1 -0
- package/node_modules/@sema/gerador-python/package.json +14 -7
- package/node_modules/@sema/gerador-python/src/index.ts +850 -0
- package/node_modules/@sema/gerador-python/tsconfig.json +13 -0
- package/node_modules/@sema/gerador-python/tsconfig.tsbuildinfo +1 -0
- package/node_modules/@sema/gerador-typescript/package.json +14 -7
- package/node_modules/@sema/gerador-typescript/src/index.ts +876 -0
- package/node_modules/@sema/gerador-typescript/tsconfig.json +13 -0
- package/node_modules/@sema/gerador-typescript/tsconfig.tsbuildinfo +1 -0
- package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.d.ts +22 -0
- package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js +97 -0
- package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/index.d.ts +1 -0
- package/node_modules/@sema/nucleo/dist/index.js +1 -0
- package/node_modules/@sema/nucleo/dist/index.js.map +1 -1
- package/node_modules/@sema/nucleo/package.json +10 -7
- package/node_modules/@sema/nucleo/src/ast/tipos.ts +207 -0
- package/node_modules/@sema/nucleo/src/diagnosticos/index.ts +43 -0
- package/node_modules/@sema/nucleo/src/diagnosticos/melhorador.ts +130 -0
- package/node_modules/@sema/nucleo/src/formatador/index.ts +530 -0
- package/node_modules/@sema/nucleo/src/index.ts +184 -0
- package/node_modules/@sema/nucleo/src/ir/conversor.ts +1037 -0
- package/node_modules/@sema/nucleo/src/ir/modelos.ts +403 -0
- package/node_modules/@sema/nucleo/src/lexer/lexer.ts +166 -0
- package/node_modules/@sema/nucleo/src/lexer/tokens.ts +79 -0
- package/node_modules/@sema/nucleo/src/parser/gramatica.ebnf +41 -0
- package/node_modules/@sema/nucleo/src/parser/parser.ts +936 -0
- package/node_modules/@sema/nucleo/src/persistencia/contratos.ts +379 -0
- package/node_modules/@sema/nucleo/src/semantico/analisador.ts +3126 -0
- package/node_modules/@sema/nucleo/src/semantico/estruturas.ts +665 -0
- package/node_modules/@sema/nucleo/src/semantico/seguranca.ts +362 -0
- package/node_modules/@sema/nucleo/src/util/arquivos.ts +28 -0
- package/node_modules/@sema/nucleo/tsconfig.json +9 -0
- package/node_modules/@sema/nucleo/tsconfig.tsbuildinfo +1 -0
- package/node_modules/@sema/padroes/package.json +10 -7
- package/node_modules/@sema/padroes/src/index.ts +382 -0
- package/node_modules/@sema/padroes/tsconfig.json +9 -0
- package/node_modules/@sema/padroes/tsconfig.tsbuildinfo +1 -0
- package/package.json +74 -75
- package/AGENTS.md +0 -294
- package/AGENT_CONTEXT_PACK.json +0 -164
- package/LICENSE +0 -22
- package/SEMA_BRIEF.curto.txt +0 -11
- package/SEMA_BRIEF.md +0 -511
- package/SEMA_BRIEF.micro.txt +0 -9
- package/SEMA_INDEX.json +0 -7588
- package/docs/AGENT_STARTER.md +0 -109
- package/docs/api.md +0 -82
- package/docs/cli.md +0 -175
- package/docs/como-ensinar-a-sema-para-ia.md +0 -155
- package/docs/deploy.md +0 -93
- package/docs/documentacao.md +0 -88
- package/docs/env.md +0 -105
- package/docs/extensao-vscode.md +0 -53
- package/docs/fluxo-pratico-ia-sema.md +0 -187
- package/docs/instalacao-e-primeiro-uso.md +0 -134
- package/docs/integracao-com-ia.md +0 -110
- package/docs/mcp.md +0 -292
- package/docs/pagamento-ponta-a-ponta.md +0 -171
- package/docs/persistencia-vendor-first.md +0 -151
- package/docs/prompt-base-ia-sema.md +0 -111
- package/docs/repositories.md +0 -54
- package/docs/rollback.md +0 -49
- package/docs/seguranca.md +0 -126
- package/docs/sintaxe.md +0 -218
- package/llms-full.txt +0 -35
- package/llms.txt +0 -18
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import type { Diagnostico } from "../diagnosticos/index.js";
|
|
2
|
+
import type {
|
|
3
|
+
ContratoErroRouteSemantico,
|
|
4
|
+
EfeitoSemantico,
|
|
5
|
+
EtapaFlowSemantica,
|
|
6
|
+
ExpressaoSemantica,
|
|
7
|
+
TransicaoEstadoSemantica,
|
|
8
|
+
} from "../semantico/estruturas.js";
|
|
9
|
+
import type {
|
|
10
|
+
CompatibilidadePersistencia,
|
|
11
|
+
ConsistenciaPersistencia,
|
|
12
|
+
DurabilidadePersistencia,
|
|
13
|
+
EngineBanco,
|
|
14
|
+
ModeloConsultaPersistencia,
|
|
15
|
+
ModeloTransacaoPersistencia,
|
|
16
|
+
StatusCompatibilidadePersistencia,
|
|
17
|
+
TipoRecursoPersistencia,
|
|
18
|
+
} from "../persistencia/contratos.js";
|
|
19
|
+
import type {
|
|
20
|
+
ClassificacaoDadoSemantico,
|
|
21
|
+
ModoAuthSemantico,
|
|
22
|
+
MotivoAuditSemantico,
|
|
23
|
+
OrigemAuthSemantica,
|
|
24
|
+
PrincipalAuthSemantico,
|
|
25
|
+
RedacaoLogSemantica,
|
|
26
|
+
TenantAuthzSemantico,
|
|
27
|
+
} from "../semantico/seguranca.js";
|
|
28
|
+
|
|
29
|
+
export type PerfilCompatibilidade = "publico" | "interno" | "experimental" | "legado" | "deprecado";
|
|
30
|
+
export type StatusResolucaoSemantica = "nao_verificado" | "resolvido" | "parcial" | "inferido" | "quebrado" | "nao_encontrado";
|
|
31
|
+
export type NivelConfiancaSemantica = "alta" | "media" | "baixa";
|
|
32
|
+
export type NivelRiscoSemantico = "baixo" | "medio" | "alto";
|
|
33
|
+
export type TipoSuperficieIr = "worker" | "evento" | "fila" | "cron" | "webhook" | "cache" | "storage" | "policy";
|
|
34
|
+
|
|
35
|
+
export interface IrCampo {
|
|
36
|
+
nome: string;
|
|
37
|
+
tipo: string;
|
|
38
|
+
modificadores: string[];
|
|
39
|
+
tipoOriginal: string;
|
|
40
|
+
tipoBase: string;
|
|
41
|
+
cardinalidade: "unitario" | "lista" | "mapa" | "uniao";
|
|
42
|
+
opcional: boolean;
|
|
43
|
+
tiposAlternativos: string[];
|
|
44
|
+
tipoItem?: string;
|
|
45
|
+
chaveMapa?: string;
|
|
46
|
+
valorMapa?: string;
|
|
47
|
+
refinamentos: string[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IrImplementacaoTask {
|
|
51
|
+
origem: "ts" | "py" | "dart" | "lua" | "cs" | "java" | "go" | "rust" | "cpp";
|
|
52
|
+
caminho: string;
|
|
53
|
+
origemArquivo?: string;
|
|
54
|
+
origemSimbolo?: string;
|
|
55
|
+
resolucaoImpl?: string;
|
|
56
|
+
statusImpl?: StatusResolucaoSemantica;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface IrVinculo {
|
|
60
|
+
tipo: string;
|
|
61
|
+
valor: string;
|
|
62
|
+
arquivo?: string;
|
|
63
|
+
simbolo?: string;
|
|
64
|
+
recurso?: string;
|
|
65
|
+
superficie?: string;
|
|
66
|
+
statusResolucao?: StatusResolucaoSemantica;
|
|
67
|
+
confianca?: NivelConfiancaSemantica;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface IrExecucao {
|
|
71
|
+
idempotencia: boolean;
|
|
72
|
+
timeout: string;
|
|
73
|
+
retry: string;
|
|
74
|
+
compensacao: string;
|
|
75
|
+
criticidadeOperacional: "baixa" | "media" | "alta" | "critica";
|
|
76
|
+
explicita: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface IrAuth {
|
|
80
|
+
explicita: boolean;
|
|
81
|
+
modo?: ModoAuthSemantico | string;
|
|
82
|
+
estrategia?: string;
|
|
83
|
+
principal?: PrincipalAuthSemantico | string;
|
|
84
|
+
origem?: OrigemAuthSemantica | string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface IrAuthz {
|
|
88
|
+
explicita: boolean;
|
|
89
|
+
papeis: string[];
|
|
90
|
+
escopos: string[];
|
|
91
|
+
politica?: string;
|
|
92
|
+
tenant?: TenantAuthzSemantico | string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface IrCampoDadoClassificado {
|
|
96
|
+
origem: string;
|
|
97
|
+
campo: string;
|
|
98
|
+
classificacao: ClassificacaoDadoSemantico | string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface IrDados {
|
|
102
|
+
explicita: boolean;
|
|
103
|
+
classificacaoPadrao?: ClassificacaoDadoSemantico | string;
|
|
104
|
+
redacaoLog?: RedacaoLogSemantica | string;
|
|
105
|
+
retencao?: string;
|
|
106
|
+
campos: IrCampoDadoClassificado[];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface IrAudit {
|
|
110
|
+
explicita: boolean;
|
|
111
|
+
evento?: string;
|
|
112
|
+
ator?: string;
|
|
113
|
+
correlacao?: string;
|
|
114
|
+
retencao?: string;
|
|
115
|
+
motivo?: MotivoAuditSemantico | string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface IrSegredo {
|
|
119
|
+
nome: string;
|
|
120
|
+
origem?: string;
|
|
121
|
+
escopo?: string;
|
|
122
|
+
acesso?: string;
|
|
123
|
+
rotacao?: string;
|
|
124
|
+
naoLogar?: boolean;
|
|
125
|
+
naoRetornar?: boolean;
|
|
126
|
+
mascarar?: boolean;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface IrSegredos {
|
|
130
|
+
explicita: boolean;
|
|
131
|
+
itens: IrSegredo[];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface IrForbidden {
|
|
135
|
+
explicita: boolean;
|
|
136
|
+
regras: string[];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface IrBlocoDeclarativo {
|
|
140
|
+
campos: IrCampo[];
|
|
141
|
+
linhas: string[];
|
|
142
|
+
blocos: IrBlocoDeclarativoAninhado[];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface IrBlocoDeclarativoAninhado {
|
|
146
|
+
nome: string;
|
|
147
|
+
conteudo: IrBlocoDeclarativo;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface IrCasoTeste {
|
|
151
|
+
nome: string;
|
|
152
|
+
given: IrBlocoDeclarativo;
|
|
153
|
+
when?: IrBlocoDeclarativo;
|
|
154
|
+
expect: IrBlocoDeclarativo;
|
|
155
|
+
error?: IrBlocoDeclarativo;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface IrResumoAgente {
|
|
159
|
+
riscos: string[];
|
|
160
|
+
checks: string[];
|
|
161
|
+
entidadesAfetadas: string[];
|
|
162
|
+
superficiesPublicas: string[];
|
|
163
|
+
mutacoesPrevistas: string[];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface IrType {
|
|
167
|
+
nome: string;
|
|
168
|
+
definicao: IrBlocoDeclarativo;
|
|
169
|
+
invariantes: ExpressaoSemantica[];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface IrEntity {
|
|
173
|
+
nome: string;
|
|
174
|
+
campos: IrCampo[];
|
|
175
|
+
invariantes: ExpressaoSemantica[];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface IrEnum {
|
|
179
|
+
nome: string;
|
|
180
|
+
valores: string[];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface IrUse {
|
|
184
|
+
origem: "sema" | "ts" | "py" | "dart" | "lua" | "cs" | "java" | "go" | "rust" | "cpp";
|
|
185
|
+
caminho: string;
|
|
186
|
+
externo: boolean;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface IrInteropExterno {
|
|
190
|
+
origem: "ts" | "py" | "dart" | "lua" | "cs" | "java" | "go" | "rust" | "cpp";
|
|
191
|
+
caminho: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface IrErroOperacional {
|
|
195
|
+
codigo: string;
|
|
196
|
+
mensagem: string;
|
|
197
|
+
categoria?: string;
|
|
198
|
+
recuperabilidade?: string;
|
|
199
|
+
acaoChamador?: string;
|
|
200
|
+
impactaEstado?: boolean;
|
|
201
|
+
requerCompensacao?: boolean;
|
|
202
|
+
origemTask?: string;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface IrTask {
|
|
206
|
+
nome: string;
|
|
207
|
+
input: IrCampo[];
|
|
208
|
+
output: IrCampo[];
|
|
209
|
+
rules: string[];
|
|
210
|
+
regrasEstruturadas: ExpressaoSemantica[];
|
|
211
|
+
effects: string[];
|
|
212
|
+
efeitosEstruturados: EfeitoSemantico[];
|
|
213
|
+
implementacoesExternas: IrImplementacaoTask[];
|
|
214
|
+
vinculos: IrVinculo[];
|
|
215
|
+
execucao: IrExecucao;
|
|
216
|
+
auth: IrAuth;
|
|
217
|
+
authz: IrAuthz;
|
|
218
|
+
dados: IrDados;
|
|
219
|
+
audit: IrAudit;
|
|
220
|
+
segredos: IrSegredos;
|
|
221
|
+
forbidden: IrForbidden;
|
|
222
|
+
guarantees: string[];
|
|
223
|
+
garantiasEstruturadas: ExpressaoSemantica[];
|
|
224
|
+
errors: Record<string, string>;
|
|
225
|
+
errosDetalhados: IrErroOperacional[];
|
|
226
|
+
perfilCompatibilidade: PerfilCompatibilidade;
|
|
227
|
+
stateContract?: IrTaskStateContract;
|
|
228
|
+
resumoAgente: IrResumoAgente;
|
|
229
|
+
tests: IrCasoTeste[];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface IrErroPublico extends IrErroOperacional {
|
|
233
|
+
nome: string;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface IrRoutePublica {
|
|
237
|
+
metodo?: string;
|
|
238
|
+
caminho?: string;
|
|
239
|
+
task?: string;
|
|
240
|
+
input: IrCampo[];
|
|
241
|
+
output: IrCampo[];
|
|
242
|
+
errors: IrErroPublico[];
|
|
243
|
+
effects: EfeitoSemantico[];
|
|
244
|
+
garantiasMinimas: string[];
|
|
245
|
+
confiancaContrato?: NivelConfiancaSemantica;
|
|
246
|
+
riscoRegressao?: NivelRiscoSemantico;
|
|
247
|
+
divergenciasPublicas?: string[];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface IrTaskStateContract {
|
|
251
|
+
nomeEstado?: string;
|
|
252
|
+
campos: IrCampo[];
|
|
253
|
+
linhas: string[];
|
|
254
|
+
transicoes: TransicaoEstadoSemantica[];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export interface IrFlow {
|
|
258
|
+
nome: string;
|
|
259
|
+
campos: IrCampo[];
|
|
260
|
+
linhas: string[];
|
|
261
|
+
tasksReferenciadas: string[];
|
|
262
|
+
etapasEstruturadas: EtapaFlowSemantica[];
|
|
263
|
+
effects: string[];
|
|
264
|
+
efeitosEstruturados: EfeitoSemantico[];
|
|
265
|
+
vinculos: IrVinculo[];
|
|
266
|
+
perfilCompatibilidade: PerfilCompatibilidade;
|
|
267
|
+
resumoAgente: IrResumoAgente;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface IrRoute {
|
|
271
|
+
nome: string;
|
|
272
|
+
campos: IrCampo[];
|
|
273
|
+
linhas: string[];
|
|
274
|
+
metodo?: string;
|
|
275
|
+
caminho?: string;
|
|
276
|
+
task?: string;
|
|
277
|
+
inputPublico: IrCampo[];
|
|
278
|
+
outputPublico: IrCampo[];
|
|
279
|
+
errosPublicos: ContratoErroRouteSemantico[];
|
|
280
|
+
efeitosPublicos: EfeitoSemantico[];
|
|
281
|
+
vinculos: IrVinculo[];
|
|
282
|
+
auth: IrAuth;
|
|
283
|
+
authz: IrAuthz;
|
|
284
|
+
dados: IrDados;
|
|
285
|
+
audit: IrAudit;
|
|
286
|
+
segredos: IrSegredos;
|
|
287
|
+
forbidden: IrForbidden;
|
|
288
|
+
perfilCompatibilidade: PerfilCompatibilidade;
|
|
289
|
+
garantiasPublicasMinimas: string[];
|
|
290
|
+
resumoAgente: IrResumoAgente;
|
|
291
|
+
publico: IrRoutePublica;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export interface IrSuperficie {
|
|
295
|
+
tipo: TipoSuperficieIr;
|
|
296
|
+
nome: string;
|
|
297
|
+
campos: IrCampo[];
|
|
298
|
+
linhas: string[];
|
|
299
|
+
task?: string;
|
|
300
|
+
input: IrCampo[];
|
|
301
|
+
output: IrCampo[];
|
|
302
|
+
effects: EfeitoSemantico[];
|
|
303
|
+
implementacoesExternas: IrImplementacaoTask[];
|
|
304
|
+
vinculos: IrVinculo[];
|
|
305
|
+
execucao: IrExecucao;
|
|
306
|
+
auth: IrAuth;
|
|
307
|
+
authz: IrAuthz;
|
|
308
|
+
dados: IrDados;
|
|
309
|
+
audit: IrAudit;
|
|
310
|
+
segredos: IrSegredos;
|
|
311
|
+
forbidden: IrForbidden;
|
|
312
|
+
perfilCompatibilidade: PerfilCompatibilidade;
|
|
313
|
+
resumoAgente: IrResumoAgente;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export interface IrState {
|
|
317
|
+
nome?: string;
|
|
318
|
+
campos: IrCampo[];
|
|
319
|
+
linhas: string[];
|
|
320
|
+
invariantes: ExpressaoSemantica[];
|
|
321
|
+
transicoes: TransicaoEstadoSemantica[];
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export interface IrCompatibilidadePersistencia extends CompatibilidadePersistencia {
|
|
325
|
+
engine: EngineBanco;
|
|
326
|
+
status: StatusCompatibilidadePersistencia;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export interface IrRecursoPersistencia {
|
|
330
|
+
nome: string;
|
|
331
|
+
resourceKind: TipoRecursoPersistencia;
|
|
332
|
+
entity?: string;
|
|
333
|
+
collection?: string;
|
|
334
|
+
table?: string;
|
|
335
|
+
consistency?: ConsistenciaPersistencia | string;
|
|
336
|
+
durability?: DurabilidadePersistencia | string;
|
|
337
|
+
transactionModel?: ModeloTransacaoPersistencia | string;
|
|
338
|
+
queryModel?: ModeloConsultaPersistencia | string;
|
|
339
|
+
mode?: string;
|
|
340
|
+
isolation?: string;
|
|
341
|
+
strategy?: string;
|
|
342
|
+
ttl?: string;
|
|
343
|
+
retention?: string;
|
|
344
|
+
path?: string;
|
|
345
|
+
from?: string;
|
|
346
|
+
to?: string;
|
|
347
|
+
surface?: string;
|
|
348
|
+
adapter?: string;
|
|
349
|
+
portavel?: boolean;
|
|
350
|
+
capabilities: string[];
|
|
351
|
+
operations: string[];
|
|
352
|
+
indexing: string[];
|
|
353
|
+
guarantees: string[];
|
|
354
|
+
diagnostics: string[];
|
|
355
|
+
risks: string[];
|
|
356
|
+
fields: IrCampo[];
|
|
357
|
+
lines: string[];
|
|
358
|
+
block: IrBlocoDeclarativo;
|
|
359
|
+
compatibilidade: IrCompatibilidadePersistencia[];
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export interface IrBancoDados {
|
|
363
|
+
nome: string;
|
|
364
|
+
engine?: EngineBanco;
|
|
365
|
+
schema?: string;
|
|
366
|
+
database?: string;
|
|
367
|
+
consistency?: ConsistenciaPersistencia | string;
|
|
368
|
+
durability?: DurabilidadePersistencia | string;
|
|
369
|
+
transactionModel?: ModeloTransacaoPersistencia | string;
|
|
370
|
+
queryModel?: ModeloConsultaPersistencia | string;
|
|
371
|
+
portavel?: boolean;
|
|
372
|
+
adapter?: string;
|
|
373
|
+
capabilities: string[];
|
|
374
|
+
operations: string[];
|
|
375
|
+
indexing: string[];
|
|
376
|
+
guarantees: string[];
|
|
377
|
+
diagnostics: string[];
|
|
378
|
+
risks: string[];
|
|
379
|
+
fields: IrCampo[];
|
|
380
|
+
lines: string[];
|
|
381
|
+
block: IrBlocoDeclarativo;
|
|
382
|
+
resources: IrRecursoPersistencia[];
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export interface IrModulo {
|
|
386
|
+
nome: string;
|
|
387
|
+
uses: string[];
|
|
388
|
+
imports: IrUse[];
|
|
389
|
+
interoperabilidades: IrInteropExterno[];
|
|
390
|
+
vinculos: IrVinculo[];
|
|
391
|
+
perfilCompatibilidade: PerfilCompatibilidade;
|
|
392
|
+
types: IrType[];
|
|
393
|
+
entities: IrEntity[];
|
|
394
|
+
enums: IrEnum[];
|
|
395
|
+
tasks: IrTask[];
|
|
396
|
+
flows: IrFlow[];
|
|
397
|
+
routes: IrRoute[];
|
|
398
|
+
superficies: IrSuperficie[];
|
|
399
|
+
states: IrState[];
|
|
400
|
+
databases: IrBancoDados[];
|
|
401
|
+
resumoAgente: IrResumoAgente;
|
|
402
|
+
diagnosticos: Diagnostico[];
|
|
403
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { criarDiagnostico, type Diagnostico, type PosicaoFonte } from "../diagnosticos/index.js";
|
|
2
|
+
import { PALAVRAS_CHAVE, type Token, type TipoToken } from "./tokens.js";
|
|
3
|
+
|
|
4
|
+
export interface ResultadoLexer {
|
|
5
|
+
tokens: Token[];
|
|
6
|
+
diagnosticos: Diagnostico[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function avancar(posicao: PosicaoFonte, caractere: string): PosicaoFonte {
|
|
10
|
+
if (caractere === "\n") {
|
|
11
|
+
return { indice: posicao.indice + 1, linha: posicao.linha + 1, coluna: 1 };
|
|
12
|
+
}
|
|
13
|
+
return { indice: posicao.indice + 1, linha: posicao.linha, coluna: posicao.coluna + 1 };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function criarToken(tipo: TipoToken, valor: string, inicio: PosicaoFonte, fim: PosicaoFonte, arquivo?: string): Token {
|
|
17
|
+
return {
|
|
18
|
+
tipo,
|
|
19
|
+
valor,
|
|
20
|
+
intervalo: { inicio, fim, arquivo },
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function tokenizar(codigo: string, arquivo?: string): ResultadoLexer {
|
|
25
|
+
const tokens: Token[] = [];
|
|
26
|
+
const diagnosticos: Diagnostico[] = [];
|
|
27
|
+
let posicao: PosicaoFonte = { indice: 0, linha: 1, coluna: 1 };
|
|
28
|
+
|
|
29
|
+
while (posicao.indice < codigo.length) {
|
|
30
|
+
const inicio = { ...posicao };
|
|
31
|
+
const atual = codigo[posicao.indice]!;
|
|
32
|
+
|
|
33
|
+
if (atual === " " || atual === "\t" || atual === "\r") {
|
|
34
|
+
posicao = avancar(posicao, atual);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (atual === "\n") {
|
|
39
|
+
posicao = avancar(posicao, atual);
|
|
40
|
+
tokens.push(criarToken("nova_linha", "\n", inicio, { ...posicao }, arquivo));
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (atual === "/" && codigo[posicao.indice + 1] === "/") {
|
|
45
|
+
let texto = "";
|
|
46
|
+
let cursor = { ...posicao };
|
|
47
|
+
while (cursor.indice < codigo.length && codigo[cursor.indice] !== "\n") {
|
|
48
|
+
texto += codigo[cursor.indice];
|
|
49
|
+
cursor = avancar(cursor, codigo[cursor.indice]!);
|
|
50
|
+
}
|
|
51
|
+
tokens.push(criarToken("comentario", texto, inicio, cursor, arquivo));
|
|
52
|
+
posicao = cursor;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (atual === "\"") {
|
|
57
|
+
let texto = "";
|
|
58
|
+
let cursor = avancar(posicao, atual);
|
|
59
|
+
let fechado = false;
|
|
60
|
+
while (cursor.indice < codigo.length) {
|
|
61
|
+
const caractere = codigo[cursor.indice]!;
|
|
62
|
+
if (caractere === "\\") {
|
|
63
|
+
const proximo = codigo[cursor.indice + 1];
|
|
64
|
+
if (proximo) {
|
|
65
|
+
texto += caractere + proximo;
|
|
66
|
+
cursor = avancar(avancar(cursor, caractere), proximo);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (caractere === "\"") {
|
|
71
|
+
fechado = true;
|
|
72
|
+
cursor = avancar(cursor, caractere);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
texto += caractere;
|
|
76
|
+
cursor = avancar(cursor, caractere);
|
|
77
|
+
}
|
|
78
|
+
if (!fechado) {
|
|
79
|
+
diagnosticos.push(
|
|
80
|
+
criarDiagnostico(
|
|
81
|
+
"LEX001",
|
|
82
|
+
"Texto nao foi fechado com aspas.",
|
|
83
|
+
"erro",
|
|
84
|
+
{ inicio, fim: cursor, arquivo },
|
|
85
|
+
"Feche a string com aspas duplas.",
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
posicao = cursor;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
tokens.push(criarToken("texto", texto, inicio, cursor, arquivo));
|
|
92
|
+
posicao = cursor;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (/[0-9]/.test(atual)) {
|
|
97
|
+
let texto = "";
|
|
98
|
+
let cursor = { ...posicao };
|
|
99
|
+
while (cursor.indice < codigo.length && /[0-9.]/.test(codigo[cursor.indice]!)) {
|
|
100
|
+
texto += codigo[cursor.indice];
|
|
101
|
+
cursor = avancar(cursor, codigo[cursor.indice]!);
|
|
102
|
+
}
|
|
103
|
+
tokens.push(criarToken("numero", texto, inicio, cursor, arquivo));
|
|
104
|
+
posicao = cursor;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (/[A-Za-z_]/.test(atual)) {
|
|
109
|
+
let texto = "";
|
|
110
|
+
let cursor = { ...posicao };
|
|
111
|
+
while (cursor.indice < codigo.length && /[A-Za-z0-9_.-]/.test(codigo[cursor.indice]!)) {
|
|
112
|
+
texto += codigo[cursor.indice];
|
|
113
|
+
cursor = avancar(cursor, codigo[cursor.indice]!);
|
|
114
|
+
}
|
|
115
|
+
const tipo: TipoToken = PALAVRAS_CHAVE.has(texto) ? "palavra_chave" : "identificador";
|
|
116
|
+
tokens.push(criarToken(tipo, texto, inicio, cursor, arquivo));
|
|
117
|
+
posicao = cursor;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const doisCaracteres = codigo.slice(posicao.indice, posicao.indice + 2);
|
|
122
|
+
if (["==", "!=", ">=", "<=", "->"].includes(doisCaracteres)) {
|
|
123
|
+
const cursor = avancar(avancar(posicao, doisCaracteres[0]!), doisCaracteres[1]!);
|
|
124
|
+
tokens.push(criarToken("operador", doisCaracteres, inicio, cursor, arquivo));
|
|
125
|
+
posicao = cursor;
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if ("{}[]():,.".includes(atual)) {
|
|
130
|
+
const cursor = avancar(posicao, atual);
|
|
131
|
+
tokens.push(criarToken("pontuacao", atual, inicio, cursor, arquivo));
|
|
132
|
+
posicao = cursor;
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if ("=><+-*/|?".includes(atual)) {
|
|
137
|
+
const cursor = avancar(posicao, atual);
|
|
138
|
+
tokens.push(criarToken("operador", atual, inicio, cursor, arquivo));
|
|
139
|
+
posicao = cursor;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
diagnosticos.push(
|
|
144
|
+
criarDiagnostico(
|
|
145
|
+
"LEX002",
|
|
146
|
+
`Caractere inesperado encontrado: "${atual}".`,
|
|
147
|
+
"erro",
|
|
148
|
+
{ inicio, fim: avancar(posicao, atual), arquivo },
|
|
149
|
+
"Remova o caractere ou adicione suporte no lexer.",
|
|
150
|
+
),
|
|
151
|
+
);
|
|
152
|
+
posicao = avancar(posicao, atual);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
tokens.push(
|
|
156
|
+
criarToken(
|
|
157
|
+
"fim_arquivo",
|
|
158
|
+
"",
|
|
159
|
+
{ ...posicao },
|
|
160
|
+
{ ...posicao },
|
|
161
|
+
arquivo,
|
|
162
|
+
),
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
return { tokens, diagnosticos };
|
|
166
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { IntervaloFonte } from "../diagnosticos/index.js";
|
|
2
|
+
|
|
3
|
+
export type TipoToken =
|
|
4
|
+
| "palavra_chave"
|
|
5
|
+
| "identificador"
|
|
6
|
+
| "texto"
|
|
7
|
+
| "numero"
|
|
8
|
+
| "pontuacao"
|
|
9
|
+
| "operador"
|
|
10
|
+
| "nova_linha"
|
|
11
|
+
| "comentario"
|
|
12
|
+
| "fim_arquivo";
|
|
13
|
+
|
|
14
|
+
export interface Token {
|
|
15
|
+
tipo: TipoToken;
|
|
16
|
+
valor: string;
|
|
17
|
+
intervalo: IntervaloFonte;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const PALAVRAS_CHAVE = new Set([
|
|
21
|
+
"module",
|
|
22
|
+
"use",
|
|
23
|
+
"database",
|
|
24
|
+
"type",
|
|
25
|
+
"entity",
|
|
26
|
+
"enum",
|
|
27
|
+
"task",
|
|
28
|
+
"worker",
|
|
29
|
+
"evento",
|
|
30
|
+
"fila",
|
|
31
|
+
"cron",
|
|
32
|
+
"webhook",
|
|
33
|
+
"cache",
|
|
34
|
+
"storage",
|
|
35
|
+
"policy",
|
|
36
|
+
"input",
|
|
37
|
+
"output",
|
|
38
|
+
"rules",
|
|
39
|
+
"effects",
|
|
40
|
+
"impl",
|
|
41
|
+
"vinculos",
|
|
42
|
+
"execucao",
|
|
43
|
+
"auth",
|
|
44
|
+
"authz",
|
|
45
|
+
"dados",
|
|
46
|
+
"audit",
|
|
47
|
+
"segredos",
|
|
48
|
+
"forbidden",
|
|
49
|
+
"guarantees",
|
|
50
|
+
"state",
|
|
51
|
+
"flow",
|
|
52
|
+
"route",
|
|
53
|
+
"tests",
|
|
54
|
+
"error",
|
|
55
|
+
"docs",
|
|
56
|
+
"comments",
|
|
57
|
+
"table",
|
|
58
|
+
"view",
|
|
59
|
+
"query",
|
|
60
|
+
"transaction",
|
|
61
|
+
"index",
|
|
62
|
+
"constraint",
|
|
63
|
+
"relationship",
|
|
64
|
+
"collection",
|
|
65
|
+
"document",
|
|
66
|
+
"keyspace",
|
|
67
|
+
"stream",
|
|
68
|
+
"lock",
|
|
69
|
+
"retention",
|
|
70
|
+
"replication",
|
|
71
|
+
"fields",
|
|
72
|
+
"invariants",
|
|
73
|
+
"transitions",
|
|
74
|
+
"given",
|
|
75
|
+
"when",
|
|
76
|
+
"expect",
|
|
77
|
+
"caso",
|
|
78
|
+
"required",
|
|
79
|
+
]);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
arquivo = modulo ;
|
|
2
|
+
modulo = "module" identificador "{" declaracao_modulo* "}" ;
|
|
3
|
+
declaracao_modulo = use | docs | comments | vinculos | database | type | entity | enum | task | flow | route | worker | evento | fila | cron | webhook | cache | storage | policy | state | tests ;
|
|
4
|
+
use = "use" identificador ;
|
|
5
|
+
database = "database" identificador bloco_generico ;
|
|
6
|
+
type = "type" identificador bloco_generico ;
|
|
7
|
+
entity = "entity" identificador bloco_generico ;
|
|
8
|
+
enum = "enum" identificador "{" identificador ("," identificador)* "}" ;
|
|
9
|
+
task = "task" identificador bloco_generico ;
|
|
10
|
+
flow = "flow" identificador bloco_generico ;
|
|
11
|
+
route = "route" identificador bloco_generico ;
|
|
12
|
+
worker = "worker" identificador bloco_generico ;
|
|
13
|
+
evento = "evento" identificador bloco_generico ;
|
|
14
|
+
fila = "fila" identificador bloco_generico ;
|
|
15
|
+
cron = "cron" identificador bloco_generico ;
|
|
16
|
+
webhook = "webhook" identificador bloco_generico ;
|
|
17
|
+
cache = "cache" identificador bloco_generico ;
|
|
18
|
+
storage = "storage" identificador bloco_generico ;
|
|
19
|
+
policy = "policy" identificador bloco_generico ;
|
|
20
|
+
state = "state" bloco_generico ;
|
|
21
|
+
tests = "tests" "{" caso* "}" ;
|
|
22
|
+
caso = "caso" texto "{" given? when? expect? error? docs? comments? "}" ;
|
|
23
|
+
given = "given" bloco_generico ;
|
|
24
|
+
when = "when" bloco_generico ;
|
|
25
|
+
expect = "expect" bloco_generico ;
|
|
26
|
+
error = "error" bloco_generico ;
|
|
27
|
+
vinculos = "vinculos" bloco_generico ;
|
|
28
|
+
docs = "docs" bloco_generico ;
|
|
29
|
+
comments = "comments" bloco_generico ;
|
|
30
|
+
bloco_generico = "{" item_bloco* "}" ;
|
|
31
|
+
item_bloco = campo | linha | bloco_generico_nomeado | bloco_generico_nomeado_livre ;
|
|
32
|
+
bloco_generico_nomeado = palavra_chave "{" item_bloco* "}" ;
|
|
33
|
+
bloco_generico_nomeado_livre = identificador identificador "{" item_bloco* "}" ;
|
|
34
|
+
campo = identificador ":" valor valor_modificador* ;
|
|
35
|
+
linha = valor+ ;
|
|
36
|
+
valor = identificador | numero | texto ;
|
|
37
|
+
valor_modificador = identificador ;
|
|
38
|
+
identificador = ? token de identificador ? ;
|
|
39
|
+
numero = ? token numerico ? ;
|
|
40
|
+
texto = ? token textual ? ;
|
|
41
|
+
palavra_chave = "input" | "output" | "rules" | "effects" | "impl" | "vinculos" | "execucao" | "auth" | "authz" | "dados" | "audit" | "segredos" | "forbidden" | "guarantees" | "state" | "fields" | "tests" | "error" | "docs" | "comments" | "given" | "when" | "expect" ;
|