gemcap-be-common 1.4.216 → 1.4.218

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.
@@ -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 PROSPECT_FILE_AI_SUMMARY_STATUSES: readonly ["PENDING", "DONE", "ERROR"];
27
- export type TProspectFileAiSummaryStatus = (typeof PROSPECT_FILE_AI_SUMMARY_STATUSES)[number];
28
- export interface IProspectFileAiSummary {
29
- fileId: mongoose.Types.ObjectId;
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 IProspectFileAiSummaryDoc extends IProspectFileAiSummary, Document {
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 IProspectFileAiSummaryLean extends IProspectFileAiSummary {
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 IProspectFileAiSummaryPlain extends Omit<IProspectFileAiSummary, 'fileId'> {
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<IProspectFileAiSummaryDoc>;
55
- export declare const ProspectFileAiSummarySchema: mongoose.Schema<IProspectFileAiSummaryDoc, mongoose.Model<IProspectFileAiSummaryDoc, any, any, any, mongoose.Document<unknown, any, IProspectFileAiSummaryDoc> & IProspectFileAiSummaryDoc & Required<{
67
+ export type TProspectFileAiSummaryModel = mongoose.Model<IBorrowerNoteAiSummaryDoc>;
68
+ export declare const BorrowerNoteAiSummarySchema: 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, IProspectFileAiSummaryDoc, mongoose.Document<unknown, {}, mongoose.FlatRecord<IProspectFileAiSummaryDoc>> & mongoose.FlatRecord<IProspectFileAiSummaryDoc> & Required<{
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<IProspectFileAiSummaryDoc, {}, {}, {}, mongoose.Document<unknown, {}, IProspectFileAiSummaryDoc> & IProspectFileAiSummaryDoc & Required<{
73
+ export declare const BorrowerNoteAiSummary: mongoose.Model<IBorrowerNoteAiSummaryDoc, {}, {}, {}, mongoose.Document<unknown, {}, IBorrowerNoteAiSummaryDoc> & IBorrowerNoteAiSummaryDoc & Required<{
61
74
  _id: mongoose.Types.ObjectId;
62
75
  }>, any>;
@@ -0,0 +1,67 @@
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.BorrowerNoteAiSummary = exports.BorrowerNoteAiSummarySchema = exports.PROSPECT_FILE_AI_SUMMARY_STATUSES = exports.AI_SUMMARY_TARGET_TYPES = void 0;
7
+ const mongoose_1 = __importDefault(require("mongoose"));
8
+ const _models_1 = require("./_models");
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
+ };
18
+ exports.BorrowerNoteAiSummarySchema = new mongoose_1.default.Schema({
19
+ targetType: {
20
+ type: String,
21
+ enum: exports.AI_SUMMARY_TARGET_TYPES,
22
+ required: true,
23
+ index: true,
24
+ },
25
+ noteId: {
26
+ type: mongoose_1.default.Schema.Types.ObjectId,
27
+ ref: _models_1.MODEL_NAMES.borrowerNote,
28
+ required: true,
29
+ index: true,
30
+ },
31
+ fileId: {
32
+ type: String,
33
+ required: false,
34
+ index: true,
35
+ },
36
+ summary: String,
37
+ subject: String,
38
+ status: {
39
+ type: String,
40
+ enum: exports.PROSPECT_FILE_AI_SUMMARY_STATUSES,
41
+ default: exports.PROSPECT_FILE_AI_SUMMARY_STATUSES.PENDING,
42
+ index: true,
43
+ },
44
+ model: String,
45
+ promptSlug: String,
46
+ promptVersion: Number,
47
+ contentHash: {
48
+ type: String,
49
+ index: true,
50
+ },
51
+ error: String,
52
+ }, {
53
+ timestamps: true,
54
+ versionKey: false,
55
+ });
56
+ exports.BorrowerNoteAiSummarySchema.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.BorrowerNoteAiSummarySchema.index({ noteId: 1, targetType: 1 }, { unique: true, partialFilterExpression: { targetType: exports.AI_SUMMARY_TARGET_TYPES.NOTE } });
66
+ exports.BorrowerNoteAiSummarySchema.index({ noteId: 1, fileId: 1, targetType: 1 }, { unique: true, partialFilterExpression: { targetType: exports.AI_SUMMARY_TARGET_TYPES.NOTE_FILE } });
67
+ exports.BorrowerNoteAiSummary = mongoose_1.default.model(_models_1.MODEL_NAMES.BorrowerNoteAiSummary, exports.BorrowerNoteAiSummarySchema);
@@ -0,0 +1,115 @@
1
+ import mongoose from 'mongoose';
2
+
3
+ import { MODEL_NAMES } from './_models';
4
+
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;
22
+ summary: string;
23
+ subject: string;
24
+ status: TProspectFileAiSummaryStatus;
25
+ model: string;
26
+ promptSlug: string;
27
+ promptVersion: number;
28
+ contentHash: string;
29
+ error?: string;
30
+ }
31
+
32
+ export interface IBorrowerNoteAiSummaryDoc extends IBorrowerNoteAiSummary, Document {
33
+ _id: mongoose.Types.ObjectId;
34
+ createdAt: Date;
35
+ updatedAt: Date;
36
+ }
37
+
38
+ export interface IBorrowerNoteAiSummaryLean extends IBorrowerNoteAiSummary {
39
+ _id: mongoose.Types.ObjectId;
40
+ createdAt: Date;
41
+ updatedAt: Date;
42
+ }
43
+
44
+ export interface IBorrowerNoteAiSummaryPlain extends Omit<IBorrowerNoteAiSummary, 'fileId' | 'noteId'> {
45
+ _id: string;
46
+ noteId: string;
47
+ fileId: string;
48
+ createdAt: Date;
49
+ updatedAt: Date;
50
+ }
51
+
52
+ export type TProspectFileAiSummaryModel = mongoose.Model<IBorrowerNoteAiSummaryDoc>;
53
+
54
+ export const BorrowerNoteAiSummarySchema = new mongoose.Schema<IBorrowerNoteAiSummaryDoc>({
55
+ targetType: {
56
+ type: String,
57
+ enum: AI_SUMMARY_TARGET_TYPES,
58
+ required: true,
59
+ index: true,
60
+ },
61
+ noteId: {
62
+ type: mongoose.Schema.Types.ObjectId,
63
+ ref: MODEL_NAMES.borrowerNote,
64
+ required: true,
65
+ index: true,
66
+ },
67
+ fileId: {
68
+ type: String,
69
+ required: false,
70
+ index: true,
71
+ },
72
+ summary: String,
73
+ subject: String,
74
+ status: {
75
+ type: String,
76
+ enum: PROSPECT_FILE_AI_SUMMARY_STATUSES,
77
+ default: PROSPECT_FILE_AI_SUMMARY_STATUSES.PENDING,
78
+ index: true,
79
+ },
80
+ model: String,
81
+ promptSlug: String,
82
+ promptVersion: Number,
83
+ contentHash: {
84
+ type: String,
85
+ index: true,
86
+ },
87
+ error: String,
88
+ }, {
89
+ timestamps: true,
90
+ versionKey: false,
91
+ });
92
+
93
+ BorrowerNoteAiSummarySchema.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
+ BorrowerNoteAiSummarySchema.index(
106
+ { noteId: 1, targetType: 1 },
107
+ { unique: true, partialFilterExpression: { targetType: AI_SUMMARY_TARGET_TYPES.NOTE } },
108
+ );
109
+
110
+ BorrowerNoteAiSummarySchema.index(
111
+ { noteId: 1, fileId: 1, targetType: 1 },
112
+ { unique: true, partialFilterExpression: { targetType: AI_SUMMARY_TARGET_TYPES.NOTE_FILE } },
113
+ );
114
+
115
+ export const BorrowerNoteAiSummary = mongoose.model<IBorrowerNoteAiSummaryDoc>(MODEL_NAMES.BorrowerNoteAiSummary, BorrowerNoteAiSummarySchema);
@@ -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',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.4.216",
3
+ "version": "1.4.218",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {