gemcap-be-common 1.5.128 → 1.5.130

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.
@@ -1,13 +1,4 @@
1
1
  /// <reference types="mongoose/types/types" />
2
- /// <reference types="mongoose/types/document" />
3
- /// <reference types="mongoose/types/models" />
4
- /// <reference types="mongoose/types/collection" />
5
- /// <reference types="mongoose/types/connection" />
6
- /// <reference types="mongoose/types/query" />
7
- /// <reference types="mongoose/types/error" />
8
- /// <reference types="mongoose/types/populate" />
9
- /// <reference types="mongoose/types/utility" />
10
- /// <reference types="mongoose/types/schemaoptions" />
11
2
  /// <reference types="mongoose/types/aggregate" />
12
3
  /// <reference types="mongoose/types/callback" />
13
4
  /// <reference types="mongoose/types/collection" />
@@ -35,166 +26,23 @@
35
26
  import mongoose from 'mongoose';
36
27
  import { ILedgerDataRow } from './reports.db';
37
28
  import { ILoanProductDoc } from '../models/LoanProducts.model';
38
- import { IProductBrokerDocWithBroker } from '../models/ProductBroker.model';
39
- export declare const getProductBrokers: (productId: string) => Promise<IProductBrokerDocWithBroker[]>;
29
+ import { IProductBrokerDocWithLoanBroker } from '../models/ProductBroker.model';
30
+ export declare const getProductBrokers: (productId: string) => Promise<IProductBrokerDocWithLoanBroker[]>;
40
31
  export declare const enrichWithBrokers: (transactions: ILedgerDataRow[], product: ILoanProductDoc) => Promise<ILedgerDataRow[]>;
