-
Notifications
You must be signed in to change notification settings - Fork 4
/
tigerbeetle.ts
126 lines (113 loc) · 2.89 KB
/
tigerbeetle.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
export interface TigerBeetle {
GetID: () => Promise<GetIDResponse>
CreateAccounts: (req: CreateAccountsRequest) => Promise<CreateAccountsResponse>
CreateTransfers: (req: CreateTransfersRequest) => Promise<CreateTransfersResponse>
LookupAccounts: (req: LookupAccountsRequest) => Promise<LookupAccountsResponse>
LookupTransfers: (req: LookupTransfersRequest) => Promise<LookupTransfersResponse>
GetAccountTransfers: (req: GetAccountTransfersRequest) => Promise<GetAccountTransfersResponse>
GetAccountBalances: (req: GetAccountBalancesRequest) => Promise<GetAccountBalancesResponse>
}
type int64 = number
type int32 = number
type bool = boolean
export interface GetIDResponse {
id: string;
}
export interface CreateAccountsRequest {
accounts: Account[];
}
export interface CreateAccountsResponse {
results: string[];
}
export interface CreateTransfersRequest {
transfers: Transfer[];
}
export interface CreateTransfersResponse {
results: string[];
}
export interface LookupAccountsRequest {
account_ids: string[];
}
export interface LookupAccountsResponse {
accounts: Account[];
}
export interface LookupTransfersRequest {
transfer_ids: string[];
}
export interface LookupTransfersResponse {
transfers: Transfer[];
}
export interface GetAccountTransfersRequest {
filter: AccountFilter;
}
export interface GetAccountTransfersResponse {
transfers: Transfer[];
}
export interface GetAccountBalancesRequest {
filter: AccountFilter;
}
export interface GetAccountBalancesResponse {
account_balances: AccountBalance[];
}
// Types
// ----------------------------------------------------------------
export interface Account extends UserData {
id: string;
debits_pending: int64;
debits_posted: int64;
credits_pending: int64;
credits_posted: int64;
ledger: int64;
code: int32;
flags?: AccountFlags;
timestamp?: string;
}
export interface AccountFlags {
linked?: bool;
debits_must_not_exceed_credits?: bool;
credits_must_not_exceed_debits?: bool;
history?: bool;
}
export interface Transfer extends UserData {
id: string;
debit_account_id: string;
credit_account_id: string;
amount: int64;
pending_id?: string;
ledger: int64;
code: int32;
transfer_flags?: TransferFlags;
timestamp?: string;
}
export interface TransferFlags {
linked?: bool;
pending?: bool;
post_pending_transfer?: bool;
void_pending_transfer?: bool;
balancing_debit?: bool;
balancing_credit?: bool;
}
export interface AccountFilter {
account_id: string;
timestamp_min?: string;
timestamp_max?: string;
limit: int32;
flags?: AccountFilterFlags;
}
export interface AccountFilterFlags {
debits?: bool;
credits?: bool;
reserved?: bool;
}
export interface AccountBalance {
debits_pending: int64;
debits_posted: int64;
credits_pending: int64;
credits_posted: int64;
timestamp: string;
}
interface UserData {
user_data128?: string;
user_data64?: int64;
user_data32?: int32;
}