gemcap-be-common 1.4.120 → 1.4.121

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.
@@ -2,6 +2,7 @@ export declare const AiExchange: "ai.exchange";
2
2
  export declare const AiRoutingKeys: {
3
3
  readonly compliance: {
4
4
  readonly findMatch: "AI.COMPLIANCE.FIND_MATCH";
5
+ readonly summary: "AI.COMPLIANCE.SUMMARY";
5
6
  };
6
7
  };
7
8
  export declare const AiQueues: {
@@ -5,6 +5,7 @@ exports.AiExchange = 'ai.exchange';
5
5
  exports.AiRoutingKeys = {
6
6
  compliance: {
7
7
  findMatch: 'AI.COMPLIANCE.FIND_MATCH',
8
+ summary: 'AI.COMPLIANCE.SUMMARY',
8
9
  },
9
10
  };
10
11
  exports.AiQueues = {
@@ -3,6 +3,7 @@ export const AiExchange = 'ai.exchange' as const;
3
3
  export const AiRoutingKeys = {
4
4
  compliance: {
5
5
  findMatch: 'AI.COMPLIANCE.FIND_MATCH',
6
+ summary: 'AI.COMPLIANCE.SUMMARY',
6
7
  },
7
8
  } as const;
8
9
 
@@ -27,14 +27,37 @@ export type ICashAllocationProductStringified = {
27
27
 
28
28
  type CashAllocationProductModel = Model<ICashAllocationProduct>;
29
29
 
30
+ const normalizeAccountValue = (
31
+ value: unknown,
32
+ ): mongoose.Types.ObjectId | 'BANK' | null => {
33
+ if (value === null || value === undefined || value === '') {
34
+ return null;
35
+ }
36
+
37
+ if (value === 'BANK') {
38
+ return 'BANK';
39
+ }
40
+
41
+ if (typeof value === 'string' && mongoose.isValidObjectId(value)) {
42
+ return new mongoose.Types.ObjectId(value);
43
+ }
44
+
45
+ if (value instanceof mongoose.Types.ObjectId) {
46
+ return value;
47
+ }
48
+
49
+ return null;
50
+ };
51
+
30
52
  export const AccountSchema = {
31
53
  type: Map,
32
54
  of: new Schema({
33
55
  accountId1: {
34
56
  type: Schema.Types.Mixed,
35
57
  required: false,
58
+ set: normalizeAccountValue,
36
59
  validate: {
37
- validator: function (value: mongoose.Types.ObjectId | 'BANK' | null) {
60
+ validator: function(value: mongoose.Types.ObjectId | 'BANK' | null) {
38
61
  return (
39
62
  value === null ||
40
63
  mongoose.isValidObjectId(value) ||
@@ -48,8 +71,9 @@ export const AccountSchema = {
48
71
  accountId2: {
49
72
  type: Schema.Types.Mixed,
50
73
  required: false,
74
+ set: normalizeAccountValue,
51
75
  validate: {
52
- validator: function (value: mongoose.Types.ObjectId | 'BANK' | null) {
76
+ validator: function(value: mongoose.Types.ObjectId | 'BANK' | null) {
53
77
  return (
54
78
  value === null ||
55
79
  mongoose.isValidObjectId(value) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.4.120",
3
+ "version": "1.4.121",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {