@gugananuvem/aws-local-simulator 1.0.9 → 1.0.11

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 (41) hide show
  1. package/README.md +204 -192
  2. package/bin/aws-local-simulator.js +62 -62
  3. package/package.json +2 -2
  4. package/src/config/config-loader.js +112 -112
  5. package/src/config/default-config.js +65 -65
  6. package/src/config/env-loader.js +68 -66
  7. package/src/index.js +130 -130
  8. package/src/index.mjs +123 -123
  9. package/src/server.js +221 -219
  10. package/src/services/apigateway/index.js +66 -66
  11. package/src/services/apigateway/server.js +434 -434
  12. package/src/services/apigateway/simulator.js +1251 -1251
  13. package/src/services/cognito/index.js +65 -65
  14. package/src/services/cognito/server.js +228 -228
  15. package/src/services/cognito/simulator.js +847 -847
  16. package/src/services/dynamodb/index.js +70 -70
  17. package/src/services/dynamodb/server.js +121 -121
  18. package/src/services/dynamodb/simulator.js +620 -614
  19. package/src/services/ecs/index.js +66 -0
  20. package/src/services/ecs/server.js +234 -0
  21. package/src/services/ecs/simulator.js +845 -0
  22. package/src/services/eventbridge/index.js +84 -84
  23. package/src/services/index.js +18 -18
  24. package/src/services/lambda/handler-loader.js +172 -172
  25. package/src/services/lambda/index.js +72 -72
  26. package/src/services/lambda/route-registry.js +274 -274
  27. package/src/services/lambda/server.js +152 -152
  28. package/src/services/lambda/simulator.js +284 -277
  29. package/src/services/s3/index.js +69 -69
  30. package/src/services/s3/server.js +238 -238
  31. package/src/services/s3/simulator.js +740 -740
  32. package/src/services/sns/index.js +75 -75
  33. package/src/services/sqs/index.js +95 -95
  34. package/src/services/sqs/server.js +273 -273
  35. package/src/services/sqs/simulator.js +659 -659
  36. package/src/template/aws-config-template.js +87 -87
  37. package/src/template/aws-config-template.mjs +90 -90
  38. package/src/template/config-template.json +203 -165
  39. package/src/utils/aws-config.js +91 -91
  40. package/src/utils/local-store.js +67 -67
  41. package/src/utils/logger.js +59 -59
