rez_core 5.0.70 → 5.0.72
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/filter/service/filter.service.js +2 -2
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/integration/service/wrapper.service.d.ts +3 -1
- package/dist/module/integration/service/wrapper.service.js +25 -3
- package/dist/module/integration/service/wrapper.service.js.map +1 -1
- package/dist/module/meta/service/entity-dynamic.service.d.ts +3 -1
- package/dist/module/meta/service/entity-dynamic.service.js +39 -20
- package/dist/module/meta/service/entity-dynamic.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/filter/service/filter.service.ts +2 -2
- package/src/module/integration/service/wrapper.service.ts +38 -1
- package/src/module/meta/service/entity-dynamic.service.ts +64 -28
package/package.json
CHANGED
|
@@ -982,7 +982,7 @@ export class FilterService {
|
|
|
982
982
|
})();
|
|
983
983
|
|
|
984
984
|
return {
|
|
985
|
-
query: `${dateColumn}
|
|
985
|
+
query: `${dateColumn} <= :${key}`,
|
|
986
986
|
params: { [key]: dayBefore },
|
|
987
987
|
};
|
|
988
988
|
|
|
@@ -1094,7 +1094,7 @@ export class FilterService {
|
|
|
1094
1094
|
const targetDate = subtractBusinessDays(numVal);
|
|
1095
1095
|
|
|
1096
1096
|
return {
|
|
1097
|
-
query: `${dateColumn}
|
|
1097
|
+
query: `${dateColumn} <= :${key}`,
|
|
1098
1098
|
params: { [key]: targetDate },
|
|
1099
1099
|
};
|
|
1100
1100
|
}
|
|
@@ -4,6 +4,8 @@ import { GenericMessageDto, IntegrationService } from './integration.service';
|
|
|
4
4
|
import { GoogleService } from './calendar-event.service';
|
|
5
5
|
import { IcsMeetingService } from 'src/module/ics/service/ics.service';
|
|
6
6
|
import { LoggingService } from 'src/utils/service/loggingUtil.service';
|
|
7
|
+
import { MediaDataService } from 'src/module/meta/service/media-data.service';
|
|
8
|
+
import axios from 'axios';
|
|
7
9
|
|
|
8
10
|
@Injectable()
|
|
9
11
|
export class WrapperService {
|
|
@@ -15,6 +17,7 @@ export class WrapperService {
|
|
|
15
17
|
private readonly googleService: GoogleService,
|
|
16
18
|
private readonly icsService: IcsMeetingService,
|
|
17
19
|
private readonly loggingService: LoggingService,
|
|
20
|
+
private readonly mediaService: MediaDataService,
|
|
18
21
|
) {}
|
|
19
22
|
|
|
20
23
|
/**
|
|
@@ -384,11 +387,45 @@ export class WrapperService {
|
|
|
384
387
|
user_id: loggedInUser.id,
|
|
385
388
|
entity_type: entity.entity_type,
|
|
386
389
|
entity_id: entity.entity_id,
|
|
387
|
-
attachments:
|
|
390
|
+
attachments: [],
|
|
388
391
|
mediaUrl: entity.mediaUrl,
|
|
389
392
|
organization_id: organization_id,
|
|
390
393
|
} as any;
|
|
391
394
|
|
|
395
|
+
// attachments: [1, 2, 3, 4]
|
|
396
|
+
|
|
397
|
+
if (entity.attachments && entity.attachments.length > 0) {
|
|
398
|
+
mailPayload.attachments = [];
|
|
399
|
+
|
|
400
|
+
for (const attachmentId of entity.attachments) {
|
|
401
|
+
// Step 1: Download or get media file
|
|
402
|
+
const url = await this.mediaService.getMediaDownloadUrl(
|
|
403
|
+
attachmentId,
|
|
404
|
+
{},
|
|
405
|
+
60000,
|
|
406
|
+
);
|
|
407
|
+
|
|
408
|
+
if (!url?.signedUrl) continue;
|
|
409
|
+
|
|
410
|
+
// Step 2: Fetch file content
|
|
411
|
+
const response = await axios.get(url.signedUrl, {
|
|
412
|
+
responseType: 'arraybuffer',
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
// Step 3: Convert to base64
|
|
416
|
+
const base64Content = Buffer.from(response.data).toString('base64');
|
|
417
|
+
|
|
418
|
+
// Step 4: Push formatted attachment
|
|
419
|
+
mailPayload.attachments.push({
|
|
420
|
+
content: base64Content,
|
|
421
|
+
type:
|
|
422
|
+
response.headers['content-type'] || 'application/octet-stream',
|
|
423
|
+
filename: `attachment-${attachmentId}`,
|
|
424
|
+
disposition: 'attachment',
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
392
429
|
this.loggingService.log(
|
|
393
430
|
'debug',
|
|
394
431
|
'wrapperService',
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
2
|
import { STATUS_ACTIVE } from 'src/constant/global.constant';
|
|
3
|
-
import { DataSource } from 'typeorm';
|
|
3
|
+
import { DataSource,In } from 'typeorm';
|
|
4
4
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
5
5
|
import { MediaDataService } from './media-data.service';
|
|
6
6
|
import { ResolverService } from './resolver.service';
|
|
7
7
|
import { ConfigService } from '@nestjs/config';
|
|
8
8
|
import { EntityMasterRepository } from '../repository/entity-master.repository';
|
|
9
|
+
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
9
10
|
|
|
10
11
|
@Injectable()
|
|
11
12
|
export class EntityDynamicService {
|
|
@@ -15,6 +16,7 @@ export class EntityDynamicService {
|
|
|
15
16
|
private readonly resolverService: ResolverService,
|
|
16
17
|
private readonly configService: ConfigService,
|
|
17
18
|
private readonly entityMasterRepo: EntityMasterRepository,
|
|
19
|
+
private readonly reflectionHelper: ReflectionHelper,
|
|
18
20
|
) {}
|
|
19
21
|
|
|
20
22
|
// -----------------------------
|
|
@@ -160,13 +162,22 @@ export class EntityDynamicService {
|
|
|
160
162
|
): Promise<any> {
|
|
161
163
|
const organizationId = loggedInUser.organization_id;
|
|
162
164
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
const repo = this.reflectionHelper.getRepoService('EntityRelation')
|
|
166
|
+
|
|
167
|
+
const getRelation = await repo.find({
|
|
168
|
+
where:{
|
|
169
|
+
organization_id:organizationId,
|
|
170
|
+
source_entity_type:entityType,
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
// const getRelation = await this.dataSource.query(
|
|
175
|
+
// `SELECT *
|
|
176
|
+
// FROM frm_entity_relation
|
|
177
|
+
// WHERE organization_id = $1
|
|
178
|
+
// AND source_entity_type = $2`,
|
|
179
|
+
// [organizationId, entityType],
|
|
180
|
+
// );
|
|
170
181
|
|
|
171
182
|
const { mappedEntities, ...mainData } = data;
|
|
172
183
|
|
|
@@ -204,19 +215,30 @@ export class EntityDynamicService {
|
|
|
204
215
|
mainID, // this will pass for parent_id
|
|
205
216
|
);
|
|
206
217
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
const relationRepo = this.reflectionHelper.getRepoService('EntityRelationData')
|
|
219
|
+
|
|
220
|
+
await relationRepo.save({
|
|
221
|
+
organizationId: organizationId,
|
|
222
|
+
source_entity_id: mainID,
|
|
223
|
+
source_entity_type: entityType,
|
|
224
|
+
target_entity_id: createdRelatedEntity.id,
|
|
225
|
+
targetEntityType: targetEntityType,
|
|
226
|
+
relation_type: relationType
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
// await this.dataSource.query(
|
|
230
|
+
// `INSERT INTO frm_entity_relation_data (organization_id, source_entity_id, source_entity_type,
|
|
231
|
+
// target_entity_id, target_entity_type, relation_type)
|
|
232
|
+
// VALUES ($1, $2, $3, $4, $5, $6)`,
|
|
233
|
+
// [
|
|
234
|
+
// organizationId,
|
|
235
|
+
// mainID,
|
|
236
|
+
// entityType,
|
|
237
|
+
// createdRelatedEntity.id,
|
|
238
|
+
// targetEntityType,
|
|
239
|
+
// relationType,
|
|
240
|
+
// ],
|
|
241
|
+
// );
|
|
220
242
|
}
|
|
221
243
|
}
|
|
222
244
|
}
|
|
@@ -241,14 +263,28 @@ export class EntityDynamicService {
|
|
|
241
263
|
id,
|
|
242
264
|
loggedInUser,
|
|
243
265
|
);
|
|
266
|
+
const relationRepo = this.reflectionHelper.getRepoService('EntityRelation');
|
|
267
|
+
const relatedEntityRepo = this.reflectionHelper.getRepoService('EntityRelationData');
|
|
244
268
|
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
)
|
|
269
|
+
const relations = await relationRepo.find({
|
|
270
|
+
where: {source_entity_type: entityType}
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
const targetTypes = relations.map(r=> r.target_entity_type)
|
|
274
|
+
|
|
275
|
+
if (targetTypes.length === 0) {
|
|
276
|
+
return {
|
|
277
|
+
entity_type: entityType,
|
|
278
|
+
...mainEntity,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const relatedEntities = await relatedEntityRepo.find({
|
|
283
|
+
where: {
|
|
284
|
+
source_entity_id: id,
|
|
285
|
+
target_entity_type: In(targetTypes),
|
|
286
|
+
},
|
|
287
|
+
});
|
|
252
288
|
|
|
253
289
|
// Format response to match create entity structure
|
|
254
290
|
const response: any = {
|