@pax2pay/model-banking 0.1.660 → 0.1.663
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/Rail/Address/Bic.ts +27 -0
- package/Rail/Address/index.ts +28 -17
- package/Rail/index.ts +2 -0
- package/Transaction/Amount/Charge/index.ts +17 -0
- package/Transaction/Amount/index.ts +8 -0
- package/Transaction/Creatable.ts +16 -0
- package/Transaction/Exchange.ts +7 -0
- package/Transaction/Identifier.ts +1 -0
- package/Transaction/Incoming.ts +11 -0
- package/Transaction/Note.ts +11 -0
- package/Transaction/PreTransaction/Authorization.ts +8 -0
- package/Transaction/PreTransaction/Base.ts +9 -0
- package/Transaction/PreTransaction/Incoming.ts +11 -0
- package/Transaction/PreTransaction/Outgoing.ts +3 -2
- package/Transaction/PreTransaction/index.ts +2 -0
- package/Transaction/Reference.ts +9 -0
- package/Transaction/Status.ts +2 -0
- package/Transaction/index.ts +33 -0
- package/dist/cjs/Account/Details.d.ts +6 -0
- package/dist/cjs/Account/index.d.ts +12 -0
- package/dist/cjs/Rail/Address/Bic.d.ts +19 -0
- package/dist/cjs/Rail/Address/Bic.js +24 -0
- package/dist/cjs/Rail/Address/Bic.js.map +1 -0
- package/dist/cjs/Rail/Address/index.d.ts +12 -4
- package/dist/cjs/Rail/Address/index.js +39 -30
- package/dist/cjs/Rail/Address/index.js.map +1 -1
- package/dist/cjs/Rail/index.d.ts +18 -0
- package/dist/cjs/Rail/index.js +2 -0
- package/dist/cjs/Rail/index.js.map +1 -1
- package/dist/cjs/Transaction/Amount/Charge/index.d.ts +479 -0
- package/dist/cjs/Transaction/Amount/Charge/index.js +17 -0
- package/dist/cjs/Transaction/Amount/Charge/index.js.map +1 -1
- package/dist/cjs/Transaction/Amount/index.d.ts +612 -0
- package/dist/cjs/Transaction/Amount/index.js +8 -0
- package/dist/cjs/Transaction/Amount/index.js.map +1 -1
- package/dist/cjs/Transaction/Creatable.d.ts +1197 -0
- package/dist/cjs/Transaction/Creatable.js +16 -0
- package/dist/cjs/Transaction/Creatable.js.map +1 -1
- package/dist/cjs/Transaction/Exchange.d.ts +367 -0
- package/dist/cjs/Transaction/Exchange.js +7 -0
- package/dist/cjs/Transaction/Exchange.js.map +1 -1
- package/dist/cjs/Transaction/Identifier.d.ts +1 -0
- package/dist/cjs/Transaction/Identifier.js +1 -0
- package/dist/cjs/Transaction/Identifier.js.map +1 -1
- package/dist/cjs/Transaction/Note.d.ts +21 -0
- package/dist/cjs/Transaction/Note.js +11 -0
- package/dist/cjs/Transaction/Note.js.map +1 -1
- package/dist/cjs/Transaction/PreTransaction/Authorization.d.ts +583 -0
- package/dist/cjs/Transaction/PreTransaction/Authorization.js +8 -0
- package/dist/cjs/Transaction/PreTransaction/Authorization.js.map +1 -1
- package/dist/cjs/Transaction/PreTransaction/Base.d.ts +617 -0
- package/dist/cjs/Transaction/PreTransaction/Base.js +9 -0
- package/dist/cjs/Transaction/PreTransaction/Base.js.map +1 -1
- package/dist/cjs/Transaction/PreTransaction/Incoming.d.ts +703 -0
- package/dist/cjs/Transaction/PreTransaction/Incoming.js +11 -0
- package/dist/cjs/Transaction/PreTransaction/Incoming.js.map +1 -1
- package/dist/cjs/Transaction/PreTransaction/Outgoing.d.ts +614 -2
- package/dist/cjs/Transaction/PreTransaction/Outgoing.js +3 -1
- package/dist/cjs/Transaction/PreTransaction/Outgoing.js.map +1 -1
- package/dist/cjs/Transaction/PreTransaction/index.d.ts +1895 -0
- package/dist/cjs/Transaction/PreTransaction/index.js +2 -0
- package/dist/cjs/Transaction/PreTransaction/index.js.map +1 -1
- package/dist/cjs/Transaction/Reference.d.ts +13 -0
- package/dist/cjs/Transaction/Reference.js +9 -0
- package/dist/cjs/Transaction/Reference.js.map +1 -1
- package/dist/cjs/Transaction/Status.d.ts +21 -0
- package/dist/cjs/Transaction/Status.js +2 -0
- package/dist/cjs/Transaction/Status.js.map +1 -1
- package/dist/cjs/Transaction/index.d.ts +4189 -0
- package/dist/cjs/Transaction/index.js +33 -0
- package/dist/cjs/Transaction/index.js.map +1 -1
- package/dist/mjs/Account/Details.d.ts +6 -0
- package/dist/mjs/Account/index.d.ts +12 -0
- package/dist/mjs/Rail/Address/Bic.d.ts +19 -0
- package/dist/mjs/Rail/Address/Bic.js +21 -0
- package/dist/mjs/Rail/Address/Bic.js.map +1 -0
- package/dist/mjs/Rail/Address/index.d.ts +12 -4
- package/dist/mjs/Rail/Address/index.js +39 -30
- package/dist/mjs/Rail/Address/index.js.map +1 -1
- package/dist/mjs/Rail/index.d.ts +18 -0
- package/dist/mjs/Rail/index.js +2 -0
- package/dist/mjs/Rail/index.js.map +1 -1
- package/dist/mjs/Transaction/Amount/Charge/index.d.ts +479 -0
- package/dist/mjs/Transaction/Amount/Charge/index.js +17 -0
- package/dist/mjs/Transaction/Amount/Charge/index.js.map +1 -1
- package/dist/mjs/Transaction/Amount/index.d.ts +612 -0
- package/dist/mjs/Transaction/Amount/index.js +8 -0
- package/dist/mjs/Transaction/Amount/index.js.map +1 -1
- package/dist/mjs/Transaction/Creatable.d.ts +1197 -0
- package/dist/mjs/Transaction/Creatable.js +16 -0
- package/dist/mjs/Transaction/Creatable.js.map +1 -1
- package/dist/mjs/Transaction/Exchange.d.ts +367 -0
- package/dist/mjs/Transaction/Exchange.js +7 -0
- package/dist/mjs/Transaction/Exchange.js.map +1 -1
- package/dist/mjs/Transaction/Identifier.d.ts +1 -0
- package/dist/mjs/Transaction/Identifier.js +1 -0
- package/dist/mjs/Transaction/Identifier.js.map +1 -1
- package/dist/mjs/Transaction/Note.d.ts +21 -0
- package/dist/mjs/Transaction/Note.js +11 -0
- package/dist/mjs/Transaction/Note.js.map +1 -1
- package/dist/mjs/Transaction/PreTransaction/Authorization.d.ts +583 -0
- package/dist/mjs/Transaction/PreTransaction/Authorization.js +8 -0
- package/dist/mjs/Transaction/PreTransaction/Authorization.js.map +1 -1
- package/dist/mjs/Transaction/PreTransaction/Base.d.ts +617 -0
- package/dist/mjs/Transaction/PreTransaction/Base.js +9 -0
- package/dist/mjs/Transaction/PreTransaction/Base.js.map +1 -1
- package/dist/mjs/Transaction/PreTransaction/Incoming.d.ts +703 -0
- package/dist/mjs/Transaction/PreTransaction/Incoming.js +11 -0
- package/dist/mjs/Transaction/PreTransaction/Incoming.js.map +1 -1
- package/dist/mjs/Transaction/PreTransaction/Outgoing.d.ts +614 -2
- package/dist/mjs/Transaction/PreTransaction/Outgoing.js +3 -1
- package/dist/mjs/Transaction/PreTransaction/Outgoing.js.map +1 -1
- package/dist/mjs/Transaction/PreTransaction/index.d.ts +1895 -0
- package/dist/mjs/Transaction/PreTransaction/index.js +2 -0
- package/dist/mjs/Transaction/PreTransaction/index.js.map +1 -1
- package/dist/mjs/Transaction/Reference.d.ts +13 -0
- package/dist/mjs/Transaction/Reference.js +9 -0
- package/dist/mjs/Transaction/Reference.js.map +1 -1
- package/dist/mjs/Transaction/Status.d.ts +21 -0
- package/dist/mjs/Transaction/Status.js +2 -0
- package/dist/mjs/Transaction/Status.js.map +1 -1
- package/dist/mjs/Transaction/index.d.ts +4189 -0
- package/dist/mjs/Transaction/index.js +33 -0
- package/dist/mjs/Transaction/index.js.map +1 -1
- package/package.json +5 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isly } from "isly"
|
|
2
|
+
import { zod } from "../../zod"
|
|
3
|
+
|
|
4
|
+
export interface Bic {
|
|
5
|
+
type: "bic"
|
|
6
|
+
account: string
|
|
7
|
+
institution: string // BIC, validated against the SWIFT directory by the supplier
|
|
8
|
+
holder: string
|
|
9
|
+
transactor?: string
|
|
10
|
+
}
|
|
11
|
+
export namespace Bic {
|
|
12
|
+
export const currencies = ["USD"] as const
|
|
13
|
+
export const type = isly.object<Bic>({
|
|
14
|
+
type: isly.string("bic"),
|
|
15
|
+
account: isly.string(),
|
|
16
|
+
institution: isly.string(),
|
|
17
|
+
holder: isly.string(),
|
|
18
|
+
transactor: isly.string().optional(),
|
|
19
|
+
})
|
|
20
|
+
export const typeZod = zod.object({
|
|
21
|
+
type: zod.literal("bic"),
|
|
22
|
+
account: zod.string(),
|
|
23
|
+
institution: zod.string(),
|
|
24
|
+
holder: zod.string(),
|
|
25
|
+
transactor: zod.string().optional(),
|
|
26
|
+
})
|
|
27
|
+
}
|
package/Rail/Address/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isly } from "isly"
|
|
2
2
|
import { Realm } from "../../Realm"
|
|
3
3
|
import { zod } from "../../zod"
|
|
4
|
+
import { Bic as AddressBic } from "./Bic"
|
|
4
5
|
import { Card as AddressCard } from "./Card"
|
|
5
6
|
import { Iban as AddressIban } from "./Iban"
|
|
6
7
|
import { Internal as AddressInternal } from "./internal"
|
|
@@ -15,13 +16,14 @@ export type Address =
|
|
|
15
16
|
| AddressInternal
|
|
16
17
|
| AddressPaxGiro
|
|
17
18
|
| AddressScan
|
|
19
|
+
| AddressBic
|
|
18
20
|
export namespace Address {
|
|
19
21
|
export const realm: Record<Realm, string[]> = {
|
|
20
|
-
test: ["paxgiro", "internal", "iban", "scan", "card", "paxgiro-credit"],
|
|
22
|
+
test: ["paxgiro", "internal", "iban", "bic", "scan", "card", "paxgiro-credit"],
|
|
21
23
|
uk: ["internal", "iban", "scan", "card"],
|
|
22
24
|
eea: ["internal", "iban", "scan", "card"],
|
|
23
25
|
}
|
|
24
|
-
export const values = ["paxgiro", "internal", "iban", "scan", "card", "paxgiro-credit"] as const
|
|
26
|
+
export const values = ["paxgiro", "internal", "iban", "bic", "scan", "card", "paxgiro-credit"] as const
|
|
25
27
|
export type Type = (typeof values)[number]
|
|
26
28
|
export function compare(addresses: [Address, Address]): boolean {
|
|
27
29
|
return Object.entries(addresses[0]).every(([key, value]) => value == (addresses[1] as any)[key])
|
|
@@ -36,44 +38,50 @@ export namespace Address {
|
|
|
36
38
|
}
|
|
37
39
|
return result
|
|
38
40
|
}
|
|
39
|
-
export function stringify(
|
|
41
|
+
export function stringify(address: Address): string {
|
|
40
42
|
let result: string
|
|
41
|
-
switch (
|
|
43
|
+
switch (address.type) {
|
|
42
44
|
case "iban":
|
|
43
|
-
result = `iban-${
|
|
45
|
+
result = `iban-${address.iban}`
|
|
44
46
|
break
|
|
45
47
|
case "paxgiro":
|
|
46
|
-
result = `pxg-${
|
|
48
|
+
result = `pxg-${address.identifier}`
|
|
47
49
|
break
|
|
48
50
|
case "internal":
|
|
49
|
-
result = `internal-${
|
|
51
|
+
result = `internal-${address.identifier}`
|
|
50
52
|
break
|
|
51
53
|
case "scan":
|
|
52
|
-
result = `scan-${
|
|
54
|
+
result = `scan-${address.sort}-${address.account}`
|
|
53
55
|
break
|
|
54
56
|
case "card":
|
|
55
|
-
result = "id" in
|
|
57
|
+
result = "id" in address ? `${address.type}-${address.id}` : `${address.type}-merchant-${address.merchant.id}`
|
|
58
|
+
break
|
|
59
|
+
case "bic":
|
|
60
|
+
result = `bic-${address.institution}-${address.account}`
|
|
56
61
|
break
|
|
57
62
|
}
|
|
58
63
|
return result
|
|
59
64
|
}
|
|
60
|
-
export function beautify(
|
|
65
|
+
export function beautify(address: Address): string {
|
|
61
66
|
let result: string
|
|
62
|
-
switch (
|
|
67
|
+
switch (address.type) {
|
|
63
68
|
case "iban":
|
|
64
|
-
result = `${
|
|
69
|
+
result = `${address.iban}`
|
|
65
70
|
break
|
|
66
71
|
case "paxgiro":
|
|
67
|
-
result = `${
|
|
72
|
+
result = `${address.identifier}`
|
|
68
73
|
break
|
|
69
74
|
case "internal":
|
|
70
|
-
result = `${
|
|
75
|
+
result = `${address.identifier}`
|
|
71
76
|
break
|
|
72
77
|
case "scan":
|
|
73
|
-
result = `${
|
|
78
|
+
result = `${address.sort} ${address.account}`
|
|
74
79
|
break
|
|
75
80
|
case "card":
|
|
76
|
-
result = "id" in
|
|
81
|
+
result = "id" in address ? `${address.type}-${address.id}` : `${address.type}-merchant-${address.merchant.id}`
|
|
82
|
+
break
|
|
83
|
+
case "bic":
|
|
84
|
+
result = `${address.institution} ${address.account}`
|
|
77
85
|
break
|
|
78
86
|
}
|
|
79
87
|
return result
|
|
@@ -84,7 +92,8 @@ export namespace Address {
|
|
|
84
92
|
AddressIban.type,
|
|
85
93
|
AddressInternal.type,
|
|
86
94
|
AddressPaxGiro.type,
|
|
87
|
-
AddressScan.type
|
|
95
|
+
AddressScan.type,
|
|
96
|
+
AddressBic.type
|
|
88
97
|
)
|
|
89
98
|
export const typeZod = zod.union([
|
|
90
99
|
AddressCard.typeZod,
|
|
@@ -93,6 +102,7 @@ export namespace Address {
|
|
|
93
102
|
AddressInternal.typeZod,
|
|
94
103
|
AddressPaxGiro.typeZod,
|
|
95
104
|
AddressScan.typeZod,
|
|
105
|
+
AddressBic.typeZod,
|
|
96
106
|
])
|
|
97
107
|
|
|
98
108
|
export import PaxGiro = AddressPaxGiro
|
|
@@ -101,4 +111,5 @@ export namespace Address {
|
|
|
101
111
|
export import Internal = AddressInternal
|
|
102
112
|
export import Card = AddressCard
|
|
103
113
|
export import Route = AddressRoute
|
|
114
|
+
export import Bic = AddressBic
|
|
104
115
|
}
|
package/Rail/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isly } from "isly"
|
|
2
|
+
import { zod } from "../zod"
|
|
2
3
|
import { Address as RailAddress } from "./Address"
|
|
3
4
|
|
|
4
5
|
export type Rail = (typeof Rail.rails)[number]
|
|
@@ -21,5 +22,6 @@ export namespace Rail {
|
|
|
21
22
|
"rix-inst",
|
|
22
23
|
] as const
|
|
23
24
|
export const type = isly.string<Rail>(rails)
|
|
25
|
+
export const typeZod = zod.enum(rails)
|
|
24
26
|
export import Address = RailAddress
|
|
25
27
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
3
|
import { Card } from "../../../Card"
|
|
4
|
+
import { zod } from "../../../zod"
|
|
4
5
|
|
|
5
6
|
export interface Charge {
|
|
6
7
|
merchant?: Charge.Merchant
|
|
@@ -18,6 +19,11 @@ export namespace Charge {
|
|
|
18
19
|
rate: isly.number(),
|
|
19
20
|
preset: isly.union(Card.Preset.type, isly.string("default")),
|
|
20
21
|
})
|
|
22
|
+
export const typeZod = zod.object({
|
|
23
|
+
amount: zod.number(),
|
|
24
|
+
rate: zod.number(),
|
|
25
|
+
preset: zod.union([Card.Preset.typeZod, zod.literal("default")]),
|
|
26
|
+
})
|
|
21
27
|
}
|
|
22
28
|
export interface Merchant {
|
|
23
29
|
amount: number
|
|
@@ -36,6 +42,13 @@ export namespace Charge {
|
|
|
36
42
|
account: isly.string(),
|
|
37
43
|
}),
|
|
38
44
|
})
|
|
45
|
+
export const typeZod = zod.object({
|
|
46
|
+
amount: zod.number(),
|
|
47
|
+
rate: zod.number(),
|
|
48
|
+
merchant: Card.Restriction.Merchant.typeZod,
|
|
49
|
+
preset: zod.union([Card.Preset.typeZod, zod.literal("default")]),
|
|
50
|
+
destination: zod.object({ account: zod.string() }),
|
|
51
|
+
})
|
|
39
52
|
}
|
|
40
53
|
export function total(currency: isoly.Currency, charges: Charge): number {
|
|
41
54
|
return isoly.Currency.add(currency, charges.fx?.amount ?? 0, charges.merchant?.amount ?? 0)
|
|
@@ -44,4 +57,8 @@ export namespace Charge {
|
|
|
44
57
|
merchant: Charge.Merchant.type.optional(),
|
|
45
58
|
fx: Charge.Fx.type.optional(),
|
|
46
59
|
})
|
|
60
|
+
export const typeZod = zod.object({
|
|
61
|
+
merchant: Charge.Merchant.typeZod.optional(),
|
|
62
|
+
fx: Charge.Fx.typeZod.optional(),
|
|
63
|
+
})
|
|
47
64
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
|
+
import { zod } from "../../zod"
|
|
3
4
|
import { Exchange } from "../Exchange"
|
|
4
5
|
import { Charge as AmountCharge } from "./Charge"
|
|
5
6
|
|
|
@@ -19,6 +20,13 @@ export namespace Amount {
|
|
|
19
20
|
total: isly.number(),
|
|
20
21
|
exchange: Exchange.type.optional(),
|
|
21
22
|
})
|
|
23
|
+
export const typeZod = zod.object({
|
|
24
|
+
original: zod.number(),
|
|
25
|
+
charge: zod.number(),
|
|
26
|
+
charges: Amount.Charge.typeZod.optional(),
|
|
27
|
+
total: zod.number(),
|
|
28
|
+
exchange: Exchange.typeZod.optional(),
|
|
29
|
+
})
|
|
22
30
|
export function change(
|
|
23
31
|
currency: isoly.Currency,
|
|
24
32
|
amount: Amount,
|
package/Transaction/Creatable.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { isly } from "isly"
|
|
|
3
3
|
import { Account } from "../Account"
|
|
4
4
|
import { Preset } from "../Card/Preset"
|
|
5
5
|
import { Rail } from "../Rail"
|
|
6
|
+
import { zod } from "../zod"
|
|
6
7
|
import { Amount } from "./Amount"
|
|
7
8
|
import { Exchange } from "./Exchange"
|
|
8
9
|
|
|
@@ -24,6 +25,14 @@ export namespace Creatable {
|
|
|
24
25
|
exchange: Exchange.type.optional(),
|
|
25
26
|
reference: isly.object<{ reference?: string }>({ reference: isly.string().optional() }).optional(),
|
|
26
27
|
})
|
|
28
|
+
export const typeZod = zod.object({
|
|
29
|
+
counterpart: Rail.Address.typeZod,
|
|
30
|
+
currency: zod.enum(isoly.Currency.values),
|
|
31
|
+
amount: zod.number(),
|
|
32
|
+
description: zod.string(),
|
|
33
|
+
exchange: Exchange.typeZod.optional(),
|
|
34
|
+
reference: zod.object({ reference: zod.string().optional() }).optional(),
|
|
35
|
+
})
|
|
27
36
|
export interface CardTransaction extends Creatable {
|
|
28
37
|
account: Pick<Rail.Address.Card, "id" | "type">
|
|
29
38
|
accountId: string
|
|
@@ -39,6 +48,13 @@ export namespace Creatable {
|
|
|
39
48
|
reference: isly.object<{ reference: string }>({ reference: isly.string() }),
|
|
40
49
|
approvalCode: isly.string().optional(),
|
|
41
50
|
})
|
|
51
|
+
export const typeZod = Creatable.typeZod.extend({
|
|
52
|
+
account: Rail.Address.Card.typeZod.pick({ id: true, type: true }),
|
|
53
|
+
accountId: zod.string(),
|
|
54
|
+
counterpart: Rail.Address.Card.Counterpart.typeZod,
|
|
55
|
+
reference: zod.object({ reference: zod.string() }),
|
|
56
|
+
approvalCode: zod.string().optional(),
|
|
57
|
+
})
|
|
42
58
|
export function charge(creatable: CardTransaction, preset: Preset, charges?: Account.Charge): Amount.Charge {
|
|
43
59
|
return Account.Charge.evaluate(
|
|
44
60
|
creatable.counterpart,
|
package/Transaction/Exchange.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isly } from "isly"
|
|
2
2
|
import { Amount } from "../Amount"
|
|
3
|
+
import { zod } from "../zod"
|
|
3
4
|
|
|
4
5
|
export interface Exchange {
|
|
5
6
|
rate: number
|
|
@@ -14,4 +15,10 @@ export namespace Exchange {
|
|
|
14
15
|
from: Amount.type.optional(),
|
|
15
16
|
quote: isly.string().optional(),
|
|
16
17
|
})
|
|
18
|
+
export const typeZod = zod.object({
|
|
19
|
+
rate: zod.number(),
|
|
20
|
+
to: Amount.typeZod.optional(),
|
|
21
|
+
from: Amount.typeZod.optional(),
|
|
22
|
+
quote: zod.string().optional(),
|
|
23
|
+
})
|
|
17
24
|
}
|
|
@@ -4,6 +4,7 @@ import { Identifier as Pax2PayIdentifier } from "../Identifier"
|
|
|
4
4
|
export type Identifier = Pax2PayIdentifier
|
|
5
5
|
export namespace Identifier {
|
|
6
6
|
export const type = Pax2PayIdentifier.type
|
|
7
|
+
export const typeZod = Pax2PayIdentifier.typeZod
|
|
7
8
|
export function generate(): string {
|
|
8
9
|
//This function will stop working 4199-11-24T01:22:57.664Z
|
|
9
10
|
//Then we need to replace "zzy" instead
|
package/Transaction/Incoming.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
3
|
import { Rail } from "../Rail"
|
|
4
|
+
import { zod } from "../zod"
|
|
4
5
|
import { Reference as TransactionReference } from "./Reference"
|
|
5
6
|
|
|
6
7
|
export interface Incoming {
|
|
@@ -24,4 +25,14 @@ export namespace Incoming {
|
|
|
24
25
|
rail: Rail.type.optional(),
|
|
25
26
|
reference: TransactionReference.type.optional(),
|
|
26
27
|
})
|
|
28
|
+
export const typeZod = zod.object({
|
|
29
|
+
account: Rail.Address.typeZod,
|
|
30
|
+
counterpart: Rail.Address.typeZod,
|
|
31
|
+
currency: zod.enum(isoly.Currency.values),
|
|
32
|
+
amount: zod.number(),
|
|
33
|
+
description: zod.string(),
|
|
34
|
+
posted: zod.string(),
|
|
35
|
+
rail: Rail.typeZod.optional(),
|
|
36
|
+
reference: TransactionReference.typeZod.optional(),
|
|
37
|
+
})
|
|
27
38
|
}
|
package/Transaction/Note.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
|
+
import { zod } from "../zod"
|
|
3
4
|
|
|
4
5
|
export interface Note extends Note.Creatable {
|
|
5
6
|
author: string
|
|
@@ -32,9 +33,19 @@ export namespace Note {
|
|
|
32
33
|
flags: isly.string().array().optional(),
|
|
33
34
|
rule: isly.any().optional(),
|
|
34
35
|
})
|
|
36
|
+
export const typeZod = zod.object({
|
|
37
|
+
text: zod.string().optional(),
|
|
38
|
+
action: zod.enum(["approve", "reject"]).optional(),
|
|
39
|
+
flags: zod.array(zod.string()).optional(),
|
|
40
|
+
rule: zod.any().optional(),
|
|
41
|
+
})
|
|
35
42
|
}
|
|
36
43
|
export const type = Creatable.type.extend<Note>({
|
|
37
44
|
author: isly.string(),
|
|
38
45
|
created: isly.string(),
|
|
39
46
|
})
|
|
47
|
+
export const typeZod = Creatable.typeZod.extend({
|
|
48
|
+
author: zod.string(),
|
|
49
|
+
created: zod.string().refine(isoly.DateTime.is),
|
|
50
|
+
})
|
|
40
51
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isly } from "isly"
|
|
2
2
|
import { Rail } from "../../Rail"
|
|
3
|
+
import { zod } from "../../zod"
|
|
3
4
|
import { Base } from "./Base"
|
|
4
5
|
|
|
5
6
|
export interface Authorization extends Base {
|
|
@@ -17,4 +18,11 @@ export namespace Authorization {
|
|
|
17
18
|
reference: isly.object<{ reference: string }>({ reference: isly.string() }),
|
|
18
19
|
approvalCode: isly.string().optional(),
|
|
19
20
|
})
|
|
21
|
+
export const typeZod = Base.typeZod.extend({
|
|
22
|
+
type: zod.literal("authorization"),
|
|
23
|
+
account: Rail.Address.Card.typeZod.pick({ id: true, type: true }),
|
|
24
|
+
counterpart: Rail.Address.Card.Counterpart.typeZod,
|
|
25
|
+
reference: zod.object({ reference: zod.string() }),
|
|
26
|
+
approvalCode: zod.string().optional(),
|
|
27
|
+
})
|
|
20
28
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isoly } from "isoly"
|
|
2
2
|
import { isly } from "isly"
|
|
3
3
|
import { Rail } from "../../Rail"
|
|
4
|
+
import { zod } from "../../zod"
|
|
4
5
|
import { Exchange } from "../Exchange"
|
|
5
6
|
|
|
6
7
|
export interface Base {
|
|
@@ -20,4 +21,12 @@ export namespace Base {
|
|
|
20
21
|
description: isly.string(),
|
|
21
22
|
exchange: Exchange.type.optional(),
|
|
22
23
|
})
|
|
24
|
+
export const typeZod = zod.object({
|
|
25
|
+
type: zod.enum(["outgoing", "incoming", "authorization"]),
|
|
26
|
+
counterpart: Rail.Address.typeZod,
|
|
27
|
+
currency: zod.enum(isoly.Currency.values),
|
|
28
|
+
amount: zod.number(),
|
|
29
|
+
description: zod.string(),
|
|
30
|
+
exchange: Exchange.typeZod.optional(),
|
|
31
|
+
})
|
|
23
32
|
}
|
|
@@ -2,6 +2,7 @@ import { isoly } from "isoly"
|
|
|
2
2
|
import { isly } from "isly"
|
|
3
3
|
import { Rail } from "../../Rail"
|
|
4
4
|
import { Settlement } from "../../Settlement"
|
|
5
|
+
import { zod } from "../../zod"
|
|
5
6
|
import { Reference as TransactionReference } from "../Reference"
|
|
6
7
|
import { Base } from "./Base"
|
|
7
8
|
|
|
@@ -26,6 +27,16 @@ export namespace Incoming {
|
|
|
26
27
|
rail: Rail.type.optional(),
|
|
27
28
|
reference: TransactionReference.type.optional(),
|
|
28
29
|
})
|
|
30
|
+
export const typeZod = Base.typeZod.extend({
|
|
31
|
+
type: zod.literal("incoming"),
|
|
32
|
+
account: Rail.Address.typeZod,
|
|
33
|
+
currency: zod.enum(isoly.Currency.values),
|
|
34
|
+
amount: zod.number(),
|
|
35
|
+
description: zod.string(),
|
|
36
|
+
posted: zod.string(),
|
|
37
|
+
rail: Rail.typeZod.optional(),
|
|
38
|
+
reference: TransactionReference.typeZod.optional(),
|
|
39
|
+
})
|
|
29
40
|
export function fromRefund(entry: Settlement.Entry.Creatable.Refund, card: Rail.Address.Card): Incoming {
|
|
30
41
|
const [currency, amount] = entry.amount
|
|
31
42
|
return {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { zod } from "../../zod"
|
|
2
|
+
import { Base } from "./Base"
|
|
2
3
|
|
|
3
4
|
export interface Outgoing extends Base {
|
|
4
5
|
type: "outgoing"
|
|
5
6
|
}
|
|
6
7
|
export namespace Outgoing {
|
|
7
|
-
export const
|
|
8
|
+
export const typeZod = Base.typeZod.extend({ type: zod.literal("outgoing") })
|
|
8
9
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Rail } from "../../Rail"
|
|
2
|
+
import { zod } from "../../zod"
|
|
2
3
|
import { Authorization as PreTransactionAuthorization } from "./Authorization"
|
|
3
4
|
import { Incoming as PreTransactionIncoming } from "./Incoming"
|
|
4
5
|
import { Outgoing as PreTransactionOutgoing } from "./Outgoing"
|
|
@@ -13,4 +14,5 @@ export namespace PreTransaction {
|
|
|
13
14
|
export import Authorization = PreTransactionAuthorization
|
|
14
15
|
export import Incoming = PreTransactionIncoming
|
|
15
16
|
export import Outgoing = PreTransactionOutgoing
|
|
17
|
+
export const typeZod = zod.union([Outgoing.typeZod, Authorization.typeZod, Incoming.typeZod])
|
|
16
18
|
}
|
package/Transaction/Reference.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isly } from "isly"
|
|
2
2
|
import { Supplier } from "../Supplier"
|
|
3
|
+
import { zod } from "../zod"
|
|
3
4
|
|
|
4
5
|
export interface Reference {
|
|
5
6
|
supplier?: Supplier
|
|
@@ -19,4 +20,12 @@ export namespace Reference {
|
|
|
19
20
|
instruction: isly.string().optional(),
|
|
20
21
|
network: isly.string().optional(),
|
|
21
22
|
})
|
|
23
|
+
export const typeZod = zod.object({
|
|
24
|
+
supplier: Supplier.typeZod.optional(),
|
|
25
|
+
reference: zod.string().optional(),
|
|
26
|
+
returnId: zod.string().optional(),
|
|
27
|
+
endToEndId: zod.string().optional(),
|
|
28
|
+
instruction: zod.string().optional(),
|
|
29
|
+
network: zod.string().optional(),
|
|
30
|
+
})
|
|
22
31
|
}
|
package/Transaction/Status.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isly } from "isly"
|
|
2
|
+
import { zod } from "../zod"
|
|
2
3
|
|
|
3
4
|
export type Status = Status.Success | [Status.Fail, Status.Reason]
|
|
4
5
|
export namespace Status {
|
|
@@ -27,4 +28,5 @@ export namespace Status {
|
|
|
27
28
|
Success,
|
|
28
29
|
isly.tuple<[Fail, Status.Reason]>(Fail, Reason)
|
|
29
30
|
)
|
|
31
|
+
export const typeZod = zod.union([zod.enum(successes), zod.tuple([zod.enum(failures), zod.enum(reasons)])])
|
|
30
32
|
}
|
package/Transaction/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { Rail } from "../Rail"
|
|
|
7
7
|
import { Report } from "../Report"
|
|
8
8
|
import type { Rule } from "../Rule"
|
|
9
9
|
import { Settlement } from "../Settlement"
|
|
10
|
+
import { zod } from "../zod"
|
|
10
11
|
import { Amount as TransactionAmount } from "./Amount"
|
|
11
12
|
import { Creatable as TransactionCreatable } from "./Creatable"
|
|
12
13
|
import { Exchange as TransactionExchange } from "./Exchange"
|
|
@@ -85,6 +86,32 @@ export namespace Transaction {
|
|
|
85
86
|
risk: isly.number().optional(),
|
|
86
87
|
state: isly.any().optional(),
|
|
87
88
|
})
|
|
89
|
+
export const typeZod = zod.object({
|
|
90
|
+
counterpart: Rail.Address.typeZod,
|
|
91
|
+
currency: zod.enum(isoly.Currency.values),
|
|
92
|
+
amount: Amount.typeZod,
|
|
93
|
+
description: zod.string(),
|
|
94
|
+
organization: zod.string(),
|
|
95
|
+
accountId: zod.string(),
|
|
96
|
+
accountName: zod.string().optional(),
|
|
97
|
+
account: Rail.Address.typeZod,
|
|
98
|
+
type: zod.enum(types).optional(),
|
|
99
|
+
direction: zod.enum(directions).optional(),
|
|
100
|
+
id: Identifier.typeZod,
|
|
101
|
+
reference: Reference.typeZod.optional(),
|
|
102
|
+
posted: zod.string().refine(isoly.DateTime.is),
|
|
103
|
+
transacted: zod.string().refine(isoly.DateTime.is).optional(),
|
|
104
|
+
by: zod.string().optional(),
|
|
105
|
+
balance: zod.object({ actual: zod.number(), available: zod.number(), reserved: zod.number() }),
|
|
106
|
+
operations: zod.array(Operation.typeZod).optional(),
|
|
107
|
+
status: Status.typeZod,
|
|
108
|
+
rail: Rail.typeZod.optional(),
|
|
109
|
+
flags: zod.array(zod.string()),
|
|
110
|
+
oldFlags: zod.array(zod.string()),
|
|
111
|
+
notes: zod.array(Note.typeZod),
|
|
112
|
+
risk: zod.number().optional(),
|
|
113
|
+
state: zod.any().optional(),
|
|
114
|
+
})
|
|
88
115
|
export function amountFromOperations(transaction: Transaction, operations: Operation[]): Amount {
|
|
89
116
|
const changes = Operation.sum(operations)
|
|
90
117
|
const reserved = isoly.Currency.add(
|
|
@@ -105,6 +132,7 @@ export namespace Transaction {
|
|
|
105
132
|
}
|
|
106
133
|
export namespace Legacy {
|
|
107
134
|
export const type = Transaction.type.omit<"amount">(["amount"]).extend<Legacy>({ amount: isly.number() })
|
|
135
|
+
export const typeZod = Transaction.typeZod.omit({ amount: true }).extend({ amount: zod.number() })
|
|
108
136
|
}
|
|
109
137
|
export function fromLegacy(transaction: Transaction | Legacy): Transaction {
|
|
110
138
|
return {
|
|
@@ -131,6 +159,7 @@ export namespace Transaction {
|
|
|
131
159
|
export type Event = Omit<Transaction, "state">
|
|
132
160
|
export namespace Event {
|
|
133
161
|
export const type = Transaction.type.omit(["state"])
|
|
162
|
+
export const typeZod = Transaction.typeZod.omit({ state: true })
|
|
134
163
|
|
|
135
164
|
export function from(transaction: Transaction): Event {
|
|
136
165
|
return (({ state, ...event }) => event)(transaction)
|
|
@@ -384,5 +413,9 @@ export namespace Transaction {
|
|
|
384
413
|
account: Rail.Address.Card.type,
|
|
385
414
|
counterpart: Rail.Address.Card.Counterpart.type,
|
|
386
415
|
})
|
|
416
|
+
export const typeZod = Transaction.typeZod.omit({ account: true, counterpart: true }).extend({
|
|
417
|
+
account: Rail.Address.Card.typeZod,
|
|
418
|
+
counterpart: Rail.Address.Card.Counterpart.typeZod,
|
|
419
|
+
})
|
|
387
420
|
}
|
|
388
421
|
}
|
|
@@ -251,6 +251,12 @@ export declare namespace Details {
|
|
|
251
251
|
account: zod.ZodString;
|
|
252
252
|
holder: zod.ZodString;
|
|
253
253
|
institution: zod.ZodOptional<zod.ZodString>;
|
|
254
|
+
}, zod.z.core.$strip>, zod.ZodObject<{
|
|
255
|
+
type: zod.ZodLiteral<"bic">;
|
|
256
|
+
account: zod.ZodString;
|
|
257
|
+
institution: zod.ZodString;
|
|
258
|
+
holder: zod.ZodString;
|
|
259
|
+
transactor: zod.ZodOptional<zod.ZodString>;
|
|
254
260
|
}, zod.z.core.$strip>]>>;
|
|
255
261
|
}, zod.z.core.$strip>;
|
|
256
262
|
interface Creatable {
|
|
@@ -284,6 +284,12 @@ export declare namespace Account {
|
|
|
284
284
|
account: zod.ZodString;
|
|
285
285
|
holder: zod.ZodString;
|
|
286
286
|
institution: zod.ZodOptional<zod.ZodString>;
|
|
287
|
+
}, zod.z.core.$strip>, zod.ZodObject<{
|
|
288
|
+
type: zod.ZodLiteral<"bic">;
|
|
289
|
+
account: zod.ZodString;
|
|
290
|
+
institution: zod.ZodString;
|
|
291
|
+
holder: zod.ZodString;
|
|
292
|
+
transactor: zod.ZodOptional<zod.ZodString>;
|
|
287
293
|
}, zod.z.core.$strip>]>>;
|
|
288
294
|
details: zod.ZodOptional<zod.ZodObject<{
|
|
289
295
|
supplier: zod.ZodEnum<{
|
|
@@ -526,6 +532,12 @@ export declare namespace Account {
|
|
|
526
532
|
account: zod.ZodString;
|
|
527
533
|
holder: zod.ZodString;
|
|
528
534
|
institution: zod.ZodOptional<zod.ZodString>;
|
|
535
|
+
}, zod.z.core.$strip>, zod.ZodObject<{
|
|
536
|
+
type: zod.ZodLiteral<"bic">;
|
|
537
|
+
account: zod.ZodString;
|
|
538
|
+
institution: zod.ZodString;
|
|
539
|
+
holder: zod.ZodString;
|
|
540
|
+
transactor: zod.ZodOptional<zod.ZodString>;
|
|
529
541
|
}, zod.z.core.$strip>]>>;
|
|
530
542
|
}, zod.z.core.$strip>>;
|
|
531
543
|
charges: zod.ZodOptional<zod.ZodObject<{
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { zod } from "../../zod";
|
|
2
|
+
export interface Bic {
|
|
3
|
+
type: "bic";
|
|
4
|
+
account: string;
|
|
5
|
+
institution: string;
|
|
6
|
+
holder: string;
|
|
7
|
+
transactor?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace Bic {
|
|
10
|
+
const currencies: readonly ["USD"];
|
|
11
|
+
const type: import("isly/dist/cjs/object").IslyObject<Bic, object>;
|
|
12
|
+
const typeZod: zod.ZodObject<{
|
|
13
|
+
type: zod.ZodLiteral<"bic">;
|
|
14
|
+
account: zod.ZodString;
|
|
15
|
+
institution: zod.ZodString;
|
|
16
|
+
holder: zod.ZodString;
|
|
17
|
+
transactor: zod.ZodOptional<zod.ZodString>;
|
|
18
|
+
}, zod.z.core.$strip>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Bic = void 0;
|
|
4
|
+
const isly_1 = require("isly");
|
|
5
|
+
const zod_1 = require("../../zod");
|
|
6
|
+
var Bic;
|
|
7
|
+
(function (Bic) {
|
|
8
|
+
Bic.currencies = ["USD"];
|
|
9
|
+
Bic.type = isly_1.isly.object({
|
|
10
|
+
type: isly_1.isly.string("bic"),
|
|
11
|
+
account: isly_1.isly.string(),
|
|
12
|
+
institution: isly_1.isly.string(),
|
|
13
|
+
holder: isly_1.isly.string(),
|
|
14
|
+
transactor: isly_1.isly.string().optional(),
|
|
15
|
+
});
|
|
16
|
+
Bic.typeZod = zod_1.zod.object({
|
|
17
|
+
type: zod_1.zod.literal("bic"),
|
|
18
|
+
account: zod_1.zod.string(),
|
|
19
|
+
institution: zod_1.zod.string(),
|
|
20
|
+
holder: zod_1.zod.string(),
|
|
21
|
+
transactor: zod_1.zod.string().optional(),
|
|
22
|
+
});
|
|
23
|
+
})(Bic || (exports.Bic = Bic = {}));
|
|
24
|
+
//# sourceMappingURL=Bic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bic.js","sourceRoot":"","sources":["../../../../Rail/Address/Bic.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAC3B,mCAA+B;AAS/B,IAAiB,GAAG,CAgBnB;AAhBD,WAAiB,GAAG;IACN,cAAU,GAAG,CAAC,KAAK,CAAU,CAAA;IAC7B,QAAI,GAAG,WAAI,CAAC,MAAM,CAAM;QACpC,IAAI,EAAE,WAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QACxB,OAAO,EAAE,WAAI,CAAC,MAAM,EAAE;QACtB,WAAW,EAAE,WAAI,CAAC,MAAM,EAAE;QAC1B,MAAM,EAAE,WAAI,CAAC,MAAM,EAAE;QACrB,UAAU,EAAE,WAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACpC,CAAC,CAAA;IACW,WAAO,GAAG,SAAG,CAAC,MAAM,CAAC;QACjC,IAAI,EAAE,SAAG,CAAC,OAAO,CAAC,KAAK,CAAC;QACxB,OAAO,EAAE,SAAG,CAAC,MAAM,EAAE;QACrB,WAAW,EAAE,SAAG,CAAC,MAAM,EAAE;QACzB,MAAM,EAAE,SAAG,CAAC,MAAM,EAAE;QACpB,UAAU,EAAE,SAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACnC,CAAC,CAAA;AACH,CAAC,EAhBgB,GAAG,mBAAH,GAAG,QAgBnB"}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { isly } from "isly";
|
|
2
2
|
import { Realm } from "../../Realm";
|
|
3
3
|
import { zod } from "../../zod";
|
|
4
|
+
import { Bic as AddressBic } from "./Bic";
|
|
4
5
|
import { Card as AddressCard } from "./Card";
|
|
5
6
|
import { Iban as AddressIban } from "./Iban";
|
|
6
7
|
import { Internal as AddressInternal } from "./internal";
|
|
7
8
|
import { PaxGiro as AddressPaxGiro } from "./PaxGiro";
|
|
8
9
|
import { Route as AddressRoute } from "./Route";
|
|
9
10
|
import { Scan as AddressScan } from "./Scan";
|
|
10
|
-
export type Address = AddressCard | AddressCard.Counterpart | AddressIban | AddressInternal | AddressPaxGiro | AddressScan;
|
|
11
|
+
export type Address = AddressCard | AddressCard.Counterpart | AddressIban | AddressInternal | AddressPaxGiro | AddressScan | AddressBic;
|
|
11
12
|
export declare namespace Address {
|
|
12
13
|
const realm: Record<Realm, string[]>;
|
|
13
|
-
const values: readonly ["paxgiro", "internal", "iban", "scan", "card", "paxgiro-credit"];
|
|
14
|
+
const values: readonly ["paxgiro", "internal", "iban", "bic", "scan", "card", "paxgiro-credit"];
|
|
14
15
|
type Type = (typeof values)[number];
|
|
15
16
|
function compare(addresses: [Address, Address]): boolean;
|
|
16
17
|
function parse(value: string): Address | undefined;
|
|
17
|
-
function stringify(
|
|
18
|
-
function beautify(
|
|
18
|
+
function stringify(address: Address): string;
|
|
19
|
+
function beautify(address: Address): string;
|
|
19
20
|
const type: isly.Type<Address>;
|
|
20
21
|
const typeZod: zod.ZodUnion<readonly [zod.ZodObject<{
|
|
21
22
|
type: zod.ZodLiteral<"card">;
|
|
@@ -70,6 +71,12 @@ export declare namespace Address {
|
|
|
70
71
|
account: zod.ZodString;
|
|
71
72
|
holder: zod.ZodString;
|
|
72
73
|
institution: zod.ZodOptional<zod.ZodString>;
|
|
74
|
+
}, zod.z.core.$strip>, zod.ZodObject<{
|
|
75
|
+
type: zod.ZodLiteral<"bic">;
|
|
76
|
+
account: zod.ZodString;
|
|
77
|
+
institution: zod.ZodString;
|
|
78
|
+
holder: zod.ZodString;
|
|
79
|
+
transactor: zod.ZodOptional<zod.ZodString>;
|
|
73
80
|
}, zod.z.core.$strip>]>;
|
|
74
81
|
export import PaxGiro = AddressPaxGiro;
|
|
75
82
|
export import Iban = AddressIban;
|
|
@@ -77,4 +84,5 @@ export declare namespace Address {
|
|
|
77
84
|
export import Internal = AddressInternal;
|
|
78
85
|
export import Card = AddressCard;
|
|
79
86
|
export import Route = AddressRoute;
|
|
87
|
+
export import Bic = AddressBic;
|
|
80
88
|
}
|