@@ -1,76 +1,76 @@
1
- /**
2
- * SNS Service - Ponto de entrada (Stub para implementação futura)
3
- */
4
-
5
- const logger = require('../../utils/logger');
6
-
7
- class SNSService {
8
- constructor(config) {
9
- this.config = config;
10
- this.name = 'sns';
11
- this.port = config.ports.sns;
12
- this.isRunning = false;
13
- this.topics = new Map();
14
- }
15
-
16
- async initialize() {
17
- logger.debug(`Inicializando SNS Service na porta ${this.port}...`);
18
- logger.warn('⚠️ SNS Service ainda não está completamente implementado');
19
-
20
- // TODO: Implementar SNS simulator
21
- // Por enquanto, apenas cria um stub
22
- this.topics = new Map();
23
- }
24
-
25
- async start() {
26
- if (this.isRunning) return;
27
-
28
- // TODO: Iniciar servidor HTTP para SNS
29
- this.isRunning = true;
30
- logger.info(`📢 SNS Service stub rodando (porta ${this.port}) - Implementação em breve`);
31
- }
32
-
33
- async stop() {
34
- if (!this.isRunning) return;
35
- this.isRunning = false;
36
- }
37
-
38
- async reset() {
39
- this.topics.clear();
40
- logger.debug('SNS: Todos os dados resetados');
41
- }
42
-
43
- getStatus() {
44
- return {
45
- running: this.isRunning,
46
- port: this.port,
47
- endpoint: `http://localhost:${this.port}`,
48
- implemented: false,
49
- topicsCount: this.topics.size
50
- };
51
- }
52
-
53
- // Métodos stub para compatibilidade
54
- async createTopic(topicName) {
55
- if (!this.topics.has(topicName)) {
56
- this.topics.set(topicName, {
57
- name: topicName,
58
- arn: `arn:aws:sns:local:000000000000:${topicName}`,
59
- subscriptions: [],
60
- createdAt: new Date().toISOString()
61
- });
62
- }
63
- return this.topics.get(topicName);
64
- }
65
-
66
- async publish(topicArn, message) {
67
- const topic = Array.from(this.topics.values()).find(t => t.arn === topicArn);
68
- if (!topic) {
69
- throw new Error(`Topic not found: ${topicArn}`);
70
- }
71
- logger.verboso(`SNS: Published message to ${topic.name}`);
72
- return { MessageId: Math.random().toString(36).substring(7) };
73
- }
74
- }
75
-
1
+ /**
2
+ * SNS Service - Ponto de entrada (Stub para implementação futura)
3
+ */
4
+
5
+ const logger = require('../../utils/logger');
6
+
7
+ class SNSService {
8
+ constructor(config) {
9
+ this.config = config;
10
+ this.name = 'sns';
11
+ this.port = config.ports.sns;
12
+ this.isRunning = false;
13
+ this.topics = new Map();
14
+ }
15
+
16
+ async initialize() {
17
+ logger.debug(`Inicializando SNS Service na porta ${this.port}...`);
18
+ logger.warn('⚠️ SNS Service ainda não está completamente implementado');
19
+
20
+ // TODO: Implementar SNS simulator
21
+ // Por enquanto, apenas cria um stub
22
+ this.topics = new Map();
23
+ }
24
+
25
+ async start() {
26
+ if (this.isRunning) return;
27
+
28
+ // TODO: Iniciar servidor HTTP para SNS
29
+ this.isRunning = true;
30
+ logger.info(`📢 SNS Service stub rodando (porta ${this.port}) - Implementação em breve`);
31
+ }
32
+
33
+ async stop() {
34
+ if (!this.isRunning) return;
35
+ this.isRunning = false;
36
+ }
37
+
38
+ async reset() {
39
+ this.topics.clear();
40
+ logger.debug('SNS: Todos os dados resetados');
41
+ }
42
+
43
+ getStatus() {
44
+ return {
45
+ running: this.isRunning,
46
+ port: this.port,
47
+ endpoint: `http://localhost:${this.port}`,
48
+ implemented: false,
49
+ topicsCount: this.topics.size
50
+ };
51
+ }
52
+
53
+ // Métodos stub para compatibilidade
54
+ async createTopic(topicName) {
55
+ if (!this.topics.has(topicName)) {
56
+ this.topics.set(topicName, {
57
+ name: topicName,
58
+ arn: `arn:aws:sns:local:000000000000:${topicName}`,
59
+ subscriptions: [],
60
+ createdAt: new Date().toISOString()
61
+ });
62
+ }
63
+ return this.topics.get(topicName);
64
+ }
65
+
66
+ async publish(topicArn, message) {
67
+ const topic = Array.from(this.topics.values()).find(t => t.arn === topicArn);
68
+ if (!topic) {
69
+ throw new Error(`Topic not found: ${topicArn}`);
70
+ }
71
+ logger.verboso(`SNS: Published message to ${topic.name}`);
72
+ return { MessageId: Math.random().toString(36).substring(7) };
73
+ }
74
+ }
75
+
76
76
  module.exports = SNSService;
