@gugananuvem/aws-local-simulator 1.0.8 → 1.0.9

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 (37) hide show
  1. package/bin/aws-local-simulator.js +62 -1
  2. package/package.json +10 -7
  3. package/src/config/config-loader.js +113 -0
  4. package/src/config/default-config.js +65 -0
  5. package/src/config/env-loader.js +67 -0
  6. package/src/index.js +131 -1
  7. package/src/index.mjs +124 -0
  8. package/src/server.js +219 -0
  9. package/src/services/apigateway/index.js +67 -0
  10. package/src/services/apigateway/server.js +435 -0
  11. package/src/services/apigateway/simulator.js +1252 -0
  12. package/src/services/cognito/index.js +66 -0
  13. package/src/services/cognito/server.js +229 -0
  14. package/src/services/cognito/simulator.js +848 -0
  15. package/src/services/dynamodb/index.js +71 -0
  16. package/src/services/dynamodb/server.js +122 -0
  17. package/src/services/dynamodb/simulator.js +614 -0
  18. package/src/services/eventbridge/index.js +85 -0
  19. package/src/services/index.js +19 -0
  20. package/src/services/lambda/handler-loader.js +173 -0
  21. package/src/services/lambda/index.js +73 -0
  22. package/src/services/lambda/route-registry.js +275 -0
  23. package/src/services/lambda/server.js +153 -0
  24. package/src/services/lambda/simulator.js +278 -0
  25. package/src/services/s3/index.js +70 -0
  26. package/src/services/s3/server.js +239 -0
  27. package/src/services/s3/simulator.js +740 -0
  28. package/src/services/sns/index.js +76 -0
  29. package/src/services/sqs/index.js +96 -0
  30. package/src/services/sqs/server.js +274 -0
  31. package/src/services/sqs/simulator.js +660 -0
  32. package/src/template/aws-config-template.js +88 -0
  33. package/src/template/aws-config-template.mjs +91 -0
  34. package/src/template/config-template.json +165 -0
  35. package/src/utils/aws-config.js +92 -0
  36. package/src/utils/local-store.js +68 -0
  37. package/src/utils/logger.js +60 -0
