@pax2pay/model-banking 0.0.2 → 0.0.4
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/Account/Creatable.ts +9 -0
- package/Account/index.ts +43 -0
- package/Balances/index.ts +25 -0
- package/Event/index.ts +66 -0
- package/Operation/Creatable.ts +81 -0
- package/Operation/index.ts +69 -0
- package/Organization/Creatable.ts +9 -0
- package/Organization/index.ts +23 -0
- package/Rail/Iban.ts +11 -0
- package/Rail/PaxGiro.ts +12 -0
- package/Rail/Type.ts +1 -0
- package/Rail/index.ts +75 -0
- package/Rail/internal.ts +12 -0
- package/Transaction/Creatable.ts +29 -0
- package/Transaction/index.ts +50 -0
- package/dist/Account/Creatable.d.ts +6 -0
- package/dist/Account/Creatable.js +8 -0
- package/dist/Account/Creatable.js.map +1 -0
- package/dist/Account/index.d.ts +23 -0
- package/dist/Account/index.js +37 -0
- package/dist/Account/index.js.map +1 -0
- package/dist/Balances/index.d.ts +9 -0
- package/dist/Balances/index.js +19 -0
- package/dist/Balances/index.js.map +1 -0
- package/dist/Event/index.d.ts +33 -0
- package/dist/Event/index.js +65 -0
- package/dist/Event/index.js.map +1 -0
- package/dist/Operation/Creatable.d.ts +48 -0
- package/dist/Operation/Creatable.js +61 -0
- package/dist/Operation/Creatable.js.map +1 -0
- package/dist/Operation/index.d.ts +16 -0
- package/dist/Operation/index.js +56 -0
- package/dist/Operation/index.js.map +1 -0
- package/dist/Organization/Creatable.d.ts +6 -0
- package/dist/Organization/Creatable.js +8 -0
- package/dist/Organization/Creatable.js.map +1 -0
- package/dist/Organization/index.d.ts +11 -0
- package/dist/Organization/index.js +19 -0
- package/dist/Organization/index.js.map +1 -0
- package/dist/Rail/Iban.d.ts +8 -0
- package/dist/Rail/Iban.js +9 -0
- package/dist/Rail/Iban.js.map +1 -0
- package/dist/Rail/PaxGiro.d.ts +9 -0
- package/dist/Rail/PaxGiro.js +10 -0
- package/dist/Rail/PaxGiro.js.map +1 -0
- package/dist/Rail/Type.d.ts +1 -0
- package/dist/Rail/Type.js +2 -0
- package/dist/Rail/Type.js.map +1 -0
- package/dist/Rail/index.d.ts +18 -0
- package/dist/Rail/index.js +59 -0
- package/dist/Rail/index.js.map +1 -0
- package/dist/Rail/internal.d.ts +9 -0
- package/dist/Rail/internal.js +10 -0
- package/dist/Rail/internal.js.map +1 -0
- package/dist/Transaction/Creatable.d.ts +14 -0
- package/dist/Transaction/Creatable.js +20 -0
- package/dist/Transaction/Creatable.js.map +1 -0
- package/dist/Transaction/index.d.ts +20 -0
- package/dist/Transaction/index.js +37 -0
- package/dist/Transaction/index.js.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/index.ts +7 -1
- package/package.json +15 -10
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Account as modelAccount } from "../Account";
|
|
2
|
+
import { Operation as modelOperation } from "../Operation";
|
|
3
|
+
import { Organization as modelOrganization } from "../Organization";
|
|
4
|
+
import { Rail as modelRail } from "../Rail";
|
|
5
|
+
import { Transaction as modelTransaction } from "../Transaction";
|
|
6
|
+
export interface Event {
|
|
7
|
+
organization?: string;
|
|
8
|
+
account?: string;
|
|
9
|
+
entity: Entity;
|
|
10
|
+
action: string;
|
|
11
|
+
data: any;
|
|
12
|
+
}
|
|
13
|
+
type Entity = "account" | "transaction" | "operation" | "rail" | "organization" | "authorization";
|
|
14
|
+
export declare namespace Event {
|
|
15
|
+
namespace Account {
|
|
16
|
+
function created(account: modelAccount, organization: string): Event;
|
|
17
|
+
}
|
|
18
|
+
namespace Operation {
|
|
19
|
+
function performed(operation: modelOperation, organization: string, account: string): Event;
|
|
20
|
+
}
|
|
21
|
+
namespace Organization {
|
|
22
|
+
function created(organization: modelOrganization): Event;
|
|
23
|
+
}
|
|
24
|
+
namespace Rail {
|
|
25
|
+
function added(rail: modelRail, organization: string, account: string): Event;
|
|
26
|
+
}
|
|
27
|
+
namespace Transaction {
|
|
28
|
+
function initiated(transaction: modelTransaction, organization: string, account: string): Event;
|
|
29
|
+
function settled(transaction: modelTransaction, organization: string, account: string): Event;
|
|
30
|
+
function incoming(transaction: modelTransaction, organization: string, account: string): Event;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export var Event;
|
|
2
|
+
(function (Event) {
|
|
3
|
+
let Account;
|
|
4
|
+
(function (Account) {
|
|
5
|
+
function created(account, organization) {
|
|
6
|
+
return { organization: organization, entity: "account", action: "created", data: account };
|
|
7
|
+
}
|
|
8
|
+
Account.created = created;
|
|
9
|
+
})(Account = Event.Account || (Event.Account = {}));
|
|
10
|
+
let Operation;
|
|
11
|
+
(function (Operation) {
|
|
12
|
+
function performed(operation, organization, account) {
|
|
13
|
+
return { organization: organization, account: account, entity: "operation", action: "performed", data: operation };
|
|
14
|
+
}
|
|
15
|
+
Operation.performed = performed;
|
|
16
|
+
})(Operation = Event.Operation || (Event.Operation = {}));
|
|
17
|
+
let Organization;
|
|
18
|
+
(function (Organization) {
|
|
19
|
+
function created(organization) {
|
|
20
|
+
return { entity: "organization", action: "created", data: organization };
|
|
21
|
+
}
|
|
22
|
+
Organization.created = created;
|
|
23
|
+
})(Organization = Event.Organization || (Event.Organization = {}));
|
|
24
|
+
let Rail;
|
|
25
|
+
(function (Rail) {
|
|
26
|
+
function added(rail, organization, account) {
|
|
27
|
+
return { organization: organization, account: account, entity: "rail", action: "added", data: rail };
|
|
28
|
+
}
|
|
29
|
+
Rail.added = added;
|
|
30
|
+
})(Rail = Event.Rail || (Event.Rail = {}));
|
|
31
|
+
let Transaction;
|
|
32
|
+
(function (Transaction) {
|
|
33
|
+
function initiated(transaction, organization, account) {
|
|
34
|
+
return {
|
|
35
|
+
organization: organization,
|
|
36
|
+
account: account,
|
|
37
|
+
entity: "transaction",
|
|
38
|
+
action: "initiated",
|
|
39
|
+
data: transaction,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
Transaction.initiated = initiated;
|
|
43
|
+
function settled(transaction, organization, account) {
|
|
44
|
+
return {
|
|
45
|
+
organization: organization,
|
|
46
|
+
account: account,
|
|
47
|
+
entity: "transaction",
|
|
48
|
+
action: "settled",
|
|
49
|
+
data: transaction,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
Transaction.settled = settled;
|
|
53
|
+
function incoming(transaction, organization, account) {
|
|
54
|
+
return {
|
|
55
|
+
organization: organization,
|
|
56
|
+
account: account,
|
|
57
|
+
entity: "transaction",
|
|
58
|
+
action: "incoming",
|
|
59
|
+
data: transaction,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
Transaction.incoming = incoming;
|
|
63
|
+
})(Transaction = Event.Transaction || (Event.Transaction = {}));
|
|
64
|
+
})(Event || (Event = {}));
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Event/index.ts"],"names":[],"mappings":"AAeA,MAAM,KAAW,KAAK,CAkDrB;AAlDD,WAAiB,KAAK;IACrB,IAAiB,OAAO,CAIvB;IAJD,WAAiB,OAAO;QACvB,SAAgB,OAAO,CAAC,OAAqB,EAAE,YAAoB;YAClE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;QAC3F,CAAC;QAFe,eAAO,UAEtB,CAAA;IACF,CAAC,EAJgB,OAAO,GAAP,aAAO,KAAP,aAAO,QAIvB;IACD,IAAiB,SAAS,CAIzB;IAJD,WAAiB,SAAS;QACzB,SAAgB,SAAS,CAAC,SAAyB,EAAE,YAAoB,EAAE,OAAe;YACzF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,SAA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C;QARe,mBAAO,UAQtB,CAAA;QACD,SAAgB,QAAQ,CAAC,WAA6B,EAAE,YAAoB,EAAE,OAAe;YAC5F,OAAO;gBACN,YAAY,EAAE,YAAY;gBAC1B,OAAO,EAAE,OAAO;gBAChB,MAAM,EAAE,aAAa;gBACrB,MAAM,EAAE,UAAU;gBAClB,IAAI,EAAE,WAAW;aACjB,CAAA;QACF,CAAC;QARe,oBAAQ,WAQvB,CAAA;IACF,CAAC,EA5BgB,WAAW,GAAX,iBAAW,KAAX,iBAAW,QA4B3B;AACF,CAAC,EAlDgB,KAAK,KAAL,KAAK,QAkDrB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as isoly from "isoly";
|
|
2
|
+
import { Balances } from "../Balances";
|
|
3
|
+
export type OperationStatus = "pending" | "success" | "failed";
|
|
4
|
+
type ChangeType = {
|
|
5
|
+
type: "add" | "subtract";
|
|
6
|
+
amount: number;
|
|
7
|
+
status: OperationStatus;
|
|
8
|
+
};
|
|
9
|
+
export type Change = Partial<Record<Balances.Entry, ChangeType>>;
|
|
10
|
+
export declare namespace Change {
|
|
11
|
+
function is(value: any | Change): value is Change;
|
|
12
|
+
function isChangeType(value: ChangeType | any): value is ChangeType;
|
|
13
|
+
type Reservation = {
|
|
14
|
+
reserved: {
|
|
15
|
+
type: "add";
|
|
16
|
+
amount: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
type Deposit = {
|
|
20
|
+
actual: {
|
|
21
|
+
type: "add";
|
|
22
|
+
amount: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
type Finalization = {
|
|
26
|
+
reserved: {
|
|
27
|
+
type: "subtract";
|
|
28
|
+
amount: number;
|
|
29
|
+
};
|
|
30
|
+
actual: {
|
|
31
|
+
type: "subtract";
|
|
32
|
+
amount: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
function isReservation(value: Reservation | any): value is Reservation;
|
|
36
|
+
function isDeposit(value: Deposit | any): value is Deposit;
|
|
37
|
+
function isFinalization(value: Finalization | any): value is Finalization;
|
|
38
|
+
}
|
|
39
|
+
export interface Creatable {
|
|
40
|
+
currency: isoly.Currency;
|
|
41
|
+
change: Change;
|
|
42
|
+
}
|
|
43
|
+
export declare namespace Creatable {
|
|
44
|
+
function is(value: any | Creatable): value is Creatable;
|
|
45
|
+
function openReservation(currency: isoly.Currency, amount: number): Creatable;
|
|
46
|
+
function openDeposit(currency: isoly.Currency, amount: number): Creatable;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as isoly from "isoly";
|
|
2
|
+
export var Change;
|
|
3
|
+
(function (Change) {
|
|
4
|
+
function is(value) {
|
|
5
|
+
return (typeof value == "object" &&
|
|
6
|
+
(value.actual == undefined || isChangeType(value.actual)) &&
|
|
7
|
+
(value.reserved == undefined || isChangeType(value.reserved)) &&
|
|
8
|
+
(value.actual || value.reserved));
|
|
9
|
+
}
|
|
10
|
+
Change.is = is;
|
|
11
|
+
function isChangeType(value) {
|
|
12
|
+
return (typeof value == "object" &&
|
|
13
|
+
typeof value.amount == "number" &&
|
|
14
|
+
value.amount > 0 &&
|
|
15
|
+
(value.type == "add" || value.type == "subtract") &&
|
|
16
|
+
typeof value.status == "string" &&
|
|
17
|
+
(value.status == "pending" || value.status == "success" || value.status == "failed"));
|
|
18
|
+
}
|
|
19
|
+
Change.isChangeType = isChangeType;
|
|
20
|
+
function isReservation(value) {
|
|
21
|
+
return (Change.is({ ...value }) &&
|
|
22
|
+
value.actual == undefined &&
|
|
23
|
+
typeof value.reserved == "object" &&
|
|
24
|
+
value.reserved.type == "add");
|
|
25
|
+
}
|
|
26
|
+
Change.isReservation = isReservation;
|
|
27
|
+
function isDeposit(value) {
|
|
28
|
+
return (Change.is({ ...value }) &&
|
|
29
|
+
value.reserved == undefined &&
|
|
30
|
+
typeof value.actual == "object" &&
|
|
31
|
+
value.actual.type == "add");
|
|
32
|
+
}
|
|
33
|
+
Change.isDeposit = isDeposit;
|
|
34
|
+
function isFinalization(value) {
|
|
35
|
+
return (Change.is({ ...value }) &&
|
|
36
|
+
typeof value.actual == "object" &&
|
|
37
|
+
value.actual.type == "subtract" &&
|
|
38
|
+
typeof value.reserved == "object" &&
|
|
39
|
+
value.reserved.type == "subtract");
|
|
40
|
+
}
|
|
41
|
+
Change.isFinalization = isFinalization;
|
|
42
|
+
})(Change || (Change = {}));
|
|
43
|
+
export var Creatable;
|
|
44
|
+
(function (Creatable) {
|
|
45
|
+
function is(value) {
|
|
46
|
+
return (typeof value == "object" &&
|
|
47
|
+
isoly.Currency.is(value.currency) &&
|
|
48
|
+
typeof value.change == "object" &&
|
|
49
|
+
Change.is(value.change));
|
|
50
|
+
}
|
|
51
|
+
Creatable.is = is;
|
|
52
|
+
function openReservation(currency, amount) {
|
|
53
|
+
return { currency: currency, change: { reserved: { type: "add", amount: amount, status: "pending" } } };
|
|
54
|
+
}
|
|
55
|
+
Creatable.openReservation = openReservation;
|
|
56
|
+
function openDeposit(currency, amount) {
|
|
57
|
+
return { currency: currency, change: { actual: { type: "add", amount: amount, status: "pending" } } };
|
|
58
|
+
}
|
|
59
|
+
Creatable.openDeposit = openDeposit;
|
|
60
|
+
})(Creatable || (Creatable = {}));
|
|
61
|
+
//# sourceMappingURL=Creatable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Creatable.js","sourceRoot":"../","sources":["Operation/Creatable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,MAAM,KAAW,MAAM,CAkDtB;AAlDD,WAAiB,MAAM;IACtB,SAAgB,EAAE,CAAC,KAAmB;QACrC,OAAO,CACN,OAAO,KAAK,IAAI,QAAQ;YACxB,CAAC,KAAK,CAAC,MAAM,IAAI,SAAS,IAAI,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACzD,CAAC,KAAK,CAAC,QAAQ,IAAI,SAAS,IAAI,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0,0 +1,16 @@
|
|
|
1
|
+
import * as cryptly from "cryptly";
|
|
2
|
+
import * as gracely from "gracely";
|
|
3
|
+
import * as isoly from "isoly";
|
|
4
|
+
import { Creatable as OperationCreatable } from "./Creatable";
|
|
5
|
+
export interface Operation extends OperationCreatable {
|
|
6
|
+
id: cryptly.Identifier;
|
|
7
|
+
created: isoly.DateTime;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace Operation {
|
|
10
|
+
function is(value: any | Operation): value is Operation;
|
|
11
|
+
function fromCreatable(operation: Creatable): Operation;
|
|
12
|
+
function reverse(operation: Operation): Operation;
|
|
13
|
+
function openFinalization(reservation: Operation): Operation | gracely.Error;
|
|
14
|
+
type Creatable = OperationCreatable;
|
|
15
|
+
const Creatable: typeof OperationCreatable;
|
|
16
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as cryptly from "cryptly";
|
|
2
|
+
import * as gracely from "gracely";
|
|
3
|
+
import * as isoly from "isoly";
|
|
4
|
+
import { Creatable as OperationCreatable } from "./Creatable";
|
|
5
|
+
export var Operation;
|
|
6
|
+
(function (Operation) {
|
|
7
|
+
function is(value) {
|
|
8
|
+
return (typeof value == "object" &&
|
|
9
|
+
cryptly.Identifier.is(value.id, 8) &&
|
|
10
|
+
isoly.DateTime.is(value.created) &&
|
|
11
|
+
OperationCreatable.is({ ...value }));
|
|
12
|
+
}
|
|
13
|
+
Operation.is = is;
|
|
14
|
+
function fromCreatable(operation) {
|
|
15
|
+
const id = cryptly.Identifier.generate(8);
|
|
16
|
+
const timestamp = isoly.DateTime.now();
|
|
17
|
+
return {
|
|
18
|
+
...operation,
|
|
19
|
+
id: id,
|
|
20
|
+
created: timestamp,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
Operation.fromCreatable = fromCreatable;
|
|
24
|
+
function reverse(operation) {
|
|
25
|
+
const id = cryptly.Identifier.generate(8);
|
|
26
|
+
const timestamp = isoly.DateTime.now();
|
|
27
|
+
const reverseChange = Object.fromEntries(Object.entries(operation.change)
|
|
28
|
+
.filter(([k, v]) => v.status == "success")
|
|
29
|
+
.map(([k, v]) => [k, { type: v.type == "add" ? "subtract" : "add", amount: v.amount, status: "pending" }]));
|
|
30
|
+
return {
|
|
31
|
+
...operation,
|
|
32
|
+
id: id,
|
|
33
|
+
created: timestamp,
|
|
34
|
+
change: reverseChange,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
Operation.reverse = reverse;
|
|
38
|
+
function openFinalization(reservation) {
|
|
39
|
+
return typeof reservation.change.actual == "object" ||
|
|
40
|
+
typeof reservation.change.reserved == "undefined" ||
|
|
41
|
+
reservation.change.reserved.status == "failed"
|
|
42
|
+
? gracely.client.invalidContent("Operation", "Amount is not reserved.")
|
|
43
|
+
: {
|
|
44
|
+
id: cryptly.Identifier.generate(8),
|
|
45
|
+
created: isoly.DateTime.now(),
|
|
46
|
+
currency: reservation.currency,
|
|
47
|
+
change: {
|
|
48
|
+
actual: { type: "subtract", amount: reservation.change.reserved.amount, status: "pending" },
|
|
49
|
+
reserved: { type: "subtract", amount: reservation.change.reserved.amount, status: "pending" },
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
Operation.openFinalization = openFinalization;
|
|
54
|
+
Operation.Creatable = OperationCreatable;
|
|
55
|
+
})(Operation || (Operation = {}));
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Operation/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,SAAS,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAO7D,MAAM,KAAW,SAAS,CAwDzB;AAxDD,WAAiB,SAAS;IACzB,SAAgB,EAAE,CAAC,K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D,WAAiB,SAAS;IACzB,SAAgB,EAAE,CAAC,KAAsB;QACxC,OAAO,OAAO,KAAK,IAAI,QAAQ,IAAI,OAAO,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAA;IACjE,CAAC;IAFe,YAAE,KAEjB,CAAA;AACF,CAAC,EAJgB,SAAS,KAAT,SAAS,QAIzB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as cryptly from "cryptly";
|
|
2
|
+
import { Creatable as OrganizationCreatable } from "./Creatable";
|
|
3
|
+
export interface Organization extends OrganizationCreatable {
|
|
4
|
+
readonly id: cryptly.Identifier;
|
|
5
|
+
}
|
|
6
|
+
export declare namespace Organization {
|
|
7
|
+
function is(value: Organization | any): value is Organization;
|
|
8
|
+
function fromCreatable(organization: Creatable): Organization;
|
|
9
|
+
type Creatable = OrganizationCreatable;
|
|
10
|
+
const Creatable: typeof OrganizationCreatable;
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as cryptly from "cryptly";
|
|
2
|
+
import { Creatable as OrganizationCreatable } from "./Creatable";
|
|
3
|
+
export var Organization;
|
|
4
|
+
(function (Organization) {
|
|
5
|
+
function is(value) {
|
|
6
|
+
return !!(value &&
|
|
7
|
+
typeof value == "object" &&
|
|
8
|
+
cryptly.Identifier.is(value.id, 8) &&
|
|
9
|
+
typeof value.name == "string" &&
|
|
10
|
+
typeof value.value == "number");
|
|
11
|
+
}
|
|
12
|
+
Organization.is = is;
|
|
13
|
+
function fromCreatable(organization) {
|
|
14
|
+
return { ...organization, id: cryptly.Identifier.generate(8) };
|
|
15
|
+
}
|
|
16
|
+
Organization.fromCreatable = fromCreatable;
|
|
17
|
+
Organization.Creatable = OrganizationCreatable;
|
|
18
|
+
})(Organization || (Organization = {}));
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Organization/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,SAAS,IAAI,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAMhE,MAAM,KAAW,YAAY,CAe5B;AAfD,WAAiB,YAAY;IAC5B,SAAgB,EAAE,CAAC,KAAyB;QAC3C,OAAO,CAAC,CAAC,CACR,KAAK;YACL,OAAO,KAAK,IAAI,QAAQ;YACxB,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;YAClC,OAAO,KAAK,CAAC,IAAI,IAAI,QAAQ;YAC7B,OAAO,KAAK,CAAC,KAAK,IAAI,QAAQ,CAC9B,CAAA;IACF,CAAC;IARe,eAAE,KAQjB,CAAA;IACD,SAAgB,aAAa,CAAC,YAAuB;QACpD,OAAO,EAAE,GAAG,YAAY,EAAE,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/D,CAAC;IAFe,0BAAa,gBAE5B,CAAA;IAEY,sBAAS,GAAG,qBAAqB,CAAA;AAC/C,CAAC,EAfgB,YAAY,KAAZ,YAAY,QAe5B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export var Iban;
|
|
2
|
+
(function (Iban) {
|
|
3
|
+
Iban.currencies = ["EUR", "GBP", "SEK", "USD"];
|
|
4
|
+
function is(value) {
|
|
5
|
+
return typeof value == "object" && typeof value.iban == "string" && value.type == "iban";
|
|
6
|
+
}
|
|
7
|
+
Iban.is = is;
|
|
8
|
+
})(Iban || (Iban = {}));
|
|
9
|
+
//# sourceMappingURL=Iban.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Iban.js","sourceRoot":"../","sources":["Rail/Iban.ts"],"names":[],"mappings":"AAIA,MAAM,KAAW,IAAI,CAMpB;AAND,WAAiB,IAAI;IACP,eAAU,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAU,CAAA;IAE/D,SAAgB,EAAE,CAAC,KAAiB;QACnC,OAAO,OAAO,KAAK,IAAI,QAAQ,IAAI,OAAO,KAAK,CAAC,IAAI,IAAI,QAAQ,IAAI,KAAK,CAAC,IAAI,IAAI,MAAM,CAAA;IACzF,CAAC;IAFe,OAAE,KAEjB,CAAA;AACF,CAAC,EANgB,IAAI,KAAJ,IAAI,QAMpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as cryptly from "cryptly";
|
|
2
|
+
export interface PaxGiro {
|
|
3
|
+
type: "paxgiro";
|
|
4
|
+
identifier: cryptly.Identifier;
|
|
5
|
+
}
|
|
6
|
+
export declare namespace PaxGiro {
|
|
7
|
+
const currencies: readonly ["EUR", "GBP", "SEK", "USD"];
|
|
8
|
+
function is(value: PaxGiro | any): value is PaxGiro;
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as cryptly from "cryptly";
|
|
2
|
+
export var PaxGiro;
|
|
3
|
+
(function (PaxGiro) {
|
|
4
|
+
PaxGiro.currencies = ["EUR", "GBP", "SEK", "USD"];
|
|
5
|
+
function is(value) {
|
|
6
|
+
return typeof value == "object" && cryptly.Identifier.is(value.identifier, 8) && value.type == "paxgiro";
|
|
7
|
+
}
|
|
8
|
+
PaxGiro.is = is;
|
|
9
|
+
})(PaxGiro || (PaxGiro = {}));
|
|
10
|
+
//# sourceMappingURL=PaxGiro.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaxGiro.js","sourceRoot":"../","sources":["Rail/PaxGiro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAMlC,MAAM,KAAW,OAAO,CAKvB;AALD,WAAiB,OAAO;IACV,kBAAU,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAU,CAAA;IAC/D,SAAgB,EAAE,CAAC,KAAoB;QACtC,OAAO,OAAO,KAAK,IAAI,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,SAAS,CAAA;IACzG,CAAC;IAFe,UAAE,KAEjB,CAAA;AACF,CAAC,EALgB,OAAO,KAAP,OAAO,QAKvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Type = "iban" | "paxgiro" | "swedish" | "internal";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Type.js","sourceRoot":"../","sources":["Rail/Type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Iban as RailIban } from "./Iban";
|
|
2
|
+
import { Internal as RailInternal } from "./internal";
|
|
3
|
+
import { PaxGiro as RailPaxGiro } from "./PaxGiro";
|
|
4
|
+
import { Type as RailType } from "./Type";
|
|
5
|
+
export type Rail = RailPaxGiro | RailIban | RailInternal;
|
|
6
|
+
export declare namespace Rail {
|
|
7
|
+
function parse(value: string): Rail | undefined;
|
|
8
|
+
function stringify(rail: Rail): string;
|
|
9
|
+
function is(value: Rail | any): value is Rail;
|
|
10
|
+
function hasSameIdentifiers(sender: Rail, recipient: Rail): boolean;
|
|
11
|
+
type Type = RailType;
|
|
12
|
+
type PaxGiro = RailPaxGiro;
|
|
13
|
+
const PaxGiro: typeof RailPaxGiro;
|
|
14
|
+
type Iban = RailIban;
|
|
15
|
+
const Iban: typeof RailIban;
|
|
16
|
+
type Internal = RailInternal;
|
|
17
|
+
const Internal: typeof RailInternal;
|
|
18
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Iban as RailIban } from "./Iban";
|
|
2
|
+
import { Internal as RailInternal } from "./internal";
|
|
3
|
+
import { PaxGiro as RailPaxGiro } from "./PaxGiro";
|
|
4
|
+
export var Rail;
|
|
5
|
+
(function (Rail) {
|
|
6
|
+
function parse(value) {
|
|
7
|
+
let result;
|
|
8
|
+
const splitted = value.split("-");
|
|
9
|
+
switch (splitted[0]) {
|
|
10
|
+
case "pxg":
|
|
11
|
+
result = splitted.length == 2 ? { type: "paxgiro", identifier: splitted[1] } : undefined;
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
Rail.parse = parse;
|
|
17
|
+
function stringify(rail) {
|
|
18
|
+
let result;
|
|
19
|
+
switch (rail.type) {
|
|
20
|
+
case "iban":
|
|
21
|
+
result = `iban-${rail.iban}`;
|
|
22
|
+
break;
|
|
23
|
+
case "paxgiro":
|
|
24
|
+
result = `pxg-${rail.identifier}`;
|
|
25
|
+
break;
|
|
26
|
+
case "internal":
|
|
27
|
+
result = "";
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
Rail.stringify = stringify;
|
|
33
|
+
function is(value) {
|
|
34
|
+
return typeof value == "object" && (Rail.PaxGiro.is(value) || Rail.Iban.is(value) || Rail.Internal.is(value));
|
|
35
|
+
}
|
|
36
|
+
Rail.is = is;
|
|
37
|
+
function hasSameIdentifiers(sender, recipient) {
|
|
38
|
+
let result = false;
|
|
39
|
+
if (sender.type == recipient.type) {
|
|
40
|
+
switch (sender.type) {
|
|
41
|
+
case "iban":
|
|
42
|
+
result = sender.iban == recipient.iban;
|
|
43
|
+
break;
|
|
44
|
+
case "paxgiro":
|
|
45
|
+
result = sender.identifier == recipient.identifier;
|
|
46
|
+
break;
|
|
47
|
+
case "internal":
|
|
48
|
+
result = sender.identifier == recipient.identifier;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
Rail.hasSameIdentifiers = hasSameIdentifiers;
|
|
55
|
+
Rail.PaxGiro = RailPaxGiro;
|
|
56
|
+
Rail.Iban = RailIban;
|
|
57
|
+
Rail.Internal = RailInternal;
|
|
58
|
+
})(Rail || (Rail = {}));
|
|
59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AAO,KAAK,IAAI,QAAQ,IAAI,CAAC,KAAA,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAA,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAA,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/F,CAAC;IAFe,OAAE,KAEjB,CAAA;IAED,SAAgB,kBAAkB,CAAC,MAAY,EAAE,SAAe;QAC/D,IAAI,MAAM,GAAG,KAAK,CAAA;QAClB,IAAI,MAAM,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE;YAClC,QAAQ,MAAM,CAAC,IAAI,EAAE;gBACpB,KAAK,MAAM;oBACV,MAAM,GAAG,MAAM,CAAC,IAAI,IAAK,SAAkB,CAAC,IAAI,CAAA;oBAChD,MAAK;gBACN,KAAK,SAAS;oBACb,MAAM,GAAG,MAAM,CAAC,UAAU,IAAK,SAAqB,CAAC,UAAU,CAAA;oBAC/D,MAAK;gBACN,KAAK,UAAU;oBACd,MAAM,GAAG,MAAM,CAAC,UAAU,IAAK,SAAsB,CAAC,UAAU,CAAA;oBAChE,MAAK;aACN;SACD;QACD,OAAO,MAAM,CAAA;IACd,CAAC;IAhBe,uBAAkB,qBAgBjC,CAAA;IAIY,YAAO,GAAG,WAAW,CAAA;IAErB,SAAI,GAAG,QAAQ,CAAA;IAEf,aAAQ,GAAG,YAAY,CAAA;AACrC,CAAC,EAnEgB,IAAI,KAAJ,IAAI,QAmEpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as cryptly from "cryptly";
|
|
2
|
+
export interface Internal {
|
|
3
|
+
type: "internal";
|
|
4
|
+
identifier: cryptly.Identifier;
|
|
5
|
+
}
|
|
6
|
+
export declare namespace Internal {
|
|
7
|
+
const currencies: readonly ["EUR", "GBP", "SEK", "USD"];
|
|
8
|
+
function is(value: Internal | any): value is Internal;
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as cryptly from "cryptly";
|
|
2
|
+
export var Internal;
|
|
3
|
+
(function (Internal) {
|
|
4
|
+
Internal.currencies = ["EUR", "GBP", "SEK", "USD"];
|
|
5
|
+
function is(value) {
|
|
6
|
+
return typeof value == "object" && cryptly.Identifier.is(value.identifier, 8) && value.type == "internal";
|
|
7
|
+
}
|
|
8
|
+
Internal.is = is;
|
|
9
|
+
})(Internal || (Internal = {}));
|
|
10
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"../","sources":["Rail/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAMlC,MAAM,KAAW,QAAQ,CAKxB;AALD,WAAiB,QAAQ;IACX,mBAAU,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAU,CAAA;IAC/D,SAAgB,EAAE,CAAC,KAAqB;QACvC,OAAO,OAAO,KAAK,IAAI,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,UAAU,CAAA;IAC1G,CAAC;IAFe,WAAE,KAEjB,CAAA;AACF,CAAC,EALgB,QAAQ,KAAR,QAAQ,QAKxB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as isoly from "isoly";
|
|
2
|
+
import { Operation } from "../Operation";
|
|
3
|
+
import { Rail } from "../Rail";
|
|
4
|
+
export interface Creatable {
|
|
5
|
+
account: Rail;
|
|
6
|
+
counterpart: Rail;
|
|
7
|
+
currency: isoly.Currency;
|
|
8
|
+
amount: number;
|
|
9
|
+
description?: string;
|
|
10
|
+
operations?: Operation.Creatable[];
|
|
11
|
+
}
|
|
12
|
+
export declare namespace Creatable {
|
|
13
|
+
function is(value: any | Creatable): value is Creatable;
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as isoly from "isoly";
|
|
2
|
+
import { Operation } from "../Operation";
|
|
3
|
+
import { Rail } from "../Rail";
|
|
4
|
+
export var Creatable;
|
|
5
|
+
(function (Creatable) {
|
|
6
|
+
function is(value) {
|
|
7
|
+
return (typeof value == "object" &&
|
|
8
|
+
Rail.is(value.account) &&
|
|
9
|
+
Rail.is(value.counterpart) &&
|
|
10
|
+
!Rail.hasSameIdentifiers(value.account, value.counterpart) &&
|
|
11
|
+
isoly.Currency.is(value.currency) &&
|
|
12
|
+
typeof value.amount == "number" &&
|
|
13
|
+
value.amount > 0 &&
|
|
14
|
+
(value.description == undefined || typeof value.description == "string") &&
|
|
15
|
+
(value.operations == undefined ||
|
|
16
|
+
(Array.isArray(value.operations) && value.operations.every(Operation.Creatable.is))));
|
|
17
|
+
}
|
|
18
|
+
Creatable.is = is;
|
|
19
|
+
})(Creatable || (Creatable = {}));
|
|
20
|
+
//# sourceMappingURL=Creatable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Creatable.js","sourceRoot":"../","sources":["Transaction/Creatable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAW9B,MAAM,KAAW,SAAS,CAezB;AAfD,WAAiB,SAAS;IACzB,SAAgB,EAAE,CAAC,KAAsB;QACxC,OAAO,CACN,OAAO,KAAK,IAAI,QAAQ;YACxB,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;YACtB,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC;YAC1B,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC;YAC1D,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC;YACjC,OAAO,KAAK,CAAC,MAAM,IAAI,QAAQ;YAC/B,KAAK,CAAC,MAAM,GAAG,CAAC;YAChB,CAAC,KAAK,CAAC,WAAW,IAAI,SAAS,IAAI,OAAO,KAAK,CAAC,WAAW,IAAI,QAAQ,CAAC;YACxE,CAAC,KAAK,CAAC,UAAU,IAAI,SAAS;gBAC7B,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CACrF,CAAA;IACF,CAAC;IAbe,YAAE,KAajB,CAAA;AACF,CAAC,EAfgB,SAAS,KAAT,SAAS,QAezB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as cryptly from "cryptly";
|
|
2
|
+
import * as isoly from "isoly";
|
|
3
|
+
import { Operation } from "../Operation";
|
|
4
|
+
import { Creatable as TransactionCreatable } from "./Creatable";
|
|
5
|
+
export interface Transaction extends TransactionCreatable {
|
|
6
|
+
readonly id: cryptly.Identifier;
|
|
7
|
+
readonly timestamp: isoly.DateTime;
|
|
8
|
+
type: "actual" | "available";
|
|
9
|
+
balance: number;
|
|
10
|
+
operations: Operation[];
|
|
11
|
+
}
|
|
12
|
+
export declare namespace Transaction {
|
|
13
|
+
function is(value: any | Transaction): value is Transaction;
|
|
14
|
+
function fromCreatable(transaction: Creatable & {
|
|
15
|
+
operations: Operation.Creatable[];
|
|
16
|
+
}, type: "actual" | "available", result: number): Transaction;
|
|
17
|
+
function isIdentifier(value: cryptly.Identifier | any): value is cryptly.Identifier;
|
|
18
|
+
type Creatable = TransactionCreatable;
|
|
19
|
+
const Creatable: typeof TransactionCreatable;
|
|
20
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as cryptly from "cryptly";
|
|
2
|
+
import * as isoly from "isoly";
|
|
3
|
+
import { Operation } from "../Operation";
|
|
4
|
+
import { Creatable as TransactionCreatable } from "./Creatable";
|
|
5
|
+
export var Transaction;
|
|
6
|
+
(function (Transaction) {
|
|
7
|
+
function is(value) {
|
|
8
|
+
return (typeof value == "object" &&
|
|
9
|
+
TransactionCreatable.is({ ...value }) &&
|
|
10
|
+
cryptly.Identifier.is(value.id, 8) &&
|
|
11
|
+
isoly.DateTime.is(value.timestamp) &&
|
|
12
|
+
(value.type == "actual" || value.type == "available") &&
|
|
13
|
+
typeof value.balance == "number" &&
|
|
14
|
+
Array.isArray(value.operations) &&
|
|
15
|
+
value.operations.every(Operation.is));
|
|
16
|
+
}
|
|
17
|
+
Transaction.is = is;
|
|
18
|
+
function fromCreatable(transaction, type, result) {
|
|
19
|
+
const id = cryptly.Identifier.generate(8);
|
|
20
|
+
const timestamp = isoly.DateTime.now();
|
|
21
|
+
return {
|
|
22
|
+
id: id,
|
|
23
|
+
timestamp: timestamp,
|
|
24
|
+
type: type,
|
|
25
|
+
balance: result,
|
|
26
|
+
...transaction,
|
|
27
|
+
operations: transaction.operations.map(Operation.fromCreatable),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
Transaction.fromCreatable = fromCreatable;
|
|
31
|
+
function isIdentifier(value) {
|
|
32
|
+
return cryptly.Identifier.is(value, 8);
|
|
33
|
+
}
|
|
34
|
+
Transaction.isIdentifier = isIdentifier;
|
|
35
|
+
Transaction.Creatable = TransactionCreatable;
|
|
36
|
+
})(Transaction || (Transaction = {}));
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../","sources":["Transaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,SAAS,IAAI,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAW/D,MAAM,KAAW,WAA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