mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-12 23:59:09 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65ab16236f | ||
|
|
b4cc8151d7 |
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
FROM node:20-alpine AS base_image
|
FROM node:20-alpine AS base_image
|
||||||
RUN npm install -g npm@10.8.2
|
RUN npm install -g npm@latest
|
||||||
|
|
||||||
FROM base_image AS build_base
|
FROM base_image AS build_base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
@@ -111,8 +111,6 @@ spec:
|
|||||||
value: "{{ .Values.maestro.redis_tls }}"
|
value: "{{ .Values.maestro.redis_tls }}"
|
||||||
- name: PLATFORM_API_URL
|
- name: PLATFORM_API_URL
|
||||||
value: {{ .Values.maestro.platform_api_url }}
|
value: {{ .Values.maestro.platform_api_url }}
|
||||||
- name: CONNECTIONS_API_URL
|
|
||||||
value: {{ .Values.maestro.connections_api_url | default "" | quote }}
|
|
||||||
- name: STORAGE_EXPLORER_API_URL
|
- name: STORAGE_EXPLORER_API_URL
|
||||||
value: {{ .Values.maestro.storage_explorer_api_url | quote }}
|
value: {{ .Values.maestro.storage_explorer_api_url | quote }}
|
||||||
- name: FIREBASE_BASE_URL
|
- name: FIREBASE_BASE_URL
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ maestro:
|
|||||||
cookie_secret: "ff7bc13823edb2ae50d248e5780bddc9d4b31c36"
|
cookie_secret: "ff7bc13823edb2ae50d248e5780bddc9d4b31c36"
|
||||||
redis_database: "1"
|
redis_database: "1"
|
||||||
platform_api_url: https://xs2hkhq07k.execute-api.us-east-1.amazonaws.com
|
platform_api_url: https://xs2hkhq07k.execute-api.us-east-1.amazonaws.com
|
||||||
connections_api_url: https://iy40eans64.execute-api.us-east-1.amazonaws.com
|
|
||||||
storage_explorer_api_url: "http://storage-explorer-{customer}.data-apps.svc.cluster.local:8000/api"
|
storage_explorer_api_url: "http://storage-explorer-{customer}.data-apps.svc.cluster.local:8000/api"
|
||||||
firebase_base_url: https://feature-flag-25bf6-default-rtdb.firebaseio.com/stg
|
firebase_base_url: https://feature-flag-25bf6-default-rtdb.firebaseio.com/stg
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ maestro:
|
|||||||
open_customer_id: f239718a-a271-4ef9-ae7e-02a2f0f3aa6e
|
open_customer_id: f239718a-a271-4ef9-ae7e-02a2f0f3aa6e
|
||||||
open_group_id: 401573bb-334f-44b2-b30e-88d4cea31ae9
|
open_group_id: 401573bb-334f-44b2-b30e-88d4cea31ae9
|
||||||
platform_api_url: https://oz8v2zid1e.execute-api.us-east-1.amazonaws.com
|
platform_api_url: https://oz8v2zid1e.execute-api.us-east-1.amazonaws.com
|
||||||
connections_api_url: https://wv6fw7ayj4.execute-api.us-east-1.amazonaws.com
|
|
||||||
storage_explorer_api_url: "https://storage-explorer-{customer}.dadosfera.ai/api"
|
storage_explorer_api_url: "https://storage-explorer-{customer}.dadosfera.ai/api"
|
||||||
dedicated_proxy: ""
|
dedicated_proxy: ""
|
||||||
restricted_ip: ""
|
restricted_ip: ""
|
||||||
|
|||||||
+90
-162
@@ -3343,7 +3343,14 @@
|
|||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": ""
|
"description": "",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -3640,46 +3647,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/pipelinesV2/{id}/upgrade": {
|
|
||||||
"patch": {
|
|
||||||
"operationId": "PipelinesController_upgradeConnector",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "dadosfera-lang",
|
|
||||||
"in": "header",
|
|
||||||
"required": false,
|
|
||||||
"schema": {
|
|
||||||
"enum": [
|
|
||||||
"pt-br",
|
|
||||||
"en-us"
|
|
||||||
],
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"required": true,
|
|
||||||
"in": "path",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"204": {
|
|
||||||
"description": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"PipelinesV2"
|
|
||||||
],
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/pipelinesV2/init-upload": {
|
"/pipelinesV2/init-upload": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "PipelinesController_initUploadFile",
|
"operationId": "PipelinesController_initUploadFile",
|
||||||
@@ -3867,6 +3834,88 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/pipelines/start/{id}": {
|
||||||
|
"post": {
|
||||||
|
"operationId": "PipelinesController_activate",
|
||||||
|
"summary": "",
|
||||||
|
"deprecated": true,
|
||||||
|
"description": "This method is deprecated. Please use route /pipelinesV2/start/:id instead",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"required": true,
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": "",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"Pipelines"
|
||||||
|
],
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"access-token": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"access-token": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/pipelines/{id}/status": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "PipelinesController_getPipelineStatus",
|
||||||
|
"summary": "",
|
||||||
|
"deprecated": true,
|
||||||
|
"description": "This method is deprecated. Please use route /pipelinesV2/:id/status instead",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"required": true,
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"Pipelines"
|
||||||
|
],
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"access-token": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"access-token": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/transformations": {
|
"/transformations": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "TransformationsController_create",
|
"operationId": "TransformationsController_create",
|
||||||
@@ -4570,50 +4619,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/platform/pipelines/{pipelineId}/pipeline_run/{runId}/jobs": {
|
|
||||||
"get": {
|
|
||||||
"operationId": "PlatformApiController_getPipelineRunJobs",
|
|
||||||
"summary": "Get pipeline run jobs",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "pipelineId",
|
|
||||||
"required": true,
|
|
||||||
"in": "path",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "runId",
|
|
||||||
"required": true,
|
|
||||||
"in": "path",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"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",
|
||||||
@@ -5940,66 +5945,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/catalog/data-asset/{id}/certification-status": {
|
|
||||||
"put": {
|
|
||||||
"operationId": "CatalogController_updateDataAssetCertificationStatus",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "dadosfera-lang",
|
|
||||||
"in": "header",
|
|
||||||
"required": false,
|
|
||||||
"schema": {
|
|
||||||
"enum": [
|
|
||||||
"pt-br",
|
|
||||||
"en-us"
|
|
||||||
],
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"required": true,
|
|
||||||
"in": "path",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"requestBody": {
|
|
||||||
"required": true,
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/IUpdateCertificationStatusRequest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/IUpdateCertificationStatusRequest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"Catalog"
|
|
||||||
],
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/catalog/data-asset/{id}/manage-permissions": {
|
"/catalog/data-asset/{id}/manage-permissions": {
|
||||||
"put": {
|
"put": {
|
||||||
"operationId": "CatalogController_manageDataAssetPermissions",
|
"operationId": "CatalogController_manageDataAssetPermissions",
|
||||||
@@ -11080,23 +11025,6 @@
|
|||||||
"data_asset"
|
"data_asset"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"IUpdateCertificationStatusRequest": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"certification_status": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"draft",
|
|
||||||
"in_review",
|
|
||||||
"approved",
|
|
||||||
"deprecated"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"certification_status"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ICreateDataAsset": {
|
"ICreateDataAsset": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
Generated
+15
-4
@@ -16,7 +16,8 @@
|
|||||||
"@aws-sdk/lib-dynamodb": "^3.414.0",
|
"@aws-sdk/lib-dynamodb": "^3.414.0",
|
||||||
"@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-v2": "^3.40.0-beta.10",
|
"@dadosfera/protospack": "2.5.3",
|
||||||
|
"@dadosfera/protospack-v2": "3.40.0-beta.8",
|
||||||
"@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",
|
||||||
@@ -1734,10 +1735,20 @@
|
|||||||
"winston-log2gelf": "^2.4.0"
|
"winston-log2gelf": "^2.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@dadosfera/protospack": {
|
||||||
|
"version": "2.5.3",
|
||||||
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com/npm/dadosfera-npm/@dadosfera/protospack/-/protospack-2.5.3.tgz",
|
||||||
|
"integrity": "sha512-yOLnd+s6n9VkPpZXO8HnUY27CQPHj/qs+ecddviA4Ldn0Gx4KGRgbVdsSSP45nPm0GHhCd2bHg4ap+la7xtRmA==",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"rxjs": "^7.5.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@dadosfera/protospack-v2": {
|
"node_modules/@dadosfera/protospack-v2": {
|
||||||
"version": "3.40.0-beta.10",
|
"version": "3.40.0-beta.8",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.40.0-beta.10.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.40.0-beta.8.tgz",
|
||||||
"integrity": "sha512-F45dSEIKG+gwwDMYHayA242bFwhFTJbZm26KesQbGhf4I45ur6hYZD8dK0voNuVQInLMQhtm6+7th6/jJ8xpTQ==",
|
"integrity": "sha512-JE5qMjqB3UOM+tCUxB1EwYLQW0PecsaQIa1KDpKEaG3lrzG/H13z8iJi3WH/DuVav2EI94i9VcJWJ1Y0F7ribw==",
|
||||||
|
"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
-1
@@ -34,7 +34,8 @@
|
|||||||
"@aws-sdk/lib-dynamodb": "^3.414.0",
|
"@aws-sdk/lib-dynamodb": "^3.414.0",
|
||||||
"@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-v2": "^3.40.0-beta.10",
|
"@dadosfera/protospack": "2.5.3",
|
||||||
|
"@dadosfera/protospack-v2": "3.40.0-beta.8",
|
||||||
"@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",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { ConnectionTestModule } from './modules/connection-test/connection-test.
|
|||||||
import { NetworkConfigModule } from './modules/network-config/network-config.module';
|
import { NetworkConfigModule } from './modules/network-config/network-config.module';
|
||||||
import { InputsModule } from './modules/inputs/inputs.module';
|
import { InputsModule } from './modules/inputs/inputs.module';
|
||||||
import { OauthModule } from './modules/oauth/oauth.module';
|
import { OauthModule } from './modules/oauth/oauth.module';
|
||||||
|
import { PipelinesModule } from './modules/pipelines/pipelines.module';
|
||||||
import { TransformationsModule } from './modules/transformations/transformations.module';
|
import { TransformationsModule } from './modules/transformations/transformations.module';
|
||||||
import { HealthModule } from './modules/health/health.module';
|
import { HealthModule } from './modules/health/health.module';
|
||||||
import { CatalogModule } from './modules/catalog/catalog.module';
|
import { CatalogModule } from './modules/catalog/catalog.module';
|
||||||
@@ -59,6 +60,7 @@ import { ReleaseNoteModule } from './modules/release_note/release_note.module';
|
|||||||
PermissionsModule,
|
PermissionsModule,
|
||||||
TermsOfUseModule,
|
TermsOfUseModule,
|
||||||
ConnectionTestModule,
|
ConnectionTestModule,
|
||||||
|
PipelinesModule,
|
||||||
TransformationsModule,
|
TransformationsModule,
|
||||||
UsersModule,
|
UsersModule,
|
||||||
RolesModule,
|
RolesModule,
|
||||||
|
|||||||
@@ -357,16 +357,6 @@ export const PERMISSIONS_GROUPS = {
|
|||||||
'es-es': 'Crear y editar atributos en el catálogo',
|
'es-es': 'Crear y editar atributos en el catálogo',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CERTIFY: {
|
|
||||||
seqid: 53,
|
|
||||||
claim: 'catalog:certify',
|
|
||||||
usage: PermissionUsages.PUBLIC,
|
|
||||||
name: {
|
|
||||||
'pt-br': 'Alterar o status de certificação dos Ativos',
|
|
||||||
'en-us': "Change Assets' certification status",
|
|
||||||
'es-es': 'Cambiar el estado de certificación de los Activos',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
DELETE: {
|
DELETE: {
|
||||||
seqid: 1,
|
seqid: 1,
|
||||||
claim: 'catalog:delete',
|
claim: 'catalog:delete',
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
HttpStatus,
|
HttpStatus,
|
||||||
Res,
|
Res,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ValidationPipe } from '../../pipes/object-validation.pipe';
|
|
||||||
import {
|
import {
|
||||||
ApiCreatedResponse,
|
ApiCreatedResponse,
|
||||||
ApiHeaders,
|
ApiHeaders,
|
||||||
@@ -47,7 +46,6 @@ import {
|
|||||||
IMakeAComment,
|
IMakeAComment,
|
||||||
IOneDataAsset,
|
IOneDataAsset,
|
||||||
IPreviewResponse,
|
IPreviewResponse,
|
||||||
IUpdateCertificationStatusRequest,
|
|
||||||
IUpdateDataRequest,
|
IUpdateDataRequest,
|
||||||
TriggerCatalogReq,
|
TriggerCatalogReq,
|
||||||
TriggerCatalogRes,
|
TriggerCatalogRes,
|
||||||
@@ -495,8 +493,6 @@ export class CatalogController {
|
|||||||
language,
|
language,
|
||||||
});
|
});
|
||||||
|
|
||||||
delete (body as any).certification_status;
|
|
||||||
|
|
||||||
const result = await this.catalogService.updateOneDataAsset({
|
const result = await this.catalogService.updateOneDataAsset({
|
||||||
body,
|
body,
|
||||||
data_asset_id,
|
data_asset_id,
|
||||||
@@ -510,33 +506,6 @@ export class CatalogController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put('data-asset/:id/certification-status')
|
|
||||||
@RequireSomePermission(
|
|
||||||
PERMISSIONS_GROUPS.CATALOG.permissions.CERTIFY,
|
|
||||||
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
|
||||||
)
|
|
||||||
async updateDataAssetCertificationStatus(
|
|
||||||
@User() user: RequestUser,
|
|
||||||
@Language() language: LanguageEnum,
|
|
||||||
@Param('id') data_asset_id: string,
|
|
||||||
@Body(new ValidationPipe()) body: IUpdateCertificationStatusRequest,
|
|
||||||
): Promise<IUpdateCertificationStatusRequest> {
|
|
||||||
const { customer_id, customer_name, user_id, username } = user;
|
|
||||||
const metadata = PackTheMetadata({
|
|
||||||
customer_id,
|
|
||||||
customer_name,
|
|
||||||
user_id,
|
|
||||||
username,
|
|
||||||
language,
|
|
||||||
});
|
|
||||||
|
|
||||||
return this.catalogService.updateCertificationStatus({
|
|
||||||
body,
|
|
||||||
data_asset_id,
|
|
||||||
metadata,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post('data-asset/:id/docs')
|
@Post('data-asset/:id/docs')
|
||||||
@RequireSomePermission(
|
@RequireSomePermission(
|
||||||
PERMISSIONS_GROUPS.CATALOG.permissions.UPDATE,
|
PERMISSIONS_GROUPS.CATALOG.permissions.UPDATE,
|
||||||
|
|||||||
@@ -5,17 +5,20 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
|||||||
import { CatalogController } from './catalog.controller';
|
import { CatalogController } from './catalog.controller';
|
||||||
import { CatalogClientConfiguration } from './catalog-client';
|
import { CatalogClientConfiguration } from './catalog-client';
|
||||||
import { ClientsModule } from '@nestjs/microservices';
|
import { ClientsModule } from '@nestjs/microservices';
|
||||||
|
import { PipelinesModule as OldPipelineModule } from 'src/modules/pipelines/pipelines.module';
|
||||||
import { UsersModule } from '../users/users.module';
|
import { UsersModule } from '../users/users.module';
|
||||||
import { RolesModule } from '../roles/roles.module';
|
import { RolesModule } from '../roles/roles.module';
|
||||||
import { CustomersModule } from '../customers/customers.module';
|
import { CustomersModule } from '../customers/customers.module';
|
||||||
import { ShareModule } from './share/share.module';
|
import { ShareModule } from './share/share.module';
|
||||||
import { CatalogService } from './catalog.service';
|
import { CatalogService } from './catalog.service';
|
||||||
|
import { MixpanelModule } from '../mixpanel/mixpanel.module';
|
||||||
|
|
||||||
const client = new CatalogClientConfiguration();
|
const client = new CatalogClientConfiguration();
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ClientsModule.register([client.providerOptions]),
|
ClientsModule.register([client.providerOptions]),
|
||||||
|
OldPipelineModule,
|
||||||
UsersModule,
|
UsersModule,
|
||||||
RolesModule,
|
RolesModule,
|
||||||
CustomersModule,
|
CustomersModule,
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import {
|
|||||||
AssetReporter,
|
AssetReporter,
|
||||||
BatchRemoveRlsRulesRequest,
|
BatchRemoveRlsRulesRequest,
|
||||||
CreateDataDocsDTO,
|
CreateDataDocsDTO,
|
||||||
IUpdateCertificationStatusRequest,
|
|
||||||
IUpdateDataRequest,
|
IUpdateDataRequest,
|
||||||
TriggerCatalogReq,
|
TriggerCatalogReq,
|
||||||
} from './dtos';
|
} from './dtos';
|
||||||
@@ -385,28 +384,6 @@ class CatalogService implements OnModuleInit {
|
|||||||
return { data_asset: asset[0] };
|
return { data_asset: asset[0] };
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateCertificationStatus(data: {
|
|
||||||
data_asset_id: string;
|
|
||||||
body: IUpdateCertificationStatusRequest;
|
|
||||||
metadata: Metadata;
|
|
||||||
}) {
|
|
||||||
const { body, data_asset_id, metadata } = data;
|
|
||||||
|
|
||||||
await lastValueFrom(
|
|
||||||
this.catalogWriteService.UpdateDataAsset(
|
|
||||||
{
|
|
||||||
id: data_asset_id,
|
|
||||||
changes: JSON.stringify({
|
|
||||||
certification_status: body.certification_status,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
metadata,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return { certification_status: body.certification_status };
|
|
||||||
}
|
|
||||||
|
|
||||||
async updateOneDataAsset(data: {
|
async updateOneDataAsset(data: {
|
||||||
data_asset_id: string;
|
data_asset_id: string;
|
||||||
customer_id: string;
|
customer_id: string;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { ApiProperty, ApiPropertyOptional, PickType } from '@nestjs/swagger';
|
import { ApiProperty, ApiPropertyOptional, PickType } from '@nestjs/swagger';
|
||||||
import { IsEnum } from 'class-validator';
|
|
||||||
import { CreateDataAssetRequest } from '@dadosfera/protospack-v2/dist/lib/Catalog/interfaces/messages';
|
import { CreateDataAssetRequest } from '@dadosfera/protospack-v2/dist/lib/Catalog/interfaces/messages';
|
||||||
|
|
||||||
export enum DataAssetShareType {
|
export enum DataAssetShareType {
|
||||||
@@ -7,12 +6,6 @@ export enum DataAssetShareType {
|
|||||||
public = 'public',
|
public = 'public',
|
||||||
private = 'private',
|
private = 'private',
|
||||||
}
|
}
|
||||||
export enum CertificationStatus {
|
|
||||||
draft = 'draft',
|
|
||||||
in_review = 'in_review',
|
|
||||||
approved = 'approved',
|
|
||||||
deprecated = 'deprecated',
|
|
||||||
}
|
|
||||||
export enum OrderEnum {
|
export enum OrderEnum {
|
||||||
asc = 'asc',
|
asc = 'asc',
|
||||||
desc = 'desc',
|
desc = 'desc',
|
||||||
@@ -212,13 +205,6 @@ export class IUpdateDataRequest {
|
|||||||
@ApiPropertyOptional()
|
@ApiPropertyOptional()
|
||||||
docs?: string;
|
docs?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class IUpdateCertificationStatusRequest {
|
|
||||||
@ApiProperty({ enum: CertificationStatus })
|
|
||||||
@IsEnum(CertificationStatus)
|
|
||||||
certification_status: CertificationStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ICreateDataAsset implements CreateDataAssetRequest {
|
export class ICreateDataAsset implements CreateDataAssetRequest {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
display_name: string;
|
display_name: string;
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import {
|
|||||||
} from '@nestjs/microservices';
|
} from '@nestjs/microservices';
|
||||||
import { ConnectionTest } from '@dadosfera/protospack-v2';
|
import { ConnectionTest } from '@dadosfera/protospack-v2';
|
||||||
|
|
||||||
const infactoryUrl = process.env.INFACTORY_URL ?? '';
|
|
||||||
const isLocalConnection =
|
const isLocalConnection =
|
||||||
infactoryUrl.startsWith('in-factory:') || infactoryUrl.includes('0.0.0.0');
|
process.env.INFACTORY_URL.startsWith('in-factory:') ||
|
||||||
|
process.env.INFACTORY_URL.includes('0.0.0.0');
|
||||||
|
|
||||||
export class ConnectionTestClientConfiguration {
|
export class ConnectionTestClientConfiguration {
|
||||||
private config: GrpcOptions = {
|
private config: GrpcOptions = {
|
||||||
|
|||||||
@@ -22,9 +22,6 @@ import {
|
|||||||
ConnectionTestListTablesRes,
|
ConnectionTestListTablesRes,
|
||||||
GetTableMetadataRes,
|
GetTableMetadataRes,
|
||||||
GetTableMetadataReq,
|
GetTableMetadataReq,
|
||||||
RefreshCatalogReq,
|
|
||||||
RefreshCatalogRes,
|
|
||||||
RefreshCatalogStatusReq,
|
|
||||||
} from './dto/connection-test';
|
} from './dto/connection-test';
|
||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
import { Authenticated } from 'src/decorators/authentication.decorator';
|
import { Authenticated } from 'src/decorators/authentication.decorator';
|
||||||
@@ -87,7 +84,7 @@ export class ConnectionTestController {
|
|||||||
});
|
});
|
||||||
return this.connectionTestService.connectionTestListSchemas(
|
return this.connectionTestService.connectionTestListSchemas(
|
||||||
body,
|
body,
|
||||||
user,
|
user.customer_name,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +101,7 @@ export class ConnectionTestController {
|
|||||||
});
|
});
|
||||||
return this.connectionTestService.connectionTestListTables(
|
return this.connectionTestService.connectionTestListTables(
|
||||||
body,
|
body,
|
||||||
user,
|
user.customer_name,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,38 +118,7 @@ export class ConnectionTestController {
|
|||||||
});
|
});
|
||||||
return this.connectionTestService.getTableMetadata(
|
return this.connectionTestService.getTableMetadata(
|
||||||
body,
|
body,
|
||||||
user,
|
user.customer_name,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('refresh-catalog')
|
|
||||||
@ApiOkResponse({ type: RefreshCatalogRes })
|
|
||||||
@HttpCode(HttpStatus.ACCEPTED)
|
|
||||||
async refreshCatalog(
|
|
||||||
@User() user: RequestUser,
|
|
||||||
@Body(new ValidationPipe()) body: RefreshCatalogReq,
|
|
||||||
) {
|
|
||||||
this.logger.info('/connection-test/refresh-catalog', {
|
|
||||||
user: user.user_id,
|
|
||||||
customer: user.customer_name,
|
|
||||||
connection: body.connection_id,
|
|
||||||
});
|
|
||||||
return this.connectionTestService.refreshCatalog(body, user);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post('refresh-catalog/status')
|
|
||||||
@ApiOkResponse({ type: RefreshCatalogRes })
|
|
||||||
@HttpCode(HttpStatus.OK)
|
|
||||||
async refreshCatalogStatus(
|
|
||||||
@User() user: RequestUser,
|
|
||||||
@Body(new ValidationPipe()) body: RefreshCatalogStatusReq,
|
|
||||||
) {
|
|
||||||
this.logger.info('/connection-test/refresh-catalog/status', {
|
|
||||||
user: user.user_id,
|
|
||||||
customer: user.customer_name,
|
|
||||||
connection: body.connection_id,
|
|
||||||
session: body.session_id,
|
|
||||||
});
|
|
||||||
return this.connectionTestService.refreshCatalogStatus(body, user);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,10 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
|||||||
import { ClientsModule } from '@nestjs/microservices';
|
import { ClientsModule } from '@nestjs/microservices';
|
||||||
import { ConnectionTestClientConfiguration } from './connection-test-client.config';
|
import { ConnectionTestClientConfiguration } from './connection-test-client.config';
|
||||||
import { ConnectionModule } from '../connection/connection.module';
|
import { ConnectionModule } from '../connection/connection.module';
|
||||||
import { ConnectionsApiModule } from '../connections-api/connections-api.module';
|
|
||||||
import { PlatformApiModule } from '../platform-api/platform-api.module';
|
|
||||||
const client = new ConnectionTestClientConfiguration();
|
const client = new ConnectionTestClientConfiguration();
|
||||||
@Module({
|
@Module({
|
||||||
controllers: [ConnectionTestController],
|
controllers: [ConnectionTestController],
|
||||||
providers: [ConnectionTestService, DadosferaLogger],
|
providers: [ConnectionTestService, DadosferaLogger],
|
||||||
imports: [
|
imports: [ClientsModule.register([client.providerOptions]), ConnectionModule],
|
||||||
ClientsModule.register([client.providerOptions]),
|
|
||||||
ConnectionModule,
|
|
||||||
ConnectionsApiModule,
|
|
||||||
PlatformApiModule,
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
export class ConnectionTestModule {}
|
export class ConnectionTestModule {}
|
||||||
|
|||||||
@@ -1,205 +0,0 @@
|
|||||||
import { ConnectionTestService } from './connection-test.service';
|
|
||||||
import { RequestUser } from 'src/decorators/user.decorator';
|
|
||||||
|
|
||||||
describe('ConnectionTestService catalog cache', () => {
|
|
||||||
const user: RequestUser = {
|
|
||||||
user_id: 'user-id',
|
|
||||||
username: 'user@example.com',
|
|
||||||
permissions: [],
|
|
||||||
customer_id: 'customer-id',
|
|
||||||
customer_name: 'customer-name',
|
|
||||||
customer_tier: 'standard',
|
|
||||||
access_token: 'token',
|
|
||||||
customer_modules: [],
|
|
||||||
roles: [],
|
|
||||||
};
|
|
||||||
const grpcClient = { getService: jest.fn().mockReturnValue({}) };
|
|
||||||
const connectionsService = {};
|
|
||||||
const connectionsApiService = { proxy: jest.fn() };
|
|
||||||
const platformApiService = { proxy: jest.fn() };
|
|
||||||
let service: ConnectionTestService;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
jest.clearAllMocks();
|
|
||||||
service = new ConnectionTestService(
|
|
||||||
grpcClient as any,
|
|
||||||
connectionsService as any,
|
|
||||||
connectionsApiService as any,
|
|
||||||
platformApiService as any,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('keeps the existing schemas response contract', async () => {
|
|
||||||
connectionsApiService.proxy.mockResolvedValue({
|
|
||||||
schemas: [{ schema_name: 'analytics' }, { schema_name: 'public' }],
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
service.connectionTestListSchemas(
|
|
||||||
{ connection_id: 'config-id', plugin: 'postgresql' },
|
|
||||||
user,
|
|
||||||
),
|
|
||||||
).resolves.toEqual({
|
|
||||||
operation_result: true,
|
|
||||||
schema_list: ['analytics', 'public'],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('keeps the existing tables response contract', async () => {
|
|
||||||
connectionsApiService.proxy.mockResolvedValue({
|
|
||||||
tables: [{ table_name: 'customers' }, { table_name: 'orders' }],
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
service.connectionTestListTables(
|
|
||||||
{
|
|
||||||
connection_id: 'config-id',
|
|
||||||
plugin: 'postgresql',
|
|
||||||
schema: 'public',
|
|
||||||
},
|
|
||||||
user,
|
|
||||||
),
|
|
||||||
).resolves.toEqual({
|
|
||||||
operation_result: true,
|
|
||||||
table_list: ['customers', 'orders'],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('maps cached columns to the existing table metadata contract', async () => {
|
|
||||||
connectionsApiService.proxy.mockResolvedValue({
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
column_name: 'id',
|
|
||||||
data_type: 'bigint',
|
|
||||||
is_primary_key: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
service.getTableMetadata(
|
|
||||||
{
|
|
||||||
connection_id: 'config-id',
|
|
||||||
plugin: 'postgresql',
|
|
||||||
schema: 'public',
|
|
||||||
table_list: ['customers'],
|
|
||||||
},
|
|
||||||
user,
|
|
||||||
),
|
|
||||||
).resolves.toEqual({
|
|
||||||
operation_result: true,
|
|
||||||
tables_metadata: [
|
|
||||||
{
|
|
||||||
table_name: 'customers',
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
type: 'bigint',
|
|
||||||
is_primary_key: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
references: [],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
expect(connectionsApiService.proxy).toHaveBeenCalledWith(
|
|
||||||
'GET',
|
|
||||||
'/connection_catalog/config-id/schemas/public/tables/customers/columns',
|
|
||||||
user,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('submits a catalog refresh without holding the request open', async () => {
|
|
||||||
platformApiService.proxy.mockResolvedValue({
|
|
||||||
session_id: 'session-id',
|
|
||||||
date: '20260731',
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
service.refreshCatalog(
|
|
||||||
{ connection_id: 'config-id', plugin: 'postgresql' },
|
|
||||||
user,
|
|
||||||
),
|
|
||||||
).resolves.toEqual({
|
|
||||||
operation_result: true,
|
|
||||||
status: 'PENDING',
|
|
||||||
session_id: 'session-id',
|
|
||||||
date: '20260731',
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(platformApiService.proxy).toHaveBeenCalledWith(
|
|
||||||
'POST',
|
|
||||||
'/connection_test',
|
|
||||||
user,
|
|
||||||
{
|
|
||||||
customer_id: user.customer_name,
|
|
||||||
plugin: 'postgresql',
|
|
||||||
task: {
|
|
||||||
task_type: 'refresh_catalog',
|
|
||||||
connection: {
|
|
||||||
provider: 'connection_manager',
|
|
||||||
config_id: 'config-id',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('keeps polling without changing the catalog pointer while pending', async () => {
|
|
||||||
platformApiService.proxy.mockResolvedValue({ status: 'PENDING' });
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
service.refreshCatalogStatus(
|
|
||||||
{
|
|
||||||
connection_id: 'config-id',
|
|
||||||
plugin: 'postgresql',
|
|
||||||
session_id: 'session-id',
|
|
||||||
date: '20260731',
|
|
||||||
},
|
|
||||||
user,
|
|
||||||
),
|
|
||||||
).resolves.toEqual({
|
|
||||||
operation_result: false,
|
|
||||||
status: 'PENDING',
|
|
||||||
session_id: 'session-id',
|
|
||||||
date: '20260731',
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(connectionsApiService.proxy).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('publishes the catalog pointer after the refresh finishes', async () => {
|
|
||||||
platformApiService.proxy.mockResolvedValue({ status: 'DONE' });
|
|
||||||
connectionsApiService.proxy.mockResolvedValue({
|
|
||||||
last_catalog_refresh_status: 'SUCCESS',
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
service.refreshCatalogStatus(
|
|
||||||
{
|
|
||||||
connection_id: 'config/id',
|
|
||||||
plugin: 'postgresql',
|
|
||||||
session_id: 'session-id',
|
|
||||||
date: '20260731',
|
|
||||||
},
|
|
||||||
user,
|
|
||||||
),
|
|
||||||
).resolves.toEqual({
|
|
||||||
operation_result: true,
|
|
||||||
status: 'DONE',
|
|
||||||
session_id: 'session-id',
|
|
||||||
date: '20260731',
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(connectionsApiService.proxy).toHaveBeenCalledWith(
|
|
||||||
'PUT',
|
|
||||||
'/connection_config/config%2Fid/catalog_metadata',
|
|
||||||
user,
|
|
||||||
{
|
|
||||||
last_catalog_refresh_status: 'SUCCESS',
|
|
||||||
last_catalog_connection_test_date: '20260731',
|
|
||||||
last_catalog_connection_test_session_id: 'session-id',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { ClientGrpc } from '@nestjs/microservices';
|
import { ClientGrpc } from '@nestjs/microservices';
|
||||||
import { ConnectionTest } from '@dadosfera/protospack-v2';
|
import { ConnectionTest } from '@dadosfera/protospack-v2';
|
||||||
import { lastValueFrom } from 'rxjs';
|
import { lastValueFrom } from 'rxjs';
|
||||||
@@ -13,9 +13,6 @@ import {
|
|||||||
ConnectionTestPingRes,
|
ConnectionTestPingRes,
|
||||||
GetTableMetadataReq,
|
GetTableMetadataReq,
|
||||||
GetTableMetadataRes,
|
GetTableMetadataRes,
|
||||||
RefreshCatalogReq,
|
|
||||||
RefreshCatalogRes,
|
|
||||||
RefreshCatalogStatusReq,
|
|
||||||
} from './dto/connection-test';
|
} from './dto/connection-test';
|
||||||
import { ConnectionClientService } from '../connection/client.service';
|
import { ConnectionClientService } from '../connection/client.service';
|
||||||
import {
|
import {
|
||||||
@@ -24,8 +21,6 @@ import {
|
|||||||
} from '../connection/dtos/connection';
|
} from '../connection/dtos/connection';
|
||||||
import { RequestUser } from 'src/decorators/user.decorator';
|
import { RequestUser } from 'src/decorators/user.decorator';
|
||||||
import { PackTheMetadata } from 'src/utils/PackTheMetadata';
|
import { PackTheMetadata } from 'src/utils/PackTheMetadata';
|
||||||
import { ConnectionsApiService } from '../connections-api/connections-api.service';
|
|
||||||
import { PlatformApiService } from '../platform-api/platform-api.service';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ConnectionTestService {
|
export class ConnectionTestService {
|
||||||
@@ -33,8 +28,6 @@ export class ConnectionTestService {
|
|||||||
constructor(
|
constructor(
|
||||||
@Inject('ConnectionTestGrpcClient') private readonly grpcClient: ClientGrpc,
|
@Inject('ConnectionTestGrpcClient') private readonly grpcClient: ClientGrpc,
|
||||||
private connectionsService: ConnectionClientService,
|
private connectionsService: ConnectionClientService,
|
||||||
private connectionsApiService: ConnectionsApiService,
|
|
||||||
private platformApiService: PlatformApiService,
|
|
||||||
) {
|
) {
|
||||||
this.connectionTestReadClient =
|
this.connectionTestReadClient =
|
||||||
grpcClient.getService<ConnectionTest.ReadService.ConnectionTestReadServices>(
|
grpcClient.getService<ConnectionTest.ReadService.ConnectionTestReadServices>(
|
||||||
@@ -154,137 +147,45 @@ export class ConnectionTestService {
|
|||||||
}
|
}
|
||||||
async connectionTestListSchemas(
|
async connectionTestListSchemas(
|
||||||
body: ConnectionTestListSchemasReq,
|
body: ConnectionTestListSchemasReq,
|
||||||
user: RequestUser,
|
customer_name: string,
|
||||||
): Promise<ConnectionTestListSchemasRes> {
|
): Promise<ConnectionTestListSchemasRes> {
|
||||||
const result = await this.connectionsApiService.proxy(
|
const { connection_id, plugin } = body;
|
||||||
'GET',
|
return lastValueFrom(
|
||||||
`/connection_catalog/${encodeURIComponent(body.connection_id)}/schemas`,
|
this.connectionTestReadClient.ListSchemas({
|
||||||
user,
|
connection_id,
|
||||||
|
customer_name,
|
||||||
|
plugin,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
return {
|
|
||||||
operation_result: true,
|
|
||||||
schema_list: result.schemas.map((schema) => schema.schema_name),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async connectionTestListTables(
|
async connectionTestListTables(
|
||||||
body: ConnectionTestListTablesReq,
|
body: ConnectionTestListTablesReq,
|
||||||
user: RequestUser,
|
customer_name: string,
|
||||||
): Promise<ConnectionTestListTablesRes> {
|
): Promise<ConnectionTestListTablesRes> {
|
||||||
const result = await this.connectionsApiService.proxy(
|
const { connection_id, plugin, schema } = body;
|
||||||
'GET',
|
return lastValueFrom(
|
||||||
`/connection_catalog/${encodeURIComponent(body.connection_id)}` +
|
this.connectionTestReadClient.ListTables({
|
||||||
`/schemas/${encodeURIComponent(body.schema)}/tables`,
|
connection_id,
|
||||||
user,
|
customer_name,
|
||||||
|
plugin,
|
||||||
|
schema,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
return {
|
|
||||||
operation_result: true,
|
|
||||||
table_list: result.tables.map((table) => table.table_name),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTableMetadata(
|
async getTableMetadata(
|
||||||
body: GetTableMetadataReq,
|
body: GetTableMetadataReq,
|
||||||
user: RequestUser,
|
customer_name: string,
|
||||||
): Promise<GetTableMetadataRes> {
|
): Promise<GetTableMetadataRes> {
|
||||||
const tables_metadata = await Promise.all(
|
const { schema, plugin, table_list, connection_id } = body;
|
||||||
body.table_list.map(async (table_name) => {
|
return lastValueFrom(
|
||||||
const result = await this.connectionsApiService.proxy(
|
this.connectionTestReadClient.GetTableMetadata({
|
||||||
'GET',
|
connection_id,
|
||||||
`/connection_catalog/${encodeURIComponent(body.connection_id)}` +
|
customer_name,
|
||||||
`/schemas/${encodeURIComponent(body.schema)}` +
|
plugin,
|
||||||
`/tables/${encodeURIComponent(table_name)}/columns`,
|
schema,
|
||||||
user,
|
table_list,
|
||||||
);
|
|
||||||
return {
|
|
||||||
table_name,
|
|
||||||
columns: result.columns.map((column) => ({
|
|
||||||
name: column.column_name,
|
|
||||||
type: column.data_type,
|
|
||||||
is_primary_key: column.is_primary_key,
|
|
||||||
})),
|
|
||||||
references: [],
|
|
||||||
};
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
return { operation_result: true, tables_metadata };
|
|
||||||
}
|
|
||||||
|
|
||||||
async refreshCatalog(
|
|
||||||
body: RefreshCatalogReq,
|
|
||||||
user: RequestUser,
|
|
||||||
): Promise<RefreshCatalogRes> {
|
|
||||||
const task = await this.platformApiService.proxy(
|
|
||||||
'POST',
|
|
||||||
'/connection_test',
|
|
||||||
user,
|
|
||||||
{
|
|
||||||
customer_id: user.customer_name,
|
|
||||||
plugin: body.plugin,
|
|
||||||
task: {
|
|
||||||
task_type: 'refresh_catalog',
|
|
||||||
connection: {
|
|
||||||
provider: 'connection_manager',
|
|
||||||
config_id: body.connection_id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!task.session_id || !task.date) {
|
|
||||||
throw new HttpException(
|
|
||||||
'Platform API did not return a catalog refresh task identifier',
|
|
||||||
HttpStatus.BAD_GATEWAY,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
operation_result: true,
|
|
||||||
status: 'PENDING',
|
|
||||||
session_id: task.session_id,
|
|
||||||
date: task.date,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async refreshCatalogStatus(
|
|
||||||
body: RefreshCatalogStatusReq,
|
|
||||||
user: RequestUser,
|
|
||||||
): Promise<RefreshCatalogRes> {
|
|
||||||
const result = await this.platformApiService.proxy(
|
|
||||||
'POST',
|
|
||||||
'/connection_test/status',
|
|
||||||
user,
|
|
||||||
{
|
|
||||||
session_id: body.session_id,
|
|
||||||
date: body.date,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (result.status === 'DONE') {
|
|
||||||
await this.connectionsApiService.proxy(
|
|
||||||
'PUT',
|
|
||||||
`/connection_config/${encodeURIComponent(
|
|
||||||
body.connection_id,
|
|
||||||
)}/catalog_metadata`,
|
|
||||||
user,
|
|
||||||
{
|
|
||||||
last_catalog_refresh_status: 'SUCCESS',
|
|
||||||
last_catalog_connection_test_date: body.date,
|
|
||||||
last_catalog_connection_test_session_id: body.session_id,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else if (result.status === 'ERROR' || result.status === 'EXPIRED') {
|
|
||||||
throw new HttpException(
|
|
||||||
`Catalog refresh finished with status ${result.status}`,
|
|
||||||
HttpStatus.BAD_GATEWAY,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
operation_result: result.status === 'DONE',
|
|
||||||
status: result.status,
|
|
||||||
session_id: body.session_id,
|
|
||||||
date: body.date,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
|
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
|
||||||
import { IsIn, IsString, IsOptional } from 'class-validator';
|
import { IsString, IsOptional } from 'class-validator';
|
||||||
import { DatabaseConnectionPropertiesDto } from 'src/modules/connection/dtos/connection';
|
import { DatabaseConnectionPropertiesDto } from 'src/modules/connection/dtos/connection';
|
||||||
import { CreateConnectionDto } from 'src/modules/connection/dtos/connection';
|
import { CreateConnectionDto } from 'src/modules/connection/dtos/connection';
|
||||||
export class ColumnDto {
|
export class ColumnDto {
|
||||||
@@ -7,8 +7,6 @@ export class ColumnDto {
|
|||||||
name: string;
|
name: string;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
type: string;
|
type: string;
|
||||||
@ApiProperty()
|
|
||||||
is_primary_key: boolean;
|
|
||||||
}
|
}
|
||||||
export class TableMetadataDto {
|
export class TableMetadataDto {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@@ -133,37 +131,3 @@ export class GetTableMetadataRes {
|
|||||||
@ApiProperty({ type: [TableMetadataDto] })
|
@ApiProperty({ type: [TableMetadataDto] })
|
||||||
tables_metadata: TableMetadataDto[];
|
tables_metadata: TableMetadataDto[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RefreshCatalogReq {
|
|
||||||
@ApiProperty()
|
|
||||||
@IsString()
|
|
||||||
connection_id: string;
|
|
||||||
|
|
||||||
@ApiProperty({ enum: ['oracle', 'mysql', 'postgresql', 'sqlserver'] })
|
|
||||||
@IsIn(['oracle', 'mysql', 'postgresql', 'sqlserver'])
|
|
||||||
plugin: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class RefreshCatalogStatusReq extends RefreshCatalogReq {
|
|
||||||
@ApiProperty()
|
|
||||||
@IsString()
|
|
||||||
session_id: string;
|
|
||||||
|
|
||||||
@ApiProperty()
|
|
||||||
@IsString()
|
|
||||||
date: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class RefreshCatalogRes {
|
|
||||||
@ApiProperty()
|
|
||||||
operation_result: boolean;
|
|
||||||
|
|
||||||
@ApiProperty()
|
|
||||||
status: string;
|
|
||||||
|
|
||||||
@ApiProperty()
|
|
||||||
session_id: string;
|
|
||||||
|
|
||||||
@ApiProperty()
|
|
||||||
date: string;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import {
|
|||||||
} from '@nestjs/microservices';
|
} from '@nestjs/microservices';
|
||||||
import { ConnectionManager } from '@dadosfera/protospack-v2';
|
import { ConnectionManager } from '@dadosfera/protospack-v2';
|
||||||
|
|
||||||
const infactoryUrl = process.env.INFACTORY_URL ?? '';
|
|
||||||
const isLocalConnection =
|
const isLocalConnection =
|
||||||
infactoryUrl.startsWith('in-factory:') || infactoryUrl.includes('0.0.0.0');
|
process.env.INFACTORY_URL.startsWith('in-factory:') ||
|
||||||
|
process.env.INFACTORY_URL.includes('0.0.0.0');
|
||||||
|
|
||||||
export class ConnectionClientConfiguration {
|
export class ConnectionClientConfiguration {
|
||||||
public name = 'ConnectionClientConfiguration';
|
public name = 'ConnectionClientConfiguration';
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
export const CONNECTIONS_API_CONFIG = {
|
|
||||||
getUrl: (): string => {
|
|
||||||
const url = process.env.CONNECTIONS_API_URL;
|
|
||||||
if (!url) {
|
|
||||||
throw new Error('CONNECTIONS_API_URL environment variable is not set');
|
|
||||||
}
|
|
||||||
return url;
|
|
||||||
},
|
|
||||||
region: process.env.AWS_REGION || 'us-east-1',
|
|
||||||
timeout: parseInt(process.env.CONNECTIONS_API_TIMEOUT || '30000', 10),
|
|
||||||
};
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
|
||||||
|
|
||||||
import { ConnectionsApiService } from './connections-api.service';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
providers: [ConnectionsApiService, DadosferaLogger],
|
|
||||||
exports: [ConnectionsApiService],
|
|
||||||
})
|
|
||||||
export class ConnectionsApiModule {}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
import { Injectable, Inject, HttpException } from '@nestjs/common';
|
|
||||||
import { SignatureV4 } from '@aws-sdk/signature-v4';
|
|
||||||
import { Sha256 } from '@aws-crypto/sha256-js';
|
|
||||||
import { defaultProvider } from '@aws-sdk/credential-provider-node';
|
|
||||||
import axios, { AxiosResponse, Method } from 'axios';
|
|
||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
|
||||||
|
|
||||||
import { RequestUser } from '../../decorators/user.decorator';
|
|
||||||
import { CONNECTIONS_API_CONFIG } from './connections-api.config';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ConnectionsApiService {
|
|
||||||
private signer: SignatureV4;
|
|
||||||
private logger: any;
|
|
||||||
|
|
||||||
constructor(@Inject(DadosferaLogger) dadosferaLogger: DadosferaLogger) {
|
|
||||||
this.logger = dadosferaLogger.logger;
|
|
||||||
this.signer = new SignatureV4({
|
|
||||||
service: 'execute-api',
|
|
||||||
region: CONNECTIONS_API_CONFIG.region,
|
|
||||||
credentials: defaultProvider(),
|
|
||||||
sha256: Sha256,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async proxy(
|
|
||||||
method: string,
|
|
||||||
path: string,
|
|
||||||
user: RequestUser,
|
|
||||||
body?: any,
|
|
||||||
query?: Record<string, string>,
|
|
||||||
): Promise<any> {
|
|
||||||
const baseUrl = CONNECTIONS_API_CONFIG.getUrl();
|
|
||||||
const url = new URL(`${baseUrl}${path}`);
|
|
||||||
|
|
||||||
if (query) {
|
|
||||||
Object.entries(query).forEach(([key, value]) => {
|
|
||||||
if (value !== undefined && value !== null) {
|
|
||||||
url.searchParams.set(key, String(value));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const headers: Record<string, string> = {
|
|
||||||
host: url.hostname,
|
|
||||||
'content-type': 'application/json',
|
|
||||||
customer_name: user.customer_name || '',
|
|
||||||
customer_id: user.customer_id || '',
|
|
||||||
'x-user-id': user.user_id || '',
|
|
||||||
'x-username': user.username || '',
|
|
||||||
'x-customer-tier': user.customer_tier || '',
|
|
||||||
'x-customer-id': user.customer_id || '',
|
|
||||||
};
|
|
||||||
const requestToSign = {
|
|
||||||
method: method.toUpperCase(),
|
|
||||||
protocol: url.protocol,
|
|
||||||
hostname: url.hostname,
|
|
||||||
port: url.port ? parseInt(url.port, 10) : undefined,
|
|
||||||
path: url.pathname + url.search,
|
|
||||||
headers,
|
|
||||||
body: body ? JSON.stringify(body) : undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const signedRequest = await this.signer.sign(requestToSign);
|
|
||||||
const response: AxiosResponse = await axios({
|
|
||||||
method: method as Method,
|
|
||||||
url: url.href,
|
|
||||||
headers: signedRequest.headers as Record<string, string>,
|
|
||||||
data: body,
|
|
||||||
timeout: CONNECTIONS_API_CONFIG.timeout,
|
|
||||||
validateStatus: () => true,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.status >= 400) {
|
|
||||||
throw new HttpException(response.data, response.status);
|
|
||||||
}
|
|
||||||
return response.data;
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('Connections API proxy error', {
|
|
||||||
error: error.message,
|
|
||||||
path,
|
|
||||||
method: method.toUpperCase(),
|
|
||||||
});
|
|
||||||
if (error instanceof HttpException) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
if (error.response) {
|
|
||||||
throw new HttpException(error.response.data, error.response.status);
|
|
||||||
}
|
|
||||||
if (error.code === 'ECONNREFUSED') {
|
|
||||||
throw new HttpException('Connections API service unavailable', 503);
|
|
||||||
}
|
|
||||||
if (error.code === 'ETIMEDOUT' || error.code === 'ECONNABORTED') {
|
|
||||||
throw new HttpException('Connections API request timeout', 504);
|
|
||||||
}
|
|
||||||
throw new HttpException('Internal server error', 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,9 +6,9 @@ import {
|
|||||||
} from '@nestjs/microservices';
|
} from '@nestjs/microservices';
|
||||||
import { ConnectorManager } from '@dadosfera/protospack-v2';
|
import { ConnectorManager } from '@dadosfera/protospack-v2';
|
||||||
|
|
||||||
const infactoryUrl = process.env.INFACTORY_URL ?? '';
|
|
||||||
const isLocalConnection =
|
const isLocalConnection =
|
||||||
infactoryUrl.startsWith('in-factory:') || infactoryUrl.includes('0.0.0.0');
|
process.env.INFACTORY_URL.startsWith('in-factory:') ||
|
||||||
|
process.env.INFACTORY_URL.includes('0.0.0.0');
|
||||||
|
|
||||||
export class ConnectorClientConfiguration {
|
export class ConnectorClientConfiguration {
|
||||||
public name = 'ConnectorClientConfiguration';
|
public name = 'ConnectorClientConfiguration';
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
export interface Info {
|
import { Info } from '@dadosfera/protospack/dist/lib/interfaces';
|
||||||
user_id: string;
|
|
||||||
customer_id: string;
|
|
||||||
customer: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Values {
|
interface Values {
|
||||||
jdbc_user: string;
|
jdbc_user: string;
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import {
|
|||||||
type GrpcOptions,
|
type GrpcOptions,
|
||||||
} from '@nestjs/microservices';
|
} from '@nestjs/microservices';
|
||||||
|
|
||||||
const infactoryUrl = process.env.INFACTORY_URL ?? '';
|
|
||||||
const isLocalConnection =
|
const isLocalConnection =
|
||||||
infactoryUrl.startsWith('in-factory:') || infactoryUrl.includes('0.0.0.0');
|
process.env.INFACTORY_URL.startsWith('in-factory:') ||
|
||||||
|
process.env.INFACTORY_URL.includes('0.0.0.0');
|
||||||
export class InputsGrpcClient {
|
export class InputsGrpcClient {
|
||||||
public readonly name = 'InputsGrpcClient';
|
public readonly name = 'InputsGrpcClient';
|
||||||
private config: GrpcOptions = {
|
private config: GrpcOptions = {
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import {
|
|||||||
} from '@nestjs/microservices';
|
} from '@nestjs/microservices';
|
||||||
import { NetworkConfig } from '@dadosfera/protospack-v2';
|
import { NetworkConfig } from '@dadosfera/protospack-v2';
|
||||||
|
|
||||||
const infactoryUrl = process.env.INFACTORY_URL ?? '';
|
|
||||||
const isLocalConnection =
|
const isLocalConnection =
|
||||||
infactoryUrl.startsWith('in-factory:') || infactoryUrl.includes('0.0.0.0');
|
process.env.INFACTORY_URL.startsWith('in-factory:') ||
|
||||||
|
process.env.INFACTORY_URL.includes('0.0.0.0');
|
||||||
|
|
||||||
export class NetworkConfigGrpcClient {
|
export class NetworkConfigGrpcClient {
|
||||||
public name = 'NetworkConfigGrpcClient';
|
public name = 'NetworkConfigGrpcClient';
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import { ConflictException, Inject, OnModuleInit } from '@nestjs/common';
|
||||||
|
import { ClientGrpc } from '@nestjs/microservices';
|
||||||
|
import {
|
||||||
|
PipelineServicesNames,
|
||||||
|
PipelinesServiceInterface,
|
||||||
|
} from '@dadosfera/protospack';
|
||||||
|
import { lastValueFrom } from 'rxjs';
|
||||||
|
|
||||||
|
import { IIdRequest } from './interfaces';
|
||||||
|
|
||||||
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
|
import { PipelinesClientConfiguration } from './pipelines-client';
|
||||||
|
|
||||||
|
export class PipelinesClientService implements OnModuleInit {
|
||||||
|
private pipelineService: PipelinesServiceInterface;
|
||||||
|
logger: DadosferaLogger;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@Inject(DadosferaLogger)
|
||||||
|
dadosferaLogger: DadosferaLogger,
|
||||||
|
@Inject(PipelinesClientConfiguration.name)
|
||||||
|
private readonly grpcClient: ClientGrpc,
|
||||||
|
) {
|
||||||
|
this.logger = dadosferaLogger.logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
onModuleInit() {
|
||||||
|
this.pipelineService =
|
||||||
|
this.grpcClient.getService<PipelinesServiceInterface>(
|
||||||
|
PipelineServicesNames.PipelineService,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getPipelineStatus(data) {
|
||||||
|
this.logger.info('PipelinesClientService - GetPipelineStatus');
|
||||||
|
|
||||||
|
const statusPipelineResponse = await lastValueFrom(
|
||||||
|
this.pipelineService.getPipelineStatus(data),
|
||||||
|
)
|
||||||
|
.then((res) => {
|
||||||
|
const statusArray =
|
||||||
|
res.status?.sort((a, b) => {
|
||||||
|
if (a.id < b.id) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}) || [];
|
||||||
|
return { status: statusArray };
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
this.logger.error(err.message);
|
||||||
|
throw new Error(err);
|
||||||
|
});
|
||||||
|
this.logger.info('Done');
|
||||||
|
|
||||||
|
return statusPipelineResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
async runPipeline({ id, info }: IIdRequest) {
|
||||||
|
this.logger.info('PipelinesClientService - RunPipeline');
|
||||||
|
const statusPipelineResponse = await lastValueFrom(
|
||||||
|
this.pipelineService.triggerPipeline({ id, info }),
|
||||||
|
).catch((err) => {
|
||||||
|
this.logger.error(err.message);
|
||||||
|
throw new Error(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (statusPipelineResponse.status == false) {
|
||||||
|
throw new ConflictException(
|
||||||
|
'This pipeline is not ready yet to execute, Try again later!',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.info('Done');
|
||||||
|
return statusPipelineResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
import { Info } from '@dadosfera/protospack/dist/lib/interfaces';
|
||||||
|
|
||||||
|
export interface ICreatePipelineDto {
|
||||||
|
input: IdRequest;
|
||||||
|
transformations: IdRequest[];
|
||||||
|
output: IdRequest;
|
||||||
|
tags: string[];
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
info: Info;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IdRequest {
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IIdRequest {
|
||||||
|
id: string;
|
||||||
|
info: Info;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IUpdatePipelineRequest {
|
||||||
|
input: IdRequest;
|
||||||
|
transformations: IdRequest[];
|
||||||
|
output: IdRequest;
|
||||||
|
tags: string[];
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
id: string;
|
||||||
|
info: Info;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IGetPipelineLogsRequest {
|
||||||
|
id: string;
|
||||||
|
details: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import {
|
||||||
|
ClientsProviderAsyncOptions,
|
||||||
|
GrpcOptions,
|
||||||
|
Transport,
|
||||||
|
} from '@nestjs/microservices';
|
||||||
|
import { PipelinePackages, PipelineProtoFilePath } from '@dadosfera/protospack';
|
||||||
|
import { credentials } from '@grpc/grpc-js';
|
||||||
|
|
||||||
|
const isLocalConnection =
|
||||||
|
process.env.PIFACTORY_URL.startsWith('pi-factory:') ||
|
||||||
|
process.env.PIFACTORY_URL.includes('0.0.0.0');
|
||||||
|
|
||||||
|
export class PipelinesClientConfiguration {
|
||||||
|
public name = 'PipelinesClientConfiguration';
|
||||||
|
private config: GrpcOptions = {
|
||||||
|
transport: Transport.GRPC,
|
||||||
|
options: {
|
||||||
|
url: process.env.PIFACTORY_URL,
|
||||||
|
package: PipelinePackages,
|
||||||
|
credentials: isLocalConnection ? undefined : credentials.createSsl(),
|
||||||
|
protoPath: PipelineProtoFilePath,
|
||||||
|
loader: {
|
||||||
|
keepCase: true,
|
||||||
|
enums: String,
|
||||||
|
defaults: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
providerOptions: ClientsProviderAsyncOptions = {
|
||||||
|
name: this.name,
|
||||||
|
...this.config,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import { Body, Controller, Get, Inject, Param, Post } from '@nestjs/common';
|
||||||
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||||
|
import {
|
||||||
|
AuthenticateCondition,
|
||||||
|
Authenticated,
|
||||||
|
RequireSomePermission,
|
||||||
|
} from 'src/decorators/authentication.decorator';
|
||||||
|
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
|
||||||
|
import { PipelinesService } from './pipelines.service';
|
||||||
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
|
import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
|
||||||
|
|
||||||
|
@ApiInternalOnlyController()
|
||||||
|
@ApiTags('Pipelines')
|
||||||
|
@Controller('pipelines')
|
||||||
|
@Authenticated()
|
||||||
|
export class PipelinesController {
|
||||||
|
logger: DadosferaLogger;
|
||||||
|
constructor(
|
||||||
|
@Inject(DadosferaLogger)
|
||||||
|
dadosferaLogger: DadosferaLogger,
|
||||||
|
private pipelineService: PipelinesService,
|
||||||
|
) {
|
||||||
|
this.logger = dadosferaLogger.logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('start/:id')
|
||||||
|
@RequireSomePermission(PERMISSIONS_GROUPS.PIPELINE.permissions.CREATE)
|
||||||
|
@ApiOperation({
|
||||||
|
deprecated: true,
|
||||||
|
description:
|
||||||
|
'This method is deprecated. Please use route /pipelinesV2/start/:id instead',
|
||||||
|
})
|
||||||
|
async activate(@Param('id') id: string, @Body() body) {
|
||||||
|
const { info } = body;
|
||||||
|
|
||||||
|
this.logger.info(
|
||||||
|
process.env.DEV_URL + `/pipeline/start/${id} - ON START PIPELINE ROUTE`,
|
||||||
|
{
|
||||||
|
user: body.info.user_id,
|
||||||
|
customer: body.info.customer,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = await this.pipelineService.runPipeline({ id, info });
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id/status')
|
||||||
|
@ApiOperation({
|
||||||
|
deprecated: true,
|
||||||
|
description:
|
||||||
|
'This method is deprecated. Please use route /pipelinesV2/:id/status instead',
|
||||||
|
})
|
||||||
|
@RequireSomePermission(PERMISSIONS_GROUPS.IMPORT_FILES.permissions.VIEW, PERMISSIONS_GROUPS.PIPELINE.permissions.GET)
|
||||||
|
async getPipelineStatus(@Body() body, @Param('id') id: string) {
|
||||||
|
body.id = id;
|
||||||
|
|
||||||
|
this.logger.info(
|
||||||
|
process.env.DEV_URL + `/pipeline/${id} - ON GET PIPELINE STATUS ROUTE`,
|
||||||
|
{
|
||||||
|
user: body.info.user_id,
|
||||||
|
customer: body.info.customer,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = await this.pipelineService.getPipelineStatus(body);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ClientsModule } from '@nestjs/microservices';
|
||||||
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
|
|
||||||
|
import { PipelinesController } from './pipelines.controller';
|
||||||
|
import { PipelinesService } from './pipelines.service';
|
||||||
|
|
||||||
|
import { PipelinesClientConfiguration } from './pipelines-client';
|
||||||
|
import { PipelinesClientService } from './client.service';
|
||||||
|
|
||||||
|
const client = new PipelinesClientConfiguration();
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [ClientsModule.register([client.providerOptions])],
|
||||||
|
controllers: [PipelinesController],
|
||||||
|
providers: [PipelinesService, PipelinesClientService, DadosferaLogger],
|
||||||
|
exports: [PipelinesService],
|
||||||
|
})
|
||||||
|
export class PipelinesModule {}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||||
|
import { PipelinesClientService } from './client.service';
|
||||||
|
import { IIdRequest } from './interfaces';
|
||||||
|
import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class PipelinesService {
|
||||||
|
constructor(private pipelineClient: PipelinesClientService) {}
|
||||||
|
|
||||||
|
async getPipelineStatus(data: IIdRequest) {
|
||||||
|
try {
|
||||||
|
const pipelineStatusResponse =
|
||||||
|
await this.pipelineClient.getPipelineStatus(data);
|
||||||
|
|
||||||
|
return objectCamelToSnake(pipelineStatusResponse);
|
||||||
|
} catch (err) {
|
||||||
|
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async runPipeline({ id, info }: IIdRequest) {
|
||||||
|
try {
|
||||||
|
const triggerPipelineResponse = await this.pipelineClient.runPipeline({
|
||||||
|
id,
|
||||||
|
info,
|
||||||
|
});
|
||||||
|
|
||||||
|
return objectCamelToSnake(triggerPipelineResponse);
|
||||||
|
} catch (err) {
|
||||||
|
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
|
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
|
||||||
|
import { Info } from '@dadosfera/protospack/dist/lib/interfaces';
|
||||||
|
|
||||||
export class PipelineInputsDTO {
|
export class PipelineInputsDTO {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@@ -61,12 +62,6 @@ export interface IIdRequest {
|
|||||||
info: Info;
|
info: Info;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Info {
|
|
||||||
user_id: string;
|
|
||||||
customer_id: string;
|
|
||||||
customer: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IUpdatePipelineRequest {
|
export interface IUpdatePipelineRequest {
|
||||||
input: IdRequest;
|
input: IdRequest;
|
||||||
transformations: IdRequest[];
|
transformations: IdRequest[];
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import { Messages } from '@dadosfera/protospack-v2/dist/lib/PipelineV2';
|
|||||||
import { RequestUser, User } from 'src/decorators/user.decorator';
|
import { RequestUser, User } from 'src/decorators/user.decorator';
|
||||||
import { PackTheMetadata } from 'src/utils/PackTheMetadata';
|
import { PackTheMetadata } from 'src/utils/PackTheMetadata';
|
||||||
|
|
||||||
|
import { PipelinesService as OldPipelineService } from 'src/modules/pipelines/pipelines.service';
|
||||||
import {
|
import {
|
||||||
ICompleteUploadCSVFile,
|
ICompleteUploadCSVFile,
|
||||||
ICreatePipelineCSVFile,
|
ICreatePipelineCSVFile,
|
||||||
@@ -62,7 +63,9 @@ export class PipelinesController {
|
|||||||
constructor(
|
constructor(
|
||||||
@Inject(DadosferaLogger)
|
@Inject(DadosferaLogger)
|
||||||
dadosferaLogger: DadosferaLogger,
|
dadosferaLogger: DadosferaLogger,
|
||||||
|
|
||||||
private pipelinesClientService: PipelinesService,
|
private pipelinesClientService: PipelinesService,
|
||||||
|
private oldPipelinesService: OldPipelineService,
|
||||||
) {
|
) {
|
||||||
this.logger = dadosferaLogger.logger;
|
this.logger = dadosferaLogger.logger;
|
||||||
}
|
}
|
||||||
@@ -198,7 +201,7 @@ export class PipelinesController {
|
|||||||
customer: body.info.customer,
|
customer: body.info.customer,
|
||||||
});
|
});
|
||||||
|
|
||||||
const response = await this.pipelinesClientService.getPipelineStatus(body);
|
const response = await this.oldPipelinesService.getPipelineStatus(body);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@@ -365,21 +368,6 @@ export class PipelinesController {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch('/:id/upgrade')
|
|
||||||
@RequireSomePermission(PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE)
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
async upgradeConnector(
|
|
||||||
@Language() language: LanguageEnum,
|
|
||||||
@Param('id') id: string,
|
|
||||||
@User() user: RequestUser
|
|
||||||
) {
|
|
||||||
this.logger.info('PipelinesController - upgrade connector');
|
|
||||||
|
|
||||||
const metadata = PackTheMetadata(user);
|
|
||||||
|
|
||||||
await this.pipelinesClientService.upgrade(id, metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@ApiNoContentResponse()
|
@ApiNoContentResponse()
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
@@ -509,7 +497,7 @@ export class PipelinesController {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const response = await this.pipelinesClientService.runPipeline({ id, info });
|
const response = await this.oldPipelinesService.runPipeline({ id, info });
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { PipelinesService } from './pipelines.service';
|
|||||||
|
|
||||||
import { PipelinesClientConfiguration } from './pipelines-client';
|
import { PipelinesClientConfiguration } from './pipelines-client';
|
||||||
|
|
||||||
|
import { PipelinesModule as OldPipelineModule } from 'src/modules/pipelines/pipelines.module';
|
||||||
import { ConnectorModule } from '../connector/connector.module';
|
import { ConnectorModule } from '../connector/connector.module';
|
||||||
import { InputsModule } from '../inputs/inputs.module';
|
import { InputsModule } from '../inputs/inputs.module';
|
||||||
import { TransformationsModule } from '../transformations/transformations.module';
|
import { TransformationsModule } from '../transformations/transformations.module';
|
||||||
@@ -20,6 +21,7 @@ const client = new PipelinesClientConfiguration();
|
|||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ClientsModule.register([client.providerOptions]),
|
ClientsModule.register([client.providerOptions]),
|
||||||
|
OldPipelineModule,
|
||||||
ConnectorModule,
|
ConnectorModule,
|
||||||
InputsModule,
|
InputsModule,
|
||||||
TransformationsModule,
|
TransformationsModule,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/* eslint-disable no-async-promise-executor */
|
/* eslint-disable no-async-promise-executor */
|
||||||
import {
|
import {
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
ConflictException,
|
|
||||||
HttpException,
|
HttpException,
|
||||||
HttpStatus,
|
HttpStatus,
|
||||||
Inject,
|
Inject,
|
||||||
@@ -18,7 +17,7 @@ import { lastValueFrom } from 'rxjs';
|
|||||||
|
|
||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
import { PipelinesClientConfiguration } from './pipelines-client';
|
import { PipelinesClientConfiguration } from './pipelines-client';
|
||||||
import { ICreatePipelineV2Req, IIdRequest, UpdatePlatformInputRequest, UpdateTableDTO } from './interfaces';
|
import { ICreatePipelineV2Req, UpdatePlatformInputRequest, UpdateTableDTO } from './interfaces';
|
||||||
import { PipelineV2CreateRequest } from '@dadosfera/protospack-v2/dist/lib/PipelineV2/interfaces/messages';
|
import { PipelineV2CreateRequest } from '@dadosfera/protospack-v2/dist/lib/PipelineV2/interfaces/messages';
|
||||||
import { Metadata } from '@grpc/grpc-js';
|
import { Metadata } from '@grpc/grpc-js';
|
||||||
import { ConnectorClientService } from '../connector/client.service';
|
import { ConnectorClientService } from '../connector/client.service';
|
||||||
@@ -177,15 +176,6 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
return updatePipelineResponse;
|
return updatePipelineResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
async upgrade(id: string, metadata: Metadata) {
|
|
||||||
await lastValueFrom(
|
|
||||||
this.pipelineWriteService.Upgrade(
|
|
||||||
{ id },
|
|
||||||
metadata,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async remove(data: { id: string; metadata: Metadata; user: RequestUser }) {
|
async remove(data: { id: string; metadata: Metadata; user: RequestUser }) {
|
||||||
const { id, metadata, user } = data;
|
const { id, metadata, user } = data;
|
||||||
const info = {
|
const info = {
|
||||||
@@ -633,49 +623,4 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
return assets;
|
return assets;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPipelineStatus(data) {
|
|
||||||
this.logger.info('PipelinesClientService - GetPipelineStatus');
|
|
||||||
|
|
||||||
const statusPipelineResponse = await lastValueFrom(
|
|
||||||
this.pipelineReadService.PipelineV2GetPipelineV2Status(data),
|
|
||||||
)
|
|
||||||
.then((res) => {
|
|
||||||
const statusArray =
|
|
||||||
res.status?.sort((a, b) => {
|
|
||||||
if (a.id < b.id) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}) || [];
|
|
||||||
return { status: statusArray };
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
this.logger.error(err.message);
|
|
||||||
throw new Error(err);
|
|
||||||
});
|
|
||||||
this.logger.info('Done');
|
|
||||||
|
|
||||||
return statusPipelineResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
async runPipeline({ id, info }: IIdRequest) {
|
|
||||||
this.logger.info('PipelinesClientService - RunPipeline');
|
|
||||||
const statusPipelineResponse = await lastValueFrom(
|
|
||||||
this.pipelineWriteService.PipelineV2TriggerPipelineV2({ id, info }),
|
|
||||||
).catch((err) => {
|
|
||||||
this.logger.error(err.message);
|
|
||||||
throw new Error(err);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (statusPipelineResponse.status == false) {
|
|
||||||
throw new ConflictException(
|
|
||||||
'This pipeline is not ready yet to execute, Try again later!',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.logger.info('Done');
|
|
||||||
return statusPipelineResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { ReleaseNoteController } from './release_note.controller';
|
import { ReleaseNoteController } from './release_note.controller';
|
||||||
import { ReleaseNoteService } from './release_note.service';
|
import { ReleaseNoteService } from './release_note.service';
|
||||||
import DadosferaLogger from '@dadosfera/dadosfera-logs';
|
|
||||||
|
|
||||||
describe('ReleaseNoteController', () => {
|
describe('ReleaseNoteController', () => {
|
||||||
let controller: ReleaseNoteController;
|
let controller: ReleaseNoteController;
|
||||||
@@ -9,7 +8,7 @@ describe('ReleaseNoteController', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
controllers: [ReleaseNoteController],
|
controllers: [ReleaseNoteController],
|
||||||
providers: [ReleaseNoteService, DadosferaLogger],
|
providers: [ReleaseNoteService],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
controller = module.get<ReleaseNoteController>(ReleaseNoteController);
|
controller = module.get<ReleaseNoteController>(ReleaseNoteController);
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
import { ReleaseNoteService } from './release_note.service';
|
import { ReleaseNoteService } from './release_note.service';
|
||||||
import DadosferaLogger from '@dadosfera/dadosfera-logs';
|
|
||||||
|
|
||||||
describe('ReleaseNoteService', () => {
|
describe('ReleaseNoteService', () => {
|
||||||
let service: ReleaseNoteService;
|
let service: ReleaseNoteService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
providers: [ReleaseNoteService, DadosferaLogger],
|
providers: [ReleaseNoteService],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<ReleaseNoteService>(ReleaseNoteService);
|
service = module.get<ReleaseNoteService>(ReleaseNoteService);
|
||||||
|
|||||||
+2
-5
@@ -1,8 +1,5 @@
|
|||||||
export interface Info {
|
import { Info } from '@dadosfera/protospack/dist/lib/interfaces';
|
||||||
user_id: string;
|
|
||||||
customer_id: string;
|
|
||||||
customer: string;
|
|
||||||
}
|
|
||||||
export interface ICreateTransformationsRequest {
|
export interface ICreateTransformationsRequest {
|
||||||
transformations: Transformation[];
|
transformations: Transformation[];
|
||||||
info: Info;
|
info: Info;
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import {
|
|||||||
import { credentials } from '@grpc/grpc-js';
|
import { credentials } from '@grpc/grpc-js';
|
||||||
import { Transformation } from '@dadosfera/protospack-v2';
|
import { Transformation } from '@dadosfera/protospack-v2';
|
||||||
|
|
||||||
const infactoryUrl = process.env.INFACTORY_URL ?? '';
|
|
||||||
const isLocalConnection =
|
const isLocalConnection =
|
||||||
infactoryUrl.startsWith('in-factory:') || infactoryUrl.includes('0.0.0.0');
|
process.env.INFACTORY_URL.startsWith('in-factory:') ||
|
||||||
|
process.env.INFACTORY_URL.includes('0.0.0.0');
|
||||||
|
|
||||||
export class TransformationsClientConfiguration {
|
export class TransformationsClientConfiguration {
|
||||||
public name = 'TransformationsClientConfiguration';
|
public name = 'TransformationsClientConfiguration';
|
||||||
|
|||||||
Reference in New Issue
Block a user