@@ -1,3 +1,64 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- (function(_0x1806d8,_0x213cfd){function _0x21d08c(_0x6c77c6,_0x425b51){return _0x5446(_0x425b51-0x53,_0x6c77c6);}const _0x566036=_0x1806d8();while(!![]){try{const _0x55cd2b=-parseInt(_0x21d08c(0x1c4,0x1b9))/0x1+parseInt(_0x21d08c(0x1bb,0x1b4))/0x2+-parseInt(_0x21d08c(0x1a9,0x1a2))/0x3*(-parseInt(_0x21d08c(0x1ab,0x1a3))/0x4)+-parseInt(_0x21d08c(0x1bf,0x1b8))/0x5*(parseInt(_0x21d08c(0x1a6,0x1a8))/0x6)+parseInt(_0x21d08c(0x1aa,0x1a7))/0x7+parseInt(_0x21d08c(0x1ad,0x1b6))/0x8+-parseInt(_0x21d08c(0x1ae,0x1a9))/0x9;if(_0x55cd2b===_0x213cfd)break;else _0x566036['push'](_0x566036['shift']());}catch(_0xb76872){_0x566036['push'](_0x566036['shift']());}}}(_0x29e7,0xbe531));function _0x5446(_0x43728d,_0x3090ef){_0x43728d=_0x43728d-0x14f;const _0x29e789=_0x29e7();let _0x5446c5=_0x29e789[_0x43728d];return _0x5446c5;}const {AWSLocalSimulator}=require(_0x5b2cfc(0x4ed,0x4f9));function _0x29e7(){const _0x5850a7=['catch','Erro:','log','5193608nMgeOD','697164AYBvBD','2610306HLTuYk','reset','stringify','restart','\x0aAWS\x20Local\x20Simulator\x20-\x20CLI\x20Commands:\x0a\x20\x20start\x20[configPath]\x20\x20-\x20Inicia\x20o\x20simulador\x0a\x20\x20stop\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20-\x20Para\x20o\x20simulador\x0a\x20\x20restart\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20-\x20Reinicia\x20o\x20simulador\x0a\x20\x20reset\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20-\x20Reseta\x20todos\x20os\x20dados\x0a\x20\x20status\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20-\x20Mostra\x20status\x20dos\x20serviços\x0a\x20\x20help\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20-\x20Mostra\x20esta\x20ajuda\x0a\x0aExemplos:\x0a\x20\x20npx\x20aws-local-simulator\x20start\x0a\x20\x20npx\x20aws-local-simulator\x20start\x20./my-config.json\x0a\x20\x20AWS_LOCAL_SIMULATOR_LOG=verboso\x20npx\x20aws-local-simulator\x20start\x0a\x20\x20\x20\x20\x20\x20','getStatus','start','cwd','exit','stop','path','1611254ZmUIbu','argv','4315048VSZSEW','../src/index','65qqfscz','1000745OVtyBn','2240877HpqKQg','8vUjbFl'];_0x29e7=function(){return _0x5850a7;};return _0x29e7();}function _0x5b2cfc(_0x16ecfa,_0x4b679c){return _0x5446(_0x4b679c-0x395,_0x16ecfa);}const logger=require('../src/utils/logger'),path=require(_0x5b2cfc(0x4fb,0x4f5)),command=process[_0x5b2cfc(0x503,0x4f7)][0x2],configPath=process[_0x5b2cfc(0x4fe,0x4f7)][0x3],simulator=new AWSLocalSimulator({'configPath':configPath?path['resolve'](process[_0x5b2cfc(0x4f0,0x4f2)](),configPath):undefined});async function main(){function _0x344dd5(_0x342def,_0x2bcdfe){return _0x5b2cfc(_0x342def,_0x2bcdfe- -0x306);}switch(command){case'start':await simulator[_0x344dd5(0x1f2,0x1eb)]();break;case'stop':await simulator[_0x344dd5(0x1f2,0x1ee)]();break;case _0x344dd5(0x1f2,0x1e8):await simulator['restart']();break;case _0x344dd5(0x1eb,0x1e6):await simulator['reset']();break;case'status':const _0x34576f=simulator[_0x344dd5(0x1ec,0x1ea)]();console[_0x344dd5(0x1e8,0x1e2)](JSON[_0x344dd5(0x1f2,0x1e7)](_0x34576f,null,0x2));break;case'help':default:console[_0x344dd5(0x1ea,0x1e2)](_0x344dd5(0x1ef,0x1e9));break;}}main()[_0x5b2cfc(0x4e7,0x4e6)](_0x4a613c=>{function _0x255ebf(_0x45f7ce,_0x25da30){return _0x5b2cfc(_0x25da30,_0x45f7ce- -0x5a4);}logger['error'](_0x255ebf(-0xbd,-0xb1),_0x4a613c),process[_0x255ebf(-0xb1,-0xbb)](0x1);});
3
+ /**
4
+ * CLI para AWS Local Simulator
5
+ */
6
+
7
+ const { AWSLocalSimulator } = require('../src/index');
8
+ const logger = require('../src/utils/logger');
9
+ const path = require('path');
10
+
11
+ const command = process.argv[2];
12
+ const configPath = process.argv[3];
13
+
14
+ const simulator = new AWSLocalSimulator({
15
+ configPath: configPath ? path.resolve(process.cwd(), configPath) : undefined
16
+ });
17
+
18
+ async function main() {
19
+ switch (command) {
20
+ case 'start':
21
+ await simulator.start();
22
+ break;
23
+
24
+ case 'stop':
25
+ await simulator.stop();
26
+ break;
27
+
28
+ case 'restart':
29
+ await simulator.restart();
30
+ break;
31
+
32
+ case 'reset':
33
+ await simulator.reset();
34
+ break;
35
+
36
+ case 'status':
37
+ const status = simulator.getStatus();
38
+ console.log(JSON.stringify(status, null, 2));
39
+ break;
40
+
41
+ case 'help':
42
+ default:
43
+ console.log(`
44
+ AWS Local Simulator - CLI Commands:
45
+ start [configPath] - Inicia o simulador
46
+ stop - Para o simulador
47
+ restart - Reinicia o simulador
48
+ reset - Reseta todos os dados
49
+ status - Mostra status dos serviços
50
+ help - Mostra esta ajuda
51
+
52
+ Exemplos:
53
+ npx aws-local-simulator start
54
+ npx aws-local-simulator start ./my-config.json
55
+ AWS_LOCAL_SIMULATOR_LOG=verboso npx aws-local-simulator start
56
+ `);
57
+ break;
58
+ }
59
+ }
60
+
61
+ main().catch(error => {
62
+ logger.error('Erro:', error);
63
+ process.exit(1);
64
+ });
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@gugananuvem/aws-local-simulator",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Simulador local completo para serviços AWS",
5
5
  "main": "src/index.js",
6
6
  "bin": {
7
7
  "aws-local-simulator": "bin/aws-local-simulator.js"
8
8
  },