41
- export declare const getBorrowerBrokers: (borrowerId: string) => Promise<(mongoose.FlattenMaps<import("../models/ProductBroker.model").IProductBrokerDoc> & Required<{
32
+ export declare const getBorrowerBrokers: (borrowerId: string) => Promise<(mongoose.FlattenMaps<import("../models/ProductBroker.model").IProductBroker> & {
42
33
  _id: mongoose.Types.ObjectId;
43
- }>)[]>;
44
- export declare const getAllProductBrokers: () => Promise<(mongoose.FlattenMaps<import("../models/ProductBroker.model").IProductBrokerDoc> & Required<{
34
+ })[]>;
35
+ export declare const getAllProductBrokers: () => Promise<(mongoose.FlattenMaps<import("../models/ProductBroker.model").IProductBroker> & {
45
36
  _id: mongoose.Types.ObjectId;
46
- }>)[]>;
37
+ })[]>;
47
38
  export declare const getAllLoanBrokers: () => Promise<{
48
39
  emails: mongoose.FlattenMaps<import("../models/LoanBroker.model").ILoanBrokerEmail>[];
40
+ uiId: string;
49
41
  order: number;
50
42
  active: boolean;
51
43
  name: string;
52
- _id: any;
53
- __v?: any;
54
- $assertPopulated: <Paths = {}>(path: string | string[], values?: Partial<Paths>) => Omit<import("../models/LoanBroker.model").ILoanBrokerDoc, keyof Paths> & Paths;
55
- $clone: () => import("../models/LoanBroker.model").ILoanBrokerDoc;
56
- $getAllSubdocs: () => mongoose.Document<any, any, any>[];
57
- $ignore: (path: string) => void;
58
- $isDefault: (path: string) => boolean;
59
- $isDeleted: (val?: boolean) => boolean;
60
- $getPopulatedDocs: () => mongoose.Document<any, any, any>[];
61
- $inc: (path: string | string[], val?: number) => import("../models/LoanBroker.model").ILoanBrokerDoc;
62
- $isEmpty: (path: string) => boolean;
63
- $isValid: (path: string) => boolean;
64
- $locals: mongoose.FlattenMaps<Record<string, unknown>>;
65
- $markValid: (path: string) => void;
66
- $model: {
67
- <ModelType = mongoose.Model<unknown, {}, {}, {}, mongoose.Document<unknown, {}, unknown> & Required<{
68
- _id: unknown;
69
- }>, any>>(name: string): ModelType;
70
- <ModelType_1 = mongoose.Model<any, {}, {}, {}, any, any>>(): ModelType_1;
71
- };
72
- $op: "save" | "validate" | "remove";
73
- $session: (session?: mongoose.mongo.ClientSession) => mongoose.mongo.ClientSession;
74
- $set: {
75
- (path: string | Record<string, any>, val: any, type: any, options?: mongoose.DocumentSetOptions): import("../models/LoanBroker.model").ILoanBrokerDoc;
76
- (path: string | Record<string, any>, val: any, options?: mongoose.DocumentSetOptions): import("../models/LoanBroker.model").ILoanBrokerDoc;
77
- (value: string | Record<string, any>): import("../models/LoanBroker.model").ILoanBrokerDoc;
78
- };
79
- $where: mongoose.FlattenMaps<Record<string, unknown>>;
80
- baseModelName?: string;
81
- collection: mongoose.Collection<mongoose.mongo.BSON.Document>;
82
- db: mongoose.FlattenMaps<mongoose.Connection>;
83
- deleteOne: (options?: mongoose.QueryOptions<unknown>) => any;
84
- depopulate: (path?: string | string[]) => import("../models/LoanBroker.model").ILoanBrokerDoc;
85
- directModifiedPaths: () => string[];
86
- equals: (doc: mongoose.Document<any, any, any>) => boolean;
87
- errors?: mongoose.Error.ValidationError;
88
- get: {
89
- <T extends string | number | symbol>(path: T, type?: any, options?: any): any;
90
- (path: string, type?: any, options?: any): any;
91
- };
92
- getChanges: () => mongoose.UpdateQuery<import("../models/LoanBroker.model").ILoanBrokerDoc>;
93
- id?: any;
94
- increment: () => import("../models/LoanBroker.model").ILoanBrokerDoc;
95
- init: (obj: mongoose.AnyObject, opts?: mongoose.AnyObject) => import("../models/LoanBroker.model").ILoanBrokerDoc;
96
- invalidate: {
97
- <T_1 extends string | number | symbol>(path: T_1, errorMsg: string | NativeError, value?: any, kind?: string): NativeError;
98
- (path: string, errorMsg: string | NativeError, value?: any, kind?: string): NativeError;
99
- };
100
- isDirectModified: {
101
- <T_2 extends string | number | symbol>(path: T_2 | T_2[]): boolean;
102
- (path: string | string[]): boolean;
103
- };
104
- isDirectSelected: {
105
- <T_3 extends string | number | symbol>(path: T_3): boolean;
106
- (path: string): boolean;
107
- };
108
- isInit: {
109
- <T_4 extends string | number | symbol>(path: T_4): boolean;
110
- (path: string): boolean;
111
- };
112
- isModified: {
113
- <T_5 extends string | number | symbol>(path?: T_5 | T_5[], options?: {
114
- ignoreAtomics?: boolean;
115
- }): boolean;
116
- (path?: string | string[], options?: {
117
- ignoreAtomics?: boolean;
118
- }): boolean;
119
- };
120
- isNew: boolean;
121
- isSelected: {
122
- <T_6 extends string | number | symbol>(path: T_6): boolean;
123
- (path: string): boolean;
124
- };
125
- markModified: {
126
- <T_7 extends string | number | symbol>(path: T_7, scope?: any): void;
127
- (path: string, scope?: any): void;
128
- };
129
- model: {
130
- <ModelType_2 = mongoose.Model<unknown, {}, {}, {}, mongoose.Document<unknown, {}, unknown> & Required<{
131
- _id: unknown;
132
- }>, any>>(name: string): ModelType_2;
133
- <ModelType_3 = mongoose.Model<any, {}, {}, {}, any, any>>(): ModelType_3;
134
- };
135
- modifiedPaths: (options?: {
136
- includeChildren?: boolean;
137
- }) => string[];
138
- overwrite: (obj: mongoose.AnyObject) => import("../models/LoanBroker.model").ILoanBrokerDoc;
139
- $parent: () => mongoose.Document<any, any, any>;
140
- populate: {
141
- <Paths_1 = {}>(path: string | mongoose.PopulateOptions | (string | mongoose.PopulateOptions)[]): Promise<mongoose.MergeType<import("../models/LoanBroker.model").ILoanBrokerDoc, Paths_1>>;
142
- <Paths_2 = {}>(path: string, select?: string | mongoose.AnyObject, model?: mongoose.Model<any, {}, {}, {}, any, any>, match?: mongoose.AnyObject, options?: mongoose.PopulateOptions): Promise<mongoose.MergeType<import("../models/LoanBroker.model").ILoanBrokerDoc, Paths_2>>;
143
- };
144
- populated: (path: string) => any;
145
- replaceOne: (replacement?: mongoose.AnyObject, options?: mongoose.QueryOptions<unknown>) => mongoose.Query<any, import("../models/LoanBroker.model").ILoanBrokerDoc, {}, import("../models/LoanBroker.model").ILoanBrokerDoc, "find">;
146
- save: (options?: mongoose.SaveOptions) => Promise<import("../models/LoanBroker.model").ILoanBrokerDoc>;
147
- schema: mongoose.FlattenMaps<mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
148
- [x: string]: unknown;
149
- }, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
150
- [x: string]: unknown;
151
- }>> & mongoose.FlatRecord<{
152
- [x: string]: unknown;
153
- }> & Required<{
154
- _id: unknown;
155
- }>>>;
156
- set: {
157
- <T_8 extends string | number | symbol>(path: T_8, val: any, type: any, options?: mongoose.DocumentSetOptions): import("../models/LoanBroker.model").ILoanBrokerDoc;
158
- (path: string | Record<string, any>, val: any, type: any, options?: mongoose.DocumentSetOptions): import("../models/LoanBroker.model").ILoanBrokerDoc;
159
- (path: string | Record<string, any>, val: any, options?: mongoose.DocumentSetOptions): import("../models/LoanBroker.model").ILoanBrokerDoc;
160
- (value: string | Record<string, any>): import("../models/LoanBroker.model").ILoanBrokerDoc;
161
- };
162
- toJSON: {
163
- <T_9 = any>(options?: mongoose.ToObjectOptions<mongoose.Document<unknown, {}, unknown> & Required<{
164
- _id: unknown;
165
- }>> & {
166
- flattenMaps?: true;
167
- }): mongoose.FlattenMaps<T_9>;
168
- <T_10 = any>(options: mongoose.ToObjectOptions<mongoose.Document<unknown, {}, unknown> & Required<{
169
- _id: unknown;
170
- }>> & {
171
- flattenMaps: false;
172
- }): T_10;
173
- };
174
- toObject: <T_11 = any>(options?: mongoose.ToObjectOptions<mongoose.Document<unknown, {}, unknown> & Required<{
175
- _id: unknown;
176
- }>>) => mongoose.Require_id<T_11>;
177
- unmarkModified: {
178
- <T_12 extends string | number | symbol>(path: T_12): void;
179
- (path: string): void;
180
- };
181
- updateOne: (update?: mongoose.UpdateWithAggregationPipeline | mongoose.UpdateQuery<import("../models/LoanBroker.model").ILoanBrokerDoc>, options?: mongoose.QueryOptions<unknown>) => mongoose.Query<any, import("../models/LoanBroker.model").ILoanBrokerDoc, {}, import("../models/LoanBroker.model").ILoanBrokerDoc, "find">;
182
- validate: {
183
- <T_13 extends string | number | symbol>(pathsToValidate?: T_13 | T_13[], options?: mongoose.AnyObject): Promise<void>;
184
- (pathsToValidate?: mongoose.PathsToValidate, options?: mongoose.AnyObject): Promise<void>;
185
- (options: {
186
- pathsToSkip?: mongoose.pathsToSkip;
187
- }): Promise<void>;
188
- };
189
- validateSync: {
190
- (options: {
191
- [k: string]: any;
192
- pathsToSkip?: mongoose.pathsToSkip;
193
- }): mongoose.Error.ValidationError;
194
- <T_14 extends string | number | symbol>(pathsToValidate?: T_14 | T_14[], options?: mongoose.AnyObject): mongoose.Error.ValidationError;
195
- (pathsToValidate?: mongoose.PathsToValidate, options?: mongoose.AnyObject): mongoose.Error.ValidationError;
196
- };
44
+ _id: mongoose.Types.ObjectId;
197
45
  }[]>;
