@riocrypto/common-server 1.0.2931 → 1.0.2933

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
@@ -132,6 +132,11 @@ export * from "./models/liquidity-sourcing-exclusion";
132
132
  export * from "./models/liquidity-sourcing-settings";
133
133
  export * from "./models/compliance-session";
134
134
  export * from "./models/compliance-bot-chat";
135
+ export * from "./models/internal-support-session";
136
+ export * from "./models/internal-support-chat-message";
137
+ export * from "./models/internal-support-audit-event";
138
+ export * from "./models/internal-support-case";
139
+ export * from "./models/internal-support-security";
135
140
  export * from "./models/compliance-bot-rule";
136
141
  export * from "./models/compliance-bot-rule-result";
137
142
  export * from "./models/compliance-rule-set";
package/build/index.js CHANGED
@@ -148,6 +148,11 @@ __exportStar(require("./models/liquidity-sourcing-exclusion"), exports);
148
148
  __exportStar(require("./models/liquidity-sourcing-settings"), exports);
149
149
  __exportStar(require("./models/compliance-session"), exports);
150
150
  __exportStar(require("./models/compliance-bot-chat"), exports);
151
+ __exportStar(require("./models/internal-support-session"), exports);
152
+ __exportStar(require("./models/internal-support-chat-message"), exports);
153
+ __exportStar(require("./models/internal-support-audit-event"), exports);
154
+ __exportStar(require("./models/internal-support-case"), exports);
155
+ __exportStar(require("./models/internal-support-security"), exports);
151
156
  __exportStar(require("./models/compliance-bot-rule"), exports);
152
157
  __exportStar(require("./models/compliance-bot-rule-result"), exports);
153
158
  __exportStar(require("./models/compliance-rule-set"), exports);
@@ -1,9 +1,17 @@
1
1
  import { Fiat, Side, Crypto, ExternalTradeType, ExternalTradingProvider, ExternalTradeStatus, ExternalTradeAmountType, EmarketsSettlementType, LmaxOrderType, LmaxSide, LmaxTimeInForce } from "@riocrypto/common";
2
2
  import { Mongoose, Model, Document, HydratedDocument } from "mongoose";
