@pax2pay/model-banking 0.1.84 → 0.1.86
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/Organization/index.ts +3 -0
- package/Rule/definitions.ts +7 -0
- package/Rule/index.ts +45 -0
- package/dist/Organization/index.d.ts +3 -0
- package/dist/Organization/index.js +2 -0
- package/dist/Organization/index.js.map +1 -1
- package/dist/Rule/definitions.d.ts +2 -0
- package/dist/Rule/definitions.js +6 -0
- package/dist/Rule/definitions.js.map +1 -0
- package/dist/Rule/index.d.ts +21 -0
- package/dist/Rule/index.js +30 -0
- package/dist/Rule/index.js.map +1 -0
- package/dist/pax2pay.d.ts +1 -0
- package/dist/pax2pay.js +1 -0
- package/dist/pax2pay.js.map +1 -1
- package/package.json +2 -2
- package/pax2pay.ts +1 -0
package/Organization/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as cryptly from "cryptly"
|
|
2
2
|
import { Changeable as OrganizationChangeable } from "./Changeable"
|
|
3
|
+
import { Contact as OrganizationContact } from "./Contact"
|
|
3
4
|
import { Creatable as OrganizationCreatable } from "./Creatable"
|
|
4
5
|
import { Rule as OrganizationRule } from "./Rule"
|
|
5
6
|
|
|
@@ -22,6 +23,8 @@ export namespace Organization {
|
|
|
22
23
|
export const Creatable = OrganizationCreatable
|
|
23
24
|
export type Changeable = OrganizationChangeable
|
|
24
25
|
export const Changeable = OrganizationChangeable
|
|
26
|
+
export type Contact = OrganizationContact
|
|
27
|
+
export const Contact = OrganizationContact
|
|
25
28
|
export type Rule = OrganizationRule
|
|
26
29
|
export const Rule = OrganizationRule
|
|
27
30
|
export namespace Rule {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { selectively } from "selectively"
|
|
2
|
+
|
|
3
|
+
export const definitions: Record<string, selectively.Definition> = {
|
|
4
|
+
exceedsAmount: { arguments: ["max"], definition: "amount>max" },
|
|
5
|
+
isInternal: { arguments: [], definition: "counterpart.type:internal" },
|
|
6
|
+
alwaysTrue: { arguments: [], definition: "amount>0|amount<0" },
|
|
7
|
+
}
|
package/Rule/index.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { selectively } from "selectively"
|
|
2
|
+
import { isly } from "isly"
|
|
3
|
+
import { definitions } from "./definitions"
|
|
4
|
+
|
|
5
|
+
export interface Rule {
|
|
6
|
+
name: string
|
|
7
|
+
description: string
|
|
8
|
+
action: Rule.Action
|
|
9
|
+
type: Rule.Kind
|
|
10
|
+
condition: string
|
|
11
|
+
flags: string[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export namespace Rule {
|
|
15
|
+
export const actions = ["review", "reject", "flag"] as const
|
|
16
|
+
export type Action = typeof actions[number]
|
|
17
|
+
export const kinds = ["authorization", "outbound", "inbound"] as const
|
|
18
|
+
export type Kind = typeof kinds[number]
|
|
19
|
+
export const type = isly.object<Rule>({
|
|
20
|
+
name: isly.string(),
|
|
21
|
+
description: isly.string(),
|
|
22
|
+
action: isly.string(actions),
|
|
23
|
+
type: isly.string(kinds),
|
|
24
|
+
condition: isly.string(),
|
|
25
|
+
flags: isly.string().array(),
|
|
26
|
+
})
|
|
27
|
+
export const is = type.is
|
|
28
|
+
export const flaw = type.flaw
|
|
29
|
+
export function stringify(rule: Rule): string {
|
|
30
|
+
return `{ label: ${rule.name}, action: ${rule.action}, type: ${rule.type}, condition: ${rule.condition}, description: ${rule.description}. }`
|
|
31
|
+
}
|
|
32
|
+
export function evaluate<S extends object>(
|
|
33
|
+
rules: Rule[],
|
|
34
|
+
state: S,
|
|
35
|
+
macros?: Record<string, selectively.Definition>
|
|
36
|
+
): Record<Action, Rule[]> {
|
|
37
|
+
const result: Record<Action, Rule[]> = { review: [], reject: [], flag: [] }
|
|
38
|
+
rules.forEach(
|
|
39
|
+
r =>
|
|
40
|
+
selectively.resolve({ ...macros, ...definitions }, selectively.parse(r.condition)).is(state) &&
|
|
41
|
+
result[r.action].push(r)
|
|
42
|
+
)
|
|
43
|
+
return result
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as cryptly from "cryptly";
|
|
2
2
|
import { Changeable as OrganizationChangeable } from "./Changeable";
|
|
3
|
+
import { Contact as OrganizationContact } from "./Contact";
|
|
3
4
|
import { Creatable as OrganizationCreatable } from "./Creatable";
|
|
4
5
|
import { Rule as OrganizationRule } from "./Rule";
|
|
5
6
|
export interface Organization extends OrganizationCreatable {
|
|
@@ -13,6 +14,8 @@ export declare namespace Organization {
|
|
|
13
14
|
const Creatable: typeof OrganizationCreatable;
|
|
14
15
|
type Changeable = OrganizationChangeable;
|
|
15
16
|
const Changeable: typeof OrganizationChangeable;
|
|
17
|
+
type Contact = OrganizationContact;
|
|
18
|
+
const Contact: typeof OrganizationContact;
|
|
16
19
|
type Rule = OrganizationRule;
|
|
17
20
|
const Rule: typeof OrganizationRule;
|
|
18
21
|
namespace Rule {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as cryptly from "cryptly";
|
|
2
2
|
import { Changeable as OrganizationChangeable } from "./Changeable";
|
|
3
|
+
import { Contact as OrganizationContact } from "./Contact";
|
|
3
4
|
import { Creatable as OrganizationCreatable } from "./Creatable";
|
|
4
5
|
import { Rule as OrganizationRule } from "./Rule";
|
|
5
6
|
export var Organization;
|
|
@@ -18,6 +19,7 @@ export var Organization;
|
|
|
18
19
|
Organization.isIdentifier = isIdentifier;
|
|
19
20
|
Organization.Creatable = OrganizationCreatable;
|
|
20
21
|
Organization.Changeable = OrganizationChangeable;
|
|
22
|
+
Organization.Contact = OrganizationContact;
|
|
21
23
|
Organization.Rule = OrganizationRule;
|
|
22
24
|
})(Organization || (Organization = {}));
|
|
23
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Organization/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,C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sB,CAAA;IAEnC,oBAAO,GAAG,mBAAmB,CAAA;IAE7B,iBAAI,GAAG,gBAAgB,CAAA;AAIrC,CAAC,EAtBgB,YAAY,KAAZ,YAAY,QAsB5B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const definitions = {
|
|
2
|
+
exceedsAmount: { arguments: ["max"], definition: "amount>max" },
|
|
3
|
+
isInternal: { arguments: [], definition: "counterpart.type:internal" },
|
|
4
|
+
alwaysTrue: { arguments: [], definition: "amount>0|amount<0" },
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"../","sources":["Rule/definitions.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAA2C;IAClE,aAAa,EAAE,EAAE,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE;IAC/D,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,2BAA2B,EAAE;IACtE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE;CAC9D,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { selectively } from "selectively";
|
|
2
|
+
import { isly } from "isly";
|
|
3
|
+
export interface Rule {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
action: Rule.Action;
|
|
7
|
+
type: Rule.Kind;
|
|
8
|
+
condition: string;
|
|
9
|
+
flags: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare namespace Rule {
|
|
12
|
+
const actions: readonly ["review", "reject", "flag"];
|
|
13
|
+
type Action = typeof actions[number];
|
|
14
|
+
const kinds: readonly ["authorization", "outbound", "inbound"];
|
|
15
|
+
type Kind = typeof kinds[number];
|
|
16
|
+
const type: isly.object.ExtendableType<Rule>;
|
|
17
|
+
const is: isly.Type.IsFunction<Rule>;
|
|
18
|
+
const flaw: isly.Type.FlawFunction;
|
|
19
|
+
function stringify(rule: Rule): string;
|
|
20
|
+
function evaluate<S extends object>(rules: Rule[], state: S, macros?: Record<string, selectively.Definition>): Record<Action, Rule[]>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { selectively } from "selectively";
|
|
2
|
+
import { isly } from "isly";
|
|
3
|
+
import { definitions } from "./definitions";
|
|
4
|
+
export var Rule;
|
|
5
|
+
(function (Rule) {
|
|
6
|
+
Rule.actions = ["review", "reject", "flag"];
|
|
7
|
+
Rule.kinds = ["authorization", "outbound", "inbound"];
|
|
8
|
+
Rule.type = isly.object({
|
|
9
|
+
name: isly.string(),
|
|
10
|
+
description: isly.string(),
|
|
11
|
+
action: isly.string(Rule.actions),
|
|
12
|
+
type: isly.string(Rule.kinds),
|
|
13
|
+
condition: isly.string(),
|
|
14
|
+
flags: isly.string().array(),
|
|
15
|
+
});
|
|
16
|
+
Rule.is = Rule.type.is;
|
|
17
|
+
Rule.flaw = Rule.type.flaw;
|
|
18
|
+
function stringify(rule) {
|
|
19
|
+
return `{ label: ${rule.name}, action: ${rule.action}, type: ${rule.type}, condition: ${rule.condition}, description: ${rule.description}. }`;
|
|
20
|
+
}
|
|
21
|
+
Rule.stringify = stringify;
|
|
22
|
+
function evaluate(rules, state, macros) {
|
|
23
|
+
const result = { review: [], reject: [], flag: [] };
|
|
24
|
+
rules.forEach(r => selectively.resolve({ ...macros, ...definitions }, selectively.parse(r.condition)).is(state) &&
|
|
25
|
+
result[r.action].push(r));
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
Rule.evaluate = evaluate;
|
|
29
|
+
})(Rule || (Rule = {}));
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Rule/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aA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"}
|
|
1
|
+
{"version":3,"file":"pax2pay.js","sourceRoot":"../","sources":["pax2pay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pax2pay/model-banking",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.86",
|
|
4
4
|
"description": "Library containing data model types and functions for the Pax2Pay Banking API.",
|
|
5
5
|
"author": "Pax2Pay Ltd",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"^.+\\.(j|t)sx?$": "ts-jest"
|
|
30
30
|
},
|
|
31
31
|
"transformIgnorePatterns": [
|
|
32
|
-
"<rootDir>/node_modules/(?!(cryptly|authly|isly|isoly|gracely|cloudly-http|cloudly-rest|cloudly-router|cloudly-formdata|@userwidgets)/.*)"
|
|
32
|
+
"<rootDir>/node_modules/(?!(cryptly|authly|isly|isoly|gracely|cloudly-http|cloudly-rest|cloudly-router|cloudly-formdata|@userwidgets|selectively)/.*)"
|
|
33
33
|
],
|
|
34
34
|
"testEnvironment": "node",
|
|
35
35
|
"testRegex": "((\\.|/)(test|spec))(\\.|\\/.+)(jsx?|tsx?)$",
|
package/pax2pay.ts
CHANGED