@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,68 +1,68 @@
1
- /**
2
- * Local Store - Persistência em arquivos JSON
3
- */
4
-
5
- const fs = require('fs');
6
- const path = require('path');
7
- const mkdirp = require('mkdirp');
8
-
9
- class LocalStore {
10
- constructor(dataDir) {
11
- this.dataDir = dataDir;
12
- this.ensureDir();
13
- }
14
-
15
- ensureDir() {
16
- if (!fs.existsSync(this.dataDir)) {
17
- mkdirp.sync(this.dataDir);
18
- }
19
- }
20
-
21
- getFilePath(entity) {
22
- return path.join(this.dataDir, `${entity}.json`);
23
- }
24
-
25
- read(entity) {
26
- const filePath = this.getFilePath(entity);
27
- if (!fs.existsSync(filePath)) return [];
28
-
29
- try {
30
- const content = fs.readFileSync(filePath, 'utf8');
31
- return JSON.parse(content);
32
- } catch (error) {
33
- console.error(`Erro ao ler ${entity}:`, error);
34
- return [];
35
- }
36
- }
37
-
38
- write(entity, data) {
39
- const filePath = this.getFilePath(entity);
40
- try {
41
- fs.writeFileSync(filePath, JSON.stringify(data, null, 2));
42
- } catch (error) {
43
- console.error(`Erro ao escrever ${entity}:`, error);
44
- throw error;
45
- }
46
- }
47
-
48
- delete(entity) {
49
- const filePath = this.getFilePath(entity);
50
- if (fs.existsSync(filePath)) {
51
- fs.unlinkSync(filePath);
52
- }
53
- }
54
-
55
- exists(entity) {
56
- const filePath = this.getFilePath(entity);
57
- return fs.existsSync(filePath);
58
- }
59
-
60
- list() {
61
- if (!fs.existsSync(this.dataDir)) return [];
62
- return fs.readdirSync(this.dataDir)
63
- .filter(f => f.endsWith('.json'))
64
- .map(f => f.replace('.json', ''));
65
- }
66
- }
67
-
1
+ /**
2
+ * Local Store - Persistência em arquivos JSON
3
+ */
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const mkdirp = require('mkdirp');
8
+
9
+ class LocalStore {
10
+ constructor(dataDir) {
11
+ this.dataDir = dataDir;
12
+ this.ensureDir();
13
+ }
14
+
15
+ ensureDir() {
16
+ if (!fs.existsSync(this.dataDir)) {
17
+ mkdirp.sync(this.dataDir);
18
+ }
19
+ }
20
+
21
+ getFilePath(entity) {
22
+ return path.join(this.dataDir, `${entity}.json`);
23
+ }
24
+
25
+ read(entity) {
26
+ const filePath = this.getFilePath(entity);
27
+ if (!fs.existsSync(filePath)) return [];
28
+
29
+ try {
30
+ const content = fs.readFileSync(filePath, 'utf8');
31
+ return JSON.parse(content);
32
+ } catch (error) {
33
+ console.error(`Erro ao ler ${entity}:`, error);
34
+ return [];
35
+ }
36
+ }
37
+
38
+ write(entity, data) {
39
+ const filePath = this.getFilePath(entity);
40
+ try {
41
+ fs.writeFileSync(filePath, JSON.stringify(data, null, 2));
42
+ } catch (error) {
43
+ console.error(`Erro ao escrever ${entity}:`, error);
44
+ throw error;
45
+ }
46
+ }
47
+
48
+ delete(entity) {
49
+ const filePath = this.getFilePath(entity);
50
+ if (fs.existsSync(filePath)) {
51
+ fs.unlinkSync(filePath);
52
+ }
53
+ }
54
+
55
+ exists(entity) {
56
+ const filePath = this.getFilePath(entity);
57
+ return fs.existsSync(filePath);
58
+ }
59
+
60
+ list() {
61
+ if (!fs.existsSync(this.dataDir)) return [];
62
+ return fs.readdirSync(this.dataDir)
63
+ .filter(f => f.endsWith('.json'))
64
+ .map(f => f.replace('.json', ''));
65
+ }
66
+ }
67
+
68
68
  module.exports = LocalStore;
