mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-13 05:59:07 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0369f10b5c |
+2
-2
@@ -22,7 +22,7 @@ ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
|
||||
# run aws cli without mounting secret, because CI already has AWS credentials
|
||||
FROM build_base AS ci_image
|
||||
RUN aws codeartifact login --tool npm --namespace @dadosfera --repository dadosfera-npm --domain dadosfera --domain-owner 611330257153 --region us-east-1
|
||||
RUN npm ci
|
||||
RUN npm ci --ignore-scripts
|
||||
COPY . .
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ FROM build_base AS dev
|
||||
RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
|
||||
aws codeartifact login --tool npm --namespace @dadosfera --repository dadosfera-npm --domain dadosfera --domain-owner 611330257153 --region us-east-1
|
||||
# flag --build-from-source is required to force-build sqlite3
|
||||
RUN npm ci
|
||||
RUN npm ci --ignore-scripts
|
||||
COPY . .
|
||||
ENTRYPOINT npm run start:dev
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
|
||||
FROM build_base AS build
|
||||
RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
|
||||
aws codeartifact login --tool npm --namespace @dadosfera --repository dadosfera-npm --domain dadosfera --domain-owner 611330257153 --region us-east-1
|
||||
RUN npm ci
|
||||
RUN npm ci --ignore-scripts
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
|
||||
+109
-41
@@ -7627,42 +7627,6 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/platform/jobs/{jobId}": {
|
||||
"delete": {
|
||||
"operationId": "PlatformApiController_deleteJob",
|
||||
"summary": "Delete a job and mark its table as deleted in DynamoDB",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "jobId",
|
||||
"required": true,
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"Platform API"
|
||||
],
|
||||
"security": [
|
||||
{
|
||||
"access-token": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/platform/jobs/jdbc/{jobId}": {
|
||||
"get": {
|
||||
"operationId": "PlatformApiController_getJdbcJob",
|
||||
@@ -10169,9 +10133,6 @@
|
||||
"$ref": "#/components/schemas/Column"
|
||||
}
|
||||
},
|
||||
"destination": {
|
||||
"type": "object"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -10188,7 +10149,6 @@
|
||||
"required": [
|
||||
"name",
|
||||
"columns",
|
||||
"destination",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
@@ -10468,6 +10428,114 @@
|
||||
"engine"
|
||||
]
|
||||
},
|
||||
"ValidationTableDTO": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"tables": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"tables"
|
||||
]
|
||||
},
|
||||
"EnforceMfa": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"enabled"
|
||||
]
|
||||
},
|
||||
"CustomerLinkItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"href": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"iconSrc": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"href",
|
||||
"name",
|
||||
"description"
|
||||
]
|
||||
},
|
||||
"CustomerSidebarSection": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"title": {
|
||||
"type": "object"
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/CustomerSidebarMenuItem"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/CustomerSidebarLinkItem"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"title",
|
||||
"items"
|
||||
]
|
||||
},
|
||||
"CustomerLinksConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"home": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/CustomerLinkItem"
|
||||
}
|
||||
},
|
||||
"sidebar": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/CustomerSidebarSection"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"CustomerLinksResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"links": {
|
||||
"$ref": "#/components/schemas/CustomerLinksConfig"
|
||||
}
|
||||
}
|
||||
},
|
||||
"CustomerLinkRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"links": {
|
||||
"$ref": "#/components/schemas/CustomerLinksConfig"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"links"
|
||||
]
|
||||
},
|
||||
"IRole": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -11094,7 +11162,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"title": {
|
||||
"type": "object"
|
||||
"type": "string"
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
|
||||
Generated
+8
-8
@@ -17,7 +17,7 @@
|
||||
"@aws-sdk/signature-v4": "^3.370.0",
|
||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||
"@dadosfera/protospack": "2.5.3",
|
||||
"@dadosfera/protospack-v2": "^3.40.0-beta.3",
|
||||
"@dadosfera/protospack-v2": "^3.39.0",
|
||||
"@grpc/grpc-js": "^1.9.3",
|
||||
"@grpc/proto-loader": "^0.7.9",
|
||||
"@nestjs/cli": "^9.5.0",
|
||||
@@ -31,7 +31,7 @@
|
||||
"@nestjs/schematics": "^9.2.0",
|
||||
"@nestjs/swagger": "^6.3.0",
|
||||
"@nestjs/testing": "^9.4.3",
|
||||
"axios": "^0.30.2",
|
||||
"axios": "0.30.3",
|
||||
"cache-manager": "^5.1.4",
|
||||
"cache-manager-ioredis-yet": "^1.1.0",
|
||||
"class-transformer": "^0.5.1",
|
||||
@@ -1745,9 +1745,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@dadosfera/protospack-v2": {
|
||||
"version": "3.40.0-beta.3",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.40.0-beta.3.tgz",
|
||||
"integrity": "sha512-m77RSqAO+hZkjUgbdrMqC+6yyyo7indH6fWP3WuygCHGYwdN6FsWTA+EGTAhXQRSgNlI8h358ZpRoILnnGzLMg==",
|
||||
"version": "3.39.0",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.39.0.tgz",
|
||||
"integrity": "sha512-z6q+ZRpbDT6apfmly1+X818DgAFUCilFO0ATP7xR5+SH+GAUAJLY1dJRQDEkq5vFIfXnC2Nmm9aODZAs+9/5vw==",
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^1.9.3",
|
||||
"rxjs": "^7.5.5"
|
||||
@@ -5598,9 +5598,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "0.30.2",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.30.2.tgz",
|
||||
"integrity": "sha512-0pE4RQ4UQi1jKY6p7u6i1Tkzqmu+d+/tHS7Q7rKunWLB9WyilBTpHHpXzPNMDj5hTbK0B0PTLSz07yqMBiF6xg==",
|
||||
"version": "0.30.3",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.30.3.tgz",
|
||||
"integrity": "sha512-5/tmEb6TmE/ax3mdXBc/Mi6YdPGxQsv+0p5YlciXWt3PHIn0VamqCXhRMtScnwY3lbgSXLneOuXAKUhgmSRpwg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.4",
|
||||
|
||||
+6
-2
@@ -35,7 +35,7 @@
|
||||
"@aws-sdk/signature-v4": "^3.370.0",
|
||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||
"@dadosfera/protospack": "2.5.3",
|
||||
"@dadosfera/protospack-v2": "^3.40.0-beta.3",
|
||||
"@dadosfera/protospack-v2": "^3.39.0",
|
||||
"@grpc/grpc-js": "^1.9.3",
|
||||
"@grpc/proto-loader": "^0.7.9",
|
||||
"@nestjs/cli": "^9.5.0",
|
||||
@@ -49,7 +49,7 @@
|
||||
"@nestjs/schematics": "^9.2.0",
|
||||
"@nestjs/swagger": "^6.3.0",
|
||||
"@nestjs/testing": "^9.4.3",
|
||||
"axios": "^0.30.2",
|
||||
"axios": "0.30.3",
|
||||
"cache-manager": "^5.1.4",
|
||||
"cache-manager-ioredis-yet": "^1.1.0",
|
||||
"class-transformer": "^0.5.1",
|
||||
@@ -81,6 +81,7 @@
|
||||
"swagger-ui-express": "^4.6.3"
|
||||
},
|
||||
"overrides": {
|
||||
"axios": "0.30.3",
|
||||
"form-data": "^4.0.4",
|
||||
"body-parser": "^1.20.3",
|
||||
"cross-spawn": "^7.0.5",
|
||||
@@ -117,5 +118,8 @@
|
||||
"ts-node": "^10.9.1",
|
||||
"tsconfig-paths": "^3.14.2",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"resolutions": {
|
||||
"axios": "0.30.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,11 +220,10 @@ export class PipelinesController {
|
||||
|
||||
const result = await this.pipelinesClientService
|
||||
.findOne({ id }, metadata)
|
||||
.then(async (res) => {
|
||||
.then((res) => {
|
||||
//{pipeline:{tables: {tables: [], input_id: ''}}}
|
||||
const parsed = JSON.parse(res.pipeline.config.tables);
|
||||
const tables = parsed?.tables ?? parsed;
|
||||
|
||||
let tables = JSON.parse(res.pipeline.config.tables);
|
||||
if (tables?.tables) tables = tables.tables;
|
||||
Object.assign(res.pipeline, {
|
||||
transformations: res.pipeline.transformations
|
||||
? JSON.parse(res.pipeline.transformations)
|
||||
|
||||
@@ -933,61 +933,6 @@ export class PlatformApiController {
|
||||
);
|
||||
}
|
||||
|
||||
@Delete('jobs/:jobId')
|
||||
@ApiOperation({ summary: 'Delete a job and mark its table as deleted in DynamoDB' })
|
||||
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.DELETE)
|
||||
async deleteJob(
|
||||
@Param('jobId') jobId: string,
|
||||
@User() user: RequestUser,
|
||||
) {
|
||||
const normalizedJobId = this.normalizeJobId(jobId);
|
||||
const esPipelineId = this.extractPipelineIdFromJobId(jobId);
|
||||
|
||||
// Fetch job details and ES pipeline in parallel — both are reads with no mutual dependency
|
||||
const [jobResult, esPipelineResult] = await Promise.allSettled([
|
||||
this.platformApiService.proxy('GET', `/jobs/${normalizedJobId}`, user),
|
||||
this.elasticsearchService.getPipeline(user.customer_name, esPipelineId),
|
||||
]);
|
||||
|
||||
const tableName: string | undefined = jobResult.status === 'fulfilled'
|
||||
? jobResult.value?.source_config?.table_name
|
||||
: undefined;
|
||||
|
||||
if (jobResult.status === 'rejected') {
|
||||
this.logger.warn('deleteJob: could not fetch job before deletion', { jobId, error: jobResult.reason?.message });
|
||||
}
|
||||
|
||||
// Main operation
|
||||
const result = await this.platformApiService.proxy('DELETE', `/jobs/${normalizedJobId}`, user);
|
||||
|
||||
// Sync deleted status to DynamoDB — follows syncJobInputToDynamoDB pattern
|
||||
// config.tables in ES stores the DynamoDB input ID (legacy field naming)
|
||||
const dynamoInputId: string | undefined = esPipelineResult.status === 'fulfilled'
|
||||
? esPipelineResult.value?.config?.tables
|
||||
: undefined;
|
||||
|
||||
if (esPipelineResult.status === 'rejected') {
|
||||
this.logger.warn('deleteJob: could not fetch ES pipeline for DynamoDB sync', { jobId, error: esPipelineResult.reason?.message });
|
||||
}
|
||||
|
||||
if (tableName && dynamoInputId) {
|
||||
await this.dynamoDBService.updateInputTable(
|
||||
user.customer_id,
|
||||
dynamoInputId,
|
||||
tableName,
|
||||
{ status: 'deleted' },
|
||||
).catch((error) => {
|
||||
this.logger.error('Failed to sync job deletion to DynamoDB', { jobId, tableName, error: error.message });
|
||||
});
|
||||
} else if (!tableName) {
|
||||
this.logger.warn('deleteJob: table name not resolved, skipping DynamoDB sync', { jobId });
|
||||
} else {
|
||||
this.logger.warn('deleteJob: no input ID in ES pipeline, skipping DynamoDB sync', { jobId });
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ==================== JOBS - JDBC SYNC MODE ROUTES ====================
|
||||
|
||||
@Get('jobs/jdbc/:jobId')
|
||||
|
||||
@@ -7,10 +7,9 @@ import { PlatformApiService } from './platform-api.service';
|
||||
import { ElasticsearchModule } from '../../services/elasticsearch';
|
||||
import { DynamoDBModule } from '../../services/dynamodb';
|
||||
import { CustomersModule } from '../customers/customers.module';
|
||||
import { PipelinesV2Module } from '../pipelinesV2/pipelines.module';
|
||||
|
||||
@Module({
|
||||
imports: [ElasticsearchModule, DynamoDBModule, CustomersModule, PipelinesV2Module],
|
||||
imports: [ElasticsearchModule, DynamoDBModule, CustomersModule],
|
||||
controllers: [PlatformApiController],
|
||||
providers: [PlatformApiService, DadosferaLogger],
|
||||
exports: [PlatformApiService],
|
||||
|
||||
@@ -30,7 +30,6 @@ export interface InputDocument {
|
||||
type: string;
|
||||
columns?: string[];
|
||||
reference_column?: ReferenceColumn;
|
||||
status?: string;
|
||||
}>;
|
||||
credentials?: Record<string, any>;
|
||||
}
|
||||
@@ -126,13 +125,9 @@ export class DynamoDBService {
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
const { Item } = await this.documentClient.send(getCommand);
|
||||
return Item as InputDocument | null;
|
||||
} catch (error) {
|
||||
this.logger.error('DynamoDB: findInput failed', { inputId, clientId, error: error.message });
|
||||
throw error;
|
||||
}
|
||||
const { Item } = await this.documentClient.send(getCommand);
|
||||
|
||||
return Item as InputDocument | null;
|
||||
}
|
||||
|
||||
async deleteInput(clientId: string, inputId: string): Promise<void> {
|
||||
@@ -168,7 +163,6 @@ export class DynamoDBService {
|
||||
type?: string;
|
||||
columns?: string[];
|
||||
reference_column?: ReferenceColumn | null;
|
||||
status?: string;
|
||||
},
|
||||
): Promise<void> {
|
||||
const dynamoTableName = DYNAMODB_CONFIG.inputsTable();
|
||||
@@ -209,7 +203,6 @@ export class DynamoDBService {
|
||||
updatedTable.reference_column = changes.reference_column;
|
||||
}
|
||||
}
|
||||
if ('status' in changes) updatedTable.status = changes.status;
|
||||
|
||||
tables[tableIndex] = updatedTable;
|
||||
|
||||
@@ -238,53 +231,4 @@ export class DynamoDBService {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a specific table entry from the input document.
|
||||
* Fetches the current document, removes the matching table, and saves.
|
||||
*/
|
||||
async removeInputTable(
|
||||
clientId: string,
|
||||
inputId: string,
|
||||
tableName: string,
|
||||
): Promise<void> {
|
||||
const dynamoTableName = DYNAMODB_CONFIG.inputsTable();
|
||||
|
||||
this.logger.info('DynamoDB: Removing input table', {
|
||||
inputId,
|
||||
tableName,
|
||||
});
|
||||
|
||||
const current = await this.findInput(clientId, inputId);
|
||||
if (!current) {
|
||||
this.logger.warn('DynamoDB: Input not found for table removal', { inputId });
|
||||
return;
|
||||
}
|
||||
|
||||
const tables = (current.tables || []).filter((t) => t.name !== tableName);
|
||||
|
||||
const putCommand = new PutCommand({
|
||||
TableName: dynamoTableName,
|
||||
Item: {
|
||||
...current,
|
||||
tables,
|
||||
updated_at: new Date().toISOString(),
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
await this.documentClient.send(putCommand);
|
||||
this.logger.info('DynamoDB: Input table removed successfully', {
|
||||
inputId,
|
||||
tableName,
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.error('DynamoDB: Failed to remove input table', {
|
||||
inputId,
|
||||
tableName,
|
||||
error: error.message,
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user