@dynamatix/gb-schemas 2.3.241 โ 2.3.242
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/README.md +308 -308
- package/dist/applicants/applicant.model.d.ts +6 -6
- package/dist/applicants/applicant.model.d.ts.map +1 -1
- package/dist/applicants/applicant.model.js +0 -3
- package/dist/applications/application-valuation-report.model.d.ts +2520 -0
- package/dist/applications/application-valuation-report.model.d.ts.map +1 -1
- package/dist/applications/application-valuation-report.model.js +445 -0
- package/dist/applications/application-valuation-report.type.d.ts +142 -0
- package/dist/applications/application-valuation-report.type.d.ts.map +1 -1
- package/dist/applications/application-valuation.model.d.ts +6 -6
- package/dist/applications/application.model.d.ts +6 -6
- package/dist/applications/broker.model.d.ts +6 -6
- package/dist/applications/solicitor.model.d.ts +6 -6
- package/dist/properties/property.model.d.ts +6 -6
- package/package.json +87 -87
- package/dist/applicants/applicant-income-source.model.d.ts +0 -26
- package/dist/applicants/applicant-income-source.model.d.ts.map +0 -1
- package/dist/applicants/applicant-income.model.d.ts +0 -160
- package/dist/applicants/applicant-income.model.d.ts.map +0 -1
- package/dist/applicants/applicant-other-income.model.d.ts +0 -85
- package/dist/applicants/applicant-other-income.model.d.ts.map +0 -1
- package/dist/applications/application-document.model.d.ts +0 -158
- package/dist/applications/application-document.model.d.ts.map +0 -1
- package/dist/applications/document.model.d.ts +0 -158
- package/dist/applications/document.model.d.ts.map +0 -1
- package/dist/applications/productfeatures.model.d.ts +0 -368
- package/dist/applications/productfeatures.model.d.ts.map +0 -1
- package/dist/shared/document-type-model.d.ts +0 -48
- package/dist/shared/document-type-model.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,309 +1,309 @@
|
|
|
1
|
-
# GB Schemas (@dynamatix/gb-schemas)
|
|
2
|
-
|
|
3
|
-
A comprehensive TypeScript/Mongoose schema library for Gatehouse Bank backend systems, providing data models for mortgage applications, applicants, properties, and related financial services.
|
|
4
|
-
|
|
5
|
-
## ๐๏ธ Project Overview
|
|
6
|
-
|
|
7
|
-
This package contains all the schemas and data models used in Gatehouse Bank's backend systems. It provides a robust foundation for managing mortgage applications, applicant data, property information, and various financial commitments through well-defined Mongoose schemas with TypeScript support.
|
|
8
|
-
|
|
9
|
-
## ๐ฆ Package Information
|
|
10
|
-
|
|
11
|
-
- **Name**: `@dynamatix/gb-schemas`
|
|
12
|
-
- **Version**: 1.3.305
|
|
13
|
-
- **Description**: All the schemas for Gatehouse Bank back-end
|
|
14
|
-
- **Type**: ES Module
|
|
15
|
-
- **Main**: `dist/index.js`
|
|
16
|
-
- **Types**: `dist/index.d.ts`
|
|
17
|
-
|
|
18
|
-
## ๐ Features
|
|
19
|
-
|
|
20
|
-
- **TypeScript Support**: Full TypeScript definitions and type safety
|
|
21
|
-
- **Mongoose Integration**: Built on Mongoose ODM for MongoDB
|
|
22
|
-
- **Audit Middleware**: Built-in audit trail support via `@dynamatix/cat-shared`
|
|
23
|
-
- **Workflow Middleware**: Automatic workflow triggering based on database events
|
|
24
|
-
- **Custom Value Objects**: Specialized types for financial data (Pound, Account Number, Sort Code)
|
|
25
|
-
- **Modular Architecture**: Organized into logical domains (applications, applicants, properties, etc.)
|
|
26
|
-
- **Migration Scripts**: Comprehensive data migration and maintenance tools
|
|
27
|
-
|
|
28
|
-
## ๐ Project Structure
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
gb-schemas-node/
|
|
32
|
-
โโโ applicants/ # Applicant-related schemas and models
|
|
33
|
-
โโโ applications/ # Application management schemas
|
|
34
|
-
โโโ properties/ # Property and security schemas
|
|
35
|
-
โโโ product-catalogues/ # Product definition schemas
|
|
36
|
-
โโโ shared/ # Common/shared schemas and utilities
|
|
37
|
-
โโโ users/ # User management schemas
|
|
38
|
-
โโโ underwriter/ # Underwriting-related schemas
|
|
39
|
-
โโโ value-objects/ # Custom Mongoose types
|
|
40
|
-
โโโ api-models/ # API-specific model definitions
|
|
41
|
-
โโโ entities/ # Entity layer schemas
|
|
42
|
-
โโโ examples/ # Usage examples
|
|
43
|
-
โโโ scripts/ # Migration and utility scripts
|
|
44
|
-
โโโ schema-docs/ # Schema documentation generation
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## ๐ง Installation
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
npm install @dynamatix/gb-schemas
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## ๐ Usage
|
|
54
|
-
|
|
55
|
-
### Basic Import
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
import {
|
|
59
|
-
ApplicantModel,
|
|
60
|
-
ApplicationModel,
|
|
61
|
-
PropertyModel
|
|
62
|
-
} from '@dynamatix/gb-schemas';
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Modular Imports
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
// Import specific modules
|
|
69
|
-
import { ApplicantModel } from '@dynamatix/gb-schemas/applicants';
|
|
70
|
-
import { ApplicationModel } from '@dynamatix/gb-schemas/applications';
|
|
71
|
-
import { PropertyModel } from '@dynamatix/gb-schemas/properties';
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Example: Adding Applicant Income
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
import mongoose from 'mongoose';
|
|
78
|
-
import ApplicantIncomeModel from '@dynamatix/gb-schemas/applicants/applicant-income.model';
|
|
79
|
-
|
|
80
|
-
// Connect to MongoDB
|
|
81
|
-
await mongoose.connect(MONGODB_URI);
|
|
82
|
-
|
|
83
|
-
// Create new applicant income record
|
|
84
|
-
const newIncome = new ApplicantIncomeModel({
|
|
85
|
-
applicantId: 'your-applicant-id',
|
|
86
|
-
selfEmployedIncomeRationale: 'Based on last 2 years of accounts'
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const savedIncome = await newIncome.save();
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Workflow Middleware
|
|
93
|
-
|
|
94
|
-
The library includes a powerful workflow middleware system that automatically triggers workflows based on database events.
|
|
95
|
-
|
|
96
|
-
```typescript
|
|
97
|
-
import { initializeWorkflowMiddlewareWithCheck } from '@dynamatix/gb-schemas';
|
|
98
|
-
|
|
99
|
-
// Initialize workflow middleware for ALL schemas with one call
|
|
100
|
-
initializeWorkflowMiddlewareWithCheck();
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
**Environment Variables:**
|
|
104
|
-
- `WORKFLOW_API_KEY`: Required API key for workflow service authentication
|
|
105
|
-
- `WORKFLOW_API_URL`: Optional workflow API URL (default: https://your-workflow-api.com/api/v1/workflows/execute)
|
|
106
|
-
- `WORKFLOW_TIMEOUT`: Optional timeout in milliseconds (default: 30000)
|
|
107
|
-
- `WORKFLOW_RETRY_ATTEMPTS`: Optional retry attempts (default: 3)
|
|
108
|
-
- `WORKFLOW_RETRY_DELAY`: Optional retry delay in milliseconds (default: 1000)
|
|
109
|
-
|
|
110
|
-
For detailed documentation, see [Workflow Middleware Guide](./docs/WORKFLOW_MIDDLEWARE.md).
|
|
111
|
-
|
|
112
|
-
## ๐๏ธ Core Schemas
|
|
113
|
-
|
|
114
|
-
### Applicants
|
|
115
|
-
- **Applicant**: Core applicant information (personal details, addresses, employment status)
|
|
116
|
-
- **Applicant Income**: Various income types (employment, self-employed, pension, property)
|
|
117
|
-
- **Applicant Commitments**: Financial commitments (mortgages, loans, credit cards)
|
|
118
|
-
- **Applicant Credit Data**: Credit profile and credit report information
|
|
119
|
-
- **Applicant Expenditure**: Spending patterns and financial outgoings
|
|
120
|
-
|
|
121
|
-
### Applications
|
|
122
|
-
- **Application**: Main application record with workflow and status tracking
|
|
123
|
-
- **Application Mortgage**: Mortgage-specific application details
|
|
124
|
-
- **Application Credit Profile**: Credit assessment information
|
|
125
|
-
- **Application Legal**: Legal documentation and compliance data
|
|
126
|
-
- **Application Notes**: Application-related notes and comments
|
|
127
|
-
|
|
128
|
-
### Properties
|
|
129
|
-
- **Property**: Property details and characteristics
|
|
130
|
-
- **Security**: Security and collateral information
|
|
131
|
-
|
|
132
|
-
### Product Catalogues
|
|
133
|
-
- **Product Catalogue**: Product definitions and variants
|
|
134
|
-
- **Product Definitions**: Detailed product specifications
|
|
135
|
-
- **Product Variants**: Product customization options
|
|
136
|
-
|
|
137
|
-
### Shared Models
|
|
138
|
-
- **Lookup**: Reference data and lookup values
|
|
139
|
-
- **System Parameters**: Configuration and system settings
|
|
140
|
-
- **Tasks**: Workflow task management
|
|
141
|
-
- **Alerts**: System notification system
|
|
142
|
-
- **Workflow Triggers**: Configuration for automatic workflow execution
|
|
143
|
-
|
|
144
|
-
## ๐ฐ Custom Value Objects
|
|
145
|
-
|
|
146
|
-
### Pound Type
|
|
147
|
-
Custom Mongoose type for handling UK currency values with automatic formatting and validation.
|
|
148
|
-
|
|
149
|
-
```typescript
|
|
150
|
-
import { Pound, formatPound } from '@dynamatix/gb-schemas/value-objects/pound';
|
|
151
|
-
|
|
152
|
-
// Automatically handles currency formatting and validation
|
|
153
|
-
const amount = new Pound('1,234.56'); // Returns 1234.56
|
|
154
|
-
const formatted = formatPound(1234.56); // Returns "ยฃ1,234.56"
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### Account Number & Sort Code
|
|
158
|
-
Specialized types for UK banking information with validation.
|
|
159
|
-
|
|
160
|
-
## ๐ Migration Scripts
|
|
161
|
-
|
|
162
|
-
The project includes comprehensive migration and maintenance scripts:
|
|
163
|
-
|
|
164
|
-
### Available Scripts
|
|
165
|
-
|
|
166
|
-
```bash
|
|
167
|
-
# Income migration
|
|
168
|
-
npm run migrate:applicant-income
|
|
169
|
-
|
|
170
|
-
# Self-employed ID migration
|
|
171
|
-
npm run migrate:self-employed-id
|
|
172
|
-
|
|
173
|
-
# Employment verification
|
|
174
|
-
npm run check:applicants-employment
|
|
175
|
-
|
|
176
|
-
# Application cleanup
|
|
177
|
-
npm run delete:applications-by-type
|
|
178
|
-
|
|
179
|
-
# API config updates
|
|
180
|
-
npm run update:apiconfigs-paths
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### Key Migration Scripts
|
|
184
|
-
|
|
185
|
-
- **`migrate-applicant-income.js`**: Migrates from old income model to new separated models
|
|
186
|
-
- **`migrate-self-employed-id.js`**: Updates self-employed applicant references
|
|
187
|
-
- **`check-applicants-without-employment.js`**: Validates employment data integrity
|
|
188
|
-
- **`update-apiconfigs-paths.js`**: Updates API configuration paths
|
|
189
|
-
|
|
190
|
-
## ๐ ๏ธ Development
|
|
191
|
-
|
|
192
|
-
### Prerequisites
|
|
193
|
-
|
|
194
|
-
- Node.js (v18+)
|
|
195
|
-
- TypeScript 5.3+
|
|
196
|
-
- MongoDB 6.14+
|
|
197
|
-
|
|
198
|
-
### Setup
|
|
199
|
-
|
|
200
|
-
```bash
|
|
201
|
-
# Install dependencies
|
|
202
|
-
npm install
|
|
203
|
-
|
|
204
|
-
# Build the project
|
|
205
|
-
npm run build
|
|
206
|
-
|
|
207
|
-
# Generate documentation
|
|
208
|
-
npm run generate-docs
|
|
209
|
-
|
|
210
|
-
# Run examples
|
|
211
|
-
npm run example:income
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### Build Configuration
|
|
215
|
-
|
|
216
|
-
The project uses TypeScript with ES2020 modules and generates declaration files:
|
|
217
|
-
|
|
218
|
-
```json
|
|
219
|
-
{
|
|
220
|
-
"target": "ES2020",
|
|
221
|
-
"module": "ES2020",
|
|
222
|
-
"outDir": "./dist",
|
|
223
|
-
"declaration": true,
|
|
224
|
-
"declarationMap": true
|
|
225
|
-
}
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
## ๐ API Reference
|
|
229
|
-
|
|
230
|
-
### Main Exports
|
|
231
|
-
|
|
232
|
-
```typescript
|
|
233
|
-
// Core models
|
|
234
|
-
export * from './applications';
|
|
235
|
-
export * from './applicants';
|
|
236
|
-
export * from './properties';
|
|
237
|
-
export * from './shared';
|
|
238
|
-
export * from './users';
|
|
239
|
-
export * from './product-catalogues';
|
|
240
|
-
export * from './underwriter';
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### Model Relationships
|
|
244
|
-
|
|
245
|
-
- **Applications** โ **Applicants** (one-to-many)
|
|
246
|
-
- **Applications** โ **Properties** (one-to-many)
|
|
247
|
-
- **Applications** โ **Product** (many-to-one)
|
|
248
|
-
- **Applicants** โ **Income Models** (one-to-many)
|
|
249
|
-
- **Applicants** โ **Commitment Models** (one-to-many)
|
|
250
|
-
|
|
251
|
-
## ๐ Security & Compliance
|
|
252
|
-
|
|
253
|
-
- **GDPR Support**: Built-in GDPR consent tracking
|
|
254
|
-
- **Audit Trail**: Comprehensive audit logging via middleware
|
|
255
|
-
- **Data Validation**: Strict schema validation and type checking
|
|
256
|
-
- **Access Control**: User permission and role-based access models
|
|
257
|
-
|
|
258
|
-
## ๐งช Testing & Examples
|
|
259
|
-
|
|
260
|
-
### Example Scripts
|
|
261
|
-
|
|
262
|
-
- **`add-applicant-income.ts`**: Demonstrates creating applicant income records
|
|
263
|
-
- **Migration Scripts**: Show real-world data migration patterns
|
|
264
|
-
|
|
265
|
-
### Running Examples
|
|
266
|
-
|
|
267
|
-
```bash
|
|
268
|
-
# Run income example
|
|
269
|
-
npm run example:income
|
|
270
|
-
|
|
271
|
-
# Generate documentation
|
|
272
|
-
npm run generate-docs
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
## ๐ Documentation
|
|
276
|
-
|
|
277
|
-
- **Schema Documentation**: Auto-generated via `npm run generate-docs`
|
|
278
|
-
- **Migration Guides**: Detailed README files in the `scripts/` directory
|
|
279
|
-
- **API Models**: Type-safe API model definitions
|
|
280
|
-
|
|
281
|
-
## ๐ค Contributing
|
|
282
|
-
|
|
283
|
-
1. Fork the repository
|
|
284
|
-
2. Create a feature branch
|
|
285
|
-
3. Make your changes
|
|
286
|
-
4. Ensure TypeScript compilation passes
|
|
287
|
-
5. Submit a pull request
|
|
288
|
-
|
|
289
|
-
## ๐ License
|
|
290
|
-
|
|
291
|
-
ISC License - see package.json for details
|
|
292
|
-
|
|
293
|
-
## ๐ Support
|
|
294
|
-
|
|
295
|
-
- **Issues**: [GitHub Issues](https://github.com/DynamatixAnalyticsPvtLtd/gb-schemas/issues)
|
|
296
|
-
- **Repository**: [GitHub Repository](https://github.com/DynamatixAnalyticsPvtLtd/gb-schemas)
|
|
297
|
-
- **Author**: Dynamatix
|
|
298
|
-
|
|
299
|
-
## ๐ Version History
|
|
300
|
-
|
|
301
|
-
- **Current**: 1.3.305
|
|
302
|
-
- **Dependencies**:
|
|
303
|
-
- `@dynamatix/cat-shared`: ^0.0.119
|
|
304
|
-
- `mongoose`: ^8.9.5
|
|
305
|
-
- `mongodb`: ^6.14.2
|
|
306
|
-
|
|
307
|
-
---
|
|
308
|
-
|
|
1
|
+
# GB Schemas (@dynamatix/gb-schemas)
|
|
2
|
+
|
|
3
|
+
A comprehensive TypeScript/Mongoose schema library for Gatehouse Bank backend systems, providing data models for mortgage applications, applicants, properties, and related financial services.
|
|
4
|
+
|
|
5
|
+
## ๐๏ธ Project Overview
|
|
6
|
+
|
|
7
|
+
This package contains all the schemas and data models used in Gatehouse Bank's backend systems. It provides a robust foundation for managing mortgage applications, applicant data, property information, and various financial commitments through well-defined Mongoose schemas with TypeScript support.
|
|
8
|
+
|
|
9
|
+
## ๐ฆ Package Information
|
|
10
|
+
|
|
11
|
+
- **Name**: `@dynamatix/gb-schemas`
|
|
12
|
+
- **Version**: 1.3.305
|
|
13
|
+
- **Description**: All the schemas for Gatehouse Bank back-end
|
|
14
|
+
- **Type**: ES Module
|
|
15
|
+
- **Main**: `dist/index.js`
|
|
16
|
+
- **Types**: `dist/index.d.ts`
|
|
17
|
+
|
|
18
|
+
## ๐ Features
|
|
19
|
+
|
|
20
|
+
- **TypeScript Support**: Full TypeScript definitions and type safety
|
|
21
|
+
- **Mongoose Integration**: Built on Mongoose ODM for MongoDB
|
|
22
|
+
- **Audit Middleware**: Built-in audit trail support via `@dynamatix/cat-shared`
|
|
23
|
+
- **Workflow Middleware**: Automatic workflow triggering based on database events
|
|
24
|
+
- **Custom Value Objects**: Specialized types for financial data (Pound, Account Number, Sort Code)
|
|
25
|
+
- **Modular Architecture**: Organized into logical domains (applications, applicants, properties, etc.)
|
|
26
|
+
- **Migration Scripts**: Comprehensive data migration and maintenance tools
|
|
27
|
+
|
|
28
|
+
## ๐ Project Structure
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
gb-schemas-node/
|
|
32
|
+
โโโ applicants/ # Applicant-related schemas and models
|
|
33
|
+
โโโ applications/ # Application management schemas
|
|
34
|
+
โโโ properties/ # Property and security schemas
|
|
35
|
+
โโโ product-catalogues/ # Product definition schemas
|
|
36
|
+
โโโ shared/ # Common/shared schemas and utilities
|
|
37
|
+
โโโ users/ # User management schemas
|
|
38
|
+
โโโ underwriter/ # Underwriting-related schemas
|
|
39
|
+
โโโ value-objects/ # Custom Mongoose types
|
|
40
|
+
โโโ api-models/ # API-specific model definitions
|
|
41
|
+
โโโ entities/ # Entity layer schemas
|
|
42
|
+
โโโ examples/ # Usage examples
|
|
43
|
+
โโโ scripts/ # Migration and utility scripts
|
|
44
|
+
โโโ schema-docs/ # Schema documentation generation
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## ๐ง Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install @dynamatix/gb-schemas
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## ๐ Usage
|
|
54
|
+
|
|
55
|
+
### Basic Import
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import {
|
|
59
|
+
ApplicantModel,
|
|
60
|
+
ApplicationModel,
|
|
61
|
+
PropertyModel
|
|
62
|
+
} from '@dynamatix/gb-schemas';
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Modular Imports
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// Import specific modules
|
|
69
|
+
import { ApplicantModel } from '@dynamatix/gb-schemas/applicants';
|
|
70
|
+
import { ApplicationModel } from '@dynamatix/gb-schemas/applications';
|
|
71
|
+
import { PropertyModel } from '@dynamatix/gb-schemas/properties';
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Example: Adding Applicant Income
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import mongoose from 'mongoose';
|
|
78
|
+
import ApplicantIncomeModel from '@dynamatix/gb-schemas/applicants/applicant-income.model';
|
|
79
|
+
|
|
80
|
+
// Connect to MongoDB
|
|
81
|
+
await mongoose.connect(MONGODB_URI);
|
|
82
|
+
|
|
83
|
+
// Create new applicant income record
|
|
84
|
+
const newIncome = new ApplicantIncomeModel({
|
|
85
|
+
applicantId: 'your-applicant-id',
|
|
86
|
+
selfEmployedIncomeRationale: 'Based on last 2 years of accounts'
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const savedIncome = await newIncome.save();
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Workflow Middleware
|
|
93
|
+
|
|
94
|
+
The library includes a powerful workflow middleware system that automatically triggers workflows based on database events.
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { initializeWorkflowMiddlewareWithCheck } from '@dynamatix/gb-schemas';
|
|
98
|
+
|
|
99
|
+
// Initialize workflow middleware for ALL schemas with one call
|
|
100
|
+
initializeWorkflowMiddlewareWithCheck();
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Environment Variables:**
|
|
104
|
+
- `WORKFLOW_API_KEY`: Required API key for workflow service authentication
|
|
105
|
+
- `WORKFLOW_API_URL`: Optional workflow API URL (default: https://your-workflow-api.com/api/v1/workflows/execute)
|
|
106
|
+
- `WORKFLOW_TIMEOUT`: Optional timeout in milliseconds (default: 30000)
|
|
107
|
+
- `WORKFLOW_RETRY_ATTEMPTS`: Optional retry attempts (default: 3)
|
|
108
|
+
- `WORKFLOW_RETRY_DELAY`: Optional retry delay in milliseconds (default: 1000)
|
|
109
|
+
|
|
110
|
+
For detailed documentation, see [Workflow Middleware Guide](./docs/WORKFLOW_MIDDLEWARE.md).
|
|
111
|
+
|
|
112
|
+
## ๐๏ธ Core Schemas
|
|
113
|
+
|
|
114
|
+
### Applicants
|
|
115
|
+
- **Applicant**: Core applicant information (personal details, addresses, employment status)
|
|
116
|
+
- **Applicant Income**: Various income types (employment, self-employed, pension, property)
|
|
117
|
+
- **Applicant Commitments**: Financial commitments (mortgages, loans, credit cards)
|
|
118
|
+
- **Applicant Credit Data**: Credit profile and credit report information
|
|
119
|
+
- **Applicant Expenditure**: Spending patterns and financial outgoings
|
|
120
|
+
|
|
121
|
+
### Applications
|
|
122
|
+
- **Application**: Main application record with workflow and status tracking
|
|
123
|
+
- **Application Mortgage**: Mortgage-specific application details
|
|
124
|
+
- **Application Credit Profile**: Credit assessment information
|
|
125
|
+
- **Application Legal**: Legal documentation and compliance data
|
|
126
|
+
- **Application Notes**: Application-related notes and comments
|
|
127
|
+
|
|
128
|
+
### Properties
|
|
129
|
+
- **Property**: Property details and characteristics
|
|
130
|
+
- **Security**: Security and collateral information
|
|
131
|
+
|
|
132
|
+
### Product Catalogues
|
|
133
|
+
- **Product Catalogue**: Product definitions and variants
|
|
134
|
+
- **Product Definitions**: Detailed product specifications
|
|
135
|
+
- **Product Variants**: Product customization options
|
|
136
|
+
|
|
137
|
+
### Shared Models
|
|
138
|
+
- **Lookup**: Reference data and lookup values
|
|
139
|
+
- **System Parameters**: Configuration and system settings
|
|
140
|
+
- **Tasks**: Workflow task management
|
|
141
|
+
- **Alerts**: System notification system
|
|
142
|
+
- **Workflow Triggers**: Configuration for automatic workflow execution
|
|
143
|
+
|
|
144
|
+
## ๐ฐ Custom Value Objects
|
|
145
|
+
|
|
146
|
+
### Pound Type
|
|
147
|
+
Custom Mongoose type for handling UK currency values with automatic formatting and validation.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { Pound, formatPound } from '@dynamatix/gb-schemas/value-objects/pound';
|
|
151
|
+
|
|
152
|
+
// Automatically handles currency formatting and validation
|
|
153
|
+
const amount = new Pound('1,234.56'); // Returns 1234.56
|
|
154
|
+
const formatted = formatPound(1234.56); // Returns "ยฃ1,234.56"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Account Number & Sort Code
|
|
158
|
+
Specialized types for UK banking information with validation.
|
|
159
|
+
|
|
160
|
+
## ๐ Migration Scripts
|
|
161
|
+
|
|
162
|
+
The project includes comprehensive migration and maintenance scripts:
|
|
163
|
+
|
|
164
|
+
### Available Scripts
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Income migration
|
|
168
|
+
npm run migrate:applicant-income
|
|
169
|
+
|
|
170
|
+
# Self-employed ID migration
|
|
171
|
+
npm run migrate:self-employed-id
|
|
172
|
+
|
|
173
|
+
# Employment verification
|
|
174
|
+
npm run check:applicants-employment
|
|
175
|
+
|
|
176
|
+
# Application cleanup
|
|
177
|
+
npm run delete:applications-by-type
|
|
178
|
+
|
|
179
|
+
# API config updates
|
|
180
|
+
npm run update:apiconfigs-paths
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Key Migration Scripts
|
|
184
|
+
|
|
185
|
+
- **`migrate-applicant-income.js`**: Migrates from old income model to new separated models
|
|
186
|
+
- **`migrate-self-employed-id.js`**: Updates self-employed applicant references
|
|
187
|
+
- **`check-applicants-without-employment.js`**: Validates employment data integrity
|
|
188
|
+
- **`update-apiconfigs-paths.js`**: Updates API configuration paths
|
|
189
|
+
|
|
190
|
+
## ๐ ๏ธ Development
|
|
191
|
+
|
|
192
|
+
### Prerequisites
|
|
193
|
+
|
|
194
|
+
- Node.js (v18+)
|
|
195
|
+
- TypeScript 5.3+
|
|
196
|
+
- MongoDB 6.14+
|
|
197
|
+
|
|
198
|
+
### Setup
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Install dependencies
|
|
202
|
+
npm install
|
|
203
|
+
|
|
204
|
+
# Build the project
|
|
205
|
+
npm run build
|
|
206
|
+
|
|
207
|
+
# Generate documentation
|
|
208
|
+
npm run generate-docs
|
|
209
|
+
|
|
210
|
+
# Run examples
|
|
211
|
+
npm run example:income
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Build Configuration
|
|
215
|
+
|
|
216
|
+
The project uses TypeScript with ES2020 modules and generates declaration files:
|
|
217
|
+
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"target": "ES2020",
|
|
221
|
+
"module": "ES2020",
|
|
222
|
+
"outDir": "./dist",
|
|
223
|
+
"declaration": true,
|
|
224
|
+
"declarationMap": true
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## ๐ API Reference
|
|
229
|
+
|
|
230
|
+
### Main Exports
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
// Core models
|
|
234
|
+
export * from './applications';
|
|
235
|
+
export * from './applicants';
|
|
236
|
+
export * from './properties';
|
|
237
|
+
export * from './shared';
|
|
238
|
+
export * from './users';
|
|
239
|
+
export * from './product-catalogues';
|
|
240
|
+
export * from './underwriter';
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Model Relationships
|
|
244
|
+
|
|
245
|
+
- **Applications** โ **Applicants** (one-to-many)
|
|
246
|
+
- **Applications** โ **Properties** (one-to-many)
|
|
247
|
+
- **Applications** โ **Product** (many-to-one)
|
|
248
|
+
- **Applicants** โ **Income Models** (one-to-many)
|
|
249
|
+
- **Applicants** โ **Commitment Models** (one-to-many)
|
|
250
|
+
|
|
251
|
+
## ๐ Security & Compliance
|
|
252
|
+
|
|
253
|
+
- **GDPR Support**: Built-in GDPR consent tracking
|
|
254
|
+
- **Audit Trail**: Comprehensive audit logging via middleware
|
|
255
|
+
- **Data Validation**: Strict schema validation and type checking
|
|
256
|
+
- **Access Control**: User permission and role-based access models
|
|
257
|
+
|
|
258
|
+
## ๐งช Testing & Examples
|
|
259
|
+
|
|
260
|
+
### Example Scripts
|
|
261
|
+
|
|
262
|
+
- **`add-applicant-income.ts`**: Demonstrates creating applicant income records
|
|
263
|
+
- **Migration Scripts**: Show real-world data migration patterns
|
|
264
|
+
|
|
265
|
+
### Running Examples
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
# Run income example
|
|
269
|
+
npm run example:income
|
|
270
|
+
|
|
271
|
+
# Generate documentation
|
|
272
|
+
npm run generate-docs
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## ๐ Documentation
|
|
276
|
+
|
|
277
|
+
- **Schema Documentation**: Auto-generated via `npm run generate-docs`
|
|
278
|
+
- **Migration Guides**: Detailed README files in the `scripts/` directory
|
|
279
|
+
- **API Models**: Type-safe API model definitions
|
|
280
|
+
|
|
281
|
+
## ๐ค Contributing
|
|
282
|
+
|
|
283
|
+
1. Fork the repository
|
|
284
|
+
2. Create a feature branch
|
|
285
|
+
3. Make your changes
|
|
286
|
+
4. Ensure TypeScript compilation passes
|
|
287
|
+
5. Submit a pull request
|
|
288
|
+
|
|
289
|
+
## ๐ License
|
|
290
|
+
|
|
291
|
+
ISC License - see package.json for details
|
|
292
|
+
|
|
293
|
+
## ๐ Support
|
|
294
|
+
|
|
295
|
+
- **Issues**: [GitHub Issues](https://github.com/DynamatixAnalyticsPvtLtd/gb-schemas/issues)
|
|
296
|
+
- **Repository**: [GitHub Repository](https://github.com/DynamatixAnalyticsPvtLtd/gb-schemas)
|
|
297
|
+
- **Author**: Dynamatix
|
|
298
|
+
|
|
299
|
+
## ๐ Version History
|
|
300
|
+
|
|
301
|
+
- **Current**: 1.3.305
|
|
302
|
+
- **Dependencies**:
|
|
303
|
+
- `@dynamatix/cat-shared`: ^0.0.119
|
|
304
|
+
- `mongoose`: ^8.9.5
|
|
305
|
+
- `mongodb`: ^6.14.2
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
309
|
*This package provides the foundational data layer for Gatehouse Bank's mortgage and financial services backend systems.*
|
|
@@ -137,9 +137,9 @@ declare const ApplicantModel: mongoose.Model<{
|
|
|
137
137
|
addressLine3?: unknown;
|
|
138
138
|
addressCity?: unknown;
|
|
139
139
|
addressCountryLid?: mongoose.Types.ObjectId | null | undefined;
|
|
140
|
+
email?: unknown;
|
|
140
141
|
creditProfile?: unknown;
|
|
141
142
|
isUkResident?: unknown;
|
|
142
|
-
email?: unknown;
|
|
143
143
|
firstName?: unknown;
|
|
144
144
|
lastName?: unknown;
|
|
145
145
|
incomeSourceId?: mongoose.Types.ObjectId | null | undefined;
|
|
@@ -488,9 +488,9 @@ declare const ApplicantModel: mongoose.Model<{
|
|
|
488
488
|
addressLine3?: unknown;
|
|
489
489
|
addressCity?: unknown;
|
|
490
490
|
addressCountryLid?: mongoose.Types.ObjectId | null | undefined;
|
|
491
|
+
email?: unknown;
|
|
491
492
|
creditProfile?: unknown;
|
|
492
493
|
isUkResident?: unknown;
|
|
493
|
-
email?: unknown;
|
|
494
494
|
firstName?: unknown;
|
|
495
495
|
lastName?: unknown;
|
|
496
496
|
incomeSourceId?: mongoose.Types.ObjectId | null | undefined;
|
|
@@ -839,9 +839,9 @@ declare const ApplicantModel: mongoose.Model<{
|
|
|
839
839
|
addressLine3?: unknown;
|
|
840
840
|
addressCity?: unknown;
|
|
841
841
|
addressCountryLid?: mongoose.Types.ObjectId | null | undefined;
|
|
842
|
+
email?: unknown;
|
|
842
843
|
creditProfile?: unknown;
|
|
843
844
|
isUkResident?: unknown;
|
|
844
|
-
email?: unknown;
|
|
845
845
|
firstName?: unknown;
|
|
846
846
|
lastName?: unknown;
|
|
847
847
|
incomeSourceId?: mongoose.Types.ObjectId | null | undefined;
|
|
@@ -1109,8 +1109,8 @@ declare const ApplicantModel: mongoose.Model<{
|
|
|
1109
1109
|
addressLine3: string;
|
|
1110
1110
|
addressCity: string;
|
|
1111
1111
|
addressCountryLid: mongoose.Types.ObjectId;
|
|
1112
|
-
isUkResident: boolean;
|
|
1113
1112
|
email: string;
|
|
1113
|
+
isUkResident: boolean;
|
|
1114
1114
|
firstName: string;
|
|
1115
1115
|
lastName: string;
|
|
1116
1116
|
incomeSourceId: mongoose.Types.ObjectId;
|
|
@@ -1265,8 +1265,8 @@ declare const ApplicantModel: mongoose.Model<{
|
|
|
1265
1265
|
addressLine3: string;
|
|
1266
1266
|
addressCity: string;
|
|
1267
1267
|
addressCountryLid: mongoose.Types.ObjectId;
|
|
1268
|
-
isUkResident: boolean;
|
|
1269
1268
|
email: string;
|
|
1269
|
+
isUkResident: boolean;
|
|
1270
1270
|
firstName: string;
|
|
1271
1271
|
lastName: string;
|
|
1272
1272
|
incomeSourceId: mongoose.Types.ObjectId;
|
|
@@ -1421,8 +1421,8 @@ declare const ApplicantModel: mongoose.Model<{
|
|
|
1421
1421
|
addressLine3: string;
|
|
1422
1422
|
addressCity: string;
|
|
1423
1423
|
addressCountryLid: mongoose.Types.ObjectId;
|
|
1424
|
-
isUkResident: boolean;
|
|
1425
1424
|
email: string;
|
|
1425
|
+
isUkResident: boolean;
|
|
1426
1426
|
firstName: string;
|
|
1427
1427
|
lastName: string;
|
|
1428
1428
|
incomeSourceId: mongoose.Types.ObjectId;
|