@pax2pay/model-banking 0.1.654 → 0.1.655
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/Backup/Rule.ts +13 -9
- package/Organization/Creatable.ts +1 -1
- package/Organization/index.ts +1 -1
- package/Rule/State/Transaction.ts +2 -2
- package/Rule/State/index.ts +2 -2
- package/Rule/index.ts +7 -36
- package/Rule/type.ts +5 -2
- package/Transaction/Note.ts +10 -2
- package/dist/cjs/Audit.d.ts +1 -1
- package/dist/cjs/Backup/Rule.d.ts +1 -1
- package/dist/cjs/Backup/Rule.js +12 -9
- package/dist/cjs/Backup/Rule.js.map +1 -1
- package/dist/cjs/Organization/Creatable.d.ts +1 -1
- package/dist/cjs/Organization/index.d.ts +1 -1
- package/dist/cjs/Rule/State/Transaction.d.ts +2 -2
- package/dist/cjs/Rule/State/Transaction.js.map +1 -1
- package/dist/cjs/Rule/State/index.d.ts +3 -3
- package/dist/cjs/Rule/State/index.js.map +1 -1
- package/dist/cjs/Rule/index.d.ts +8 -14
- package/dist/cjs/Rule/index.js +6 -33
- package/dist/cjs/Rule/index.js.map +1 -1
- package/dist/cjs/Rule/type.d.ts +2 -2
- package/dist/cjs/Rule/type.js +2 -2
- package/dist/cjs/Rule/type.js.map +1 -1
- package/dist/cjs/Transaction/Note.d.ts +10 -2
- package/dist/cjs/Transaction/Note.js.map +1 -1
- package/dist/cjs/User/Access/Permission.d.ts +4 -4
- package/dist/cjs/User/Access/index.d.ts +3 -3
- package/dist/cjs/User/JWT/Payload.d.ts +12 -12
- package/dist/cjs/User/index.d.ts +6 -6
- package/dist/mjs/Audit.d.ts +1 -1
- package/dist/mjs/Backup/Rule.d.ts +1 -1
- package/dist/mjs/Backup/Rule.js +12 -9
- package/dist/mjs/Backup/Rule.js.map +1 -1
- package/dist/mjs/Organization/Creatable.d.ts +1 -1
- package/dist/mjs/Organization/index.d.ts +1 -1
- package/dist/mjs/Rule/State/Transaction.d.ts +2 -2
- package/dist/mjs/Rule/State/Transaction.js.map +1 -1
- package/dist/mjs/Rule/State/index.d.ts +3 -3
- package/dist/mjs/Rule/State/index.js.map +1 -1
- package/dist/mjs/Rule/index.d.ts +8 -14
- package/dist/mjs/Rule/index.js +6 -33
- package/dist/mjs/Rule/index.js.map +1 -1
- package/dist/mjs/Rule/type.d.ts +2 -2
- package/dist/mjs/Rule/type.js +2 -2
- package/dist/mjs/Rule/type.js.map +1 -1
- package/dist/mjs/Transaction/Note.d.ts +10 -2
- package/dist/mjs/Transaction/Note.js.map +1 -1
- package/dist/mjs/User/Access/Permission.d.ts +4 -4
- package/dist/mjs/User/Access/index.d.ts +3 -3
- package/dist/mjs/User/JWT/Payload.d.ts +12 -12
- package/dist/mjs/User/index.d.ts +6 -6
- package/package.json +1 -1
- package/Rule/Base.ts +0 -43
- package/Rule/Other.ts +0 -47
- package/Rule/control.ts +0 -7
- package/dist/cjs/Rule/Base.d.ts +0 -27
- package/dist/cjs/Rule/Base.js +0 -36
- package/dist/cjs/Rule/Base.js.map +0 -1
- package/dist/cjs/Rule/Other.d.ts +0 -20
- package/dist/cjs/Rule/Other.js +0 -42
- package/dist/cjs/Rule/Other.js.map +0 -1
- package/dist/cjs/Rule/control.d.ts +0 -4
- package/dist/cjs/Rule/control.js +0 -8
- package/dist/cjs/Rule/control.js.map +0 -1
- package/dist/mjs/Rule/Base.d.ts +0 -27
- package/dist/mjs/Rule/Base.js +0 -33
- package/dist/mjs/Rule/Base.js.map +0 -1
- package/dist/mjs/Rule/Other.d.ts +0 -20
- package/dist/mjs/Rule/Other.js +0 -39
- package/dist/mjs/Rule/Other.js.map +0 -1
- package/dist/mjs/Rule/control.d.ts +0 -4
- package/dist/mjs/Rule/control.js +0 -5
- package/dist/mjs/Rule/control.js.map +0 -1
package/Backup/Rule.ts
CHANGED
|
@@ -12,14 +12,18 @@ export namespace Rule {
|
|
|
12
12
|
value: modelRule,
|
|
13
13
|
action: Base.Action,
|
|
14
14
|
data?: { organization?: string; account?: string }
|
|
15
|
-
) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
) => {
|
|
16
|
+
// Rule is currently typed as `never`, so its fields are read via a cast until rules are retyped.
|
|
17
|
+
const rule = value as { code: string; category: string; type: string; action: string }
|
|
18
|
+
return {
|
|
19
|
+
entityType: "rule",
|
|
20
|
+
entity: rule.code,
|
|
21
|
+
...data,
|
|
22
|
+
action,
|
|
23
|
+
created: isoly.DateTime.now(),
|
|
24
|
+
meta: `${rule.category}.${rule.type}.${rule.action}`,
|
|
25
|
+
value,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
24
28
|
export const addSender = Base.pipeToSender(create)
|
|
25
29
|
}
|
package/Organization/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isly } from "isly"
|
|
2
2
|
import { Type } from "../Account/Type"
|
|
3
3
|
import { Realm } from "../Realm"
|
|
4
|
-
import { Rule } from "../Rule"
|
|
4
|
+
import type { Rule } from "../Rule"
|
|
5
5
|
import { type as ruleType } from "../Rule/type"
|
|
6
6
|
import { Changeable as OrganizationChangeable } from "./Changeable"
|
|
7
7
|
import { Contact as OrganizationContact } from "./Contact"
|
|
@@ -5,7 +5,7 @@ import type { Rule } from "../index"
|
|
|
5
5
|
|
|
6
6
|
export type Transaction = ModelTransaction.Creatable.Resolved & {
|
|
7
7
|
id: string
|
|
8
|
-
kind: Rule.
|
|
8
|
+
kind: Rule.Kind
|
|
9
9
|
stage: "finalize" | "initiate"
|
|
10
10
|
amount: number
|
|
11
11
|
type: ModelTransaction.Types
|
|
@@ -19,7 +19,7 @@ export namespace Transaction {
|
|
|
19
19
|
export function from(
|
|
20
20
|
account: ModelAccount,
|
|
21
21
|
transaction: ModelTransaction.Creatable.Resolved | ModelTransaction,
|
|
22
|
-
kind: Rule.
|
|
22
|
+
kind: Rule.Kind,
|
|
23
23
|
stage: "finalize" | "initiate"
|
|
24
24
|
): Transaction {
|
|
25
25
|
const amount = Math.abs(typeof transaction.amount == "number" ? transaction.amount : transaction.amount.original)
|
package/Rule/State/index.ts
CHANGED
|
@@ -39,7 +39,7 @@ export namespace State {
|
|
|
39
39
|
account: ModelAccount,
|
|
40
40
|
address: Rail.Address,
|
|
41
41
|
transaction: ModelTransaction.Creatable.Resolved | ModelTransaction,
|
|
42
|
-
kind: Rule.
|
|
42
|
+
kind: Rule.Kind,
|
|
43
43
|
stage: "finalize" | "initiate",
|
|
44
44
|
card?: Card,
|
|
45
45
|
organization?: Organization
|
|
@@ -52,7 +52,7 @@ export namespace State {
|
|
|
52
52
|
organization,
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
export const type: Record<ModelTransaction.PreTransaction["type"], Rule.
|
|
55
|
+
export const type: Record<ModelTransaction.PreTransaction["type"], Rule.Kind> = {
|
|
56
56
|
authorization: "authorization",
|
|
57
57
|
incoming: "inbound",
|
|
58
58
|
outgoing: "outbound",
|
package/Rule/index.ts
CHANGED
|
@@ -1,48 +1,19 @@
|
|
|
1
1
|
import { isly } from "isly"
|
|
2
|
-
import type { Note } from "../Transaction/Note"
|
|
3
|
-
import { Base as RuleBase } from "./Base"
|
|
4
|
-
import { control as ruleControl } from "./control"
|
|
5
|
-
import { Other as RuleOther } from "./Other"
|
|
6
2
|
import { State as RuleState } from "./State"
|
|
7
3
|
import { type as ruleType } from "./type"
|
|
8
4
|
|
|
9
|
-
export type Rule =
|
|
5
|
+
export type Rule = never
|
|
10
6
|
export namespace Rule {
|
|
11
|
-
export import Other = RuleOther
|
|
12
7
|
export import State = RuleState
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
export type Kind = (typeof Kind.values)[number]
|
|
9
|
+
export namespace Kind {
|
|
10
|
+
export const values = ["authorization", "outbound", "inbound", "capture", "refund"] as const
|
|
11
|
+
export const type = isly.string<Kind>(values)
|
|
12
|
+
}
|
|
18
13
|
export type Action = (typeof Action.values)[number]
|
|
19
14
|
export namespace Action {
|
|
20
|
-
export const values = [
|
|
15
|
+
export const values = ["review", "reject", "flag"] as const
|
|
21
16
|
export const type = isly.string<Action>(values)
|
|
22
17
|
}
|
|
23
18
|
export const type = ruleType
|
|
24
|
-
export function evaluate(rules: Rule[], state: RuleState): RuleState.Evaluated {
|
|
25
|
-
const outcomes: Record<Rule.Action, Rule[]> = {
|
|
26
|
-
review: [],
|
|
27
|
-
reject: [],
|
|
28
|
-
flag: [],
|
|
29
|
-
}
|
|
30
|
-
const notes: Note[] = []
|
|
31
|
-
const evaluated = Other.evaluate(
|
|
32
|
-
rules.filter(rule => Base.Kind.is(state.transaction.kind, rule, state.organization?.groups, state.card?.preset)),
|
|
33
|
-
state
|
|
34
|
-
)
|
|
35
|
-
notes.push(...evaluated.notes)
|
|
36
|
-
outcomes.flag.push(...evaluated.outcomes.flag)
|
|
37
|
-
outcomes.review.push(...evaluated.outcomes.review)
|
|
38
|
-
outcomes.reject.push(...evaluated.outcomes.reject)
|
|
39
|
-
const outcome = outcomes.reject.length > 0 ? "reject" : outcomes.review.length > 0 ? "review" : "approve"
|
|
40
|
-
return { ...state, flags: [...evaluated.flags], notes, outcomes, outcome }
|
|
41
|
-
}
|
|
42
|
-
export function isLegacy(rule: Rule): boolean {
|
|
43
|
-
return !Rule.Base.Category.type.is(rule.category)
|
|
44
|
-
}
|
|
45
|
-
export function fromLegacy(rule: Rule): Rule {
|
|
46
|
-
return isLegacy(rule) ? { ...rule, category: "fincrime" } : rule
|
|
47
|
-
}
|
|
48
19
|
}
|
package/Rule/type.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isly } from "isly"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// Standalone isly type for rules, kept out of Rule/index.ts to avoid a circular
|
|
4
|
+
// import (Rule/index → Rule/State → State/Card → Card → Rule). Rule is currently
|
|
5
|
+
// typed as `never`, so this validates to `never[]` when used as an array.
|
|
6
|
+
export const type = isly.any<never>()
|
package/Transaction/Note.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
|
-
import type { Rule } from "../Rule"
|
|
4
3
|
|
|
5
4
|
export interface Note extends Note.Creatable {
|
|
6
5
|
author: string
|
|
@@ -15,7 +14,16 @@ export namespace Note {
|
|
|
15
14
|
text?: string
|
|
16
15
|
action?: "approve" | "reject"
|
|
17
16
|
flags?: string[]
|
|
18
|
-
rule?:
|
|
17
|
+
rule?: {
|
|
18
|
+
action: "reject"
|
|
19
|
+
code: string
|
|
20
|
+
name: string
|
|
21
|
+
type: "authorization"
|
|
22
|
+
category: "fincrime"
|
|
23
|
+
condition: ""
|
|
24
|
+
description: string
|
|
25
|
+
flags: ["category", "merchant"]
|
|
26
|
+
}
|
|
19
27
|
}
|
|
20
28
|
export namespace Creatable {
|
|
21
29
|
export const type = isly.object<Creatable>({
|
package/dist/cjs/Audit.d.ts
CHANGED
|
@@ -38,6 +38,6 @@ export declare namespace Audit {
|
|
|
38
38
|
readonly clearbank: readonly ["assessmentFailed", "validationFailed"];
|
|
39
39
|
};
|
|
40
40
|
const keys: (keyof typeof value)[];
|
|
41
|
-
const type: isly.Type<"clearbank" | "
|
|
41
|
+
const type: isly.Type<"clearbank" | "account" | "transaction" | "organization" | "rule" | "settlements" | "user" | "marqeta" | "label" | "route">;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -10,7 +10,7 @@ export declare namespace Rule {
|
|
|
10
10
|
organization?: string;
|
|
11
11
|
account?: string;
|
|
12
12
|
}>;
|
|
13
|
-
const addSender: (sender: (backup: Rule) => any | Promise<any>) => (args_0:
|
|
13
|
+
const addSender: (sender: (backup: Rule) => any | Promise<any>) => (args_0: never, args_1: "created" | "cancelled" | "updated" | "removed" | "inactivated", args_2?: {
|
|
14
14
|
organization?: string;
|
|
15
15
|
account?: string;
|
|
16
16
|
} | undefined) => ReturnType<(backup: Rule) => any | Promise<any>>;
|
package/dist/cjs/Backup/Rule.js
CHANGED
|
@@ -5,15 +5,18 @@ const isoly_1 = require("isoly");
|
|
|
5
5
|
const Base_1 = require("./Base");
|
|
6
6
|
var Rule;
|
|
7
7
|
(function (Rule) {
|
|
8
|
-
Rule.create = (value, action, data) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
Rule.create = (value, action, data) => {
|
|
9
|
+
const rule = value;
|
|
10
|
+
return {
|
|
11
|
+
entityType: "rule",
|
|
12
|
+
entity: rule.code,
|
|
13
|
+
...data,
|
|
14
|
+
action,
|
|
15
|
+
created: isoly_1.isoly.DateTime.now(),
|
|
16
|
+
meta: `${rule.category}.${rule.type}.${rule.action}`,
|
|
17
|
+
value,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
17
20
|
Rule.addSender = Base_1.Base.pipeToSender(Rule.create);
|
|
18
21
|
})(Rule || (exports.Rule = Rule = {}));
|
|
19
22
|
//# sourceMappingURL=Rule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rule.js","sourceRoot":"","sources":["../../../Backup/Rule.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B,iCAA6B;AAO7B,IAAiB,IAAI,
|
|
1
|
+
{"version":3,"file":"Rule.js","sourceRoot":"","sources":["../../../Backup/Rule.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAE7B,iCAA6B;AAO7B,IAAiB,IAAI,CAmBpB;AAnBD,WAAiB,IAAI;IACP,WAAM,GAA8E,CAChG,KAAgB,EAChB,MAAmB,EACnB,IAAkD,EACjD,EAAE;QAEH,MAAM,IAAI,GAAG,KAAyE,CAAA;QACtF,OAAO;YACN,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,IAAI,CAAC,IAAI;YACjB,GAAG,IAAI;YACP,MAAM;YACN,OAAO,EAAE,aAAK,CAAC,QAAQ,CAAC,GAAG,EAAE;YAC7B,IAAI,EAAE,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE;YACpD,KAAK;SACL,CAAA;IACF,CAAC,CAAA;IACY,cAAS,GAAG,WAAI,CAAC,YAAY,CAAC,KAAA,MAAM,CAAC,CAAA;AACnD,CAAC,EAnBgB,IAAI,oBAAJ,IAAI,QAmBpB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Type } from "../Account/Type";
|
|
2
2
|
import { Realm } from "../Realm";
|
|
3
|
-
import { Rule } from "../Rule";
|
|
3
|
+
import type { Rule } from "../Rule";
|
|
4
4
|
import { Changeable as OrganizationChangeable } from "./Changeable";
|
|
5
5
|
import { Contact as OrganizationContact } from "./Contact";
|
|
6
6
|
import { Creatable as OrganizationCreatable } from "./Creatable";
|
|
@@ -4,7 +4,7 @@ import { Transaction as ModelTransaction } from "../../Transaction";
|
|
|
4
4
|
import type { Rule } from "../index";
|
|
5
5
|
export type Transaction = ModelTransaction.Creatable.Resolved & {
|
|
6
6
|
id: string;
|
|
7
|
-
kind: Rule.
|
|
7
|
+
kind: Rule.Kind;
|
|
8
8
|
stage: "finalize" | "initiate";
|
|
9
9
|
amount: number;
|
|
10
10
|
type: ModelTransaction.Types;
|
|
@@ -15,5 +15,5 @@ export type Transaction = ModelTransaction.Creatable.Resolved & {
|
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
export declare namespace Transaction {
|
|
18
|
-
function from(account: ModelAccount, transaction: ModelTransaction.Creatable.Resolved | ModelTransaction, kind: Rule.
|
|
18
|
+
function from(account: ModelAccount, transaction: ModelTransaction.Creatable.Resolved | ModelTransaction, kind: Rule.Kind, stage: "finalize" | "initiate"): Transaction;
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../Rule/State/Transaction.ts"],"names":[],"mappings":";;;AAEA,mDAAmE;AAenE,IAAiB,WAAW,CAkB3B;AAlBD,WAAiB,WAAW;IAC3B,SAAgB,IAAI,CACnB,OAAqB,EACrB,WAAmE,EACnE,
|
|
1
|
+
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../Rule/State/Transaction.ts"],"names":[],"mappings":";;;AAEA,mDAAmE;AAenE,IAAiB,WAAW,CAkB3B;AAlBD,WAAiB,WAAW;IAC3B,SAAgB,IAAI,CACnB,OAAqB,EACrB,WAAmE,EACnE,IAAe,EACf,KAA8B;QAE9B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,WAAW,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QACjH,OAAO;YACN,GAAG,WAAW;YACd,EAAE,EAAE,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,yBAAgB,CAAC,UAAU,CAAC,QAAQ,EAAE;YACjF,KAAK;YACL,IAAI;YACJ,MAAM;YACN,IAAI,EAAE,yBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC;YACrE,QAAQ,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;SACnE,CAAA;IACF,CAAC;IAhBe,gBAAI,OAgBnB,CAAA;AACF,CAAC,EAlBgB,WAAW,2BAAX,WAAW,QAkB3B"}
|
|
@@ -26,7 +26,7 @@ export declare namespace State {
|
|
|
26
26
|
type Outcome = (typeof Outcome.values)[number];
|
|
27
27
|
namespace Outcome {
|
|
28
28
|
const values: readonly ["approve", "reject", "review"];
|
|
29
|
-
const type: isly.Type<"
|
|
29
|
+
const type: isly.Type<"review" | "approve" | "reject">;
|
|
30
30
|
}
|
|
31
31
|
interface Evaluated extends State {
|
|
32
32
|
outcomes: globalThis.Partial<Record<Rule.Action, Rule[]>>;
|
|
@@ -34,6 +34,6 @@ export declare namespace State {
|
|
|
34
34
|
flags: string[];
|
|
35
35
|
notes: ModelTransaction.Note[];
|
|
36
36
|
}
|
|
37
|
-
function from(account: ModelAccount, address: Rail.Address, transaction: ModelTransaction.Creatable.Resolved | ModelTransaction, kind: Rule.
|
|
38
|
-
const type: Record<ModelTransaction.PreTransaction["type"], Rule.
|
|
37
|
+
function from(account: ModelAccount, address: Rail.Address, transaction: ModelTransaction.Creatable.Resolved | ModelTransaction, kind: Rule.Kind, stage: "finalize" | "initiate", card?: Card, organization?: Organization): State;
|
|
38
|
+
const type: Record<ModelTransaction.PreTransaction["type"], Rule.Kind>;
|
|
39
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../Rule/State/index.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAK3B,uCAAmD;AACnD,mDAAqE;AACrE,iCAA0C;AAC1C,iDAAkE;AAClE,uCAAmD;AACnD,+CAA+D;AAS/D,IAAiB,KAAK,CAwCrB;AAxCD,WAAiB,KAAK;IACP,aAAO,GAAG,iBAAY,CAAA;IACtB,mBAAa,GAAG,6BAAkB,CAAA;IAClC,UAAI,GAAG,WAAS,CAAA;IAChB,aAAO,GAAG,iBAAY,CAAA;IACtB,iBAAW,GAAG,yBAAgB,CAAA;IAC9B,kBAAY,GAAG,2BAAiB,CAAA;IAE9C,IAAiB,OAAO,CAGvB;IAHD,WAAiB,OAAO;QACV,cAAM,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAA;QACjD,YAAI,GAAG,WAAI,CAAC,MAAM,CAAU,QAAA,MAAM,CAAC,CAAA;IACjD,CAAC,EAHgB,OAAO,GAAP,aAAO,KAAP,aAAO,QAGvB;IAOD,SAAgB,IAAI,CACnB,OAAqB,EACrB,OAAqB,EACrB,WAAmE,EACnE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../Rule/State/index.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAK3B,uCAAmD;AACnD,mDAAqE;AACrE,iCAA0C;AAC1C,iDAAkE;AAClE,uCAAmD;AACnD,+CAA+D;AAS/D,IAAiB,KAAK,CAwCrB;AAxCD,WAAiB,KAAK;IACP,aAAO,GAAG,iBAAY,CAAA;IACtB,mBAAa,GAAG,6BAAkB,CAAA;IAClC,UAAI,GAAG,WAAS,CAAA;IAChB,aAAO,GAAG,iBAAY,CAAA;IACtB,iBAAW,GAAG,yBAAgB,CAAA;IAC9B,kBAAY,GAAG,2BAAiB,CAAA;IAE9C,IAAiB,OAAO,CAGvB;IAHD,WAAiB,OAAO;QACV,cAAM,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAA;QACjD,YAAI,GAAG,WAAI,CAAC,MAAM,CAAU,QAAA,MAAM,CAAC,CAAA;IACjD,CAAC,EAHgB,OAAO,GAAP,aAAO,KAAP,aAAO,QAGvB;IAOD,SAAgB,IAAI,CACnB,OAAqB,EACrB,OAAqB,EACrB,WAAmE,EACnE,IAAe,EACf,KAA8B,EAC9B,IAAW,EACX,YAA2B;QAE3B,OAAO;YACN,OAAO,EAAE,MAAA,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;YACvC,WAAW,EAAE,MAAA,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC;YAChE,aAAa,EAAE,MAAA,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC;YAC9C,IAAI;YACJ,YAAY;SACZ,CAAA;IACF,CAAC;IAhBe,UAAI,OAgBnB,CAAA;IACY,UAAI,GAA+D;QAC/E,aAAa,EAAE,eAAe;QAC9B,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,UAAU;KACpB,CAAA;AACF,CAAC,EAxCgB,KAAK,qBAAL,KAAK,QAwCrB"}
|
package/dist/cjs/Rule/index.d.ts
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import { isly } from "isly";
|
|
2
|
-
import { Base as RuleBase } from "./Base";
|
|
3
|
-
import { control as ruleControl } from "./control";
|
|
4
|
-
import { Other as RuleOther } from "./Other";
|
|
5
2
|
import { State as RuleState } from "./State";
|
|
6
|
-
export type Rule =
|
|
3
|
+
export type Rule = never;
|
|
7
4
|
export declare namespace Rule {
|
|
8
|
-
export import Other = RuleOther;
|
|
9
5
|
export import State = RuleState;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
type Kind = (typeof Kind.values)[number];
|
|
7
|
+
namespace Kind {
|
|
8
|
+
const values: readonly ["authorization", "outbound", "inbound", "capture", "refund"];
|
|
9
|
+
const type: isly.Type<"capture" | "refund" | "authorization" | "inbound" | "outbound">;
|
|
10
|
+
}
|
|
14
11
|
type Action = (typeof Action.values)[number];
|
|
15
12
|
namespace Action {
|
|
16
13
|
const values: readonly ["review", "reject", "flag"];
|
|
17
|
-
const type: isly.Type<"
|
|
14
|
+
const type: isly.Type<"review" | "reject" | "flag">;
|
|
18
15
|
}
|
|
19
|
-
const type:
|
|
20
|
-
function evaluate(rules: Rule[], state: RuleState): RuleState.Evaluated;
|
|
21
|
-
function isLegacy(rule: Rule): boolean;
|
|
22
|
-
function fromLegacy(rule: Rule): Rule;
|
|
16
|
+
const type: isly.Type<never>;
|
|
23
17
|
}
|
package/dist/cjs/Rule/index.js
CHANGED
|
@@ -2,48 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Rule = void 0;
|
|
4
4
|
const isly_1 = require("isly");
|
|
5
|
-
const Base_1 = require("./Base");
|
|
6
|
-
const control_1 = require("./control");
|
|
7
|
-
const Other_1 = require("./Other");
|
|
8
5
|
const State_1 = require("./State");
|
|
9
6
|
const type_1 = require("./type");
|
|
10
7
|
var Rule;
|
|
11
8
|
(function (Rule) {
|
|
12
|
-
Rule.Other = Other_1.Other;
|
|
13
9
|
Rule.State = State_1.State;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
let Kind;
|
|
11
|
+
(function (Kind) {
|
|
12
|
+
Kind.values = ["authorization", "outbound", "inbound", "capture", "refund"];
|
|
13
|
+
Kind.type = isly_1.isly.string(Kind.values);
|
|
14
|
+
})(Kind = Rule.Kind || (Rule.Kind = {}));
|
|
18
15
|
let Action;
|
|
19
16
|
(function (Action) {
|
|
20
|
-
Action.values = [
|
|
17
|
+
Action.values = ["review", "reject", "flag"];
|
|
21
18
|
Action.type = isly_1.isly.string(Action.values);
|
|
22
19
|
})(Action = Rule.Action || (Rule.Action = {}));
|
|
23
20
|
Rule.type = type_1.type;
|
|
24
|
-
function evaluate(rules, state) {
|
|
25
|
-
const outcomes = {
|
|
26
|
-
review: [],
|
|
27
|
-
reject: [],
|
|
28
|
-
flag: [],
|
|
29
|
-
};
|
|
30
|
-
const notes = [];
|
|
31
|
-
const evaluated = Rule.Other.evaluate(rules.filter(rule => Rule.Base.Kind.is(state.transaction.kind, rule, state.organization?.groups, state.card?.preset)), state);
|
|
32
|
-
notes.push(...evaluated.notes);
|
|
33
|
-
outcomes.flag.push(...evaluated.outcomes.flag);
|
|
34
|
-
outcomes.review.push(...evaluated.outcomes.review);
|
|
35
|
-
outcomes.reject.push(...evaluated.outcomes.reject);
|
|
36
|
-
const outcome = outcomes.reject.length > 0 ? "reject" : outcomes.review.length > 0 ? "review" : "approve";
|
|
37
|
-
return { ...state, flags: [...evaluated.flags], notes, outcomes, outcome };
|
|
38
|
-
}
|
|
39
|
-
Rule.evaluate = evaluate;
|
|
40
|
-
function isLegacy(rule) {
|
|
41
|
-
return !Rule.Base.Category.type.is(rule.category);
|
|
42
|
-
}
|
|
43
|
-
Rule.isLegacy = isLegacy;
|
|
44
|
-
function fromLegacy(rule) {
|
|
45
|
-
return isLegacy(rule) ? { ...rule, category: "fincrime" } : rule;
|
|
46
|
-
}
|
|
47
|
-
Rule.fromLegacy = fromLegacy;
|
|
48
21
|
})(Rule || (exports.Rule = Rule = {}));
|
|
49
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../Rule/index.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../Rule/index.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAC3B,mCAA4C;AAC5C,iCAAyC;AAGzC,IAAiB,IAAI,CAapB;AAbD,WAAiB,IAAI;IACN,UAAK,GAAG,aAAS,CAAA;IAE/B,IAAiB,IAAI,CAGpB;IAHD,WAAiB,IAAI;QACP,WAAM,GAAG,CAAC,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAU,CAAA;QAC/E,SAAI,GAAG,WAAI,CAAC,MAAM,CAAO,KAAA,MAAM,CAAC,CAAA;IAC9C,CAAC,EAHgB,IAAI,GAAJ,SAAI,KAAJ,SAAI,QAGpB;IAED,IAAiB,MAAM,CAGtB;IAHD,WAAiB,MAAM;QACT,aAAM,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAA;QAC9C,WAAI,GAAG,WAAI,CAAC,MAAM,CAAS,OAAA,MAAM,CAAC,CAAA;IAChD,CAAC,EAHgB,MAAM,GAAN,WAAM,KAAN,WAAM,QAGtB;IACY,SAAI,GAAG,WAAQ,CAAA;AAC7B,CAAC,EAbgB,IAAI,oBAAJ,IAAI,QAapB"}
|
package/dist/cjs/Rule/type.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const type:
|
|
1
|
+
import { isly } from "isly";
|
|
2
|
+
export declare const type: isly.Type<never>;
|
package/dist/cjs/Rule/type.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.type = void 0;
|
|
4
|
-
const
|
|
5
|
-
exports.type =
|
|
4
|
+
const isly_1 = require("isly");
|
|
5
|
+
exports.type = isly_1.isly.any();
|
|
6
6
|
//# sourceMappingURL=type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../../Rule/type.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../../Rule/type.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAKd,QAAA,IAAI,GAAG,WAAI,CAAC,GAAG,EAAS,CAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isoly } from "isoly";
|
|
2
|
-
import type { Rule } from "../Rule";
|
|
3
2
|
export interface Note extends Note.Creatable {
|
|
4
3
|
author: string;
|
|
5
4
|
created: isoly.DateTime;
|
|
@@ -10,7 +9,16 @@ export declare namespace Note {
|
|
|
10
9
|
text?: string;
|
|
11
10
|
action?: "approve" | "reject";
|
|
12
11
|
flags?: string[];
|
|
13
|
-
rule?:
|
|
12
|
+
rule?: {
|
|
13
|
+
action: "reject";
|
|
14
|
+
code: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: "authorization";
|
|
17
|
+
category: "fincrime";
|
|
18
|
+
condition: "";
|
|
19
|
+
description: string;
|
|
20
|
+
flags: ["category", "merchant"];
|
|
21
|
+
};
|
|
14
22
|
}
|
|
15
23
|
namespace Creatable {
|
|
16
24
|
const type: import("isly/dist/cjs/object").IslyObject<Creatable, object>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Note.js","sourceRoot":"","sources":["../../../Transaction/Note.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,+BAA2B;
|
|
1
|
+
{"version":3,"file":"Note.js","sourceRoot":"","sources":["../../../Transaction/Note.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,+BAA2B;AAO3B,IAAiB,IAAI,CA+BpB;AA/BD,WAAiB,IAAI;IACpB,SAAgB,aAAa,CAAC,IAAe,EAAE,MAAc;QAC5D,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,aAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;IAClE,CAAC;IAFe,kBAAa,gBAE5B,CAAA;IAgBD,IAAiB,SAAS,CAOzB;IAPD,WAAiB,SAAS;QACZ,cAAI,GAAG,WAAI,CAAC,MAAM,CAAY;YAC1C,IAAI,EAAE,WAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC9B,MAAM,EAAE,WAAI,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE;YACrD,KAAK,EAAE,WAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;YACvC,IAAI,EAAE,WAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;SAC3B,CAAC,CAAA;IACH,CAAC,EAPgB,SAAS,GAAT,cAAS,KAAT,cAAS,QAOzB;IACY,SAAI,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAO;QAC/C,MAAM,EAAE,WAAI,CAAC,MAAM,EAAE;QACrB,OAAO,EAAE,WAAI,CAAC,MAAM,EAAE;KACtB,CAAC,CAAA;AACH,CAAC,EA/BgB,IAAI,oBAAJ,IAAI,QA+BpB"}
|
|
@@ -30,26 +30,26 @@ export declare namespace Permission {
|
|
|
30
30
|
}
|
|
31
31
|
const values: readonly ["*", "card", "log", "operation", "organization", "rule", "settlement", "transaction", "treasury", "user"];
|
|
32
32
|
const typeZod: zod.ZodEnum<{
|
|
33
|
-
rule: "rule";
|
|
34
33
|
card: "card";
|
|
35
34
|
transaction: "transaction";
|
|
36
35
|
settlement: "settlement";
|
|
37
36
|
organization: "organization";
|
|
37
|
+
rule: "rule";
|
|
38
38
|
user: "user";
|
|
39
39
|
log: "log";
|
|
40
40
|
operation: "operation";
|
|
41
41
|
"*": "*";
|
|
42
42
|
treasury: "treasury";
|
|
43
43
|
}>;
|
|
44
|
-
const type: isly.Type<"
|
|
44
|
+
const type: isly.Type<"card" | "transaction" | "settlement" | "organization" | "rule" | "user" | "log" | "operation" | "*" | "treasury">;
|
|
45
45
|
}
|
|
46
|
-
const type: isly.Type<Partial<Record<"
|
|
46
|
+
const type: isly.Type<Partial<Record<"card" | "transaction" | "settlement" | "organization" | "rule" | "user" | "log" | "operation" | "*" | "treasury", "developer" | "read" | "write" | "admin">>>;
|
|
47
47
|
const typeZod: zod.ZodRecord<zod.ZodEnum<{
|
|
48
|
-
rule: "rule";
|
|
49
48
|
card: "card";
|
|
50
49
|
transaction: "transaction";
|
|
51
50
|
settlement: "settlement";
|
|
52
51
|
organization: "organization";
|
|
52
|
+
rule: "rule";
|
|
53
53
|
user: "user";
|
|
54
54
|
log: "log";
|
|
55
55
|
operation: "operation";
|
|
@@ -6,11 +6,11 @@ export declare namespace Access {
|
|
|
6
6
|
const type: import("isly/dist/cjs/object").IslyObject<object, object>;
|
|
7
7
|
const typeZod: zod.ZodObject<{
|
|
8
8
|
uk: zod.ZodOptional<zod.ZodRecord<zod.ZodEnum<{
|
|
9
|
-
rule: "rule";
|
|
10
9
|
card: "card";
|
|
11
10
|
transaction: "transaction";
|
|
12
11
|
settlement: "settlement";
|
|
13
12
|
organization: "organization";
|
|
13
|
+
rule: "rule";
|
|
14
14
|
user: "user";
|
|
15
15
|
log: "log";
|
|
16
16
|
operation: "operation";
|
|
@@ -23,11 +23,11 @@ export declare namespace Access {
|
|
|
23
23
|
admin: "admin";
|
|
24
24
|
}>>>;
|
|
25
25
|
eea: zod.ZodOptional<zod.ZodRecord<zod.ZodEnum<{
|
|
26
|
-
rule: "rule";
|
|
27
26
|
card: "card";
|
|
28
27
|
transaction: "transaction";
|
|
29
28
|
settlement: "settlement";
|
|
30
29
|
organization: "organization";
|
|
30
|
+
rule: "rule";
|
|
31
31
|
user: "user";
|
|
32
32
|
log: "log";
|
|
33
33
|
operation: "operation";
|
|
@@ -40,11 +40,11 @@ export declare namespace Access {
|
|
|
40
40
|
admin: "admin";
|
|
41
41
|
}>>>;
|
|
42
42
|
test: zod.ZodOptional<zod.ZodRecord<zod.ZodEnum<{
|
|
43
|
-
rule: "rule";
|
|
44
43
|
card: "card";
|
|
45
44
|
transaction: "transaction";
|
|
46
45
|
settlement: "settlement";
|
|
47
46
|
organization: "organization";
|
|
47
|
+
rule: "rule";
|
|
48
48
|
user: "user";
|
|
49
49
|
log: "log";
|
|
50
50
|
operation: "operation";
|