@pax2pay/model-banking 0.1.198 → 0.1.200
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/Client/Settlements.ts +2 -3
- package/Operation/Changes.ts +4 -1
- package/Operation/Creatable.ts +1 -0
- package/Rule/index.ts +1 -1
- package/Transaction/Collect/Creatable.ts +14 -0
- package/Transaction/Collect/Failed.ts +33 -0
- package/Transaction/Collect/index.ts +41 -0
- package/Transaction/index.ts +8 -2
- package/dist/Client/Settlements.d.ts +1 -2
- package/dist/Client/Settlements.js +2 -2
- package/dist/Client/Settlements.js.map +1 -1
- package/dist/Operation/Changes.js +1 -1
- package/dist/Operation/Changes.js.map +1 -1
- package/dist/Operation/Creatable.d.ts +1 -1
- package/dist/Operation/Creatable.js +1 -0
- package/dist/Operation/Creatable.js.map +1 -1
- package/dist/Rule/index.d.ts +1 -1
- package/dist/Transaction/Collect/Creatable.d.ts +10 -0
- package/dist/Transaction/Collect/Creatable.js +10 -0
- package/dist/Transaction/Collect/Creatable.js.map +1 -0
- package/dist/Transaction/Collect/Failed.d.ts +17 -0
- package/dist/Transaction/Collect/Failed.js +27 -0
- package/dist/Transaction/Collect/Failed.js.map +1 -0
- package/dist/Transaction/Collect/index.d.ts +20 -0
- package/dist/Transaction/Collect/index.js +38 -0
- package/dist/Transaction/Collect/index.js.map +1 -0
- package/dist/Transaction/index.d.ts +8 -2
- package/dist/Transaction/index.js +2 -0
- package/dist/Transaction/index.js.map +1 -1
- package/package.json +1 -1
package/Client/Settlements.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { gracely } from "gracely"
|
|
2
|
-
import { isoly } from "isoly"
|
|
3
2
|
import { http } from "cloudly-http"
|
|
4
3
|
import * as rest from "cloudly-rest"
|
|
5
4
|
import { Settlement } from "../Settlement"
|
|
@@ -12,8 +11,8 @@ export class Settlements extends rest.Collection<gracely.Error> {
|
|
|
12
11
|
async create(configuration: string): Promise<Settlement | gracely.Error> {
|
|
13
12
|
return this.client.post<Settlement>(`/settlement`, { configuration: configuration })
|
|
14
13
|
}
|
|
15
|
-
async fetch(id: string
|
|
16
|
-
return this.client.get<Settlement>(`/settlement/${id}
|
|
14
|
+
async fetch(id: string): Promise<Settlement | gracely.Error> {
|
|
15
|
+
return this.client.get<Settlement>(`/settlement/${id}`)
|
|
17
16
|
}
|
|
18
17
|
async list(): Promise<Settlement[] | gracely.Error> {
|
|
19
18
|
return this.client.get<Settlement[] & { cursor?: string | undefined }>(`/settlement`)
|
package/Operation/Changes.ts
CHANGED
|
@@ -12,7 +12,10 @@ export namespace Changes {
|
|
|
12
12
|
export const values = [...Balances.Balance.Entry.values, ...Counterbalances.Counterbalance.Entry.values]
|
|
13
13
|
export const type = isly.string(values)
|
|
14
14
|
}
|
|
15
|
-
export const type = isly.record<Changes>(
|
|
15
|
+
export const type = isly.record<Changes>(
|
|
16
|
+
isly.union(Entry.type, Counterbalances.Counterbalance.Entry.type),
|
|
17
|
+
Change.type
|
|
18
|
+
)
|
|
16
19
|
export const is = type.is
|
|
17
20
|
export const flaw = type.flaw
|
|
18
21
|
}
|
package/Operation/Creatable.ts
CHANGED
package/Rule/index.ts
CHANGED
|
@@ -21,7 +21,7 @@ export namespace Rule {
|
|
|
21
21
|
export type Authorization = RuleState.Authorization
|
|
22
22
|
export type Card = RuleState.Card
|
|
23
23
|
export namespace Card {
|
|
24
|
-
export type
|
|
24
|
+
export type Statistics = RuleState.Card.Statistics
|
|
25
25
|
}
|
|
26
26
|
export type Transaction = RuleState.Transaction
|
|
27
27
|
export type Data = RuleState.Data
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cryptly } from "cryptly"
|
|
2
|
+
import { isly } from "isly"
|
|
3
|
+
import { Counterbalances } from "../../CounterBalances"
|
|
4
|
+
|
|
5
|
+
export interface Creatable {
|
|
6
|
+
source: Counterbalances.Counterbalance.Entry.Settlement
|
|
7
|
+
target: cryptly.Identifier
|
|
8
|
+
}
|
|
9
|
+
export namespace Creatable {
|
|
10
|
+
export const type = isly.object<Creatable>({
|
|
11
|
+
source: isly.string(),
|
|
12
|
+
target: isly.fromIs("cryptly.Identifier", cryptly.Identifier.is),
|
|
13
|
+
})
|
|
14
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { gracely } from "gracely"
|
|
2
|
+
import { Counterbalances } from "../../CounterBalances"
|
|
3
|
+
import type { Transaction } from "../index"
|
|
4
|
+
import { Creatable } from "./Creatable"
|
|
5
|
+
|
|
6
|
+
export type Failed = { counterbalances: Counterbalances; reasons: Failed.Reason[] }
|
|
7
|
+
export namespace Failed {
|
|
8
|
+
export type Reason = {
|
|
9
|
+
transaction?: Partial<Transaction>
|
|
10
|
+
collect?: Creatable
|
|
11
|
+
error?: gracely.Error
|
|
12
|
+
}
|
|
13
|
+
export function from(collect: Creatable, error: gracely.Error, transaction?: Partial<Transaction>): Failed {
|
|
14
|
+
return {
|
|
15
|
+
counterbalances: transaction?.currency
|
|
16
|
+
? {
|
|
17
|
+
[transaction.currency]: { [collect.source]: transaction.amount },
|
|
18
|
+
}
|
|
19
|
+
: {},
|
|
20
|
+
reasons: [{ transaction, collect, error }],
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function aggregate(addendee: Failed | undefined, addend: Failed | undefined): Failed | undefined {
|
|
24
|
+
return !addendee
|
|
25
|
+
? addend
|
|
26
|
+
: !addend
|
|
27
|
+
? addendee
|
|
28
|
+
: {
|
|
29
|
+
counterbalances: Counterbalances.add(addendee?.counterbalances, addend?.counterbalances),
|
|
30
|
+
reasons: [...(addendee?.reasons ?? []), ...(addend?.reasons ?? [])],
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { gracely } from "gracely"
|
|
2
|
+
import { Counterbalances } from "../../CounterBalances"
|
|
3
|
+
import type { Transaction } from "../index"
|
|
4
|
+
import { Creatable as CollectCreatable } from "./Creatable"
|
|
5
|
+
import { Failed } from "./Failed"
|
|
6
|
+
|
|
7
|
+
export type Collect = {
|
|
8
|
+
counterbalances: Counterbalances
|
|
9
|
+
failed?: Failed
|
|
10
|
+
}
|
|
11
|
+
export namespace Collect {
|
|
12
|
+
export type Creatable = CollectCreatable
|
|
13
|
+
export namespace Creatable {
|
|
14
|
+
export const type = CollectCreatable.type
|
|
15
|
+
export const is = CollectCreatable.type.is
|
|
16
|
+
export const flaw = CollectCreatable.type.flaw
|
|
17
|
+
}
|
|
18
|
+
export function from(transaction: Partial<Transaction>, creatable: CollectCreatable, error?: gracely.Error): Collect {
|
|
19
|
+
const counterbalances =
|
|
20
|
+
transaction.currency && transaction.amount
|
|
21
|
+
? { [transaction.currency]: { [creatable.source]: Math.abs(transaction.amount) } }
|
|
22
|
+
: {}
|
|
23
|
+
return error
|
|
24
|
+
? {
|
|
25
|
+
counterbalances: {},
|
|
26
|
+
failed: Failed.from(creatable, error, transaction),
|
|
27
|
+
}
|
|
28
|
+
: {
|
|
29
|
+
counterbalances,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function sum(collects: Collect[]): Collect {
|
|
33
|
+
return collects.reduce((r, e) => aggregate(r, e), { counterbalances: {} })
|
|
34
|
+
}
|
|
35
|
+
export function aggregate(addendee: Collect, addend: Collect): Collect {
|
|
36
|
+
return {
|
|
37
|
+
counterbalances: Counterbalances.add(addendee.counterbalances, addend.counterbalances),
|
|
38
|
+
failed: Failed.aggregate(addendee.failed, addend.failed),
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
package/Transaction/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { isly } from "isly"
|
|
|
4
4
|
import { Identifier } from "../Identifier"
|
|
5
5
|
import { Operation } from "../Operation"
|
|
6
6
|
import { Rail } from "../Rail"
|
|
7
|
+
import { Collect as TransactionCollect } from "./Collect"
|
|
7
8
|
import { Creatable as TransactionCreatable } from "./Creatable"
|
|
8
9
|
import { Incoming as TransactionIncoming } from "./Incoming"
|
|
9
10
|
import { Note as TransactionNote } from "./Note"
|
|
@@ -28,17 +29,22 @@ export interface Transaction extends Transaction.Creatable {
|
|
|
28
29
|
export namespace Transaction {
|
|
29
30
|
export type Creatable = TransactionCreatable
|
|
30
31
|
export const Creatable = TransactionCreatable
|
|
32
|
+
export type Collect = TransactionCollect
|
|
33
|
+
export const Collect = TransactionCollect
|
|
34
|
+
export namespace Collect {
|
|
35
|
+
export type Creatable = TransactionCollect.Creatable
|
|
36
|
+
}
|
|
31
37
|
export type Incoming = TransactionIncoming
|
|
32
38
|
export const Incoming = TransactionIncoming
|
|
33
39
|
export type Reference = TransactionReference
|
|
34
40
|
export const Reference = TransactionReference
|
|
35
41
|
export type Note = TransactionNote
|
|
36
42
|
export const Note = TransactionNote
|
|
37
|
-
export type Status = TransactionStatus
|
|
38
|
-
export const Status = TransactionStatus
|
|
39
43
|
export namespace Note {
|
|
40
44
|
export type Creatable = TransactionNote.Creatable
|
|
41
45
|
}
|
|
46
|
+
export type Status = TransactionStatus
|
|
47
|
+
export const Status = TransactionStatus
|
|
42
48
|
export const type = Creatable.type.extend<Transaction>({
|
|
43
49
|
organization: isly.string(),
|
|
44
50
|
accountId: isly.string(),
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { gracely } from "gracely";
|
|
2
|
-
import { isoly } from "isoly";
|
|
3
2
|
import { http } from "cloudly-http";
|
|
4
3
|
import * as rest from "cloudly-rest";
|
|
5
4
|
import { Settlement } from "../Settlement";
|
|
6
5
|
export declare class Settlements extends rest.Collection<gracely.Error> {
|
|
7
6
|
constructor(client: http.Client);
|
|
8
7
|
create(configuration: string): Promise<Settlement | gracely.Error>;
|
|
9
|
-
fetch(id: string
|
|
8
|
+
fetch(id: string): Promise<Settlement | gracely.Error>;
|
|
10
9
|
list(): Promise<Settlement[] | gracely.Error>;
|
|
11
10
|
remove(settlement: string): Promise<Settlement | gracely.Error>;
|
|
12
11
|
update(settlement: string): Promise<Settlement | gracely.Error>;
|
|
@@ -6,8 +6,8 @@ export class Settlements extends rest.Collection {
|
|
|
6
6
|
async create(configuration) {
|
|
7
7
|
return this.client.post(`/settlement`, { configuration: configuration });
|
|
8
8
|
}
|
|
9
|
-
async fetch(id
|
|
10
|
-
return this.client.get(`/settlement/${id}
|
|
9
|
+
async fetch(id) {
|
|
10
|
+
return this.client.get(`/settlement/${id}`);
|
|
11
11
|
}
|
|
12
12
|
async list() {
|
|
13
13
|
return this.client.get(`/settlement`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Settlements.js","sourceRoot":"../","sources":["Client/Settlements.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Settlements.js","sourceRoot":"../","sources":["Client/Settlements.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,cAAc,CAAA;AAGpC,MAAM,OAAO,WAAY,SAAQ,IAAI,CAAC,UAAyB;IAC9D,YAAY,MAAmB;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAA;IACd,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,aAAqB;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAa,aAAa,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC,CAAA;IACrF,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,EAAU;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAa,eAAe,EAAE,EAAE,CAAC,CAAA;IACxD,CAAC;IACD,KAAK,CAAC,IAAI;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAiD,aAAa,CAAC,CAAA;IACtF,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAa,eAAe,UAAU,EAAE,CAAC,CAAA;IACnE,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAa,eAAe,UAAU,EAAE,EAAE,EAAE,CAAC,CAAA;IACtE,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,UAAkB;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAqB,eAAe,UAAU,QAAQ,CAAC,CAAA;IAC9E,CAAC;IACD,KAAK,CAAC,iBAAiB,CAAC,UAAkB;QACzC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAqB,eAAe,UAAU,eAAe,CAAC,CAAA;IACrF,CAAC;CACD"}
|
|
@@ -9,7 +9,7 @@ export var Changes;
|
|
|
9
9
|
Entry.values = [...Balances.Balance.Entry.values, ...Counterbalances.Counterbalance.Entry.values];
|
|
10
10
|
Entry.type = isly.string(Entry.values);
|
|
11
11
|
})(Entry = Changes.Entry || (Changes.Entry = {}));
|
|
12
|
-
Changes.type = isly.record(Entry.type, Change.type);
|
|
12
|
+
Changes.type = isly.record(isly.union(Entry.type, Counterbalances.Counterbalance.Entry.type), Change.type);
|
|
13
13
|
Changes.is = Changes.type.is;
|
|
14
14
|
Changes.flaw = Changes.type.flaw;
|
|
15
15
|
})(Changes || (Changes = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Changes.js","sourceRoot":"../","sources":["Operation/Changes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAK3C,MAAM,KAAW,OAAO,
|
|
1
|
+
{"version":3,"file":"Changes.js","sourceRoot":"../","sources":["Operation/Changes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAK3C,MAAM,KAAW,OAAO,CAYvB;AAZD,WAAiB,OAAO;IAEvB,IAAiB,KAAK,CAGrB;IAHD,WAAiB,KAAK;QACR,YAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,eAAe,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAC3F,UAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAA,MAAM,CAAC,CAAA;IACxC,CAAC,EAHgB,KAAK,GAAL,aAAK,KAAL,aAAK,QAGrB;IACY,YAAI,GAAG,IAAI,CAAC,MAAM,CAC9B,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,EACjE,MAAM,CAAC,IAAI,CACX,CAAA;IACY,UAAE,GAAG,QAAA,IAAI,CAAC,EAAE,CAAA;IACZ,YAAI,GAAG,QAAA,IAAI,CAAC,IAAI,CAAA;AAC9B,CAAC,EAZgB,OAAO,KAAP,OAAO,QAYvB"}
|
|
@@ -9,7 +9,7 @@ export interface Creatable {
|
|
|
9
9
|
type: Creatable.Type;
|
|
10
10
|
}
|
|
11
11
|
export declare namespace Creatable {
|
|
12
|
-
const types: readonly ["authorization", "settlement", "incoming", "finalizeIncoming", "outgoing", "finalizeOutgoing", "deposit", "remove", "legacy"];
|
|
12
|
+
const types: readonly ["authorization", "settlement", "incoming", "finalizeIncoming", "outgoing", "finalizeOutgoing", "deposit", "remove", "legacy", "collect"];
|
|
13
13
|
type Type = typeof types[number];
|
|
14
14
|
const type: isly.object.ExtendableType<Creatable>;
|
|
15
15
|
const is: isly.Type.IsFunction<Creatable>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Creatable.js","sourceRoot":"../","sources":["Operation/Creatable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASnC,MAAM,KAAW,SAAS,
|
|
1
|
+
{"version":3,"file":"Creatable.js","sourceRoot":"../","sources":["Operation/Creatable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASnC,MAAM,KAAW,SAAS,CAsBzB;AAtBD,WAAiB,SAAS;IACZ,eAAK,GAAG;QACpB,eAAe;QACf,YAAY;QACZ,UAAU;QACV,kBAAkB;QAClB,UAAU;QACV,kBAAkB;QAClB,SAAS;QACT,QAAQ;QACR,QAAQ;QACR,SAAS;KACA,CAAA;IAEG,cAAI,GAAG,IAAI,CAAC,MAAM,CAAY;QAC1C,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACjE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1D,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,UAAA,KAAK,CAAC;KACxB,CAAC,CAAA;IACW,YAAE,GAAG,UAAA,IAAI,CAAC,EAAE,CAAA;IACZ,cAAI,GAAG,UAAA,IAAI,CAAC,IAAI,CAAA;AAC9B,CAAC,EAtBgB,SAAS,KAAT,SAAS,QAsBzB"}
|
package/dist/Rule/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare namespace Rule {
|
|
|
18
18
|
type Authorization = RuleState.Authorization;
|
|
19
19
|
type Card = RuleState.Card;
|
|
20
20
|
namespace Card {
|
|
21
|
-
type
|
|
21
|
+
type Statistics = RuleState.Card.Statistics;
|
|
22
22
|
}
|
|
23
23
|
type Transaction = RuleState.Transaction;
|
|
24
24
|
type Data = RuleState.Data;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { cryptly } from "cryptly";
|
|
2
|
+
import { isly } from "isly";
|
|
3
|
+
import { Counterbalances } from "../../CounterBalances";
|
|
4
|
+
export interface Creatable {
|
|
5
|
+
source: Counterbalances.Counterbalance.Entry.Settlement;
|
|
6
|
+
target: cryptly.Identifier;
|
|
7
|
+
}
|
|
8
|
+
export declare namespace Creatable {
|
|
9
|
+
const type: isly.object.ExtendableType<Creatable>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { cryptly } from "cryptly";
|
|
2
|
+
import { isly } from "isly";
|
|
3
|
+
export var Creatable;
|
|
4
|
+
(function (Creatable) {
|
|
5
|
+
Creatable.type = isly.object({
|
|
6
|
+
source: isly.string(),
|
|
7
|
+
target: isly.fromIs("cryptly.Identifier", cryptly.Identifier.is),
|
|
8
|
+
});
|
|
9
|
+
})(Creatable || (Creatable = {}));
|
|
10
|
+
//# sourceMappingURL=Creatable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Creatable.js","sourceRoot":"../","sources":["Transaction/Collect/Creatable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAO3B,MAAM,KAAW,SAAS,CAKzB;AALD,WAAiB,SAAS;IACZ,cAAI,GAAG,IAAI,CAAC,MAAM,CAAY;QAC1C,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;QACrB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;KAChE,CAAC,CAAA;AACH,CAAC,EALgB,SAAS,KAAT,SAAS,QAKzB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { gracely } from "gracely";
|
|
2
|
+
import { Counterbalances } from "../../CounterBalances";
|
|
3
|
+
import type { Transaction } from "../index";
|
|
4
|
+
import { Creatable } from "./Creatable";
|
|
5
|
+
export type Failed = {
|
|
6
|
+
counterbalances: Counterbalances;
|
|
7
|
+
reasons: Failed.Reason[];
|
|
8
|
+
};
|
|
9
|
+
export declare namespace Failed {
|
|
10
|
+
type Reason = {
|
|
11
|
+
transaction?: Partial<Transaction>;
|
|
12
|
+
collect?: Creatable;
|
|
13
|
+
error?: gracely.Error;
|
|
14
|
+
};
|
|
15
|
+
function from(collect: Creatable, error: gracely.Error, transaction?: Partial<Transaction>): Failed;
|
|
16
|
+
function aggregate(addendee: Failed | undefined, addend: Failed | undefined): Failed | undefined;
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Counterbalances } from "../../CounterBalances";
|
|
2
|
+
export var Failed;
|
|
3
|
+
(function (Failed) {
|
|
4
|
+
function from(collect, error, transaction) {
|
|
5
|
+
return {
|
|
6
|
+
counterbalances: transaction?.currency
|
|
7
|
+
? {
|
|
8
|
+
[transaction.currency]: { [collect.source]: transaction.amount },
|
|
9
|
+
}
|
|
10
|
+
: {},
|
|
11
|
+
reasons: [{ transaction, collect, error }],
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Failed.from = from;
|
|
15
|
+
function aggregate(addendee, addend) {
|
|
16
|
+
return !addendee
|
|
17
|
+
? addend
|
|
18
|
+
: !addend
|
|
19
|
+
? addendee
|
|
20
|
+
: {
|
|
21
|
+
counterbalances: Counterbalances.add(addendee?.counterbalances, addend?.counterbalances),
|
|
22
|
+
reasons: [...(addendee?.reasons ?? []), ...(addend?.reasons ?? [])],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
Failed.aggregate = aggregate;
|
|
26
|
+
})(Failed || (Failed = {}));
|
|
27
|
+
//# sourceMappingURL=Failed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Failed.js","sourceRoot":"../","sources":["Transaction/Collect/Failed.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAKvD,MAAM,KAAW,MAAM,CA0BtB;AA1BD,WAAiB,MAAM;IAMtB,SAAgB,IAAI,CAAC,OAAkB,EAAE,KAAoB,EAAE,WAAkC;QAChG,OAAO;YACN,eAAe,EAAE,WAAW,EAAE,QAAQ;gBACrC,CAAC,CAAC;oBACA,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE;iBAC/D;gBACH,CAAC,CAAC,EAAE;YACL,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;SAC1C,CAAA;IACF,CAAC;IATe,WAAI,OASnB,CAAA;IACD,SAAgB,SAAS,CAAC,QAA4B,EAAE,MAA0B;QACjF,OAAO,CAAC,QAAQ;YACf,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,CAAC,MAAM;gBACT,CAAC,CAAC,QAAQ;gBACV,CAAC,CAAC;oBACA,eAAe,EAAE,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,CAAC;oBACxF,OAAO,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;iBAClE,CAAA;IACL,CAAC;IATe,gBAAS,YASxB,CAAA;AACF,CAAC,EA1BgB,MAAM,KAAN,MAAM,QA0BtB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { gracely } from "gracely";
|
|
2
|
+
import { Counterbalances } from "../../CounterBalances";
|
|
3
|
+
import type { Transaction } from "../index";
|
|
4
|
+
import { Creatable as CollectCreatable } from "./Creatable";
|
|
5
|
+
import { Failed } from "./Failed";
|
|
6
|
+
export type Collect = {
|
|
7
|
+
counterbalances: Counterbalances;
|
|
8
|
+
failed?: Failed;
|
|
9
|
+
};
|
|
10
|
+
export declare namespace Collect {
|
|
11
|
+
type Creatable = CollectCreatable;
|
|
12
|
+
namespace Creatable {
|
|
13
|
+
const type: import("isly/dist/cjs/object").object.ExtendableType<CollectCreatable>;
|
|
14
|
+
const is: import("isly/dist/cjs/Type").Type.IsFunction<CollectCreatable>;
|
|
15
|
+
const flaw: import("isly/dist/cjs/Type").Type.FlawFunction;
|
|
16
|
+
}
|
|
17
|
+
function from(transaction: Partial<Transaction>, creatable: CollectCreatable, error?: gracely.Error): Collect;
|
|
18
|
+
function sum(collects: Collect[]): Collect;
|
|
19
|
+
function aggregate(addendee: Collect, addend: Collect): Collect;
|
|
20
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Counterbalances } from "../../CounterBalances";
|
|
2
|
+
import { Creatable as CollectCreatable } from "./Creatable";
|
|
3
|
+
import { Failed } from "./Failed";
|
|
4
|
+
export var Collect;
|
|
5
|
+
(function (Collect) {
|
|
6
|
+
let Creatable;
|
|
7
|
+
(function (Creatable) {
|
|
8
|
+
Creatable.type = CollectCreatable.type;
|
|
9
|
+
Creatable.is = CollectCreatable.type.is;
|
|
10
|
+
Creatable.flaw = CollectCreatable.type.flaw;
|
|
11
|
+
})(Creatable = Collect.Creatable || (Collect.Creatable = {}));
|
|
12
|
+
function from(transaction, creatable, error) {
|
|
13
|
+
const counterbalances = transaction.currency && transaction.amount
|
|
14
|
+
? { [transaction.currency]: { [creatable.source]: Math.abs(transaction.amount) } }
|
|
15
|
+
: {};
|
|
16
|
+
return error
|
|
17
|
+
? {
|
|
18
|
+
counterbalances: {},
|
|
19
|
+
failed: Failed.from(creatable, error, transaction),
|
|
20
|
+
}
|
|
21
|
+
: {
|
|
22
|
+
counterbalances,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
Collect.from = from;
|
|
26
|
+
function sum(collects) {
|
|
27
|
+
return collects.reduce((r, e) => aggregate(r, e), { counterbalances: {} });
|
|
28
|
+
}
|
|
29
|
+
Collect.sum = sum;
|
|
30
|
+
function aggregate(addendee, addend) {
|
|
31
|
+
return {
|
|
32
|
+
counterbalances: Counterbalances.add(addendee.counterbalances, addend.counterbalances),
|
|
33
|
+
failed: Failed.aggregate(addendee.failed, addend.failed),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
Collect.aggregate = aggregate;
|
|
37
|
+
})(Collect || (Collect = {}));
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Transaction/Collect/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAMjC,MAAM,KAAW,OAAO,CA8BvB;AA9BD,WAAiB,OAAO;IAEvB,IAAiB,SAAS,CAIzB;IAJD,WAAiB,SAAS;QACZ,cAAI,GAAG,gBAAgB,CAAC,IAAI,CAAA;QAC5B,YAAE,GAAG,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAA;QAC7B,cAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAA;IAC/C,CAAC,EAJgB,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAIzB;IACD,SAAgB,IAAI,CAAC,WAAiC,EAAE,SAA2B,EAAE,KAAqB;QACzG,MAAM,eAAe,GACpB,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,MAAM;YACzC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,EAAE;YAClF,CAAC,CAAC,EAAE,CAAA;QACN,OAAO,KAAK;YACX,CAAC,CAAC;gBACA,eAAe,EAAE,EAAE;gBACnB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,WAAW,CAAC;aACjD;YACH,CAAC,CAAC;gBACA,eAAe;aACd,CAAA;IACL,CAAC;IAbe,YAAI,OAanB,CAAA;IACD,SAAgB,GAAG,CAAC,QAAmB;QACtC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAA;IAC3E,CAAC;IAFe,WAAG,MAElB,CAAA;IACD,SAAgB,SAAS,CAAC,QAAiB,EAAE,MAAe;QAC3D,OAAO;YACN,eAAe,EAAE,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC,eAAe,CAAC;YACtF,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;SACxD,CAAA;IACF,CAAC;IALe,iBAAS,YAKxB,CAAA;AACF,CAAC,EA9BgB,OAAO,KAAP,OAAO,QA8BvB"}
|
|
@@ -3,6 +3,7 @@ import { isoly } from "isoly";
|
|
|
3
3
|
import { isly } from "isly";
|
|
4
4
|
import { Operation } from "../Operation";
|
|
5
5
|
import { Rail } from "../Rail";
|
|
6
|
+
import { Collect as TransactionCollect } from "./Collect";
|
|
6
7
|
import { Creatable as TransactionCreatable } from "./Creatable";
|
|
7
8
|
import { Incoming as TransactionIncoming } from "./Incoming";
|
|
8
9
|
import { Note as TransactionNote } from "./Note";
|
|
@@ -26,17 +27,22 @@ export interface Transaction extends Transaction.Creatable {
|
|
|
26
27
|
export declare namespace Transaction {
|
|
27
28
|
type Creatable = TransactionCreatable;
|
|
28
29
|
const Creatable: typeof TransactionCreatable;
|
|
30
|
+
type Collect = TransactionCollect;
|
|
31
|
+
const Collect: typeof TransactionCollect;
|
|
32
|
+
namespace Collect {
|
|
33
|
+
type Creatable = TransactionCollect.Creatable;
|
|
34
|
+
}
|
|
29
35
|
type Incoming = TransactionIncoming;
|
|
30
36
|
const Incoming: typeof TransactionIncoming;
|
|
31
37
|
type Reference = TransactionReference;
|
|
32
38
|
const Reference: typeof TransactionReference;
|
|
33
39
|
type Note = TransactionNote;
|
|
34
40
|
const Note: typeof TransactionNote;
|
|
35
|
-
type Status = TransactionStatus;
|
|
36
|
-
const Status: typeof TransactionStatus;
|
|
37
41
|
namespace Note {
|
|
38
42
|
type Creatable = TransactionNote.Creatable;
|
|
39
43
|
}
|
|
44
|
+
type Status = TransactionStatus;
|
|
45
|
+
const Status: typeof TransactionStatus;
|
|
40
46
|
const type: isly.object.ExtendableType<Transaction>;
|
|
41
47
|
const is: isly.Type.IsFunction<Transaction>;
|
|
42
48
|
const flaw: isly.Type.FlawFunction;
|
|
@@ -4,6 +4,7 @@ import { isly } from "isly";
|
|
|
4
4
|
import { Identifier } from "../Identifier";
|
|
5
5
|
import { Operation } from "../Operation";
|
|
6
6
|
import { Rail } from "../Rail";
|
|
7
|
+
import { Collect as TransactionCollect } from "./Collect";
|
|
7
8
|
import { Creatable as TransactionCreatable } from "./Creatable";
|
|
8
9
|
import { Incoming as TransactionIncoming } from "./Incoming";
|
|
9
10
|
import { Note as TransactionNote } from "./Note";
|
|
@@ -12,6 +13,7 @@ import { Status as TransactionStatus } from "./Status";
|
|
|
12
13
|
export var Transaction;
|
|
13
14
|
(function (Transaction) {
|
|
14
15
|
Transaction.Creatable = TransactionCreatable;
|
|
16
|
+
Transaction.Collect = TransactionCollect;
|
|
15
17
|
Transaction.Incoming = TransactionIncoming;
|
|
16
18
|
Transaction.Reference = TransactionReference;
|
|
17
19
|
Transaction.Note = TransactionNote;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Transaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,SAAS,IAAI,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,QAAQ,IAAI,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,EAAE,SAAS,IAAI,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAiBtD,MAAM,KAAW,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Transaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,OAAO,IAAI,kBAAkB,EA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