rez_core 3.1.161 → 3.1.163

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "3.1.161",
3
+ "version": "3.1.163",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -50,6 +50,32 @@ export class ListMasterController {
50
50
  );
51
51
  }
52
52
 
53
+ // Public/internal endpoint (no JWT required)
54
+ @Get('/getDropdownDataPublic/:type')
55
+ @HttpCode(HttpStatus.OK)
56
+ async getDropdownDataPublic(
57
+ @Param('type') type: string,
58
+ @Query() queryParams: Record<string, string>,
59
+ ) {
60
+ const { inactiveIds,loggedInUser, ...params } = queryParams;
61
+
62
+ const inactiveIdsArray = inactiveIds
63
+ ? inactiveIds.split(',').map((id) => parseInt(id, 10))
64
+ : [];
65
+
66
+ // Default user object (if organization_id or appcode is needed in service)
67
+
68
+
69
+ return await this.service.getDropdownOptions(
70
+ type,
71
+ params,
72
+ inactiveIdsArray,
73
+ loggedInUser,
74
+ );
75
+ }
76
+
77
+
78
+
53
79
  @Get('/getDataSourceList/:source')
54
80
  @UseGuards(JwtAuthGuard)
55
81
  @HttpCode(HttpStatus.OK)
@@ -18,7 +18,8 @@ import { STATUS_ACTIVE, STATUS_INACTIVE } from 'src/constant/global.constant';
18
18
  import { ListMasterExtension } from './list-master-extension.interface';
19
19
  import { ListMasterEngine } from './list-master-engine';
20
20
  import { Action } from '../../workflow-automation/interface/action.interface';
21
-
21
+ import axios from 'axios';
22
+ import { ConfigService } from '@nestjs/config';
22
23
 
23
24
  @Injectable()
24
25
  export class ListMasterService {
@@ -33,19 +34,18 @@ export class ListMasterService {
33
34
  private readonly apiRegistryService: ApiRegistryService,
34
35
  private readonly httpService: HttpService,
35
36
  private readonly listMasterEngine: ListMasterEngine,
37
+ private readonly configService: ConfigService,
36
38
  ) {}
37
39
 
38
40
  private readonly skipLevelFilterEntities = ['BRN'];
39
41
  private readonly actions = new Map<string, Action>();
40
42
 
41
-
42
43
  registerAction(actionName: string, actionInstance: Action) {
43
44
  this.actions.set(actionName, actionInstance);
44
45
  console.log(
45
46
  `⚙️ [WorkflowAutomationEngine] Registered action: ${actionName}`,
46
47
  );
47
48
  }
48
-
49
49
 
50
50
  async getResolvedListCode(
51
51
  code: string,
@@ -73,29 +73,47 @@ export class ListMasterService {
73
73
  type,
74
74
  loggedInUser?.organization_id,
75
75
  );
76
-
77
- if (!config) throw new NotFoundException(`Type ${type} not found`);
78
-
79
- if (config.appcode!=loggedInUser?.appcode) {
80
-
81
- const impl = this.actions.get("LIST_MASTER")
82
76
 
77
+ if (!config) throw new NotFoundException(`Type ${type} not found`);
83
78
 
79
+ if (config.appcode != loggedInUser?.appcode) {
80
+ // Call internal API for appcode mismatch
81
+ try {
82
+ const baseUrl = this.configService.get<string>('REDIRECT_BE_URL');
83
+ const response = await axios.post(
84
+ `${baseUrl}/api/getDropdownDataPublic/${type}`,
85
+ {
86
+ inactiveIds: inactiveIdsArray?.join(',') || '',
87
+ loggedInUser: JSON.stringify(loggedInUser),
88
+ ...params,
89
+ },
90
+ {
91
+ headers: {
92
+ 'Content-Type': 'application/json',
93
+ },
94
+ },
95
+ );
84
96
 
85
- if(impl) {
86
- await impl.execute("HEY");
97
+ console.log('✅ Internal API response:', response.data);
98
+ return response.data;
99
+ } catch (error) {
100
+ console.error('⚠️ Internal API call failed:', error.message);
101
+ throw new BadRequestException(
102
+ `Failed to fetch dropdown for type ${type} from internal API`,
103
+ );
87
104
  }
88
-
89
-
90
-
91
105
  }
92
- // Check if a dynamic extension exists for this type
93
-
106
+
94
107
  // Fallback to old logic if no extension exists
95
108
  switch (config.source) {
96
109
  case 'entity':
97
- return this.fetchFromEntity(type, params, inactiveIdsArray, loggedInUser);
98
-
110
+ return this.fetchFromEntity(
111
+ type,
112
+ params,
113
+ inactiveIdsArray,
114
+ loggedInUser,
115
+ );
116
+
99
117
  case 'master':
100
118
  return this.listItemsRepo.findItemsByType(
101
119
  type,
@@ -104,21 +122,30 @@ export class ListMasterService {
104
122
  loggedInUser?.organization_id,
105
123
  params,
106
124
  );
107
-
125
+
108
126
  case 'operator':
109
127
  return this.listItemsRepo.findOperatorsByType(
110
128
  type,
111
129
  loggedInUser?.organization_id,
112
130
  );
113
-
131
+
114
132
  case 'custom':
115
- return this.fetchFromExternalSource(config.custom_source_id, params);
116
-
133
+ // If you want Axios call here too:
134
+ try {
135
+ const response = await axios.get(
136
+ `https://external-source.com/${config.custom_source_id}`,
137
+ { params },
138
+ );
139
+ return response.data;
140
+ } catch (error) {
141
+ console.error('⚠️ Custom source fetch failed:', error.message);
142
+ throw new BadRequestException('Failed to fetch custom source');
143
+ }
144
+
117
145
  default:
118
146
  throw new BadRequestException(`Unknown source: ${config.source}`);
119
147
  }
120
148
  }
121
-
122
149
 
123
150
  private async fetchFromEntity(
124
151
  sourceList: string,