rez_core 3.1.153 → 3.1.155
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/module/listmaster/listmaster.module.js +8 -3
- package/dist/module/listmaster/listmaster.module.js.map +1 -1
- package/dist/module/listmaster/service/list-master-engine.d.ts +6 -0
- package/dist/module/listmaster/service/list-master-engine.js +35 -0
- package/dist/module/listmaster/service/list-master-engine.js.map +1 -0
- package/dist/module/listmaster/service/list-master-extension.interface.d.ts +3 -2
- package/dist/module/listmaster/service/list-master-extension.interface.js +0 -4
- package/dist/module/listmaster/service/list-master-extension.interface.js.map +1 -1
- package/dist/module/listmaster/service/list-master-registry.d.ts +6 -0
- package/dist/module/listmaster/service/list-master-registry.js +26 -0
- package/dist/module/listmaster/service/list-master-registry.js.map +1 -0
- package/dist/module/listmaster/service/list-master.service.d.ts +3 -3
- package/dist/module/listmaster/service/list-master.service.js +16 -16
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/listmaster/listmaster.module.ts +14 -6
- package/src/module/listmaster/service/list-master-engine.ts +19 -0
- package/src/module/listmaster/service/list-master-extension.interface.ts +3 -13
- package/src/module/listmaster/service/list-master-registry.ts +15 -0
- package/src/module/listmaster/service/list-master.service.ts +24 -40
package/package.json
CHANGED
|
@@ -5,12 +5,13 @@ import { ListMasterItems } from './entity/list-master-items.entity';
|
|
|
5
5
|
import { ListMasterRepository } from './repository/list-master.repository';
|
|
6
6
|
import { ListMasterItemsRepository } from './repository/list-master-items.repository';
|
|
7
7
|
import { ListMasterService } from './service/list-master.service';
|
|
8
|
+
import { ListMasterItemService } from './service/list-master-item.service';
|
|
8
9
|
import { EntityModule } from '../meta/entity.module';
|
|
9
10
|
import { ListMasterController } from './controller/list-master.controller';
|
|
10
11
|
import { ThirdPartyModule } from '../third-party-module/third-party.module';
|
|
11
12
|
import { HttpModule } from '@nestjs/axios';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
13
|
+
import { ListMasterRegistry } from './service/list-master-registry';
|
|
14
|
+
import { ListMasterEngine } from './service/list-master-engine';
|
|
14
15
|
|
|
15
16
|
@Module({
|
|
16
17
|
imports: [
|
|
@@ -20,17 +21,24 @@ import { ListMasterExtension } from './service/list-master-extension.interface';
|
|
|
20
21
|
HttpModule,
|
|
21
22
|
],
|
|
22
23
|
providers: [
|
|
23
|
-
{
|
|
24
|
-
{
|
|
24
|
+
{provide: 'ListMasterService', useClass: ListMasterService},
|
|
25
|
+
{provide: 'ListMasterItemService', useClass: ListMasterItemService},
|
|
25
26
|
ListMasterRepository,
|
|
26
27
|
ListMasterItemsRepository,
|
|
27
|
-
|
|
28
|
+
|
|
29
|
+
// Engine and registry
|
|
30
|
+
ListMasterRegistry,
|
|
31
|
+
ListMasterEngine,
|
|
32
|
+
|
|
33
|
+
// Provide LIST_MASTER_EXTENSIONS (empty array by default)
|
|
34
|
+
{ provide: 'LIST_MASTER_EXTENSIONS', useValue: [] },
|
|
28
35
|
],
|
|
29
36
|
controllers: [ListMasterController],
|
|
30
37
|
exports: [
|
|
31
38
|
'ListMasterService',
|
|
32
39
|
'ListMasterItemService',
|
|
33
|
-
|
|
40
|
+
ListMasterRegistry,
|
|
41
|
+
ListMasterEngine,
|
|
34
42
|
],
|
|
35
43
|
})
|
|
36
44
|
export class ListMasterModule {}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Injectable, Inject } from '@nestjs/common';
|
|
2
|
+
import { ListMasterExtension } from './list-master-extension.interface';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class ListMasterEngine {
|
|
6
|
+
private extensions = new Map<string, ListMasterExtension>();
|
|
7
|
+
|
|
8
|
+
constructor(
|
|
9
|
+
@Inject('LIST_MASTER_EXTENSIONS') extensions: ListMasterExtension[],
|
|
10
|
+
) {
|
|
11
|
+
extensions.forEach(ext => this.extensions.set(ext.name, ext));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async execute(name: string, payload: any) {
|
|
15
|
+
const ext = this.extensions.get(name) || this.extensions.get('GLOBAL');
|
|
16
|
+
if (!ext) throw new Error(`ListMaster extension not found: ${name}`);
|
|
17
|
+
return ext.fetchDropdown({ type: name, ...payload });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Called when list master appcode doesn't match
|
|
5
|
-
* @param type - list type
|
|
6
|
-
* @param params - filter params
|
|
7
|
-
* @param loggedInUser - current user
|
|
8
|
-
*/
|
|
9
|
-
abstract handleAppcodeMismatch(
|
|
10
|
-
type: string,
|
|
11
|
-
params: Record<string, any>,
|
|
12
|
-
loggedInUser: any,
|
|
13
|
-
): Promise<any>;
|
|
1
|
+
export interface ListMasterExtension {
|
|
2
|
+
name: string; // type identifier
|
|
3
|
+
fetchDropdown(payload: any): Promise<any>;
|
|
14
4
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { ListMasterExtension } from './list-master-extension.interface';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class ListMasterRegistry {
|
|
6
|
+
private actions = new Map<string, ListMasterExtension>();
|
|
7
|
+
|
|
8
|
+
register(action: ListMasterExtension) {
|
|
9
|
+
this.actions.set(action.name, action);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get(name: string): ListMasterExtension | undefined {
|
|
13
|
+
return this.actions.get(name);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -16,6 +16,7 @@ import { UserData } from 'src/module/user/entity/user.entity';
|
|
|
16
16
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
17
17
|
import { STATUS_ACTIVE, STATUS_INACTIVE } from 'src/constant/global.constant';
|
|
18
18
|
import { ListMasterExtension } from './list-master-extension.interface';
|
|
19
|
+
import { ListMasterEngine } from './list-master-engine';
|
|
19
20
|
|
|
20
21
|
@Injectable()
|
|
21
22
|
export class ListMasterService {
|
|
@@ -29,8 +30,7 @@ export class ListMasterService {
|
|
|
29
30
|
private readonly listItemsRepo: ListMasterItemsRepository,
|
|
30
31
|
private readonly apiRegistryService: ApiRegistryService,
|
|
31
32
|
private readonly httpService: HttpService,
|
|
32
|
-
|
|
33
|
-
private readonly listMasterExtension?: ListMasterExtension,
|
|
33
|
+
private readonly listMasterEngine: ListMasterEngine,
|
|
34
34
|
) {}
|
|
35
35
|
|
|
36
36
|
private readonly skipLevelFilterEntities = ['BRN'];
|
|
@@ -61,46 +61,28 @@ export class ListMasterService {
|
|
|
61
61
|
type,
|
|
62
62
|
loggedInUser?.organization_id,
|
|
63
63
|
);
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
if (!config) throw new NotFoundException(`Type ${type} not found`);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
) {
|
|
78
|
-
|
|
79
|
-
this.listMasterExtension &&
|
|
80
|
-
typeof this.listMasterExtension.handleAppcodeMismatch === 'function'
|
|
81
|
-
) {
|
|
82
|
-
// Call the override function
|
|
83
|
-
return this.listMasterExtension.handleAppcodeMismatch(
|
|
84
|
-
type,
|
|
85
|
-
params,
|
|
86
|
-
loggedInUser,
|
|
87
|
-
);
|
|
88
|
-
} else {
|
|
89
|
-
throw new BadRequestException(
|
|
90
|
-
`Appcode mismatch and no handler provided`,
|
|
91
|
-
);
|
|
92
|
-
}
|
|
66
|
+
|
|
67
|
+
// Check if a dynamic extension exists for this type
|
|
68
|
+
try {
|
|
69
|
+
const extensionResult = await this.listMasterEngine.execute(type, {
|
|
70
|
+
params,
|
|
71
|
+
inactiveIdsArray,
|
|
72
|
+
loggedInUser,
|
|
73
|
+
config,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
if (extensionResult !== undefined) return extensionResult;
|
|
77
|
+
} catch (err) {
|
|
78
|
+
console.warn(`No extension found for type ${type}, falling back to default logic`);
|
|
93
79
|
}
|
|
94
|
-
|
|
80
|
+
|
|
81
|
+
// Fallback to old logic if no extension exists
|
|
95
82
|
switch (config.source) {
|
|
96
83
|
case 'entity':
|
|
97
|
-
return this.fetchFromEntity(
|
|
98
|
-
|
|
99
|
-
params,
|
|
100
|
-
inactiveIdsArray,
|
|
101
|
-
loggedInUser,
|
|
102
|
-
);
|
|
103
|
-
|
|
84
|
+
return this.fetchFromEntity(type, params, inactiveIdsArray, loggedInUser);
|
|
85
|
+
|
|
104
86
|
case 'master':
|
|
105
87
|
return this.listItemsRepo.findItemsByType(
|
|
106
88
|
type,
|
|
@@ -109,19 +91,21 @@ export class ListMasterService {
|
|
|
109
91
|
loggedInUser?.organization_id,
|
|
110
92
|
params,
|
|
111
93
|
);
|
|
112
|
-
|
|
94
|
+
|
|
113
95
|
case 'operator':
|
|
114
96
|
return this.listItemsRepo.findOperatorsByType(
|
|
115
97
|
type,
|
|
116
98
|
loggedInUser?.organization_id,
|
|
117
99
|
);
|
|
100
|
+
|
|
118
101
|
case 'custom':
|
|
119
102
|
return this.fetchFromExternalSource(config.custom_source_id, params);
|
|
120
|
-
|
|
103
|
+
|
|
121
104
|
default:
|
|
122
105
|
throw new BadRequestException(`Unknown source: ${config.source}`);
|
|
123
106
|
}
|
|
124
107
|
}
|
|
108
|
+
|
|
125
109
|
|
|
126
110
|
private async fetchFromEntity(
|
|
127
111
|
sourceList: string,
|