@@ -1,60 +1,60 @@
1
- /**
2
- * Logger configurável
3
- */
4
-
5
- let currentLogLevel = 'info';
6
-
7
- const LOG_LEVELS = {
8
- silent: 0,
9
- error: 1,
10
- warn: 2,
11
- info: 3,
12
- debug: 4,
13
- verboso: 5
14
- };
15
-
16
- class Logger {
17
- static setLevel(level) {
18
- if (LOG_LEVELS[level] !== undefined) {
19
- currentLogLevel = level;
20
- }
21
- }
22
-
23
- static error(...args) {
24
- if (LOG_LEVELS[currentLogLevel] >= LOG_LEVELS.error) {
25
- console.error('\x1b[31m%s\x1b[0m', '❌', ...args);
26
- }
27
- }
28
-
29
- static warn(...args) {
30
- if (LOG_LEVELS[currentLogLevel] >= LOG_LEVELS.warn) {
31
- console.warn('\x1b[33m%s\x1b[0m', '⚠️', ...args);
32
- }
33
- }
34
-
35
- static info(...args) {
36
- if (LOG_LEVELS[currentLogLevel] >= LOG_LEVELS.info) {
37
- console.log('\x1b[36m%s\x1b[0m', 'ℹ️', ...args);
38
- }
39
- }
40
-
41
- static debug(...args) {
42
- if (LOG_LEVELS[currentLogLevel] >= LOG_LEVELS.debug) {
43
- console.debug('\x1b[90m%s\x1b[0m', '🔍', ...args);
44
- }
45
- }
46
-
47
- static verboso(...args) {
48
- if (LOG_LEVELS[currentLogLevel] >= LOG_LEVELS.verboso) {
49
- console.log('\x1b[35m%s\x1b[0m', '📝', ...args);
50
- }
51
- }
52
-
53
- static success(...args) {
54
- if (LOG_LEVELS[currentLogLevel] >= LOG_LEVELS.info) {
55
- console.log('\x1b[32m%s\x1b[0m', '✅', ...args);
56
- }
57
- }
58
- }
59
-
1
+ /**
2
+ * Logger configurável
3
+ */
4
+
5
+ let currentLogLevel = 'info';
6
+
7
+ const LOG_LEVELS = {
8
+ silent: 0,
9
+ error: 1,
10
+ warn: 2,
11
+ info: 3,
12
+ debug: 4,
13
+ verboso: 5
14
+ };
15
+
16
+ class Logger {
17
+ static setLevel(level) {
18
+ if (LOG_LEVELS[level] !== undefined) {
19
+ currentLogLevel = level;
20
+ }
21
+ }
22
+
23
+ static error(...args) {
24
+ if (LOG_LEVELS[currentLogLevel] >= LOG_LEVELS.error) {
25
+ console.error('\x1b[31m%s\x1b[0m', '❌', ...args);
26
+ }
27
+ }
28
+
29
+ static warn(...args) {
30
+ if (LOG_LEVELS[currentLogLevel] >= LOG_LEVELS.warn) {
31
+ console.warn('\x1b[33m%s\x1b[0m', '⚠️', ...args);
32
+ }
33
+ }
34
+
35
+ static info(...args) {
36
+ if (LOG_LEVELS[currentLogLevel] >= LOG_LEVELS.info) {
37
+ console.log('\x1b[36m%s\x1b[0m', 'ℹ️', ...args);
38
+ }
39
+ }
40
+
41
+ static debug(...args) {
42
+ if (LOG_LEVELS[currentLogLevel] >= LOG_LEVELS.debug) {
43
+ console.debug('\x1b[90m%s\x1b[0m', '🔍', ...args);
44
+ }
45
+ }
46
+
47
+ static verboso(...args) {
48
+ if (LOG_LEVELS[currentLogLevel] >= LOG_LEVELS.verboso) {
49
+ console.log('\x1b[35m%s\x1b[0m', '📝', ...args);
50
+ }
51
+ }
52
+
53
+ static success(...args) {
54
+ if (LOG_LEVELS[currentLogLevel] >= LOG_LEVELS.info) {
55
+ console.log('\x1b[32m%s\x1b[0m', '✅', ...args);
56
+ }
57
+ }
58
+ }
59
+
60
60
  module.exports = Logger;