rez_core 4.0.291 → 4.0.292
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/250218_nodejs_core.iml +12 -0
- package/.idea/codeStyles/Project.xml +59 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/dist/module/entity_json/entity_json.module.js +2 -1
- package/dist/module/entity_json/entity_json.module.js.map +1 -1
- package/dist/module/entity_json/service/entityJson.repository.d.ts +7 -0
- package/dist/module/entity_json/service/entityJson.repository.js +45 -0
- package/dist/module/entity_json/service/entityJson.repository.js.map +1 -0
- package/dist/module/entity_json/service/entity_json.service.d.ts +3 -1
- package/dist/module/entity_json/service/entity_json.service.js +48 -73
- package/dist/module/entity_json/service/entity_json.service.js.map +1 -1
- package/dist/module/filter/service/filter.service.js +11 -11
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/entity_json/entity_json.module.ts +2 -1
- package/src/module/entity_json/service/entityJson.repository.ts +37 -0
- package/src/module/entity_json/service/entity_json.service.ts +81 -165
- package/src/module/filter/service/filter.service.ts +13 -13
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<component name="ProjectCodeStyleConfiguration">
|
|
2
|
+
<code_scheme name="Project" version="173">
|
|
3
|
+
<HTMLCodeStyleSettings>
|
|
4
|
+
<option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
|
5
|
+
</HTMLCodeStyleSettings>
|
|
6
|
+
<JSCodeStyleSettings version="0">
|
|
7
|
+
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
8
|
+
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
9
|
+
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
10
|
+
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
11
|
+
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
|
12
|
+
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
13
|
+
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
14
|
+
</JSCodeStyleSettings>
|
|
15
|
+
<TypeScriptCodeStyleSettings version="0">
|
|
16
|
+
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
17
|
+
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
18
|
+
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
19
|
+
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
20
|
+
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
|
21
|
+
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
22
|
+
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
23
|
+
</TypeScriptCodeStyleSettings>
|
|
24
|
+
<VueCodeStyleSettings>
|
|
25
|
+
<option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
|
|
26
|
+
<option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
|
|
27
|
+
</VueCodeStyleSettings>
|
|
28
|
+
<codeStyleSettings language="HTML">
|
|
29
|
+
<option name="SOFT_MARGINS" value="80" />
|
|
30
|
+
<indentOptions>
|
|
31
|
+
<option name="INDENT_SIZE" value="2" />
|
|
32
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
33
|
+
<option name="TAB_SIZE" value="2" />
|
|
34
|
+
</indentOptions>
|
|
35
|
+
</codeStyleSettings>
|
|
36
|
+
<codeStyleSettings language="JavaScript">
|
|
37
|
+
<option name="SOFT_MARGINS" value="80" />
|
|
38
|
+
<indentOptions>
|
|
39
|
+
<option name="INDENT_SIZE" value="2" />
|
|
40
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
41
|
+
<option name="TAB_SIZE" value="2" />
|
|
42
|
+
</indentOptions>
|
|
43
|
+
</codeStyleSettings>
|
|
44
|
+
<codeStyleSettings language="TypeScript">
|
|
45
|
+
<option name="SOFT_MARGINS" value="80" />
|
|
46
|
+
<indentOptions>
|
|
47
|
+
<option name="INDENT_SIZE" value="2" />
|
|
48
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
49
|
+
<option name="TAB_SIZE" value="2" />
|
|
50
|
+
</indentOptions>
|
|
51
|
+
</codeStyleSettings>
|
|
52
|
+
<codeStyleSettings language="Vue">
|
|
53
|
+
<option name="SOFT_MARGINS" value="80" />
|
|
54
|
+
<indentOptions>
|
|
55
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
56
|
+
</indentOptions>
|
|
57
|
+
</codeStyleSettings>
|
|
58
|
+
</code_scheme>
|
|
59
|
+
</component>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/250218_nodejs_core.iml" filepath="$PROJECT_DIR$/.idea/250218_nodejs_core.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
|
@@ -15,6 +15,7 @@ const entity_json_controller_1 = require("./controller/entity_json.controller");
|
|
|
15
15
|
const filter_module_1 = require("../filter/filter.module");
|
|
16
16
|
const utils_module_1 = require("../../utils/utils.module");
|
|
17
17
|
const entityJson_entity_1 = require("./entity/entityJson.entity");
|
|
18
|
+
const entityJson_repository_1 = require("./service/entityJson.repository");
|
|
18
19
|
let EntityJSONModule = class EntityJSONModule {
|
|
19
20
|
};
|
|
20
21
|
exports.EntityJSONModule = EntityJSONModule;
|
|
@@ -22,7 +23,7 @@ exports.EntityJSONModule = EntityJSONModule = __decorate([
|
|
|
22
23
|
(0, common_1.Module)({
|
|
23
24
|
imports: [entity_module_1.EntityModule, typeorm_1.TypeOrmModule.forFeature([entityJson_entity_1.EntityJson]), filter_module_1.FilterModule, utils_module_1.UtilsModule],
|
|
24
25
|
controllers: [entity_json_controller_1.EntityJSONController],
|
|
25
|
-
providers: [entity_json_service_1.EntityJSONService],
|
|
26
|
+
providers: [entity_json_service_1.EntityJSONService, entityJson_repository_1.EntityJSONRepository],
|
|
26
27
|
exports: [],
|
|
27
28
|
})
|
|
28
29
|
], EntityJSONModule);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity_json.module.js","sourceRoot":"","sources":["../../../src/module/entity_json/entity_json.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,yDAAqD;AACrD,6CAAgD;AAChD,uEAAkE;AAClE,gFAA2E;AAC3E,2DAAuD;AACvD,2DAAqD;AACrD,kEAAwD;
|
|
1
|
+
{"version":3,"file":"entity_json.module.js","sourceRoot":"","sources":["../../../src/module/entity_json/entity_json.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,yDAAqD;AACrD,6CAAgD;AAChD,uEAAkE;AAClE,gFAA2E;AAC3E,2DAAuD;AACvD,2DAAqD;AACrD,kEAAwD;AACxD,2EAAuE;AAQhE,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAAG,CAAA;AAAnB,4CAAgB;2BAAhB,gBAAgB;IAN5B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,4BAAY,EAAE,uBAAa,CAAC,UAAU,CAAC,CAAC,8BAAU,CAAC,CAAC,EAAC,4BAAY,EAAC,0BAAW,CAAC;QACxF,WAAW,EAAE,CAAC,6CAAoB,CAAC;QACnC,SAAS,EAAE,CAAC,uCAAiB,EAAC,4CAAoB,CAAC;QACnD,OAAO,EAAE,EAAE;KACZ,CAAC;GACW,gBAAgB,CAAG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Repository } from "typeorm";
|
|
2
|
+
import { EntityJson } from "../entity/entityJson.entity";
|
|
3
|
+
export declare class EntityJSONRepository {
|
|
4
|
+
private readonly entityJSONRepository;
|
|
5
|
+
constructor(entityJSONRepository: Repository<EntityJson>);
|
|
6
|
+
create(flatJson: Partial<EntityJson>): Promise<EntityJson | null>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.EntityJSONRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const entityJson_entity_1 = require("../entity/entityJson.entity");
|
|
20
|
+
let EntityJSONRepository = class EntityJSONRepository {
|
|
21
|
+
constructor(entityJSONRepository) {
|
|
22
|
+
this.entityJSONRepository = entityJSONRepository;
|
|
23
|
+
}
|
|
24
|
+
async create(flatJson) {
|
|
25
|
+
const { entity_type, entity_id } = flatJson;
|
|
26
|
+
const existing = await this.entityJSONRepository.findOne({
|
|
27
|
+
where: { entity_type, entity_id },
|
|
28
|
+
});
|
|
29
|
+
if (existing) {
|
|
30
|
+
await this.entityJSONRepository.update(existing.id, flatJson);
|
|
31
|
+
return this.entityJSONRepository.findOne({
|
|
32
|
+
where: { id: existing.id },
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const created = this.entityJSONRepository.create(flatJson);
|
|
36
|
+
return this.entityJSONRepository.save(created);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.EntityJSONRepository = EntityJSONRepository;
|
|
40
|
+
exports.EntityJSONRepository = EntityJSONRepository = __decorate([
|
|
41
|
+
(0, common_1.Injectable)(),
|
|
42
|
+
__param(0, (0, typeorm_1.InjectRepository)(entityJson_entity_1.EntityJson)),
|
|
43
|
+
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
44
|
+
], EntityJSONRepository);
|
|
45
|
+
//# sourceMappingURL=entityJson.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entityJson.repository.js","sourceRoot":"","sources":["../../../../src/module/entity_json/service/entityJson.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AACrC,mEAAyD;AAKlD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,YAEmB,oBAA4C;QAA5C,yBAAoB,GAApB,oBAAoB,CAAwB;IAC5D,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,QAA6B;QACxC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;QAG5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;YACvD,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE;SAClC,CAAC,CAAC;QAEH,IAAI,QAAQ,EAAE,CAAC;YAEb,MAAM,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;YAG9D,OAAO,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;gBACvC,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE;aAC3B,CAAC,CAAC;QACL,CAAC;QAGD,MAAM,OAAO,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACF,CAAA;AA5BY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,8BAAU,CAAC,CAAA;qCACU,oBAAU;GAHxC,oBAAoB,CA4BhC"}
|
|
@@ -3,11 +3,13 @@ import { AttributeMaster } from 'src/module/meta/entity/attribute-master.entity'
|
|
|
3
3
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
4
4
|
import { LoggingService } from 'src/utils/service/loggingUtil.service';
|
|
5
5
|
import { DataSource } from 'typeorm';
|
|
6
|
+
import { EntityJSONRepository } from './entityJson.repository';
|
|
6
7
|
export declare class EntityJSONService extends EntityServiceImpl {
|
|
7
8
|
private readonly dataSource;
|
|
8
9
|
private readonly filterService;
|
|
9
10
|
private readonly loggerService;
|
|
10
|
-
|
|
11
|
+
private readonly EntityJSONRepository;
|
|
12
|
+
constructor(dataSource: DataSource, filterService: FilterService, loggerService: LoggingService, EntityJSONRepository: EntityJSONRepository);
|
|
11
13
|
getAttributeForFlatJSON(entityType: string, loggedInUser: any, flag?: 'flat_json' | 'dropdown' | 'all'): Promise<any[] | Record<string, null> | {
|
|
12
14
|
flat_json: Record<string, null>;
|
|
13
15
|
attributes: {
|
|
@@ -18,12 +18,14 @@ const entity_relation_entity_1 = require("../../meta/entity/entity-relation.enti
|
|
|
18
18
|
const entity_service_impl_service_1 = require("../../meta/service/entity-service-impl.service");
|
|
19
19
|
const loggingUtil_service_1 = require("../../../utils/service/loggingUtil.service");
|
|
20
20
|
const typeorm_1 = require("typeorm");
|
|
21
|
+
const entityJson_repository_1 = require("./entityJson.repository");
|
|
21
22
|
let EntityJSONService = class EntityJSONService extends entity_service_impl_service_1.EntityServiceImpl {
|
|
22
|
-
constructor(dataSource, filterService, loggerService) {
|
|
23
|
+
constructor(dataSource, filterService, loggerService, EntityJSONRepository) {
|
|
23
24
|
super();
|
|
24
25
|
this.dataSource = dataSource;
|
|
25
26
|
this.filterService = filterService;
|
|
26
27
|
this.loggerService = loggerService;
|
|
28
|
+
this.EntityJSONRepository = EntityJSONRepository;
|
|
27
29
|
}
|
|
28
30
|
async getAttributeForFlatJSON(entityType, loggedInUser, flag) {
|
|
29
31
|
const orgId = loggedInUser.organization_id;
|
|
@@ -42,26 +44,16 @@ let EntityJSONService = class EntityJSONService extends entity_service_impl_serv
|
|
|
42
44
|
.select(['rel.target_entity_type'])
|
|
43
45
|
.where('rel.source_entity_type = :entityType', { entityType })
|
|
44
46
|
.andWhere('rel.organization_id = :orgId', { orgId })
|
|
45
|
-
.andWhere('rel.relation_type = :relationType', {
|
|
46
|
-
relationType: 'ONE_TO_ONE',
|
|
47
|
-
})
|
|
47
|
+
.andWhere('rel.relation_type = :relationType', { relationType: 'ONE_TO_ONE' })
|
|
48
48
|
.getRawMany();
|
|
49
|
-
const relatedTypesList = relatedEntityTypes.map(
|
|
49
|
+
const relatedTypesList = relatedEntityTypes.map(x => x.rel_target_entity_type);
|
|
50
50
|
await this.loggerService.log('debug', 'EntityJSONService', 'getAttributeForFlatJSON', `Found ${relatedTypesList.length} ONE-TO-ONE related entity types`);
|
|
51
51
|
const relatedAttributes = relatedTypesList.length
|
|
52
52
|
? await this.dataSource
|
|
53
53
|
.getRepository(attribute_master_entity_1.AttributeMaster)
|
|
54
54
|
.createQueryBuilder('attr')
|
|
55
|
-
.select([
|
|
56
|
-
'attr.
|
|
57
|
-
'attr.name',
|
|
58
|
-
'attr.flat_json_key',
|
|
59
|
-
'attr.mapped_entity_type',
|
|
60
|
-
'attr.attribute_key',
|
|
61
|
-
])
|
|
62
|
-
.where('attr.mapped_entity_type IN (:...types)', {
|
|
63
|
-
types: relatedTypesList,
|
|
64
|
-
})
|
|
55
|
+
.select(['attr.id', 'attr.name', 'attr.flat_json_key', 'attr.mapped_entity_type', 'attr.attribute_key'])
|
|
56
|
+
.where('attr.mapped_entity_type IN (:...types)', { types: relatedTypesList })
|
|
65
57
|
.andWhere('attr.organization_id = :orgId', { orgId })
|
|
66
58
|
.getMany()
|
|
67
59
|
: [];
|
|
@@ -71,45 +63,34 @@ let EntityJSONService = class EntityJSONService extends entity_service_impl_serv
|
|
|
71
63
|
.createQueryBuilder('fla')
|
|
72
64
|
.innerJoin(attribute_master_entity_1.AttributeMaster, 'attr', 'fla.applicable_entity_type = attr.mapped_entity_type AND fla.applicable_attribute_key = attr.attribute_key')
|
|
73
65
|
.select([
|
|
74
|
-
'fla.applicable_entity_type',
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'
|
|
66
|
+
'fla.applicable_entity_type AS applicable_entity_type',
|
|
67
|
+
'fla.applicable_attribute_key AS applicable_attribute_key',
|
|
68
|
+
'fla.attribute_key AS target_attribute_key',
|
|
69
|
+
'fla.saved_filter_code AS saved_filter_code',
|
|
70
|
+
'attr.name AS name',
|
|
71
|
+
'attr.id AS id',
|
|
78
72
|
])
|
|
79
73
|
.where('attr.organization_id = :orgId', { orgId })
|
|
80
74
|
.getRawMany();
|
|
81
75
|
await this.loggerService.log('debug', 'EntityJSONService', 'getAttributeForFlatJSON', `Loaded ${linkedAttributes.length} linked attributes`);
|
|
82
76
|
if (flag === 'flat_json' || flag === 'all') {
|
|
83
77
|
const result = {};
|
|
84
|
-
mainAttributes.forEach(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
92
|
-
linkedAttributes.forEach((link) => {
|
|
93
|
-
if (link.applicable_attribute_key)
|
|
94
|
-
result[link.applicable_attribute_key] = null;
|
|
95
|
-
});
|
|
96
|
-
if (flag === 'all')
|
|
78
|
+
mainAttributes.forEach(attr => { if (attr.flat_json_key)
|
|
79
|
+
result[attr.flat_json_key] = null; });
|
|
80
|
+
relatedAttributes.forEach(attr => { if (attr.flat_json_key)
|
|
81
|
+
result[attr.flat_json_key] = null; });
|
|
82
|
+
linkedAttributes.forEach(link => { if (link.target_attribute_key)
|
|
83
|
+
result[link.target_attribute_key] = null; });
|
|
84
|
+
if (flag === 'all') {
|
|
97
85
|
return { flat_json: result, attributes: { mainAttributes, relatedAttributes, linkedAttributes } };
|
|
86
|
+
}
|
|
98
87
|
return result;
|
|
99
88
|
}
|
|
100
89
|
const dropdown = [];
|
|
101
|
-
dropdown.push(...mainAttributes.map(
|
|
102
|
-
dropdown.push(...relatedAttributes.map(
|
|
103
|
-
label: a.name,
|
|
104
|
-
value: a.flat_json_key,
|
|
105
|
-
})));
|
|
90
|
+
dropdown.push(...mainAttributes.map(a => ({ label: a.name, value: a.flat_json_key })));
|
|
91
|
+
dropdown.push(...relatedAttributes.map(a => ({ label: a.name, value: a.flat_json_key })));
|
|
106
92
|
if (linkedAttributes.length > 0) {
|
|
107
|
-
dropdown.push({
|
|
108
|
-
...linkedAttributes.map((a) => ({
|
|
109
|
-
label: a.name,
|
|
110
|
-
value: a.attribute_key,
|
|
111
|
-
})),
|
|
112
|
-
});
|
|
93
|
+
dropdown.push(...linkedAttributes.map(a => ({ label: a.name, value: a.attribute_key })));
|
|
113
94
|
}
|
|
114
95
|
return dropdown;
|
|
115
96
|
}
|
|
@@ -130,10 +111,8 @@ let EntityJSONService = class EntityJSONService extends entity_service_impl_serv
|
|
|
130
111
|
};
|
|
131
112
|
const attrMap = {};
|
|
132
113
|
const allAttrs = [...safeAttributes.mainAttributes, ...safeAttributes.relatedAttributes];
|
|
133
|
-
allAttrs.forEach(attr => {
|
|
134
|
-
|
|
135
|
-
attrMap[attr.attribute_key] = attr.flat_json_key || attr.attribute_key;
|
|
136
|
-
});
|
|
114
|
+
allAttrs.forEach(attr => { if (attr.attribute_key)
|
|
115
|
+
attrMap[attr.attribute_key] = attr.flat_json_key || attr.attribute_key; });
|
|
137
116
|
const mainData = await this.getResolvedEntityData(entityType, entityId, loggedInUser);
|
|
138
117
|
this.mergeEntityDataIntoFlatJson(flatJson, mainData, attrMap);
|
|
139
118
|
const relations = await this.dataSource
|
|
@@ -149,19 +128,25 @@ let EntityJSONService = class EntityJSONService extends entity_service_impl_serv
|
|
|
149
128
|
this.mergeEntityDataIntoFlatJson(flatJson, relatedData, attrMap);
|
|
150
129
|
}
|
|
151
130
|
for (const linkAttr of safeAttributes.linkedAttributes) {
|
|
152
|
-
|
|
131
|
+
const childEntityType = linkAttr.applicable_entity_type;
|
|
132
|
+
const sourceKey = linkAttr.applicable_attribute_key;
|
|
133
|
+
const targetKey = linkAttr.target_attribute_key;
|
|
134
|
+
if (!childEntityType || !sourceKey || !targetKey)
|
|
153
135
|
continue;
|
|
154
|
-
const mappingValue = mainData?.[
|
|
155
|
-
const value = await this.applyLinkedFilterUsingSavedFilter(
|
|
136
|
+
const mappingValue = mainData?.[sourceKey] ?? null;
|
|
137
|
+
const value = await this.applyLinkedFilterUsingSavedFilter(childEntityType, linkAttr.saved_filter_code, sourceKey, mappingValue, targetKey, loggedInUser, entityId);
|
|
156
138
|
if (value !== null && value !== undefined) {
|
|
157
|
-
|
|
158
|
-
|| (linkAttr.target_attribute_key || linkAttr.applicable_attribute_key);
|
|
159
|
-
flatJson[flatKey] = value;
|
|
139
|
+
flatJson[targetKey] = value;
|
|
160
140
|
}
|
|
161
141
|
}
|
|
162
|
-
await this.
|
|
163
|
-
|
|
164
|
-
|
|
142
|
+
await this.loggerService.log('info', 'EntityJSONService', 'updateEntityJSON', `Saving flat JSON for entity: ${entityType}#${entityId}`);
|
|
143
|
+
let JsonData = {
|
|
144
|
+
entity_type: entityType,
|
|
145
|
+
entity_id: entityId,
|
|
146
|
+
json_data: flatJson,
|
|
147
|
+
created_by: loggedInUser.id,
|
|
148
|
+
};
|
|
149
|
+
await this.EntityJSONRepository.create(JsonData);
|
|
165
150
|
return flatJson;
|
|
166
151
|
}
|
|
167
152
|
mergeEntityDataIntoFlatJson(flatJson, entityData, attrMap) {
|
|
@@ -178,8 +163,7 @@ let EntityJSONService = class EntityJSONService extends entity_service_impl_serv
|
|
|
178
163
|
}
|
|
179
164
|
}
|
|
180
165
|
async applyLinkedFilterUsingSavedFilter(childEntityType, savedFilterCode, childFilterAttribute, mappingValue, targetAttribute, loggedInUser, entity_id) {
|
|
181
|
-
if (!savedFilterCode &&
|
|
182
|
-
(mappingValue === null || mappingValue === undefined))
|
|
166
|
+
if (!savedFilterCode && (mappingValue === null || mappingValue === undefined))
|
|
183
167
|
return null;
|
|
184
168
|
const dto = {
|
|
185
169
|
entity_type: childEntityType,
|
|
@@ -188,27 +172,17 @@ let EntityJSONService = class EntityJSONService extends entity_service_impl_serv
|
|
|
188
172
|
page: 1,
|
|
189
173
|
size: 1,
|
|
190
174
|
};
|
|
191
|
-
if (mappingValue !== null &&
|
|
192
|
-
mappingValue !== undefined &&
|
|
193
|
-
mappingValue !== '') {
|
|
175
|
+
if (mappingValue !== null && mappingValue !== undefined && mappingValue !== '') {
|
|
194
176
|
dto.quickFilter = [
|
|
195
|
-
{
|
|
196
|
-
filter_attribute: childFilterAttribute,
|
|
197
|
-
filter_operator: 'equal',
|
|
198
|
-
filter_value: mappingValue,
|
|
199
|
-
},
|
|
177
|
+
{ filter_attribute: childFilterAttribute, filter_operator: 'equal', filter_value: mappingValue },
|
|
200
178
|
];
|
|
201
179
|
}
|
|
202
180
|
dto.quickFilter = [
|
|
203
|
-
{
|
|
204
|
-
filter_attribute: 'parent_id',
|
|
205
|
-
filter_operator: 'equal',
|
|
206
|
-
filter_value: entity_id,
|
|
207
|
-
},
|
|
181
|
+
{ filter_attribute: 'parent_id', filter_operator: 'equal', filter_value: [entity_id] },
|
|
208
182
|
];
|
|
209
183
|
const result = await this.filterService.applyFilter(dto);
|
|
210
184
|
const rows = result?.data?.entity_list || [];
|
|
211
|
-
return rows.length ? (rows[0][
|
|
185
|
+
return rows.length ? (rows[0][childFilterAttribute] ?? null) : null;
|
|
212
186
|
}
|
|
213
187
|
};
|
|
214
188
|
exports.EntityJSONService = EntityJSONService;
|
|
@@ -216,6 +190,7 @@ exports.EntityJSONService = EntityJSONService = __decorate([
|
|
|
216
190
|
(0, common_1.Injectable)(),
|
|
217
191
|
__metadata("design:paramtypes", [typeorm_1.DataSource,
|
|
218
192
|
filter_service_1.FilterService,
|
|
219
|
-
loggingUtil_service_1.LoggingService
|
|
193
|
+
loggingUtil_service_1.LoggingService,
|
|
194
|
+
entityJson_repository_1.EntityJSONRepository])
|
|
220
195
|
], EntityJSONService);
|
|
221
196
|
//# sourceMappingURL=entity_json.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity_json.service.js","sourceRoot":"","sources":["../../../../src/module/entity_json/service/entity_json.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,wEAAyE;AACzE,oGAA+F;AAC/F,uFAAiF;AACjF,qFAA+E;AAC/E,gGAAwF;AACxF,oFAAuE;AACvE,qCAAqC;
|
|
1
|
+
{"version":3,"file":"entity_json.service.js","sourceRoot":"","sources":["../../../../src/module/entity_json/service/entity_json.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,wEAAyE;AACzE,oGAA+F;AAC/F,uFAAiF;AACjF,qFAA+E;AAC/E,gGAAwF;AACxF,oFAAuE;AACvE,qCAAqC;AACrC,mEAA+D;AAGxD,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,+CAAiB;IACtD,YACmB,UAAsB,EACtB,aAA4B,EAC5B,aAA6B,EAC7B,oBAAyC;QAE1D,KAAK,EAAE,CAAC;QALS,eAAU,GAAV,UAAU,CAAY;QACtB,kBAAa,GAAb,aAAa,CAAe;QAC5B,kBAAa,GAAb,aAAa,CAAgB;QAC7B,yBAAoB,GAApB,oBAAoB,CAAqB;IAG5D,CAAC;IAED,KAAK,CAAC,uBAAuB,CAC3B,UAAkB,EAClB,YAAiB,EACjB,IAAuC;QAEvC,MAAM,KAAK,GAAG,YAAY,CAAC,eAAe,CAAC;QAE3C,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,kCAAkC,UAAU,UAAU,KAAK,EAAE,CAAC,CAAC;QAEpJ,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,UAAU;aACzC,aAAa,CAAC,yCAAe,CAAC;aAC9B,kBAAkB,CAAC,MAAM,CAAC;aAC1B,MAAM,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;aAC5E,KAAK,CAAC,uCAAuC,EAAE,EAAE,UAAU,EAAE,CAAC;aAC9D,QAAQ,CAAC,+BAA+B,EAAE,EAAE,KAAK,EAAE,CAAC;aACpD,OAAO,EAAE,CAAC;QAE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;YACf,WAAW,EAAE,eAAe;YAC5B,YAAY;YACZ,eAAe;YACf,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,CAAC;SACR,CAAC;QAEF,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,KAAK,EAAE,EAAE,CAAC;YAC/E,GAAG,CAAC,WAAW,GAAG;gBAChB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE;aACjG,CAAC;QACJ,CAAC;QAED,GAAG,CAAC,WAAW,GAAG;YAChB,EAAE,gBAAgB,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,SAAS,CAAC,EAAE;SACvF,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACzD,MAAM,IAAI,GAAG,MAAM,EAAE,IAAI,EAAE,WAAW,IAAI,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACtE,CAAC;CACF,CAAA;AA9NY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAGoB,oBAAU;QACP,8BAAa;QACb,oCAAc;QACR,4CAAoB;GALjD,iBAAiB,CA8N7B"}
|
|
@@ -566,7 +566,7 @@ let FilterService = class FilterService {
|
|
|
566
566
|
}
|
|
567
567
|
buildDateCondition(attr, op, val, key) {
|
|
568
568
|
const dateColumn = `DATE(e.${attr})`;
|
|
569
|
-
const monthColumn = `
|
|
569
|
+
const monthColumn = `DATE_FORMAT(e.${attr}, '%Y-%m-01')`;
|
|
570
570
|
const numVal = Number(val);
|
|
571
571
|
switch (op) {
|
|
572
572
|
case 'equal':
|
|
@@ -604,12 +604,12 @@ let FilterService = class FilterService {
|
|
|
604
604
|
.startOf('month')
|
|
605
605
|
.format('YYYY-MM-DD');
|
|
606
606
|
return {
|
|
607
|
-
query: `${monthColumn} <
|
|
607
|
+
query: `${monthColumn} < DATE_FORMAT(:${key}, '%Y-%m-01')`,
|
|
608
608
|
params: { [key]: target },
|
|
609
609
|
};
|
|
610
610
|
}
|
|
611
611
|
return {
|
|
612
|
-
query: `${monthColumn} <
|
|
612
|
+
query: `${monthColumn} < DATE_FORMAT(:${key}, '%Y-%m-01')`,
|
|
613
613
|
params: { [key]: val },
|
|
614
614
|
};
|
|
615
615
|
case 'is_month_after':
|
|
@@ -619,31 +619,31 @@ let FilterService = class FilterService {
|
|
|
619
619
|
.startOf('month')
|
|
620
620
|
.format('YYYY-MM-DD');
|
|
621
621
|
return {
|
|
622
|
-
query: `${monthColumn} >
|
|
622
|
+
query: `${monthColumn} > DATE_FORMAT(:${key}, '%Y-%m-01')`,
|
|
623
623
|
params: { [key]: target },
|
|
624
624
|
};
|
|
625
625
|
}
|
|
626
626
|
return {
|
|
627
|
-
query: `${monthColumn} >
|
|
627
|
+
query: `${monthColumn} > DATE_FORMAT(:${key}, '%Y-%m-01')`,
|
|
628
628
|
params: { [key]: val },
|
|
629
629
|
};
|
|
630
630
|
case 'is_day_before':
|
|
631
631
|
if (isNaN(numVal))
|
|
632
632
|
throw new common_1.BadRequestException('Value must be a number for is_day_before');
|
|
633
|
+
const beforeDate = moment()
|
|
634
|
+
.subtract(numVal, 'days')
|
|
635
|
+
.format('YYYY-MM-DD');
|
|
633
636
|
return {
|
|
634
637
|
query: `${dateColumn} < :${key}`,
|
|
635
|
-
params: {
|
|
636
|
-
[key]: moment().subtract(numVal, 'days').format('YYYY-MM-DD'),
|
|
637
|
-
},
|
|
638
|
+
params: { [key]: beforeDate },
|
|
638
639
|
};
|
|
639
640
|
case 'is_day_after':
|
|
640
641
|
if (isNaN(numVal))
|
|
641
642
|
throw new common_1.BadRequestException('Value must be a number for is_day_after');
|
|
643
|
+
const afterDate = moment().add(numVal, 'days').format('YYYY-MM-DD');
|
|
642
644
|
return {
|
|
643
645
|
query: `${dateColumn} > :${key}`,
|
|
644
|
-
params: {
|
|
645
|
-
[key]: moment().add(numVal, 'days').format('YYYY-MM-DD'),
|
|
646
|
-
},
|
|
646
|
+
params: { [key]: afterDate },
|
|
647
647
|
};
|
|
648
648
|
case 'between': {
|
|
649
649
|
if (typeof val === 'string') {
|