gemcap-be-common 1.3.91 → 1.3.92

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.
@@ -158,13 +158,13 @@ export type TProspectFiles = {
158
158
  };
159
159
  };
160
160
  export type TProspectAuditorFiles = Map<string, IProspectFile[]>;
161
- export interface IProspectFiles {
161
+ export interface IProspectFilesLegacy {
162
162
  files: TProspectFiles;
163
163
  auditorFiles: TProspectAuditorFiles;
164
164
  auditorSharedFiles: IProspectFile[];
165
165
  acceptedFiles: string[];
166
166
  }
167
- export interface IProspect extends IProspectBase, IProspectExternalNew, IProspectFiles {
167
+ export interface IProspect extends IProspectBase, IProspectExternalNew, IProspectFilesLegacy {
168
168
  probability: number;
169
169
  businessDescription: string;
170
170
  comments: string;
@@ -384,6 +384,7 @@ const fileDetailsSchema = new mongoose_1.default.Schema({
384
384
  const ProspectFilesSchema = {
385
385
  type: mongoose_1.default.Schema.Types.Mixed,
386
386
  default: (0, exports.initialFileGroups)(),
387
+ required: false,
387
388
  };
388
389
  exports.ProspectSchema = new mongoose_1.default.Schema({
389
390
  isDeclined: {
@@ -498,9 +499,11 @@ exports.ProspectSchema = new mongoose_1.default.Schema({
498
499
  type: Map,
499
500
  of: [fileDetailsSchema],
500
501
  default: {},
502
+ required: false,
501
503
  },
502
504
  acceptedFiles: [{
503
505
  type: String,
506
+ required: false,
504
507
  }],
505
508
  underwriterIds: [{
506
509
  type: mongoose_1.default.Schema.Types.ObjectId,
@@ -343,14 +343,14 @@ export type TProspectFiles = {
343
343
 
344
344
  export type TProspectAuditorFiles = Map<string, IProspectFile[]>;
345
345
 
346
- export interface IProspectFiles {
346
+ export interface IProspectFilesLegacy {
347
347
  files: TProspectFiles;
348
348
  auditorFiles: TProspectAuditorFiles;
349
349
  auditorSharedFiles: IProspectFile[];
350
350
  acceptedFiles: string[];
351
351
  }
352
352
 
353
- export interface IProspect extends IProspectBase, IProspectExternalNew, IProspectFiles {
353
+ export interface IProspect extends IProspectBase, IProspectExternalNew, IProspectFilesLegacy {
354
354
  probability: number;
355
355
  businessDescription: string;
356
356
  comments: string;
@@ -540,6 +540,7 @@ const fileDetailsSchema = new mongoose.Schema<IProspectFile>({
540
540
  const ProspectFilesSchema = {
541
541
  type: mongoose.Schema.Types.Mixed,
542
542
  default: initialFileGroups(),
543
+ required: false,
543
544
  };
544
545
 
545
546
  export const ProspectSchema = new mongoose.Schema<IProspect, ProspectModel>(
@@ -656,9 +657,11 @@ export const ProspectSchema = new mongoose.Schema<IProspect, ProspectModel>(
656
657
  type: Map,
657
658
  of: [fileDetailsSchema],
658
659
  default: {},
660
+ required: false,
659
661
  },
660
662
  acceptedFiles: [{
661
663
  type: String,
664
+ required: false,
662
665
  }],
663
666
  underwriterIds: [{
664
667
  type: mongoose.Schema.Types.ObjectId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.3.91",
3
+ "version": "1.3.92",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -19,7 +19,8 @@ class CrmProspectsService {
19
19
  for (const [group, rowMap] of Object.entries(files || {})) {
20
20
  for (const [rowId, fileArray] of Object.entries(rowMap)) {
21
21
  for (const file of fileArray) {
22
- await ProspectFile_model_1.ProspectFile.create({
22
+ const newFile = {
23
+ type: ProspectFile_model_1.EProspectFileType.FILE,
23
24
  prospectId,
24
25
  group,
25
26
  rowId,
@@ -28,23 +29,27 @@ class CrmProspectsService {
28
29
  uploadedAt: file.uploadedAt,
29
30
  sharepointId: file.sharepointId,
30
31
  sharepointWebUrl: file.sharepointWebUrl,
31
- });
32
+ };
33
+ await ProspectFile_model_1.ProspectFile.create(newFile);
32
34
  }
33
35
  }
34
36
  }
35
37
  for (const file of auditorSharedFiles) {
36
- await ProspectFile_model_1.ProspectFile.create({
38
+ const newFile = {
39
+ type: ProspectFile_model_1.EProspectFileType.AUDITOR_SHARED_FILE,
37
40
  prospectId,
38
41
  fileId: file.fileId,
39
42
  filename: file.filename,
40
43
  uploadedAt: file.uploadedAt,
41
44
  sharepointId: file.sharepointId,
42
45
  sharepointWebUrl: file.sharepointWebUrl,
43
- });
46
+ };
47
+ await ProspectFile_model_1.ProspectFile.create(newFile);
44
48
  }
45
49
  for (const [auditorId, fileArray] of Object.entries(auditorFiles)) {
46
50
  for (const file of fileArray) {
47
- await ProspectFile_model_1.ProspectFile.create({
51
+ const newFile = {
52
+ type: ProspectFile_model_1.EProspectFileType.AUDITOR_FILE,
48
53
  prospectId,
49
54
  auditorId: new mongoose_1.default.Types.ObjectId(auditorId),
50
55
  fileId: file.fileId,
@@ -52,7 +57,8 @@ class CrmProspectsService {
52
57
  uploadedAt: file.uploadedAt,
53
58
  sharepointId: file.sharepointId,
54
59
  sharepointWebUrl: file.sharepointWebUrl,
55
- });
60
+ };
61
+ await ProspectFile_model_1.ProspectFile.create(newFile);
56
62
  }
57
63
  }
58
64
  }
@@ -1,7 +1,7 @@
1
1
  import mongoose from 'mongoose';
2
2
 
3
3
  import { Prospect } from '../models/Prospect.model';
4
- import { ProspectFile } from '../models/ProspectFile.model';
4
+ import { EProspectFileType, IProspectFile, ProspectFile } from '../models/ProspectFile.model';
5
5
 
6
6
  export class CrmProspectsService {
7
7
  async resetFiles() {
@@ -18,7 +18,8 @@ export class CrmProspectsService {
18
18
  for (const [group, rowMap] of Object.entries(files || {})) {
19
19
  for (const [rowId, fileArray] of Object.entries(rowMap)) {
20
20
  for (const file of fileArray) {
21
- await ProspectFile.create({
21
+ const newFile: IProspectFile = {
22
+ type: EProspectFileType.FILE,
22
23
  prospectId,
23
24
  group,
24
25
  rowId,
@@ -27,25 +28,29 @@ export class CrmProspectsService {
27
28
  uploadedAt: file.uploadedAt,
28
29
  sharepointId: file.sharepointId,
29
30
  sharepointWebUrl: file.sharepointWebUrl,
30
- });
31
+ };
32
+ await ProspectFile.create(newFile);
31
33
  }
32
34
  }
33
35
  }
34
36
 
35
37
  for (const file of auditorSharedFiles) {
36
- await ProspectFile.create({
38
+ const newFile: IProspectFile = {
39
+ type: EProspectFileType.AUDITOR_SHARED_FILE,
37
40
  prospectId,
38
41
  fileId: file.fileId,
39
42
  filename: file.filename,
40
43
  uploadedAt: file.uploadedAt,
41
44
  sharepointId: file.sharepointId,
42
45
  sharepointWebUrl: file.sharepointWebUrl,
43
- });
46
+ };
47
+ await ProspectFile.create(newFile);
44
48
  }
45
49
 
46
50
  for (const [auditorId, fileArray] of Object.entries(auditorFiles)) {
47
51
  for (const file of fileArray) {
48
- await ProspectFile.create({
52
+ const newFile: IProspectFile = {
53
+ type: EProspectFileType.AUDITOR_FILE,
49
54
  prospectId,
50
55
  auditorId: new mongoose.Types.ObjectId(auditorId),
51
56
  fileId: file.fileId,
@@ -53,7 +58,8 @@ export class CrmProspectsService {
53
58
  uploadedAt: file.uploadedAt,
54
59
  sharepointId: file.sharepointId,
55
60
  sharepointWebUrl: file.sharepointWebUrl,
56
- });
61
+ };
62
+ await ProspectFile.create(newFile);
57
63
  }
58
64
  }
59
65
  }