198
- export declare const getBrokerProducts: (loanBrokerId: string) => Promise<(mongoose.FlattenMaps<import("../models/ProductBroker.model").IProductBrokerDoc> & Required<{
46
+ export declare const getBrokerProducts: (loanBrokerId: string) => Promise<(mongoose.FlattenMaps<import("../models/ProductBroker.model").IProductBroker> & {
199
47
  _id: mongoose.Types.ObjectId;
200
- }>)[]>;
48
+ })[]>;
package/db/brokers.db.js CHANGED
@@ -11,7 +11,7 @@ const reports_db_1 = require("./reports.db");
11
11
  const ProductBroker_model_1 = require("../models/ProductBroker.model");
12
12
  const LoanBroker_model_1 = require("../models/LoanBroker.model");
13
13
  const getProductBrokers = async (productId) => {
14
- return ProductBroker_model_1.ProductBrokerModel.aggregate([
14
+ return ProductBroker_model_1.ProductBroker.aggregate([
15
15
  {
16
16
  '$match': {
17
17
  'productId': new mongoose_1.default.Types.ObjectId(productId),
@@ -63,21 +63,21 @@ const enrichWithBrokers = async (transactions, product) => {
63
63
  };
64
64
  exports.enrichWithBrokers = enrichWithBrokers;
65
65
  const getBorrowerBrokers = async (borrowerId) => {
66
- return ProductBroker_model_1.ProductBrokerModel
66
+ return ProductBroker_model_1.ProductBroker
67
67
  .find({ borrowerId }, { createdAt: 0, updatedAt: 0, __v: 0 })
68
68
  .sort({ order: 1 })
69
69
  .lean();
70
70
  };
71
71
  exports.getBorrowerBrokers = getBorrowerBrokers;
72
72
  const getAllProductBrokers = async () => {
73
- return ProductBroker_model_1.ProductBrokerModel
73
+ return ProductBroker_model_1.ProductBroker
74
74
  .find({}, { createdAt: 0, updatedAt: 0, __v: 0 })
75
75
  .sort({ order: 1 })
76
76
  .lean();
77
77
  };
78
78
  exports.getAllProductBrokers = getAllProductBrokers;
79
79
  const getAllLoanBrokers = async () => {
80
- const results = await LoanBroker_model_1.LoanBrokerModel
80
+ const results = await LoanBroker_model_1.LoanBroker
81
81
  .find({}, { createdAt: 0, updatedAt: 0, __v: 0 })
82
82
  .sort({ order: 1 })
83
83
  .lean();
@@ -88,7 +88,7 @@ const getAllLoanBrokers = async () => {
88
88
  };
89
89
  exports.getAllLoanBrokers = getAllLoanBrokers;
90
90
  const getBrokerProducts = async (loanBrokerId) => {
91
- return ProductBroker_model_1.ProductBrokerModel
91
+ return ProductBroker_model_1.ProductBroker
92
92
  .find({ loanBrokerId }, { createdAt: 0, updatedAt: 0, __v: 0 })
93
93
  .sort({ order: 1, BSCode: 1, PLCode: 1 })
94
94
  .lean();
package/db/brokers.db.ts CHANGED
@@ -4,11 +4,11 @@ import mongoose from 'mongoose';
4
4
  import { MODEL_NAMES } from '../models/_models';
5
5
  import { EChargeType, ILedgerDataRow } from './reports.db';
6
6
  import { ILoanProductDoc } from '../models/LoanProducts.model';
7
- import { IProductBrokerDocWithBroker, ProductBrokerModel } from '../models/ProductBroker.model';
8
- import { LoanBrokerModel } from '../models/LoanBroker.model';
7
+ import { IProductBrokerDocWithLoanBroker, ProductBroker } from '../models/ProductBroker.model';
8
+ import { LoanBroker } from '../models/LoanBroker.model';
9
9
 
10
10
  export const getProductBrokers = async (productId: string) => {
11
- return ProductBrokerModel.aggregate<IProductBrokerDocWithBroker>([
11
+ return ProductBroker.aggregate<IProductBrokerDocWithLoanBroker>([
12
12
  {
13
13
  '$match': {
14
14
  'productId': new mongoose.Types.ObjectId(productId),
@@ -38,7 +38,7 @@ export const enrichWithBrokers = async (transactions: ILedgerDataRow[], product:
38
38
  if (productBrokers.length === 0) {
39
39
  return transactions;
40
40
  }
41
- const handleFee = (t: ILedgerDataRow, broker: IProductBrokerDocWithBroker, shareName: 'adminShare' | 'interestShare' | 'otherShare'): ILedgerDataRow => {
41
+ const handleFee = (t: ILedgerDataRow, broker: IProductBrokerDocWithLoanBroker, shareName: 'adminShare' | 'interestShare' | 'otherShare'): ILedgerDataRow => {
42
42
  return {
43
43
  ...t,
44
44
  statementAmount: new Decimal(-t.statementAmount).mul(broker[shareName]).toDP(2).toNumber(),
@@ -50,9 +50,9 @@ export const enrichWithBrokers = async (transactions: ILedgerDataRow[], product:
50
50
  };
51
51
 
52
52
  const handlers = {
53
- [EChargeType.ADMIN_FEE]: (t: ILedgerDataRow, broker: IProductBrokerDocWithBroker) => handleFee(t, broker, 'adminShare'),
54
- [EChargeType.INTEREST_FEE]: (t: ILedgerDataRow, broker: IProductBrokerDocWithBroker) => handleFee(t, broker, 'interestShare'),
55
- [EChargeType.OTHER]: (t: ILedgerDataRow, broker: IProductBrokerDocWithBroker) => handleFee(t, broker, 'otherShare'),
53
+ [EChargeType.ADMIN_FEE]: (t: ILedgerDataRow, broker: IProductBrokerDocWithLoanBroker) => handleFee(t, broker, 'adminShare'),
54
+ [EChargeType.INTEREST_FEE]: (t: ILedgerDataRow, broker: IProductBrokerDocWithLoanBroker) => handleFee(t, broker, 'interestShare'),
55
+ [EChargeType.OTHER]: (t: ILedgerDataRow, broker: IProductBrokerDocWithLoanBroker) => handleFee(t, broker, 'otherShare'),
56
56
  };
57
57
 
58
58
  return transactions.reduce((acc, t) => {
@@ -62,21 +62,21 @@ export const enrichWithBrokers = async (transactions: ILedgerDataRow[], product:
62
62
  };
63
63
 
64
64
  export const getBorrowerBrokers = async (borrowerId: string) => {
65
- return ProductBrokerModel
65
+ return ProductBroker
66
66
  .find({ borrowerId }, { createdAt: 0, updatedAt: 0, __v: 0 })
67
67
  .sort({ order: 1 })
68
68
  .lean();
69
69
  };
70
70
 
71
71
  export const getAllProductBrokers = async () => {
72
- return ProductBrokerModel
72
+ return ProductBroker
73
73
  .find({}, { createdAt: 0, updatedAt: 0, __v: 0 })
74
74
  .sort({ order: 1 })
75
75
  .lean();
76
76
  };
77
77
 
78
78
  export const getAllLoanBrokers = async () => {
79
- const results = await LoanBrokerModel
79
+ const results = await LoanBroker
80
80
  .find({}, { createdAt: 0, updatedAt: 0, __v: 0 })
81
81
  .sort({ order: 1 })
82
82
  .lean();
@@ -87,7 +87,7 @@ export const getAllLoanBrokers = async () => {
87
87
  };
88
88
 
89
89
  export const getBrokerProducts = async (loanBrokerId: string) => {
90
- return ProductBrokerModel
90
+ return ProductBroker
91
91
  .find({ loanBrokerId }, { createdAt: 0, updatedAt: 0, __v: 0 })
92
92
  .sort({ order: 1, BSCode: 1, PLCode: 1 })
93
93
  .lean();
@@ -31,6 +31,8 @@ import mongoose from 'mongoose';
31
31
  import { TModelName } from './_models';
32
32
  import { TTaskStatus } from '../interfaces/task.interface';
33
33
  export declare const AI_JOBS_FOLDER = "AI_jobs";
34
+ export declare const AI_JOB_TYPES: readonly ["loan-memo-excel", "approval-memo", "email-summary"];
35
+ export type TAIJobType = (typeof AI_JOB_TYPES)[number];
34
36
  export interface IAIJobResponseChunk {
35
37
  type: 'text' | 'thinking' | 'tool' | 'status';
36
38
  timestamp: Date;
@@ -68,6 +70,7 @@ export interface IAIJobTarget {
68
70
  export interface IAIJob {
69
71
  taskId: string;
70
72
  userId: string;
73
+ taskType: TAIJobType;
71
74
  status: TTaskStatus;
72
75
  target: IAIJobTarget;
73
76
  context: unknown;
@@ -3,10 +3,15 @@ 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.AIJob = exports.AIJobSchema = exports.AI_JOBS_FOLDER = void 0;
6
+ exports.AIJob = exports.AIJobSchema = exports.AI_JOB_TYPES = exports.AI_JOBS_FOLDER = void 0;
7
7
  const mongoose_1 = __importDefault(require("mongoose"));
8
8
  const _models_1 = require("./_models");
9
9
  exports.AI_JOBS_FOLDER = 'AI_jobs';
10
+ exports.AI_JOB_TYPES = [
11
+ 'loan-memo-excel',
12
+ 'approval-memo',
13
+ 'email-summary',
14
+ ];
10
15
  exports.AIJobSchema = new mongoose_1.default.Schema({
11
16
  taskId: {
12
17
  type: String,
@@ -16,6 +21,12 @@ exports.AIJobSchema = new mongoose_1.default.Schema({
16
21
  type: 'String',
17
22
  required: true,
18
23
  },
24
+ taskType: {
25
+ type: String,
26
+ enum: exports.AI_JOB_TYPES,
27
+ required: true,
28
+ index: true,
29
+ },
19
30
  status: {
20
31
  type: String,
21
32
  required: true,
@@ -119,5 +130,10 @@ exports.AIJobSchema = new mongoose_1.default.Schema({
119
130
  timestamps: { createdAt: true, updatedAt: true },
120
131
  versionKey: false,
121
132
  });
133
+ exports.AIJobSchema.index({
134
+ userId: 1,
135
+ taskType: 1,
136
+ createdAt: -1,
137
+ });
122
138
  exports.AIJobSchema.index({ taskId: 1, userId: 1, status: 1 }, { unique: true });
123
139
  exports.AIJob = mongoose_1.default.model(_models_1.MODEL_NAMES.AIJobs, exports.AIJobSchema);
@@ -5,6 +5,14 @@ import { TTaskStatus } from '../interfaces/task.interface';
5
5
 
6
6
  export const AI_JOBS_FOLDER = 'AI_jobs';
7
7
 
8
+ export const AI_JOB_TYPES = [
9
+ 'loan-memo-excel',
10
+ 'approval-memo',
11
+ 'email-summary',
12
+ ] as const;
13
+
14
+ export type TAIJobType = (typeof AI_JOB_TYPES)[number];
15
+
8
16
  export interface IAIJobResponseChunk {
9
17
  type: 'text' | 'thinking' | 'tool' | 'status';
10
18
  timestamp: Date;
@@ -51,6 +59,8 @@ export interface IAIJob {
51
59
  taskId: string;
52
60
  userId: string;
53
61
 
62
+ taskType: TAIJobType;
63
+
54
64
  status: TTaskStatus;
55
65
 
56
66
  target: IAIJobTarget;
@@ -109,6 +119,12 @@ export const AIJobSchema = new mongoose.Schema<IAIJob, TAIJobModel>(
109
119
  type: 'String',
110
120
  required: true,
111
121
  },
122
+ taskType: {
123
+ type: String,
124
+ enum: AI_JOB_TYPES,
125
+ required: true,
126
+ index: true,
127
+ },
112
128
  status: {
113
129
  type: String,
114
130
  required: true,
@@ -221,6 +237,12 @@ export const AIJobSchema = new mongoose.Schema<IAIJob, TAIJobModel>(
221
237
  },
222
238
  );
223
239
 
240
+ AIJobSchema.index({
241
+ userId: 1,
242
+ taskType: 1,
243
+ createdAt: -1,
244
+ });
245
+
224
246
  AIJobSchema.index(
225
247
  { taskId: 1, userId: 1, status: 1 },
226
248
  { unique: true },
@@ -1,7 +1,8 @@
1
1
  /// <reference types="mongoose/types/types" />
2
- /// <reference types="mongoose/types/document" />
3
2
  /// <reference types="mongoose/types/models" />
3
+ /// <reference types="mongoose/types/schemaoptions" />
4
4
  /// <reference types="mongoose/types/utility" />
5
+ /// <reference types="mongoose/types/document" />
5
6
  /// <reference types="mongoose/types/aggregate" />
6
7
  /// <reference types="mongoose/types/callback" />
7
8
  /// <reference types="mongoose/types/collection" />
@@ -26,69 +27,42 @@
26
27
  /// <reference types="mongoose/types/validation" />
27
28
  /// <reference types="mongoose/types/virtuals" />
28
29
  /// <reference types="mongoose/types/inferschematype" />
29
- import mongoose, { Document } from 'mongoose';
30
+ import mongoose from 'mongoose';
30
31
  import Joi from 'joi';
31
32
  export declare const LoanBrokerValidationSchema: Joi.ObjectSchema<any>;
32
33
  export interface ILoanBrokerEmail {
33
- _id?: mongoose.Types.ObjectId | string;
34
+ uiId: string;
34
35
  email: string;
35
36
  title: string;
36
37
  isActive: boolean;
37
38
  }
39
+ export interface ILoanBrokerEmailLean extends ILoanBrokerEmail {
40
+ _id: mongoose.Types.ObjectId;
41
+ }
42
+ export interface ILoanBrokerEmailPlain extends ILoanBrokerEmail {
43
+ _id: string;
44
+ }
38
45
  export interface ILoanBroker {
46
+ uiId: string;
39
47
  order: number;
40
48
  active: boolean;
41
49
  name: string;
42
50
  emails: ILoanBrokerEmail[];
43
51
  }
44
- export interface ILoanBrokerWithId extends ILoanBroker {
52
+ export interface ILoanBrokerLean extends ILoanBroker {
45
53
  _id: mongoose.Types.ObjectId;
54
+ createdAt: Date;
55
+ updatedAt: Date;
46
56
  }
47
- export type ILoanBrokerView = Omit<ILoanBrokerWithId, 'order'>;
48
- export interface ILoanBrokerDoc extends ILoanBroker, Document {
57
+ export interface ILoanBrokerPlain extends Omit<ILoanBroker, 'emails'> {
58
+ _id: string;
59
+ emails: ILoanBrokerEmailPlain[];
60
+ createdAt: Date;
61
+ updatedAt: Date;
49
62
  }
50
- export declare const LoanBrokerSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
51
- timestamps: true;
52
- }, {
53
- createdAt: NativeDate;
54
- updatedAt: NativeDate;
55
- } & {
56
- name: string;
57
- order: number;
58
- active: boolean;
59
- emails: mongoose.Types.DocumentArray<{
60
- email: string;
61
- title: string;
62
- isActive: boolean;
63
- }>;
64
- __v?: number;
65
- }, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
66
- createdAt: NativeDate;
67
- updatedAt: NativeDate;
68
- } & {
69
- name: string;
70
- order: number;
71
- active: boolean;
72
- emails: mongoose.Types.DocumentArray<{
73
- email: string;
74
- title: string;
75
- isActive: boolean;
76
- }>;
77
- __v?: number;
78
- }>> & mongoose.FlatRecord<{
79
- createdAt: NativeDate;
80
- updatedAt: NativeDate;
81
- } & {
82
- name: string;
83
- order: number;
84
- active: boolean;
85
- emails: mongoose.Types.DocumentArray<{
86
- email: string;
87
- title: string;
88
- isActive: boolean;
89
- }>;
90
- __v?: number;
91
- }> & {
63
+ export type TLoanBrokerDoc = mongoose.HydratedDocument<ILoanBroker>;
64
+ export type LoanBrokerModel = mongoose.Model<ILoanBroker>;
65
+ export declare const LoanBrokerSchema: mongoose.Schema<ILoanBroker, LoanBrokerModel, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, ILoanBroker, mongoose.Document<unknown, {}, mongoose.FlatRecord<ILoanBroker>> & mongoose.FlatRecord<ILoanBroker> & {
92
66
  _id: mongoose.Types.ObjectId;
93
67
  }>;
94
- export declare const LoanBrokerModel: mongoose.Model<ILoanBrokerDoc>;
68
+ export declare const LoanBroker: LoanBrokerModel;
@@ -3,18 +3,24 @@ 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.LoanBrokerModel = exports.LoanBrokerSchema = exports.LoanBrokerValidationSchema = void 0;
6
+ exports.LoanBroker = exports.LoanBrokerSchema = exports.LoanBrokerValidationSchema = void 0;
7
7
  const mongoose_1 = __importDefault(require("mongoose"));
8
8
  const joi_1 = __importDefault(require("joi"));
9
9
  const _models_1 = require("./_models");
10
10
  exports.LoanBrokerValidationSchema = joi_1.default.object({
11
11
  _id: joi_1.default.string().allow(null),
12
+ uiId: joi_1.default.string(),
12
13
  order: joi_1.default.number(),
13
14
  active: joi_1.default.boolean().required(),
14
15
  name: joi_1.default.string().required(),
15
16
  emails: joi_1.default.array(),
16
17
  });
17
18
  exports.LoanBrokerSchema = new mongoose_1.default.Schema({
19
+ uiId: {
20
+ type: String,
21
+ required: true,
22
+ trim: true,
23
+ },
18
24
  order: {
19
25
  type: Number,
20
26
  required: true,
@@ -29,6 +35,11 @@ exports.LoanBrokerSchema = new mongoose_1.default.Schema({
29
35
  trim: true,
30
36
  },
31
37
  emails: [{
38
+ uiId: {
39
+ type: String,
40
+ required: true,
41
+ trim: true,
42
+ },
32
43
  email: {
33
44
  type: String,
34
45
  required: true,
@@ -44,6 +55,8 @@ exports.LoanBrokerSchema = new mongoose_1.default.Schema({
44
55
  required: true,
45
56
  },
46
57
  }],
47
- __v: { type: Number, select: false },
48
- }, { timestamps: true });
49
- exports.LoanBrokerModel = mongoose_1.default.model(_models_1.MODEL_NAMES.loanBrokers, exports.LoanBrokerSchema);
58
+ }, {
59
+ timestamps: { createdAt: true, updatedAt: true },
60
+ versionKey: false,
61
+ });
62
+ exports.LoanBroker = mongoose_1.default.model(_models_1.MODEL_NAMES.loanBrokers, exports.LoanBrokerSchema);
@@ -1,10 +1,11 @@
1
- import mongoose, { Document } from 'mongoose';
1
+ import mongoose from 'mongoose';
2
2
  import Joi from 'joi';
3
3
 
4
4
  import { MODEL_NAMES } from './_models';
5
5
 
6
6
  export const LoanBrokerValidationSchema = Joi.object({
7
7
  _id: Joi.string().allow(null),
8
+ uiId: Joi.string(),
8
9
  order: Joi.number(),
9
10
  active: Joi.boolean().required(),
10
11
  name: Joi.string().required(),
@@ -12,30 +13,52 @@ export const LoanBrokerValidationSchema = Joi.object({
12
13
  });
13
14
 
14
15
  export interface ILoanBrokerEmail {
15
- _id?: mongoose.Types.ObjectId | string
16
+ uiId: string;
16
17
  email: string,
17
18
  title: string,
18
19
  isActive: boolean
19
20
  }
20
21
 
22
+ export interface ILoanBrokerEmailLean extends ILoanBrokerEmail {
23
+ _id: mongoose.Types.ObjectId;
24
+ }
25
+
26
+ export interface ILoanBrokerEmailPlain extends ILoanBrokerEmail {
27
+ _id: string;
28
+ }
29
+
21
30
  export interface ILoanBroker {
31
+ uiId: string;
22
32
  order: number;
23
33
  active: boolean;
24
34
  name: string;
25
35
  emails: ILoanBrokerEmail[];
26
36
  }
27
37
 
28
- export interface ILoanBrokerWithId extends ILoanBroker {
38
+ export interface ILoanBrokerLean extends ILoanBroker {
29
39
  _id: mongoose.Types.ObjectId;
40
+ createdAt: Date;
41
+ updatedAt: Date;
30
42
  }
31
43
 
32
- export type ILoanBrokerView = Omit<ILoanBrokerWithId, 'order'>
33
-
34
- export interface ILoanBrokerDoc extends ILoanBroker, Document {
44
+ export interface ILoanBrokerPlain extends Omit<ILoanBroker, 'emails'> {
45
+ _id: string;
46
+ emails: ILoanBrokerEmailPlain[];
47
+ createdAt: Date;
48
+ updatedAt: Date;
35
49
  }
36
50
 
37
- export const LoanBrokerSchema = new mongoose.Schema(
51
+ export type TLoanBrokerDoc = mongoose.HydratedDocument<ILoanBroker>
52
+
53
+ export type LoanBrokerModel = mongoose.Model<ILoanBroker>;
54
+
55
+ export const LoanBrokerSchema = new mongoose.Schema<ILoanBroker, LoanBrokerModel>(
38
56
  {
57
+ uiId: {
58
+ type: String,
59
+ required: true,
60
+ trim: true,
61
+ },
39
62
  order: {
40
63
  type: Number,
41
64
  required: true,
@@ -50,6 +73,11 @@ export const LoanBrokerSchema = new mongoose.Schema(
50
73
  trim: true,
51
74
  },
52
75
  emails: [{
76
+ uiId: {
77
+ type: String,
78
+ required: true,
79
+ trim: true,
80
+ },
53
81
  email: {
54
82
  type: String,
55
83
  required: true,
@@ -65,9 +93,11 @@ export const LoanBrokerSchema = new mongoose.Schema(
65
93
  required: true,
66
94
  },
67
95
  }],
68
- __v: { type: Number, select: false },
69
96
  },
70
- { timestamps: true },
97
+ {
98
+ timestamps: { createdAt: true, updatedAt: true },
99
+ versionKey: false,
100
+ },
71
101
  );
72
102
 
73
- export const LoanBrokerModel: mongoose.Model<ILoanBrokerDoc> = mongoose.model<ILoanBrokerDoc>(MODEL_NAMES.loanBrokers, LoanBrokerSchema);
103
+ export const LoanBroker = mongoose.model<ILoanBroker, LoanBrokerModel>(MODEL_NAMES.loanBrokers, LoanBrokerSchema);