@riocrypto/common-server 1.0.1721 → 1.0.1722

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.
@@ -0,0 +1,56 @@
1
+ import { Fiat, Crypto, Side, AlertType, AlertTriggerCondition } from "@riocrypto/common";
2
+ import { Mongoose, Model, Document } from "mongoose";
3
+ interface AlertAttrs {
4
+ createdAt: Date;
5
+ type: AlertType;
6
+ priceTrigger?: {
7
+ condition: AlertTriggerCondition;
8
+ value: number;
9
+ side: Side;
10
+ fiat: Fiat;
11
+ crypto: Crypto;
12
+ cooldown?: number;
13
+ };
14
+ liquidityTrigger: {
15
+ condition: AlertTriggerCondition;
16
+ value: number;
17
+ assetType?: "crypto" | "fiat";
18
+ asset?: Crypto | Fiat;
19
+ cooldown?: number;
20
+ };
21
+ destinationType: "telegram";
22
+ telegramDestination: {
23
+ chatId?: string;
24
+ username?: string;
25
+ };
26
+ }
27
+ interface AlertModel extends Model<AlertDoc> {
28
+ build(attrs: AlertAttrs): AlertDoc;
29
+ }
30
+ interface AlertDoc extends Document {
31
+ _id: string;
32
+ createdAt: Date;
33
+ type: AlertType;
34
+ priceTrigger?: {
35
+ condition: AlertTriggerCondition;
36
+ value: number;
37
+ side: Side;
38
+ fiat: Fiat;
39
+ crypto: Crypto;
40
+ cooldown?: number;
41
+ };
42
+ liquidityTrigger: {
43
+ condition: AlertTriggerCondition;
44
+ value: number;
45
+ assetType?: "crypto" | "fiat";
46
+ asset?: Crypto | Fiat;
47
+ cooldown?: number;
48
+ };
49
+ destinationType: "telegram";
50
+ telegramDestination: {
51
+ chatId?: string;
52
+ username?: string;
53
+ };
54
+ }
55
+ declare const buildAlert: (mongoose: Mongoose) => AlertModel;
56
+ export { buildAlert, AlertDoc, AlertAttrs };
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildAlert = void 0;
4
+ const buildAlert = (mongoose) => {
5
+ // if model is already defined, return it
6
+ if (mongoose.models.Alert) {
7
+ return mongoose.model("Alert");
8
+ }
9
+ const AlertSchema = new mongoose.Schema({
10
+ createdAt: {
11
+ type: Date,
12
+ required: true,
13
+ },
14
+ type: {
15
+ type: String,
16
+ required: true,
17
+ },
18
+ priceTrigger: {
19
+ condition: {
20
+ type: String,
21
+ required: false,
22
+ },
23
+ value: {
24
+ type: Number,
25
+ required: false,
26
+ },
27
+ side: {
28
+ type: String,
29
+ required: false,
30
+ },
31
+ fiat: {
32
+ type: String,
33
+ required: false,
34
+ },
35
+ crypto: {
36
+ type: String,
37
+ required: false,
38
+ },
39
+ cooldown: {
40
+ type: Number,
41
+ required: false,
42
+ },
43
+ },
44
+ liquidityTrigger: {
45
+ condition: {
46
+ type: String,
47
+ required: true,
48
+ },
49
+ value: {
50
+ type: Number,
51
+ required: true,
52
+ },
53
+ assetType: {
54
+ type: String,
55
+ required: false,
56
+ },
57
+ asset: {
58
+ type: String,
59
+ required: false,
60
+ },
61
+ cooldown: {
62
+ type: Number,
63
+ required: false,
64
+ },
65
+ },
66
+ destinationType: {
67
+ type: String,
68
+ required: true,
69
+ },
70
+ telegramDestination: {
71
+ chatId: {
72
+ type: String,
73
+ required: false,
74
+ },
75
+ username: {
76
+ type: String,
77
+ required: false,
78
+ },
79
+ },
80
+ }, {
81
+ toJSON: {
82
+ transform(doc, ret) {
83
+ ret.id = ret._id.valueOf();
84
+ delete ret._id;
85
+ delete ret.__v;
86
+ },
87
+ },
88
+ });
89
+ AlertSchema.statics.build = (attrs) => {
90
+ return new Alert(attrs);
91
+ };
92
+ const Alert = mongoose.model("Alert", AlertSchema);
93
+ return Alert;
94
+ };
95
+ exports.buildAlert = buildAlert;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1721",
3
+ "version": "1.0.1722",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  "@google-cloud/secret-manager": "^5.3.0",
27
27
  "@google-cloud/storage": "^6.9.5",
28
28
  "@hyperdx/node-opentelemetry": "^0.4.2",
29
- "@riocrypto/common": "^1.0.1505",
29
+ "@riocrypto/common": "^1.0.1507",
30
30
  "@types/express": "^4.17.13",
31
31
  "axios": "^1.6.0",
32
32
  "crypto-js": "^4.2.0",