3
+ interface ExternalTradeImportMeta {
4
+ fileName?: string;
5
+ importedBy?: string;
6
+ importedAt: Date;
7
+ providerOrderIdIsSynthetic?: boolean;
8
+ sourceRow?: Record<string, string>;
9
+ }
3
10
  interface ExternalTradeAttrs {
4
11
  createdAt: Date;
5
12
  providerOrderId?: string;
6
13
  tradeKey?: string;
14
+ valueDate?: string;
7
15
  type: ExternalTradeType;
8
16
  side: Side;
9
17
  provider: ExternalTradingProvider;
@@ -72,11 +80,13 @@ interface ExternalTradeAttrs {
72
80
  externalTradingAlgorithmId?: string;
73
81
  arbitrageSessionId?: string;
74
82
  isImported?: boolean;
83
+ importMeta?: ExternalTradeImportMeta;
75
84
  }
76
85
  interface ExternalTradeDoc extends Document {
77
86
  createdAt: Date;
78
87
  providerOrderId?: string;
79
88
  tradeKey?: string;
89
+ valueDate?: string;
80
90
  type: ExternalTradeType;
81
91
  side: Side;
82
92
  amountType: ExternalTradeAmountType;
@@ -146,9 +156,10 @@ interface ExternalTradeDoc extends Document {
146
156
  externalTradingAlgorithmId?: string;
147
157
  arbitrageSessionId?: string;
148
158
  isImported?: boolean;
159
+ importMeta?: ExternalTradeImportMeta;
149
160
  }
150
161
  interface ExternalTradeModel extends Model<ExternalTradeDoc> {
151
162
  build(attrs: ExternalTradeAttrs): HydratedDocument<ExternalTradeDoc>;
152
163
  }
153
164
  declare const buildExternalTrade: (mongoose: Mongoose) => ExternalTradeModel;
154
- export { buildExternalTrade, ExternalTradeDoc, ExternalTradeAttrs };
165
+ export { buildExternalTrade, ExternalTradeDoc, ExternalTradeAttrs, ExternalTradeImportMeta, };
@@ -17,6 +17,9 @@ const buildExternalTrade = (mongoose) => {
17
17
  tradeKey: {
18
18
  type: String,
19
19
  },
20
+ valueDate: {
21
+ type: String,
22
+ },
20
23
  requestedAmountType: {
21
24
  type: String,
22
25
  required: true,
@@ -90,6 +93,9 @@ const buildExternalTrade = (mongoose) => {
90
93
  type: Boolean,
91
94
  default: false,
92
95
  },
96
+ importMeta: {
97
+ type: Object,
98
+ },
93
99
  }, {
94
100
  toJSON: {
95
101
  transform(doc, ret) {
@@ -0,0 +1,18 @@
1
+ import mongoose from "mongoose";
2
+ import { InternalSupportAuditType } from "@riocrypto/common";
3
+ export interface InternalSupportAuditEventDoc extends mongoose.Document {
4
+ sessionId: string;
5
+ adminAuthId: string;
6
+ adminAuthEmail: string;
7
+ type: InternalSupportAuditType;
8
+ toolName?: string;
9
+ toolInput?: any;
10
+ detail?: string;
11
+ redactionCounts?: Record<string, number>;
12
+ inputTokens?: number;
13
+ outputTokens?: number;
14
+ createdAt: Date;
15
+ }
16
+ export type InternalSupportAuditEventModel = mongoose.Model<InternalSupportAuditEventDoc>;
17
+ declare const buildInternalSupportAuditEvent: (mongoose: typeof mongoose) => InternalSupportAuditEventModel;
18
+ export { buildInternalSupportAuditEvent };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildInternalSupportAuditEvent = void 0;
4
+ const common_1 = require("@riocrypto/common");
5
+ const buildInternalSupportAuditEvent = (mongoose) => {
6
+ if (mongoose.models.InternalSupportAuditEvent) {
7
+ return mongoose.model("InternalSupportAuditEvent");
8
+ }
9
+ const schema = new mongoose.Schema({
10
+ sessionId: { type: String, required: true },
11
+ adminAuthId: { type: String, required: true },
12
+ adminAuthEmail: { type: String, required: true },
13
+ type: { type: String, enum: Object.values(common_1.InternalSupportAuditType), required: true },
14
+ toolName: { type: String },
15
+ toolInput: { type: mongoose.Schema.Types.Mixed },
16
+ detail: { type: String },
17
+ redactionCounts: { type: mongoose.Schema.Types.Mixed },
18
+ inputTokens: { type: Number },
19
+ outputTokens: { type: Number },
20
+ }, {
21
+ timestamps: { createdAt: true, updatedAt: false },
22
+ collection: "internalSupportAuditEvents",
23
+ });
24
+ // Daily caps count and sum per admin, type and time window on every new
25
+ // question, so that query is index-only. The per-session index is in
26
+ // event order for reviewing one conversation's trail.
27
+ schema.index({ adminAuthId: 1, type: 1, createdAt: -1 });
28
+ schema.index({ sessionId: 1, createdAt: 1 });
29
+ schema.index({ type: 1, createdAt: -1 });
30
+ return mongoose.model("InternalSupportAuditEvent", schema);
31
+ };
32
+ exports.buildInternalSupportAuditEvent = buildInternalSupportAuditEvent;
@@ -0,0 +1,19 @@
1
+ import mongoose from "mongoose";
2
+ import { InternalSupportCaseConfidence } from "@riocrypto/common";
3
+ export interface InternalSupportCaseDoc extends mongoose.Document {
4
+ sessionId: string;
5
+ adminAuthEmail: string;
6
+ symptom: string;
7
+ services: string[];
8
+ rootCause: string;
9
+ evidence: string;
10
+ resolution: string;
11
+ confidence: InternalSupportCaseConfidence;
12
+ tags: string[];
13
+ questions: number;
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ }
17
+ export type InternalSupportCaseModel = mongoose.Model<InternalSupportCaseDoc>;
18
+ declare const buildInternalSupportCase: (mongoose: typeof mongoose) => InternalSupportCaseModel;
19
+ export { buildInternalSupportCase };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildInternalSupportCase = void 0;
4
+ const buildInternalSupportCase = (mongoose) => {
5
+ if (mongoose.models.InternalSupportCase) {
6
+ return mongoose.model("InternalSupportCase");
7
+ }
8
+ const schema = new mongoose.Schema({
9
+ sessionId: { type: String, required: true, unique: true },
10
+ adminAuthEmail: { type: String, required: true },
11
+ symptom: { type: String, required: true },
12
+ services: { type: [String], default: [] },
13
+ rootCause: { type: String, default: "" },
14
+ evidence: { type: String, default: "" },
15
+ resolution: { type: String, default: "" },
16
+ confidence: { type: String, enum: ["low", "medium", "high"], default: "low" },
17
+ tags: { type: [String], default: [] },
18
+ questions: { type: Number, default: 1 },
19
+ }, {
20
+ timestamps: true,
21
+ collection: "internalSupportCases",
22
+ toJSON: {
23
+ transform(_doc, ret) {
24
+ ret.id = ret._id;
25
+ delete ret._id;
26
+ delete ret.__v;
27
+ },
28
+ },
29
+ });
30
+ // Weighted text index so a new question matches on the symptom and the
31
+ // services first, then on the cause and the tags.
32
+ schema.index({ symptom: "text", tags: "text", services: "text", rootCause: "text", resolution: "text" }, {
33
+ weights: { symptom: 10, tags: 8, services: 6, rootCause: 4, resolution: 2 },
34
+ name: "case_text",
35
+ });
36
+ schema.index({ updatedAt: -1 });
37
+ return mongoose.model("InternalSupportCase", schema);
38
+ };
39
+ exports.buildInternalSupportCase = buildInternalSupportCase;
@@ -0,0 +1,13 @@
1
+ import mongoose from "mongoose";
2
+ import { InternalSupportChatKind } from "@riocrypto/common";
3
+ export interface InternalSupportChatMessageDoc extends mongoose.Document {
4
+ sessionId: string;
5
+ sequenceNumber: number;
6
+ kind: InternalSupportChatKind;
7
+ text: string;
8
+ toolName?: string;
9
+ createdAt: Date;
10
+ }
11
+ export type InternalSupportChatMessageModel = mongoose.Model<InternalSupportChatMessageDoc>;
12
+ declare const buildInternalSupportChatMessage: (mongoose: typeof mongoose) => InternalSupportChatMessageModel;
13
+ export { buildInternalSupportChatMessage };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildInternalSupportChatMessage = void 0;
4
+ const common_1 = require("@riocrypto/common");
5
+ const buildInternalSupportChatMessage = (mongoose) => {
6
+ if (mongoose.models.InternalSupportChatMessage) {
7
+ return mongoose.model("InternalSupportChatMessage");
8
+ }
9
+ const schema = new mongoose.Schema({
10
+ sessionId: { type: String, required: true, index: true },
11
+ sequenceNumber: { type: Number, required: true },
12
+ kind: { type: String, enum: Object.values(common_1.InternalSupportChatKind), required: true },
13
+ text: { type: String, required: true },
14
+ toolName: { type: String },
15
+ }, {
16
+ timestamps: { createdAt: true, updatedAt: false },
17
+ collection: "internalSupportChatMessages",
18
+ toJSON: {
19
+ transform(_doc, ret) {
20
+ ret.id = ret._id;
21
+ delete ret._id;
22
+ delete ret.__v;
23
+ },
24
+ },
25
+ });
26
+ schema.index({ sessionId: 1, sequenceNumber: 1 }, { unique: true });
27
+ return mongoose.model("InternalSupportChatMessage", schema);
28
+ };
29
+ exports.buildInternalSupportChatMessage = buildInternalSupportChatMessage;
@@ -0,0 +1,36 @@
1
+ import mongoose from "mongoose";
2
+ import { InternalSupportSecuritySignalType } from "@riocrypto/common";
3
+ export interface InternalSupportSecuritySignalDoc extends mongoose.Document {
4
+ adminAuthId: string;
5
+ adminAuthEmail: string;
6
+ adminAuthName: string;
7
+ sessionId?: string;
8
+ type: InternalSupportSecuritySignalType;
9
+ detail: string;
10
+ createdAt: Date;
11
+ }
12
+ export type InternalSupportSecuritySignalModel = mongoose.Model<InternalSupportSecuritySignalDoc>;
13
+ declare const buildInternalSupportSecuritySignal: (mongoose: typeof mongoose) => InternalSupportSecuritySignalModel;
14
+ export interface InternalSupportLockoutDoc extends mongoose.Document {
15
+ adminAuthId: string;
16
+ adminAuthEmail: string;
17
+ adminAuthName: string;
18
+ reason: string;
19
+ lockedAt: Date;
20
+ lockedUntil: Date;
21
+ unlockedAt?: Date;
22
+ unlockedBy?: string;
23
+ }
24
+ export type InternalSupportLockoutModel = mongoose.Model<InternalSupportLockoutDoc>;
25
+ declare const buildInternalSupportLockout: (mongoose: typeof mongoose) => InternalSupportLockoutModel;
26
+ export declare const INTERNAL_SUPPORT_CONTROLS_KEY = "global";
27
+ export interface InternalSupportControlsDoc extends mongoose.Document {
28
+ key: string;
29
+ disabled: boolean;
30
+ disabledAt?: Date;
31
+ disabledBy?: string;
32
+ reason?: string;
33
+ }
34
+ export type InternalSupportControlsModel = mongoose.Model<InternalSupportControlsDoc>;
35
+ declare const buildInternalSupportControls: (mongoose: typeof mongoose) => InternalSupportControlsModel;
36
+ export { buildInternalSupportSecuritySignal, buildInternalSupportLockout, buildInternalSupportControls };
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildInternalSupportControls = exports.buildInternalSupportLockout = exports.buildInternalSupportSecuritySignal = exports.INTERNAL_SUPPORT_CONTROLS_KEY = void 0;
4
+ const common_1 = require("@riocrypto/common");
5
+ const buildInternalSupportSecuritySignal = (mongoose) => {
6
+ if (mongoose.models.InternalSupportSecuritySignal) {
7
+ return mongoose.model("InternalSupportSecuritySignal");
8
+ }
9
+ const schema = new mongoose.Schema({
10
+ adminAuthId: { type: String, required: true, index: true },
11
+ adminAuthEmail: { type: String, required: true },
12
+ adminAuthName: { type: String, default: "" },
13
+ sessionId: { type: String },
14
+ type: {
15
+ type: String,
16
+ enum: Object.values(common_1.InternalSupportSecuritySignalType),
17
+ required: true,
18
+ },
19
+ detail: { type: String, default: "" },
20
+ }, {
21
+ timestamps: { createdAt: true, updatedAt: false },
22
+ collection: "internalSupportSecuritySignals",
23
+ });
24
+ schema.index({ createdAt: -1 });
25
+ schema.index({ adminAuthId: 1, createdAt: -1 });
26
+ return mongoose.model("InternalSupportSecuritySignal", schema);
27
+ };
28
+ exports.buildInternalSupportSecuritySignal = buildInternalSupportSecuritySignal;
29
+ const buildInternalSupportLockout = (mongoose) => {
30
+ if (mongoose.models.InternalSupportLockout) {
31
+ return mongoose.model("InternalSupportLockout");
32
+ }
33
+ const schema = new mongoose.Schema({
34
+ adminAuthId: { type: String, required: true, index: true },
35
+ adminAuthEmail: { type: String, required: true },
36
+ adminAuthName: { type: String, default: "" },
37
+ reason: { type: String, default: "" },
38
+ lockedAt: { type: Date, required: true },
39
+ lockedUntil: { type: Date, required: true },
40
+ unlockedAt: { type: Date },
41
+ unlockedBy: { type: String },
42
+ }, {
43
+ collection: "internalSupportLockouts",
44
+ toJSON: {
45
+ transform(_doc, ret) {
46
+ ret.id = ret._id;
47
+ delete ret._id;
48
+ delete ret.__v;
49
+ },
50
+ },
51
+ });
52
+ return mongoose.model("InternalSupportLockout", schema);
53
+ };
54
+ exports.buildInternalSupportLockout = buildInternalSupportLockout;
55
+ // Singleton (key "global"). Read on every write request so the switch works
56
+ // without a redeploy; flipped by a super admin or by the monitor when a
57
+ // global trip condition is met.
58
+ exports.INTERNAL_SUPPORT_CONTROLS_KEY = "global";
59
+ const buildInternalSupportControls = (mongoose) => {
60
+ if (mongoose.models.InternalSupportControls) {
61
+ return mongoose.model("InternalSupportControls");
62
+ }
63
+ const schema = new mongoose.Schema({
64
+ key: { type: String, required: true, unique: true },
65
+ disabled: { type: Boolean, default: false },
66
+ disabledAt: { type: Date },
67
+ disabledBy: { type: String },
68
+ reason: { type: String },
69
+ }, {
70
+ collection: "internalSupportControls",
71
+ toJSON: {
72
+ transform(_doc, ret) {
73
+ delete ret._id;
74
+ delete ret.__v;
75
+ delete ret.key;
76
+ },
77
+ },
78
+ });
79
+ return mongoose.model("InternalSupportControls", schema);
80
+ };
81
+ exports.buildInternalSupportControls = buildInternalSupportControls;
@@ -0,0 +1,18 @@
1
+ import mongoose from "mongoose";
2
+ import { InternalSupportSessionStatus } from "@riocrypto/common";
3
+ export interface InternalSupportSessionDoc extends mongoose.Document {
4
+ sessionId: string;
5
+ adminAuthId: string;
6
+ adminAuthEmail: string;
7
+ adminAuthName: string;
8
+ title: string;
9
+ status: InternalSupportSessionStatus;
10
+ modelId: string;
11
+ apiMessages: any[];
12
+ sequenceNumber: number;
13
+ createdAt: Date;
14
+ updatedAt: Date;
15
+ }
16
+ export type InternalSupportSessionModel = mongoose.Model<InternalSupportSessionDoc>;
17
+ declare const buildInternalSupportSession: (mongoose: typeof mongoose) => InternalSupportSessionModel;
18
+ export { buildInternalSupportSession };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildInternalSupportSession = void 0;
4
+ const common_1 = require("@riocrypto/common");
5
+ const buildInternalSupportSession = (mongoose) => {
6
+ if (mongoose.models.InternalSupportSession) {
7
+ return mongoose.model("InternalSupportSession");
8
+ }
9
+ const schema = new mongoose.Schema({
10
+ sessionId: { type: String, required: true, unique: true, index: true },
11
+ adminAuthId: { type: String, required: true, index: true },
12
+ adminAuthEmail: { type: String, required: true },
13
+ adminAuthName: { type: String, default: "" },
14
+ title: { type: String, default: "" },
15
+ status: {
16
+ type: String,
17
+ enum: Object.values(common_1.InternalSupportSessionStatus),
18
+ default: common_1.InternalSupportSessionStatus.Idle,
19
+ },
20
+ modelId: { type: String, default: "" },
21
+ apiMessages: { type: Array, default: [] },
22
+ sequenceNumber: { type: Number, default: 0 },
23
+ }, {
24
+ timestamps: true,
25
+ collection: "internalSupportSessions",
26
+ toJSON: {
27
+ transform(_doc, ret) {
28
+ ret.id = ret._id;
29
+ delete ret._id;
30
+ delete ret.__v;
31
+ delete ret.apiMessages;
32
+ },
33
+ },
34
+ });
35
+ return mongoose.model("InternalSupportSession", schema);
36
+ };
37
+ exports.buildInternalSupportSession = buildInternalSupportSession;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2931",
3
+ "version": "1.0.2933",
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.2728",
31
+ "@riocrypto/common": "1.0.2729",
32
32
  "@slack/web-api": "^7.15.0",
33
33
  "@types/express": "^4.17.25",
34
34
  "axios": "1.18.1",