9
+ "scripts": {
10
+ "start": "node bin/aws-local-simulator.js start"
11
+ },
9
12
  "jest": {
10
13
  "setupFilesAfterEnv": [
11
14
  "<rootDir>/tests/setup.js"
@@ -59,7 +62,10 @@
59
62
  "node": ">=14.0.0"
60
63
  },
61
64
  "files": [
62
- "dist/"
65
+ "src/",
66
+ "bin/",
67
+ "README.md",
68
+ "LICENSE"
63
69
  ],
64
70
  "publishConfig": {
65
71
  "directory": "dist"
@@ -103,9 +109,6 @@
103
109
  "optional": true
104
110
  }
105
111
  },
106
- "scripts": {
107
- "start": "node bin/aws-local-simulator.js start"
108
- },
109
- "obfuscated": true,
110
- "obfuscatedAt": "2026-03-29T02:34:32.163Z"
112
+ "buildDate": "2026-03-29T02:36:24.504Z",
113
+ "published": true
111
114
  }
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Carrega configurações do usuário
3
+ */
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const defaultConfig = require('./default-config');
8
+ const EnvLoader = require('./env-loader');
9
+ const logger = require('../utils/logger');
10
+
11
+ class ConfigLoader {
12
+ static async load(configPath) {
13
+ logger.info('📝 Carregando configurações...');
14
+
15
+ // 1. Carrega configurações padrão
16
+ let config = { ...defaultConfig };
17
+
18
+ // 2. Sobrescreve com variáveis de ambiente
19
+ const envConfig = EnvLoader.load();
20
+ config = this.mergeDeep(config, envConfig);
21
+
22
+ // 3. Sobrescreve com arquivo de configuração do usuário se existir
23
+ if (configPath) {
24
+ const userConfig = await this.loadUserConfig(configPath);
25
+ config = this.mergeDeep(config, userConfig);
26
+ } else {
27
+ // Tenta encontrar arquivo de configuração padrão
28
+ const possiblePaths = [
29
+ path.join(process.cwd(), 'aws-local-simulator.json'),
30
+ path.join(process.cwd(), 'aws-local-simulator.config.json'),
31
+ path.join(process.cwd(), '.aws-local-simulator.json')
32
+ ];
33
+
34
+ for (const possiblePath of possiblePaths) {
35
+ if (fs.existsSync(possiblePath)) {
36
+ const userConfig = await this.loadUserConfig(possiblePath);
37
+ config = this.mergeDeep(config, userConfig);
38
+ logger.info(`✅ Configuração carregada de: ${possiblePath}`);
39
+ break;
40
+ }
41
+ }
42
+ }
43
+
44
+ // 4. Valida configurações
45
+ this.validate(config);
46
+
47
+ logger.info(`✅ Configurações carregadas (logLevel: ${config.logLevel})`);
48
+
49
+ return config;
50
+ }
51
+
52
+ static async loadUserConfig(filePath) {
53
+ try {
54
+ const fullPath = path.resolve(process.cwd(), filePath);
55
+
56
+ if (!fs.existsSync(fullPath)) {
57
+ logger.warn(`Arquivo de configuração não encontrado: ${fullPath}`);
58
+ return {};
59
+ }
60
+
61
+ const content = fs.readFileSync(fullPath, 'utf8');
62
+ const config = JSON.parse(content);
63
+
64
+ return config;
65
+ } catch (error) {
66
+ logger.error(`Erro ao carregar configuração de ${filePath}:`, error);
67
+ throw error;
68
+ }
69
+ }
70
+
71
+ static validate(config) {
72
+ // Valida serviços
73
+ const enabledServices = Object.entries(config.services)
74
+ .filter(([_, enabled]) => enabled)
75
+ .map(([name]) => name);
76
+
77
+ if (enabledServices.length === 0) {
78
+ logger.warn('⚠️ Nenhum serviço está habilitado!');
79
+ } else {
80
+ logger.info(`📦 Serviços habilitados: ${enabledServices.join(', ')}`);
81
+ }
82
+
83
+ // Valida diretório de dados
84
+ if (!config.dataDir) {
85
+ throw new Error('dataDir não configurado');
86
+ }
87
+
88
+ // Valida portas
89
+ for (const [service, port] of Object.entries(config.ports)) {
90
+ if (config.services[service] && (port < 1 || port > 65535)) {
91
+ throw new Error(`Porta inválida para ${service}: ${port}`);
92
+ }
93
+ }
94
+ }
95
+
96
+ static mergeDeep(target, source) {
97
+ const output = { ...target };
98
+
99
+ for (const key in source) {
100
+ if (source.hasOwnProperty(key)) {
101
+ if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
102
+ output[key] = this.mergeDeep(target[key] || {}, source[key]);
103
+ } else {
104
+ output[key] = source[key];
105
+ }
106
+ }
107
+ }
108
+
109
+ return output;
110
+ }
111
+ }
112
+
113
+ module.exports = { loadConfig: ConfigLoader.load.bind(ConfigLoader) };
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Configurações padrão do simulador
3
+ */
4
+
5
+ module.exports = {
6
+ // Serviços habilitados por padrão
7
+ services: {
8
+ dynamodb: true,
9
+ s3: true,
10
+ sqs: true,
11
+ lambda: true,
12
+ sns: false, // Desabilitado por padrão
13
+ eventbridge: false, // Desabilitado por padrão
14
+ ecs: false,
15
+ cognito: false,
16
+ apigateway: false,
17
+ },
18
+
19
+ // Portas padrão
20
+ ports: {
21
+ dynamodb: 8000,
22
+ s3: 4566,
23
+ sqs: 9324,
24
+ lambda: 3001,
25
+ sns: 9911,
26
+ eventbridge: 4010,
27
+ ecs: 8080,
28
+ cognito: 9229,
29
+ apigateway: 4567,
30
+ },
31
+ apigateway: {
32
+ defaultCors: {
33
+ allowOrigins: ["*"],
34
+ allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
35
+ allowHeaders: ["*"],
36
+ maxAge: 300,
37
+ },
38
+ defaultThrottling: {
39
+ burstLimit: 100,
40
+ rateLimit: 10,
41
+ },
42
+ enableAccessLogging: true,
43
+ autoDeploy: true,
44
+ },
45
+ // Configurações de persistência
46
+ dataDir: "./.aws-local-simulator-data",
47
+
48
+ // Configurações de logging
49
+ logLevel: "info", // silent, info, debug, verboso
50
+
51
+ // Configurações das Lambdas
52
+ lambdas: [], // Será preenchido pelo usuário
53
+
54
+ // Configurações de CORS
55
+ cors: true,
56
+
57
+ // Auto-criação de tabelas DynamoDB
58
+ autoCreateTables: true,
59
+
60
+ // Auto-criação de buckets S3
61
+ autoCreateBuckets: true,
62
+
63
+ // Configurações adicionais
64
+ additional: {},
65
+ };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Carrega configurações de variáveis de ambiente
3
+ */
4
+
5
+ const logger = require('../utils/logger');
6
+
7
+ class EnvLoader {
8
+ static load() {
9
+ const config = {};
10
+
11
+ // Carrega configuração de serviços
12
+ config.services = {
13
+ dynamodb: this.getEnvBool('AWS_LOCAL_SIMULATOR_DYNAMODB', true),
14
+ s3: this.getEnvBool('AWS_LOCAL_SIMULATOR_S3', true),
15
+ sqs: this.getEnvBool('AWS_LOCAL_SIMULATOR_SQS', true),
16
+ lambda: this.getEnvBool('AWS_LOCAL_SIMULATOR_LAMBDA', true),
17
+ sns: this.getEnvBool('AWS_LOCAL_SIMULATOR_SNS', false),
18
+ eventbridge: this.getEnvBool('AWS_LOCAL_SIMULATOR_EVENTBRIDGE', false)
19
+ };
20
+
21
+ // Carrega portas
22
+ config.ports = {
23
+ dynamodb: this.getEnvInt('AWS_LOCAL_SIMULATOR_DYNAMODB_PORT', 8000),
24
+ s3: this.getEnvInt('AWS_LOCAL_SIMULATOR_S3_PORT', 4566),
25
+ sqs: this.getEnvInt('AWS_LOCAL_SIMULATOR_SQS_PORT', 9324),
26
+ lambda: this.getEnvInt('AWS_LOCAL_SIMULATOR_LAMBDA_PORT', 3001),
27
+ sns: this.getEnvInt('AWS_LOCAL_SIMULATOR_SNS_PORT', 9911),
28
+ eventbridge: this.getEnvInt('AWS_LOCAL_SIMULATOR_EVENTBRIDGE_PORT', 4010)
29
+ };
30
+
31
+ // Carrega diretório de dados
32
+ config.dataDir = process.env.AWS_LOCAL_SIMULATOR_DATA || './.aws-local-simulator-data';
33
+
34
+ // Carrega nível de log
35
+ config.logLevel = process.env.AWS_LOCAL_SIMULATOR_LOG || 'info';
36
+
37
+ // Carrega CORS
38
+ config.cors = this.getEnvBool('AWS_LOCAL_SIMULATOR_CORS', true);
39
+
40
+ // Carrega auto-create
41
+ config.autoCreateTables = this.getEnvBool('AWS_LOCAL_SIMULATOR_AUTO_CREATE_TABLES', true);
42
+ config.autoCreateBuckets = this.getEnvBool('AWS_LOCAL_SIMULATOR_AUTO_CREATE_BUCKETS', true);
43
+
44
+ logger.debug('Variáveis de ambiente carregadas:', config);
45
+
46
+ return config;
47
+ }
48
+
49
+ static getEnvBool(key, defaultValue) {
50
+ const value = process.env[key];
51
+ if (value === undefined) return defaultValue;
52
+ return value === 'true' || value === '1' || value === 'yes';
53
+ }
54
+
55
+ static getEnvInt(key, defaultValue) {
56
+ const value = process.env[key];
57
+ if (value === undefined) return defaultValue;
58
+ const parsed = parseInt(value, 10);
59
+ return isNaN(parsed) ? defaultValue : parsed;
60
+ }
61
+
62
+ static getEnvString(key, defaultValue) {
63
+ return process.env[key] || defaultValue;
64
+ }
65
+ }
66
+
67
+ module.exports = EnvLoader;
package/src/index.js CHANGED
@@ -1 +1,131 @@
1
- function _0x3c6e(){const _0x267fa4=['3667699EdwGTD','1913860DGyRaC','dynamodb','./services/sns','./services/s3','configPath','getStatus','default','getLambda','getService','start','./services/lambda/route-registry','./services/sqs','3155872WshjSv','error','reset','3484602cYDLHv','isRunning','warn','exports','./services/lambda/handler-loader','./utils/logger','❌\x20Erro\x20ao\x20iniciar\x20simulador:','options','864603JLPxOd','stop','restart','2322aZMexD','getS3','✅\x20AWS\x20Local\x20Simulator\x20iniciado\x20com\x20sucesso','974244HpguIW','lambda','success','getSQS','🗑️\x20Todos\x20os\x20dados\x20foram\x20resetados','2162OGKWFU','./config/config-loader','getDynamoDB','❌\x20Erro\x20ao\x20parar\x20simulador:','10nRArVF','getSimulator','server','🛑\x20AWS\x20Local\x20Simulator\x20parado'];_0x3c6e=function(){return _0x267fa4;};return _0x3c6e();}(function(_0x4a0c2d,_0xff59ce){const _0x20fb27=_0x4a0c2d();function _0x5a60f9(_0x53963f,_0x2bde90){return _0x4f28(_0x2bde90- -0x30a,_0x53963f);}while(!![]){try{const _0x249898=-parseInt(_0x5a60f9(-0x1b0,-0x1b5))/0x1+-parseInt(_0x5a60f9(-0x1af,-0x1aa))/0x2*(-parseInt(_0x5a60f9(-0x1a3,-0x1b2))/0x3)+-parseInt(_0x5a60f9(-0x1a4,-0x1a1))/0x4+-parseInt(_0x5a60f9(-0x1a4,-0x1a6))/0x5*(parseInt(_0x5a60f9(-0x19b,-0x1af))/0x6)+parseInt(_0x5a60f9(-0x195,-0x1a2))/0x7+parseInt(_0x5a60f9(-0x1a7,-0x195))/0x8+parseInt(_0x5a60f9(-0x198,-0x192))/0x9;if(_0x249898===_0xff59ce)break;else _0x20fb27['push'](_0x20fb27['shift']());}catch(_0x484db7){_0x20fb27['push'](_0x20fb27['shift']());}}}(_0x3c6e,0x73d81));function _0x4f28(_0x5daf5c,_0x4a0a48){_0x5daf5c=_0x5daf5c-0x14e;const _0x3c6e41=_0x3c6e();let _0x4f28d4=_0x3c6e41[_0x5daf5c];return _0x4f28d4;}const Server=require('./server'),{loadConfig}=require(_0x255a6e(0x449,0x455)),logger=require(_0x255a6e(0x43a,0x436)),DynamoDBService=require('./services/dynamodb'),S3Service=require(_0x255a6e(0x454,0x447)),SQSService=require(_0x255a6e(0x45c,0x466)),LambdaService=require('./services/lambda'),SNSService=require(_0x255a6e(0x453,0x44e)),EventBridgeService=require('./services/eventbridge');function _0x255a6e(_0x3976c1,_0x4db590){return _0x4f28(_0x3976c1-0x2e8,_0x4db590);}const LocalStore=require('./utils/local-store'),HandlerLoader=require(_0x255a6e(0x439,0x43f)),RouteRegistry=require(_0x255a6e(0x45b,0x453));class AWSLocalSimulator{constructor(_0x55e30e={}){function _0x25d1ea(_0x62d8ed,_0x3e4dff){return _0x255a6e(_0x3e4dff-0x59,_0x62d8ed);}this[_0x25d1ea(0x4a4,0x495)]=_0x55e30e,this['server']=null,this['isRunning']=![];}async[_0x255a6e(0x45a,0x447)](){function _0x11214a(_0x22d13f,_0x4c5fc1){return _0x255a6e(_0x4c5fc1- -0x37,_0x22d13f);}if(this['isRunning'])return logger[_0x11214a(0x409,0x400)]('Simulador\x20já\x20está\x20rodando'),this;try{const _0x1f07ba=await loadConfig(this[_0x11214a(0x40d,0x405)][_0x11214a(0x421,0x41e)]);return this[_0x11214a(0x40c,0x417)]=new Server(_0x1f07ba),await this[_0x11214a(0x420,0x417)][_0x11214a(0x435,0x423)](),this[_0x11214a(0x40d,0x3ff)]=!![],logger[_0x11214a(0x3ff,0x40e)](_0x11214a(0x40c,0x40b)),this;}catch(_0x2d397d){logger[_0x11214a(0x43c,0x427)](_0x11214a(0x40d,0x404),_0x2d397d);throw _0x2d397d;}}async['stop'](){if(!this['isRunning']||!this[_0xaff410(0x3a7,0x3b6)])return logger[_0xaff410(0x390,0x38c)]('Simulador\x20não\x20está\x20rodando'),this;function _0xaff410(_0x4b13ba,_0xb219b9){return _0x255a6e(_0x4b13ba- -0xa7,_0xb219b9);}try{return await this[_0xaff410(0x3a7,0x3b6)][_0xaff410(0x397,0x38b)](),this[_0xaff410(0x38f,0x389)]=![],logger['info'](_0xaff410(0x3a8,0x3aa)),this;}catch(_0x163692){logger[_0xaff410(0x3b7,0x3a6)](_0xaff410(0x3a4,0x3b0),_0x163692);throw _0x163692;}}async[_0x255a6e(0x43f,0x435)](){await this[_0x427f33(0x53,0x40)]();function _0x427f33(_0x522dd6,_0x4a1838){return _0x255a6e(_0x522dd6- -0x3eb,_0x4a1838);}return await this[_0x427f33(0x6f,0x70)](),this;}async[_0x255a6e(0x45f,0x465)](){function _0x4d9747(_0x36ee96,_0x44874d){return _0x255a6e(_0x36ee96- -0x152,_0x44874d);}if(!this[_0x4d9747(0x2fc,0x30d)])throw new Error('Simulador\x20não\x20iniciado');return await this[_0x4d9747(0x2fc,0x2ef)][_0x4d9747(0x30d,0x313)](),logger[_0x4d9747(0x2f3,0x2f1)](_0x4d9747(0x2f5,0x2f0)),this;}[_0x255a6e(0x456,0x44e)](){if(!this[_0x4ad5a4(0x14,0x1f)])return{'running':![]};function _0x4ad5a4(_0x244a31,_0xaa5681){return _0x255a6e(_0x244a31- -0x43a,_0xaa5681);}return{'running':this['isRunning'],'services':this[_0x4ad5a4(0x14,0x5)][_0x4ad5a4(0x1c,0xc)]()};}['getService'](_0x5845df){function _0x4aeb90(_0x27ab3b,_0x43520e){return _0x255a6e(_0x43520e- -0x1a6,_0x27ab3b);}if(!this[_0x4aeb90(0x2b6,0x2a8)])return null;return this[_0x4aeb90(0x2a8,0x2a8)][_0x4aeb90(0x2a0,0x2b3)](_0x5845df);}[_0x255a6e(0x44a,0x443)](){function _0x446ce2(_0x3a8ca7,_0x3a3704){return _0x255a6e(_0x3a3704- -0x3cd,_0x3a8ca7);}return this[_0x446ce2(0x97,0x8c)](_0x446ce2(0x98,0x85))?.[_0x446ce2(0x70,0x80)]();}[_0x255a6e(0x441,0x451)](){function _0x1abf5c(_0x236fea,_0x46b8eb){return _0x255a6e(_0x236fea- -0x16d,_0x46b8eb);}return this[_0x1abf5c(0x2ec,0x2eb)]('s3')?.[_0x1abf5c(0x2e0,0x2ea)]();}[_0x255a6e(0x446,0x455)](){function _0x33e45d(_0xad40df,_0x3e2b44){return _0x255a6e(_0xad40df- -0x2bb,_0x3e2b44);}return this[_0x33e45d(0x19e,0x1ac)]('sqs')?.[_0x33e45d(0x192,0x19c)]();}[_0x255a6e(0x458,0x45f)](){function _0x4abf8a(_0x43b4a2,_0x321257){return _0x255a6e(_0x43b4a2- -0x31a,_0x321257);}return this[_0x4abf8a(0x13f,0x152)](_0x4abf8a(0x12a,0x134))?.['getSimulator']();}}module[_0x255a6e(0x438,0x43b)]={'AWSLocalSimulator':AWSLocalSimulator,'Server':Server,'DynamoDBService':DynamoDBService,'S3Service':S3Service,'SQSService':SQSService,'LambdaService':LambdaService,'SNSService':SNSService,'EventBridgeService':EventBridgeService,'LocalStore':LocalStore,'HandlerLoader':HandlerLoader,'RouteRegistry':RouteRegistry},module['exports'][_0x255a6e(0x457,0x445)]=AWSLocalSimulator;
1
+ /**
2
+ * AWS Local Simulator - Entry Point Principal
3
+ */
4
+
5
+ const Server = require('./server');
6
+ const { loadConfig } = require('./config/config-loader');
7
+ const logger = require('./utils/logger');
8
+
9
+ // Exporta serviços para uso programático
10
+ const DynamoDBService = require('./services/dynamodb');
11
+ const S3Service = require('./services/s3');
12
+ const SQSService = require('./services/sqs');
13
+ const LambdaService = require('./services/lambda');
14
+ const SNSService = require('./services/sns');
15
+ const EventBridgeService = require('./services/eventbridge');
16
+
17
+ // Exporta utilitários
18
+ const LocalStore = require('./utils/local-store');
19
+ const HandlerLoader = require('./services/lambda/handler-loader');
20
+ const RouteRegistry = require('./services/lambda/route-registry');
21
+
22
+ class AWSLocalSimulator {
23
+ constructor(options = {}) {
24
+ this.options = options;
25
+ this.server = null;
26
+ this.isRunning = false;
27
+ }
28
+
29
+ async start() {
30
+ if (this.isRunning) {
31
+ logger.warn('Simulador já está rodando');
32
+ return this;
33
+ }
34
+
35
+ try {
36
+ const config = await loadConfig(this.options.configPath);
37
+ this.server = new Server(config);
38
+ await this.server.start();
39
+ this.isRunning = true;
40
+ logger.success('✅ AWS Local Simulator iniciado com sucesso');
41
+ return this;
42
+ } catch (error) {
43
+ logger.error('❌ Erro ao iniciar simulador:', error);
44
+ throw error;
45
+ }
46
+ }
47
+
48
+ async stop() {
49
+ if (!this.isRunning || !this.server) {
50
+ logger.warn('Simulador não está rodando');
51
+ return this;
52
+ }
53
+
54
+ try {
55
+ await this.server.stop();
56
+ this.isRunning = false;
57
+ logger.info('🛑 AWS Local Simulator parado');
58
+ return this;
59
+ } catch (error) {
60
+ logger.error('❌ Erro ao parar simulador:', error);
61
+ throw error;
62
+ }
63
+ }
64
+
65
+ async restart() {
66
+ await this.stop();
67
+ await this.start();
68
+ return this;
69
+ }
70
+
71
+ async reset() {
72
+ if (!this.server) {
73
+ throw new Error('Simulador não iniciado');
74
+ }
75
+ await this.server.reset();
76
+ logger.success('🗑️ Todos os dados foram resetados');
77
+ return this;
78
+ }
79
+
80
+ getStatus() {
81
+ if (!this.server) {
82
+ return { running: false };
83
+ }
84
+ return {
85
+ running: this.isRunning,
86
+ services: this.server.getStatus()
87
+ };
88
+ }
89
+
90
+ getService(serviceName) {
91
+ if (!this.server) {
92
+ return null;
93
+ }
94
+ return this.server.getService(serviceName);
95
+ }
96
+
97
+ // Métodos de conveniência
98
+ getDynamoDB() {
99
+ return this.getService('dynamodb')?.getSimulator();
100
+ }
101
+
102
+ getS3() {
103
+ return this.getService('s3')?.getSimulator();
104
+ }
105
+
106
+ getSQS() {
107
+ return this.getService('sqs')?.getSimulator();
108
+ }
109
+
110
+ getLambda() {
111
+ return this.getService('lambda')?.getSimulator();
112
+ }
113
+ }
114
+
115
+ // Exporta classes e utilitários
116
+ module.exports = {
117
+ AWSLocalSimulator,
118
+ Server,
119
+ DynamoDBService,
120
+ S3Service,
121
+ SQSService,
122
+ LambdaService,
123
+ SNSService,
124
+ EventBridgeService,
125
+ LocalStore,
126
+ HandlerLoader,
127
+ RouteRegistry
128
+ };
129
+
130
+ // Exporta também como default para ES Modules compatibilidade
131
+ module.exports.default = AWSLocalSimulator;
package/src/index.mjs ADDED
@@ -0,0 +1,124 @@
1
+ /**
2
+ * AWS Local Simulator - ES Module Entry Point
3
+ */
4
+
5
+ import Server from './server.js';
6
+ import { loadConfig } from './config/config-loader.js';
7
+ import logger from './utils/logger.js';
8
+ import DynamoDBService from './services/dynamodb/index.js';
9
+ import S3Service from './services/s3/index.js';
10
+ import SQSService from './services/sqs/index.js';
11
+ import LambdaService from './services/lambda/index.js';
12
+ import SNSService from './services/sns/index.js';
13
+ import EventBridgeService from './services/eventbridge/index.js';
14
+ import LocalStore from './utils/local-store.js';
15
+ import HandlerLoader from './services/lambda/handler-loader.js';
16
+ import RouteRegistry from './services/lambda/route-registry.js';
17
+
18
+ export class AWSLocalSimulator {
19
+ constructor(options = {}) {
20
+ this.options = options;
21
+ this.server = null;
22
+ this.isRunning = false;
23
+ }
24
+
25
+ async start() {
26
+ if (this.isRunning) {
27
+ logger.warn('Simulador já está rodando');
28
+ return this;
29
+ }
30
+
31
+ try {
32
+ const config = await loadConfig(this.options.configPath);
33
+ this.server = new Server(config);
34
+ await this.server.start();
35
+ this.isRunning = true;
36
+ logger.success('✅ AWS Local Simulator iniciado com sucesso');
37
+ return this;
38
+ } catch (error) {
39
+ logger.error('❌ Erro ao iniciar simulador:', error);
40
+ throw error;
41
+ }
42
+ }
43
+
44
+ async stop() {
45
+ if (!this.isRunning || !this.server) {
46
+ logger.warn('Simulador não está rodando');
47
+ return this;
48
+ }
49
+
50
+ try {
51
+ await this.server.stop();
52
+ this.isRunning = false;
53
+ logger.info('🛑 AWS Local Simulator parado');
54
+ return this;
55
+ } catch (error) {
56
+ logger.error('❌ Erro ao parar simulador:', error);
57
+ throw error;
58
+ }
59
+ }
60
+
61
+ async restart() {
62
+ await this.stop();
63
+ await this.start();
64
+ return this;
65
+ }
66
+
67
+ async reset() {
68
+ if (!this.server) {
69
+ throw new Error('Simulador não iniciado');
70
+ }
71
+ await this.server.reset();
72
+ logger.success('🗑️ Todos os dados foram resetados');
73
+ return this;
74
+ }
75
+
76
+ getStatus() {
77
+ if (!this.server) {
78
+ return { running: false };
79
+ }
80
+ return {
81
+ running: this.isRunning,
82
+ services: this.server.getStatus()
83
+ };
84
+ }
85
+
86
+ getService(serviceName) {
87
+ if (!this.server) {
88
+ return null;
89
+ }
90
+ return this.server.getService(serviceName);
91
+ }
92
+
93
+ getDynamoDB() {
94
+ return this.getService('dynamodb')?.getSimulator();
95
+ }
96
+
97
+ getS3() {
98
+ return this.getService('s3')?.getSimulator();
99
+ }
100
+
101
+ getSQS() {
102
+ return this.getService('sqs')?.getSimulator();
103
+ }
104
+
105
+ getLambda() {
106
+ return this.getService('lambda')?.getSimulator();
107
+ }
108
+ }
109
+
110
+ // Exporta classes e utilitários
111
+ export {
112
+ Server,
113
+ DynamoDBService,
114
+ S3Service,
115
+ SQSService,
116
+ LambdaService,
117
+ SNSService,
118
+ EventBridgeService,
119
+ LocalStore,
120
+ HandlerLoader,
121
+ RouteRegistry
122
+ };
123
+
124
+ export default AWSLocalSimulator;