mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-29 11:10:05 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28efdf95d9 | ||
|
|
1ef9fd4298 | ||
|
|
5c24ec5560 | ||
|
|
962e094a65 | ||
|
|
131b166d8d | ||
|
|
5419f3690c | ||
|
|
6f3eb7965b | ||
|
|
909f0d4a4e | ||
|
|
8c8fdf5f88 | ||
|
|
e9582a51c2 | ||
|
|
0590c20af8 | ||
|
|
05eefe866b | ||
|
|
fa023756c7 | ||
|
|
7f967e5e75 | ||
|
|
2a0b17e45a | ||
|
|
b1f6d765b2 | ||
|
|
3c9ed08515 | ||
|
|
c7ca8297c9 | ||
|
|
d269e9efe4 |
+124
-10
@@ -1587,6 +1587,17 @@
|
|||||||
],
|
],
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "canUntoggleLogic",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"enum": [
|
||||||
|
"data_assets_sharing"
|
||||||
|
],
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
@@ -2433,16 +2444,71 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/pipelinesV2/upload": {
|
"/pipelinesV2/init-upload": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "PipelinesController_uploadFile",
|
"operationId": "PipelinesController_initUploadFile",
|
||||||
"parameters": [],
|
"parameters": [],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"required": true,
|
"required": true,
|
||||||
"content": {
|
"content": {
|
||||||
"multipart/form-data": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/IUploadCSVFile"
|
"$ref": "#/components/schemas/IInitUploadCSVFile"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"PipelinesV2"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/pipelinesV2/complete-upload": {
|
||||||
|
"post": {
|
||||||
|
"operationId": "PipelinesController_completeUploadFile",
|
||||||
|
"parameters": [],
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/ICompleteUploadCSVFile"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": "",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"PipelinesV2"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/pipelinesV2/file": {
|
||||||
|
"post": {
|
||||||
|
"operationId": "PipelinesController_uploadedFile",
|
||||||
|
"parameters": [],
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/ICreatePipelineCSVFile"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3339,7 +3405,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"info": {
|
"info": {
|
||||||
"title": "Maestro - main",
|
"title": "Maestro - feature/upload-to-s3-presigned",
|
||||||
"description": "Documentation for Maestro gateway",
|
"description": "Documentation for Maestro gateway",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"contact": {}
|
"contact": {}
|
||||||
@@ -3993,6 +4059,10 @@
|
|||||||
},
|
},
|
||||||
"usage": {
|
"usage": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"canUntoggle": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Whether this role can be untoggled"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
@@ -4470,6 +4540,10 @@
|
|||||||
},
|
},
|
||||||
"usage": {
|
"usage": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"canUntoggle": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Whether this role can be untoggled"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
@@ -4560,6 +4634,10 @@
|
|||||||
},
|
},
|
||||||
"usage": {
|
"usage": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"canUntoggle": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Whether this role can be untoggled"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
@@ -5223,16 +5301,52 @@
|
|||||||
"updated_at"
|
"updated_at"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"IUploadCSVFile": {
|
"IInitUploadCSVFile": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"file": {
|
"file_name": {
|
||||||
"type": "string",
|
"type": "string"
|
||||||
"format": "binary"
|
|
||||||
},
|
},
|
||||||
|
"parts": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"file_name",
|
||||||
|
"parts"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ICompleteUploadCSVFile": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"upload_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"file_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"parts": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"upload_id",
|
||||||
|
"file_name",
|
||||||
|
"parts"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ICreatePipelineCSVFile": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"file_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -5247,8 +5361,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"file",
|
|
||||||
"name",
|
"name",
|
||||||
|
"file_name",
|
||||||
"description",
|
"description",
|
||||||
"encoding",
|
"encoding",
|
||||||
"sep",
|
"sep",
|
||||||
|
|||||||
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.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack-v2": "3.27.1",
|
"@dadosfera/protospack-v2": "3.28.0",
|
||||||
"@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",
|
||||||
@@ -1727,9 +1727,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@dadosfera/protospack-v2": {
|
"node_modules/@dadosfera/protospack-v2": {
|
||||||
"version": "3.27.1",
|
"version": "3.28.0",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.27.1.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.28.0.tgz",
|
||||||
"integrity": "sha512-bAhHSS1cquIJadHiWSO1FFJFfugrJXEIWKFzE7PByeC9XldGru/qlART7KXbxqYHQq8lALKJy1ILyMyG91BsTA==",
|
"integrity": "sha512-JZYYhoaXFUpb5W/fBVt4XYe1Hlef2x9aLlM2Yv0erYn9QAu+/Pb99YnXbkgawQVlmJojSRrAvSwq1o9yOgKCrg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
@@ -12284,9 +12284,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@dadosfera/protospack-v2": {
|
"@dadosfera/protospack-v2": {
|
||||||
"version": "3.27.1",
|
"version": "3.28.0",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.27.1.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.28.0.tgz",
|
||||||
"integrity": "sha512-bAhHSS1cquIJadHiWSO1FFJFfugrJXEIWKFzE7PByeC9XldGru/qlART7KXbxqYHQq8lALKJy1ILyMyG91BsTA==",
|
"integrity": "sha512-JZYYhoaXFUpb5W/fBVt4XYe1Hlef2x9aLlM2Yv0erYn9QAu+/Pb99YnXbkgawQVlmJojSRrAvSwq1o9yOgKCrg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,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.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack-v2": "3.27.1",
|
"@dadosfera/protospack-v2": "3.28.0",
|
||||||
"@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",
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import { AuthClientService } from './auth.service';
|
|||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter';
|
import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter';
|
||||||
import { RequestUser, User } from 'src/authentication/user.decorator';
|
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||||
import { Metadata } from '@grpc/grpc-js';
|
|
||||||
import {
|
import {
|
||||||
AuthRefreshAccessTokenReq,
|
AuthRefreshAccessTokenReq,
|
||||||
AuthSignInReq,
|
AuthSignInReq,
|
||||||
@@ -58,8 +57,7 @@ export class AuthController {
|
|||||||
@Headers('Dadosfera-Lang') language: string,
|
@Headers('Dadosfera-Lang') language: string,
|
||||||
): Promise<AuthSignInRes> {
|
): Promise<AuthSignInRes> {
|
||||||
this.logger.info('/auth - SignIn');
|
this.logger.info('/auth - SignIn');
|
||||||
const metadata = new Metadata();
|
const metadata = PackTheMetadata({ language: language || 'pt-br' });
|
||||||
metadata.add('language', language || 'pt-br');
|
|
||||||
return this.authClient.signIn({ username, password, totp }, metadata);
|
return this.authClient.signIn({ username, password, totp }, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,12 +113,18 @@ export class AuthController {
|
|||||||
|
|
||||||
@Post('reset-password')
|
@Post('reset-password')
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
async resetPassword(@Body() body: AuthResetPasswordRequest) {
|
async resetPassword(
|
||||||
|
@Body() body: AuthResetPasswordRequest,
|
||||||
|
@Headers('dadosfera-lang') language,
|
||||||
|
) {
|
||||||
this.logger.info('/auth - reset-password');
|
this.logger.info('/auth - reset-password');
|
||||||
|
const metadata = PackTheMetadata({
|
||||||
|
language: language,
|
||||||
|
});
|
||||||
|
|
||||||
const { username } = body;
|
const { username } = body;
|
||||||
|
|
||||||
return this.authClient.resetPassword({ username });
|
return this.authClient.resetPassword({ username }, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('verify-reset-password-code')
|
@Post('verify-reset-password-code')
|
||||||
|
|||||||
@@ -90,10 +90,15 @@ export class AuthClientService implements OnModuleInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async resetPassword({ username }: AuthResetPasswordRequest) {
|
async resetPassword(
|
||||||
|
{ username }: AuthResetPasswordRequest,
|
||||||
|
metadata: Metadata,
|
||||||
|
) {
|
||||||
this.logger.info('resetPassword');
|
this.logger.info('resetPassword');
|
||||||
|
|
||||||
return lastValueFrom(this.authService.AuthResetPassword({ username }));
|
return lastValueFrom(
|
||||||
|
this.authService.AuthResetPassword({ username }, metadata),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async verifyResetPasswordCode({
|
async verifyResetPasswordCode({
|
||||||
|
|||||||
@@ -15,9 +15,55 @@ export class MixpanelController {
|
|||||||
delete body.info;
|
delete body.info;
|
||||||
const mixpanel = init(this.mixpanelToken);
|
const mixpanel = init(this.mixpanelToken);
|
||||||
|
|
||||||
|
const separator = user.username.includes('-') ? '-' : '.';
|
||||||
|
const removeValues = [
|
||||||
|
'.dadosferatech.dadosfera',
|
||||||
|
'.demo.dadosfera',
|
||||||
|
'.dadosferademo',
|
||||||
|
'.dadosferarh.dadosfera',
|
||||||
|
'.dadosferatech.dadosfera2',
|
||||||
|
'.dadosferatech.dadosfera',
|
||||||
|
'.dadosfera.fin',
|
||||||
|
'.dadosferafin.dadosfera',
|
||||||
|
'.praxio.dadosfera',
|
||||||
|
'.dadosfera.tech',
|
||||||
|
'.treinamentos@dadosfera.ai',
|
||||||
|
'.dadosfera2',
|
||||||
|
'.treinamentosfera',
|
||||||
|
'.dadosfera',
|
||||||
|
];
|
||||||
|
|
||||||
|
let username = user.username;
|
||||||
|
|
||||||
|
removeValues.forEach((value) => {
|
||||||
|
username = username.replace(value, '');
|
||||||
|
});
|
||||||
|
|
||||||
|
username = username.split('@')?.[0];
|
||||||
|
username = username.split('+')?.[0];
|
||||||
|
|
||||||
|
let firstName = username
|
||||||
|
.substring(0, username.indexOf(separator))
|
||||||
|
.replace('dadosfera', '');
|
||||||
|
let lastName = username
|
||||||
|
.substring(username.lastIndexOf(separator) + 1)
|
||||||
|
.replace('dadosfera', '');
|
||||||
|
|
||||||
|
if (!firstName) {
|
||||||
|
firstName = lastName;
|
||||||
|
lastName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
firstName = this.capitalize(firstName);
|
||||||
|
lastName = this.capitalize(lastName);
|
||||||
|
|
||||||
await mixpanel.people.set(user.username, {
|
await mixpanel.people.set(user.username, {
|
||||||
$name: user.username,
|
$first_name: firstName,
|
||||||
$email: user.username,
|
$last_name: lastName,
|
||||||
|
$name: this.getFullName(firstName, lastName),
|
||||||
|
$email: user.username.includes('@')
|
||||||
|
? user.username
|
||||||
|
: user.username + '@dadosfera.ai',
|
||||||
customer_name: user.customer_name,
|
customer_name: user.customer_name,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -30,4 +76,16 @@ export class MixpanelController {
|
|||||||
|
|
||||||
return { id, body, user: user.username };
|
return { id, body, user: user.username };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
capitalize(sentence: string): string {
|
||||||
|
if (!sentence) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return sentence[0].toUpperCase() + sentence.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
getFullName(firstName: string, lastName: string) {
|
||||||
|
return `${firstName}${lastName ? ' ' + lastName : ''}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,13 +67,32 @@ export interface IGetPipelineLogsRequest {
|
|||||||
details: string;
|
details: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class IUploadCSVFile {
|
export class IInitUploadCSVFile {
|
||||||
@ApiProperty({ format: 'binary' })
|
@ApiProperty()
|
||||||
file: string;
|
file_name: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
parts: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ICompleteUploadCSVFile {
|
||||||
|
@ApiProperty()
|
||||||
|
upload_id: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
file_name: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
parts: { ETag: string; PartNumber: number }[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ICreatePipelineCSVFile {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
file_name: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
description: string;
|
description: string;
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,9 @@ import {
|
|||||||
HttpCode,
|
HttpCode,
|
||||||
HttpStatus,
|
HttpStatus,
|
||||||
Patch,
|
Patch,
|
||||||
UseInterceptors,
|
|
||||||
UploadedFile,
|
|
||||||
HttpException,
|
HttpException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import {
|
import {
|
||||||
ApiConsumes,
|
|
||||||
ApiCreatedResponse,
|
ApiCreatedResponse,
|
||||||
ApiNoContentResponse,
|
ApiNoContentResponse,
|
||||||
ApiTags,
|
ApiTags,
|
||||||
@@ -36,12 +33,13 @@ import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
|||||||
|
|
||||||
import { PipelinesService as OldPipelineService } from 'src/modules/pipelines/pipelines.service';
|
import { PipelinesService as OldPipelineService } from 'src/modules/pipelines/pipelines.service';
|
||||||
import {
|
import {
|
||||||
|
ICompleteUploadCSVFile,
|
||||||
|
ICreatePipelineCSVFile,
|
||||||
ICreatePipelineV2Req,
|
ICreatePipelineV2Req,
|
||||||
IPipelineV2,
|
IPipelineV2,
|
||||||
IUploadCSVFile,
|
IInitUploadCSVFile,
|
||||||
} from './interfaces';
|
} from './interfaces';
|
||||||
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
||||||
import { FileInterceptor } from '@nestjs/platform-express';
|
|
||||||
|
|
||||||
@UseFilters(new GrpcToHttpExceptionFilter())
|
@UseFilters(new GrpcToHttpExceptionFilter())
|
||||||
@ApiTags('PipelinesV2')
|
@ApiTags('PipelinesV2')
|
||||||
@@ -300,37 +298,27 @@ export class PipelinesController {
|
|||||||
this.logger.info('PipelinesController - delete: OK');
|
this.logger.info('PipelinesController - delete: OK');
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('/upload')
|
@Post('/init-upload')
|
||||||
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.CREATE)
|
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.CREATE)
|
||||||
@ApiConsumes('multipart/form-data')
|
async initUploadFile(
|
||||||
@UseInterceptors(
|
|
||||||
FileInterceptor('file', { limits: { fileSize: 50 * 1000 * 1000 + 1 } }),
|
|
||||||
)
|
|
||||||
async uploadFile(
|
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@UploadedFile() file,
|
@Body() body: IInitUploadCSVFile,
|
||||||
@Body() body: IUploadCSVFile,
|
|
||||||
) {
|
) {
|
||||||
this.logger.info('/upload - Upload Connector Route');
|
this.logger.info('/upload - Init Upload File Route');
|
||||||
const metadata = PackTheMetadata({ ...user });
|
const metadata = PackTheMetadata({ ...user });
|
||||||
|
|
||||||
const parts_of_file_name = file.originalname.split('.');
|
const { file_name, parts } = body;
|
||||||
const file_format = parts_of_file_name.pop();
|
|
||||||
const file_name = parts_of_file_name.join('.');
|
|
||||||
let name = `${new Date().getTime()}_${file_name}`;
|
|
||||||
body.name ? (name = `${new Date().getTime()}_${body.name}`) : name;
|
|
||||||
|
|
||||||
const source_prefix = `${user.customer_name}/${name}.${file_format}`;
|
const { urls, upload_id } =
|
||||||
|
await this.pipelinesClientService.initUploadFile(
|
||||||
|
{
|
||||||
|
name: file_name,
|
||||||
|
parts: String(parts),
|
||||||
|
},
|
||||||
|
metadata,
|
||||||
|
);
|
||||||
|
|
||||||
const response = await this.pipelinesClientService.uploadFile(
|
if (!urls) {
|
||||||
{
|
|
||||||
file,
|
|
||||||
name,
|
|
||||||
},
|
|
||||||
metadata,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!response.url) {
|
|
||||||
this.logger.info('pipeline/upload - Failed File pipeline');
|
this.logger.info('pipeline/upload - Failed File pipeline');
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
'Upload failed, try again in a few minutes, if the problem persists, contact support.',
|
'Upload failed, try again in a few minutes, if the problem persists, contact support.',
|
||||||
@@ -338,7 +326,37 @@ export class PipelinesController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { sep, header, encoding, description } = body;
|
return { urls: JSON.parse(urls), upload_id };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/complete-upload')
|
||||||
|
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.CREATE)
|
||||||
|
async completeUploadFile(
|
||||||
|
@User() user: RequestUser,
|
||||||
|
@Body() body: ICompleteUploadCSVFile,
|
||||||
|
) {
|
||||||
|
this.logger.info('/upload - Complete Upload File Route');
|
||||||
|
const metadata = PackTheMetadata({ ...user });
|
||||||
|
|
||||||
|
const { upload_id, parts, file_name } = body;
|
||||||
|
|
||||||
|
return await this.pipelinesClientService.completeUploadFile(
|
||||||
|
{ upload_id, parts, file_name },
|
||||||
|
metadata,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('/file')
|
||||||
|
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.CREATE)
|
||||||
|
async uploadedFile(
|
||||||
|
@User() user: RequestUser,
|
||||||
|
@Body() body: ICreatePipelineCSVFile,
|
||||||
|
) {
|
||||||
|
this.logger.info('/upload - Upload Connector Route');
|
||||||
|
const metadata = PackTheMetadata({ ...user });
|
||||||
|
|
||||||
|
const { name, sep, header, encoding, description, file_name } = body;
|
||||||
|
const source_prefix = `${user.customer_name}/${file_name}`;
|
||||||
|
|
||||||
const upload_pipeline = {
|
const upload_pipeline = {
|
||||||
connection_id: process.env.UPLOAD_FILE_AGENT_CONNECTION,
|
connection_id: process.env.UPLOAD_FILE_AGENT_CONNECTION,
|
||||||
@@ -346,7 +364,7 @@ export class PipelinesController {
|
|||||||
connector_plugin: 'aws_s3',
|
connector_plugin: 'aws_s3',
|
||||||
connector_version: '1.0.0',
|
connector_version: '1.0.0',
|
||||||
image_url: 'https://assets.dadosfera.ai/images/connectors/csv.svg',
|
image_url: 'https://assets.dadosfera.ai/images/connectors/csv.svg',
|
||||||
name: body.name || file_name,
|
name,
|
||||||
description,
|
description,
|
||||||
transformations_ids: [],
|
transformations_ids: [],
|
||||||
tags: [],
|
tags: [],
|
||||||
|
|||||||
@@ -261,13 +261,10 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
return { objects: JSON.parse(objects) };
|
return { objects: JSON.parse(objects) };
|
||||||
}
|
}
|
||||||
|
|
||||||
async uploadFile(uploadFile, metadata) {
|
async initUploadFile(uploadFile, metadata) {
|
||||||
const body: Messages.PipelineV2UploadFileRequest = {
|
const body: Messages.PipelineV2UploadFileRequest = {
|
||||||
file: {
|
|
||||||
buffer: uploadFile.file.buffer,
|
|
||||||
mimetypes: uploadFile.file.mimetype,
|
|
||||||
},
|
|
||||||
name: uploadFile.name,
|
name: uploadFile.name,
|
||||||
|
parts: uploadFile.parts,
|
||||||
};
|
};
|
||||||
|
|
||||||
return lastValueFrom(
|
return lastValueFrom(
|
||||||
@@ -293,4 +290,21 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async completeUploadFile(uploadFile, metadata) {
|
||||||
|
const body: Messages.PipelineV2CompleteUploadFileRequest = {
|
||||||
|
upload_id: uploadFile.upload_id,
|
||||||
|
parts: JSON.stringify(uploadFile.parts),
|
||||||
|
name: uploadFile.file_name,
|
||||||
|
};
|
||||||
|
|
||||||
|
return lastValueFrom(
|
||||||
|
this.pipelineWriteService.PipelineV2CompleteUploadFile(body, metadata),
|
||||||
|
).catch((err) => {
|
||||||
|
throw new HttpException(
|
||||||
|
err.details,
|
||||||
|
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ export class RoleDto {
|
|||||||
customer?: Customer;
|
customer?: Customer;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
usage: string;
|
usage: string;
|
||||||
|
@ApiPropertyOptional({ description: 'Whether this role can be untoggled' })
|
||||||
|
canUntoggle?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CustomerRole extends OmitType(RoleDto, ['customer']) {}
|
export class CustomerRole extends OmitType(RoleDto, ['customer']) {}
|
||||||
@@ -34,11 +36,17 @@ export enum TrueOrFalseEnum {
|
|||||||
true = 'true',
|
true = 'true',
|
||||||
false = 'false',
|
false = 'false',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum CanUntoggleLogicEnum {
|
||||||
|
data_assets_sharing = 'data_assets_sharing',
|
||||||
|
}
|
||||||
export class GetRolesByCustomerReq {
|
export class GetRolesByCustomerReq {
|
||||||
@ApiPropertyOptional()
|
@ApiPropertyOptional()
|
||||||
permissionId?: string[];
|
permissionId?: string[];
|
||||||
@ApiPropertyOptional({ enum: TrueOrFalseEnum })
|
@ApiPropertyOptional({ enum: TrueOrFalseEnum })
|
||||||
getUsers?: TrueOrFalseEnum;
|
getUsers?: TrueOrFalseEnum;
|
||||||
|
@ApiPropertyOptional({ enum: CanUntoggleLogicEnum })
|
||||||
|
canUntoggleLogic?: CanUntoggleLogicEnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GetRolesByCustomerRes {
|
export class GetRolesByCustomerRes {
|
||||||
|
|||||||
@@ -71,12 +71,12 @@ export class RolesController {
|
|||||||
@ApiOkResponse({ type: GetRolesByCustomerRes })
|
@ApiOkResponse({ type: GetRolesByCustomerRes })
|
||||||
async searchRoles(
|
async searchRoles(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Query() filters: GetRolesByCustomerReq,
|
@Query() params: GetRolesByCustomerReq,
|
||||||
@Headers('dadosfera-lang') language,
|
@Headers('dadosfera-lang') language,
|
||||||
) {
|
) {
|
||||||
this.logger.info('searchRoles', { user });
|
this.logger.info('searchRoles', { user });
|
||||||
this.rolesService.setLanguage(language);
|
this.rolesService.setLanguage(language);
|
||||||
return await this.rolesService.roleSearch(filters, user);
|
return await this.rolesService.roleSearch(params, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
|
|||||||
@@ -70,12 +70,7 @@ export class RolesService {
|
|||||||
return { role: roleTreated };
|
return { role: roleTreated };
|
||||||
}
|
}
|
||||||
|
|
||||||
async roleSearch(
|
async roleSearch(filters: GetRolesByCustomerReq, { customer_id }) {
|
||||||
filters: GetRolesByCustomerReq,
|
|
||||||
{ customer_id, access_token }: any,
|
|
||||||
) {
|
|
||||||
const meta = new Metadata();
|
|
||||||
meta.add('access_token', access_token);
|
|
||||||
let { permissionId: permissionIds } = filters;
|
let { permissionId: permissionIds } = filters;
|
||||||
if (permissionIds && !Array.isArray(permissionIds))
|
if (permissionIds && !Array.isArray(permissionIds))
|
||||||
permissionIds = [permissionIds];
|
permissionIds = [permissionIds];
|
||||||
@@ -89,15 +84,13 @@ export class RolesService {
|
|||||||
return seqId;
|
return seqId;
|
||||||
}) || [];
|
}) || [];
|
||||||
const roles = await lastValueFrom(
|
const roles = await lastValueFrom(
|
||||||
this.rolesClientService.RoleSearch(
|
this.rolesClientService.RoleSearch({
|
||||||
{
|
customerId: customer_id,
|
||||||
customerId: customer_id,
|
getUsers: isGetUsers,
|
||||||
getUsers: isGetUsers,
|
permissionIds: [],
|
||||||
permissionIds: [],
|
permissionSeqIds,
|
||||||
permissionSeqIds,
|
canUntoggleLogic: filters.canUntoggleLogic,
|
||||||
},
|
}),
|
||||||
meta,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
const rolesTreated = this.getRolesPermissionsName(roles.roles);
|
const rolesTreated = this.getRolesPermissionsName(roles.roles);
|
||||||
return { roles: rolesTreated };
|
return { roles: rolesTreated };
|
||||||
|
|||||||
Reference in New Issue
Block a user