gemcap-be-common 1.3.85 → 1.3.87
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/models/Prospect.model.d.ts +2 -0
- package/models/Prospect.model.ts +2 -0
- package/models/ProspectFile.model.d.ts +41 -0
- package/models/ProspectFile.model.js +49 -0
- package/models/ProspectFile.model.ts +61 -0
- package/models/_models.d.ts +2 -0
- package/models/_models.js +2 -0
- package/models/_models.ts +2 -0
- package/package.json +1 -1
- package/services/crm-prospects.service.d.ts +4 -0
- package/services/crm-prospects.service.js +61 -0
- package/services/crm-prospects.service.ts +61 -0
- package/tsconfig.tsbuildinfo +1 -1
package/models/Prospect.model.ts
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
import mongoose from 'mongoose';
|
|
26
|
+
export interface ICRMProspectFile {
|
|
27
|
+
prospectId: mongoose.Types.ObjectId;
|
|
28
|
+
group?: string;
|
|
29
|
+
rowId?: string;
|
|
30
|
+
auditorId?: mongoose.Types.ObjectId;
|
|
31
|
+
fileId: string;
|
|
32
|
+
filename: string;
|
|
33
|
+
uploadedAt: Date;
|
|
34
|
+
sharepointId?: string;
|
|
35
|
+
sharepointWebUrl?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ICRMProspectFileDoc extends ICRMProspectFile, mongoose.Document {
|
|
38
|
+
}
|
|
39
|
+
export declare const CRMProspectFile: mongoose.Model<ICRMProspectFileDoc, {}, {}, {}, mongoose.Document<unknown, {}, ICRMProspectFileDoc> & ICRMProspectFileDoc & {
|
|
40
|
+
_id: mongoose.Types.ObjectId;
|
|
41
|
+
}, any>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CRMProspectFile = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const _models_1 = require("./_models");
|
|
9
|
+
const CRMProspectFileSchema = new mongoose_1.default.Schema({
|
|
10
|
+
prospectId: {
|
|
11
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
12
|
+
ref: _models_1.MODEL_NAMES.CRMProspects,
|
|
13
|
+
required: true,
|
|
14
|
+
index: true,
|
|
15
|
+
},
|
|
16
|
+
group: {
|
|
17
|
+
type: String,
|
|
18
|
+
},
|
|
19
|
+
rowId: {
|
|
20
|
+
type: String,
|
|
21
|
+
},
|
|
22
|
+
auditorId: {
|
|
23
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
24
|
+
ref: _models_1.MODEL_NAMES.CRMAuditors,
|
|
25
|
+
index: true,
|
|
26
|
+
},
|
|
27
|
+
fileId: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
filename: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
uploadedAt: {
|
|
36
|
+
type: Date,
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
sharepointId: {
|
|
40
|
+
type: String,
|
|
41
|
+
},
|
|
42
|
+
sharepointWebUrl: {
|
|
43
|
+
type: String,
|
|
44
|
+
},
|
|
45
|
+
}, {
|
|
46
|
+
timestamps: true,
|
|
47
|
+
versionKey: false,
|
|
48
|
+
});
|
|
49
|
+
exports.CRMProspectFile = mongoose_1.default.model(_models_1.MODEL_NAMES.CRMProspectFiles, CRMProspectFileSchema);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
import { MODEL_NAMES } from './_models';
|
|
4
|
+
|
|
5
|
+
export interface ICRMProspectFile {
|
|
6
|
+
prospectId: mongoose.Types.ObjectId;
|
|
7
|
+
group?: string;
|
|
8
|
+
rowId?: string;
|
|
9
|
+
auditorId?: mongoose.Types.ObjectId;
|
|
10
|
+
fileId: string;
|
|
11
|
+
filename: string;
|
|
12
|
+
uploadedAt: Date;
|
|
13
|
+
sharepointId?: string;
|
|
14
|
+
sharepointWebUrl?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ICRMProspectFileDoc extends ICRMProspectFile, mongoose.Document {
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const CRMProspectFileSchema = new mongoose.Schema<ICRMProspectFileDoc>({
|
|
21
|
+
prospectId: {
|
|
22
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
23
|
+
ref: MODEL_NAMES.CRMProspects,
|
|
24
|
+
required: true,
|
|
25
|
+
index: true,
|
|
26
|
+
},
|
|
27
|
+
group: {
|
|
28
|
+
type: String,
|
|
29
|
+
},
|
|
30
|
+
rowId: {
|
|
31
|
+
type: String,
|
|
32
|
+
},
|
|
33
|
+
auditorId: {
|
|
34
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
35
|
+
ref: MODEL_NAMES.CRMAuditors,
|
|
36
|
+
index: true,
|
|
37
|
+
},
|
|
38
|
+
fileId: {
|
|
39
|
+
type: String,
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
filename: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: true,
|
|
45
|
+
},
|
|
46
|
+
uploadedAt: {
|
|
47
|
+
type: Date,
|
|
48
|
+
required: true,
|
|
49
|
+
},
|
|
50
|
+
sharepointId: {
|
|
51
|
+
type: String,
|
|
52
|
+
},
|
|
53
|
+
sharepointWebUrl: {
|
|
54
|
+
type: String,
|
|
55
|
+
},
|
|
56
|
+
}, {
|
|
57
|
+
timestamps: true,
|
|
58
|
+
versionKey: false,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const CRMProspectFile = mongoose.model<ICRMProspectFileDoc>(MODEL_NAMES.CRMProspectFiles, CRMProspectFileSchema);
|
package/models/_models.d.ts
CHANGED
|
@@ -37,7 +37,9 @@ export declare const MODEL_NAMES: {
|
|
|
37
37
|
companies: string;
|
|
38
38
|
complianceBorrowers: string;
|
|
39
39
|
complianceItemGroups: string;
|
|
40
|
+
CRMAuditors: string;
|
|
40
41
|
CRMProspects: string;
|
|
42
|
+
CRMProspectFiles: string;
|
|
41
43
|
CRMProspectIndustries: string;
|
|
42
44
|
CRMProspectSources: string;
|
|
43
45
|
CRMProspectExternalUpdates: string;
|
package/models/_models.js
CHANGED
|
@@ -40,7 +40,9 @@ exports.MODEL_NAMES = {
|
|
|
40
40
|
companies: 'companies',
|
|
41
41
|
complianceBorrowers: 'complianceBorrowers',
|
|
42
42
|
complianceItemGroups: 'complianceItemGroups',
|
|
43
|
+
CRMAuditors: 'auditors',
|
|
43
44
|
CRMProspects: 'crm_prospects',
|
|
45
|
+
CRMProspectFiles: 'crm_prospects_files',
|
|
44
46
|
CRMProspectIndustries: 'crm_prospect_industries',
|
|
45
47
|
CRMProspectSources: 'crm_prospect_sources',
|
|
46
48
|
CRMProspectExternalUpdates: 'crm_prospect_external_updates',
|
package/models/_models.ts
CHANGED
|
@@ -37,7 +37,9 @@ export const MODEL_NAMES = {
|
|
|
37
37
|
companies: 'companies',
|
|
38
38
|
complianceBorrowers: 'complianceBorrowers',
|
|
39
39
|
complianceItemGroups: 'complianceItemGroups',
|
|
40
|
+
CRMAuditors: 'auditors',
|
|
40
41
|
CRMProspects: 'crm_prospects',
|
|
42
|
+
CRMProspectFiles: 'crm_prospects_files',
|
|
41
43
|
CRMProspectIndustries: 'crm_prospect_industries',
|
|
42
44
|
CRMProspectSources: 'crm_prospect_sources',
|
|
43
45
|
CRMProspectExternalUpdates: 'crm_prospect_external_updates',
|
package/package.json
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CrmProspectsService = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const Prospect_model_1 = require("../models/Prospect.model");
|
|
9
|
+
const ProspectFile_model_1 = require("../models/ProspectFile.model");
|
|
10
|
+
class CrmProspectsService {
|
|
11
|
+
async resetFiles() {
|
|
12
|
+
await ProspectFile_model_1.CRMProspectFile.deleteMany({});
|
|
13
|
+
await this.migrateFiles();
|
|
14
|
+
}
|
|
15
|
+
async migrateFiles() {
|
|
16
|
+
const prospects = await Prospect_model_1.CRMProspect.find().lean();
|
|
17
|
+
for (const prospect of prospects) {
|
|
18
|
+
const { _id: prospectId, files, auditorFiles, auditorSharedFiles } = prospect;
|
|
19
|
+
for (const [group, rowMap] of Object.entries(files || {})) {
|
|
20
|
+
for (const [rowId, fileArray] of Object.entries(rowMap)) {
|
|
21
|
+
for (const file of fileArray) {
|
|
22
|
+
await ProspectFile_model_1.CRMProspectFile.create({
|
|
23
|
+
prospectId,
|
|
24
|
+
group,
|
|
25
|
+
rowId,
|
|
26
|
+
fileId: file.fileId,
|
|
27
|
+
filename: file.filename,
|
|
28
|
+
uploadedAt: file.uploadedAt,
|
|
29
|
+
sharepointId: file.sharepointId,
|
|
30
|
+
sharepointWebUrl: file.sharepointWebUrl,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
for (const file of auditorSharedFiles) {
|
|
36
|
+
await ProspectFile_model_1.CRMProspectFile.create({
|
|
37
|
+
prospectId,
|
|
38
|
+
fileId: file.fileId,
|
|
39
|
+
filename: file.filename,
|
|
40
|
+
uploadedAt: file.uploadedAt,
|
|
41
|
+
sharepointId: file.sharepointId,
|
|
42
|
+
sharepointWebUrl: file.sharepointWebUrl,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
for (const [auditorId, fileArray] of Object.entries(auditorFiles)) {
|
|
46
|
+
for (const file of fileArray) {
|
|
47
|
+
await ProspectFile_model_1.CRMProspectFile.create({
|
|
48
|
+
prospectId,
|
|
49
|
+
auditorId: new mongoose_1.default.Types.ObjectId(auditorId),
|
|
50
|
+
fileId: file.fileId,
|
|
51
|
+
filename: file.filename,
|
|
52
|
+
uploadedAt: file.uploadedAt,
|
|
53
|
+
sharepointId: file.sharepointId,
|
|
54
|
+
sharepointWebUrl: file.sharepointWebUrl,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.CrmProspectsService = CrmProspectsService;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
import { CRMProspect } from '../models/Prospect.model';
|
|
4
|
+
import { CRMProspectFile } from '../models/ProspectFile.model';
|
|
5
|
+
|
|
6
|
+
export class CrmProspectsService {
|
|
7
|
+
async resetFiles() {
|
|
8
|
+
await CRMProspectFile.deleteMany({});
|
|
9
|
+
await this.migrateFiles();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async migrateFiles() {
|
|
13
|
+
const prospects = await CRMProspect.find().lean();
|
|
14
|
+
|
|
15
|
+
for (const prospect of prospects) {
|
|
16
|
+
const { _id: prospectId, files, auditorFiles, auditorSharedFiles } = prospect;
|
|
17
|
+
|
|
18
|
+
for (const [group, rowMap] of Object.entries(files || {})) {
|
|
19
|
+
for (const [rowId, fileArray] of Object.entries(rowMap)) {
|
|
20
|
+
for (const file of fileArray) {
|
|
21
|
+
await CRMProspectFile.create({
|
|
22
|
+
prospectId,
|
|
23
|
+
group,
|
|
24
|
+
rowId,
|
|
25
|
+
fileId: file.fileId,
|
|
26
|
+
filename: file.filename,
|
|
27
|
+
uploadedAt: file.uploadedAt,
|
|
28
|
+
sharepointId: file.sharepointId,
|
|
29
|
+
sharepointWebUrl: file.sharepointWebUrl,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
for (const file of auditorSharedFiles) {
|
|
36
|
+
await CRMProspectFile.create({
|
|
37
|
+
prospectId,
|
|
38
|
+
fileId: file.fileId,
|
|
39
|
+
filename: file.filename,
|
|
40
|
+
uploadedAt: file.uploadedAt,
|
|
41
|
+
sharepointId: file.sharepointId,
|
|
42
|
+
sharepointWebUrl: file.sharepointWebUrl,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
for (const [auditorId, fileArray] of Object.entries(auditorFiles)) {
|
|
47
|
+
for (const file of fileArray) {
|
|
48
|
+
await CRMProspectFile.create({
|
|
49
|
+
prospectId,
|
|
50
|
+
auditorId: new mongoose.Types.ObjectId(auditorId),
|
|
51
|
+
fileId: file.fileId,
|
|
52
|
+
filename: file.filename,
|
|
53
|
+
uploadedAt: file.uploadedAt,
|
|
54
|
+
sharepointId: file.sharepointId,
|
|
55
|
+
sharepointWebUrl: file.sharepointWebUrl,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|