rez_core 2.1.111 → 2.1.113
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/dist/app.module.js +2 -0
- package/dist/app.module.js.map +1 -1
- package/dist/core.module.js +6 -0
- package/dist/core.module.js.map +1 -1
- package/dist/module/listmaster/controller/list-master.controller.d.ts +0 -3
- package/dist/module/listmaster/controller/list-master.controller.js +0 -16
- package/dist/module/listmaster/controller/list-master.controller.js.map +1 -1
- package/dist/module/listmaster/service/list-master-item.service.d.ts +1 -2
- package/dist/module/listmaster/service/list-master-item.service.js +0 -41
- package/dist/module/listmaster/service/list-master-item.service.js.map +1 -1
- package/dist/module/master/controller/master.controller.d.ts +1 -1
- package/dist/module/master/service/master.service.d.ts +1 -1
- package/dist/module/master/service/master.service.js +2 -3
- package/dist/module/master/service/master.service.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.d.ts +2 -0
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/resolver/controller/resolver.controller.d.ts +8 -0
- package/dist/module/resolver/controller/resolver.controller.js +45 -0
- package/dist/module/resolver/controller/resolver.controller.js.map +1 -0
- package/dist/module/resolver/resolver.module.d.ts +2 -0
- package/dist/module/resolver/resolver.module.js +25 -0
- package/dist/module/resolver/resolver.module.js.map +1 -0
- package/dist/module/resolver/service/resolver.service.d.ts +8 -0
- package/dist/module/resolver/service/resolver.service.js +68 -0
- package/dist/module/resolver/service/resolver.service.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/app.module.ts +2 -0
- package/src/core.module.ts +6 -0
- package/src/module/listmaster/controller/list-master.controller.ts +16 -16
- package/src/module/listmaster/service/list-master-item.service.ts +62 -63
- package/src/module/master/service/master.service.ts +2 -3
- package/src/module/meta/service/entity-service-impl.service.ts +3 -2
- package/src/module/resolver/controller/resolver.controller.ts +35 -0
- package/src/module/resolver/resolver.module.ts +12 -0
- package/src/module/resolver/service/resolver.service.ts +84 -0
package/package.json
CHANGED
package/src/app.module.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { FilterModule } from './module/filter/filter.module';
|
|
|
14
14
|
import { LeadModule } from './module/lead/lead.module';
|
|
15
15
|
import { LayoutPreferenceModule } from './module/layout_preference/layout_preference.module';
|
|
16
16
|
import { WorkflowModule } from './module/workflow/workflow.module';
|
|
17
|
+
import { ResolverModule } from './module/resolver/resolver.module';
|
|
17
18
|
|
|
18
19
|
@Module({
|
|
19
20
|
imports: [
|
|
@@ -32,6 +33,7 @@ import { WorkflowModule } from './module/workflow/workflow.module';
|
|
|
32
33
|
LeadModule,
|
|
33
34
|
LayoutPreferenceModule,
|
|
34
35
|
WorkflowModule,
|
|
36
|
+
ResolverModule,
|
|
35
37
|
],
|
|
36
38
|
})
|
|
37
39
|
export class AppModule {}
|
package/src/core.module.ts
CHANGED
|
@@ -13,6 +13,8 @@ import { FilterModule } from './module/filter/filter.module';
|
|
|
13
13
|
import { AuthModule } from './module/auth/auth.module';
|
|
14
14
|
import { LeadModule } from './module/lead/lead.module';
|
|
15
15
|
import { LayoutPreferenceModule } from './module/layout_preference/layout_preference.module';
|
|
16
|
+
import { WorkflowModule } from './module/workflow/workflow.module';
|
|
17
|
+
import { ResolverModule } from './module/resolver/resolver.module';
|
|
16
18
|
|
|
17
19
|
@Global()
|
|
18
20
|
@Module({})
|
|
@@ -33,6 +35,8 @@ export class CoreModule {
|
|
|
33
35
|
AuthModule,
|
|
34
36
|
LeadModule,
|
|
35
37
|
LayoutPreferenceModule,
|
|
38
|
+
WorkflowModule,
|
|
39
|
+
ResolverModule,
|
|
36
40
|
];
|
|
37
41
|
|
|
38
42
|
const exportsArray = [
|
|
@@ -46,6 +50,8 @@ export class CoreModule {
|
|
|
46
50
|
FilterModule,
|
|
47
51
|
LeadModule,
|
|
48
52
|
LayoutPreferenceModule,
|
|
53
|
+
WorkflowModule,
|
|
54
|
+
ResolverModule,
|
|
49
55
|
];
|
|
50
56
|
|
|
51
57
|
if (isSso) {
|
|
@@ -50,23 +50,23 @@ export class ListMasterController {
|
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
@Post('/getResolvedListMasterItems/:type')
|
|
54
|
-
@UseGuards(JwtAuthGuard)
|
|
55
|
-
@HttpCode(HttpStatus.OK)
|
|
56
|
-
async getResolvedListMasterItems(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
) {
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
// @Post('/getResolvedListMasterItems/:type')
|
|
54
|
+
// @UseGuards(JwtAuthGuard)
|
|
55
|
+
// @HttpCode(HttpStatus.OK)
|
|
56
|
+
// async getResolvedListMasterItems(
|
|
57
|
+
// @Body() entityData: any,
|
|
58
|
+
// @Param('type') type: string,
|
|
59
|
+
// @Req() req: Request & { user: any },
|
|
60
|
+
// ) {
|
|
61
|
+
// const loggedInUser = req.user.userData;
|
|
62
|
+
// const entityType = type;
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
64
|
+
// return await this.listMasterItemService.getResolvedListMasterItems(
|
|
65
|
+
// loggedInUser,
|
|
66
|
+
// entityData,
|
|
67
|
+
// entityType,
|
|
68
|
+
// );
|
|
69
|
+
// }
|
|
70
70
|
|
|
71
71
|
@Get('/getListMasterItems/:type')
|
|
72
72
|
@UseGuards(JwtAuthGuard)
|
|
@@ -18,7 +18,7 @@ export class ListMasterItemService extends EntityServiceImpl {
|
|
|
18
18
|
private readonly listMasterRepo: ListMasterItemsRepository,
|
|
19
19
|
@Inject(forwardRef(() => EntityServiceImpl))
|
|
20
20
|
private readonly entityServiceImpl: EntityServiceImpl,
|
|
21
|
-
|
|
21
|
+
protected readonly attributeMasterService: AttributeMasterService,
|
|
22
22
|
) {
|
|
23
23
|
super();
|
|
24
24
|
}
|
|
@@ -213,66 +213,65 @@ export class ListMasterItemService extends EntityServiceImpl {
|
|
|
213
213
|
// return resolvedEntityData;
|
|
214
214
|
// }
|
|
215
215
|
|
|
216
|
-
async getResolvedListMasterItems(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
): Promise<any> {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
216
|
+
// async getResolvedListMasterItems(
|
|
217
|
+
// loggedInUser: UserData,
|
|
218
|
+
// entityData: any,
|
|
219
|
+
// entityType: string,
|
|
220
|
+
// ): Promise<any> {
|
|
221
|
+
// // const resolvedEntityData = super.getResolvedData(
|
|
222
|
+
// // loggedInUser,
|
|
223
|
+
// // entityData,
|
|
224
|
+
// // entityType,
|
|
225
|
+
// // );
|
|
226
|
+
// // const attributeItems =
|
|
227
|
+
// // await this.attributeMasterService.findAttributesByMappedEntityType(
|
|
228
|
+
// // entityType,
|
|
229
|
+
// // loggedInUser,
|
|
230
|
+
// // );
|
|
231
|
+
// // const resolvedEntityData = { ...entityData };
|
|
232
|
+
// // for (const attr of attributeItems) {
|
|
233
|
+
// // const field = attr.attribute_key;
|
|
234
|
+
// // const codeValue = entityData[field];
|
|
235
|
+
// // if (!codeValue) continue;
|
|
236
|
+
// // // ---------- ENTITY data_source_type ----------
|
|
237
|
+
// // if (attr.data_source_type === 'entity') {
|
|
238
|
+
// // if (Array.isArray(codeValue)) {
|
|
239
|
+
// // const resolvedValues: string[] = [];
|
|
240
|
+
// // for (const code of codeValue) {
|
|
241
|
+
// // const item = await super.getEntityData(
|
|
242
|
+
// // attr.datasource_list,
|
|
243
|
+
// // code,
|
|
244
|
+
// // loggedInUser,
|
|
245
|
+
// // );
|
|
246
|
+
// // resolvedValues.push(item?.[attr.data_source_attribute] ?? code);
|
|
247
|
+
// // }
|
|
248
|
+
// // resolvedEntityData[field] = resolvedValues;
|
|
249
|
+
// // } else {
|
|
250
|
+
// // const item = await super.getEntityData(
|
|
251
|
+
// // attr.datasource_list,
|
|
252
|
+
// // codeValue,
|
|
253
|
+
// // loggedInUser,
|
|
254
|
+
// // );
|
|
255
|
+
// // resolvedEntityData[field] =
|
|
256
|
+
// // item?.[attr.data_source_attribute] ?? codeValue;
|
|
257
|
+
// // }
|
|
258
|
+
// // }
|
|
259
|
+
// // // ---------- MASTER data_source_type ----------
|
|
260
|
+
// // else if (attr.data_source_type === 'master') {
|
|
261
|
+
// // if (Array.isArray(codeValue)) {
|
|
262
|
+
// // const resolvedValues: string[] = [];
|
|
263
|
+
// // for (const code of codeValue) {
|
|
264
|
+
// // const item = await this.listItemsRepo.findById(code);
|
|
265
|
+
// // resolvedValues.push(item?.[attr.data_source_attribute] ?? code);
|
|
266
|
+
// // }
|
|
267
|
+
// // resolvedEntityData[field] = resolvedValues;
|
|
268
|
+
// // } else {
|
|
269
|
+
// // const item = await this.listItemsRepo.findById(codeValue);
|
|
270
|
+
// // resolvedEntityData[field] =
|
|
271
|
+
// // item?.[attr.data_source_attribute] ?? codeValue;
|
|
272
|
+
// // }
|
|
273
|
+
// // }
|
|
274
|
+
// // }
|
|
275
|
+
// // return resolvedEntityData;
|
|
276
|
+
// }
|
|
278
277
|
}
|
|
@@ -161,9 +161,8 @@ export class MasterService {
|
|
|
161
161
|
const entityMasterData =
|
|
162
162
|
await this.entityMasterService.getEntityByTableName(table);
|
|
163
163
|
|
|
164
|
-
if (!entityMasterData
|
|
165
|
-
|
|
166
|
-
return;
|
|
164
|
+
if (!entityMasterData) {
|
|
165
|
+
throw new Error(`Entity master not found for table: ${table}`);
|
|
167
166
|
}
|
|
168
167
|
|
|
169
168
|
const attributes =
|
|
@@ -21,6 +21,8 @@ import {
|
|
|
21
21
|
} from '../../../constant/global.constant';
|
|
22
22
|
import { EntityValidationService } from './entity-validation.service';
|
|
23
23
|
import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
|
|
24
|
+
import { ListMasterItemService } from 'src/module/listmaster/service/list-master-item.service';
|
|
25
|
+
import { AttributeMasterService } from './attribute-master.service';
|
|
24
26
|
|
|
25
27
|
@Injectable()
|
|
26
28
|
export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
@@ -33,8 +35,7 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
33
35
|
@Inject() protected readonly loggingService: LoggingService;
|
|
34
36
|
@Inject()
|
|
35
37
|
protected readonly entityValidationService: EntityValidationService;
|
|
36
|
-
|
|
37
|
-
// private readonly listMasterService: ListMasterService;
|
|
38
|
+
protected readonly attributeMasterService: AttributeMasterService;
|
|
38
39
|
|
|
39
40
|
async createEntity(
|
|
40
41
|
entityData: BaseEntity,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
Controller,
|
|
4
|
+
HttpCode,
|
|
5
|
+
HttpStatus,
|
|
6
|
+
Param,
|
|
7
|
+
Post,
|
|
8
|
+
Req,
|
|
9
|
+
UseGuards,
|
|
10
|
+
} from '@nestjs/common';
|
|
11
|
+
import { ResolverService } from '../service/resolver.service';
|
|
12
|
+
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
13
|
+
|
|
14
|
+
@Controller()
|
|
15
|
+
export class ResolverController {
|
|
16
|
+
constructor(private readonly resolverService: ResolverService) {}
|
|
17
|
+
|
|
18
|
+
@Post('getResolvedData/:type')
|
|
19
|
+
@UseGuards(JwtAuthGuard)
|
|
20
|
+
@HttpCode(HttpStatus.OK)
|
|
21
|
+
async getResolvedListMasterItems(
|
|
22
|
+
@Body() entityData: any,
|
|
23
|
+
@Param('type') type: string,
|
|
24
|
+
@Req() req: Request & { user: any },
|
|
25
|
+
) {
|
|
26
|
+
const loggedInUser = req.user.userData;
|
|
27
|
+
const entityType = type;
|
|
28
|
+
|
|
29
|
+
return await this.resolverService.getResolvedData(
|
|
30
|
+
loggedInUser,
|
|
31
|
+
entityData,
|
|
32
|
+
entityType,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { ResolverService } from './service/resolver.service';
|
|
3
|
+
import { ResolverController } from './controller/resolver.controller';
|
|
4
|
+
import { EntityModule } from '../meta/entity.module';
|
|
5
|
+
|
|
6
|
+
@Module({
|
|
7
|
+
imports: [EntityModule],
|
|
8
|
+
controllers: [ResolverController],
|
|
9
|
+
providers: [ResolverService],
|
|
10
|
+
exports: [ResolverService],
|
|
11
|
+
})
|
|
12
|
+
export class ResolverModule {}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { DataSource } from 'typeorm';
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
4
|
+
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class ResolverService extends EntityServiceImpl {
|
|
8
|
+
constructor(private readonly dataSource: DataSource) {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async getResolvedData(
|
|
13
|
+
loggedInUser: UserData,
|
|
14
|
+
entityData: any,
|
|
15
|
+
entityType: string,
|
|
16
|
+
): Promise<any> {
|
|
17
|
+
const attributeItems = await this.dataSource.query(
|
|
18
|
+
`SELECT * FROM cr_attribute_master WHERE mapped_entity_type = ? AND organization_id = ?`,
|
|
19
|
+
[entityType, loggedInUser.organization_id],
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const resolvedEntityData = { ...entityData };
|
|
23
|
+
|
|
24
|
+
for (const attr of attributeItems) {
|
|
25
|
+
const field = attr.attribute_key;
|
|
26
|
+
const codeValue = entityData[field];
|
|
27
|
+
|
|
28
|
+
if (!codeValue) continue;
|
|
29
|
+
|
|
30
|
+
// -------- ENTITY data_source_type --------
|
|
31
|
+
if (attr.data_source_type === 'entity') {
|
|
32
|
+
if (Array.isArray(codeValue)) {
|
|
33
|
+
const resolvedValues: string[] = [];
|
|
34
|
+
|
|
35
|
+
for (const code of codeValue) {
|
|
36
|
+
const item = await super.getEntityData(
|
|
37
|
+
attr.datasource_list,
|
|
38
|
+
code,
|
|
39
|
+
loggedInUser,
|
|
40
|
+
);
|
|
41
|
+
resolvedValues.push(item?.[attr.data_source_attribute] ?? code);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
resolvedEntityData[field] = resolvedValues;
|
|
45
|
+
} else {
|
|
46
|
+
const item = await super.getEntityData(
|
|
47
|
+
attr.datasource_list,
|
|
48
|
+
codeValue,
|
|
49
|
+
loggedInUser,
|
|
50
|
+
);
|
|
51
|
+
resolvedEntityData[field] =
|
|
52
|
+
item?.[attr.data_source_attribute] ?? codeValue;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// -------- MASTER data_source_type --------
|
|
57
|
+
else if (attr.data_source_type === 'master') {
|
|
58
|
+
if (Array.isArray(codeValue)) {
|
|
59
|
+
const resolvedValues: string[] = [];
|
|
60
|
+
|
|
61
|
+
for (const code of codeValue) {
|
|
62
|
+
const [item] = await this.dataSource.query(
|
|
63
|
+
`SELECT * FROM cr_list_master_items WHERE id = ? AND organization_id = ?`,
|
|
64
|
+
[code, loggedInUser.organization_id],
|
|
65
|
+
);
|
|
66
|
+
resolvedValues.push(item?.[attr.data_source_attribute] ?? code);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
resolvedEntityData[field] = resolvedValues;
|
|
70
|
+
} else {
|
|
71
|
+
const [item] = await this.dataSource.query(
|
|
72
|
+
`SELECT * FROM cr_list_master_items WHERE id = ? AND organization_id = ?`,
|
|
73
|
+
[codeValue, loggedInUser.organization_id],
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
resolvedEntityData[field] =
|
|
77
|
+
item?.[attr.data_source_attribute] ?? codeValue;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return resolvedEntityData;
|
|
83
|
+
}
|
|
84
|
+
}
|