mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-28 19:50:05 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8551239038 | ||
|
|
4cf7c6e17b | ||
|
|
88c9c36eb0 | ||
|
|
4b317778f7 | ||
|
|
2eea9787cd | ||
|
|
c1ab5d152f | ||
|
|
8798f5d54e | ||
|
|
1da733b5bc | ||
|
|
930c8bc037 | ||
|
|
0913741500 | ||
|
|
3e9d0063ae | ||
|
|
2bc0fe1e9e | ||
|
|
f0fb6e6b4a | ||
|
|
74c27d9637 | ||
|
|
216c83d7fa |
Generated
+7
-7
@@ -12,7 +12,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.3",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.3",
|
||||||
"@dadosfera/protospack-v2": "3.17.2",
|
"@dadosfera/protospack-v2": "3.17.5",
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"@grpc/proto-loader": "^0.6.13",
|
"@grpc/proto-loader": "^0.6.13",
|
||||||
"@nestjs/common": "^8.4.7",
|
"@nestjs/common": "^8.4.7",
|
||||||
@@ -1726,9 +1726,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@dadosfera/protospack-v2": {
|
"node_modules/@dadosfera/protospack-v2": {
|
||||||
"version": "3.17.2",
|
"version": "3.17.5",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.17.2.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.17.5.tgz",
|
||||||
"integrity": "sha512-N1hn7lIBWgc4JPEAdlQ3jt+++y61XYb9amDmgOUbfSt4803oSdAnCktrcxq3/0e/ZuSYm0qESOkKn0uNLDlGcg==",
|
"integrity": "sha512-pVi9yCqCIngreW/z75jDqo7dladmN/z49K5m2vdd4ljS7yR21XicrCIg+YxSOwFga4wa3c8bI6WZ40Mp8ah8IA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
@@ -12305,9 +12305,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@dadosfera/protospack-v2": {
|
"@dadosfera/protospack-v2": {
|
||||||
"version": "3.17.2",
|
"version": "3.17.5",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.17.2.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.17.5.tgz",
|
||||||
"integrity": "sha512-N1hn7lIBWgc4JPEAdlQ3jt+++y61XYb9amDmgOUbfSt4803oSdAnCktrcxq3/0e/ZuSYm0qESOkKn0uNLDlGcg==",
|
"integrity": "sha512-pVi9yCqCIngreW/z75jDqo7dladmN/z49K5m2vdd4ljS7yR21XicrCIg+YxSOwFga4wa3c8bI6WZ40Mp8ah8IA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.3",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.3",
|
||||||
"@dadosfera/protospack-v2": "3.17.2",
|
"@dadosfera/protospack-v2": "3.17.5",
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"@grpc/proto-loader": "^0.6.13",
|
"@grpc/proto-loader": "^0.6.13",
|
||||||
"@nestjs/common": "^8.4.7",
|
"@nestjs/common": "^8.4.7",
|
||||||
|
|||||||
@@ -26,16 +26,22 @@ import {
|
|||||||
ConnectionsApiNetworkConfig,
|
ConnectionsApiNetworkConfig,
|
||||||
NetworkConfigDto,
|
NetworkConfigDto,
|
||||||
} from '../network-config/dto/network-config';
|
} from '../network-config/dto/network-config';
|
||||||
|
import DadosferaLogger from '@dadosfera/dadosfera-logs/dist';
|
||||||
|
|
||||||
export class ConnectionClientService implements OnModuleInit {
|
export class ConnectionClientService implements OnModuleInit {
|
||||||
private connectionServiceRead: ConnectionManager.ReadService.ConnectionManagerReadServices;
|
private connectionServiceRead: ConnectionManager.ReadService.ConnectionManagerReadServices;
|
||||||
private connectionServiceWrite: ConnectionManager.WriteService.ConnectionManagerWriteServices;
|
private connectionServiceWrite: ConnectionManager.WriteService.ConnectionManagerWriteServices;
|
||||||
|
logger: DadosferaLogger;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(ConnectionClientConfiguration.name)
|
@Inject(ConnectionClientConfiguration.name)
|
||||||
private readonly grpcClient: ClientGrpc,
|
private readonly grpcClient: ClientGrpc,
|
||||||
private usersService: UsersService,
|
private usersService: UsersService,
|
||||||
private connectorService: ConnectorClientService,
|
private connectorService: ConnectorClientService,
|
||||||
) {}
|
private dadosferaLogger: DadosferaLogger,
|
||||||
|
) {
|
||||||
|
this.logger = dadosferaLogger.logger;
|
||||||
|
}
|
||||||
|
|
||||||
onModuleInit() {
|
onModuleInit() {
|
||||||
this.connectionServiceWrite =
|
this.connectionServiceWrite =
|
||||||
@@ -198,34 +204,58 @@ export class ConnectionClientService implements OnModuleInit {
|
|||||||
JSON.parse(connectorsStr).map((c) => c),
|
JSON.parse(connectorsStr).map((c) => c),
|
||||||
);
|
);
|
||||||
const { customers } = await this.usersService.findAllCustomers();
|
const { customers } = await this.usersService.findAllCustomers();
|
||||||
const promises: Promise<{
|
|
||||||
|
const customer_connections: {
|
||||||
customer_name: string;
|
customer_name: string;
|
||||||
customer_id: string;
|
customer_id: string;
|
||||||
productConnections: Record<string, any>[];
|
productConnections: Record<string, any>[];
|
||||||
platformConnections: ConnectionApiConnection[];
|
platformConnections: ConnectionApiConnection[];
|
||||||
productNetworkConfigs: Record<string, any>[];
|
productNetworkConfigs: Record<string, any>[];
|
||||||
platformNetworkConfigs: ConnectionsApiNetworkConfig[];
|
platformNetworkConfigs: ConnectionsApiNetworkConfig[];
|
||||||
}>[] = [];
|
}[] = [];
|
||||||
|
for (const customer of customers) {
|
||||||
|
const { name: customer_name, id: customer_id } = customer;
|
||||||
|
|
||||||
customers.forEach((c) => {
|
const customer_connection = await this.INTERNAL_getAllConnections({
|
||||||
const customer_name = c.name;
|
customer_name,
|
||||||
const customer_id = c.id;
|
}).then((res) => ({
|
||||||
promises.push(
|
customer_name,
|
||||||
this.INTERNAL_getAllConnections({ customer_name }).then((res) => ({
|
customer_id,
|
||||||
customer_name,
|
platformConnections: res.platformConnections
|
||||||
customer_id,
|
? JSON.parse(res.platformConnections)
|
||||||
platformConnections: JSON.parse(res.platformConnections),
|
: [],
|
||||||
productConnections: JSON.parse(res.productConnections),
|
productConnections: res.productConnections
|
||||||
productNetworkConfigs: JSON.parse(res.productNetworkConfigs),
|
? JSON.parse(res.productConnections)
|
||||||
platformNetworkConfigs: JSON.parse(res.platformNetworkConfigs),
|
: [],
|
||||||
})),
|
productNetworkConfigs: res.productNetworkConfigs
|
||||||
|
? JSON.parse(res.productNetworkConfigs)
|
||||||
|
: [],
|
||||||
|
platformNetworkConfigs: res.platformNetworkConfigs
|
||||||
|
? JSON.parse(res.platformNetworkConfigs)
|
||||||
|
: [],
|
||||||
|
}));
|
||||||
|
customer_connections.push(customer_connection);
|
||||||
|
}
|
||||||
|
this.logger.info(
|
||||||
|
'DEBUG_ConnectionsMigrations - ' + JSON.stringify(customer_connections),
|
||||||
|
);
|
||||||
|
|
||||||
|
const migrations: {
|
||||||
|
customer_name: string;
|
||||||
|
status: any[];
|
||||||
|
productConnectionsMissing: ConnectionApiConnection[];
|
||||||
|
productNetworkConfigsMissing: ConnectionsApiNetworkConfig[];
|
||||||
|
}[] = [];
|
||||||
|
for (const customer_connection of customer_connections) {
|
||||||
|
const productConnectionsMissing: ConnectionApiConnection[] = [];
|
||||||
|
const productNetworkConfigsMissing: ConnectionsApiNetworkConfig[] = [];
|
||||||
|
const status: any[] = [];
|
||||||
|
let updatePromises: Promise<any>[] = [];
|
||||||
|
|
||||||
|
this.logger.info(
|
||||||
|
'DEBUG_ConnectionsMigrations - customer_connections ' +
|
||||||
|
JSON.stringify(customer_connection),
|
||||||
);
|
);
|
||||||
});
|
|
||||||
const customer_connections = await Promise.all(promises);
|
|
||||||
|
|
||||||
const productConnectionsMissing: ConnectionApiConnection[] = [];
|
|
||||||
const productNetworkConfigsMissing: ConnectionsApiNetworkConfig[] = [];
|
|
||||||
const migrations = customer_connections.map((cc) => {
|
|
||||||
const {
|
const {
|
||||||
customer_name,
|
customer_name,
|
||||||
productConnections,
|
productConnections,
|
||||||
@@ -233,100 +263,108 @@ export class ConnectionClientService implements OnModuleInit {
|
|||||||
productNetworkConfigs,
|
productNetworkConfigs,
|
||||||
platformNetworkConfigs,
|
platformNetworkConfigs,
|
||||||
customer_id,
|
customer_id,
|
||||||
} = cc;
|
} = customer_connection;
|
||||||
|
|
||||||
platformConnections.forEach((plc) => {
|
platformConnections?.forEach((plc) => {
|
||||||
const productConnection = productConnections.find(
|
const productConnection = productConnections.find(
|
||||||
(prc) => prc.id === plc.config_id,
|
(prc) => prc.id === plc.config_id,
|
||||||
);
|
);
|
||||||
if (!productConnection) productConnectionsMissing.push(plc);
|
if (!productConnection) productConnectionsMissing.push(plc);
|
||||||
});
|
});
|
||||||
|
platformNetworkConfigs?.forEach((platNetConfig) => {
|
||||||
platformNetworkConfigs.forEach((platNetConfig) => {
|
|
||||||
const productNetworkConfig = productNetworkConfigs.find(
|
const productNetworkConfig = productNetworkConfigs.find(
|
||||||
(prodNetConfig) => prodNetConfig.id === platNetConfig.config_id,
|
(prodNetConfig) => prodNetConfig.id === platNetConfig.config_id,
|
||||||
);
|
);
|
||||||
if (!productNetworkConfig)
|
if (!productNetworkConfig)
|
||||||
productNetworkConfigsMissing.push(platNetConfig);
|
productNetworkConfigsMissing.push(platNetConfig);
|
||||||
});
|
});
|
||||||
|
if (apply) {
|
||||||
|
for (const network_config of productNetworkConfigsMissing) {
|
||||||
|
const networkConfigToCatalog = {
|
||||||
|
id: network_config.config_id,
|
||||||
|
created_at: network_config.created_at,
|
||||||
|
updated_at: network_config.updated_at,
|
||||||
|
customer_name: customer_name,
|
||||||
|
customer_id: customer_id,
|
||||||
|
user_id: '',
|
||||||
|
network_type_id: '',
|
||||||
|
network_type_name: network_config.type,
|
||||||
|
type: network_config.type,
|
||||||
|
plugin: network_config.plugin,
|
||||||
|
name: network_config.name,
|
||||||
|
description: network_config.description,
|
||||||
|
properties: undefined,
|
||||||
|
keywords: undefined,
|
||||||
|
tags: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
const updatePromises: Promise<any>[] = [];
|
|
||||||
for (const network_config of productNetworkConfigsMissing) {
|
|
||||||
const networkConfigToCatalog = {
|
|
||||||
id: network_config.config_id,
|
|
||||||
created_at: network_config.created_at,
|
|
||||||
updated_at: network_config.updated_at,
|
|
||||||
customer_name: cc.customer_name,
|
|
||||||
customer_id: cc.customer_id,
|
|
||||||
user_id: '',
|
|
||||||
network_type_id: '',
|
|
||||||
network_type_name: network_config.type,
|
|
||||||
type: network_config.type,
|
|
||||||
plugin: network_config.plugin,
|
|
||||||
name: network_config.name,
|
|
||||||
description: network_config.description,
|
|
||||||
properties: undefined,
|
|
||||||
keywords: undefined,
|
|
||||||
tags: undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (apply) {
|
|
||||||
updatePromises.push(
|
updatePromises.push(
|
||||||
this.catalogExistingConnection({
|
this.catalogExistingConnection({
|
||||||
networkConfig: networkConfigToCatalog,
|
networkConfig: networkConfigToCatalog,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for (const connection of productConnectionsMissing) {
|
|
||||||
const connector = connectors.find(
|
|
||||||
(c) => c._source.plugin === connection.plugin,
|
|
||||||
);
|
|
||||||
const connectionToCatalog = {
|
|
||||||
id: connection.config_id,
|
|
||||||
created_at: connection.created_at,
|
|
||||||
updated_at: new Date().toISOString(),
|
|
||||||
customer_id: customer_id,
|
|
||||||
user_id: '',
|
|
||||||
plugin: connection.plugin,
|
|
||||||
name: connection.name,
|
|
||||||
description: connection.description,
|
|
||||||
image_url: connector._source.image,
|
|
||||||
network_config_id: connection.network_config_id,
|
|
||||||
type: connection.type,
|
|
||||||
connector_id: connector._id,
|
|
||||||
connector_name: connector._source.name,
|
|
||||||
in_use: 1,
|
|
||||||
username: 'auto',
|
|
||||||
customer_name: customer_name,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (apply) {
|
this.logger.info(
|
||||||
|
'DEBUG_ConnectionsMigrations - Creating missing network configs for customer' +
|
||||||
|
customer_name +
|
||||||
|
' - ' +
|
||||||
|
JSON.stringify(customer_connection),
|
||||||
|
);
|
||||||
|
const updateStatuses = await Promise.all(updatePromises);
|
||||||
|
status.push(...updateStatuses);
|
||||||
|
updatePromises = [];
|
||||||
|
for (const connection of productConnectionsMissing) {
|
||||||
|
const connector = connectors.find(
|
||||||
|
(c) => c._source.plugin === connection.plugin,
|
||||||
|
);
|
||||||
|
const connectionToCatalog = {
|
||||||
|
id: connection.config_id,
|
||||||
|
created_at: connection.created_at,
|
||||||
|
updated_at: new Date().toISOString(),
|
||||||
|
customer_id: customer_id,
|
||||||
|
user_id: '',
|
||||||
|
plugin: connection.plugin,
|
||||||
|
name: connection.name,
|
||||||
|
description: connection.description,
|
||||||
|
image_url: connector._source.image,
|
||||||
|
network_config_id: connection.network_config_id,
|
||||||
|
type: connection.type,
|
||||||
|
connector_id: connector._id,
|
||||||
|
connector_name: connector._source.name,
|
||||||
|
in_use: 1,
|
||||||
|
username: '',
|
||||||
|
customer_name,
|
||||||
|
};
|
||||||
|
|
||||||
updatePromises.push(
|
updatePromises.push(
|
||||||
this.catalogExistingConnection({ connection: connectionToCatalog }),
|
this.catalogExistingConnection({ connection: connectionToCatalog }),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
this.logger.info(
|
||||||
|
'DEBUG_ConnectionsMigrations - Creating missing connections for customer' +
|
||||||
|
' - ' +
|
||||||
|
customer_name +
|
||||||
|
JSON.stringify(customer_connection),
|
||||||
|
);
|
||||||
|
const updateStatuses_2 = await Promise.all(updatePromises);
|
||||||
|
status.push(...updateStatuses_2);
|
||||||
}
|
}
|
||||||
return {
|
|
||||||
customer: { ...cc },
|
this.logger.info(
|
||||||
updatePromises,
|
'DEBUG_ConnectionsMigrations - migrations for customer ' +
|
||||||
|
customer_name +
|
||||||
|
' - ' +
|
||||||
|
JSON.stringify(customer_connection),
|
||||||
|
);
|
||||||
|
migrations.push({
|
||||||
|
customer_name,
|
||||||
|
status,
|
||||||
productConnectionsMissing,
|
productConnectionsMissing,
|
||||||
productNetworkConfigsMissing,
|
productNetworkConfigsMissing,
|
||||||
};
|
|
||||||
});
|
|
||||||
const customersStatus: any[] = [];
|
|
||||||
for (const migration of migrations) {
|
|
||||||
let status: any[] = [];
|
|
||||||
if (apply) {
|
|
||||||
status = await Promise.all(migration.updatePromises);
|
|
||||||
}
|
|
||||||
customersStatus.push({
|
|
||||||
customer: migration.customer.customer_name,
|
|
||||||
status,
|
|
||||||
productConnectionsMissing: migration.productConnectionsMissing,
|
|
||||||
productNetworkConfigsMissing: migration.productNetworkConfigsMissing,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return { customersStatus };
|
|
||||||
|
return { migrations };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export class ConnectorController {
|
|||||||
@Headers('dadosfera-lang') language,
|
@Headers('dadosfera-lang') language,
|
||||||
@Query() queries: GetAllDto,
|
@Query() queries: GetAllDto,
|
||||||
) {
|
) {
|
||||||
this.logger.info('/upload - Upload Connector Route');
|
this.logger.info('/GET - getAllConnectors Route');
|
||||||
if (!language) language = 'en-us';
|
if (!language) language = 'en-us';
|
||||||
|
|
||||||
const { search, size, page, ...filters } = queries;
|
const { search, size, page, ...filters } = queries;
|
||||||
@@ -120,7 +120,7 @@ export class ConnectorController {
|
|||||||
page: page || 1,
|
page: page || 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
const connectors = JSON.parse(response.connectors).connectors;
|
const connectors = JSON.parse(response.connectors);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
message: response.message,
|
message: response.message,
|
||||||
@@ -153,7 +153,7 @@ export class ConnectorController {
|
|||||||
@Param('plugin') plugin: string,
|
@Param('plugin') plugin: string,
|
||||||
@Query('version') version: string,
|
@Query('version') version: string,
|
||||||
) {
|
) {
|
||||||
this.logger.info('/upload - Upload Connector Route');
|
this.logger.info('/GET/:plugin - getConnector Route');
|
||||||
if (!language) language = 'en-us';
|
if (!language) language = 'en-us';
|
||||||
|
|
||||||
const pluginId = `${plugin}-${version}`;
|
const pluginId = `${plugin}-${version}`;
|
||||||
|
|||||||
@@ -98,6 +98,8 @@ export class UpdateUserReq {
|
|||||||
@ApiPropertyOptional()
|
@ApiPropertyOptional()
|
||||||
name?: string;
|
name?: string;
|
||||||
@ApiPropertyOptional()
|
@ApiPropertyOptional()
|
||||||
|
email?: string;
|
||||||
|
@ApiPropertyOptional()
|
||||||
jobTitle?: string;
|
jobTitle?: string;
|
||||||
@ApiPropertyOptional()
|
@ApiPropertyOptional()
|
||||||
department?: string;
|
department?: string;
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ export class UsersService implements OnModuleInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async updateUser(req: UpdateUserReq, id: string, customerId: string) {
|
async updateUser(req: UpdateUserReq, id: string, customerId: string) {
|
||||||
const { department, hierarchy, jobTitle, name, roleNames } = req;
|
const { department, hierarchy, jobTitle, name, roleNames, email } = req;
|
||||||
if (roleNames) {
|
if (roleNames) {
|
||||||
await this.setRoles({ roleNames, userId: id }, customerId);
|
await this.setRoles({ roleNames, userId: id }, customerId);
|
||||||
}
|
}
|
||||||
@@ -112,6 +112,7 @@ export class UsersService implements OnModuleInit {
|
|||||||
department,
|
department,
|
||||||
hierarchy,
|
hierarchy,
|
||||||
jobTitle,
|
jobTitle,
|
||||||
|
email,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
return { user: this.adjustUsersPayload([user])[0] };
|
return { user: this.adjustUsersPayload([user])[0] };
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user