rez_core 5.0.211 → 6.1.0
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/config/database.config.js +1 -1
- package/dist/config/database.config.js.map +1 -1
- package/dist/migrations/1732612800000-AddEntityJsonGinIndex.d.ts +6 -0
- package/dist/migrations/1732612800000-AddEntityJsonGinIndex.js +32 -0
- package/dist/migrations/1732612800000-AddEntityJsonGinIndex.js.map +1 -0
- package/dist/module/entity_json/controller/entity_json.controller.d.ts +2 -9
- package/dist/module/entity_json/controller/entity_json.controller.js.map +1 -1
- package/dist/module/entity_json/entity/entityJson.entity.d.ts +2 -1
- package/dist/module/entity_json/entity/entityJson.entity.js +5 -1
- package/dist/module/entity_json/entity/entityJson.entity.js.map +1 -1
- package/dist/module/entity_json/entity_json.module.js +7 -2
- package/dist/module/entity_json/entity_json.module.js.map +1 -1
- package/dist/module/entity_json/service/entity_json.service.d.ts +5 -12
- package/dist/module/entity_json/service/entity_json.service.js +111 -29
- package/dist/module/entity_json/service/entity_json.service.js.map +1 -1
- package/dist/module/filter/controller/filter.controller.d.ts +12 -0
- package/dist/module/filter/controller/filter.controller.js +1 -1
- package/dist/module/filter/controller/filter.controller.js.map +1 -1
- package/dist/module/filter/filter.module.js +11 -2
- package/dist/module/filter/filter.module.js.map +1 -1
- package/dist/module/filter/service/filter.service.d.ts +38 -2
- package/dist/module/filter/service/filter.service.js +42 -49
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/filter/service/flatjson-filter.service.d.ts +32 -0
- package/dist/module/filter/service/flatjson-filter.service.js +632 -0
- package/dist/module/filter/service/flatjson-filter.service.js.map +1 -0
- package/dist/module/filter/service/saved-filter.service.d.ts +3 -2
- package/dist/module/filter/service/saved-filter.service.js +14 -18
- package/dist/module/filter/service/saved-filter.service.js.map +1 -1
- package/dist/module/linked_attributes/controller/linked_attributes.controller.d.ts +19 -0
- package/dist/module/linked_attributes/controller/linked_attributes.controller.js +77 -0
- package/dist/module/linked_attributes/controller/linked_attributes.controller.js.map +1 -1
- package/dist/module/linked_attributes/dto/create-linked-attribute-smart.dto.d.ts +13 -0
- package/dist/module/linked_attributes/dto/create-linked-attribute-smart.dto.js +64 -0
- package/dist/module/linked_attributes/dto/create-linked-attribute-smart.dto.js.map +1 -0
- package/dist/module/linked_attributes/linked_attributes.module.js +4 -2
- package/dist/module/linked_attributes/linked_attributes.module.js.map +1 -1
- package/dist/module/linked_attributes/service/linked_attributes.service.d.ts +41 -1
- package/dist/module/linked_attributes/service/linked_attributes.service.js +265 -1
- package/dist/module/linked_attributes/service/linked_attributes.service.js.map +1 -1
- package/dist/module/meta/controller/attribute-master.controller.d.ts +3 -0
- package/dist/module/meta/controller/attribute-master.controller.js +12 -0
- package/dist/module/meta/controller/attribute-master.controller.js.map +1 -1
- package/dist/module/meta/entity.module.js +2 -2
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/service/attribute-master.service.d.ts +6 -1
- package/dist/module/meta/service/attribute-master.service.js +20 -2
- package/dist/module/meta/service/attribute-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-master.service.js +1 -0
- package/dist/module/meta/service/entity-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-relation.service.d.ts +4 -3
- package/dist/module/meta/service/entity-relation.service.js +10 -4
- package/dist/module/meta/service/entity-relation.service.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.d.ts +1 -1
- package/dist/module/meta/service/entity-service-impl.service.js +2 -2
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/meta/service/entity-table.service.d.ts +5 -4
- package/dist/module/meta/service/entity-table.service.js +45 -24
- package/dist/module/meta/service/entity-table.service.js.map +1 -1
- package/dist/module/meta/service/resolver.service.d.ts +1 -1
- package/dist/module/meta/service/resolver.service.js +6 -3
- package/dist/module/meta/service/resolver.service.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.js +2 -3
- package/dist/module/workflow-automation/service/workflow-automation.service.js.map +1 -1
- package/dist/table.config.d.ts +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/config/database.config.ts +1 -1
- package/src/migrations/1732612800000-AddEntityJsonGinIndex.ts +41 -0
- package/src/module/entity_json/controller/entity_json.controller.ts +13 -0
- package/src/module/entity_json/docs/FlatJson_Filterin_System.md +2804 -0
- package/src/module/entity_json/entity/entityJson.entity.ts +4 -1
- package/src/module/entity_json/entity_json.module.ts +9 -5
- package/src/module/entity_json/service/entity_json.service.ts +236 -49
- package/src/module/filter/controller/filter.controller.ts +4 -4
- package/src/module/filter/filter.module.ts +12 -3
- package/src/module/filter/service/filter.service.ts +130 -71
- package/src/module/filter/service/flatjson-filter.service.ts +903 -0
- package/src/module/filter/service/saved-filter.service.ts +16 -26
- package/src/module/filter/test/flatjson-filter.service.spec.ts +415 -0
- package/src/module/linked_attributes/controller/linked_attributes.controller.ts +85 -0
- package/src/module/linked_attributes/dto/create-linked-attribute-smart.dto.ts +54 -0
- package/src/module/linked_attributes/linked_attributes.module.ts +5 -3
- package/src/module/linked_attributes/service/linked_attributes.service.ts +545 -2
- package/src/module/linked_attributes/test/linked-attributes.service.spec.ts +244 -0
- package/src/module/meta/controller/attribute-master.controller.ts +12 -0
- package/src/module/meta/entity.module.ts +3 -3
- package/src/module/meta/service/attribute-master.service.ts +29 -1
- package/src/module/meta/service/entity-master.service.ts +1 -0
- package/src/module/meta/service/entity-relation.service.ts +10 -6
- package/src/module/meta/service/entity-service-impl.service.ts +2 -1
- package/src/module/meta/service/entity-table.service.ts +82 -68
- package/src/module/meta/service/entity.service.ts +0 -1
- package/src/module/meta/service/resolver.service.ts +7 -3
- package/src/module/workflow-automation/service/workflow-automation.service.ts +2 -4
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { Test, TestingModule } from '@nestjs/testing';
|
|
2
|
+
import { LinkedAttributesService } from '../service/linked_attributes.service';
|
|
3
|
+
import { DataSource } from 'typeorm';
|
|
4
|
+
import { EntityMasterService } from 'src/module/meta/service/entity-master.service';
|
|
5
|
+
import { AttributeMasterService } from 'src/module/meta/service/attribute-master.service';
|
|
6
|
+
import { SavedFilterService } from 'src/module/filter/service/saved-filter.service';
|
|
7
|
+
import { SavedFilterDetailRepository } from 'src/module/filter/repository/saved.filter-detail.repository';
|
|
8
|
+
import { EntityJSONService } from 'src/module/entity_json/service/entity_json.service';
|
|
9
|
+
|
|
10
|
+
describe('LinkedAttributesService - Phase 1 Tests', () => {
|
|
11
|
+
let service: LinkedAttributesService;
|
|
12
|
+
let dataSource: DataSource;
|
|
13
|
+
let entityMasterService: EntityMasterService;
|
|
14
|
+
let attributeMasterService: AttributeMasterService;
|
|
15
|
+
|
|
16
|
+
const mockDataSource = {
|
|
17
|
+
getRepository: jest.fn(),
|
|
18
|
+
transaction: jest.fn(),
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const mockEntityMasterService = {
|
|
22
|
+
getEntityData: jest.fn(),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const mockAttributeMasterService = {
|
|
26
|
+
findAttributesByMappedEntityType: jest.fn(),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const mockSavedFilterService = {
|
|
30
|
+
createEntity: jest.fn(),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const mockSavedFilterDetailRepository = {
|
|
34
|
+
findByMappedFilterCode: jest.fn(),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const mockEntityJSONService = {
|
|
38
|
+
updateEntityJSON: jest.fn(),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const mockLoggedInUser = {
|
|
42
|
+
id: 1,
|
|
43
|
+
organization_id: 100,
|
|
44
|
+
level_type: 'ORG',
|
|
45
|
+
level_id: 100,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
beforeEach(async () => {
|
|
49
|
+
const module: TestingModule = await Test.createTestingModule({
|
|
50
|
+
providers: [
|
|
51
|
+
LinkedAttributesService,
|
|
52
|
+
{ provide: DataSource, useValue: mockDataSource },
|
|
53
|
+
{ provide: EntityMasterService, useValue: mockEntityMasterService },
|
|
54
|
+
{
|
|
55
|
+
provide: AttributeMasterService,
|
|
56
|
+
useValue: mockAttributeMasterService,
|
|
57
|
+
},
|
|
58
|
+
{ provide: 'SavedFilterService', useValue: mockSavedFilterService },
|
|
59
|
+
{
|
|
60
|
+
provide: SavedFilterDetailRepository,
|
|
61
|
+
useValue: mockSavedFilterDetailRepository,
|
|
62
|
+
},
|
|
63
|
+
{ provide: EntityJSONService, useValue: mockEntityJSONService },
|
|
64
|
+
],
|
|
65
|
+
}).compile();
|
|
66
|
+
|
|
67
|
+
service = module.get<LinkedAttributesService>(LinkedAttributesService);
|
|
68
|
+
dataSource = module.get<DataSource>(DataSource);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
afterEach(() => {
|
|
72
|
+
jest.clearAllMocks();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('Task 1.1: generateAttributeKey', () => {
|
|
76
|
+
it('should generate correct attribute key format', () => {
|
|
77
|
+
const result = service.generateAttributeKey('LFMG', 'name', 1);
|
|
78
|
+
expect(result).toBe('LFMG__name__1');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should handle different sequences', () => {
|
|
82
|
+
expect(service.generateAttributeKey('LFMG', 'name', 1)).toBe(
|
|
83
|
+
'LFMG__name__1',
|
|
84
|
+
);
|
|
85
|
+
expect(service.generateAttributeKey('LFMG', 'name', 2)).toBe(
|
|
86
|
+
'LFMG__name__2',
|
|
87
|
+
);
|
|
88
|
+
expect(service.generateAttributeKey('LFMG', 'name', 99)).toBe(
|
|
89
|
+
'LFMG__name__99',
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should throw error for empty entity_type', () => {
|
|
94
|
+
expect(() => service.generateAttributeKey('', 'name', 1)).toThrow(
|
|
95
|
+
'applicable_entity_type is required and cannot be empty',
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('should throw error for empty attribute_key', () => {
|
|
100
|
+
expect(() => service.generateAttributeKey('LFMG', '', 1)).toThrow(
|
|
101
|
+
'applicable_attribute_key is required and cannot be empty',
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should throw error for invalid sequence', () => {
|
|
106
|
+
expect(() => service.generateAttributeKey('LFMG', 'name', 0)).toThrow(
|
|
107
|
+
'sequence must be a positive integer greater than 0',
|
|
108
|
+
);
|
|
109
|
+
expect(() => service.generateAttributeKey('LFMG', 'name', -1)).toThrow(
|
|
110
|
+
'sequence must be a positive integer greater than 0',
|
|
111
|
+
);
|
|
112
|
+
expect(() => service.generateAttributeKey('LFMG', 'name', 1.5)).toThrow(
|
|
113
|
+
'sequence must be a positive integer greater than 0',
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should trim whitespace from inputs', () => {
|
|
118
|
+
expect(() =>
|
|
119
|
+
service.generateAttributeKey(' ', 'name', 1),
|
|
120
|
+
).toThrow();
|
|
121
|
+
expect(() =>
|
|
122
|
+
service.generateAttributeKey('LFMG', ' ', 1),
|
|
123
|
+
).toThrow();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
describe('Task 1.2: Validation Engine', () => {
|
|
128
|
+
it('should validate required fields', async () => {
|
|
129
|
+
const payload = {
|
|
130
|
+
field_name: '',
|
|
131
|
+
mapped_entity_type: 'LEAD',
|
|
132
|
+
applicable_entity_type: 'LFMG',
|
|
133
|
+
applicable_attribute_key: 'name',
|
|
134
|
+
organization_id: 100,
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const result = await service.validateLinkedAttribute(
|
|
138
|
+
payload,
|
|
139
|
+
mockLoggedInUser,
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
expect(result.valid).toBe(false);
|
|
143
|
+
expect(result.errors).toContain(
|
|
144
|
+
"Required field 'field_name' is missing or empty",
|
|
145
|
+
);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('should validate entity type exists', async () => {
|
|
149
|
+
mockEntityMasterService.getEntityData.mockRejectedValue(
|
|
150
|
+
new Error('Not found'),
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
const payload = {
|
|
154
|
+
field_name: 'Father Name',
|
|
155
|
+
mapped_entity_type: 'INVALID',
|
|
156
|
+
applicable_entity_type: 'LFMG',
|
|
157
|
+
applicable_attribute_key: 'name',
|
|
158
|
+
organization_id: 100,
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const result = await service.validateLinkedAttribute(
|
|
162
|
+
payload,
|
|
163
|
+
mockLoggedInUser,
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
expect(result.valid).toBe(false);
|
|
167
|
+
expect(
|
|
168
|
+
result.errors.some((e) => e.includes('does not exist')),
|
|
169
|
+
).toBe(true);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('should pass validation for valid payload', async () => {
|
|
173
|
+
// Mock successful validations
|
|
174
|
+
mockEntityMasterService.getEntityData
|
|
175
|
+
.mockResolvedValueOnce({ id: 1 }) // mapped_entity_type
|
|
176
|
+
.mockResolvedValueOnce({ id: 2 }); // applicable_entity_type
|
|
177
|
+
|
|
178
|
+
mockAttributeMasterService.findAttributesByMappedEntityType.mockResolvedValue(
|
|
179
|
+
[{ attribute_key: 'name' }],
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
const mockRepository = {
|
|
183
|
+
createQueryBuilder: jest.fn().mockReturnValue({
|
|
184
|
+
where: jest.fn().mockReturnThis(),
|
|
185
|
+
andWhere: jest.fn().mockReturnThis(),
|
|
186
|
+
getOne: jest.fn().mockResolvedValue(null), // No duplicate
|
|
187
|
+
}),
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
mockDataSource.getRepository.mockReturnValue(mockRepository);
|
|
191
|
+
|
|
192
|
+
const payload = {
|
|
193
|
+
field_name: 'Father Name',
|
|
194
|
+
mapped_entity_type: 'LEAD',
|
|
195
|
+
applicable_entity_type: 'LFMG',
|
|
196
|
+
applicable_attribute_key: 'name',
|
|
197
|
+
organization_id: 100,
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const result = await service.validateLinkedAttribute(
|
|
201
|
+
payload,
|
|
202
|
+
mockLoggedInUser,
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
expect(result.valid).toBe(true);
|
|
206
|
+
expect(result.errors).toHaveLength(0);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
describe('Task 1.4: Smart Create Method', () => {
|
|
211
|
+
it('should throw BadRequestException on validation failure', async () => {
|
|
212
|
+
// Mock validation failure
|
|
213
|
+
mockEntityMasterService.getEntityData.mockRejectedValue(
|
|
214
|
+
new Error('Not found'),
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
const dto = {
|
|
218
|
+
field_name: 'Father Name',
|
|
219
|
+
mapped_entity_type: 'INVALID',
|
|
220
|
+
applicable_entity_type: 'LFMG',
|
|
221
|
+
applicable_attribute_key: 'name',
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
await expect(
|
|
225
|
+
service.createLinkedAttributeSmart(dto, mockLoggedInUser),
|
|
226
|
+
).rejects.toThrow();
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe('Integration Tests', () => {
|
|
231
|
+
it('should handle end-to-end attribute key generation', () => {
|
|
232
|
+
// Test the full flow: sequence 1, 2, 3
|
|
233
|
+
expect(service.generateAttributeKey('LFMG', 'name', 1)).toBe(
|
|
234
|
+
'LFMG__name__1',
|
|
235
|
+
);
|
|
236
|
+
expect(service.generateAttributeKey('LFMG', 'email', 1)).toBe(
|
|
237
|
+
'LFMG__email__1',
|
|
238
|
+
);
|
|
239
|
+
expect(service.generateAttributeKey('CONTACT', 'phone', 1)).toBe(
|
|
240
|
+
'CONTACT__phone__1',
|
|
241
|
+
);
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
});
|
|
@@ -81,4 +81,16 @@ export class AttributeMasterController {
|
|
|
81
81
|
loggedInUser,
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
|
+
|
|
85
|
+
@Get('getAll/:entityType')
|
|
86
|
+
async getAttributes(
|
|
87
|
+
@Param('entityType') entityType: string,
|
|
88
|
+
@Req() req: Request & { user: any },
|
|
89
|
+
) {
|
|
90
|
+
const loggedInUser = req.user.userData;
|
|
91
|
+
return await this.attributeMasterService.getAttributes(
|
|
92
|
+
entityType,
|
|
93
|
+
loggedInUser,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
84
96
|
}
|
|
@@ -77,13 +77,13 @@ import { EntityRelationRepository } from './repository/entity-relation.repositor
|
|
|
77
77
|
AppMaster,
|
|
78
78
|
EntityRelation,
|
|
79
79
|
EntityRelationData,
|
|
80
|
-
EntityUpdateService
|
|
81
80
|
]),
|
|
82
81
|
forwardRef(() => ListMasterModule),
|
|
83
82
|
forwardRef(() => FilterModule),
|
|
83
|
+
forwardRef(() => require('../entity_json/entity_json.module').EntityJSONModule),
|
|
84
84
|
UtilsModule,
|
|
85
|
-
WorkflowAutomationModule,
|
|
86
|
-
|
|
85
|
+
forwardRef(() => WorkflowAutomationModule),
|
|
86
|
+
|
|
87
87
|
],
|
|
88
88
|
providers: [
|
|
89
89
|
EntityMasterService,
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { forwardRef, Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import { AttributeMasterRepository } from '../repository/attribute-master.repository';
|
|
3
3
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
4
4
|
import { AttributeMaster } from '../entity/attribute-master.entity';
|
|
5
|
+
import { EntityMasterRepository } from '../repository/entity-master.repository';
|
|
6
|
+
import { EntityJSONService } from 'src/module/entity_json/service/entity_json.service';
|
|
5
7
|
|
|
6
8
|
@Injectable()
|
|
7
9
|
export class AttributeMasterService {
|
|
8
10
|
constructor(
|
|
9
11
|
private readonly attributeMasterRepository: AttributeMasterRepository,
|
|
12
|
+
@Inject(forwardRef(() => EntityMasterRepository))
|
|
13
|
+
private readonly entityMasterRepository: EntityMasterRepository,
|
|
14
|
+
@Inject(forwardRef(() => EntityJSONService))
|
|
15
|
+
private readonly entityJSONService: EntityJSONService,
|
|
10
16
|
) {
|
|
11
17
|
}
|
|
12
18
|
|
|
@@ -129,4 +135,26 @@ export class AttributeMasterService {
|
|
|
129
135
|
loggedInUser.enterprise_id
|
|
130
136
|
);
|
|
131
137
|
}
|
|
138
|
+
|
|
139
|
+
async getAttributes(entityType: string, loggedInUser: any) {
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
const entityData = await this.entityMasterRepository.getEntityByMappedEntityType(
|
|
143
|
+
entityType,
|
|
144
|
+
loggedInUser.enterprise_id,
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
if (entityData && entityData.is_flag_json) {
|
|
148
|
+
return this.entityJSONService.getAttributeForFlatJSON(
|
|
149
|
+
entityType,
|
|
150
|
+
loggedInUser,
|
|
151
|
+
'filter_attribute',
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return await this.findAttributesByMappedEntityType(
|
|
156
|
+
entityType,
|
|
157
|
+
loggedInUser,
|
|
158
|
+
);
|
|
159
|
+
}
|
|
132
160
|
}
|
|
@@ -17,6 +17,7 @@ export class EntityMasterService {
|
|
|
17
17
|
private readonly dataSource: DataSource,
|
|
18
18
|
@Inject('ListMasterService')
|
|
19
19
|
private readonly listMasterService: ListMasterService,
|
|
20
|
+
@Inject(forwardRef(() => SavedFilterRepositoryService))
|
|
20
21
|
private readonly savedFilterRepoService: SavedFilterRepositoryService,
|
|
21
22
|
) {}
|
|
22
23
|
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { Inject, Injectable, forwardRef } from '@nestjs/common';
|
|
2
2
|
import { EntityServiceImpl } from './entity-service-impl.service';
|
|
3
3
|
import { EntityMasterRepository } from '../repository/entity-master.repository';
|
|
4
|
+
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
4
5
|
import { EntityRelationRepository } from '../repository/entity-relation.repository';
|
|
5
6
|
|
|
6
7
|
@Injectable()
|
|
7
|
-
export class EntityRelationService
|
|
8
|
-
constructor(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export class EntityRelationService {
|
|
9
|
+
constructor(
|
|
10
|
+
@Inject(forwardRef(() => EntityMasterRepository))
|
|
11
|
+
private entityMasterRepo: EntityMasterRepository,
|
|
12
|
+
@Inject(forwardRef(() => ReflectionHelper))
|
|
13
|
+
private readonly reflectionHelper: ReflectionHelper,
|
|
14
|
+
private entityRelationRepository: EntityRelationRepository
|
|
15
|
+
) {}
|
|
12
16
|
|
|
13
17
|
async getEntityRelations(
|
|
14
18
|
entityType: string,
|
|
@@ -344,6 +344,7 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
344
344
|
entityType: string,
|
|
345
345
|
entityId: number,
|
|
346
346
|
loggedInUser: UserData,
|
|
347
|
+
format_disable?: boolean,
|
|
347
348
|
): Promise<any> {
|
|
348
349
|
const entityData = await this.entityMasterService.getEntityData(
|
|
349
350
|
entityType,
|
|
@@ -361,7 +362,7 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
361
362
|
}
|
|
362
363
|
const data = await repoService.findOne({ where: { id: entityId } });
|
|
363
364
|
|
|
364
|
-
return this.resolverService.getResolvedData(loggedInUser, data, entityType);
|
|
365
|
+
return this.resolverService.getResolvedData(loggedInUser, data, entityType,format_disable);
|
|
365
366
|
}
|
|
366
367
|
|
|
367
368
|
async getResolvedEntityDataByDataSource(
|
|
@@ -5,18 +5,22 @@ import { EntityTableDto } from '../dto/entity-table.dto';
|
|
|
5
5
|
import { DISPLAY_LIST } from '../../../constant/global.constant';
|
|
6
6
|
import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
|
|
7
7
|
import { SavedFilterRepositoryService } from 'src/module/filter/repository/saved-filter.repository';
|
|
8
|
+
import { AttributeMasterService } from './attribute-master.service';
|
|
8
9
|
|
|
9
10
|
@Injectable()
|
|
10
11
|
export class EntityTableService {
|
|
11
12
|
constructor(
|
|
12
13
|
private entityTableRepository: EntityTableRepository,
|
|
13
14
|
private readonly entityTableColumnRepository: EntityTableColumnRepository,
|
|
15
|
+
// private readonly entityJSONService: EntityJSONService,
|
|
14
16
|
|
|
15
17
|
@Inject(forwardRef(() => 'ListMasterService'))
|
|
16
18
|
@Inject('ListMasterService')
|
|
17
19
|
private readonly listMasterService: ListMasterService,
|
|
18
20
|
|
|
21
|
+
@Inject(forwardRef(() => SavedFilterRepositoryService))
|
|
19
22
|
private readonly savedFilterRepoService: SavedFilterRepositoryService,
|
|
23
|
+
private readonly attributeMasterService: AttributeMasterService,
|
|
20
24
|
) {}
|
|
21
25
|
|
|
22
26
|
async getEntityData(mappedEntityType: string | null, loggedInUser) {
|
|
@@ -79,77 +83,87 @@ export class EntityTableService {
|
|
|
79
83
|
displayType: string,
|
|
80
84
|
loggedInUser: any,
|
|
81
85
|
) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
let entityTableDto: any = {};
|
|
87
|
+
|
|
88
|
+
entityTableDto.column_list = [
|
|
89
|
+
{
|
|
90
|
+
name:'Code',
|
|
91
|
+
attribute_key:'code',
|
|
92
|
+
data_type:'text'
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name:'name',
|
|
96
|
+
attribute_key:'name',
|
|
97
|
+
data_type:'text'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name:'status',
|
|
101
|
+
attribute_key:'status',
|
|
102
|
+
data_type:'select'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name:'description',
|
|
106
|
+
attribute_key:'description',
|
|
107
|
+
data_type:'text'
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
entityTableDto.operation_list = {
|
|
112
|
+
text: await this.listMasterService.getDropdownOptions(
|
|
113
|
+
'OPT',
|
|
114
|
+
{},
|
|
115
|
+
[],
|
|
116
|
+
loggedInUser,
|
|
117
|
+
),
|
|
118
|
+
number: await this.listMasterService.getDropdownOptions(
|
|
119
|
+
'OPN',
|
|
120
|
+
{},
|
|
121
|
+
[],
|
|
122
|
+
loggedInUser,
|
|
123
|
+
),
|
|
124
|
+
date: await this.listMasterService.getDropdownOptions(
|
|
125
|
+
'OPD',
|
|
126
|
+
{},
|
|
127
|
+
[],
|
|
128
|
+
loggedInUser,
|
|
129
|
+
),
|
|
130
|
+
select: await this.listMasterService.getDropdownOptions(
|
|
131
|
+
'OPS',
|
|
132
|
+
{},
|
|
133
|
+
[],
|
|
134
|
+
loggedInUser,
|
|
135
|
+
),
|
|
136
|
+
multiselect: await this.listMasterService.getDropdownOptions(
|
|
137
|
+
'OPM',
|
|
138
|
+
{},
|
|
139
|
+
[],
|
|
140
|
+
loggedInUser,
|
|
141
|
+
),
|
|
142
|
+
year: await this.listMasterService.getDropdownOptions(
|
|
143
|
+
'OPY',
|
|
144
|
+
{},
|
|
145
|
+
[],
|
|
146
|
+
loggedInUser,
|
|
147
|
+
),
|
|
148
|
+
// Add any other operations you want to include
|
|
149
|
+
};
|
|
150
|
+
entityTableDto.default_filter =
|
|
151
|
+
await this.savedFilterRepoService.getDefaultFilterByEntityType(
|
|
152
|
+
entityType,
|
|
153
|
+
);
|
|
154
|
+
if (loggedInUser.id) {
|
|
155
|
+
entityTableDto.saved_filter =
|
|
156
|
+
await this.savedFilterRepoService.getSavedFiltersByUserIdAndEntityType(
|
|
157
|
+
loggedInUser.id,
|
|
158
|
+
entityType,
|
|
95
159
|
);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
[],
|
|
101
|
-
loggedInUser,
|
|
102
|
-
),
|
|
103
|
-
number: await this.listMasterService.getDropdownOptions(
|
|
104
|
-
'OPN',
|
|
105
|
-
{},
|
|
106
|
-
[],
|
|
107
|
-
loggedInUser,
|
|
108
|
-
),
|
|
109
|
-
date: await this.listMasterService.getDropdownOptions(
|
|
110
|
-
'OPD',
|
|
111
|
-
{},
|
|
112
|
-
[],
|
|
113
|
-
loggedInUser,
|
|
114
|
-
),
|
|
115
|
-
select: await this.listMasterService.getDropdownOptions(
|
|
116
|
-
'OPS',
|
|
117
|
-
{},
|
|
118
|
-
[],
|
|
119
|
-
loggedInUser,
|
|
120
|
-
),
|
|
121
|
-
multiselect: await this.listMasterService.getDropdownOptions(
|
|
122
|
-
'OPM',
|
|
123
|
-
{},
|
|
124
|
-
[],
|
|
125
|
-
loggedInUser,
|
|
126
|
-
),
|
|
127
|
-
year: await this.listMasterService.getDropdownOptions(
|
|
128
|
-
'OPY',
|
|
129
|
-
{},
|
|
130
|
-
[],
|
|
160
|
+
}
|
|
161
|
+
if (loggedInUser.id) {
|
|
162
|
+
entityTableDto.shared_filter =
|
|
163
|
+
await this.savedFilterRepoService.getSharedFiltersByLevelTypeAndLevelId(
|
|
131
164
|
loggedInUser,
|
|
132
|
-
|
|
133
|
-
// Add any other operations you want to include
|
|
134
|
-
};
|
|
135
|
-
entityTableDto.default_filter =
|
|
136
|
-
await this.savedFilterRepoService.getDefaultFilterByEntityType(
|
|
137
|
-
entityTable.list_type,
|
|
165
|
+
entityType,
|
|
138
166
|
);
|
|
139
|
-
if (loggedInUser.id) {
|
|
140
|
-
entityTableDto.saved_filter =
|
|
141
|
-
await this.savedFilterRepoService.getSavedFiltersByUserIdAndEntityType(
|
|
142
|
-
loggedInUser,
|
|
143
|
-
entityTable.list_type,
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
if (loggedInUser.id) {
|
|
147
|
-
entityTableDto.shared_filter =
|
|
148
|
-
await this.savedFilterRepoService.getSharedFiltersByLevelTypeAndLevelId(
|
|
149
|
-
loggedInUser,
|
|
150
|
-
entityTable.list_type,
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
167
|
}
|
|
154
168
|
|
|
155
169
|
return entityTableDto;
|
|
@@ -2,7 +2,6 @@ import { UserData } from '../../user/entity/user.entity';
|
|
|
2
2
|
import { BaseEntity } from '../entity/base-entity.entity';
|
|
3
3
|
import { EntityListData } from '../dto/entity-list-data.dto';
|
|
4
4
|
import { EntityManager } from 'typeorm';
|
|
5
|
-
import { FilterRequestDto } from '../../filter/dto/filter-request.dto';
|
|
6
5
|
|
|
7
6
|
export interface EntityService<T extends BaseEntity> {
|
|
8
7
|
createEntity(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Inject, Injectable } from '@nestjs/common';
|
|
1
|
+
import { Inject, Injectable, forwardRef } from '@nestjs/common';
|
|
2
2
|
import { UserData } from '../../user/entity/user.entity';
|
|
3
3
|
import * as moment from 'moment';
|
|
4
4
|
import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
|
|
@@ -17,7 +17,9 @@ export class ResolverService {
|
|
|
17
17
|
private readonly listMasterService: ListMasterService,
|
|
18
18
|
private readonly moduleRef: ModuleRef,
|
|
19
19
|
private readonly attributeMasterRepo: AttributeMasterRepository,
|
|
20
|
+
@Inject(forwardRef(() => ReflectionHelper))
|
|
20
21
|
private readonly reflectionHelper: ReflectionHelper,
|
|
22
|
+
@Inject(forwardRef(() => EntityMasterRepository))
|
|
21
23
|
private readonly entityMasterRepo: EntityMasterRepository,
|
|
22
24
|
private readonly entityManger: EntityManager,
|
|
23
25
|
) {}
|
|
@@ -36,6 +38,7 @@ export class ResolverService {
|
|
|
36
38
|
loggedInUser: any,
|
|
37
39
|
entityData: any,
|
|
38
40
|
entityType: string,
|
|
41
|
+
format_disable?: boolean,
|
|
39
42
|
): Promise<any> {
|
|
40
43
|
const attributeItems =
|
|
41
44
|
await this.attributeMasterRepo.findAttributesByMappedEntityType(
|
|
@@ -109,7 +112,7 @@ export class ResolverService {
|
|
|
109
112
|
// -------- DATE / DATETIME --------
|
|
110
113
|
else if (
|
|
111
114
|
attr.element_type === 'date' ||
|
|
112
|
-
attr.element_type === 'datetime'
|
|
115
|
+
(attr.element_type === 'datetime' && !format_disable)
|
|
113
116
|
) {
|
|
114
117
|
const dateFormat =
|
|
115
118
|
attr.element_type === 'date' ? 'DD-MM-YYYY' : 'DD-MM-YYYY HH:mm:ss';
|
|
@@ -128,7 +131,8 @@ export class ResolverService {
|
|
|
128
131
|
// --------UPLOAD / IMAGE --------
|
|
129
132
|
else if (
|
|
130
133
|
(attr.element_type === 'upload' || attr.element_type === 'image') &&
|
|
131
|
-
typeof resolvedEntityData[field] !== 'object'
|
|
134
|
+
typeof resolvedEntityData[field] !== 'object' &&
|
|
135
|
+
!format_disable
|
|
132
136
|
) {
|
|
133
137
|
const mediaService = await this.getMediaDataService();
|
|
134
138
|
const uploadData = await mediaService.getMediaDownloadUrl(
|
|
@@ -112,8 +112,7 @@ export class WorkflowAutomationService extends EntityServiceImpl {
|
|
|
112
112
|
this.logger.debug(
|
|
113
113
|
`Existing event filter found: ${workflow.condition_filter_code}`,
|
|
114
114
|
);
|
|
115
|
-
const existing = await this.savedFilterService.
|
|
116
|
-
ENTITYTYPE_SAVEDFILTERMASTER,
|
|
115
|
+
const existing = await this.savedFilterService.getSavedFilterByCode(
|
|
117
116
|
workflow.condition_filter_code,
|
|
118
117
|
loggedInUser,
|
|
119
118
|
);
|
|
@@ -259,8 +258,7 @@ export class WorkflowAutomationService extends EntityServiceImpl {
|
|
|
259
258
|
if (workflowAutomation.trigger_type === 'on_event') {
|
|
260
259
|
if (workflowAutomation.condition_filter_code) {
|
|
261
260
|
const eventFilterMaster: any =
|
|
262
|
-
await this.savedFilterService.
|
|
263
|
-
ENTITYTYPE_SAVEDFILTERMASTER,
|
|
261
|
+
await this.savedFilterService.getSavedFilterByCode(
|
|
264
262
|
workflowAutomation.condition_filter_code,
|
|
265
263
|
loggedInUser,
|
|
266
264
|
);
|