@riocrypto/common-server 1.0.2791 → 1.0.2795

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.
@@ -19,6 +19,10 @@ export interface BinanceOrderResponse {
19
19
  orderListId: number;
20
20
  clientOrderId: string;
21
21
  transactTime?: number;
22
+ time?: number;
23
+ updateTime?: number;
24
+ workingTime?: number;
25
+ origQuoteOrderQty?: string;
22
26
  price: string;
23
27
  origQty: string;
24
28
  executedQty: string;
@@ -34,6 +38,21 @@ export interface BinanceOrderResponse {
34
38
  commissionAsset: string;
35
39
  }>;
36
40
  }
41
+ export interface BinanceMyTrade {
42
+ symbol: string;
43
+ id: number;
44
+ orderId: number;
45
+ orderListId: number;
46
+ price: string;
47
+ qty: string;
48
+ quoteQty: string;
49
+ commission: string;
50
+ commissionAsset: string;
51
+ time: number;
52
+ isBuyer: boolean;
53
+ isMaker: boolean;
54
+ isBestMatch: boolean;
55
+ }
37
56
  export interface BinanceWithdrawHistoryItem {
38
57
  id: string;
39
58
  amount: string;
@@ -142,8 +161,19 @@ declare class BinanceClient {
142
161
  getOrder(symbol: string, orderId: number): Promise<BinanceOrderResponse>;
143
162
  cancelOrder(symbol: string, orderId: number): Promise<any>;
144
163
  getOpenOrders(symbol: string): Promise<BinanceOrderResponse[]>;
145
- getAllOrders(symbol: string): Promise<BinanceOrderResponse[]>;
146
- getMyTrades(symbol: string, orderId?: number): Promise<any[]>;
164
+ getAllOrders(symbol: string, options?: {
165
+ orderId?: number;
166
+ startTime?: number;
167
+ endTime?: number;
168
+ limit?: number;
169
+ }): Promise<BinanceOrderResponse[]>;
170
+ getMyTrades(symbol: string, options?: {
171
+ orderId?: number;
172
+ startTime?: number;
173
+ endTime?: number;
174
+ fromId?: number;
175
+ limit?: number;
176
+ }): Promise<BinanceMyTrade[]>;
147
177
  getRecentTrades(symbol: string, limit?: number): Promise<BinanceTradeItem[]>;
148
178
  getExchangeInfo(): Promise<BinanceExchangeInfo>;
149
179
  getOrderBook(symbol: string, limit?: number): Promise<BinanceOrderBook>;
@@ -165,14 +165,14 @@ class BinanceClient {
165
165
  return this.signedGet("/api/v3/openOrders", { symbol });
166
166
  });
167
167
  }
