@riocrypto/common-server 1.0.2835 → 1.0.2836

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.
@@ -2,6 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getProcessor = void 0;
4
4
  const common_1 = require("@riocrypto/common");
5
+ // Alfin only takes effect in Test/Local. In every other environment we never
6
+ // route to Alfin (regardless of user attributes or active processors), so the
7
+ // service can be deployed before Alfin is actually enabled.
8
+ const isAlfinEnabled = () => [common_1.RioEnv.Test, common_1.RioEnv.Local].includes(process.env.RIO_ENV);
5
9
  const getProcessor = ({ country, fiat, user, activeProcessors, side, isBinanceRFQ, }) => {
6
10
  var _a, _b, _c, _d, _e, _f;
7
11
  if (isBinanceRFQ === true) {
@@ -18,11 +22,13 @@ const getProcessor = ({ country, fiat, user, activeProcessors, side, isBinanceRF
18
22
  else if (fiat === common_1.Fiat.PEN) {
19
23
  if (country === common_1.Country.Peru) {
20
24
  if (side === common_1.Side.Buy &&
25
+ isAlfinEnabled() &&
21
26
  ((_a = user.attributes) === null || _a === void 0 ? void 0 : _a.includes(common_1.UserAttribute.UseAlfinForPENDeposits)) &&
22
27
  activeProcessors.includes(common_1.Processor.Alfin)) {
23
28
  return common_1.Processor.Alfin;
24
29
  }
25
30
  if (side === common_1.Side.Sell &&
31
+ isAlfinEnabled() &&
26
32
  ((_b = user.attributes) === null || _b === void 0 ? void 0 : _b.includes(common_1.UserAttribute.UseAlfinForPENWithdrawals)) &&
27
33
  activeProcessors.includes(common_1.Processor.Alfin)) {
28
34
  return common_1.Processor.Alfin;
@@ -71,11 +77,13 @@ const getProcessor = ({ country, fiat, user, activeProcessors, side, isBinanceRF
71
77
  }
72
78
  else if (country === common_1.Country.Peru) {
73
79
  if (side === common_1.Side.Buy &&
80
+ isAlfinEnabled() &&
74
81
  ((_e = user.attributes) === null || _e === void 0 ? void 0 : _e.includes(common_1.UserAttribute.UseAlfinForUSDDeposits)) &&
75
82
  activeProcessors.includes(common_1.Processor.Alfin)) {
76
83
  return common_1.Processor.Alfin;
77
84
  }
78
85
  if (side === common_1.Side.Sell &&
86
+ isAlfinEnabled() &&
79
87
  ((_f = user.attributes) === null || _f === void 0 ? void 0 : _f.includes(common_1.UserAttribute.UseAlfinForUSDWithdrawals)) &&
80
88
  activeProcessors.includes(common_1.Processor.Alfin)) {
81
89
  return common_1.Processor.Alfin;
@@ -13,6 +13,7 @@ interface ComplianceRuleResultAttrs {
13
13
  outcome?: ComplianceRuleOutcome;
14
14
  tag?: string;
15
15
  renderMarkdown?: boolean;
16
+ displayOrder?: number;
16
17
  }
17
18
  interface ComplianceRuleResultDoc extends mongoose.Document {
18
19
  id: string;
@@ -27,6 +28,7 @@ interface ComplianceRuleResultDoc extends mongoose.Document {
27
28
  outcome?: ComplianceRuleOutcome;
28
29
  tag?: string;
29
30
  renderMarkdown?: boolean;
31
+ displayOrder?: number;
30
32
  }
31
33
  interface ComplianceRuleResultModel extends mongoose.Model<ComplianceRuleResultDoc> {
32
34
  build(attrs: ComplianceRuleResultAttrs): HydratedDocument<ComplianceRuleResultDoc>;
@@ -60,6 +60,13 @@ const buildComplianceRuleResult = (mongoose) => {
60
60
  required: false,
61
61
  default: false,
62
62
  },
63
+ // Snapshot of the parent rule's displayOrder at run time so
64
+ // the PDF report orders rows within a tag group correctly
65
+ // even after the rule is reordered or deleted.
66
+ displayOrder: {
67
+ type: Number,
68
+ required: false,
69
+ },
63
70
  }, {
64
71
  toJSON: {
65
72
  transform(doc, ret) {
@@ -9,6 +9,7 @@ interface ComplianceRuleAttrs {
9
9
  ruleSetId?: string;
10
10
  tag?: string;
11
11
  renderMarkdown?: boolean;
12
+ displayOrder?: number;
12
13
  }
13
14
  interface ComplianceRuleDoc extends mongoose.Document {
14
15
  id: string;
@@ -20,6 +21,7 @@ interface ComplianceRuleDoc extends mongoose.Document {
20
21
  ruleSetId?: string;
21
22
  tag?: string;
22
23
  renderMarkdown?: boolean;
24
+ displayOrder?: number;
23
25
  }
24
26
  interface ComplianceRuleModel extends mongoose.Model<ComplianceRuleDoc> {
25
27
  build(attrs: ComplianceRuleAttrs): HydratedDocument<ComplianceRuleDoc>;
@@ -55,6 +55,15 @@ const buildComplianceRule = (mongoose) => {
55
55
  required: false,
56
56
  default: false,
57
57
  },
58
+ // Presentational sort key within the rule's
59
+ // (ruleSetId, stepType) section. Assigned by drag/drop
60
+ // reordering in the Dexter rules tree; orders rules in the
61
+ // GUI and the PDF report. Does not affect engine execution
62
+ // order. Optional/absent for legacy rules (sort last).
63
+ displayOrder: {
64
+ type: Number,
65
+ required: false,
66
+ },
58
67
  }, {
59
68
  toJSON: {
60
69
  transform(doc, ret) {
@@ -70,6 +79,9 @@ const buildComplianceRule = (mongoose) => {
70
79
  // the "tag" field in the rule editor: distinct(tag) scoped to a
71
80
  // ruleSet, including only rules that actually carry a tag.
72
81
  ComplianceRuleSchema.index({ ruleSetId: 1, tag: 1 });
82
+ // Supports the per-step-type ordered fetch used by the rules tree
83
+ // and the reorder write path (rules of a set+step in display order).
84
+ ComplianceRuleSchema.index({ ruleSetId: 1, stepType: 1, displayOrder: 1 });
73
85
  ComplianceRuleSchema.statics.build = (attrs) => {
74
86
  return new ComplianceRule(attrs);
75
87
  };
@@ -5,6 +5,7 @@ interface ComplianceRuleSetAttrs {
5
5
  name: string;
6
6
  description?: string;
7
7
  isDefault: boolean;
8
+ tagOrder?: string[];
8
9
  createdAt: Date;
9
10
  updatedAt: Date;
10
11
  }
@@ -15,6 +16,7 @@ interface ComplianceRuleSetDoc extends mongoose.Document {
15
16
  name: string;
16
17
  description?: string;
17
18
  isDefault: boolean;
19
+ tagOrder?: string[];
18
20
  createdAt: Date;
19
21
  updatedAt: Date;
20
22
  }
@@ -27,6 +27,14 @@ const buildComplianceRuleSet = (mongoose) => {
27
27
  required: true,
28
28
  default: false,
29
29
  },
30
+ // Ordered list of tag labels controlling tag-group sequence
31
+ // in the PDF report. Tags absent from this list render after
32
+ // (alphabetically); the untagged bucket is always last.
33
+ tagOrder: {
34
+ type: [String],
35
+ required: false,
36
+ default: [],
37
+ },
30
38
  createdAt: {
31
39
  type: Date,
32
40
  required: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2835",
3
+ "version": "1.0.2836",
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.2634",
31
+ "@riocrypto/common": "1.0.2637",
32
32
  "@slack/web-api": "^7.15.0",
33
33
  "@types/express": "^4.17.25",
34
34
  "axios": "1.16.0",