@gugananuvem/aws-local-simulator 1.0.34 → 1.0.39
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 +662 -658
- package/package.json +11 -4
- package/src/config/default-config.js +71 -0
- package/src/config/env-loader.js +4 -2
- package/src/middleware/authorization.js +271 -0
- package/src/middleware/cloudtrail-logger.js +333 -0
- package/src/middleware/error-handler.js +138 -0
- package/src/middleware/index.js +79 -0
- package/src/middleware/policy-enforcement.js +407 -0
- package/src/server.js +74 -4
- package/src/services/acm/index.js +66 -0
- package/src/services/acm/models/certificate.js +202 -0
- package/src/services/acm/server.js +224 -0
- package/src/services/acm/simulator.js +293 -0
- package/src/services/alb/index.js +104 -0
- package/src/services/alb/models/loadBalancer.js +88 -0
- package/src/services/alb/models/targetGroup.js +128 -0
- package/src/services/alb/server.js +160 -0
- package/src/services/alb/simulator.js +262 -0
- package/src/services/apigateway/index.js +22 -0
- package/src/services/apigateway/server.js +247 -35
- package/src/services/apigateway/simulator.js +780 -26
- package/src/services/asg/index.js +100 -0
- package/src/services/asg/models/autoScalingGroup.js +110 -0
- package/src/services/asg/models/launchTemplate.js +41 -0
- package/src/services/asg/models/scalingPolicy.js +51 -0
- package/src/services/asg/server.js +236 -0
- package/src/services/asg/simulator.js +410 -0
- package/src/services/aurora/cluster-manager.js +731 -0
- package/src/services/aurora/data-api.js +514 -0
- package/src/services/aurora/db-engine.js +270 -0
- package/src/services/aurora/index.js +159 -0
- package/src/services/aurora/rds-api.js +189 -0
- package/src/services/aurora/server.js +213 -0
- package/src/services/aurora/sql-translator.js +334 -0
- package/src/services/cloudformation/index.js +2 -2
- package/src/services/cloudformation/server.js +1 -0
- package/src/services/cloudfront/cache-engine.js +225 -0
- package/src/services/cloudfront/geo-restrictions.js +377 -0
- package/src/services/cloudfront/index.js +220 -0
- package/src/services/cloudfront/models/behavior.js +158 -0
- package/src/services/cloudfront/models/distribution.js +284 -0
- package/src/services/cloudfront/models/index.js +99 -0
- package/src/services/cloudfront/models/invalidation.js +109 -0
- package/src/services/cloudfront/models/origin.js +155 -0
- package/src/services/cloudfront/origin-router.js +552 -0
- package/src/services/cloudfront/origin-validator.js +398 -0
- package/src/services/cloudfront/server.js +512 -0
- package/src/services/cloudfront/signed-url-generator.js +377 -0
- package/src/services/cloudfront/simulator.js +425 -0
- package/src/services/cloudfront/store.js +326 -0
- package/src/services/cloudshell/env-builder.js +27 -0
- package/src/services/cloudshell/index.js +48 -0
- package/src/services/cloudshell/routes.js +60 -0
- package/src/services/cloudshell/session-manager.js +226 -0
- package/src/services/cloudshell/static/.gitkeep +0 -0
- package/src/services/cloudshell/static/index.html +406 -0
- package/src/services/cloudshell/websocket-handler.js +107 -0
- package/src/services/cloudtrail/index.js +2 -3
- package/src/services/cloudtrail/server.js +68 -0
- package/src/services/cognito/server.js +4 -1
- package/src/services/dynamodb/server.js +4 -1
- package/src/services/dynamodb/simulator.js +2 -1
- package/src/services/ec2/index.js +101 -0
- package/src/services/ec2/instanceServer.js +311 -0
- package/src/services/ec2/models/ami.js +39 -0
- package/src/services/ec2/models/instance.js +98 -0
- package/src/services/ec2/models/networkInterface.js +74 -0
- package/src/services/ec2/models/securityGroup.js +71 -0
- package/src/services/ec2/server.js +350 -0
- package/src/services/ec2/simulator.js +436 -0
- package/src/services/eventbridge/server.js +36 -0
- package/src/services/eventbridge/simulator.js +230 -45
- package/src/services/iam/index.js +65 -0
- package/src/services/iam/middleware.js +99 -0
- package/src/services/iam/server.js +331 -0
- package/src/services/iam/simulator.js +1432 -0
- package/src/services/index.js +28 -0
- package/src/services/kinesis-analytics/index.js +105 -0
- package/src/services/kinesis-analytics/models/application.js +325 -0
- package/src/services/kinesis-analytics/models/index.js +12 -0
- package/src/services/kinesis-analytics/server.js +250 -0
- package/src/services/kinesis-analytics/simulator.js +407 -0
- package/src/services/kinesis-analytics/store.js +176 -0
- package/src/services/kinesis-data-streams/index.js +106 -0
- package/src/services/kinesis-data-streams/models/index.js +12 -0
- package/src/services/kinesis-data-streams/models/record.js +70 -0
- package/src/services/kinesis-data-streams/models/stream.js +280 -0
- package/src/services/kinesis-data-streams/server.js +255 -0
- package/src/services/kinesis-data-streams/simulator.js +514 -0
- package/src/services/kinesis-data-streams/store.js +163 -0
- package/src/services/kinesis-firehose/index.js +106 -0
- package/src/services/kinesis-firehose/models/delivery-stream.js +265 -0
- package/src/services/kinesis-firehose/models/index.js +10 -0
- package/src/services/kinesis-firehose/server.js +215 -0
- package/src/services/kinesis-firehose/simulator.js +388 -0
- package/src/services/kinesis-firehose/store.js +163 -0
- package/src/services/kms/server.js +4 -1
- package/src/services/lambda/handler-loader.js +50 -5
- package/src/services/lambda/index.js +26 -0
- package/src/services/lambda/server.js +18 -12
- package/src/services/lambda/simulator.js +73 -17
- package/src/services/opensearch/index.js +105 -0
- package/src/services/opensearch/models/document.js +115 -0
- package/src/services/opensearch/models/index.js +73 -0
- package/src/services/opensearch/server.js +310 -0
- package/src/services/opensearch/simulator.js +605 -0
- package/src/services/opensearch/store.js +162 -0
- package/src/services/organizations/control-tower-simulator.js +321 -0
- package/src/services/organizations/control-tower-store.js +182 -0
- package/src/services/organizations/iam-integration.js +413 -0
- package/src/services/organizations/index.js +172 -0
- package/src/services/organizations/models/index.js +13 -0
- package/src/services/organizations/models/invitation.js +48 -0
- package/src/services/organizations/models/organization.js +566 -0
- package/src/services/organizations/models/role.js +244 -0
- package/src/services/organizations/models/scp.js +131 -0
- package/src/services/organizations/server.js +736 -0
- package/src/services/organizations/simulator.js +593 -0
- package/src/services/organizations/store.js +235 -0
- package/src/services/organizations/vpc-integration.js +453 -0
- package/src/services/route53/index.js +67 -0
- package/src/services/route53/models/healthCheck.js +101 -0
- package/src/services/route53/models/hostedZone.js +37 -0
- package/src/services/route53/models/resourceRecord.js +106 -0
- package/src/services/route53/server.js +841 -0
- package/src/services/route53/simulator.js +350 -0
- package/src/services/s3/index.js +62 -0
- package/src/services/s3/presigned-url-generator.js +337 -0
- package/src/services/s3/server.js +231 -0
- package/src/services/s3/simulator.js +551 -4
- package/src/services/sns/index.js +31 -0
- package/src/services/sns/server.js +9 -0
- package/src/services/sqs/index.js +38 -0
- package/src/services/sqs/server.js +57 -4
- package/src/services/sqs/simulator.js +423 -33
- package/src/services/sts/simulator.js +209 -17
- package/src/services/vpc/README.md +459 -0
- package/src/services/vpc/ec2ResponseFormatter.js +431 -0
- package/src/services/vpc/index.js +90 -0
- package/src/services/vpc/models/internetGateway.js +71 -0
- package/src/services/vpc/models/routeTable.js +160 -0
- package/src/services/vpc/models/subnet.js +48 -0
- package/src/services/vpc/models/vpc.js +37 -0
- package/src/services/vpc/models/vpcEndpoint.js +100 -0
- package/src/services/vpc/models/vpcGateway.js +134 -0
- package/src/services/vpc/server.js +836 -0
- package/src/services/vpc/simulator.js +613 -0
- package/src/utils/policy-cache.js +215 -0
- package/aws-config +0 -154
package/src/services/index.js
CHANGED
|
@@ -21,6 +21,20 @@ const { SecretManagerService } = require('./secret-manager');
|
|
|
21
21
|
const { ParameterStoreService } = require('./parameter-store');
|
|
22
22
|
const { ConfigService } = require('./config');
|
|
23
23
|
const { AthenaService } = require('./athena');
|
|
24
|
+
const { AuroraService } = require('./aurora');
|
|
25
|
+
const IAMService = require('./iam');
|
|
26
|
+
const VPCService = require('./vpc');
|
|
27
|
+
const EC2Service = require('./ec2');
|
|
28
|
+
const ALBService = require('./alb');
|
|
29
|
+
const ASGService = require('./asg');
|
|
30
|
+
const OpenSearchService = require('./opensearch');
|
|
31
|
+
const KinesisDataStreamsService = require('./kinesis-data-streams');
|
|
32
|
+
const KinesisFirehoseService = require('./kinesis-firehose');
|
|
33
|
+
const KinesisAnalyticsService = require('./kinesis-analytics');
|
|
34
|
+
const OrganizationsService = require('./organizations');
|
|
35
|
+
const CloudFrontService = require('./cloudfront');
|
|
36
|
+
const Route53Service = require('./route53');
|
|
37
|
+
const ACMService = require('./acm');
|
|
24
38
|
|
|
25
39
|
module.exports = {
|
|
26
40
|
DynamoDBService,
|
|
@@ -42,4 +56,18 @@ module.exports = {
|
|
|
42
56
|
ParameterStoreService,
|
|
43
57
|
ConfigService,
|
|
44
58
|
AthenaService,
|
|
59
|
+
AuroraService,
|
|
60
|
+
IAMService,
|
|
61
|
+
VPCService,
|
|
62
|
+
EC2Service,
|
|
63
|
+
ALBService,
|
|
64
|
+
ASGService,
|
|
65
|
+
OpenSearchService,
|
|
66
|
+
KinesisDataStreamsService,
|
|
67
|
+
KinesisFirehoseService,
|
|
68
|
+
KinesisAnalyticsService,
|
|
69
|
+
OrganizationsService,
|
|
70
|
+
CloudFrontService,
|
|
71
|
+
Route53Service,
|
|
72
|
+
ACMService,
|
|
45
73
|
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kinesis Data Analytics Service - Ponto de entrada
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const KinesisAnalyticsServer = require('./server');
|
|
6
|
+
const KinesisAnalyticsSimulator = require('./simulator');
|
|
7
|
+
|
|
8
|
+
class KinesisAnalyticsService {
|
|
9
|
+
constructor(config) {
|
|
10
|
+
this.config = config;
|
|
11
|
+
this.name = 'kinesis-analytics';
|
|
12
|
+
this.port = config.ports['kinesis-analytics'] || 4570;
|
|
13
|
+
this.server = null;
|
|
14
|
+
this.simulator = null;
|
|
15
|
+
this.isRunning = false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async initialize() {
|
|
19
|
+
const logger = require('../../utils/logger');
|
|
20
|
+
logger.debug(`Inicializando Kinesis Analytics Service na porta ${this.port}...`);
|
|
21
|
+
|
|
22
|
+
this.simulator = new KinesisAnalyticsSimulator(this.config);
|
|
23
|
+
await this.simulator.initialize();
|
|
24
|
+
|
|
25
|
+
this.server = new KinesisAnalyticsServer(this.port, this.config);
|
|
26
|
+
this.server.simulator = this.simulator;
|
|
27
|
+
|
|
28
|
+
await this.server.initialize();
|
|
29
|
+
|
|
30
|
+
logger.debug('Kinesis Analytics Service inicializado');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
injectDependencies(server) {
|
|
34
|
+
// Aqui você pode injetar dependências de outros serviços se necessário
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async start() {
|
|
38
|
+
const logger = require('../../utils/logger');
|
|
39
|
+
|
|
40
|
+
if (this.isRunning) {
|
|
41
|
+
logger.warn('Kinesis Analytics Service já está em execução');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
await this.server.start();
|
|
47
|
+
this.isRunning = true;
|
|
48
|
+
logger.info('Kinesis Analytics Service iniciado com sucesso');
|
|
49
|
+
} catch (error) {
|
|
50
|
+
logger.error(`Erro ao iniciar Kinesis Analytics Service: ${error.message}`);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async stop() {
|
|
56
|
+
const logger = require('../../utils/logger');
|
|
57
|
+
|
|
58
|
+
if (!this.isRunning) {
|
|
59
|
+
logger.warn('Kinesis Analytics Service não está em execução');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
await this.server.stop();
|
|
65
|
+
this.isRunning = false;
|
|
66
|
+
logger.info('Kinesis Analytics Service parado com sucesso');
|
|
67
|
+
} catch (error) {
|
|
68
|
+
logger.error(`Erro ao parar Kinesis Analytics Service: ${error.message}`);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async reset() {
|
|
74
|
+
const logger = require('../../utils/logger');
|
|
75
|
+
try {
|
|
76
|
+
await this.simulator.reset();
|
|
77
|
+
logger.info('Kinesis Analytics Service resetado');
|
|
78
|
+
} catch (error) {
|
|
79
|
+
logger.error(`Erro ao resetar Kinesis Analytics Service: ${error.message}`);
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
getSimulator() {
|
|
85
|
+
return this.simulator;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
getStatus() {
|
|
89
|
+
const stats = this.simulator?.getStats() || { applicationsCount: 0, totalInputs: 0, totalOutputs: 0 };
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
name: this.name,
|
|
93
|
+
running: this.isRunning,
|
|
94
|
+
port: this.port,
|
|
95
|
+
endpoint: `http://localhost:${this.port}`,
|
|
96
|
+
resources: {
|
|
97
|
+
applicationsCount: stats.applicationsCount,
|
|
98
|
+
totalInputs: stats.totalInputs,
|
|
99
|
+
totalOutputs: stats.totalOutputs
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
module.exports = KinesisAnalyticsService;
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kinesis Data Analytics - Application Model
|
|
3
|
+
* Representa uma aplicação de analytics
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { v4: uuidv4 } = require('uuid');
|
|
7
|
+
|
|
8
|
+
class Application {
|
|
9
|
+
constructor(applicationName, config = {}) {
|
|
10
|
+
this.applicationName = applicationName;
|
|
11
|
+
this.applicationArn = `arn:aws:kinesisanalytics:us-east-1:123456789012:application/${applicationName}`;
|
|
12
|
+
this.applicationStatus = 'READY';
|
|
13
|
+
this.applicationVersionId = 1;
|
|
14
|
+
this.creationTimestamp = new Date().toISOString();
|
|
15
|
+
|
|
16
|
+
// Runtime Environment (SQL ou JAVA_FLINK)
|
|
17
|
+
this.runtimeEnvironment = config.runtimeEnvironment || 'SQL_1_0';
|
|
18
|
+
this.serviceExecutionRole = config.serviceExecutionRole || 'arn:aws:iam::123456789012:role/kinesis-analytics-role';
|
|
19
|
+
|
|
20
|
+
// Application description
|
|
21
|
+
this.applicationDescription = config.applicationDescription || '';
|
|
22
|
+
this.lastUpdateTimestamp = new Date().toISOString();
|
|
23
|
+
|
|
24
|
+
// Inputs - input streams
|
|
25
|
+
this.inputs = new Map();
|
|
26
|
+
this.inputCount = 0;
|
|
27
|
+
|
|
28
|
+
// Outputs - saídas da query
|
|
29
|
+
this.outputs = new Map();
|
|
30
|
+
this.outputCount = 0;
|
|
31
|
+
|
|
32
|
+
// Reference Data Sources
|
|
33
|
+
this.referenceDataSources = new Map();
|
|
34
|
+
|
|
35
|
+
// SQL Code
|
|
36
|
+
this.sqlCode = '';
|
|
37
|
+
|
|
38
|
+
// Application Configuration
|
|
39
|
+
this.applicationConfiguration = {
|
|
40
|
+
sqlApplicationConfiguration: {
|
|
41
|
+
inputs: [],
|
|
42
|
+
outputs: [],
|
|
43
|
+
referenceDataSources: []
|
|
44
|
+
},
|
|
45
|
+
environmentProperties: {
|
|
46
|
+
propertyGroups: []
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Metrics
|
|
51
|
+
this.inputRecordsCount = 0;
|
|
52
|
+
this.processedRecordsCount = 0;
|
|
53
|
+
this.outputRecordsCount = 0;
|
|
54
|
+
this.processedBytes = 0;
|
|
55
|
+
this.errors = [];
|
|
56
|
+
|
|
57
|
+
// Tags
|
|
58
|
+
this.tags = config.tags || {};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Adiciona input (input stream)
|
|
63
|
+
*/
|
|
64
|
+
addInput(inputName, config = {}) {
|
|
65
|
+
const input = new Input(inputName, config);
|
|
66
|
+
this.inputs.set(inputName, input);
|
|
67
|
+
this.inputCount++;
|
|
68
|
+
this.lastUpdateTimestamp = new Date().toISOString();
|
|
69
|
+
return input;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Obtém input
|
|
74
|
+
*/
|
|
75
|
+
getInput(inputName) {
|
|
76
|
+
return this.inputs.get(inputName);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Remove input
|
|
81
|
+
*/
|
|
82
|
+
removeInput(inputName) {
|
|
83
|
+
if (this.inputs.delete(inputName)) {
|
|
84
|
+
this.inputCount--;
|
|
85
|
+
this.lastUpdateTimestamp = new Date().toISOString();
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Adiciona output
|
|
93
|
+
*/
|
|
94
|
+
addOutput(outputName, config = {}) {
|
|
95
|
+
const output = new Output(outputName, config);
|
|
96
|
+
this.outputs.set(outputName, output);
|
|
97
|
+
this.outputCount++;
|
|
98
|
+
this.lastUpdateTimestamp = new Date().toISOString();
|
|
99
|
+
return output;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Obtém output
|
|
104
|
+
*/
|
|
105
|
+
getOutput(outputName) {
|
|
106
|
+
return this.outputs.get(outputName);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Remove output
|
|
111
|
+
*/
|
|
112
|
+
removeOutput(outputName) {
|
|
113
|
+
if (this.outputs.delete(outputName)) {
|
|
114
|
+
this.outputCount--;
|
|
115
|
+
this.lastUpdateTimestamp = new Date().toISOString();
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Define SQL code
|
|
123
|
+
*/
|
|
124
|
+
setSqlCode(sqlCode) {
|
|
125
|
+
this.sqlCode = sqlCode;
|
|
126
|
+
this.lastUpdateTimestamp = new Date().toISOString();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Obtém SQL code
|
|
131
|
+
*/
|
|
132
|
+
getSqlCode() {
|
|
133
|
+
return this.sqlCode;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Registra um record de input
|
|
138
|
+
*/
|
|
139
|
+
recordInputData(inputName, recordData) {
|
|
140
|
+
const input = this.inputs.get(inputName);
|
|
141
|
+
if (input) {
|
|
142
|
+
input.recordCount++;
|
|
143
|
+
input.recordsTimestamp.push(Date.now());
|
|
144
|
+
this.inputRecordsCount++;
|
|
145
|
+
this.lastUpdateTimestamp = new Date().toISOString();
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Registra um record de output
|
|
153
|
+
*/
|
|
154
|
+
recordOutputData(outputName, recordData) {
|
|
155
|
+
const output = this.outputs.get(outputName);
|
|
156
|
+
if (output) {
|
|
157
|
+
output.recordCount++;
|
|
158
|
+
output.recordsTimestamp.push(Date.now());
|
|
159
|
+
this.outputRecordsCount++;
|
|
160
|
+
this.lastUpdateTimestamp = new Date().toISOString();
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Retorna descrição da aplicação
|
|
168
|
+
*/
|
|
169
|
+
describe() {
|
|
170
|
+
return {
|
|
171
|
+
ApplicationDetail: {
|
|
172
|
+
ApplicationName: this.applicationName,
|
|
173
|
+
ApplicationArn: this.applicationArn,
|
|
174
|
+
ApplicationStatus: this.applicationStatus,
|
|
175
|
+
ApplicationVersionId: this.applicationVersionId,
|
|
176
|
+
CreationTimestamp: this.creationTimestamp,
|
|
177
|
+
LastUpdateTimestamp: this.lastUpdateTimestamp,
|
|
178
|
+
ApplicationDescription: this.applicationDescription,
|
|
179
|
+
RuntimeEnvironment: this.runtimeEnvironment,
|
|
180
|
+
ServiceExecutionRole: this.serviceExecutionRole,
|
|
181
|
+
ApplicationConfiguration: this.applicationConfiguration,
|
|
182
|
+
CloudWatchLoggingOptionDescriptions: []
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
toJSON() {
|
|
188
|
+
return {
|
|
189
|
+
applicationName: this.applicationName,
|
|
190
|
+
applicationArn: this.applicationArn,
|
|
191
|
+
applicationStatus: this.applicationStatus,
|
|
192
|
+
applicationVersionId: this.applicationVersionId,
|
|
193
|
+
creationTimestamp: this.creationTimestamp,
|
|
194
|
+
lastUpdateTimestamp: this.lastUpdateTimestamp,
|
|
195
|
+
inputCount: this.inputCount,
|
|
196
|
+
outputCount: this.outputCount,
|
|
197
|
+
inputRecordsCount: this.inputRecordsCount,
|
|
198
|
+
processedRecordsCount: this.processedRecordsCount,
|
|
199
|
+
outputRecordsCount: this.outputRecordsCount,
|
|
200
|
+
runtimeEnvironment: this.runtimeEnvironment
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Input Model - Entrada de dados (stream)
|
|
207
|
+
*/
|
|
208
|
+
class Input {
|
|
209
|
+
constructor(inputName, config = {}) {
|
|
210
|
+
this.inputName = inputName;
|
|
211
|
+
this.inputId = uuidv4();
|
|
212
|
+
this.sourceStreamArn = config.sourceStreamArn || null;
|
|
213
|
+
this.inputStartingPositionConfiguration = config.inputStartingPositionConfiguration || {
|
|
214
|
+
inputStartingPosition: 'NOW'
|
|
215
|
+
};
|
|
216
|
+
this.recordCount = 0;
|
|
217
|
+
this.recordsTimestamp = [];
|
|
218
|
+
this.createdAt = new Date().toISOString();
|
|
219
|
+
this.schema = config.schema || {
|
|
220
|
+
RecordColumns: [],
|
|
221
|
+
RecordFormat: {
|
|
222
|
+
RecordFormatType: 'JSON'
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
toJSON() {
|
|
228
|
+
return {
|
|
229
|
+
inputName: this.inputName,
|
|
230
|
+
inputId: this.inputId,
|
|
231
|
+
sourceStreamArn: this.sourceStreamArn,
|
|
232
|
+
recordCount: this.recordCount,
|
|
233
|
+
createdAt: this.createdAt,
|
|
234
|
+
schema: this.schema
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Output Model - Saída de dados (destino)
|
|
241
|
+
*/
|
|
242
|
+
class Output {
|
|
243
|
+
constructor(outputName, config = {}) {
|
|
244
|
+
this.outputName = outputName;
|
|
245
|
+
this.outputId = uuidv4();
|
|
246
|
+
this.destinationSchema = config.destinationSchema || {
|
|
247
|
+
RecordFormatType: 'JSON'
|
|
248
|
+
};
|
|
249
|
+
this.destination = config.destination || {
|
|
250
|
+
DestinationType: 'KINESIS_STREAMS',
|
|
251
|
+
KinesisStreamsOutput: {
|
|
252
|
+
ResourceArn: config.resourceArn || null,
|
|
253
|
+
RoleArn: config.roleArn || null
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
this.recordCount = 0;
|
|
257
|
+
this.recordsTimestamp = [];
|
|
258
|
+
this.createdAt = new Date().toISOString();
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
toJSON() {
|
|
262
|
+
return {
|
|
263
|
+
outputName: this.outputName,
|
|
264
|
+
outputId: this.outputId,
|
|
265
|
+
destination: this.destination,
|
|
266
|
+
recordCount: this.recordCount,
|
|
267
|
+
createdAt: this.createdAt
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Query Model - Consulta SQL
|
|
274
|
+
*/
|
|
275
|
+
class Query {
|
|
276
|
+
constructor(queryName, config = {}) {
|
|
277
|
+
this.queryName = queryName;
|
|
278
|
+
this.queryId = uuidv4();
|
|
279
|
+
this.sqlQuery = config.sqlQuery || '';
|
|
280
|
+
this.status = 'READY';
|
|
281
|
+
this.createdAt = new Date().toISOString();
|
|
282
|
+
this.lastModifiedAt = new Date().toISOString();
|
|
283
|
+
this.executedCount = 0;
|
|
284
|
+
this.results = [];
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Executa query e retorna resultados
|
|
289
|
+
*/
|
|
290
|
+
execute(data) {
|
|
291
|
+
this.executedCount++;
|
|
292
|
+
this.lastModifiedAt = new Date().toISOString();
|
|
293
|
+
|
|
294
|
+
// Simulação básica de query execution
|
|
295
|
+
const result = {
|
|
296
|
+
queryId: this.queryId,
|
|
297
|
+
executedAt: new Date().toISOString(),
|
|
298
|
+
rowsProcessed: Array.isArray(data) ? data.length : 1,
|
|
299
|
+
status: 'SUCCEEDED',
|
|
300
|
+
data: data
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
this.results.push(result);
|
|
304
|
+
return result;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
toJSON() {
|
|
308
|
+
return {
|
|
309
|
+
queryName: this.queryName,
|
|
310
|
+
queryId: this.queryId,
|
|
311
|
+
sqlQuery: this.sqlQuery,
|
|
312
|
+
status: this.status,
|
|
313
|
+
createdAt: this.createdAt,
|
|
314
|
+
lastModifiedAt: this.lastModifiedAt,
|
|
315
|
+
executedCount: this.executedCount
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
module.exports = {
|
|
321
|
+
Application,
|
|
322
|
+
Input,
|
|
323
|
+
Output,
|
|
324
|
+
Query
|
|
325
|
+
};
|