mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-25 10:10:05 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae8573a75d | ||
|
|
da8cf2d590 |
+41
-109
@@ -7627,6 +7627,42 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/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}": {
|
"/platform/jobs/jdbc/{jobId}": {
|
||||||
"get": {
|
"get": {
|
||||||
"operationId": "PlatformApiController_getJdbcJob",
|
"operationId": "PlatformApiController_getJdbcJob",
|
||||||
@@ -10133,6 +10169,9 @@
|
|||||||
"$ref": "#/components/schemas/Column"
|
"$ref": "#/components/schemas/Column"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"destination": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -10149,6 +10188,7 @@
|
|||||||
"required": [
|
"required": [
|
||||||
"name",
|
"name",
|
||||||
"columns",
|
"columns",
|
||||||
|
"destination",
|
||||||
"type"
|
"type"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -10428,114 +10468,6 @@
|
|||||||
"engine"
|
"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": {
|
"IRole": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -11162,7 +11094,7 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"title": {
|
"title": {
|
||||||
"type": "string"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"items": {
|
"items": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
|||||||
Generated
+4
-4
@@ -17,7 +17,7 @@
|
|||||||
"@aws-sdk/signature-v4": "^3.370.0",
|
"@aws-sdk/signature-v4": "^3.370.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack": "2.5.3",
|
"@dadosfera/protospack": "2.5.3",
|
||||||
"@dadosfera/protospack-v2": "^3.39.0",
|
"@dadosfera/protospack-v2": "^3.40.0-beta.3",
|
||||||
"@grpc/grpc-js": "^1.9.3",
|
"@grpc/grpc-js": "^1.9.3",
|
||||||
"@grpc/proto-loader": "^0.7.9",
|
"@grpc/proto-loader": "^0.7.9",
|
||||||
"@nestjs/cli": "^9.5.0",
|
"@nestjs/cli": "^9.5.0",
|
||||||
@@ -1745,9 +1745,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@dadosfera/protospack-v2": {
|
"node_modules/@dadosfera/protospack-v2": {
|
||||||
"version": "3.39.0",
|
"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.39.0.tgz",
|
"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-z6q+ZRpbDT6apfmly1+X818DgAFUCilFO0ATP7xR5+SH+GAUAJLY1dJRQDEkq5vFIfXnC2Nmm9aODZAs+9/5vw==",
|
"integrity": "sha512-m77RSqAO+hZkjUgbdrMqC+6yyyo7indH6fWP3WuygCHGYwdN6FsWTA+EGTAhXQRSgNlI8h358ZpRoILnnGzLMg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.9.3",
|
"@grpc/grpc-js": "^1.9.3",
|
||||||
"rxjs": "^7.5.5"
|
"rxjs": "^7.5.5"
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@
|
|||||||
"@aws-sdk/signature-v4": "^3.370.0",
|
"@aws-sdk/signature-v4": "^3.370.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack": "2.5.3",
|
"@dadosfera/protospack": "2.5.3",
|
||||||
"@dadosfera/protospack-v2": "^3.39.0",
|
"@dadosfera/protospack-v2": "^3.40.0-beta.3",
|
||||||
"@grpc/grpc-js": "^1.9.3",
|
"@grpc/grpc-js": "^1.9.3",
|
||||||
"@grpc/proto-loader": "^0.7.9",
|
"@grpc/proto-loader": "^0.7.9",
|
||||||
"@nestjs/cli": "^9.5.0",
|
"@nestjs/cli": "^9.5.0",
|
||||||
|
|||||||
@@ -220,10 +220,11 @@ export class PipelinesController {
|
|||||||
|
|
||||||
const result = await this.pipelinesClientService
|
const result = await this.pipelinesClientService
|
||||||
.findOne({ id }, metadata)
|
.findOne({ id }, metadata)
|
||||||
.then((res) => {
|
.then(async (res) => {
|
||||||
//{pipeline:{tables: {tables: [], input_id: ''}}}
|
//{pipeline:{tables: {tables: [], input_id: ''}}}
|
||||||
let tables = JSON.parse(res.pipeline.config.tables);
|
const parsed = JSON.parse(res.pipeline.config.tables);
|
||||||
if (tables?.tables) tables = tables.tables;
|
const tables = parsed?.tables ?? parsed;
|
||||||
|
|
||||||
Object.assign(res.pipeline, {
|
Object.assign(res.pipeline, {
|
||||||
transformations: res.pipeline.transformations
|
transformations: res.pipeline.transformations
|
||||||
? JSON.parse(res.pipeline.transformations)
|
? JSON.parse(res.pipeline.transformations)
|
||||||
|
|||||||
@@ -933,6 +933,61 @@ 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 ====================
|
// ==================== JOBS - JDBC SYNC MODE ROUTES ====================
|
||||||
|
|
||||||
@Get('jobs/jdbc/:jobId')
|
@Get('jobs/jdbc/:jobId')
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ import { PlatformApiService } from './platform-api.service';
|
|||||||
import { ElasticsearchModule } from '../../services/elasticsearch';
|
import { ElasticsearchModule } from '../../services/elasticsearch';
|
||||||
import { DynamoDBModule } from '../../services/dynamodb';
|
import { DynamoDBModule } from '../../services/dynamodb';
|
||||||
import { CustomersModule } from '../customers/customers.module';
|
import { CustomersModule } from '../customers/customers.module';
|
||||||
|
import { PipelinesV2Module } from '../pipelinesV2/pipelines.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [ElasticsearchModule, DynamoDBModule, CustomersModule],
|
imports: [ElasticsearchModule, DynamoDBModule, CustomersModule, PipelinesV2Module],
|
||||||
controllers: [PlatformApiController],
|
controllers: [PlatformApiController],
|
||||||
providers: [PlatformApiService, DadosferaLogger],
|
providers: [PlatformApiService, DadosferaLogger],
|
||||||
exports: [PlatformApiService],
|
exports: [PlatformApiService],
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export interface InputDocument {
|
|||||||
type: string;
|
type: string;
|
||||||
columns?: string[];
|
columns?: string[];
|
||||||
reference_column?: ReferenceColumn;
|
reference_column?: ReferenceColumn;
|
||||||
|
status?: string;
|
||||||
}>;
|
}>;
|
||||||
credentials?: Record<string, any>;
|
credentials?: Record<string, any>;
|
||||||
}
|
}
|
||||||
@@ -125,9 +126,13 @@ export class DynamoDBService {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { Item } = await this.documentClient.send(getCommand);
|
try {
|
||||||
|
const { Item } = await this.documentClient.send(getCommand);
|
||||||
return Item as InputDocument | null;
|
return Item as InputDocument | null;
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('DynamoDB: findInput failed', { inputId, clientId, error: error.message });
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteInput(clientId: string, inputId: string): Promise<void> {
|
async deleteInput(clientId: string, inputId: string): Promise<void> {
|
||||||
@@ -163,6 +168,7 @@ export class DynamoDBService {
|
|||||||
type?: string;
|
type?: string;
|
||||||
columns?: string[];
|
columns?: string[];
|
||||||
reference_column?: ReferenceColumn | null;
|
reference_column?: ReferenceColumn | null;
|
||||||
|
status?: string;
|
||||||
},
|
},
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const dynamoTableName = DYNAMODB_CONFIG.inputsTable();
|
const dynamoTableName = DYNAMODB_CONFIG.inputsTable();
|
||||||
@@ -203,6 +209,7 @@ export class DynamoDBService {
|
|||||||
updatedTable.reference_column = changes.reference_column;
|
updatedTable.reference_column = changes.reference_column;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ('status' in changes) updatedTable.status = changes.status;
|
||||||
|
|
||||||
tables[tableIndex] = updatedTable;
|
tables[tableIndex] = updatedTable;
|
||||||
|
|
||||||
@@ -231,4 +238,53 @@ export class DynamoDBService {
|
|||||||
throw error;
|
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