mirror of
https://github.com/dadosfera/maestro.git
synced 2026-12-02 00:30:06 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
298a02bf19 | ||
|
|
1b63c815c8 | ||
|
|
bb1eaa2738 | ||
|
|
96d3a4bb53 | ||
|
|
63bfd53b31 | ||
|
|
ca9aaa7f22 | ||
|
|
1bf3707de7 | ||
|
|
c7bafa638c |
+2
-2
@@ -22,7 +22,7 @@ ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
|
|||||||
# run aws cli without mounting secret, because CI already has AWS credentials
|
# run aws cli without mounting secret, because CI already has AWS credentials
|
||||||
FROM build_base AS ci_image
|
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 aws codeartifact login --tool npm --namespace @dadosfera --repository dadosfera-npm --domain dadosfera --domain-owner 611330257153 --region us-east-1
|
||||||
RUN npm ci --ignore-scripts
|
RUN npm ci
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ FROM build_base AS dev
|
|||||||
RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
|
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
|
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
|
# flag --build-from-source is required to force-build sqlite3
|
||||||
RUN npm ci --ignore-scripts
|
RUN npm ci
|
||||||
COPY . .
|
COPY . .
|
||||||
ENTRYPOINT npm run start:dev
|
ENTRYPOINT npm run start:dev
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
|
|||||||
FROM build_base AS build
|
FROM build_base AS build
|
||||||
RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
|
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
|
aws codeartifact login --tool npm --namespace @dadosfera --repository dadosfera-npm --domain dadosfera --domain-owner 611330257153 --region us-east-1
|
||||||
RUN npm ci --ignore-scripts
|
RUN npm ci
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
|||||||
+8
-82
@@ -3576,7 +3576,14 @@
|
|||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": ""
|
"description": "",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -4519,50 +4526,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/platform/pipeline/{pipelineId}/pipeline_run/{runId}/cancel": {
|
|
||||||
"post": {
|
|
||||||
"operationId": "PlatformApiController_cancelPipelineRun",
|
|
||||||
"summary": "Cancel a running pipeline run",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "pipelineId",
|
|
||||||
"required": true,
|
|
||||||
"in": "path",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "runId",
|
|
||||||
"required": true,
|
|
||||||
"in": "path",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"201": {
|
|
||||||
"description": "",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"type": "object"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"Platform API"
|
|
||||||
],
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/platform/jobs/{jobId}/input": {
|
"/platform/jobs/{jobId}/input": {
|
||||||
"put": {
|
"put": {
|
||||||
"operationId": "PlatformApiController_updateJobInput",
|
"operationId": "PlatformApiController_updateJobInput",
|
||||||
@@ -4705,43 +4668,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/platform/pipelines/{pipelineId}/inputs/{inputId}": {
|
|
||||||
"delete": {
|
|
||||||
"operationId": "PlatformApiController_deleteTable",
|
|
||||||
"summary": "Mark a table as deleted and delete its associated job via platform-api",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "pipelineId",
|
|
||||||
"required": true,
|
|
||||||
"in": "path",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "inputId",
|
|
||||||
"required": true,
|
|
||||||
"in": "path",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"Platform API"
|
|
||||||
],
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/platform/jobs/jdbc/{jobId}": {
|
"/platform/jobs/jdbc/{jobId}": {
|
||||||
"get": {
|
"get": {
|
||||||
"operationId": "PlatformApiController_getJdbcJob",
|
"operationId": "PlatformApiController_getJdbcJob",
|
||||||
|
|||||||
Generated
+5
-5
@@ -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.40.0-beta.5",
|
"@dadosfera/protospack-v2": "^3.39.0",
|
||||||
"@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",
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
"@nestjs/schematics": "^9.2.0",
|
"@nestjs/schematics": "^9.2.0",
|
||||||
"@nestjs/swagger": "^6.3.0",
|
"@nestjs/swagger": "^6.3.0",
|
||||||
"@nestjs/testing": "^9.4.3",
|
"@nestjs/testing": "^9.4.3",
|
||||||
"axios": "0.30.3",
|
"axios": "^0.30.2",
|
||||||
"cache-manager": "^5.1.4",
|
"cache-manager": "^5.1.4",
|
||||||
"cache-manager-ioredis-yet": "^1.1.0",
|
"cache-manager-ioredis-yet": "^1.1.0",
|
||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
@@ -1745,9 +1745,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@dadosfera/protospack-v2": {
|
"node_modules/@dadosfera/protospack-v2": {
|
||||||
"version": "3.40.0-beta.5",
|
"version": "3.39.0",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.40.0-beta.5.tgz",
|
"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-iocKv/XXp2jKAasO5ONgm31cKfLgNsU4pEKZMr6YnR7nQaH11WcW7rnuagNxWoik++wLUqbYyf0bZWRDzMlCPA==",
|
"integrity": "sha512-z6q+ZRpbDT6apfmly1+X818DgAFUCilFO0ATP7xR5+SH+GAUAJLY1dJRQDEkq5vFIfXnC2Nmm9aODZAs+9/5vw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.9.3",
|
"@grpc/grpc-js": "^1.9.3",
|
||||||
"rxjs": "^7.5.5"
|
"rxjs": "^7.5.5"
|
||||||
|
|||||||
+3
-7
@@ -10,7 +10,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"co:login": "aws codeartifact login --tool npm --namespace @dadosfera --repository dadosfera-npm --domain dadosfera --domain-owner 611330257153 --region us-east-1",
|
"co:login": "aws codeartifact login --tool npm --namespace @dadosfera --repository dadosfera-npm --domain dadosfera --domain-owner 611330257153 --region us-east-1",
|
||||||
"proto-update": "npm i @dadosfera/protospack-v2@v3.40.0-beta.1 --save-exact",
|
"proto-update": "npm i @dadosfera/protospack-v2@latest --save-exact",
|
||||||
"prebuild": "rimraf dist",
|
"prebuild": "rimraf dist",
|
||||||
"build": "nest build",
|
"build": "nest build",
|
||||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||||
@@ -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.40.0-beta.5",
|
"@dadosfera/protospack-v2": "^3.39.0",
|
||||||
"@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",
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
"@nestjs/schematics": "^9.2.0",
|
"@nestjs/schematics": "^9.2.0",
|
||||||
"@nestjs/swagger": "^6.3.0",
|
"@nestjs/swagger": "^6.3.0",
|
||||||
"@nestjs/testing": "^9.4.3",
|
"@nestjs/testing": "^9.4.3",
|
||||||
"axios": "0.30.3",
|
"axios": "^0.30.2",
|
||||||
"cache-manager": "^5.1.4",
|
"cache-manager": "^5.1.4",
|
||||||
"cache-manager-ioredis-yet": "^1.1.0",
|
"cache-manager-ioredis-yet": "^1.1.0",
|
||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
@@ -81,7 +81,6 @@
|
|||||||
"swagger-ui-express": "^4.6.3"
|
"swagger-ui-express": "^4.6.3"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"axios": "0.30.3",
|
|
||||||
"form-data": "^4.0.4",
|
"form-data": "^4.0.4",
|
||||||
"body-parser": "^1.20.3",
|
"body-parser": "^1.20.3",
|
||||||
"cross-spawn": "^7.0.5",
|
"cross-spawn": "^7.0.5",
|
||||||
@@ -118,8 +117,5 @@
|
|||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"tsconfig-paths": "^3.14.2",
|
"tsconfig-paths": "^3.14.2",
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^4.9.5"
|
||||||
},
|
|
||||||
"resolutions": {
|
|
||||||
"axios": "0.30.3"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import {
|
|||||||
InputCreateS3Request,
|
InputCreateS3Request,
|
||||||
InputNewCreateRequest,
|
InputNewCreateRequest,
|
||||||
InputUpdateResponse,
|
InputUpdateResponse,
|
||||||
RollbackInputRequest,
|
|
||||||
TestConnectionRequest,
|
TestConnectionRequest,
|
||||||
} from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/messages';
|
} from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/messages';
|
||||||
import { Info } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entities';
|
import { Info } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entities';
|
||||||
@@ -210,8 +209,7 @@ export class InputsService {
|
|||||||
// this.validateCron({ ...data, info });
|
// this.validateCron({ ...data, info });
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
tablesUpdate,
|
nimbusUpdates,
|
||||||
dataAssetUpdate,
|
|
||||||
input
|
input
|
||||||
} = await this.OLD_inputClient.update({
|
} = await this.OLD_inputClient.update({
|
||||||
id,
|
id,
|
||||||
@@ -224,29 +222,13 @@ export class InputsService {
|
|||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
input: updateInputResponse,
|
input: updateInputResponse,
|
||||||
tablesUpdate,
|
nimbusUpdates
|
||||||
dataAssetUpdate
|
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async rollbackUpdate(
|
|
||||||
data: RollbackInputRequest
|
|
||||||
) {
|
|
||||||
this.logger.info('PipelinesClientService - rollbackUpdate');
|
|
||||||
this.logger.info('Rolling back input update with data: ' + JSON.stringify(data));
|
|
||||||
const updatePipelineResponse = await lastValueFrom(
|
|
||||||
this.inputWriteService.RollbackInputUpdate(
|
|
||||||
data
|
|
||||||
),
|
|
||||||
);
|
|
||||||
this.logger.info('Done');
|
|
||||||
|
|
||||||
return updatePipelineResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
async remove(idRequest: IIdRequest) {
|
async remove(idRequest: IIdRequest) {
|
||||||
return lastValueFrom(this.inputWriteService.InputRemove(idRequest));
|
return lastValueFrom(this.inputWriteService.InputRemove(idRequest));
|
||||||
}
|
}
|
||||||
@@ -288,12 +270,4 @@ export class InputsService {
|
|||||||
};
|
};
|
||||||
return formatedPayload;
|
return formatedPayload;
|
||||||
}
|
}
|
||||||
|
|
||||||
async markTableDeleted(data: { input_id: string; table_name: string; info: Info }) {
|
|
||||||
return lastValueFrom(this.inputWriteService.MarkTableDeleted(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
async unmarkTableDeleted(data: { input_id: string; table_name: string; info: Info }) {
|
|
||||||
return lastValueFrom((this.inputWriteService as any).UnmarkTableDeleted(data));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,9 +53,6 @@ import { TableColumns } from '../inputs/dtos/input.model';
|
|||||||
import { UpdateInputRequest } from '../inputs/dtos/old_interfaces';
|
import { UpdateInputRequest } from '../inputs/dtos/old_interfaces';
|
||||||
import { Info } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entities';
|
import { Info } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entities';
|
||||||
|
|
||||||
type PipelineTable = { name: string; job_id?: string; is_deleted?: boolean; [key: string]: any };
|
|
||||||
type PipelineTablesConfig = { input_id?: string; tables: PipelineTable[] };
|
|
||||||
|
|
||||||
@ApiTags('PipelinesV2')
|
@ApiTags('PipelinesV2')
|
||||||
@ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }])
|
@ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }])
|
||||||
@UseFilters(new GrpcToHttpExceptionFilter())
|
@UseFilters(new GrpcToHttpExceptionFilter())
|
||||||
@@ -65,7 +62,6 @@ export class PipelinesController {
|
|||||||
constructor(
|
constructor(
|
||||||
@Inject(DadosferaLogger)
|
@Inject(DadosferaLogger)
|
||||||
dadosferaLogger: DadosferaLogger,
|
dadosferaLogger: DadosferaLogger,
|
||||||
|
|
||||||
private pipelinesClientService: PipelinesService,
|
private pipelinesClientService: PipelinesService,
|
||||||
private oldPipelinesService: OldPipelineService,
|
private oldPipelinesService: OldPipelineService,
|
||||||
) {
|
) {
|
||||||
@@ -226,27 +222,30 @@ export class PipelinesController {
|
|||||||
language,
|
language,
|
||||||
});
|
});
|
||||||
|
|
||||||
const pipelineRes = await this.pipelinesClientService.findOne({ id }, metadata);
|
const result = await this.pipelinesClientService
|
||||||
|
.findOne({ id }, metadata)
|
||||||
|
.then((res) => {
|
||||||
|
//{pipeline:{tables: {tables: [], input_id: ''}}}
|
||||||
|
let tables = JSON.parse(res.pipeline.config.tables);
|
||||||
|
const input_id = tables?.input_id;
|
||||||
|
if (tables?.tables) tables = tables.tables;
|
||||||
|
Object.assign(res.pipeline, {
|
||||||
|
transformations: res.pipeline.transformations
|
||||||
|
? JSON.parse(res.pipeline.transformations)
|
||||||
|
: [],
|
||||||
|
config: {
|
||||||
|
cron: res.pipeline.config.cron,
|
||||||
|
tables,
|
||||||
|
input_id
|
||||||
|
},
|
||||||
|
properties: res.pipeline.properties
|
||||||
|
? JSON.parse(res.pipeline.properties)
|
||||||
|
: {},
|
||||||
|
});
|
||||||
|
return res;
|
||||||
|
});
|
||||||
|
|
||||||
const parsed: PipelineTablesConfig = JSON.parse(pipelineRes.pipeline.config.tables);
|
return result;
|
||||||
const input_id = parsed.input_id;
|
|
||||||
const tables: PipelineTable[] = parsed.tables ?? [];
|
|
||||||
|
|
||||||
Object.assign(pipelineRes.pipeline, {
|
|
||||||
transformations: pipelineRes.pipeline.transformations
|
|
||||||
? JSON.parse(pipelineRes.pipeline.transformations)
|
|
||||||
: [],
|
|
||||||
config: {
|
|
||||||
cron: pipelineRes.pipeline.config.cron,
|
|
||||||
tables,
|
|
||||||
input_id,
|
|
||||||
},
|
|
||||||
properties: pipelineRes.pipeline.properties
|
|
||||||
? JSON.parse(pipelineRes.pipeline.properties)
|
|
||||||
: {},
|
|
||||||
});
|
|
||||||
|
|
||||||
return pipelineRes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch('/:id')
|
@Patch('/:id')
|
||||||
|
|||||||
@@ -28,13 +28,11 @@ import { getObjValueFromPath, objHasPath } from 'src/utils/ObjValueFromPath';
|
|||||||
import ErrorCodes from 'src/utils/errorCodes';
|
import ErrorCodes from 'src/utils/errorCodes';
|
||||||
import ErrorBuilder from 'src/utils/ErrorBuilder';
|
import ErrorBuilder from 'src/utils/ErrorBuilder';
|
||||||
import { PlatformApiService } from '../platform-api/platform-api.service';
|
import { PlatformApiService } from '../platform-api/platform-api.service';
|
||||||
import { Info } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entities';
|
import { Info, NewTable } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entities';
|
||||||
import { TableUpdate } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/messages';
|
import { NimbusUpdate } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/messages';
|
||||||
import { AxiosError } from 'axios';
|
import axios from 'axios';
|
||||||
import { NimbusService } from 'src/services/nimbus/nimbus.service';
|
import { NimbusService } from 'src/services/nimbus/nimbus.service';
|
||||||
|
|
||||||
type RollbackPromise = () => Promise<any>;
|
|
||||||
|
|
||||||
export class PipelinesService implements OnModuleInit {
|
export class PipelinesService implements OnModuleInit {
|
||||||
logger: DadosferaLogger;
|
logger: DadosferaLogger;
|
||||||
pipelineWriteService: WriteService.PipelineV2WriteService;
|
pipelineWriteService: WriteService.PipelineV2WriteService;
|
||||||
@@ -354,117 +352,33 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
async updatePipelineInput(pipelineId: string, inputId: string, updateInputDTO: UpdatePlatformInputRequest, info: Info, user: RequestUser, metadata: Metadata) {
|
async updatePipelineInput(pipelineId: string, inputId: string, updateInputDTO: UpdatePlatformInputRequest, info: Info, user: RequestUser, metadata: Metadata) {
|
||||||
this.logger.info('InputClientService - Update');
|
this.logger.info('InputClientService - Update');
|
||||||
|
|
||||||
const {
|
this.logger.info('Update Dynamo Reference');
|
||||||
input: oldInput
|
|
||||||
} = await this.inputsService.findOne({
|
|
||||||
id: inputId,
|
|
||||||
info: info
|
|
||||||
});
|
|
||||||
|
|
||||||
this.logger.info('Update Dynamo Reference :' + JSON.stringify(oldInput));
|
|
||||||
const pipelineIdFormat = pipelineId.split('-').join('_');
|
const pipelineIdFormat = pipelineId.split('-').join('_');
|
||||||
const rollback: RollbackPromise[] = [];
|
console.log("updatePipelineInput", info, updateInputDTO)
|
||||||
|
|
||||||
const updateInputResponse = await this.inputsService.update(
|
const updateInputResponse = await this.inputsService.update(
|
||||||
inputId,
|
inputId,
|
||||||
updateInputDTO,
|
updateInputDTO,
|
||||||
info
|
info
|
||||||
|
)
|
||||||
|
|
||||||
|
this.logger.info(JSON.stringify(updateInputResponse))
|
||||||
|
await this.updateNimbus(info.customer, updateInputResponse.nimbusUpdates);
|
||||||
|
|
||||||
|
await this.updatePlatformJobs(
|
||||||
|
pipelineIdFormat,
|
||||||
|
updateInputDTO,
|
||||||
|
user
|
||||||
);
|
);
|
||||||
|
|
||||||
const inputRollback = () => {
|
|
||||||
this.logger.info("exec rollback to input: " + JSON.stringify(oldInput));
|
|
||||||
return this.inputsService.rollbackUpdate(
|
|
||||||
{
|
|
||||||
id: inputId,
|
|
||||||
dataAssetUpdate: updateInputResponse.dataAssetUpdate,
|
|
||||||
tables: oldInput.tables,
|
|
||||||
info
|
|
||||||
}
|
|
||||||
) as Promise<any>;
|
|
||||||
}
|
|
||||||
|
|
||||||
rollback.push(inputRollback);
|
|
||||||
|
|
||||||
this.logger.info("Input Update Response: " + JSON.stringify(updateInputResponse))
|
|
||||||
|
|
||||||
const nimbusUpdates = updateInputResponse?.tablesUpdate || [];
|
|
||||||
|
|
||||||
nimbusUpdates.forEach(update => {
|
|
||||||
const nimbusRollback = () => {
|
|
||||||
return this.nimbusService.renameTable(
|
|
||||||
info.customer,
|
|
||||||
update.database,
|
|
||||||
{
|
|
||||||
table_name: update.table_name,
|
|
||||||
table_schema: update.table_schema
|
|
||||||
},
|
|
||||||
{
|
|
||||||
table_name: update.old_table_name,
|
|
||||||
table_schema: update.old_table_schema
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
rollback.push(nimbusRollback);
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
await this.updateNimbus(info.customer, nimbusUpdates);
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error(error);
|
|
||||||
if (error instanceof AxiosError) {
|
|
||||||
this.logger.error(JSON.stringify(error.response.data));
|
|
||||||
}
|
|
||||||
await this.executeRenameRollback(rollback);
|
|
||||||
|
|
||||||
throw new Error("Error Nimbus updating tables");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await this.updatePlatformJobs(
|
|
||||||
pipelineIdFormat,
|
|
||||||
updateInputResponse.input.type,
|
|
||||||
updateInputDTO,
|
|
||||||
user
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error(error);
|
|
||||||
await this.executeRenameRollback(rollback)
|
|
||||||
throw new Error("Error Platform API updating jobs");
|
|
||||||
}
|
|
||||||
|
|
||||||
return updateInputResponse;
|
return updateInputResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async executeRenameRollback(request: RollbackPromise[]) {
|
private async updateNimbus(customer: string, changes: NimbusUpdate[]) {
|
||||||
this.logger.info('rollback steps: ' + request.length)
|
|
||||||
const result = await Promise.allSettled(request.map(func => func()));
|
|
||||||
result.forEach(promise => {
|
|
||||||
this.logger.info("Promise finish with status: " + promise.status)
|
|
||||||
|
|
||||||
if (promise.status === "rejected") {
|
|
||||||
this.logger.error("reject with: " + JSON.stringify(promise.reason || {}))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (promise.status === "fulfilled") {
|
|
||||||
this.logger.info("success with: " + JSON.stringify(promise.value || {}))
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private async updateNimbus(customer: string, changes: TableUpdate[]) {
|
|
||||||
// throw new Error("teste error nimbus");
|
|
||||||
this.logger.info('Nimbus Changes: ' + JSON.stringify(changes));
|
this.logger.info('Nimbus Changes: ' + JSON.stringify(changes));
|
||||||
if(!changes || changes.length === 0) return;
|
if(!changes || changes.length === 0) return;
|
||||||
|
|
||||||
const requests = changes.map(change => {
|
const requests = changes.map(change => {
|
||||||
return this.nimbusService.renameTable(customer, change.database, {
|
return this.nimbusService.renameTable(customer, change.database, change.old, change.new);
|
||||||
table_name: change.old_table_name,
|
|
||||||
table_schema: change.old_table_schema
|
|
||||||
}, {
|
|
||||||
table_name: change.table_name,
|
|
||||||
table_schema: change.table_schema
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const values = await Promise.allSettled(requests);
|
const values = await Promise.allSettled(requests);
|
||||||
@@ -472,23 +386,9 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
const success = values.map(request => request.status === "fulfilled")
|
const success = values.map(request => request.status === "fulfilled")
|
||||||
|
|
||||||
this.logger.info("Updates with succes: " + success.length);
|
this.logger.info("Updates with succes: " + success.length);
|
||||||
|
|
||||||
values.forEach(promise => {
|
|
||||||
this.logger.info("Promise finish with status: " + promise.status)
|
|
||||||
|
|
||||||
if (promise.status === "rejected") {
|
|
||||||
this.logger.error("reject with: " + JSON.stringify(promise.reason || {}));
|
|
||||||
throw new Error(promise.reason );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (promise.status === "fulfilled") {
|
|
||||||
this.logger.info("success with: " + JSON.stringify(promise.value || {}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async updatePlatformJobs(pipelineId: string, pipelineType: string, updateInputDTO: UpdatePlatformInputRequest, user: RequestUser) {
|
async updatePlatformJobs(pipelineId: string, updateInputDTO: UpdatePlatformInputRequest, user: RequestUser) {
|
||||||
const jobsUpdated = [];
|
const jobsUpdated = [];
|
||||||
|
|
||||||
for (const [index, table] of updateInputDTO.tables.entries()) {
|
for (const [index, table] of updateInputDTO.tables.entries()) {
|
||||||
@@ -496,10 +396,6 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
job_id: `${pipelineId}_${index}`,
|
job_id: `${pipelineId}_${index}`,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (table.type !== "incremental_with_qualify") {
|
|
||||||
delete table.destinations?.qualify;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (table.memory) {
|
if (table.memory) {
|
||||||
jobUpdate["memory"] = {
|
jobUpdate["memory"] = {
|
||||||
amount: table.memory * 1000
|
amount: table.memory * 1000
|
||||||
@@ -529,8 +425,8 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
|
|
||||||
if (table.type) {
|
if (table.type) {
|
||||||
hasUpdateSyncMode = true;
|
hasUpdateSyncMode = true;
|
||||||
|
|
||||||
jobSyncMode['target_load_type'] = table.type;
|
jobSyncMode['target_load_type'] = table.type;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasUpdateSyncMode) {
|
if(hasUpdateSyncMode) {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import {
|
|||||||
Inject,
|
Inject,
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
HttpException,
|
HttpException,
|
||||||
NotFoundException,
|
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
@@ -30,7 +29,6 @@ import { validateCronAgainstScheduleLimit } from '../../utils/cron-validation';
|
|||||||
import { CatalogService } from '../catalog/catalog.service';
|
import { CatalogService } from '../catalog/catalog.service';
|
||||||
import { PackTheMetadata } from '../../utils/PackTheMetadata';
|
import { PackTheMetadata } from '../../utils/PackTheMetadata';
|
||||||
import { ValidationTableDTO } from './platform-api.dto';
|
import { ValidationTableDTO } from './platform-api.dto';
|
||||||
import { InputsService } from '../inputs/inputs.service';
|
|
||||||
|
|
||||||
|
|
||||||
type ValidateTablesDTO = {
|
type ValidateTablesDTO = {
|
||||||
@@ -56,7 +54,6 @@ export class PlatformApiController {
|
|||||||
private readonly dynamoDBService: DynamoDBService,
|
private readonly dynamoDBService: DynamoDBService,
|
||||||
private readonly customersService: CustomersService,
|
private readonly customersService: CustomersService,
|
||||||
private readonly catalogService: CatalogService,
|
private readonly catalogService: CatalogService,
|
||||||
private readonly inputsService: InputsService,
|
|
||||||
@Inject(DadosferaLogger) dadosferaLogger: DadosferaLogger,
|
@Inject(DadosferaLogger) dadosferaLogger: DadosferaLogger,
|
||||||
) {
|
) {
|
||||||
this.logger = dadosferaLogger.logger;
|
this.logger = dadosferaLogger.logger;
|
||||||
@@ -848,24 +845,6 @@ export class PlatformApiController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('pipeline/:pipelineId/pipeline_run/:runId/cancel')
|
|
||||||
@ApiOperation({ summary: 'Cancel a running pipeline run' })
|
|
||||||
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE)
|
|
||||||
async cancelPipelineRun(
|
|
||||||
@Param('pipelineId') pipelineId: string,
|
|
||||||
@Param('runId') runId: string,
|
|
||||||
@User() user: RequestUser,
|
|
||||||
) {
|
|
||||||
const normalizedPipelineId = this.normalizePipelineId(pipelineId);
|
|
||||||
const normalizedRunId = this.normalizePipelineId(runId);
|
|
||||||
|
|
||||||
return this.platformApiService.proxy(
|
|
||||||
'POST',
|
|
||||||
`/pipeline/${normalizedPipelineId}/pipeline_run/${normalizedRunId}/cancel`,
|
|
||||||
user,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== JOBS - COLUMN EDITING ROUTES ====================
|
// ==================== JOBS - COLUMN EDITING ROUTES ====================
|
||||||
|
|
||||||
@Put('jobs/:jobId/input')
|
@Put('jobs/:jobId/input')
|
||||||
@@ -965,52 +944,226 @@ export class PlatformApiController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete('pipelines/:pipelineId/inputs/:inputId')
|
// ==================== JOBS - JDBC SYNC MODE ROUTES ====================
|
||||||
@ApiOperation({ summary: 'Mark a table as deleted and delete its associated job via platform-api' })
|
|
||||||
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.DELETE)
|
@Get('jobs/jdbc/:jobId')
|
||||||
async deleteTable(
|
@ApiOperation({ summary: 'Get JDBC job details' })
|
||||||
@Param('pipelineId') pipelineId: string,
|
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.GET)
|
||||||
@Param('inputId') inputId: string,
|
async getJdbcJob(@Param('jobId') jobId: string, @User() user: RequestUser) {
|
||||||
@Body() body: { table_name: string },
|
// Normalize job ID for Platform API (replace - with _)
|
||||||
|
const normalizedJobId = this.normalizeJobId(jobId);
|
||||||
|
return this.platformApiService.proxy('GET', `/jobs/jdbc/${normalizedJobId}`, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('jobs/jdbc/:jobId/sync-mode')
|
||||||
|
@ApiOperation({ summary: 'Update JDBC job sync mode' })
|
||||||
|
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE)
|
||||||
|
async updateJdbcSyncMode(
|
||||||
|
@Param('jobId') jobId: string,
|
||||||
|
@Body() body: any,
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
) {
|
) {
|
||||||
const tableName = body.table_name;
|
// Normalize job ID for Platform API (replace - with _)
|
||||||
const info = {
|
const normalizedJobId = this.normalizeJobId(jobId);
|
||||||
customer_id: user.customer_id,
|
|
||||||
customer: user.customer_name,
|
|
||||||
user_id: user.user_id,
|
|
||||||
};
|
|
||||||
|
|
||||||
this.logger.info('deleteTable: marking table as deleted', { inputId, tableName });
|
const result = await this.platformApiService.proxy(
|
||||||
const updatedInput: any = await this.inputsService.markTableDeleted({ input_id: inputId, table_name: tableName, info });
|
'POST',
|
||||||
this.logger.info('deleteTable: table marked as deleted', { inputId, tableName });
|
`/jobs/jdbc/${normalizedJobId}/sync-mode`,
|
||||||
|
user,
|
||||||
|
body,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Sync to DynamoDB (pass raw jobId for pipeline extraction)
|
||||||
|
await this.syncJdbcSyncModeToDynamoDB(jobId, body, user);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('jobs/:jobId/rename-tables')
|
||||||
|
@ApiOperation({ summary: 'Rename job output tables and sync to catalog' })
|
||||||
|
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE)
|
||||||
|
async renameJobTables(
|
||||||
|
@Param('jobId') jobId: string,
|
||||||
|
@Body() body: RenameTablesBody,
|
||||||
|
@User() user: RequestUser,
|
||||||
|
) {
|
||||||
|
const normalizedJobId = this.normalizeJobId(jobId);
|
||||||
|
|
||||||
|
const currentJob = await this.getJobByAnyConnectorType(normalizedJobId, user);
|
||||||
|
|
||||||
|
const result = await this.platformApiService.proxy(
|
||||||
|
'POST',
|
||||||
|
`/jobs/${normalizedJobId}/rename-tables`,
|
||||||
|
user,
|
||||||
|
body,
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const normalizedPipelineId = this.normalizePipelineId(pipelineId);
|
await this.syncTableRenameToCatalog(jobId, body, currentJob, user);
|
||||||
this.logger.info('deleteTable: fetching pipeline from platform-api', { pipelineId, normalizedPipelineId });
|
|
||||||
const platformPipeline = await this.platformApiService.proxy('GET', `/pipeline/${normalizedPipelineId}`, user);
|
|
||||||
this.logger.info('deleteTable: pipeline fetched', { jobCount: platformPipeline?.jobs?.length });
|
|
||||||
|
|
||||||
const job = platformPipeline?.jobs?.find((j: any) => j.input?.table_name === tableName);
|
|
||||||
if (!job) throw new NotFoundException(`Job for table '${tableName}' not found in pipeline`);
|
|
||||||
|
|
||||||
this.logger.info('deleteTable: deleting job from platform-api', { jobId: job.job_id });
|
|
||||||
await this.platformApiService.proxy('DELETE', `/jobs/${job.job_id}`, user);
|
|
||||||
this.logger.info('deleteTable: job deleted', { jobId: job.job_id });
|
|
||||||
|
|
||||||
return { name: tableName, is_deleted: updatedInput.is_deleted ?? true, deleted_at: updatedInput.deleted_at };
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error('deleteTable: platform-api delete failed, attempting rollback', { tableName, error: error.message });
|
this.logger.error('Catalog sync failed, rolling back Snowflake rename', { jobId, error: error.message });
|
||||||
|
|
||||||
|
const reverseBody = this.buildSnowflakeRollbackBody(body, currentJob.output_config || {});
|
||||||
|
if (reverseBody) {
|
||||||
|
try {
|
||||||
|
await this.platformApiService.proxy('POST', `/jobs/${normalizedJobId}/rename-tables`, user, reverseBody);
|
||||||
|
this.logger.info('Snowflake rename rolled back', { jobId });
|
||||||
|
} catch (rollbackError) {
|
||||||
|
this.logger.error('Snowflake rollback failed', { jobId, error: rollbackError.message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new HttpException('Table rename failed: catalog sync error, Snowflake reverted', 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildSnowflakeRollbackBody(
|
||||||
|
body: RenameTablesBody,
|
||||||
|
outputConfig: any,
|
||||||
|
): RenameTablesBody | null {
|
||||||
|
const reverse: RenameTablesBody = {};
|
||||||
|
|
||||||
|
if (body.raw) {
|
||||||
|
const nested = outputConfig.raw;
|
||||||
|
const oldTableName = nested?.table_name || outputConfig.table_name;
|
||||||
|
const oldTableSchema = nested?.table_schema || 'PUBLIC';
|
||||||
|
if (oldTableName) reverse.raw = { table_name: oldTableName, table_schema: oldTableSchema };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.qualify) {
|
||||||
|
const nested = outputConfig.qualify;
|
||||||
|
if (nested?.table_name) reverse.qualify = { table_name: nested.table_name, table_schema: nested.table_schema || 'STAGED' };
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.keys(reverse).length > 0 ? reverse : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sync table rename to Elasticsearch and Nimbus.
|
||||||
|
*
|
||||||
|
* For each target (raw, qualify):
|
||||||
|
* 1. Resolve old table name from output_config
|
||||||
|
* 2. Find the ES data asset by pipeline + table + schema
|
||||||
|
* 3. Update ES, Nimbus table-metadata, column-metadata, and data-preview
|
||||||
|
* 4. If any step fails, rollback all completed steps for that target
|
||||||
|
*/
|
||||||
|
private async syncTableRenameToCatalog(
|
||||||
|
jobId: string,
|
||||||
|
body: RenameTablesBody,
|
||||||
|
currentJob: any,
|
||||||
|
user: RequestUser,
|
||||||
|
): Promise<void> {
|
||||||
|
const pipelineId = this.extractPipelineIdFromJobId(jobId);
|
||||||
|
const outputConfig = currentJob.output_config || {};
|
||||||
|
const nimbusUrl = this.catalogService._getNimbusUrl({ info: { customer: user.customer_name } });
|
||||||
|
const databaseName = `DADOSFERA_PRD_${user.customer_name.toUpperCase()}`;
|
||||||
|
|
||||||
|
const targets = this.buildRenameTargets(body, outputConfig);
|
||||||
|
|
||||||
|
for (const { key, oldTableName, oldTableSchema, newValues } of targets) {
|
||||||
|
const rollbackSteps: Array<() => Promise<void>> = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.inputsService.unmarkTableDeleted({ input_id: inputId, table_name: tableName, info });
|
const dataAsset = await this.elasticsearchService.findDataAssetByTable(
|
||||||
} catch (rollbackError) {
|
user.customer_name, oldTableName, oldTableSchema,
|
||||||
this.logger.error('deleteTable: rollback failed', { tableName, error: rollbackError.message });
|
);
|
||||||
|
|
||||||
|
if (!dataAsset) {
|
||||||
|
this.logger.warn(`No data asset found for ${key}`, { jobId, pipelineId, oldTableName, oldTableSchema });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { _es_id: esAssetId, nimbus_id: nimbusId } = dataAsset;
|
||||||
|
const oldValues = { table_name: oldTableName, table_schema: oldTableSchema };
|
||||||
|
|
||||||
|
// ES update
|
||||||
|
const esFields = { name: newValues.table_name, table_name: newValues.table_name, table_schema: newValues.table_schema, display_name: newValues.table_name };
|
||||||
|
await this.elasticsearchService.updateDataAsset(user.customer_name, esAssetId, esFields);
|
||||||
|
rollbackSteps.push(() => this.elasticsearchService.updateDataAsset(
|
||||||
|
user.customer_name, esAssetId,
|
||||||
|
{ name: oldTableName, table_name: oldTableName, table_schema: oldTableSchema, display_name: oldTableName },
|
||||||
|
));
|
||||||
|
|
||||||
|
const newTableNameUpper = newValues.table_name.toUpperCase();
|
||||||
|
const newTableSchemaUpper = newValues.table_schema.toUpperCase();
|
||||||
|
const oldTableNameUpper = oldTableName.toUpperCase();
|
||||||
|
const oldTableSchemaUpper = oldTableSchema.toUpperCase();
|
||||||
|
|
||||||
|
// Nimbus table-metadata
|
||||||
|
if (nimbusId) {
|
||||||
|
await this.catalogService.renameTableOnNimbus(nimbusUrl, nimbusId, { table_name: newTableNameUpper, table_schema: newTableSchemaUpper });
|
||||||
|
rollbackSteps.push(() => this.catalogService.renameTableOnNimbus(nimbusUrl, nimbusId, { table_name: oldTableNameUpper, table_schema: oldTableSchemaUpper }));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nimbus column-metadata
|
||||||
|
await this.catalogService.renameColumnMetadataOnNimbus(
|
||||||
|
nimbusUrl, databaseName, oldTableNameUpper, oldTableSchemaUpper, newTableNameUpper, newTableSchemaUpper,
|
||||||
|
);
|
||||||
|
rollbackSteps.push(() => this.catalogService.renameColumnMetadataOnNimbus(
|
||||||
|
nimbusUrl, databaseName, newTableNameUpper, newTableSchemaUpper, oldTableNameUpper, oldTableSchemaUpper,
|
||||||
|
));
|
||||||
|
|
||||||
|
// Nimbus data-preview
|
||||||
|
await this.catalogService.renameDataPreviewOnNimbus(
|
||||||
|
nimbusUrl, databaseName, oldTableNameUpper, oldTableSchemaUpper, newTableNameUpper, newTableSchemaUpper,
|
||||||
|
);
|
||||||
|
rollbackSteps.push(() => this.catalogService.renameDataPreviewOnNimbus(
|
||||||
|
nimbusUrl, databaseName, newTableNameUpper, newTableSchemaUpper, oldTableNameUpper, oldTableSchemaUpper,
|
||||||
|
));
|
||||||
|
|
||||||
|
this.logger.info(`Synced catalog rename for ${key}`, { jobId, oldTableName, newTableName: newValues.table_name });
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(`Catalog sync failed for ${key}, rolling back catalog`, { jobId, error: error.message });
|
||||||
|
await this.executeRollback(rollbackSteps, key, jobId);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== JOBS - JDBC SYNC MODE ROUTES ====================
|
private buildRenameTargets(
|
||||||
|
body: RenameTablesBody,
|
||||||
|
outputConfig: any,
|
||||||
|
): Array<{ key: string; oldTableName: string; oldTableSchema: string; newValues: { table_name: string; table_schema: string } }> {
|
||||||
|
const DEFAULT_SCHEMAS = { raw: 'PUBLIC', qualify: 'STAGED' };
|
||||||
|
const targets: Array<{ key: string; oldTableName: string; oldTableSchema: string; newValues: { table_name: string; table_schema: string } }> = [];
|
||||||
|
|
||||||
|
for (const key of ['raw', 'qualify'] as const) {
|
||||||
|
if (!body[key]) continue;
|
||||||
|
|
||||||
|
const nested = outputConfig[key];
|
||||||
|
|
||||||
|
// qualify: only sync if output_config.qualify already exists
|
||||||
|
if (key === 'qualify' && !nested?.table_name) continue;
|
||||||
|
|
||||||
|
const oldTableName = nested?.table_name || outputConfig.table_name;
|
||||||
|
if (!oldTableName) continue;
|
||||||
|
|
||||||
|
targets.push({
|
||||||
|
key,
|
||||||
|
oldTableName,
|
||||||
|
oldTableSchema: nested?.table_schema || DEFAULT_SCHEMAS[key],
|
||||||
|
newValues: body[key],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return targets;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async executeRollback(
|
||||||
|
steps: Array<() => Promise<void>>,
|
||||||
|
targetKey: string,
|
||||||
|
jobId: string,
|
||||||
|
): Promise<void> {
|
||||||
|
for (const rollback of steps.reverse()) {
|
||||||
|
try {
|
||||||
|
await rollback();
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(`Rollback failed for ${targetKey}`, { jobId, error: error.message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Get('jobs/jdbc/configs/allowed_datatypes')
|
@Get('jobs/jdbc/configs/allowed_datatypes')
|
||||||
@ApiOperation({ summary: 'Get allowed datatypes for JDBC' })
|
@ApiOperation({ summary: 'Get allowed datatypes for JDBC' })
|
||||||
@@ -1023,6 +1176,52 @@ export class PlatformApiController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== JOBS - SINGER REPLICATION ROUTES ====================
|
||||||
|
|
||||||
|
@Get('jobs/singer/:jobId')
|
||||||
|
@ApiOperation({ summary: 'Get Singer job details' })
|
||||||
|
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.GET)
|
||||||
|
async getSingerJob(@Param('jobId') jobId: string, @User() user: RequestUser) {
|
||||||
|
// Normalize job ID for Platform API (replace - with _)
|
||||||
|
const normalizedJobId = this.normalizeJobId(jobId);
|
||||||
|
return this.platformApiService.proxy('GET', `/jobs/singer/${normalizedJobId}`, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('jobs/singer/:jobId/sync-mode')
|
||||||
|
@ApiOperation({ summary: 'Update Singer job sync mode' })
|
||||||
|
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE)
|
||||||
|
async updateSingerSyncMode(
|
||||||
|
@Param('jobId') jobId: string,
|
||||||
|
@Body() body: any,
|
||||||
|
@User() user: RequestUser,
|
||||||
|
) {
|
||||||
|
// Normalize job ID for Platform API (replace - with _)
|
||||||
|
const normalizedJobId = this.normalizeJobId(jobId);
|
||||||
|
|
||||||
|
const result = await this.platformApiService.proxy(
|
||||||
|
'POST',
|
||||||
|
`/jobs/singer/${normalizedJobId}/sync-mode`,
|
||||||
|
user,
|
||||||
|
body,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Sync to DynamoDB (pass raw jobId for pipeline extraction)
|
||||||
|
await this.syncSingerSyncModeToDynamoDB(jobId, body, user);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== JOBS - S3 ROUTES ====================
|
||||||
|
|
||||||
|
@Get('jobs/s3/:jobId')
|
||||||
|
@ApiOperation({ summary: 'Get S3 job details' })
|
||||||
|
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.GET)
|
||||||
|
async getS3Job(@Param('jobId') jobId: string, @User() user: RequestUser) {
|
||||||
|
// Normalize job ID for Platform API (replace - with _)
|
||||||
|
const normalizedJobId = this.normalizeJobId(jobId);
|
||||||
|
return this.platformApiService.proxy('GET', `/jobs/s3/${normalizedJobId}`, user);
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== HEALTH ROUTE ====================
|
// ==================== HEALTH ROUTE ====================
|
||||||
|
|
||||||
@Get('health')
|
@Get('health')
|
||||||
|
|||||||
@@ -8,10 +8,9 @@ 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 { CatalogModule } from '../catalog/catalog.module';
|
import { CatalogModule } from '../catalog/catalog.module';
|
||||||
import { InputsModule } from '../inputs/inputs.module';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [ElasticsearchModule, DynamoDBModule, CustomersModule, CatalogModule, InputsModule],
|
imports: [ElasticsearchModule, DynamoDBModule, CustomersModule, CatalogModule],
|
||||||
controllers: [PlatformApiController],
|
controllers: [PlatformApiController],
|
||||||
providers: [PlatformApiService, DadosferaLogger],
|
providers: [PlatformApiService, DadosferaLogger],
|
||||||
exports: [PlatformApiService],
|
exports: [PlatformApiService],
|
||||||
|
|||||||
@@ -125,13 +125,9 @@ export class DynamoDBService {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
const { Item } = await this.documentClient.send(getCommand);
|
||||||
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> {
|
||||||
@@ -207,6 +203,7 @@ export class DynamoDBService {
|
|||||||
updatedTable.reference_column = changes.reference_column;
|
updatedTable.reference_column = changes.reference_column;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tables[tableIndex] = updatedTable;
|
tables[tableIndex] = updatedTable;
|
||||||
|
|
||||||
// Save updated document
|
// Save updated document
|
||||||
@@ -234,5 +231,4 @@ export class DynamoDBService {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export class NimbusService {
|
|||||||
const path = `/api/catalog/rename-tables/?database_name=${encodeURIComponent(database)}&table_name=${encodeURIComponent(old.table_name)}&table_schema=${encodeURIComponent(old.table_schema)}`;
|
const path = `/api/catalog/rename-tables/?database_name=${encodeURIComponent(database)}&table_name=${encodeURIComponent(old.table_name)}&table_schema=${encodeURIComponent(old.table_schema)}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.logger.info("Request for PATCH " + nimbusUrl + path);
|
this.logger.info("Request for PATCH" + nimbusUrl + path);
|
||||||
this.logger.info("Payload: " + JSON.stringify(update));
|
this.logger.info("Payload: " + JSON.stringify(update));
|
||||||
const { data } = await axios.patch(nimbusUrl + path, {
|
const { data } = await axios.patch(nimbusUrl + path, {
|
||||||
table_name: update.table_name,
|
table_name: update.table_name,
|
||||||
|
|||||||
Reference in New Issue
Block a user