infrawise 0.5.0 → 0.6.0
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/README.md +5 -11
- package/dist/adapters/aws.js +50 -64
- package/dist/adapters/dynamodb.js +17 -22
- package/dist/adapters/logs.js +12 -16
- package/dist/adapters/mongodb.js +10 -16
- package/dist/adapters/mysql.js +8 -17
- package/dist/adapters/postgres.js +9 -13
- package/dist/adapters/terraform.js +14 -56
- package/dist/analyzers/aws-services.js +7 -17
- package/dist/analyzers/dynamodb.js +6 -12
- package/dist/analyzers/index.js +13 -41
- package/dist/analyzers/mongodb.js +4 -9
- package/dist/analyzers/mysql.js +4 -9
- package/dist/analyzers/postgres.js +3 -9
- package/dist/analyzers/rds.js +5 -13
- package/dist/analyzers/terraform.js +1 -5
- package/dist/cli/commands/analyze.js +118 -158
- package/dist/cli/commands/auth.js +24 -30
- package/dist/cli/commands/dev.js +45 -84
- package/dist/cli/commands/doctor.js +35 -74
- package/dist/cli/commands/init.js +33 -72
- package/dist/cli/index.js +21 -23
- package/dist/cli/utils.js +40 -86
- package/dist/context/index.js +49 -85
- package/dist/core/cache.js +5 -43
- package/dist/core/config.js +43 -82
- package/dist/core/errors.js +7 -17
- package/dist/core/index.js +4 -22
- package/dist/core/logger.js +4 -10
- package/dist/graph/index.js +15 -32
- package/dist/server/index.js +84 -89
- package/dist/types.js +1 -2
- package/package.json +31 -30
package/dist/core/cache.js
CHANGED
|
@@ -1,43 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.writeCache = writeCache;
|
|
37
|
-
exports.readCache = readCache;
|
|
38
|
-
exports.clearCache = clearCache;
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
const path = __importStar(require("path"));
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
41
3
|
const CACHE_VERSION = '1.0.0';
|
|
42
4
|
const CACHE_DIR = path.join(process.cwd(), '.infrawise', 'cache');
|
|
43
5
|
function ensureCacheDir() {
|
|
@@ -45,7 +7,7 @@ function ensureCacheDir() {
|
|
|
45
7
|
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
|
46
8
|
}
|
|
47
9
|
}
|
|
48
|
-
function writeCache(key, data) {
|
|
10
|
+
export function writeCache(key, data) {
|
|
49
11
|
ensureCacheDir();
|
|
50
12
|
const entry = {
|
|
51
13
|
timestamp: Date.now(),
|
|
@@ -55,7 +17,7 @@ function writeCache(key, data) {
|
|
|
55
17
|
const filePath = path.join(CACHE_DIR, `${key}.json`);
|
|
56
18
|
fs.writeFileSync(filePath, JSON.stringify(entry, null, 2), 'utf-8');
|
|
57
19
|
}
|
|
58
|
-
function readCache(key, maxAgeMs = 3600000) {
|
|
20
|
+
export function readCache(key, maxAgeMs = 3600000) {
|
|
59
21
|
const filePath = path.join(CACHE_DIR, `${key}.json`);
|
|
60
22
|
if (!fs.existsSync(filePath))
|
|
61
23
|
return null;
|
|
@@ -72,7 +34,7 @@ function readCache(key, maxAgeMs = 3600000) {
|
|
|
72
34
|
return null;
|
|
73
35
|
}
|
|
74
36
|
}
|
|
75
|
-
function clearCache(key) {
|
|
37
|
+
export function clearCache(key) {
|
|
76
38
|
if (key) {
|
|
77
39
|
const filePath = path.join(CACHE_DIR, `${key}.json`);
|
|
78
40
|
if (fs.existsSync(filePath))
|
package/dist/core/config.js
CHANGED
|
@@ -1,90 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ConfigError = exports.InfrawiseConfigSchema = void 0;
|
|
37
|
-
exports.loadConfig = loadConfig;
|
|
38
|
-
exports.generateDefaultConfig = generateDefaultConfig;
|
|
39
|
-
const zod_1 = require("zod");
|
|
40
|
-
const fs = __importStar(require("fs"));
|
|
41
|
-
const path = __importStar(require("path"));
|
|
42
|
-
const yaml = __importStar(require("js-yaml"));
|
|
43
|
-
exports.InfrawiseConfigSchema = zod_1.z.object({
|
|
44
|
-
project: zod_1.z.string().min(1, 'Project name is required'),
|
|
45
|
-
aws: zod_1.z
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import * as yaml from 'js-yaml';
|
|
5
|
+
export const InfrawiseConfigSchema = z.object({
|
|
6
|
+
project: z.string().min(1, 'Project name is required'),
|
|
7
|
+
aws: z
|
|
46
8
|
.object({
|
|
47
|
-
profile:
|
|
48
|
-
region:
|
|
49
|
-
endpoint:
|
|
9
|
+
profile: z.string().optional().default('default'),
|
|
10
|
+
region: z.string().optional().default('us-east-1'),
|
|
11
|
+
endpoint: z.string().optional(),
|
|
50
12
|
})
|
|
51
13
|
.optional()
|
|
52
|
-
.default({}),
|
|
53
|
-
dynamodb:
|
|
54
|
-
postgres:
|
|
55
|
-
enabled:
|
|
56
|
-
connectionString:
|
|
14
|
+
.default({ profile: 'default', region: 'us-east-1' }),
|
|
15
|
+
dynamodb: z.object({ enabled: z.boolean().optional().default(true), includeTables: z.array(z.string()).optional() }).optional(),
|
|
16
|
+
postgres: z.object({
|
|
17
|
+
enabled: z.boolean().optional().default(false),
|
|
18
|
+
connectionString: z.string().optional(),
|
|
57
19
|
}).optional(),
|
|
58
|
-
mysql:
|
|
59
|
-
enabled:
|
|
60
|
-
connectionString:
|
|
20
|
+
mysql: z.object({
|
|
21
|
+
enabled: z.boolean().optional().default(false),
|
|
22
|
+
connectionString: z.string().optional(),
|
|
61
23
|
}).optional(),
|
|
62
|
-
mongodb:
|
|
63
|
-
enabled:
|
|
64
|
-
connectionString:
|
|
65
|
-
databases:
|
|
24
|
+
mongodb: z.object({
|
|
25
|
+
enabled: z.boolean().optional().default(false),
|
|
26
|
+
connectionString: z.string().optional(),
|
|
27
|
+
databases: z.array(z.string()).optional(),
|
|
66
28
|
}).optional(),
|
|
67
|
-
terraform:
|
|
68
|
-
sqs:
|
|
69
|
-
sns:
|
|
70
|
-
ssm:
|
|
71
|
-
enabled:
|
|
72
|
-
paths:
|
|
29
|
+
terraform: z.object({ enabled: z.boolean().optional().default(true) }).optional(),
|
|
30
|
+
sqs: z.object({ enabled: z.boolean().optional().default(true) }).optional(),
|
|
31
|
+
sns: z.object({ enabled: z.boolean().optional().default(true) }).optional(),
|
|
32
|
+
ssm: z.object({
|
|
33
|
+
enabled: z.boolean().optional().default(true),
|
|
34
|
+
paths: z.array(z.string()).optional(),
|
|
73
35
|
}).optional(),
|
|
74
|
-
secretsManager:
|
|
75
|
-
lambda:
|
|
76
|
-
rds:
|
|
77
|
-
kafka:
|
|
78
|
-
cloudwatchLogs:
|
|
79
|
-
enabled:
|
|
80
|
-
logGroupPrefixes:
|
|
81
|
-
windowHours:
|
|
36
|
+
secretsManager: z.object({ enabled: z.boolean().optional().default(true) }).optional(),
|
|
37
|
+
lambda: z.object({ enabled: z.boolean().optional().default(true) }).optional(),
|
|
38
|
+
rds: z.object({ enabled: z.boolean().optional().default(false) }).optional(),
|
|
39
|
+
kafka: z.object({ enabled: z.boolean().optional().default(false) }).optional(),
|
|
40
|
+
cloudwatchLogs: z.object({
|
|
41
|
+
enabled: z.boolean().optional().default(false),
|
|
42
|
+
logGroupPrefixes: z.array(z.string()).optional(),
|
|
43
|
+
windowHours: z.number().int().positive().optional().default(24),
|
|
82
44
|
}).optional(),
|
|
83
|
-
analysis:
|
|
84
|
-
sampleSize:
|
|
45
|
+
analysis: z.object({
|
|
46
|
+
sampleSize: z.number().int().positive().optional().default(100),
|
|
85
47
|
}).optional(),
|
|
86
48
|
});
|
|
87
|
-
class ConfigError extends Error {
|
|
49
|
+
export class ConfigError extends Error {
|
|
88
50
|
details;
|
|
89
51
|
constructor(message, details) {
|
|
90
52
|
super(message);
|
|
@@ -92,8 +54,7 @@ class ConfigError extends Error {
|
|
|
92
54
|
this.name = 'ConfigError';
|
|
93
55
|
}
|
|
94
56
|
}
|
|
95
|
-
|
|
96
|
-
function loadConfig(configPath) {
|
|
57
|
+
export function loadConfig(configPath) {
|
|
97
58
|
const resolvedPath = configPath
|
|
98
59
|
? path.resolve(configPath)
|
|
99
60
|
: path.resolve(process.cwd(), 'infrawise.yaml');
|
|
@@ -122,14 +83,14 @@ function loadConfig(configPath) {
|
|
|
122
83
|
catch (err) {
|
|
123
84
|
throw new ConfigError(`Invalid YAML in configuration file: ${resolvedPath}`, [String(err)]);
|
|
124
85
|
}
|
|
125
|
-
const result =
|
|
86
|
+
const result = InfrawiseConfigSchema.safeParse(parsedYaml);
|
|
126
87
|
if (!result.success) {
|
|
127
|
-
const details = result.error.
|
|
88
|
+
const details = result.error.issues.map((e) => ` - ${e.path.join('.')}: ${e.message}`);
|
|
128
89
|
throw new ConfigError('Configuration validation failed', details);
|
|
129
90
|
}
|
|
130
91
|
return result.data;
|
|
131
92
|
}
|
|
132
|
-
function generateDefaultConfig(projectName, options) {
|
|
93
|
+
export function generateDefaultConfig(projectName, options) {
|
|
133
94
|
const config = {
|
|
134
95
|
project: projectName,
|
|
135
96
|
aws: {
|
package/dist/core/errors.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConfigError = exports.RepositoryScanError = exports.PostgresConnectionError = exports.DynamoDBError = exports.AWSConnectionError = exports.InfrawiseError = void 0;
|
|
4
|
-
exports.formatError = formatError;
|
|
5
|
-
class InfrawiseError extends Error {
|
|
1
|
+
export class InfrawiseError extends Error {
|
|
6
2
|
reasons;
|
|
7
3
|
remediation;
|
|
8
4
|
constructor(message, reasons, remediation) {
|
|
@@ -26,8 +22,7 @@ class InfrawiseError extends Error {
|
|
|
26
22
|
return lines.join('\n');
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
|
-
|
|
30
|
-
class AWSConnectionError extends InfrawiseError {
|
|
25
|
+
export class AWSConnectionError extends InfrawiseError {
|
|
31
26
|
constructor(details) {
|
|
32
27
|
super('Unable to connect to AWS.', [
|
|
33
28
|
'Invalid or missing AWS credentials',
|
|
@@ -38,8 +33,7 @@ class AWSConnectionError extends InfrawiseError {
|
|
|
38
33
|
this.name = 'AWSConnectionError';
|
|
39
34
|
}
|
|
40
35
|
}
|
|
41
|
-
|
|
42
|
-
class DynamoDBError extends InfrawiseError {
|
|
36
|
+
export class DynamoDBError extends InfrawiseError {
|
|
43
37
|
constructor(details) {
|
|
44
38
|
super('Unable to access DynamoDB.', [
|
|
45
39
|
'Insufficient IAM permissions (need dynamodb:ListTables, dynamodb:DescribeTable)',
|
|
@@ -50,8 +44,7 @@ class DynamoDBError extends InfrawiseError {
|
|
|
50
44
|
this.name = 'DynamoDBError';
|
|
51
45
|
}
|
|
52
46
|
}
|
|
53
|
-
|
|
54
|
-
class PostgresConnectionError extends InfrawiseError {
|
|
47
|
+
export class PostgresConnectionError extends InfrawiseError {
|
|
55
48
|
constructor(details) {
|
|
56
49
|
super('Unable to connect to PostgreSQL.', [
|
|
57
50
|
'Invalid connection string',
|
|
@@ -62,8 +55,7 @@ class PostgresConnectionError extends InfrawiseError {
|
|
|
62
55
|
this.name = 'PostgresConnectionError';
|
|
63
56
|
}
|
|
64
57
|
}
|
|
65
|
-
|
|
66
|
-
class RepositoryScanError extends InfrawiseError {
|
|
58
|
+
export class RepositoryScanError extends InfrawiseError {
|
|
67
59
|
constructor(details) {
|
|
68
60
|
super('Unable to scan repository.', [
|
|
69
61
|
'Path does not exist or is not accessible',
|
|
@@ -74,8 +66,7 @@ class RepositoryScanError extends InfrawiseError {
|
|
|
74
66
|
this.name = 'RepositoryScanError';
|
|
75
67
|
}
|
|
76
68
|
}
|
|
77
|
-
|
|
78
|
-
class ConfigError extends InfrawiseError {
|
|
69
|
+
export class ConfigError extends InfrawiseError {
|
|
79
70
|
constructor(details) {
|
|
80
71
|
super('Invalid or missing configuration.', [
|
|
81
72
|
'infrawise.yaml not found in current directory',
|
|
@@ -85,8 +76,7 @@ class ConfigError extends InfrawiseError {
|
|
|
85
76
|
this.name = 'ConfigError';
|
|
86
77
|
}
|
|
87
78
|
}
|
|
88
|
-
|
|
89
|
-
function formatError(err) {
|
|
79
|
+
export function formatError(err) {
|
|
90
80
|
if (err instanceof InfrawiseError) {
|
|
91
81
|
return err.format();
|
|
92
82
|
}
|
package/dist/core/index.js
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_1.loadConfig; } });
|
|
6
|
-
Object.defineProperty(exports, "generateDefaultConfig", { enumerable: true, get: function () { return config_1.generateDefaultConfig; } });
|
|
7
|
-
Object.defineProperty(exports, "InfrawiseConfigSchema", { enumerable: true, get: function () { return config_1.InfrawiseConfigSchema; } });
|
|
8
|
-
Object.defineProperty(exports, "ConfigValidationError", { enumerable: true, get: function () { return config_1.ConfigError; } });
|
|
9
|
-
var logger_1 = require("./logger");
|
|
10
|
-
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_1.logger; } });
|
|
11
|
-
var errors_1 = require("./errors");
|
|
12
|
-
Object.defineProperty(exports, "InfrawiseError", { enumerable: true, get: function () { return errors_1.InfrawiseError; } });
|
|
13
|
-
Object.defineProperty(exports, "AWSConnectionError", { enumerable: true, get: function () { return errors_1.AWSConnectionError; } });
|
|
14
|
-
Object.defineProperty(exports, "DynamoDBError", { enumerable: true, get: function () { return errors_1.DynamoDBError; } });
|
|
15
|
-
Object.defineProperty(exports, "PostgresConnectionError", { enumerable: true, get: function () { return errors_1.PostgresConnectionError; } });
|
|
16
|
-
Object.defineProperty(exports, "RepositoryScanError", { enumerable: true, get: function () { return errors_1.RepositoryScanError; } });
|
|
17
|
-
Object.defineProperty(exports, "ConfigError", { enumerable: true, get: function () { return errors_1.ConfigError; } });
|
|
18
|
-
Object.defineProperty(exports, "formatError", { enumerable: true, get: function () { return errors_1.formatError; } });
|
|
19
|
-
var cache_1 = require("./cache");
|
|
20
|
-
Object.defineProperty(exports, "writeCache", { enumerable: true, get: function () { return cache_1.writeCache; } });
|
|
21
|
-
Object.defineProperty(exports, "readCache", { enumerable: true, get: function () { return cache_1.readCache; } });
|
|
22
|
-
Object.defineProperty(exports, "clearCache", { enumerable: true, get: function () { return cache_1.clearCache; } });
|
|
1
|
+
export { loadConfig, generateDefaultConfig, InfrawiseConfigSchema, ConfigError as ConfigValidationError } from './config.js';
|
|
2
|
+
export { logger } from './logger.js';
|
|
3
|
+
export { InfrawiseError, AWSConnectionError, DynamoDBError, PostgresConnectionError, RepositoryScanError, ConfigError, formatError, } from './errors.js';
|
|
4
|
+
export { writeCache, readCache, clearCache } from './cache.js';
|
package/dist/core/logger.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.logger = void 0;
|
|
7
|
-
const pino_1 = __importDefault(require("pino"));
|
|
1
|
+
import pino from 'pino';
|
|
8
2
|
function createLogger() {
|
|
9
3
|
const isDevelopment = process.env.NODE_ENV !== 'production';
|
|
10
4
|
if (isDevelopment) {
|
|
11
|
-
return (
|
|
5
|
+
return pino({
|
|
12
6
|
level: process.env.LOG_LEVEL ?? 'info',
|
|
13
7
|
transport: {
|
|
14
8
|
target: 'pino-pretty',
|
|
@@ -21,8 +15,8 @@ function createLogger() {
|
|
|
21
15
|
},
|
|
22
16
|
});
|
|
23
17
|
}
|
|
24
|
-
return (
|
|
18
|
+
return pino({
|
|
25
19
|
level: process.env.LOG_LEVEL ?? 'info',
|
|
26
20
|
});
|
|
27
21
|
}
|
|
28
|
-
|
|
22
|
+
export const logger = createLogger();
|
package/dist/graph/index.js
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildGraph = buildGraph;
|
|
4
|
-
exports.getTableNodes = getTableNodes;
|
|
5
|
-
exports.getFunctionNodes = getFunctionNodes;
|
|
6
|
-
exports.getIndexNodes = getIndexNodes;
|
|
7
|
-
exports.getQueueNodes = getQueueNodes;
|
|
8
|
-
exports.getTopicNodes = getTopicNodes;
|
|
9
|
-
exports.getSecretNodes = getSecretNodes;
|
|
10
|
-
exports.getParameterNodes = getParameterNodes;
|
|
11
|
-
exports.getLogGroupNodes = getLogGroupNodes;
|
|
12
|
-
exports.getLambdaNodes = getLambdaNodes;
|
|
13
|
-
exports.getEdgesForNode = getEdgesForNode;
|
|
14
|
-
exports.getOutgoingEdges = getOutgoingEdges;
|
|
15
|
-
exports.getIncomingEdges = getIncomingEdges;
|
|
16
|
-
exports.getScanEdges = getScanEdges;
|
|
17
|
-
exports.getEdgeFrequency = getEdgeFrequency;
|
|
18
|
-
function buildGraph(operations, dynamoMeta, postgresMeta, mysqlMeta = [], mongoMeta = [], servicesMeta = {}) {
|
|
1
|
+
export function buildGraph(operations, dynamoMeta, postgresMeta, mysqlMeta = [], mongoMeta = [], servicesMeta = {}) {
|
|
19
2
|
const nodes = [];
|
|
20
3
|
const edges = [];
|
|
21
4
|
const nodeIds = new Set();
|
|
@@ -226,46 +209,46 @@ function resolveEdgeType(operationType) {
|
|
|
226
209
|
return 'query';
|
|
227
210
|
}
|
|
228
211
|
// ── Typed node selectors ─────────────────────────────────────────────────────
|
|
229
|
-
function getTableNodes(graph) {
|
|
212
|
+
export function getTableNodes(graph) {
|
|
230
213
|
return graph.nodes.filter((n) => n.type === 'table');
|
|
231
214
|
}
|
|
232
|
-
function getFunctionNodes(graph) {
|
|
215
|
+
export function getFunctionNodes(graph) {
|
|
233
216
|
return graph.nodes.filter((n) => n.type === 'function');
|
|
234
217
|
}
|
|
235
|
-
function getIndexNodes(graph) {
|
|
218
|
+
export function getIndexNodes(graph) {
|
|
236
219
|
return graph.nodes.filter((n) => n.type === 'index');
|
|
237
220
|
}
|
|
238
|
-
function getQueueNodes(graph) {
|
|
221
|
+
export function getQueueNodes(graph) {
|
|
239
222
|
return graph.nodes.filter((n) => n.type === 'queue');
|
|
240
223
|
}
|
|
241
|
-
function getTopicNodes(graph) {
|
|
224
|
+
export function getTopicNodes(graph) {
|
|
242
225
|
return graph.nodes.filter((n) => n.type === 'topic');
|
|
243
226
|
}
|
|
244
|
-
function getSecretNodes(graph) {
|
|
227
|
+
export function getSecretNodes(graph) {
|
|
245
228
|
return graph.nodes.filter((n) => n.type === 'secret');
|
|
246
229
|
}
|
|
247
|
-
function getParameterNodes(graph) {
|
|
230
|
+
export function getParameterNodes(graph) {
|
|
248
231
|
return graph.nodes.filter((n) => n.type === 'parameter');
|
|
249
232
|
}
|
|
250
|
-
function getLogGroupNodes(graph) {
|
|
233
|
+
export function getLogGroupNodes(graph) {
|
|
251
234
|
return graph.nodes.filter((n) => n.type === 'log_group');
|
|
252
235
|
}
|
|
253
|
-
function getLambdaNodes(graph) {
|
|
236
|
+
export function getLambdaNodes(graph) {
|
|
254
237
|
return graph.nodes.filter((n) => n.type === 'lambda');
|
|
255
238
|
}
|
|
256
|
-
function getEdgesForNode(graph, nodeId) {
|
|
239
|
+
export function getEdgesForNode(graph, nodeId) {
|
|
257
240
|
return graph.edges.filter((e) => e.from === nodeId || e.to === nodeId);
|
|
258
241
|
}
|
|
259
|
-
function getOutgoingEdges(graph, nodeId) {
|
|
242
|
+
export function getOutgoingEdges(graph, nodeId) {
|
|
260
243
|
return graph.edges.filter((e) => e.from === nodeId);
|
|
261
244
|
}
|
|
262
|
-
function getIncomingEdges(graph, nodeId) {
|
|
245
|
+
export function getIncomingEdges(graph, nodeId) {
|
|
263
246
|
return graph.edges.filter((e) => e.to === nodeId);
|
|
264
247
|
}
|
|
265
|
-
function getScanEdges(graph) {
|
|
248
|
+
export function getScanEdges(graph) {
|
|
266
249
|
return graph.edges.filter((e) => e.type === 'scan');
|
|
267
250
|
}
|
|
268
|
-
function getEdgeFrequency(graph) {
|
|
251
|
+
export function getEdgeFrequency(graph) {
|
|
269
252
|
const freq = new Map();
|
|
270
253
|
for (const edge of graph.edges) {
|
|
271
254
|
const key = `${edge.from}->${edge.to}`;
|