@riocrypto/common-server 1.0.2940 → 1.0.2942
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/build/index.d.ts
CHANGED
|
@@ -112,6 +112,7 @@ export * from "./models/axe-telegram-thread";
|
|
|
112
112
|
export * from "./models/auth-activity-slack-thread";
|
|
113
113
|
export * from "./models/onboarding-review-slack-thread";
|
|
114
114
|
export * from "./models/compliance-report-slack-thread";
|
|
115
|
+
export * from "./models/transaction-monitoring-alert";
|
|
115
116
|
export * from "./models/twap-slack-thread";
|
|
116
117
|
export * from "./models/twap-session";
|
|
117
118
|
export * from "./models/bulk-bank-payout";
|
package/build/index.js
CHANGED
|
@@ -128,6 +128,7 @@ __exportStar(require("./models/axe-telegram-thread"), exports);
|
|
|
128
128
|
__exportStar(require("./models/auth-activity-slack-thread"), exports);
|
|
129
129
|
__exportStar(require("./models/onboarding-review-slack-thread"), exports);
|
|
130
130
|
__exportStar(require("./models/compliance-report-slack-thread"), exports);
|
|
131
|
+
__exportStar(require("./models/transaction-monitoring-alert"), exports);
|
|
131
132
|
__exportStar(require("./models/twap-slack-thread"), exports);
|
|
132
133
|
__exportStar(require("./models/twap-session"), exports);
|
|
133
134
|
__exportStar(require("./models/bulk-bank-payout"), exports);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Country, TransactionMonitoringAlertSeverity, TransactionMonitoringDirection, TransactionMonitoringRule } from "@riocrypto/common";
|
|
2
|
+
import mongoose, { HydratedDocument } from "mongoose";
|
|
3
|
+
interface TransactionMonitoringAlertAttrs {
|
|
4
|
+
createdAt: Date;
|
|
5
|
+
userId: string;
|
|
6
|
+
country: Country;
|
|
7
|
+
rule: TransactionMonitoringRule;
|
|
8
|
+
severity: TransactionMonitoringAlertSeverity;
|
|
9
|
+
direction?: TransactionMonitoringDirection;
|
|
10
|
+
periodKey: string;
|
|
11
|
+
orderIds: string[];
|
|
12
|
+
summary: string;
|
|
13
|
+
metrics: Record<string, number>;
|
|
14
|
+
slackChannelId?: string;
|
|
15
|
+
slackMessageTs?: string;
|
|
16
|
+
}
|
|
17
|
+
interface TransactionMonitoringAlertDoc extends mongoose.Document {
|
|
18
|
+
createdAt: Date;
|
|
19
|
+
userId: string;
|
|
20
|
+
country: Country;
|
|
21
|
+
rule: TransactionMonitoringRule;
|
|
22
|
+
severity: TransactionMonitoringAlertSeverity;
|
|
23
|
+
direction?: TransactionMonitoringDirection;
|
|
24
|
+
periodKey: string;
|
|
25
|
+
orderIds: string[];
|
|
26
|
+
summary: string;
|
|
27
|
+
metrics: Record<string, number>;
|
|
28
|
+
slackChannelId?: string;
|
|
29
|
+
slackMessageTs?: string;
|
|
30
|
+
}
|
|
31
|
+
interface TransactionMonitoringAlertModel extends mongoose.Model<TransactionMonitoringAlertDoc> {
|
|
32
|
+
build(attrs: TransactionMonitoringAlertAttrs): HydratedDocument<TransactionMonitoringAlertDoc>;
|
|
33
|
+
}
|
|
34
|
+
declare const buildTransactionMonitoringAlert: (mongoose: typeof mongoose) => TransactionMonitoringAlertModel;
|
|
35
|
+
export { buildTransactionMonitoringAlert, TransactionMonitoringAlertDoc, TransactionMonitoringAlertAttrs, };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildTransactionMonitoringAlert = void 0;
|
|
4
|
+
const buildTransactionMonitoringAlert = (mongoose) => {
|
|
5
|
+
// if model is already defined, return it
|
|
6
|
+
if (mongoose.models.TransactionMonitoringAlert) {
|
|
7
|
+
return mongoose.model("TransactionMonitoringAlert");
|
|
8
|
+
}
|
|
9
|
+
const TransactionMonitoringAlertSchema = new mongoose.Schema({
|
|
10
|
+
createdAt: {
|
|
11
|
+
type: mongoose.Schema.Types.Date,
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
userId: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
country: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
rule: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
severity: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
direction: {
|
|
31
|
+
type: String,
|
|
32
|
+
},
|
|
33
|
+
periodKey: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
orderIds: [
|
|
38
|
+
{
|
|
39
|
+
type: String,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
summary: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: true,
|
|
45
|
+
},
|
|
46
|
+
metrics: {
|
|
47
|
+
type: Object,
|
|
48
|
+
},
|
|
49
|
+
slackChannelId: {
|
|
50
|
+
type: String,
|
|
51
|
+
},
|
|
52
|
+
slackMessageTs: {
|
|
53
|
+
type: String,
|
|
54
|
+
},
|
|
55
|
+
}, {
|
|
56
|
+
toJSON: {
|
|
57
|
+
transform(doc, ret) {
|
|
58
|
+
ret.id = ret._id;
|
|
59
|
+
delete ret._id;
|
|
60
|
+
delete ret.__v;
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
// direction is absent for scenarios that look at both directions at once,
|
|
65
|
+
// and Mongo treats a missing field as null in a unique index, so those
|
|
66
|
+
// alerts still dedup correctly against each other.
|
|
67
|
+
TransactionMonitoringAlertSchema.index({ userId: 1, country: 1, rule: 1, direction: 1, periodKey: 1 }, { unique: true });
|
|
68
|
+
TransactionMonitoringAlertSchema.index({ userId: 1, createdAt: -1 });
|
|
69
|
+
TransactionMonitoringAlertSchema.statics.build = (attrs) => {
|
|
70
|
+
return new TransactionMonitoringAlert(attrs);
|
|
71
|
+
};
|
|
72
|
+
const TransactionMonitoringAlert = mongoose.model("TransactionMonitoringAlert", TransactionMonitoringAlertSchema);
|
|
73
|
+
return TransactionMonitoringAlert;
|
|
74
|
+
};
|
|
75
|
+
exports.buildTransactionMonitoringAlert = buildTransactionMonitoringAlert;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2942",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@google-cloud/secret-manager": "^5.6.0",
|
|
29
29
|
"@google-cloud/storage": "^7.19.0",
|
|
30
30
|
"@hyperdx/node-opentelemetry": "^0.10.3",
|
|
31
|
-
"@riocrypto/common": "1.0.
|
|
31
|
+
"@riocrypto/common": "1.0.2737",
|
|
32
32
|
"@slack/web-api": "^7.15.0",
|
|
33
33
|
"@types/express": "^4.17.25",
|
|
34
34
|
"axios": "1.18.1",
|