@riocrypto/common-server 1.0.2669 → 1.0.2672

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.
@@ -28,7 +28,17 @@ const getBulkPaymentFromReference = (reference, mongoose) => __awaiter(void 0, v
28
28
  ],
29
29
  },
30
30
  });
31
- // Reference format: 2 chars from random portion (8-9) + last 6 chars of ID
31
+ // First try exact match on stored reference field (most reliable)
32
+ const exactMatch = bulkPayments.find((bp) => { var _a; return ((_a = bp.reference) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === referenceText; });
33
+ if (exactMatch) {
34
+ return exactMatch;
35
+ }
36
+ // Bulk payment references must contain "bp" prefix to avoid false positives
37
+ // with order references that don't have this prefix
38
+ if (!referenceText.includes("bp")) {
39
+ throw new Error("Bulk payment not found");
40
+ }
41
+ // Match by ID pattern: 2 chars from random portion (8-9) + last 6 chars
32
42
  const bulkPayment = bulkPayments.find((bulkPayment) => {
33
43
  const bulkPaymentId = bulkPayment.id.toString().toLowerCase();
34
44
  const randomPrefix = bulkPaymentId.slice(8, 10);
@@ -47,14 +47,13 @@ const getOrderFromReference = (reference, mongoose) => __awaiter(void 0, void 0,
47
47
  break;
48
48
  }
49
49
  // Check each order ID against the reference
50
- // Reference format: 2 chars from random portion (8-9) + last 6 chars of order ID
50
+ // Reference format: 2 chars from random portion (8-9) + last 6 chars
51
51
  for (const order of orders) {
52
52
  const orderId = order._id.toString().toLowerCase();
53
53
  const randomPrefix = orderId.slice(8, 10);
54
54
  const last6 = orderId.slice(-6);
55
55
  const reference8Chars = randomPrefix + last6;
56
56
  if (referenceText.includes(reference8Chars)) {
57
- // Found a match, now fetch the full order document
58
57
  foundOrder = yield Order.findById(order._id);
59
58
  break;
60
59
  }
package/build/index.d.ts CHANGED
@@ -107,6 +107,7 @@ export * from "./models/order-log";
107
107
  export * from "./models/approved-alternative-bank-account-holder-name";
108
108
  export * from "./models/liquidity-sourcing-plan";
109
109
  export * from "./models/liquidity-sourcing-exclusion";
110
+ export * from "./models/liquidity-sourcing-settings";
110
111
  export * from "./clients/axios-with-logging";
111
112
  export * from "./clients/slack-client";
112
113
  export * from "./clients/fireblocks-client";
package/build/index.js CHANGED
@@ -123,6 +123,7 @@ __exportStar(require("./models/order-log"), exports);
123
123
  __exportStar(require("./models/approved-alternative-bank-account-holder-name"), exports);
124
124
  __exportStar(require("./models/liquidity-sourcing-plan"), exports);
125
125
  __exportStar(require("./models/liquidity-sourcing-exclusion"), exports);
126
+ __exportStar(require("./models/liquidity-sourcing-settings"), exports);
126
127
  __exportStar(require("./clients/axios-with-logging"), exports);
127
128
  __exportStar(require("./clients/slack-client"), exports);
128
129
  __exportStar(require("./clients/fireblocks-client"), exports);
@@ -0,0 +1,16 @@
1
+ import mongoose from "mongoose";
2
+ import { LiquiditySourcingSettings } from "@riocrypto/common";
3
+ interface LiquiditySourcingSettingsAttrs {
4
+ mxnEnabled: boolean;
5
+ usdcEnabled: boolean;
6
+ usdtEnabled: boolean;
7
+ updatedAt: Date;
8
+ }
9
+ interface LiquiditySourcingSettingsDoc extends mongoose.Document, Omit<LiquiditySourcingSettings, "id"> {
10
+ id: string;
11
+ }
12
+ interface LiquiditySourcingSettingsModel extends mongoose.Model<LiquiditySourcingSettingsDoc> {
13
+ build(attrs: LiquiditySourcingSettingsAttrs): LiquiditySourcingSettingsDoc;
14
+ }
15
+ declare const buildLiquiditySourcingSettings: (mongooseInstance: mongoose.Mongoose) => LiquiditySourcingSettingsModel;
16
+ export { LiquiditySourcingSettingsAttrs, LiquiditySourcingSettingsDoc, LiquiditySourcingSettingsModel, buildLiquiditySourcingSettings, };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildLiquiditySourcingSettings = void 0;
7
+ const mongoose_1 = __importDefault(require("mongoose"));
8
+ const LiquiditySourcingSettingsSchema = new mongoose_1.default.Schema({
9
+ mxnEnabled: { type: Boolean, required: true, default: true },
10
+ usdcEnabled: { type: Boolean, required: true, default: true },
11
+ usdtEnabled: { type: Boolean, required: true, default: true },
12
+ updatedAt: { type: Date, required: true },
13
+ }, {
14
+ toJSON: {
15
+ transform(doc, ret) {
16
+ ret.id = ret._id;
17
+ delete ret._id;
18
+ delete ret.__v;
19
+ },
20
+ },
21
+ });
22
+ const buildLiquiditySourcingSettings = (mongooseInstance) => {
23
+ if (mongooseInstance.models.LiquiditySourcingSettings) {
24
+ return mongooseInstance.model("LiquiditySourcingSettings");
25
+ }
26
+ LiquiditySourcingSettingsSchema.statics.build = (attrs) => {
27
+ return new LiquiditySourcingSettingsModelInstance(attrs);
28
+ };
29
+ const LiquiditySourcingSettingsModelInstance = mongooseInstance.model("LiquiditySourcingSettings", LiquiditySourcingSettingsSchema);
30
+ return LiquiditySourcingSettingsModelInstance;
31
+ };
32
+ exports.buildLiquiditySourcingSettings = buildLiquiditySourcingSettings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2669",
3
+ "version": "1.0.2672",
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.3.0",
29
29
  "@google-cloud/storage": "^6.9.5",
30
30
  "@hyperdx/node-opentelemetry": "^0.7.0",
31
- "@riocrypto/common": "^1.0.2468",
31
+ "@riocrypto/common": "^1.0.2470",
32
32
  "@types/express": "^4.17.13",
33
33
  "axios": "^1.7.4",
34
34
  "crypto-js": "^4.2.0",