gemcap-be-common 1.4.216 → 1.4.217
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/ProspectFileAiSummary.model.d.ts +24 -11
- package/models/ProspectFileAiSummary.model.js +37 -7
- package/models/ProspectFileAiSummary.model.ts +62 -26
- package/models/_models.d.ts +1 -1
- package/models/_models.js +1 -1
- package/models/_models.ts +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -23,10 +23,21 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose from 'mongoose';
|
|
26
|
-
export declare const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
export declare const AI_SUMMARY_TARGET_TYPES: {
|
|
27
|
+
readonly NOTE: "NOTE";
|
|
28
|
+
readonly NOTE_FILE: "NOTE_FILE";
|
|
29
|
+
};
|
|
30
|
+
export type TAiSummaryTargetType = typeof AI_SUMMARY_TARGET_TYPES[keyof typeof AI_SUMMARY_TARGET_TYPES];
|
|
31
|
+
export declare const PROSPECT_FILE_AI_SUMMARY_STATUSES: {
|
|
32
|
+
readonly PENDING: "PENDING";
|
|
33
|
+
readonly DONE: "DONE";
|
|
34
|
+
readonly ERROR: "ERROR";
|
|
35
|
+
};
|
|
36
|
+
export type TProspectFileAiSummaryStatus = typeof PROSPECT_FILE_AI_SUMMARY_STATUSES[keyof typeof PROSPECT_FILE_AI_SUMMARY_STATUSES];
|
|
37
|
+
export interface IBorrowerNoteAiSummary {
|
|
38
|
+
targetType: TAiSummaryTargetType;
|
|
39
|
+
noteId: mongoose.Types.ObjectId;
|
|
40
|
+
fileId?: string;
|
|
30
41
|
summary: string;
|
|
31
42
|
subject: string;
|
|
32
43
|
status: TProspectFileAiSummaryStatus;
|
|
@@ -36,27 +47,29 @@ export interface IProspectFileAiSummary {
|
|
|
36
47
|
contentHash: string;
|
|
37
48
|
error?: string;
|
|
38
49
|
}
|
|
39
|
-
export interface
|
|
50
|
+
export interface IBorrowerNoteAiSummaryDoc extends IBorrowerNoteAiSummary, Document {
|
|
40
51
|
_id: mongoose.Types.ObjectId;
|
|
41
52
|
createdAt: Date;
|
|
42
53
|
updatedAt: Date;
|
|
43
54
|
}
|
|
44
|
-
export interface
|
|
55
|
+
export interface IBorrowerNoteAiSummaryLean extends IBorrowerNoteAiSummary {
|
|
45
56
|
_id: mongoose.Types.ObjectId;
|
|
46
57
|
createdAt: Date;
|
|
47
58
|
updatedAt: Date;
|
|
48
59
|
}
|
|
49
|
-
export interface
|
|
60
|
+
export interface IBorrowerNoteAiSummaryPlain extends Omit<IBorrowerNoteAiSummary, 'fileId' | 'noteId'> {
|
|
50
61
|
_id: string;
|
|
62
|
+
noteId: string;
|
|
63
|
+
fileId: string;
|
|
51
64
|
createdAt: Date;
|
|
52
65
|
updatedAt: Date;
|
|
53
66
|
}
|
|
54
|
-
export type TProspectFileAiSummaryModel = mongoose.Model<
|
|
55
|
-
export declare const ProspectFileAiSummarySchema: mongoose.Schema<
|
|
67
|
+
export type TProspectFileAiSummaryModel = mongoose.Model<IBorrowerNoteAiSummaryDoc>;
|
|
68
|
+
export declare const ProspectFileAiSummarySchema: mongoose.Schema<IBorrowerNoteAiSummaryDoc, mongoose.Model<IBorrowerNoteAiSummaryDoc, any, any, any, mongoose.Document<unknown, any, IBorrowerNoteAiSummaryDoc> & IBorrowerNoteAiSummaryDoc & Required<{
|
|
56
69
|
_id: mongoose.Types.ObjectId;
|
|
57
|
-
}>, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions,
|
|
70
|
+
}>, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, IBorrowerNoteAiSummaryDoc, mongoose.Document<unknown, {}, mongoose.FlatRecord<IBorrowerNoteAiSummaryDoc>> & mongoose.FlatRecord<IBorrowerNoteAiSummaryDoc> & Required<{
|
|
58
71
|
_id: mongoose.Types.ObjectId;
|
|
59
72
|
}>>;
|
|
60
|
-
export declare const ProspectFileAiSummary: mongoose.Model<
|
|
73
|
+
export declare const ProspectFileAiSummary: mongoose.Model<IBorrowerNoteAiSummaryDoc, {}, {}, {}, mongoose.Document<unknown, {}, IBorrowerNoteAiSummaryDoc> & IBorrowerNoteAiSummaryDoc & Required<{
|
|
61
74
|
_id: mongoose.Types.ObjectId;
|
|
62
75
|
}>, any>;
|
|
@@ -3,23 +3,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ProspectFileAiSummary = exports.ProspectFileAiSummarySchema = exports.PROSPECT_FILE_AI_SUMMARY_STATUSES = void 0;
|
|
6
|
+
exports.ProspectFileAiSummary = exports.ProspectFileAiSummarySchema = exports.PROSPECT_FILE_AI_SUMMARY_STATUSES = exports.AI_SUMMARY_TARGET_TYPES = void 0;
|
|
7
7
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
8
|
const _models_1 = require("./_models");
|
|
9
|
-
exports.
|
|
9
|
+
exports.AI_SUMMARY_TARGET_TYPES = {
|
|
10
|
+
NOTE: 'NOTE',
|
|
11
|
+
NOTE_FILE: 'NOTE_FILE',
|
|
12
|
+
};
|
|
13
|
+
exports.PROSPECT_FILE_AI_SUMMARY_STATUSES = {
|
|
14
|
+
PENDING: 'PENDING',
|
|
15
|
+
DONE: 'DONE',
|
|
16
|
+
ERROR: 'ERROR',
|
|
17
|
+
};
|
|
10
18
|
exports.ProspectFileAiSummarySchema = new mongoose_1.default.Schema({
|
|
11
|
-
|
|
12
|
-
type:
|
|
13
|
-
|
|
19
|
+
targetType: {
|
|
20
|
+
type: String,
|
|
21
|
+
enum: exports.AI_SUMMARY_TARGET_TYPES,
|
|
22
|
+
required: true,
|
|
14
23
|
index: true,
|
|
24
|
+
},
|
|
25
|
+
noteId: {
|
|
26
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
27
|
+
ref: _models_1.MODEL_NAMES.borrowerNote,
|
|
15
28
|
required: true,
|
|
29
|
+
index: true,
|
|
30
|
+
},
|
|
31
|
+
fileId: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: false,
|
|
34
|
+
index: true,
|
|
16
35
|
},
|
|
17
36
|
summary: String,
|
|
18
37
|
subject: String,
|
|
19
38
|
status: {
|
|
20
39
|
type: String,
|
|
21
40
|
enum: exports.PROSPECT_FILE_AI_SUMMARY_STATUSES,
|
|
22
|
-
default:
|
|
41
|
+
default: exports.PROSPECT_FILE_AI_SUMMARY_STATUSES.PENDING,
|
|
23
42
|
index: true,
|
|
24
43
|
},
|
|
25
44
|
model: String,
|
|
@@ -34,4 +53,15 @@ exports.ProspectFileAiSummarySchema = new mongoose_1.default.Schema({
|
|
|
34
53
|
timestamps: true,
|
|
35
54
|
versionKey: false,
|
|
36
55
|
});
|
|
37
|
-
exports.
|
|
56
|
+
exports.ProspectFileAiSummarySchema.pre('validate', function (next) {
|
|
57
|
+
if (this.targetType === exports.AI_SUMMARY_TARGET_TYPES.NOTE) {
|
|
58
|
+
this.fileId = null;
|
|
59
|
+
}
|
|
60
|
+
if (this.targetType === exports.AI_SUMMARY_TARGET_TYPES.NOTE_FILE && !this.fileId) {
|
|
61
|
+
return next(new Error('fileId is required for NOTE_FILE summary'));
|
|
62
|
+
}
|
|
63
|
+
next();
|
|
64
|
+
});
|
|
65
|
+
exports.ProspectFileAiSummarySchema.index({ noteId: 1, targetType: 1 }, { unique: true, partialFilterExpression: { targetType: exports.AI_SUMMARY_TARGET_TYPES.NOTE } });
|
|
66
|
+
exports.ProspectFileAiSummarySchema.index({ noteId: 1, fileId: 1, targetType: 1 }, { unique: true, partialFilterExpression: { targetType: exports.AI_SUMMARY_TARGET_TYPES.NOTE_FILE } });
|
|
67
|
+
exports.ProspectFileAiSummary = mongoose_1.default.model(_models_1.MODEL_NAMES.BorrowerNoteAiSummary, exports.ProspectFileAiSummarySchema);
|
|
@@ -2,78 +2,114 @@ import mongoose from 'mongoose';
|
|
|
2
2
|
|
|
3
3
|
import { MODEL_NAMES } from './_models';
|
|
4
4
|
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
export const AI_SUMMARY_TARGET_TYPES = {
|
|
6
|
+
NOTE: 'NOTE',
|
|
7
|
+
NOTE_FILE: 'NOTE_FILE',
|
|
8
|
+
} as const;
|
|
9
|
+
export type TAiSummaryTargetType = typeof AI_SUMMARY_TARGET_TYPES[keyof typeof AI_SUMMARY_TARGET_TYPES];
|
|
10
|
+
|
|
11
|
+
export const PROSPECT_FILE_AI_SUMMARY_STATUSES = {
|
|
12
|
+
PENDING: 'PENDING',
|
|
13
|
+
DONE: 'DONE',
|
|
14
|
+
ERROR: 'ERROR',
|
|
15
|
+
} as const;
|
|
16
|
+
export type TProspectFileAiSummaryStatus = typeof PROSPECT_FILE_AI_SUMMARY_STATUSES[keyof typeof PROSPECT_FILE_AI_SUMMARY_STATUSES];
|
|
17
|
+
|
|
18
|
+
export interface IBorrowerNoteAiSummary {
|
|
19
|
+
targetType: TAiSummaryTargetType;
|
|
20
|
+
noteId: mongoose.Types.ObjectId;
|
|
21
|
+
fileId?: string;
|
|
12
22
|
summary: string;
|
|
13
23
|
subject: string;
|
|
14
|
-
|
|
15
24
|
status: TProspectFileAiSummaryStatus;
|
|
16
|
-
|
|
17
25
|
model: string;
|
|
18
26
|
promptSlug: string;
|
|
19
27
|
promptVersion: number;
|
|
20
|
-
|
|
21
28
|
contentHash: string;
|
|
22
|
-
|
|
23
29
|
error?: string;
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
export interface
|
|
32
|
+
export interface IBorrowerNoteAiSummaryDoc extends IBorrowerNoteAiSummary, Document {
|
|
27
33
|
_id: mongoose.Types.ObjectId;
|
|
28
34
|
createdAt: Date;
|
|
29
35
|
updatedAt: Date;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
export interface
|
|
38
|
+
export interface IBorrowerNoteAiSummaryLean extends IBorrowerNoteAiSummary {
|
|
33
39
|
_id: mongoose.Types.ObjectId;
|
|
34
40
|
createdAt: Date;
|
|
35
41
|
updatedAt: Date;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
|
-
export interface
|
|
44
|
+
export interface IBorrowerNoteAiSummaryPlain extends Omit<IBorrowerNoteAiSummary, 'fileId' | 'noteId'> {
|
|
39
45
|
_id: string;
|
|
46
|
+
noteId: string;
|
|
47
|
+
fileId: string;
|
|
40
48
|
createdAt: Date;
|
|
41
49
|
updatedAt: Date;
|
|
42
50
|
}
|
|
43
51
|
|
|
44
|
-
export type TProspectFileAiSummaryModel = mongoose.Model<
|
|
52
|
+
export type TProspectFileAiSummaryModel = mongoose.Model<IBorrowerNoteAiSummaryDoc>;
|
|
45
53
|
|
|
46
|
-
export const ProspectFileAiSummarySchema = new mongoose.Schema<
|
|
47
|
-
|
|
48
|
-
type:
|
|
49
|
-
|
|
54
|
+
export const ProspectFileAiSummarySchema = new mongoose.Schema<IBorrowerNoteAiSummaryDoc>({
|
|
55
|
+
targetType: {
|
|
56
|
+
type: String,
|
|
57
|
+
enum: AI_SUMMARY_TARGET_TYPES,
|
|
58
|
+
required: true,
|
|
50
59
|
index: true,
|
|
60
|
+
},
|
|
61
|
+
noteId: {
|
|
62
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
63
|
+
ref: MODEL_NAMES.borrowerNote,
|
|
51
64
|
required: true,
|
|
65
|
+
index: true,
|
|
66
|
+
},
|
|
67
|
+
fileId: {
|
|
68
|
+
type: String,
|
|
69
|
+
required: false,
|
|
70
|
+
index: true,
|
|
52
71
|
},
|
|
53
|
-
|
|
54
72
|
summary: String,
|
|
55
73
|
subject: String,
|
|
56
|
-
|
|
57
74
|
status: {
|
|
58
75
|
type: String,
|
|
59
76
|
enum: PROSPECT_FILE_AI_SUMMARY_STATUSES,
|
|
60
|
-
default:
|
|
77
|
+
default: PROSPECT_FILE_AI_SUMMARY_STATUSES.PENDING,
|
|
61
78
|
index: true,
|
|
62
79
|
},
|
|
63
|
-
|
|
64
80
|
model: String,
|
|
65
81
|
promptSlug: String,
|
|
66
82
|
promptVersion: Number,
|
|
67
|
-
|
|
68
83
|
contentHash: {
|
|
69
84
|
type: String,
|
|
70
85
|
index: true,
|
|
71
86
|
},
|
|
72
|
-
|
|
73
87
|
error: String,
|
|
74
88
|
}, {
|
|
75
89
|
timestamps: true,
|
|
76
90
|
versionKey: false,
|
|
77
91
|
});
|
|
78
92
|
|
|
79
|
-
|
|
93
|
+
ProspectFileAiSummarySchema.pre('validate', function(next) {
|
|
94
|
+
if (this.targetType === AI_SUMMARY_TARGET_TYPES.NOTE) {
|
|
95
|
+
this.fileId = null as any;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (this.targetType === AI_SUMMARY_TARGET_TYPES.NOTE_FILE && !this.fileId) {
|
|
99
|
+
return next(new Error('fileId is required for NOTE_FILE summary'));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
next();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
ProspectFileAiSummarySchema.index(
|
|
106
|
+
{ noteId: 1, targetType: 1 },
|
|
107
|
+
{ unique: true, partialFilterExpression: { targetType: AI_SUMMARY_TARGET_TYPES.NOTE } },
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
ProspectFileAiSummarySchema.index(
|
|
111
|
+
{ noteId: 1, fileId: 1, targetType: 1 },
|
|
112
|
+
{ unique: true, partialFilterExpression: { targetType: AI_SUMMARY_TARGET_TYPES.NOTE_FILE } },
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
export const ProspectFileAiSummary = mongoose.model<IBorrowerNoteAiSummaryDoc>(MODEL_NAMES.BorrowerNoteAiSummary, ProspectFileAiSummarySchema);
|
package/models/_models.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare const MODEL_NAMES: {
|
|
|
35
35
|
borrowerSettings: string;
|
|
36
36
|
borrowerSummaries: string;
|
|
37
37
|
borrowerNote: string;
|
|
38
|
+
BorrowerNoteAiSummary: string;
|
|
38
39
|
borrowerNoteSubject: string;
|
|
39
40
|
calendarDays: string;
|
|
40
41
|
cashAllocations: string;
|
|
@@ -49,7 +50,6 @@ export declare const MODEL_NAMES: {
|
|
|
49
50
|
CRMAuditors: string;
|
|
50
51
|
CRMProspects: string;
|
|
51
52
|
CRMProspectFiles: string;
|
|
52
|
-
CRMProspectFilesAiSummary: string;
|
|
53
53
|
CRMProspectIndustries: string;
|
|
54
54
|
CRMProspectSources: string;
|
|
55
55
|
CRMProspectExternalUpdates: string;
|
package/models/_models.js
CHANGED
|
@@ -38,6 +38,7 @@ exports.MODEL_NAMES = {
|
|
|
38
38
|
borrowerSettings: 'borrowerSettings',
|
|
39
39
|
borrowerSummaries: 'borrower_summaries',
|
|
40
40
|
borrowerNote: 'borrower_notes',
|
|
41
|
+
BorrowerNoteAiSummary: 'borrower_note_summaries',
|
|
41
42
|
borrowerNoteSubject: 'borrower_note_subjects',
|
|
42
43
|
calendarDays: 'calendar_days',
|
|
43
44
|
cashAllocations: 'cash_allocations',
|
|
@@ -52,7 +53,6 @@ exports.MODEL_NAMES = {
|
|
|
52
53
|
CRMAuditors: 'auditors',
|
|
53
54
|
CRMProspects: 'crm_prospects',
|
|
54
55
|
CRMProspectFiles: 'crm_prospect_files',
|
|
55
|
-
CRMProspectFilesAiSummary: 'crm_prospect_file_summaries',
|
|
56
56
|
CRMProspectIndustries: 'crm_prospect_industries',
|
|
57
57
|
CRMProspectSources: 'crm_prospect_sources',
|
|
58
58
|
CRMProspectExternalUpdates: 'crm_prospect_external_updates',
|
package/models/_models.ts
CHANGED
|
@@ -35,6 +35,7 @@ export const MODEL_NAMES = {
|
|
|
35
35
|
borrowerSettings: 'borrowerSettings',
|
|
36
36
|
borrowerSummaries: 'borrower_summaries',
|
|
37
37
|
borrowerNote: 'borrower_notes',
|
|
38
|
+
BorrowerNoteAiSummary: 'borrower_note_summaries',
|
|
38
39
|
borrowerNoteSubject: 'borrower_note_subjects',
|
|
39
40
|
calendarDays: 'calendar_days',
|
|
40
41
|
cashAllocations: 'cash_allocations',
|
|
@@ -49,7 +50,6 @@ export const MODEL_NAMES = {
|
|
|
49
50
|
CRMAuditors: 'auditors',
|
|
50
51
|
CRMProspects: 'crm_prospects',
|
|
51
52
|
CRMProspectFiles: 'crm_prospect_files',
|
|
52
|
-
CRMProspectFilesAiSummary: 'crm_prospect_file_summaries',
|
|
53
53
|
CRMProspectIndustries: 'crm_prospect_industries',
|
|
54
54
|
CRMProspectSources: 'crm_prospect_sources',
|
|
55
55
|
CRMProspectExternalUpdates: 'crm_prospect_external_updates',
|