mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-21 19:39:08 +00:00
Compare commits
32
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09dced9fcd | ||
|
|
165b533172 | ||
|
|
b1dc567394 | ||
|
|
a0a1303515 | ||
|
|
c21d977f7c | ||
|
|
399d3492d3 | ||
|
|
b0b557246e | ||
|
|
f6ababbe7a | ||
|
|
c490814a98 | ||
|
|
3ba2c91893 | ||
|
|
e789076ed4 | ||
|
|
3b6ddaaee6 | ||
|
|
8073194604 | ||
|
|
cd2c53b5c5 | ||
|
|
d84b5e184b | ||
|
|
b8be2c7803 | ||
|
|
24fce721e3 | ||
|
|
23a9a27db1 | ||
|
|
0f5ed50af9 | ||
|
|
5f8f6a64ab | ||
|
|
8800ac2736 | ||
|
|
bdb82c2ce4 | ||
|
|
6d9ecc3568 | ||
|
|
fff3523152 | ||
|
|
8624d3f016 | ||
|
|
4f4da5bebe | ||
|
|
f00d2bf41d | ||
|
|
dc1d1400d8 | ||
|
|
d4451153a3 | ||
|
|
06ba759ea3 | ||
|
|
dd0d08ad6e | ||
|
|
ec81082877 |
@@ -3,6 +3,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Maestro
|
# Maestro
|
||||||
|
|
||||||
Maestro é a API principal da Dadosfera. É responsável pela comunicação do Frontend com nossos microsserviços.
|
Maestro é a API principal da Dadosfera. É responsável pela comunicação do Frontend com nossos microsserviços.
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ spec:
|
|||||||
value: {{ .Values.maestro.redis_host }}
|
value: {{ .Values.maestro.redis_host }}
|
||||||
- name: REDIS_PORT
|
- name: REDIS_PORT
|
||||||
value: "{{ .Values.maestro.redis_port }}"
|
value: "{{ .Values.maestro.redis_port }}"
|
||||||
|
- name: REDIS_TLS
|
||||||
|
value: "{{ .Values.maestro.redis_tls }}"
|
||||||
- name: JWT_PRIVATE_KEY
|
- name: JWT_PRIVATE_KEY
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ maestro:
|
|||||||
redis_host: "aaapzppmlyamkocqwstpo7zvopczyyiyuy6xzm2g6c5k4mq3a66be4a-0.redis.sa-saopaulo-1.oci.oraclecloud.com"
|
redis_host: "aaapzppmlyamkocqwstpo7zvopczyyiyuy6xzm2g6c5k4mq3a66be4a-0.redis.sa-saopaulo-1.oci.oraclecloud.com"
|
||||||
redis_port: "6379"
|
redis_port: "6379"
|
||||||
redis_database: "0"
|
redis_database: "0"
|
||||||
|
redis_tls: "true"
|
||||||
cookie_secret: "13cc5e136d3074bcc05bec8697092ec1f5f376bf"
|
cookie_secret: "13cc5e136d3074bcc05bec8697092ec1f5f376bf"
|
||||||
autoscaling:
|
autoscaling:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|||||||
@@ -4471,6 +4471,14 @@
|
|||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "asset_type",
|
||||||
|
"required": true,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
@@ -6269,6 +6277,39 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/customers/{id}/theme/reset": {
|
||||||
|
"post": {
|
||||||
|
"operationId": "ThemeController_resetTheme",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"required": true,
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/CustomerThemeResponse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"201": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"Theme"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/network-policy": {
|
"/network-policy": {
|
||||||
"get": {
|
"get": {
|
||||||
"operationId": "NetworkPolicyController_getNetworks",
|
"operationId": "NetworkPolicyController_getNetworks",
|
||||||
|
|||||||
Vendored
+1
@@ -16,6 +16,7 @@ declare global {
|
|||||||
OPEN_CUSTOMER_ID: string;
|
OPEN_CUSTOMER_ID: string;
|
||||||
DEDICATED_PROXY: string;
|
DEDICATED_PROXY: string;
|
||||||
COOKIE_SECRET: string;
|
COOKIE_SECRET: string;
|
||||||
|
REDIS_TLS?: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+5
-6
@@ -12,7 +12,7 @@
|
|||||||
"@aws-sdk/client-secrets-manager": "^3.414.0",
|
"@aws-sdk/client-secrets-manager": "^3.414.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.38.0-beta.10",
|
"@dadosfera/protospack-v2": "3.38.0-beta.16",
|
||||||
"@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",
|
||||||
@@ -57,8 +57,8 @@
|
|||||||
"swagger-ui-express": "^4.6.3"
|
"swagger-ui-express": "^4.6.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/cookie-parser": "^1.4.9",
|
|
||||||
"@types/cache-manager": "^4.0.6",
|
"@types/cache-manager": "^4.0.6",
|
||||||
|
"@types/cookie-parser": "^1.4.9",
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
"@types/express-session": "^1.18.1",
|
"@types/express-session": "^1.18.1",
|
||||||
"@types/jest": "27.0.2",
|
"@types/jest": "27.0.2",
|
||||||
@@ -1408,10 +1408,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@dadosfera/protospack-v2": {
|
"node_modules/@dadosfera/protospack-v2": {
|
||||||
"version": "3.38.0-beta.10",
|
"version": "3.38.0-beta.16",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.38.0-beta.10.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.38.0-beta.16.tgz",
|
||||||
"integrity": "sha512-4miwovVFHtBY1VTHdW8BVmSB8m+LXfIA8uigHbeo8IwreMtTHuLpvfenT4MBSPkdVmlo9+0XBKKf+PaSqtdMAg==",
|
"integrity": "sha512-ijURcmETXdgVgXhIPxapK7w0z6begXm4WDZ6EJtUGg+oYlJd9QOxbwaD7akRzW8XTdccmIo0Vov065KB812J0A==",
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.9.3",
|
"@grpc/grpc-js": "^1.9.3",
|
||||||
"rxjs": "^7.5.5"
|
"rxjs": "^7.5.5"
|
||||||
|
|||||||
+2
-2
@@ -30,7 +30,7 @@
|
|||||||
"@aws-sdk/client-secrets-manager": "^3.414.0",
|
"@aws-sdk/client-secrets-manager": "^3.414.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.38.0-beta.10",
|
"@dadosfera/protospack-v2": "3.38.0-beta.16",
|
||||||
"@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",
|
||||||
@@ -78,8 +78,8 @@
|
|||||||
"multer": "1.4.5-lts.1"
|
"multer": "1.4.5-lts.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/cookie-parser": "^1.4.9",
|
|
||||||
"@types/cache-manager": "^4.0.6",
|
"@types/cache-manager": "^4.0.6",
|
||||||
|
"@types/cookie-parser": "^1.4.9",
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
"@types/express-session": "^1.18.1",
|
"@types/express-session": "^1.18.1",
|
||||||
"@types/jest": "27.0.2",
|
"@types/jest": "27.0.2",
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import jwt, { JwtPayload } from 'jsonwebtoken';
|
||||||
|
|
||||||
|
export function extractUserFrom(aRawJwt: string) {
|
||||||
|
const decodedToken = jwt.decode(aRawJwt, {
|
||||||
|
complete: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const payload = decodedToken.payload as JwtPayload;
|
||||||
|
|
||||||
|
return {
|
||||||
|
user_id: payload.user_id,
|
||||||
|
username: payload.username,
|
||||||
|
permissions: payload.permissions,
|
||||||
|
customer_id: payload.customer_id,
|
||||||
|
customer_name: payload.customer_name,
|
||||||
|
customer_tier: payload.customer_tier,
|
||||||
|
customer_modules: payload.customer_modules,
|
||||||
|
access_token: aRawJwt,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -390,6 +390,25 @@ export const PERMISSIONS_GROUPS = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
LINEAGE: {
|
||||||
|
title: {
|
||||||
|
'pt-br': 'Explorar | Linhagem',
|
||||||
|
'en-us': 'Explore | Lineage',
|
||||||
|
'es-es': 'Explorar | Linaje',
|
||||||
|
},
|
||||||
|
permissions: {
|
||||||
|
VIEW: {
|
||||||
|
seqid: 50,
|
||||||
|
claim: 'lineage:view',
|
||||||
|
usage: PermissionUsages.PUBLIC,
|
||||||
|
name: {
|
||||||
|
'pt-br': 'Acessar ao módulo de Linhagem',
|
||||||
|
'en-us': 'Access to Lineage module',
|
||||||
|
'es-es': 'Acceda al módulo de Linaje',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
EMBED: {
|
EMBED: {
|
||||||
title: {
|
title: {
|
||||||
'pt-br': 'Analisar | Incorporação',
|
'pt-br': 'Analisar | Incorporação',
|
||||||
|
|||||||
+19
-8
@@ -18,25 +18,36 @@ async function bootstrap() {
|
|||||||
});
|
});
|
||||||
const logger = new DadosferaLogger();
|
const logger = new DadosferaLogger();
|
||||||
|
|
||||||
|
const corsOrigins = [];
|
||||||
|
|
||||||
|
if (process.env.ENV === 'local') {
|
||||||
|
corsOrigins.push('http://localhost:4200');
|
||||||
|
} else {
|
||||||
|
corsOrigins.push(
|
||||||
|
'https://app.stg.dadosfera.ai',
|
||||||
|
'https://app.dadosfera.ai',
|
||||||
|
'https://private-frontend.stg.dadosfera.ai',
|
||||||
|
'https://unimed.dadosfera.ai',
|
||||||
|
'https://boston-scientific.dadosfera.ai',
|
||||||
|
'https://plataforma.dadosfera.ai'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const app = await NestFactory.create(AppModule, {
|
const app = await NestFactory.create(AppModule, {
|
||||||
logger,
|
logger,
|
||||||
cors: {
|
cors: {
|
||||||
origin: [
|
origin: corsOrigins,
|
||||||
'https://app.stg.dadosfera.ai',
|
|
||||||
'https://app.dadosfera.ai',
|
|
||||||
'https://unimed.dadosfera.ai',
|
|
||||||
'https://boston-scientific.dadosfera.ai',
|
|
||||||
'https://plataforma.dadosfera.ai'
|
|
||||||
],
|
|
||||||
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
||||||
preflightContinue: false,
|
preflightContinue: false,
|
||||||
optionsSuccessStatus: 204,
|
optionsSuccessStatus: 204,
|
||||||
credentials: true,
|
credentials: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use(helmet());
|
app.use(helmet());
|
||||||
app.use(cookieParser(process.env.COOKIE_SECRET));
|
app.use(cookieParser(process.env.COOKIE_SECRET));
|
||||||
if (process.env.ENV === 'prd') {
|
|
||||||
|
if (process.env.ENV !== 'local') {
|
||||||
app.use('/catalog/register-dataset', json({ limit: '10mb' }));
|
app.use('/catalog/register-dataset', json({ limit: '10mb' }));
|
||||||
app.use(
|
app.use(
|
||||||
'/catalog/register-dataset',
|
'/catalog/register-dataset',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Controller, Post, Body, Put, Get} from '@nestjs/common';
|
import { Controller, Body, Put, Get, NotFoundException} from '@nestjs/common';
|
||||||
import { AssignService } from './assign.service';
|
import { AssignService } from './assign.service';
|
||||||
import { CreateAssignDto } from './dto/create-assign.dto';
|
import { CreateAssignDto } from './dto/create-assign.dto';
|
||||||
import { Authenticated, RequireModule, RequireSomePermission } from 'src/decorators/authentication.decorator';
|
import { Authenticated, RequireModule, RequireSomePermission } from 'src/decorators/authentication.decorator';
|
||||||
@@ -28,6 +28,10 @@ export class AssignController {
|
|||||||
@RequireModule(DADOSFERA_MODULES_KEYS.EMBED_ASSIGNED)
|
@RequireModule(DADOSFERA_MODULES_KEYS.EMBED_ASSIGNED)
|
||||||
async get(@User() user: RequestUser) {
|
async get(@User() user: RequestUser) {
|
||||||
const metadata = PackTheMetadata(user);
|
const metadata = PackTheMetadata(user);
|
||||||
return await this.assignService.get(metadata);
|
try {
|
||||||
|
return await this.assignService.get(metadata);
|
||||||
|
} catch (error) {
|
||||||
|
throw new NotFoundException(error.message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -423,6 +423,7 @@ export class CatalogController {
|
|||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Language() language: LanguageEnum,
|
@Language() language: LanguageEnum,
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
|
@Query('asset_type') asset_type: string,
|
||||||
): Promise<IDocsResponse> {
|
): Promise<IDocsResponse> {
|
||||||
const { customer_name, customer_id, user_id, username } = user;
|
const { customer_name, customer_id, user_id, username } = user;
|
||||||
|
|
||||||
@@ -439,7 +440,7 @@ export class CatalogController {
|
|||||||
language,
|
language,
|
||||||
});
|
});
|
||||||
|
|
||||||
const docs = await this.catalogService.getDataDocs(id, metadata);
|
const docs = await this.catalogService.getDataDocs(id, asset_type, metadata);
|
||||||
|
|
||||||
return { docs };
|
return { docs };
|
||||||
}
|
}
|
||||||
@@ -487,21 +488,32 @@ export class CatalogController {
|
|||||||
@Headers() headers,
|
@Headers() headers,
|
||||||
@Param('id') table_id: string,
|
@Param('id') table_id: string,
|
||||||
@Body('docs') docs: string,
|
@Body('docs') docs: string,
|
||||||
|
@Query('asset_type') asset_type: string,
|
||||||
) {
|
) {
|
||||||
const { user_id, customer_name } = user;
|
const { user_id, customer_name, customer_id, username } = user;
|
||||||
|
|
||||||
this.logger.info(`/catalog - ON GET DATA DOCS ROUTE`, {
|
const metadata = PackTheMetadata({
|
||||||
|
customer_id,
|
||||||
|
customer_name,
|
||||||
|
user_id,
|
||||||
|
username,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.logger.info(`/catalog - ON POST DATA DOCS ROUTE`, {
|
||||||
user_id,
|
user_id,
|
||||||
customer_name,
|
customer_name,
|
||||||
});
|
});
|
||||||
|
|
||||||
const res = await this.catalogService.createDataDocs({
|
const body = {
|
||||||
table_id,
|
table_id,
|
||||||
docs,
|
docs,
|
||||||
|
asset_type,
|
||||||
info: {
|
info: {
|
||||||
customer: customer_name,
|
customer: customer_name,
|
||||||
},
|
},
|
||||||
});
|
}
|
||||||
|
|
||||||
|
const res = await this.catalogService.createDataDocs(body, metadata);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,11 @@ import { CatalogClientConfiguration } from './catalog-client';
|
|||||||
import { UsersService } from '../users/users.service';
|
import { UsersService } from '../users/users.service';
|
||||||
import { RolesService } from '../roles/roles.service';
|
import { RolesService } from '../roles/roles.service';
|
||||||
import { Metadata } from '@grpc/grpc-js';
|
import { Metadata } from '@grpc/grpc-js';
|
||||||
|
import { PackTheMetadata } from 'src/utils/PackTheMetadata';
|
||||||
import {
|
import {
|
||||||
AssetReporter,
|
AssetReporter,
|
||||||
BatchRemoveRlsRulesRequest,
|
BatchRemoveRlsRulesRequest,
|
||||||
|
CreateDataDocsDTO,
|
||||||
IUpdateDataRequest,
|
IUpdateDataRequest,
|
||||||
TriggerCatalogReq,
|
TriggerCatalogReq,
|
||||||
} from './dtos';
|
} from './dtos';
|
||||||
@@ -197,9 +199,11 @@ class CatalogService implements OnModuleInit {
|
|||||||
async getUserRolesIds(userId: string) {
|
async getUserRolesIds(userId: string) {
|
||||||
const result = await this.userService.findOneById(userId).catch(() => null);
|
const result = await this.userService.findOneById(userId).catch(() => null);
|
||||||
|
|
||||||
const roles_ids = result.user.roles.map((role) => role.id);
|
if (result) {
|
||||||
|
return result.user.roles.map((role) => role.id);
|
||||||
|
}
|
||||||
|
|
||||||
return roles_ids;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
async searchDataAssets(
|
async searchDataAssets(
|
||||||
@@ -335,9 +339,9 @@ class CatalogService implements OnModuleInit {
|
|||||||
return { data_asset: asset[0] };
|
return { data_asset: asset[0] };
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDataDocs(id: string, metadata: Metadata) {
|
async getDataDocs(id: string, assetType: string, metadata: Metadata) {
|
||||||
const { documentation } = await lastValueFrom(
|
const { documentation } = await lastValueFrom(
|
||||||
this.catalogReadService.GetDatasetDoc({ id, type: undefined }, metadata),
|
this.catalogReadService.GetDatasetDoc({ id }, metadata),
|
||||||
);
|
);
|
||||||
|
|
||||||
const docs = JSON.parse(documentation);
|
const docs = JSON.parse(documentation);
|
||||||
@@ -366,7 +370,16 @@ class CatalogService implements OnModuleInit {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
async createDataDocs(body) {
|
async createDataDocs(body: CreateDataDocsDTO, metadata: Metadata) {
|
||||||
|
if (body.asset_type === 'table' || body.asset_type === 'view') {
|
||||||
|
return this.createDataDocsViaNimbus(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.createDataDocsViaGrpc(body, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async createDataDocsViaNimbus(body: CreateDataDocsDTO) {
|
||||||
|
this.logger.info('Creating data docs via Nimbus for table/view');
|
||||||
const nimbusUrl = this._getNimbusUrl(body);
|
const nimbusUrl = this._getNimbusUrl(body);
|
||||||
const { data } = await axios.post(
|
const { data } = await axios.post(
|
||||||
`${nimbusUrl}/api/catalog/data-docs/`,
|
`${nimbusUrl}/api/catalog/data-docs/`,
|
||||||
@@ -375,6 +388,30 @@ class CatalogService implements OnModuleInit {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async createDataDocsViaGrpc(body: CreateDataDocsDTO, metadata: Metadata) {
|
||||||
|
this.logger.info('Creating data docs via gRPC for other asset types');
|
||||||
|
try {
|
||||||
|
const response: any = await lastValueFrom(
|
||||||
|
this.catalogWriteService.UpdateDataAssetDoc(
|
||||||
|
{
|
||||||
|
id: body.table_id,
|
||||||
|
docs: body.docs,
|
||||||
|
},
|
||||||
|
metadata,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('Error creating data asset docs:', error);
|
||||||
|
throw new HttpException(
|
||||||
|
'Failed to create data asset documentation',
|
||||||
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async findAllTags(data, metadata) {
|
async findAllTags(data, metadata) {
|
||||||
this.logger.info('CatalogService - findAllCustomerTags');
|
this.logger.info('CatalogService - findAllCustomerTags');
|
||||||
|
|
||||||
|
|||||||
@@ -328,3 +328,10 @@ export type AssetReporter = {
|
|||||||
created_at: string;
|
created_at: string;
|
||||||
tags: string;
|
tags: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type CreateDataDocsDTO = {
|
||||||
|
table_id: string;
|
||||||
|
docs: string;
|
||||||
|
asset_type: string;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -160,7 +160,7 @@ export class ShareService implements OnModuleInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { documentation } = await lastValueFrom(
|
const { documentation } = await lastValueFrom(
|
||||||
this.catalogReadService.GetDatasetDoc({ id, type: undefined }, metadata),
|
this.catalogReadService.GetDatasetDoc({ id }, metadata),
|
||||||
);
|
);
|
||||||
console.log(documentation);
|
console.log(documentation);
|
||||||
const docs = JSON.parse(documentation);
|
const docs = JSON.parse(documentation);
|
||||||
|
|||||||
@@ -1,29 +1,46 @@
|
|||||||
import { Body, Controller, Inject, Param, Post, Req } from '@nestjs/common';
|
import { Body, Controller, Inject, Param, Post, Req } from '@nestjs/common';
|
||||||
import { init } from 'mixpanel';
|
|
||||||
import { Authenticated } from 'src/decorators/authentication.decorator';
|
|
||||||
import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
|
import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
|
||||||
import { RequestUser, User } from 'src/decorators/user.decorator';
|
import { RequestUser } from 'src/decorators/user.decorator';
|
||||||
import { MixpanelService } from './mixpanel.service';
|
import { MixpanelService } from './mixpanel.service';
|
||||||
|
import { extractUserFrom } from 'src/authentication/extract-user';
|
||||||
|
import DadosferaLogger from '@dadosfera/dadosfera-logs';
|
||||||
|
|
||||||
@ApiInternalOnlyController()
|
@ApiInternalOnlyController()
|
||||||
@Controller('trackEvent')
|
@Controller('trackEvent')
|
||||||
export class MixpanelController {
|
export class MixpanelController {
|
||||||
|
logger: DadosferaLogger;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private mixpanelService: MixpanelService
|
@Inject(DadosferaLogger)
|
||||||
) {}
|
dadosferaLogger: DadosferaLogger,
|
||||||
|
private mixpanelService: MixpanelService,
|
||||||
|
) {
|
||||||
|
this.logger = dadosferaLogger.logger;
|
||||||
|
}
|
||||||
|
|
||||||
@Post(':id')
|
@Post(':id')
|
||||||
async trackEvent(
|
async trackEvent(
|
||||||
@Param('id') id,
|
@Param('id') id,
|
||||||
@Body() body,
|
@Body() body,
|
||||||
@User() user: RequestUser,
|
|
||||||
@Req() request
|
@Req() request
|
||||||
) {
|
) {
|
||||||
|
this.logger.info(`POST Track Event: ${id}`)
|
||||||
delete body.info;
|
delete body.info;
|
||||||
|
|
||||||
|
const anonymousUser = {
|
||||||
|
username: "anonymous",
|
||||||
|
customer_name: "anonymous"
|
||||||
|
} as RequestUser
|
||||||
|
|
||||||
|
const hasToken = request.headers['authorization'];
|
||||||
|
|
||||||
|
const user = hasToken ? extractUserFrom(hasToken) : anonymousUser;
|
||||||
|
|
||||||
|
this.logger.info(`Has user: ${typeof hasToken == "string"}`)
|
||||||
|
|
||||||
await this.mixpanelService.track(id, user, request, body)
|
await this.mixpanelService.track(id, user, request, body)
|
||||||
|
|
||||||
|
this.logger.info(`Event successful`)
|
||||||
return { id, body, user: user.username };
|
return { id, body, user: user.username };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,4 +124,24 @@ export class ThemeController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post('/:id/theme/reset')
|
||||||
|
@ApiOkResponse({ type: CustomerThemeResponse })
|
||||||
|
async resetTheme(@Param('id') id: string) {
|
||||||
|
this.logger.info('getCustomerTheme with id' + id);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.themeService.resetTheme(id);
|
||||||
|
|
||||||
|
return { theme: null };
|
||||||
|
}catch (err) {
|
||||||
|
if (err.details === ErrorCodes.CUSTOMER.NOT_FOUND) {
|
||||||
|
this.logger.error('Error - getCustomerTheme - Expect CUSTOMER.NOT_FOUND');
|
||||||
|
throw new HttpException(err.details, HttpStatus.NOT_FOUND);
|
||||||
|
} else {
|
||||||
|
this.logger.error('Error - getCustomerTheme Unknown Error:' + err?.message);
|
||||||
|
return { theme: null };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,18 @@ export class ThemeService implements OnModuleInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async resetTheme(id: string) {
|
||||||
|
const { theme } = await firstValueFrom(
|
||||||
|
this.themeService.ResetCustomerTheme({
|
||||||
|
id
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
theme
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async createThemeByCustomer(id: string, theme: CustomerThemeRequest & Files) {
|
async createThemeByCustomer(id: string, theme: CustomerThemeRequest & Files) {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
this.logger.error('Error - saveCustomertheme - not found id:' + id);
|
this.logger.error('Error - saveCustomertheme - not found id:' + id);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { redisStore } from 'cache-manager-ioredis-yet';
|
|||||||
keyPrefix: 'maestro:sso',
|
keyPrefix: 'maestro:sso',
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.ENV !== 'local') {
|
if (process.env.REDIS_TLS === 'true') {
|
||||||
baseRedisConfig['tls'] = {
|
baseRedisConfig['tls'] = {
|
||||||
servername: process.env.REDIS_HOST,
|
servername: process.env.REDIS_HOST,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user