types-nora-api 0.0.146 → 0.0.148
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/classes.d.ts +159 -1
- package/dist/classes.js +52 -1
- package/dist/scripts/extrairClasses.config.d.ts +27 -0
- package/dist/scripts/extrairClasses.config.js +66 -0
- package/dist/scripts/extrairClasses.d.ts +9 -0
- package/dist/scripts/extrairClasses.js +161 -0
- package/dist/scripts/extrairClasses.utils.d.ts +58 -0
- package/dist/scripts/extrairClasses.utils.js +255 -0
- package/dist/src/classes.d.ts +1066 -0
- package/dist/src/classes.js +218 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/package.json +3 -2
package/dist/classes.d.ts
CHANGED
|
@@ -754,6 +754,64 @@ type TelemetrySnapshot = {
|
|
|
754
754
|
lastEvents: TelemetryEventLog[];
|
|
755
755
|
serverTime: number;
|
|
756
756
|
};
|
|
757
|
+
type EventoTipo = 'recebe' | 'envia' | 'recebe-envia';
|
|
758
|
+
type EventoConfig<T extends EventoTipo, P, R = void> = {
|
|
759
|
+
tipo: T;
|
|
760
|
+
payload: P;
|
|
761
|
+
} & (T extends 'recebe-envia' ? {
|
|
762
|
+
response: R;
|
|
763
|
+
} : {});
|
|
764
|
+
type EventoDef = EventoConfig<'recebe', any> | EventoConfig<'envia', any> | EventoConfig<'recebe-envia', any, any>;
|
|
765
|
+
type GatewayDef = Record<string, EventoDef>;
|
|
766
|
+
type GatewaysCollection = Record<string, GatewayDef>;
|
|
767
|
+
declare function createGateway<T extends Record<string, EventoConfig<EventoTipo, any, any>>>(config: T): T;
|
|
768
|
+
declare namespace EventosWebSocket {
|
|
769
|
+
const gateways: {
|
|
770
|
+
readonly GameEngine: {
|
|
771
|
+
testeGameEngine1: {
|
|
772
|
+
tipo: "recebe-envia";
|
|
773
|
+
payload: {
|
|
774
|
+
teste1: string;
|
|
775
|
+
};
|
|
776
|
+
response: {
|
|
777
|
+
ok: boolean;
|
|
778
|
+
msg: string;
|
|
779
|
+
};
|
|
780
|
+
};
|
|
781
|
+
testeGameEngine2: {
|
|
782
|
+
tipo: "recebe";
|
|
783
|
+
payload: {
|
|
784
|
+
teste2: number;
|
|
785
|
+
};
|
|
786
|
+
};
|
|
787
|
+
testeDuplicado: {
|
|
788
|
+
tipo: "recebe-envia";
|
|
789
|
+
payload: {};
|
|
790
|
+
response: {
|
|
791
|
+
msg: string;
|
|
792
|
+
};
|
|
793
|
+
};
|
|
794
|
+
};
|
|
795
|
+
readonly Chat: {
|
|
796
|
+
testeChat1: {
|
|
797
|
+
tipo: "recebe-envia";
|
|
798
|
+
payload: {
|
|
799
|
+
mensagem: string;
|
|
800
|
+
};
|
|
801
|
+
response: {
|
|
802
|
+
entregue: boolean;
|
|
803
|
+
};
|
|
804
|
+
};
|
|
805
|
+
testeDuplicado: {
|
|
806
|
+
tipo: "recebe-envia";
|
|
807
|
+
payload: {};
|
|
808
|
+
response: {
|
|
809
|
+
msg: string;
|
|
810
|
+
};
|
|
811
|
+
};
|
|
812
|
+
};
|
|
813
|
+
};
|
|
814
|
+
}
|
|
757
815
|
type SOCKET_AcessoUsuario = {
|
|
758
816
|
usuario: UsuarioDto;
|
|
759
817
|
paginaAtual?: PaginaObjeto | null;
|
|
@@ -905,4 +963,104 @@ declare enum EstiloSessao {
|
|
|
905
963
|
SESSAO_UNICA_NAO_CANONICA = 2,
|
|
906
964
|
ERRO = 3
|
|
907
965
|
}
|
|
908
|
-
|
|
966
|
+
type Gateways = typeof EventosWebSocket.gateways;
|
|
967
|
+
type EventoTipoLiteral = EventoTipo;
|
|
968
|
+
type FiltraEventosPorTipo<G extends GatewayDef, Tipo extends EventoTipoLiteral> = {
|
|
969
|
+
[K in keyof G as G[K] extends {
|
|
970
|
+
tipo: Tipo;
|
|
971
|
+
} ? K : never]: G[K];
|
|
972
|
+
};
|
|
973
|
+
declare function criarEventosFiltrados<Tipo extends EventoTipoLiteral>(tipo: Tipo): { [G in keyof Gateways]: {
|
|
974
|
+
eventos: { [E in keyof FiltraEventosPorTipo<Gateways[G], Tipo>]: FiltraEventosPorTipo<Gateways[G], Tipo>[E] & {
|
|
975
|
+
readonly nome: E;
|
|
976
|
+
readonly gateway: G;
|
|
977
|
+
readonly fullName: `${Extract<G, string>}:${Extract<E, string>}`;
|
|
978
|
+
}; };
|
|
979
|
+
}; };
|
|
980
|
+
declare const Eventos_Recebe: {
|
|
981
|
+
readonly GameEngine: {
|
|
982
|
+
eventos: {
|
|
983
|
+
testeGameEngine2: {
|
|
984
|
+
tipo: "recebe";
|
|
985
|
+
payload: {
|
|
986
|
+
teste2: number;
|
|
987
|
+
};
|
|
988
|
+
} & {
|
|
989
|
+
readonly nome: "testeGameEngine2";
|
|
990
|
+
readonly gateway: "GameEngine";
|
|
991
|
+
readonly fullName: "GameEngine:testeGameEngine2";
|
|
992
|
+
};
|
|
993
|
+
};
|
|
994
|
+
};
|
|
995
|
+
readonly Chat: {
|
|
996
|
+
eventos: {};
|
|
997
|
+
};
|
|
998
|
+
};
|
|
999
|
+
declare const Eventos_Envia: {
|
|
1000
|
+
readonly GameEngine: {
|
|
1001
|
+
eventos: {};
|
|
1002
|
+
};
|
|
1003
|
+
readonly Chat: {
|
|
1004
|
+
eventos: {};
|
|
1005
|
+
};
|
|
1006
|
+
};
|
|
1007
|
+
declare const Eventos_RecebeEnvia: {
|
|
1008
|
+
readonly GameEngine: {
|
|
1009
|
+
eventos: {
|
|
1010
|
+
testeGameEngine1: {
|
|
1011
|
+
tipo: "recebe-envia";
|
|
1012
|
+
payload: {
|
|
1013
|
+
teste1: string;
|
|
1014
|
+
};
|
|
1015
|
+
response: {
|
|
1016
|
+
ok: boolean;
|
|
1017
|
+
msg: string;
|
|
1018
|
+
};
|
|
1019
|
+
} & {
|
|
1020
|
+
readonly nome: "testeGameEngine1";
|
|
1021
|
+
readonly gateway: "GameEngine";
|
|
1022
|
+
readonly fullName: "GameEngine:testeGameEngine1";
|
|
1023
|
+
};
|
|
1024
|
+
testeDuplicado: {
|
|
1025
|
+
tipo: "recebe-envia";
|
|
1026
|
+
payload: {};
|
|
1027
|
+
response: {
|
|
1028
|
+
msg: string;
|
|
1029
|
+
};
|
|
1030
|
+
} & {
|
|
1031
|
+
readonly nome: "testeDuplicado";
|
|
1032
|
+
readonly gateway: "GameEngine";
|
|
1033
|
+
readonly fullName: "GameEngine:testeDuplicado";
|
|
1034
|
+
};
|
|
1035
|
+
};
|
|
1036
|
+
};
|
|
1037
|
+
readonly Chat: {
|
|
1038
|
+
eventos: {
|
|
1039
|
+
testeChat1: {
|
|
1040
|
+
tipo: "recebe-envia";
|
|
1041
|
+
payload: {
|
|
1042
|
+
mensagem: string;
|
|
1043
|
+
};
|
|
1044
|
+
response: {
|
|
1045
|
+
entregue: boolean;
|
|
1046
|
+
};
|
|
1047
|
+
} & {
|
|
1048
|
+
readonly nome: "testeChat1";
|
|
1049
|
+
readonly gateway: "Chat";
|
|
1050
|
+
readonly fullName: "Chat:testeChat1";
|
|
1051
|
+
};
|
|
1052
|
+
testeDuplicado: {
|
|
1053
|
+
tipo: "recebe-envia";
|
|
1054
|
+
payload: {};
|
|
1055
|
+
response: {
|
|
1056
|
+
msg: string;
|
|
1057
|
+
};
|
|
1058
|
+
} & {
|
|
1059
|
+
readonly nome: "testeDuplicado";
|
|
1060
|
+
readonly gateway: "Chat";
|
|
1061
|
+
readonly fullName: "Chat:testeDuplicado";
|
|
1062
|
+
};
|
|
1063
|
+
};
|
|
1064
|
+
};
|
|
1065
|
+
};
|
|
1066
|
+
export { IArcoAventura, ArcoAventuraDto, IAventura, AventuraDto, IConviteGrupoAventuraPersonagem, ConviteGrupoAventuraPersonagemDto, IGrupoAventura, GrupoAventuraDto, IGrupoAventuraPersonagem, GrupoAventuraPersonagemDto, IRespostaConvite, RespostaConviteDto, IVariavelAmbiente, VariavelAmbienteDto, IConquista, ConquistaDto, ITipoConquista, TipoConquistaDto, IDetalheSessaoAventura, DetalheSessaoAventuraDto, IDetalheSessaoCanonica, DetalheSessaoCanonicaDto, CapituloSessaoCanonica, IDetalheSessaoNaoCanonica, DetalheSessaoNaoCanonicaDto, IDetalheSessaoUnica, DetalheSessaoUnicaDto, IParticipanteSessaoUnica, ParticipanteSessaoUnicaDto, ICoeficienteGanhoEstatisticaClasse, CoeficienteGanhoEstatisticaClasseDto, IGanhoNivelClasse, GanhoNivelClasseDto, DadosDoTipoGanho, DadosGanho_Atributos, DadosGanho_Pericias, DadosGanho_Estatisticas, DadosGanho_Classes, DadosGanho_ValorMaximoAtributo, DadosGanho_PontosHabilidadesEspeciais, DadosGanho_PontosHabilidadesParanormais, DadosGanho_PontosHabilidadeElemental, IGanhoRelativoCoeficienteAtributo, GanhoRelativoCoeficienteAtributoDto, ITipoGanhoNivel, TipoGanhoNivelDto, IGeracao, GeracaoDto, IImagem, ImagemDto, ITipoImagem, TipoImagemDto, IAlcance, AlcanceDto, IAtributo, AtributoDto, ICategoriaRitual, CategoriaRitualDto, ICirculoRitual, CirculoRitualDto, IClasse, ClasseDto, IDuracao, DuracaoDto, IElemento, ElementoDto, IEstatisticaDanificavel, EstatisticaDanificavelDto, IExecucao, ExecucaoDto, IFormatoAlcance, FormatoAlcanceDto, ILinhaEfeito, LinhaEfeitoDto, INivel, NivelDto, INivelComponente, NivelComponenteDto, INivelProficiencia, NivelProficienciaDto, INivelRitual, NivelRitualDto, IPatentePericia, PatentePericiaDto, IPericia, PericiaDto, IProficiencia, ProficienciaDto, ITipoAlvo, TipoAlvoDto, ITipoCategoria, TipoCategoriaDto, ITipoDano, TipoDanoDto, ITipoEfeito, TipoEfeitoDto, ITipoItem, TipoItemDto, ITipoProficiencia, TipoProficienciaDto, ILink, LinkDto, ITipoLink, TipoLinkDto, IDificuldadeSessao, DificuldadeSessaoDto, IEstiloSessaoMestrada, EstiloSessaoMestradaDto, ITipoSessao, TipoSessaoDto, IPerfilAdmin, PerfilAdminDto, IPerfilJogador, PerfilJogadorDto, IPerfilMestre, PerfilMestreDto, IFichaPersonagem, FichaPersonagemDto, ObjetoFicha, DetalheEvolucao, DetalhesExtras, FichaDeJogo, AtributoFicha, PericiaFicha, EstatisticaDanificavelFicha, DetalheFicha, RegistroPericiaLivre, IInformacaoPersonagem, InformacaoPersonagemDto, IPersonagem, PersonagemDto, IResumoPersonagemAventura, ResumoPersonagemAventuraDto, ITipoPersonagem, TipoPersonagemDto, IDetalheRascunhoAventura, DetalheRascunhoAventuraDto, IDetalheRascunhoSessaoUnica, DetalheRascunhoSessaoUnicaDto, IDetalheRascunhoSessaoUnicaCanonica, DetalheRascunhoSessaoUnicaCanonicaDto, IRascunho, RascunhoDto, IEstudo, EstudoDto, IRegistroSessao, RegistroSessaoDto, ISessao, SessaoDto, AuthSession, ICustomizacaoUsuario, CustomizacaoUsuarioDto, IDisponibilidadeUsuario, DisponibilidadeUsuarioDto, ListaDisponibilidadesUsuario, DisponibilidadesDDS, JanelaDisponibilidade, IUsuario, UsuarioDto, PAGINAS, PaginaChave, PaginaObjeto, TelemetryConnectionInfo, TelemetryEventLog, TelemetrySnapshot, EventoTipo, EventoConfig, EventoDef, GatewayDef, GatewaysCollection, createGateway, EventosWebSocket, SOCKET_AcessoUsuario, PaletaCores, EstruturaPaginaDefinicao, ConteudoItem, DefinicaoElemento, ListaItem, AventuraEstado, EstadoPendenciaPersonagem, EstadoPendenciaAdministrativaPersonagem, EstadoOcupacaoPersonagem, EstadoSessao, DiaDaSemana, obtemDiaDaSemanaPorExtensoPorDDS, NumeroHora24, NumeroMomento, MomentoFormatado24, MomentoFormatado, CargoExibicaoUsuario, CargosUsuario, ObjetoAutenticacao, ObjetoCache, ObjetoPendeciaPersonagem, TipoVariavelAmbiente, ObjetoEvolucaoCompleto, ObjetoEvolucao, ObjetoGanhosEvolucao, GanhoEstatistica, FormatoMomento, DetalheUtilizacaoRascunho, EstiloSessao, Gateways, EventoTipoLiteral, FiltraEventosPorTipo, criarEventosFiltrados, Eventos_Recebe, Eventos_Envia, Eventos_RecebeEnvia };
|
package/dist/classes.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
+
// Gerado automaticamente por extrairClasses.ts
|
|
2
3
|
class AuthSession {
|
|
3
4
|
expiredAt;
|
|
4
5
|
id;
|
|
@@ -73,6 +74,40 @@ const PAGINAS = {
|
|
|
73
74
|
nome: 'Página de Mestre',
|
|
74
75
|
},
|
|
75
76
|
};
|
|
77
|
+
function createGateway(config) { return config; }
|
|
78
|
+
//
|
|
79
|
+
var EventosWebSocket;
|
|
80
|
+
(function (EventosWebSocket) {
|
|
81
|
+
const GameEngine = createGateway({
|
|
82
|
+
testeGameEngine1: {
|
|
83
|
+
tipo: 'recebe-envia',
|
|
84
|
+
payload: { teste1: '' },
|
|
85
|
+
response: { ok: true, msg: '' },
|
|
86
|
+
},
|
|
87
|
+
testeGameEngine2: {
|
|
88
|
+
tipo: 'recebe',
|
|
89
|
+
payload: { teste2: 0 },
|
|
90
|
+
},
|
|
91
|
+
testeDuplicado: {
|
|
92
|
+
tipo: 'recebe-envia',
|
|
93
|
+
payload: {},
|
|
94
|
+
response: { msg: '' },
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
const Chat = createGateway({
|
|
98
|
+
testeChat1: {
|
|
99
|
+
tipo: 'recebe-envia',
|
|
100
|
+
payload: { mensagem: '' },
|
|
101
|
+
response: { entregue: true },
|
|
102
|
+
},
|
|
103
|
+
testeDuplicado: {
|
|
104
|
+
tipo: 'recebe-envia',
|
|
105
|
+
payload: {},
|
|
106
|
+
response: { msg: '' },
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
EventosWebSocket.gateways = { GameEngine, Chat };
|
|
110
|
+
})(EventosWebSocket || (EventosWebSocket = {}));
|
|
76
111
|
// @tipoCompartilhadoFront
|
|
77
112
|
var AventuraEstado;
|
|
78
113
|
(function (AventuraEstado) {
|
|
@@ -164,4 +199,20 @@ var EstiloSessao;
|
|
|
164
199
|
EstiloSessao[EstiloSessao["SESSAO_UNICA_NAO_CANONICA"] = 2] = "SESSAO_UNICA_NAO_CANONICA";
|
|
165
200
|
EstiloSessao[EstiloSessao["ERRO"] = 3] = "ERRO";
|
|
166
201
|
})(EstiloSessao || (EstiloSessao = {}));
|
|
167
|
-
|
|
202
|
+
function criarEventosFiltrados(tipo) {
|
|
203
|
+
const result = {};
|
|
204
|
+
for (const [gatewayName, gatewayDef] of Object.entries(EventosWebSocket.gateways)) {
|
|
205
|
+
const eventosFiltrados = Object.entries(gatewayDef).filter(([, evento]) => evento.tipo === tipo).map(([eventName, evento]) => [eventName, {
|
|
206
|
+
...evento,
|
|
207
|
+
nome: eventName,
|
|
208
|
+
gateway: gatewayName,
|
|
209
|
+
fullName: `${gatewayName}:${eventName}`,
|
|
210
|
+
}]);
|
|
211
|
+
result[gatewayName] = { eventos: Object.fromEntries(eventosFiltrados) };
|
|
212
|
+
}
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
const Eventos_Recebe = criarEventosFiltrados('recebe');
|
|
216
|
+
const Eventos_Envia = criarEventosFiltrados('envia');
|
|
217
|
+
const Eventos_RecebeEnvia = criarEventosFiltrados('recebe-envia');
|
|
218
|
+
export { AuthSession, PAGINAS, createGateway, EventosWebSocket, AventuraEstado, EstadoPendenciaPersonagem, EstadoPendenciaAdministrativaPersonagem, EstadoOcupacaoPersonagem, EstadoSessao, DiaDaSemana, obtemDiaDaSemanaPorExtensoPorDDS, CargoExibicaoUsuario, FormatoMomento, EstiloSessao, criarEventosFiltrados, Eventos_Recebe, Eventos_Envia, Eventos_RecebeEnvia };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CONFIGURAÇÃO DE EXTRAÇÃO DE TIPOS
|
|
3
|
+
* Arquivo: extrairClasses.config.ts
|
|
4
|
+
*/
|
|
5
|
+
export declare const FilterType: {
|
|
6
|
+
readonly ALL: "ALL";
|
|
7
|
+
readonly MARKED: "MARKED";
|
|
8
|
+
};
|
|
9
|
+
export type FilterType = typeof FilterType[keyof typeof FilterType];
|
|
10
|
+
export interface ExtractionSource {
|
|
11
|
+
source: string;
|
|
12
|
+
filter: FilterType;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface OutputConfig {
|
|
16
|
+
file: string;
|
|
17
|
+
header: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* CONFIGURAÇÃO PRINCIPAL DE EXTRAÇÃO
|
|
21
|
+
*/
|
|
22
|
+
export declare const EXTRACTION_CONFIG: readonly ExtractionSource[];
|
|
23
|
+
export declare const OUTPUT_CONFIG: OutputConfig;
|
|
24
|
+
/**
|
|
25
|
+
* VALIDAÇÃO DA CONFIGURAÇÃO
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateConfig(): boolean;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CONFIGURAÇÃO DE EXTRAÇÃO DE TIPOS
|
|
3
|
+
* Arquivo: extrairClasses.config.ts
|
|
4
|
+
*/
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { dirname } from 'path';
|
|
8
|
+
// Obter __dirname em ES Modules
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = dirname(__filename);
|
|
11
|
+
// CORREÇÃO: Estamos em src/@types/scripts/, precisamos subir 2 níveis para src/
|
|
12
|
+
// e então acessar modules/ e shared/ que estão no MESMO nível de @types/
|
|
13
|
+
const SRC_ROOT = path.resolve(__dirname, '../../');
|
|
14
|
+
console.log('🔧 SRC_ROOT:', SRC_ROOT);
|
|
15
|
+
// Tipos de filtro disponíveis
|
|
16
|
+
export const FilterType = {
|
|
17
|
+
ALL: 'ALL',
|
|
18
|
+
MARKED: 'MARKED'
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* CONFIGURAÇÃO PRINCIPAL DE EXTRAÇÃO
|
|
22
|
+
*/
|
|
23
|
+
export const EXTRACTION_CONFIG = [
|
|
24
|
+
{
|
|
25
|
+
source: path.join(SRC_ROOT, 'modules/**/*.type.ts'),
|
|
26
|
+
filter: FilterType.ALL,
|
|
27
|
+
description: 'Todos os arquivos .type.ts dentro de src/modules'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
source: path.join(SRC_ROOT, 'shared/types.ts'),
|
|
31
|
+
filter: FilterType.MARKED,
|
|
32
|
+
description: 'Arquivo src/shared/types.ts (apenas com @tipoCompartilhadoFront)'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
source: path.join(SRC_ROOT, 'shared/ws.types.ts'),
|
|
36
|
+
filter: FilterType.ALL,
|
|
37
|
+
description: 'Arquivo src/shared/ws.types.ts (todas as definições exportadas)'
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
export const OUTPUT_CONFIG = {
|
|
41
|
+
file: path.resolve(__dirname, '../src/classes.ts'),
|
|
42
|
+
header: '// AUTO-GENERATED FILE - DO NOT EDIT\n// Gerado automaticamente por extrairClasses.ts\n\n'
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* VALIDAÇÃO DA CONFIGURAÇÃO
|
|
46
|
+
*/
|
|
47
|
+
export function validateConfig() {
|
|
48
|
+
const errors = [];
|
|
49
|
+
EXTRACTION_CONFIG.forEach((config, index) => {
|
|
50
|
+
if (!Object.values(FilterType).includes(config.filter)) {
|
|
51
|
+
errors.push(`Configuração [${index}]: Filtro '${config.filter}' não é válido`);
|
|
52
|
+
}
|
|
53
|
+
if (!config.source || typeof config.source !== 'string') {
|
|
54
|
+
errors.push(`Configuração [${index}]: Source deve ser uma string não vazia`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
if (!OUTPUT_CONFIG.file || typeof OUTPUT_CONFIG.file !== 'string') {
|
|
58
|
+
errors.push('OUTPUT_CONFIG.file deve ser uma string não vazia');
|
|
59
|
+
}
|
|
60
|
+
if (errors.length > 0) {
|
|
61
|
+
throw new Error(`Erro na configuração:\n${errors.join('\n')}`);
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
// Validação automática
|
|
66
|
+
validateConfig();
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SCRIPT PRINCIPAL DE EXTRAÇÃO DE TIPOS
|
|
3
|
+
* Arquivo: extrairClasses.ts
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, writeFileSync } from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import { dirname } from 'path';
|
|
9
|
+
// Configurações e utilitários
|
|
10
|
+
import { EXTRACTION_CONFIG, OUTPUT_CONFIG, validateConfig } from './extrairClasses.config.js';
|
|
11
|
+
import { findTypeFiles, ensureDirectoryExists, processFile, consolidateResults } from './extrairClasses.utils.js';
|
|
12
|
+
// ==================================================
|
|
13
|
+
// INICIALIZAÇÃO E CONFIGURAÇÃO
|
|
14
|
+
// ==================================================
|
|
15
|
+
// Obter __dirname em ES Modules
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const __dirname = dirname(__filename);
|
|
18
|
+
// ==================================================
|
|
19
|
+
// FUNÇÕES AUXILIARES
|
|
20
|
+
// ==================================================
|
|
21
|
+
/**
|
|
22
|
+
* Extrai mensagem de erro de forma segura
|
|
23
|
+
*/
|
|
24
|
+
function getErrorMessage(error) {
|
|
25
|
+
if (error instanceof Error) {
|
|
26
|
+
return error.message;
|
|
27
|
+
}
|
|
28
|
+
return String(error);
|
|
29
|
+
}
|
|
30
|
+
// ==================================================
|
|
31
|
+
// FUNÇÕES DE PROCESSAMENTO
|
|
32
|
+
// ==================================================
|
|
33
|
+
/**
|
|
34
|
+
* Expande padrões glob para lista de arquivos concretos
|
|
35
|
+
*/
|
|
36
|
+
function expandSourcePattern(sourcePattern) {
|
|
37
|
+
// Se for um padrão glob (contém **)
|
|
38
|
+
if (sourcePattern.includes('**')) {
|
|
39
|
+
const baseDir = path.dirname(sourcePattern.replace(/\*\*/g, ''));
|
|
40
|
+
if (!existsSync(baseDir)) {
|
|
41
|
+
console.log(` ❌ Diretório base não existe: ${baseDir}`);
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
return findTypeFiles(baseDir);
|
|
45
|
+
}
|
|
46
|
+
// Se for um arquivo específico
|
|
47
|
+
return [sourcePattern];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Processa uma configuração de extração individual
|
|
51
|
+
*/
|
|
52
|
+
function processExtractionConfig(config) {
|
|
53
|
+
console.log(`\n📁 ${config.description}`);
|
|
54
|
+
console.log(` Source: ${config.source}`);
|
|
55
|
+
console.log(` Filtro: ${config.filter}`);
|
|
56
|
+
try {
|
|
57
|
+
const filesToProcess = expandSourcePattern(config.source);
|
|
58
|
+
console.log(` Arquivos encontrados: ${filesToProcess.length}`);
|
|
59
|
+
const results = [];
|
|
60
|
+
for (const filePath of filesToProcess) {
|
|
61
|
+
if (existsSync(filePath)) {
|
|
62
|
+
const result = processFile(filePath, config.filter);
|
|
63
|
+
results.push(result);
|
|
64
|
+
console.log(` ✅ ${path.relative(process.cwd(), filePath)} → ${result.exportedNames.length} definições`);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
console.warn(` ⚠️ Arquivo não encontrado: ${filePath}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return results;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
console.error(` ❌ Erro:`, getErrorMessage(error));
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Executa o pipeline completo de extração
|
|
79
|
+
*/
|
|
80
|
+
function executeExtractionPipeline() {
|
|
81
|
+
console.log('🚀 INICIANDO EXTRAÇÃO DE TIPOS');
|
|
82
|
+
console.log('='.repeat(60));
|
|
83
|
+
const allProcessingResults = [];
|
|
84
|
+
// Processa cada configuração na ordem definida
|
|
85
|
+
for (const config of EXTRACTION_CONFIG) {
|
|
86
|
+
const configResults = processExtractionConfig(config);
|
|
87
|
+
allProcessingResults.push(...configResults);
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
processingResults: allProcessingResults,
|
|
91
|
+
totalFiles: allProcessingResults.length,
|
|
92
|
+
totalDefinitions: allProcessingResults.reduce((sum, result) => sum + result.exportedNames.length, 0)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Salva o conteúdo consolidado no arquivo de saída
|
|
97
|
+
*/
|
|
98
|
+
function saveConsolidatedFile(consolidatedContent) {
|
|
99
|
+
try {
|
|
100
|
+
ensureDirectoryExists(path.dirname(OUTPUT_CONFIG.file));
|
|
101
|
+
writeFileSync(OUTPUT_CONFIG.file, consolidatedContent, 'utf8');
|
|
102
|
+
console.log(`\n💾 ARQUIVO SALVO: ${OUTPUT_CONFIG.file}`);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
throw new Error(`Erro ao salvar arquivo: ${getErrorMessage(error)}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Exibe resumo da execução
|
|
110
|
+
*/
|
|
111
|
+
function displayExecutionSummary(extractionResult, outputPath) {
|
|
112
|
+
console.log('\n' + '='.repeat(60));
|
|
113
|
+
console.log('📊 RESUMO FINAL');
|
|
114
|
+
console.log('='.repeat(60));
|
|
115
|
+
console.log(`📁 Arquivos processados: ${extractionResult.totalFiles}`);
|
|
116
|
+
console.log(`📝 Definições extraídas: ${extractionResult.totalDefinitions}`);
|
|
117
|
+
console.log(`💾 Arquivo gerado: ${outputPath}`);
|
|
118
|
+
if (extractionResult.totalFiles === 0) {
|
|
119
|
+
console.log('❌ NENHUM ARQUIVO FOI PROCESSADO!');
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
console.log('✅ EXTRAÇÃO CONCLUÍDA COM SUCESSO!');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// ==================================================
|
|
126
|
+
// EXECUÇÃO PRINCIPAL
|
|
127
|
+
// ==================================================
|
|
128
|
+
/**
|
|
129
|
+
* Função principal do script
|
|
130
|
+
*/
|
|
131
|
+
async function main() {
|
|
132
|
+
try {
|
|
133
|
+
console.log('🔧 Iniciando validação da configuração...');
|
|
134
|
+
validateConfig();
|
|
135
|
+
console.log('🔧 Executando pipeline de extração...');
|
|
136
|
+
const extractionResult = executeExtractionPipeline();
|
|
137
|
+
if (extractionResult.totalFiles === 0) {
|
|
138
|
+
console.log('\n⚠️ ATENÇÃO: Nenhum arquivo foi processado!');
|
|
139
|
+
console.log(' Verifique:');
|
|
140
|
+
console.log(' 1. Se os diretórios modules/ e shared/ existem');
|
|
141
|
+
console.log(' 2. Se há arquivos .type.ts em modules/');
|
|
142
|
+
console.log(' 3. Se shared/types.ts e shared/ws.types.ts existem');
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
console.log('\n🔧 Consolidando resultados...');
|
|
146
|
+
const consolidatedContent = consolidateResults(extractionResult.processingResults, OUTPUT_CONFIG.header);
|
|
147
|
+
console.log('🔧 Salvando arquivo final...');
|
|
148
|
+
saveConsolidatedFile(consolidatedContent);
|
|
149
|
+
displayExecutionSummary(extractionResult, OUTPUT_CONFIG.file);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
console.error('\n❌ ERRO CRÍTICO:', getErrorMessage(error));
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// EXECUTAR SEMPRE - SEM CONDIÇÃO
|
|
157
|
+
main().catch(error => {
|
|
158
|
+
console.error('Erro não tratado:', getErrorMessage(error));
|
|
159
|
+
process.exit(1);
|
|
160
|
+
});
|
|
161
|
+
export default main;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UTILITÁRIOS PARA EXTRAÇÃO DE TIPOS
|
|
3
|
+
* Arquivo: extrairClasses.utils.ts
|
|
4
|
+
*/
|
|
5
|
+
import * as ts from 'typescript';
|
|
6
|
+
export interface FileProcessingResult {
|
|
7
|
+
content: string;
|
|
8
|
+
exportedNames: string[];
|
|
9
|
+
filePath: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Marcador para definições que devem ser compartilhadas com o frontend
|
|
13
|
+
*/
|
|
14
|
+
export declare const TIPO_COMPARTILHADO_FRONT_MARKER = "@tipoCompartilhadoFront";
|
|
15
|
+
/**
|
|
16
|
+
* Verifica se um nó AST possui o marcador @tipoCompartilhadoFront
|
|
17
|
+
*/
|
|
18
|
+
export declare function hasTipoCompartilhadoFrontMarker(node: ts.Node, fileContent: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Verifica se uma declaração de variável deve ser considerada para extração
|
|
21
|
+
*/
|
|
22
|
+
export declare function shouldExtractVariableStatement(node: ts.VariableStatement, snippet: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Verifica se um nó deve ser extraído baseado no filtro
|
|
25
|
+
*/
|
|
26
|
+
export declare function shouldExtractNode(node: ts.Node, filterType: string, fileContent: string, snippet: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Remove palavras-chave de export mantendo a declaração
|
|
29
|
+
*/
|
|
30
|
+
export declare function removeExportKeywords(content: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Extrai nomes de identificadores de declarações de variável
|
|
33
|
+
*/
|
|
34
|
+
export declare function extractVariableNames(node: ts.VariableStatement): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Extrai o nome de um nó nomeado
|
|
37
|
+
*/
|
|
38
|
+
export declare function extractNodeName(node: ts.Node): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Encontra recursivamente arquivos .type.ts em um diretório
|
|
41
|
+
*/
|
|
42
|
+
export declare function findTypeFiles(dir: string): string[];
|
|
43
|
+
/**
|
|
44
|
+
* Garante que um diretório existe (cria se necessário)
|
|
45
|
+
*/
|
|
46
|
+
export declare function ensureDirectoryExists(dirPath: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Cria um SourceFile TypeScript para análise AST
|
|
49
|
+
*/
|
|
50
|
+
export declare function createTypeScriptSourceFile(filePath: string, fileContent: string): ts.SourceFile;
|
|
51
|
+
/**
|
|
52
|
+
* Processa um arquivo individual e extrai suas definições
|
|
53
|
+
*/
|
|
54
|
+
export declare function processFile(filePath: string, filterType: string): FileProcessingResult;
|
|
55
|
+
/**
|
|
56
|
+
* Consolida resultados de múltiplos arquivos em conteúdo final
|
|
57
|
+
*/
|
|
58
|
+
export declare function consolidateResults(processingResults: FileProcessingResult[], header?: string): string;
|