@dynamatix/gb-schemas 0.21.0 → 0.21.2
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/applications/application-audit.model.js +1 -1
- package/applications/application-checklist-Item.model.js +1 -1
- package/applications/application-company-model.js +1 -1
- package/applications/application-document.model.js +1 -1
- package/applications/application-fieldconfig.model.js +1 -1
- package/applications/application-mortgage.model.js +1 -1
- package/applications/application-note.model.js +1 -1
- package/applications/application-onboarding.model.js +1 -1
- package/applications/application-rationale.model.js +1 -1
- package/applications/application-risk-narrative.model.js +1 -1
- package/applications/broker.model.js +1 -1
- package/applications/document.model.js +1 -1
- package/applications/productfeatures.model.js +1 -1
- package/package.json +1 -1
- package/product-catalogues/product-catalogue.model.js +1 -1
- package/product-catalogues/product-definitions.model.js +1 -1
- package/product-catalogues/product-variant.model.js +1 -1
- package/properties/property.model.js +1 -1
- package/shared/alert.model.js +1 -1
- package/shared/checklist.model.js +1 -1
- package/shared/lookup-group.model.js +1 -1
- package/shared/lookup.model.js +1 -1
- package/shared/task-document.model.js +1 -1
- package/shared/task.model.js +1 -1
- package/users/user.model.js +1 -1
- package/utils/encryption.middleware.js +24 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
-
import mongooseEncryption from "../utils/encryption.middleware";
|
|
2
|
+
import mongooseEncryption from "../utils/encryption.middleware.js";
|
|
3
3
|
|
|
4
4
|
const checkListItemSchema = new mongoose.Schema({
|
|
5
5
|
additionalOfferConditions: { type: String, default: "" },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
-
import mongooseEncryption from "../utils/encryption.middleware";
|
|
2
|
+
import mongooseEncryption from "../utils/encryption.middleware.js";
|
|
3
3
|
|
|
4
4
|
const fieldConfigSchema = new mongoose.Schema({
|
|
5
5
|
fieldName: { type: String, required: true, unique: true },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
-
import mongooseEncryption from "../utils/encryption.middleware";
|
|
2
|
+
import mongooseEncryption from "../utils/encryption.middleware.js";
|
|
3
3
|
|
|
4
4
|
const mortgageSchema = new mongoose.Schema({
|
|
5
5
|
depositComeFrom: { type: String, required: true },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
-
import mongooseEncryption from "../utils/encryption.middleware";
|
|
2
|
+
import mongooseEncryption from "../utils/encryption.middleware.js";
|
|
3
3
|
|
|
4
4
|
const noteSchema = new mongoose.Schema({
|
|
5
5
|
applicationId: { type: mongoose.Schema.Types.ObjectId, ref: "Application", required: true },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
-
import mongooseEncryption from "../utils/encryption.middleware";
|
|
2
|
+
import mongooseEncryption from "../utils/encryption.middleware.js";
|
|
3
3
|
|
|
4
4
|
const rationaleSchema = new mongoose.Schema({
|
|
5
5
|
applicationId: { type: mongoose.Schema.Types.ObjectId, ref: "Application", required: true },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
|
-
import mongooseEncryption from '../utils/encryption.middleware';
|
|
2
|
+
import mongooseEncryption from '../utils/encryption.middleware.js';
|
|
3
3
|
|
|
4
4
|
const applicantionRiskNarrativeSchema = new mongoose.Schema({
|
|
5
5
|
call1RequestedOn: { type: String },
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
-
import mongooseEncryption from "../utils/encryption.middleware";
|
|
2
|
+
import mongooseEncryption from "../utils/encryption.middleware.js";
|
|
3
3
|
|
|
4
4
|
const productCatalogueSchema = new mongoose.Schema({
|
|
5
5
|
productCatalogueId: { type: String, required: true },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
|
-
import mongooseEncryption from "../utils/encryption.middleware";
|
|
2
|
+
import mongooseEncryption from "../utils/encryption.middleware.js";
|
|
3
3
|
|
|
4
4
|
const productVariantSchema = new mongoose.Schema({
|
|
5
5
|
productCatalogueId: { ref: "ProductCatalogue", type: mongoose.Schema.Types.ObjectId, required: true },
|
package/shared/alert.model.js
CHANGED
package/shared/lookup.model.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
|
-
import mongooseEncryption from '../utils/encryption.middleware';
|
|
2
|
+
import mongooseEncryption from '../utils/encryption.middleware.js';
|
|
3
3
|
|
|
4
4
|
// Define the schema for TaskDocumentType
|
|
5
5
|
const taskDocumentTypeSchema = new mongoose.Schema({
|
package/shared/task.model.js
CHANGED
package/users/user.model.js
CHANGED
|
@@ -37,6 +37,16 @@ export default function mongooseEncryption(schema, options) {
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
+
|
|
41
|
+
// Encrypt before update operations (single or multiple documents)
|
|
42
|
+
schema.pre("update", function (result) {
|
|
43
|
+
if (Array.isArray(result)) {
|
|
44
|
+
result.forEach(doc => doc.set(decryptObject(doc.toObject(), collectionName)));
|
|
45
|
+
} else {
|
|
46
|
+
result.set(encryptObject(result.toObject(), collectionName)); // Decrypt single document
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
40
50
|
// Decrypt after update operations (single or multiple documents)
|
|
41
51
|
schema.post("update", function (result) {
|
|
42
52
|
if (Array.isArray(result)) {
|
|
@@ -46,6 +56,13 @@ export default function mongooseEncryption(schema, options) {
|
|
|
46
56
|
}
|
|
47
57
|
});
|
|
48
58
|
|
|
59
|
+
// Encrypt after updateOne operations
|
|
60
|
+
schema.pre("updateOne", function (result) {
|
|
61
|
+
if (result && result.toObject) {
|
|
62
|
+
result.set(encryptObject(result.toObject(), collectionName)); // Decrypt single document
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
49
66
|
// Decrypt after updateOne operations
|
|
50
67
|
schema.post("updateOne", function (result) {
|
|
51
68
|
if (result && result.toObject) {
|
|
@@ -53,6 +70,12 @@ export default function mongooseEncryption(schema, options) {
|
|
|
53
70
|
}
|
|
54
71
|
});
|
|
55
72
|
|
|
73
|
+
schema.pre("findOneAndUpdate", function (result) {
|
|
74
|
+
if (result && result.toObject) {
|
|
75
|
+
result.set(encryptObject(result.toObject(), collectionName)); // Decrypt single document
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
56
79
|
// Decrypt after find operations (e.g., find, findMany)
|
|
57
80
|
schema.post("find", function (docs) {
|
|
58
81
|
console.log("find", docs);
|
|
@@ -73,6 +96,7 @@ export default function mongooseEncryption(schema, options) {
|
|
|
73
96
|
if (doc) doc.set(decryptObject(doc.toObject(), collectionName)); // Decrypt single document
|
|
74
97
|
});
|
|
75
98
|
|
|
99
|
+
|
|
76
100
|
// Decrypt after findOneAndUpdate operations
|
|
77
101
|
schema.post("findOneAndUpdate", function (doc) {
|
|
78
102
|
console.log("findOneAndUpdate", doc);
|