rez_core 1.0.44 → 1.0.46
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/core.module.js +3 -0
- package/dist/core.module.js.map +1 -1
- package/dist/module/listmaster/controller/list-master.controller.d.ts +2 -10
- package/dist/module/listmaster/controller/list-master.controller.js +7 -5
- package/dist/module/listmaster/controller/list-master.controller.js.map +1 -1
- package/dist/module/listmaster/entity/list-master-items.entity.d.ts +1 -0
- package/dist/module/listmaster/entity/list-master-items.entity.js +4 -0
- package/dist/module/listmaster/entity/list-master-items.entity.js.map +1 -1
- package/dist/module/listmaster/entity/list-master.entity.d.ts +1 -0
- package/dist/module/listmaster/entity/list-master.entity.js +4 -0
- package/dist/module/listmaster/entity/list-master.entity.js.map +1 -1
- package/dist/module/listmaster/listmaster.module.js +3 -1
- package/dist/module/listmaster/listmaster.module.js.map +1 -1
- package/dist/module/listmaster/repository/list-master-items.repository.js +1 -1
- package/dist/module/listmaster/repository/list-master-items.repository.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.d.ts +9 -10
- package/dist/module/listmaster/service/list-master.service.js +49 -4
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/master/service/master.service.js.map +1 -1
- package/dist/module/meta/entity/view-master.entity.d.ts +1 -2
- package/dist/module/meta/entity/view-master.entity.js +2 -6
- package/dist/module/meta/entity/view-master.entity.js.map +1 -1
- package/dist/module/meta/entity.module.js +3 -1
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/service/update-form-json.service.d.ts +9 -0
- package/dist/module/meta/service/update-form-json.service.js +39 -0
- package/dist/module/meta/service/update-form-json.service.js.map +1 -0
- package/dist/module/third-party-module/entity/third-party-api-registry.entity.d.ts +5 -2
- package/dist/module/third-party-module/entity/third-party-api-registry.entity.js +14 -2
- package/dist/module/third-party-module/entity/third-party-api-registry.entity.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core.module.ts +4 -0
- package/src/module/listmaster/controller/list-master.controller.ts +8 -9
- package/src/module/listmaster/entity/list-master-items.entity.ts +3 -0
- package/src/module/listmaster/entity/list-master.entity.ts +3 -0
- package/src/module/listmaster/listmaster.module.ts +3 -1
- package/src/module/listmaster/repository/list-master-items.repository.ts +1 -1
- package/src/module/listmaster/service/list-master.service.ts +59 -3
- package/src/module/master/service/master.service.ts +2 -0
- package/src/module/meta/entity/view-master.entity.ts +2 -5
- package/src/module/meta/entity.module.ts +3 -1
- package/src/module/meta/service/update-form-json.service.ts +31 -0
- package/src/module/third-party-module/entity/third-party-api-registry.entity.ts +24 -15
package/package.json
CHANGED
package/src/core.module.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { EntityModule } from './module/meta/entity.module';
|
|
|
7
7
|
import { ModuleModule } from './module/module/module.module';
|
|
8
8
|
import { NotificationModule } from './module/notification/notification.module';
|
|
9
9
|
import { LayoutModule } from './module/layout/layout.module';
|
|
10
|
+
import { ListMasterModule } from './module/listmaster/listmaster.module';
|
|
10
11
|
|
|
11
12
|
@Global()
|
|
12
13
|
@Module({})
|
|
@@ -28,6 +29,7 @@ export class CoreModule {
|
|
|
28
29
|
ModuleModule,
|
|
29
30
|
NotificationModule,
|
|
30
31
|
LayoutModule,
|
|
32
|
+
ListMasterModule,
|
|
31
33
|
],
|
|
32
34
|
exports: [
|
|
33
35
|
ConfigModule,
|
|
@@ -39,6 +41,8 @@ export class CoreModule {
|
|
|
39
41
|
ModuleModule,
|
|
40
42
|
NotificationModule,
|
|
41
43
|
LayoutModule,
|
|
44
|
+
ListMasterModule,
|
|
45
|
+
|
|
42
46
|
],
|
|
43
47
|
};
|
|
44
48
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { Controller,
|
|
2
|
-
import { ListMasterService } from
|
|
1
|
+
import { Body, Controller, HttpCode, HttpStatus, Param, Post } from '@nestjs/common';
|
|
2
|
+
import { ListMasterService } from '../service/list-master.service';
|
|
3
3
|
|
|
4
|
-
@Controller(
|
|
4
|
+
@Controller('list-master')
|
|
5
5
|
export class ListMasterController {
|
|
6
|
-
|
|
7
6
|
constructor(private readonly service: ListMasterService) {}
|
|
8
7
|
|
|
9
|
-
@
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
@Post('/getDropdownData/:type')
|
|
9
|
+
@HttpCode(HttpStatus.OK)
|
|
10
|
+
async getDropdownData(@Param('type') type: string, @Body() params) {
|
|
11
|
+
return await this.service.getDropdownOptions(type, params);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
}
|
|
13
|
+
}
|
|
@@ -7,9 +7,11 @@ import { ListMasterItemsRepository } from './repository/list-master-items.reposi
|
|
|
7
7
|
import { ListMasterService } from './service/list-master.service';
|
|
8
8
|
import { EntityModule } from '../meta/entity.module';
|
|
9
9
|
import { ListMasterController } from './controller/list-master.controller';
|
|
10
|
+
import { ThirdPartyModule } from '../third-party-module/third-party.module';
|
|
11
|
+
import { HttpModule } from '@nestjs/axios';
|
|
10
12
|
|
|
11
13
|
@Module({
|
|
12
|
-
imports: [TypeOrmModule.forFeature([ListMasterData, ListMasterItems]),EntityModule],
|
|
14
|
+
imports: [TypeOrmModule.forFeature([ListMasterData, ListMasterItems]),EntityModule, ThirdPartyModule, HttpModule],
|
|
13
15
|
providers: [ListMasterRepository, ListMasterItemsRepository, ListMasterService],
|
|
14
16
|
controllers: [ListMasterController]
|
|
15
17
|
})
|
|
@@ -15,7 +15,7 @@ export class ListMasterItemsRepository{
|
|
|
15
15
|
where: { listtype: type, status: 'active' },
|
|
16
16
|
order: { sortindex: 'ASC' },
|
|
17
17
|
});
|
|
18
|
-
return items.map(i => ({ label: i.name, value: i.
|
|
18
|
+
return items.map(i => ({ label: i.name, value: i.value }));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
}
|
|
@@ -6,17 +6,22 @@ import {
|
|
|
6
6
|
} from '@nestjs/common';
|
|
7
7
|
import { ListMasterItemsRepository } from '../repository/list-master-items.repository';
|
|
8
8
|
import { ListMasterRepository } from '../repository/list-master.repository';
|
|
9
|
+
import { ApiRegistryService } from '../../third-party-module/service/api-registry.service';
|
|
10
|
+
import { firstValueFrom } from 'rxjs';
|
|
11
|
+
import { HttpService } from '@nestjs/axios';
|
|
9
12
|
|
|
10
13
|
@Injectable()
|
|
11
14
|
export class ListMasterService extends EntityServiceImpl {
|
|
12
15
|
constructor(
|
|
13
16
|
private readonly listMasterRepo: ListMasterRepository,
|
|
14
17
|
private readonly listItemsRepo: ListMasterItemsRepository,
|
|
18
|
+
private readonly apiRegistryService: ApiRegistryService,
|
|
19
|
+
private readonly httpService: HttpService,
|
|
15
20
|
) {
|
|
16
21
|
super();
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
async getDropdownOptions(type: string) {
|
|
24
|
+
async getDropdownOptions(type: string, params: Record<string, string>) {
|
|
20
25
|
const config = await this.listMasterRepo.findByType(type);
|
|
21
26
|
|
|
22
27
|
if (!config) throw new NotFoundException(`Type ${type} not found`);
|
|
@@ -29,8 +34,7 @@ export class ListMasterService extends EntityServiceImpl {
|
|
|
29
34
|
return this.listItemsRepo.findItemsByType(type);
|
|
30
35
|
|
|
31
36
|
case 'custom':
|
|
32
|
-
|
|
33
|
-
return { message: `Custom API for type ${type} not implemented` };
|
|
37
|
+
return this.fetchFromExternalSource(config.custom_source_id, params);
|
|
34
38
|
|
|
35
39
|
default:
|
|
36
40
|
throw new BadRequestException(`Unknown source: ${config.source}`);
|
|
@@ -55,4 +59,56 @@ export class ListMasterService extends EntityServiceImpl {
|
|
|
55
59
|
}
|
|
56
60
|
return result;
|
|
57
61
|
}
|
|
62
|
+
|
|
63
|
+
private async fetchFromExternalSource(
|
|
64
|
+
customSourceId: number,
|
|
65
|
+
params?: Record<string, string>,
|
|
66
|
+
) {
|
|
67
|
+
let apiRegistry = await this.apiRegistryService.findById(customSourceId);
|
|
68
|
+
if (!apiRegistry) return [];
|
|
69
|
+
|
|
70
|
+
const url = `${apiRegistry.base_url}${apiRegistry.endpoint}`;
|
|
71
|
+
const payload = this.injectDynamicParams(apiRegistry.request_payload_schema, params);
|
|
72
|
+
|
|
73
|
+
const response = await firstValueFrom(
|
|
74
|
+
this.httpService.request({
|
|
75
|
+
url,
|
|
76
|
+
method: apiRegistry.http_method || 'POST',
|
|
77
|
+
data: payload,
|
|
78
|
+
headers: apiRegistry.headers ? apiRegistry.headers : undefined,
|
|
79
|
+
}),
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const data = this.extractByPath(response.data, apiRegistry.response_data_path);
|
|
83
|
+
|
|
84
|
+
if (Array.isArray(data) && typeof data[0] === 'string') {
|
|
85
|
+
return data.map((item: string) => ({ label: item, value: item }));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return data.map((item: any) => ({
|
|
89
|
+
label: item[apiRegistry?.label],
|
|
90
|
+
value: item[apiRegistry?.value],
|
|
91
|
+
}));
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private injectDynamicParams(payload: any, params?: Record<string, string>): any {
|
|
96
|
+
if(params) {
|
|
97
|
+
const stringified = JSON.stringify(payload);
|
|
98
|
+
const replaced = stringified.replace(/{{(.*?)}}/g, (_, key) => params[key.trim()] || '');
|
|
99
|
+
return JSON.parse(replaced);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private extractByPath(obj: any, path: string): any {
|
|
104
|
+
if (!path || !obj) return obj;
|
|
105
|
+
|
|
106
|
+
return path.split('.').reduce((acc, key) => {
|
|
107
|
+
if (acc && typeof acc === 'object') {
|
|
108
|
+
return acc[key];
|
|
109
|
+
}
|
|
110
|
+
return undefined;
|
|
111
|
+
}, obj);
|
|
112
|
+
}
|
|
113
|
+
|
|
58
114
|
}
|
|
@@ -12,11 +12,8 @@ export class ViewMaster extends BaseEntity {
|
|
|
12
12
|
@Column({ length: 50, nullable: true })
|
|
13
13
|
mapped_entity_type: string;
|
|
14
14
|
|
|
15
|
-
@Column({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@Column({nullable: true})
|
|
19
|
-
section_information: string;
|
|
15
|
+
@Column({ length: 50, nullable: true })
|
|
16
|
+
identifier: string;
|
|
20
17
|
|
|
21
18
|
@Column({nullable: true})
|
|
22
19
|
description: string;
|
|
@@ -23,6 +23,7 @@ import { MediaData } from './entity/media-data.entity';
|
|
|
23
23
|
import { MediaDataService } from './service/media-data.service';
|
|
24
24
|
import { MediaDataRepository } from './repository/media-data.repository';
|
|
25
25
|
import { MediaController } from './controller/media.controller';
|
|
26
|
+
import { ViewMaster } from './entity/view-master.entity';
|
|
26
27
|
|
|
27
28
|
@Module({
|
|
28
29
|
imports: [
|
|
@@ -32,7 +33,8 @@ import { MediaController } from './controller/media.controller';
|
|
|
32
33
|
PreferenceMaster,
|
|
33
34
|
EntityTable,
|
|
34
35
|
EntityTableColumn,
|
|
35
|
-
MediaData
|
|
36
|
+
MediaData,
|
|
37
|
+
ViewMaster,
|
|
36
38
|
]),
|
|
37
39
|
UtilsModule,
|
|
38
40
|
],
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Injectable } from "@nestjs/common";
|
|
2
|
+
import { InjectRepository } from "@nestjs/typeorm";
|
|
3
|
+
import { ViewMaster } from "../entity/view-master.entity";
|
|
4
|
+
import { Repository } from "typeorm";
|
|
5
|
+
import { ClockIDGenService } from "src/utils/service/clockIDGenUtil.service";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class UpdateFormJsonService {
|
|
11
|
+
constructor(
|
|
12
|
+
@InjectRepository(ViewMaster)
|
|
13
|
+
private readonly viewMasterRepository: Repository<ViewMaster>,
|
|
14
|
+
private readonly clockIDGenService: ClockIDGenService,
|
|
15
|
+
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
async updateFormJson(body:any): Promise<ViewMaster> {
|
|
19
|
+
|
|
20
|
+
const entityType = this.clockIDGenService.idGenerator();
|
|
21
|
+
|
|
22
|
+
const newViewMasterRecord = ({})
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
return this.viewMasterRepository.save(newViewMasterRecord)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
}
|
|
@@ -5,39 +5,48 @@ export class ThirdPartyApiRegistry {
|
|
|
5
5
|
@PrimaryGeneratedColumn()
|
|
6
6
|
id: number;
|
|
7
7
|
|
|
8
|
-
@Column({nullable: true})
|
|
8
|
+
@Column({ nullable: true })
|
|
9
9
|
api_name: string;
|
|
10
10
|
|
|
11
|
-
@Column({nullable: true})
|
|
11
|
+
@Column({ nullable: true })
|
|
12
12
|
provider_name: string;
|
|
13
13
|
|
|
14
|
-
@Column({nullable: true})
|
|
14
|
+
@Column({ nullable: true })
|
|
15
15
|
base_url: string;
|
|
16
16
|
|
|
17
|
-
@Column({nullable: true})
|
|
17
|
+
@Column({ nullable: true })
|
|
18
18
|
endpoint: string;
|
|
19
19
|
|
|
20
|
-
@Column({nullable: true})
|
|
20
|
+
@Column({ nullable: true })
|
|
21
21
|
http_method: string;
|
|
22
22
|
|
|
23
|
-
@Column({type: 'json', nullable: true})
|
|
24
|
-
headers: string
|
|
23
|
+
@Column({ type: 'json', nullable: true })
|
|
24
|
+
headers: Record<string, string>;
|
|
25
25
|
|
|
26
|
-
@Column({nullable: true})
|
|
27
|
-
request_payload_schema: string
|
|
26
|
+
@Column({ nullable: true, type: 'json' })
|
|
27
|
+
request_payload_schema: Record<string, any>;
|
|
28
28
|
|
|
29
|
-
@Column({nullable: true})
|
|
29
|
+
@Column({ nullable: true })
|
|
30
|
+
response_data_path: string;
|
|
31
|
+
|
|
32
|
+
@Column({ nullable: true })
|
|
30
33
|
auth_type: string;
|
|
31
34
|
|
|
32
|
-
@Column({nullable: true, type: 'json'})
|
|
35
|
+
@Column({ nullable: true, type: 'json' })
|
|
33
36
|
auth_config: string;
|
|
34
37
|
|
|
35
|
-
@Column({nullable: true})
|
|
38
|
+
@Column({ nullable: true })
|
|
36
39
|
is_active: number;
|
|
37
40
|
|
|
38
|
-
@Column({nullable: true, type: 'datetime'})
|
|
39
|
-
created_date:
|
|
41
|
+
@Column({ nullable: true, type: 'datetime' })
|
|
42
|
+
created_date: Date;
|
|
40
43
|
|
|
41
|
-
@Column({nullable: true, type: 'datetime'})
|
|
44
|
+
@Column({ nullable: true, type: 'datetime' })
|
|
42
45
|
modified_date: Date;
|
|
46
|
+
|
|
47
|
+
@Column({ nullable: true})
|
|
48
|
+
label: string;
|
|
49
|
+
|
|
50
|
+
@Column({ nullable: true })
|
|
51
|
+
value: string;
|
|
43
52
|
}
|