mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-27 09:40:04 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be061a0fb9 | ||
|
|
c83f6a68d1 | ||
|
|
06424d6bcf | ||
|
|
45b82515fc | ||
|
|
a9cc951e34 | ||
|
|
93ccf506fb | ||
|
|
706d0ccfa0 | ||
|
|
c2eec4e95c | ||
|
|
ac3132b6eb | ||
|
|
a2c1f2da6f |
+49
-1
@@ -534,6 +534,46 @@
|
|||||||
],
|
],
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "search",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "filters",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "size",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "page",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "type",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
@@ -1504,7 +1544,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"info": {
|
"info": {
|
||||||
"title": "Maestro - feat/docs-refactor",
|
"title": "Maestro - fix/upload-files",
|
||||||
"description": "This is the Maestro API",
|
"description": "This is the Maestro API",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"contact": {}
|
"contact": {}
|
||||||
@@ -2173,6 +2213,9 @@
|
|||||||
"description": {
|
"description": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"connection_id": {
|
"connection_id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -2213,6 +2256,7 @@
|
|||||||
"required": [
|
"required": [
|
||||||
"name",
|
"name",
|
||||||
"description",
|
"description",
|
||||||
|
"type",
|
||||||
"connection_id",
|
"connection_id",
|
||||||
"cron",
|
"cron",
|
||||||
"connector_name",
|
"connector_name",
|
||||||
@@ -2233,6 +2277,9 @@
|
|||||||
"description": {
|
"description": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"connection_id": {
|
"connection_id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -2280,6 +2327,7 @@
|
|||||||
"id",
|
"id",
|
||||||
"name",
|
"name",
|
||||||
"description",
|
"description",
|
||||||
|
"type",
|
||||||
"connection_id",
|
"connection_id",
|
||||||
"cron",
|
"cron",
|
||||||
"connector_name",
|
"connector_name",
|
||||||
|
|||||||
+54
-2
@@ -2707,6 +2707,46 @@
|
|||||||
],
|
],
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "search",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "filters",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "size",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "page",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "type",
|
||||||
|
"required": false,
|
||||||
|
"in": "query",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
@@ -4676,7 +4716,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"info": {
|
"info": {
|
||||||
"title": "Maestro - feat/docs-refactor",
|
"title": "Maestro - fix/upload-files",
|
||||||
"description": "This is the Maestro API",
|
"description": "This is the Maestro API",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"contact": {}
|
"contact": {}
|
||||||
@@ -6346,6 +6386,9 @@
|
|||||||
"description": {
|
"description": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"connection_id": {
|
"connection_id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -6386,6 +6429,7 @@
|
|||||||
"required": [
|
"required": [
|
||||||
"name",
|
"name",
|
||||||
"description",
|
"description",
|
||||||
|
"type",
|
||||||
"connection_id",
|
"connection_id",
|
||||||
"cron",
|
"cron",
|
||||||
"connector_name",
|
"connector_name",
|
||||||
@@ -6406,6 +6450,9 @@
|
|||||||
"description": {
|
"description": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"connection_id": {
|
"connection_id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -6453,6 +6500,7 @@
|
|||||||
"id",
|
"id",
|
||||||
"name",
|
"name",
|
||||||
"description",
|
"description",
|
||||||
|
"type",
|
||||||
"connection_id",
|
"connection_id",
|
||||||
"cron",
|
"cron",
|
||||||
"connector_name",
|
"connector_name",
|
||||||
@@ -6520,6 +6568,9 @@
|
|||||||
},
|
},
|
||||||
"header": {
|
"header": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"engine": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
@@ -6528,7 +6579,8 @@
|
|||||||
"description",
|
"description",
|
||||||
"encoding",
|
"encoding",
|
||||||
"sep",
|
"sep",
|
||||||
"header"
|
"header",
|
||||||
|
"engine"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"IRole": {
|
"IRole": {
|
||||||
|
|||||||
Generated
+7
-7
@@ -12,7 +12,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack-v2": "3.29.0",
|
"@dadosfera/protospack-v2": "3.29.1",
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"@grpc/proto-loader": "^0.6.13",
|
"@grpc/proto-loader": "^0.6.13",
|
||||||
"@nestjs/common": "^8.4.7",
|
"@nestjs/common": "^8.4.7",
|
||||||
@@ -1727,9 +1727,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@dadosfera/protospack-v2": {
|
"node_modules/@dadosfera/protospack-v2": {
|
||||||
"version": "3.29.0",
|
"version": "3.29.1",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.29.0.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.29.1.tgz",
|
||||||
"integrity": "sha512-G66u9V+/+5rQb+fpJdDXydTaji2Mlr0Ro5TTYcQleITKU9DjF1WZs/jP/Qu0Y224nCb8HhePvaVl/Rr0wtLt4w==",
|
"integrity": "sha512-uVswwXltdG0aX8cYVSFPRcROPWjOlW5bJGFfn5RNodKyHeBiTVDWBB3/YgocKrWV4mYBSbZ11ctBzjSAOkf/0Q==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
@@ -12284,9 +12284,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@dadosfera/protospack-v2": {
|
"@dadosfera/protospack-v2": {
|
||||||
"version": "3.29.0",
|
"version": "3.29.1",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.29.0.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.29.1.tgz",
|
||||||
"integrity": "sha512-G66u9V+/+5rQb+fpJdDXydTaji2Mlr0Ro5TTYcQleITKU9DjF1WZs/jP/Qu0Y224nCb8HhePvaVl/Rr0wtLt4w==",
|
"integrity": "sha512-uVswwXltdG0aX8cYVSFPRcROPWjOlW5bJGFfn5RNodKyHeBiTVDWBB3/YgocKrWV4mYBSbZ11ctBzjSAOkf/0Q==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack-v2": "3.29.0",
|
"@dadosfera/protospack-v2": "3.29.1",
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"@grpc/proto-loader": "^0.6.13",
|
"@grpc/proto-loader": "^0.6.13",
|
||||||
"@nestjs/common": "^8.4.7",
|
"@nestjs/common": "^8.4.7",
|
||||||
|
|||||||
@@ -428,12 +428,12 @@ export const PERMISSIONS_GROUPS = {
|
|||||||
permissions: {
|
permissions: {
|
||||||
OPEN: {
|
OPEN: {
|
||||||
seqid: 16,
|
seqid: 16,
|
||||||
claim: 'GET /zendesk',
|
claim: 'support-chat:access',
|
||||||
usage: PermissionUsages.INTERNAL,
|
usage: PermissionUsages.INTERNAL,
|
||||||
name: {
|
name: {
|
||||||
'pt-br': 'Acessar Zendesk',
|
'pt-br': 'Acessar chat de suporte',
|
||||||
'en-us': 'Access Zendesk',
|
'en-us': 'Access support chat',
|
||||||
'es-es': 'Acceso Zendesk',
|
'es-es': 'Acceder al chat de soporte',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ export class IPipelineV2 {
|
|||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
description: string;
|
description: string;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
|
type: string;
|
||||||
|
@ApiProperty()
|
||||||
connection_id: string;
|
connection_id: string;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
cron: string;
|
cron: string;
|
||||||
@@ -104,4 +106,20 @@ export class ICreatePipelineCSVFile {
|
|||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
header: boolean;
|
header: boolean;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
engine: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PipelineFindAllReq {
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
search?: string | undefined;
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
filters?: string | undefined;
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
size?: string | undefined;
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
page?: string | undefined;
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
type?: string | undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import {
|
|||||||
ICreatePipelineV2Req,
|
ICreatePipelineV2Req,
|
||||||
IPipelineV2,
|
IPipelineV2,
|
||||||
IInitUploadCSVFile,
|
IInitUploadCSVFile,
|
||||||
|
PipelineFindAllReq,
|
||||||
} from './interfaces';
|
} from './interfaces';
|
||||||
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
||||||
import { LanguageEnum } from 'src/utils/languages.enum';
|
import { LanguageEnum } from 'src/utils/languages.enum';
|
||||||
@@ -115,7 +116,7 @@ export class PipelinesController {
|
|||||||
async findAll(
|
async findAll(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Language() language: LanguageEnum,
|
@Language() language: LanguageEnum,
|
||||||
@Query() data,
|
@Query() data: PipelineFindAllReq,
|
||||||
) {
|
) {
|
||||||
this.logger.info('PipelinesController - findAll', { user });
|
this.logger.info('PipelinesController - findAll', { user });
|
||||||
|
|
||||||
@@ -370,30 +371,37 @@ export class PipelinesController {
|
|||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Body() body: ICreatePipelineCSVFile,
|
@Body() body: ICreatePipelineCSVFile,
|
||||||
) {
|
) {
|
||||||
this.logger.info('/upload - Upload Connector Route');
|
this.logger.info('/file - Upload Connector Route');
|
||||||
const metadata = PackTheMetadata({ ...user });
|
const metadata = PackTheMetadata({ ...user });
|
||||||
|
|
||||||
const { name, sep, header, encoding, description, file_name } = body;
|
const { name, sep, header, encoding, description, file_name, engine } =
|
||||||
|
body;
|
||||||
|
|
||||||
|
const file_format_params = {
|
||||||
|
...(sep && { sep }),
|
||||||
|
...(encoding && { encoding }),
|
||||||
|
...(header !== undefined ? { header } : {}),
|
||||||
|
};
|
||||||
|
|
||||||
const source_prefix = `${user.customer_name}/${file_name}`;
|
const source_prefix = `${user.customer_name}/${file_name}`;
|
||||||
|
|
||||||
const upload_pipeline = {
|
const upload_pipeline: ICreatePipelineV2Req = {
|
||||||
connection_id: process.env.UPLOAD_FILE_AGENT_CONNECTION,
|
connection_id: process.env.UPLOAD_FILE_AGENT_CONNECTION,
|
||||||
connector_name: 'Amazon S3',
|
connector_name: 'Amazon S3',
|
||||||
connector_plugin: 'aws_s3',
|
connector_plugin: 'aws_s3',
|
||||||
connector_version: '1.0.0',
|
connector_version: '1.0.0',
|
||||||
image_url: 'https://assets.dadosfera.ai/images/connectors/csv.svg',
|
image_url: `https://assets.dadosfera.ai/images/connectors/${engine}.svg`,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
transformations_ids: [],
|
transformations_ids: [],
|
||||||
tags: [],
|
tags: [],
|
||||||
cron: '@once',
|
cron: '@once',
|
||||||
config: { cron: '@once', tables: [] },
|
type: 'upload',
|
||||||
properties: {
|
properties: {
|
||||||
engine: 'csv',
|
engine,
|
||||||
source_bucket: process.env.BUCKET_CUSTOMER_CSV_ASSETS,
|
source_bucket: process.env.BUCKET_CUSTOMER_CSV_ASSETS,
|
||||||
source_prefix,
|
source_prefix,
|
||||||
file_format_params: { sep, encoding, header: Boolean(header) },
|
file_format_params,
|
||||||
is_a_upload_csv: true,
|
|
||||||
},
|
},
|
||||||
input_id: undefined,
|
input_id: undefined,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import { ConnectorClientService } from '../connector/client.service';
|
|||||||
import { InputsService } from '../inputs/inputs.service';
|
import { InputsService } from '../inputs/inputs.service';
|
||||||
import { RequestUser } from 'src/decorators/user.decorator';
|
import { RequestUser } from 'src/decorators/user.decorator';
|
||||||
import { TransformationsService } from '../transformations/transformations.service';
|
import { TransformationsService } from '../transformations/transformations.service';
|
||||||
import { getObjValueFromPath } from 'src/utils/ObjValueFromPath';
|
import { getObjValueFromPath, objHasPath } from 'src/utils/ObjValueFromPath';
|
||||||
import ErrorCodes from 'src/utils/errorCodes';
|
import ErrorCodes from 'src/utils/errorCodes';
|
||||||
import ErrorBuilder from 'src/utils/ErrorBuilder';
|
import ErrorBuilder from 'src/utils/ErrorBuilder';
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
this.logger.info('PipelinesClientService - findOneProperties');
|
this.logger.info('PipelinesClientService - findOneProperties');
|
||||||
const { pipeline } = await this.findOne({ id }, metadata);
|
const { pipeline } = await this.findOne({ id }, metadata);
|
||||||
|
|
||||||
const pipelineProperties = JSON.parse(pipeline.properties);
|
const properties = JSON.parse(pipeline.properties);
|
||||||
|
|
||||||
const connectorId = `${pipeline.connector_plugin}-${pipeline.connector_version}`;
|
const connectorId = `${pipeline.connector_plugin}-${pipeline.connector_version}`;
|
||||||
|
|
||||||
@@ -228,24 +228,30 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
connectorId,
|
connectorId,
|
||||||
metadata.get('language')[0].toString(),
|
metadata.get('language')[0].toString(),
|
||||||
);
|
);
|
||||||
const connector = JSON.parse(res.connector);
|
const connector: { [key: string]: any; config_controls: any[] } =
|
||||||
const config_controls = connector.config_controls || [];
|
JSON.parse(res.connector);
|
||||||
|
const config_controls = (connector.config_controls || []).filter(
|
||||||
|
(config_control) => {
|
||||||
|
const path: string = config_control.name;
|
||||||
|
|
||||||
for (const config_control of config_controls) {
|
if (!objHasPath({ object: { properties }, path })) return false;
|
||||||
const path: string = config_control.name;
|
|
||||||
const default_value = getObjValueFromPath({
|
const default_value = getObjValueFromPath({
|
||||||
object: { properties: pipelineProperties },
|
object: { properties },
|
||||||
path,
|
path,
|
||||||
});
|
});
|
||||||
if (default_value != undefined)
|
if (default_value != undefined)
|
||||||
config_control.default_value = default_value;
|
config_control.default_value = default_value;
|
||||||
}
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pipeline: {
|
pipeline: {
|
||||||
...pipeline,
|
...pipeline,
|
||||||
config_controls,
|
config_controls,
|
||||||
properties: pipelineProperties,
|
properties: properties,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,6 +308,20 @@ export function EnrichErrorCode(code: string) {
|
|||||||
'Tente realizar a ação novamente. Caso o erro persista, entre em contato com o suporte',
|
'Tente realizar a ação novamente. Caso o erro persista, entre em contato com o suporte',
|
||||||
code,
|
code,
|
||||||
};
|
};
|
||||||
|
case ErrorCodes.CATALOG.PREVIEW_TOO_BIG:
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
error: 'Erro ao buscar prévia',
|
||||||
|
message: 'Ocorreu um erro devido ao tamanho da prévia do ativo.',
|
||||||
|
code,
|
||||||
|
};
|
||||||
|
case ErrorCodes.CATALOG.METADATA_TOO_BIG:
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
error: 'Erro ao buscar informações',
|
||||||
|
message: 'Ocorreu um erro devido ao tamanho das informações do ativo.',
|
||||||
|
code,
|
||||||
|
};
|
||||||
case ErrorCodes.INTERNAL:
|
case ErrorCodes.INTERNAL:
|
||||||
case ErrorCodes.UNKNOWN:
|
case ErrorCodes.UNKNOWN:
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -8,3 +8,18 @@ export function getObjValueFromPath<T>(data: { object: T; path: string }): T {
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function objHasPath<T extends object>(data: {
|
||||||
|
object: T;
|
||||||
|
path: string;
|
||||||
|
}): boolean {
|
||||||
|
const { object, path } = data;
|
||||||
|
const keys = path.split('.');
|
||||||
|
|
||||||
|
let value = JSON.parse(JSON.stringify(object));
|
||||||
|
for (const key of keys) {
|
||||||
|
if (!(key in value)) return false;
|
||||||
|
value = value[key];
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ const TRANSFORMATION = {
|
|||||||
};
|
};
|
||||||
const CATALOG = {
|
const CATALOG = {
|
||||||
DATA_ASSET_NOT_FOUND: 'CATALOG.DATA_ASSET_NOT_FOUND',
|
DATA_ASSET_NOT_FOUND: 'CATALOG.DATA_ASSET_NOT_FOUND',
|
||||||
|
PREVIEW_TOO_BIG: 'CATALOG.PREVIEW_TOO_BIG',
|
||||||
|
METADATA_TOO_BIG: 'CATALOG.METADATA_TOO_BIG',
|
||||||
};
|
};
|
||||||
const ErrorCodes = {
|
const ErrorCodes = {
|
||||||
UNKNOWN: 'UNKNOWN',
|
UNKNOWN: 'UNKNOWN',
|
||||||
|
|||||||
Reference in New Issue
Block a user