mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-06 10:09:08 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00cbadbb45 | ||
|
|
47ad527d38 | ||
|
|
d54f381998 | ||
|
|
3fd586753e | ||
|
|
9b3894f9e4 | ||
|
|
4a5f8f679a | ||
|
|
a444f5e5ec | ||
|
|
0d30c1cf83 |
@@ -23,6 +23,7 @@ import {
|
|||||||
} 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';
|
||||||
import { CreateInputReq } from './dtos/input.model';
|
import { CreateInputReq } from './dtos/input.model';
|
||||||
|
import { Metadata } from '@grpc/grpc-js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|
||||||
@@ -73,10 +74,10 @@ export class InputsService {
|
|||||||
objectCamelToSnake(createInputResponse);
|
objectCamelToSnake(createInputResponse);
|
||||||
return createInputResponse;
|
return createInputResponse;
|
||||||
},
|
},
|
||||||
update: async (updateInputDTO: UpdateInputRequest): Promise<InputUpdateResponse> => {
|
update: async (updateInputDTO: UpdateInputRequest, metadata: Metadata): Promise<InputUpdateResponse> => {
|
||||||
this.logger.info('InputClientService - Update' + JSON.stringify(updateInputDTO));
|
this.logger.info('InputClientService - Update' + JSON.stringify(updateInputDTO));
|
||||||
const updateInputResponse = await lastValueFrom(
|
const updateInputResponse = await lastValueFrom(
|
||||||
this.inputWriteService.InputUpdate(updateInputDTO),
|
this.inputWriteService.InputUpdate(updateInputDTO, metadata),
|
||||||
);
|
);
|
||||||
|
|
||||||
return updateInputResponse;
|
return updateInputResponse;
|
||||||
@@ -206,7 +207,7 @@ export class InputsService {
|
|||||||
return findOneInputResponse;
|
return findOneInputResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(id: string, data, info: Info) {
|
async update(id: string, data, info: Info, metadata?: Metadata) {
|
||||||
// this.validateCron({ ...data, info });
|
// this.validateCron({ ...data, info });
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
@@ -217,7 +218,7 @@ export class InputsService {
|
|||||||
id,
|
id,
|
||||||
...data,
|
...data,
|
||||||
info,
|
info,
|
||||||
});
|
}, metadata);
|
||||||
|
|
||||||
const updateInputResponse = this.adjustInputPayload(
|
const updateInputResponse = this.adjustInputPayload(
|
||||||
input,
|
input,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
HttpException,
|
HttpException,
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
UseGuards,
|
UseGuards,
|
||||||
Res,
|
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import {
|
import {
|
||||||
ApiCreatedResponse,
|
ApiCreatedResponse,
|
||||||
@@ -318,7 +317,6 @@ export class PipelinesController {
|
|||||||
) {
|
) {
|
||||||
this.logger.info('PipelinesController - update', { user });
|
this.logger.info('PipelinesController - update', { user });
|
||||||
|
|
||||||
const { customer_id, customer_name, user_id, username } = user;
|
|
||||||
const info: Info = {
|
const info: Info = {
|
||||||
user_id: user.user_id,
|
user_id: user.user_id,
|
||||||
customer: user.customer_name,
|
customer: user.customer_name,
|
||||||
@@ -326,13 +324,7 @@ export class PipelinesController {
|
|||||||
pipeline_id: pipelineId
|
pipeline_id: pipelineId
|
||||||
};
|
};
|
||||||
|
|
||||||
const metadata = PackTheMetadata({
|
const metadata = PackTheMetadata(user);
|
||||||
customer_id,
|
|
||||||
customer_name,
|
|
||||||
user_id,
|
|
||||||
username,
|
|
||||||
language,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await this.pipelinesClientService.updatePipelineInput(
|
const response = await this.pipelinesClientService.updatePipelineInput(
|
||||||
pipelineId,
|
pipelineId,
|
||||||
|
|||||||
@@ -383,7 +383,8 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
const updateInputResponse = await this.inputsService.update(
|
const updateInputResponse = await this.inputsService.update(
|
||||||
inputId,
|
inputId,
|
||||||
updateInputDTO,
|
updateInputDTO,
|
||||||
info
|
info,
|
||||||
|
metadata
|
||||||
);
|
);
|
||||||
|
|
||||||
const inputRollback = () => {
|
const inputRollback = () => {
|
||||||
@@ -404,34 +405,36 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
|
|
||||||
const nimbusUpdates = updateInputResponse?.tablesUpdate || [];
|
const nimbusUpdates = updateInputResponse?.tablesUpdate || [];
|
||||||
|
|
||||||
nimbusUpdates.forEach(update => {
|
if (user.customer_modules.includes('catalog')) {
|
||||||
const nimbusRollback = () => {
|
nimbusUpdates.forEach(update => {
|
||||||
return this.nimbusService.renameTable(
|
const nimbusRollback = () => {
|
||||||
info.customer,
|
return this.nimbusService.renameTable(
|
||||||
update.database,
|
info.customer,
|
||||||
{
|
update.database,
|
||||||
table_name: update.table_name,
|
{
|
||||||
table_schema: update.table_schema
|
table_name: update.table_name,
|
||||||
},
|
table_schema: update.table_schema
|
||||||
{
|
},
|
||||||
table_name: update.old_table_name,
|
{
|
||||||
table_schema: update.old_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");
|
||||||
}
|
}
|
||||||
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 {
|
try {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ interface IMetadata {
|
|||||||
details?: string;
|
details?: string;
|
||||||
sensitive?: string;
|
sensitive?: string;
|
||||||
roles?: string[];
|
roles?: string[];
|
||||||
|
customer_modules?: string[];
|
||||||
is_data_manager?: boolean;
|
is_data_manager?: boolean;
|
||||||
access_token?: string;
|
access_token?: string;
|
||||||
host?: string;
|
host?: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user