168
- getAllOrders(symbol) {
168
+ getAllOrders(symbol, options) {
169
169
  return __awaiter(this, void 0, void 0, function* () {
170
- return this.signedGet("/api/v3/allOrders", { symbol });
170
+ return this.signedGet("/api/v3/allOrders", Object.assign({ symbol }, options));
171
171
  });
172
172
  }
173
- getMyTrades(symbol, orderId) {
173
+ getMyTrades(symbol, options) {
174
174
  return __awaiter(this, void 0, void 0, function* () {
175
- return this.signedGet("/api/v3/myTrades", { symbol, orderId });
175
+ return this.signedGet("/api/v3/myTrades", Object.assign({ symbol }, options));
176
176
  });
177
177
  }
178
178
  // Market data
package/build/index.d.ts CHANGED
@@ -118,6 +118,8 @@ export * from "./models/compliance-session";
118
118
  export * from "./models/compliance-bot-chat";
119
119
  export * from "./models/compliance-bot-rule";
120
120
  export * from "./models/compliance-bot-rule-result";
121
+ export * from "./models/compliance-rule-set";
122
+ export * from "./models/compliance-user-cache";
121
123
  export * from "./models/binance-rfq-log";
122
124
  export * from "./models/binance-rfq-order";
123
125
  export * from "./models/binance-rfq-quote";
package/build/index.js CHANGED
@@ -134,6 +134,8 @@ __exportStar(require("./models/compliance-session"), exports);
134
134
  __exportStar(require("./models/compliance-bot-chat"), exports);
135
135
  __exportStar(require("./models/compliance-bot-rule"), exports);
136
136
  __exportStar(require("./models/compliance-bot-rule-result"), exports);
137
+ __exportStar(require("./models/compliance-rule-set"), exports);
138
+ __exportStar(require("./models/compliance-user-cache"), exports);
137
139
  __exportStar(require("./models/binance-rfq-log"), exports);
138
140
  __exportStar(require("./models/binance-rfq-order"), exports);
139
141
  __exportStar(require("./models/binance-rfq-quote"), exports);
@@ -1,11 +1,13 @@
1
1
  import mongoose, { HydratedDocument } from "mongoose";
2
2
  import { ComplianceRuleResultStatus, ComplianceRuleOutcome } from "@riocrypto/common";
3
+ import type { ComplianceStepType } from "@riocrypto/common";
3
4
  interface ComplianceRuleResultAttrs {
4
5
  sessionId: string;
5
6
  ruleId: string;
6
7
  name: string;
7
8
  status: ComplianceRuleResultStatus;
8
9
  prompt: string;
10
+ stepType: ComplianceStepType;
9
11
  data: string;
10
12
  details: string;
11
13
  outcome?: ComplianceRuleOutcome;
@@ -17,6 +19,7 @@ interface ComplianceRuleResultDoc extends mongoose.Document {
17
19
  name: string;
18
20
  status: ComplianceRuleResultStatus;
19
21
  prompt: string;
22
+ stepType: ComplianceStepType;
20
23
  data: string;
21
24
  details: string;
22
25
  outcome?: ComplianceRuleOutcome;
@@ -26,6 +26,12 @@ const buildComplianceRuleResult = (mongoose) => {
26
26
  type: String,
27
27
  required: true,
28
28
  },
29
+ stepType: {
30
+ type: String,
31
+ required: true,
32
+ // Hard-coded literal: see compliance-bot-rule.ts for rationale.
33
+ default: "simple",
34
+ },
29
35
  data: {
30
36
  type: String,
31
37
  required: false,
@@ -1,9 +1,12 @@
1
1
  import mongoose, { HydratedDocument } from "mongoose";
2
+ import type { ComplianceStepType } from "@riocrypto/common";
2
3
  interface ComplianceRuleAttrs {
3
4
  country: string;
4
5
  name: string;
5
6
  prompt: string;
6
7
  ruleType: string;
8
+ stepType: ComplianceStepType;
9
+ ruleSetId?: string;
7
10
  }
8
11
  interface ComplianceRuleDoc extends mongoose.Document {
9
12
  id: string;
@@ -11,6 +14,8 @@ interface ComplianceRuleDoc extends mongoose.Document {
11
14
  name: string;
12
15
  prompt: string;
13
16
  ruleType: string;
17
+ stepType: ComplianceStepType;
18
+ ruleSetId?: string;
14
19
  }
15
20
  interface ComplianceRuleModel extends mongoose.Model<ComplianceRuleDoc> {
16
21
  build(attrs: ComplianceRuleAttrs): HydratedDocument<ComplianceRuleDoc>;
@@ -22,6 +22,23 @@ const buildComplianceRule = (mongoose) => {
22
22
  type: String,
23
23
  required: true,
24
24
  },
25
+ stepType: {
26
+ type: String,
27
+ required: true,
28
+ // Hard-coded literal to avoid a runtime dependency on
29
+ // @riocrypto/common's enum value -- consumers (compliance-bot)
30
+ // resolve common-server's `@riocrypto/common` dep to the
31
+ // published version, which may not yet export this enum.
32
+ default: "simple",
33
+ },
34
+ // Owning rule set. Required at the application layer for any
35
+ // freshly-saved rule, but kept optional in the schema so legacy
36
+ // rule docs predating the rule-set migration still hydrate; the
37
+ // bot's startup migration backfills these.
38
+ ruleSetId: {
39
+ type: String,
40
+ required: false,
41
+ },
25
42
  }, {
26
43
  toJSON: {
27
44
  transform(doc, ret) {
@@ -32,6 +49,7 @@ const buildComplianceRule = (mongoose) => {
32
49
  },
33
50
  });
34
51
  ComplianceRuleSchema.index({ country: 1 });
52
+ ComplianceRuleSchema.index({ ruleSetId: 1 });
35
53
  ComplianceRuleSchema.statics.build = (attrs) => {
36
54
  return new ComplianceRule(attrs);
37
55
  };
@@ -0,0 +1,25 @@
1
+ import mongoose, { HydratedDocument } from "mongoose";
2
+ interface ComplianceRuleSetAttrs {
3
+ country: string;
4
+ ruleType: string;
5
+ name: string;
6
+ description?: string;
7
+ isDefault: boolean;
8
+ createdAt: Date;
9
+ updatedAt: Date;
10
+ }
11
+ interface ComplianceRuleSetDoc extends mongoose.Document {
12
+ id: string;
13
+ country: string;
14
+ ruleType: string;
15
+ name: string;
16
+ description?: string;
17
+ isDefault: boolean;
18
+ createdAt: Date;
19
+ updatedAt: Date;
20
+ }
21
+ interface ComplianceRuleSetModel extends mongoose.Model<ComplianceRuleSetDoc> {
22
+ build(attrs: ComplianceRuleSetAttrs): HydratedDocument<ComplianceRuleSetDoc>;
23
+ }
24
+ declare const buildComplianceRuleSet: (mongoose: typeof mongoose) => ComplianceRuleSetModel;
25
+ export { buildComplianceRuleSet, ComplianceRuleSetDoc, ComplianceRuleSetAttrs, };
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildComplianceRuleSet = void 0;
4
+ const buildComplianceRuleSet = (mongoose) => {
5
+ if (mongoose.models.ComplianceRuleSet) {
6
+ return mongoose.model("ComplianceRuleSet");
7
+ }
8
+ const ComplianceRuleSetSchema = new mongoose.Schema({
9
+ country: {
10
+ type: String,
11
+ required: true,
12
+ },
13
+ ruleType: {
14
+ type: String,
15
+ required: true,
16
+ },
17
+ name: {
18
+ type: String,
19
+ required: true,
20
+ },
21
+ description: {
22
+ type: String,
23
+ required: false,
24
+ },
25
+ isDefault: {
26
+ type: Boolean,
27
+ required: true,
28
+ default: false,
29
+ },
30
+ createdAt: {
31
+ type: Date,
32
+ required: true,
33
+ default: () => new Date(),
34
+ },
35
+ updatedAt: {
36
+ type: Date,
37
+ required: true,
38
+ default: () => new Date(),
39
+ },
40
+ }, {
41
+ toJSON: {
42
+ transform(doc, ret) {
43
+ ret.id = ret._id;
44
+ delete ret._id;
45
+ delete ret.__v;
46
+ },
47
+ },
48
+ });
49
+ // Lookup index for the common "list sets in this bucket" query.
50
+ ComplianceRuleSetSchema.index({ country: 1, ruleType: 1 });
51
+ // The same display name shouldn't appear twice within a single bucket --
52
+ // it's how operators tell sets apart in the UI.
53
+ ComplianceRuleSetSchema.index({ country: 1, ruleType: 1, name: 1 }, { unique: true });
54
+ // At most one default per (country, ruleType). Partial filter so only
55
+ // documents with `isDefault: true` participate in the uniqueness check;
56
+ // everything else can coexist freely.
57
+ ComplianceRuleSetSchema.index({ country: 1, ruleType: 1, isDefault: 1 }, {
58
+ unique: true,
59
+ partialFilterExpression: { isDefault: true },
60
+ });
61
+ ComplianceRuleSetSchema.statics.build = (attrs) => {
62
+ return new ComplianceRuleSet(attrs);
63
+ };
64
+ const ComplianceRuleSet = mongoose.model("ComplianceRuleSet", ComplianceRuleSetSchema);
65
+ return ComplianceRuleSet;
66
+ };
67
+ exports.buildComplianceRuleSet = buildComplianceRuleSet;
@@ -9,6 +9,10 @@ interface ComplianceSessionAttrs {
9
9
  status: ComplianceSessionStatus;
10
10
  transcript: string;
11
11
  modelName: string;
12
+ startedBy?: string;
13
+ startedByName?: string;
14
+ ruleSetId?: string;
15
+ ruleSetName?: string;
12
16
  }
13
17
  interface ComplianceSessionDoc extends mongoose.Document {
14
18
  id: string;
@@ -19,6 +23,10 @@ interface ComplianceSessionDoc extends mongoose.Document {
19
23
  status: ComplianceSessionStatus;
20
24
  transcript: string;
21
25
  modelName: string;
26
+ startedBy?: string;
27
+ startedByName?: string;
28
+ ruleSetId?: string;
29
+ ruleSetName?: string;
22
30
  }
23
31
  interface ComplianceSessionModel extends mongoose.Model<ComplianceSessionDoc> {
24
32
  build(attrs: ComplianceSessionAttrs): HydratedDocument<ComplianceSessionDoc>;
@@ -37,6 +37,28 @@ const buildComplianceSession = (mongoose) => {
37
37
  type: String,
38
38
  required: false,
39
39
  },
40
+ // Identity of the admin who initiated this compliance session.
41
+ // Optional so previously persisted sessions still load.
42
+ startedBy: {
43
+ type: String,
44
+ required: false,
45
+ },
46
+ startedByName: {
47
+ type: String,
48
+ required: false,
49
+ },
50
+ // Snapshot of the rule set this session ran against. The id is
51
+ // kept for joining to the current set; the name is denormalized
52
+ // so the UI can attribute a historical run even after a set is
53
+ // renamed/deleted. Both optional so older sessions still load.
54
+ ruleSetId: {
55
+ type: String,
56
+ required: false,
57
+ },
58
+ ruleSetName: {
59
+ type: String,
60
+ required: false,
61
+ },
40
62
  }, {
41
63
  toJSON: {
42
64
  transform(doc, ret) {
@@ -0,0 +1,23 @@
1
+ import mongoose, { HydratedDocument } from "mongoose";
2
+ interface ComplianceUserCacheDocumentAttrs {
3
+ fileName: string;
4
+ text: string;
5
+ }
6
+ interface ComplianceUserCacheAttrs {
7
+ userId: string;
8
+ profileJson: string;
9
+ documents: ComplianceUserCacheDocumentAttrs[];
10
+ updatedAt: Date;
11
+ }
12
+ interface ComplianceUserCacheDoc extends mongoose.Document {
13
+ id: string;
14
+ userId: string;
15
+ profileJson: string;
16
+ documents: ComplianceUserCacheDocumentAttrs[];
17
+ updatedAt: Date;
18
+ }
19
+ interface ComplianceUserCacheModel extends mongoose.Model<ComplianceUserCacheDoc> {
20
+ build(attrs: ComplianceUserCacheAttrs): HydratedDocument<ComplianceUserCacheDoc>;
21
+ }
22
+ declare const buildComplianceUserCache: (mongoose: typeof mongoose) => ComplianceUserCacheModel;
23
+ export { buildComplianceUserCache, ComplianceUserCacheDoc, ComplianceUserCacheAttrs, ComplianceUserCacheDocumentAttrs, };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildComplianceUserCache = void 0;
4
+ const buildComplianceUserCache = (mongoose) => {
5
+ if (mongoose.models.ComplianceUserCache) {
6
+ return mongoose.model("ComplianceUserCache");
7
+ }
8
+ const ComplianceUserCacheDocumentSchema = new mongoose.Schema({
9
+ fileName: {
10
+ type: String,
11
+ required: true,
12
+ },
13
+ text: {
14
+ type: String,
15
+ required: true,
16
+ },
17
+ }, { _id: false });
18
+ const ComplianceUserCacheSchema = new mongoose.Schema({
19
+ userId: {
20
+ type: String,
21
+ required: true,
22
+ unique: true,
23
+ index: true,
24
+ },
25
+ profileJson: {
26
+ type: String,
27
+ required: false,
28
+ default: "",
29
+ },
30
+ documents: {
31
+ type: [ComplianceUserCacheDocumentSchema],
32
+ required: true,
33
+ default: [],
34
+ },
35
+ updatedAt: {
36
+ type: Date,
37
+ required: true,
38
+ },
39
+ }, {
40
+ toJSON: {
41
+ transform(doc, ret) {
42
+ ret.id = ret._id;
43
+ delete ret._id;
44
+ delete ret.__v;
45
+ },
46
+ },
47
+ });
48
+ ComplianceUserCacheSchema.statics.build = (attrs) => {
49
+ return new ComplianceUserCache(attrs);
50
+ };
51
+ const ComplianceUserCache = mongoose.model("ComplianceUserCache", ComplianceUserCacheSchema);
52
+ return ComplianceUserCache;
53
+ };
54
+ exports.buildComplianceUserCache = buildComplianceUserCache;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2791",
3
+ "version": "1.0.2795",
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.2596",
31
+ "@riocrypto/common": "1.0.2600",
32
32
  "@slack/web-api": "^7.15.0",
33
33
  "@types/express": "^4.17.25",
34
34
  "axios": "1.16.0",