@@ -1,96 +1,96 @@
1
- /**
2
- * SQS Service - Ponto de entrada
3
- * Exporta o serviço principal e seus componentes
4
- */
5
-
6
- const SQSServer = require('./server');
7
- const SQSSimulator = require('./simulator');
8
-
9
- class SQSService {
10
- constructor(config, dependencies = {}) {
11
- this.config = config;
12
- this.lambdaService = dependencies.lambda;
13
- this.name = 'sqs';
14
- this.port = config.ports.sqs;
15
- this.server = null;
16
- this.simulator = null;
17
- this.isRunning = false;
18
- }
19
-
20
- async initialize() {
21
- const logger = require('../../utils/logger');
22
- logger.debug(`Inicializando SQS Service na porta ${this.port}...`);
23
-
24
- // Cria o simulador
25
- this.simulator = new SQSSimulator(this.config, this.lambdaService);
26
-
27
- // Cria o servidor HTTP
28
- this.server = new SQSServer(this.port, this.config, this.lambdaService);
29
- this.server.simulator = this.simulator;
30
-
31
- await this.server.initialize();
32
-
33
- // Configura filas associadas a Lambdas
34
- await this.setupQueueTriggers();
35
-
36
- logger.debug('SQS Service inicializado');
37
- }
38
-
39
- async setupQueueTriggers() {
40
- if (!this.config.sqs?.queues) return;
41
-
42
- const logger = require('../../utils/logger');
43
-
44
- for (const queueConfig of this.config.sqs.queues) {
45
- if (queueConfig.lambdaPath && this.lambdaService) {
46
- const handler = this.lambdaService.getHandler(queueConfig.lambdaPath);
47
- if (handler) {
48
- this.simulator.attachLambdaToQueue(
49
- queueConfig.name,
50
- handler,
51
- { batchSize: queueConfig.batchSize || 10 }
52
- );
53
- logger.debug(`🔗 Fila ${queueConfig.name} -> Lambda ${queueConfig.lambdaPath}`);
54
- } else {
55
- logger.warn(`⚠️ Lambda não encontrada para fila ${queueConfig.name}: ${queueConfig.lambdaPath}`);
56
- }
57
- }
58
- }
59
- }
60
-
61
- async start() {
62
- if (this.isRunning) return;
63
- await this.server.start();
64
- this.isRunning = true;
65
- }
66
-
67
- async stop() {
68
- if (!this.isRunning) return;
69
- await this.server.stop();
70
- this.isRunning = false;
71
- }
72
-
73
- async reset() {
74
- await this.simulator.reset();
75
- }
76
-
77
- getStatus() {
78
- return {
79
- running: this.isRunning,
80
- port: this.port,
81
- endpoint: `http://localhost:${this.port}`,
82
- queuesCount: this.simulator?.getQueuesCount() || 0,
83
- messagesCount: this.simulator?.getTotalMessagesCount() || 0
84
- };
85
- }
86
-
87
- getSimulator() {
88
- return this.simulator;
89
- }
90
-
91
- getServer() {
92
- return this.server;
93
- }
94
- }
95
-
1
+ /**
2
+ * SQS Service - Ponto de entrada
3
+ * Exporta o serviço principal e seus componentes
4
+ */
5
+
6
+ const SQSServer = require('./server');
7
+ const SQSSimulator = require('./simulator');
8
+
9
+ class SQSService {
10
+ constructor(config, dependencies = {}) {
11
+ this.config = config;
12
+ this.lambdaService = dependencies.lambda;
13
+ this.name = 'sqs';
14
+ this.port = config.ports.sqs;
15
+ this.server = null;
16
+ this.simulator = null;
17
+ this.isRunning = false;
18
+ }
19
+
20
+ async initialize() {
21
+ const logger = require('../../utils/logger');
22
+ logger.debug(`Inicializando SQS Service na porta ${this.port}...`);
23
+
24
+ // Cria o simulador
25
+ this.simulator = new SQSSimulator(this.config, this.lambdaService);
26
+
27
+ // Cria o servidor HTTP
28
+ this.server = new SQSServer(this.port, this.config, this.lambdaService);
29
+ this.server.simulator = this.simulator;
30
+
31
+ await this.server.initialize();
32
+
33
+ // Configura filas associadas a Lambdas
34
+ await this.setupQueueTriggers();
35
+
36
+ logger.debug('SQS Service inicializado');
37
+ }
38
+
39
+ async setupQueueTriggers() {
40
+ if (!this.config.sqs?.queues) return;
41
+
42
+ const logger = require('../../utils/logger');
43
+
44
+ for (const queueConfig of this.config.sqs.queues) {
45
+ if (queueConfig.lambdaPath && this.lambdaService) {
46
+ const handler = this.lambdaService.getHandler(queueConfig.lambdaPath);
47
+ if (handler) {
48
+ this.simulator.attachLambdaToQueue(
49
+ queueConfig.name,
50
+ handler,
51
+ { batchSize: queueConfig.batchSize || 10 }
52
+ );
53
+ logger.debug(`🔗 Fila ${queueConfig.name} -> Lambda ${queueConfig.lambdaPath}`);
54
+ } else {
55
+ logger.warn(`⚠️ Lambda não encontrada para fila ${queueConfig.name}: ${queueConfig.lambdaPath}`);
56
+ }
57
+ }
58
+ }
59
+ }
60
+
61
+ async start() {
62
+ if (this.isRunning) return;
63
+ await this.server.start();
64
+ this.isRunning = true;
65
+ }
66
+
67
+ async stop() {
68
+ if (!this.isRunning) return;
69
+ await this.server.stop();
70
+ this.isRunning = false;
71
+ }
72
+
73
+ async reset() {
74
+ await this.simulator.reset();
75
+ }
76
+
77
+ getStatus() {
78
+ return {
79
+ running: this.isRunning,
80
+ port: this.port,
81
+ endpoint: `http://localhost:${this.port}`,
82
+ queuesCount: this.simulator?.getQueuesCount() || 0,
83
+ messagesCount: this.simulator?.getTotalMessagesCount() || 0
84
+ };
85
+ }
86
+
87
+ getSimulator() {
88
+ return this.simulator;
89
+ }
90
+
91
+ getServer() {
92
+ return this.server;
93
+ }
94
+ }
95
+
96
96
  module.exports = SQSService;